@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,648 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useDirection } from "@radix-ui/react-direction";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { Star } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { useComitorMessages } 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
|
+
const ROOT_NAME = "Rating";
|
|
15
|
+
const ITEM_NAME = "RatingItem";
|
|
16
|
+
const ENTRY_FOCUS = "ratingFocusGroup.onEntryFocus";
|
|
17
|
+
const EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
18
|
+
function getItemId(id, value) {
|
|
19
|
+
return `${id}-item-${value}`;
|
|
20
|
+
}
|
|
21
|
+
function getPartialFillGradientId(id, step) {
|
|
22
|
+
return `partial-fill-gradient-${id}-${step}`;
|
|
23
|
+
}
|
|
24
|
+
const MAP_KEY_TO_FOCUS_INTENT = {
|
|
25
|
+
ArrowLeft: "prev",
|
|
26
|
+
ArrowUp: "prev",
|
|
27
|
+
ArrowRight: "next",
|
|
28
|
+
ArrowDown: "next",
|
|
29
|
+
Home: "first",
|
|
30
|
+
End: "last"
|
|
31
|
+
};
|
|
32
|
+
function getDirectionAwareKey(key, dir) {
|
|
33
|
+
if (dir !== "rtl") return key;
|
|
34
|
+
return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
|
|
35
|
+
}
|
|
36
|
+
function getFocusIntent(event, dir, orientation) {
|
|
37
|
+
const key = getDirectionAwareKey(event.key, dir);
|
|
38
|
+
if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
|
|
39
|
+
if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
|
|
40
|
+
return MAP_KEY_TO_FOCUS_INTENT[key];
|
|
41
|
+
}
|
|
42
|
+
function focusFirst(candidates, preventScroll = false) {
|
|
43
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
44
|
+
for (const candidateRef of candidates) {
|
|
45
|
+
const candidate = candidateRef.current;
|
|
46
|
+
if (!candidate) continue;
|
|
47
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
48
|
+
candidate.focus({ preventScroll });
|
|
49
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const StoreContext = React.createContext(null);
|
|
53
|
+
function useStoreContext(consumerName) {
|
|
54
|
+
const context = React.useContext(StoreContext);
|
|
55
|
+
if (!context) {
|
|
56
|
+
throw new Error(`\`${consumerName}\` ph\u1EA3i n\u1EB1m b\xEAn trong \`${ROOT_NAME}\``);
|
|
57
|
+
}
|
|
58
|
+
return context;
|
|
59
|
+
}
|
|
60
|
+
function useStore(selector, ogStore) {
|
|
61
|
+
const contextStore = React.useContext(StoreContext);
|
|
62
|
+
const store = ogStore ?? contextStore;
|
|
63
|
+
if (!store) {
|
|
64
|
+
throw new Error(`\`useRating\` ph\u1EA3i \u0111\u01B0\u1EE3c g\u1ECDi b\xEAn trong \`${ROOT_NAME}\``);
|
|
65
|
+
}
|
|
66
|
+
const getSnapshot = React.useCallback(() => selector(store.getState()), [store, selector]);
|
|
67
|
+
return React.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
68
|
+
}
|
|
69
|
+
const RatingContext = React.createContext(null);
|
|
70
|
+
function useRatingContext(consumerName) {
|
|
71
|
+
const context = React.useContext(RatingContext);
|
|
72
|
+
if (!context) {
|
|
73
|
+
throw new Error(`\`${consumerName}\` ph\u1EA3i n\u1EB1m b\xEAn trong \`${ROOT_NAME}\``);
|
|
74
|
+
}
|
|
75
|
+
return context;
|
|
76
|
+
}
|
|
77
|
+
const FocusContext = React.createContext(null);
|
|
78
|
+
function useFocusContext(consumerName) {
|
|
79
|
+
const context = React.useContext(FocusContext);
|
|
80
|
+
if (!context) {
|
|
81
|
+
throw new Error(`\`${consumerName}\` ph\u1EA3i n\u1EB1m b\xEAn trong \`FocusProvider\``);
|
|
82
|
+
}
|
|
83
|
+
return context;
|
|
84
|
+
}
|
|
85
|
+
function Rating(props) {
|
|
86
|
+
const {
|
|
87
|
+
value: valueProp,
|
|
88
|
+
defaultValue = 0,
|
|
89
|
+
onValueChange,
|
|
90
|
+
onHover,
|
|
91
|
+
onFocus: onFocusProp,
|
|
92
|
+
onMouseDown: onMouseDownProp,
|
|
93
|
+
dir: dirProp,
|
|
94
|
+
orientation = "horizontal",
|
|
95
|
+
activationMode = "automatic",
|
|
96
|
+
size = "default",
|
|
97
|
+
max = 5,
|
|
98
|
+
step = 1,
|
|
99
|
+
clearable = false,
|
|
100
|
+
asChild,
|
|
101
|
+
disabled = false,
|
|
102
|
+
readOnly = false,
|
|
103
|
+
required = false,
|
|
104
|
+
itemLabel: itemLabelProp,
|
|
105
|
+
className,
|
|
106
|
+
children,
|
|
107
|
+
id,
|
|
108
|
+
name,
|
|
109
|
+
ref,
|
|
110
|
+
...rootProps
|
|
111
|
+
} = props;
|
|
112
|
+
const t = useComitorMessages("rating");
|
|
113
|
+
const itemLabel = itemLabelProp ?? t.itemLabel;
|
|
114
|
+
const dir = useDirection(dirProp);
|
|
115
|
+
const instanceId = React.useId();
|
|
116
|
+
const rootId = id ?? instanceId;
|
|
117
|
+
const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
|
|
118
|
+
const stateRef = useLazyRef(() => ({
|
|
119
|
+
value: valueProp ?? defaultValue,
|
|
120
|
+
hoveredValue: null
|
|
121
|
+
}));
|
|
122
|
+
const propsRef = useAsRef({
|
|
123
|
+
onValueChange,
|
|
124
|
+
onHover,
|
|
125
|
+
onFocus: onFocusProp,
|
|
126
|
+
onMouseDown: onMouseDownProp,
|
|
127
|
+
step
|
|
128
|
+
});
|
|
129
|
+
const store = React.useMemo(() => {
|
|
130
|
+
return {
|
|
131
|
+
subscribe: (cb) => {
|
|
132
|
+
listenersRef.current.add(cb);
|
|
133
|
+
return () => listenersRef.current.delete(cb);
|
|
134
|
+
},
|
|
135
|
+
getState: () => stateRef.current,
|
|
136
|
+
setState: (key, value2) => {
|
|
137
|
+
if (Object.is(stateRef.current[key], value2)) return;
|
|
138
|
+
if (key === "value" && typeof value2 === "number") {
|
|
139
|
+
stateRef.current.value = value2;
|
|
140
|
+
propsRef.current.onValueChange?.(value2);
|
|
141
|
+
} else if (key === "hoveredValue") {
|
|
142
|
+
stateRef.current.hoveredValue = value2;
|
|
143
|
+
propsRef.current.onHover?.(value2);
|
|
144
|
+
} else {
|
|
145
|
+
stateRef.current[key] = value2;
|
|
146
|
+
}
|
|
147
|
+
store.notify();
|
|
148
|
+
},
|
|
149
|
+
notify: () => {
|
|
150
|
+
for (const cb of listenersRef.current) {
|
|
151
|
+
cb();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}, [listenersRef, stateRef, propsRef]);
|
|
156
|
+
useIsomorphicLayoutEffect(() => {
|
|
157
|
+
if (valueProp !== void 0) {
|
|
158
|
+
store.setState("value", valueProp);
|
|
159
|
+
}
|
|
160
|
+
}, [valueProp]);
|
|
161
|
+
const value = useStore((state) => state.value, store);
|
|
162
|
+
const [formTrigger, setFormTrigger] = React.useState(null);
|
|
163
|
+
const composedRef = useComposedRefs(ref, (node) => setFormTrigger(node));
|
|
164
|
+
const isFormControl = formTrigger ? !!formTrigger.closest("form") : true;
|
|
165
|
+
const [tabStopId, setTabStopId] = React.useState(null);
|
|
166
|
+
const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
|
|
167
|
+
const [focusableItemCount, setFocusableItemCount] = React.useState(0);
|
|
168
|
+
const isClickFocusRef = React.useRef(false);
|
|
169
|
+
const itemsRef = React.useRef(/* @__PURE__ */ new Map());
|
|
170
|
+
const autoIndexMapRef = React.useRef(/* @__PURE__ */ new Map());
|
|
171
|
+
const nextAutoIndexRef = React.useRef(0);
|
|
172
|
+
const getAutoIndex = React.useCallback((instanceId2) => {
|
|
173
|
+
const existingIndex = autoIndexMapRef.current.get(instanceId2);
|
|
174
|
+
if (existingIndex !== void 0) {
|
|
175
|
+
return existingIndex;
|
|
176
|
+
}
|
|
177
|
+
const newIndex = nextAutoIndexRef.current++;
|
|
178
|
+
autoIndexMapRef.current.set(instanceId2, newIndex);
|
|
179
|
+
return newIndex;
|
|
180
|
+
}, []);
|
|
181
|
+
const onItemFocus = React.useCallback((tabStopId2) => {
|
|
182
|
+
setTabStopId(tabStopId2);
|
|
183
|
+
}, []);
|
|
184
|
+
const onItemShiftTab = React.useCallback(() => {
|
|
185
|
+
setIsTabbingBackOut(true);
|
|
186
|
+
}, []);
|
|
187
|
+
const onFocusableItemAdd = React.useCallback(() => {
|
|
188
|
+
setFocusableItemCount((prevCount) => prevCount + 1);
|
|
189
|
+
}, []);
|
|
190
|
+
const onFocusableItemRemove = React.useCallback(() => {
|
|
191
|
+
setFocusableItemCount((prevCount) => prevCount - 1);
|
|
192
|
+
}, []);
|
|
193
|
+
const onItemRegister = React.useCallback((item) => {
|
|
194
|
+
itemsRef.current.set(item.id, item);
|
|
195
|
+
}, []);
|
|
196
|
+
const onItemUnregister = React.useCallback((id2) => {
|
|
197
|
+
itemsRef.current.delete(id2);
|
|
198
|
+
}, []);
|
|
199
|
+
const getItems = React.useCallback(() => {
|
|
200
|
+
return Array.from(itemsRef.current.values()).filter((item) => item.ref.current).sort((a, b) => {
|
|
201
|
+
const elementA = a.ref.current;
|
|
202
|
+
const elementB = b.ref.current;
|
|
203
|
+
if (!elementA || !elementB) return 0;
|
|
204
|
+
const position = elementA.compareDocumentPosition(elementB);
|
|
205
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
206
|
+
return -1;
|
|
207
|
+
}
|
|
208
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
209
|
+
return 1;
|
|
210
|
+
}
|
|
211
|
+
return 0;
|
|
212
|
+
});
|
|
213
|
+
}, []);
|
|
214
|
+
const onBlur = React.useCallback(
|
|
215
|
+
(event) => {
|
|
216
|
+
rootProps.onBlur?.(event);
|
|
217
|
+
if (event.defaultPrevented) return;
|
|
218
|
+
setIsTabbingBackOut(false);
|
|
219
|
+
},
|
|
220
|
+
[rootProps.onBlur]
|
|
221
|
+
);
|
|
222
|
+
const onFocus = React.useCallback(
|
|
223
|
+
(event) => {
|
|
224
|
+
propsRef.current.onFocus?.(event);
|
|
225
|
+
if (event.defaultPrevented) return;
|
|
226
|
+
const isKeyboardFocus = !isClickFocusRef.current;
|
|
227
|
+
if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
|
|
228
|
+
const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
|
|
229
|
+
event.currentTarget.dispatchEvent(entryFocusEvent);
|
|
230
|
+
if (!entryFocusEvent.defaultPrevented) {
|
|
231
|
+
const items = Array.from(itemsRef.current.values()).filter((item) => !item.disabled);
|
|
232
|
+
const selectedItem = propsRef.current.step < 1 ? items.find((item) => item.value === Math.ceil(value)) : items.find((item) => item.value === value);
|
|
233
|
+
const currentItem = items.find((item) => item.id === tabStopId);
|
|
234
|
+
const candidateItems = [selectedItem, currentItem, ...items].filter(Boolean);
|
|
235
|
+
const candidateRefs = candidateItems.map((item) => item.ref);
|
|
236
|
+
focusFirst(candidateRefs, false);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
isClickFocusRef.current = false;
|
|
240
|
+
},
|
|
241
|
+
[propsRef, isTabbingBackOut, value, tabStopId]
|
|
242
|
+
);
|
|
243
|
+
const onMouseDown = React.useCallback(
|
|
244
|
+
(event) => {
|
|
245
|
+
propsRef.current.onMouseDown?.(event);
|
|
246
|
+
if (event.defaultPrevented) return;
|
|
247
|
+
isClickFocusRef.current = true;
|
|
248
|
+
},
|
|
249
|
+
[propsRef]
|
|
250
|
+
);
|
|
251
|
+
const contextValue = React.useMemo(
|
|
252
|
+
() => ({
|
|
253
|
+
rootId,
|
|
254
|
+
dir,
|
|
255
|
+
orientation,
|
|
256
|
+
activationMode,
|
|
257
|
+
disabled,
|
|
258
|
+
readOnly,
|
|
259
|
+
size,
|
|
260
|
+
max,
|
|
261
|
+
step,
|
|
262
|
+
clearable,
|
|
263
|
+
itemLabel,
|
|
264
|
+
getAutoIndex
|
|
265
|
+
}),
|
|
266
|
+
[rootId, dir, orientation, activationMode, disabled, readOnly, size, max, step, clearable, itemLabel, getAutoIndex]
|
|
267
|
+
);
|
|
268
|
+
const focusContextValue = React.useMemo(
|
|
269
|
+
() => ({
|
|
270
|
+
tabStopId,
|
|
271
|
+
onItemFocus,
|
|
272
|
+
onItemShiftTab,
|
|
273
|
+
onFocusableItemAdd,
|
|
274
|
+
onFocusableItemRemove,
|
|
275
|
+
onItemRegister,
|
|
276
|
+
onItemUnregister,
|
|
277
|
+
getItems
|
|
278
|
+
}),
|
|
279
|
+
[
|
|
280
|
+
tabStopId,
|
|
281
|
+
onItemFocus,
|
|
282
|
+
onItemShiftTab,
|
|
283
|
+
onFocusableItemAdd,
|
|
284
|
+
onFocusableItemRemove,
|
|
285
|
+
onItemRegister,
|
|
286
|
+
onItemUnregister,
|
|
287
|
+
getItems
|
|
288
|
+
]
|
|
289
|
+
);
|
|
290
|
+
const RootPrimitive = asChild ? Slot : "div";
|
|
291
|
+
const partialFillGradient = /* @__PURE__ */ jsx("svg", { width: "0", height: "0", "aria-hidden": "true", focusable: "false", style: { position: "absolute" }, children: /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("linearGradient", { id: getPartialFillGradientId(rootId, step), children: dir === "rtl" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
292
|
+
/* @__PURE__ */ jsx("stop", { offset: "50%", stopColor: "transparent" }),
|
|
293
|
+
/* @__PURE__ */ jsx("stop", { offset: "50%", stopColor: "currentColor" })
|
|
294
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
295
|
+
/* @__PURE__ */ jsx("stop", { offset: "50%", stopColor: "currentColor" }),
|
|
296
|
+
/* @__PURE__ */ jsx("stop", { offset: "50%", stopColor: "transparent" })
|
|
297
|
+
] }) }) }) });
|
|
298
|
+
return /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children: /* @__PURE__ */ jsx(RatingContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(FocusContext.Provider, { value: focusContextValue, children: [
|
|
299
|
+
/* @__PURE__ */ jsx(
|
|
300
|
+
RootPrimitive,
|
|
301
|
+
{
|
|
302
|
+
id: rootId,
|
|
303
|
+
role: "radiogroup",
|
|
304
|
+
"aria-orientation": orientation,
|
|
305
|
+
"aria-disabled": disabled || void 0,
|
|
306
|
+
"aria-readonly": readOnly || void 0,
|
|
307
|
+
"aria-required": required || void 0,
|
|
308
|
+
"data-disabled": disabled ? "" : void 0,
|
|
309
|
+
"data-readonly": readOnly ? "" : void 0,
|
|
310
|
+
"data-orientation": orientation,
|
|
311
|
+
"data-slot": "rating",
|
|
312
|
+
dir,
|
|
313
|
+
tabIndex: isTabbingBackOut || focusableItemCount === 0 ? -1 : 0,
|
|
314
|
+
...rootProps,
|
|
315
|
+
ref: composedRef,
|
|
316
|
+
className: cn(
|
|
317
|
+
/*
|
|
318
|
+
* Ngôi sao là thành phần PHI VĂN BẢN mang nghĩa (nó LÀ giá trị) → màu đi qua bậc
|
|
319
|
+
* `-ink` của tone, không phải token tô nền. Bản gốc `text-primary` đọc thẳng màu
|
|
320
|
+
* TÔ NỀN; ở bảng mặc định hai token trùng nhau (`--primary-ink: var(--primary)`),
|
|
321
|
+
* nhưng bảng tương phản cao kéo `--primary-ink` xuống bậc tối — và chỉ `-ink` mới
|
|
322
|
+
* được đổi theo. Hợp đồng §1 của docs/hop-dong-mau.md.
|
|
323
|
+
*/
|
|
324
|
+
"flex gap-1 text-primary-ink outline-none",
|
|
325
|
+
orientation === "horizontal" ? "flex-row items-center" : "flex-col items-start",
|
|
326
|
+
className
|
|
327
|
+
),
|
|
328
|
+
onBlur,
|
|
329
|
+
onFocus,
|
|
330
|
+
onMouseDown,
|
|
331
|
+
children: asChild ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
332
|
+
children,
|
|
333
|
+
partialFillGradient
|
|
334
|
+
] })
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
asChild ? partialFillGradient : null,
|
|
338
|
+
isFormControl && /* @__PURE__ */ jsx(
|
|
339
|
+
VisuallyHiddenInput,
|
|
340
|
+
{
|
|
341
|
+
type: "hidden",
|
|
342
|
+
control: formTrigger,
|
|
343
|
+
name,
|
|
344
|
+
value,
|
|
345
|
+
disabled,
|
|
346
|
+
readOnly,
|
|
347
|
+
required
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
] }) }) });
|
|
351
|
+
}
|
|
352
|
+
function RatingItem(props) {
|
|
353
|
+
const {
|
|
354
|
+
index,
|
|
355
|
+
asChild,
|
|
356
|
+
onClick: onClickProp,
|
|
357
|
+
onFocus: onFocusProp,
|
|
358
|
+
onKeyDown: onKeyDownProp,
|
|
359
|
+
onMouseDown: onMouseDownProp,
|
|
360
|
+
onMouseEnter: onMouseEnterProp,
|
|
361
|
+
onMouseMove: onMouseMoveProp,
|
|
362
|
+
onMouseLeave: onMouseLeaveProp,
|
|
363
|
+
disabled,
|
|
364
|
+
className,
|
|
365
|
+
children,
|
|
366
|
+
ref,
|
|
367
|
+
...itemProps
|
|
368
|
+
} = props;
|
|
369
|
+
const itemRef = React.useRef(null);
|
|
370
|
+
const composedRef = useComposedRefs(ref, itemRef);
|
|
371
|
+
const context = useRatingContext(ITEM_NAME);
|
|
372
|
+
const instanceId = React.useId();
|
|
373
|
+
const actualIndex = React.useMemo(() => {
|
|
374
|
+
if (index !== void 0) {
|
|
375
|
+
return index;
|
|
376
|
+
}
|
|
377
|
+
return context.getAutoIndex(instanceId);
|
|
378
|
+
}, [index, context, instanceId]);
|
|
379
|
+
const itemValue = actualIndex + 1;
|
|
380
|
+
const store = useStoreContext(ITEM_NAME);
|
|
381
|
+
const focusContext = useFocusContext(ITEM_NAME);
|
|
382
|
+
const value = useStore((state) => state.value);
|
|
383
|
+
const hoveredValue = useStore((state) => state.hoveredValue);
|
|
384
|
+
const clearable = context.clearable;
|
|
385
|
+
const step = context.step;
|
|
386
|
+
const activationMode = context.activationMode;
|
|
387
|
+
const itemId = getItemId(context.rootId, itemValue);
|
|
388
|
+
const isDisabled = context.disabled || disabled;
|
|
389
|
+
const isReadOnly = context.readOnly;
|
|
390
|
+
const isTabStop = focusContext.tabStopId === itemId;
|
|
391
|
+
const displayValue = hoveredValue ?? value;
|
|
392
|
+
const isFilled = displayValue >= itemValue;
|
|
393
|
+
const isPartiallyFilled = step < 1 && displayValue >= itemValue - step && displayValue < itemValue;
|
|
394
|
+
const isHovered = hoveredValue !== null && hoveredValue < itemValue;
|
|
395
|
+
const isChecked = value > 0 && Math.ceil(value) === itemValue;
|
|
396
|
+
const isMouseClickRef = React.useRef(false);
|
|
397
|
+
const propsRef = useAsRef({
|
|
398
|
+
onClick: onClickProp,
|
|
399
|
+
onFocus: onFocusProp,
|
|
400
|
+
onKeyDown: onKeyDownProp,
|
|
401
|
+
onMouseDown: onMouseDownProp,
|
|
402
|
+
onMouseEnter: onMouseEnterProp,
|
|
403
|
+
onMouseMove: onMouseMoveProp,
|
|
404
|
+
onMouseLeave: onMouseLeaveProp
|
|
405
|
+
});
|
|
406
|
+
useIsomorphicLayoutEffect(() => {
|
|
407
|
+
focusContext.onItemRegister({
|
|
408
|
+
id: itemId,
|
|
409
|
+
ref: itemRef,
|
|
410
|
+
value: itemValue,
|
|
411
|
+
disabled: !!isDisabled
|
|
412
|
+
});
|
|
413
|
+
if (!isDisabled) {
|
|
414
|
+
focusContext.onFocusableItemAdd();
|
|
415
|
+
}
|
|
416
|
+
return () => {
|
|
417
|
+
focusContext.onItemUnregister(itemId);
|
|
418
|
+
if (!isDisabled) {
|
|
419
|
+
focusContext.onFocusableItemRemove();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
}, [focusContext, itemId, itemValue, isDisabled]);
|
|
423
|
+
const onClick = React.useCallback(
|
|
424
|
+
(event) => {
|
|
425
|
+
propsRef.current.onClick?.(event);
|
|
426
|
+
if (event.defaultPrevented) return;
|
|
427
|
+
if (!isDisabled && !isReadOnly) {
|
|
428
|
+
let newValue = itemValue;
|
|
429
|
+
if (step < 1) {
|
|
430
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
431
|
+
const clickX = event.clientX - rect.left;
|
|
432
|
+
const isLeftHalf = clickX < rect.width / 2;
|
|
433
|
+
if (context.dir === "rtl") {
|
|
434
|
+
if (!isLeftHalf) {
|
|
435
|
+
newValue = itemValue - step;
|
|
436
|
+
}
|
|
437
|
+
} else {
|
|
438
|
+
if (isLeftHalf) {
|
|
439
|
+
newValue = itemValue - step;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (clearable && value === newValue) {
|
|
444
|
+
newValue = 0;
|
|
445
|
+
}
|
|
446
|
+
store.setState("value", newValue);
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
[isDisabled, isReadOnly, clearable, step, value, itemValue, store, context.dir, propsRef]
|
|
450
|
+
);
|
|
451
|
+
const onFocus = React.useCallback(
|
|
452
|
+
(event) => {
|
|
453
|
+
propsRef.current.onFocus?.(event);
|
|
454
|
+
if (event.defaultPrevented) return;
|
|
455
|
+
focusContext.onItemFocus(itemId);
|
|
456
|
+
const isKeyboardFocus = !isMouseClickRef.current;
|
|
457
|
+
if (!isDisabled && !isReadOnly && activationMode !== "manual" && isKeyboardFocus) {
|
|
458
|
+
const isHalfStepValue = step < 1 && value === itemValue - step;
|
|
459
|
+
if (!isHalfStepValue) {
|
|
460
|
+
const newValue = clearable && value === itemValue ? 0 : itemValue;
|
|
461
|
+
store.setState("value", newValue);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
isMouseClickRef.current = false;
|
|
465
|
+
},
|
|
466
|
+
[focusContext, itemId, activationMode, isDisabled, isReadOnly, clearable, value, itemValue, step, store, propsRef]
|
|
467
|
+
);
|
|
468
|
+
const onKeyDown = React.useCallback(
|
|
469
|
+
(event) => {
|
|
470
|
+
propsRef.current.onKeyDown?.(event);
|
|
471
|
+
if (event.defaultPrevented) return;
|
|
472
|
+
if ((event.key === "Enter" || event.key === " ") && activationMode === "manual") {
|
|
473
|
+
event.preventDefault();
|
|
474
|
+
if (!isDisabled && !isReadOnly && itemRef.current) {
|
|
475
|
+
itemRef.current.click();
|
|
476
|
+
}
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (event.key === "Tab" && event.shiftKey) {
|
|
480
|
+
focusContext.onItemShiftTab();
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (event.target !== event.currentTarget) return;
|
|
484
|
+
const focusIntent = getFocusIntent(event, context.dir, context.orientation);
|
|
485
|
+
if (focusIntent !== void 0) {
|
|
486
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
|
|
487
|
+
event.preventDefault();
|
|
488
|
+
if (step < 1 && (focusIntent === "prev" || focusIntent === "next")) {
|
|
489
|
+
if (!isDisabled && !isReadOnly) {
|
|
490
|
+
let newValue = value;
|
|
491
|
+
if (focusIntent === "next") {
|
|
492
|
+
newValue = Math.min(value + step, context.max);
|
|
493
|
+
} else {
|
|
494
|
+
newValue = Math.max(value - step, 0);
|
|
495
|
+
}
|
|
496
|
+
store.setState("value", newValue);
|
|
497
|
+
const items2 = focusContext.getItems().filter((item) => !item.disabled);
|
|
498
|
+
const targetItem = items2.find((item) => item.value === Math.ceil(newValue));
|
|
499
|
+
if (targetItem?.ref.current) {
|
|
500
|
+
queueMicrotask(() => targetItem.ref.current?.focus());
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
const items = focusContext.getItems().filter((item) => !item.disabled);
|
|
506
|
+
let candidateRefs = items.map((item) => item.ref);
|
|
507
|
+
if (focusIntent === "last") {
|
|
508
|
+
candidateRefs.reverse();
|
|
509
|
+
} else if (focusIntent === "prev" || focusIntent === "next") {
|
|
510
|
+
if (focusIntent === "prev") candidateRefs.reverse();
|
|
511
|
+
const currentIndex = candidateRefs.findIndex((ref2) => ref2.current === event.currentTarget);
|
|
512
|
+
candidateRefs = candidateRefs.slice(currentIndex + 1);
|
|
513
|
+
}
|
|
514
|
+
queueMicrotask(() => focusFirst(candidateRefs));
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
[
|
|
518
|
+
focusContext,
|
|
519
|
+
context.dir,
|
|
520
|
+
context.orientation,
|
|
521
|
+
activationMode,
|
|
522
|
+
isDisabled,
|
|
523
|
+
isReadOnly,
|
|
524
|
+
step,
|
|
525
|
+
value,
|
|
526
|
+
context.max,
|
|
527
|
+
store,
|
|
528
|
+
propsRef
|
|
529
|
+
]
|
|
530
|
+
);
|
|
531
|
+
const onMouseDown = React.useCallback(
|
|
532
|
+
(event) => {
|
|
533
|
+
propsRef.current.onMouseDown?.(event);
|
|
534
|
+
if (event.defaultPrevented) return;
|
|
535
|
+
isMouseClickRef.current = true;
|
|
536
|
+
if (isDisabled) {
|
|
537
|
+
event.preventDefault();
|
|
538
|
+
} else {
|
|
539
|
+
focusContext.onItemFocus(itemId);
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
[focusContext, itemId, isDisabled, propsRef]
|
|
543
|
+
);
|
|
544
|
+
const onMouseEnter = React.useCallback(
|
|
545
|
+
(event) => {
|
|
546
|
+
propsRef.current.onMouseEnter?.(event);
|
|
547
|
+
if (event.defaultPrevented) return;
|
|
548
|
+
if (!isDisabled && !isReadOnly) {
|
|
549
|
+
let hoverValue = itemValue;
|
|
550
|
+
if (step < 1) {
|
|
551
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
552
|
+
const mouseX = event.clientX - rect.left;
|
|
553
|
+
const isLeftHalf = mouseX < rect.width / 2;
|
|
554
|
+
if (context.dir === "rtl") {
|
|
555
|
+
if (!isLeftHalf) {
|
|
556
|
+
hoverValue = itemValue - step;
|
|
557
|
+
}
|
|
558
|
+
} else {
|
|
559
|
+
if (isLeftHalf) {
|
|
560
|
+
hoverValue = itemValue - step;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
store.setState("hoveredValue", hoverValue);
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
[isDisabled, isReadOnly, step, itemValue, store, context.dir, propsRef]
|
|
568
|
+
);
|
|
569
|
+
const onMouseLeave = React.useCallback(
|
|
570
|
+
(event) => {
|
|
571
|
+
propsRef.current.onMouseLeave?.(event);
|
|
572
|
+
if (event.defaultPrevented) return;
|
|
573
|
+
if (!isDisabled && !isReadOnly) {
|
|
574
|
+
store.setState("hoveredValue", null);
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
[isDisabled, isReadOnly, store, propsRef]
|
|
578
|
+
);
|
|
579
|
+
const onMouseMove = React.useCallback(
|
|
580
|
+
(event) => {
|
|
581
|
+
propsRef.current.onMouseMove?.(event);
|
|
582
|
+
if (event.defaultPrevented) return;
|
|
583
|
+
if (!isDisabled && !isReadOnly && step < 1) {
|
|
584
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
585
|
+
const mouseX = event.clientX - rect.left;
|
|
586
|
+
const isLeftHalf = mouseX < rect.width / 2;
|
|
587
|
+
let hoverValue = itemValue;
|
|
588
|
+
if (context.dir === "rtl") {
|
|
589
|
+
hoverValue = !isLeftHalf ? itemValue - step : itemValue;
|
|
590
|
+
} else {
|
|
591
|
+
hoverValue = isLeftHalf ? itemValue - step : itemValue;
|
|
592
|
+
}
|
|
593
|
+
store.setState("hoveredValue", hoverValue);
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
[isDisabled, isReadOnly, step, itemValue, store, context.dir, propsRef]
|
|
597
|
+
);
|
|
598
|
+
const dataState = isFilled ? "full" : isPartiallyFilled ? "partial" : "empty";
|
|
599
|
+
const ItemPrimitive = asChild ? Slot : "button";
|
|
600
|
+
return /* @__PURE__ */ jsx(
|
|
601
|
+
ItemPrimitive,
|
|
602
|
+
{
|
|
603
|
+
role: "radio",
|
|
604
|
+
type: "button",
|
|
605
|
+
id: itemId,
|
|
606
|
+
"aria-label": context.itemLabel(itemValue, context.max),
|
|
607
|
+
"aria-checked": isChecked,
|
|
608
|
+
"aria-posinset": itemValue,
|
|
609
|
+
"aria-setsize": context.max,
|
|
610
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
611
|
+
"data-readonly": isReadOnly ? "" : void 0,
|
|
612
|
+
"data-state": dataState,
|
|
613
|
+
"data-hovered": isHovered ? "" : void 0,
|
|
614
|
+
"data-slot": "rating-item",
|
|
615
|
+
disabled: isDisabled,
|
|
616
|
+
tabIndex: isTabStop ? 0 : -1,
|
|
617
|
+
...itemProps,
|
|
618
|
+
ref: composedRef,
|
|
619
|
+
style: {
|
|
620
|
+
...itemProps.style,
|
|
621
|
+
...isPartiallyFilled && {
|
|
622
|
+
"--partial-fill": `url(#${getPartialFillGradientId(context.rootId, step)})`
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
className: cn(
|
|
626
|
+
// Viền focus cùng khuôn với `Checkbox`/`RadioGroup` của gói.
|
|
627
|
+
"inline-flex items-center justify-center rounded transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",
|
|
628
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:transition-colors [&_svg]:duration-200 data-[state=empty]:[&_svg]:fill-transparent data-[state=full]:[&_svg]:fill-current data-[state=partial]:[&_svg]:fill-(--partial-fill) [&_svg:not([class*='size-'])]:size-full",
|
|
629
|
+
context.size === "sm" ? "size-4" : context.size === "lg" ? "size-6" : "size-5",
|
|
630
|
+
className
|
|
631
|
+
),
|
|
632
|
+
onClick,
|
|
633
|
+
onFocus,
|
|
634
|
+
onKeyDown,
|
|
635
|
+
onMouseDown,
|
|
636
|
+
onMouseEnter,
|
|
637
|
+
onMouseMove,
|
|
638
|
+
onMouseLeave,
|
|
639
|
+
children: typeof children === "function" ? children(dataState) : children ?? /* @__PURE__ */ jsx(Star, { "aria-hidden": "true" })
|
|
640
|
+
}
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
export {
|
|
644
|
+
Rating,
|
|
645
|
+
RatingItem,
|
|
646
|
+
useStore as useRating
|
|
647
|
+
};
|
|
648
|
+
//# sourceMappingURL=rating.js.map
|