wcs-core 7.2.2 → 7.4.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/README.md +11 -9
- package/design-tokens/dist/sncf-groupe-root-scoped.css +227 -227
- package/design-tokens/dist/sncf-groupe.css +227 -227
- package/design-tokens/dist/sncf-holding-root-scoped.css +227 -227
- package/design-tokens/dist/sncf-holding.css +227 -227
- package/design-tokens/dist/sncf-reseau-root-scoped.css +227 -227
- package/design-tokens/dist/sncf-reseau.css +227 -227
- package/design-tokens/dist/sncf-voyageurs-root-scoped.css +242 -242
- package/design-tokens/dist/sncf-voyageurs.css +242 -242
- package/dist/cjs/accessibility-5f681a74.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{popper-8d6e7fca.js → popper-1b61df21.js} +10 -17
- package/dist/cjs/popper-1b61df21.js.map +1 -0
- package/dist/cjs/wcs-accordion-panel.cjs.entry.js +1 -1
- package/dist/cjs/wcs-accordion-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-accordion.cjs.entry.js +2 -1
- package/dist/cjs/wcs-accordion.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/wcs-breadcrumb.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-checkbox.cjs.entry.js +3 -2
- package/dist/cjs/wcs-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-chip.cjs.entry.js +102 -0
- package/dist/cjs/wcs-chip.cjs.entry.js.map +1 -0
- package/dist/cjs/wcs-com-nav-item.cjs.entry.js +1 -1
- package/dist/cjs/wcs-com-nav-item.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-com-nav.cjs.entry.js +3 -3
- package/dist/cjs/wcs-com-nav.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-dropdown.cjs.entry.js +1 -1
- package/dist/cjs/wcs-error_3.cjs.entry.js +1 -1
- package/dist/cjs/wcs-error_3.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-galactic-menu.cjs.entry.js +1 -1
- package/dist/cjs/wcs-grid.cjs.entry.js +5 -4
- package/dist/cjs/wcs-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-horizontal-stepper.cjs.entry.js +3 -2
- package/dist/cjs/wcs-horizontal-stepper.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-modal.cjs.entry.js +2 -2
- package/dist/cjs/wcs-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-select_2.cjs.entry.js +59 -24
- package/dist/cjs/wcs-select_2.cjs.entry.js.map +1 -1
- package/dist/cjs/wcs-tabs.cjs.entry.js +1 -1
- package/dist/cjs/wcs-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/wcs.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/accordion/accordion.e2e.playwright.js +183 -0
- package/dist/collection/components/accordion/accordion.e2e.playwright.js.map +1 -0
- package/dist/collection/components/accordion/accordion.js +2 -1
- package/dist/collection/components/accordion/accordion.js.map +1 -1
- package/dist/collection/components/accordion-panel/accordion-panel.js +3 -3
- package/dist/collection/components/accordion-panel/accordion-panel.js.map +1 -1
- package/dist/collection/components/alert/alert.e2e.playwright.js +125 -0
- package/dist/collection/components/alert/alert.e2e.playwright.js.map +1 -0
- package/dist/collection/components/alert-drawer/alert-drawer.e2e.playwright.js +107 -0
- package/dist/collection/components/alert-drawer/alert-drawer.e2e.playwright.js.map +1 -0
- package/dist/collection/components/breadcrumb/breadcrumb.e2e.playwright.js +188 -0
- package/dist/collection/components/breadcrumb/breadcrumb.e2e.playwright.js.map +1 -0
- package/dist/collection/components/breadcrumb/breadcrumb.js +2 -2
- package/dist/collection/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/collection/components/button/button.e2e.playwright.js +26 -0
- package/dist/collection/components/button/button.e2e.playwright.js.map +1 -0
- package/dist/collection/components/button/button.js +1 -1
- package/dist/collection/components/checkbox/checkbox.css +3 -0
- package/dist/collection/components/checkbox/checkbox.e2e.playwright.js +39 -0
- package/dist/collection/components/checkbox/checkbox.e2e.playwright.js.map +1 -0
- package/dist/collection/components/checkbox/checkbox.js +21 -2
- package/dist/collection/components/checkbox/checkbox.js.map +1 -1
- package/dist/collection/components/chip/chip-interface.js +2 -0
- package/dist/collection/components/chip/chip-interface.js.map +1 -0
- package/dist/collection/components/chip/chip.css +220 -0
- package/dist/collection/components/chip/chip.e2e.playwright.js +190 -0
- package/dist/collection/components/chip/chip.e2e.playwright.js.map +1 -0
- package/dist/collection/components/chip/chip.js +341 -0
- package/dist/collection/components/chip/chip.js.map +1 -0
- package/dist/collection/components/com-nav/com-nav.css +15 -0
- package/dist/collection/components/com-nav/{com-nav.e2e.js → com-nav.e2e.playwright.js} +60 -44
- package/dist/collection/components/com-nav/com-nav.e2e.playwright.js.map +1 -0
- package/dist/collection/components/com-nav/com-nav.js +3 -3
- package/dist/collection/components/com-nav/com-nav.js.map +1 -1
- package/dist/collection/components/com-nav-category/com-nav-category.js +1 -1
- package/dist/collection/components/com-nav-item/com-nav-item.css +2 -2
- package/dist/collection/components/com-nav-submenu/com-nav-submenu.js +1 -1
- package/dist/collection/components/counter/counter.e2e.playwright.js +187 -0
- package/dist/collection/components/counter/counter.e2e.playwright.js.map +1 -0
- package/dist/collection/components/counter/counter.js +1 -1
- package/dist/collection/components/dropdown/dropdown.e2e.playwright.js +320 -0
- package/dist/collection/components/dropdown/dropdown.e2e.playwright.js.map +1 -0
- package/dist/collection/components/dropdown/dropdown.js +1 -1
- package/dist/collection/components/editable-field/editable-field.e2e.playwright.js +156 -0
- package/dist/collection/components/editable-field/editable-field.e2e.playwright.js.map +1 -0
- package/dist/collection/components/form-field/form-field.e2e.playwright.js +104 -0
- package/dist/collection/components/form-field/form-field.e2e.playwright.js.map +1 -0
- package/dist/collection/components/galactic-menu/galactic-menu.js +1 -1
- package/dist/collection/components/grid/grid.e2e.playwright.js +153 -0
- package/dist/collection/components/grid/grid.e2e.playwright.js.map +1 -0
- package/dist/collection/components/grid/grid.js +6 -5
- package/dist/collection/components/grid/grid.js.map +1 -1
- package/dist/collection/components/grid-column/grid-column.js +1 -1
- package/dist/collection/components/grid-pagination/grid-pagination.js +1 -1
- package/dist/collection/components/header/header.js +1 -1
- package/dist/collection/components/horizontal-stepper/horizontal-step.js +2 -1
- package/dist/collection/components/horizontal-stepper/horizontal-step.js.map +1 -1
- package/dist/collection/components/horizontal-stepper/horizontal-stepper-interface.js.map +1 -1
- package/dist/collection/components/horizontal-stepper/horizontal-stepper.js +5 -1
- package/dist/collection/components/horizontal-stepper/horizontal-stepper.js.map +1 -1
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/input/input.e2e.playwright.js +157 -0
- package/dist/collection/components/input/input.e2e.playwright.js.map +1 -0
- package/dist/collection/components/input/input.js +2 -2
- package/dist/collection/components/label/label.css +4 -6
- package/dist/collection/components/label/label.js +1 -1
- package/dist/collection/components/mat-icon/mat-icon.js +1 -1
- package/dist/collection/components/modal/modal.css +4 -0
- package/dist/collection/components/modal/modal.e2e.playwright.js +35 -0
- package/dist/collection/components/modal/modal.e2e.playwright.js.map +1 -0
- package/dist/collection/components/modal/modal.js +2 -2
- package/dist/collection/components/modal/modal.js.map +1 -1
- package/dist/collection/components/native-select/native-select.js +1 -1
- package/dist/collection/components/nav/nav.js +1 -1
- package/dist/collection/components/progress-bar/progress-bar.js +1 -1
- package/dist/collection/components/progress-radial/progress-radial.js +1 -1
- package/dist/collection/components/radio/radio.js +1 -1
- package/dist/collection/components/radio-group/radio-group.e2e.playwright.js +231 -0
- package/dist/collection/components/radio-group/radio-group.e2e.playwright.js.map +1 -0
- package/dist/collection/components/radio-group/radio-group.js +1 -1
- package/dist/collection/components/select/select.e2e.playwright.js +1702 -0
- package/dist/collection/components/select/select.e2e.playwright.js.map +1 -0
- package/dist/collection/components/select/select.js +49 -20
- package/dist/collection/components/select/select.js.map +1 -1
- package/dist/collection/components/select-option/select-option.js +3 -3
- package/dist/collection/components/select-option/select-option.js.map +1 -1
- package/dist/collection/components/switch/switch.e2e.playwright.js +40 -0
- package/dist/collection/components/switch/switch.e2e.playwright.js.map +1 -0
- package/dist/collection/components/switch/switch.js +1 -1
- package/dist/collection/components/tabs/tabs.e2e.playwright.js +205 -0
- package/dist/collection/components/tabs/tabs.e2e.playwright.js.map +1 -0
- package/dist/collection/components/tabs/tabs.js +1 -1
- package/dist/collection/components/textarea/textarea.e2e.playwright.js +133 -0
- package/dist/collection/components/textarea/textarea.e2e.playwright.js.map +1 -0
- package/dist/collection/components/textarea/textarea.js +1 -1
- package/dist/collection/utils/accessibility.js +16 -0
- package/dist/collection/utils/accessibility.js.map +1 -1
- package/dist/collection/utils/playwright/test-expect.js +2 -0
- package/dist/collection/utils/playwright/test-expect.js.map +1 -0
- package/dist/collection/utils/playwright/test.js +16 -0
- package/dist/collection/utils/playwright/test.js.map +1 -0
- package/dist/esm/accessibility-069640cf.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{popper-e491c314.js → popper-ac238961.js} +10 -17
- package/dist/esm/popper-ac238961.js.map +1 -0
- package/dist/esm/wcs-accordion-panel.entry.js +1 -1
- package/dist/esm/wcs-accordion-panel.entry.js.map +1 -1
- package/dist/esm/wcs-accordion.entry.js +2 -1
- package/dist/esm/wcs-accordion.entry.js.map +1 -1
- package/dist/esm/wcs-breadcrumb.entry.js +1 -1
- package/dist/esm/wcs-breadcrumb.entry.js.map +1 -1
- package/dist/esm/wcs-checkbox.entry.js +3 -2
- package/dist/esm/wcs-checkbox.entry.js.map +1 -1
- package/dist/esm/wcs-chip.entry.js +98 -0
- package/dist/esm/wcs-chip.entry.js.map +1 -0
- package/dist/esm/wcs-com-nav-item.entry.js +1 -1
- package/dist/esm/wcs-com-nav-item.entry.js.map +1 -1
- package/dist/esm/wcs-com-nav.entry.js +3 -3
- package/dist/esm/wcs-com-nav.entry.js.map +1 -1
- package/dist/esm/wcs-dropdown.entry.js +1 -1
- package/dist/esm/wcs-error_3.entry.js +1 -1
- package/dist/esm/wcs-error_3.entry.js.map +1 -1
- package/dist/esm/wcs-galactic-menu.entry.js +1 -1
- package/dist/esm/wcs-grid.entry.js +5 -4
- package/dist/esm/wcs-grid.entry.js.map +1 -1
- package/dist/esm/wcs-horizontal-stepper.entry.js +3 -2
- package/dist/esm/wcs-horizontal-stepper.entry.js.map +1 -1
- package/dist/esm/wcs-modal.entry.js +2 -2
- package/dist/esm/wcs-modal.entry.js.map +1 -1
- package/dist/esm/wcs-select_2.entry.js +59 -24
- package/dist/esm/wcs-select_2.entry.js.map +1 -1
- package/dist/esm/wcs-tabs.entry.js +1 -1
- package/dist/esm/wcs-tooltip.entry.js +1 -1
- package/dist/esm/wcs.js +1 -1
- package/dist/types/components/accordion/accordion.e2e.playwright.d.ts +1 -0
- package/dist/types/components/accordion-panel/accordion-panel.d.ts +5 -0
- package/dist/types/components/alert/alert.e2e.playwright.d.ts +1 -0
- package/dist/types/components/alert-drawer/alert-drawer.e2e.playwright.d.ts +1 -0
- package/dist/types/components/breadcrumb/breadcrumb.e2e.playwright.d.ts +1 -0
- package/dist/types/components/button/button.e2e.playwright.d.ts +1 -0
- package/dist/types/components/checkbox/checkbox.d.ts +4 -0
- package/dist/types/components/checkbox/checkbox.e2e.playwright.d.ts +1 -0
- package/dist/types/components/chip/chip-interface.d.ts +4 -0
- package/dist/types/components/chip/chip.d.ts +132 -0
- package/dist/types/components/chip/chip.e2e.playwright.d.ts +1 -0
- package/dist/types/components/com-nav/com-nav.e2e.playwright.d.ts +1 -0
- package/dist/types/components/counter/counter.e2e.playwright.d.ts +1 -0
- package/dist/types/components/dropdown/dropdown.e2e.playwright.d.ts +1 -0
- package/dist/types/components/editable-field/editable-field.e2e.playwright.d.ts +1 -0
- package/dist/types/components/form-field/form-field.e2e.playwright.d.ts +1 -0
- package/dist/types/components/grid/grid.e2e.playwright.d.ts +1 -0
- package/dist/types/components/horizontal-stepper/horizontal-stepper-interface.d.ts +2 -0
- package/dist/types/components/horizontal-stepper/horizontal-stepper.d.ts +4 -0
- package/dist/types/components/input/input.e2e.playwright.d.ts +1 -0
- package/dist/types/components/modal/modal.e2e.playwright.d.ts +1 -0
- package/dist/types/components/radio-group/radio-group.e2e.playwright.d.ts +1 -0
- package/dist/types/components/select/select.d.ts +7 -1
- package/dist/types/components/select/select.e2e.playwright.d.ts +1 -0
- package/dist/types/components/switch/switch.e2e.playwright.d.ts +1 -0
- package/dist/types/components/tabs/tabs.e2e.playwright.d.ts +1 -0
- package/dist/types/components/textarea/textarea.e2e.playwright.d.ts +1 -0
- package/dist/types/components.d.ts +354 -0
- package/dist/types/utils/accessibility.d.ts +7 -0
- package/dist/types/utils/playwright/test-expect.d.ts +33 -0
- package/dist/types/utils/playwright/test.d.ts +7 -0
- package/dist/wcs/{p-8e9bd0f1.entry.js → p-0326f834.entry.js} +2 -2
- package/dist/wcs/{p-8e9bd0f1.entry.js.map → p-0326f834.entry.js.map} +1 -1
- package/dist/wcs/p-2221bf0c.entry.js +16 -0
- package/dist/wcs/p-2221bf0c.entry.js.map +1 -0
- package/dist/wcs/p-4ae08567.entry.js +2 -0
- package/dist/wcs/p-4ae08567.entry.js.map +1 -0
- package/dist/wcs/p-4e2d6227.entry.js +2 -0
- package/dist/wcs/p-4e2d6227.entry.js.map +1 -0
- package/dist/wcs/p-828b45b4.entry.js +2 -0
- package/dist/wcs/p-828b45b4.entry.js.map +1 -0
- package/dist/wcs/p-8332a7e3.entry.js +2 -0
- package/dist/wcs/p-8332a7e3.entry.js.map +1 -0
- package/dist/wcs/p-990698a7.entry.js +2 -0
- package/dist/wcs/p-990698a7.entry.js.map +1 -0
- package/dist/wcs/{p-ec383729.entry.js → p-9b76b8e6.entry.js} +2 -2
- package/dist/wcs/{p-ec383729.entry.js.map → p-9b76b8e6.entry.js.map} +1 -1
- package/dist/wcs/{p-1f593d06.entry.js → p-abd8d5a0.entry.js} +2 -2
- package/dist/wcs/{p-622f7403.entry.js → p-c6f8c45c.entry.js} +2 -2
- package/dist/wcs/{p-a94e685c.entry.js → p-db7ba599.entry.js} +2 -2
- package/dist/wcs/p-e1fb3625.js +2 -0
- package/dist/wcs/p-e1fb3625.js.map +1 -0
- package/dist/wcs/p-ed3b0709.entry.js +2 -0
- package/dist/wcs/p-ed3b0709.entry.js.map +1 -0
- package/dist/wcs/{p-6c6079ee.entry.js → p-f2eeb249.entry.js} +2 -2
- package/dist/wcs/{p-6c6079ee.entry.js.map → p-f2eeb249.entry.js.map} +1 -1
- package/dist/wcs/{p-a956dc84.entry.js → p-f2f7595e.entry.js} +2 -2
- package/dist/wcs/{p-a956dc84.entry.js.map → p-f2f7595e.entry.js.map} +1 -1
- package/dist/wcs/p-fb2751c2.js.map +1 -1
- package/dist/wcs/p-fbd68522.entry.js +2 -0
- package/dist/wcs/p-fbd68522.entry.js.map +1 -0
- package/dist/wcs/{p-8c2605fd.entry.js → p-fe303f58.entry.js} +2 -2
- package/dist/wcs/wcs.esm.js +1 -1
- package/dist/wcs/wcs.esm.js.map +1 -1
- package/package.json +18 -24
- package/dist/cjs/popper-8d6e7fca.js.map +0 -1
- package/dist/collection/components/alert/alert.e2e.js +0 -142
- package/dist/collection/components/alert/alert.e2e.js.map +0 -1
- package/dist/collection/components/alert-drawer/alert-drawer.e2e.js +0 -111
- package/dist/collection/components/alert-drawer/alert-drawer.e2e.js.map +0 -1
- package/dist/collection/components/breadcrumb/breadcrumb.e2e.js +0 -223
- package/dist/collection/components/breadcrumb/breadcrumb.e2e.js.map +0 -1
- package/dist/collection/components/button/button.e2e.js +0 -25
- package/dist/collection/components/button/button.e2e.js.map +0 -1
- package/dist/collection/components/checkbox/checkbox.e2e.js +0 -45
- package/dist/collection/components/checkbox/checkbox.e2e.js.map +0 -1
- package/dist/collection/components/com-nav/com-nav.e2e.js.map +0 -1
- package/dist/collection/components/counter/counter.e2e.js +0 -206
- package/dist/collection/components/counter/counter.e2e.js.map +0 -1
- package/dist/collection/components/dropdown/dropdown.e2e.js +0 -156
- package/dist/collection/components/dropdown/dropdown.e2e.js.map +0 -1
- package/dist/collection/components/editable-field/editable-field.e2e.js +0 -176
- package/dist/collection/components/editable-field/editable-field.e2e.js.map +0 -1
- package/dist/collection/components/form-field/form-field.e2e.js +0 -122
- package/dist/collection/components/form-field/form-field.e2e.js.map +0 -1
- package/dist/collection/components/grid/grid.e2e.js +0 -147
- package/dist/collection/components/grid/grid.e2e.js.map +0 -1
- package/dist/collection/components/input/input.e2e.js +0 -152
- package/dist/collection/components/input/input.e2e.js.map +0 -1
- package/dist/collection/components/modal/modal.e2e.js +0 -36
- package/dist/collection/components/modal/modal.e2e.js.map +0 -1
- package/dist/collection/components/radio-group/radio-group.e2e.js +0 -239
- package/dist/collection/components/radio-group/radio-group.e2e.js.map +0 -1
- package/dist/collection/components/select/select.e2e.js +0 -1081
- package/dist/collection/components/select/select.e2e.js.map +0 -1
- package/dist/collection/components/switch/switch.e2e.js +0 -45
- package/dist/collection/components/switch/switch.e2e.js.map +0 -1
- package/dist/collection/components/tabs/tabs.e2e.js +0 -207
- package/dist/collection/components/tabs/tabs.e2e.js.map +0 -1
- package/dist/collection/components/textarea/textarea.e2e.js +0 -132
- package/dist/collection/components/textarea/textarea.e2e.js.map +0 -1
- package/dist/collection/utils/tests.js +0 -23
- package/dist/collection/utils/tests.js.map +0 -1
- package/dist/esm/popper-e491c314.js.map +0 -1
- package/dist/types/utils/tests.d.ts +0 -4
- package/dist/wcs/p-02f31010.entry.js +0 -2
- package/dist/wcs/p-02f31010.entry.js.map +0 -1
- package/dist/wcs/p-0dd07842.entry.js +0 -2
- package/dist/wcs/p-0dd07842.entry.js.map +0 -1
- package/dist/wcs/p-0f864e86.js +0 -2
- package/dist/wcs/p-0f864e86.js.map +0 -1
- package/dist/wcs/p-1244daa0.entry.js +0 -2
- package/dist/wcs/p-1244daa0.entry.js.map +0 -1
- package/dist/wcs/p-1fbe0328.entry.js +0 -2
- package/dist/wcs/p-1fbe0328.entry.js.map +0 -1
- package/dist/wcs/p-4fb2d985.entry.js +0 -2
- package/dist/wcs/p-4fb2d985.entry.js.map +0 -1
- package/dist/wcs/p-b94a09b6.entry.js +0 -16
- package/dist/wcs/p-b94a09b6.entry.js.map +0 -1
- package/dist/wcs/p-fd187bce.entry.js +0 -2
- package/dist/wcs/p-fd187bce.entry.js.map +0 -1
- /package/dist/wcs/{p-1f593d06.entry.js.map → p-abd8d5a0.entry.js.map} +0 -0
- /package/dist/wcs/{p-622f7403.entry.js.map → p-c6f8c45c.entry.js.map} +0 -0
- /package/dist/wcs/{p-a94e685c.entry.js.map → p-db7ba599.entry.js.map} +0 -0
- /package/dist/wcs/{p-8c2605fd.entry.js.map → p-fe303f58.entry.js.map} +0 -0
|
@@ -53,6 +53,7 @@ export class Checkbox {
|
|
|
53
53
|
this.name = this.checkboxId;
|
|
54
54
|
this.indeterminate = false;
|
|
55
55
|
this.checked = false;
|
|
56
|
+
this.required = false;
|
|
56
57
|
this.labelAlignment = 'center';
|
|
57
58
|
this.disabled = false;
|
|
58
59
|
}
|
|
@@ -117,7 +118,7 @@ export class Checkbox {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
render() {
|
|
120
|
-
return (h(Host, { key: '
|
|
121
|
+
return (h(Host, { key: '84af94b1e903c4a7a44d7c216b122faa1d67c125' }, h("label", { key: 'df9cd51e804a3d07dcd9698b98492f868747a5ef', htmlFor: this.name, class: "wcs-container", "aria-disabled": this.disabled }, h("input", Object.assign({ key: '68d52bb45b20bd37dfab4845e7a664b0a5e65e49', onBlur: this.handleBlur.bind(this), onChange: this.handleChange.bind(this), onFocus: this.handleFocus.bind(this), onClick: this.handleInputClick.bind(this), checked: this.checked, class: "wcs-checkbox", type: "checkbox", ref: (el) => (this.nativeInput = el), name: this.name, disabled: this.disabled, id: this.name }, this.inheritedAttributes)), h("span", { key: '506c869a0bcbf742422e7b2029e8862687cbf286', class: "wcs-checkmark" }), h("span", { key: '81e8130a3f3eed1d02d0bf075f5793b0e12a64ae', class: "text" }, h("slot", { key: '97387419d47b55af6c4911df5aeaa2bcd89f750c', onSlotchange: (_) => this.onSlotChange() })))));
|
|
121
122
|
}
|
|
122
123
|
static get is() { return "wcs-checkbox"; }
|
|
123
124
|
static get encapsulation() { return "shadow"; }
|
|
@@ -188,6 +189,24 @@ export class Checkbox {
|
|
|
188
189
|
"reflect": true,
|
|
189
190
|
"defaultValue": "false"
|
|
190
191
|
},
|
|
192
|
+
"required": {
|
|
193
|
+
"type": "boolean",
|
|
194
|
+
"mutable": false,
|
|
195
|
+
"complexType": {
|
|
196
|
+
"original": "boolean",
|
|
197
|
+
"resolved": "boolean",
|
|
198
|
+
"references": {}
|
|
199
|
+
},
|
|
200
|
+
"required": false,
|
|
201
|
+
"optional": false,
|
|
202
|
+
"docs": {
|
|
203
|
+
"tags": [],
|
|
204
|
+
"text": "If `true`, the user must fill in a value before submitting a form."
|
|
205
|
+
},
|
|
206
|
+
"attribute": "required",
|
|
207
|
+
"reflect": false,
|
|
208
|
+
"defaultValue": "false"
|
|
209
|
+
},
|
|
191
210
|
"labelAlignment": {
|
|
192
211
|
"type": "string",
|
|
193
212
|
"mutable": true,
|
|
@@ -303,7 +322,7 @@ export class Checkbox {
|
|
|
303
322
|
"signature": "(attr: AriaAttributeName, value: string | null | undefined) => Promise<void>",
|
|
304
323
|
"parameters": [{
|
|
305
324
|
"name": "attr",
|
|
306
|
-
"type": "
|
|
325
|
+
"type": "`aria-${string}` | \"role\"",
|
|
307
326
|
"docs": ""
|
|
308
327
|
}, {
|
|
309
328
|
"name": "value",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../../src/components/checkbox/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,IAAI,EACJ,KAAK,EAGL,CAAC,EACD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACT,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,qBAAqB,E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{\n Component,\n Prop,\n Event,\n EventEmitter,\n ComponentInterface,\n h,\n Host,\n Method,\n Element,\n Listen\n} from '@stencil/core';\nimport { CheckboxChangeEventDetail, CheckboxLabelAlignment } from './checkbox-interface';\nimport { AriaAttributeName, MutableAriaAttribute } from \"../../utils/mutable-aria-attribute\";\nimport { inheritAriaAttributes, inheritAttributes, setOrRemoveAttribute } from \"../../utils/helpers\";\nimport { ControlComponentWithLabel, getSlottedContentText } from \"../../utils/control-component-interface\";\n\nconst CHECKBOX_INHERITED_ATTRS = ['tabindex', 'title'];\n\n/**\n * The checkbox component is an input for choosing one or more items from a set by checking / unchecking it.\n * \n * @cssprop --wcs-checkbox-border-color-default - Default color of the border\n * @cssprop --wcs-checkbox-border-color-hover - Color of the border when hovered\n * @cssprop --wcs-checkbox-border-color-disabled - Color of the border when disabled\n * @cssprop --wcs-checkbox-border-color-selected - Color of the border when selected\n * @cssprop --wcs-checkbox-border-color-indeterminate - Color of the border when indeterminate\n * \n * @cssprop --wcs-checkbox-border-radius - Border radius of the checkbox\n * @cssprop --wcs-checkbox-border-width - Width of the border of the checkbox\n * \n * @cssprop --wcs-checkbox-size - Size of the checkbox\n * \n * @cssprop --wcs-checkbox-text-color-default - Color of the text when the checkbox is not selected\n * @cssprop --wcs-checkbox-text-color-disabled - Color of the text when the checkbox is disabled\n * @cssprop --wcs-checkbox-text-color-hover - Color of the text when the checkbox is hovered\n * @cssprop --wcs-checkbox-text-color-selected - Color of the text when the checkbox is selected\n * \n * @cssprop --wcs-checkbox-text-font-size - Font size of the text\n * @cssprop --wcs-checkbox-text-font-weight - Font weight of the text\n * \n * @cssprop --wcs-checkbox-background-color-default - Default background color of the checkbox\n * @cssprop --wcs-checkbox-background-color-hover - Background color of the checkbox when hovered\n * @cssprop --wcs-checkbox-background-color-disabled - Background color of the checkbox when disabled\n * @cssprop --wcs-checkbox-background-color-selected - Background color of the checkbox when selected\n * @cssprop --wcs-checkbox-background-color-indeterminate - Background color of the checkbox when indeterminate\n * \n * @cssprop --wcs-checkbox-outline-radius-focus - Border radius of the focus outline\n * @cssprop --wcs-checkbox-outline-color-focus - Color of the focus outline\n * \n * @cssprop --wcs-checkbox-gap - Gap between the checkbox and the label\n * @cssprop --wcs-checkmark-color - Color of the checkmark\n * @cssprop --wcs-checkmark-height - Height of the checkmark (From the bottom left to the top right of the checkmark)\n * @cssprop --wcs-checkmark-width - Width of the checkmark (From the bottom right to the top left of the checkmark)\n * @cssprop --wcs-checkmark-border-width - Width of the border of the checkmark\n *\n * @cssprop --wcs-indeterminate-bar-width - Width of the indeterminate bar\n * @cssprop --wcs-indeterminate-bar-height - Height of the indeterminate bar\n * @cssprop --wcs-indeterminate-bar-border-radius - Border-radius of the indeterminate bar\n * @cssprop --wcs-indeterminate-bar-background-color - Color of the indeterminate bar\n * \n * @cssprop --wcs-checkbox-transition-duration - Duration of the transition\n */\n@Component({\n tag: 'wcs-checkbox',\n styleUrl: 'checkbox.scss',\n shadow: {\n delegatesFocus: true,\n },\n})\nexport class Checkbox implements ComponentInterface, MutableAriaAttribute, ControlComponentWithLabel {\n @Element() private el!: HTMLElement;\n private nativeInput!: HTMLInputElement;\n private inheritedAttributes: { [k: string]: any } = {};\n private checkboxId = `wcs-checkbox-${checkboxIds++}`;\n\n @Prop() name = this.checkboxId;\n /**\n * If `true` the checkbox is in indeterminate state.\n */\n @Prop({ reflect: true, mutable: true }) indeterminate: boolean = false;\n\n /**\n * If `true`, the checkbox is selected.\n */\n @Prop({ reflect: true, mutable: true }) checked: boolean = false;\n\n /**\n * Specifie the alignment of the checkbox with the label content\n */\n @Prop({ mutable: true, reflect: true }) labelAlignment: CheckboxLabelAlignment = 'center';\n\n /**\n * Specify whether the checkbox is disabled or not.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * Emitted when the checked property has changed.\n */\n @Event() wcsChange!: EventEmitter<CheckboxChangeEventDetail>;\n\n /**\n * Emitted when the checkbox has focus.\n */\n @Event() wcsFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event() wcsBlur!: EventEmitter<FocusEvent>;\n\n componentWillLoad(): Promise<void> | void {\n this.inheritedAttributes = {\n ...inheritAriaAttributes(this.el),\n ...inheritAttributes(this.el, CHECKBOX_INHERITED_ATTRS),\n };\n }\n\n componentDidLoad() {\n this.onSlotChange();\n }\n\n @Method()\n async setAriaAttribute(attr: AriaAttributeName, value: string | null | undefined) {\n setOrRemoveAttribute(this.nativeInput, attr, value);\n }\n\n @Method()\n async getLabel(): Promise<string> {\n return getSlottedContentText(this.el);\n }\n\n handleChange(e: Event) {\n e.stopImmediatePropagation();\n e.preventDefault();\n this.toggleCheckboxState();\n }\n \n @Listen('click')\n async handleHostClick(e: Event){\n e.preventDefault();\n e.stopPropagation();\n \n this.toggleCheckboxState();\n }\n\n handleInputClick(ev: PointerEvent) {\n // If the click event is coming from the mouse we ignore it.\n // We only want to handle the keyboard interactions as it is the only purpose of this native input\n if (ev.detail) {\n ev.stopImmediatePropagation()\n ev.preventDefault();\n }\n }\n\n toggleCheckboxState() {\n if (this.disabled) return;\n \n this.indeterminate = false;\n this.checked = !this.checked;\n this.wcsChange.emit({\n checked: this.checked,\n });\n }\n \n handleFocus(event: FocusEvent) {\n this.wcsFocus.emit(event);\n }\n\n handleBlur(event: FocusEvent) {\n this.wcsBlur.emit(event);\n }\n\n onSlotChange() { \n const slot = this.el.shadowRoot.querySelector('slot');\n if (slot) {\n // TODO: remove when pseudo-class that indicate a slot has content is supported in all major browsers \n // (https://github.com/w3c/csswg-drafts/issues/6867)\n // https://developer.mozilla.org/en-US/docs/Web/CSS/:empty\n const assignedNodes = slot.assignedNodes();\n if (assignedNodes.length > 0) {\n this.el.shadowRoot.querySelector('.text').classList.remove('hidden');\n } else {\n this.el.shadowRoot.querySelector('.text').classList.add('hidden');\n }\n }\n }\n \n render() {\n return (\n <Host>\n <label htmlFor={this.name} class=\"wcs-container\" aria-disabled={this.disabled}>\n <input\n onBlur={this.handleBlur.bind(this)}\n onChange={this.handleChange.bind(this)}\n onFocus={this.handleFocus.bind(this)}\n onClick={this.handleInputClick.bind(this)}\n checked={this.checked}\n class=\"wcs-checkbox\"\n type=\"checkbox\"\n ref={(el) => (this.nativeInput = el)}\n name={this.name}\n disabled={this.disabled}\n id={this.name}\n {...this.inheritedAttributes}\n ></input>\n <span class=\"wcs-checkmark\"></span>\n <span class=\"text\">\n <slot onSlotchange={(_) => this.onSlotChange()} />\n </span>\n </label>\n </Host>\n );\n }\n}\n\nlet checkboxIds = 0;\n"]}
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../../src/components/checkbox/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,IAAI,EACJ,KAAK,EAGL,CAAC,EACD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACT,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAA6B,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAE3G,MAAM,wBAAwB,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAQH,MAAM,OAAO,QAAQ;;QAGT,wBAAmB,GAAyB,EAAE,CAAC;QAC/C,eAAU,GAAG,gBAAgB,WAAW,EAAE,EAAE,CAAC;oBAEtC,IAAI,CAAC,UAAU;6BAImC,KAAK;uBAKX,KAAK;wBAKpC,KAAK;8BAKgD,QAAQ;wBAK5C,KAAK;;IAiBlD,iBAAiB;QACb,IAAI,CAAC,mBAAmB,mCACjB,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,GAC9B,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,wBAAwB,CAAC,CAC1D,CAAC;IACN,CAAC;IAED,gBAAgB;QACZ,IAAI,CAAC,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C,QAAQ,EACvB,EAAE,EAAE,IAAI,CAAC,IAAI,IACT,IAAI,CAAC,mBAAmB,EACvB;gBACT,6DAAM,KAAK,EAAC,eAAe,GAAQ;gBACnC,6DAAM,KAAK,EAAC,MAAM;oBACd,6DAAM,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,GAAI,CAC/C,CACH,CACL,CACV,CAAC;IACN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ;AAED,IAAI,WAAW,GAAG,CAAC,CAAC","sourcesContent":["import {\n Component,\n Prop,\n Event,\n EventEmitter,\n ComponentInterface,\n h,\n Host,\n Method,\n Element,\n Listen\n} from '@stencil/core';\nimport { CheckboxChangeEventDetail, CheckboxLabelAlignment } from './checkbox-interface';\nimport { AriaAttributeName, MutableAriaAttribute } from \"../../utils/mutable-aria-attribute\";\nimport { inheritAriaAttributes, inheritAttributes, setOrRemoveAttribute } from \"../../utils/helpers\";\nimport { ControlComponentWithLabel, getSlottedContentText } from \"../../utils/control-component-interface\";\n\nconst CHECKBOX_INHERITED_ATTRS = ['tabindex', 'title'];\n\n/**\n * The checkbox component is an input for choosing one or more items from a set by checking / unchecking it.\n * \n * @cssprop --wcs-checkbox-border-color-default - Default color of the border\n * @cssprop --wcs-checkbox-border-color-hover - Color of the border when hovered\n * @cssprop --wcs-checkbox-border-color-disabled - Color of the border when disabled\n * @cssprop --wcs-checkbox-border-color-selected - Color of the border when selected\n * @cssprop --wcs-checkbox-border-color-indeterminate - Color of the border when indeterminate\n * \n * @cssprop --wcs-checkbox-border-radius - Border radius of the checkbox\n * @cssprop --wcs-checkbox-border-width - Width of the border of the checkbox\n * \n * @cssprop --wcs-checkbox-size - Size of the checkbox\n * \n * @cssprop --wcs-checkbox-text-color-default - Color of the text when the checkbox is not selected\n * @cssprop --wcs-checkbox-text-color-disabled - Color of the text when the checkbox is disabled\n * @cssprop --wcs-checkbox-text-color-hover - Color of the text when the checkbox is hovered\n * @cssprop --wcs-checkbox-text-color-selected - Color of the text when the checkbox is selected\n * \n * @cssprop --wcs-checkbox-text-font-size - Font size of the text\n * @cssprop --wcs-checkbox-text-font-weight - Font weight of the text\n * \n * @cssprop --wcs-checkbox-background-color-default - Default background color of the checkbox\n * @cssprop --wcs-checkbox-background-color-hover - Background color of the checkbox when hovered\n * @cssprop --wcs-checkbox-background-color-disabled - Background color of the checkbox when disabled\n * @cssprop --wcs-checkbox-background-color-selected - Background color of the checkbox when selected\n * @cssprop --wcs-checkbox-background-color-indeterminate - Background color of the checkbox when indeterminate\n * \n * @cssprop --wcs-checkbox-outline-radius-focus - Border radius of the focus outline\n * @cssprop --wcs-checkbox-outline-color-focus - Color of the focus outline\n * \n * @cssprop --wcs-checkbox-gap - Gap between the checkbox and the label\n * @cssprop --wcs-checkmark-color - Color of the checkmark\n * @cssprop --wcs-checkmark-height - Height of the checkmark (From the bottom left to the top right of the checkmark)\n * @cssprop --wcs-checkmark-width - Width of the checkmark (From the bottom right to the top left of the checkmark)\n * @cssprop --wcs-checkmark-border-width - Width of the border of the checkmark\n *\n * @cssprop --wcs-indeterminate-bar-width - Width of the indeterminate bar\n * @cssprop --wcs-indeterminate-bar-height - Height of the indeterminate bar\n * @cssprop --wcs-indeterminate-bar-border-radius - Border-radius of the indeterminate bar\n * @cssprop --wcs-indeterminate-bar-background-color - Color of the indeterminate bar\n * \n * @cssprop --wcs-checkbox-transition-duration - Duration of the transition\n */\n@Component({\n tag: 'wcs-checkbox',\n styleUrl: 'checkbox.scss',\n shadow: {\n delegatesFocus: true,\n },\n})\nexport class Checkbox implements ComponentInterface, MutableAriaAttribute, ControlComponentWithLabel {\n @Element() private el!: HTMLElement;\n private nativeInput!: HTMLInputElement;\n private inheritedAttributes: { [k: string]: any } = {};\n private checkboxId = `wcs-checkbox-${checkboxIds++}`;\n\n @Prop() name = this.checkboxId;\n /**\n * If `true` the checkbox is in indeterminate state.\n */\n @Prop({ reflect: true, mutable: true }) indeterminate: boolean = false;\n\n /**\n * If `true`, the checkbox is selected.\n */\n @Prop({ reflect: true, mutable: true }) checked: boolean = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required: boolean = false\n\n /**\n * Specifie the alignment of the checkbox with the label content\n */\n @Prop({ mutable: true, reflect: true }) labelAlignment: CheckboxLabelAlignment = 'center';\n\n /**\n * Specify whether the checkbox is disabled or not.\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * Emitted when the checked property has changed.\n */\n @Event() wcsChange!: EventEmitter<CheckboxChangeEventDetail>;\n\n /**\n * Emitted when the checkbox has focus.\n */\n @Event() wcsFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event() wcsBlur!: EventEmitter<FocusEvent>;\n\n componentWillLoad(): Promise<void> | void {\n this.inheritedAttributes = {\n ...inheritAriaAttributes(this.el),\n ...inheritAttributes(this.el, CHECKBOX_INHERITED_ATTRS),\n };\n }\n\n componentDidLoad() {\n this.onSlotChange();\n }\n\n @Method()\n async setAriaAttribute(attr: AriaAttributeName, value: string | null | undefined) {\n setOrRemoveAttribute(this.nativeInput, attr, value);\n }\n\n @Method()\n async getLabel(): Promise<string> {\n return getSlottedContentText(this.el);\n }\n\n handleChange(e: Event) {\n e.stopImmediatePropagation();\n e.preventDefault();\n this.toggleCheckboxState();\n }\n \n @Listen('click')\n async handleHostClick(e: Event){\n e.preventDefault();\n e.stopPropagation();\n \n this.toggleCheckboxState();\n }\n\n handleInputClick(ev: PointerEvent) {\n // If the click event is coming from the mouse we ignore it.\n // We only want to handle the keyboard interactions as it is the only purpose of this native input\n if (ev.detail) {\n ev.stopImmediatePropagation()\n ev.preventDefault();\n }\n }\n\n toggleCheckboxState() {\n if (this.disabled) return;\n \n this.indeterminate = false;\n this.checked = !this.checked;\n this.wcsChange.emit({\n checked: this.checked,\n });\n }\n \n handleFocus(event: FocusEvent) {\n this.wcsFocus.emit(event);\n }\n\n handleBlur(event: FocusEvent) {\n this.wcsBlur.emit(event);\n }\n\n onSlotChange() { \n const slot = this.el.shadowRoot.querySelector('slot');\n if (slot) {\n // TODO: remove when pseudo-class that indicate a slot has content is supported in all major browsers \n // (https://github.com/w3c/csswg-drafts/issues/6867)\n // https://developer.mozilla.org/en-US/docs/Web/CSS/:empty\n const assignedNodes = slot.assignedNodes();\n if (assignedNodes.length > 0) {\n this.el.shadowRoot.querySelector('.text').classList.remove('hidden');\n } else {\n this.el.shadowRoot.querySelector('.text').classList.add('hidden');\n }\n }\n }\n \n render() {\n return (\n <Host>\n <label htmlFor={this.name} class=\"wcs-container\" aria-disabled={this.disabled}>\n <input\n onBlur={this.handleBlur.bind(this)}\n onChange={this.handleChange.bind(this)}\n onFocus={this.handleFocus.bind(this)}\n onClick={this.handleInputClick.bind(this)}\n checked={this.checked}\n class=\"wcs-checkbox\"\n type=\"checkbox\"\n ref={(el) => (this.nativeInput = el)}\n name={this.name}\n disabled={this.disabled}\n id={this.name}\n {...this.inheritedAttributes}\n ></input>\n <span class=\"wcs-checkmark\"></span>\n <span class=\"text\">\n <slot onSlotchange={(_) => this.onSlotChange()} />\n </span>\n </label>\n </Host>\n );\n }\n}\n\nlet checkboxIds = 0;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip-interface.js","sourceRoot":"","sources":["../../../src/components/chip/chip-interface.ts"],"names":[],"mappings":"","sourcesContent":["import { WcsSize } from '../../shared-types';\n\nexport type WcsChipMode = 'selectable' | 'dismissible';\nexport type WcsChipSize = Extract<WcsSize, 's'>;\nexport type WcsChipVariant = 'primary' | 'secondary';\n"]}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Applies all the outline properties useful to show a dashed-focus ring around a component.
|
|
3
|
+
TODO: replace `$border-radius: 0.1rem` with semantic border-radius but keep in mind some components that must stay at 2px border-radius: checkbox, radio, links, ...
|
|
4
|
+
*/
|
|
5
|
+
:host {
|
|
6
|
+
--wcs-chip-height: var(--wcs-semantic-size-s);
|
|
7
|
+
--wcs-chip-font-size: var(--wcs-semantic-font-size-base);
|
|
8
|
+
--wcs-chip-font-weight: var(--wcs-semantic-font-weight-medium);
|
|
9
|
+
--wcs-chip-focus-outline-border-width: var(--wcs-semantic-border-width-large);
|
|
10
|
+
--wcs-chip-padding-vertical: var(--wcs-semantic-spacing-base);
|
|
11
|
+
--wcs-chip-padding-horizontal: var(--wcs-semantic-spacing-base-150);
|
|
12
|
+
--wcs-chip-padding-horizontal-dismissible: var(--wcs-semantic-spacing-base);
|
|
13
|
+
--wcs-chip-selectable-background-color: var(--wcs-semantic-color-background-action-secondary-default);
|
|
14
|
+
--wcs-chip-selectable-background-color-pressed: var(--wcs-semantic-color-background-action-secondary-press);
|
|
15
|
+
--wcs-chip-selectable-background-color-hover: var(--wcs-semantic-color-background-action-secondary-hover);
|
|
16
|
+
--wcs-chip-selectable-background-color-selected: var(--wcs-semantic-color-background-action-primary-default);
|
|
17
|
+
--wcs-chip-selectable-background-color-selected-hover: var(--wcs-semantic-color-background-action-primary-hover);
|
|
18
|
+
--wcs-chip-selectable-background-color-selected-pressed: var(--wcs-semantic-color-background-action-primary-press);
|
|
19
|
+
--wcs-chip-selectable-background-color-selected-disabled: var(--wcs-semantic-color-background-action-primary-disabled);
|
|
20
|
+
--wcs-chip-selectable-color: var(--wcs-semantic-color-foreground-action-secondary-default);
|
|
21
|
+
--wcs-chip-selectable-color-hover: var(--wcs-semantic-color-foreground-action-secondary-hover);
|
|
22
|
+
--wcs-chip-selectable-color-pressed: var(--wcs-semantic-color-foreground-action-secondary-press);
|
|
23
|
+
--wcs-chip-selectable-color-disabled: var(--wcs-semantic-color-text-disabled);
|
|
24
|
+
--wcs-chip-selectable-color-selected: var(--wcs-semantic-color-foreground-action-primary-default);
|
|
25
|
+
--wcs-chip-selectable-color-selected-hover: var(--wcs-semantic-color-foreground-action-primary-hover);
|
|
26
|
+
--wcs-chip-selectable-color-selected-pressed: var(--wcs-semantic-color-foreground-action-primary-press);
|
|
27
|
+
--wcs-chip-border-radius: var(--wcs-semantic-border-radius-base);
|
|
28
|
+
--wcs-chip-border-line-width: var(--wcs-semantic-border-width-default);
|
|
29
|
+
--wcs-chip-selectable-border-color: var(--wcs-semantic-color-border-action-secondary-default);
|
|
30
|
+
--wcs-chip-selectable-border-color-hover: var(--wcs-semantic-color-border-control-indicator-hover);
|
|
31
|
+
--wcs-chip-selectable-border-color-pressed: var(--wcs-semantic-color-border-action-secondary-press);
|
|
32
|
+
--wcs-chip-selectable-border-color-disabled: var(--wcs-semantic-color-border-action-secondary-disabled);
|
|
33
|
+
--wcs-chip-selectable-content-gap: var(--wcs-semantic-spacing-base);
|
|
34
|
+
--wcs-chip-selectable-focus-outline-color: var(--wcs-semantic-color-border-focus-base);
|
|
35
|
+
--wcs-chip-dismissible-content-gap: var(--wcs-semantic-spacing-base-05);
|
|
36
|
+
--wcs-chip-dismissible-padding-right: var(--wcs-semantic-spacing-base-05);
|
|
37
|
+
--wcs-chip-dismissible-button-outline-radius: var(--wcs-semantic-border-radius-full);
|
|
38
|
+
--wcs-chip-dismissible-primary-focus-outline-color: var(--wcs-semantic-color-border-focus-base-on-secondary);
|
|
39
|
+
--wcs-chip-dismissible-primary-border-color: var(--wcs-semantic-color-background-action-primary-default);
|
|
40
|
+
--wcs-chip-dismissible-primary-border-color-disabled: var(--wcs-semantic-color-background-action-primary-disabled);
|
|
41
|
+
--wcs-chip-dismissible-primary-color: var(--wcs-semantic-color-foreground-action-primary-default);
|
|
42
|
+
--wcs-chip-dismissible-primary-color-hover: var(--wcs-semantic-color-foreground-action-primary-hover);
|
|
43
|
+
--wcs-chip-dismissible-primary-color-pressed: var(--wcs-semantic-color-foreground-action-primary-press);
|
|
44
|
+
--wcs-chip-dismissible-primary-color-disabled: var(--wcs-semantic-color-text-disabled);
|
|
45
|
+
--wcs-chip-dismissible-primary-background-color: var(--wcs-semantic-color-background-action-primary-default);
|
|
46
|
+
--wcs-chip-dismissible-primary-background-color-hover: var(--wcs-semantic-color-background-action-primary-hover);
|
|
47
|
+
--wcs-chip-dismissible-primary-background-color-pressed: var(--wcs-semantic-color-background-action-primary-press);
|
|
48
|
+
--wcs-chip-dismissible-primary-background-color-disabled: var(--wcs-semantic-color-background-action-primary-disabled);
|
|
49
|
+
--wcs-chip-dismissible-secondary-button-focus-outline-color: var(--wcs-semantic-color-border-focus-base);
|
|
50
|
+
--wcs-chip-dismissible-secondary-border-color: var(--wcs-semantic-color-border-action-secondary-default);
|
|
51
|
+
--wcs-chip-dismissible-secondary-border-color-disabled: var(--wcs-semantic-color-border-action-secondary-disabled);
|
|
52
|
+
--wcs-chip-dismissible-secondary-color: var(--wcs-semantic-color-foreground-action-secondary-default);
|
|
53
|
+
--wcs-chip-dismissible-secondary-color-disabled: var(--wcs-semantic-color-foreground-disabled);
|
|
54
|
+
--wcs-chip-dismissible-secondary-background-color: var(--wcs-semantic-color-background-action-secondary-default);
|
|
55
|
+
--wcs-chip-dismissible-secondary-button-background-color: var(--wcs-semantic-color-background-action-secondary-default);
|
|
56
|
+
--wcs-chip-dismissible-secondary-button-background-color-hover: var(--wcs-semantic-color-background-surface-accent-lighter);
|
|
57
|
+
--wcs-chip-dismissible-secondary-button-background-color-pressed: var(--wcs-semantic-color-background-surface-accent-light);
|
|
58
|
+
--wcs-chip-dismissible-secondary-button-background-color-disabled: var(--wcs-semantic-color-background-action-secondary-disabled);
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
vertical-align: middle;
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
height: var(--wcs-chip-height);
|
|
65
|
+
border-radius: var(--wcs-chip-border-radius);
|
|
66
|
+
font-size: var(--wcs-chip-font-size);
|
|
67
|
+
font-weight: var(--wcs-chip-font-weight);
|
|
68
|
+
padding: var(--wcs-chip-padding-vertical) var(--wcs-chip-padding-horizontal);
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
user-select: none;
|
|
71
|
+
transition-property: color, background-color;
|
|
72
|
+
transition-duration: var(--wcs-semantic-motion-duration-feedback-base);
|
|
73
|
+
transition-timing-function: ease-out;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([mode=selectable]) {
|
|
77
|
+
gap: var(--wcs-chip-selectable-content-gap);
|
|
78
|
+
border: solid var(--wcs-chip-border-line-width) var(--wcs-chip-selectable-border-color);
|
|
79
|
+
background-color: var(--wcs-chip-selectable-background-color);
|
|
80
|
+
color: var(--wcs-chip-selectable-color);
|
|
81
|
+
}
|
|
82
|
+
:host([mode=selectable]):host(:focus-visible) {
|
|
83
|
+
outline: var(--wcs-chip-focus-outline-border-width) dashed var(--wcs-chip-selectable-focus-outline-color);
|
|
84
|
+
outline-offset: var(--wcs-semantic-spacing-small);
|
|
85
|
+
border-radius: var(--wcs-chip-border-radius);
|
|
86
|
+
}
|
|
87
|
+
:host([mode=selectable]):host(:not([disabled])):host(:not([selected])):host(:hover) {
|
|
88
|
+
background-color: var(--wcs-chip-selectable-background-color-hover);
|
|
89
|
+
color: var(--wcs-chip-selectable-color-hover);
|
|
90
|
+
border-color: var(--wcs-chip-selectable-border-color-hover);
|
|
91
|
+
}
|
|
92
|
+
:host([mode=selectable]):host(:not([disabled])):host(:not([selected])):host(:active) {
|
|
93
|
+
background-color: var(--wcs-chip-selectable-background-color-pressed);
|
|
94
|
+
color: var(--wcs-chip-selectable-color-pressed);
|
|
95
|
+
border-color: var(--wcs-chip-selectable-border-color-pressed);
|
|
96
|
+
}
|
|
97
|
+
:host([mode=selectable]):host(:not([disabled])):host([selected]) {
|
|
98
|
+
color: var(--wcs-chip-selectable-color-selected);
|
|
99
|
+
background-color: var(--wcs-chip-selectable-background-color-selected);
|
|
100
|
+
border-color: transparent;
|
|
101
|
+
}
|
|
102
|
+
:host([mode=selectable]):host(:not([disabled])):host([selected]) svg path {
|
|
103
|
+
fill: var(--wcs-chip-selectable-color-selected);
|
|
104
|
+
transform: translateY(-1.5px);
|
|
105
|
+
}
|
|
106
|
+
:host([mode=selectable]):host(:not([disabled])):host([selected]):host(:hover) {
|
|
107
|
+
background-color: var(--wcs-chip-selectable-background-color-selected-hover);
|
|
108
|
+
color: var(--wcs-chip-selectable-color-selected-hover);
|
|
109
|
+
}
|
|
110
|
+
:host([mode=selectable]):host(:not([disabled])):host([selected]):host(:hover) svg path {
|
|
111
|
+
fill: var(--wcs-chip-selectable-color-selected-hover);
|
|
112
|
+
}
|
|
113
|
+
:host([mode=selectable]):host(:not([disabled])):host([selected]):host(:active) {
|
|
114
|
+
background-color: var(--wcs-chip-selectable-background-color-selected-pressed);
|
|
115
|
+
color: var(--wcs-chip-selectable-color-selected-pressed);
|
|
116
|
+
}
|
|
117
|
+
:host([mode=selectable]):host(:not([disabled])):host([selected]):host(:active) svg path {
|
|
118
|
+
fill: var(--wcs-chip-selectable-color-selected-pressed);
|
|
119
|
+
}
|
|
120
|
+
:host([mode=selectable]):host([disabled]) {
|
|
121
|
+
color: var(--wcs-chip-selectable-color-disabled);
|
|
122
|
+
cursor: not-allowed;
|
|
123
|
+
}
|
|
124
|
+
:host([mode=selectable]):host([disabled]) svg path {
|
|
125
|
+
fill: var(--wcs-chip-selectable-color-disabled);
|
|
126
|
+
}
|
|
127
|
+
:host([mode=selectable]):host([disabled]):host(:not([selected])) {
|
|
128
|
+
border-color: var(--wcs-chip-selectable-border-color-disabled);
|
|
129
|
+
}
|
|
130
|
+
:host([mode=selectable]):host([disabled]):host([selected]) {
|
|
131
|
+
background-color: var(--wcs-chip-selectable-background-color-selected-disabled);
|
|
132
|
+
border: 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
:host([mode=dismissible]) {
|
|
136
|
+
cursor: initial;
|
|
137
|
+
border: solid var(--wcs-chip-border-line-width) var(--wcs-chip-dismissible-primary-border-color);
|
|
138
|
+
color: var(--wcs-chip-dismissible-primary-color);
|
|
139
|
+
background-color: var(--wcs-chip-dismissible-primary-background-color);
|
|
140
|
+
gap: var(--wcs-chip-dismissible-content-gap);
|
|
141
|
+
padding-right: var(--wcs-chip-dismissible-padding-right);
|
|
142
|
+
}
|
|
143
|
+
:host([mode=dismissible]) button {
|
|
144
|
+
background: transparent;
|
|
145
|
+
border: none;
|
|
146
|
+
margin: 0;
|
|
147
|
+
padding: 0;
|
|
148
|
+
border-radius: var(--wcs-semantic-border-radius-full);
|
|
149
|
+
display: inline-flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
justify-content: center;
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
color: inherit;
|
|
154
|
+
width: var(--wcs-semantic-size-xs);
|
|
155
|
+
height: var(--wcs-semantic-size-xs);
|
|
156
|
+
}
|
|
157
|
+
:host([mode=dismissible]) button:focus {
|
|
158
|
+
outline: none;
|
|
159
|
+
}
|
|
160
|
+
:host([mode=dismissible]) button:focus svg {
|
|
161
|
+
outline: var(--wcs-chip-focus-outline-border-width) dashed var(--wcs-chip-dismissible-primary-focus-outline-color);
|
|
162
|
+
outline-offset: var(--wcs-semantic-spacing-small);
|
|
163
|
+
border-radius: var(--wcs-chip-dismissible-button-outline-radius);
|
|
164
|
+
}
|
|
165
|
+
:host([mode=dismissible]):host(:not([open])) {
|
|
166
|
+
display: none;
|
|
167
|
+
margin: 0;
|
|
168
|
+
}
|
|
169
|
+
:host([mode=dismissible]):host(:not([disabled])) button:hover {
|
|
170
|
+
background-color: var(--wcs-chip-dismissible-primary-background-color-hover);
|
|
171
|
+
color: var(--wcs-chip-dismissible-primary-color-hover);
|
|
172
|
+
}
|
|
173
|
+
:host([mode=dismissible]):host(:not([disabled])) button:active {
|
|
174
|
+
background-color: var(--wcs-chip-dismissible-primary-background-color-pressed);
|
|
175
|
+
color: var(--wcs-chip-dismissible-primary-color-pressed);
|
|
176
|
+
}
|
|
177
|
+
:host([mode=dismissible]):host([disabled]) {
|
|
178
|
+
color: var(--wcs-chip-dismissible-primary-color-disabled);
|
|
179
|
+
background-color: var(--wcs-chip-dismissible-primary-background-color-disabled);
|
|
180
|
+
cursor: not-allowed;
|
|
181
|
+
border: solid var(--wcs-chip-border-line-width) var(--wcs-chip-dismissible-primary-border-color-disabled);
|
|
182
|
+
}
|
|
183
|
+
:host([mode=dismissible]):host([disabled]) svg {
|
|
184
|
+
cursor: not-allowed;
|
|
185
|
+
}
|
|
186
|
+
:host([mode=dismissible]):host([disabled]) svg path {
|
|
187
|
+
fill: var(--wcs-chip-dismissible-primary-color-disabled);
|
|
188
|
+
}
|
|
189
|
+
:host([mode=dismissible]):host([variant=secondary]) {
|
|
190
|
+
color: var(--wcs-chip-dismissible-secondary-color);
|
|
191
|
+
background-color: var(--wcs-chip-dismissible-secondary-background-color);
|
|
192
|
+
border: solid var(--wcs-chip-border-line-width) var(--wcs-chip-dismissible-secondary-border-color);
|
|
193
|
+
}
|
|
194
|
+
:host([mode=dismissible]):host([variant=secondary]) button {
|
|
195
|
+
background: var(--wcs-chip-dismissible-secondary-button-background-color);
|
|
196
|
+
}
|
|
197
|
+
:host([mode=dismissible]):host([variant=secondary]) button:focus {
|
|
198
|
+
outline: none;
|
|
199
|
+
}
|
|
200
|
+
:host([mode=dismissible]):host([variant=secondary]) button:focus svg {
|
|
201
|
+
outline: var(--wcs-chip-focus-outline-border-width) dashed var(--wcs-chip-dismissible-secondary-button-focus-outline-color);
|
|
202
|
+
outline-offset: var(--wcs-semantic-spacing-small);
|
|
203
|
+
border-radius: var(--wcs-chip-dismissible-button-outline-radius);
|
|
204
|
+
}
|
|
205
|
+
:host([mode=dismissible]):host([variant=secondary]):host(:not([disabled])) button:hover {
|
|
206
|
+
background-color: var(--wcs-chip-dismissible-secondary-button-background-color-hover);
|
|
207
|
+
color: var(--wcs-chip-dismissible-secondary-button-color-hover);
|
|
208
|
+
}
|
|
209
|
+
:host([mode=dismissible]):host([variant=secondary]):host(:not([disabled])) button:active {
|
|
210
|
+
background-color: var(--wcs-chip-dismissible-secondary-button-background-color-pressed);
|
|
211
|
+
color: var(--wcs-chip-dismissible-secondary-button-color-pressed);
|
|
212
|
+
}
|
|
213
|
+
:host([mode=dismissible]):host([variant=secondary]):host([disabled]) {
|
|
214
|
+
color: var(--wcs-chip-dismissible-secondary-color-disabled);
|
|
215
|
+
background-color: var(--wcs-chip-dismissible-secondary-background-color-disabled);
|
|
216
|
+
border: solid var(--wcs-chip-border-line-width) var(--wcs-chip-dismissible-secondary-border-color-disabled);
|
|
217
|
+
}
|
|
218
|
+
:host([mode=dismissible]):host([variant=secondary]):host([disabled]) svg path {
|
|
219
|
+
fill: var(--wcs-chip-dismissible-secondary-color-disabled);
|
|
220
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { setWcsContent } from "../../utils/playwright/test";
|
|
2
|
+
import { test } from "@stencil/playwright";
|
|
3
|
+
import { expect } from "@playwright/test";
|
|
4
|
+
test.describe('Chip component', () => {
|
|
5
|
+
test.describe('Events', () => {
|
|
6
|
+
test('should emit wcsChipSelectChange with selected=true on click (selectable by default)', async ({ page }) => {
|
|
7
|
+
// Given
|
|
8
|
+
await setWcsContent(page, `
|
|
9
|
+
<wcs-chip value="chip-id" label="Chip"></wcs-chip>
|
|
10
|
+
`);
|
|
11
|
+
const chip = page.locator('wcs-chip');
|
|
12
|
+
const wcsChipSelectChangeEventSpy = await chip.spyOnEvent('wcsChipSelectChange');
|
|
13
|
+
// When
|
|
14
|
+
await chip.click();
|
|
15
|
+
await page.waitForChanges();
|
|
16
|
+
// Then
|
|
17
|
+
expect(wcsChipSelectChangeEventSpy).toHaveReceivedEventDetail({ value: 'chip-id', selected: true });
|
|
18
|
+
});
|
|
19
|
+
test('should toggle selection and emit on Space/Enter (selectable)', async ({ page }) => {
|
|
20
|
+
// Given
|
|
21
|
+
await setWcsContent(page, `
|
|
22
|
+
<wcs-chip value="chip-id" label="Chip"></wcs-chip>
|
|
23
|
+
`);
|
|
24
|
+
const chip = page.locator('wcs-chip');
|
|
25
|
+
const wcsChipSelectChangeEventSpy = await chip.spyOnEvent('wcsChipSelectChange');
|
|
26
|
+
// When - Space selects
|
|
27
|
+
await chip.focus();
|
|
28
|
+
await chip.press('Space');
|
|
29
|
+
// When - Enter toggles back
|
|
30
|
+
await chip.press('Enter');
|
|
31
|
+
await page.waitForChanges();
|
|
32
|
+
// Then
|
|
33
|
+
expect(wcsChipSelectChangeEventSpy).toHaveReceivedEventTimes(2);
|
|
34
|
+
expect(wcsChipSelectChangeEventSpy).toHaveNthReceivedEventDetail(1, { value: 'chip-id', selected: false });
|
|
35
|
+
});
|
|
36
|
+
test('should emit wcsChipDismiss when clicking dismiss button (dismissible)', async ({ page }) => {
|
|
37
|
+
// Given
|
|
38
|
+
await setWcsContent(page, `
|
|
39
|
+
<wcs-chip mode="dismissible" value="chip-id" label="Chip"></wcs-chip>
|
|
40
|
+
`);
|
|
41
|
+
const chip = page.locator('wcs-chip');
|
|
42
|
+
const wcsChipDismissEventSpy = await chip.spyOnEvent('wcsChipDismiss');
|
|
43
|
+
const dismissBtn = page.locator('wcs-chip button');
|
|
44
|
+
// When
|
|
45
|
+
await dismissBtn.click();
|
|
46
|
+
await page.waitForChanges();
|
|
47
|
+
// Then
|
|
48
|
+
expect(wcsChipDismissEventSpy).toHaveReceivedEventDetail({ value: 'chip-id' });
|
|
49
|
+
// open prop should be false -> attribute removed
|
|
50
|
+
await expect(chip).not.toHaveAttribute('open');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
test.describe('Keyboard', () => {
|
|
54
|
+
test('Delete/Backspace on dismiss button dismisses the chip', async ({ page }) => {
|
|
55
|
+
// Given
|
|
56
|
+
await setWcsContent(page, `
|
|
57
|
+
<wcs-chip mode="dismissible" value="chip-id" label="Chip"></wcs-chip>
|
|
58
|
+
`);
|
|
59
|
+
const chip = page.locator('wcs-chip');
|
|
60
|
+
const wcsChipDismissEventSpy = await chip.spyOnEvent('wcsChipDismiss');
|
|
61
|
+
const dismissBtn = page.locator('wcs-chip button');
|
|
62
|
+
// When
|
|
63
|
+
await dismissBtn.focus();
|
|
64
|
+
await page.keyboard.press('Delete');
|
|
65
|
+
await page.waitForChanges();
|
|
66
|
+
// Then
|
|
67
|
+
await expect(wcsChipDismissEventSpy).toHaveReceivedEventTimes(1);
|
|
68
|
+
await expect(chip).not.toHaveAttribute('open');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
test.describe('Accessibility', () => {
|
|
72
|
+
test('exposes proper ARIA for selectable: role=checkbox, aria-checked toggles, tabindex respects disabled', async ({ page }) => {
|
|
73
|
+
// Given
|
|
74
|
+
await setWcsContent(page, `
|
|
75
|
+
<wcs-chip value="chip-id" label="Chip"></wcs-chip>
|
|
76
|
+
`);
|
|
77
|
+
const chip = page.locator('wcs-chip');
|
|
78
|
+
// Then default
|
|
79
|
+
await expect(chip).toHaveAttribute('role', 'checkbox');
|
|
80
|
+
await expect(chip).toHaveAttribute('aria-checked', 'false');
|
|
81
|
+
await expect(chip).toHaveAttribute('tabindex', '0');
|
|
82
|
+
// When
|
|
83
|
+
await chip.click();
|
|
84
|
+
await page.waitForChanges();
|
|
85
|
+
// Then toggled
|
|
86
|
+
await expect(chip).toHaveAttribute('aria-checked', 'true');
|
|
87
|
+
});
|
|
88
|
+
test('exposes proper ARIA/disabled for dismissible: button has label and respects disabled', async ({ page }) => {
|
|
89
|
+
// Given
|
|
90
|
+
await setWcsContent(page, `
|
|
91
|
+
<wcs-chip mode="dismissible" value="chip-id" label="Chip"></wcs-chip>
|
|
92
|
+
`);
|
|
93
|
+
const chip = page.locator('wcs-chip');
|
|
94
|
+
const btn = page.locator('wcs-chip button');
|
|
95
|
+
// Then
|
|
96
|
+
await expect(btn).toHaveAttribute('aria-label', 'Supprimer Chip');
|
|
97
|
+
// When disabled
|
|
98
|
+
await chip.evaluate((el) => el.disabled = true);
|
|
99
|
+
await page.waitForChanges();
|
|
100
|
+
// Then
|
|
101
|
+
await expect(chip).toHaveAttribute('aria-disabled', 'true');
|
|
102
|
+
await expect(btn).toBeDisabled();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
test.describe('Disabled state', () => {
|
|
106
|
+
test('does not emit select event when disabled (click and Space)', async ({ page }) => {
|
|
107
|
+
// Given
|
|
108
|
+
await setWcsContent(page, `
|
|
109
|
+
<wcs-chip disabled value="chip-id" label="Chip"></wcs-chip>
|
|
110
|
+
`);
|
|
111
|
+
const chip = page.locator('wcs-chip');
|
|
112
|
+
const wcsChipSelectChangeEventSpy = await chip.spyOnEvent('wcsChipSelectChange');
|
|
113
|
+
// When
|
|
114
|
+
await chip.click({ force: true });
|
|
115
|
+
await chip.press('Space');
|
|
116
|
+
await page.waitForChanges();
|
|
117
|
+
// Then
|
|
118
|
+
expect(wcsChipSelectChangeEventSpy).toHaveReceivedEventTimes(0);
|
|
119
|
+
await expect(chip).toHaveAttribute('tabindex', '-1');
|
|
120
|
+
await expect(chip).toHaveAttribute('aria-checked', 'false');
|
|
121
|
+
});
|
|
122
|
+
test('does not emit dismiss event when disabled', async ({ page }) => {
|
|
123
|
+
// Given
|
|
124
|
+
await setWcsContent(page, `
|
|
125
|
+
<wcs-chip disabled mode="dismissible" value="chip-id" label="Chip"></wcs-chip>
|
|
126
|
+
`);
|
|
127
|
+
const chip = page.locator('wcs-chip');
|
|
128
|
+
const wcsChipDismissEventSpy = await chip.spyOnEvent('wcsChipDismiss');
|
|
129
|
+
const btn = page.locator('wcs-chip button');
|
|
130
|
+
// When
|
|
131
|
+
await btn.click({ force: true });
|
|
132
|
+
await page.waitForChanges();
|
|
133
|
+
// Then
|
|
134
|
+
expect(wcsChipDismissEventSpy).toHaveReceivedEventTimes(0);
|
|
135
|
+
await expect(chip).toHaveAttribute('open', '');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
test.describe('Focus management', () => {
|
|
139
|
+
test('after dismiss, focus moves to next actionable chip (selectable host)', async ({ page }) => {
|
|
140
|
+
// Given
|
|
141
|
+
await setWcsContent(page, `
|
|
142
|
+
<div>
|
|
143
|
+
<wcs-chip id="c1" mode="dismissible" value="c1" label="One"></wcs-chip>
|
|
144
|
+
<wcs-chip id="c2" value="c2" label="Two"></wcs-chip>
|
|
145
|
+
</div>
|
|
146
|
+
`);
|
|
147
|
+
const btn = page.locator('#c1 button');
|
|
148
|
+
// When
|
|
149
|
+
await btn.click();
|
|
150
|
+
await page.waitForChanges();
|
|
151
|
+
// Then
|
|
152
|
+
const c2 = page.locator('#c2');
|
|
153
|
+
await expect(c2).toBeFocused();
|
|
154
|
+
});
|
|
155
|
+
test('after dismiss, focus moves to next actionable chip (dismissable host)', async ({ page }) => {
|
|
156
|
+
// Given
|
|
157
|
+
await setWcsContent(page, `
|
|
158
|
+
<div>
|
|
159
|
+
<wcs-chip id="c1" mode="dismissible" value="c1" label="One"></wcs-chip>
|
|
160
|
+
<wcs-chip id="c2" mode="dismissible" value="c2" label="Two"></wcs-chip>
|
|
161
|
+
</div>
|
|
162
|
+
`);
|
|
163
|
+
const c1 = page.locator('#c1 button');
|
|
164
|
+
// When
|
|
165
|
+
await c1.click();
|
|
166
|
+
await page.waitForChanges();
|
|
167
|
+
// Then
|
|
168
|
+
const c2 = page.locator('#c2');
|
|
169
|
+
await expect(c2).toBeFocused();
|
|
170
|
+
});
|
|
171
|
+
test('skips disabled chips when moving focus after dismiss', async ({ page }) => {
|
|
172
|
+
// Given
|
|
173
|
+
await setWcsContent(page, `
|
|
174
|
+
<div>
|
|
175
|
+
<wcs-chip id="c1" mode="dismissible" value="c1" label="One"></wcs-chip>
|
|
176
|
+
<wcs-chip id="c2" disabled value="c2" label="Two"></wcs-chip>
|
|
177
|
+
<wcs-chip id="c3" value="c3" label="Three"></wcs-chip>
|
|
178
|
+
</div>
|
|
179
|
+
`);
|
|
180
|
+
const btn = page.locator('#c1 button');
|
|
181
|
+
// When
|
|
182
|
+
await btn.click();
|
|
183
|
+
await page.waitForChanges();
|
|
184
|
+
// Then
|
|
185
|
+
const c3 = page.locator('#c3');
|
|
186
|
+
await expect(c3).toBeFocused();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=chip.e2e.playwright.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip.e2e.playwright.js","sourceRoot":"","sources":["../../../src/components/chip/chip.e2e.playwright.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAW,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IACjC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;QACzB,IAAI,CAAC,qFAAqF,EAAE,KAAK,EAAE,EAAE,IAAI,EAAqB,EAAE,EAAE;YAC9H,QAAQ;YACR,MAAM,aAAa,CAAC,IAAI,EAAE;;aAEzB,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACtC,MAAM,2BAA2B,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;YAEjF,OAAO;YACP,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAE5B,OAAO;YACP,MAAM,CAAC,2BAA2B,CAAC,CAAC,yBAAyB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACxG,CAAC,CAAC,CAAC;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AC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC/B,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,sDAAsD,EAAE,KAAK,EAAE,EAAE,IAAI,EAAqB,EAAE,EAAE;YAC/F,QAAQ;YACR,MAAM,aAAa,CAAC,IAAI,EAAE;;;;;;aAMzB,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAEvC,OAAO;YACP,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAE5B,OAAO;YACP,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC/B,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { setWcsContent } from '../../utils/playwright/test';\nimport { test, E2EPage } from \"@stencil/playwright\";\n\nimport { expect } from \"@playwright/test\";\n\ntest.describe('Chip component', () => {\n test.describe('Events', () => {\n test('should emit wcsChipSelectChange with selected=true on click (selectable by default)', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n const wcsChipSelectChangeEventSpy = await chip.spyOnEvent('wcsChipSelectChange');\n\n // When\n await chip.click();\n await page.waitForChanges();\n\n // Then\n expect(wcsChipSelectChangeEventSpy).toHaveReceivedEventDetail({ value: 'chip-id', selected: true });\n });\n\n test('should toggle selection and emit on Space/Enter (selectable)', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n const wcsChipSelectChangeEventSpy = await chip.spyOnEvent('wcsChipSelectChange');\n\n // When - Space selects\n await chip.focus();\n await chip.press('Space');\n // When - Enter toggles back\n await chip.press('Enter');\n await page.waitForChanges();\n\n // Then\n expect(wcsChipSelectChangeEventSpy).toHaveReceivedEventTimes(2);\n expect(wcsChipSelectChangeEventSpy).toHaveNthReceivedEventDetail(1, { value: 'chip-id', selected: false });\n });\n\n test('should emit wcsChipDismiss when clicking dismiss button (dismissible)', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip mode=\"dismissible\" value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n const wcsChipDismissEventSpy = await chip.spyOnEvent('wcsChipDismiss');\n const dismissBtn = page.locator('wcs-chip button');\n\n // When\n await dismissBtn.click();\n await page.waitForChanges();\n\n // Then\n expect(wcsChipDismissEventSpy).toHaveReceivedEventDetail({ value: 'chip-id' });\n // open prop should be false -> attribute removed\n await expect(chip).not.toHaveAttribute('open');\n });\n });\n\n test.describe('Keyboard', () => {\n test('Delete/Backspace on dismiss button dismisses the chip', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip mode=\"dismissible\" value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n const wcsChipDismissEventSpy = await chip.spyOnEvent('wcsChipDismiss');\n const dismissBtn = page.locator('wcs-chip button');\n\n // When\n await dismissBtn.focus();\n await page.keyboard.press('Delete');\n await page.waitForChanges();\n\n // Then\n await expect(wcsChipDismissEventSpy).toHaveReceivedEventTimes(1);\n await expect(chip).not.toHaveAttribute('open');\n });\n });\n\n test.describe('Accessibility', () => {\n test('exposes proper ARIA for selectable: role=checkbox, aria-checked toggles, tabindex respects disabled', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n\n // Then default\n await expect(chip).toHaveAttribute('role', 'checkbox');\n await expect(chip).toHaveAttribute('aria-checked', 'false');\n await expect(chip).toHaveAttribute('tabindex', '0');\n\n // When\n await chip.click();\n await page.waitForChanges();\n\n // Then toggled\n await expect(chip).toHaveAttribute('aria-checked', 'true');\n });\n\n test('exposes proper ARIA/disabled for dismissible: button has label and respects disabled', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip mode=\"dismissible\" value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n const btn = page.locator('wcs-chip button');\n\n // Then\n await expect(btn).toHaveAttribute('aria-label', 'Supprimer Chip');\n\n // When disabled\n await chip.evaluate((el: any) => el.disabled = true);\n await page.waitForChanges();\n\n // Then\n await expect(chip).toHaveAttribute('aria-disabled', 'true');\n await expect(btn).toBeDisabled();\n });\n });\n\n test.describe('Disabled state', () => {\n test('does not emit select event when disabled (click and Space)', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip disabled value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n const wcsChipSelectChangeEventSpy = await chip.spyOnEvent('wcsChipSelectChange');\n\n // When\n await chip.click({ force: true });\n await chip.press('Space');\n await page.waitForChanges();\n\n // Then\n expect(wcsChipSelectChangeEventSpy).toHaveReceivedEventTimes(0);\n await expect(chip).toHaveAttribute('tabindex', '-1');\n await expect(chip).toHaveAttribute('aria-checked', 'false');\n });\n\n test('does not emit dismiss event when disabled', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <wcs-chip disabled mode=\"dismissible\" value=\"chip-id\" label=\"Chip\"></wcs-chip>\n `);\n\n const chip = page.locator('wcs-chip');\n const wcsChipDismissEventSpy = await chip.spyOnEvent('wcsChipDismiss');\n const btn = page.locator('wcs-chip button');\n\n // When\n await btn.click({ force: true });\n await page.waitForChanges();\n\n // Then\n expect(wcsChipDismissEventSpy).toHaveReceivedEventTimes(0);\n await expect(chip).toHaveAttribute('open', '');\n });\n });\n\n test.describe('Focus management', () => {\n test('after dismiss, focus moves to next actionable chip (selectable host)', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <div>\n <wcs-chip id=\"c1\" mode=\"dismissible\" value=\"c1\" label=\"One\"></wcs-chip>\n <wcs-chip id=\"c2\" value=\"c2\" label=\"Two\"></wcs-chip>\n </div>\n `);\n\n const btn = page.locator('#c1 button');\n\n // When\n await btn.click();\n await page.waitForChanges();\n\n // Then\n const c2 = page.locator('#c2');\n await expect(c2).toBeFocused();\n });\n\n test('after dismiss, focus moves to next actionable chip (dismissable host)', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <div>\n <wcs-chip id=\"c1\" mode=\"dismissible\" value=\"c1\" label=\"One\"></wcs-chip>\n <wcs-chip id=\"c2\" mode=\"dismissible\" value=\"c2\" label=\"Two\"></wcs-chip>\n </div>\n `);\n\n const c1 = page.locator('#c1 button');\n\n // When\n await c1.click();\n await page.waitForChanges();\n\n // Then\n const c2 = page.locator('#c2');\n await expect(c2).toBeFocused();\n });\n\n test('skips disabled chips when moving focus after dismiss', async ({ page }: { page: E2EPage }) => {\n // Given\n await setWcsContent(page, `\n <div>\n <wcs-chip id=\"c1\" mode=\"dismissible\" value=\"c1\" label=\"One\"></wcs-chip>\n <wcs-chip id=\"c2\" disabled value=\"c2\" label=\"Two\"></wcs-chip>\n <wcs-chip id=\"c3\" value=\"c3\" label=\"Three\"></wcs-chip>\n </div>\n `);\n\n const btn = page.locator('#c1 button');\n\n // When\n await btn.click();\n await page.waitForChanges();\n\n // Then\n const c3 = page.locator('#c3');\n await expect(c3).toBeFocused();\n });\n });\n});\n"]}
|