@techsio/ui-kit 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -6
- package/dist/.storybook/decorator.d.ts +12 -0
- package/dist/.storybook/decorator.d.ts.map +1 -0
- package/dist/.storybook/main.d.ts +4 -0
- package/dist/.storybook/main.d.ts.map +1 -0
- package/dist/.storybook/preview.d.ts +5 -0
- package/dist/.storybook/preview.d.ts.map +1 -0
- package/dist/.storybook/test-runner.d.ts +12 -0
- package/dist/.storybook/test-runner.d.ts.map +1 -0
- package/dist/atoms/badge.js +37 -19
- package/dist/atoms/button.js +167 -154
- package/dist/atoms/checkbox.js +52 -0
- package/dist/atoms/figma/badge.figma.js +33 -0
- package/dist/atoms/figma/button.figma.js +76 -0
- package/dist/atoms/figma/checkbox.figma.js +35 -0
- package/dist/atoms/figma/icon.figma.js +33 -0
- package/dist/atoms/figma/image.figma.js +21 -0
- package/dist/atoms/figma/input.figma.js +34 -0
- package/dist/atoms/figma/label.figma.js +25 -0
- package/dist/atoms/figma/link-button.figma.js +42 -0
- package/dist/atoms/figma/link.figma.js +15 -0
- package/dist/atoms/figma/numeric-input.figma.js +52 -0
- package/dist/atoms/figma/rating.figma.js +38 -0
- package/dist/atoms/figma/skeleton.figma.js +119 -0
- package/dist/atoms/figma/status-text.figma.js +27 -0
- package/dist/atoms/figma/textarea.figma.js +38 -0
- package/dist/atoms/figma/tooltip.figma.js +47 -0
- package/dist/atoms/icon.js +17 -17
- package/dist/atoms/image.js +22 -4
- package/dist/atoms/input.js +40 -34
- package/dist/atoms/label.js +10 -10
- package/dist/atoms/link-button.js +19 -18
- package/dist/atoms/link.js +6 -4
- package/dist/atoms/numeric-input.js +98 -70
- package/dist/atoms/rating.js +30 -30
- package/dist/atoms/skeleton.js +47 -47
- package/dist/atoms/status-text.js +75 -0
- package/dist/atoms/textarea.js +48 -42
- package/dist/atoms/tooltip.js +17 -17
- package/dist/molecules/accordion.js +58 -60
- package/dist/molecules/breadcrumb.js +206 -124
- package/dist/molecules/carousel.js +139 -87
- package/dist/molecules/color-select.js +56 -56
- package/dist/molecules/combobox.js +131 -104
- package/dist/molecules/dialog.js +97 -97
- package/dist/molecules/figma/accordion.figma.js +41 -0
- package/dist/molecules/figma/breadcrumb.figma.js +31 -0
- package/dist/molecules/figma/carousel.figma.js +34 -0
- package/dist/molecules/figma/combobox.figma.js +38 -0
- package/dist/molecules/figma/dialog.figma.js +24 -0
- package/dist/molecules/figma/form-checkbox.figma.js +41 -0
- package/dist/molecules/figma/form-input.figma.js +38 -0
- package/dist/molecules/figma/form-numeric-input.figma.js +67 -0
- package/dist/molecules/figma/form-textarea.figma.js +38 -0
- package/dist/molecules/figma/menu.figma.js +26 -0
- package/dist/molecules/figma/pagination.figma.js +22 -0
- package/dist/molecules/figma/popover.figma.js +38 -0
- package/dist/molecules/figma/product-card.figma.js +34 -0
- package/dist/molecules/figma/radio-card.figma.js +35 -0
- package/dist/molecules/figma/radio-group.figma.js +45 -0
- package/dist/molecules/figma/search-form.figma.js +24 -0
- package/dist/molecules/figma/select.figma.js +46 -0
- package/dist/molecules/figma/slider.figma.js +30 -0
- package/dist/molecules/figma/steps.figma.js +33 -0
- package/dist/molecules/figma/switch.figma.js +33 -0
- package/dist/molecules/figma/tabs.figma.js +46 -0
- package/dist/molecules/figma/toast.figma.js +34 -0
- package/dist/molecules/figma/tree-view.figma.js +30 -0
- package/dist/molecules/form-checkbox.js +121 -48
- package/dist/molecules/form-input.js +15 -27
- package/dist/molecules/form-numeric-input.js +11 -24
- package/dist/molecules/form-textarea.js +15 -27
- package/dist/molecules/menu.js +69 -67
- package/dist/molecules/pagination.js +112 -76
- package/dist/molecules/phone-input.js +654 -0
- package/dist/molecules/popover.js +221 -96
- package/dist/molecules/product-card.js +38 -37
- package/dist/molecules/radio-card.js +517 -0
- package/dist/molecules/radio-group.js +341 -0
- package/dist/molecules/search-form.js +170 -91
- package/dist/molecules/select.js +369 -141
- package/dist/molecules/slider.js +72 -85
- package/dist/molecules/steps.js +517 -152
- package/dist/molecules/switch.js +37 -43
- package/dist/molecules/tabs.js +63 -61
- package/dist/molecules/toast.js +32 -32
- package/dist/molecules/tree-view.js +89 -83
- package/dist/organisms/footer.js +50 -52
- package/dist/organisms/gallery.js +244 -0
- package/dist/organisms/header.js +60 -58
- package/dist/organisms/table.js +52 -52
- package/dist/src/atoms/badge.d.ts +27 -7
- package/dist/src/atoms/badge.d.ts.map +1 -1
- package/dist/src/atoms/button.d.ts +7 -6
- package/dist/src/atoms/button.d.ts.map +1 -1
- package/dist/src/atoms/checkbox.d.ts +11 -0
- package/dist/src/atoms/checkbox.d.ts.map +1 -0
- package/dist/src/atoms/figma/badge.figma.d.ts +2 -0
- package/dist/src/atoms/figma/badge.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/button.figma.d.ts +2 -0
- package/dist/src/atoms/figma/button.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/checkbox.figma.d.ts +2 -0
- package/dist/src/atoms/figma/checkbox.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/icon.figma.d.ts +2 -0
- package/dist/src/atoms/figma/icon.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/image.figma.d.ts +2 -0
- package/dist/src/atoms/figma/image.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/input.figma.d.ts +2 -0
- package/dist/src/atoms/figma/input.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/label.figma.d.ts +2 -0
- package/dist/src/atoms/figma/label.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/link-button.figma.d.ts +2 -0
- package/dist/src/atoms/figma/link-button.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/link.figma.d.ts +2 -0
- package/dist/src/atoms/figma/link.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/numeric-input.figma.d.ts +2 -0
- package/dist/src/atoms/figma/numeric-input.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/rating.figma.d.ts +2 -0
- package/dist/src/atoms/figma/rating.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/skeleton.figma.d.ts +2 -0
- package/dist/src/atoms/figma/skeleton.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/status-text.figma.d.ts +2 -0
- package/dist/src/atoms/figma/status-text.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/textarea.figma.d.ts +2 -0
- package/dist/src/atoms/figma/textarea.figma.d.ts.map +1 -0
- package/dist/src/atoms/figma/tooltip.figma.d.ts +2 -0
- package/dist/src/atoms/figma/tooltip.figma.d.ts.map +1 -0
- package/dist/src/atoms/icon.d.ts +6 -6
- package/dist/src/atoms/image.d.ts +35 -9
- package/dist/src/atoms/image.d.ts.map +1 -1
- package/dist/src/atoms/input.d.ts +3 -3
- package/dist/src/atoms/input.d.ts.map +1 -1
- package/dist/src/atoms/label.d.ts +2 -2
- package/dist/src/atoms/link-button.d.ts +71 -12
- package/dist/src/atoms/link-button.d.ts.map +1 -1
- package/dist/src/atoms/link.d.ts +5 -5
- package/dist/src/atoms/link.d.ts.map +1 -1
- package/dist/src/atoms/numeric-input.d.ts +23 -22
- package/dist/src/atoms/numeric-input.d.ts.map +1 -1
- package/dist/src/atoms/rating.d.ts +6 -5
- package/dist/src/atoms/rating.d.ts.map +1 -1
- package/dist/src/atoms/skeleton.d.ts +15 -15
- package/dist/src/atoms/skeleton.d.ts.map +1 -1
- package/dist/src/atoms/status-text.d.ts +97 -0
- package/dist/src/atoms/status-text.d.ts.map +1 -0
- package/dist/src/atoms/textarea.d.ts +3 -3
- package/dist/src/atoms/textarea.d.ts.map +1 -1
- package/dist/src/atoms/tooltip.d.ts +3 -3
- package/dist/src/atoms/tooltip.d.ts.map +1 -1
- package/dist/src/molecules/accordion.d.ts +14 -13
- package/dist/src/molecules/accordion.d.ts.map +1 -1
- package/dist/src/molecules/breadcrumb.d.ts +132 -35
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
- package/dist/src/molecules/carousel.d.ts +67 -16
- package/dist/src/molecules/carousel.d.ts.map +1 -1
- package/dist/src/molecules/color-select.d.ts +4 -4
- package/dist/src/molecules/combobox.d.ts +36 -9
- package/dist/src/molecules/combobox.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +3 -3
- package/dist/src/molecules/dialog.d.ts.map +1 -1
- package/dist/src/molecules/figma/accordion.figma.d.ts +2 -0
- package/dist/src/molecules/figma/accordion.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/breadcrumb.figma.d.ts +2 -0
- package/dist/src/molecules/figma/breadcrumb.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/carousel.figma.d.ts +2 -0
- package/dist/src/molecules/figma/carousel.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/combobox.figma.d.ts +2 -0
- package/dist/src/molecules/figma/combobox.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/dialog.figma.d.ts +2 -0
- package/dist/src/molecules/figma/dialog.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/form-checkbox.figma.d.ts +2 -0
- package/dist/src/molecules/figma/form-checkbox.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/form-input.figma.d.ts +2 -0
- package/dist/src/molecules/figma/form-input.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/form-numeric-input.figma.d.ts +2 -0
- package/dist/src/molecules/figma/form-numeric-input.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/form-textarea.figma.d.ts +2 -0
- package/dist/src/molecules/figma/form-textarea.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/menu.figma.d.ts +2 -0
- package/dist/src/molecules/figma/menu.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/pagination.figma.d.ts +2 -0
- package/dist/src/molecules/figma/pagination.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/popover.figma.d.ts +2 -0
- package/dist/src/molecules/figma/popover.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/product-card.figma.d.ts +2 -0
- package/dist/src/molecules/figma/product-card.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/radio-card.figma.d.ts +2 -0
- package/dist/src/molecules/figma/radio-card.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/radio-group.figma.d.ts +2 -0
- package/dist/src/molecules/figma/radio-group.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/search-form.figma.d.ts +2 -0
- package/dist/src/molecules/figma/search-form.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/select.figma.d.ts +2 -0
- package/dist/src/molecules/figma/select.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/slider.figma.d.ts +2 -0
- package/dist/src/molecules/figma/slider.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/steps.figma.d.ts +2 -0
- package/dist/src/molecules/figma/steps.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/switch.figma.d.ts +2 -0
- package/dist/src/molecules/figma/switch.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/tabs.figma.d.ts +2 -0
- package/dist/src/molecules/figma/tabs.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/toast.figma.d.ts +2 -0
- package/dist/src/molecules/figma/toast.figma.d.ts.map +1 -0
- package/dist/src/molecules/figma/tree-view.figma.d.ts +2 -0
- package/dist/src/molecules/figma/tree-view.figma.d.ts.map +1 -0
- package/dist/src/molecules/form-checkbox.d.ts +22 -12
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
- package/dist/src/molecules/form-input.d.ts +8 -6
- package/dist/src/molecules/form-input.d.ts.map +1 -1
- package/dist/src/molecules/form-numeric-input.d.ts +6 -6
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
- package/dist/src/molecules/form-textarea.d.ts +8 -6
- package/dist/src/molecules/form-textarea.d.ts.map +1 -1
- package/dist/src/molecules/menu.d.ts +11 -11
- package/dist/src/molecules/menu.d.ts.map +1 -1
- package/dist/src/molecules/pagination.d.ts +37 -9
- package/dist/src/molecules/pagination.d.ts.map +1 -1
- package/dist/src/molecules/phone-input.d.ts +246 -0
- package/dist/src/molecules/phone-input.d.ts.map +1 -0
- package/dist/src/molecules/popover.d.ts +76 -24
- package/dist/src/molecules/popover.d.ts.map +1 -1
- package/dist/src/molecules/product-card.d.ts +11 -10
- package/dist/src/molecules/product-card.d.ts.map +1 -1
- package/dist/src/molecules/radio-card.d.ts +429 -0
- package/dist/src/molecules/radio-card.d.ts.map +1 -0
- package/dist/src/molecules/radio-group.d.ts +245 -0
- package/dist/src/molecules/radio-group.d.ts.map +1 -0
- package/dist/src/molecules/search-form.d.ts +94 -27
- package/dist/src/molecules/search-form.d.ts.map +1 -1
- package/dist/src/molecules/select.d.ts +124 -30
- package/dist/src/molecules/select.d.ts.map +1 -1
- package/dist/src/molecules/slider.d.ts +9 -12
- package/dist/src/molecules/slider.d.ts.map +1 -1
- package/dist/src/molecules/steps.d.ts +236 -64
- package/dist/src/molecules/steps.d.ts.map +1 -1
- package/dist/src/molecules/switch.d.ts +7 -7
- package/dist/src/molecules/switch.d.ts.map +1 -1
- package/dist/src/molecules/tabs.d.ts +10 -10
- package/dist/src/molecules/tabs.d.ts.map +1 -1
- package/dist/src/molecules/toast.d.ts +6 -6
- package/dist/src/molecules/tree-view.d.ts +14 -14
- package/dist/src/molecules/tree-view.d.ts.map +1 -1
- package/dist/src/organisms/footer.d.ts +15 -6
- package/dist/src/organisms/footer.d.ts.map +1 -1
- package/dist/src/organisms/gallery.d.ts +147 -0
- package/dist/src/organisms/gallery.d.ts.map +1 -0
- package/dist/src/organisms/header.d.ts +9 -9
- package/dist/src/organisms/header.d.ts.map +1 -1
- package/dist/src/organisms/table.d.ts +10 -10
- package/dist/src/organisms/table.d.ts.map +1 -1
- package/dist/src/templates/accordion.d.ts +3 -3
- package/dist/src/templates/breadcrumb.d.ts +28 -0
- package/dist/src/templates/breadcrumb.d.ts.map +1 -0
- package/dist/src/templates/carousel.d.ts +4 -4
- package/dist/src/templates/carousel.d.ts.map +1 -1
- package/dist/src/templates/gallery.d.ts +43 -0
- package/dist/src/templates/gallery.d.ts.map +1 -0
- package/dist/src/templates/numeric-input.d.ts +5 -5
- package/dist/src/templates/popover.d.ts +19 -0
- package/dist/src/templates/popover.d.ts.map +1 -0
- package/dist/src/templates/product-card.d.ts +4 -4
- package/dist/src/templates/select.d.ts +22 -0
- package/dist/src/templates/select.d.ts.map +1 -0
- package/dist/src/templates/tabs.d.ts +4 -4
- package/dist/src/types/zag.d.ts +19 -18
- package/dist/src/types/zag.d.ts.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/stories/atoms/badge.stories.d.ts +12 -0
- package/dist/stories/atoms/badge.stories.d.ts.map +1 -0
- package/dist/stories/atoms/button.stories.d.ts +12 -0
- package/dist/stories/atoms/button.stories.d.ts.map +1 -0
- package/dist/stories/atoms/checkbox.stories.d.ts +56 -0
- package/dist/stories/atoms/checkbox.stories.d.ts.map +1 -0
- package/dist/stories/atoms/icon.stories.d.ts +11 -0
- package/dist/stories/atoms/icon.stories.d.ts.map +1 -0
- package/dist/stories/atoms/image.stories.d.ts +8 -0
- package/dist/stories/atoms/image.stories.d.ts.map +1 -0
- package/dist/stories/atoms/input.stories.d.ts +8 -0
- package/dist/stories/atoms/input.stories.d.ts.map +1 -0
- package/dist/stories/atoms/numeric-input.stories.d.ts +23 -0
- package/dist/stories/atoms/numeric-input.stories.d.ts.map +1 -0
- package/dist/stories/atoms/rating.stories.d.ts +10 -0
- package/dist/stories/atoms/rating.stories.d.ts.map +1 -0
- package/dist/stories/atoms/skeleton.stories.d.ts +34 -0
- package/dist/stories/atoms/skeleton.stories.d.ts.map +1 -0
- package/dist/stories/atoms/status-text.stories.d.ts +15 -0
- package/dist/stories/atoms/status-text.stories.d.ts.map +1 -0
- package/dist/stories/atoms/textarea.stories.d.ts +12 -0
- package/dist/stories/atoms/textarea.stories.d.ts.map +1 -0
- package/dist/stories/atoms/tooltip.stories.d.ts +28 -0
- package/dist/stories/atoms/tooltip.stories.d.ts.map +1 -0
- package/dist/stories/helpers/icon-options.d.ts +4 -0
- package/dist/stories/helpers/icon-options.d.ts.map +1 -0
- package/dist/stories/molecules/accordion.stories.d.ts +14 -0
- package/dist/stories/molecules/accordion.stories.d.ts.map +1 -0
- package/dist/stories/molecules/breadcrumb.stories.d.ts +14 -0
- package/dist/stories/molecules/breadcrumb.stories.d.ts.map +1 -0
- package/dist/stories/molecules/carousel.stories.d.ts +19 -0
- package/dist/stories/molecules/carousel.stories.d.ts.map +1 -0
- package/dist/stories/molecules/color-select.stories.d.ts +12 -0
- package/dist/stories/molecules/color-select.stories.d.ts.map +1 -0
- package/dist/stories/molecules/combobox.stories.d.ts +11 -0
- package/dist/stories/molecules/combobox.stories.d.ts.map +1 -0
- package/dist/stories/molecules/dialog.stories.d.ts +19 -0
- package/dist/stories/molecules/dialog.stories.d.ts.map +1 -0
- package/dist/stories/molecules/form-checkbox.stories.d.ts +17 -0
- package/dist/stories/molecules/form-checkbox.stories.d.ts.map +1 -0
- package/dist/stories/molecules/form-input.stories.d.ts +12 -0
- package/dist/stories/molecules/form-input.stories.d.ts.map +1 -0
- package/dist/stories/molecules/form-numeric-input.stories.d.ts +17 -0
- package/dist/stories/molecules/form-numeric-input.stories.d.ts.map +1 -0
- package/dist/stories/molecules/form-textarea.stories.d.ts +12 -0
- package/dist/stories/molecules/form-textarea.stories.d.ts.map +1 -0
- package/dist/stories/molecules/menu.stories.d.ts +22 -0
- package/dist/stories/molecules/menu.stories.d.ts.map +1 -0
- package/dist/stories/molecules/pagination.stories.d.ts +13 -0
- package/dist/stories/molecules/pagination.stories.d.ts.map +1 -0
- package/dist/stories/molecules/phone-input.stories.d.ts +19 -0
- package/dist/stories/molecules/phone-input.stories.d.ts.map +1 -0
- package/dist/stories/molecules/popover.stories.d.ts +140 -0
- package/dist/stories/molecules/popover.stories.d.ts.map +1 -0
- package/dist/stories/molecules/product-card.stories.d.ts +41 -0
- package/dist/stories/molecules/product-card.stories.d.ts.map +1 -0
- package/dist/stories/molecules/radio-card.stories.d.ts +13 -0
- package/dist/stories/molecules/radio-card.stories.d.ts.map +1 -0
- package/dist/stories/molecules/radio-group.stories.d.ts +13 -0
- package/dist/stories/molecules/radio-group.stories.d.ts.map +1 -0
- package/dist/stories/molecules/search-form.stories.d.ts +16 -0
- package/dist/stories/molecules/search-form.stories.d.ts.map +1 -0
- package/dist/stories/molecules/select.stories.d.ts +19 -0
- package/dist/stories/molecules/select.stories.d.ts.map +1 -0
- package/dist/stories/molecules/slider.stories.d.ts +19 -0
- package/dist/stories/molecules/slider.stories.d.ts.map +1 -0
- package/dist/stories/molecules/steps.stories.d.ts +19 -0
- package/dist/stories/molecules/steps.stories.d.ts.map +1 -0
- package/dist/stories/molecules/switch.stories.d.ts +13 -0
- package/dist/stories/molecules/switch.stories.d.ts.map +1 -0
- package/dist/stories/molecules/tabs.stories.d.ts +18 -0
- package/dist/stories/molecules/tabs.stories.d.ts.map +1 -0
- package/dist/stories/molecules/toast.stories.d.ts +11 -0
- package/dist/stories/molecules/toast.stories.d.ts.map +1 -0
- package/dist/stories/molecules/tree-view.stories.d.ts +17 -0
- package/dist/stories/molecules/tree-view.stories.d.ts.map +1 -0
- package/dist/stories/organisms/footer.stories.d.ts +12 -0
- package/dist/stories/organisms/footer.stories.d.ts.map +1 -0
- package/dist/stories/organisms/gallery.stories.d.ts +73 -0
- package/dist/stories/organisms/gallery.stories.d.ts.map +1 -0
- package/dist/stories/organisms/header.stories.d.ts +12 -0
- package/dist/stories/organisms/header.stories.d.ts.map +1 -0
- package/dist/stories/organisms/table.stories.d.ts +56 -0
- package/dist/stories/organisms/table.stories.d.ts.map +1 -0
- package/dist/stories/overview/apca-contrast-test.stories.d.ts +8 -0
- package/dist/stories/overview/apca-contrast-test.stories.d.ts.map +1 -0
- package/dist/stories/overview/color-palette.stories.d.ts +8 -0
- package/dist/stories/overview/color-palette.stories.d.ts.map +1 -0
- package/dist/stories/overview/component-comparison.stories.d.ts +6 -0
- package/dist/stories/overview/component-comparison.stories.d.ts.map +1 -0
- package/dist/stories/templates/accordion.stories.d.ts +8 -0
- package/dist/stories/templates/accordion.stories.d.ts.map +1 -0
- package/dist/stories/templates/breadcrumb.stories.d.ts +12 -0
- package/dist/stories/templates/breadcrumb.stories.d.ts.map +1 -0
- package/dist/stories/templates/carousel.stories.d.ts +8 -0
- package/dist/stories/templates/carousel.stories.d.ts.map +1 -0
- package/dist/stories/templates/comprehensive-form.stories.d.ts +26 -0
- package/dist/stories/templates/comprehensive-form.stories.d.ts.map +1 -0
- package/dist/stories/templates/gallery.stories.d.ts +7 -0
- package/dist/stories/templates/gallery.stories.d.ts.map +1 -0
- package/dist/stories/templates/numeric-input.stories.d.ts +8 -0
- package/dist/stories/templates/numeric-input.stories.d.ts.map +1 -0
- package/dist/stories/templates/popover.stories.d.ts +55 -0
- package/dist/stories/templates/popover.stories.d.ts.map +1 -0
- package/dist/stories/templates/product-card.stories.d.ts +10 -0
- package/dist/stories/templates/product-card.stories.d.ts.map +1 -0
- package/dist/stories/templates/select.stories.d.ts +10 -0
- package/dist/stories/templates/select.stories.d.ts.map +1 -0
- package/dist/stories/templates/tabs.stories.d.ts +8 -0
- package/dist/stories/templates/tabs.stories.d.ts.map +1 -0
- package/dist/templates/accordion.js +9 -9
- package/dist/templates/breadcrumb.js +78 -0
- package/dist/templates/carousel.js +13 -15
- package/dist/templates/gallery.js +89 -0
- package/dist/templates/numeric-input.js +4 -4
- package/dist/templates/popover.js +35 -0
- package/dist/templates/product-card.js +10 -10
- package/dist/templates/select.js +43 -0
- package/dist/templates/tabs.js +8 -8
- package/dist/test/visual.spec.d.ts +2 -0
- package/dist/test/visual.spec.d.ts.map +1 -0
- package/dist/utils.js +1 -1
- package/package.json +41 -28
- package/src/tokens/_base.css +3 -3
- package/src/tokens/_layout.css +4 -0
- package/src/tokens/_semantic.css +49 -10
- package/src/tokens/_tokens-base.css +67 -0
- package/src/tokens/_typography.css +36 -6
- package/src/tokens/components/_form-control.css +67 -0
- package/src/tokens/components/atoms/_badge.css +16 -5
- package/src/tokens/components/atoms/_button.css +16 -10
- package/src/tokens/components/atoms/_checkbox.css +52 -0
- package/src/tokens/components/atoms/_icon.css +90 -2
- package/src/tokens/components/atoms/_image.css +5 -0
- package/src/tokens/components/atoms/_input.css +11 -32
- package/src/tokens/components/atoms/_label.css +11 -0
- package/src/tokens/components/atoms/_numeric-input.css +27 -13
- package/src/tokens/components/atoms/_rating.css +2 -2
- package/src/tokens/components/atoms/_status-text.css +32 -0
- package/src/tokens/components/atoms/_textarea.css +15 -17
- package/src/tokens/components/components.css +10 -1
- package/src/tokens/components/molecules/_accordion.css +1 -8
- package/src/tokens/components/molecules/_breadcrumb.css +42 -20
- package/src/tokens/components/molecules/_carousel.css +10 -2
- package/src/tokens/components/molecules/_color-select.css +3 -3
- package/src/tokens/components/molecules/_combobox.css +15 -21
- package/src/tokens/components/molecules/_dialog.css +0 -1
- package/src/tokens/components/molecules/_menu.css +0 -1
- package/src/tokens/components/molecules/_pagination.css +3 -3
- package/src/tokens/components/molecules/_phone-input.css +63 -0
- package/src/tokens/components/molecules/_popover.css +3 -0
- package/src/tokens/components/molecules/_product-card.css +9 -1
- package/src/tokens/components/molecules/_radio-card.css +197 -0
- package/src/tokens/components/molecules/_radio-group.css +150 -0
- package/src/tokens/components/molecules/_search-form.css +7 -3
- package/src/tokens/components/molecules/_select.css +41 -20
- package/src/tokens/components/molecules/_steps.css +115 -34
- package/src/tokens/components/molecules/_toast.css +5 -5
- package/src/tokens/components/molecules/_tree-view.css +5 -6
- package/src/tokens/components/organisms/_footer.css +1 -6
- package/src/tokens/components/organisms/_gallery.css +35 -0
- package/src/tokens/components/organisms/_header.css +8 -0
- package/src/tokens/figma/dark/variables.css +1406 -0
- package/src/tokens/figma/light/variables.css +1406 -0
- package/src/tokens/index.css +1 -65
- package/src/tokens/tokens-only.css +1 -64
- package/dist/atoms/error-text.js +0 -38
- package/dist/atoms/extra-text.js +0 -27
- package/dist/molecules/checkbox.js +0 -98
- package/dist/src/atoms/error-text.d.ts +0 -29
- package/dist/src/atoms/error-text.d.ts.map +0 -1
- package/dist/src/atoms/extra-text.d.ts +0 -27
- package/dist/src/atoms/extra-text.d.ts.map +0 -1
- package/dist/src/molecules/checkbox.d.ts +0 -19
- package/dist/src/molecules/checkbox.d.ts.map +0 -1
- package/src/tokens/components/molecules/_checkbox.css +0 -34
- package/src/tokens/components/molecules/index.css +0 -2
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AsYouType, formatIncompletePhoneNumber, getCountryCallingCode, isSupportedCountry, parseIncompletePhoneNumber, parsePhoneNumberFromString } from "libphonenumber-js/max";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Input } from "../atoms/input.js";
|
|
5
|
+
import { Label } from "../atoms/label.js";
|
|
6
|
+
import { StatusText } from "../atoms/status-text.js";
|
|
7
|
+
import { tv } from "../utils.js";
|
|
8
|
+
import { Select } from "./select.js";
|
|
9
|
+
const defaultNativeValidationMessage = "Enter a valid phone number.";
|
|
10
|
+
const defaultPhoneInputCountries = [
|
|
11
|
+
{
|
|
12
|
+
value: "SK",
|
|
13
|
+
label: "Slovakia",
|
|
14
|
+
name: "Slovakia"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: "CZ",
|
|
18
|
+
label: "Czechia",
|
|
19
|
+
name: "Czechia"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: "HU",
|
|
23
|
+
label: "Hungary",
|
|
24
|
+
name: "Hungary"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
value: "RO",
|
|
28
|
+
label: "Romania",
|
|
29
|
+
name: "Romania"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: "PL",
|
|
33
|
+
label: "Poland",
|
|
34
|
+
name: "Poland"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: "AT",
|
|
38
|
+
label: "Austria",
|
|
39
|
+
name: "Austria"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
value: "DE",
|
|
43
|
+
label: "Germany",
|
|
44
|
+
name: "Germany"
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
const phoneInputVariants = tv({
|
|
48
|
+
slots: {
|
|
49
|
+
root: [
|
|
50
|
+
"relative flex w-full flex-col gap-phone-input-root"
|
|
51
|
+
],
|
|
52
|
+
control: [
|
|
53
|
+
"form-control-base",
|
|
54
|
+
"relative flex w-full items-center overflow-hidden",
|
|
55
|
+
"text-phone-input-fg",
|
|
56
|
+
"hover:border-phone-input-border-hover hover:bg-phone-input-bg-hover",
|
|
57
|
+
"phone-input-focus",
|
|
58
|
+
"data-[disabled]:cursor-not-allowed",
|
|
59
|
+
"data-[disabled]:border-phone-input-border-disabled",
|
|
60
|
+
"data-[disabled]:bg-phone-input-bg-disabled",
|
|
61
|
+
"data-[disabled]:text-phone-input-fg-disabled",
|
|
62
|
+
"data-[validation=error]:border-(length:--border-width-validation)",
|
|
63
|
+
"data-[validation=error]:border-phone-input-border-danger data-[validation=error]:outline-phone-input-border-danger",
|
|
64
|
+
"data-[validation=error]:outline-(style:--default-ring-style) data-[validation=error]:outline-(length:--default-ring-width)",
|
|
65
|
+
"data-[validation=error]:outline-offset-(length:--default-ring-offset)",
|
|
66
|
+
"data-[validation=success]:border-(length:--border-width-validation)",
|
|
67
|
+
"data-[validation=success]:border-phone-input-border-success data-[validation=success]:outline-phone-input-border-success",
|
|
68
|
+
"data-[validation=success]:outline-(style:--default-ring-style) data-[validation=success]:outline-(length:--default-ring-width)",
|
|
69
|
+
"data-[validation=success]:outline-offset-(length:--default-ring-offset)",
|
|
70
|
+
"data-[validation=warning]:border-(length:--border-width-validation)",
|
|
71
|
+
"data-[validation=warning]:border-phone-input-border-warning data-[validation=warning]:outline-phone-input-border-warning",
|
|
72
|
+
"data-[validation=warning]:outline-(style:--default-ring-style) data-[validation=warning]:outline-(length:--default-ring-width)",
|
|
73
|
+
"data-[validation=warning]:outline-offset-(length:--default-ring-offset)",
|
|
74
|
+
"transition-colors duration-200 motion-reduce:transition-none"
|
|
75
|
+
],
|
|
76
|
+
countrySelectRoot: [
|
|
77
|
+
"contents"
|
|
78
|
+
],
|
|
79
|
+
countrySelectControl: [
|
|
80
|
+
"h-full w-auto shrink-0"
|
|
81
|
+
],
|
|
82
|
+
countryTrigger: [
|
|
83
|
+
"shrink-0",
|
|
84
|
+
"bg-phone-input-trigger-bg-base",
|
|
85
|
+
"hover:bg-phone-input-trigger-bg-hover",
|
|
86
|
+
"border-(length:--border-phone-input-trigger)",
|
|
87
|
+
"focus-visible:outline-none",
|
|
88
|
+
"w-phone-input-trigger",
|
|
89
|
+
"focus-visible:bg-phone-input-trigger-bg-hover"
|
|
90
|
+
],
|
|
91
|
+
countryValue: [
|
|
92
|
+
"flex items-center gap-phone-input-country-value"
|
|
93
|
+
],
|
|
94
|
+
countryFlag: [
|
|
95
|
+
"inline-flex min-w-phone-input-country-flag items-center justify-center",
|
|
96
|
+
"rounded-phone-input-country-flag",
|
|
97
|
+
"font-medium text-phone-input-country-flag uppercase"
|
|
98
|
+
],
|
|
99
|
+
countryCallingCode: [
|
|
100
|
+
"font-medium text-phone-input-country-calling-code"
|
|
101
|
+
],
|
|
102
|
+
input: [
|
|
103
|
+
"min-w-0 flex-1 border-0",
|
|
104
|
+
"bg-phone-input-input-bg-base",
|
|
105
|
+
"text-phone-input-fg",
|
|
106
|
+
"placeholder:text-phone-input-placeholder",
|
|
107
|
+
"hover:bg-phone-input-input-bg-hover",
|
|
108
|
+
"focus:bg-phone-input-input-bg-focus",
|
|
109
|
+
"focus-visible:outline-none",
|
|
110
|
+
"disabled:text-phone-input-fg-disabled"
|
|
111
|
+
],
|
|
112
|
+
itemContent: [
|
|
113
|
+
"flex min-w-0 items-center gap-phone-input-item"
|
|
114
|
+
],
|
|
115
|
+
itemMeta: [
|
|
116
|
+
"shrink-0 text-phone-input-item-meta"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
variants: {
|
|
120
|
+
size: {
|
|
121
|
+
sm: {
|
|
122
|
+
control: "h-form-control-sm rounded-phone-input-sm text-phone-input-sm",
|
|
123
|
+
input: "text-phone-input-sm"
|
|
124
|
+
},
|
|
125
|
+
md: {
|
|
126
|
+
control: "h-form-control-md rounded-phone-input-md text-phone-input-md",
|
|
127
|
+
input: "text-phone-input-md"
|
|
128
|
+
},
|
|
129
|
+
lg: {
|
|
130
|
+
control: "h-form-control-lg rounded-phone-input-lg text-phone-input-lg",
|
|
131
|
+
input: "text-phone-input-lg"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
defaultVariants: {
|
|
136
|
+
size: "md"
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const PhoneInputContext = /*#__PURE__*/ createContext(null);
|
|
140
|
+
function usePhoneInputContext() {
|
|
141
|
+
const context = useContext(PhoneInputContext);
|
|
142
|
+
if (!context) throw new Error("PhoneInput components must be used within PhoneInput");
|
|
143
|
+
return context;
|
|
144
|
+
}
|
|
145
|
+
const PhoneInputItemContext = /*#__PURE__*/ createContext(null);
|
|
146
|
+
function usePhoneInputItemContext() {
|
|
147
|
+
const context = useContext(PhoneInputItemContext);
|
|
148
|
+
if (!context) throw new Error("PhoneInput item components must be used within PhoneInput.Item");
|
|
149
|
+
return context;
|
|
150
|
+
}
|
|
151
|
+
function PhoneInput({ countries: countriesProp = defaultPhoneInputCountries, value, defaultValue = "", country, defaultCountry = "CZ", name, countryName, form, required = false, disabled = false, readOnly = false, nativeValidation = false, nativeValidationMessage = defaultNativeValidationMessage, validateStatus = "default", onValueChange, onCountryChange, size = "md", id: providedId, className, children, ref, ...props }) {
|
|
152
|
+
const generatedId = useId();
|
|
153
|
+
const id = providedId || generatedId;
|
|
154
|
+
const countries = useMemo(()=>normalizePhoneInputCountries(countriesProp.length > 0 ? countriesProp : defaultPhoneInputCountries), [
|
|
155
|
+
countriesProp
|
|
156
|
+
]);
|
|
157
|
+
const fallbackCountry = resolveCountry(countries, getInitialCountry(value ?? defaultValue, defaultCountry, countries));
|
|
158
|
+
const [internalCountry, setInternalCountry] = useState(fallbackCountry);
|
|
159
|
+
const selectedCountry = resolveCountry(countries, country ?? internalCountry);
|
|
160
|
+
const selectedCountryItem = getCountryItem(countries, selectedCountry);
|
|
161
|
+
const previousControlledValueRef = useRef(value);
|
|
162
|
+
const [internalValue, setInternalValue] = useState(()=>formatPhoneInputValue(defaultValue, selectedCountry));
|
|
163
|
+
const isValueControlled = void 0 !== value;
|
|
164
|
+
const inputValue = isValueControlled ? formatPhoneInputValue(value, selectedCountry) : internalValue;
|
|
165
|
+
const details = useMemo(()=>getPhoneInputValueDetailsInternal(inputValue, selectedCountry, {
|
|
166
|
+
countries
|
|
167
|
+
}), [
|
|
168
|
+
countries,
|
|
169
|
+
inputValue,
|
|
170
|
+
selectedCountry
|
|
171
|
+
]);
|
|
172
|
+
const nativeFormValue = details.isValid ? details.e164 : inputValue;
|
|
173
|
+
useEffect(()=>{
|
|
174
|
+
if (!isValueControlled || country || value === previousControlledValueRef.current) return;
|
|
175
|
+
previousControlledValueRef.current = value;
|
|
176
|
+
const nextCountry = getCountryFromValue(value ?? "", countries);
|
|
177
|
+
if (nextCountry && nextCountry !== internalCountry) setInternalCountry(nextCountry);
|
|
178
|
+
}, [
|
|
179
|
+
countries,
|
|
180
|
+
country,
|
|
181
|
+
internalCountry,
|
|
182
|
+
isValueControlled,
|
|
183
|
+
value
|
|
184
|
+
]);
|
|
185
|
+
const setInputValue = (nextValue)=>{
|
|
186
|
+
const nextDetails = getPhoneInputValueDetailsInternal(nextValue, selectedCountry, {
|
|
187
|
+
countries,
|
|
188
|
+
syncCountryFromValue: true
|
|
189
|
+
});
|
|
190
|
+
const didChangeCountry = nextDetails.country !== selectedCountry;
|
|
191
|
+
if (!isValueControlled) setInternalValue(nextDetails.value);
|
|
192
|
+
if (didChangeCountry && !country) setInternalCountry(nextDetails.country);
|
|
193
|
+
if (didChangeCountry) onCountryChange?.({
|
|
194
|
+
...nextDetails,
|
|
195
|
+
countryItem: getCountryItem(countries, nextDetails.country)
|
|
196
|
+
});
|
|
197
|
+
onValueChange?.(nextDetails);
|
|
198
|
+
};
|
|
199
|
+
const setCountryValue = (nextCountry)=>{
|
|
200
|
+
const nextCountryItem = getCountryItem(countries, nextCountry);
|
|
201
|
+
const nextDetails = getPhoneInputValueDetailsInternal(inputValue, nextCountry, {
|
|
202
|
+
countries
|
|
203
|
+
});
|
|
204
|
+
if (!country) setInternalCountry(nextCountry);
|
|
205
|
+
if (!isValueControlled) setInternalValue(nextDetails.value);
|
|
206
|
+
onCountryChange?.({
|
|
207
|
+
...nextDetails,
|
|
208
|
+
countryItem: nextCountryItem
|
|
209
|
+
});
|
|
210
|
+
onValueChange?.(nextDetails);
|
|
211
|
+
};
|
|
212
|
+
const styles = phoneInputVariants({
|
|
213
|
+
size
|
|
214
|
+
});
|
|
215
|
+
return /*#__PURE__*/ jsxs(PhoneInputContext.Provider, {
|
|
216
|
+
value: {
|
|
217
|
+
countries,
|
|
218
|
+
selectedCountry,
|
|
219
|
+
selectedCountryItem,
|
|
220
|
+
setCountryValue,
|
|
221
|
+
countryName,
|
|
222
|
+
form,
|
|
223
|
+
size,
|
|
224
|
+
inputId: `${id}-input`,
|
|
225
|
+
inputValue,
|
|
226
|
+
setInputValue,
|
|
227
|
+
details,
|
|
228
|
+
disabled,
|
|
229
|
+
nativeValidation,
|
|
230
|
+
nativeValidationMessage,
|
|
231
|
+
readOnly,
|
|
232
|
+
required,
|
|
233
|
+
validateStatus
|
|
234
|
+
},
|
|
235
|
+
children: [
|
|
236
|
+
name && /*#__PURE__*/ jsx("input", {
|
|
237
|
+
disabled: disabled,
|
|
238
|
+
form: form,
|
|
239
|
+
name: name,
|
|
240
|
+
type: "hidden",
|
|
241
|
+
value: nativeFormValue
|
|
242
|
+
}),
|
|
243
|
+
/*#__PURE__*/ jsx("div", {
|
|
244
|
+
className: styles.root({
|
|
245
|
+
className
|
|
246
|
+
}),
|
|
247
|
+
"data-disabled": disabled || void 0,
|
|
248
|
+
ref: ref,
|
|
249
|
+
...props,
|
|
250
|
+
children: children
|
|
251
|
+
})
|
|
252
|
+
]
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
PhoneInput.Label = function({ children, ...props }) {
|
|
256
|
+
const { disabled, inputId, required, size } = usePhoneInputContext();
|
|
257
|
+
return /*#__PURE__*/ jsx(Label, {
|
|
258
|
+
disabled: disabled,
|
|
259
|
+
htmlFor: inputId,
|
|
260
|
+
required: required,
|
|
261
|
+
size: size,
|
|
262
|
+
...props,
|
|
263
|
+
children: children
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
PhoneInput.Control = function({ children, className, ref, ...props }) {
|
|
267
|
+
const { disabled, readOnly, size, validateStatus } = usePhoneInputContext();
|
|
268
|
+
const styles = phoneInputVariants({
|
|
269
|
+
size
|
|
270
|
+
});
|
|
271
|
+
const validationDataAttrs = "default" !== validateStatus ? {
|
|
272
|
+
"data-validation": validateStatus
|
|
273
|
+
} : {};
|
|
274
|
+
return /*#__PURE__*/ jsx("div", {
|
|
275
|
+
className: styles.control({
|
|
276
|
+
className
|
|
277
|
+
}),
|
|
278
|
+
"data-disabled": disabled || void 0,
|
|
279
|
+
"data-readonly": readOnly || void 0,
|
|
280
|
+
ref: ref,
|
|
281
|
+
...validationDataAttrs,
|
|
282
|
+
...props,
|
|
283
|
+
children: children
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
PhoneInput.CountrySelect = function({ children, className, closeOnSelect = true }) {
|
|
287
|
+
const { countries, countryName, disabled, form, readOnly, selectedCountry, setCountryValue, size } = usePhoneInputContext();
|
|
288
|
+
const styles = phoneInputVariants({
|
|
289
|
+
size
|
|
290
|
+
});
|
|
291
|
+
return /*#__PURE__*/ jsx(Select, {
|
|
292
|
+
className: styles.countrySelectRoot({
|
|
293
|
+
className
|
|
294
|
+
}),
|
|
295
|
+
closeOnSelect: closeOnSelect,
|
|
296
|
+
disabled: disabled,
|
|
297
|
+
form: form,
|
|
298
|
+
items: countries,
|
|
299
|
+
name: countryName,
|
|
300
|
+
onValueChange: (selectDetails)=>{
|
|
301
|
+
const nextCountry = selectDetails.value[0];
|
|
302
|
+
if (nextCountry && isSupportedCountry(nextCountry)) setCountryValue(nextCountry);
|
|
303
|
+
},
|
|
304
|
+
readOnly: readOnly,
|
|
305
|
+
size: size,
|
|
306
|
+
value: [
|
|
307
|
+
selectedCountry
|
|
308
|
+
],
|
|
309
|
+
children: children
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
PhoneInput.CountryPicker = function({ className, selectProps, controlProps, triggerProps, positionerProps, contentProps }) {
|
|
313
|
+
const { countries } = usePhoneInputContext();
|
|
314
|
+
return /*#__PURE__*/ jsxs(PhoneInput.CountrySelect, {
|
|
315
|
+
...selectProps,
|
|
316
|
+
className: selectProps?.className ?? className,
|
|
317
|
+
children: [
|
|
318
|
+
/*#__PURE__*/ jsx(PhoneInput.CountryControl, {
|
|
319
|
+
...controlProps,
|
|
320
|
+
children: /*#__PURE__*/ jsx(PhoneInput.CountryTrigger, {
|
|
321
|
+
...triggerProps
|
|
322
|
+
})
|
|
323
|
+
}),
|
|
324
|
+
/*#__PURE__*/ jsx(PhoneInput.CountryPositioner, {
|
|
325
|
+
...positionerProps,
|
|
326
|
+
children: /*#__PURE__*/ jsx(PhoneInput.CountryContent, {
|
|
327
|
+
...contentProps,
|
|
328
|
+
children: countries.map((item)=>/*#__PURE__*/ jsxs(PhoneInput.CountryItem, {
|
|
329
|
+
item: item,
|
|
330
|
+
children: [
|
|
331
|
+
/*#__PURE__*/ jsx(PhoneInput.CountryItemText, {}),
|
|
332
|
+
/*#__PURE__*/ jsx(PhoneInput.CountryItemMeta, {})
|
|
333
|
+
]
|
|
334
|
+
}, item.value))
|
|
335
|
+
})
|
|
336
|
+
})
|
|
337
|
+
]
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
PhoneInput.CountryControl = function({ children, className, ref, ...props }) {
|
|
341
|
+
const { size } = usePhoneInputContext();
|
|
342
|
+
const styles = phoneInputVariants({
|
|
343
|
+
size
|
|
344
|
+
});
|
|
345
|
+
return /*#__PURE__*/ jsx(Select.Control, {
|
|
346
|
+
className: styles.countrySelectControl({
|
|
347
|
+
className
|
|
348
|
+
}),
|
|
349
|
+
ref: ref,
|
|
350
|
+
...props,
|
|
351
|
+
children: children
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
PhoneInput.CountryTrigger = function({ children, className, ref, ...props }) {
|
|
355
|
+
const { selectedCountryItem, size } = usePhoneInputContext();
|
|
356
|
+
const styles = phoneInputVariants({
|
|
357
|
+
size
|
|
358
|
+
});
|
|
359
|
+
return /*#__PURE__*/ jsx(Select.Trigger, {
|
|
360
|
+
className: styles.countryTrigger({
|
|
361
|
+
className
|
|
362
|
+
}),
|
|
363
|
+
ref: ref,
|
|
364
|
+
...props,
|
|
365
|
+
children: children ?? /*#__PURE__*/ jsxs(PhoneInput.CountryValue, {
|
|
366
|
+
children: [
|
|
367
|
+
/*#__PURE__*/ jsx(PhoneInput.CountryFlag, {
|
|
368
|
+
item: selectedCountryItem
|
|
369
|
+
}),
|
|
370
|
+
/*#__PURE__*/ jsx(PhoneInput.CountryCallingCode, {
|
|
371
|
+
item: selectedCountryItem
|
|
372
|
+
})
|
|
373
|
+
]
|
|
374
|
+
})
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
PhoneInput.CountryValue = function({ children, className, ref, ...props }) {
|
|
378
|
+
const { size } = usePhoneInputContext();
|
|
379
|
+
const styles = phoneInputVariants({
|
|
380
|
+
size
|
|
381
|
+
});
|
|
382
|
+
return /*#__PURE__*/ jsx("span", {
|
|
383
|
+
className: styles.countryValue({
|
|
384
|
+
className
|
|
385
|
+
}),
|
|
386
|
+
ref: ref,
|
|
387
|
+
...props,
|
|
388
|
+
children: children
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
PhoneInput.CountryFlag = function({ item, className, ref, ...props }) {
|
|
392
|
+
const { selectedCountryItem, size } = usePhoneInputContext();
|
|
393
|
+
const styles = phoneInputVariants({
|
|
394
|
+
size
|
|
395
|
+
});
|
|
396
|
+
return /*#__PURE__*/ jsx("span", {
|
|
397
|
+
className: styles.countryFlag({
|
|
398
|
+
className
|
|
399
|
+
}),
|
|
400
|
+
ref: ref,
|
|
401
|
+
...props,
|
|
402
|
+
children: renderCountryFlag(item ?? selectedCountryItem)
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
PhoneInput.CountryCallingCode = function({ item, className, ref, ...props }) {
|
|
406
|
+
const { selectedCountryItem, size } = usePhoneInputContext();
|
|
407
|
+
const styles = phoneInputVariants({
|
|
408
|
+
size
|
|
409
|
+
});
|
|
410
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
411
|
+
className: styles.countryCallingCode({
|
|
412
|
+
className
|
|
413
|
+
}),
|
|
414
|
+
ref: ref,
|
|
415
|
+
...props,
|
|
416
|
+
children: [
|
|
417
|
+
"+",
|
|
418
|
+
getPhoneCountryCallingCode(item ?? selectedCountryItem)
|
|
419
|
+
]
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
PhoneInput.Input = function({ className, onChange, placeholder = "Phone number", ref, ...props }) {
|
|
423
|
+
const { details, disabled, form, inputId, inputValue, nativeValidation, nativeValidationMessage, readOnly, required, setInputValue, size, validateStatus } = usePhoneInputContext();
|
|
424
|
+
const styles = phoneInputVariants({
|
|
425
|
+
size
|
|
426
|
+
});
|
|
427
|
+
const inputRef = useRef(null);
|
|
428
|
+
const setInputRef = useCallback((node)=>{
|
|
429
|
+
inputRef.current = node;
|
|
430
|
+
assignRef(ref, node);
|
|
431
|
+
}, [
|
|
432
|
+
ref
|
|
433
|
+
]);
|
|
434
|
+
useEffect(()=>{
|
|
435
|
+
const input = inputRef.current;
|
|
436
|
+
if (!input) return;
|
|
437
|
+
const hasInvalidValue = nativeValidation && "" !== inputValue.trim() && !details.isValid && !disabled && !readOnly;
|
|
438
|
+
input.setCustomValidity(hasInvalidValue ? nativeValidationMessage : "");
|
|
439
|
+
}, [
|
|
440
|
+
details.isValid,
|
|
441
|
+
disabled,
|
|
442
|
+
inputValue,
|
|
443
|
+
nativeValidation,
|
|
444
|
+
nativeValidationMessage,
|
|
445
|
+
readOnly
|
|
446
|
+
]);
|
|
447
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
448
|
+
...props,
|
|
449
|
+
"aria-invalid": "error" === validateStatus || nativeValidation && "" !== inputValue.trim() && !details.isValid || void 0,
|
|
450
|
+
className: styles.input({
|
|
451
|
+
className
|
|
452
|
+
}),
|
|
453
|
+
disabled: disabled,
|
|
454
|
+
form: form,
|
|
455
|
+
id: inputId,
|
|
456
|
+
inputMode: "tel",
|
|
457
|
+
name: void 0,
|
|
458
|
+
onChange: (event)=>{
|
|
459
|
+
setInputValue(event.target.value);
|
|
460
|
+
onChange?.(event);
|
|
461
|
+
},
|
|
462
|
+
placeholder: placeholder,
|
|
463
|
+
readOnly: readOnly,
|
|
464
|
+
ref: setInputRef,
|
|
465
|
+
required: required,
|
|
466
|
+
size: size,
|
|
467
|
+
type: "tel",
|
|
468
|
+
value: inputValue
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
PhoneInput.CountryPositioner = function({ children, ...props }) {
|
|
472
|
+
return /*#__PURE__*/ jsx(Select.Positioner, {
|
|
473
|
+
...props,
|
|
474
|
+
children: children
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
PhoneInput.CountryContent = function({ children, ...props }) {
|
|
478
|
+
return /*#__PURE__*/ jsx(Select.Content, {
|
|
479
|
+
...props,
|
|
480
|
+
children: children
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
PhoneInput.CountryItem = function({ item, children, ...props }) {
|
|
484
|
+
return /*#__PURE__*/ jsx(PhoneInputItemContext.Provider, {
|
|
485
|
+
value: {
|
|
486
|
+
item
|
|
487
|
+
},
|
|
488
|
+
children: /*#__PURE__*/ jsx(Select.Item, {
|
|
489
|
+
item: item,
|
|
490
|
+
...props,
|
|
491
|
+
children: children
|
|
492
|
+
})
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
PhoneInput.CountryItemText = function({ children, ...props }) {
|
|
496
|
+
const { size } = usePhoneInputContext();
|
|
497
|
+
const { item } = usePhoneInputItemContext();
|
|
498
|
+
const styles = phoneInputVariants({
|
|
499
|
+
size
|
|
500
|
+
});
|
|
501
|
+
return /*#__PURE__*/ jsx(Select.ItemText, {
|
|
502
|
+
...props,
|
|
503
|
+
children: children ?? /*#__PURE__*/ jsxs("span", {
|
|
504
|
+
className: styles.itemContent(),
|
|
505
|
+
children: [
|
|
506
|
+
/*#__PURE__*/ jsx(PhoneInput.CountryFlag, {
|
|
507
|
+
item: item
|
|
508
|
+
}),
|
|
509
|
+
/*#__PURE__*/ jsx("span", {
|
|
510
|
+
className: "truncate",
|
|
511
|
+
children: item.label
|
|
512
|
+
})
|
|
513
|
+
]
|
|
514
|
+
})
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
PhoneInput.CountryItemMeta = function({ children, className, ref, ...props }) {
|
|
518
|
+
const { size } = usePhoneInputContext();
|
|
519
|
+
const { item } = usePhoneInputItemContext();
|
|
520
|
+
const styles = phoneInputVariants({
|
|
521
|
+
size
|
|
522
|
+
});
|
|
523
|
+
return /*#__PURE__*/ jsx("span", {
|
|
524
|
+
className: styles.itemMeta({
|
|
525
|
+
className
|
|
526
|
+
}),
|
|
527
|
+
ref: ref,
|
|
528
|
+
...props,
|
|
529
|
+
children: children ?? `+${getPhoneCountryCallingCode(item)}`
|
|
530
|
+
});
|
|
531
|
+
};
|
|
532
|
+
PhoneInput.CountryItemIndicator = function({ ...props }) {
|
|
533
|
+
return /*#__PURE__*/ jsx(Select.ItemIndicator, {
|
|
534
|
+
...props
|
|
535
|
+
});
|
|
536
|
+
};
|
|
537
|
+
PhoneInput.Positioner = PhoneInput.CountryPositioner;
|
|
538
|
+
PhoneInput.Content = PhoneInput.CountryContent;
|
|
539
|
+
PhoneInput.Item = PhoneInput.CountryItem;
|
|
540
|
+
PhoneInput.ItemText = PhoneInput.CountryItemText;
|
|
541
|
+
PhoneInput.ItemMeta = PhoneInput.CountryItemMeta;
|
|
542
|
+
PhoneInput.ItemIndicator = PhoneInput.CountryItemIndicator;
|
|
543
|
+
PhoneInput.StatusText = function({ status, showIcon, children, ...props }) {
|
|
544
|
+
const { size, validateStatus } = usePhoneInputContext();
|
|
545
|
+
return /*#__PURE__*/ jsx(StatusText, {
|
|
546
|
+
showIcon: showIcon,
|
|
547
|
+
size: size,
|
|
548
|
+
status: status ?? validateStatus,
|
|
549
|
+
...props,
|
|
550
|
+
children: children
|
|
551
|
+
});
|
|
552
|
+
};
|
|
553
|
+
function formatPhoneInputValue(value, country) {
|
|
554
|
+
if (!value.trim()) return "";
|
|
555
|
+
const parsedNumber = parsePhoneNumberFromString(value, country);
|
|
556
|
+
if (parsedNumber?.country === country) return formatNationalSignificantPhoneValue(parsedNumber.nationalNumber, country);
|
|
557
|
+
if (parsedNumber?.country) return formatIncompletePhoneNumber(value, country);
|
|
558
|
+
return formatNationalSignificantPhoneValue(value, country);
|
|
559
|
+
}
|
|
560
|
+
function getPhoneInputValueDetails(value, country) {
|
|
561
|
+
return getPhoneInputValueDetailsInternal(value, country);
|
|
562
|
+
}
|
|
563
|
+
function getPhoneInputValueDetailsInternal(value, country, options = {}) {
|
|
564
|
+
const parsedValue = parsePhoneNumberFromString(value, country);
|
|
565
|
+
const valueCountry = parsedValue?.country;
|
|
566
|
+
const detailsCountry = options.syncCountryFromValue && valueCountry && isCountryAvailable(options.countries, valueCountry) ? valueCountry : country;
|
|
567
|
+
const formattedValue = formatPhoneInputValue(value, detailsCountry);
|
|
568
|
+
const formatter = new AsYouType(detailsCountry);
|
|
569
|
+
formatter.input(value);
|
|
570
|
+
const parsedNumber = parsePhoneNumberFromString(value, detailsCountry) ?? parsePhoneNumberFromString(formattedValue, detailsCountry);
|
|
571
|
+
const hasCountryMismatch = !!parsedNumber?.country && parsedNumber.country !== detailsCountry;
|
|
572
|
+
const detailsNumber = hasCountryMismatch ? void 0 : parsedNumber;
|
|
573
|
+
const formatterNumber = formatter.getNumber();
|
|
574
|
+
const isPossible = hasCountryMismatch ? false : detailsNumber?.isPossible() ?? formatter.isPossible();
|
|
575
|
+
const isValid = hasCountryMismatch ? false : detailsNumber?.isValid() ?? formatter.isValid();
|
|
576
|
+
return {
|
|
577
|
+
value: formattedValue,
|
|
578
|
+
e164: isValid ? detailsNumber?.number ?? formatter.getNumberValue() ?? "" : "",
|
|
579
|
+
country: detailsCountry,
|
|
580
|
+
callingCode: getPhoneCountryCallingCode(detailsCountry),
|
|
581
|
+
nationalNumber: hasCountryMismatch ? "" : detailsNumber?.nationalNumber.toString() ?? formatterNumber?.nationalNumber ?? "",
|
|
582
|
+
isPossible,
|
|
583
|
+
isValid
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function normalizePhoneInputCountries(countries) {
|
|
587
|
+
return countries.map((item)=>{
|
|
588
|
+
const displayValue = getCountryDisplayValue(item);
|
|
589
|
+
if (item.displayValue === displayValue) return item;
|
|
590
|
+
return {
|
|
591
|
+
...item,
|
|
592
|
+
displayValue
|
|
593
|
+
};
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
function getCountryDisplayValue(item) {
|
|
597
|
+
if (item.displayValue) return item.displayValue;
|
|
598
|
+
if (item.name) return item.name;
|
|
599
|
+
return "string" == typeof item.label ? item.label : item.value;
|
|
600
|
+
}
|
|
601
|
+
function isCountryAvailable(countries, country) {
|
|
602
|
+
if (!isSupportedCountry(country)) return false;
|
|
603
|
+
return !countries || countries.some((item)=>item.value === country && !item.disabled);
|
|
604
|
+
}
|
|
605
|
+
function getInitialCountry(value, defaultCountry, countries) {
|
|
606
|
+
const parsedCountry = getCountryFromValue(value, countries);
|
|
607
|
+
if (parsedCountry) return parsedCountry;
|
|
608
|
+
return defaultCountry;
|
|
609
|
+
}
|
|
610
|
+
function getCountryFromValue(value, countries) {
|
|
611
|
+
const parsedCountry = parsePhoneNumberFromString(value)?.country;
|
|
612
|
+
return parsedCountry && isCountryAvailable(countries, parsedCountry) ? parsedCountry : void 0;
|
|
613
|
+
}
|
|
614
|
+
function formatNationalSignificantPhoneValue(value, country) {
|
|
615
|
+
const callingCode = getPhoneCountryCallingCode(country);
|
|
616
|
+
const incompleteValue = parseIncompletePhoneNumber(value);
|
|
617
|
+
if (incompleteValue.startsWith("+")) {
|
|
618
|
+
if (incompleteValue.startsWith(`+${callingCode}`)) return stripCountryCallingCode(formatIncompletePhoneNumber(incompleteValue, country), callingCode);
|
|
619
|
+
return formatIncompletePhoneNumber(value, country);
|
|
620
|
+
}
|
|
621
|
+
return stripCountryCallingCode(formatIncompletePhoneNumber(`+${callingCode}${incompleteValue}`, country), callingCode);
|
|
622
|
+
}
|
|
623
|
+
function stripCountryCallingCode(value, callingCode) {
|
|
624
|
+
const prefix = `+${callingCode}`;
|
|
625
|
+
return value.startsWith(prefix) ? value.slice(prefix.length).trimStart() : value;
|
|
626
|
+
}
|
|
627
|
+
function resolveCountry(countries, country) {
|
|
628
|
+
const supportedCountry = isSupportedCountry(country) ? country : "SK";
|
|
629
|
+
if (isCountryAvailable(countries, supportedCountry)) return supportedCountry;
|
|
630
|
+
return countries.find((item)=>!item.disabled)?.value ?? "SK";
|
|
631
|
+
}
|
|
632
|
+
function getCountryItem(countries, country) {
|
|
633
|
+
return countries.find((item)=>item.value === country) ?? {
|
|
634
|
+
value: country,
|
|
635
|
+
label: country,
|
|
636
|
+
name: country
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function assignRef(ref, value) {
|
|
640
|
+
if (!ref) return;
|
|
641
|
+
if ("function" == typeof ref) return void ref(value);
|
|
642
|
+
ref.current = value;
|
|
643
|
+
}
|
|
644
|
+
function getPhoneCountryCallingCode(country) {
|
|
645
|
+
const countryCode = "string" == typeof country ? country : country.value;
|
|
646
|
+
const callingCode = getCountryCallingCode(countryCode);
|
|
647
|
+
if ("string" != typeof country && country.callingCode === callingCode) return country.callingCode;
|
|
648
|
+
return callingCode;
|
|
649
|
+
}
|
|
650
|
+
function renderCountryFlag(item) {
|
|
651
|
+
return item.flag ?? item.value;
|
|
652
|
+
}
|
|
653
|
+
PhoneInput.displayName = "PhoneInput";
|
|
654
|
+
export { PhoneInput, defaultPhoneInputCountries, formatPhoneInputValue, getPhoneInputValueDetails, phoneInputVariants, usePhoneInputContext };
|