@choice-ui/react 1.4.3 → 1.4.5
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/dist/components/alert-dialog/dist/index.d.ts +20 -41
- package/dist/components/alert-dialog/dist/index.js +497 -0
- package/dist/components/alert-dialog/src/alert-dialog.js +1 -1
- package/dist/components/alert-dialog/src/hooks/use-alert-dialog.d.ts +1 -1
- package/dist/components/alert-dialog/src/index.d.ts +4 -5
- package/dist/components/alert-dialog/src/types.d.ts +11 -11
- package/dist/components/avatar/dist/index.js +4 -4
- package/dist/components/avatar/src/avatar.js +4 -4
- package/dist/components/badge/src/badge.js +2 -2
- package/dist/components/badge/src/index.d.ts +2 -1
- package/dist/components/button/dist/index.js +4 -4
- package/dist/components/button/src/button.js +4 -4
- package/dist/components/calendar/dist/index.d.ts +296 -296
- package/dist/components/calendar/dist/index.js +57 -56
- package/dist/components/calendar/src/date-range-input/date-range-input.d.ts +5 -5
- package/dist/components/calendar/src/time-calendar/time-calendar.d.ts +3 -3
- package/dist/components/calendar/src/time-calendar/time-calendar.js +2 -2
- package/dist/components/calendar/src/time-input/time-input.d.ts +9 -9
- package/dist/components/calendar/src/time-input/time-input.js +4 -4
- package/dist/components/calendar/src/types.d.ts +165 -165
- package/dist/components/calendar/src/utils/constants.js +32 -31
- package/dist/components/calendar/src/utils/date-comparisons.d.ts +34 -34
- package/dist/components/calendar/src/utils/locale.d.ts +12 -12
- package/dist/components/calendar/src/utils/month.d.ts +3 -3
- package/dist/components/calendar/src/utils/month.js +1 -1
- package/dist/components/calendar/src/utils/parsers/month-names.js +3 -3
- package/dist/components/calendar/src/utils/parsers/numeric-utils.d.ts +20 -20
- package/dist/components/calendar/src/utils/parsers/numeric-utils.js +8 -8
- package/dist/components/calendar/src/utils/parsers/parsers.d.ts +17 -17
- package/dist/components/calendar/src/utils/parsers/parsers.js +2 -2
- package/dist/components/calendar/src/utils/parsers/prediction.d.ts +7 -7
- package/dist/components/calendar/src/utils/parsers/relative-dates.js +6 -6
- package/dist/components/calendar/src/utils/quarter.d.ts +13 -13
- package/dist/components/calendar/src/utils/quarter.js +6 -6
- package/dist/components/calendar/src/utils/time.d.ts +8 -8
- package/dist/components/calendar/src/utils/year.d.ts +3 -3
- package/dist/components/calendar/src/utils/year.js +3 -3
- package/dist/components/checkbox/dist/index.d.ts +1 -12
- package/dist/components/checkbox/dist/index.js +9 -9
- package/dist/components/checkbox/src/checkbox-label.js +2 -2
- package/dist/components/checkbox/src/checkbox.js +6 -5
- package/dist/components/checkbox/src/context.js +1 -1
- package/dist/components/checkbox/src/index.d.ts +0 -3
- package/dist/components/chip/dist/index.js +6 -6
- package/dist/components/chip/src/chip.js +6 -6
- package/dist/components/chip/src/index.d.ts +2 -1
- package/dist/components/chips-input/dist/index.js +270 -0
- package/dist/components/chips-input/src/index.d.ts +2 -1
- package/dist/components/code-block/dist/index.d.ts +14 -32
- package/dist/components/code-block/dist/index.js +211 -147
- package/dist/components/code-block/src/code-block.d.ts +8 -1
- package/dist/components/code-block/src/code-block.js +14 -3
- package/dist/components/code-block/src/components/code-block-code.js +31 -5
- package/dist/components/code-block/src/components/code-block-header.js +45 -10
- package/dist/components/code-block/src/index.d.ts +3 -9
- package/dist/components/combobox/dist/index.d.ts +21 -2
- package/dist/components/combobox/dist/index.js +16 -13
- package/dist/components/combobox/src/combobox-trigger.d.ts +1 -1
- package/dist/components/combobox/src/combobox-trigger.js +7 -4
- package/dist/components/combobox/src/combobox.d.ts +20 -1
- package/dist/components/combobox/src/combobox.js +10 -10
- package/dist/components/command/dist/index.d.ts +65 -4
- package/dist/components/command/src/command.js +6 -5
- package/dist/components/command/src/components/command-divider.d.ts +4 -1
- package/dist/components/command/src/components/command-group.d.ts +16 -1
- package/dist/components/command/src/components/command-group.js +56 -54
- package/dist/components/command/src/components/command-input.js +3 -3
- package/dist/components/command/src/components/command-item.d.ts +1 -1
- package/dist/components/command/src/components/command-item.js +117 -115
- package/dist/components/command/src/components/command-loading.d.ts +8 -0
- package/dist/components/command/src/components/command-loading.js +1 -1
- package/dist/components/command/src/context/create-command-context.js +1 -1
- package/dist/components/command/src/hooks/use-schedule-layout-effect.d.ts +1 -1
- package/dist/components/command/src/hooks/use-value.js +2 -2
- package/dist/components/command/src/index.d.ts +16 -8
- package/dist/components/command/src/tv.d.ts +30 -0
- package/dist/components/command/src/tv.js +10 -0
- package/dist/components/command/src/types.d.ts +8 -0
- package/dist/components/command/src/utils/constants.d.ts +1 -1
- package/dist/components/command/src/utils/constants.js +1 -1
- package/dist/components/command/src/utils/helpers.d.ts +0 -1
- package/dist/components/command/src/utils/helpers.js +1 -3
- package/dist/components/command/src/utils/index.d.ts +1 -0
- package/dist/components/comments/src/comment-input/components/comment-input-mention-popover.js +4 -2
- package/dist/components/comments/src/comments.js +1 -1
- package/dist/components/context-input/dist/index.d.ts +15 -340
- package/dist/components/context-input/src/components/mention-menu.d.ts +5 -4
- package/dist/components/context-input/src/components/mention-menu.js +19 -4
- package/dist/components/context-input/src/components/mention.d.ts +2 -2
- package/dist/components/context-input/src/components/slate-editor.js +4 -2
- package/dist/components/context-input/src/context-input.js +31 -16
- package/dist/components/context-input/src/extensions/with-mentions.d.ts +1 -1
- package/dist/components/context-input/src/extensions/with-mentions.js +10 -9
- package/dist/components/context-input/src/hooks/use-context-input.js +87 -46
- package/dist/components/context-input/src/hooks/use-mentions.d.ts +11 -10
- package/dist/components/context-input/src/hooks/use-mentions.js +147 -128
- package/dist/components/context-input/src/index.d.ts +2 -5
- package/dist/components/context-input/src/types.d.ts +12 -12
- package/dist/components/context-input/src/utils/mention-spacing.d.ts +16 -16
- package/dist/components/context-input/src/utils/mention-spacing.js +1 -27
- package/dist/components/context-input/src/utils/slate-converters.d.ts +6 -6
- package/dist/components/context-input/src/utils/slate-converters.js +3 -69
- package/dist/components/context-input/src/utils/text-extraction.js +7 -1
- package/dist/components/context-menu/src/context-menu.js +10 -4
- package/dist/components/dialog/dist/index.js +1 -2
- package/dist/components/dialog/src/dialog.js +0 -1
- package/dist/components/dialog/src/hooks/use-floating-dialog.js +1 -1
- package/dist/components/dialog/src/index.d.ts +3 -2
- package/dist/components/dropdown/dist/index.d.ts +1 -2
- package/dist/components/dropdown/dist/index.js +23 -8
- package/dist/components/dropdown/src/dropdown.d.ts +1 -2
- package/dist/components/dropdown/src/dropdown.js +23 -8
- package/dist/components/emoji-picker/dist/index.d.ts +33 -1
- package/dist/components/emoji-picker/dist/index.js +3 -1
- package/dist/components/emoji-picker/src/emoji-picker.d.ts +1 -1
- package/dist/components/emoji-picker/src/emoji-picker.js +3 -1
- package/dist/components/emoji-picker/src/index.d.ts +3 -1
- package/dist/components/form/dist/index.d.ts +93 -98
- package/dist/components/form/src/adapters/base-adapter.d.ts +3 -3
- package/dist/components/form/src/adapters/checkbox-adapter.d.ts +1 -1
- package/dist/components/form/src/adapters/chips-input-adapter.d.ts +9 -0
- package/dist/components/form/src/adapters/chips-input-adapter.js +38 -0
- package/dist/components/form/src/adapters/index.d.ts +8 -7
- package/dist/components/form/src/adapters/input-adapter.d.ts +1 -1
- package/dist/components/form/src/adapters/multi-select-adapter.d.ts +1 -1
- package/dist/components/form/src/adapters/numeric-input-adapter.d.ts +1 -1
- package/dist/components/form/src/adapters/raido-group-adapter.d.ts +1 -7
- package/dist/components/form/src/adapters/range-adapter.d.ts +1 -7
- package/dist/components/form/src/adapters/segmented-adapter.d.ts +1 -7
- package/dist/components/form/src/adapters/select-adapter.d.ts +1 -1
- package/dist/components/form/src/adapters/switch-adapter.d.ts +1 -1
- package/dist/components/form/src/adapters/textarea-adapter.d.ts +1 -1
- package/dist/components/form/src/index.d.ts +18 -16
- package/dist/components/form/src/index.js +16 -13
- package/dist/components/form/src/types.d.ts +58 -51
- package/dist/components/hint/dist/index.d.ts +10 -54
- package/dist/components/hint/src/components/info-content.d.ts +3 -5
- package/dist/components/hint/src/components/info-content.js +14 -6
- package/dist/components/hint/src/components/info-trigger.d.ts +2 -3
- package/dist/components/hint/src/components/info-trigger.js +4 -2
- package/dist/components/hint/src/context/hint-context.d.ts +2 -0
- package/dist/components/hint/src/context/hint-context.js +1 -1
- package/dist/components/hint/src/hint.d.ts +7 -7
- package/dist/components/hint/src/hint.js +24 -29
- package/dist/components/hint/src/hooks/use-hint.d.ts +4 -2
- package/dist/components/hint/src/hooks/use-hint.js +12 -4
- package/dist/components/hint/src/index.d.ts +3 -3
- package/dist/components/hint/src/tv.d.ts +33 -0
- package/dist/components/hint/src/tv.js +11 -0
- package/dist/components/icon-button/dist/index.js +2 -2
- package/dist/components/icon-button/src/icon-button.js +2 -2
- package/dist/components/index.d.ts +3 -0
- package/dist/components/input/dist/index.js +4 -4
- package/dist/components/input/src/input.js +3 -3
- package/dist/components/input/src/tv.js +1 -1
- package/dist/components/kbd/dist/index.js +4 -4
- package/dist/components/kbd/src/kbd.js +4 -4
- package/dist/components/label/dist/index.js +3 -3
- package/dist/components/label/src/tv.js +3 -3
- package/dist/components/link-button/dist/index.js +3 -3
- package/dist/components/link-button/src/link-button.js +3 -3
- package/dist/components/list/src/components/list-content.js +2 -2
- package/dist/components/list/src/components/list-divider.js +3 -3
- package/dist/components/list/src/components/list-item.js +5 -5
- package/dist/components/list/src/components/list-label.js +2 -2
- package/dist/components/list/src/components/list-sub-trigger.js +4 -4
- package/dist/components/list/src/list.js +2 -2
- package/dist/components/md-input/dist/index.d.ts +8 -104
- package/dist/components/md-input/src/components/extensions/md-input-mention.d.ts +6 -4
- package/dist/components/md-input/src/components/extensions/md-input-mention.js +23 -6
- package/dist/components/md-input/src/components/md-input-container.js +1 -0
- package/dist/components/md-input/src/components/md-input-editor.js +4 -1
- package/dist/components/md-input/src/components/md-input-footer.js +5 -1
- package/dist/components/md-input/src/components/toolbar/default-actions.d.ts +2 -2
- package/dist/components/md-input/src/components/toolbar/toolbar-button.d.ts +1 -0
- package/dist/components/md-input/src/components/toolbar/toolbar-button.js +1 -7
- package/dist/components/md-input/src/components/toolbar/toolbar.d.ts +2 -2
- package/dist/components/md-input/src/hooks/use-markdown-mentions.d.ts +5 -4
- package/dist/components/md-input/src/hooks/use-markdown-mentions.js +31 -4
- package/dist/components/md-input/src/index.d.ts +1 -4
- package/dist/components/md-input/src/md-input.js +18 -14
- package/dist/components/md-input/src/tv.d.ts +3 -0
- package/dist/components/md-input/src/tv.js +2 -1
- package/dist/components/md-input/src/types.d.ts +18 -16
- package/dist/components/md-render/dist/index.d.ts +1 -4
- package/dist/components/md-render/dist/index.js +8 -9
- package/dist/components/md-render/src/components/markdown-components.js +3 -3
- package/dist/components/md-render/src/index.d.ts +0 -1
- package/dist/components/md-render/src/md-render.js +5 -4
- package/dist/components/md-render/src/tv.js +1 -1
- package/dist/components/menubar/dist/index.d.ts +50 -0
- package/dist/components/menubar/src/components/index.d.ts +3 -0
- package/dist/components/menubar/src/components/menubar-divider.d.ts +8 -0
- package/dist/components/menubar/src/components/menubar-divider.js +24 -0
- package/dist/components/menubar/src/components/menubar-item.d.ts +8 -0
- package/dist/components/menubar/src/components/menubar-item.js +195 -0
- package/dist/components/menubar/src/components/menubar-trigger.d.ts +8 -0
- package/dist/components/menubar/src/components/menubar-trigger.js +45 -0
- package/dist/components/menubar/src/context/index.d.ts +1 -0
- package/dist/components/menubar/src/context/menubar-context.d.ts +34 -0
- package/dist/components/menubar/src/context/menubar-context.js +13 -0
- package/dist/components/menubar/src/index.d.ts +3 -0
- package/dist/components/menubar/src/menubar.d.ts +22 -0
- package/dist/components/menubar/src/menubar.js +177 -0
- package/dist/components/menubar/src/tv.d.ts +108 -0
- package/dist/components/menubar/src/tv.js +72 -0
- package/dist/components/menubar/tsup.config.d.ts +2 -0
- package/dist/components/menus/dist/index.d.ts +144 -143
- package/dist/components/menus/dist/index.js +50 -49
- package/dist/components/menus/src/components/menu-button.js +2 -2
- package/dist/components/menus/src/components/menu-checkbox.d.ts +1 -2
- package/dist/components/menus/src/components/menu-checkbox.js +2 -2
- package/dist/components/menus/src/components/menu-divider.js +3 -3
- package/dist/components/menus/src/components/menu-item.js +5 -5
- package/dist/components/menus/src/components/menu-label.js +2 -2
- package/dist/components/menus/src/components/menu-scroll-arrow.d.ts +2 -2
- package/dist/components/menus/src/components/menu-scroll-arrow.js +13 -3
- package/dist/components/menus/src/components/menu-search.js +3 -3
- package/dist/components/menus/src/components/menu-trigger.js +4 -4
- package/dist/components/menus/src/context/menu-context-item.d.ts +6 -6
- package/dist/components/menus/src/context/menu-context-item.js +2 -2
- package/dist/components/menus/src/context/menu-context-sub-trigger.js +4 -19
- package/dist/components/menus/src/context/menu-context.d.ts +2 -2
- package/dist/components/menus/src/hooks/use-menu-base-refs.d.ts +12 -12
- package/dist/components/menus/src/hooks/use-menu-children.d.ts +16 -16
- package/dist/components/menus/src/hooks/use-menu-floating.d.ts +22 -22
- package/dist/components/menus/src/hooks/use-menu-refs.d.ts +8 -8
- package/dist/components/menus/src/hooks/use-menu-refs.js +2 -2
- package/dist/components/menus/src/hooks/use-menu-scroll-height.d.ts +11 -11
- package/dist/components/menus/src/hooks/use-menu-scroll.d.ts +18 -18
- package/dist/components/menus/src/hooks/use-menu-selection.d.ts +21 -21
- package/dist/components/menus/src/hooks/use-menu-state.d.ts +11 -11
- package/dist/components/menus/src/hooks/use-menu-state.js +4 -4
- package/dist/components/menus/src/hooks/use-menu-touch.d.ts +11 -11
- package/dist/components/menus/src/hooks/use-menu-tree.d.ts +15 -15
- package/dist/components/menus/src/index.d.ts +5 -0
- package/dist/components/menus/src/menus.js +2 -2
- package/dist/components/menus/src/tv.d.ts +15 -0
- package/dist/components/menus/src/tv.js +8 -2
- package/dist/components/modal/dist/index.d.ts +3 -1
- package/dist/components/modal/dist/index.js +18 -11
- package/dist/components/modal/src/components/modal-content.js +2 -2
- package/dist/components/modal/src/components/modal-footer.js +2 -2
- package/dist/components/modal/src/components/modal-header.d.ts +3 -1
- package/dist/components/modal/src/components/modal-header.js +12 -5
- package/dist/components/modal/src/modal.js +2 -2
- package/dist/components/multi-select/dist/index.js +13 -11
- package/dist/components/multi-select/src/components/multi-select-trigger.js +8 -8
- package/dist/components/multi-select/src/multi-select.js +5 -3
- package/dist/components/numeric-input/dist/index.d.ts +10 -117
- package/dist/components/numeric-input/dist/index.js +18 -24
- package/dist/components/numeric-input/src/components/numeric-input-element.js +2 -2
- package/dist/components/numeric-input/src/components/numeric-input-menu-trigger.d.ts +1 -1
- package/dist/components/numeric-input/src/components/numeric-input-menu-trigger.js +2 -2
- package/dist/components/numeric-input/src/components/numeric-input-variable.d.ts +1 -2
- package/dist/components/numeric-input/src/components/numeric-input-variable.js +3 -3
- package/dist/components/numeric-input/src/hooks/use-input-interactions.d.ts +3 -3
- package/dist/components/numeric-input/src/hooks/use-numeric-input.d.ts +3 -3
- package/dist/components/numeric-input/src/hooks/use-numeric-value-processing.d.ts +3 -3
- package/dist/components/numeric-input/src/hooks/use-step-calculation.d.ts +6 -6
- package/dist/components/numeric-input/src/index.d.ts +5 -4
- package/dist/components/numeric-input/src/numeric-input.js +9 -9
- package/dist/components/numeric-input/src/utils/error-handler.d.ts +8 -8
- package/dist/components/numeric-input/src/utils/expression-evaluator.d.ts +11 -11
- package/dist/components/numeric-input/src/utils/input-parser.d.ts +8 -8
- package/dist/components/numeric-input/src/utils/numeric-value-processor.d.ts +6 -6
- package/dist/components/numeric-input/src/utils/pattern-parser.d.ts +7 -7
- package/dist/components/numeric-input/src/utils/value-comparator.d.ts +16 -16
- package/dist/components/numeric-input/src/utils/value-processor.d.ts +14 -14
- package/dist/components/pagination/src/components/pagination-items-per-page.js +1 -1
- package/dist/components/pagination/src/components/pagination-navigation.js +5 -5
- package/dist/components/pagination/src/components/pagination-root.js +3 -3
- package/dist/components/pagination/src/components/pagination-spinner.js +20 -19
- package/dist/components/pagination/src/context/index.d.ts +1 -0
- package/dist/components/popover/dist/index.d.ts +2 -4
- package/dist/components/popover/dist/index.js +25 -33
- package/dist/components/popover/src/components/popover-header.js +1 -1
- package/dist/components/popover/src/hooks/use-drag.d.ts +3 -3
- package/dist/components/popover/src/hooks/use-floating-popover.d.ts +0 -2
- package/dist/components/popover/src/hooks/use-floating-popover.js +16 -13
- package/dist/components/popover/src/index.d.ts +2 -1
- package/dist/components/popover/src/popover.d.ts +1 -2
- package/dist/components/popover/src/popover.js +11 -21
- package/dist/components/progress/src/index.d.ts +4 -2
- package/dist/components/radio/dist/index.d.ts +1 -17
- package/dist/components/radio/dist/index.js +7 -10
- package/dist/components/radio/src/context.js +1 -1
- package/dist/components/radio/src/index.d.ts +0 -4
- package/dist/components/radio/src/radio-label.js +2 -2
- package/dist/components/radio/src/radio.js +4 -4
- package/dist/components/range/dist/index.js +16 -16
- package/dist/components/range/src/index.d.ts +4 -2
- package/dist/components/range/src/range-tuple.js +10 -10
- package/dist/components/range/src/range.js +6 -6
- package/dist/components/rich-input/dist/index.d.ts +12 -366
- package/dist/components/rich-input/src/components/rich-input-editable-component.d.ts +2 -2
- package/dist/components/rich-input/src/components/rich-input-viewport.d.ts +2 -2
- package/dist/components/rich-input/src/hooks/use-editor-config.d.ts +1 -1
- package/dist/components/rich-input/src/hooks/use-editor-effects.js +3 -0
- package/dist/components/rich-input/src/hooks/use-floating-ui.js +1 -1
- package/dist/components/rich-input/src/hooks/use-keyboard-shortcuts.d.ts +9 -9
- package/dist/components/rich-input/src/hooks/use-rich-input.d.ts +2 -2
- package/dist/components/rich-input/src/hooks/use-rich-input.js +40 -17
- package/dist/components/rich-input/src/hooks/use-selection-events.js +1 -2
- package/dist/components/rich-input/src/index.d.ts +3 -5
- package/dist/components/rich-input/src/rich-input-base.js +1 -1
- package/dist/components/rich-input/src/utils/custom-options.js +1 -1
- package/dist/components/rich-input/src/utils/editor-utils.js +1 -1
- package/dist/components/rich-input/src/utils/markdown-to-slate.d.ts +2 -2
- package/dist/components/rich-input/src/utils/slate-to-markdown.d.ts +1 -1
- package/dist/components/rich-input/src/utils/slate-to-markdown.js +9 -0
- package/dist/components/scroll-area/dist/index.d.ts +19 -19
- package/dist/components/scroll-area/dist/index.js +24 -24
- package/dist/components/scroll-area/src/components/scroll-area-corner.js +2 -2
- package/dist/components/scroll-area/src/components/scroll-area-root.js +3 -3
- package/dist/components/scroll-area/src/components/scroll-area-scrollbar.js +2 -2
- package/dist/components/scroll-area/src/components/scroll-area-thumb.js +2 -2
- package/dist/components/scroll-area/src/hooks/use-scroll-performance-monitor.d.ts +6 -6
- package/dist/components/scroll-area/src/hooks/use-scroll-performance-monitor.js +3 -3
- package/dist/components/scroll-area/src/hooks/use-scroll-state-and-visibility.d.ts +1 -1
- package/dist/components/scroll-area/src/hooks/use-scroll-state-and-visibility.js +3 -3
- package/dist/components/scroll-area/src/hooks/use-scrollbar.d.ts +2 -2
- package/dist/components/scroll-area/src/hooks/use-thumb.d.ts +2 -2
- package/dist/components/scroll-area/src/tv.d.ts +18 -18
- package/dist/components/scroll-area/src/tv.js +12 -12
- package/dist/components/scroll-area/src/types.d.ts +8 -8
- package/dist/components/scroll-area/src/utils/index.d.ts +3 -3
- package/dist/components/search-input/dist/index.js +3 -3
- package/dist/components/search-input/src/index.d.ts +2 -1
- package/dist/components/search-input/src/search-input.js +3 -3
- package/dist/components/segmented/dist/index.js +5 -5
- package/dist/components/segmented/src/segmented-item.js +3 -3
- package/dist/components/segmented/src/segmented.js +2 -2
- package/dist/components/select/dist/index.js +4 -4
- package/dist/components/select/src/select.js +4 -4
- package/dist/components/separator/dist/index.d.ts +26 -0
- package/dist/components/separator/src/index.d.ts +2 -0
- package/dist/components/separator/src/separator.d.ts +22 -0
- package/dist/components/separator/src/separator.js +33 -0
- package/dist/components/separator/src/tv.d.ts +76 -0
- package/dist/components/separator/src/tv.js +25 -0
- package/dist/components/separator/tsup.config.d.ts +2 -0
- package/dist/components/skeleton/dist/index.d.ts +1 -28
- package/dist/components/skeleton/src/context/skeleton-context.js +1 -1
- package/dist/components/skeleton/src/hooks/use-skeleton.d.ts +1 -2
- package/dist/components/skeleton/src/hooks/use-skeleton.js +1 -1
- package/dist/components/skeleton/src/index.d.ts +1 -3
- package/dist/components/skeleton/src/skeleton.d.ts +0 -13
- package/dist/components/skeleton/src/skeleton.js +4 -6
- package/dist/components/skeleton/src/tv.d.ts +18 -12
- package/dist/components/skeleton/src/tv.js +10 -6
- package/dist/components/slot/dist/index.d.ts +10 -10
- package/dist/components/slot/dist/index.js +4 -2
- package/dist/components/slot/src/slot.d.ts +12 -12
- package/dist/components/slot/src/slot.js +6 -3
- package/dist/components/stackflow/src/context.js +1 -1
- package/dist/components/stackflow/src/index.d.ts +2 -1
- package/dist/components/switch/dist/index.d.ts +2 -2
- package/dist/components/switch/dist/index.js +6 -7
- package/dist/components/switch/src/index.d.ts +2 -1
- package/dist/components/switch/src/switch.js +6 -6
- package/dist/components/table/dist/index.d.ts +679 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/src/components/column-resizer.d.ts +8 -0
- package/dist/components/table/src/components/column-resizer.js +58 -0
- package/dist/components/table/src/components/drag-guide.d.ts +6 -0
- package/dist/components/table/src/components/drag-guide.js +64 -0
- package/dist/components/table/src/components/index.d.ts +12 -0
- package/dist/components/table/src/components/resize-guide.d.ts +5 -0
- package/dist/components/table/src/components/resize-guide.js +25 -0
- package/dist/components/table/src/components/table-body.d.ts +6 -0
- package/dist/components/table/src/components/table-body.js +335 -0
- package/dist/components/table/src/components/table-cell.d.ts +6 -0
- package/dist/components/table/src/components/table-cell.js +89 -0
- package/dist/components/table/src/components/table-column.d.ts +5 -0
- package/dist/components/table/src/components/table-column.js +269 -0
- package/dist/components/table/src/components/table-empty.d.ts +8 -0
- package/dist/components/table/src/components/table-empty.js +10 -0
- package/dist/components/table/src/components/table-footer.d.ts +7 -0
- package/dist/components/table/src/components/table-footer.js +15 -0
- package/dist/components/table/src/components/table-header.d.ts +3 -0
- package/dist/components/table/src/components/table-header.js +88 -0
- package/dist/components/table/src/components/table-root.d.ts +3 -0
- package/dist/components/table/src/components/table-root.js +317 -0
- package/dist/components/table/src/components/table-row.d.ts +23 -0
- package/dist/components/table/src/components/table-row.js +166 -0
- package/dist/components/table/src/components/table-value.d.ts +6 -0
- package/dist/components/table/src/components/table-value.js +8 -0
- package/dist/components/table/src/context.d.ts +121 -0
- package/dist/components/table/src/context.js +63 -0
- package/dist/components/table/src/hooks/index.d.ts +4 -0
- package/dist/components/table/src/hooks/use-column-order.d.ts +26 -0
- package/dist/components/table/src/hooks/use-column-order.js +95 -0
- package/dist/components/table/src/hooks/use-column-resize.d.ts +17 -0
- package/dist/components/table/src/hooks/use-column-resize.js +75 -0
- package/dist/components/table/src/hooks/use-consecutive-selection-style.d.ts +12 -0
- package/dist/components/table/src/hooks/use-consecutive-selection-style.js +28 -0
- package/dist/components/table/src/hooks/use-table.d.ts +35 -0
- package/dist/components/table/src/hooks/use-table.js +245 -0
- package/dist/components/table/src/index.d.ts +4 -0
- package/dist/components/table/src/table.d.ts +88 -0
- package/dist/components/table/src/table.js +24 -0
- package/dist/components/table/src/tv.d.ts +176 -0
- package/dist/components/table/src/tv.js +97 -0
- package/dist/components/table/src/types.d.ts +292 -0
- package/dist/components/table/tsup.config.d.ts +2 -0
- package/dist/components/tabs/dist/index.js +4 -3
- package/dist/components/tabs/src/tabs.d.ts +2 -2
- package/dist/components/tabs/src/tabs.js +5 -4
- package/dist/components/text-field/dist/index.d.ts +1 -1
- package/dist/components/text-field/dist/index.js +10 -10
- package/dist/components/text-field/src/components/field-addon.d.ts +1 -2
- package/dist/components/text-field/src/index.d.ts +3 -1
- package/dist/components/text-field/src/text-field.js +10 -10
- package/dist/components/textarea/dist/index.d.ts +33 -5
- package/dist/components/textarea/dist/index.js +32 -7
- package/dist/components/textarea/src/components/autosize/index.d.ts +6 -1
- package/dist/components/textarea/src/components/autosize/index.js +31 -6
- package/dist/components/textarea/src/textarea.js +1 -1
- package/dist/components/textarea/src/types.d.ts +33 -5
- package/dist/components/toggle-button/dist/index.d.ts +26 -2
- package/dist/components/toggle-button/src/context.d.ts +11 -0
- package/dist/components/toggle-button/src/context.js +13 -0
- package/dist/components/toggle-button/src/index.d.ts +2 -0
- package/dist/components/toggle-button/src/toggle-button.js +4 -4
- package/dist/components/toggle-button/src/toggle-group.d.ts +26 -0
- package/dist/components/toggle-button/src/toggle-group.js +156 -0
- package/dist/components/toggle-button/src/tv.d.ts +67 -3
- package/dist/components/toggle-button/src/tv.js +45 -14
- package/dist/components/tooltip/dist/index.d.ts +10 -43
- package/dist/components/tooltip/dist/index.js +35 -33
- package/dist/components/tooltip/src/components/tooltip-arrow.js +1 -1
- package/dist/components/tooltip/src/components/tooltip-content.js +5 -4
- package/dist/components/tooltip/src/context/index.d.ts +1 -0
- package/dist/components/tooltip/src/hooks/use-tooltip.js +3 -3
- package/dist/components/tooltip/src/index.d.ts +2 -4
- package/dist/components/tooltip/src/tooltip.d.ts +7 -1
- package/dist/components/tooltip/src/tooltip.js +6 -1
- package/dist/components/tooltip/src/tv.js +1 -1
- package/dist/components/virtualized-grid/dist/index.d.ts +2 -2
- package/dist/components/virtualized-grid/src/use-item-pool.js +14 -26
- package/dist/components/virtualized-grid/src/use-virtualized-grid.d.ts +1 -1
- package/dist/components/virtualized-grid/src/use-virtualized-grid.js +14 -8
- package/dist/components/virtualized-grid/src/utility.d.ts +1 -1
- package/dist/components/virtualized-grid/src/utility.js +37 -31
- package/dist/components/virtualized-grid/src/virtualized-grid.js +27 -17
- package/dist/context/choice-ui-provider.d.ts +35 -0
- package/dist/context/choice-ui-provider.js +14 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +50 -195
- package/package.json +1 -1
- package/dist/components/code-block/src/index.js +0 -15
- package/dist/components/rich-input/src/hooks/use-mouse-events.js +0 -113
- package/dist/components/rich-input/src/hooks/use-validation.js +0 -80
- package/dist/components/rich-input/src/utils/markdown-to-slate.js +0 -219
- /package/dist/components/command/src/{command-score.d.ts → utils/command-score.d.ts} +0 -0
- /package/dist/components/command/src/{command-score.js → utils/command-score.js} +0 -0
- /package/dist/components/pagination/src/{components → context}/pagination-context.d.ts +0 -0
- /package/dist/components/pagination/src/{components → context}/pagination-context.js +0 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useCallback, useMemo } from "react";
|
|
3
|
+
import { TableStaticContext, TableScrollContext, TableSelectionContext, TableColumnStateContext, TableDragResizeContext, TableRowsContext } from "../context.js";
|
|
4
|
+
import { tableVariants } from "../tv.js";
|
|
5
|
+
import { DragGuide } from "./drag-guide.js";
|
|
6
|
+
import { ResizeGuide } from "./resize-guide.js";
|
|
7
|
+
import { useTable } from "../hooks/use-table.js";
|
|
8
|
+
import { useColumnResize } from "../hooks/use-column-resize.js";
|
|
9
|
+
import { useColumnOrder } from "../hooks/use-column-order.js";
|
|
10
|
+
import { useConsecutiveSelectionStyle } from "../hooks/use-consecutive-selection-style.js";
|
|
11
|
+
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
12
|
+
function TableRoot({
|
|
13
|
+
data,
|
|
14
|
+
getRowKey,
|
|
15
|
+
selectable = false,
|
|
16
|
+
selectionMode = "multiple",
|
|
17
|
+
selectedKeys: controlledSelectedKeys,
|
|
18
|
+
defaultSelectedKeys,
|
|
19
|
+
onSelectionChange,
|
|
20
|
+
virtualized = true,
|
|
21
|
+
rowHeight = 32,
|
|
22
|
+
overscan = 5,
|
|
23
|
+
scrollMode = "container",
|
|
24
|
+
scrollRef,
|
|
25
|
+
sortable = false,
|
|
26
|
+
sorting: controlledSorting,
|
|
27
|
+
defaultSorting,
|
|
28
|
+
onSortingChange,
|
|
29
|
+
resizable = false,
|
|
30
|
+
columnWidths: controlledColumnWidths,
|
|
31
|
+
defaultColumnWidths,
|
|
32
|
+
onColumnWidthsChange,
|
|
33
|
+
reorderable = false,
|
|
34
|
+
columnOrder: controlledColumnOrder,
|
|
35
|
+
defaultColumnOrder,
|
|
36
|
+
onColumnOrderChange,
|
|
37
|
+
activeRowKey,
|
|
38
|
+
onRowClick,
|
|
39
|
+
onScroll,
|
|
40
|
+
className,
|
|
41
|
+
height,
|
|
42
|
+
tableRef: instanceRef,
|
|
43
|
+
children
|
|
44
|
+
}) {
|
|
45
|
+
const tv = tableVariants();
|
|
46
|
+
const tableRef = useRef(null);
|
|
47
|
+
const headerInnerRef = useRef(null);
|
|
48
|
+
const [bodyScrollRef, setBodyScrollRef] = useState(null);
|
|
49
|
+
const syncScrollLeft = useCallback((value) => {
|
|
50
|
+
if (headerInnerRef.current) {
|
|
51
|
+
headerInnerRef.current.style.transform = `translateX(-${value}px)`;
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
const {
|
|
55
|
+
rows,
|
|
56
|
+
columns,
|
|
57
|
+
registerColumn,
|
|
58
|
+
unregisterColumn,
|
|
59
|
+
selectedKeys,
|
|
60
|
+
toggleRowSelection,
|
|
61
|
+
selectAll,
|
|
62
|
+
deselectAll,
|
|
63
|
+
isRowSelected,
|
|
64
|
+
isAllSelected,
|
|
65
|
+
isSomeSelected,
|
|
66
|
+
handleCheckboxClick,
|
|
67
|
+
sorting,
|
|
68
|
+
toggleSort,
|
|
69
|
+
getSortDirection,
|
|
70
|
+
tableInstance
|
|
71
|
+
} = useTable({
|
|
72
|
+
data,
|
|
73
|
+
getRowKey,
|
|
74
|
+
selectionMode: selectable ? selectionMode : "none",
|
|
75
|
+
selectedKeys: controlledSelectedKeys,
|
|
76
|
+
defaultSelectedKeys,
|
|
77
|
+
onSelectionChange,
|
|
78
|
+
sorting: controlledSorting,
|
|
79
|
+
defaultSorting,
|
|
80
|
+
onSortingChange,
|
|
81
|
+
tableRef: instanceRef
|
|
82
|
+
});
|
|
83
|
+
const { columnWidths, resizeState, getColumnWidth, startResize, updateResize, endResize } = useColumnResize({
|
|
84
|
+
columnWidths: controlledColumnWidths,
|
|
85
|
+
defaultColumnWidths,
|
|
86
|
+
onColumnWidthsChange
|
|
87
|
+
});
|
|
88
|
+
const {
|
|
89
|
+
columnOrder,
|
|
90
|
+
dragState,
|
|
91
|
+
startDrag,
|
|
92
|
+
updateDragTarget,
|
|
93
|
+
updateDragPosition,
|
|
94
|
+
endDrag,
|
|
95
|
+
cancelDrag
|
|
96
|
+
} = useColumnOrder({
|
|
97
|
+
columnOrder: controlledColumnOrder,
|
|
98
|
+
defaultColumnOrder: defaultColumnOrder ?? columns.map((c) => c.id),
|
|
99
|
+
onColumnOrderChange
|
|
100
|
+
});
|
|
101
|
+
const getConsecutiveStyle = useConsecutiveSelectionStyle(rows, selectedKeys);
|
|
102
|
+
const dataRef = useRef(data);
|
|
103
|
+
dataRef.current = data;
|
|
104
|
+
const getRowKeyRef = useRef(getRowKey);
|
|
105
|
+
getRowKeyRef.current = getRowKey;
|
|
106
|
+
const onRowClickRef = useRef(onRowClick);
|
|
107
|
+
onRowClickRef.current = onRowClick;
|
|
108
|
+
const onScrollRef = useRef(onScroll);
|
|
109
|
+
onScrollRef.current = onScroll;
|
|
110
|
+
const stableGetData = useCallback(() => dataRef.current, []);
|
|
111
|
+
const stableGetRowKey = useCallback(
|
|
112
|
+
(row, index) => getRowKeyRef.current(row, index),
|
|
113
|
+
[]
|
|
114
|
+
);
|
|
115
|
+
const stableOnRowClick = useCallback(
|
|
116
|
+
(row, event) => {
|
|
117
|
+
var _a;
|
|
118
|
+
return (_a = onRowClickRef.current) == null ? void 0 : _a.call(onRowClickRef, row, event);
|
|
119
|
+
},
|
|
120
|
+
[]
|
|
121
|
+
);
|
|
122
|
+
const stableOnScroll = useCallback(
|
|
123
|
+
(event) => {
|
|
124
|
+
var _a;
|
|
125
|
+
return (_a = onScrollRef.current) == null ? void 0 : _a.call(onScrollRef, event);
|
|
126
|
+
},
|
|
127
|
+
[]
|
|
128
|
+
);
|
|
129
|
+
const stableSetBodyScrollRef = useCallback((ref) => {
|
|
130
|
+
setBodyScrollRef(ref);
|
|
131
|
+
}, []);
|
|
132
|
+
const staticContextValue = useMemo(
|
|
133
|
+
() => ({
|
|
134
|
+
getData: stableGetData,
|
|
135
|
+
getRowKey: stableGetRowKey,
|
|
136
|
+
columns,
|
|
137
|
+
registerColumn,
|
|
138
|
+
unregisterColumn,
|
|
139
|
+
selectable,
|
|
140
|
+
selectionMode: selectable ? selectionMode : "none",
|
|
141
|
+
sortable,
|
|
142
|
+
resizable,
|
|
143
|
+
reorderable,
|
|
144
|
+
virtualized,
|
|
145
|
+
rowHeight,
|
|
146
|
+
overscan,
|
|
147
|
+
scrollMode,
|
|
148
|
+
scrollRef,
|
|
149
|
+
tableRef,
|
|
150
|
+
toggleSort,
|
|
151
|
+
getSortDirection,
|
|
152
|
+
onRowClick: stableOnRowClick,
|
|
153
|
+
onScroll: stableOnScroll,
|
|
154
|
+
tableInstance
|
|
155
|
+
}),
|
|
156
|
+
[
|
|
157
|
+
stableGetData,
|
|
158
|
+
stableGetRowKey,
|
|
159
|
+
columns,
|
|
160
|
+
registerColumn,
|
|
161
|
+
unregisterColumn,
|
|
162
|
+
selectable,
|
|
163
|
+
selectionMode,
|
|
164
|
+
sortable,
|
|
165
|
+
resizable,
|
|
166
|
+
reorderable,
|
|
167
|
+
virtualized,
|
|
168
|
+
rowHeight,
|
|
169
|
+
overscan,
|
|
170
|
+
scrollMode,
|
|
171
|
+
scrollRef,
|
|
172
|
+
toggleSort,
|
|
173
|
+
getSortDirection,
|
|
174
|
+
stableOnRowClick,
|
|
175
|
+
stableOnScroll,
|
|
176
|
+
tableInstance
|
|
177
|
+
]
|
|
178
|
+
);
|
|
179
|
+
const scrollContextValue = useMemo(
|
|
180
|
+
() => ({
|
|
181
|
+
headerInnerRef,
|
|
182
|
+
syncScrollLeft,
|
|
183
|
+
bodyScrollRef,
|
|
184
|
+
setBodyScrollRef: stableSetBodyScrollRef
|
|
185
|
+
}),
|
|
186
|
+
[syncScrollLeft, bodyScrollRef, stableSetBodyScrollRef]
|
|
187
|
+
);
|
|
188
|
+
const selectionContextValue = useMemo(
|
|
189
|
+
() => ({
|
|
190
|
+
selectedKeys,
|
|
191
|
+
isRowSelected,
|
|
192
|
+
toggleRowSelection,
|
|
193
|
+
handleCheckboxClick,
|
|
194
|
+
isAllSelected,
|
|
195
|
+
isSomeSelected,
|
|
196
|
+
selectAll,
|
|
197
|
+
deselectAll,
|
|
198
|
+
getConsecutiveStyle,
|
|
199
|
+
activeRowKey: activeRowKey ?? null
|
|
200
|
+
}),
|
|
201
|
+
[
|
|
202
|
+
selectedKeys,
|
|
203
|
+
isRowSelected,
|
|
204
|
+
toggleRowSelection,
|
|
205
|
+
handleCheckboxClick,
|
|
206
|
+
isAllSelected,
|
|
207
|
+
isSomeSelected,
|
|
208
|
+
selectAll,
|
|
209
|
+
deselectAll,
|
|
210
|
+
getConsecutiveStyle,
|
|
211
|
+
activeRowKey
|
|
212
|
+
]
|
|
213
|
+
);
|
|
214
|
+
const columnStateContextValue = useMemo(
|
|
215
|
+
() => ({
|
|
216
|
+
columnWidths,
|
|
217
|
+
columnOrder: columnOrder.length > 0 ? columnOrder : columns.map((c) => c.id),
|
|
218
|
+
sorting,
|
|
219
|
+
getColumnWidth
|
|
220
|
+
}),
|
|
221
|
+
[columnWidths, columnOrder, columns, sorting, getColumnWidth]
|
|
222
|
+
);
|
|
223
|
+
const dragResizeContextValue = useMemo(
|
|
224
|
+
() => ({
|
|
225
|
+
resizeState,
|
|
226
|
+
startResize,
|
|
227
|
+
updateResize,
|
|
228
|
+
endResize,
|
|
229
|
+
dragState,
|
|
230
|
+
startDrag,
|
|
231
|
+
updateDragTarget,
|
|
232
|
+
updateDragPosition,
|
|
233
|
+
endDrag,
|
|
234
|
+
cancelDrag
|
|
235
|
+
}),
|
|
236
|
+
[
|
|
237
|
+
resizeState,
|
|
238
|
+
startResize,
|
|
239
|
+
updateResize,
|
|
240
|
+
endResize,
|
|
241
|
+
dragState,
|
|
242
|
+
startDrag,
|
|
243
|
+
updateDragTarget,
|
|
244
|
+
updateDragPosition,
|
|
245
|
+
endDrag,
|
|
246
|
+
cancelDrag
|
|
247
|
+
]
|
|
248
|
+
);
|
|
249
|
+
const rowsContextValue = useMemo(() => ({ rows }), [rows]);
|
|
250
|
+
const handleTableDragOver = useCallback(
|
|
251
|
+
(e) => {
|
|
252
|
+
if (!dragState || !reorderable || !tableRef.current) return;
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
e.dataTransfer.dropEffect = "move";
|
|
255
|
+
const tableRect = tableRef.current.getBoundingClientRect();
|
|
256
|
+
const mouseX = e.clientX - tableRect.left;
|
|
257
|
+
updateDragPosition(mouseX);
|
|
258
|
+
const orderedCols = columnOrder.length > 0 ? columnOrder : columns.map((c) => c.id);
|
|
259
|
+
let leftOffset = selectable ? 40 : 0;
|
|
260
|
+
let targetIdx = 0;
|
|
261
|
+
for (let i = 0; i < orderedCols.length; i++) {
|
|
262
|
+
const colId = orderedCols[i];
|
|
263
|
+
const col = columns.find((c) => c.id === colId);
|
|
264
|
+
const colWidth = getColumnWidth(colId) ?? (typeof (col == null ? void 0 : col.width) === "number" ? col.width : 150);
|
|
265
|
+
const colMidpoint = leftOffset + colWidth / 2;
|
|
266
|
+
if (e.clientX - tableRect.left < colMidpoint) {
|
|
267
|
+
targetIdx = i;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
leftOffset += colWidth;
|
|
271
|
+
targetIdx = i + 1;
|
|
272
|
+
}
|
|
273
|
+
updateDragTarget(targetIdx);
|
|
274
|
+
},
|
|
275
|
+
[
|
|
276
|
+
dragState,
|
|
277
|
+
reorderable,
|
|
278
|
+
selectable,
|
|
279
|
+
columnOrder,
|
|
280
|
+
columns,
|
|
281
|
+
getColumnWidth,
|
|
282
|
+
updateDragPosition,
|
|
283
|
+
updateDragTarget
|
|
284
|
+
]
|
|
285
|
+
);
|
|
286
|
+
const handleTableDrop = useCallback(
|
|
287
|
+
(e) => {
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
endDrag();
|
|
290
|
+
},
|
|
291
|
+
[endDrag]
|
|
292
|
+
);
|
|
293
|
+
return /* @__PURE__ */ jsx(TableStaticContext.Provider, { value: staticContextValue, children: /* @__PURE__ */ jsx(TableScrollContext.Provider, { value: scrollContextValue, children: /* @__PURE__ */ jsx(TableSelectionContext.Provider, { value: selectionContextValue, children: /* @__PURE__ */ jsx(TableColumnStateContext.Provider, { value: columnStateContextValue, children: /* @__PURE__ */ jsx(TableDragResizeContext.Provider, { value: dragResizeContextValue, children: /* @__PURE__ */ jsx(TableRowsContext.Provider, { value: rowsContextValue, children: /* @__PURE__ */ jsxs(
|
|
294
|
+
"div",
|
|
295
|
+
{
|
|
296
|
+
ref: tableRef,
|
|
297
|
+
role: "table",
|
|
298
|
+
"aria-rowcount": rows.length,
|
|
299
|
+
"aria-colcount": columns.length + (selectable ? 1 : 0),
|
|
300
|
+
className: tcx(
|
|
301
|
+
tv.root({ resizing: !!resizeState, dragging: !!dragState }),
|
|
302
|
+
className
|
|
303
|
+
),
|
|
304
|
+
style: { height },
|
|
305
|
+
onDragOver: handleTableDragOver,
|
|
306
|
+
onDrop: handleTableDrop,
|
|
307
|
+
children: [
|
|
308
|
+
children,
|
|
309
|
+
/* @__PURE__ */ jsx(ResizeGuide, {}),
|
|
310
|
+
/* @__PURE__ */ jsx(DragGuide, {})
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
) }) }) }) }) }) });
|
|
314
|
+
}
|
|
315
|
+
export {
|
|
316
|
+
TableRoot
|
|
317
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ConsecutiveStyle, TableRowProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal props that include pre-computed values from context
|
|
5
|
+
* This allows the component to be properly memoized
|
|
6
|
+
*/
|
|
7
|
+
interface TableRowInternalProps extends TableRowProps {
|
|
8
|
+
selectable: boolean;
|
|
9
|
+
isSelected: boolean;
|
|
10
|
+
isActive: boolean;
|
|
11
|
+
consecutiveStyle: ConsecutiveStyle;
|
|
12
|
+
columnOrder: string[];
|
|
13
|
+
reorderable: boolean;
|
|
14
|
+
hasRowClick: boolean;
|
|
15
|
+
onCheckboxClick: (e: React.MouseEvent) => void;
|
|
16
|
+
onRowClickHandler: ((event: React.MouseEvent) => void) | undefined;
|
|
17
|
+
onRowKeyDown: ((event: React.KeyboardEvent) => void) | undefined;
|
|
18
|
+
}
|
|
19
|
+
declare function TableRowPure({ rowKey, index, children, className, selectable, isSelected, isActive, consecutiveStyle, columnOrder, reorderable, hasRowClick, onCheckboxClick, onRowClickHandler, onRowKeyDown, }: TableRowInternalProps): ReactNode;
|
|
20
|
+
declare const TableRowMemo: import('react').MemoExoticComponent<typeof TableRowPure>;
|
|
21
|
+
export type { TableRowProps };
|
|
22
|
+
export { TableRowMemo as TableRowPure };
|
|
23
|
+
export declare function TableRow({ rowKey, index, children, className, onClick, }: TableRowProps): ReactNode;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox as Checkbox2 } from "../../../checkbox/dist/index.js";
|
|
3
|
+
import { useCallback, useMemo, memo, Children, isValidElement } from "react";
|
|
4
|
+
import { tableVariants } from "../tv.js";
|
|
5
|
+
import { useTableStatic, useTableSelection, useTableColumnState, useTableRows } from "../context.js";
|
|
6
|
+
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
7
|
+
const NOOP = () => {
|
|
8
|
+
};
|
|
9
|
+
function TableRowPure({
|
|
10
|
+
rowKey,
|
|
11
|
+
index,
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
// Pre-computed values
|
|
15
|
+
selectable,
|
|
16
|
+
isSelected,
|
|
17
|
+
isActive,
|
|
18
|
+
consecutiveStyle,
|
|
19
|
+
columnOrder,
|
|
20
|
+
reorderable,
|
|
21
|
+
hasRowClick,
|
|
22
|
+
// Stable handlers
|
|
23
|
+
onCheckboxClick,
|
|
24
|
+
onRowClickHandler,
|
|
25
|
+
onRowKeyDown
|
|
26
|
+
}) {
|
|
27
|
+
const tv = tableVariants();
|
|
28
|
+
const orderedChildren = useMemo(() => {
|
|
29
|
+
if (!reorderable || columnOrder.length === 0) {
|
|
30
|
+
return children;
|
|
31
|
+
}
|
|
32
|
+
const childArray = Children.toArray(children);
|
|
33
|
+
const childMap = /* @__PURE__ */ new Map();
|
|
34
|
+
childArray.forEach((child) => {
|
|
35
|
+
if (isValidElement(child) && child.props.columnId) {
|
|
36
|
+
childMap.set(child.props.columnId, child);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const sorted = columnOrder.map((id) => childMap.get(id)).filter((child) => child !== void 0);
|
|
40
|
+
childArray.forEach((child) => {
|
|
41
|
+
if (isValidElement(child) && child.props.columnId && !columnOrder.includes(child.props.columnId)) {
|
|
42
|
+
sorted.push(child);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return sorted;
|
|
46
|
+
}, [children, columnOrder, reorderable]);
|
|
47
|
+
const rowClassName = useMemo(
|
|
48
|
+
() => tcx(
|
|
49
|
+
tv.rowStatic({ selected: isSelected, active: isActive }),
|
|
50
|
+
// Always use rowStatic - virtualized rows are wrapped by VirtualRowWrapper
|
|
51
|
+
consecutiveStyle,
|
|
52
|
+
className
|
|
53
|
+
),
|
|
54
|
+
[tv, hasRowClick, isSelected, isActive, consecutiveStyle, className]
|
|
55
|
+
);
|
|
56
|
+
return /* @__PURE__ */ jsxs(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
role: "row",
|
|
60
|
+
"aria-selected": isSelected,
|
|
61
|
+
"aria-rowindex": index + 2,
|
|
62
|
+
className: rowClassName,
|
|
63
|
+
"data-selected": isSelected,
|
|
64
|
+
"data-active": isActive,
|
|
65
|
+
"data-index": index,
|
|
66
|
+
onClick: onRowClickHandler,
|
|
67
|
+
onKeyDown: onRowKeyDown,
|
|
68
|
+
tabIndex: hasRowClick ? 0 : void 0,
|
|
69
|
+
children: [
|
|
70
|
+
selectable && /* @__PURE__ */ jsx(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
role: "cell",
|
|
74
|
+
className: tv.cellCheckbox(),
|
|
75
|
+
style: { width: 40, minWidth: 40, flexShrink: 0 },
|
|
76
|
+
children: /* @__PURE__ */ jsx(
|
|
77
|
+
Checkbox2,
|
|
78
|
+
{
|
|
79
|
+
variant: "accent",
|
|
80
|
+
value: isSelected,
|
|
81
|
+
onChange: NOOP,
|
|
82
|
+
onClick: onCheckboxClick
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
orderedChildren
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
const TableRowMemo = memo(TableRowPure, (prev, next) => {
|
|
93
|
+
return prev.rowKey === next.rowKey && prev.index === next.index && prev.className === next.className && prev.selectable === next.selectable && prev.isSelected === next.isSelected && prev.isActive === next.isActive && prev.consecutiveStyle === next.consecutiveStyle && prev.reorderable === next.reorderable && prev.hasRowClick === next.hasRowClick && prev.columnOrder === next.columnOrder;
|
|
94
|
+
});
|
|
95
|
+
function TableRow({
|
|
96
|
+
rowKey,
|
|
97
|
+
index,
|
|
98
|
+
children,
|
|
99
|
+
className,
|
|
100
|
+
onClick
|
|
101
|
+
}) {
|
|
102
|
+
const { selectable, onRowClick, reorderable } = useTableStatic();
|
|
103
|
+
const { isRowSelected, handleCheckboxClick, activeRowKey, getConsecutiveStyle } = useTableSelection();
|
|
104
|
+
const { columnOrder } = useTableColumnState();
|
|
105
|
+
const { rows } = useTableRows();
|
|
106
|
+
const isSelected = isRowSelected(rowKey);
|
|
107
|
+
const isActive = activeRowKey === rowKey;
|
|
108
|
+
const consecutiveStyle = getConsecutiveStyle(index);
|
|
109
|
+
const hasRowClick = !!onRowClick || !!onClick;
|
|
110
|
+
const onCheckboxClick = useCallback(
|
|
111
|
+
(e) => {
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
handleCheckboxClick(rowKey, index, e);
|
|
114
|
+
},
|
|
115
|
+
[handleCheckboxClick, rowKey, index]
|
|
116
|
+
);
|
|
117
|
+
const onRowClickHandler = useMemo(() => {
|
|
118
|
+
if (!onRowClick && !onClick) return void 0;
|
|
119
|
+
return (event) => {
|
|
120
|
+
onClick == null ? void 0 : onClick(event);
|
|
121
|
+
if (index >= 0 && index < rows.length) {
|
|
122
|
+
const row = rows[index];
|
|
123
|
+
if (row && onRowClick) {
|
|
124
|
+
onRowClick(row.data, event);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}, [onClick, onRowClick, rows, index]);
|
|
129
|
+
const onRowKeyDown = useMemo(() => {
|
|
130
|
+
if (!onRowClick && !onClick) return void 0;
|
|
131
|
+
return (event) => {
|
|
132
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
if (index >= 0 && index < rows.length) {
|
|
135
|
+
const row = rows[index];
|
|
136
|
+
if (row && onRowClick) {
|
|
137
|
+
onRowClick(row.data, event);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}, [onClick, onRowClick, rows, index]);
|
|
143
|
+
return /* @__PURE__ */ jsx(
|
|
144
|
+
TableRowMemo,
|
|
145
|
+
{
|
|
146
|
+
rowKey,
|
|
147
|
+
index,
|
|
148
|
+
className,
|
|
149
|
+
selectable,
|
|
150
|
+
isSelected,
|
|
151
|
+
isActive,
|
|
152
|
+
consecutiveStyle,
|
|
153
|
+
columnOrder,
|
|
154
|
+
reorderable,
|
|
155
|
+
hasRowClick,
|
|
156
|
+
onCheckboxClick,
|
|
157
|
+
onRowClickHandler,
|
|
158
|
+
onRowKeyDown,
|
|
159
|
+
children
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
TableRow,
|
|
165
|
+
TableRowMemo as TableRowPure
|
|
166
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { tcx } from "../../../../shared/utils/tcx/tcx.js";
|
|
3
|
+
function TableValue({ children, className }) {
|
|
4
|
+
return /* @__PURE__ */ jsx("span", { className: tcx("flex-1 truncate", className), children });
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
TableValue
|
|
8
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ColumnOrderState, ColumnWidthsState, ConsecutiveStyle, RowKey, ScrollMode, SelectionMode, SortDirection, SortingState, TableColumnDef, TableInstance } from './types';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Static context - rarely changes
|
|
5
|
+
* Contains: columns, config, refs, and stable handlers
|
|
6
|
+
*/
|
|
7
|
+
export interface TableStaticContextValue<T = unknown> {
|
|
8
|
+
getData: () => T[];
|
|
9
|
+
getRowKey: (row: T, index: number) => RowKey;
|
|
10
|
+
columns: TableColumnDef<T>[];
|
|
11
|
+
registerColumn: (column: TableColumnDef<T>) => void;
|
|
12
|
+
unregisterColumn: (id: string) => void;
|
|
13
|
+
selectable: boolean;
|
|
14
|
+
selectionMode: SelectionMode;
|
|
15
|
+
sortable: boolean;
|
|
16
|
+
resizable: boolean;
|
|
17
|
+
reorderable: boolean;
|
|
18
|
+
virtualized: boolean;
|
|
19
|
+
/** Fixed row height in pixels */
|
|
20
|
+
rowHeight: number;
|
|
21
|
+
overscan: number;
|
|
22
|
+
scrollMode: ScrollMode;
|
|
23
|
+
/** External scroll container ref (for external scroll mode) */
|
|
24
|
+
scrollRef?: RefObject<HTMLElement>;
|
|
25
|
+
tableRef: RefObject<HTMLDivElement>;
|
|
26
|
+
toggleSort: (columnId: string) => void;
|
|
27
|
+
getSortDirection: (columnId: string) => SortDirection | null;
|
|
28
|
+
onRowClick?: (row: T, event: React.MouseEvent) => void;
|
|
29
|
+
onScroll?: (event: {
|
|
30
|
+
scrollTop: number;
|
|
31
|
+
scrollHeight: number;
|
|
32
|
+
clientHeight: number;
|
|
33
|
+
}) => void;
|
|
34
|
+
tableInstance: TableInstance<T>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Scroll sync context - for header/body horizontal scroll synchronization
|
|
38
|
+
* Uses refs for direct DOM manipulation to avoid React re-renders during scroll
|
|
39
|
+
*/
|
|
40
|
+
export interface TableScrollContextValue {
|
|
41
|
+
/** Header inner element ref for direct DOM transform */
|
|
42
|
+
headerInnerRef: RefObject<HTMLDivElement>;
|
|
43
|
+
/** Sync scroll position directly to header (bypasses React state) */
|
|
44
|
+
syncScrollLeft: (value: number) => void;
|
|
45
|
+
/** Body scroll container ref (for virtualization) */
|
|
46
|
+
bodyScrollRef: RefObject<HTMLDivElement> | null;
|
|
47
|
+
/** Set body scroll container ref */
|
|
48
|
+
setBodyScrollRef: (ref: RefObject<HTMLDivElement>) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Selection context - changes when selection changes
|
|
52
|
+
*/
|
|
53
|
+
export interface TableSelectionContextValue {
|
|
54
|
+
selectedKeys: Set<RowKey>;
|
|
55
|
+
isRowSelected: (key: RowKey) => boolean;
|
|
56
|
+
toggleRowSelection: (key: RowKey, index?: number) => void;
|
|
57
|
+
handleCheckboxClick: (key: RowKey, index: number, event: React.MouseEvent) => void;
|
|
58
|
+
isAllSelected: () => boolean;
|
|
59
|
+
isSomeSelected: () => boolean;
|
|
60
|
+
selectAll: () => void;
|
|
61
|
+
deselectAll: () => void;
|
|
62
|
+
getConsecutiveStyle: (index: number) => ConsecutiveStyle;
|
|
63
|
+
activeRowKey: RowKey | null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Column state context - changes during resize/reorder
|
|
67
|
+
*/
|
|
68
|
+
export interface TableColumnStateContextValue {
|
|
69
|
+
columnWidths: ColumnWidthsState;
|
|
70
|
+
columnOrder: ColumnOrderState;
|
|
71
|
+
sorting: SortingState[];
|
|
72
|
+
getColumnWidth: (columnId: string) => number | undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Drag/Resize context - changes very frequently during interactions
|
|
76
|
+
*/
|
|
77
|
+
export interface TableDragResizeContextValue {
|
|
78
|
+
resizeState: {
|
|
79
|
+
columnId: string;
|
|
80
|
+
startX: number;
|
|
81
|
+
startWidth: number;
|
|
82
|
+
currentX: number;
|
|
83
|
+
} | null;
|
|
84
|
+
startResize: (columnId: string, startX: number, startWidth: number) => void;
|
|
85
|
+
updateResize: (currentX: number) => void;
|
|
86
|
+
endResize: () => void;
|
|
87
|
+
dragState: {
|
|
88
|
+
columnId: string;
|
|
89
|
+
targetIndex: number;
|
|
90
|
+
mouseX: number;
|
|
91
|
+
sourceLeft: number;
|
|
92
|
+
sourceWidth: number;
|
|
93
|
+
} | null;
|
|
94
|
+
startDrag: (columnId: string, mouseX: number, sourceLeft: number, sourceWidth: number) => void;
|
|
95
|
+
updateDragTarget: (targetIndex: number) => void;
|
|
96
|
+
updateDragPosition: (mouseX: number) => void;
|
|
97
|
+
endDrag: () => void;
|
|
98
|
+
cancelDrag: () => void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Row data context - contains rows array
|
|
102
|
+
*/
|
|
103
|
+
export interface TableRowsContextValue<T = unknown> {
|
|
104
|
+
rows: Array<{
|
|
105
|
+
key: RowKey;
|
|
106
|
+
data: T;
|
|
107
|
+
index: number;
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
110
|
+
export declare const TableStaticContext: import('react').Context<TableStaticContextValue<unknown> | null>;
|
|
111
|
+
export declare const TableScrollContext: import('react').Context<TableScrollContextValue | null>;
|
|
112
|
+
export declare const TableSelectionContext: import('react').Context<TableSelectionContextValue | null>;
|
|
113
|
+
export declare const TableColumnStateContext: import('react').Context<TableColumnStateContextValue | null>;
|
|
114
|
+
export declare const TableDragResizeContext: import('react').Context<TableDragResizeContextValue | null>;
|
|
115
|
+
export declare const TableRowsContext: import('react').Context<TableRowsContextValue<unknown> | null>;
|
|
116
|
+
export declare function useTableStatic<T = unknown>(): TableStaticContextValue<T>;
|
|
117
|
+
export declare function useTableScroll(): TableScrollContextValue;
|
|
118
|
+
export declare function useTableSelection(): TableSelectionContextValue;
|
|
119
|
+
export declare function useTableColumnState(): TableColumnStateContextValue;
|
|
120
|
+
export declare function useTableDragResize(): TableDragResizeContextValue;
|
|
121
|
+
export declare function useTableRows<T = unknown>(): TableRowsContextValue<T>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useContext, createContext } from "react";
|
|
2
|
+
const TableStaticContext = createContext(null);
|
|
3
|
+
const TableScrollContext = createContext(null);
|
|
4
|
+
const TableSelectionContext = createContext(null);
|
|
5
|
+
const TableColumnStateContext = createContext(null);
|
|
6
|
+
const TableDragResizeContext = createContext(null);
|
|
7
|
+
const TableRowsContext = createContext(null);
|
|
8
|
+
function useTableStatic() {
|
|
9
|
+
const context = useContext(TableStaticContext);
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error("Table components must be used within a Table");
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
function useTableScroll() {
|
|
16
|
+
const context = useContext(TableScrollContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw new Error("Table components must be used within a Table");
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
function useTableSelection() {
|
|
23
|
+
const context = useContext(TableSelectionContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("Table components must be used within a Table");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
function useTableColumnState() {
|
|
30
|
+
const context = useContext(TableColumnStateContext);
|
|
31
|
+
if (!context) {
|
|
32
|
+
throw new Error("Table components must be used within a Table");
|
|
33
|
+
}
|
|
34
|
+
return context;
|
|
35
|
+
}
|
|
36
|
+
function useTableDragResize() {
|
|
37
|
+
const context = useContext(TableDragResizeContext);
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error("Table components must be used within a Table");
|
|
40
|
+
}
|
|
41
|
+
return context;
|
|
42
|
+
}
|
|
43
|
+
function useTableRows() {
|
|
44
|
+
const context = useContext(TableRowsContext);
|
|
45
|
+
if (!context) {
|
|
46
|
+
throw new Error("Table components must be used within a Table");
|
|
47
|
+
}
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
TableColumnStateContext,
|
|
52
|
+
TableDragResizeContext,
|
|
53
|
+
TableRowsContext,
|
|
54
|
+
TableScrollContext,
|
|
55
|
+
TableSelectionContext,
|
|
56
|
+
TableStaticContext,
|
|
57
|
+
useTableColumnState,
|
|
58
|
+
useTableDragResize,
|
|
59
|
+
useTableRows,
|
|
60
|
+
useTableScroll,
|
|
61
|
+
useTableSelection,
|
|
62
|
+
useTableStatic
|
|
63
|
+
};
|