@warp-ds/elements 2.2.0-next.1 → 2.2.0-next.11
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 +27 -17
- package/dist/.storybook/utilities.d.ts +28 -0
- package/dist/.storybook/utilities.js +52 -0
- package/dist/api.js +1 -49
- package/dist/api.js.map +4 -4
- package/dist/custom-elements.json +4282 -0
- package/dist/packages/affix/affix.stories.d.ts +10 -0
- package/dist/packages/affix/affix.stories.js +25 -0
- package/dist/packages/affix/affix.test.d.ts +1 -0
- package/dist/packages/affix/affix.test.js +9 -0
- package/dist/packages/affix/index.d.ts +52 -24
- package/dist/packages/affix/index.js +2448 -2240
- package/dist/packages/affix/index.js.map +4 -4
- package/dist/packages/affix/react.d.ts +2 -0
- package/dist/packages/affix/react.js +8 -0
- package/dist/packages/affix/styles.d.ts +1 -0
- package/dist/packages/affix/styles.js +2 -0
- package/dist/packages/alert/alert.stories.d.ts +15 -0
- package/dist/packages/alert/alert.stories.js +68 -0
- package/dist/packages/alert/alert.test.d.ts +1 -0
- package/dist/packages/alert/alert.test.js +16 -0
- package/dist/packages/alert/index.d.ts +27 -17
- package/dist/packages/alert/index.js +2452 -2446
- package/dist/packages/alert/index.js.map +4 -4
- package/dist/packages/alert/react.d.ts +2 -0
- package/dist/packages/alert/react.js +8 -0
- package/dist/packages/alert/styles.d.ts +1 -0
- package/dist/packages/alert/styles.js +2 -0
- package/dist/packages/attention/attention.stories.d.ts +15 -0
- package/dist/packages/attention/attention.stories.js +188 -0
- package/dist/packages/attention/attention.test.d.ts +1 -0
- package/dist/packages/attention/attention.test.js +11 -0
- package/dist/packages/attention/index.d.ts +62 -90
- package/dist/packages/attention/index.js +3360 -3984
- package/dist/packages/attention/index.js.map +4 -4
- package/dist/packages/attention/layout-styles.d.ts +1 -0
- package/dist/packages/attention/layout-styles.js +905 -0
- package/dist/packages/attention/locales/da/messages.mjs +1 -0
- package/dist/packages/attention/locales/en/messages.mjs +1 -0
- package/dist/packages/attention/locales/fi/messages.mjs +1 -0
- package/dist/packages/attention/locales/nb/messages.mjs +1 -0
- package/dist/packages/attention/locales/sv/messages.mjs +1 -0
- package/dist/packages/attention/react.d.ts +1 -0
- package/dist/packages/attention/react.js +9 -0
- package/dist/packages/attention/styles.d.ts +1 -0
- package/dist/packages/attention/styles.js +2 -0
- package/dist/packages/badge/badge.stories.d.ts +17 -0
- package/dist/packages/badge/badge.stories.js +68 -0
- package/dist/packages/badge/badge.test.d.ts +1 -0
- package/dist/packages/badge/badge.test.js +9 -0
- package/dist/packages/badge/index.d.ts +17 -11
- package/dist/packages/badge/index.js +2441 -300
- package/dist/packages/badge/index.js.map +4 -4
- package/dist/packages/badge/react.d.ts +2 -0
- package/dist/packages/badge/react.js +8 -0
- package/dist/packages/badge/styles.d.ts +1 -0
- package/dist/packages/badge/styles.js +2 -0
- package/dist/packages/box/box.stories.d.ts +14 -0
- package/dist/packages/box/box.stories.js +59 -0
- package/dist/packages/box/box.test.d.ts +1 -0
- package/dist/packages/box/box.test.js +9 -0
- package/dist/packages/box/index.d.ts +22 -20
- package/dist/packages/box/index.js +2441 -304
- package/dist/packages/box/index.js.map +4 -4
- package/dist/packages/box/react.d.ts +2 -0
- package/dist/packages/box/react.js +8 -0
- package/dist/packages/box/slot.test.d.ts +1 -0
- package/dist/packages/box/slot.test.js +9 -0
- package/dist/packages/box/styles.d.ts +1 -0
- package/dist/packages/box/styles.js +2 -0
- package/dist/packages/breadcrumbs/breadcrumbs.stories.d.ts +12 -0
- package/dist/packages/breadcrumbs/breadcrumbs.stories.js +60 -0
- package/dist/packages/breadcrumbs/breadcrumbs.test.d.ts +1 -0
- package/dist/packages/breadcrumbs/breadcrumbs.test.js +16 -0
- package/dist/packages/breadcrumbs/index.d.ts +24 -16
- package/dist/packages/breadcrumbs/index.js +2402 -2051
- package/dist/packages/breadcrumbs/index.js.map +4 -4
- package/dist/packages/breadcrumbs/locales/da/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/en/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/fi/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/nb/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/locales/sv/messages.mjs +1 -0
- package/dist/packages/breadcrumbs/react.d.ts +2 -0
- package/dist/packages/breadcrumbs/react.js +8 -0
- package/dist/packages/breadcrumbs/styles.d.ts +1 -0
- package/dist/packages/breadcrumbs/styles.js +2 -0
- package/dist/packages/button/button.stories.d.ts +21 -0
- package/dist/packages/button/button.stories.js +119 -0
- package/dist/packages/button/button.test.d.ts +1 -0
- package/dist/packages/button/button.test.js +24 -0
- package/dist/packages/button/index.d.ts +111 -56
- package/dist/packages/button/index.js +2612 -2130
- package/dist/packages/button/index.js.map +4 -4
- package/dist/packages/button/locales/da/messages.mjs +1 -0
- package/dist/packages/button/locales/en/messages.mjs +1 -0
- package/dist/packages/button/locales/fi/messages.mjs +1 -0
- package/dist/packages/button/locales/nb/messages.mjs +1 -0
- package/dist/packages/button/locales/sv/messages.mjs +1 -0
- package/dist/packages/button/react.d.ts +2 -0
- package/dist/packages/button/react.js +8 -0
- package/dist/packages/button/styles.d.ts +1 -0
- package/dist/packages/button/styles.js +2 -0
- package/dist/packages/card/card.stories.d.ts +15 -0
- package/dist/packages/card/card.stories.js +82 -0
- package/dist/packages/card/card.test.d.ts +1 -0
- package/dist/packages/card/card.test.js +9 -0
- package/dist/packages/card/index.d.ts +33 -16
- package/dist/packages/card/index.js +2403 -2067
- package/dist/packages/card/index.js.map +4 -4
- package/dist/packages/card/locales/da/messages.mjs +1 -0
- package/dist/packages/card/locales/en/messages.mjs +1 -0
- package/dist/packages/card/locales/fi/messages.mjs +1 -0
- package/dist/packages/card/locales/nb/messages.mjs +1 -0
- package/dist/packages/card/locales/sv/messages.mjs +1 -0
- package/dist/packages/card/react.d.ts +2 -0
- package/dist/packages/card/react.js +8 -0
- package/dist/packages/card/styles.d.ts +1 -0
- package/dist/packages/card/styles.js +2 -0
- package/dist/packages/datepicker/DatePicker.test.d.ts +1 -0
- package/dist/packages/datepicker/DatePicker.test.js +68 -0
- package/dist/packages/datepicker/datepicker.d.ts +107 -0
- package/dist/packages/datepicker/datepicker.js +2785 -0
- package/dist/packages/datepicker/datepicker.js.map +7 -0
- package/dist/packages/datepicker/datepicker.stories.d.ts +11 -0
- package/dist/packages/datepicker/datepicker.stories.js +50 -0
- package/dist/packages/datepicker/datepicker.test.d.ts +2 -0
- package/dist/packages/datepicker/datepicker.test.js +62 -0
- package/dist/packages/datepicker/index.d.ts +1 -0
- package/dist/packages/datepicker/index.js +2785 -0
- package/dist/packages/datepicker/index.js.map +7 -0
- package/dist/packages/datepicker/locales/da/messages.d.mts +1 -0
- package/dist/packages/datepicker/locales/da/messages.mjs +1 -0
- package/dist/packages/datepicker/locales/en/messages.d.mts +1 -0
- package/dist/packages/datepicker/locales/en/messages.mjs +1 -0
- package/dist/packages/datepicker/locales/fi/messages.d.mts +1 -0
- package/dist/packages/datepicker/locales/fi/messages.mjs +1 -0
- package/dist/packages/datepicker/locales/nb/messages.d.mts +1 -0
- package/dist/packages/datepicker/locales/nb/messages.mjs +1 -0
- package/dist/packages/datepicker/locales/sv/messages.d.mts +1 -0
- package/dist/packages/datepicker/locales/sv/messages.mjs +1 -0
- package/dist/packages/datepicker/react.d.ts +2 -0
- package/dist/packages/datepicker/react.js +8 -0
- package/dist/packages/datepicker/styles/w-datepicker-calendar.styles.d.ts +1 -0
- package/dist/packages/datepicker/styles/w-datepicker-calendar.styles.js +15 -0
- package/dist/packages/datepicker/styles/w-datepicker-day.styles.d.ts +1 -0
- package/dist/packages/datepicker/styles/w-datepicker-day.styles.js +64 -0
- package/dist/packages/datepicker/styles/w-datepicker-month.styles.d.ts +1 -0
- package/dist/packages/datepicker/styles/w-datepicker-month.styles.js +72 -0
- package/dist/packages/datepicker/styles/w-datepicker.styles.d.ts +1 -0
- package/dist/packages/datepicker/styles/w-datepicker.styles.js +101 -0
- package/dist/packages/datepicker/utils.d.ts +13 -0
- package/dist/packages/datepicker/utils.js +28 -0
- package/dist/packages/dead-toggle/dead-toggle.stories.d.ts +10 -0
- package/dist/packages/dead-toggle/dead-toggle.stories.js +23 -0
- package/dist/packages/dead-toggle/dead-toggle.test.d.ts +1 -0
- package/dist/packages/dead-toggle/dead-toggle.test.js +9 -0
- package/dist/packages/dead-toggle/index.d.ts +21 -0
- package/dist/packages/dead-toggle/index.js +2487 -0
- package/dist/packages/dead-toggle/index.js.map +7 -0
- package/dist/packages/dead-toggle/react.d.ts +2 -0
- package/dist/packages/dead-toggle/react.js +8 -0
- package/dist/packages/expandable/expandable.stories.d.ts +19 -0
- package/dist/packages/expandable/expandable.stories.js +133 -0
- package/dist/packages/expandable/expandable.test.d.ts +1 -0
- package/dist/packages/expandable/expandable.test.js +24 -0
- package/dist/packages/expandable/index.d.ts +55 -50
- package/dist/packages/expandable/index.js +2416 -2287
- package/dist/packages/expandable/index.js.map +4 -4
- package/dist/packages/expandable/react.d.ts +2 -0
- package/dist/packages/expandable/react.js +8 -0
- package/dist/packages/expandable/styles.d.ts +1 -0
- package/dist/packages/expandable/styles.js +2 -0
- package/dist/packages/i18n.js +44 -0
- package/dist/packages/link/index.d.ts +39 -0
- package/dist/packages/link/index.js +2646 -0
- package/dist/packages/link/index.js.map +7 -0
- package/dist/packages/link/link.stories.d.ts +20 -0
- package/dist/packages/link/link.stories.js +121 -0
- package/dist/packages/link/link.test.d.ts +1 -0
- package/dist/packages/link/link.test.js +9 -0
- package/dist/packages/link/react.d.ts +2 -0
- package/dist/packages/link/react.js +8 -0
- package/dist/packages/link/styles.d.ts +1 -0
- package/dist/packages/link/styles.js +200 -0
- package/dist/packages/modal/index.d.ts +4 -5
- package/dist/packages/modal/index.js +2649 -2569
- package/dist/packages/modal/index.js.map +4 -4
- package/dist/packages/modal/locales/da/messages.mjs +1 -0
- package/dist/packages/modal/locales/en/messages.mjs +1 -0
- package/dist/packages/modal/locales/fi/messages.mjs +1 -0
- package/dist/packages/modal/locales/nb/messages.mjs +1 -0
- package/dist/packages/modal/locales/sv/messages.mjs +1 -0
- package/dist/packages/modal/modal-footer.d.ts +18 -11
- package/dist/packages/modal/modal-footer.js +2460 -0
- package/dist/packages/modal/modal-footer.js.map +7 -0
- package/dist/packages/modal/modal-header.d.ts +30 -31
- package/dist/packages/modal/modal-header.js +2584 -0
- package/dist/packages/modal/modal-header.js.map +7 -0
- package/dist/packages/modal/modal-main.d.ts +32 -31
- package/dist/packages/modal/modal-main.js +2572 -0
- package/dist/packages/modal/modal-main.js.map +7 -0
- package/dist/packages/modal/modal.stories.d.ts +19 -0
- package/dist/packages/modal/modal.stories.js +160 -0
- package/dist/packages/modal/react.d.ts +4 -0
- package/dist/packages/modal/react.js +18 -0
- package/dist/packages/modal/util.d.ts +7 -17
- package/dist/packages/modal/util.js +21 -0
- package/dist/packages/pageindicator/index.d.ts +14 -0
- package/dist/packages/pageindicator/index.js +32 -0
- package/dist/packages/pageindicator/index.js.map +7 -0
- package/dist/packages/pageindicator/pageindicator.stories.d.ts +32 -0
- package/dist/packages/pageindicator/pageindicator.stories.js +71 -0
- package/dist/packages/pageindicator/react.d.ts +2 -0
- package/dist/packages/pageindicator/react.js +8 -0
- package/dist/packages/pageindicator/style.d.ts +1 -0
- package/dist/packages/pageindicator/style.js +26 -0
- package/dist/packages/pagination/index.d.ts +37 -0
- package/dist/packages/pagination/index.js +2494 -0
- package/dist/packages/pagination/index.js.map +7 -0
- package/dist/packages/pagination/locales/da/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/da/messages.mjs +1 -0
- package/dist/packages/pagination/locales/en/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/en/messages.mjs +1 -0
- package/dist/packages/pagination/locales/fi/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/fi/messages.mjs +1 -0
- package/dist/packages/pagination/locales/nb/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/nb/messages.mjs +1 -0
- package/dist/packages/pagination/locales/sv/messages.d.mts +1 -0
- package/dist/packages/pagination/locales/sv/messages.mjs +1 -0
- package/dist/packages/pagination/pagination.stories.d.ts +14 -0
- package/dist/packages/pagination/pagination.stories.js +56 -0
- package/dist/packages/pagination/pagination.test.d.ts +1 -0
- package/dist/packages/pagination/pagination.test.js +76 -0
- package/dist/packages/pagination/react.d.ts +2 -0
- package/dist/packages/pagination/react.js +8 -0
- package/dist/packages/pagination/styles.d.ts +1 -0
- package/dist/packages/pagination/styles.js +2 -0
- package/dist/packages/pill/index.d.ts +44 -23
- package/dist/packages/pill/index.js +2408 -2175
- package/dist/packages/pill/index.js.map +4 -4
- package/dist/packages/pill/locales/da/messages.mjs +1 -0
- package/dist/packages/pill/locales/en/messages.mjs +1 -0
- package/dist/packages/pill/locales/fi/messages.mjs +1 -0
- package/dist/packages/pill/locales/nb/messages.mjs +1 -0
- package/dist/packages/pill/locales/sv/messages.mjs +1 -0
- package/dist/packages/pill/pill.stories.d.ts +12 -0
- package/dist/packages/pill/pill.stories.js +33 -0
- package/dist/packages/pill/pill.test.d.ts +1 -0
- package/dist/packages/pill/pill.test.js +23 -0
- package/dist/packages/pill/styles.d.ts +1 -0
- package/dist/packages/pill/styles.js +2 -0
- package/dist/packages/rip-and-tear-checkbox/checkbox.d.ts +64 -0
- package/dist/packages/rip-and-tear-checkbox/checkbox.js +210 -0
- package/dist/packages/rip-and-tear-checkbox/index.d.ts +6 -0
- package/dist/packages/rip-and-tear-checkbox/index.js +160 -0
- package/dist/packages/rip-and-tear-checkbox/index.js.map +7 -0
- package/dist/packages/rip-and-tear-checkbox/styles.d.ts +1 -0
- package/dist/packages/rip-and-tear-checkbox/styles.js +116 -0
- package/dist/packages/rip-and-tear-radio/base-element.d.ts +46 -0
- package/dist/packages/rip-and-tear-radio/base-element.js +100 -0
- package/dist/packages/rip-and-tear-radio/custom-error-validator.d.ts +6 -0
- package/dist/packages/rip-and-tear-radio/custom-error-validator.js +22 -0
- package/dist/packages/rip-and-tear-radio/form-associated-element.d.ts +103 -0
- package/dist/packages/rip-and-tear-radio/form-associated-element.js +282 -0
- package/dist/packages/rip-and-tear-radio/host-styles.d.ts +1 -0
- package/dist/packages/rip-and-tear-radio/host-styles.js +12 -0
- package/dist/packages/rip-and-tear-radio/index.d.ts +8 -0
- package/dist/packages/rip-and-tear-radio/index.js +272 -0
- package/dist/packages/rip-and-tear-radio/index.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/invalid.d.ts +8 -0
- package/dist/packages/rip-and-tear-radio/invalid.js +5 -0
- package/dist/packages/rip-and-tear-radio/math.d.ts +1 -0
- package/dist/packages/rip-and-tear-radio/math.js +4 -0
- package/dist/packages/rip-and-tear-radio/radio-group-styles.d.ts +1 -0
- package/dist/packages/rip-and-tear-radio/radio-group-styles.js +60 -0
- package/dist/packages/rip-and-tear-radio/radio-group.d.ts +72 -0
- package/dist/packages/rip-and-tear-radio/radio-group.js +339 -0
- package/dist/packages/rip-and-tear-radio/radio-styles.d.ts +1 -0
- package/dist/packages/rip-and-tear-radio/radio-styles.js +172 -0
- package/dist/packages/rip-and-tear-radio/radio.d.ts +38 -0
- package/dist/packages/rip-and-tear-radio/radio.js +107 -0
- package/dist/packages/rip-and-tear-radio/required-validator.d.ts +11 -0
- package/dist/packages/rip-and-tear-radio/required-validator.js +34 -0
- package/dist/packages/rip-and-tear-radio/slot.d.ts +20 -0
- package/dist/packages/rip-and-tear-radio/slot.js +71 -0
- package/dist/packages/rip-and-tear-radio/watch.d.ts +26 -0
- package/dist/packages/rip-and-tear-radio/watch.js +39 -0
- package/dist/packages/select/index.d.ts +59 -48
- package/dist/packages/select/index.js +2421 -2236
- package/dist/packages/select/index.js.map +4 -4
- package/dist/packages/select/locales/da/messages.mjs +1 -0
- package/dist/packages/select/locales/en/messages.mjs +1 -0
- package/dist/packages/select/locales/fi/messages.mjs +1 -0
- package/dist/packages/select/locales/nb/messages.mjs +1 -0
- package/dist/packages/select/locales/sv/messages.mjs +1 -0
- package/dist/packages/select/react.d.ts +2 -0
- package/dist/packages/select/react.js +8 -0
- package/dist/packages/select/select.stories.d.ts +10 -0
- package/dist/packages/select/select.stories.js +31 -0
- package/dist/packages/select/select.test.d.ts +1 -0
- package/dist/packages/select/select.test.js +31 -0
- package/dist/packages/select/styles.d.ts +1 -0
- package/dist/packages/select/styles.js +2 -0
- package/dist/packages/steps/index.d.ts +43 -0
- package/dist/packages/steps/index.js +2465 -0
- package/dist/packages/steps/index.js.map +7 -0
- package/dist/packages/steps/locales/da/messages.d.mts +1 -0
- package/dist/packages/steps/locales/da/messages.mjs +1 -0
- package/dist/packages/steps/locales/en/messages.d.mts +1 -0
- package/dist/packages/steps/locales/en/messages.mjs +1 -0
- package/dist/packages/steps/locales/fi/messages.d.mts +1 -0
- package/dist/packages/steps/locales/fi/messages.mjs +1 -0
- package/dist/packages/steps/locales/nb/messages.d.mts +1 -0
- package/dist/packages/steps/locales/nb/messages.mjs +1 -0
- package/dist/packages/steps/locales/sv/messages.d.mts +1 -0
- package/dist/packages/steps/locales/sv/messages.mjs +1 -0
- package/dist/packages/steps/react.d.ts +3 -0
- package/dist/packages/steps/react.js +13 -0
- package/dist/packages/steps/steps.stories.d.ts +12 -0
- package/dist/packages/steps/steps.stories.js +172 -0
- package/dist/packages/steps/styles.d.ts +1 -0
- package/dist/packages/steps/styles.js +2 -0
- package/dist/packages/styles.d.ts +2 -0
- package/dist/packages/styles.js +2442 -0
- package/dist/packages/switch/index.d.ts +20 -0
- package/dist/packages/switch/index.js +2455 -0
- package/dist/packages/switch/index.js.map +7 -0
- package/dist/packages/switch/react.d.ts +2 -0
- package/dist/packages/switch/react.js +8 -0
- package/dist/packages/switch/styles.d.ts +1 -0
- package/dist/packages/switch/styles.js +2 -0
- package/dist/packages/switch/switch.stories.d.ts +9 -0
- package/dist/packages/switch/switch.stories.js +34 -0
- package/dist/packages/tabs/index.d.ts +4 -0
- package/dist/packages/tabs/index.js +2470 -0
- package/dist/packages/tabs/index.js.map +7 -0
- package/dist/packages/tabs/react.d.ts +4 -0
- package/dist/packages/tabs/react.js +18 -0
- package/dist/packages/tabs/styles.d.ts +1 -0
- package/dist/packages/tabs/styles.js +2 -0
- package/dist/packages/tabs/tab-panel.d.ts +20 -0
- package/dist/packages/tabs/tab-panel.js +51 -0
- package/dist/packages/tabs/tab.d.ts +23 -0
- package/dist/packages/tabs/tab.js +103 -0
- package/dist/packages/tabs/tabs.d.ts +38 -0
- package/dist/packages/tabs/tabs.js +238 -0
- package/dist/packages/tabs/tabs.stories.d.ts +8 -0
- package/dist/packages/tabs/tabs.stories.js +84 -0
- package/dist/packages/textfield/index.d.ts +72 -74
- package/dist/packages/textfield/index.js +2456 -413
- package/dist/packages/textfield/index.js.map +4 -4
- package/dist/packages/textfield/react.d.ts +2 -0
- package/dist/packages/textfield/react.js +8 -0
- package/dist/packages/textfield/styles.d.ts +1 -0
- package/dist/packages/textfield/styles.js +2 -0
- package/dist/packages/textfield/textfield.stories.d.ts +17 -0
- package/dist/packages/textfield/textfield.stories.js +86 -0
- package/dist/packages/textfield/textfield.test.d.ts +1 -0
- package/dist/packages/textfield/textfield.test.js +9 -0
- package/dist/packages/toast/api.d.ts +4 -45
- package/dist/packages/toast/api.js +41 -0
- package/dist/packages/toast/index.d.ts +3 -0
- package/dist/packages/toast/index.js +2466 -2787
- package/dist/packages/toast/index.js.map +4 -4
- package/dist/packages/toast/locales/da/messages.mjs +1 -0
- package/dist/packages/toast/locales/en/messages.mjs +1 -0
- package/dist/packages/toast/locales/fi/messages.mjs +1 -0
- package/dist/packages/toast/locales/nb/messages.mjs +1 -0
- package/dist/packages/toast/locales/sv/messages.mjs +1 -0
- package/dist/packages/toast/styles.d.ts +1 -0
- package/dist/packages/toast/styles.js +2 -0
- package/dist/packages/toast/toast-container.d.ts +12 -63
- package/dist/packages/toast/toast-container.js +153 -0
- package/dist/packages/toast/toast.d.ts +34 -29
- package/dist/packages/toast/toast.js +200 -0
- package/dist/packages/toast/toast.stories.d.ts +12 -0
- package/dist/packages/toast/toast.stories.js +50 -0
- package/dist/packages/toast/types.d.ts +15 -0
- package/dist/packages/toast/types.js +1 -0
- package/dist/packages/utils/expand-transition.d.ts +3 -2
- package/dist/packages/utils/expand-transition.js +59 -0
- package/dist/packages/utils/index.d.ts +1 -1
- package/dist/packages/utils/index.js +2 -0
- package/dist/packages/utils/index.js.map +7 -0
- package/dist/packages/utils/unstyled-heading.d.ts +3 -3
- package/dist/packages/utils/unstyled-heading.js +22 -0
- package/dist/packages/utils/window-exists.js +1 -0
- package/dist/setup-tests.d.ts +1 -0
- package/dist/setup-tests.js +1 -0
- package/dist/vscode.css-custom-data.json +6 -0
- package/dist/vscode.html-custom-data.json +421 -0
- package/dist/web-types.json +949 -0
- package/package.json +88 -32
- package/dist/index.d.ts +0 -18
- package/dist/index.js +0 -6832
- package/dist/index.js.map +0 -7
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from 'lit';
|
|
8
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { BaseFormAssociatedElement } from './form-associated-element';
|
|
11
|
+
import { uniqueId } from './math';
|
|
12
|
+
import './radio';
|
|
13
|
+
// eslint-disable-next-line
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
import { styles } from './radio-group-styles';
|
|
16
|
+
import { RequiredValidator } from './required-validator';
|
|
17
|
+
import { HasSlotController } from './slot';
|
|
18
|
+
/**
|
|
19
|
+
* @slot label - Alternative to the `label` attribute should you need custom HTML.
|
|
20
|
+
*/
|
|
21
|
+
export class WRadioGroup extends BaseFormAssociatedElement {
|
|
22
|
+
static { this.css = [styles]; }
|
|
23
|
+
static get validators() {
|
|
24
|
+
const validators = [
|
|
25
|
+
RequiredValidator({
|
|
26
|
+
validationElement: Object.assign(document.createElement('input'), {
|
|
27
|
+
required: true,
|
|
28
|
+
type: 'radio',
|
|
29
|
+
// we need an id that's guaranteed to be unique; users will never see this
|
|
30
|
+
name: uniqueId('__w-radio'),
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
return [...super.validators, ...validators];
|
|
35
|
+
}
|
|
36
|
+
get value() {
|
|
37
|
+
if (this.valueHasChanged) {
|
|
38
|
+
return this._value;
|
|
39
|
+
}
|
|
40
|
+
return this._value ?? this.defaultValue;
|
|
41
|
+
}
|
|
42
|
+
/** The current value of the radio group, submitted as a name/value pair with form data. */
|
|
43
|
+
set value(val) {
|
|
44
|
+
if (typeof val === 'number')
|
|
45
|
+
val = String(val);
|
|
46
|
+
this.valueHasChanged = true;
|
|
47
|
+
this._value = val;
|
|
48
|
+
}
|
|
49
|
+
//
|
|
50
|
+
// We need this because if we don't have it, FormValidation yells at us that it's "not focusable".
|
|
51
|
+
// If we use `this.tabIndex = -1` we can't focus the radio inside.
|
|
52
|
+
//
|
|
53
|
+
static { this.shadowRootOptions = { ...BaseFormAssociatedElement.shadowRootOptions, delegatesFocus: true }; }
|
|
54
|
+
constructor() {
|
|
55
|
+
super();
|
|
56
|
+
this.hasSlotController = new HasSlotController(this, 'hint', 'label');
|
|
57
|
+
this.hasRadioButtons = false;
|
|
58
|
+
/**
|
|
59
|
+
* The radio group's label. Required for proper accessibility. If you need to display HTML, use the `label` slot
|
|
60
|
+
* instead.
|
|
61
|
+
*/
|
|
62
|
+
this.label = '';
|
|
63
|
+
/** The radio groups's hint. If you need to display HTML, use the `hint` slot instead. */
|
|
64
|
+
this.hint = '';
|
|
65
|
+
/** The name of the radio group, submitted as a name/value pair with form data. */
|
|
66
|
+
this.name = null;
|
|
67
|
+
/** Disables the radio group and all child radios. */
|
|
68
|
+
this.disabled = false;
|
|
69
|
+
/** The orientation in which to show radio items. */
|
|
70
|
+
this.orientation = 'vertical';
|
|
71
|
+
this._value = null;
|
|
72
|
+
/** The default value of the form control. Primarily used for resetting the form control. */
|
|
73
|
+
this.defaultValue = this.getAttribute('value') || null;
|
|
74
|
+
/** The radio group's size. This size will be applied to all child radios and radio buttons, except when explicitly overridden. */
|
|
75
|
+
this.size = 'medium';
|
|
76
|
+
/** Ensures a child radio is checked before allowing the containing form to submit. */
|
|
77
|
+
this.required = false;
|
|
78
|
+
/**
|
|
79
|
+
* Used for SSR. if true, will show slotted label on initial render.
|
|
80
|
+
*/
|
|
81
|
+
this.withLabel = false;
|
|
82
|
+
/**
|
|
83
|
+
* Used for SSR. if true, will show slotted hint on initial render.
|
|
84
|
+
*/
|
|
85
|
+
this.withHint = false;
|
|
86
|
+
this.handleRadioClick = (e) => {
|
|
87
|
+
const clickedRadio = e.target.closest('w-radio');
|
|
88
|
+
/* eslint-disable */
|
|
89
|
+
if (!clickedRadio || clickedRadio.disabled || clickedRadio.forceDisabled || this.disabled) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const oldValue = this.value;
|
|
93
|
+
this.value = clickedRadio.value;
|
|
94
|
+
clickedRadio.checked = true;
|
|
95
|
+
const radios = this.getAllRadios();
|
|
96
|
+
for (const radio of radios) {
|
|
97
|
+
if (clickedRadio === radio) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
radio.checked = false;
|
|
101
|
+
radio.setAttribute('tabindex', '-1');
|
|
102
|
+
}
|
|
103
|
+
if (this.value !== oldValue) {
|
|
104
|
+
this.updateComplete.then(() => {
|
|
105
|
+
this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));
|
|
106
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
this.addEventListener('keydown', this.handleKeyDown);
|
|
111
|
+
this.addEventListener('click', this.handleRadioClick);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* We use the first available radio as the validationTarget similar to native HTML that shows the validation popup on
|
|
115
|
+
* the first radio element.
|
|
116
|
+
*/
|
|
117
|
+
get validationTarget() {
|
|
118
|
+
const radio = this.querySelector(':is(w-radio):not([disabled])');
|
|
119
|
+
if (!radio)
|
|
120
|
+
return undefined;
|
|
121
|
+
return radio;
|
|
122
|
+
}
|
|
123
|
+
updated(changedProperties) {
|
|
124
|
+
if (changedProperties.has('disabled') || changedProperties.has('value')) {
|
|
125
|
+
this.syncRadioElements();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
formResetCallback(...args) {
|
|
129
|
+
this.value = this.defaultValue;
|
|
130
|
+
super.formResetCallback(...args);
|
|
131
|
+
this.syncRadioElements();
|
|
132
|
+
}
|
|
133
|
+
getAllRadios() {
|
|
134
|
+
return [...this.querySelectorAll('w-radio')];
|
|
135
|
+
}
|
|
136
|
+
handleLabelClick() {
|
|
137
|
+
this.focus();
|
|
138
|
+
}
|
|
139
|
+
async syncRadioElements() {
|
|
140
|
+
const radios = this.getAllRadios();
|
|
141
|
+
let hasRadioButtons = false;
|
|
142
|
+
// Add data attributes to support styling
|
|
143
|
+
radios.forEach((radio, index) => {
|
|
144
|
+
if (radio.appearance === 'button')
|
|
145
|
+
hasRadioButtons = true;
|
|
146
|
+
radio.setAttribute('size', this.size);
|
|
147
|
+
radio.toggleAttribute('data-w-radio-horizontal', this.orientation !== 'vertical');
|
|
148
|
+
radio.toggleAttribute('data-w-radio-vertical', this.orientation === 'vertical');
|
|
149
|
+
radio.toggleAttribute('data-w-radio-first', index === 0);
|
|
150
|
+
radio.toggleAttribute('data-w-radio-inner', index !== 0 && index !== radios.length - 1);
|
|
151
|
+
radio.toggleAttribute('data-w-radio-last', index === radios.length - 1);
|
|
152
|
+
// Set forceDisabled state based on radio group's disabled state
|
|
153
|
+
radio.forceDisabled = this.disabled;
|
|
154
|
+
});
|
|
155
|
+
// If at least one radio button exists, we assume it's a radio button group
|
|
156
|
+
this.hasRadioButtons = hasRadioButtons;
|
|
157
|
+
await Promise.all(radios.map(async (radio) => {
|
|
158
|
+
await radio.updateComplete;
|
|
159
|
+
if (!radio.disabled && radio.value === this.value) {
|
|
160
|
+
radio.checked = true;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
radio.checked = false;
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
166
|
+
// Manage tabIndex based on disabled state and checked status
|
|
167
|
+
if (this.disabled) {
|
|
168
|
+
// If radio group is disabled, all radios should not be tabbable
|
|
169
|
+
radios.forEach((radio) => {
|
|
170
|
+
radio.tabIndex = -1;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// Normal tabbing behavior
|
|
175
|
+
const enabledRadios = radios.filter((radio) => !radio.disabled);
|
|
176
|
+
const checkedRadio = enabledRadios.find((radio) => radio.checked);
|
|
177
|
+
if (enabledRadios.length > 0) {
|
|
178
|
+
if (checkedRadio) {
|
|
179
|
+
// If there's a checked radio, it should be tabbable
|
|
180
|
+
enabledRadios.forEach((radio) => {
|
|
181
|
+
radio.tabIndex = radio.checked ? 0 : -1;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// If no radio is checked, first enabled radio should be tabbable
|
|
186
|
+
enabledRadios.forEach((radio, index) => {
|
|
187
|
+
radio.tabIndex = index === 0 ? 0 : -1;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Disabled radios should never be tabbable
|
|
192
|
+
radios
|
|
193
|
+
.filter((radio) => radio.disabled)
|
|
194
|
+
.forEach((radio) => {
|
|
195
|
+
radio.tabIndex = -1;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
handleKeyDown(event) {
|
|
200
|
+
if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(event.key) || this.disabled) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const radios = this.getAllRadios().filter((radio) => !radio.disabled);
|
|
204
|
+
if (radios.length <= 0) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
const oldValue = this.value;
|
|
209
|
+
const checkedRadio = radios.find((radio) => radio.checked) ?? radios[0];
|
|
210
|
+
const incr = event.key === ' ' ? 0 : ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1;
|
|
211
|
+
let index = radios.indexOf(checkedRadio) + incr;
|
|
212
|
+
if (!index)
|
|
213
|
+
index = 0;
|
|
214
|
+
if (index < 0) {
|
|
215
|
+
index = radios.length - 1;
|
|
216
|
+
}
|
|
217
|
+
if (index > radios.length - 1) {
|
|
218
|
+
index = 0;
|
|
219
|
+
}
|
|
220
|
+
const hasRadioButtons = radios.some((radio) => radio.tagName.toLowerCase() === 'w-radio-button');
|
|
221
|
+
this.getAllRadios().forEach((radio) => {
|
|
222
|
+
radio.checked = false;
|
|
223
|
+
if (!hasRadioButtons) {
|
|
224
|
+
radio.setAttribute('tabindex', '-1');
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
this.value = radios[index].value;
|
|
228
|
+
radios[index].checked = true;
|
|
229
|
+
if (!hasRadioButtons) {
|
|
230
|
+
radios[index].setAttribute('tabindex', '0');
|
|
231
|
+
radios[index].focus();
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
radios[index].shadowRoot.querySelector('button').focus();
|
|
235
|
+
}
|
|
236
|
+
if (this.value !== oldValue) {
|
|
237
|
+
this.updateComplete.then(() => {
|
|
238
|
+
this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));
|
|
239
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
}
|
|
244
|
+
/** Sets focus on the radio group. */
|
|
245
|
+
focus(options) {
|
|
246
|
+
if (this.disabled)
|
|
247
|
+
return;
|
|
248
|
+
const radios = this.getAllRadios();
|
|
249
|
+
const checked = radios.find((radio) => radio.checked);
|
|
250
|
+
const firstEnabledRadio = radios.find((radio) => !radio.disabled);
|
|
251
|
+
const radioToFocus = checked || firstEnabledRadio;
|
|
252
|
+
// Call focus for the checked radio. If no radio is checked, focus the first one that isn't disabled.
|
|
253
|
+
if (radioToFocus) {
|
|
254
|
+
radioToFocus.focus(options);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
render() {
|
|
258
|
+
const hasLabelSlot = this.hasUpdated ? this.hasSlotController.test('label') : this.withLabel;
|
|
259
|
+
const hasHintSlot = this.hasUpdated ? this.hasSlotController.test('hint') : this.withHint;
|
|
260
|
+
const hasLabel = this.label ? true : !!hasLabelSlot;
|
|
261
|
+
const hasHint = this.hint ? true : !!hasHintSlot;
|
|
262
|
+
return html `
|
|
263
|
+
<fieldset
|
|
264
|
+
part="form-control"
|
|
265
|
+
class=${classMap({
|
|
266
|
+
'form-control': true,
|
|
267
|
+
'form-control-radio-group': true,
|
|
268
|
+
'form-control-has-label': hasLabel,
|
|
269
|
+
'has-radio-buttons': this.hasRadioButtons,
|
|
270
|
+
})}
|
|
271
|
+
role="radiogroup"
|
|
272
|
+
aria-labelledby="label"
|
|
273
|
+
aria-describedby="hint"
|
|
274
|
+
aria-errormessage="error-message"
|
|
275
|
+
aria-orientation=${this.orientation}>
|
|
276
|
+
<label
|
|
277
|
+
part="form-control-label"
|
|
278
|
+
id="label"
|
|
279
|
+
class="label"
|
|
280
|
+
aria-hidden=${hasLabel ? 'false' : 'true'}
|
|
281
|
+
@click=${this.handleLabelClick}>
|
|
282
|
+
<slot name="label">${this.label}</slot>
|
|
283
|
+
</label>
|
|
284
|
+
|
|
285
|
+
<slot part="form-control-input" @slotchange=${this.syncRadioElements}></slot>
|
|
286
|
+
|
|
287
|
+
<slot
|
|
288
|
+
id="hint"
|
|
289
|
+
name="hint"
|
|
290
|
+
part="hint"
|
|
291
|
+
class=${classMap({
|
|
292
|
+
'has-slotted': hasHint,
|
|
293
|
+
})}
|
|
294
|
+
aria-hidden=${hasHint ? 'false' : 'true'}
|
|
295
|
+
>${this.hint}</slot
|
|
296
|
+
>
|
|
297
|
+
</fieldset>
|
|
298
|
+
`;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
__decorate([
|
|
302
|
+
state()
|
|
303
|
+
], WRadioGroup.prototype, "hasRadioButtons", void 0);
|
|
304
|
+
__decorate([
|
|
305
|
+
query('slot:not([name])')
|
|
306
|
+
], WRadioGroup.prototype, "defaultSlot", void 0);
|
|
307
|
+
__decorate([
|
|
308
|
+
property()
|
|
309
|
+
], WRadioGroup.prototype, "label", void 0);
|
|
310
|
+
__decorate([
|
|
311
|
+
property({ attribute: 'hint' })
|
|
312
|
+
], WRadioGroup.prototype, "hint", void 0);
|
|
313
|
+
__decorate([
|
|
314
|
+
property({ reflect: true })
|
|
315
|
+
], WRadioGroup.prototype, "name", void 0);
|
|
316
|
+
__decorate([
|
|
317
|
+
property({ type: Boolean, reflect: true })
|
|
318
|
+
], WRadioGroup.prototype, "disabled", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
property({ reflect: true })
|
|
321
|
+
], WRadioGroup.prototype, "orientation", void 0);
|
|
322
|
+
__decorate([
|
|
323
|
+
state()
|
|
324
|
+
], WRadioGroup.prototype, "value", null);
|
|
325
|
+
__decorate([
|
|
326
|
+
property({ attribute: 'value', reflect: true })
|
|
327
|
+
], WRadioGroup.prototype, "defaultValue", void 0);
|
|
328
|
+
__decorate([
|
|
329
|
+
property({ reflect: true })
|
|
330
|
+
], WRadioGroup.prototype, "size", void 0);
|
|
331
|
+
__decorate([
|
|
332
|
+
property({ type: Boolean, reflect: true })
|
|
333
|
+
], WRadioGroup.prototype, "required", void 0);
|
|
334
|
+
__decorate([
|
|
335
|
+
property({ type: Boolean, attribute: 'with-label' })
|
|
336
|
+
], WRadioGroup.prototype, "withLabel", void 0);
|
|
337
|
+
__decorate([
|
|
338
|
+
property({ type: Boolean, attribute: 'with-hint' })
|
|
339
|
+
], WRadioGroup.prototype, "withHint", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
color: var(--wa-form-control-value-color);
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
align-items: top;
|
|
8
|
+
font-family: inherit;
|
|
9
|
+
font-weight: var(--wa-form-control-value-font-weight);
|
|
10
|
+
line-height: var(--wa-form-control-value-line-height);
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
user-select: none;
|
|
13
|
+
-webkit-user-select: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host(:focus) {
|
|
17
|
+
outline: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[part~='label'] {
|
|
21
|
+
display: inline;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[part~='hint'] {
|
|
25
|
+
margin-block-start: 0.5em;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Default appearance */
|
|
29
|
+
:host([appearance='default']) {
|
|
30
|
+
.control {
|
|
31
|
+
flex: 0 0 auto;
|
|
32
|
+
position: relative;
|
|
33
|
+
display: inline-flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
width: var(--wa-form-control-toggle-size, 2rem);
|
|
37
|
+
height: var(--wa-form-control-toggle-size, 2rem);
|
|
38
|
+
border-color: var(--wa-form-control-border-color, gray);
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
border-style: var(--wa-form-control-border-style, solid);
|
|
41
|
+
border-width: var(--wa-form-control-border-width, 1px);
|
|
42
|
+
background-color: var(--wa-form-control-background-color, white);
|
|
43
|
+
color: transparent;
|
|
44
|
+
transition-property: all;
|
|
45
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
46
|
+
transition-duration: 150ms;
|
|
47
|
+
|
|
48
|
+
margin-inline-end: 0.5em;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:host([appearance='clickable']) .control {
|
|
53
|
+
position: absolute;
|
|
54
|
+
inset: 0;
|
|
55
|
+
height: 100%;
|
|
56
|
+
width: 100%;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Checked */
|
|
61
|
+
:host(:state(checked)):not(:host([appearance='clickable'])) .control {
|
|
62
|
+
/* color: var(--checked-icon-color, white); */
|
|
63
|
+
border-color: var(--wa-form-control-activated-color, blue);
|
|
64
|
+
background-color: var(--wa-form-control-background-color, white);
|
|
65
|
+
border-width: 0.6rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Focus */
|
|
69
|
+
:host(:focus-visible) .control {
|
|
70
|
+
outline: 2px solid var(--w-s-color-border-focus);
|
|
71
|
+
outline-offset: var(--w-outline-offset, 1px);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:host([appearance='clickable']:focus-visible) .control {
|
|
75
|
+
outline-offset: -4px;
|
|
76
|
+
border-radius: 8px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Disabled */
|
|
80
|
+
:host(:state(disabled)) {
|
|
81
|
+
opacity: 0.5;
|
|
82
|
+
cursor: not-allowed;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Button appearance */
|
|
86
|
+
:host([appearance='button']) {
|
|
87
|
+
align-items: center;
|
|
88
|
+
min-height: var(--wa-form-control-height);
|
|
89
|
+
background-color: var(--wa-color-surface-default);
|
|
90
|
+
border: var(--wa-form-control-border-width) var(--wa-form-control-border-style) var(--wa-form-control-border-color);
|
|
91
|
+
border-radius: var(--wa-border-radius-m);
|
|
92
|
+
padding: 0 var(--wa-form-control-padding-inline);
|
|
93
|
+
transition:
|
|
94
|
+
background-color var(--wa-transition-fast),
|
|
95
|
+
border-color var(--wa-transition-fast);
|
|
96
|
+
|
|
97
|
+
.control {
|
|
98
|
+
display: none;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Horizontal grouping - remove inner border radius */
|
|
103
|
+
:host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-inner]) {
|
|
104
|
+
border-radius: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-first]) {
|
|
108
|
+
border-start-end-radius: 0;
|
|
109
|
+
border-end-end-radius: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-last]) {
|
|
113
|
+
border-start-start-radius: 0;
|
|
114
|
+
border-end-start-radius: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Vertical grouping - remove inner border radius */
|
|
118
|
+
:host([appearance='button'][data-wa-radio-vertical][data-wa-radio-inner]) {
|
|
119
|
+
border-radius: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
:host([appearance='button'][data-wa-radio-vertical][data-wa-radio-first]) {
|
|
123
|
+
border-end-start-radius: 0;
|
|
124
|
+
border-end-end-radius: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host([appearance='button'][data-wa-radio-vertical][data-wa-radio-last]) {
|
|
128
|
+
border-start-start-radius: 0;
|
|
129
|
+
border-start-end-radius: 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@media (hover: hover) {
|
|
133
|
+
:host([appearance='button']:hover:not(:state(disabled), :state(checked))) {
|
|
134
|
+
background-color: color-mix(in srgb, var(--wa-color-surface-default) 95%, var(--wa-color-mix-hover));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:host([appearance='button']:focus-visible) {
|
|
139
|
+
outline: var(--wa-focus-ring);
|
|
140
|
+
outline-offset: var(--wa-focus-ring-offset);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
:host([appearance='button']:state(checked)) {
|
|
144
|
+
border-color: var(--wa-form-control-activated-color);
|
|
145
|
+
background-color: var(--wa-color-brand-fill-quiet);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
:host([appearance='button']:state(checked):focus-visible) {
|
|
149
|
+
outline: var(--wa-focus-ring-style) var(--wa-focus-ring-width) var(--wa-color-brand-border-loud);
|
|
150
|
+
outline-offset: var(--wa-focus-ring-offset);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* Remove inner borders and handle overlap */
|
|
154
|
+
:host([appearance='button'][data-wa-radio-horizontal]:not([data-wa-radio-first])) {
|
|
155
|
+
margin-inline-start: calc(-1 * var(--wa-form-control-border-width));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
:host([appearance='button'][data-wa-radio-vertical]:not([data-wa-radio-first])) {
|
|
159
|
+
margin-block-start: calc(-1 * var(--wa-form-control-border-width));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Ensure interactive states are visible above adjacent buttons */
|
|
163
|
+
:host([appearance='button']:hover),
|
|
164
|
+
:host([appearance='button']:state(checked)) {
|
|
165
|
+
position: relative;
|
|
166
|
+
z-index: 1;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
:host([appearance='button']:focus-visible) {
|
|
170
|
+
z-index: 2;
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PropertyValues } from 'lit';
|
|
2
|
+
import { BaseFormAssociatedElement } from './form-associated-element';
|
|
3
|
+
export declare class WRadio extends BaseFormAssociatedElement {
|
|
4
|
+
static css: import("lit").CSSResult[];
|
|
5
|
+
checked: boolean;
|
|
6
|
+
/** @internal Used by radio group to force disable radios while preserving their original disabled state. */
|
|
7
|
+
forceDisabled: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The string pointing to a form's id.
|
|
10
|
+
*/
|
|
11
|
+
form: string | null;
|
|
12
|
+
/** The radio's value. When selected, the radio group will receive this value. */
|
|
13
|
+
value: string;
|
|
14
|
+
/** The radio's value. When selected, the radio group will receive this value. */
|
|
15
|
+
appearance: 'default' | 'button' | 'clickable';
|
|
16
|
+
/**
|
|
17
|
+
* The radio's size. When used inside a radio group, the size will be determined by the radio group's size so this
|
|
18
|
+
* attribute can typically be omitted.
|
|
19
|
+
*/
|
|
20
|
+
size: 'small' | 'medium' | 'large';
|
|
21
|
+
/** Disables the radio. */
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
constructor();
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
private setInitialAttributes;
|
|
26
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
27
|
+
/**
|
|
28
|
+
* @override
|
|
29
|
+
*/
|
|
30
|
+
setValue(): void;
|
|
31
|
+
private handleClick;
|
|
32
|
+
render(): import("lit").TemplateResult<1>;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'w-radio': WRadio;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { BaseFormAssociatedElement } from './form-associated-element';
|
|
10
|
+
// eslint-disable-next-line
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
import { styles } from './radio-styles';
|
|
13
|
+
export class WRadio extends BaseFormAssociatedElement {
|
|
14
|
+
static { this.css = [styles]; }
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.checked = false;
|
|
18
|
+
/** @internal Used by radio group to force disable radios while preserving their original disabled state. */
|
|
19
|
+
this.forceDisabled = false;
|
|
20
|
+
/**
|
|
21
|
+
* The string pointing to a form's id.
|
|
22
|
+
*/
|
|
23
|
+
this.form = null;
|
|
24
|
+
/** The radio's value. When selected, the radio group will receive this value. */
|
|
25
|
+
this.appearance = 'default';
|
|
26
|
+
/**
|
|
27
|
+
* The radio's size. When used inside a radio group, the size will be determined by the radio group's size so this
|
|
28
|
+
* attribute can typically be omitted.
|
|
29
|
+
*/
|
|
30
|
+
this.size = 'medium';
|
|
31
|
+
/** Disables the radio. */
|
|
32
|
+
this.disabled = false;
|
|
33
|
+
// Update the handleClick method (around line 75)
|
|
34
|
+
this.handleClick = () => {
|
|
35
|
+
if (!this.disabled && !this.forceDisabled) {
|
|
36
|
+
this.checked = true;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
this.addEventListener('click', this.handleClick);
|
|
40
|
+
}
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
super.connectedCallback();
|
|
43
|
+
this.setInitialAttributes();
|
|
44
|
+
}
|
|
45
|
+
setInitialAttributes() {
|
|
46
|
+
this.setAttribute('role', 'radio');
|
|
47
|
+
this.tabIndex = 0;
|
|
48
|
+
this.setAttribute('aria-disabled', this.disabled || this.forceDisabled ? 'true' : 'false');
|
|
49
|
+
}
|
|
50
|
+
updated(changedProperties) {
|
|
51
|
+
super.updated(changedProperties);
|
|
52
|
+
if (changedProperties.has('checked')) {
|
|
53
|
+
this.customStates.set('checked', this.checked);
|
|
54
|
+
this.setAttribute('aria-checked', this.checked ? 'true' : 'false');
|
|
55
|
+
// Only set tabIndex if not disabled
|
|
56
|
+
if (!this.disabled && !this.forceDisabled) {
|
|
57
|
+
this.tabIndex = this.checked ? 0 : -1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (changedProperties.has('disabled') || changedProperties.has('forceDisabled')) {
|
|
61
|
+
const effectivelyDisabled = this.disabled || this.forceDisabled;
|
|
62
|
+
this.customStates.set('disabled', effectivelyDisabled);
|
|
63
|
+
this.setAttribute('aria-disabled', effectivelyDisabled ? 'true' : 'false');
|
|
64
|
+
// Set tabIndex based on disabled state
|
|
65
|
+
if (effectivelyDisabled) {
|
|
66
|
+
this.tabIndex = -1;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Restore proper tabIndex - this will be managed by the radio group
|
|
70
|
+
this.tabIndex = this.checked ? 0 : -1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @override
|
|
76
|
+
*/
|
|
77
|
+
setValue() {
|
|
78
|
+
// We override `setValue` because we don't want to set form values from here. We want to do that in "RadioGroup" itself.
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
return html `
|
|
82
|
+
<span part="control" class="control"></span>
|
|
83
|
+
<slot part="label" class="label"></slot>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
__decorate([
|
|
88
|
+
state()
|
|
89
|
+
], WRadio.prototype, "checked", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
state()
|
|
92
|
+
], WRadio.prototype, "forceDisabled", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
property({ reflect: true })
|
|
95
|
+
], WRadio.prototype, "form", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ reflect: true })
|
|
98
|
+
], WRadio.prototype, "value", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ reflect: true })
|
|
101
|
+
], WRadio.prototype, "appearance", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
property({ reflect: true })
|
|
104
|
+
], WRadio.prototype, "size", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
property({ type: Boolean })
|
|
107
|
+
], WRadio.prototype, "disabled", void 0);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Validator } from './form-associated-element';
|
|
2
|
+
export interface RequiredValidatorOptions {
|
|
3
|
+
/** This is a cheap way for us to get translation strings for the user without having proper translations. */
|
|
4
|
+
validationElement?: HTMLSelectElement | HTMLInputElement;
|
|
5
|
+
/**
|
|
6
|
+
* The property to check if its not null-ish. For most elements this will be "value".
|
|
7
|
+
* For "checkbox" for example it will be "checked"
|
|
8
|
+
*/
|
|
9
|
+
validationProperty?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const RequiredValidator: (options?: RequiredValidatorOptions) => Validator;
|