@uh-design-system/component-library 0.5.2 → 0.6.0
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/{utils-3412cbed.js → attributes-BMbXzbwU.js} +2 -28
- package/dist/cjs/component-library.cjs.js +7 -7
- package/dist/cjs/controlUtils-ofqiQxRF.js +42 -0
- package/dist/cjs/ds-accordion.cjs.entry.js +79 -0
- package/dist/cjs/ds-button.cjs.entry.js +107 -0
- package/dist/cjs/ds-card.cjs.entry.js +58 -0
- package/dist/cjs/ds-checkbox-group.cjs.entry.js +109 -49
- package/dist/cjs/ds-checkbox.cjs.entry.js +88 -79
- package/dist/cjs/ds-icon.cjs.entry.js +943 -0
- package/dist/cjs/ds-input-validity.cjs.entry.js +14 -15
- package/dist/cjs/ds-link-with-arrow.cjs.entry.js +21 -20
- package/dist/cjs/ds-link.cjs.entry.js +34 -31
- package/dist/cjs/ds-radio-button-group.cjs.entry.js +153 -0
- package/dist/cjs/ds-radio-button.cjs.entry.js +151 -0
- package/dist/cjs/ds-spinner.cjs.entry.js +62 -0
- package/dist/cjs/ds-text-input.cjs.entry.js +90 -77
- package/dist/cjs/ds-visually-hidden.cjs.entry.js +3 -6
- package/dist/cjs/index-Bp6Dd2i1.js +94 -0
- package/dist/cjs/{store-9bd20f3c.js → index-DwLFyR5p.js} +6 -2
- package/dist/cjs/{index-bf84b124.js → index-Mjp9Y-Sw.js} +701 -55
- package/dist/cjs/index.cjs.js +3 -5
- package/dist/cjs/{linkUtils-695da37c.js → linkUtils-onlbgKdI.js} +4 -2
- package/dist/cjs/loader.cjs.js +3 -5
- package/dist/cjs/utils-BjZTECpy.js +29 -0
- package/dist/collection/accessibility/stories/naming.stories.js +3 -3
- package/dist/collection/collection-manifest.json +78 -3
- package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.css +18 -17
- package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.js +91 -50
- package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.examples.stories.js +6 -6
- package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.features.stories.js +14 -14
- package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.stories.js +24 -66
- package/dist/collection/components/01-base-components/ds-button/ds-button.css +124 -145
- package/dist/collection/components/01-base-components/ds-button/ds-button.js +150 -65
- package/dist/collection/components/01-base-components/ds-button/stories/ds-button.examples.stories.js +121 -23
- package/dist/collection/components/01-base-components/ds-button/stories/ds-button.features.stories.js +49 -42
- package/dist/collection/components/01-base-components/ds-button/stories/ds-button.stories.js +16 -72
- package/dist/collection/components/01-base-components/ds-card/ds-card.css +127 -0
- package/dist/collection/components/01-base-components/ds-card/ds-card.js +303 -0
- package/dist/collection/components/01-base-components/ds-card/stories/ds-card.examples.stories.js +92 -0
- package/dist/collection/components/01-base-components/ds-card/stories/ds-card.features.stories.js +66 -0
- package/dist/collection/components/01-base-components/ds-card/stories/ds-card.stories.js +71 -0
- package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.css +46 -46
- package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.js +120 -111
- package/dist/collection/components/01-base-components/ds-checkbox/stories/ds-checkbox.features.stories.js +20 -20
- package/dist/collection/components/01-base-components/ds-checkbox/stories/ds-checkbox.stories.js +12 -25
- package/dist/collection/components/01-base-components/ds-checkbox-group/ds-checkbox-group.css +2 -3
- package/dist/collection/components/01-base-components/ds-checkbox-group/ds-checkbox-group.js +214 -63
- package/dist/collection/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.features.stories.js +215 -50
- package/dist/collection/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.stories.js +30 -28
- package/dist/collection/components/01-base-components/ds-icon/ds-icon.js +36 -31
- package/dist/collection/components/01-base-components/ds-icon/stories/ds-icon.stories.js +10 -37
- package/dist/collection/components/01-base-components/ds-input-validity/ds-input-validity.css +2 -2
- package/dist/collection/components/01-base-components/ds-input-validity/ds-input-validity.js +60 -30
- package/dist/collection/components/01-base-components/ds-input-validity/stories/ds-input-validity.features.stories.js +4 -4
- package/dist/collection/components/01-base-components/ds-input-validity/stories/ds-input-validity.stories.js +4 -9
- package/dist/collection/components/01-base-components/ds-link/ds-link.css +24 -14
- package/dist/collection/components/01-base-components/ds-link/ds-link.js +74 -75
- package/dist/collection/components/01-base-components/ds-link/stories/ds-link.examples.stories.js +27 -27
- package/dist/collection/components/01-base-components/ds-link/stories/ds-link.features.stories.js +38 -21
- package/dist/collection/components/01-base-components/ds-link/stories/ds-link.stories.js +8 -67
- package/dist/collection/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.css +10 -12
- package/dist/collection/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.js +30 -52
- package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/ds-link-with-arrow.examples.stories.js +4 -4
- package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/ds-link-with-arrow.features.stories.js +6 -6
- package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/ds-link-with-arrow.stories.js +4 -28
- package/dist/collection/components/01-base-components/ds-radio-button/ds-radio-button.css +115 -0
- package/dist/collection/components/01-base-components/ds-radio-button/ds-radio-button.js +449 -0
- package/dist/collection/components/01-base-components/ds-radio-button/stories/ds-radio-button.features.stories.js +72 -0
- package/dist/collection/components/01-base-components/ds-radio-button/stories/ds-radio-button.stories.js +22 -0
- package/dist/collection/components/01-base-components/ds-radio-button-group/ds-radio-button-group.css +30 -0
- package/dist/collection/components/01-base-components/ds-radio-button-group/ds-radio-button-group.js +360 -0
- package/dist/collection/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.examples.stories.js +42 -0
- package/dist/collection/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.features.stories.js +71 -0
- package/dist/collection/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.stories.js +60 -0
- package/dist/collection/components/01-base-components/ds-spinner/ds-spinner.css +279 -0
- package/dist/collection/components/01-base-components/ds-spinner/ds-spinner.js +221 -0
- package/dist/collection/components/01-base-components/ds-spinner/stories/ds-spinner.examples.stories.js +120 -0
- package/dist/collection/components/01-base-components/ds-spinner/stories/ds-spinner.features.stories.js +107 -0
- package/dist/collection/components/01-base-components/ds-spinner/stories/ds-spinner.stories.js +14 -0
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.css +85 -118
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.js +230 -155
- package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.examples.stories.js +26 -21
- package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.features.stories.js +40 -40
- package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.stories.js +30 -56
- package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.js +1 -1
- package/dist/collection/store.js +7 -1
- package/dist/collection/utils/attributes/attributes.js +2 -2
- package/dist/collection/utils/button/buttonUtils.js +14 -0
- package/dist/collection/utils/colours/colourTypes.js +3 -3
- package/dist/collection/utils/colours/colourUtils.js +5 -3
- package/dist/collection/utils/controls/controlUtils.js +35 -1
- package/dist/collection/utils/link/linkUtils.js +3 -2
- package/dist/collection/utils/spinner/spinnerUtils.js +20 -0
- package/dist/collection/utils/tests/testUtils.js +1 -0
- package/dist/collection/utils/typography/typographyUtils.js +3 -3
- package/dist/collection/utils/utils.js +10 -9
- package/dist/component-library/{utils-cfc536bc.js → attributes-BD_lNRxn.js} +1 -1
- package/dist/component-library/component-library.css +1 -1
- package/dist/component-library/component-library.esm.js +1 -1
- package/dist/component-library/controlUtils-CNER0MvM.js +1 -0
- package/dist/component-library/ds-accordion.entry.js +1 -0
- package/dist/component-library/ds-button.entry.js +1 -0
- package/dist/component-library/ds-card.entry.js +1 -0
- package/dist/component-library/ds-checkbox-group.entry.js +1 -1
- package/dist/component-library/ds-checkbox.entry.js +1 -1
- package/dist/component-library/ds-icon.entry.js +1 -0
- package/dist/component-library/ds-input-validity.entry.js +1 -1
- 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-radio-button-group.entry.js +1 -0
- package/dist/component-library/ds-radio-button.entry.js +1 -0
- package/dist/component-library/ds-spinner.entry.js +1 -0
- 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-BfTCfPZ1.js +6 -0
- package/dist/component-library/index-Cm7V4EAn.js +2 -0
- package/dist/component-library/index-DuYjhvTn.js +1 -0
- package/dist/component-library/index.esm.js +1 -1
- package/dist/component-library/linkUtils-02nCfO0F.js +1 -0
- package/dist/component-library/utils-CqaqnfY4.js +1 -0
- package/dist/components/attributes.js +3 -3
- package/dist/components/controlUtils.js +35 -2
- package/dist/components/ds-accordion.js +58 -42
- package/dist/components/ds-button2.js +78 -39
- package/dist/components/ds-card.d.ts +11 -0
- package/dist/components/ds-card.js +91 -0
- package/dist/components/ds-checkbox-group.js +116 -56
- package/dist/components/ds-checkbox2.js +93 -80
- package/dist/components/ds-icon2.js +292 -292
- package/dist/components/ds-input-validity2.js +17 -14
- package/dist/components/ds-link-with-arrow.js +22 -22
- package/dist/components/ds-link.js +43 -40
- package/dist/components/ds-radio-button-group.d.ts +11 -0
- package/dist/components/ds-radio-button-group.js +185 -0
- package/dist/components/ds-radio-button.d.ts +11 -0
- package/dist/components/ds-radio-button.js +198 -0
- package/dist/components/ds-spinner.d.ts +11 -0
- package/dist/components/ds-spinner.js +6 -0
- package/dist/components/ds-spinner2.js +89 -0
- package/dist/components/ds-text-input.js +126 -104
- package/dist/components/ds-visually-hidden2.js +2 -3
- package/dist/components/index.js +208 -2
- package/dist/components/index2.js +713 -39
- package/dist/components/index3.js +69 -57
- package/dist/components/linkUtils.js +4 -2
- package/dist/docs.d.ts +443 -0
- package/dist/docs.json +4790 -0
- package/dist/esm/{utils-cfc536bc.js → attributes-BD_lNRxn.js} +3 -26
- package/dist/esm/component-library.js +6 -5
- package/dist/esm/controlUtils-CNER0MvM.js +37 -0
- package/dist/esm/ds-accordion.entry.js +77 -0
- package/dist/esm/ds-button.entry.js +105 -0
- package/dist/esm/ds-card.entry.js +56 -0
- package/dist/esm/ds-checkbox-group.entry.js +108 -46
- package/dist/esm/ds-checkbox.entry.js +78 -67
- package/dist/esm/ds-icon.entry.js +941 -0
- package/dist/esm/ds-input-validity.entry.js +14 -13
- package/dist/esm/ds-link-with-arrow.entry.js +21 -18
- package/dist/esm/ds-link.entry.js +34 -29
- package/dist/esm/ds-radio-button-group.entry.js +151 -0
- package/dist/esm/ds-radio-button.entry.js +149 -0
- package/dist/esm/ds-spinner.entry.js +60 -0
- package/dist/esm/ds-text-input.entry.js +88 -73
- package/dist/esm/ds-visually-hidden.entry.js +3 -4
- package/dist/esm/index-BfTCfPZ1.js +92 -0
- package/dist/esm/{index-434995e1.js → index-Cm7V4EAn.js} +699 -34
- package/dist/{components/store.js → esm/index-DuYjhvTn.js} +6 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/{linkUtils-3d1b28cf.js → linkUtils-02nCfO0F.js} +4 -2
- package/dist/esm/loader.js +4 -4
- package/dist/esm/utils-CqaqnfY4.js +25 -0
- package/dist/hydrate/index.d.ts +271 -0
- package/dist/hydrate/index.js +22280 -0
- package/dist/hydrate/index.mjs +22272 -0
- package/dist/hydrate/package.json +12 -0
- package/dist/styles/helpers.css +15 -0
- package/dist/styles/helpers.css.map +1 -0
- package/dist/styles/mixins/_breakpoints.scss +13 -0
- package/dist/styles/mixins/_focus.scss +26 -0
- package/dist/styles/mixins/_wrapper.scss +5 -0
- package/dist/styles/mixins/imports-default/_imports.scss +2 -0
- package/dist/styles/mixins/tokens/_breakpoints.scss +13 -0
- package/dist/styles/mixins/tokens/_semantic-colours.scss +75 -0
- package/dist/styles/mixins.scss +12 -0
- package/dist/styles/variables.css +176 -0
- package/dist/styles/variables.css.map +1 -0
- package/dist/types/components/01-base-components/ds-accordion/ds-accordion.d.ts +11 -8
- package/dist/types/components/01-base-components/ds-button/ds-button.d.ts +16 -11
- package/dist/types/components/01-base-components/ds-button/stories/ds-button.examples.stories.d.ts +1 -0
- package/dist/types/components/01-base-components/ds-button/stories/ds-button.features.stories.d.ts +1 -0
- package/dist/types/components/01-base-components/ds-card/ds-card.d.ts +20 -0
- package/dist/types/components/01-base-components/ds-card/stories/ds-card.examples.stories.d.ts +8 -0
- package/dist/types/components/01-base-components/ds-card/stories/ds-card.features.stories.d.ts +8 -0
- package/dist/types/components/01-base-components/ds-card/stories/ds-card.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-checkbox/ds-checkbox.d.ts +21 -22
- package/dist/types/components/01-base-components/ds-checkbox-group/ds-checkbox-group.d.ts +21 -11
- package/dist/types/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.features.stories.d.ts +3 -0
- package/dist/types/components/01-base-components/ds-icon/ds-icon.d.ts +7 -5
- package/dist/types/components/01-base-components/ds-input-validity/ds-input-validity.d.ts +5 -6
- package/dist/types/components/01-base-components/ds-link/ds-link.d.ts +13 -14
- package/dist/types/components/01-base-components/ds-link/stories/ds-link.features.stories.d.ts +2 -0
- package/dist/types/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.d.ts +5 -7
- package/dist/types/components/01-base-components/ds-radio-button/ds-radio-button.d.ts +44 -0
- package/dist/types/components/01-base-components/ds-radio-button/stories/ds-radio-button.features.stories.d.ts +15 -0
- package/dist/types/components/01-base-components/ds-radio-button/stories/ds-radio-button.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-radio-button-group/ds-radio-button-group.d.ts +34 -0
- package/dist/types/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.examples.stories.d.ts +6 -0
- package/dist/types/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.features.stories.d.ts +11 -0
- package/dist/types/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-spinner/ds-spinner.d.ts +17 -0
- package/dist/types/components/01-base-components/ds-spinner/stories/ds-spinner.examples.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-spinner/stories/ds-spinner.features.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-spinner/stories/ds-spinner.stories.d.ts +7 -0
- package/dist/types/components/01-base-components/ds-text-input/ds-text-input.d.ts +37 -32
- package/dist/types/components.d.ts +1287 -228
- package/dist/types/stencil-public-runtime.d.ts +22 -0
- package/dist/types/store.d.ts +6 -1
- package/dist/types/utils/attributes/attributes.d.ts +1 -1
- package/dist/types/utils/button/buttonUtils.d.ts +1 -0
- package/dist/types/utils/colours/colourTypes.d.ts +3 -3
- package/dist/types/utils/controls/controlUtils.d.ts +2 -0
- package/dist/types/utils/link/linkUtils.d.ts +1 -1
- package/dist/types/utils/spinner/spinnerUtils.d.ts +1 -0
- package/dist/types/utils/tests/testUtils.d.ts +1 -0
- package/dist/types/utils/utils.d.ts +2 -1
- package/package.json +40 -36
- package/dist/cjs/controlUtils-041de0fd.js +0 -7
- package/dist/cjs/ds-accordion_3.cjs.entry.js +0 -1095
- package/dist/cjs/index-5b0b9d4c.js +0 -82
- package/dist/component-library/controlUtils-9ca4087b.js +0 -1
- package/dist/component-library/ds-accordion_3.entry.js +0 -1
- package/dist/component-library/index-434995e1.js +0 -2
- package/dist/component-library/index-72ac5051.js +0 -6
- package/dist/component-library/linkUtils-3d1b28cf.js +0 -1
- package/dist/component-library/store-b8d17c10.js +0 -1
- package/dist/esm/controlUtils-9ca4087b.js +0 -4
- package/dist/esm/ds-accordion_3.entry.js +0 -1089
- package/dist/esm/index-72ac5051.js +0 -80
- package/dist/esm/store-b8d17c10.js +0 -204
- package/dist/loader/package.json +0 -11
- /package/dist/cjs/{app-globals-3a1e7e63.js → app-globals-V2Kpy_OQ.js} +0 -0
- /package/dist/component-library/{app-globals-0f993ce5.js → app-globals-DQuL1Twl.js} +0 -0
- /package/dist/esm/{app-globals-0f993ce5.js → app-globals-DQuL1Twl.js} +0 -0
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent,
|
|
2
|
-
import { c as classNames } from './index-
|
|
3
|
-
import {
|
|
1
|
+
import { r as registerInstance, c as createEvent, g as getElement, h, F as Fragment } from './index-Cm7V4EAn.js';
|
|
2
|
+
import { c as classNames } from './index-BfTCfPZ1.js';
|
|
3
|
+
import { b as inheritAriaAttributes } from './attributes-BD_lNRxn.js';
|
|
4
|
+
import { i as idGenerator } from './utils-CqaqnfY4.js';
|
|
5
|
+
import { g as getRequiredText, a as getOptionalText, b as atLeastOneOption, c as allOptions } from './controlUtils-CNER0MvM.js';
|
|
6
|
+
import './index-DuYjhvTn.js';
|
|
4
7
|
|
|
5
|
-
const dsCheckboxGroupCss = ".ds-checkbox-group{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0}.ds-checkbox-group__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-group__assistive-text{font-size:var(--ds-fontSize-14);color:var(--ds-
|
|
6
|
-
const DsCheckboxGroupStyle0 = dsCheckboxGroupCss;
|
|
8
|
+
const dsCheckboxGroupCss = ".ds-checkbox-group{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0}.ds-checkbox-group__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-group__assistive-text{font-size:var(--ds-fontSize-14);color:var(--ds-palette-black-70);line-height:var(--ds-lineHeight-large);margin-bottom:var(--ds-spacing-2xSmall)}.ds-checkbox-group__error{display:flex}.ds-checkbox-group__error--visible{padding-top:var(--ds-spacing-3xSmall)}.ds-checkbox-group>.ds-checkbox-group__checkboxes{display:inline-flex;flex-direction:column}.ds-checkbox-group--inset{margin-left:var(--ds-spacing-large)}.ds-checkbox-group--horizontal>.ds-checkbox-group__checkboxes{flex-flow:row wrap;gap:var(--ds-spacing-small)}";
|
|
7
9
|
|
|
8
10
|
const fieldsetIdGenerator = idGenerator('ds-checkbox-group');
|
|
9
11
|
const DsCheckboxGroup = class {
|
|
10
12
|
constructor(hostRef) {
|
|
11
13
|
registerInstance(this, hostRef);
|
|
12
|
-
this.dsCheckboxGroupChange = createEvent(this, "dsCheckboxGroupChange"
|
|
13
|
-
this.dsCheckboxGroupIndeterminateChildChange = createEvent(this, "dsCheckboxGroupIndeterminateChildChange"
|
|
14
|
+
this.dsCheckboxGroupChange = createEvent(this, "dsCheckboxGroupChange");
|
|
15
|
+
this.dsCheckboxGroupIndeterminateChildChange = createEvent(this, "dsCheckboxGroupIndeterminateChildChange");
|
|
16
|
+
this.dsCheckboxGroupInvalidStateChange = createEvent(this, "dsCheckboxGroupInvalidStateChange");
|
|
17
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
18
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
22
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
23
|
+
}
|
|
14
24
|
}
|
|
25
|
+
checkboxElem;
|
|
15
26
|
fieldsetId = fieldsetIdGenerator.next().value;
|
|
16
27
|
checkboxId = `${this.fieldsetId}-checkbox`;
|
|
17
28
|
errorTextId = `${this.fieldsetId}-error`;
|
|
@@ -19,23 +30,45 @@ const DsCheckboxGroup = class {
|
|
|
19
30
|
nestedId = `${this.fieldsetId}-nested`;
|
|
20
31
|
inheritedAttributes = {};
|
|
21
32
|
get el() { return getElement(this); }
|
|
33
|
+
internals;
|
|
22
34
|
dsCheckboxGroupChange;
|
|
23
35
|
dsCheckboxGroupIndeterminateChildChange;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
dsCheckboxGroupInvalidStateChange;
|
|
37
|
+
dsLegend;
|
|
38
|
+
dsAssistiveText;
|
|
39
|
+
dsDirection = 'vertical';
|
|
40
|
+
dsErrorText = '';
|
|
41
|
+
dsText = '';
|
|
42
|
+
dsChecked = false;
|
|
43
|
+
dsDisabled = false;
|
|
44
|
+
dsRequired = false;
|
|
45
|
+
dsAllRequired = false;
|
|
46
|
+
dsOptional = false;
|
|
47
|
+
dsOptionalText;
|
|
48
|
+
childElementsCount = 1;
|
|
32
49
|
checkedChildElementCount = 0;
|
|
33
50
|
isIndeterminate = false;
|
|
34
51
|
indeterminateChildCheckboxCount = 0;
|
|
52
|
+
showInternalsValidationMessage = false;
|
|
35
53
|
elementIs = (localName) => (element) => element.localName === localName;
|
|
36
54
|
elementIsCheckbox = this.elementIs('ds-checkbox');
|
|
37
55
|
elementIsCheckboxGroup = this.elementIs('ds-checkbox-group');
|
|
38
|
-
|
|
56
|
+
getLegendText = () => {
|
|
57
|
+
if (this.dsRequired || this.dsAllRequired) {
|
|
58
|
+
return getRequiredText(this.dsLegend);
|
|
59
|
+
}
|
|
60
|
+
if (this.dsOptional) {
|
|
61
|
+
return getOptionalText(this.dsLegend, this.dsOptionalText);
|
|
62
|
+
}
|
|
63
|
+
return this.dsLegend;
|
|
64
|
+
};
|
|
65
|
+
getAriaDescribedBy = () => [
|
|
66
|
+
!!this.dsAssistiveText && this.assistiveTextId,
|
|
67
|
+
(!!this.dsErrorText || (this.showInternalsValidationMessage && !!this.internals?.validationMessage)) && this.errorTextId,
|
|
68
|
+
]
|
|
69
|
+
.filter(Boolean)
|
|
70
|
+
.join(' ');
|
|
71
|
+
getValidationMessage = () => this.dsErrorText || (this.showInternalsValidationMessage ? this.internals?.validationMessage : '');
|
|
39
72
|
getChildElements = () => {
|
|
40
73
|
const slot = this.el.shadowRoot.querySelector('slot');
|
|
41
74
|
return (slot?.assignedElements() || []);
|
|
@@ -52,7 +85,7 @@ const DsCheckboxGroup = class {
|
|
|
52
85
|
updateChildElementsChecked = (checked) => {
|
|
53
86
|
this.checkedChildElementCount = checked ? this.childElementsCount : 0;
|
|
54
87
|
this.updateChildElements((element) => {
|
|
55
|
-
element.
|
|
88
|
+
element.dsChecked = checked;
|
|
56
89
|
if (this.elementIsCheckboxGroup(element)) {
|
|
57
90
|
(async () => {
|
|
58
91
|
await element.setChecked(checked);
|
|
@@ -65,7 +98,7 @@ const DsCheckboxGroup = class {
|
|
|
65
98
|
}
|
|
66
99
|
watchCheckboxDisabledChange(newValue) {
|
|
67
100
|
this.updateChildElements((element) => {
|
|
68
|
-
element.
|
|
101
|
+
element.dsDisabled = newValue;
|
|
69
102
|
});
|
|
70
103
|
}
|
|
71
104
|
watchCheckedChange(newValue) {
|
|
@@ -74,77 +107,106 @@ const DsCheckboxGroup = class {
|
|
|
74
107
|
watchIndeterminateChange(newValue) {
|
|
75
108
|
this.dsCheckboxGroupIndeterminateChildChange.emit({ id: this.fieldsetId, indeterminate: newValue });
|
|
76
109
|
}
|
|
110
|
+
errorTextObserver(errorText) {
|
|
111
|
+
this.dsCheckboxGroupInvalidStateChange.emit(!!errorText);
|
|
112
|
+
}
|
|
77
113
|
listenIndeterminateChildChange(event) {
|
|
78
114
|
this.indeterminateChildCheckboxCount = event.detail.indeterminate ? this.indeterminateChildCheckboxCount + 1 : this.indeterminateChildCheckboxCount - 1;
|
|
79
115
|
}
|
|
80
|
-
watchCheckedChildElementCountChange(
|
|
81
|
-
this.isIndeterminate =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: true });
|
|
116
|
+
watchCheckedChildElementCountChange() {
|
|
117
|
+
this.isIndeterminate = this.checkedChildElementCount > 0 && this.checkedChildElementCount < this.childElementsCount;
|
|
118
|
+
if (this.dsRequired && this.checkedChildElementCount === 0) {
|
|
119
|
+
this.internals?.setValidity({ valueMissing: true }, atLeastOneOption(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
|
|
85
120
|
}
|
|
86
|
-
else if (
|
|
87
|
-
this.
|
|
121
|
+
else if (this.dsAllRequired && this.checkedChildElementCount !== this.childElementsCount) {
|
|
122
|
+
this.internals?.setValidity({ valueMissing: true }, allOptions(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.internals?.setValidity({ valueMissing: false });
|
|
88
126
|
}
|
|
89
127
|
}
|
|
90
|
-
updateCheckedChildElementCount = (
|
|
91
|
-
if (
|
|
92
|
-
this.checkedChildElementCount =
|
|
128
|
+
updateCheckedChildElementCount = (checked) => {
|
|
129
|
+
if (checked) {
|
|
130
|
+
this.checkedChildElementCount = Math.min(this.childElementsCount, this.checkedChildElementCount + 1);
|
|
93
131
|
}
|
|
94
132
|
else {
|
|
95
|
-
this.checkedChildElementCount =
|
|
133
|
+
this.checkedChildElementCount = Math.max(0, this.checkedChildElementCount - 1);
|
|
96
134
|
}
|
|
97
135
|
};
|
|
98
136
|
listenCheckboxChange(event) {
|
|
99
|
-
if (
|
|
100
|
-
this.
|
|
137
|
+
if (!this.showInternalsValidationMessage) {
|
|
138
|
+
this.showInternalsValidationMessage = true;
|
|
139
|
+
}
|
|
140
|
+
if (event.target === this.el) {
|
|
141
|
+
this.updateChildElementsChecked(this.checkboxElem.dsChecked);
|
|
142
|
+
this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: this.checkboxElem.dsChecked });
|
|
101
143
|
return;
|
|
102
144
|
}
|
|
103
|
-
|
|
104
|
-
|
|
145
|
+
const target = event.target;
|
|
146
|
+
if (this.getChildCheckboxElements().includes(target)) {
|
|
147
|
+
const previousCheckedChildElementCount = this.checkedChildElementCount;
|
|
148
|
+
this.updateCheckedChildElementCount(target.dsChecked);
|
|
149
|
+
if (this.checkedChildElementCount === this.childElementsCount && this.checkedChildElementCount > previousCheckedChildElementCount) {
|
|
150
|
+
this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: true });
|
|
151
|
+
}
|
|
152
|
+
else if (previousCheckedChildElementCount === this.childElementsCount && this.checkedChildElementCount < previousCheckedChildElementCount) {
|
|
153
|
+
this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: false });
|
|
154
|
+
}
|
|
105
155
|
}
|
|
106
156
|
}
|
|
107
157
|
listenCheckboxGroupChange(event) {
|
|
108
158
|
if (this.getChildElements().includes(event.target)) {
|
|
109
|
-
|
|
159
|
+
event.stopPropagation();
|
|
160
|
+
this.updateCheckedChildElementCount(event.detail.checked);
|
|
110
161
|
}
|
|
111
162
|
}
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
}
|
|
163
|
+
formResetCallback() {
|
|
164
|
+
this.internals?.setValidity({});
|
|
165
|
+
}
|
|
115
166
|
componentWillLoad() {
|
|
116
167
|
this.inheritedAttributes = inheritAriaAttributes(this.el, ['aria-labelledby']);
|
|
117
168
|
}
|
|
118
169
|
componentDidLoad() {
|
|
119
|
-
this.
|
|
170
|
+
this.childElementsCount = this.getChildElements().length;
|
|
120
171
|
this.updateChildCheckboxes(element => {
|
|
121
|
-
element.setAttribute('
|
|
172
|
+
element.setAttribute('ds-errors-disabled', 'true');
|
|
122
173
|
});
|
|
174
|
+
if (this.dsRequired) {
|
|
175
|
+
this.internals?.setValidity({ valueMissing: true }, atLeastOneOption(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
|
|
176
|
+
}
|
|
177
|
+
else if (this.dsAllRequired) {
|
|
178
|
+
this.internals?.setValidity({ valueMissing: true }, allOptions(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
|
|
179
|
+
}
|
|
123
180
|
}
|
|
124
181
|
componentDidUpdate() {
|
|
125
|
-
this.
|
|
182
|
+
const childElementCount = this.getChildElements().length;
|
|
183
|
+
if (this.childElementsCount !== childElementCount) {
|
|
184
|
+
this.childElementsCount = childElementCount;
|
|
185
|
+
}
|
|
126
186
|
}
|
|
127
187
|
render() {
|
|
128
188
|
const classes = classNames('ds-checkbox-group', {
|
|
129
|
-
'ds-checkbox-group--horizontal': this.
|
|
189
|
+
'ds-checkbox-group--horizontal': this.dsDirection === 'horizontal',
|
|
130
190
|
});
|
|
131
191
|
const legendClasses = classNames('ds-checkbox-group__legend');
|
|
132
192
|
const assistiveTextClasses = classNames('ds-checkbox-group__assistive-text');
|
|
133
193
|
const errorClasses = classNames('ds-checkbox-group__error', {
|
|
134
|
-
'ds-checkbox-group__error--visible': Boolean(this.
|
|
194
|
+
'ds-checkbox-group__error--visible': Boolean(this.dsErrorText),
|
|
135
195
|
});
|
|
136
196
|
const nestedClasses = classNames('ds-checkbox-group', 'ds-checkbox-group--inset');
|
|
137
197
|
const checkboxesClasses = classNames('ds-checkbox-group__checkboxes');
|
|
138
198
|
const ariaDescribedBy = this.getAriaDescribedBy();
|
|
139
|
-
return (h("fieldset", { key: '
|
|
199
|
+
return (h("fieldset", { key: '98ff7c5dd5c36c163ed1dfb177d5c0b28b93971a', id: this.fieldsetId, class: classes, "aria-describedby": ariaDescribedBy, ...this.inheritedAttributes }, this.dsLegend && h("legend", { key: '22274e3c85262fd08f69a9aa548d2910eaf30ce2', class: legendClasses }, this.getLegendText()), this.dsAssistiveText && (h("small", { key: '4566b9d66b0be262548ddecd11f6eda5acc6d399', class: assistiveTextClasses, id: this.assistiveTextId }, this.dsAssistiveText)), this.dsText ? (h(Fragment, null, h("ds-checkbox", { ref: checkboxElem => (this.checkboxElem = checkboxElem), dsId: this.checkboxId, dsText: this.dsText, dsChecked: this.checkedChildElementCount === this.childElementsCount, dsDisabled: this.dsDisabled, dsIndeterminate: this.indeterminateChildCheckboxCount > 0 || this.isIndeterminate }), h("fieldset", { id: this.nestedId, "aria-labelledby": this.checkboxId, class: nestedClasses }, h("slot", null)))) : (h("div", { class: checkboxesClasses }, h("slot", null))), (!!this.dsErrorText || this.dsRequired || this.dsAllRequired) && (h("div", { key: 'd0a2dbc9d46967de609096d9a398b040f5228807', class: errorClasses }, h("ds-input-validity", { key: '409b5d8fbd59b26245cb828146f28eec3d010aaa', id: this.errorTextId, dsText: this.getValidationMessage(), dsType: "error", dsAriaLive: "polite", dsAriaAtomic: "true" })))));
|
|
140
200
|
}
|
|
201
|
+
static get formAssociated() { return true; }
|
|
141
202
|
static get watchers() { return {
|
|
142
|
-
"
|
|
143
|
-
"
|
|
203
|
+
"dsDisabled": ["watchCheckboxDisabledChange"],
|
|
204
|
+
"dsChecked": ["watchCheckedChange"],
|
|
144
205
|
"isIndeterminate": ["watchIndeterminateChange"],
|
|
206
|
+
"dsErrorText": ["errorTextObserver"],
|
|
145
207
|
"checkedChildElementCount": ["watchCheckedChildElementCountChange"]
|
|
146
208
|
}; }
|
|
147
209
|
};
|
|
148
|
-
DsCheckboxGroup.style =
|
|
210
|
+
DsCheckboxGroup.style = dsCheckboxGroupCss;
|
|
149
211
|
|
|
150
212
|
export { DsCheckboxGroup as ds_checkbox_group };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent,
|
|
2
|
-
import { c as classNames } from './index-
|
|
3
|
-
import { i as
|
|
4
|
-
import { g as getRequiredText, a as getOptionalText } from './controlUtils-
|
|
5
|
-
import { i as isValidation } from './
|
|
1
|
+
import { r as registerInstance, c as createEvent, g as getElement, h, F as Fragment } from './index-Cm7V4EAn.js';
|
|
2
|
+
import { c as classNames } from './index-BfTCfPZ1.js';
|
|
3
|
+
import { i as inheritAttributes, b as inheritAriaAttributes } from './attributes-BD_lNRxn.js';
|
|
4
|
+
import { g as getRequiredText, a as getOptionalText } from './controlUtils-CNER0MvM.js';
|
|
5
|
+
import { i as isValidation } from './index-DuYjhvTn.js';
|
|
6
|
+
import { i as idGenerator } from './utils-CqaqnfY4.js';
|
|
6
7
|
|
|
7
|
-
const dsCheckboxCss = ".ds-checkbox-fieldset{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0;gap:var(--ds-spacing-3xSmall)}.ds-checkbox-fieldset__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-fieldset__assistive-text{display:inline;font-size:var(--ds-fontSize-14);color:var(--ds-
|
|
8
|
-
const DsCheckboxStyle0 = dsCheckboxCss;
|
|
8
|
+
const dsCheckboxCss = ":root{--ds-breakpoint-xSmall:20rem;--ds-breakpoint-small:30rem;--ds-breakpoint-medium:60rem;--ds-breakpoint-large:75rem;--ds-breakpoint-xLarge:90rem}.ds-checkbox-fieldset{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0;gap:var(--ds-spacing-3xSmall)}.ds-checkbox-fieldset__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-fieldset__assistive-text{display:inline;font-size:var(--ds-fontSize-14);color:var(--ds-palette-black-70);line-height:var(--ds-lineHeight-large)}.ds-checkbox{display:inline-flex;align-self:flex-start;align-items:flex-start;flex-flow:row nowrap;text-wrap:wrap;word-wrap:break-word;white-space:normal;position:relative;cursor:pointer;user-select:none;width:auto;padding:var(--ds-spacing-xSmall)}.ds-checkbox__input{cursor:pointer;appearance:none;background-color:var(--ds-palette-white);margin:0;display:grid;place-content:center;height:24px;width:24px;flex-shrink:0;margin-right:var(--ds-spacing-xSmall);border-width:var(--ds-borderWidth-thin);border-style:solid;border-color:var(--ds-palette-black-50);}.ds-checkbox__input:focus-visible{box-shadow:0 0 0 var(--ds-borderWidth-thin) var(--ds-palette-white);outline:var(--ds-borderWidth-thin) solid var(--ds-palette-black-95);outline-offset:calc(var(--ds-borderWidth-thin) * 1)}.ds-checkbox__input:hover,.ds-checkbox__input:active{border-color:var(--ds-palette-black-50)}.ds-checkbox__input:hover{background-color:var(--ds-palette-black-10)}.ds-checkbox__input:active{background-color:var(--ds-palette-black-20)}.ds-checkbox__input:disabled{cursor:not-allowed;color:var(--ds-palette-black-40);background-color:var(--ds-overlay-black-10);border-color:var(--ds-overlay-black-15)}@media (forced-colors: active){.ds-checkbox__input:disabled{border-color:GrayText}}.ds-checkbox__input:user-invalid,.ds-checkbox__input--invalid,.ds-checkbox__input--invalid:checked,.ds-checkbox__input--invalid:indeterminate{border-color:var(--ds-palette-red-50)}.ds-checkbox__input:checked,.ds-checkbox__input:indeterminate{background-color:var(--ds-palette-mainBlue-70);border-color:var(--ds-overlay-black-00)}.ds-checkbox__input:checked:hover,.ds-checkbox__input:indeterminate:hover{background-color:var(--ds-palette-mainBlue-80)}.ds-checkbox__input:checked:active,.ds-checkbox__input:indeterminate:active{background-color:var(--ds-palette-mainBlue-90)}.ds-checkbox__input:checked:disabled,.ds-checkbox__input:indeterminate:disabled{background-color:var(--ds-overlay-black-10)}.ds-checkbox__input::before{content:\"\";display:block;height:1em;width:1em;background-size:contain;background-repeat:no-repeat;background-position:center}.ds-checkbox__input:checked::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='16' height='13' viewBox='0 0 16 13' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M5.99997 7.87871L13.606 0.272705L15.7273 2.39403L5.99997 12.1214L0.272644 6.39402L2.39396 4.27271L5.99997 7.87871Z' fill='%23ffffff' /></svg>\")}.ds-checkbox__input:indeterminate::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='14' height='4' viewBox='0 0 14 4' xmlns='http://www.w3.org/2000/svg'><rect width='13.3333' height='3' transform='matrix(1 0 0 -1 0.333313 3.5)' fill='%23ffffff' /></svg>\")}.ds-checkbox__input:checked:disabled::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='16' height='13' viewBox='0 0 16 13' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M5.99997 7.87871L13.606 0.272705L15.7273 2.39403L5.99997 12.1214L0.272644 6.39402L2.39396 4.27271L5.99997 7.87871Z' fill='%23999999' /></svg>\")}.ds-checkbox__input:indeterminate:disabled::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='14' height='4' viewBox='0 0 14 4' xmlns='http://www.w3.org/2000/svg'><rect width='13.3333' height='3' transform='matrix(1 0 0 -1 0.333313 3.5)' fill='%23999999' /></svg>\")}.ds-checkbox--no-margin .ds-checkbox__input{margin-right:0}.ds-checkbox--disabled{color:var(--ds-palette-black-40)}.ds-checkbox__span--optional{color:var(--ds-palette-black-70);font-size:var(--ds-fontSize-14)}.ds-checkbox:has(.ds-checkbox__input:disabled){cursor:not-allowed}.ds-checkbox-error{display:flex}.ds-checkbox-error--visible{padding-top:var(--ds-spacing-3xSmall);padding-left:var(--ds-spacing-xSmall)}";
|
|
9
9
|
|
|
10
10
|
const checkboxIdGenerator = idGenerator('ds-checkbox');
|
|
11
11
|
const DsCheckbox = class {
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
registerInstance(this, hostRef);
|
|
14
|
-
this.
|
|
14
|
+
this.dsChange = createEvent(this, "dsChange");
|
|
15
15
|
if (hostRef.$hostElement$["s-ei"]) {
|
|
16
16
|
this.internals = hostRef.$hostElement$["s-ei"];
|
|
17
17
|
}
|
|
@@ -20,97 +20,105 @@ const DsCheckbox = class {
|
|
|
20
20
|
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
checkboxGroup = null;
|
|
23
24
|
inputElem;
|
|
24
25
|
labelId;
|
|
25
26
|
inputValidityId;
|
|
26
27
|
assistiveTextId;
|
|
27
28
|
inheritedAttributes = {};
|
|
28
|
-
initialChecked;
|
|
29
29
|
labelClicked = false;
|
|
30
30
|
get el() { return getElement(this); }
|
|
31
31
|
internals;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
dsId = checkboxIdGenerator.next().value;
|
|
33
|
+
dsChecked = false;
|
|
34
|
+
dsLegend;
|
|
35
|
+
dsAssistiveText;
|
|
36
|
+
dsText;
|
|
37
|
+
dsIndeterminate = false;
|
|
38
|
+
dsDisabled = false;
|
|
39
|
+
dsErrorText = '';
|
|
40
|
+
dsErrorsDisabled = false;
|
|
41
|
+
dsRequired = false;
|
|
42
|
+
dsOptional = false;
|
|
43
|
+
dsOptionalText;
|
|
44
|
+
dsAriaLabel;
|
|
45
|
+
dsChange;
|
|
46
|
+
invalid = !!this.dsErrorText;
|
|
47
|
+
initialChecked = this.dsChecked;
|
|
47
48
|
validationMessage;
|
|
48
49
|
setIds = () => {
|
|
49
|
-
this.labelId = `${this.
|
|
50
|
-
this.inputValidityId = `${this.
|
|
51
|
-
this.assistiveTextId = `${this.
|
|
50
|
+
this.labelId = `${this.dsId}-label`;
|
|
51
|
+
this.inputValidityId = `${this.dsId}-validity`;
|
|
52
|
+
this.assistiveTextId = `${this.dsId}-assistive-text`;
|
|
52
53
|
};
|
|
53
|
-
getValidationMessage = () => (!this.
|
|
54
|
+
getValidationMessage = () => (!this.dsErrorsDisabled ? this.dsErrorText || this.internals?.validationMessage || this.inputElem?.validationMessage : '');
|
|
54
55
|
getLegendText = () => {
|
|
55
|
-
if (this.
|
|
56
|
-
return getRequiredText(this.
|
|
56
|
+
if (this.dsRequired) {
|
|
57
|
+
return getRequiredText(this.dsLegend);
|
|
57
58
|
}
|
|
58
|
-
if (this.
|
|
59
|
-
return getOptionalText(this.
|
|
59
|
+
if (this.dsOptional) {
|
|
60
|
+
return getOptionalText(this.dsLegend, this.dsOptionalText);
|
|
60
61
|
}
|
|
61
|
-
return this.
|
|
62
|
+
return this.dsLegend;
|
|
62
63
|
};
|
|
63
64
|
getCheckboxText = () => {
|
|
64
|
-
if (this.
|
|
65
|
-
return this.
|
|
65
|
+
if (this.dsLegend) {
|
|
66
|
+
return this.dsText;
|
|
66
67
|
}
|
|
67
|
-
if (this.
|
|
68
|
-
return getRequiredText(this.
|
|
68
|
+
if (this.dsRequired) {
|
|
69
|
+
return getRequiredText(this.dsText);
|
|
69
70
|
}
|
|
70
|
-
if (this.
|
|
71
|
-
return getOptionalText(this.
|
|
71
|
+
if (this.dsOptional) {
|
|
72
|
+
return getOptionalText(this.dsText, this.dsOptionalText);
|
|
72
73
|
}
|
|
73
|
-
return this.
|
|
74
|
-
};
|
|
75
|
-
getAriaDescribedBy = () => [Boolean(this.assistiveText) && this.assistiveTextId, Boolean(this.getValidationMessage()) && this.inputValidityId].filter(Boolean).join(' ');
|
|
76
|
-
restoreInitialState = () => {
|
|
77
|
-
this.checked = this.initialChecked;
|
|
78
|
-
this.value = this.checked.toString();
|
|
79
|
-
this.internals?.setValidity({});
|
|
80
|
-
this.internals?.setFormValue(this.value);
|
|
81
|
-
};
|
|
82
|
-
setInitialState = () => {
|
|
83
|
-
this.initialChecked = this.checked;
|
|
84
|
-
this.value = this.checked.toString();
|
|
85
|
-
this.internals?.setFormValue(this.value);
|
|
74
|
+
return this.dsText;
|
|
86
75
|
};
|
|
76
|
+
getAriaDescribedBy = () => [Boolean(this.dsAssistiveText) && this.assistiveTextId, Boolean(this.getValidationMessage()) && this.inputValidityId].filter(Boolean).join(' ');
|
|
87
77
|
formResetCallback() {
|
|
88
|
-
this.
|
|
78
|
+
this.dsChecked = this.initialChecked;
|
|
79
|
+
this.internals?.setValidity({});
|
|
80
|
+
this.internals?.setFormValue(this.dsChecked.toString());
|
|
81
|
+
}
|
|
82
|
+
connectedCallback() {
|
|
83
|
+
this.checkboxGroup = this.el.closest('ds-checkbox-group');
|
|
84
|
+
if (this.checkboxGroup) {
|
|
85
|
+
this.invalid = !!this.checkboxGroup.dsErrorText;
|
|
86
|
+
this.checkboxGroup.addEventListener('dsCheckboxGroupInvalidStateChange', this.updateInvalidState);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
disconnectedCallback() {
|
|
90
|
+
if (this.checkboxGroup) {
|
|
91
|
+
this.checkboxGroup.removeEventListener('dsCheckboxGroupInvalidStateChange', this.updateInvalidState);
|
|
92
|
+
}
|
|
93
|
+
this.checkboxGroup = null;
|
|
89
94
|
}
|
|
95
|
+
updateInvalidState = (e) => {
|
|
96
|
+
this.invalid = e.detail;
|
|
97
|
+
};
|
|
90
98
|
componentWillLoad() {
|
|
91
|
-
this.setInitialState();
|
|
92
99
|
this.setIds();
|
|
93
100
|
this.inheritedAttributes = {
|
|
94
101
|
...inheritAriaAttributes(this.el, ['aria-label', 'aria-describedby', 'aria-hidden', 'aria-invalid']),
|
|
95
102
|
...inheritAttributes(this, this.el),
|
|
96
103
|
};
|
|
97
|
-
if (isValidation('server') || this.
|
|
104
|
+
if (isValidation('server') || this.dsErrorText) {
|
|
98
105
|
this.validationMessage = this.getValidationMessage();
|
|
99
106
|
}
|
|
100
107
|
}
|
|
108
|
+
dsCheckedObserver(isChecked) {
|
|
109
|
+
this.dsChange.emit(isChecked);
|
|
110
|
+
}
|
|
101
111
|
handleInput = (e) => {
|
|
102
112
|
const target = e.target;
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
this.internals?.setFormValue(this.value);
|
|
106
|
-
this.dsCheckboxInput.emit({ id: this.identifier, checked: target.checked });
|
|
113
|
+
this.dsChecked = target.checked;
|
|
114
|
+
this.internals?.setFormValue(target.checked.toString());
|
|
107
115
|
if (isValidation('client') && this.validationMessage) {
|
|
108
116
|
this.validationMessage = this.getValidationMessage();
|
|
109
117
|
}
|
|
110
118
|
};
|
|
111
119
|
handleKeyUp = (event) => {
|
|
112
120
|
if (event.key === 'Enter') {
|
|
113
|
-
this.inputElem.
|
|
121
|
+
this.inputElem.click();
|
|
114
122
|
}
|
|
115
123
|
};
|
|
116
124
|
handleBlur = () => {
|
|
@@ -127,32 +135,35 @@ const DsCheckbox = class {
|
|
|
127
135
|
};
|
|
128
136
|
renderCheckbox() {
|
|
129
137
|
const classes = classNames('ds-checkbox', {
|
|
130
|
-
'ds-checkbox--disabled': this.
|
|
131
|
-
'ds-checkbox--no-margin': Boolean(!this.
|
|
138
|
+
'ds-checkbox--disabled': this.dsDisabled,
|
|
139
|
+
'ds-checkbox--no-margin': Boolean(!this.dsText),
|
|
132
140
|
});
|
|
133
141
|
const inputClasses = classNames('ds-checkbox__input', {
|
|
134
|
-
'ds-checkbox__input--invalid': Boolean(this.
|
|
142
|
+
'ds-checkbox__input--invalid': Boolean(this.dsErrorText) || this.invalid,
|
|
135
143
|
});
|
|
136
144
|
const errorClasses = classNames('ds-checkbox-error', {
|
|
137
145
|
'ds-checkbox-error--visible': Boolean(this.validationMessage),
|
|
138
146
|
});
|
|
139
147
|
const ariaDescribedBy = this.getAriaDescribedBy();
|
|
140
|
-
return (h(Fragment, null, h("div", null, h("label", { id: this.labelId, class: classes, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp }, h("input", { ref: inputElem => (this.inputElem = inputElem), type: "checkbox", class: inputClasses, checked: this.
|
|
148
|
+
return (h(Fragment, null, h("div", null, h("label", { id: this.labelId, class: classes, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp }, h("input", { ref: inputElem => (this.inputElem = inputElem), type: "checkbox", class: inputClasses, checked: this.dsChecked, indeterminate: this.dsIndeterminate, onInput: this.handleInput, onKeyUp: this.handleKeyUp, onBlur: this.handleBlur, value: this.dsChecked.toString(), disabled: this.dsDisabled, required: this.dsRequired, id: this.dsId, "aria-describedby": ariaDescribedBy, "aria-label": this.dsAriaLabel, "aria-invalid": this.dsErrorText ? true : undefined, ...this.inheritedAttributes }), this.getCheckboxText())), !this.dsErrorsDisabled && (h("div", { class: errorClasses }, h("ds-input-validity", { id: this.inputValidityId, dsText: this.validationMessage, dsType: "error", dsAriaLive: "polite", dsAriaAtomic: "true" })))));
|
|
141
149
|
}
|
|
142
150
|
renderFieldset() {
|
|
143
151
|
const fieldsetClasses = classNames('ds-checkbox-fieldset');
|
|
144
152
|
const legendClasses = classNames('ds-checkbox-fieldset__legend');
|
|
145
153
|
const assistiveTextClasses = classNames('ds-checkbox-fieldset__assistive-text');
|
|
146
|
-
return (h("fieldset", { class: fieldsetClasses }, h("legend", { class: legendClasses }, this.getLegendText()), this.
|
|
154
|
+
return (h("fieldset", { class: fieldsetClasses }, h("legend", { class: legendClasses }, this.getLegendText()), this.dsAssistiveText && (h("small", { class: assistiveTextClasses, id: this.assistiveTextId }, this.dsAssistiveText)), this.renderCheckbox()));
|
|
147
155
|
}
|
|
148
156
|
render() {
|
|
149
|
-
if (this.
|
|
157
|
+
if (this.dsLegend) {
|
|
150
158
|
return this.renderFieldset();
|
|
151
159
|
}
|
|
152
160
|
return this.renderCheckbox();
|
|
153
161
|
}
|
|
154
162
|
static get formAssociated() { return true; }
|
|
163
|
+
static get watchers() { return {
|
|
164
|
+
"dsChecked": ["dsCheckedObserver"]
|
|
165
|
+
}; }
|
|
155
166
|
};
|
|
156
|
-
DsCheckbox.style =
|
|
167
|
+
DsCheckbox.style = dsCheckboxCss;
|
|
157
168
|
|
|
158
169
|
export { DsCheckbox as ds_checkbox };
|