@hashicorp/design-system-components 0.12.4 → 0.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/addon/components/hds/disclosure/index.hbs +1 -1
  3. package/addon/components/hds/disclosure/index.js +3 -3
  4. package/addon/components/hds/dropdown/index.hbs +2 -1
  5. package/addon/components/hds/form/checkbox/base.hbs +1 -0
  6. package/addon/components/hds/form/checkbox/base.js +19 -0
  7. package/addon/components/hds/form/checkbox/field.hbs +19 -0
  8. package/addon/components/hds/form/checkbox/group.hbs +9 -0
  9. package/addon/components/hds/form/error/index.hbs +6 -0
  10. package/addon/components/hds/form/error/index.js +56 -0
  11. package/addon/components/hds/form/error/message.hbs +3 -0
  12. package/addon/components/hds/form/field/index.hbs +21 -0
  13. package/addon/components/hds/form/field/index.js +66 -0
  14. package/addon/components/hds/form/fieldset/index.hbs +23 -0
  15. package/addon/components/hds/form/fieldset/index.js +49 -0
  16. package/addon/components/hds/form/helper-text/index.hbs +3 -0
  17. package/addon/components/hds/form/helper-text/index.js +56 -0
  18. package/addon/components/hds/form/label/index.hbs +3 -0
  19. package/addon/components/hds/form/label/index.js +24 -0
  20. package/addon/components/hds/form/legend/index.hbs +3 -0
  21. package/addon/components/hds/form/legend/index.js +24 -0
  22. package/addon/components/hds/form/radio/base.hbs +1 -0
  23. package/addon/components/hds/form/radio/base.js +19 -0
  24. package/addon/components/hds/form/radio/field.hbs +19 -0
  25. package/addon/components/hds/form/radio/group.hbs +7 -0
  26. package/addon/components/hds/form/select/base.hbs +3 -0
  27. package/addon/components/hds/form/select/base.js +22 -0
  28. package/addon/components/hds/form/select/field.hbs +18 -0
  29. package/addon/components/hds/form/text-input/base.hbs +1 -0
  30. package/addon/components/hds/form/text-input/base.js +56 -0
  31. package/addon/components/hds/form/text-input/field.hbs +16 -0
  32. package/addon/components/hds/form/textarea/base.hbs +2 -0
  33. package/addon/components/hds/form/textarea/base.js +22 -0
  34. package/addon/components/hds/form/textarea/field.hbs +15 -0
  35. package/addon/components/hds/form/toggle/base.hbs +4 -0
  36. package/addon/components/hds/form/toggle/base.js +27 -0
  37. package/addon/components/hds/form/toggle/field.hbs +20 -0
  38. package/addon/components/hds/form/utils/getAriaDescribedBy.js +21 -0
  39. package/addon/components/hds/form/utils/getElementId.js +14 -0
  40. package/addon/components/hds/link/inline.hbs +1 -2
  41. package/addon/components/hds/link/standalone.hbs +0 -2
  42. package/addon/components/hds/yield/index.hbs +2 -3
  43. package/app/components/hds/form/checkbox/base.js +1 -0
  44. package/app/components/hds/form/checkbox/field.js +1 -0
  45. package/app/components/hds/form/checkbox/group.js +1 -0
  46. package/app/components/hds/form/error/index.js +1 -0
  47. package/app/components/hds/form/error/message.js +1 -0
  48. package/app/components/hds/form/field/index.js +1 -0
  49. package/app/components/hds/form/fieldset/index.js +1 -0
  50. package/app/components/hds/form/helper-text/index.js +1 -0
  51. package/app/components/hds/form/label/index.js +1 -0
  52. package/app/components/hds/form/legend/index.js +1 -0
  53. package/app/components/hds/form/radio/base.js +1 -0
  54. package/app/components/hds/form/radio/field.js +1 -0
  55. package/app/components/hds/form/radio/group.js +1 -0
  56. package/app/components/hds/form/select/base.js +1 -0
  57. package/app/components/hds/form/select/field.js +1 -0
  58. package/app/components/hds/form/text-input/base.js +1 -0
  59. package/app/components/hds/form/text-input/field.js +1 -0
  60. package/app/components/hds/form/textarea/base.js +1 -0
  61. package/app/components/hds/form/textarea/field.js +1 -0
  62. package/app/components/hds/form/toggle/base.js +1 -0
  63. package/app/components/hds/form/toggle/field.js +1 -0
  64. package/app/styles/@hashicorp/design-system-components.scss +1 -0
  65. package/app/styles/components/badge.scss +1 -0
  66. package/app/styles/components/form/checkbox.scss +113 -0
  67. package/app/styles/components/form/error.scss +27 -0
  68. package/app/styles/components/form/field.scss +90 -0
  69. package/app/styles/components/form/group.scss +52 -0
  70. package/app/styles/components/form/helper-text.scss +10 -0
  71. package/app/styles/components/form/index.scss +18 -0
  72. package/app/styles/components/form/label.scss +12 -0
  73. package/app/styles/components/form/legend.scss +10 -0
  74. package/app/styles/components/form/radio.scss +115 -0
  75. package/app/styles/components/form/select.scss +55 -0
  76. package/app/styles/components/form/text-input.scss +136 -0
  77. package/app/styles/components/form/textarea.scss +71 -0
  78. package/app/styles/components/form/toggle.scss +185 -0
  79. package/blueprints/hds-component-test/files/tests/dummy/app/templates/components/__name__.hbs +3 -3
  80. package/package.json +3 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @hashicorp/design-system-components
