diff --git a/addons/rose/addon/components/rose/form.stories.mdx b/addons/rose/addon/components/rose/form.stories.mdx index 73cb9ccc4..c777f21c1 100644 --- a/addons/rose/addon/components/rose/form.stories.mdx +++ b/addons/rose/addon/components/rose/form.stories.mdx @@ -30,12 +30,14 @@ and actions. @label="Label" @helperText="Helper text" @onChange={{fn this.actionHandler}} - as |select| + as |Field| > - Choose an option - Value 1 - Value 2 - Value 3 + + Choose an option + Value 1 + Value 2 + Value 3 + - Choose an option - Value 1 - Value 2 - Value 3 + + Choose an option + Value 1 + Value 2 + Value 3 + ` element context component which yields option components. - * - * @example - * - * Choose an option - * Curret value - * */ export default Component.extend({ layout, diff --git a/addons/rose/addon/components/rose/form/select.stories.mdx b/addons/rose/addon/components/rose/form/select.stories.mdx index 2e9259267..9c621ed0c 100644 --- a/addons/rose/addon/components/rose/form/select.stories.mdx +++ b/addons/rose/addon/components/rose/form/select.stories.mdx @@ -12,17 +12,20 @@ Renders a form select element. ```htmlbars - Choose a color - Red - Green - Blue + + Choose a color + Red + Green + Blue + ``` @@ -31,18 +34,21 @@ Renders a form select element. template: hbs` - Choose an option - Value 1 - Value 2 - Value 3 + + Choose an option + Value 1 + Value 2 + Value 3 + `, context: { @@ -56,7 +62,8 @@ Renders a form select element. }, null ), - id: text('id', 'field-id'), + id: text('id', 'select-id'), + name: text('name', 'select-name'), label: text('label', 'Label'), helperText: text('helperText', 'Helper text'), disabled: boolean('disabled', false), diff --git a/addons/rose/addon/components/rose/form/select/select.js b/addons/rose/addon/components/rose/form/select/select.js new file mode 100644 index 000000000..7e55d8c55 --- /dev/null +++ b/addons/rose/addon/components/rose/form/select/select.js @@ -0,0 +1,11 @@ +import Component from '@ember/component'; +import layout from '../../../../templates/components/rose/form/select/select'; + +/** + * This component is used internally by rose/form/select and should not be + * instantiated directly. + */ +export default Component.extend({ + layout, + tagName: '', +}); diff --git a/addons/rose/addon/templates/components/rose/form/select.hbs b/addons/rose/addon/templates/components/rose/form/select.hbs index 586e002a1..028dff588 100644 --- a/addons/rose/addon/templates/components/rose/form/select.hbs +++ b/addons/rose/addon/templates/components/rose/form/select.hbs @@ -8,16 +8,12 @@ {{@helperText}} {{/if}} - - {{yield xs}} - + {{yield (component 'rose/form/select/select' + id=@id + name=@name + disabled=@disabled + value=@value + onChange=@onChange + )}} diff --git a/addons/rose/addon/templates/components/rose/form/select/select.hbs b/addons/rose/addon/templates/components/rose/form/select/select.hbs new file mode 100644 index 000000000..b7eaf6a6e --- /dev/null +++ b/addons/rose/addon/templates/components/rose/form/select/select.hbs @@ -0,0 +1,11 @@ + + {{yield xs}} + diff --git a/addons/rose/app/components/rose/form/select/select.js b/addons/rose/app/components/rose/form/select/select.js new file mode 100644 index 000000000..ccdac225a --- /dev/null +++ b/addons/rose/app/components/rose/form/select/select.js @@ -0,0 +1 @@ +export { default } from 'rose/components/rose/form/select/select'; \ No newline at end of file diff --git a/addons/rose/tests/dummy/app/templates/index.hbs b/addons/rose/tests/dummy/app/templates/index.hbs index 9d69a47a1..466b5fc42 100644 --- a/addons/rose/tests/dummy/app/templates/index.hbs +++ b/addons/rose/tests/dummy/app/templates/index.hbs @@ -107,21 +107,25 @@ Dummy app index template @label="Label" @helperText="Helper text" @onChange={{fn this.actionHandler}} - as |select| + as |Field| > - Choose an option - Value 1 - Value 2 - Value 3 + + Choose an option + Value 1 + Value 2 + Value 3 + - Choose an option + + Choose an option + diff --git a/addons/rose/tests/integration/components/rose/form-test.js b/addons/rose/tests/integration/components/rose/form-test.js index 2578e5538..13ed7668f 100644 --- a/addons/rose/tests/integration/components/rose/form-test.js +++ b/addons/rose/tests/integration/components/rose/form-test.js @@ -41,7 +41,14 @@ module('Integration | Component | rose/form', function (hooks) { > - + + + - Choose an option - Value 1 - Value 2 - Value 3 + + Choose an option + Value 1 + Value 2 + Value 3 + `); assert.equal(find('label').textContent.trim(), 'Label'); @@ -32,9 +34,11 @@ module('Integration | Component | rose/form/select', function (hooks) { @label="Label" @helperText="Helper text" @onChange={{fn this.onChange}} - as |select| + as |Field| > - Choose an option + + Choose an option + `); assert.equal( @@ -49,9 +53,11 @@ module('Integration | Component | rose/form/select', function (hooks) { - Choose an option + + Choose an option + `); assert.ok(find('[disabled]')); @@ -64,10 +70,12 @@ module('Integration | Component | rose/form/select', function (hooks) { - value-1 - value-2 + + value-1 + value-2 + `); assert.equal(find('select').value, 'value-1'); @@ -91,12 +99,14 @@ module('Integration | Component | rose/form/select', function (hooks) { this.onChange = this.onChange1; await render(hbs` - Choose an option - value-1 + + Choose an option + value-1 + `); await fillIn('[name="my-select"]', 'value-1');