@kumix/ui 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -45
- package/dist/{cascader-types-DVT-znZ-.d.ts → cascader-types-zhnUQ4sP.d.ts} +11 -3
- package/dist/cascader-types-zhnUQ4sP.d.ts.map +1 -0
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/agents/approval-card/index.d.ts +2 -0
- package/dist/components/agents/approval-card/index.d.ts.map +1 -1
- package/dist/components/agents/approval-card/index.js +2 -0
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/citations.d.ts +14 -2
- package/dist/components/agents/citations.d.ts.map +1 -1
- package/dist/components/agents/citations.js +11 -7
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +3 -0
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/charts/bump-chart/context.js +1 -2
- package/dist/components/charts/bump-chart/plot.js +1 -2
- package/dist/components/charts/bump-chart/point.js +1 -1
- package/dist/components/charts/bump-chart/series.d.ts +1 -0
- package/dist/components/charts/candlestick-chart/context.d.ts +79 -0
- package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/context.js +69 -0
- package/dist/components/charts/candlestick-chart/context.js.map +1 -0
- package/dist/components/charts/candlestick-chart/legend.d.ts +12 -0
- package/dist/components/charts/candlestick-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/legend.js +56 -0
- package/dist/components/charts/candlestick-chart/legend.js.map +1 -0
- package/dist/components/charts/candlestick-chart/plot.d.ts +9 -0
- package/dist/components/charts/candlestick-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/plot.js +218 -0
- package/dist/components/charts/candlestick-chart/plot.js.map +1 -0
- package/dist/components/charts/candlestick-chart.d.ts +18 -0
- package/dist/components/charts/candlestick-chart.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart.js +34 -0
- package/dist/components/charts/candlestick-chart.js.map +1 -0
- package/dist/components/charts/composition-chart/context.js +1 -2
- package/dist/components/charts/composition-chart/plot.js +1 -1
- package/dist/components/charts/donut-chart/center.d.ts +16 -0
- package/dist/components/charts/donut-chart/center.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/center.js +78 -0
- package/dist/components/charts/donut-chart/center.js.map +1 -0
- package/dist/components/charts/donut-chart/context.d.ts +68 -0
- package/dist/components/charts/donut-chart/context.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/context.js +2 -0
- package/dist/components/charts/donut-chart/legend.d.ts +17 -0
- package/dist/components/charts/donut-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/legend.js +85 -0
- package/dist/components/charts/donut-chart/legend.js.map +1 -0
- package/dist/components/charts/donut-chart/plot.d.ts +10 -0
- package/dist/components/charts/donut-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/plot.js +108 -0
- package/dist/components/charts/donut-chart/plot.js.map +1 -0
- package/dist/components/charts/donut-chart.d.ts +22 -0
- package/dist/components/charts/donut-chart.d.ts.map +1 -0
- package/dist/components/charts/donut-chart.js +37 -0
- package/dist/components/charts/donut-chart.js.map +1 -0
- package/dist/components/charts/funnel-chart.d.ts.map +1 -1
- package/dist/components/charts/funnel-chart.js +1 -2
- package/dist/components/charts/funnel-chart.js.map +1 -1
- package/dist/components/charts/heat-calendar/tooltip.js +1 -1
- package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -1
- package/dist/components/charts/liquidity-heatmap.js +1 -1
- package/dist/components/charts/order-book/depth-row.d.ts +8 -2
- package/dist/components/charts/order-book/depth-row.d.ts.map +1 -1
- package/dist/components/charts/order-book/depth-row.js +11 -3
- package/dist/components/charts/order-book/depth-row.js.map +1 -1
- package/dist/components/charts/order-book.d.ts +33 -1
- package/dist/components/charts/order-book.d.ts.map +1 -1
- package/dist/components/charts/order-book.js +92 -17
- package/dist/components/charts/order-book.js.map +1 -1
- package/dist/components/charts/price-target-fan/tooltip.js +1 -1
- package/dist/components/charts/returns-calendar/tooltip.js +1 -1
- package/dist/components/charts/status-bar/tooltip.js +1 -1
- package/dist/components/charts/treemap/tooltip.js +1 -1
- package/dist/components/charts/treemap.d.ts.map +1 -1
- package/dist/components/charts/volume-profile/tooltip.js +1 -1
- package/dist/components/charts/volume-profile.d.ts.map +1 -1
- package/dist/components/custom/confirm-dialog.d.ts +1 -0
- package/dist/components/custom/toast.d.ts +1 -0
- package/dist/components/motion/action-swap.d.ts +1 -1
- package/dist/components/motion/action-swap.d.ts.map +1 -1
- package/dist/components/motion/action-swap.js +46 -20
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/animated-badge.d.ts +1 -1
- package/dist/components/motion/animated-badge.d.ts.map +1 -1
- package/dist/components/motion/animated-badge.js +60 -101
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-sidebar.d.ts +1 -0
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-toast-stack.js +1 -1
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +2 -3
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -2
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.d.ts +1 -0
- package/dist/components/motion/bloom-menu.d.ts.map +1 -1
- package/dist/components/motion/bloom-menu.js +73 -8
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
- package/dist/components/motion/bottom-sheet.js +6 -10
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
- package/dist/components/motion/bounce-sidebar.js +34 -42
- package/dist/components/motion/bounce-sidebar.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +35 -22
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/button/stateful.d.ts.map +1 -1
- package/dist/components/motion/button/stateful.js +3 -0
- package/dist/components/motion/button/stateful.js.map +1 -1
- package/dist/components/motion/card.d.ts +44 -0
- package/dist/components/motion/card.d.ts.map +1 -0
- package/dist/components/motion/card.js +122 -0
- package/dist/components/motion/card.js.map +1 -0
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/checkbox.d.ts +3 -1
- package/dist/components/motion/checkbox.d.ts.map +1 -1
- package/dist/components/motion/checkbox.js +18 -6
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/color-picker.d.ts +110 -0
- package/dist/components/motion/color-picker.d.ts.map +1 -0
- package/dist/components/motion/color-picker.js +1053 -0
- package/dist/components/motion/color-picker.js.map +1 -0
- package/dist/components/motion/color-selector.d.ts.map +1 -1
- package/dist/components/motion/color-selector.js +9 -2
- package/dist/components/motion/color-selector.js.map +1 -1
- package/dist/components/motion/combobox/content.d.ts +1 -0
- package/dist/components/motion/command-palette.js +3 -3
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.d.ts +1 -0
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/date-range-picker.d.ts.map +1 -1
- package/dist/components/motion/digit-swap.d.ts +9 -1
- package/dist/components/motion/digit-swap.d.ts.map +1 -1
- package/dist/components/motion/digit-swap.js +18 -7
- package/dist/components/motion/digit-swap.js.map +1 -1
- package/dist/components/motion/drawer.d.ts +1 -1
- package/dist/components/motion/drawer.d.ts.map +1 -1
- package/dist/components/motion/drawer.js +10 -10
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
- package/dist/components/motion/expandable-control.d.ts +1 -0
- package/dist/components/motion/feedback-widget.js +4 -1
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/knockout-wheel.d.ts.map +1 -1
- package/dist/components/motion/knockout-wheel.js +1 -2
- package/dist/components/motion/knockout-wheel.js.map +1 -1
- package/dist/components/motion/morphing-lightbox.d.ts.map +1 -1
- package/dist/components/motion/morphing-lightbox.js +1 -1
- package/dist/components/motion/morphing-modal.d.ts +6 -1
- package/dist/components/motion/morphing-modal.d.ts.map +1 -1
- package/dist/components/motion/morphing-modal.js +37 -5
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search-chips.d.ts +54 -0
- package/dist/components/motion/morphing-search-chips.d.ts.map +1 -0
- package/dist/components/motion/morphing-search-chips.js +599 -0
- package/dist/components/motion/morphing-search-chips.js.map +1 -0
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/multi-select/content.d.ts +1 -0
- package/dist/components/motion/not-found/shared.d.ts +1 -0
- package/dist/components/motion/number-ticker.d.ts +6 -1
- package/dist/components/motion/number-ticker.d.ts.map +1 -1
- package/dist/components/motion/number-ticker.js +19 -9
- package/dist/components/motion/number-ticker.js.map +1 -1
- package/dist/components/motion/otp-input.js +19 -11
- package/dist/components/motion/otp-input.js.map +1 -1
- package/dist/components/motion/parallax.js.map +1 -1
- package/dist/components/motion/popover-morph.d.ts +5 -3
- package/dist/components/motion/popover-morph.d.ts.map +1 -1
- package/dist/components/motion/popover-morph.js +47 -52
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.d.ts +1 -0
- package/dist/components/motion/popover.js +7 -1
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/prediction-market-card.js +2 -3
- package/dist/components/motion/prediction-market-card.js.map +1 -1
- package/dist/components/motion/prediction-market.js +1 -1
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/radio.d.ts +8 -2
- package/dist/components/motion/radio.d.ts.map +1 -1
- package/dist/components/motion/radio.js +70 -10
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/scroll-progress.d.ts +1 -0
- package/dist/components/motion/select-morph.d.ts +1 -1
- package/dist/components/motion/select-morph.d.ts.map +1 -1
- package/dist/components/motion/select-morph.js +89 -21
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.d.ts.map +1 -1
- package/dist/components/motion/select.js +153 -135
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/shader-background.d.ts +4 -2
- package/dist/components/motion/shader-background.d.ts.map +1 -1
- package/dist/components/motion/shader-background.js +9 -3
- package/dist/components/motion/shader-background.js.map +1 -1
- package/dist/components/motion/shared-layout-bg.d.ts.map +1 -1
- package/dist/components/motion/shared-layout-bg.js +17 -3
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/sortable-list.d.ts +1 -0
- package/dist/components/motion/sortable-stack.js +1 -2
- package/dist/components/motion/swipeable-list.d.ts.map +1 -1
- package/dist/components/motion/swipeable-list.js +61 -4
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/tabs.d.ts +13 -3
- package/dist/components/motion/tabs.d.ts.map +1 -1
- package/dist/components/motion/tabs.js +248 -26
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/text-reveal.d.ts +1 -0
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/motion/tooltip/positioner.d.ts +8 -26
- package/dist/components/motion/tooltip/positioner.d.ts.map +1 -1
- package/dist/components/motion/tooltip/positioner.js +1 -2
- package/dist/components/motion/tooltip.d.ts +62 -20
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +1 -135
- package/dist/components/motion/wallet-card/account-avatar.js +1 -2
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-async.d.ts +21 -5
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-async.js +61 -34
- package/dist/components/reui/cascader/cascader-async.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +5 -2
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-context.d.ts +3 -1
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-context.js.map +1 -1
- package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-item.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-lib.d.ts +34 -8
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-lib.js +145 -29
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
- package/dist/components/reui/cascader/cascader.d.ts +13 -8
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader.js +31 -16
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
- package/dist/components/reui/color-picker.d.ts +280 -0
- package/dist/components/reui/color-picker.d.ts.map +1 -0
- package/dist/components/reui/color-picker.js +2013 -0
- package/dist/components/reui/color-picker.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -0
- package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts +6 -8
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +50 -29
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +2 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +10 -3
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +15 -10
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +54 -14
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +37 -42
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +174 -16
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +223 -89
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +55 -1
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +112 -22
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.d.ts +1 -0
- package/dist/components/reui/date-selector.d.ts.map +1 -1
- package/dist/components/reui/date-selector.js +22 -16
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/emoji-picker.d.ts +367 -0
- package/dist/components/reui/emoji-picker.d.ts.map +1 -0
- package/dist/components/reui/emoji-picker.js +1768 -0
- package/dist/components/reui/emoji-picker.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +3 -5
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +4 -4
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +34 -31
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/file-type.d.ts +792 -0
- package/dist/components/reui/file-type.d.ts.map +1 -0
- package/dist/components/reui/file-type.js +1367 -0
- package/dist/components/reui/file-type.js.map +1 -0
- package/dist/components/reui/filters/filters-advanced.d.ts +1 -0
- package/dist/components/reui/filters/filters-advanced.js +1 -1
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.d.ts +1 -1
- package/dist/components/reui/filters/filters-chip.d.ts +5 -1
- package/dist/components/reui/filters/filters-chip.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts.map +1 -1
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +4 -4
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt.js +5 -2
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/reui/icon-tile.js +8 -7
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +1 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts.map +1 -1
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/phone-input.js +30 -27
- package/dist/components/reui/phone-input.js.map +1 -1
- package/dist/components/reui/scrollspy.d.ts +1 -0
- package/dist/components/reui/time-picker.js +1 -1
- package/dist/components/reui/time-picker.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/code-block.d.ts +29 -0
- package/dist/components/ui/code-block.d.ts.map +1 -0
- package/dist/components/ui/code-block.js +124 -0
- package/dist/components/ui/code-block.js.map +1 -0
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/direction.js +1 -2
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/message-scroller.d.ts.map +1 -1
- package/dist/components/ui/questionnaire.d.ts.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/trace.d.ts +21 -0
- package/dist/components/ui/trace.d.ts.map +1 -0
- package/dist/components/ui/trace.js +77 -0
- package/dist/components/ui/trace.js.map +1 -0
- package/dist/context-BYXeJQnz.d.ts.map +1 -1
- package/dist/context-tTdLKYNf.js +99 -0
- package/dist/context-tTdLKYNf.js.map +1 -0
- package/dist/{copy-menu-C5GaT4Z-.js → copy-menu-DOg9Jh-U.js} +2 -2
- package/dist/{copy-menu-C5GaT4Z-.js.map → copy-menu-DOg9Jh-U.js.map} +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +1 -0
- package/dist/hooks/use-focus-trap.d.ts +22 -0
- package/dist/hooks/use-focus-trap.d.ts.map +1 -0
- package/dist/hooks/use-focus-trap.js +80 -0
- package/dist/hooks/use-focus-trap.js.map +1 -0
- package/dist/hooks/use-highlighted-code.d.ts +5 -0
- package/dist/hooks/use-highlighted-code.d.ts.map +1 -0
- package/dist/hooks/use-highlighted-code.js +128 -0
- package/dist/hooks/use-highlighted-code.js.map +1 -0
- package/dist/hooks/use-hover-gesture.d.ts +1 -0
- package/dist/hooks/use-intersection-observer.d.ts +1 -0
- package/dist/hooks/use-listbox.d.ts +29 -0
- package/dist/hooks/use-listbox.d.ts.map +1 -0
- package/dist/hooks/use-listbox.js +75 -0
- package/dist/hooks/use-listbox.js.map +1 -0
- package/dist/hooks/use-scroll-position.d.ts +1 -0
- package/dist/hooks/use-slider-input.d.ts +1 -0
- package/dist/hooks/use-viewport.d.ts +1 -0
- package/dist/lib/tick-sound.d.ts +1 -0
- package/dist/model-NSIg2p7a.d.ts +20 -0
- package/dist/model-NSIg2p7a.d.ts.map +1 -0
- package/dist/model-_mRyI6V9.d.ts +18 -0
- package/dist/model-_mRyI6V9.d.ts.map +1 -0
- package/dist/{positioner-3mCqiebN.js → positioner-3r3cfkqT.js} +97 -33
- package/dist/positioner-3r3cfkqT.js.map +1 -0
- package/dist/tooltip-Bam5KeYe.js +535 -0
- package/dist/tooltip-Bam5KeYe.js.map +1 -0
- package/dist/tooltip-C01qUgsW.d.ts.map +1 -1
- package/dist/use-position-DOi1gVL0.d.ts +32 -0
- package/dist/use-position-DOi1gVL0.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/cascader-types-DVT-znZ-.d.ts.map +0 -1
- package/dist/components/motion/tooltip.js.map +0 -1
- package/dist/model-DfeFradZ.d.ts +0 -9
- package/dist/model-DfeFradZ.d.ts.map +0 -1
- package/dist/positioner-3mCqiebN.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"morphing-search-chips.js","names":[],"sources":["../../../src/components/motion/morphing-search-chips.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type KeyboardEvent as ReactKeyboardEvent,\n type ReactNode,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Clock, LoaderCircle, Search, X } from \"lucide-react\";\nimport { AnimatePresence, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useDismiss } from \"../../hooks/use-dismiss\";\nimport { useOnOpen } from \"../../hooks/use-on-open\";\nimport { useRowCursor } from \"../../hooks/use-row-cursor\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\n// The panel's glass grows out of the bar on a spring with a little give: the\n// shared tokens are critically damped, and this one is meant to land with a\n// soft overshoot, so it stays local. It folds back faster than it grew.\nconst SPRING_MORPH = { type: \"spring\", stiffness: 380, damping: 28, mass: 0.8 } as const;\nconst MORPH_ENTER: Transition = { ...SPRING_MORPH, opacity: { duration: 0.1 } };\nconst MORPH_EXIT: Transition = {\n type: \"spring\",\n stiffness: 520,\n damping: 40,\n mass: 0.6,\n opacity: { duration: 0.12, delay: 0.1 },\n};\n// The pill the panel starts from and returns to: centred, and tucked halfway\n// behind the bar (across the 8px gap) so it emerges from the bar's edge.\nconst SEED = { width: 112, height: 40 };\nconst SEED_TUCK = 28;\n// Content fades in once the shape has mostly arrived and leaves before it goes.\nconst CONTENT_IN: Transition = { duration: 0.18, ease: EASE_OUT, delay: 0.12 };\nconst CONTENT_OUT: Transition = { duration: 0.08, ease: EASE_OUT };\n// Glass: a thin tint of the page colour over a saturated blur, a hairline edge,\n// a top highlight and a soft drop. Written inline so the install carries it\n// without the site's stylesheet.\nconst GLASS =\n \"border border-foreground/[0.08] bg-background/55 backdrop-blur-[20px] backdrop-saturate-[1.6] shadow-[inset_0_1px_0_0_rgb(255_255_255/0.06),0_24px_60px_-24px_rgb(0_0_0/0.45)]\";\n// Chips arrive on a soft spring with a touch of blur and leave on a short tween,\n// faster than they came.\nconst CHIP_HIDDEN = { opacity: 0, scale: 0.6, filter: \"blur(4px)\" };\nconst CHIP_SHOWN = { opacity: 1, scale: 1, filter: \"blur(0px)\" };\nconst CHIP_ENTER: Transition = {\n ...SPRING_SWAP,\n opacity: { duration: 0.16 },\n filter: { duration: 0.2 },\n};\nconst CHIP_EXIT: Transition = { duration: 0.16, ease: EASE_OUT };\n// Half the 56px bar: a pill, and the panel shares its corners.\nconst SURFACE_RADIUS = 28;\n// Room the panel wants above the bar before \"auto\" sends it below instead.\nconst PANEL_ROOM = 320;\n\ntype Row = { id: string; label: string; kind: \"query\" | \"recent\" | \"suggestion\" };\ntype Side = \"top\" | \"bottom\";\n\nexport interface MorphingSearchChipsProps {\n /** Active filters shown as chips inside the bar. */\n chips?: string[];\n defaultChips?: string[];\n onChipsChange?: (chips: string[]) => void;\n /** Text in the field. */\n query?: string;\n defaultQuery?: string;\n onQueryChange?: (query: string) => void;\n /** Recent searches, newest first. */\n recents?: string[];\n defaultRecents?: string[];\n onRecentsChange?: (recents: string[]) => void;\n /** Persist uncontrolled recents in localStorage under this key. */\n storageKey?: string;\n /** How many recent searches to keep. Default 5. */\n maxRecents?: number;\n /** Terms offered while typing. */\n suggestions?: string[];\n /**\n * How suggestions match the query. Default: case-insensitive substring.\n * Pass `false` when `suggestions` already arrive filtered, e.g. from a server.\n */\n filter?: ((term: string, query: string) => boolean) | false;\n /** How many matches to list under the typed query. Default 6. */\n maxSuggestions?: number;\n /** Suggestions are being fetched. */\n loading?: boolean;\n /** Most chips allowed at once. */\n maxChips?: number;\n /** Clean a term before it becomes a chip; return null to reject it. */\n normalize?: (term: string) => string | null;\n /** Shown when the field is empty and there are no recent searches. */\n emptyState?: ReactNode;\n /** Which way the surface grows. \"auto\" grows up unless there is no room. Default \"top\". */\n side?: \"top\" | \"bottom\" | \"auto\";\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n /** Submit each chip with a form under this name. */\n name?: string;\n placeholder?: string;\n /** Accessible name for the search field. */\n label?: string;\n /** Trailing controls inside the bar, such as filter buttons. */\n actions?: ReactNode;\n className?: string;\n}\n\nfunction useControllable<T>(value: T | undefined, initial: T, onChange?: (next: T) => void) {\n const [internal, setInternal] = useState(initial);\n const current = value ?? internal;\n const set = useCallback(\n (next: T) => {\n if (value === undefined) setInternal(next);\n onChange?.(next);\n },\n [value, onChange],\n );\n return [current, set, setInternal] as const;\n}\n\nconst sameTerm = (a: string, b: string) => a.trim().toLowerCase() === b.trim().toLowerCase();\nconst contains = (term: string, query: string) => term.toLowerCase().includes(query.toLowerCase());\n\nfunction Highlight({ text, query }: { text: string; query: string }) {\n const at = query ? text.toLowerCase().indexOf(query.toLowerCase()) : -1;\n if (at < 0) return text;\n return (\n <>\n {text.slice(0, at)}\n <span className=\"font-semibold\">{text.slice(at, at + query.length)}</span>\n {text.slice(at + query.length)}\n </>\n );\n}\n\nexport function MorphingSearchChips({\n chips: chipsProp,\n defaultChips = [],\n onChipsChange,\n query: queryProp,\n defaultQuery = \"\",\n onQueryChange,\n recents: recentsProp,\n defaultRecents = [],\n onRecentsChange,\n storageKey,\n maxRecents = 5,\n suggestions = [],\n filter,\n maxSuggestions = 6,\n loading = false,\n maxChips,\n normalize,\n emptyState,\n side = \"top\",\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n disabled = false,\n name,\n placeholder = \"Search\",\n label = \"Search\",\n actions,\n className,\n}: MorphingSearchChipsProps) {\n const reduce = useReducedMotion();\n const [chips, setChips] = useControllable(chipsProp, defaultChips, onChipsChange);\n const [query, setQuery] = useControllable(queryProp, defaultQuery, onQueryChange);\n const [recents, setRecentsState, setStoredRecents] = useControllable(\n recentsProp,\n defaultRecents,\n onRecentsChange,\n );\n const [openState, setOpen] = useControllable(openProp, defaultOpen, onOpenChange);\n const open = openState && !disabled;\n const [announcement, setAnnouncement] = useState({ text: \"\", count: 0 });\n const [markedChip, setMarkedChip] = useState<string | null>(null);\n const [placed, setPlaced] = useState<Side>(side === \"bottom\" ? \"bottom\" : \"top\");\n const [rtl, setRtl] = useState(false);\n const rootRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const chipsRef = useRef<HTMLDivElement>(null);\n const id = useId();\n const listId = `${id}-list`;\n const hintId = `${id}-hint`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n // The same message twice is still news; the count makes each one a change.\n const announce = useCallback(\n (text: string) => setAnnouncement((current) => ({ text, count: current.count + 1 })),\n [],\n );\n\n // A chip the keyboard has marked for removal, held by identity. Cleared rather\n // than ignored once it leaves, so the same term added back is not born marked.\n const marked = markedChip !== null && chips.includes(markedChip) ? markedChip : null;\n if (markedChip !== null && marked === null) setMarkedChip(null);\n\n // The glass grows toward the measured size of the panel's content.\n const [panelSize, setPanelSize] = useState({ width: 0, height: 0 });\n const panelObserver = useRef<ResizeObserver | null>(null);\n const measurePanel = useCallback((node: HTMLDivElement | null) => {\n panelObserver.current?.disconnect();\n panelObserver.current = null;\n if (!node) return;\n const read = () => setPanelSize({ width: node.offsetWidth, height: node.offsetHeight });\n read();\n panelObserver.current = new ResizeObserver(read);\n panelObserver.current.observe(node);\n }, []);\n\n const chipsLatest = useRef(chips);\n useLayoutEffect(() => {\n chipsLatest.current = chips;\n });\n\n // Direction decides which way chips unroll and which arrow walks back into them.\n useLayoutEffect(() => {\n if (rootRef.current) setRtl(getComputedStyle(rootRef.current).direction === \"rtl\");\n }, []);\n\n // Recents persist only when the component owns them.\n const persist = storageKey && recentsProp === undefined ? storageKey : null;\n useEffect(() => {\n if (!persist) return;\n try {\n const stored = JSON.parse(window.localStorage.getItem(persist) ?? \"null\");\n if (Array.isArray(stored)) {\n setStoredRecents(\n stored.filter((term): term is string => typeof term === \"string\").slice(0, maxRecents),\n );\n }\n } catch {\n // Storage can be blocked or hold something else; recents simply start empty.\n }\n }, [persist, maxRecents, setStoredRecents]);\n\n const setRecents = (next: string[]) => {\n setRecentsState(next);\n if (!persist) return;\n try {\n window.localStorage.setItem(persist, JSON.stringify(next));\n } catch {\n // A full or blocked store keeps this session's recents in memory only.\n }\n };\n\n const trimmed = query.trim();\n const rows = useMemo<Row[]>(() => {\n if (!trimmed) {\n return recents.map((term) => ({ id: `recent:${term}`, label: term, kind: \"recent\" }));\n }\n const seen = new Set([trimmed.toLowerCase(), ...chips.map((chip) => chip.toLowerCase())]);\n const matches: Row[] = [];\n const pools = [\n [\"recent\", recents, contains],\n [\"suggestion\", suggestions, filter === false ? () => true : (filter ?? contains)],\n ] as const;\n for (const [kind, pool, matchFn] of pools) {\n for (const term of pool) {\n const key = term.toLowerCase();\n if (seen.has(key) || !matchFn(term, trimmed)) continue;\n seen.add(key);\n matches.push({ id: `${kind}:${term}`, label: term, kind });\n }\n }\n return [\n { id: `query:${trimmed}`, label: trimmed, kind: \"query\" },\n ...matches.slice(0, maxSuggestions),\n ];\n }, [trimmed, recents, suggestions, chips, filter, maxSuggestions]);\n\n const { activeIndex, moveTo, moveActive } = useRowCursor(rows, trimmed);\n const active = rows[activeIndex];\n const showList = rows.length > 0;\n // Nothing to say means nothing to grow for: the bar still widens on focus.\n const hasPanel = showList || loading || (!trimmed && emptyState != null);\n const panelOpen = open && hasPanel;\n\n // A fresh session each time the panel opens: the highlight starts at the top.\n useOnOpen(open, () => moveTo(null));\n\n // The tallest the panel has been since it opened. Typing can grow the card but\n // never shrink it; each new session starts from its own content again.\n const [panelFloor, setPanelFloor] = useState(0);\n useOnOpen(panelOpen, () => setPanelFloor(0));\n const rowsObserver = useRef<ResizeObserver | null>(null);\n const measureRows = useCallback((node: HTMLDivElement | null) => {\n rowsObserver.current?.disconnect();\n rowsObserver.current = null;\n if (!node) return;\n // The wrapper's p-2 adds 16px around the rows.\n const read = () => setPanelFloor((floor) => Math.max(floor, node.offsetHeight + 16));\n read();\n rowsObserver.current = new ResizeObserver(read);\n rowsObserver.current.observe(node);\n }, []);\n\n // \"auto\" picks a side as the panel opens and keeps it until it closes.\n useLayoutEffect(() => {\n if (!panelOpen) return;\n if (side !== \"auto\") {\n setPlaced(side);\n return;\n }\n const rect = rootRef.current?.getBoundingClientRect();\n if (!rect) return;\n const above = rect.top;\n const below = window.innerHeight - rect.bottom;\n setPlaced(above < PANEL_ROOM && below > above ? \"bottom\" : \"top\");\n }, [panelOpen, side]);\n\n // Arrow keys can walk past the visible rows of a capped list.\n const activeOptionId = panelOpen && showList ? optionId(activeIndex) : undefined;\n useEffect(() => {\n if (activeOptionId)\n document.getElementById(activeOptionId)?.scrollIntoView({ block: \"nearest\" });\n }, [activeOptionId]);\n\n const close = useCallback(() => setOpen(false), [setOpen]);\n useDismiss(open, close, rootRef);\n\n // A chip added past the visible edge of a crowded row scrolls into view.\n const chipCount = useRef(chips.length);\n useEffect(() => {\n const row = chipsRef.current;\n const added = chips.length > chipCount.current;\n chipCount.current = chips.length;\n if (!row || !added || row.scrollWidth <= row.clientWidth) return;\n row.scrollTo({\n left: rtl ? -row.scrollWidth : row.scrollWidth,\n behavior: reduce ? \"auto\" : \"smooth\",\n });\n }, [chips.length, reduce, rtl]);\n\n const full = maxChips !== undefined && chips.length >= maxChips;\n\n const addChip = (term: string) => {\n const value = normalize ? normalize(term) : term.trim();\n if (!value) return;\n const exists = chips.some((chip) => sameTerm(chip, value));\n if (!exists && full) {\n announce(`Up to ${maxChips} filters`);\n return;\n }\n if (!exists) {\n setChips([...chips, value]);\n announce(`Added filter ${value}`);\n }\n setRecents(\n [value, ...recents.filter((recent) => !sameTerm(recent, value))].slice(0, maxRecents),\n );\n setQuery(\"\");\n };\n\n const removeChip = (term: string) => {\n setChips(chips.filter((chip) => chip !== term));\n announce(`Removed filter ${term}`);\n inputRef.current?.focus();\n };\n\n const removeRecent = (term: string) => {\n setRecents(recents.filter((recent) => recent !== term));\n announce(`Removed ${term} from recent searches`);\n };\n\n // Steps the marked chip from the one it is on now, inside the update, so two\n // presses in one batch move two chips.\n const stepMark = (direction: 1 | -1) =>\n setMarkedChip((current) => {\n const list = chipsLatest.current;\n if (list.length === 0) return null;\n const at = current === null ? list.length : list.indexOf(current);\n const next = at + direction;\n if (next >= list.length) return null;\n return list[Math.max(next, 0)];\n });\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLInputElement>) => {\n // An input method is still composing; Enter and arrows belong to it.\n if (event.nativeEvent.isComposing || event.keyCode === 229) return;\n const field = event.currentTarget;\n const atStart = field.selectionStart === 0 && field.selectionEnd === 0;\n const back = rtl ? \"ArrowRight\" : \"ArrowLeft\";\n const forward = rtl ? \"ArrowLeft\" : \"ArrowRight\";\n\n if (marked !== null) {\n if (event.key === \"Backspace\" || event.key === \"Delete\") {\n event.preventDefault();\n setMarkedChip(null);\n removeChip(marked);\n return;\n }\n if (event.key === back || event.key === forward) {\n event.preventDefault();\n stepMark(event.key === back ? -1 : 1);\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n setMarkedChip(null);\n return;\n }\n setMarkedChip(null);\n }\n\n if (event.key === \"Escape\" && query !== \"\") {\n // Clear before closing: one press undoes typing, the next leaves.\n event.preventDefault();\n event.stopPropagation();\n setQuery(\"\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n if (!open) setOpen(true);\n else moveActive(event.key === \"ArrowDown\" ? 1 : -1);\n return;\n }\n if (event.key === \"Enter\") {\n if (!panelOpen || !active) return;\n event.preventDefault();\n addChip(active.label);\n return;\n }\n if (event.key === \"Delete\" && panelOpen && active?.kind === \"recent\") {\n event.preventDefault();\n removeRecent(active.label);\n return;\n }\n if (event.key === \"Backspace\" && atStart && chips.length > 0) {\n // Mark first, remove on the second press: one stray key never loses a filter.\n event.preventDefault();\n const last = chips[chips.length - 1];\n setMarkedChip(last);\n announce(`${last} selected. Press Backspace again to remove it.`);\n return;\n }\n if (event.key === back && atStart && chips.length > 0) {\n event.preventDefault();\n stepMark(-1);\n }\n };\n\n // A press anywhere on the bar that is not its own control lands in the field.\n const focusField = (event: ReactPointerEvent) => {\n if (disabled || (event.target as Element).closest(\"button, input, a\")) return;\n event.preventDefault();\n inputRef.current?.focus();\n setOpen(true);\n };\n\n const layout = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const below = placed === \"bottom\";\n const seed = { ...SEED, y: below ? -SEED_TUCK : SEED_TUCK };\n\n const panel = (\n <>\n <div className=\"flex h-9 items-center justify-between px-3\">\n <span className=\"font-medium text-muted-foreground text-xs\">\n {trimmed ? \"Suggestions\" : \"Recent\"}\n </span>\n {!trimmed && recents.length > 0 ? (\n <button\n type=\"button\"\n onClick={() => {\n setRecents([]);\n announce(\"Cleared recent searches\");\n inputRef.current?.focus();\n }}\n className=\"rounded-md px-1.5 py-0.5 text-muted-foreground text-xs outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n >\n Clear\n </button>\n ) : null}\n </div>\n {showList ? (\n <div\n id={listId}\n role=\"listbox\"\n aria-label={trimmed ? \"Suggestions\" : \"Recent searches\"}\n aria-busy={loading || undefined}\n className=\"max-h-[min(20rem,45vh)] overflow-y-auto overscroll-contain [scrollbar-width:thin]\"\n >\n {rows.map((row, index) => {\n const selected = index === activeIndex;\n return (\n // Options are driven from the combobox field (arrows, Enter) and\n // never take focus themselves, as aria-activedescendant expects.\n <motion.div\n key={row.id}\n id={optionId(index)}\n role=\"option\"\n aria-selected={selected}\n onPointerDown={(event) => event.preventDefault()}\n onPointerMove={() => moveTo(row.id)}\n onClick={() => addChip(row.label)}\n className=\"relative flex h-11 cursor-pointer items-center gap-3 rounded-2xl px-3 text-foreground text-sm\"\n >\n {selected ? (\n <motion.span\n layoutId={`${id}-active`}\n transition={layout}\n className=\"absolute inset-0 rounded-2xl bg-foreground/6\"\n />\n ) : null}\n {row.kind === \"recent\" ? (\n <Clock\n aria-hidden=\"true\"\n className=\"relative size-4 shrink-0 text-muted-foreground\"\n />\n ) : (\n <Search\n aria-hidden=\"true\"\n className=\"relative size-4 shrink-0 text-muted-foreground\"\n />\n )}\n <span className=\"relative min-w-0 flex-1 truncate\">\n {row.kind === \"query\" ? (\n row.label\n ) : (\n <Highlight text={row.label} query={trimmed} />\n )}\n </span>\n {row.kind === \"recent\" ? (\n // Pointer shortcut only: the option cannot hold a second control,\n // and Delete removes the highlighted recent from the keyboard.\n <span\n aria-hidden=\"true\"\n onClick={(event) => {\n event.stopPropagation();\n removeRecent(row.label);\n }}\n className=\"relative grid size-7 shrink-0 place-items-center rounded-full text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground\"\n >\n <X className=\"size-3.5\" />\n </span>\n ) : null}\n </motion.div>\n );\n })}\n </div>\n ) : !trimmed && emptyState != null ? (\n <div className=\"px-3 pt-1 pb-2 text-muted-foreground text-sm\">{emptyState}</div>\n ) : null}\n {loading ? (\n <div className=\"flex h-11 items-center gap-3 px-3 text-muted-foreground text-sm\">\n <LoaderCircle aria-hidden=\"true\" className=\"size-4 motion-safe:animate-spin\" />\n Searching…\n </div>\n ) : null}\n </>\n );\n\n return (\n // The root keeps the bar's footprint; the panel floats over the page beside it.\n <div\n ref={rootRef}\n className={cn(\n \"relative flex h-14 w-full max-w-xl justify-center\",\n disabled && \"opacity-60\",\n className,\n )}\n onBlur={(event) => {\n if (rootRef.current?.contains(event.relatedTarget as Node | null)) return;\n setMarkedChip(null);\n close();\n }}\n >\n <AnimatePresence>\n {panelOpen ? (\n <PresenceGate key=\"panel\">\n {({ gate }) => (\n <div\n {...gate}\n className={cn(\n \"absolute inset-x-0 z-10\",\n below ? \"top-full mt-2\" : \"bottom-full mb-2\",\n )}\n >\n {/* The card's glass starts as a small pill on the bar's edge and\n springs out to the size of what it holds, then back on close.\n Width and height animate rather than scale so the corners stay\n true; the layer is absolute and decorative, so nothing reflows. */}\n <motion.div\n aria-hidden=\"true\"\n initial={reduce ? { opacity: 0 } : { ...seed, opacity: 0 }}\n animate={{\n width: panelSize.width || SEED.width,\n height: panelSize.height || SEED.height,\n y: 0,\n opacity: 1,\n }}\n exit={\n reduce\n ? { opacity: 0, transition: { duration: 0.12 } }\n : { ...seed, opacity: 0, transition: MORPH_EXIT }\n }\n transition={reduce ? { duration: 0 } : MORPH_ENTER}\n style={{ borderRadius: SURFACE_RADIUS, x: \"-50%\" }}\n className={cn(\"absolute left-1/2\", below ? \"top-0\" : \"bottom-0\", GLASS)}\n />\n {/* Content waits for the shape to arrive and leaves before it goes. */}\n <motion.div\n initial={{ opacity: 0, y: reduce ? 0 : below ? -6 : 6 }}\n animate={{\n opacity: 1,\n y: 0,\n transition: reduce ? { duration: 0.15 } : CONTENT_IN,\n }}\n exit={{ opacity: 0, transition: CONTENT_OUT }}\n ref={measurePanel}\n // Never shorter than this session's tallest list, so narrowing a\n // search leaves empty glass instead of pulling the card down.\n style={{ minHeight: panelFloor || undefined }}\n className=\"relative p-2\"\n >\n <div ref={measureRows}>{panel}</div>\n </motion.div>\n </div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n\n <motion.div\n layout\n transition={layout}\n onPointerDown={focusField}\n style={{ borderRadius: SURFACE_RADIUS }}\n className={cn(\n // Raised over the panel so the growing shape emerges from behind it.\n \"relative z-20 flex h-14 min-w-0 items-center gap-2 ps-4\",\n GLASS,\n disabled ? \"cursor-not-allowed\" : \"cursor-text\",\n // Trailing buttons carry their own inset; bare text needs the full one.\n actions ? \"pe-2\" : \"pe-4\",\n open ? \"w-full\" : \"w-fit max-w-full\",\n )}\n >\n <Search aria-hidden=\"true\" className=\"size-5 shrink-0 text-muted-foreground\" />\n <div\n ref={chipsRef}\n // The padding at each end is where a scrolled chip fades out; with\n // nothing scrolled under it the padding is empty, so the fade is\n // invisible. Relative, so a leaving chip popped out of flow stays\n // inside the scrolling row.\n className={cn(\n \"relative flex min-w-0 items-center gap-1.5 overflow-x-auto [scrollbar-width:none]\",\n chips.length > 0 &&\n \"mask-[linear-gradient(to_right,transparent,#000_12px,#000_calc(100%-12px),transparent)] -mx-1.5 px-3\",\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {chips.map((chip) => (\n <motion.span\n key={chip}\n layout={reduce ? false : \"position\"}\n initial={reduce ? { opacity: 0 } : CHIP_HIDDEN}\n animate={reduce ? { opacity: 1 } : CHIP_SHOWN}\n exit={\n reduce\n ? { opacity: 0, transition: { duration: 0.1 } }\n : { ...CHIP_HIDDEN, transition: CHIP_EXIT }\n }\n transition={reduce ? { duration: 0.12 } : CHIP_ENTER}\n // Grown from and folded back into the edge it is attached to, so a\n // chip reads as unrolling out of the one before it.\n style={{ transformOrigin: rtl ? \"right center\" : \"left center\" }}\n className={cn(\n \"flex h-9 shrink-0 items-center gap-1 rounded-full ps-3 pe-1 text-foreground text-sm transition-[background-color,box-shadow] duration-150\",\n marked === chip\n ? // Inset: the chip fills its scrolling row, which clips anything drawn outside it.\n \"bg-foreground/12 ring-2 ring-foreground/40 ring-inset\"\n : \"bg-foreground/[0.07]\",\n )}\n >\n <span className=\"max-w-40 truncate\" title={chip}>\n {chip}\n </span>\n <button\n type=\"button\"\n disabled={disabled}\n aria-label={`Remove filter ${chip}`}\n onClick={() => removeChip(chip)}\n className=\"grid size-7 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none\"\n >\n <X aria-hidden=\"true\" className=\"size-3.5\" />\n </button>\n </motion.span>\n ))}\n </AnimatePresence>\n </div>\n <motion.input\n ref={inputRef}\n // Glides aside as chips arrive and back as they leave.\n layout={reduce ? false : \"position\"}\n transition={layout}\n type=\"text\"\n role=\"combobox\"\n aria-label={label}\n aria-expanded={panelOpen}\n aria-controls={panelOpen && showList ? listId : undefined}\n aria-autocomplete=\"list\"\n aria-activedescendant={activeOptionId}\n aria-describedby={hintId}\n autoComplete=\"off\"\n spellCheck={false}\n enterKeyHint=\"search\"\n disabled={disabled}\n value={query}\n placeholder={placeholder}\n onChange={(event) => {\n setQuery(event.target.value);\n if (!open) setOpen(true);\n }}\n onFocus={() => setOpen(true)}\n // Escape closes the panel but leaves focus here; a click brings it back.\n onClick={() => setOpen(true)}\n onKeyDown={onKeyDown}\n // At rest the field is as wide as its placeholder, so the bar hugs its content.\n style={open ? undefined : { width: `${Math.max(placeholder.length, 6) + 2}ch` }}\n className={cn(\n // On a narrow screen the chips scroll first; the field keeps room to type.\n \"h-9 min-w-24 text-ellipsis bg-transparent text-base text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed\",\n open && \"flex-1\",\n )}\n />\n {actions ? <div className=\"flex shrink-0 items-center gap-1\">{actions}</div> : null}\n </motion.div>\n\n {name\n ? chips.map((chip) => <input key={chip} type=\"hidden\" name={name} value={chip} />)\n : null}\n <span id={hintId} className=\"sr-only\">\n Enter adds a filter. Backspace at the start of the field selects the last filter, and again\n removes it. Delete removes the highlighted recent search.\n </span>\n <span aria-live=\"polite\" className=\"sr-only\">\n {announcement.text}\n {/* Alternates an invisible character so a repeated message still changes. */}\n {announcement.count % 2 ? \" \" : \"\"}\n </span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,MAAM,cAA0B;CADT,MAAM;CAAU,WAAW;CAAK,SAAS;CAAI,MAAM;CACvB,SAAS,EAAE,UAAU,GAAI;AAAE;AAC9E,MAAM,aAAyB;CAC7B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;CACN,SAAS;EAAE,UAAU;EAAM,OAAO;CAAI;AACxC;AAGA,MAA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@kumix/utils";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
|
|
9
|
-
import { Search } from "lucide-react";
|
|
10
9
|
import { createPortal } from "react-dom";
|
|
10
|
+
import { Search } from "lucide-react";
|
|
11
11
|
//#region src/components/motion/morphing-search.tsx
|
|
12
12
|
const SEARCH_MORPH = {
|
|
13
13
|
type: "spring",
|
|
@@ -5,8 +5,8 @@ import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useSta
|
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useSpring, useTransform } from "motion/react";
|
|
8
|
-
import { X } from "lucide-react";
|
|
9
8
|
import { createPortal } from "react-dom";
|
|
9
|
+
import { X } from "lucide-react";
|
|
10
10
|
//#region src/components/motion/morphing-tabs.tsx
|
|
11
11
|
const DRAG_THRESHOLD = 5;
|
|
12
12
|
const MAX_TAB_WIDTH = 176;
|
|
@@ -12,4 +12,5 @@ export interface MultiSelectContentProps {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function MultiSelectContent({ children, side, align, sideOffset, avoidCollisions, className }: MultiSelectContentProps): import("react").ReactPortal | null;
|
|
14
14
|
//#endregion
|
|
15
|
+
export {};
|
|
15
16
|
//# sourceMappingURL=content.d.ts.map
|
|
@@ -3,6 +3,11 @@ export interface NumberTickerProps {
|
|
|
3
3
|
value: number;
|
|
4
4
|
/** Digits to pad to (left). */
|
|
5
5
|
pad?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Fraction digits to keep. The value is rounded to this many places before
|
|
8
|
+
* `format` runs (default 0, whole numbers).
|
|
9
|
+
*/
|
|
10
|
+
decimals?: number;
|
|
6
11
|
/** Per-digit roll duration in seconds. */
|
|
7
12
|
duration?: number;
|
|
8
13
|
/** Stagger between digits. */
|
|
@@ -20,6 +25,6 @@ export interface NumberTickerProps {
|
|
|
20
25
|
/** Custom formatter. Client-only — server components must use `locale` instead. */
|
|
21
26
|
format?: (value: number) => string;
|
|
22
27
|
}
|
|
23
|
-
export declare function NumberTicker({ value, pad, duration, stagger, startOnView, prefix, suffix, blur, className, digitClassName, locale, format }: NumberTickerProps): import("react").JSX.Element;
|
|
28
|
+
export declare function NumberTicker({ value, pad, decimals, duration, stagger, startOnView, prefix, suffix, blur, className, digitClassName, locale, format }: NumberTickerProps): import("react").JSX.Element;
|
|
24
29
|
//#endregion
|
|
25
30
|
//# sourceMappingURL=number-ticker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-ticker.d.ts","names":[],"sources":["../../../src/components/motion/number-ticker.tsx"],"mappings":";iBAQiB;EACf;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;EAEA,UAAU;;wBAMI,eACd,OACA,KACA,UACA,SACA,aACA,QACA,QACA,MACA,WACA,gBACA,QACA,UACC,oCAAiB,IAAA"}
|
|
1
|
+
{"version":3,"file":"number-ticker.d.ts","names":[],"sources":["../../../src/components/motion/number-ticker.tsx"],"mappings":";iBAQiB;EACf;;EAEA;;;;;EAKA;;EAEA;;EAEA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;EAEA,UAAU;;wBAMI,eACd,OACA,KACA,UACA,UACA,SACA,aACA,QACA,QACA,MACA,WACA,gBACA,QACA,UACC,oCAAiB,IAAA"}
|
|
@@ -7,7 +7,7 @@ import { animate, motion, useInView, useReducedMotion } from "motion/react";
|
|
|
7
7
|
//#region src/components/motion/number-ticker.tsx
|
|
8
8
|
const DIGIT_HEIGHT_EM = 1.1;
|
|
9
9
|
const DIGITS = Array.from({ length: 10 }, (_, n) => n);
|
|
10
|
-
function NumberTicker({ value, pad, duration = .9, stagger = .04, startOnView = true, prefix, suffix, blur = false, className, digitClassName, locale, format }) {
|
|
10
|
+
function NumberTicker({ value, pad, decimals = 0, duration = .9, stagger = .04, startOnView = true, prefix, suffix, blur = false, className, digitClassName, locale, format }) {
|
|
11
11
|
const containerRef = useRef(null);
|
|
12
12
|
const inView = useInView(containerRef, {
|
|
13
13
|
once: true,
|
|
@@ -18,12 +18,18 @@ function NumberTicker({ value, pad, duration = .9, stagger = .04, startOnView =
|
|
|
18
18
|
if (startOnView && inView) setArmed(true);
|
|
19
19
|
}, [startOnView, inView]);
|
|
20
20
|
const text = useMemo(() => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const places = Math.max(0, Math.floor(decimals));
|
|
22
|
+
const factor = 10 ** places;
|
|
23
|
+
const rounded = Math.round(value * factor) / factor;
|
|
24
|
+
const formatted = format ? format(rounded) : locale ? rounded.toLocaleString(void 0, {
|
|
25
|
+
minimumFractionDigits: places,
|
|
26
|
+
maximumFractionDigits: places
|
|
27
|
+
}) : rounded.toFixed(places);
|
|
23
28
|
return pad ? formatted.padStart(pad, "0") : formatted;
|
|
24
29
|
}, [
|
|
25
30
|
value,
|
|
26
31
|
pad,
|
|
32
|
+
decimals,
|
|
27
33
|
format,
|
|
28
34
|
locale
|
|
29
35
|
]);
|
|
@@ -50,13 +56,13 @@ function NumberTicker({ value, pad, duration = .9, stagger = .04, startOnView =
|
|
|
50
56
|
]);
|
|
51
57
|
return /* @__PURE__ */ jsxs("span", {
|
|
52
58
|
ref: containerRef,
|
|
53
|
-
className: cn("inline-flex items-
|
|
59
|
+
className: cn("inline-flex items-baseline tabular-nums", className),
|
|
54
60
|
children: [/* @__PURE__ */ jsx("span", {
|
|
55
61
|
className: "sr-only",
|
|
56
62
|
children: readableText
|
|
57
63
|
}), /* @__PURE__ */ jsxs("span", {
|
|
58
64
|
"aria-hidden": "true",
|
|
59
|
-
className: "inline-flex items-
|
|
65
|
+
className: "inline-flex items-baseline",
|
|
60
66
|
children: [
|
|
61
67
|
prefix ? /* @__PURE__ */ jsx("span", { children: prefix }) : null,
|
|
62
68
|
glyphs.map(({ char, id }, i) => {
|
|
@@ -100,13 +106,17 @@ function Digit({ digit, delay, duration, blur, className }) {
|
|
|
100
106
|
duration,
|
|
101
107
|
reduce
|
|
102
108
|
]);
|
|
103
|
-
return /* @__PURE__ */
|
|
104
|
-
className: cn("relative inline-block
|
|
109
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
110
|
+
className: cn("relative inline-block text-center [clip-path:inset(0)]", className),
|
|
105
111
|
style: {
|
|
106
112
|
height: `${DIGIT_HEIGHT_EM}em`,
|
|
113
|
+
lineHeight: `${DIGIT_HEIGHT_EM}em`,
|
|
107
114
|
width: "1ch"
|
|
108
115
|
},
|
|
109
|
-
children: /* @__PURE__ */ jsx(
|
|
116
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
117
|
+
className: "invisible",
|
|
118
|
+
children: digit
|
|
119
|
+
}), /* @__PURE__ */ jsx(motion.span, {
|
|
110
120
|
ref: columnRef,
|
|
111
121
|
initial: { y: 0 },
|
|
112
122
|
animate: { y: `-${digit * DIGIT_HEIGHT_EM}em` },
|
|
@@ -120,7 +130,7 @@ function Digit({ digit, delay, duration, blur, className }) {
|
|
|
120
130
|
className: "flex h-[1.1em] items-center justify-center leading-none",
|
|
121
131
|
children: n
|
|
122
132
|
}, n))
|
|
123
|
-
})
|
|
133
|
+
})]
|
|
124
134
|
});
|
|
125
135
|
}
|
|
126
136
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-ticker.js","names":[],"sources":["../../../src/components/motion/number-ticker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { animate, motion, useInView, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport interface NumberTickerProps {\n value: number;\n /** Digits to pad to (left). */\n pad?: number;\n /** Per-digit roll duration in seconds. */\n duration?: number;\n /** Stagger between digits. */\n stagger?: number;\n /** Render only after the element enters the viewport. */\n startOnView?: boolean;\n prefix?: string;\n suffix?: string;\n /** Add a small blur during digit rolls. */\n blur?: boolean;\n className?: string;\n digitClassName?: string;\n /** Insert locale group separators (commas). Server-component safe. */\n locale?: boolean;\n /** Custom formatter. Client-only — server components must use `locale` instead. */\n format?: (value: number) => string;\n}\n\nconst DIGIT_HEIGHT_EM = 1.1;\nconst DIGITS = Array.from({ length: 10 }, (_, n) => n);\n\nexport function NumberTicker({\n value,\n pad,\n duration = 0.9,\n stagger = 0.04,\n startOnView = true,\n prefix,\n suffix,\n blur = false,\n className,\n digitClassName,\n locale,\n format,\n}: NumberTickerProps) {\n const containerRef = useRef<HTMLSpanElement>(null);\n const inView = useInView(containerRef, { once: true, amount: 0.6 });\n const [armed, setArmed] = useState(!startOnView);\n\n useEffect(() => {\n if (startOnView && inView) setArmed(true);\n }, [startOnView, inView]);\n\n const text = useMemo(() => {\n const rounded = Math.round(value);\n const formatted = format\n ? format(rounded)\n : locale\n ? rounded.toLocaleString()\n : rounded.
|
|
1
|
+
{"version":3,"file":"number-ticker.js","names":[],"sources":["../../../src/components/motion/number-ticker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { animate, motion, useInView, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport interface NumberTickerProps {\n value: number;\n /** Digits to pad to (left). */\n pad?: number;\n /**\n * Fraction digits to keep. The value is rounded to this many places before\n * `format` runs (default 0, whole numbers).\n */\n decimals?: number;\n /** Per-digit roll duration in seconds. */\n duration?: number;\n /** Stagger between digits. */\n stagger?: number;\n /** Render only after the element enters the viewport. */\n startOnView?: boolean;\n prefix?: string;\n suffix?: string;\n /** Add a small blur during digit rolls. */\n blur?: boolean;\n className?: string;\n digitClassName?: string;\n /** Insert locale group separators (commas). Server-component safe. */\n locale?: boolean;\n /** Custom formatter. Client-only — server components must use `locale` instead. */\n format?: (value: number) => string;\n}\n\nconst DIGIT_HEIGHT_EM = 1.1;\nconst DIGITS = Array.from({ length: 10 }, (_, n) => n);\n\nexport function NumberTicker({\n value,\n pad,\n decimals = 0,\n duration = 0.9,\n stagger = 0.04,\n startOnView = true,\n prefix,\n suffix,\n blur = false,\n className,\n digitClassName,\n locale,\n format,\n}: NumberTickerProps) {\n const containerRef = useRef<HTMLSpanElement>(null);\n const inView = useInView(containerRef, { once: true, amount: 0.6 });\n const [armed, setArmed] = useState(!startOnView);\n\n useEffect(() => {\n if (startOnView && inView) setArmed(true);\n }, [startOnView, inView]);\n\n const text = useMemo(() => {\n const places = Math.max(0, Math.floor(decimals));\n const factor = 10 ** places;\n const rounded = Math.round(value * factor) / factor;\n const formatted = format\n ? format(rounded)\n : locale\n ? rounded.toLocaleString(undefined, {\n minimumFractionDigits: places,\n maximumFractionDigits: places,\n })\n : rounded.toFixed(places);\n return pad ? formatted.padStart(pad, \"0\") : formatted;\n }, [value, pad, decimals, format, locale]);\n const glyphs = useMemo(() => {\n const chars = text.split(\"\");\n // Key by place value (position from the right): a changing digit keeps its\n // identity and rolls to the new value instead of remounting and replaying\n // from 0. Growing numbers add glyphs on the left without re-keying the\n // ones, tens, hundreds already on screen.\n return chars.map((char, i) => ({ char, id: `g-${chars.length - 1 - i}` }));\n }, [text]);\n const readableText = `${prefix ?? \"\"}${text}${suffix ?? \"\"}`;\n\n // Stagger is an entrance flourish. Once the reveal has played, value\n // changes roll every digit immediately — a per-digit delay on live updates\n // reads as lag.\n const [entered, setEntered] = useState(false);\n useEffect(() => {\n if (!armed || entered) return;\n const total = (duration + glyphs.length * stagger) * 1000;\n const t = window.setTimeout(() => setEntered(true), total);\n return () => window.clearTimeout(t);\n }, [armed, entered, duration, stagger, glyphs.length]);\n\n return (\n <span ref={containerRef} className={cn(\"inline-flex items-baseline tabular-nums\", className)}>\n <span className=\"sr-only\">{readableText}</span>\n <span aria-hidden=\"true\" className=\"inline-flex items-baseline\">\n {prefix ? <span>{prefix}</span> : null}\n {glyphs.map(({ char, id }, i) => {\n const isDigit = /\\d/.test(char);\n if (!isDigit) {\n return (\n <span key={id} className=\"inline-block\">\n {char}\n </span>\n );\n }\n const digit = Number(char);\n return (\n <Digit\n key={id}\n digit={armed ? digit : 0}\n delay={entered ? 0 : i * stagger}\n duration={duration}\n blur={blur}\n className={digitClassName}\n />\n );\n })}\n {suffix ? <span>{suffix}</span> : null}\n </span>\n </span>\n );\n}\n\nfunction Digit({\n digit,\n delay,\n duration,\n blur,\n className,\n}: {\n digit: number;\n delay: number;\n duration: number;\n blur: boolean;\n className?: string;\n}) {\n const reduce = useReducedMotion();\n const columnRef = useRef<HTMLSpanElement>(null);\n\n useEffect(() => {\n if (reduce || !blur || !columnRef.current || !Number.isFinite(digit)) {\n return;\n }\n\n const node = columnRef.current;\n const controls = animate(\n node,\n { filter: [\"blur(10px)\", \"blur(0px)\"] },\n {\n duration: Math.min(duration * 0.75, 0.32),\n delay,\n ease: EASE_OUT,\n },\n );\n\n return () => {\n controls.stop();\n node.style.filter = \"blur(0px)\";\n };\n }, [blur, delay, digit, duration, reduce]);\n\n return (\n // The invisible in-flow digit gives the slot a real text baseline so it\n // lines up with surrounding text; clip-path clips the rolling column\n // without moving that baseline the way overflow: hidden would.\n <span\n className={cn(\"relative inline-block text-center [clip-path:inset(0)]\", className)}\n style={{\n height: `${DIGIT_HEIGHT_EM}em`,\n lineHeight: `${DIGIT_HEIGHT_EM}em`,\n width: \"1ch\",\n }}\n >\n <span className=\"invisible\">{digit}</span>\n <motion.span\n ref={columnRef}\n initial={{ y: 0 }}\n animate={{ y: `-${digit * DIGIT_HEIGHT_EM}em` }}\n transition={reduce ? { duration: 0 } : { duration, delay, ease: EASE_OUT }}\n className=\"absolute inset-x-0 top-0 flex flex-col items-center will-change-[transform,filter]\"\n >\n {DIGITS.map((n) => (\n <span key={n} className=\"flex h-[1.1em] items-center justify-center leading-none\">\n {n}\n </span>\n ))}\n </motion.span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;EAAC;EAAM;EAAO;EAAO;EAAU;CAAM,CAAC;CAEzC,OAIE,qBAAC,QAAD;EACE,WAAW,GAAG,0DAA0D,SAAS;EACjF,OAAO;GACL,QAAQ,GAAG,gBAAgB;GAC3B,YAAY,GAAG,gBAAgB;GAC/B,OAAO;EACT;EANF,UAAA,CAQE,oBAAC,QAAD;GAAM,WAAU;GAAa,UAAA;EAAY,CAAA,GACzC,oBAAC,OAAO,MAAR;GACE,KAAK;GACL,SAAS,EAAE,GAAG,EAAE;GAChB,SAAS,EAAE,GAAG,IAAI,QAAQ,gBAAgB,IAAI;GAC9C,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;IAAE;IAAU;IAAO,MAAM;GAAS;GACzE,WAAU;GAET,UAAA,OAAO,KAAK,MACX,oBAAC,QAAD;IAAc,WAAU;IACrB,UAAA;GACG,GAFK,CAEL,CACP;EACU,CAAA,CACT;;AAEV"}
|
|
@@ -14,6 +14,9 @@ function OTPInput({ length = 6, value: controlledValue, defaultValue = "", onCha
|
|
|
14
14
|
const [slots, setSlots] = useState(() => toSlots(controlled ? controlledValue : defaultValue, length));
|
|
15
15
|
const [focused, setFocused] = useState(false);
|
|
16
16
|
const [active, setActive] = useState(0);
|
|
17
|
+
const [announcement, setAnnouncement] = useState("");
|
|
18
|
+
const announce = (text) => setAnnouncement((previous) => previous === text ? `${text}\u00a0` : text);
|
|
19
|
+
const spokenSlot = (char) => char ? mask ? "Filled" : char : "Empty";
|
|
17
20
|
const joined = slots.join("");
|
|
18
21
|
const joinedRef = useRef(joined);
|
|
19
22
|
useEffect(() => {
|
|
@@ -30,6 +33,12 @@ function OTPInput({ length = 6, value: controlledValue, defaultValue = "", onCha
|
|
|
30
33
|
]);
|
|
31
34
|
const commit = (next) => {
|
|
32
35
|
const wasComplete = slots.every((c) => c !== "");
|
|
36
|
+
const changed = next.flatMap((c, i) => c !== slots[i] ? [i] : []);
|
|
37
|
+
const progress = `${next.filter(Boolean).length} of ${length} digits entered.`;
|
|
38
|
+
if (changed.length === 1) {
|
|
39
|
+
const char = next[changed[0]];
|
|
40
|
+
announce(char ? `${mask ? "Digit" : char}. ${progress}` : `Deleted. ${progress}`);
|
|
41
|
+
} else if (changed.length > 1) announce(progress);
|
|
33
42
|
setSlots(next);
|
|
34
43
|
const str = next.join("");
|
|
35
44
|
onChange?.(str);
|
|
@@ -75,18 +84,11 @@ function OTPInput({ length = 6, value: controlledValue, defaultValue = "", onCha
|
|
|
75
84
|
} else if (k === "Delete") {
|
|
76
85
|
e.preventDefault();
|
|
77
86
|
clearSlot(active);
|
|
78
|
-
} else if (k === "ArrowLeft") {
|
|
87
|
+
} else if (k === "ArrowLeft" || k === "ArrowRight" || k === "Home" || k === "End") {
|
|
79
88
|
e.preventDefault();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
setActive((a) => Math.min(a + 1, length - 1));
|
|
84
|
-
} else if (k === "Home") {
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
setActive(0);
|
|
87
|
-
} else if (k === "End") {
|
|
88
|
-
e.preventDefault();
|
|
89
|
-
setActive(length - 1);
|
|
89
|
+
const to = k === "ArrowLeft" ? Math.max(active - 1, 0) : k === "ArrowRight" ? Math.min(active + 1, length - 1) : k === "Home" ? 0 : length - 1;
|
|
90
|
+
setActive(to);
|
|
91
|
+
announce(`${spokenSlot(slots[to] ?? "")}, digit ${to + 1} of ${length}.`);
|
|
90
92
|
}
|
|
91
93
|
};
|
|
92
94
|
const onPaste = (e) => {
|
|
@@ -251,6 +253,12 @@ function OTPInput({ length = 6, value: controlledValue, defaultValue = "", onCha
|
|
|
251
253
|
}) : null })
|
|
252
254
|
]
|
|
253
255
|
}),
|
|
256
|
+
/* @__PURE__ */ jsx("span", {
|
|
257
|
+
"aria-live": "polite",
|
|
258
|
+
"aria-atomic": "true",
|
|
259
|
+
className: "sr-only",
|
|
260
|
+
children: announcement
|
|
261
|
+
}),
|
|
254
262
|
message ? /* @__PURE__ */ jsx("p", {
|
|
255
263
|
"aria-live": "polite",
|
|
256
264
|
className: cn("text-sm", showSuccess ? "text-emerald-500" : status === "error" ? "text-destructive" : "text-muted-foreground"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp-input.js","names":[],"sources":["../../../src/components/motion/otp-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OTPStatus = \"idle\" | \"error\" | \"success\";\n\nexport interface OTPInputProps {\n /** Number of slots. Default 6. */\n length?: number;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Fires once every slot is filled. */\n onComplete?: (value: string) => void;\n /** Optional label rendered above the slots. */\n label?: string;\n /** Helper text shown below the slots while idle. */\n hint?: string;\n /** Message shown below the slots when status is \"success\". */\n successMessage?: string;\n /** Message shown below the slots when status is \"error\". */\n errorMessage?: string;\n /** External validation feedback. \"error\" shakes, \"success\" draws a check. */\n status?: OTPStatus;\n /** Render dots instead of the typed digits. */\n mask?: boolean;\n disabled?: boolean;\n autoFocus?: boolean;\n /** Accessible label for the underlying input. */\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport function OTPInput({\n length = 6,\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onComplete,\n label,\n hint,\n successMessage,\n errorMessage,\n status = \"idle\",\n mask = false,\n disabled = false,\n autoFocus = false,\n \"aria-label\": ariaLabel = \"One-time passcode\",\n className,\n}: OTPInputProps) {\n const uid = useId();\n const reduce = useReducedMotion();\n const inputRef = useRef<HTMLInputElement>(null);\n const slotsRef = useRef<HTMLDivElement>(null);\n\n const controlled = controlledValue !== undefined;\n\n // Source of truth is a fixed-length array, so a cleared middle slot stays an\n // in-place hole instead of collapsing the digits after it to the left.\n const [slots, setSlots] = useState<string[]>(() =>\n toSlots(controlled ? controlledValue : defaultValue, length),\n );\n const [focused, setFocused] = useState(false);\n const [active, setActive] = useState(0);\n\n const joined = slots.join(\"\");\n const joinedRef = useRef(joined);\n\n useEffect(() => {\n joinedRef.current = joined;\n }, [joined]);\n\n // Pull in external value changes; skip when the parent is just echoing our own\n // onChange, so internal holes survive the controlled round-trip.\n useEffect(() => {\n if (!controlled) return;\n const incoming = sanitize(controlledValue, length);\n if (incoming !== joinedRef.current) setSlots(toSlots(incoming, length));\n }, [controlled, controlledValue, length]);\n\n const commit = (next: string[]) => {\n const wasComplete = slots.every((c) => c !== \"\");\n setSlots(next);\n const str = next.join(\"\");\n onChange?.(str);\n // Fire only on the empty→full transition, not on every edit of a full code.\n if (!wasComplete && next.every((c) => c !== \"\")) onComplete?.(str);\n };\n\n const clearSlot = (idx: number) => {\n const next = [...slots];\n next[idx] = \"\";\n commit(next);\n };\n\n const slotFromClientX = (clientX: number) => {\n const els = slotsRef.current?.children;\n if (!els) return 0;\n for (let i = 0; i < els.length; i++) {\n if (clientX < els[i].getBoundingClientRect().right) return i;\n }\n return length - 1;\n };\n\n // Single insertion path: one digit overwrites the active slot and advances; a\n // multi-digit chunk (paste / SMS autofill) fills forward from the active slot.\n const insert = (raw: string, from = active) => {\n const digits = raw.replace(/\\D/g, \"\");\n if (!digits) return;\n const next = [...slots];\n let i = from;\n for (const ch of digits) {\n if (i >= length) break;\n next[i] = ch;\n i++;\n }\n commit(next);\n setActive(Math.min(i, length - 1));\n };\n\n // The keyboard is the single source of truth: preventDefault on keydown\n // reliably blocks native insertion (unlike beforeinput in React), so the hidden\n // input never accumulates a competing string and slot holes survive.\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.metaKey || e.ctrlKey || e.altKey) return;\n const k = e.key;\n if (/^[0-9]$/.test(k)) {\n e.preventDefault();\n insert(k);\n } else if (k === \"Backspace\") {\n e.preventDefault();\n // A filled slot clears in place; an empty slot steps back and clears there.\n if (slots[active]) {\n clearSlot(active);\n } else if (active > 0) {\n clearSlot(active - 1);\n setActive((current) => Math.max(current - 1, 0));\n }\n } else if (k === \"Delete\") {\n e.preventDefault();\n clearSlot(active);\n } else if (k === \"ArrowLeft\") {\n e.preventDefault();\n setActive((a) => Math.max(a - 1, 0));\n } else if (k === \"ArrowRight\") {\n e.preventDefault();\n setActive((a) => Math.min(a + 1, length - 1));\n } else if (k === \"Home\") {\n e.preventDefault();\n setActive(0);\n } else if (k === \"End\") {\n e.preventDefault();\n setActive(length - 1);\n }\n };\n\n const onPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n if (disabled) return;\n // preventDefault suppresses the duplicate onChange, keeping that path autofill-only.\n e.preventDefault();\n insert(e.clipboardData.getData(\"text\"), active);\n };\n\n // Autofill path: SMS one-time-code arrives as a whole value in one shot.\n // Keystrokes go through onKeyDown and paste through onPaste, so only autofill\n // reaches here — spread it across the slots from the start.\n const onChangeNative = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = sanitize(e.target.value, length);\n if (!digits) return;\n commit(toSlots(digits, length));\n setActive(Math.min(digits.length, length - 1));\n };\n\n // Error shake — imperative so it replays on every transition into \"error\".\n useEffect(() => {\n if (status !== \"error\" || reduce || !slotsRef.current) return;\n animate(slotsRef.current, { x: [0, -5, 5, -3, 3, -1, 0] }, { duration: 0.45, ease: EASE_OUT });\n }, [status, reduce]);\n\n const showSuccess = status === \"success\";\n const activeIndex = focused ? active : -1;\n const message = showSuccess ? successMessage : status === \"error\" ? errorMessage : hint;\n\n return (\n <div className={cn(\"inline-flex flex-col gap-2\", className)}>\n {label ? (\n <label htmlFor={`${uid}-input`} className=\"font-medium text-foreground text-sm\">\n {label}\n </label>\n ) : null}\n <fieldset\n className=\"relative m-0 inline-flex w-max border-0 p-0\"\n onMouseDown={(e) => {\n if (disabled) return;\n // Suppress the native click-caret; we drive the active slot ourselves.\n e.preventDefault();\n // Clamp to the first empty slot so a click can't jump ahead of progress.\n const firstEmpty = slots.indexOf(\"\");\n const cap = firstEmpty === -1 ? length - 1 : firstEmpty;\n setActive(Math.min(slotFromClientX(e.clientX), cap));\n inputRef.current?.focus();\n }}\n >\n <input\n ref={inputRef}\n id={`${uid}-input`}\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n autoFocus={autoFocus}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-invalid={status === \"error\"}\n // Kept empty on purpose — our state owns the digits, native holds none.\n value=\"\"\n maxLength={length}\n onKeyDown={onKeyDown}\n onChange={onChangeNative}\n onPaste={onPaste}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n // Transparent overlay owns focus, the soft keyboard, paste and autofill;\n // the slots below are purely presentational.\n className=\"absolute inset-0 z-20 h-full w-full cursor-text bg-transparent text-transparent caret-transparent opacity-0 outline-none disabled:cursor-not-allowed\"\n />\n\n <div ref={slotsRef} className=\"flex items-center gap-2\">\n {Array.from({ length }, (_, i) => {\n const char = slots[i] ?? \"\";\n const isActive = i === activeIndex;\n return (\n <div\n key={`${uid}-${i}`}\n data-active={isActive}\n data-filled={char !== \"\"}\n className={cn(\n \"relative grid h-14 w-12 place-items-center overflow-hidden rounded-xl border font-semibold text-xl tabular-nums transition-colors duration-200\",\n showSuccess\n ? \"border-emerald-500/60 text-foreground\"\n : status === \"error\"\n ? \"border-destructive/60 text-foreground\"\n : char\n ? \"border-border-strong text-foreground\"\n : \"border-border text-muted-foreground\",\n // Active slot reads stronger; twMerge lets this win the border.\n isActive && !showSuccess && status !== \"error\" && \"border-foreground\",\n disabled && \"opacity-50\",\n )}\n >\n {/* Blinking caret marks the active slot — centered when empty,\n trailing the digit when the slot is already filled. */}\n {isActive && !showSuccess ? (\n <motion.span\n aria-hidden\n animate={reduce ? undefined : { opacity: [1, 1, 0, 0] }}\n transition={\n reduce\n ? undefined\n : { duration: 1, repeat: Number.POSITIVE_INFINITY, ease: \"linear\" }\n }\n className={cn(\n \"pointer-events-none absolute top-1/2 h-6 w-px -translate-y-1/2 bg-foreground\",\n char ? \"right-3\" : \"left-1/2 -translate-x-1/2\",\n )}\n />\n ) : null}\n\n {/* Digits roll vertically. Each is absolutely centered so enter and\n exit overlap in place — no in-flow reflow, no sideways drift. */}\n <AnimatePresence initial={false}>\n {char ? (\n <motion.span\n key={char}\n initial={reduce ? { opacity: 0 } : { y: 14, opacity: 0, filter: \"blur(4px)\" }}\n animate={reduce ? { opacity: 1 } : { y: 0, opacity: 1, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { y: -14, opacity: 0, filter: \"blur(4px)\" }}\n transition={reduce ? { duration: 0 } : { duration: 0.22, ease: EASE_OUT }}\n className=\"absolute inset-0 grid place-items-center leading-none\"\n >\n {mask ? \"•\" : char}\n </motion.span>\n ) : null}\n </AnimatePresence>\n </div>\n );\n })}\n </div>\n\n <AnimatePresence>\n {showSuccess ? (\n <motion.span\n initial={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n animate={reduce ? { opacity: 1 } : { scale: 1, opacity: 1 }}\n exit={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n transition={\n reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 28 }\n }\n className=\"pointer-events-none absolute top-1/2 -right-7 -translate-y-1/2 text-emerald-500\"\n aria-hidden\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <title>Verified</title>\n <motion.path\n d=\"M5 13l4 4L19 7\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={\n reduce ? { duration: 0 } : { duration: 0.35, ease: EASE_OUT, delay: 0.1 }\n }\n />\n </svg>\n </motion.span>\n ) : null}\n </AnimatePresence>\n </fieldset>\n\n {message ? (\n <p\n aria-live=\"polite\"\n className={cn(\n \"text-sm\",\n showSuccess\n ? \"text-emerald-500\"\n : status === \"error\"\n ? \"text-destructive\"\n : \"text-muted-foreground\",\n )}\n >\n {message}\n </p>\n ) : null}\n </div>\n );\n}\n\nfunction sanitize(raw: string, length: number) {\n return raw.replace(/\\D/g, \"\").slice(0, length);\n}\n\nfunction toSlots(raw: string, length: number) {\n const digits = sanitize(raw, length);\n return Array.from({ length }, (_, i) => digits[i] ?? \"\");\n}\n"],"mappings":";;;;;;;AAqCA,SAAgB,SAAS,EACvB,SAAS,GACT,OAAO,iBACP,eAAe,IACf,UACA,YACA,OACA,MACA,gBACA,cACA,SAAS,QACT,OAAO,OACP,WAAW,OACX,YAAY,OACZ,cAAc,YAAY,qBAC1B,aACgB;CAChB,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,WAAW,OAAuB,IAAI;CAE5C,MAAM,aAAa,oBAAoB,KAAA;CAIvC,MAAM,CAAC,OAAO,YAAY,eACxB,QAAQ,aAAa,kBAAkB,cAAc,MAAM,CAC7D;CACA,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CAEtC,MAAM,SAAS,MAAM,KAAK,EAAE;CAC5B,MAAM,YAAY,OAAO,MAAM;CAE/B,gBAAgB;EACd,UAAU,UAAU;CACtB,GAAG,CAAC,MAAM,CAAC;CAIX,gBAAgB;EACd,IAAI,CAAC,YAAY;EACjB,MAAM,WAAW,SAAS,iBAAiB,MAAM;EACjD,IAAI,aAAa,UAAU,SAAS,SAAS,QAAQ,UAAU,MAAM,CAAC;CACxE,GAAG;EAAC;EAAY;EAAiB;CAAM,CAAC;CAExC,MAAM,UAAU,SAAmB;EACjC,MAAM,cAAc,MAAM,OAAO,MAAM,MAAM,EAAE;EAC/C,SAAS,IAAI;EACb,MAAM,MAAM,KAAK,KAAK,EAAE;EACxB,WAAW,GAAG;EAEd,IAAI,CAAC,eAAe,KAAK,OAAO,MAAM,MAAM,EAAE,GAAG,aAAa,GAAG;CACnE;CAEA,MAAM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;AAC/C;AAEA,SAAS,QAAQ,KAAa,QAAgB;CAC5C,MAAM,SAAS,SAAS,KAAK,MAAM;CACnC,OAAO,MAAM,KAAK,EAAE,OAAO,IAAI,GAAG,MAAM,OAAO,MAAM,EAAE;AACzD"}
|
|
1
|
+
{"version":3,"file":"otp-input.js","names":[],"sources":["../../../src/components/motion/otp-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type OTPStatus = \"idle\" | \"error\" | \"success\";\n\nexport interface OTPInputProps {\n /** Number of slots. Default 6. */\n length?: number;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Fires once every slot is filled. */\n onComplete?: (value: string) => void;\n /** Optional label rendered above the slots. */\n label?: string;\n /** Helper text shown below the slots while idle. */\n hint?: string;\n /** Message shown below the slots when status is \"success\". */\n successMessage?: string;\n /** Message shown below the slots when status is \"error\". */\n errorMessage?: string;\n /** External validation feedback. \"error\" shakes, \"success\" draws a check. */\n status?: OTPStatus;\n /** Render dots instead of the typed digits. */\n mask?: boolean;\n disabled?: boolean;\n autoFocus?: boolean;\n /** Accessible label for the underlying input. */\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport function OTPInput({\n length = 6,\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onComplete,\n label,\n hint,\n successMessage,\n errorMessage,\n status = \"idle\",\n mask = false,\n disabled = false,\n autoFocus = false,\n \"aria-label\": ariaLabel = \"One-time passcode\",\n className,\n}: OTPInputProps) {\n const uid = useId();\n const reduce = useReducedMotion();\n const inputRef = useRef<HTMLInputElement>(null);\n const slotsRef = useRef<HTMLDivElement>(null);\n\n const controlled = controlledValue !== undefined;\n\n // Source of truth is a fixed-length array, so a cleared middle slot stays an\n // in-place hole instead of collapsing the digits after it to the left.\n const [slots, setSlots] = useState<string[]>(() =>\n toSlots(controlled ? controlledValue : defaultValue, length),\n );\n const [focused, setFocused] = useState(false);\n const [active, setActive] = useState(0);\n // The native input holds no value, so screen readers cannot echo what was\n // typed. This polite region speaks each change instead; the alternating\n // trailing space makes a repeated phrase count as new text.\n const [announcement, setAnnouncement] = useState(\"\");\n const announce = (text: string) =>\n setAnnouncement((previous) => (previous === text ? `${text}\\u00a0` : text));\n const spokenSlot = (char: string) => (char ? (mask ? \"Filled\" : char) : \"Empty\");\n\n const joined = slots.join(\"\");\n const joinedRef = useRef(joined);\n\n useEffect(() => {\n joinedRef.current = joined;\n }, [joined]);\n\n // Pull in external value changes; skip when the parent is just echoing our own\n // onChange, so internal holes survive the controlled round-trip.\n useEffect(() => {\n if (!controlled) return;\n const incoming = sanitize(controlledValue, length);\n if (incoming !== joinedRef.current) setSlots(toSlots(incoming, length));\n }, [controlled, controlledValue, length]);\n\n const commit = (next: string[]) => {\n const wasComplete = slots.every((c) => c !== \"\");\n const changed = next.flatMap((c, i) => (c !== slots[i] ? [i] : []));\n const progress = `${next.filter(Boolean).length} of ${length} digits entered.`;\n if (changed.length === 1) {\n const char = next[changed[0]];\n announce(char ? `${mask ? \"Digit\" : char}. ${progress}` : `Deleted. ${progress}`);\n } else if (changed.length > 1) {\n announce(progress);\n }\n setSlots(next);\n const str = next.join(\"\");\n onChange?.(str);\n // Fire only on the empty→full transition, not on every edit of a full code.\n if (!wasComplete && next.every((c) => c !== \"\")) onComplete?.(str);\n };\n\n const clearSlot = (idx: number) => {\n const next = [...slots];\n next[idx] = \"\";\n commit(next);\n };\n\n const slotFromClientX = (clientX: number) => {\n const els = slotsRef.current?.children;\n if (!els) return 0;\n for (let i = 0; i < els.length; i++) {\n if (clientX < els[i].getBoundingClientRect().right) return i;\n }\n return length - 1;\n };\n\n // Single insertion path: one digit overwrites the active slot and advances; a\n // multi-digit chunk (paste / SMS autofill) fills forward from the active slot.\n const insert = (raw: string, from = active) => {\n const digits = raw.replace(/\\D/g, \"\");\n if (!digits) return;\n const next = [...slots];\n let i = from;\n for (const ch of digits) {\n if (i >= length) break;\n next[i] = ch;\n i++;\n }\n commit(next);\n setActive(Math.min(i, length - 1));\n };\n\n // The keyboard is the single source of truth: preventDefault on keydown\n // reliably blocks native insertion (unlike beforeinput in React), so the hidden\n // input never accumulates a competing string and slot holes survive.\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.metaKey || e.ctrlKey || e.altKey) return;\n const k = e.key;\n if (/^[0-9]$/.test(k)) {\n e.preventDefault();\n insert(k);\n } else if (k === \"Backspace\") {\n e.preventDefault();\n // A filled slot clears in place; an empty slot steps back and clears there.\n if (slots[active]) {\n clearSlot(active);\n } else if (active > 0) {\n clearSlot(active - 1);\n setActive((current) => Math.max(current - 1, 0));\n }\n } else if (k === \"Delete\") {\n e.preventDefault();\n clearSlot(active);\n } else if (k === \"ArrowLeft\" || k === \"ArrowRight\" || k === \"Home\" || k === \"End\") {\n e.preventDefault();\n const to =\n k === \"ArrowLeft\"\n ? Math.max(active - 1, 0)\n : k === \"ArrowRight\"\n ? Math.min(active + 1, length - 1)\n : k === \"Home\"\n ? 0\n : length - 1;\n setActive(to);\n announce(`${spokenSlot(slots[to] ?? \"\")}, digit ${to + 1} of ${length}.`);\n }\n };\n\n const onPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n if (disabled) return;\n // preventDefault suppresses the duplicate onChange, keeping that path autofill-only.\n e.preventDefault();\n insert(e.clipboardData.getData(\"text\"), active);\n };\n\n // Autofill path: SMS one-time-code arrives as a whole value in one shot.\n // Keystrokes go through onKeyDown and paste through onPaste, so only autofill\n // reaches here — spread it across the slots from the start.\n const onChangeNative = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = sanitize(e.target.value, length);\n if (!digits) return;\n commit(toSlots(digits, length));\n setActive(Math.min(digits.length, length - 1));\n };\n\n // Error shake — imperative so it replays on every transition into \"error\".\n useEffect(() => {\n if (status !== \"error\" || reduce || !slotsRef.current) return;\n animate(slotsRef.current, { x: [0, -5, 5, -3, 3, -1, 0] }, { duration: 0.45, ease: EASE_OUT });\n }, [status, reduce]);\n\n const showSuccess = status === \"success\";\n const activeIndex = focused ? active : -1;\n const message = showSuccess ? successMessage : status === \"error\" ? errorMessage : hint;\n\n return (\n <div className={cn(\"inline-flex flex-col gap-2\", className)}>\n {label ? (\n <label htmlFor={`${uid}-input`} className=\"font-medium text-foreground text-sm\">\n {label}\n </label>\n ) : null}\n <fieldset\n className=\"relative m-0 inline-flex w-max border-0 p-0\"\n onMouseDown={(e) => {\n if (disabled) return;\n // Suppress the native click-caret; we drive the active slot ourselves.\n e.preventDefault();\n // Clamp to the first empty slot so a click can't jump ahead of progress.\n const firstEmpty = slots.indexOf(\"\");\n const cap = firstEmpty === -1 ? length - 1 : firstEmpty;\n setActive(Math.min(slotFromClientX(e.clientX), cap));\n inputRef.current?.focus();\n }}\n >\n <input\n ref={inputRef}\n id={`${uid}-input`}\n inputMode=\"numeric\"\n autoComplete=\"one-time-code\"\n autoFocus={autoFocus}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-invalid={status === \"error\"}\n // Kept empty on purpose — our state owns the digits, native holds none.\n value=\"\"\n maxLength={length}\n onKeyDown={onKeyDown}\n onChange={onChangeNative}\n onPaste={onPaste}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n // Transparent overlay owns focus, the soft keyboard, paste and autofill;\n // the slots below are purely presentational.\n className=\"absolute inset-0 z-20 h-full w-full cursor-text bg-transparent text-transparent caret-transparent opacity-0 outline-none disabled:cursor-not-allowed\"\n />\n\n <div ref={slotsRef} className=\"flex items-center gap-2\">\n {Array.from({ length }, (_, i) => {\n const char = slots[i] ?? \"\";\n const isActive = i === activeIndex;\n return (\n <div\n key={`${uid}-${i}`}\n data-active={isActive}\n data-filled={char !== \"\"}\n className={cn(\n \"relative grid h-14 w-12 place-items-center overflow-hidden rounded-xl border font-semibold text-xl tabular-nums transition-colors duration-200\",\n showSuccess\n ? \"border-emerald-500/60 text-foreground\"\n : status === \"error\"\n ? \"border-destructive/60 text-foreground\"\n : char\n ? \"border-border-strong text-foreground\"\n : \"border-border text-muted-foreground\",\n // Active slot reads stronger; twMerge lets this win the border.\n isActive && !showSuccess && status !== \"error\" && \"border-foreground\",\n disabled && \"opacity-50\",\n )}\n >\n {/* Blinking caret marks the active slot — centered when empty,\n trailing the digit when the slot is already filled. */}\n {isActive && !showSuccess ? (\n <motion.span\n aria-hidden\n animate={reduce ? undefined : { opacity: [1, 1, 0, 0] }}\n transition={\n reduce\n ? undefined\n : { duration: 1, repeat: Number.POSITIVE_INFINITY, ease: \"linear\" }\n }\n className={cn(\n \"pointer-events-none absolute top-1/2 h-6 w-px -translate-y-1/2 bg-foreground\",\n char ? \"right-3\" : \"left-1/2 -translate-x-1/2\",\n )}\n />\n ) : null}\n\n {/* Digits roll vertically. Each is absolutely centered so enter and\n exit overlap in place — no in-flow reflow, no sideways drift. */}\n <AnimatePresence initial={false}>\n {char ? (\n <motion.span\n key={char}\n initial={reduce ? { opacity: 0 } : { y: 14, opacity: 0, filter: \"blur(4px)\" }}\n animate={reduce ? { opacity: 1 } : { y: 0, opacity: 1, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { y: -14, opacity: 0, filter: \"blur(4px)\" }}\n transition={reduce ? { duration: 0 } : { duration: 0.22, ease: EASE_OUT }}\n className=\"absolute inset-0 grid place-items-center leading-none\"\n >\n {mask ? \"•\" : char}\n </motion.span>\n ) : null}\n </AnimatePresence>\n </div>\n );\n })}\n </div>\n\n <AnimatePresence>\n {showSuccess ? (\n <motion.span\n initial={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n animate={reduce ? { opacity: 1 } : { scale: 1, opacity: 1 }}\n exit={reduce ? { opacity: 0 } : { scale: 0.6, opacity: 0 }}\n transition={\n reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 28 }\n }\n className=\"pointer-events-none absolute top-1/2 -right-7 -translate-y-1/2 text-emerald-500\"\n aria-hidden\n >\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <title>Verified</title>\n <motion.path\n d=\"M5 13l4 4L19 7\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={\n reduce ? { duration: 0 } : { duration: 0.35, ease: EASE_OUT, delay: 0.1 }\n }\n />\n </svg>\n </motion.span>\n ) : null}\n </AnimatePresence>\n </fieldset>\n\n <span aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {announcement}\n </span>\n\n {message ? (\n <p\n aria-live=\"polite\"\n className={cn(\n \"text-sm\",\n showSuccess\n ? \"text-emerald-500\"\n : status === \"error\"\n ? \"text-destructive\"\n : \"text-muted-foreground\",\n )}\n >\n {message}\n </p>\n ) : null}\n </div>\n );\n}\n\nfunction sanitize(raw: string, length: number) {\n return raw.replace(/\\D/g, \"\").slice(0, length);\n}\n\nfunction toSlots(raw: string, length: number) {\n const digits = sanitize(raw, length);\n return Array.from({ length }, (_, i) => digits[i] ?? \"\");\n}\n"],"mappings":";;;;;;;AAqCA,SAAgB,SAAS,EACvB,SAAS,GACT,OAAO,iBACP,eAAe,IACf,UACA,YACA,OACA,MACA,gBACA,cACA,SAAS,QACT,OAAO,OACP,WAAW,OACX,YAAY,OACZ,cAAc,YAAY,qBAC1B,aACgB;CAChB,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,WAAW,OAAuB,IAAI;CAE5C,MAAM,aAAa,oBAAoB,KAAA;CAIvC,MAAM,CAAC,OAAO,YAAY,eACxB,QAAQ,aAAa,kBAAkB,cAAc,MAAM,CAC7D;CACA,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,QAAQ,aAA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M,KAAK,EAAE,OAAO,IAAI,GAAG,MAAM,OAAO,MAAM,EAAE;AACzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallax.js","names":[],"sources":["../../../src/components/motion/parallax.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, type RefObject, useRef } from \"react\";\nimport {\n type MotionStyle,\n motion,\n useReducedMotion,\n useScroll,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\n// Soft follow so the drift trails the scroll smoothly; looser than the UI\n// springs in lib/ease.ts on purpose.\nconst PARALLAX_SPRING = { stiffness: 120, damping: 30, mass: 0.6 };\n\nexport interface ParallaxProps {\n children: ReactNode;\n /**\n * Drift as a fraction of the element's travel through the viewport.\n * Positive moves with the scroll (foreground), negative against it\n * (background). ~0.1–0.5 reads best.\n */\n speed?: number;\n axis?: \"x\" | \"y\";\n /** Scroll container for contained scroll areas. Defaults to the viewport. */\n container?: RefObject<HTMLElement | null>;\n /** Spring-smooth the drift. Disabled automatically under reduced motion. */\n spring?: boolean;\n className?: string;\n}\n\nexport function Parallax({\n children,\n speed = 0.3,\n axis = \"y\",\n container,\n spring = true,\n className,\n}: ParallaxProps) {\n const reduce = useReducedMotion();\n const ref = useRef<HTMLDivElement>(null);\n const { scrollYProgress } = useScroll({\n target: ref,\n container,\n
|
|
1
|
+
{"version":3,"file":"parallax.js","names":[],"sources":["../../../src/components/motion/parallax.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, type RefObject, useRef } from \"react\";\nimport {\n type MotionStyle,\n motion,\n useReducedMotion,\n useScroll,\n useSpring,\n useTransform,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\n// Soft follow so the drift trails the scroll smoothly; looser than the UI\n// springs in lib/ease.ts on purpose.\nconst PARALLAX_SPRING = { stiffness: 120, damping: 30, mass: 0.6 };\n\nexport interface ParallaxProps {\n children: ReactNode;\n /**\n * Drift as a fraction of the element's travel through the viewport.\n * Positive moves with the scroll (foreground), negative against it\n * (background). ~0.1–0.5 reads best.\n */\n speed?: number;\n axis?: \"x\" | \"y\";\n /** Scroll container for contained scroll areas. Defaults to the viewport. */\n container?: RefObject<HTMLElement | null>;\n /** Spring-smooth the drift. Disabled automatically under reduced motion. */\n spring?: boolean;\n className?: string;\n}\n\nexport function Parallax({\n children,\n speed = 0.3,\n axis = \"y\",\n container,\n spring = true,\n className,\n}: ParallaxProps) {\n const reduce = useReducedMotion();\n const ref = useRef<HTMLDivElement>(null);\n const { scrollYProgress } = useScroll({\n target: ref,\n container,\n // A container ref defined higher in the tree may attach after this hook\n // runs; useScroll waits for it rather than falling back to the page.\n offset: [\"start end\", \"end start\"],\n });\n\n // progress 0→1 as the element crosses the viewport; map to a symmetric drift.\n const travel = speed * 100;\n const drift = useTransform(scrollYProgress, [0, 1], [travel, -travel]);\n const smoothed = useSpring(drift, PARALLAX_SPRING);\n const value = spring && !reduce ? smoothed : drift;\n\n const style: MotionStyle = reduce ? {} : axis === \"x\" ? { x: value } : { y: value };\n\n return (\n <motion.div ref={ref} style={style} className={cn(className)}>\n {children}\n </motion.div>\n );\n}\n"],"mappings":";;;;;;AAgBA,MAAM,kBAAkB;CAAE,WAAW;CAAK,SAAS;CAAI,MAAM;AAAI;AAkBjE,SAAgB,SAAS,EACvB,UACA,QAAQ,IACR,OAAO,KACP,WACA,SAAS,MACT,aACgB;CAChB,MAAM,SAAS,iBAAiB;CAChC,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,EAAE,oBAAoB,UAAU;EACpC,QAAQ;EACR;EAGA,QAAQ,CAAC,aAAa,WAAW;CACnC,CAAC;CAGD,MAAM,SAAS,QAAQ;CACvB,MAAM,QAAQ,aAAa,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;CACrE,MAAM,WAAW,UAAU,OAAO,eAAe;CACjD,MAAM,QAAQ,UAAU,CAAC,SAAS,WAAW;CAE7C,MAAM,QAAqB,SAAS,CAAC,IAAI,SAAS,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,GAAG,MAAM;CAElF,OACE,oBAAC,OAAO,KAAR;EAAiB;EAAY;EAAO,WAAW,GAAG,SAAS;EACxD;CACS,CAAA;AAEhB"}
|
|
@@ -12,9 +12,10 @@ export interface MorphPopoverProps {
|
|
|
12
12
|
className?: string;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* A popover whose panel
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* A popover whose full-size panel reveals from the corner nearest the trigger
|
|
16
|
+
* on one spring, then retraces the same clip on close. Content and surface
|
|
17
|
+
* edges keep their size throughout. Closes on outside pointer / Escape.
|
|
18
|
+
* Controlled or uncontrolled.
|
|
18
19
|
*/
|
|
19
20
|
export declare function MorphPopover({ children, open: controlledOpen, defaultOpen, onOpenChange, className }: MorphPopoverProps): import("react").JSX.Element;
|
|
20
21
|
export interface MorphPopoverTriggerProps {
|
|
@@ -38,4 +39,5 @@ export interface MorphPopoverContentProps {
|
|
|
38
39
|
}
|
|
39
40
|
export declare function MorphPopoverContent(props: MorphPopoverContentProps): import("react").ReactPortal | null;
|
|
40
41
|
//#endregion
|
|
42
|
+
export {};
|
|
41
43
|
//# sourceMappingURL=popover-morph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-morph.d.ts","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"popover-morph.d.ts","names":[],"sources":["../../../src/components/motion/popover-morph.tsx"],"mappings":";;KAiCK;KACA;iBAsBY;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;EAChB;;;;;;;;wBASc,eACd,UACA,MAAM,gBACN,aACA,cACA,aACC,oCAAiB,IAAA;iBAoFH;EACf,UAAU;;;wBAcI,sBAAsB,YAAY,2BAAwB,aAAA,kDAAA;iBAuCzD;EACf,UAAU;EACV,OAAO;EACP,QAAQ;;EAER;;EAEA;;EAEA;;EAEA,mBAAmB,SAAS;EAC5B;;wBAGc,oBAAoB,OAAO,2CAAwB"}
|