2
2
 
3
+ ## 0.12.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#406](https://github.com/hashicorp/design-system/pull/406) [`3c3f49b9`](https://github.com/hashicorp/design-system/commit/3c3f49b950fe7c0c9fa9732d9a8534d3b73e69fd) Thanks [@alex-ju](https://github.com/alex-ju)! - Fix badge vertical alignment
8
+
9
+ ## 0.12.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#399](https://github.com/hashicorp/design-system/pull/399) [`62e3077e`](https://github.com/hashicorp/design-system/commit/62e3077e5cf40e93852e9fa3489d3d1970d45070) Thanks [@alex-ju](https://github.com/alex-ju)! - Enable programmatic close on dropdown component
14
+
15
+ ## 0.12.5
16
+
17
+ ### Patch Changes
18
+
19
+ - [#391](https://github.com/hashicorp/design-system/pull/391) [`0d8515f0`](https://github.com/hashicorp/design-system/commit/0d8515f06ae15b9955a15e9cafa97dc1d4c87cee) Thanks [@didoo](https://github.com/didoo)! - Fixed bug in `Link::Standalone` and `Link::Inline` components that added `target="_blank"` and `rel="noopener noreferrer”` attributes in any case/condition.
20
+
21
+ * [#354](https://github.com/hashicorp/design-system/pull/354) [`e7997ee6`](https://github.com/hashicorp/design-system/commit/e7997ee68d7d8b104243c8b6129db1030a3cea57) Thanks [@didoo](https://github.com/didoo)! - small update to the `yield` helper component - this is used in `Alert` and `Toast` but the changes should have no impact
22
+
3
23
  ## 0.12.4
4
24
 
5
25
  ### Patch Changes
@@ -11,7 +11,7 @@
11
11
  </div>
12
12
  {{#if this.isOpen}}
13
13
  <div class="hds-disclosure__content" tabindex="-1">
14
- {{yield to="content"}}
14
+ {{yield (hash close=this.close) to="content"}}
15
15
  </div>
16
16
  {{/if}}
17
17
  </div>
@@ -29,20 +29,20 @@ export default class HdsDisclosureComponent extends Component {
29
29
  !event.relatedTarget || // click or tap a non-related target (e.g. outside the element)
30
30
  !this.element.contains(event.relatedTarget) // move focus to a target outside the element
31
31
  ) {
32
- this.deactivate();
32
+ this.close();
33
33
  }
34
34
  }
35
35
 
36
36
  @action
37
37
  onKeyUp(event) {
38
38
  if (event.key === 'Escape') {
39
- this.deactivate();
39
+ this.close();
40
40
  this.toggleRef.focus();
41
41
  }
42
42
  }
43
43
 
44
44
  @action
45
- deactivate() {
45
+ close() {
46
46
  if (this.isOpen) {
47
47
  this.isOpen = false;
48
48
  }
@@ -7,10 +7,11 @@
7
7
  )
8
8
  }}
9
9
  </:toggle>
10
- <:content>
10
+ <:content as |c|>
11
11
  <ul class={{this.listClassNames}} {{style width=@width}}>
12
12
  {{yield
13
13
  (hash
14
+ close=c.close
14
15
  CopyItem=(component "hds/dropdown/list-item/copy-item")
15
16
  Description=(component "hds/dropdown/list-item/description")
16
17
  Generic=(component "hds/dropdown/list-item/generic")
@@ -0,0 +1 @@
1
+ <input type="checkbox" class={{this.classNames}} ...attributes value={{@value}} />
@@ -0,0 +1,19 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ export default class HdsFormCheckboxBaseComponent extends Component {
4
+ /**
5
+ * Get the class names to apply to the component.
6
+ * @method classNames
7
+ * @return {string} The "class" attribute to apply to the component.
8
+ */
9
+ get classNames() {
10
+ let classes = ['hds-form-checkbox'];
11
+
12
+ // add a class based on the @isInvalid argument
13
+ if (this.args.isInvalid) {
14
+ classes.push(`hds-form-checkbox--is-invalid`);
15
+ }
16
+
17
+ return classes.join(' ');
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ <Hds::Form::Field
2
+ @layout="flag"
3
+ @contextualClass={{@contextualClass}}
4
+ @extraAriaDescribedBy={{@extraAriaDescribedBy}}
5
+ as |F|
6
+ >
7
+ {{! Notice: the order of the elements is not relevant here, because it's controlled at "Hds::Form::Field" component level }}
8
+ {{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
9
+ <F.Control>
10
+ <Hds::Form::Checkbox::Base
11
+ class="hds-form-field__control"
12
+ @value={{@value}}
13
+ @isInvalid={{@isInvalid}}
14
+ ...attributes
15
+ id={{F.id}}
16
+ aria-describedby={{F.ariaDescribedBy}}
17
+ />
18
+ </F.Control>
19
+ </Hds::Form::Field>
@@ -0,0 +1,9 @@
1
+ <Hds::Form::Fieldset @layout={{@layout}} ...attributes as |F|>
2
+ {{! Notice: the order of the elements is not relevant here, because it's controlled at "Hds::Form::Fieldset" component level }}
3
+ {{yield (hash Legend=F.Legend HelperText=F.HelperText Error=F.Error)}}
4
+ <F.Control>
5
+ {{yield
6
+ (hash Checkbox::Field=(component "hds/form/checkbox/field" contextualClass="hds-form-group__control-field"))
7
+ }}
8
+ </F.Control>
9
+ </Hds::Form::Fieldset>
@@ -0,0 +1,6 @@
1
+ <div class={{this.classNames}} id={{this.id}} {{did-insert this.onInsert}} ...attributes>
2
+ <FlightIcon class="hds-form-error__icon" @name="alert-diamond-fill" />
3
+ <div class="hds-form-error__content">
4
+ {{yield (hash Message=(component "hds/form/error/message"))}}
5
+ </div>
6
+ </div>
@@ -0,0 +1,56 @@
1
+ import Component from '@glimmer/component';
2
+ export const ID_PREFIX = 'error-';
3
+
4
+ const NOOP = () => {};
5
+
6
+ export default class HdsFormErrorIndexComponent extends Component {
7
+ /**
8
+ * Determines the unique ID to assign to the element
9
+ * @method id
10
+ * @return {(string|null)} The "id" attribute to apply to the element or null, if no controlId is provided
11
+ */
12
+ get id() {
13
+ let { controlId } = this.args;
14
+ if (controlId) {
15
+ return `${ID_PREFIX}${controlId}`;
16
+ }
17
+ return null;
18
+ }
19
+
20
+ /**
21
+ * @param onInsert
22
+ * @type {function}
23
+ * @default () => {}
24
+ */
25
+ get onInsert() {
26
+ let { onInsert } = this.args;
27
+
28
+ // notice: this is a guard used to prevent triggering an error when the component is used as standalone element
29
+ if (typeof onInsert === 'function') {
30
+ return onInsert;
31
+ } else {
32
+ return NOOP;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Get the class names to apply to the component.
38
+ * @method classNames
39
+ * @return {string} The "class" attribute to apply to the component.
40
+ */
41
+ get classNames() {
42
+ let classes = ['hds-form-error'];
43
+
44
+ // add typographic classes
45
+ classes.push('hds-typography-body-100', 'hds-font-weight-medium');
46
+
47
+ // add a class based on the @contextualClass argument
48
+ // notice: this will *not* be documented for public use
49
+ // the reason for this is that the contextual component declarations don't pass attributes to the component
50
+ if (this.args.contextualClass) {
51
+ classes.push(this.args.contextualClass);
52
+ }
53
+
54
+ return classes.join(' ');
55
+ }
56
+ }
@@ -0,0 +1,3 @@
1
+ <p class="hds-form-error__message" ...attributes>
2
+ {{yield}}
3
+ </p>
@@ -0,0 +1,21 @@
1
+ <div class={{this.classNames}} ...attributes>
2
+ {{yield (hash Label=(component "hds/form/label" controlId=this.id contextualClass="hds-form-field__label"))}}
3
+ {{yield
4
+ (hash
5
+ HelperText=(component
6
+ "hds/form/helper-text"
7
+ controlId=this.id
8
+ onInsert=this.appendDescriptor
9
+ contextualClass="hds-form-field__helper-text"
10
+ )
11
+ )
12
+ }}
13
+ {{yield (hash Control=(component "hds/yield") id=this.id ariaDescribedBy=this.ariaDescribedBy)}}
14
+ {{yield
15
+ (hash
16
+ Error=(component
17
+ "hds/form/error" controlId=this.id onInsert=this.appendDescriptor contextualClass="hds-form-field__error"
18
+ )
19
+ )
20
+ }}
21
+ </div>
@@ -0,0 +1,66 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { assert } from '@ember/debug';
4
+ import { action } from '@ember/object';
5
+ import { getElementId } from '../utils/getElementId';
6
+ import { getAriaDescribedBy } from '../utils/getAriaDescribedBy';
7
+
8
+ export const LAYOUT_TYPES = ['vertical', 'flag'];
9
+
10
+ export default class HdsFormFieldIndexComponent extends Component {
11
+ @tracked ariaDescribedBy = getAriaDescribedBy(this);
12
+ @tracked descriptors = [];
13
+
14
+ @action
15
+ appendDescriptor(element) {
16
+ this.descriptors.push(element.id);
17
+ this.ariaDescribedBy = getAriaDescribedBy(this);
18
+ }
19
+
20
+ /**
21
+ * Sets the layout of the field
22
+ *
23
+ * @param layout
24
+ * @type {string}
25
+ */
26
+ get layout() {
27
+ let { layout } = this.args;
28
+
29
+ assert(
30
+ `@type for "Hds::Form::Field" must be one of the following: ${LAYOUT_TYPES.join(
31
+ ', '
32
+ )}, received: ${layout}`,
33
+ LAYOUT_TYPES.includes(layout)
34
+ );
35
+
36
+ return layout;
37
+ }
38
+
39
+ /**
40
+ * Calculates the unique ID to assign to the form control
41
+ */
42
+ get id() {
43
+ return getElementId(this);
44
+ }
45
+
46
+ /**
47
+ * Get the class names to apply to the component.
48
+ * @method classNames
49
+ * @return {string} The "class" attribute to apply to the component.
50
+ */
51
+ get classNames() {
52
+ let classes = [];
53
+
54
+ if (this.args.layout) {
55
+ classes.push(`hds-form-field--layout-${this.layout}`);
56
+ }
57
+
58
+ // add a class based on the @contextualClass argument
59
+ // notice: this will *not* be documented for public use
60
+ if (this.args.contextualClass) {
61
+ classes.push(this.args.contextualClass);
62
+ }
63
+
64
+ return classes.join(' ');
65
+ }
66
+ }
@@ -0,0 +1,23 @@
1
+ <fieldset class={{this.classNames}} id={{this.id}} ...attributes aria-describedby={{this.ariaDescribedBy}}>
2
+ {{yield (hash Legend=(component "hds/form/legend" contextualClass="hds-form-group__legend"))}}
3
+ {{yield
4
+ (hash
5
+ HelperText=(component
6
+ "hds/form/helper-text"
7
+ controlId=this.id
8
+ onInsert=this.appendDescriptor
9
+ contextualClass="hds-form-group__helper-text"
10
+ )
11
+ )
12
+ }}
13
+ <div class="hds-form-group__control-fields-wrapper">
14
+ {{yield (hash Control=(component "hds/yield"))}}
15
+ </div>
16
+ {{yield
17
+ (hash
18
+ Error=(component
19
+ "hds/form/error" controlId=this.id onInsert=this.appendDescriptor contextualClass="hds-form-group__error"
20
+ )
21
+ )
22
+ }}
23
+ </fieldset>
@@ -0,0 +1,49 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { action } from '@ember/object';
4
+ import { getElementId } from '../utils/getElementId';
5
+ import { getAriaDescribedBy } from '../utils/getAriaDescribedBy';
6
+
7
+ export default class HdsFormFieldsetIndexComponent extends Component {
8
+ @tracked ariaDescribedBy = getAriaDescribedBy(this);
9
+ @tracked descriptors = [];
10
+
11
+ @action
12
+ appendDescriptor(element) {
13
+ this.descriptors.push(element.id);
14
+ this.ariaDescribedBy = getAriaDescribedBy(this);
15
+ }
16
+
17
+ /**
18
+ * Sets the layout of the group
19
+ *
20
+ * @param layout
21
+ * @type {enum}
22
+ * @default 'vertical'
23
+ */
24
+ get layout() {
25
+ return this.args.layout ?? 'vertical';
26
+ }
27
+
28
+ /**
29
+ * Calculates the unique ID to assign to the fieldset
30
+ */
31
+ get id() {
32
+ return getElementId(this);
33
+ }
34
+
35
+ /**
36
+ * Get the class names to apply to the component.
37
+ * @method classNames
38
+ * @return {string} The "class" attribute to apply to the component.
39
+ */
40
+ get classNames() {
41
+ // we just need a class for the layout
42
+ let classes = ['hds-form-group'];
43
+
44
+ // add a class based on the @layout argument
45
+ classes.push(`hds-form-group--layout-${this.layout}`);
46
+
47
+ return classes.join(' ');
48
+ }
49
+ }
@@ -0,0 +1,3 @@
1
+ <div class={{this.classNames}} id={{this.id}} {{did-insert this.onInsert}} ...attributes>
2
+ {{yield}}
3
+ </div>
@@ -0,0 +1,56 @@
1
+ import Component from '@glimmer/component';
2
+ export const ID_PREFIX = 'helper-text-';
3
+
4
+ const NOOP = () => {};
5
+
6
+ export default class HdsFormHelperTextIndexComponent extends Component {
7
+ /**
8
+ * Determines the unique ID to assign to the element
9
+ * @method id
10
+ * @return {(string|null)} The "id" attribute to apply to the element or null, if no controlId is provided
11
+ */
12
+ get id() {
13
+ let { controlId } = this.args;
14
+ if (controlId) {
15
+ return `${ID_PREFIX}${controlId}`;
16
+ }
17
+ return null;
18
+ }
19
+
20
+ /**
21
+ * @param onInsert
22
+ * @type {function}
23
+ * @default () => {}
24
+ */
25
+ get onInsert() {
26
+ let { onInsert } = this.args;
27
+
28
+ // notice: this is a guard used to prevent triggering an error when the component is used as standalone element
29
+ if (typeof onInsert === 'function') {
30
+ return onInsert;
31
+ } else {
32
+ return NOOP;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Get the class names to apply to the component.
38
+ * @method classNames
39
+ * @return {string} The "class" attribute to apply to the component.
40
+ */
41
+ get classNames() {
42
+ let classes = ['hds-form-helper-text'];
43
+
44
+ // add typographic classes
45
+ classes.push('hds-typography-body-100', 'hds-font-weight-regular');
46
+
47
+ // add a class based on the @contextualClass argument
48
+ // notice: this will *not* be documented for public use
49
+ // the reason for this is that the contextual component declarations don't pass attributes to the component
50
+ if (this.args.contextualClass) {
51
+ classes.push(this.args.contextualClass);
52
+ }
53
+
54
+ return classes.join(' ');
55
+ }
56
+ }
@@ -0,0 +1,3 @@
1
+ <label class={{this.classNames}} for={{@controlId}} ...attributes>
2
+ {{yield}}
3
+ </label>
@@ -0,0 +1,24 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ export default class HdsFormLabelIndexComponent extends Component {
4
+ /**
5
+ * Get the class names to apply to the component.
6
+ * @method classNames
7
+ * @return {string} The "class" attribute to apply to the component.
8
+ */
9
+ get classNames() {
10
+ let classes = ['hds-form-label'];
11
+
12
+ // add typographic classes
13
+ classes.push('hds-typography-body-200', 'hds-font-weight-semibold');
14
+
15
+ // add a class based on the @contextualClass argument
16
+ // notice: this will *not* be documented for public use
17
+ // the reason for this is that the contextual component declarations don't pass attributes to the component
18
+ if (this.args.contextualClass) {
19
+ classes.push(this.args.contextualClass);
20
+ }
21
+
22
+ return classes.join(' ');
23
+ }
24
+ }
@@ -0,0 +1,3 @@
1
+ <legend class={{this.classNames}} ...attributes>
2
+ {{yield}}
3
+ </legend>
@@ -0,0 +1,24 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ export default class HdsFormLegendIndexComponent extends Component {
4
+ /**
5
+ * Get the class names to apply to the component.
6
+ * @method classNames
7
+ * @return {string} The "class" attribute to apply to the component.
8
+ */
9
+ get classNames() {
10
+ let classes = ['hds-form-legend'];
11
+
12
+ // add typographic classes
13
+ classes.push('hds-typography-body-200', 'hds-font-weight-semibold');
14
+
15
+ // add a class based on the @contextualClass argument
16
+ // notice: this will *not* be documented for public use
17
+ // the reason for this is that the contextual component declarations don't pass attributes to the component
18
+ if (this.args.contextualClass) {
19
+ classes.push(this.args.contextualClass);
20
+ }
21
+
22
+ return classes.join(' ');
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ <input type="radio" class={{this.classNames}} ...attributes value={{@value}} />
@@ -0,0 +1,19 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ export default class HdsFormRadioBaseComponent extends Component {
4
+ /**
5
+ * Get the class names to apply to the component.
6
+ * @method classNames
7
+ * @return {string} The "class" attribute to apply to the component.
8
+ */
9
+ get classNames() {
10
+ let classes = ['hds-form-radio'];
11
+
12
+ // add a class based on the @isInvalid argument
13
+ if (this.args.isInvalid) {
14
+ classes.push(`hds-form-radio--is-invalid`);
15
+ }
16
+
17
+ return classes.join(' ');
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ <Hds::Form::Field
2
+ @layout="flag"
3
+ @contextualClass={{@contextualClass}}
4
+ @extraAriaDescribedBy={{@extraAriaDescribedBy}}
5
+ as |F|
6
+ >
7
+ {{! Notice: the order of the elements is not relevant here, because it's controlled at "Hds::Form::Field" component level }}
8
+ {{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
9
+ <F.Control>
10
+ <Hds::Form::Radio::Base
11
+ class="hds-form-field__control"
12
+ @value={{@value}}
13
+ @isInvalid={{@isInvalid}}
14
+ ...attributes
15
+ id={{F.id}}
16
+ aria-describedby={{F.ariaDescribedBy}}
17
+ />
18
+ </F.Control>
19
+ </Hds::Form::Field>
@@ -0,0 +1,7 @@
1
+ <Hds::Form::Fieldset @layout={{@layout}} ...attributes as |F|>
2
+ {{! Notice: the order of the elements is not relevant here, because it's controlled at "Hds::Form::Fieldset" component level }}
3
+ {{yield (hash Legend=F.Legend HelperText=F.HelperText Error=F.Error)}}
4
+ <F.Control>
5
+ {{yield (hash Radio::Field=(component "hds/form/radio/field" contextualClass="hds-form-group__control-field"))}}
6
+ </F.Control>
7
+ </Hds::Form::Fieldset>
@@ -0,0 +1,3 @@
1
+ <select class={{this.classNames}} {{style width=@width}} ...attributes>
2
+ {{yield (hash Options=(component "hds/yield"))}}
3
+ </select>
@@ -0,0 +1,22 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ export default class HdsFormSelectBaseComponent extends Component {
4
+ /**
5
+ * Get the class names to apply to the component.
6
+ * @method classNames
7
+ * @return {string} The "class" attribute to apply to the component.
8
+ */
9
+ get classNames() {
10
+ let classes = ['hds-form-select'];
11
+
12
+ // add typographic classes
13
+ classes.push('hds-typography-body-200', 'hds-font-weight-regular');
14
+
15
+ // add a class based on the @isInvalid argument
16
+ if (this.args.isInvalid) {
17
+ classes.push(`hds-form-select--is-invalid`);
18
+ }
19
+
20
+ return classes.join(' ');
21
+ }
22
+ }
@@ -0,0 +1,18 @@
1
+ <Hds::Form::Field @layout="vertical" @extraAriaDescribedBy={{@extraAriaDescribedBy}} as |F|>
2
+ {{! Notice: the order of the elements is not relevant here, because is controlled at "Hds::Form::Field" component level }}
3
+ {{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
4
+ <F.Control>
5
+ <Hds::Form::Select::Base
6
+ class="hds-form-field__control"
7
+ @value={{@value}}
8
+ @isInvalid={{@isInvalid}}
9
+ @width={{@width}}
10
+ ...attributes
11
+ id={{F.id}}
12
+ aria-describedby={{F.ariaDescribedBy}}
13
+ as |S|
14
+ >
15
+ {{yield (hash Options=S.Options)}}
16
+ </Hds::Form::Select::Base>
17
+ </F.Control>
18
+ </Hds::Form::Field>
@@ -0,0 +1 @@
1
+ <input class={{this.classNames}} {{style width=@width}} ...attributes value={{@value}} type={{this.type}} />
@@ -0,0 +1,56 @@
1
+ import Component from '@glimmer/component';
2
+ import { assert } from '@ember/debug';
3
+
4
+ // notice: we don't support all the possible HTML types, only a subset
5
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
6
+ export const DEFAULT_TYPE = 'text';
7
+ export const TYPES = [
8
+ 'text',
9
+ 'email',
10
+ 'password',
11
+ 'url',
12
+ 'search',
13
+ 'date',
14
+ 'time',
15
+ ];
16
+
17
+ export default class HdsFormTextInputBaseComponent extends Component {
18
+ /**
19
+ * Sets the type of input
20
+ *
21
+ * @param type
22
+ * @type {string}
23
+ * @default 'text'
24
+ */
25
+ get type() {
26
+ let { type = DEFAULT_TYPE } = this.args;
27
+
28
+ assert(
29
+ `@type for "Hds::Form::TextInput" must be one of the following: ${TYPES.join(
30
+ ', '
31
+ )}, received: ${type}`,
32
+ TYPES.includes(type)
33
+ );
34
+
35
+ return type;
36
+ }
37
+
38
+ /**
39
+ * Get the class names to apply to the component.
40
+ * @method classNames
41
+ * @return {string} The "class" attribute to apply to the component.
42
+ */
43
+ get classNames() {
44
+ let classes = ['hds-form-text-input'];
45
+
46
+ // add typographic classes
47
+ classes.push('hds-typography-body-200', 'hds-font-weight-regular');
48
+
49
+ // add a class based on the @isInvalid argument
50
+ if (this.args.isInvalid) {
51
+ classes.push(`hds-form-text-input--is-invalid`);
52
+ }
53
+
54
+ return classes.join(' ');
55
+ }
56
+ }
@@ -0,0 +1,16 @@
1
+ <Hds::Form::Field @layout="vertical" @extraAriaDescribedBy={{@extraAriaDescribedBy}} as |F|>
2
+ {{! Notice: the order of the elements is not relevant here, because is controlled at "Hds::Form::Field" component level }}
3
+ {{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
4
+ <F.Control>
5
+ <Hds::Form::TextInput::Base
6
+ class="hds-form-field__control"
7
+ @type={{@type}}
8
+ @value={{@value}}
9
+ @isInvalid={{@isInvalid}}
10
+ @width={{@width}}
11
+ ...attributes
12
+ id={{F.id}}
13
+ aria-describedby={{F.ariaDescribedBy}}
14
+ />
15
+ </F.Control>
16
+ </Hds::Form::Field>
@@ -0,0 +1,2 @@
1
+ {{! Notice: this is not the native HTML <textarea> but the Ember component <Textarea> }}
2
+ <Textarea class={{this.classNames}} {{style width=@width}} ...attributes @value={{@value}} />