@hashicorp/design-system-components 0.12.6 → 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.
- package/CHANGELOG.md +6 -0
- package/addon/components/hds/form/checkbox/base.hbs +1 -0
- package/addon/components/hds/form/checkbox/base.js +19 -0
- package/addon/components/hds/form/checkbox/field.hbs +19 -0
- package/addon/components/hds/form/checkbox/group.hbs +9 -0
- package/addon/components/hds/form/error/index.hbs +6 -0
- package/addon/components/hds/form/error/index.js +56 -0
- package/addon/components/hds/form/error/message.hbs +3 -0
- package/addon/components/hds/form/field/index.hbs +21 -0
- package/addon/components/hds/form/field/index.js +66 -0
- package/addon/components/hds/form/fieldset/index.hbs +23 -0
- package/addon/components/hds/form/fieldset/index.js +49 -0
- package/addon/components/hds/form/helper-text/index.hbs +3 -0
- package/addon/components/hds/form/helper-text/index.js +56 -0
- package/addon/components/hds/form/label/index.hbs +3 -0
- package/addon/components/hds/form/label/index.js +24 -0
- package/addon/components/hds/form/legend/index.hbs +3 -0
- package/addon/components/hds/form/legend/index.js +24 -0
- package/addon/components/hds/form/radio/base.hbs +1 -0
- package/addon/components/hds/form/radio/base.js +19 -0
- package/addon/components/hds/form/radio/field.hbs +19 -0
- package/addon/components/hds/form/radio/group.hbs +7 -0
- package/addon/components/hds/form/select/base.hbs +3 -0
- package/addon/components/hds/form/select/base.js +22 -0
- package/addon/components/hds/form/select/field.hbs +18 -0
- package/addon/components/hds/form/text-input/base.hbs +1 -0
- package/addon/components/hds/form/text-input/base.js +56 -0
- package/addon/components/hds/form/text-input/field.hbs +16 -0
- package/addon/components/hds/form/textarea/base.hbs +2 -0
- package/addon/components/hds/form/textarea/base.js +22 -0
- package/addon/components/hds/form/textarea/field.hbs +15 -0
- package/addon/components/hds/form/toggle/base.hbs +4 -0
- package/addon/components/hds/form/toggle/base.js +27 -0
- package/addon/components/hds/form/toggle/field.hbs +20 -0
- package/addon/components/hds/form/utils/getAriaDescribedBy.js +21 -0
- package/addon/components/hds/form/utils/getElementId.js +14 -0
- package/app/components/hds/form/checkbox/base.js +1 -0
- package/app/components/hds/form/checkbox/field.js +1 -0
- package/app/components/hds/form/checkbox/group.js +1 -0
- package/app/components/hds/form/error/index.js +1 -0
- package/app/components/hds/form/error/message.js +1 -0
- package/app/components/hds/form/field/index.js +1 -0
- package/app/components/hds/form/fieldset/index.js +1 -0
- package/app/components/hds/form/helper-text/index.js +1 -0
- package/app/components/hds/form/label/index.js +1 -0
- package/app/components/hds/form/legend/index.js +1 -0
- package/app/components/hds/form/radio/base.js +1 -0
- package/app/components/hds/form/radio/field.js +1 -0
- package/app/components/hds/form/radio/group.js +1 -0
- package/app/components/hds/form/select/base.js +1 -0
- package/app/components/hds/form/select/field.js +1 -0
- package/app/components/hds/form/text-input/base.js +1 -0
- package/app/components/hds/form/text-input/field.js +1 -0
- package/app/components/hds/form/textarea/base.js +1 -0
- package/app/components/hds/form/textarea/field.js +1 -0
- package/app/components/hds/form/toggle/base.js +1 -0
- package/app/components/hds/form/toggle/field.js +1 -0
- package/app/styles/@hashicorp/design-system-components.scss +1 -0
- package/app/styles/components/badge.scss +1 -0
- package/app/styles/components/form/checkbox.scss +113 -0
- package/app/styles/components/form/error.scss +27 -0
- package/app/styles/components/form/field.scss +90 -0
- package/app/styles/components/form/group.scss +52 -0
- package/app/styles/components/form/helper-text.scss +10 -0
- package/app/styles/components/form/index.scss +18 -0
- package/app/styles/components/form/label.scss +12 -0
- package/app/styles/components/form/legend.scss +10 -0
- package/app/styles/components/form/radio.scss +115 -0
- package/app/styles/components/form/select.scss +55 -0
- package/app/styles/components/form/text-input.scss +136 -0
- package/app/styles/components/form/textarea.scss +71 -0
- package/app/styles/components/form/toggle.scss +185 -0
- package/blueprints/hds-component-test/files/tests/dummy/app/templates/components/__name__.hbs +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 0.12.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -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,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,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,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,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,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,22 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
|
|
3
|
+
export default class HdsFormTextareaBaseComponent 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-textarea'];
|
|
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-textarea--is-invalid`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return classes.join(' ');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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::Textarea::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
|
+
/>
|
|
14
|
+
</F.Control>
|
|
15
|
+
</Hds::Form::Field>
|