@comitor/ui 2.0.0 → 3.0.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/LICENSE +35 -0
- package/README.md +67 -24
- package/dist/chart/chart.d.ts +6 -1
- package/dist/chart/chart.js +3 -1
- package/dist/chart/chart.js.map +1 -1
- package/dist/chart/comitor-chart.d.ts +4 -1
- package/dist/chart/comitor-chart.js +3 -1
- package/dist/chart/comitor-chart.js.map +1 -1
- package/dist/components/composite/avatar-group.d.ts +9 -6
- package/dist/components/composite/avatar-group.js +6 -2
- package/dist/components/composite/avatar-group.js.map +1 -1
- package/dist/components/composite/combobox.d.ts +11 -11
- package/dist/components/composite/combobox.js +25 -11
- package/dist/components/composite/combobox.js.map +1 -1
- package/dist/components/composite/command-palette-constants.d.ts +15 -5
- package/dist/components/composite/command-palette-constants.js +3 -2
- package/dist/components/composite/command-palette-constants.js.map +1 -1
- package/dist/components/composite/command-palette.d.ts +2 -2
- package/dist/components/composite/command-palette.js +8 -5
- package/dist/components/composite/command-palette.js.map +1 -1
- package/dist/components/composite/confirm-dialog.d.ts +8 -8
- package/dist/components/composite/confirm-dialog.js +8 -3
- package/dist/components/composite/confirm-dialog.js.map +1 -1
- package/dist/components/composite/copy-button.d.ts +7 -3
- package/dist/components/composite/copy-button.js +7 -3
- package/dist/components/composite/copy-button.js.map +1 -1
- package/dist/components/composite/data-table-constants.d.ts +7 -3
- package/dist/components/composite/data-table-constants.js +2 -9
- package/dist/components/composite/data-table-constants.js.map +1 -1
- package/dist/components/composite/data-table.js +3 -3
- package/dist/components/composite/data-table.js.map +1 -1
- package/dist/components/composite/date-picker-constants.d.ts +32 -9
- package/dist/components/composite/date-picker-constants.js +16 -11
- package/dist/components/composite/date-picker-constants.js.map +1 -1
- package/dist/components/composite/date-picker.d.ts +19 -10
- package/dist/components/composite/date-picker.js +33 -9
- package/dist/components/composite/date-picker.js.map +1 -1
- package/dist/components/composite/filter-chips.d.ts +4 -3
- package/dist/components/composite/filter-chips.js +6 -2
- package/dist/components/composite/filter-chips.js.map +1 -1
- package/dist/components/composite/inline-edit.d.ts +14 -3
- package/dist/components/composite/inline-edit.js +8 -4
- package/dist/components/composite/inline-edit.js.map +1 -1
- package/dist/components/composite/relative-time.d.ts +4 -4
- package/dist/components/composite/relative-time.js +4 -2
- package/dist/components/composite/relative-time.js.map +1 -1
- package/dist/components/composite/route-tabs-nav.d.ts +9 -0
- package/dist/components/composite/route-tabs-nav.js +11 -0
- package/dist/components/composite/route-tabs-nav.js.map +1 -0
- package/dist/components/composite/route-tabs.d.ts +4 -1
- package/dist/components/composite/route-tabs.js +3 -2
- package/dist/components/composite/route-tabs.js.map +1 -1
- package/dist/components/composite/search-filter-bar-constants.d.ts +18 -8
- package/dist/components/composite/search-filter-bar-constants.js +2 -14
- package/dist/components/composite/search-filter-bar-constants.js.map +1 -1
- package/dist/components/composite/search-filter-bar.d.ts +5 -2
- package/dist/components/composite/search-filter-bar.js +2 -2
- package/dist/components/composite/search-filter-bar.js.map +1 -1
- package/dist/components/composite/stat-card.d.ts +1 -1
- package/dist/components/composite/table-pagination-constants.d.ts +16 -11
- package/dist/components/composite/table-pagination-constants.js +2 -12
- package/dist/components/composite/table-pagination-constants.js.map +1 -1
- package/dist/components/composite/table-pagination.d.ts +6 -3
- package/dist/components/composite/table-pagination.js +3 -5
- package/dist/components/composite/table-pagination.js.map +1 -1
- package/dist/components/composite/toast.d.ts +4 -2
- package/dist/components/composite/toast.js +9 -1
- package/dist/components/composite/toast.js.map +1 -1
- package/dist/components/ui/action-bar-constants.d.ts +35 -0
- package/dist/components/ui/action-bar-constants.js +6 -0
- package/dist/components/ui/action-bar-constants.js.map +1 -0
- package/dist/components/ui/action-bar.d.ts +68 -0
- package/dist/components/ui/action-bar.js +522 -0
- package/dist/components/ui/action-bar.js.map +1 -0
- package/dist/components/ui/alert.d.ts +1 -1
- package/dist/components/ui/badge-overflow.d.ts +30 -0
- package/dist/components/ui/badge-overflow.js +181 -0
- package/dist/components/ui/badge-overflow.js.map +1 -0
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/banner.d.ts +80 -0
- package/dist/components/ui/banner.js +520 -0
- package/dist/components/ui/banner.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +11 -4
- package/dist/components/ui/breadcrumb.js +7 -2
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/calendar.d.ts +12 -5
- package/dist/components/ui/calendar.js +38 -3
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/carousel.d.ts +4 -3
- package/dist/components/ui/carousel.js +11 -4
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/circular-progress.d.ts +50 -0
- package/dist/components/ui/circular-progress.js +266 -0
- package/dist/components/ui/circular-progress.js.map +1 -0
- package/dist/components/ui/command.d.ts +5 -4
- package/dist/components/ui/command.js +6 -2
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/cropper-constants.d.ts +39 -0
- package/dist/components/ui/cropper-constants.js +6 -0
- package/dist/components/ui/cropper-constants.js.map +1 -0
- package/dist/components/ui/cropper.d.ts +107 -0
- package/dist/components/ui/cropper.js +1269 -0
- package/dist/components/ui/cropper.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +2 -2
- package/dist/components/ui/dialog.js +4 -1
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/drawer.d.ts +1 -1
- package/dist/components/ui/drawer.js +2 -2
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/kanban-constants.d.ts +67 -0
- package/dist/components/ui/kanban-constants.js +6 -0
- package/dist/components/ui/kanban-constants.js.map +1 -0
- package/dist/components/ui/kanban.d.ts +72 -0
- package/dist/components/ui/kanban.js +787 -0
- package/dist/components/ui/kanban.js.map +1 -0
- package/dist/components/ui/key-value-constants.d.ts +37 -0
- package/dist/components/ui/key-value-constants.js +6 -0
- package/dist/components/ui/key-value-constants.js.map +1 -0
- package/dist/components/ui/key-value.d.ts +96 -0
- package/dist/components/ui/key-value.js +641 -0
- package/dist/components/ui/key-value.js.map +1 -0
- package/dist/components/ui/mask-input-constants.d.ts +98 -0
- package/dist/components/ui/mask-input-constants.js +600 -0
- package/dist/components/ui/mask-input-constants.js.map +1 -0
- package/dist/components/ui/mask-input.d.ts +39 -0
- package/dist/components/ui/mask-input.js +560 -0
- package/dist/components/ui/mask-input.js.map +1 -0
- package/dist/components/ui/mention.d.ts +32 -0
- package/dist/components/ui/mention.js +126 -0
- package/dist/components/ui/mention.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +13 -9
- package/dist/components/ui/pagination.js +15 -6
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/phone-input-constants.d.ts +65 -0
- package/dist/components/ui/phone-input-constants.js +6 -0
- package/dist/components/ui/phone-input-constants.js.map +1 -0
- package/dist/components/ui/phone-input.d.ts +92 -0
- package/dist/components/ui/phone-input.js +742 -0
- package/dist/components/ui/phone-input.js.map +1 -0
- package/dist/components/ui/progress.d.ts +2 -2
- package/dist/components/ui/rating.d.ts +57 -0
- package/dist/components/ui/rating.js +648 -0
- package/dist/components/ui/rating.js.map +1 -0
- package/dist/components/ui/responsive-dialog.d.ts +35 -0
- package/dist/components/ui/responsive-dialog.js +193 -0
- package/dist/components/ui/responsive-dialog.js.map +1 -0
- package/dist/components/ui/scroll-spy.d.ts +42 -0
- package/dist/components/ui/scroll-spy.js +336 -0
- package/dist/components/ui/scroll-spy.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +2 -2
- package/dist/components/ui/sheet.js +10 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/spinner.js +4 -1
- package/dist/components/ui/spinner.js.map +1 -1
- package/dist/components/ui/stepper-constants.d.ts +34 -0
- package/dist/components/ui/stepper-constants.js +6 -0
- package/dist/components/ui/stepper-constants.js.map +1 -0
- package/dist/components/ui/stepper.d.ts +81 -0
- package/dist/components/ui/stepper.js +902 -0
- package/dist/components/ui/stepper.js.map +1 -0
- package/dist/components/ui/tags-input.d.ts +42 -0
- package/dist/components/ui/tags-input.js +129 -0
- package/dist/components/ui/tags-input.js.map +1 -0
- package/dist/components/ui/time-picker-constants.d.ts +51 -0
- package/dist/components/ui/time-picker-constants.js +6 -0
- package/dist/components/ui/time-picker-constants.js.map +1 -0
- package/dist/components/ui/time-picker.d.ts +120 -0
- package/dist/components/ui/time-picker.js +1618 -0
- package/dist/components/ui/time-picker.js.map +1 -0
- package/dist/components/ui/timeline.d.ts +32 -0
- package/dist/components/ui/timeline.js +559 -0
- package/dist/components/ui/timeline.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/tour-constants.d.ts +44 -0
- package/dist/components/ui/tour-constants.js +6 -0
- package/dist/components/ui/tour-constants.js.map +1 -0
- package/dist/components/ui/tour.d.ts +125 -0
- package/dist/components/ui/tour.js +1207 -0
- package/dist/components/ui/tour.js.map +1 -0
- package/dist/data-grid/data-grid-cell-variants.js +4 -4
- package/dist/data-grid/data-grid-cell-variants.js.map +1 -1
- package/dist/data-grid/data-grid-cell-wrapper.js +1 -1
- package/dist/data-grid/data-grid-cell-wrapper.js.map +1 -1
- package/dist/data-grid/data-grid-column-header.js +1 -1
- package/dist/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/data-grid/data-grid-context-menu.js +1 -1
- package/dist/data-grid/data-grid-context-menu.js.map +1 -1
- package/dist/data-grid/data-grid-filter-menu.d.ts +5 -4
- package/dist/data-grid/data-grid-filter-menu.js +13 -8
- package/dist/data-grid/data-grid-filter-menu.js.map +1 -1
- package/dist/data-grid/data-grid-keyboard-shortcuts.d.ts +4 -4
- package/dist/data-grid/data-grid-keyboard-shortcuts.js.map +1 -1
- package/dist/data-grid/data-grid-locale.d.ts +58 -6
- package/dist/data-grid/data-grid-locale.js +41 -9
- package/dist/data-grid/data-grid-locale.js.map +1 -1
- package/dist/data-grid/data-grid-paste-dialog.js +1 -1
- package/dist/data-grid/data-grid-paste-dialog.js.map +1 -1
- package/dist/data-grid/data-grid-row-height-menu.d.ts +4 -3
- package/dist/data-grid/data-grid-row-height-menu.js.map +1 -1
- package/dist/data-grid/data-grid-row.js +1 -1
- package/dist/data-grid/data-grid-row.js.map +1 -1
- package/dist/data-grid/data-grid-search.js +1 -1
- package/dist/data-grid/data-grid-search.js.map +1 -1
- package/dist/data-grid/data-grid-sort-menu.d.ts +4 -4
- package/dist/data-grid/data-grid-sort-menu.js +1 -1
- package/dist/data-grid/data-grid-sort-menu.js.map +1 -1
- package/dist/data-grid/data-grid-view-menu.d.ts +4 -4
- package/dist/data-grid/data-grid-view-menu.js.map +1 -1
- package/dist/data-grid/data-grid.d.ts +4 -3
- package/dist/data-grid/data-grid.js +3 -4
- package/dist/data-grid/data-grid.js.map +1 -1
- package/dist/data-grid/index.d.ts +1 -0
- package/dist/data-grid/index.js.map +1 -1
- package/dist/data-grid/messages-en.d.ts +23 -4
- package/dist/data-grid/messages-en.js +20 -0
- package/dist/data-grid/messages-en.js.map +1 -1
- package/dist/data-grid/messages-vi.d.ts +3 -1
- package/dist/data-grid/messages-vi.js +14 -0
- package/dist/data-grid/messages-vi.js.map +1 -1
- package/dist/data-grid/messages.d.ts +29 -3
- package/dist/data-grid/messages.js.map +1 -1
- package/dist/data-grid/sortable.js +17 -20
- package/dist/data-grid/sortable.js.map +1 -1
- package/dist/data-grid/types.d.ts +1 -1
- package/dist/data-grid/use-data-grid-undo-redo.d.ts +5 -4
- package/dist/data-grid/use-data-grid-undo-redo.js +4 -4
- package/dist/data-grid/use-data-grid-undo-redo.js.map +1 -1
- package/dist/data-grid/use-data-grid.d.ts +21 -6
- package/dist/data-grid/use-data-grid.js +11 -9
- package/dist/data-grid/use-data-grid.js.map +1 -1
- package/dist/data-grid/utils.d.ts +24 -4
- package/dist/data-grid/utils.js +15 -5
- package/dist/data-grid/utils.js.map +1 -1
- package/dist/i18n/locale-provider.d.ts +109 -0
- package/dist/i18n/locale-provider.js +47 -0
- package/dist/i18n/locale-provider.js.map +1 -0
- package/dist/i18n/locale.d.ts +27 -0
- package/dist/i18n/locale.js +10 -0
- package/dist/i18n/locale.js.map +1 -0
- package/dist/i18n/messages.d.ts +116 -0
- package/dist/i18n/messages.js +149 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/i18n/namespaces/action-bar.d.ts +7 -0
- package/dist/i18n/namespaces/action-bar.js +15 -0
- package/dist/i18n/namespaces/action-bar.js.map +1 -0
- package/dist/i18n/namespaces/avatar-group.d.ts +14 -0
- package/dist/i18n/namespaces/avatar-group.js +13 -0
- package/dist/i18n/namespaces/avatar-group.js.map +1 -0
- package/dist/i18n/namespaces/badge-overflow.d.ts +12 -0
- package/dist/i18n/namespaces/badge-overflow.js +11 -0
- package/dist/i18n/namespaces/badge-overflow.js.map +1 -0
- package/dist/i18n/namespaces/banner.d.ts +9 -0
- package/dist/i18n/namespaces/banner.js +7 -0
- package/dist/i18n/namespaces/banner.js.map +1 -0
- package/dist/i18n/namespaces/breadcrumb.d.ts +11 -0
- package/dist/i18n/namespaces/breadcrumb.js +13 -0
- package/dist/i18n/namespaces/breadcrumb.js.map +1 -0
- package/dist/i18n/namespaces/calendar.d.ts +40 -0
- package/dist/i18n/namespaces/calendar.js +25 -0
- package/dist/i18n/namespaces/calendar.js.map +1 -0
- package/dist/i18n/namespaces/carousel.d.ts +15 -0
- package/dist/i18n/namespaces/carousel.js +17 -0
- package/dist/i18n/namespaces/carousel.js.map +1 -0
- package/dist/i18n/namespaces/combobox.d.ts +21 -0
- package/dist/i18n/namespaces/combobox.js +23 -0
- package/dist/i18n/namespaces/combobox.js.map +1 -0
- package/dist/i18n/namespaces/command-palette.d.ts +20 -0
- package/dist/i18n/namespaces/command-palette.js +19 -0
- package/dist/i18n/namespaces/command-palette.js.map +1 -0
- package/dist/i18n/namespaces/command.d.ts +11 -0
- package/dist/i18n/namespaces/command.js +13 -0
- package/dist/i18n/namespaces/command.js.map +1 -0
- package/dist/i18n/namespaces/confirm-dialog.d.ts +13 -0
- package/dist/i18n/namespaces/confirm-dialog.js +15 -0
- package/dist/i18n/namespaces/confirm-dialog.js.map +1 -0
- package/dist/i18n/namespaces/contrast.d.ts +7 -0
- package/dist/i18n/namespaces/contrast.js +13 -0
- package/dist/i18n/namespaces/contrast.js.map +1 -0
- package/dist/i18n/namespaces/copy-button.d.ts +11 -0
- package/dist/i18n/namespaces/copy-button.js +13 -0
- package/dist/i18n/namespaces/copy-button.js.map +1 -0
- package/dist/i18n/namespaces/cropper.d.ts +7 -0
- package/dist/i18n/namespaces/cropper.js +17 -0
- package/dist/i18n/namespaces/cropper.js.map +1 -0
- package/dist/i18n/namespaces/data-table.d.ts +7 -0
- package/dist/i18n/namespaces/data-table.js +23 -0
- package/dist/i18n/namespaces/data-table.js.map +1 -0
- package/dist/i18n/namespaces/date-picker.d.ts +42 -0
- package/dist/i18n/namespaces/date-picker.js +35 -0
- package/dist/i18n/namespaces/date-picker.js.map +1 -0
- package/dist/i18n/namespaces/dialog.d.ts +9 -0
- package/dist/i18n/namespaces/dialog.js +7 -0
- package/dist/i18n/namespaces/dialog.js.map +1 -0
- package/dist/i18n/namespaces/display-axis.d.ts +25 -0
- package/dist/i18n/namespaces/display-axis.js +21 -0
- package/dist/i18n/namespaces/display-axis.js.map +1 -0
- package/dist/i18n/namespaces/file-upload.d.ts +11 -0
- package/dist/i18n/namespaces/file-upload.js +19 -0
- package/dist/i18n/namespaces/file-upload.js.map +1 -0
- package/dist/i18n/namespaces/filter-chips.d.ts +11 -0
- package/dist/i18n/namespaces/filter-chips.js +13 -0
- package/dist/i18n/namespaces/filter-chips.js.map +1 -0
- package/dist/i18n/namespaces/image-upload-field.d.ts +12 -0
- package/dist/i18n/namespaces/image-upload-field.js +23 -0
- package/dist/i18n/namespaces/image-upload-field.js.map +1 -0
- package/dist/i18n/namespaces/inline-edit.d.ts +15 -0
- package/dist/i18n/namespaces/inline-edit.js +17 -0
- package/dist/i18n/namespaces/inline-edit.js.map +1 -0
- package/dist/i18n/namespaces/kanban.d.ts +11 -0
- package/dist/i18n/namespaces/kanban.js +39 -0
- package/dist/i18n/namespaces/kanban.js.map +1 -0
- package/dist/i18n/namespaces/key-value.d.ts +10 -0
- package/dist/i18n/namespaces/key-value.js +19 -0
- package/dist/i18n/namespaces/key-value.js.map +1 -0
- package/dist/i18n/namespaces/mention.d.ts +9 -0
- package/dist/i18n/namespaces/mention.js +7 -0
- package/dist/i18n/namespaces/mention.js.map +1 -0
- package/dist/i18n/namespaces/pagination.d.ts +19 -0
- package/dist/i18n/namespaces/pagination.js +21 -0
- package/dist/i18n/namespaces/pagination.js.map +1 -0
- package/dist/i18n/namespaces/phone-input.d.ts +10 -0
- package/dist/i18n/namespaces/phone-input.js +17 -0
- package/dist/i18n/namespaces/phone-input.js.map +1 -0
- package/dist/i18n/namespaces/rating.d.ts +12 -0
- package/dist/i18n/namespaces/rating.js +11 -0
- package/dist/i18n/namespaces/rating.js.map +1 -0
- package/dist/i18n/namespaces/route-tabs.d.ts +9 -0
- package/dist/i18n/namespaces/route-tabs.js +7 -0
- package/dist/i18n/namespaces/route-tabs.js.map +1 -0
- package/dist/i18n/namespaces/scroll-spy.d.ts +9 -0
- package/dist/i18n/namespaces/scroll-spy.js +7 -0
- package/dist/i18n/namespaces/scroll-spy.js.map +1 -0
- package/dist/i18n/namespaces/search-filter-bar.d.ts +15 -0
- package/dist/i18n/namespaces/search-filter-bar.js +32 -0
- package/dist/i18n/namespaces/search-filter-bar.js.map +1 -0
- package/dist/i18n/namespaces/sheet.d.ts +9 -0
- package/dist/i18n/namespaces/sheet.js +7 -0
- package/dist/i18n/namespaces/sheet.js.map +1 -0
- package/dist/i18n/namespaces/shell.d.ts +17 -0
- package/dist/i18n/namespaces/shell.js +75 -0
- package/dist/i18n/namespaces/shell.js.map +1 -0
- package/dist/i18n/namespaces/spinner.d.ts +9 -0
- package/dist/i18n/namespaces/spinner.js +7 -0
- package/dist/i18n/namespaces/spinner.js.map +1 -0
- package/dist/i18n/namespaces/stepper.d.ts +7 -0
- package/dist/i18n/namespaces/stepper.js +15 -0
- package/dist/i18n/namespaces/stepper.js.map +1 -0
- package/dist/i18n/namespaces/table-pagination.d.ts +7 -0
- package/dist/i18n/namespaces/table-pagination.js +29 -0
- package/dist/i18n/namespaces/table-pagination.js.map +1 -0
- package/dist/i18n/namespaces/tags-input.d.ts +12 -0
- package/dist/i18n/namespaces/tags-input.js +11 -0
- package/dist/i18n/namespaces/tags-input.js.map +1 -0
- package/dist/i18n/namespaces/time-picker.d.ts +15 -0
- package/dist/i18n/namespaces/time-picker.js +25 -0
- package/dist/i18n/namespaces/time-picker.js.map +1 -0
- package/dist/i18n/namespaces/toast.d.ts +15 -0
- package/dist/i18n/namespaces/toast.js +7 -0
- package/dist/i18n/namespaces/toast.js.map +1 -0
- package/dist/i18n/namespaces/tour.d.ts +7 -0
- package/dist/i18n/namespaces/tour.js +21 -0
- package/dist/i18n/namespaces/tour.js.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +66 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/compose-refs.js.map +1 -0
- package/dist/lib/use-as-ref.js.map +1 -0
- package/dist/lib/use-is-mobile.d.ts +10 -0
- package/dist/lib/use-is-mobile.js +21 -0
- package/dist/lib/use-is-mobile.js.map +1 -0
- package/dist/lib/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/lib/use-lazy-ref.js.map +1 -0
- package/dist/lib/visually-hidden-input.d.ts +12 -0
- package/dist/lib/visually-hidden-input.js +105 -0
- package/dist/lib/visually-hidden-input.js.map +1 -0
- package/dist/shell/app-header.js.map +1 -1
- package/dist/shell/app-shell.d.ts +20 -2
- package/dist/shell/app-shell.js +4 -1
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/contrast-constants.d.ts +9 -1
- package/dist/shell/contrast-constants.js +2 -4
- package/dist/shell/contrast-constants.js.map +1 -1
- package/dist/shell/contrast-toggle.d.ts +4 -1
- package/dist/shell/contrast-toggle.js +2 -2
- package/dist/shell/contrast-toggle.js.map +1 -1
- package/dist/shell/display-axis-constants.d.ts +2 -1
- package/dist/shell/display-axis-constants.js.map +1 -1
- package/dist/shell/display-axis-controls.d.ts +15 -6
- package/dist/shell/display-axis-controls.js +11 -9
- package/dist/shell/display-axis-controls.js.map +1 -1
- package/dist/shell/mobile-menu.js.map +1 -1
- package/dist/shell/notifications-button.d.ts +1 -1
- package/dist/shell/notifications-button.js +3 -2
- package/dist/shell/notifications-button.js.map +1 -1
- package/dist/shell/shell-context.d.ts +4 -1
- package/dist/shell/shell-context.js +2 -4
- package/dist/shell/shell-context.js.map +1 -1
- package/dist/shell/sidebar.d.ts +1 -1
- package/dist/shell/sidebar.js.map +1 -1
- package/dist/shell/theme-toggle.d.ts +6 -3
- package/dist/shell/theme-toggle.js +2 -2
- package/dist/shell/theme-toggle.js.map +1 -1
- package/dist/shell/types.d.ts +14 -8
- package/dist/shell/types.js +2 -35
- package/dist/shell/types.js.map +1 -1
- package/dist/shell/user-menu.d.ts +6 -6
- package/dist/shell/user-menu.js.map +1 -1
- package/dist/shell/utils.d.ts +1 -1
- package/dist/shell/utils.js.map +1 -1
- package/dist/shell/workspace-switcher.js +1 -1
- package/dist/shell/workspace-switcher.js.map +1 -1
- package/dist/uploader/file-upload-constants.d.ts +13 -0
- package/dist/uploader/file-upload-constants.js +4 -16
- package/dist/uploader/file-upload-constants.js.map +1 -1
- package/dist/uploader/file-upload.d.ts +4 -1
- package/dist/uploader/file-upload.js +2 -2
- package/dist/uploader/file-upload.js.map +1 -1
- package/dist/uploader/image-upload-field.d.ts +5 -1
- package/dist/uploader/image-upload-field.js +2 -2
- package/dist/uploader/image-upload-field.js.map +1 -1
- package/dist/uploader/use-file-upload.d.ts +4 -0
- package/dist/uploader/use-file-upload.js +6 -2
- package/dist/uploader/use-file-upload.js.map +1 -1
- package/package.json +8 -3
- package/styles.css +19 -0
- package/dist/data-grid/compose-refs.js.map +0 -1
- package/dist/data-grid/use-as-ref.js.map +0 -1
- package/dist/data-grid/use-isomorphic-layout-effect.js.map +0 -1
- package/dist/data-grid/use-lazy-ref.js.map +0 -1
- /package/dist/{data-grid → lib}/compose-refs.d.ts +0 -0
- /package/dist/{data-grid → lib}/compose-refs.js +0 -0
- /package/dist/{data-grid → lib}/use-as-ref.d.ts +0 -0
- /package/dist/{data-grid → lib}/use-as-ref.js +0 -0
- /package/dist/{data-grid → lib}/use-isomorphic-layout-effect.d.ts +0 -0
- /package/dist/{data-grid → lib}/use-isomorphic-layout-effect.js +0 -0
- /package/dist/{data-grid → lib}/use-lazy-ref.d.ts +0 -0
- /package/dist/{data-grid → lib}/use-lazy-ref.js +0 -0
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { defaultFilter } from "cmdk";
|
|
5
|
+
import { Check, ChevronDown, Globe } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { useComitorLabels, useComitorLocale } from "../../i18n/locale-provider.js";
|
|
8
|
+
import { cn } from "../../lib/cn.js";
|
|
9
|
+
import { useComposedRefs } from "../../lib/compose-refs.js";
|
|
10
|
+
import { useAsRef } from "../../lib/use-as-ref.js";
|
|
11
|
+
import { useIsomorphicLayoutEffect } from "../../lib/use-isomorphic-layout-effect.js";
|
|
12
|
+
import { useLazyRef } from "../../lib/use-lazy-ref.js";
|
|
13
|
+
import { VisuallyHiddenInput } from "../../lib/visually-hidden-input.js";
|
|
14
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
|
|
15
|
+
import { Input } from "./input.js";
|
|
16
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
17
|
+
const ROOT_NAME = "PhoneInput";
|
|
18
|
+
const COUNTRY_SELECT_NAME = "PhoneInputCountrySelect";
|
|
19
|
+
const FIELD_NAME = "PhoneInputField";
|
|
20
|
+
const COUNTRY_DATA = [
|
|
21
|
+
["af", "93"],
|
|
22
|
+
["ax", "358"],
|
|
23
|
+
["al", "355"],
|
|
24
|
+
["dz", "213"],
|
|
25
|
+
["as", "1684"],
|
|
26
|
+
["ad", "376"],
|
|
27
|
+
["ao", "244"],
|
|
28
|
+
["ai", "1264"],
|
|
29
|
+
["ag", "1268"],
|
|
30
|
+
["ar", "54"],
|
|
31
|
+
["am", "374"],
|
|
32
|
+
["aw", "297"],
|
|
33
|
+
["au", "61"],
|
|
34
|
+
["at", "43"],
|
|
35
|
+
["az", "994"],
|
|
36
|
+
["bs", "1242"],
|
|
37
|
+
["bh", "973"],
|
|
38
|
+
["bd", "880"],
|
|
39
|
+
["bb", "1246"],
|
|
40
|
+
["by", "375"],
|
|
41
|
+
["be", "32"],
|
|
42
|
+
["bz", "501"],
|
|
43
|
+
["bj", "229"],
|
|
44
|
+
["bm", "1441"],
|
|
45
|
+
["bt", "975"],
|
|
46
|
+
["bo", "591"],
|
|
47
|
+
["ba", "387"],
|
|
48
|
+
["bw", "267"],
|
|
49
|
+
["br", "55"],
|
|
50
|
+
["io", "246"],
|
|
51
|
+
["vg", "1284"],
|
|
52
|
+
["bn", "673"],
|
|
53
|
+
["bg", "359"],
|
|
54
|
+
["bf", "226"],
|
|
55
|
+
["bi", "257"],
|
|
56
|
+
["kh", "855"],
|
|
57
|
+
["cm", "237"],
|
|
58
|
+
["ca", "1"],
|
|
59
|
+
["cv", "238"],
|
|
60
|
+
["bq", "599"],
|
|
61
|
+
["ky", "1345"],
|
|
62
|
+
["cf", "236"],
|
|
63
|
+
["td", "235"],
|
|
64
|
+
["cl", "56"],
|
|
65
|
+
["cn", "86"],
|
|
66
|
+
["co", "57"],
|
|
67
|
+
["km", "269"],
|
|
68
|
+
["cd", "243"],
|
|
69
|
+
["cg", "242"],
|
|
70
|
+
["ck", "682"],
|
|
71
|
+
["cr", "506"],
|
|
72
|
+
["ci", "225"],
|
|
73
|
+
["hr", "385"],
|
|
74
|
+
["cu", "53"],
|
|
75
|
+
["cw", "599"],
|
|
76
|
+
["cy", "357"],
|
|
77
|
+
["cz", "420"],
|
|
78
|
+
["dk", "45"],
|
|
79
|
+
["dj", "253"],
|
|
80
|
+
["dm", "1767"],
|
|
81
|
+
["do", "1"],
|
|
82
|
+
["ec", "593"],
|
|
83
|
+
["eg", "20"],
|
|
84
|
+
["sv", "503"],
|
|
85
|
+
["gq", "240"],
|
|
86
|
+
["er", "291"],
|
|
87
|
+
["ee", "372"],
|
|
88
|
+
["et", "251"],
|
|
89
|
+
["fk", "500"],
|
|
90
|
+
["fo", "298"],
|
|
91
|
+
["fj", "679"],
|
|
92
|
+
["fi", "358"],
|
|
93
|
+
["fr", "33"],
|
|
94
|
+
["gf", "594"],
|
|
95
|
+
["pf", "689"],
|
|
96
|
+
["ga", "241"],
|
|
97
|
+
["gm", "220"],
|
|
98
|
+
["ge", "995"],
|
|
99
|
+
["de", "49"],
|
|
100
|
+
["gh", "233"],
|
|
101
|
+
["gi", "350"],
|
|
102
|
+
["gr", "30"],
|
|
103
|
+
["gl", "299"],
|
|
104
|
+
["gd", "1473"],
|
|
105
|
+
["gp", "590"],
|
|
106
|
+
["gu", "1671"],
|
|
107
|
+
["gt", "502"],
|
|
108
|
+
["gg", "44"],
|
|
109
|
+
["gn", "224"],
|
|
110
|
+
["gw", "245"],
|
|
111
|
+
["gy", "592"],
|
|
112
|
+
["ht", "509"],
|
|
113
|
+
["hn", "504"],
|
|
114
|
+
["hk", "852"],
|
|
115
|
+
["hu", "36"],
|
|
116
|
+
["is", "354"],
|
|
117
|
+
["in", "91"],
|
|
118
|
+
["id", "62"],
|
|
119
|
+
["ir", "98"],
|
|
120
|
+
["iq", "964"],
|
|
121
|
+
["ie", "353"],
|
|
122
|
+
["im", "44"],
|
|
123
|
+
["il", "972"],
|
|
124
|
+
["it", "39"],
|
|
125
|
+
["jm", "1876"],
|
|
126
|
+
["jp", "81"],
|
|
127
|
+
["je", "44"],
|
|
128
|
+
["jo", "962"],
|
|
129
|
+
["kz", "7"],
|
|
130
|
+
["ke", "254"],
|
|
131
|
+
["ki", "686"],
|
|
132
|
+
["xk", "383"],
|
|
133
|
+
["kw", "965"],
|
|
134
|
+
["kg", "996"],
|
|
135
|
+
["la", "856"],
|
|
136
|
+
["lv", "371"],
|
|
137
|
+
["lb", "961"],
|
|
138
|
+
["ls", "266"],
|
|
139
|
+
["lr", "231"],
|
|
140
|
+
["ly", "218"],
|
|
141
|
+
["li", "423"],
|
|
142
|
+
["lt", "370"],
|
|
143
|
+
["lu", "352"],
|
|
144
|
+
["mo", "853"],
|
|
145
|
+
["mk", "389"],
|
|
146
|
+
["mg", "261"],
|
|
147
|
+
["mw", "265"],
|
|
148
|
+
["my", "60"],
|
|
149
|
+
["mv", "960"],
|
|
150
|
+
["ml", "223"],
|
|
151
|
+
["mt", "356"],
|
|
152
|
+
["mh", "692"],
|
|
153
|
+
["mq", "596"],
|
|
154
|
+
["mr", "222"],
|
|
155
|
+
["mu", "230"],
|
|
156
|
+
["mx", "52"],
|
|
157
|
+
["fm", "691"],
|
|
158
|
+
["md", "373"],
|
|
159
|
+
["mc", "377"],
|
|
160
|
+
["mn", "976"],
|
|
161
|
+
["me", "382"],
|
|
162
|
+
["ms", "1664"],
|
|
163
|
+
["ma", "212"],
|
|
164
|
+
["mz", "258"],
|
|
165
|
+
["mm", "95"],
|
|
166
|
+
["na", "264"],
|
|
167
|
+
["nr", "674"],
|
|
168
|
+
["np", "977"],
|
|
169
|
+
["nl", "31"],
|
|
170
|
+
["nc", "687"],
|
|
171
|
+
["nz", "64"],
|
|
172
|
+
["ni", "505"],
|
|
173
|
+
["ne", "227"],
|
|
174
|
+
["ng", "234"],
|
|
175
|
+
["nu", "683"],
|
|
176
|
+
["nf", "672"],
|
|
177
|
+
["kp", "850"],
|
|
178
|
+
["mp", "1670"],
|
|
179
|
+
["no", "47"],
|
|
180
|
+
["om", "968"],
|
|
181
|
+
["pk", "92"],
|
|
182
|
+
["pw", "680"],
|
|
183
|
+
["ps", "970"],
|
|
184
|
+
["pa", "507"],
|
|
185
|
+
["pg", "675"],
|
|
186
|
+
["py", "595"],
|
|
187
|
+
["pe", "51"],
|
|
188
|
+
["ph", "63"],
|
|
189
|
+
["pl", "48"],
|
|
190
|
+
["pt", "351"],
|
|
191
|
+
["pr", "1"],
|
|
192
|
+
["qa", "974"],
|
|
193
|
+
["re", "262"],
|
|
194
|
+
["ro", "40"],
|
|
195
|
+
["ru", "7"],
|
|
196
|
+
["rw", "250"],
|
|
197
|
+
["bl", "590"],
|
|
198
|
+
["sh", "290"],
|
|
199
|
+
["kn", "1869"],
|
|
200
|
+
["lc", "1758"],
|
|
201
|
+
["mf", "590"],
|
|
202
|
+
["pm", "508"],
|
|
203
|
+
["vc", "1784"],
|
|
204
|
+
["ws", "685"],
|
|
205
|
+
["sm", "378"],
|
|
206
|
+
["st", "239"],
|
|
207
|
+
["sa", "966"],
|
|
208
|
+
["sn", "221"],
|
|
209
|
+
["rs", "381"],
|
|
210
|
+
["sc", "248"],
|
|
211
|
+
["sl", "232"],
|
|
212
|
+
["sg", "65"],
|
|
213
|
+
["sx", "1721"],
|
|
214
|
+
["sk", "421"],
|
|
215
|
+
["si", "386"],
|
|
216
|
+
["sb", "677"],
|
|
217
|
+
["so", "252"],
|
|
218
|
+
["za", "27"],
|
|
219
|
+
["kr", "82"],
|
|
220
|
+
["ss", "211"],
|
|
221
|
+
["es", "34"],
|
|
222
|
+
["lk", "94"],
|
|
223
|
+
["sd", "249"],
|
|
224
|
+
["sr", "597"],
|
|
225
|
+
["sz", "268"],
|
|
226
|
+
["se", "46"],
|
|
227
|
+
["ch", "41"],
|
|
228
|
+
["sy", "963"],
|
|
229
|
+
["tw", "886"],
|
|
230
|
+
["tj", "992"],
|
|
231
|
+
["tz", "255"],
|
|
232
|
+
["th", "66"],
|
|
233
|
+
["tl", "670"],
|
|
234
|
+
["tg", "228"],
|
|
235
|
+
["tk", "690"],
|
|
236
|
+
["to", "676"],
|
|
237
|
+
["tt", "1868"],
|
|
238
|
+
["tn", "216"],
|
|
239
|
+
["tr", "90"],
|
|
240
|
+
["tm", "993"],
|
|
241
|
+
["tc", "1649"],
|
|
242
|
+
["tv", "688"],
|
|
243
|
+
["vi", "1340"],
|
|
244
|
+
["ug", "256"],
|
|
245
|
+
["ua", "380"],
|
|
246
|
+
["ae", "971"],
|
|
247
|
+
["gb", "44"],
|
|
248
|
+
["us", "1"],
|
|
249
|
+
["uy", "598"],
|
|
250
|
+
["uz", "998"],
|
|
251
|
+
["vu", "678"],
|
|
252
|
+
["va", "39"],
|
|
253
|
+
["ve", "58"],
|
|
254
|
+
["vn", "84"],
|
|
255
|
+
["wf", "681"],
|
|
256
|
+
["eh", "212"],
|
|
257
|
+
["ye", "967"],
|
|
258
|
+
["zm", "260"],
|
|
259
|
+
["zw", "263"]
|
|
260
|
+
];
|
|
261
|
+
function getCountryName(countryCode, regionNames) {
|
|
262
|
+
try {
|
|
263
|
+
return regionNames?.of(countryCode) ?? countryCode;
|
|
264
|
+
} catch {
|
|
265
|
+
return countryCode;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function getFlagEmoji(countryCode) {
|
|
269
|
+
const codePoints = countryCode.toUpperCase().split("").map((char) => 127397 + char.charCodeAt(0));
|
|
270
|
+
return String.fromCodePoint(...codePoints);
|
|
271
|
+
}
|
|
272
|
+
function getCountries(locale) {
|
|
273
|
+
let regionNames;
|
|
274
|
+
let collator;
|
|
275
|
+
try {
|
|
276
|
+
regionNames = new Intl.DisplayNames([locale], { type: "region" });
|
|
277
|
+
collator = new Intl.Collator(locale);
|
|
278
|
+
} catch {
|
|
279
|
+
}
|
|
280
|
+
return COUNTRY_DATA.map(([iso2, dialCode]) => {
|
|
281
|
+
const code = iso2.toUpperCase();
|
|
282
|
+
return {
|
|
283
|
+
code,
|
|
284
|
+
name: getCountryName(code, regionNames),
|
|
285
|
+
dialCode: `+${dialCode}`,
|
|
286
|
+
flag: getFlagEmoji(code)
|
|
287
|
+
};
|
|
288
|
+
}).sort((a, b) => collator ? collator.compare(a.name, b.name) : a.name.localeCompare(b.name));
|
|
289
|
+
}
|
|
290
|
+
function removeDiacritics(text) {
|
|
291
|
+
return text.normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/đ/g, "d").replace(/Đ/g, "D");
|
|
292
|
+
}
|
|
293
|
+
function filterCountries(value, search, keywords) {
|
|
294
|
+
return defaultFilter(removeDiacritics(value), removeDiacritics(search), keywords?.map(removeDiacritics));
|
|
295
|
+
}
|
|
296
|
+
const PRIMARY_COUNTRY_BY_DIAL_CODE = {
|
|
297
|
+
"+1": "US",
|
|
298
|
+
"+7": "RU",
|
|
299
|
+
"+39": "IT",
|
|
300
|
+
"+44": "GB",
|
|
301
|
+
"+212": "MA",
|
|
302
|
+
"+358": "FI",
|
|
303
|
+
"+590": "GP",
|
|
304
|
+
"+599": "CW"
|
|
305
|
+
};
|
|
306
|
+
function detectCountryFromNumber(value, countries, currentCode) {
|
|
307
|
+
if (!value?.startsWith("+")) return void 0;
|
|
308
|
+
const digits = value.slice(1).replace(/\D/g, "");
|
|
309
|
+
if (!digits) return void 0;
|
|
310
|
+
const sorted = [...countries].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
311
|
+
const matches = [];
|
|
312
|
+
for (const country of sorted) {
|
|
313
|
+
const dialCode = country.dialCode.slice(1);
|
|
314
|
+
if (digits.startsWith(dialCode)) {
|
|
315
|
+
matches.push(country);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const best = matches[0];
|
|
319
|
+
if (!best) return void 0;
|
|
320
|
+
const tied = matches.filter((c) => c.dialCode === best.dialCode);
|
|
321
|
+
if (tied.length > 1) {
|
|
322
|
+
const current = tied.find((c) => c.code === currentCode);
|
|
323
|
+
if (current) return current;
|
|
324
|
+
const primary = tied.find((c) => c.code === PRIMARY_COUNTRY_BY_DIAL_CODE[best.dialCode]);
|
|
325
|
+
if (primary) return primary;
|
|
326
|
+
}
|
|
327
|
+
return best;
|
|
328
|
+
}
|
|
329
|
+
function formatPhoneNumber(value, countries) {
|
|
330
|
+
if (!value) return "";
|
|
331
|
+
const normalized = value.startsWith("+") ? value : `+${value}`;
|
|
332
|
+
const digits = normalized.slice(1).replace(/\D/g, "");
|
|
333
|
+
if (!digits) return "+";
|
|
334
|
+
const detected = detectCountryFromNumber(`+${digits}`, countries);
|
|
335
|
+
const dialCodeLength = detected ? detected.dialCode.slice(1).length : Math.min(digits.length, 3);
|
|
336
|
+
const countryCode = digits.slice(0, dialCodeLength);
|
|
337
|
+
const rest = digits.slice(dialCodeLength);
|
|
338
|
+
let formatted = `+${countryCode}`;
|
|
339
|
+
if (rest) {
|
|
340
|
+
formatted += " ";
|
|
341
|
+
for (let i = 0; i < rest.length; i++) {
|
|
342
|
+
if (i > 0 && i % 3 === 0) {
|
|
343
|
+
formatted += " ";
|
|
344
|
+
}
|
|
345
|
+
formatted += rest[i];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return formatted;
|
|
349
|
+
}
|
|
350
|
+
const NO_TRUNK_PREFIX_COUNTRIES = /* @__PURE__ */ new Set(["IT", "SM", "VA"]);
|
|
351
|
+
const NATIONAL_INPUT_DISALLOWED = /[^\d\s().-]/g;
|
|
352
|
+
function nationalToE164(nationalInput, country) {
|
|
353
|
+
let digits = nationalInput.replace(/\D/g, "");
|
|
354
|
+
if (digits.startsWith("0") && !NO_TRUNK_PREFIX_COUNTRIES.has(country.code)) {
|
|
355
|
+
digits = digits.slice(1);
|
|
356
|
+
}
|
|
357
|
+
return digits ? `${country.dialCode}${digits}` : "";
|
|
358
|
+
}
|
|
359
|
+
function getNationalInput(state, countries) {
|
|
360
|
+
const { nationalInput, country, value } = state;
|
|
361
|
+
if (nationalInput === null) return null;
|
|
362
|
+
const selected = countries.find((c) => c.code === country);
|
|
363
|
+
if (!selected || nationalToE164(nationalInput, selected) !== value) return null;
|
|
364
|
+
return nationalInput;
|
|
365
|
+
}
|
|
366
|
+
const StoreContext = React.createContext(null);
|
|
367
|
+
function useStoreContext(consumerName) {
|
|
368
|
+
const context = React.useContext(StoreContext);
|
|
369
|
+
if (!context) {
|
|
370
|
+
throw new Error(`\`${consumerName}\` ph\u1EA3i n\u1EB1m b\xEAn trong \`${ROOT_NAME}\``);
|
|
371
|
+
}
|
|
372
|
+
return context;
|
|
373
|
+
}
|
|
374
|
+
function useStore(selector, ogStore) {
|
|
375
|
+
const contextStore = React.useContext(StoreContext);
|
|
376
|
+
const store = ogStore ?? contextStore;
|
|
377
|
+
if (!store) {
|
|
378
|
+
throw new Error(`\`usePhoneInput\` ph\u1EA3i \u0111\u01B0\u1EE3c g\u1ECDi b\xEAn trong \`${ROOT_NAME}\``);
|
|
379
|
+
}
|
|
380
|
+
const getSnapshot = React.useCallback(() => selector(store.getState()), [store, selector]);
|
|
381
|
+
return React.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
382
|
+
}
|
|
383
|
+
const PhoneInputContext = React.createContext(null);
|
|
384
|
+
function usePhoneInputContext(consumerName) {
|
|
385
|
+
const context = React.useContext(PhoneInputContext);
|
|
386
|
+
if (!context) {
|
|
387
|
+
throw new Error(`\`${consumerName}\` ph\u1EA3i n\u1EB1m b\xEAn trong \`${ROOT_NAME}\``);
|
|
388
|
+
}
|
|
389
|
+
return context;
|
|
390
|
+
}
|
|
391
|
+
function PhoneInput(props) {
|
|
392
|
+
const {
|
|
393
|
+
value: valueProp,
|
|
394
|
+
defaultValue,
|
|
395
|
+
defaultCountry,
|
|
396
|
+
country: countryProp,
|
|
397
|
+
onValueChange,
|
|
398
|
+
onCountryChange,
|
|
399
|
+
countries: countriesProp,
|
|
400
|
+
name,
|
|
401
|
+
placeholder: placeholderProp,
|
|
402
|
+
locale: localeProp,
|
|
403
|
+
labels: labelsProp,
|
|
404
|
+
asChild,
|
|
405
|
+
disabled,
|
|
406
|
+
required,
|
|
407
|
+
readOnly,
|
|
408
|
+
invalid,
|
|
409
|
+
showFlag = true,
|
|
410
|
+
className,
|
|
411
|
+
id,
|
|
412
|
+
ref,
|
|
413
|
+
...rootProps
|
|
414
|
+
} = props;
|
|
415
|
+
const { locale: providerLocale } = useComitorLocale();
|
|
416
|
+
const locale = localeProp ?? providerLocale;
|
|
417
|
+
const labels = useComitorLabels("phoneInput", labelsProp);
|
|
418
|
+
const placeholder = placeholderProp ?? labels.placeholder;
|
|
419
|
+
const instanceId = React.useId();
|
|
420
|
+
const rootId = id ?? instanceId;
|
|
421
|
+
const inputRef = React.useRef(null);
|
|
422
|
+
const countries = React.useMemo(() => countriesProp ?? getCountries(locale), [countriesProp, locale]);
|
|
423
|
+
const [formTrigger, setFormTrigger] = React.useState(null);
|
|
424
|
+
const composedRef = useComposedRefs(ref, (node) => setFormTrigger(node));
|
|
425
|
+
const isFormControl = formTrigger ? !!formTrigger.closest("form") : true;
|
|
426
|
+
const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
|
|
427
|
+
const stateRef = useLazyRef(() => {
|
|
428
|
+
const initialValue = valueProp ?? defaultValue ?? "";
|
|
429
|
+
const initialCountry = countryProp ?? defaultCountry ?? "";
|
|
430
|
+
return {
|
|
431
|
+
value: initialValue,
|
|
432
|
+
country: initialCountry,
|
|
433
|
+
open: false,
|
|
434
|
+
startsWithPlus: initialValue.startsWith("+"),
|
|
435
|
+
nationalInput: null
|
|
436
|
+
};
|
|
437
|
+
});
|
|
438
|
+
const propsRef = useAsRef({
|
|
439
|
+
onValueChange,
|
|
440
|
+
onCountryChange,
|
|
441
|
+
countries
|
|
442
|
+
});
|
|
443
|
+
const store = React.useMemo(() => {
|
|
444
|
+
return {
|
|
445
|
+
subscribe: (cb) => {
|
|
446
|
+
listenersRef.current.add(cb);
|
|
447
|
+
return () => listenersRef.current.delete(cb);
|
|
448
|
+
},
|
|
449
|
+
getState: () => stateRef.current,
|
|
450
|
+
setState: (key, value2) => {
|
|
451
|
+
if (Object.is(stateRef.current[key], value2)) return;
|
|
452
|
+
if (key === "value" && typeof value2 === "string") {
|
|
453
|
+
stateRef.current.value = value2;
|
|
454
|
+
propsRef.current.onValueChange?.(value2);
|
|
455
|
+
} else if (key === "country" && typeof value2 === "string") {
|
|
456
|
+
const nationalInput2 = getNationalInput(stateRef.current, propsRef.current.countries);
|
|
457
|
+
stateRef.current.country = value2;
|
|
458
|
+
propsRef.current.onCountryChange?.(value2);
|
|
459
|
+
if (nationalInput2 !== null) {
|
|
460
|
+
const selected = propsRef.current.countries.find((c) => c.code === value2);
|
|
461
|
+
if (selected) {
|
|
462
|
+
const nextValue = nationalToE164(nationalInput2, selected);
|
|
463
|
+
if (nextValue !== stateRef.current.value) {
|
|
464
|
+
stateRef.current.value = nextValue;
|
|
465
|
+
propsRef.current.onValueChange?.(nextValue);
|
|
466
|
+
}
|
|
467
|
+
} else {
|
|
468
|
+
stateRef.current.nationalInput = null;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
stateRef.current[key] = value2;
|
|
473
|
+
}
|
|
474
|
+
store.notify();
|
|
475
|
+
},
|
|
476
|
+
notify: () => {
|
|
477
|
+
for (const cb of listenersRef.current) {
|
|
478
|
+
cb();
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
}, [listenersRef, stateRef, propsRef]);
|
|
483
|
+
const value = useStore((state) => state.value, store);
|
|
484
|
+
const country = useStore((state) => state.country, store);
|
|
485
|
+
useIsomorphicLayoutEffect(() => {
|
|
486
|
+
if (valueProp !== void 0) {
|
|
487
|
+
store.setState("value", valueProp);
|
|
488
|
+
}
|
|
489
|
+
}, [valueProp]);
|
|
490
|
+
useIsomorphicLayoutEffect(() => {
|
|
491
|
+
if (countryProp !== void 0) {
|
|
492
|
+
store.setState("country", countryProp);
|
|
493
|
+
}
|
|
494
|
+
}, [countryProp]);
|
|
495
|
+
const startsWithPlus = useStore((state) => state.startsWithPlus, store);
|
|
496
|
+
const nationalInput = useStore((state) => getNationalInput(state, countries), store);
|
|
497
|
+
React.useEffect(() => {
|
|
498
|
+
if (!value || nationalInput !== null) return;
|
|
499
|
+
const digits = value.slice(1).replace(/\D/g, "");
|
|
500
|
+
const shouldDetect = startsWithPlus || digits.length >= 10;
|
|
501
|
+
if (!shouldDetect) return;
|
|
502
|
+
const detected = detectCountryFromNumber(value, countries, country);
|
|
503
|
+
if (detected && detected.code !== country) {
|
|
504
|
+
store.setState("country", detected.code);
|
|
505
|
+
}
|
|
506
|
+
}, [value, countries, country, store, startsWithPlus, nationalInput]);
|
|
507
|
+
const contextValue = React.useMemo(
|
|
508
|
+
() => ({
|
|
509
|
+
rootId,
|
|
510
|
+
countries,
|
|
511
|
+
placeholder,
|
|
512
|
+
labels,
|
|
513
|
+
disabled,
|
|
514
|
+
readOnly,
|
|
515
|
+
required,
|
|
516
|
+
invalid,
|
|
517
|
+
showFlag,
|
|
518
|
+
inputRef
|
|
519
|
+
}),
|
|
520
|
+
[rootId, countries, placeholder, labels, disabled, required, readOnly, invalid, showFlag]
|
|
521
|
+
);
|
|
522
|
+
const RootPrimitive = asChild ? Slot : "div";
|
|
523
|
+
return /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children: /* @__PURE__ */ jsxs(PhoneInputContext.Provider, { value: contextValue, children: [
|
|
524
|
+
/* @__PURE__ */ jsx(
|
|
525
|
+
RootPrimitive,
|
|
526
|
+
{
|
|
527
|
+
role: "group",
|
|
528
|
+
"data-slot": "phone-input",
|
|
529
|
+
"data-disabled": disabled ? "" : void 0,
|
|
530
|
+
"data-invalid": invalid ? "" : void 0,
|
|
531
|
+
"data-readonly": readOnly ? "" : void 0,
|
|
532
|
+
id: rootId,
|
|
533
|
+
...rootProps,
|
|
534
|
+
ref: composedRef,
|
|
535
|
+
className: cn(
|
|
536
|
+
/*
|
|
537
|
+
* ⚠ Khác thượng nguồn: khung mượn đúng vai trò màu của `Input` Comitor để đứng cạnh ô
|
|
538
|
+
* nhập thường trong một form không lệch (cao `h-9` thay vì `h-10`, nền `bg-background`
|
|
539
|
+
* thay vì `dark:bg-input/30` — viết thẳng thang màu thì bảng tương phản cao không đổi
|
|
540
|
+
* được). Số đo từng vai trò: chú thích đầu `input.tsx`.
|
|
541
|
+
*
|
|
542
|
+
* Focus: thượng nguồn soi `[data-slot=input-group-control]` — slot KHÔNG tồn tại trong
|
|
543
|
+
* component này, nên khung không bao giờ sáng. Ở đây soi đúng slot của ô số.
|
|
544
|
+
*
|
|
545
|
+
* Lỗi: HAI đường như `InputGroup` — `aria-invalid` trên ô số (prop `invalid`), hoặc
|
|
546
|
+
* trên CHÍNH gốc khi `<FormControl>` của `@comitor/ui/form` dán nó vào con trực tiếp.
|
|
547
|
+
* Viền lỗi là `--destructive-ink` (không phải `--destructive` — token TÔ NỀN).
|
|
548
|
+
*
|
|
549
|
+
* Vô hiệu: thượng nguồn làm mờ CẢ gốc (`data-disabled:opacity-50`) trong khi nút và ô
|
|
550
|
+
* số bên trong cũng tự mờ theo `:disabled` → nội dung còn 25%. Ở đây gốc KHÔNG mờ (như
|
|
551
|
+
* `InputGroup`); hai con tự mờ bằng `:disabled` gốc của HTML, gốc chỉ đổi nền theo ô số.
|
|
552
|
+
* `data-disabled` còn không được cổng tương phản coi là trạng thái vô hiệu — nó không
|
|
553
|
+
* chứng minh phần tử đã inert — còn `:disabled` thì có.
|
|
554
|
+
*/
|
|
555
|
+
"relative flex h-9 w-full items-center rounded-md border border-input bg-background transition-colors duration-150 ease-out hover:border-control-edge-strong",
|
|
556
|
+
"has-[[data-slot=phone-input-field]:focus-visible]:border-primary-ink has-[[data-slot=phone-input-field]:focus-visible]:ring-2 has-[[data-slot=phone-input-field]:focus-visible]:ring-ring/50",
|
|
557
|
+
"has-[[data-slot][aria-invalid=true]]:border-destructive-ink has-[[data-slot][aria-invalid=true]]:ring-destructive/30",
|
|
558
|
+
"aria-invalid:border-destructive-ink aria-invalid:hover:border-destructive-ink aria-invalid:ring-destructive/30",
|
|
559
|
+
"data-disabled:cursor-not-allowed has-[[data-slot=phone-input-field]:disabled]:bg-muted",
|
|
560
|
+
className
|
|
561
|
+
)
|
|
562
|
+
}
|
|
563
|
+
),
|
|
564
|
+
isFormControl && /* @__PURE__ */ jsx(
|
|
565
|
+
VisuallyHiddenInput,
|
|
566
|
+
{
|
|
567
|
+
type: "hidden",
|
|
568
|
+
control: formTrigger,
|
|
569
|
+
name,
|
|
570
|
+
value,
|
|
571
|
+
disabled,
|
|
572
|
+
readOnly,
|
|
573
|
+
required
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
] }) });
|
|
577
|
+
}
|
|
578
|
+
function PhoneInputCountrySelect(props) {
|
|
579
|
+
const { disabled: disabledProp, className, children, onOpenChange: onOpenChangeProp, ...popoverProps } = props;
|
|
580
|
+
const { countries, inputRef, disabled, showFlag, labels } = usePhoneInputContext(COUNTRY_SELECT_NAME);
|
|
581
|
+
const store = useStoreContext(COUNTRY_SELECT_NAME);
|
|
582
|
+
const country = useStore((state) => state.country);
|
|
583
|
+
const open = useStore((state) => state.open);
|
|
584
|
+
const onOpenChangeRef = useAsRef(onOpenChangeProp);
|
|
585
|
+
const isDisabled = disabledProp || disabled;
|
|
586
|
+
const countryContext = countries.find((c) => c.code === country);
|
|
587
|
+
const onOpenChange = React.useCallback(
|
|
588
|
+
(open2) => {
|
|
589
|
+
store.setState("open", open2);
|
|
590
|
+
onOpenChangeRef.current?.(open2);
|
|
591
|
+
},
|
|
592
|
+
[store, onOpenChangeRef]
|
|
593
|
+
);
|
|
594
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange, ...popoverProps, children: [
|
|
595
|
+
/* @__PURE__ */ jsxs(
|
|
596
|
+
PopoverTrigger,
|
|
597
|
+
{
|
|
598
|
+
"data-slot": "phone-input-country-select",
|
|
599
|
+
"aria-label": labels.countrySelect(countryContext),
|
|
600
|
+
disabled: isDisabled,
|
|
601
|
+
className: cn(
|
|
602
|
+
/*
|
|
603
|
+
* Hover `bg-muted` như nút `ghost` của gói. Viền focus cùng khuôn `Button`
|
|
604
|
+
* (`outline-ring`), nhưng THỤT VÀO trong (`-outline-offset-2`) vì nút nằm lọt trong khung
|
|
605
|
+
* của ô — viền đẩy ra ngoài sẽ đè lên khung và lên ô số bên cạnh.
|
|
606
|
+
*/
|
|
607
|
+
"flex h-full shrink-0 items-center gap-2 rounded-l-md border-r border-input bg-transparent px-3 text-sm transition-colors duration-150 ease-out hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring focus-visible:-outline-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
608
|
+
className
|
|
609
|
+
),
|
|
610
|
+
children: [
|
|
611
|
+
!countryContext ? (
|
|
612
|
+
/*
|
|
613
|
+
* ⚠ Khác thượng nguồn: bản gốc vẽ một ô `bg-muted/50` trống — 1,00:1 trên nền hover
|
|
614
|
+
* `--muted`, tức biến mất đúng lúc người dùng rê chuột vào (cổng tương phản chặn). Quả
|
|
615
|
+
* địa cầu nói được "chưa chọn quốc gia"; giữ bề rộng `w-6` của lá cờ để chọn xong không
|
|
616
|
+
* xô lệch.
|
|
617
|
+
*/
|
|
618
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "flex w-6 justify-center", children: /* @__PURE__ */ jsx(Globe, { className: "size-4 text-muted-foreground" }) })
|
|
619
|
+
) : showFlag && countryContext.flag && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "w-6 text-lg leading-none", children: countryContext.flag }),
|
|
620
|
+
/* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": "true", className: "size-4 text-muted-foreground" })
|
|
621
|
+
]
|
|
622
|
+
}
|
|
623
|
+
),
|
|
624
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[300px] p-0", align: "start", children: /* @__PURE__ */ jsxs(Command, { filter: filterCountries, children: [
|
|
625
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: labels.searchPlaceholder }),
|
|
626
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
627
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: labels.empty }),
|
|
628
|
+
/* @__PURE__ */ jsx(CommandGroup, { children: countries.map((c) => /* @__PURE__ */ jsxs(
|
|
629
|
+
CommandItem,
|
|
630
|
+
{
|
|
631
|
+
value: `${c.name} ${c.dialCode} ${c.code}`,
|
|
632
|
+
onSelect: () => {
|
|
633
|
+
store.setState("country", c.code);
|
|
634
|
+
store.setState("open", false);
|
|
635
|
+
requestAnimationFrame(() => {
|
|
636
|
+
inputRef.current?.focus();
|
|
637
|
+
});
|
|
638
|
+
},
|
|
639
|
+
children: [
|
|
640
|
+
showFlag && c.flag && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-lg", children: c.flag }),
|
|
641
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: c.name }),
|
|
642
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: c.dialCode }),
|
|
643
|
+
/* @__PURE__ */ jsx(
|
|
644
|
+
Check,
|
|
645
|
+
{
|
|
646
|
+
"aria-hidden": "true",
|
|
647
|
+
className: cn("size-4", country === c.code ? "opacity-100" : "opacity-0")
|
|
648
|
+
}
|
|
649
|
+
)
|
|
650
|
+
]
|
|
651
|
+
},
|
|
652
|
+
c.code
|
|
653
|
+
)) })
|
|
654
|
+
] })
|
|
655
|
+
] }) })
|
|
656
|
+
] });
|
|
657
|
+
}
|
|
658
|
+
function PhoneInputField(props) {
|
|
659
|
+
const {
|
|
660
|
+
onChange: onChangeProp,
|
|
661
|
+
className,
|
|
662
|
+
disabled: disabledProp,
|
|
663
|
+
readOnly: readOnlyProp,
|
|
664
|
+
required: requiredProp,
|
|
665
|
+
placeholder: placeholderProp,
|
|
666
|
+
ref,
|
|
667
|
+
...inputProps
|
|
668
|
+
} = props;
|
|
669
|
+
const { inputRef, disabled, invalid, readOnly, required, placeholder, countries } = usePhoneInputContext(FIELD_NAME);
|
|
670
|
+
const store = useStoreContext(FIELD_NAME);
|
|
671
|
+
const value = useStore((state) => state.value);
|
|
672
|
+
const nationalInput = useStore((state) => getNationalInput(state, countries));
|
|
673
|
+
const composedRef = useComposedRefs(ref, inputRef);
|
|
674
|
+
const onChangeRef = useAsRef(onChangeProp);
|
|
675
|
+
const isDisabled = disabledProp || disabled;
|
|
676
|
+
const isReadOnly = readOnlyProp || readOnly;
|
|
677
|
+
const isRequired = requiredProp || required;
|
|
678
|
+
const onChange = React.useCallback(
|
|
679
|
+
(event) => {
|
|
680
|
+
if (isDisabled || isReadOnly) return;
|
|
681
|
+
onChangeRef.current?.(event);
|
|
682
|
+
if (event.defaultPrevented) return;
|
|
683
|
+
const inputValue = event.target.value;
|
|
684
|
+
const startsWithPlus = inputValue.trimStart().startsWith("+");
|
|
685
|
+
const selectedCountry = startsWithPlus ? void 0 : countries.find((c) => c.code === store.getState().country);
|
|
686
|
+
if (selectedCountry) {
|
|
687
|
+
const nextNationalInput = inputValue.replace(NATIONAL_INPUT_DISALLOWED, "");
|
|
688
|
+
if (nextNationalInput !== inputValue) {
|
|
689
|
+
const target = event.target;
|
|
690
|
+
const caret = target.selectionStart ?? inputValue.length;
|
|
691
|
+
const nextCaret = inputValue.slice(0, caret).replace(NATIONAL_INPUT_DISALLOWED, "").length;
|
|
692
|
+
target.value = nextNationalInput;
|
|
693
|
+
target.setSelectionRange(nextCaret, nextCaret);
|
|
694
|
+
}
|
|
695
|
+
store.setState("startsWithPlus", false);
|
|
696
|
+
store.setState("nationalInput", nextNationalInput);
|
|
697
|
+
store.setState("value", nationalToE164(nextNationalInput, selectedCountry));
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
const digits = inputValue.replace(/\D/g, "");
|
|
701
|
+
const newValue = digits ? `+${digits}` : startsWithPlus ? "+" : "";
|
|
702
|
+
store.setState("startsWithPlus", startsWithPlus);
|
|
703
|
+
store.setState("nationalInput", null);
|
|
704
|
+
store.setState("value", newValue);
|
|
705
|
+
},
|
|
706
|
+
[store, countries, onChangeRef, isDisabled, isReadOnly]
|
|
707
|
+
);
|
|
708
|
+
const displayValue = React.useMemo(() => {
|
|
709
|
+
return nationalInput ?? formatPhoneNumber(value, countries);
|
|
710
|
+
}, [nationalInput, value, countries]);
|
|
711
|
+
return /* @__PURE__ */ jsx(
|
|
712
|
+
Input,
|
|
713
|
+
{
|
|
714
|
+
type: "tel",
|
|
715
|
+
inputMode: "tel",
|
|
716
|
+
"aria-required": isRequired,
|
|
717
|
+
"aria-invalid": invalid,
|
|
718
|
+
"data-slot": "phone-input-field",
|
|
719
|
+
disabled: isDisabled,
|
|
720
|
+
readOnly: isReadOnly,
|
|
721
|
+
required: isRequired,
|
|
722
|
+
...inputProps,
|
|
723
|
+
ref: composedRef,
|
|
724
|
+
className: cn(
|
|
725
|
+
// Viền, quầng focus và nền (kể cả nền `--muted` lúc vô hiệu) đều do khung gốc vẽ; ô số
|
|
726
|
+
// trong suốt và phẳng. `focus:ring-0` chứ không `focus-visible:` — `Input` vẽ quầng bằng `focus:`.
|
|
727
|
+
"h-full flex-1 rounded-l-none rounded-r-md border-0 bg-transparent focus:ring-0 disabled:bg-transparent",
|
|
728
|
+
className
|
|
729
|
+
),
|
|
730
|
+
placeholder: placeholderProp ?? placeholder,
|
|
731
|
+
value: displayValue,
|
|
732
|
+
onChange
|
|
733
|
+
}
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
export {
|
|
737
|
+
PhoneInput,
|
|
738
|
+
PhoneInputCountrySelect,
|
|
739
|
+
PhoneInputField,
|
|
740
|
+
useStore as usePhoneInput
|
|
741
|
+
};
|
|
742
|
+
//# sourceMappingURL=phone-input.js.map
|