@warp-ds/elements 2.2.0-next.2 → 2.2.0-next.21
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 +228 -28
- 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 +7146 -0
- package/dist/index.d.ts +1847 -18
- package/dist/packages/affix/affix.react.stories.d.ts +9 -0
- package/dist/packages/affix/affix.react.stories.js +10 -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 +47 -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 +15 -0
- package/dist/packages/affix/styles.d.ts +1 -0
- package/dist/packages/affix/styles.js +2 -0
- package/dist/packages/alert/alert.react.stories.d.ts +13 -0
- package/dist/packages/alert/alert.react.stories.js +44 -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 +18 -0
- package/dist/packages/alert/index.d.ts +21 -16
- 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 +11 -0
- package/dist/packages/alert/styles.d.ts +1 -0
- package/dist/packages/alert/styles.js +2 -0
- package/dist/packages/attention/attention.react.stories.d.ts +15 -0
- package/dist/packages/attention/attention.react.stories.js +92 -0
- package/dist/packages/attention/attention.stories.d.ts +15 -0
- package/dist/packages/attention/attention.stories.js +173 -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 -89
- package/dist/packages/attention/index.js +3521 -3924
- 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 +15 -0
- package/dist/packages/attention/react.js +17 -0
- package/dist/packages/attention/styles.d.ts +1 -0
- package/dist/packages/attention/styles.js +2 -0
- package/dist/packages/badge/badge.react.stories.d.ts +18 -0
- package/dist/packages/badge/badge.react.stories.js +60 -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 +12 -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 +11 -0
- package/dist/packages/badge/styles.d.ts +1 -0
- package/dist/packages/badge/styles.js +2 -0
- package/dist/packages/box/box.react.stories.d.ts +15 -0
- package/dist/packages/box/box.react.stories.js +45 -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 +17 -20
- package/dist/packages/box/index.js +2443 -299
- package/dist/packages/box/index.js.map +4 -4
- package/dist/packages/box/react.d.ts +2 -0
- package/dist/packages/box/react.js +11 -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.react.stories.d.ts +13 -0
- package/dist/packages/breadcrumbs/breadcrumbs.react.stories.js +40 -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 +19 -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 +11 -0
- package/dist/packages/breadcrumbs/styles.d.ts +1 -0
- package/dist/packages/breadcrumbs/styles.js +2 -0
- package/dist/packages/button/button.react.stories.d.ts +22 -0
- package/dist/packages/button/button.react.stories.js +102 -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 +25 -0
- package/dist/packages/button/index.d.ts +106 -56
- package/dist/packages/button/index.js +2618 -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 +11 -0
- package/dist/packages/button/styles.d.ts +1 -0
- package/dist/packages/button/styles.js +2 -0
- package/dist/packages/card/card.react.stories.d.ts +16 -0
- package/dist/packages/card/card.react.stories.js +63 -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 +27 -15
- 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 +11 -0
- package/dist/packages/card/styles.d.ts +1 -0
- package/dist/packages/card/styles.js +2 -0
- package/dist/packages/combobox/combobox.react.stories.d.ts +28 -0
- package/dist/packages/combobox/combobox.react.stories.js +90 -0
- package/dist/packages/combobox/combobox.stories.d.ts +18 -0
- package/dist/packages/combobox/combobox.stories.js +117 -0
- package/dist/packages/combobox/index.d.ts +95 -0
- package/dist/packages/combobox/index.js +2492 -0
- package/dist/packages/combobox/index.js.map +7 -0
- package/dist/packages/combobox/locales/da/messages.d.mts +1 -0
- package/dist/packages/combobox/locales/da/messages.mjs +1 -0
- package/dist/packages/combobox/locales/en/messages.d.mts +1 -0
- package/dist/packages/combobox/locales/en/messages.mjs +1 -0
- package/dist/packages/combobox/locales/fi/messages.d.mts +1 -0
- package/dist/packages/combobox/locales/fi/messages.mjs +1 -0
- package/dist/packages/combobox/locales/nb/messages.d.mts +1 -0
- package/dist/packages/combobox/locales/nb/messages.mjs +1 -0
- package/dist/packages/combobox/locales/sv/messages.d.mts +1 -0
- package/dist/packages/combobox/locales/sv/messages.mjs +1 -0
- package/dist/packages/combobox/react.d.ts +7 -0
- package/dist/packages/combobox/react.js +17 -0
- package/dist/packages/combobox/styles.d.ts +1 -0
- package/dist/packages/combobox/styles.js +2 -0
- package/dist/packages/datepicker/DatePicker.test.d.ts +2 -0
- package/dist/packages/datepicker/DatePicker.test.js +69 -0
- package/dist/packages/datepicker/datepicker.d.ts +102 -0
- package/dist/packages/datepicker/datepicker.js +2785 -0
- package/dist/packages/datepicker/datepicker.js.map +7 -0
- package/dist/packages/datepicker/datepicker.react.stories.d.ts +18 -0
- package/dist/packages/datepicker/datepicker.react.stories.js +26 -0
- package/dist/packages/datepicker/datepicker.stories.d.ts +12 -0
- package/dist/packages/datepicker/datepicker.stories.js +51 -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 +5 -0
- package/dist/packages/datepicker/react.js +15 -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.react.stories.d.ts +15 -0
- package/dist/packages/dead-toggle/dead-toggle.react.stories.js +34 -0
- package/dist/packages/dead-toggle/dead-toggle.stories.d.ts +14 -0
- package/dist/packages/dead-toggle/dead-toggle.stories.js +45 -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 +16 -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 +11 -0
- package/dist/packages/expandable/expandable.react.stories.d.ts +18 -0
- package/dist/packages/expandable/expandable.react.stories.js +103 -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 +52 -50
- package/dist/packages/expandable/index.js +2424 -2286
- package/dist/packages/expandable/index.js.map +4 -4
- package/dist/packages/expandable/react.d.ts +2 -0
- package/dist/packages/expandable/react.js +11 -0
- package/dist/packages/expandable/styles.d.ts +1 -0
- package/dist/packages/expandable/styles.js +2 -0
- package/dist/packages/i18n.js +45 -0
- package/dist/packages/link/index.d.ts +34 -0
- package/dist/packages/link/index.js +2646 -0
- package/dist/packages/link/index.js.map +7 -0
- package/dist/packages/link/link.react.stories.d.ts +21 -0
- package/dist/packages/link/link.react.stories.js +96 -0
- package/dist/packages/link/link.stories.d.ts +20 -0
- package/dist/packages/link/link.stories.js +110 -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 +11 -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 -2575
- 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 +13 -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 +25 -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 +27 -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.react.stories.d.ts +14 -0
- package/dist/packages/modal/modal.react.stories.js +27 -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 +12 -0
- package/dist/packages/modal/react.js +31 -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 +10 -0
- package/dist/packages/pageindicator/index.js +32 -0
- package/dist/packages/pageindicator/index.js.map +7 -0
- package/dist/packages/pageindicator/pageindicator.react.stories.d.ts +19 -0
- package/dist/packages/pageindicator/pageindicator.react.stories.js +20 -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 +11 -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 +32 -0
- package/dist/packages/pagination/index.js +2500 -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.react.stories.d.ts +21 -0
- package/dist/packages/pagination/pagination.react.stories.js +45 -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 +5 -0
- package/dist/packages/pagination/react.js +15 -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 +39 -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.react.stories.d.ts +23 -0
- package/dist/packages/pill/pill.react.stories.js +22 -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 +25 -0
- package/dist/packages/pill/react.d.ts +7 -0
- package/dist/packages/pill/react.js +17 -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 +160 -0
- package/dist/packages/rip-and-tear-checkbox/checkbox.js.map +7 -0
- package/dist/packages/rip-and-tear-checkbox/checkbox.stories.d.ts +8 -0
- package/dist/packages/rip-and-tear-checkbox/checkbox.stories.js +11 -0
- package/dist/packages/rip-and-tear-checkbox/index.d.ts +1 -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/react.d.ts +5 -0
- package/dist/packages/rip-and-tear-checkbox/react.js +15 -0
- package/dist/packages/rip-and-tear-checkbox/rip-and-tear-checkbox.react.stories.d.ts +12 -0
- package/dist/packages/rip-and-tear-checkbox/rip-and-tear-checkbox.react.stories.js +10 -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 +1 -0
- package/dist/packages/rip-and-tear-radio/index.js +270 -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-styles.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio-group.d.ts +72 -0
- package/dist/packages/rip-and-tear-radio/radio-group.js +270 -0
- package/dist/packages/rip-and-tear-radio/radio-group.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio-styles.d.ts +1 -0
- package/dist/packages/rip-and-tear-radio/radio-styles.js +170 -0
- package/dist/packages/rip-and-tear-radio/radio-styles.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio.d.ts +38 -0
- package/dist/packages/rip-and-tear-radio/radio.js +183 -0
- package/dist/packages/rip-and-tear-radio/radio.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/radio.stories.d.ts +8 -0
- package/dist/packages/rip-and-tear-radio/radio.stories.js +275 -0
- package/dist/packages/rip-and-tear-radio/radio.stories.js.map +7 -0
- package/dist/packages/rip-and-tear-radio/react.d.ts +9 -0
- package/dist/packages/rip-and-tear-radio/react.js +22 -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/rip-and-tear-radio.react.stories.d.ts +9 -0
- package/dist/packages/rip-and-tear-radio/rip-and-tear-radio.react.stories.js +10 -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 +56 -50
- 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 +6 -0
- package/dist/packages/select/react.js +20 -0
- package/dist/packages/select/select.react.stories.d.ts +18 -0
- package/dist/packages/select/select.react.stories.js +28 -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/slider/Slider.d.ts +2 -0
- package/dist/packages/slider/Slider.js +8 -0
- package/dist/packages/slider/SliderThumb.d.ts +2 -0
- package/dist/packages/slider/SliderThumb.js +8 -0
- package/dist/packages/slider/index.d.ts +2 -0
- package/dist/packages/slider/index.js +2791 -0
- package/dist/packages/slider/index.js.map +7 -0
- package/dist/packages/slider/oddbird-css-anchor-positioning.d.ts +2 -0
- package/dist/packages/slider/oddbird-css-anchor-positioning.js +3 -0
- package/dist/packages/slider/react.d.ts +8 -0
- package/dist/packages/slider/react.js +20 -0
- package/dist/packages/slider/slider-thumb.d.ts +57 -0
- package/dist/packages/slider/slider-thumb.js +2663 -0
- package/dist/packages/slider/slider-thumb.js.map +7 -0
- package/dist/packages/slider/slider.d.ts +46 -0
- package/dist/packages/slider/slider.js +2569 -0
- package/dist/packages/slider/slider.js.map +7 -0
- package/dist/packages/slider/slider.react.stories.d.ts +18 -0
- package/dist/packages/slider/slider.react.stories.js +119 -0
- package/dist/packages/slider/slider.stories.d.ts +17 -0
- package/dist/packages/slider/slider.stories.js +203 -0
- package/dist/packages/slider/slider.test.d.ts +4 -0
- package/dist/packages/slider/slider.test.js +83 -0
- package/dist/packages/slider/styles/w-slider-thumb.styles.d.ts +1 -0
- package/dist/packages/slider/styles/w-slider-thumb.styles.js +132 -0
- package/dist/packages/slider/styles/w-slider.styles.d.ts +1 -0
- package/dist/packages/slider/styles/w-slider.styles.js +118 -0
- package/dist/packages/slider/styles.d.ts +1 -0
- package/dist/packages/slider/styles.js +2 -0
- package/dist/packages/steps/index.d.ts +36 -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 +16 -0
- package/dist/packages/steps/steps.react.stories.d.ts +15 -0
- package/dist/packages/steps/steps.react.stories.js +112 -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 +15 -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 +5 -0
- package/dist/packages/switch/react.js +15 -0
- package/dist/packages/switch/styles.d.ts +1 -0
- package/dist/packages/switch/styles.js +2 -0
- package/dist/packages/switch/switch.react.stories.d.ts +15 -0
- package/dist/packages/switch/switch.react.stories.js +29 -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 +12 -0
- package/dist/packages/tabs/react.js +31 -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 +2441 -0
- package/dist/packages/tabs/tab-panel.js.map +7 -0
- package/dist/packages/tabs/tab.d.ts +18 -0
- package/dist/packages/tabs/tab.js +2463 -0
- package/dist/packages/tabs/tab.js.map +7 -0
- package/dist/packages/tabs/tabs.d.ts +40 -0
- package/dist/packages/tabs/tabs.js +2448 -0
- package/dist/packages/tabs/tabs.js.map +7 -0
- package/dist/packages/tabs/tabs.react.stories.d.ts +15 -0
- package/dist/packages/tabs/tabs.react.stories.js +51 -0
- package/dist/packages/tabs/tabs.stories.d.ts +8 -0
- package/dist/packages/tabs/tabs.stories.js +2545 -0
- package/dist/packages/tabs/tabs.stories.js.map +7 -0
- package/dist/packages/textfield/index.d.ts +78 -74
- package/dist/packages/textfield/index.js +2514 -422
- package/dist/packages/textfield/index.js.map +4 -4
- package/dist/packages/textfield/react.d.ts +11 -0
- package/dist/packages/textfield/react.js +21 -0
- package/dist/packages/textfield/styles/w-textfield.styles.d.ts +1 -0
- package/dist/packages/textfield/styles/w-textfield.styles.js +46 -0
- package/dist/packages/textfield/styles.d.ts +1 -0
- package/dist/packages/textfield/styles.js +2 -0
- package/dist/packages/textfield/textfield.react.stories.d.ts +37 -0
- package/dist/packages/textfield/textfield.react.stories.js +88 -0
- package/dist/packages/textfield/textfield.stories.d.ts +18 -0
- package/dist/packages/textfield/textfield.stories.js +105 -0
- package/dist/packages/textfield/textfield.test.d.ts +2 -0
- package/dist/packages/textfield/textfield.test.js +68 -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 +2458 -0
- package/dist/packages/toast/toast-container.js.map +7 -0
- package/dist/packages/toast/toast.d.ts +34 -29
- package/dist/packages/toast/toast.js +2466 -0
- package/dist/packages/toast/toast.js.map +7 -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 +738 -0
- package/dist/web-types.json +1693 -0
- package/package.json +93 -37
- package/dist/index.js +0 -6838
- package/dist/index.js.map +0 -7
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Affix } from '../affix/react';
|
|
3
|
+
import { TextField } from './react';
|
|
4
|
+
const locale = 'nb';
|
|
5
|
+
const getNumberFormatter = (locale, opts = {}) => {
|
|
6
|
+
return (value) => new Intl.NumberFormat(locale, { maximumFractionDigits: 0, ...opts }).format(value);
|
|
7
|
+
};
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Forms/Textfield',
|
|
10
|
+
render(args) {
|
|
11
|
+
return React.createElement(TextField, { ...args });
|
|
12
|
+
},
|
|
13
|
+
component: TextField,
|
|
14
|
+
};
|
|
15
|
+
export const Default = {
|
|
16
|
+
args: {
|
|
17
|
+
label: 'Email',
|
|
18
|
+
type: 'email',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export const WithPlaceholder = {
|
|
22
|
+
args: {
|
|
23
|
+
label: 'Email',
|
|
24
|
+
placeholder: 'user@example.com',
|
|
25
|
+
type: 'email',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const WithHelpText = {
|
|
29
|
+
args: {
|
|
30
|
+
label: 'Password',
|
|
31
|
+
helpText: 'Must be at least 8 characters',
|
|
32
|
+
type: 'password',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export const Invalid = {
|
|
36
|
+
args: {
|
|
37
|
+
label: 'Email',
|
|
38
|
+
invalid: true,
|
|
39
|
+
helpText: 'Please enter a valid email address',
|
|
40
|
+
value: 'invalid-email',
|
|
41
|
+
type: 'email',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export const Disabled = {
|
|
45
|
+
args: {
|
|
46
|
+
label: 'Email',
|
|
47
|
+
disabled: true,
|
|
48
|
+
value: 'user@example.com',
|
|
49
|
+
type: 'email',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export const ReadOnly = {
|
|
53
|
+
args: {
|
|
54
|
+
label: 'Email',
|
|
55
|
+
readOnly: true,
|
|
56
|
+
value: 'user@example.com',
|
|
57
|
+
type: 'email',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export const Required = {
|
|
61
|
+
args: {
|
|
62
|
+
label: 'Email',
|
|
63
|
+
required: true,
|
|
64
|
+
type: 'email',
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
export const WithAffix = {
|
|
68
|
+
args: {
|
|
69
|
+
label: 'Price',
|
|
70
|
+
placeholder: '1 000 000',
|
|
71
|
+
type: 'text',
|
|
72
|
+
},
|
|
73
|
+
render(args) {
|
|
74
|
+
return (React.createElement(TextField, { ...args },
|
|
75
|
+
React.createElement(Affix, { slot: "suffix", label: "kr" })));
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
export const Masking = {
|
|
79
|
+
args: {
|
|
80
|
+
label: 'Price',
|
|
81
|
+
placeholder: '1 000 000',
|
|
82
|
+
type: 'text',
|
|
83
|
+
},
|
|
84
|
+
render({ ...args }) {
|
|
85
|
+
return (React.createElement(TextField, { ...args, formatter: getNumberFormatter(locale) },
|
|
86
|
+
React.createElement(Affix, { slot: "suffix", label: "kr" })));
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components-vite';
|
|
2
|
+
import type { WarpTextField } from './index.js';
|
|
3
|
+
import './index.js';
|
|
4
|
+
declare const args: Partial<WarpTextField> & {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
declare const meta: Meta<typeof args>;
|
|
8
|
+
export default meta;
|
|
9
|
+
type Story = StoryObj<typeof args>;
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
export declare const WithPlaceholder: Story;
|
|
12
|
+
export declare const WithHelpText: Story;
|
|
13
|
+
export declare const Invalid: Story;
|
|
14
|
+
export declare const Disabled: Story;
|
|
15
|
+
export declare const ReadOnly: Story;
|
|
16
|
+
export declare const Required: Story;
|
|
17
|
+
export declare const WithAffix: Story;
|
|
18
|
+
export declare const Masking: Story;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { spread } from '@open-wc/lit-helpers';
|
|
2
|
+
import { getStorybookHelpers } from '@wc-toolkit/storybook-helpers';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { prespread } from '../../.storybook/utilities.js';
|
|
5
|
+
import './index.js';
|
|
6
|
+
const { events, args, argTypes } = getStorybookHelpers('w-textfield');
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Forms/Textfield',
|
|
9
|
+
render(args) {
|
|
10
|
+
return html `<w-textfield ${spread(prespread(args))}></w-textfield>`;
|
|
11
|
+
},
|
|
12
|
+
args,
|
|
13
|
+
argTypes,
|
|
14
|
+
parameters: {
|
|
15
|
+
actions: {
|
|
16
|
+
handles: events,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
export const Default = {
|
|
22
|
+
args: {
|
|
23
|
+
label: 'Email',
|
|
24
|
+
type: 'email',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const WithPlaceholder = {
|
|
28
|
+
args: {
|
|
29
|
+
label: 'Email',
|
|
30
|
+
placeholder: 'user@example.com',
|
|
31
|
+
type: 'email',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export const WithHelpText = {
|
|
35
|
+
args: {
|
|
36
|
+
label: 'Password',
|
|
37
|
+
'help-text': 'Must be at least 8 characters',
|
|
38
|
+
type: 'password',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
export const Invalid = {
|
|
42
|
+
args: {
|
|
43
|
+
label: 'Email',
|
|
44
|
+
invalid: true,
|
|
45
|
+
'help-text': 'Please enter a valid email address',
|
|
46
|
+
value: 'invalid-email',
|
|
47
|
+
type: 'email',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export const Disabled = {
|
|
51
|
+
args: {
|
|
52
|
+
label: 'Email',
|
|
53
|
+
disabled: true,
|
|
54
|
+
value: 'user@example.com',
|
|
55
|
+
type: 'email',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
export const ReadOnly = {
|
|
59
|
+
args: {
|
|
60
|
+
label: 'Email',
|
|
61
|
+
'read-only': true,
|
|
62
|
+
value: 'user@example.com',
|
|
63
|
+
type: 'email',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export const Required = {
|
|
67
|
+
args: {
|
|
68
|
+
label: 'Email',
|
|
69
|
+
required: true,
|
|
70
|
+
type: 'email',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
export const WithAffix = {
|
|
74
|
+
args: {
|
|
75
|
+
label: 'Price',
|
|
76
|
+
placeholder: '1 000 000',
|
|
77
|
+
type: 'text',
|
|
78
|
+
},
|
|
79
|
+
render(args) {
|
|
80
|
+
return html `
|
|
81
|
+
<w-textfield ${spread(prespread(args))}>
|
|
82
|
+
<w-affix slot="suffix" label="kr"></w-affix>
|
|
83
|
+
</w-textfield>
|
|
84
|
+
`;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
export const Masking = {
|
|
88
|
+
args: {
|
|
89
|
+
label: 'Price',
|
|
90
|
+
placeholder: '1 000 000',
|
|
91
|
+
type: 'text',
|
|
92
|
+
locale: 'nb',
|
|
93
|
+
},
|
|
94
|
+
render({ locale, ...args }) {
|
|
95
|
+
return html `
|
|
96
|
+
<w-textfield ${spread(prespread(args))} data-testid="masking">
|
|
97
|
+
<w-affix slot="suffix" label="kr"></w-affix>
|
|
98
|
+
</w-textfield>
|
|
99
|
+
<script type="module">
|
|
100
|
+
const maskingTextfield = document.querySelector('w-textfield[data-testid="masking"]');
|
|
101
|
+
maskingTextfield.formatter = window.getNumberFormatter('${locale}').format;
|
|
102
|
+
</script>
|
|
103
|
+
`;
|
|
104
|
+
},
|
|
105
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { userEvent } from '@vitest/browser/context';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { expect, test, vi } from 'vitest';
|
|
4
|
+
import { render } from 'vitest-browser-lit';
|
|
5
|
+
import '../affix/index.js';
|
|
6
|
+
import './index.js';
|
|
7
|
+
test('renders the textfield', async () => {
|
|
8
|
+
const component = html `<w-textfield label="Test label"></w-textfield>`;
|
|
9
|
+
const page = render(component);
|
|
10
|
+
await expect.element(page.getByText('Test label')).toBeVisible();
|
|
11
|
+
});
|
|
12
|
+
test('works as expected in forms', async () => {
|
|
13
|
+
const label = 'Test label';
|
|
14
|
+
const component = html `
|
|
15
|
+
<form data-testid="form">
|
|
16
|
+
<w-textfield label="${label}" name="message" value="Hola el Mundo"></w-textfield>
|
|
17
|
+
</form>
|
|
18
|
+
`;
|
|
19
|
+
const page = render(component);
|
|
20
|
+
await expect.element(page.getByLabelText(label)).toHaveValue('Hola el Mundo');
|
|
21
|
+
let formData = new FormData(page.getByTestId('form').element());
|
|
22
|
+
expect(formData.get('message')).toBe('Hola el Mundo');
|
|
23
|
+
const inputHandler = vi.fn();
|
|
24
|
+
const changeHandler = vi.fn();
|
|
25
|
+
page.getByLabelText(label).element().addEventListener('input', inputHandler);
|
|
26
|
+
page.getByLabelText(label).element().addEventListener('change', changeHandler);
|
|
27
|
+
await page.getByLabelText(label).fill('Hello, World');
|
|
28
|
+
expect(inputHandler).toHaveBeenCalled();
|
|
29
|
+
expect(changeHandler).not.toHaveBeenCalled();
|
|
30
|
+
await userEvent.tab(); // trigger a blur to fire the change event
|
|
31
|
+
expect(changeHandler).toHaveBeenCalled();
|
|
32
|
+
await expect.element(page.getByLabelText(label)).toHaveValue('Hello, World');
|
|
33
|
+
formData = new FormData(page.getByTestId('form').element());
|
|
34
|
+
expect(formData.get('message')).toBe('Hello, World');
|
|
35
|
+
});
|
|
36
|
+
test('renders help text if provided', async () => {
|
|
37
|
+
const component = html `<w-textfield label="Test label" help-text="Helpful help text"></w-textfield>`;
|
|
38
|
+
const page = render(component);
|
|
39
|
+
await expect.element(page.getByText('Helpful help text')).toBeVisible();
|
|
40
|
+
});
|
|
41
|
+
test('marks input field as aria-invalid if the invalid prop is true', async () => {
|
|
42
|
+
const component = html `<w-textfield label="Test label" invalid help-text="No, bad input!"></w-textfield>`;
|
|
43
|
+
const page = render(component);
|
|
44
|
+
await expect.element(page.getByLabelText('Test label')).toHaveAccessibleErrorMessage('No, bad input!');
|
|
45
|
+
});
|
|
46
|
+
test('marks input field as readonly if the read-only prop is true', async () => {
|
|
47
|
+
const component = html `<w-textfield label="Test label" read-only></w-textfield>`;
|
|
48
|
+
const page = render(component);
|
|
49
|
+
await expect.element(page.getByLabelText('Test label')).toHaveAttribute('readonly', '');
|
|
50
|
+
});
|
|
51
|
+
test('renders affix component in the prefix slot', async () => {
|
|
52
|
+
const component = html `
|
|
53
|
+
<w-textfield label="Test label">
|
|
54
|
+
<w-affix slot="prefix" label="kr"></w-affix>
|
|
55
|
+
</w-textfield>
|
|
56
|
+
`;
|
|
57
|
+
const page = render(component);
|
|
58
|
+
await expect.element(page.getByText('kr')).toBeVisible();
|
|
59
|
+
});
|
|
60
|
+
test('renders affix component in the suffix slot', async () => {
|
|
61
|
+
const component = html `
|
|
62
|
+
<w-textfield label="Test label">
|
|
63
|
+
<w-affix slot="suffix" label="kr"></w-affix>
|
|
64
|
+
</w-textfield>
|
|
65
|
+
`;
|
|
66
|
+
const page = render(component);
|
|
67
|
+
await expect.element(page.getByText('kr')).toBeVisible();
|
|
68
|
+
});
|
|
@@ -1,54 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
* Toast helper function options
|
|
3
|
-
* @typedef {Object} ToastOptions
|
|
4
|
-
* @property {(number|string)} [id] Custom identifier
|
|
5
|
-
* @property {('success'|'error'|'warning')} [type] Type of toast
|
|
6
|
-
* @property {String} [text] The toast message. Only needed when updating text on existing toast
|
|
7
|
-
* @property {(number|string)} [duration] Duration of toast in milliseconds. Defaults to 5000. For accessibility reasons, toasts should never be interactive and therefore need to auto remove. If you must disable auto remove, set duration to Number.POSITIVE_INFINITY.
|
|
8
|
-
* @property {Boolean} [canclose] Whether the toast can be dismissed. Defaults to false. WARNING! For accessibility reasons, toasts should not be interactive and canclose should always be false. If the toast absolutely must be dismissable, set this to true.
|
|
9
|
-
*/
|
|
1
|
+
import type { ToastInternal, ToastOptions } from './types';
|
|
10
2
|
/**
|
|
11
3
|
* Creates a new toast
|
|
12
|
-
* @param {String} message Message
|
|
13
|
-
* @param {ToastOptions?} options Toast options
|
|
14
|
-
* @returns {ToastOptions} Toast details
|
|
15
4
|
*/
|
|
16
|
-
export function toast(message: string, options
|
|
5
|
+
export declare function toast(message: string, options?: ToastOptions): ToastOptions;
|
|
17
6
|
/**
|
|
18
7
|
* Remove an existing toast
|
|
19
|
-
* @param {String|Number} id Toast identifier
|
|
20
|
-
* @return {Promise<Boolean>} Resolves to true if deleted, false if not found
|
|
21
8
|
*/
|
|
22
|
-
export function removeToast(id: string | number): Promise<boolean
|
|
9
|
+
export declare function removeToast(id: string | number): Promise<boolean> | undefined;
|
|
23
10
|
/**
|
|
24
11
|
* Update an existing toast
|
|
25
|
-
* @param {String|Number} id Toast identifier
|
|
26
|
-
* @param {ToastOptions?} options Toast options
|
|
27
|
-
* @returns {WarpToastContainer} Toast details
|
|
28
|
-
*/
|
|
29
|
-
export function updateToast(id: string | number, options: ToastOptions | null): WarpToastContainer;
|
|
30
|
-
/**
|
|
31
|
-
* Toast helper function options
|
|
32
12
|
*/
|
|
33
|
-
export
|
|
34
|
-
/**
|
|
35
|
-
* Custom identifier
|
|
36
|
-
*/
|
|
37
|
-
id?: (number | string);
|
|
38
|
-
/**
|
|
39
|
-
* Type of toast
|
|
40
|
-
*/
|
|
41
|
-
type?: ("success" | "error" | "warning");
|
|
42
|
-
/**
|
|
43
|
-
* The toast message. Only needed when updating text on existing toast
|
|
44
|
-
*/
|
|
45
|
-
text?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Duration of toast in milliseconds. Defaults to 5000. For accessibility reasons, toasts should never be interactive and therefore need to auto remove. If you must disable auto remove, set duration to Number.POSITIVE_INFINITY.
|
|
48
|
-
*/
|
|
49
|
-
duration?: (number | string);
|
|
50
|
-
/**
|
|
51
|
-
* Whether the toast can be dismissed. Defaults to false. WARNING! For accessibility reasons, toasts should not be interactive and canclose should always be false. If the toast absolutely must be dismissable, set this to true.
|
|
52
|
-
*/
|
|
53
|
-
canclose?: boolean;
|
|
54
|
-
};
|
|
13
|
+
export declare function updateToast(id: string | number, options?: ToastOptions): ToastInternal | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { windowExists } from '../utils/window-exists';
|
|
2
|
+
function getToastContainer() {
|
|
3
|
+
const container = customElements.get('w-toast-container');
|
|
4
|
+
return container;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new toast
|
|
8
|
+
*/
|
|
9
|
+
export function toast(message, options) {
|
|
10
|
+
if (!windowExists)
|
|
11
|
+
return;
|
|
12
|
+
const toast = getToastContainer().init();
|
|
13
|
+
const data = {
|
|
14
|
+
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),
|
|
15
|
+
text: message,
|
|
16
|
+
duration: 5000,
|
|
17
|
+
type: 'success',
|
|
18
|
+
...options,
|
|
19
|
+
};
|
|
20
|
+
toast.set(data);
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Remove an existing toast
|
|
25
|
+
*/
|
|
26
|
+
export function removeToast(id) {
|
|
27
|
+
if (!windowExists)
|
|
28
|
+
return;
|
|
29
|
+
const toast = getToastContainer().init();
|
|
30
|
+
return toast.del(id);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Update an existing toast
|
|
34
|
+
*/
|
|
35
|
+
export function updateToast(id, options) {
|
|
36
|
+
if (!windowExists)
|
|
37
|
+
return;
|
|
38
|
+
const toast = getToastContainer().init();
|
|
39
|
+
toast.set({ ...toast.get(id), ...options });
|
|
40
|
+
return toast.get(id);
|
|
41
|
+
}
|