@uh-design-system/component-library 0.4.0 → 0.4.2
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/dist/cjs/component-library.cjs.js +3 -3
- package/dist/cjs/controlUtils-041de0fd.js +7 -0
- package/dist/cjs/ds-accordion_3.cjs.entry.js +27 -20
- package/dist/cjs/ds-checkbox-group.cjs.entry.js +156 -0
- package/dist/cjs/ds-checkbox.cjs.entry.js +153 -0
- package/dist/cjs/ds-input-validity.cjs.entry.js +38 -0
- package/dist/cjs/ds-link-with-arrow.cjs.entry.js +8 -7
- package/dist/cjs/ds-link.cjs.entry.js +11 -8
- package/dist/cjs/ds-text-input.cjs.entry.js +30 -6
- package/dist/cjs/ds-visually-hidden.cjs.entry.js +2 -2
- package/dist/cjs/{index-bfa0f441.js → index-b2bddcf4.js} +326 -125
- package/dist/cjs/{linkUtils-695da37c.js → linkUtils-e911e899.js} +10 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/utils-c9113835.js +18 -0
- package/dist/collection/accessibility/accessibility.stories.js +10 -0
- package/dist/collection/accessibility/stories/ariaLabel.stories.js +19 -0
- package/dist/collection/accessibility/stories/ariaLabelledBy.stories.js +49 -0
- package/dist/collection/accessibility/stories/naming.stories.js +39 -0
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/00-foundations/icons/categories/information.js +4 -0
- package/dist/collection/components/00-foundations/typography/stories/typography.stories.js +133 -48
- package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.css +1 -1
- package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.js +6 -6
- package/dist/collection/components/01-base-components/ds-button/ds-button.css +9 -9
- package/dist/collection/components/01-base-components/ds-button/ds-button.js +2 -2
- package/dist/collection/components/01-base-components/ds-button/stories/ds-button.examples.stories.js +53 -12
- package/dist/collection/components/01-base-components/ds-button/stories/ds-button.features.stories.js +88 -55
- package/dist/collection/components/01-base-components/ds-button/stories/ds-button.stories.js +1 -1
- package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.css +144 -0
- package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.js +429 -0
- package/dist/collection/components/01-base-components/ds-checkbox/stories/ds-checkbox.features.stories.js +115 -0
- package/dist/collection/components/01-base-components/ds-checkbox/stories/ds-checkbox.stories.js +37 -0
- package/dist/collection/components/01-base-components/ds-checkbox-group/ds-checkbox-group.css +38 -0
- package/dist/collection/components/01-base-components/ds-checkbox-group/ds-checkbox-group.js +445 -0
- package/dist/collection/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.features.stories.js +89 -0
- package/dist/collection/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.stories.js +47 -0
- package/dist/collection/components/01-base-components/ds-icon/ds-icon.js +1 -1
- package/dist/collection/components/01-base-components/ds-icon/{ds-icon.stories.js → stories/ds-icon.stories.js} +12 -2
- package/dist/collection/components/01-base-components/ds-input-validity/ds-input-validity.css +31 -0
- package/dist/collection/components/01-base-components/ds-input-validity/ds-input-validity.js +114 -0
- package/dist/collection/components/01-base-components/ds-input-validity/stories/ds-input-validity.features.stories.js +17 -0
- package/dist/collection/components/01-base-components/ds-input-validity/stories/ds-input-validity.stories.js +21 -0
- package/dist/collection/components/01-base-components/ds-link/ds-link.css +19 -139
- package/dist/collection/components/01-base-components/ds-link/ds-link.js +68 -8
- package/dist/collection/components/01-base-components/ds-link/stories/ds-link.examples.stories.js +6 -2
- package/dist/collection/components/01-base-components/ds-link/stories/ds-link.features.stories.js +2 -2
- package/dist/collection/components/01-base-components/ds-link/stories/ds-link.stories.js +15 -4
- package/dist/collection/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.css +1 -139
- package/dist/collection/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.js +25 -5
- package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/{ds-arrow-link.examples.stories.js → ds-link-with-arrow.examples.stories.js} +26 -3
- package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/{ds-arrow-link.stories.js → ds-link-with-arrow.stories.js} +5 -4
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.css +8 -11
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.js +30 -5
- package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.examples.stories.js +29 -7
- package/dist/collection/components/01-base-components/ds-text-input/utils.js +0 -6
- package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.js +1 -1
- package/dist/collection/utils/controls/controlUtils.js +2 -0
- package/dist/collection/utils/link/linkUtils.js +9 -0
- package/dist/collection/utils/typography/typographyUtils.js +39 -0
- package/dist/collection/utils/utils.js +24 -6
- package/dist/component-library/component-library.css +1 -1
- package/dist/component-library/component-library.esm.js +1 -1
- package/dist/component-library/controlUtils-9ca4087b.js +1 -0
- package/dist/component-library/ds-accordion_3.entry.js +1 -1
- package/dist/component-library/ds-checkbox-group.entry.js +1 -0
- package/dist/component-library/ds-checkbox.entry.js +1 -0
- package/dist/component-library/ds-input-validity.entry.js +1 -0
- package/dist/component-library/ds-link-with-arrow.entry.js +1 -1
- package/dist/component-library/ds-link.entry.js +1 -1
- package/dist/component-library/ds-text-input.entry.js +1 -1
- package/dist/component-library/ds-visually-hidden.entry.js +1 -1
- package/dist/component-library/index-50783b0c.js +2 -0
- package/dist/component-library/{linkUtils-3d1b28cf.js → linkUtils-fe63ff72.js} +1 -1
- package/dist/component-library/utils-b5843ae1.js +1 -0
- package/dist/components/attributes.js +1 -80
- package/dist/components/controlUtils.js +4 -0
- package/dist/components/ds-accordion.js +8 -8
- package/dist/components/ds-button2.js +4 -3
- package/dist/components/ds-checkbox-group.d.ts +11 -0
- package/dist/components/ds-checkbox-group.js +206 -0
- package/dist/components/ds-checkbox.d.ts +11 -0
- package/dist/components/ds-checkbox.js +6 -0
- package/dist/components/ds-checkbox2.js +185 -0
- package/dist/components/ds-icon2.js +24 -4
- package/dist/components/ds-input-validity.d.ts +11 -0
- package/dist/components/ds-input-validity.js +6 -0
- package/dist/components/ds-input-validity2.js +59 -0
- package/dist/components/ds-link-with-arrow.js +10 -8
- package/dist/components/ds-link.js +15 -9
- package/dist/components/ds-text-input.js +30 -7
- package/dist/components/ds-visually-hidden2.js +1 -1
- package/dist/components/index2.js +298 -130
- package/dist/components/index3.js +80 -0
- package/dist/components/linkUtils.js +10 -1
- package/dist/esm/component-library.js +4 -4
- package/dist/esm/controlUtils-9ca4087b.js +4 -0
- package/dist/esm/ds-accordion_3.entry.js +25 -18
- package/dist/esm/ds-checkbox-group.entry.js +152 -0
- package/dist/esm/ds-checkbox.entry.js +149 -0
- package/dist/esm/ds-input-validity.entry.js +34 -0
- package/dist/esm/ds-link-with-arrow.entry.js +8 -7
- package/dist/esm/ds-link.entry.js +11 -8
- package/dist/esm/ds-text-input.entry.js +30 -6
- package/dist/esm/ds-visually-hidden.entry.js +2 -2
- package/dist/esm/{index-42701395.js → index-50783b0c.js} +326 -126
- package/dist/esm/{linkUtils-3d1b28cf.js → linkUtils-fe63ff72.js} +10 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/utils-b5843ae1.js +15 -0
- package/dist/types/accessibility/accessibility.stories.d.ts +3 -0
- package/dist/types/accessibility/stories/ariaLabel.stories.d.ts +5 -0
- package/dist/types/accessibility/stories/ariaLabelledBy.stories.d.ts +4 -0
- package/dist/types/accessibility/stories/naming.stories.d.ts +4 -0
- package/dist/types/components/00-foundations/typography/stories/typography.stories.d.ts +1 -0
- package/dist/types/components/01-base-components/ds-button/stories/ds-button.examples.stories.d.ts +2 -0
- package/dist/types/components/01-base-components/ds-button/stories/ds-button.features.stories.d.ts +4 -1
- package/dist/types/components/01-base-components/ds-checkbox/ds-checkbox.d.ts +49 -0
- package/dist/types/components/01-base-components/ds-checkbox/stories/ds-checkbox.features.stories.d.ts +13 -0
- package/dist/types/components/01-base-components/ds-checkbox/stories/ds-checkbox.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-checkbox-group/ds-checkbox-group.d.ts +56 -0
- package/dist/types/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.features.stories.d.ts +11 -0
- package/dist/types/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-icon/{ds-icon.stories.d.ts → stories/ds-icon.stories.d.ts} +2 -1
- package/dist/types/components/01-base-components/ds-input-validity/ds-input-validity.d.ts +12 -0
- package/dist/types/components/01-base-components/ds-input-validity/stories/ds-input-validity.features.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-input-validity/stories/ds-input-validity.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-link/ds-link.d.ts +4 -1
- package/dist/types/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.d.ts +1 -0
- package/dist/types/components/01-base-components/ds-text-input/ds-text-input.d.ts +5 -0
- package/dist/types/components/01-base-components/ds-text-input/utils.d.ts +0 -1
- package/dist/types/components.d.ts +142 -2
- package/dist/types/utils/controls/controlUtils.d.ts +2 -0
- package/dist/types/utils/link/linkUtils.d.ts +1 -0
- package/dist/types/utils/typography/typographyUtils.d.ts +5 -0
- package/dist/types/utils/utils.d.ts +10 -3
- package/package.json +19 -18
- package/dist/cjs/utils-8b73aa91.js +0 -10
- package/dist/collection/components/00-foundations/typography/typography.stories.js +0 -68
- package/dist/component-library/index-42701395.js +0 -2
- package/dist/component-library/utils-cca2a41a.js +0 -1
- package/dist/components/utils.js +0 -8
- package/dist/esm/utils-cca2a41a.js +0 -8
- package/dist/types/components/00-foundations/typography/typography.stories.d.ts +0 -7
- /package/dist/cjs/{attributes-f7831329.js → attributes-5f5b58be.js} +0 -0
- /package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/{ds-arrow-link.features.stories.js → ds-link-with-arrow.features.stories.js} +0 -0
- /package/dist/collection/utils/{attributes.js → attributes/attributes.js} +0 -0
- /package/dist/component-library/{attributes-9419ac39.js → attributes-7d09be1b.js} +0 -0
- /package/dist/esm/{attributes-9419ac39.js → attributes-7d09be1b.js} +0 -0
- /package/dist/types/components/01-base-components/ds-link-with-arrow/stories/{ds-arrow-link.examples.stories.d.ts → ds-link-with-arrow.examples.stories.d.ts} +0 -0
- /package/dist/types/components/01-base-components/ds-link-with-arrow/stories/{ds-arrow-link.features.stories.d.ts → ds-link-with-arrow.features.stories.d.ts} +0 -0
- /package/dist/types/components/01-base-components/ds-link-with-arrow/stories/{ds-arrow-link.stories.d.ts → ds-link-with-arrow.stories.d.ts} +0 -0
- /package/dist/types/utils/{attributes.d.ts → attributes/attributes.d.ts} +0 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { Fragment, h } from "@stencil/core";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { inheritAriaAttributes } from "../../../utils/attributes/attributes";
|
|
4
|
+
import { idGenerator } from "../../../utils/utils";
|
|
5
|
+
import { getOptionalText, getRequiredText } from "../../../utils/controls/controlUtils";
|
|
6
|
+
const checkboxIdGenerator = idGenerator('ds-checkbox');
|
|
7
|
+
export class DsCheckbox {
|
|
8
|
+
labelId;
|
|
9
|
+
errorTextId;
|
|
10
|
+
assistiveTextId;
|
|
11
|
+
inheritedAttributes = {};
|
|
12
|
+
initialChecked;
|
|
13
|
+
inputElem;
|
|
14
|
+
el;
|
|
15
|
+
internals;
|
|
16
|
+
dsCheckboxChange;
|
|
17
|
+
dsCheckboxError;
|
|
18
|
+
checkboxId;
|
|
19
|
+
checked = false;
|
|
20
|
+
legend;
|
|
21
|
+
assistiveText;
|
|
22
|
+
text;
|
|
23
|
+
indeterminate = false;
|
|
24
|
+
disabled = false;
|
|
25
|
+
errorText = '';
|
|
26
|
+
errorsDisabled = false;
|
|
27
|
+
required = false;
|
|
28
|
+
optional = false;
|
|
29
|
+
optionalText;
|
|
30
|
+
ariaLabel;
|
|
31
|
+
value = this.checked.toString();
|
|
32
|
+
validationMessage;
|
|
33
|
+
setIds = () => {
|
|
34
|
+
this.checkboxId = this.checkboxId || checkboxIdGenerator.next().value;
|
|
35
|
+
this.labelId = `${this.checkboxId}-label`;
|
|
36
|
+
this.errorTextId = `${this.checkboxId}-error`;
|
|
37
|
+
this.assistiveTextId = `${this.checkboxId}-assistive-text`;
|
|
38
|
+
};
|
|
39
|
+
getErrorText = () => (!this.errorsDisabled ? this.errorText || this.internals?.validationMessage || this.inputElem?.validationMessage : '');
|
|
40
|
+
getLegendText = () => {
|
|
41
|
+
if (this.required) {
|
|
42
|
+
return getRequiredText(this.legend);
|
|
43
|
+
}
|
|
44
|
+
if (this.optional) {
|
|
45
|
+
return getOptionalText(this.legend, this.optionalText);
|
|
46
|
+
}
|
|
47
|
+
return this.legend;
|
|
48
|
+
};
|
|
49
|
+
getCheckboxText = () => {
|
|
50
|
+
if (this.legend) {
|
|
51
|
+
return this.text;
|
|
52
|
+
}
|
|
53
|
+
if (this.required) {
|
|
54
|
+
return getRequiredText(this.text);
|
|
55
|
+
}
|
|
56
|
+
if (this.optional) {
|
|
57
|
+
return getOptionalText(this.text, this.optionalText);
|
|
58
|
+
}
|
|
59
|
+
return this.text;
|
|
60
|
+
};
|
|
61
|
+
getAriaDescribedBy = () => [Boolean(this.assistiveText) && this.assistiveTextId, Boolean(this.getErrorText()) && this.errorTextId].filter(Boolean).join(' ');
|
|
62
|
+
restoreInitialState = () => {
|
|
63
|
+
this.checked = this.initialChecked;
|
|
64
|
+
this.value = this.checked.toString();
|
|
65
|
+
this.internals?.setValidity({});
|
|
66
|
+
this.internals?.setFormValue(this.value);
|
|
67
|
+
};
|
|
68
|
+
setInitialState = () => {
|
|
69
|
+
this.initialChecked = this.checked;
|
|
70
|
+
this.value = this.checked.toString();
|
|
71
|
+
this.internals?.setFormValue(this.value);
|
|
72
|
+
};
|
|
73
|
+
emitCheckboxError = () => {
|
|
74
|
+
this.dsCheckboxError.emit(this.getErrorText());
|
|
75
|
+
};
|
|
76
|
+
formResetCallback() {
|
|
77
|
+
this.restoreInitialState();
|
|
78
|
+
}
|
|
79
|
+
componentWillLoad() {
|
|
80
|
+
this.setInitialState();
|
|
81
|
+
this.setIds();
|
|
82
|
+
this.inheritedAttributes = inheritAriaAttributes(this.el, ['aria-label', 'aria-describedby', 'aria-hidden']);
|
|
83
|
+
}
|
|
84
|
+
componentDidLoad() {
|
|
85
|
+
this.ariaLabel = this.el.getAttribute('aria-label');
|
|
86
|
+
this.el.removeAttribute('aria-label');
|
|
87
|
+
}
|
|
88
|
+
componentDidUpdate() {
|
|
89
|
+
this.emitCheckboxError();
|
|
90
|
+
}
|
|
91
|
+
handleChange = () => {
|
|
92
|
+
this.checked = !this.checked;
|
|
93
|
+
this.value = this.checked.toString();
|
|
94
|
+
this.internals?.setFormValue(this.value);
|
|
95
|
+
this.dsCheckboxChange.emit({ id: this.checkboxId, checked: this.checked });
|
|
96
|
+
};
|
|
97
|
+
handleKeyUp = (event) => {
|
|
98
|
+
if (event.key === 'Enter') {
|
|
99
|
+
this.handleChange();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
renderCheckbox() {
|
|
103
|
+
const classes = classNames('ds-checkbox', {
|
|
104
|
+
'ds-checkbox--disabled': this.disabled,
|
|
105
|
+
'ds-checkbox--no-margin': Boolean(!this.text),
|
|
106
|
+
});
|
|
107
|
+
const inputClasses = classNames('ds-checkbox__input', {
|
|
108
|
+
'ds-checkbox__input--invalid': Boolean(this.errorText),
|
|
109
|
+
});
|
|
110
|
+
const errorText = this.getErrorText();
|
|
111
|
+
const errorClasses = classNames('ds-checkbox-error', {
|
|
112
|
+
'ds-checkbox-error--visible': Boolean(errorText),
|
|
113
|
+
});
|
|
114
|
+
const ariaDescribedBy = this.getAriaDescribedBy();
|
|
115
|
+
return (h(Fragment, null, h("div", null, h("label", { id: this.labelId, class: classes }, h("input", { ref: inputElem => (this.inputElem = inputElem), type: "checkbox", class: inputClasses, checked: this.checked, indeterminate: this.indeterminate, onChange: this.handleChange, onKeyUp: this.handleKeyUp, value: this.value, disabled: this.disabled, required: this.required, id: this.checkboxId, "aria-describedby": ariaDescribedBy, "aria-label": this.ariaLabel, ...this.inheritedAttributes }), this.getCheckboxText())), !this.errorsDisabled && (h("div", { class: errorClasses }, h("ds-input-validity", { id: this.errorTextId, text: errorText, type: "error" })))));
|
|
116
|
+
}
|
|
117
|
+
renderFieldset() {
|
|
118
|
+
const fieldsetClasses = classNames('ds-checkbox-fieldset');
|
|
119
|
+
const legendClasses = classNames('ds-checkbox-fieldset__legend');
|
|
120
|
+
const assistiveTextClasses = classNames('ds-checkbox-fieldset__assistive-text');
|
|
121
|
+
return (h("fieldset", { class: fieldsetClasses }, h("legend", { class: legendClasses }, this.getLegendText()), this.assistiveText && (h("small", { class: assistiveTextClasses, id: this.assistiveTextId }, this.assistiveText)), this.renderCheckbox()));
|
|
122
|
+
}
|
|
123
|
+
render() {
|
|
124
|
+
if (this.legend) {
|
|
125
|
+
return this.renderFieldset();
|
|
126
|
+
}
|
|
127
|
+
return this.renderCheckbox();
|
|
128
|
+
}
|
|
129
|
+
static get is() { return "ds-checkbox"; }
|
|
130
|
+
static get encapsulation() { return "shadow"; }
|
|
131
|
+
static get formAssociated() { return true; }
|
|
132
|
+
static get originalStyleUrls() {
|
|
133
|
+
return {
|
|
134
|
+
"$": ["ds-checkbox.scss"]
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
static get styleUrls() {
|
|
138
|
+
return {
|
|
139
|
+
"$": ["ds-checkbox.css"]
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
static get properties() {
|
|
143
|
+
return {
|
|
144
|
+
"checkboxId": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"mutable": true,
|
|
147
|
+
"complexType": {
|
|
148
|
+
"original": "string",
|
|
149
|
+
"resolved": "string",
|
|
150
|
+
"references": {}
|
|
151
|
+
},
|
|
152
|
+
"required": false,
|
|
153
|
+
"optional": true,
|
|
154
|
+
"docs": {
|
|
155
|
+
"tags": [],
|
|
156
|
+
"text": ""
|
|
157
|
+
},
|
|
158
|
+
"getter": false,
|
|
159
|
+
"setter": false,
|
|
160
|
+
"attribute": "id",
|
|
161
|
+
"reflect": false
|
|
162
|
+
},
|
|
163
|
+
"checked": {
|
|
164
|
+
"type": "boolean",
|
|
165
|
+
"mutable": true,
|
|
166
|
+
"complexType": {
|
|
167
|
+
"original": "boolean",
|
|
168
|
+
"resolved": "boolean",
|
|
169
|
+
"references": {}
|
|
170
|
+
},
|
|
171
|
+
"required": false,
|
|
172
|
+
"optional": false,
|
|
173
|
+
"docs": {
|
|
174
|
+
"tags": [],
|
|
175
|
+
"text": ""
|
|
176
|
+
},
|
|
177
|
+
"getter": false,
|
|
178
|
+
"setter": false,
|
|
179
|
+
"attribute": "checked",
|
|
180
|
+
"reflect": false,
|
|
181
|
+
"defaultValue": "false"
|
|
182
|
+
},
|
|
183
|
+
"legend": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"mutable": false,
|
|
186
|
+
"complexType": {
|
|
187
|
+
"original": "string",
|
|
188
|
+
"resolved": "string",
|
|
189
|
+
"references": {}
|
|
190
|
+
},
|
|
191
|
+
"required": false,
|
|
192
|
+
"optional": true,
|
|
193
|
+
"docs": {
|
|
194
|
+
"tags": [],
|
|
195
|
+
"text": ""
|
|
196
|
+
},
|
|
197
|
+
"getter": false,
|
|
198
|
+
"setter": false,
|
|
199
|
+
"attribute": "legend",
|
|
200
|
+
"reflect": false
|
|
201
|
+
},
|
|
202
|
+
"assistiveText": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"mutable": false,
|
|
205
|
+
"complexType": {
|
|
206
|
+
"original": "string",
|
|
207
|
+
"resolved": "string",
|
|
208
|
+
"references": {}
|
|
209
|
+
},
|
|
210
|
+
"required": false,
|
|
211
|
+
"optional": true,
|
|
212
|
+
"docs": {
|
|
213
|
+
"tags": [],
|
|
214
|
+
"text": ""
|
|
215
|
+
},
|
|
216
|
+
"getter": false,
|
|
217
|
+
"setter": false,
|
|
218
|
+
"attribute": "assistive-text",
|
|
219
|
+
"reflect": false
|
|
220
|
+
},
|
|
221
|
+
"text": {
|
|
222
|
+
"type": "string",
|
|
223
|
+
"mutable": false,
|
|
224
|
+
"complexType": {
|
|
225
|
+
"original": "string",
|
|
226
|
+
"resolved": "string",
|
|
227
|
+
"references": {}
|
|
228
|
+
},
|
|
229
|
+
"required": false,
|
|
230
|
+
"optional": true,
|
|
231
|
+
"docs": {
|
|
232
|
+
"tags": [],
|
|
233
|
+
"text": ""
|
|
234
|
+
},
|
|
235
|
+
"getter": false,
|
|
236
|
+
"setter": false,
|
|
237
|
+
"attribute": "text",
|
|
238
|
+
"reflect": false
|
|
239
|
+
},
|
|
240
|
+
"indeterminate": {
|
|
241
|
+
"type": "boolean",
|
|
242
|
+
"mutable": false,
|
|
243
|
+
"complexType": {
|
|
244
|
+
"original": "boolean",
|
|
245
|
+
"resolved": "boolean",
|
|
246
|
+
"references": {}
|
|
247
|
+
},
|
|
248
|
+
"required": false,
|
|
249
|
+
"optional": false,
|
|
250
|
+
"docs": {
|
|
251
|
+
"tags": [],
|
|
252
|
+
"text": ""
|
|
253
|
+
},
|
|
254
|
+
"getter": false,
|
|
255
|
+
"setter": false,
|
|
256
|
+
"attribute": "indeterminate",
|
|
257
|
+
"reflect": false,
|
|
258
|
+
"defaultValue": "false"
|
|
259
|
+
},
|
|
260
|
+
"disabled": {
|
|
261
|
+
"type": "boolean",
|
|
262
|
+
"mutable": false,
|
|
263
|
+
"complexType": {
|
|
264
|
+
"original": "boolean",
|
|
265
|
+
"resolved": "boolean",
|
|
266
|
+
"references": {}
|
|
267
|
+
},
|
|
268
|
+
"required": false,
|
|
269
|
+
"optional": false,
|
|
270
|
+
"docs": {
|
|
271
|
+
"tags": [],
|
|
272
|
+
"text": ""
|
|
273
|
+
},
|
|
274
|
+
"getter": false,
|
|
275
|
+
"setter": false,
|
|
276
|
+
"attribute": "disabled",
|
|
277
|
+
"reflect": false,
|
|
278
|
+
"defaultValue": "false"
|
|
279
|
+
},
|
|
280
|
+
"errorText": {
|
|
281
|
+
"type": "string",
|
|
282
|
+
"mutable": false,
|
|
283
|
+
"complexType": {
|
|
284
|
+
"original": "string",
|
|
285
|
+
"resolved": "string",
|
|
286
|
+
"references": {}
|
|
287
|
+
},
|
|
288
|
+
"required": false,
|
|
289
|
+
"optional": false,
|
|
290
|
+
"docs": {
|
|
291
|
+
"tags": [],
|
|
292
|
+
"text": ""
|
|
293
|
+
},
|
|
294
|
+
"getter": false,
|
|
295
|
+
"setter": false,
|
|
296
|
+
"attribute": "error-text",
|
|
297
|
+
"reflect": false,
|
|
298
|
+
"defaultValue": "''"
|
|
299
|
+
},
|
|
300
|
+
"errorsDisabled": {
|
|
301
|
+
"type": "boolean",
|
|
302
|
+
"mutable": false,
|
|
303
|
+
"complexType": {
|
|
304
|
+
"original": "boolean",
|
|
305
|
+
"resolved": "boolean",
|
|
306
|
+
"references": {}
|
|
307
|
+
},
|
|
308
|
+
"required": false,
|
|
309
|
+
"optional": false,
|
|
310
|
+
"docs": {
|
|
311
|
+
"tags": [],
|
|
312
|
+
"text": ""
|
|
313
|
+
},
|
|
314
|
+
"getter": false,
|
|
315
|
+
"setter": false,
|
|
316
|
+
"attribute": "data-errors-disabled",
|
|
317
|
+
"reflect": false,
|
|
318
|
+
"defaultValue": "false"
|
|
319
|
+
},
|
|
320
|
+
"required": {
|
|
321
|
+
"type": "boolean",
|
|
322
|
+
"mutable": false,
|
|
323
|
+
"complexType": {
|
|
324
|
+
"original": "boolean",
|
|
325
|
+
"resolved": "boolean",
|
|
326
|
+
"references": {}
|
|
327
|
+
},
|
|
328
|
+
"required": false,
|
|
329
|
+
"optional": false,
|
|
330
|
+
"docs": {
|
|
331
|
+
"tags": [],
|
|
332
|
+
"text": ""
|
|
333
|
+
},
|
|
334
|
+
"getter": false,
|
|
335
|
+
"setter": false,
|
|
336
|
+
"attribute": "required",
|
|
337
|
+
"reflect": false,
|
|
338
|
+
"defaultValue": "false"
|
|
339
|
+
},
|
|
340
|
+
"optional": {
|
|
341
|
+
"type": "boolean",
|
|
342
|
+
"mutable": false,
|
|
343
|
+
"complexType": {
|
|
344
|
+
"original": "boolean",
|
|
345
|
+
"resolved": "boolean",
|
|
346
|
+
"references": {}
|
|
347
|
+
},
|
|
348
|
+
"required": false,
|
|
349
|
+
"optional": false,
|
|
350
|
+
"docs": {
|
|
351
|
+
"tags": [],
|
|
352
|
+
"text": ""
|
|
353
|
+
},
|
|
354
|
+
"getter": false,
|
|
355
|
+
"setter": false,
|
|
356
|
+
"attribute": "optional",
|
|
357
|
+
"reflect": false,
|
|
358
|
+
"defaultValue": "false"
|
|
359
|
+
},
|
|
360
|
+
"optionalText": {
|
|
361
|
+
"type": "string",
|
|
362
|
+
"mutable": false,
|
|
363
|
+
"complexType": {
|
|
364
|
+
"original": "string",
|
|
365
|
+
"resolved": "string",
|
|
366
|
+
"references": {}
|
|
367
|
+
},
|
|
368
|
+
"required": false,
|
|
369
|
+
"optional": true,
|
|
370
|
+
"docs": {
|
|
371
|
+
"tags": [],
|
|
372
|
+
"text": ""
|
|
373
|
+
},
|
|
374
|
+
"getter": false,
|
|
375
|
+
"setter": false,
|
|
376
|
+
"attribute": "optional-text",
|
|
377
|
+
"reflect": false
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
static get states() {
|
|
382
|
+
return {
|
|
383
|
+
"ariaLabel": {},
|
|
384
|
+
"value": {},
|
|
385
|
+
"validationMessage": {}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
static get events() {
|
|
389
|
+
return [{
|
|
390
|
+
"method": "dsCheckboxChange",
|
|
391
|
+
"name": "dsCheckboxChange",
|
|
392
|
+
"bubbles": true,
|
|
393
|
+
"cancelable": true,
|
|
394
|
+
"composed": true,
|
|
395
|
+
"docs": {
|
|
396
|
+
"tags": [],
|
|
397
|
+
"text": ""
|
|
398
|
+
},
|
|
399
|
+
"complexType": {
|
|
400
|
+
"original": "CheckboxChangeEvent",
|
|
401
|
+
"resolved": "CheckboxChangeEvent",
|
|
402
|
+
"references": {
|
|
403
|
+
"CheckboxChangeEvent": {
|
|
404
|
+
"location": "local",
|
|
405
|
+
"path": "/Users/teemuparssinen/hy/uh-design-system/component-library/packages/component-library/src/components/01-base-components/ds-checkbox/ds-checkbox.tsx",
|
|
406
|
+
"id": "src/components/01-base-components/ds-checkbox/ds-checkbox.tsx::CheckboxChangeEvent"
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
"method": "dsCheckboxError",
|
|
412
|
+
"name": "dsCheckboxError",
|
|
413
|
+
"bubbles": true,
|
|
414
|
+
"cancelable": true,
|
|
415
|
+
"composed": true,
|
|
416
|
+
"docs": {
|
|
417
|
+
"tags": [],
|
|
418
|
+
"text": ""
|
|
419
|
+
},
|
|
420
|
+
"complexType": {
|
|
421
|
+
"original": "string",
|
|
422
|
+
"resolved": "string",
|
|
423
|
+
"references": {}
|
|
424
|
+
}
|
|
425
|
+
}];
|
|
426
|
+
}
|
|
427
|
+
static get elementRef() { return "el"; }
|
|
428
|
+
static get attachInternalsMemberName() { return "internals"; }
|
|
429
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { litTemplateResultToString } from "../../../../utils/utils";
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Base Components/Checkbox/Features',
|
|
5
|
+
component: 'ds-checkbox',
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
export const Unchecked = {
|
|
9
|
+
args: {
|
|
10
|
+
text: 'Checkbox text',
|
|
11
|
+
checked: false,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export const Checked = {
|
|
15
|
+
args: {
|
|
16
|
+
text: 'Checkbox text',
|
|
17
|
+
checked: true,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
export const Indeterminate = {
|
|
21
|
+
args: {
|
|
22
|
+
text: 'Checkbox text',
|
|
23
|
+
indeterminate: true,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export const Disabled = {
|
|
27
|
+
args: {
|
|
28
|
+
text: 'Checkbox text',
|
|
29
|
+
checked: false,
|
|
30
|
+
disabled: true
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const Invalid = {
|
|
34
|
+
args: {
|
|
35
|
+
text: 'Checkbox text',
|
|
36
|
+
checked: false,
|
|
37
|
+
errorText: 'Error text',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const withoutValueTextDOM = html `
|
|
41
|
+
<div class="ds-sb-without-value-text">
|
|
42
|
+
<ds-checkbox checked="false" aria-label="Checkbox text"></ds-checkbox>
|
|
43
|
+
<ds-checkbox disabled="true" aria-label="Checkbox text"></ds-checkbox>
|
|
44
|
+
<ds-checkbox error-text="Error text" aria-label="Checkbox text"></ds-checkbox>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
export const WithoutValueText = {
|
|
48
|
+
parameters: {
|
|
49
|
+
docs: {
|
|
50
|
+
source: {
|
|
51
|
+
code: litTemplateResultToString(withoutValueTextDOM),
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
render: () => html `
|
|
56
|
+
<style>
|
|
57
|
+
.ds-sb-without-value-text {
|
|
58
|
+
display: flex;
|
|
59
|
+
gap: 1rem;
|
|
60
|
+
}
|
|
61
|
+
</style>
|
|
62
|
+
${withoutValueTextDOM}
|
|
63
|
+
`,
|
|
64
|
+
};
|
|
65
|
+
const requiredAndOptionalDOM = html `
|
|
66
|
+
<div class="ds-sb-required-and-optional">
|
|
67
|
+
<ds-checkbox required="true" text="Checkbox text"></ds-checkbox>
|
|
68
|
+
<ds-checkbox optional="true" text="Checkbox text"></ds-checkbox>
|
|
69
|
+
<div>
|
|
70
|
+
`;
|
|
71
|
+
export const RequiredAndOptional = {
|
|
72
|
+
parameters: {
|
|
73
|
+
docs: {
|
|
74
|
+
source: {
|
|
75
|
+
code: litTemplateResultToString(requiredAndOptionalDOM),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
render: () => html `
|
|
80
|
+
<style>
|
|
81
|
+
.ds-sb-required-and-optional {
|
|
82
|
+
display: grid;
|
|
83
|
+
gap: 1rem;
|
|
84
|
+
grid-template-columns: 1fr 1fr;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
87
|
+
${requiredAndOptionalDOM}
|
|
88
|
+
`,
|
|
89
|
+
};
|
|
90
|
+
const withLegendAndAssistiveTextDOM = html `
|
|
91
|
+
<div class="ds-sb-with-legend-and-assistive-text">
|
|
92
|
+
<ds-checkbox legend="Legend text" assistive-text="Assistive text" text="Checkbox text"></ds-checkbox>
|
|
93
|
+
<ds-checkbox legend="Legend text" assistive-text="Assistive text" text="Checkbox text" required="true"></ds-checkbox>
|
|
94
|
+
<ds-checkbox legend="Legend text" assistive-text="Assistive text" text="Checkbox text" optional="true"></ds-checkbox>
|
|
95
|
+
</div>
|
|
96
|
+
`;
|
|
97
|
+
export const WithLegendAndAssistiveText = {
|
|
98
|
+
parameters: {
|
|
99
|
+
docs: {
|
|
100
|
+
source: {
|
|
101
|
+
code: litTemplateResultToString(withLegendAndAssistiveTextDOM),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
render: () => html `
|
|
106
|
+
<style>
|
|
107
|
+
.ds-sb-with-legend-and-assistive-text {
|
|
108
|
+
display: grid;
|
|
109
|
+
gap: 1rem;
|
|
110
|
+
grid-template-columns: 1fr 1fr;
|
|
111
|
+
}
|
|
112
|
+
</style>
|
|
113
|
+
${withLegendAndAssistiveTextDOM}
|
|
114
|
+
`,
|
|
115
|
+
};
|
package/dist/collection/components/01-base-components/ds-checkbox/stories/ds-checkbox.stories.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const meta = {
|
|
2
|
+
title: 'Base Components/Checkbox',
|
|
3
|
+
component: 'ds-checkbox',
|
|
4
|
+
};
|
|
5
|
+
export default meta;
|
|
6
|
+
export const Default = {
|
|
7
|
+
args: {
|
|
8
|
+
text: 'Checkbox text',
|
|
9
|
+
checked: false,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export const Playground = {
|
|
13
|
+
args: {
|
|
14
|
+
text: 'Checkbox text',
|
|
15
|
+
checked: false,
|
|
16
|
+
indeterminate: false,
|
|
17
|
+
disabled: false,
|
|
18
|
+
errorText: '',
|
|
19
|
+
required: false,
|
|
20
|
+
optional: false,
|
|
21
|
+
legend: '',
|
|
22
|
+
assistiveText: '',
|
|
23
|
+
optionalText: '',
|
|
24
|
+
},
|
|
25
|
+
argTypes: {
|
|
26
|
+
text: { control: 'text' },
|
|
27
|
+
checked: { control: 'boolean' },
|
|
28
|
+
indeterminate: { control: 'boolean' },
|
|
29
|
+
disabled: { control: 'boolean' },
|
|
30
|
+
errorText: { control: 'text' },
|
|
31
|
+
required: { control: 'boolean' },
|
|
32
|
+
optional: { control: 'boolean' },
|
|
33
|
+
legend: { control: 'text' },
|
|
34
|
+
assistiveText: { control: 'text' },
|
|
35
|
+
optionalText: { control: 'text' },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.ds-checkbox-group {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
border: none;
|
|
5
|
+
padding: 0;
|
|
6
|
+
margin: 0;
|
|
7
|
+
}
|
|
8
|
+
.ds-checkbox-group__legend {
|
|
9
|
+
padding-inline: 0;
|
|
10
|
+
font-size: var(--ds-fontSize-16);
|
|
11
|
+
font-weight: var(--ds-fontWeight-semibold);
|
|
12
|
+
letter-spacing: var(--ds-letterSpacing-wide);
|
|
13
|
+
line-height: var(--ds-lineHeight-large);
|
|
14
|
+
}
|
|
15
|
+
.ds-checkbox-group__assistive-text {
|
|
16
|
+
font-size: var(--ds-fontSize-14);
|
|
17
|
+
color: var(--ds-textColor-secondary);
|
|
18
|
+
line-height: var(--ds-lineHeight-large);
|
|
19
|
+
margin-bottom: var(--ds-spacing-2xSmall);
|
|
20
|
+
}
|
|
21
|
+
.ds-checkbox-group__error {
|
|
22
|
+
display: flex;
|
|
23
|
+
}
|
|
24
|
+
.ds-checkbox-group__error--visible {
|
|
25
|
+
padding-top: var(--ds-spacing-3xSmall);
|
|
26
|
+
}
|
|
27
|
+
.ds-checkbox-group > .ds-checkbox-group__checkboxes {
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
}
|
|
31
|
+
.ds-checkbox-group--inset {
|
|
32
|
+
margin-left: var(--ds-spacing-large);
|
|
33
|
+
}
|
|
34
|
+
.ds-checkbox-group--horizontal > .ds-checkbox-group__checkboxes {
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
gap: var(--ds-spacing-small);
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
}
|