@kumix/ui 0.1.3 → 0.2.1
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 +115 -95
- package/dist/components/reui/alert.d.ts +12 -0
- package/dist/components/reui/alert.d.ts.map +1 -0
- package/dist/components/reui/alert.js +58 -0
- package/dist/components/reui/alert.js.map +1 -0
- package/dist/components/reui/autocomplete.d.ts +43 -0
- package/dist/components/reui/autocomplete.d.ts.map +1 -0
- package/dist/components/reui/autocomplete.js +165 -0
- package/dist/components/reui/autocomplete.js.map +1 -0
- package/dist/components/reui/badge.d.ts +17 -0
- package/dist/components/reui/badge.d.ts.map +1 -0
- package/dist/components/reui/badge.js +75 -0
- package/dist/components/reui/badge.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts +17 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.js +127 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts +18 -0
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-header.js +228 -0
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts +10 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +28 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts +22 -0
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-pagination.js +144 -0
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts +12 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +289 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts +14 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +166 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +10 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +171 -0
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +29 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +269 -0
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table.d.ts +116 -0
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid-table.js +864 -0
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid.d.ts +112 -0
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -0
- package/dist/components/reui/data-grid/data-grid.js +134 -0
- package/dist/components/reui/data-grid/data-grid.js.map +1 -0
- package/dist/components/reui/date-selector.d.ts +131 -0
- package/dist/components/reui/date-selector.d.ts.map +1 -0
- package/dist/components/reui/date-selector.js +783 -0
- package/dist/components/reui/date-selector.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.d.ts +7 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +108 -0
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-content.d.ts +15 -0
- package/dist/components/reui/event-calendar/event-calendar-content.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-content.js +44 -0
- package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts +30 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.js +581 -0
- package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts +73 -0
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-event.js +299 -0
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts +103 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.js +141 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.d.ts +111 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.js +398 -0
- package/dist/components/reui/event-calendar/event-calendar-lib.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts +29 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +530 -0
- package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts +71 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.js +319 -0
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts +32 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js +300 -0
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts +14 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js +355 -0
- package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts +35 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js +651 -0
- package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts +236 -0
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-types.js +2 -0
- package/dist/components/reui/event-calendar/event-calendar.d.ts +561 -0
- package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar.js +817 -0
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -0
- package/dist/components/reui/filters.d.ts +176 -0
- package/dist/components/reui/filters.d.ts.map +1 -0
- package/dist/components/reui/filters.js +1216 -0
- package/dist/components/reui/filters.js.map +1 -0
- package/dist/components/reui/frame.d.ts +32 -0
- package/dist/components/reui/frame.d.ts.map +1 -0
- package/dist/components/reui/frame.js +115 -0
- package/dist/components/reui/frame.js.map +1 -0
- package/dist/components/reui/gantt/gantt-bar.d.ts +44 -0
- package/dist/components/reui/gantt/gantt-bar.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-bar.js +229 -0
- package/dist/components/reui/gantt/gantt-bar.js.map +1 -0
- package/dist/components/reui/gantt/gantt-dnd.d.ts +36 -0
- package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-dnd.js +615 -0
- package/dist/components/reui/gantt/gantt-dnd.js.map +1 -0
- package/dist/components/reui/gantt/gantt-i18n.d.ts +91 -0
- package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-i18n.js +131 -0
- package/dist/components/reui/gantt/gantt-i18n.js.map +1 -0
- package/dist/components/reui/gantt/gantt-lib.d.ts +123 -0
- package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-lib.js +354 -0
- package/dist/components/reui/gantt/gantt-lib.js.map +1 -0
- package/dist/components/reui/gantt/gantt-nav.d.ts +60 -0
- package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-nav.js +266 -0
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -0
- package/dist/components/reui/gantt/gantt-recurrence.d.ts +37 -0
- package/dist/components/reui/gantt/gantt-recurrence.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-recurrence.js +230 -0
- package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -0
- package/dist/components/reui/gantt/gantt-types.d.ts +251 -0
- package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-types.js +2 -0
- package/dist/components/reui/gantt/gantt-view.d.ts +10 -0
- package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt-view.js +2193 -0
- package/dist/components/reui/gantt/gantt-view.js.map +1 -0
- package/dist/components/reui/gantt/gantt.d.ts +602 -0
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -0
- package/dist/components/reui/gantt/gantt.js +796 -0
- package/dist/components/reui/gantt/gantt.js.map +1 -0
- package/dist/components/reui/icon-stack.d.ts +7 -0
- package/dist/components/reui/icon-stack.d.ts.map +1 -0
- package/dist/components/reui/icon-stack.js +76 -0
- package/dist/components/reui/icon-stack.js.map +1 -0
- package/dist/components/reui/kanban.d.ts +70 -0
- package/dist/components/reui/kanban.d.ts.map +1 -0
- package/dist/components/reui/kanban.js +519 -0
- package/dist/components/reui/kanban.js.map +1 -0
- package/dist/components/reui/number-field.d.ts +29 -0
- package/dist/components/reui/number-field.d.ts.map +1 -0
- package/dist/components/reui/number-field.js +127 -0
- package/dist/components/reui/number-field.js.map +1 -0
- package/dist/components/reui/phone-input.d.ts +13 -0
- package/dist/components/reui/phone-input.d.ts.map +1 -0
- package/dist/components/reui/phone-input.js +126 -0
- package/dist/components/reui/phone-input.js.map +1 -0
- package/dist/components/reui/rating.d.ts +34 -0
- package/dist/components/reui/rating.d.ts.map +1 -0
- package/dist/components/reui/rating.js +94 -0
- package/dist/components/reui/rating.js.map +1 -0
- package/dist/components/reui/scrollspy.d.ts +17 -0
- package/dist/components/reui/scrollspy.d.ts.map +1 -0
- package/dist/components/reui/scrollspy.js +130 -0
- package/dist/components/reui/scrollspy.js.map +1 -0
- package/dist/components/reui/sortable.d.ts +48 -0
- package/dist/components/reui/sortable.d.ts.map +1 -0
- package/dist/components/reui/sortable.js +230 -0
- package/dist/components/reui/sortable.js.map +1 -0
- package/dist/components/reui/stepper.d.ts +63 -0
- package/dist/components/reui/stepper.d.ts.map +1 -0
- package/dist/components/reui/stepper.js +234 -0
- package/dist/components/reui/stepper.js.map +1 -0
- package/dist/components/reui/timeline.d.ts +24 -0
- package/dist/components/reui/timeline.d.ts.map +1 -0
- package/dist/components/reui/timeline.js +123 -0
- package/dist/components/reui/timeline.js.map +1 -0
- package/dist/components/reui/tree.d.ts +23 -0
- package/dist/components/reui/tree.d.ts.map +1 -0
- package/dist/components/reui/tree.js +115 -0
- package/dist/components/reui/tree.js.map +1 -0
- package/dist/components/ui/accordion.d.ts +9 -0
- package/dist/components/ui/accordion.d.ts.map +1 -0
- package/dist/components/ui/accordion.js +56 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +21 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +96 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/alert.d.ts +13 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/alert.js +45 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/aspect-ratio.d.ts +8 -0
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/components/ui/aspect-ratio.js +16 -0
- package/dist/components/ui/aspect-ratio.js.map +1 -0
- package/dist/components/ui/attachment.d.ts +26 -0
- package/dist/components/ui/attachment.d.ts.map +1 -0
- package/dist/components/ui/attachment.js +106 -0
- package/dist/components/ui/attachment.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +14 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +52 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +32 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +13 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +72 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/bubble.d.ts +19 -0
- package/dist/components/ui/bubble.d.ts.map +1 -0
- package/dist/components/ui/bubble.js +75 -0
- package/dist/components/ui/bubble.js.map +1 -0
- package/dist/components/ui/button-group.d.ts +14 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button-group.js +44 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +47 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +13 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +110 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/card.d.ts +14 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +58 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/carousel.d.ts +31 -0
- package/dist/components/ui/carousel.d.ts.map +1 -0
- package/dist/components/ui/carousel.js +135 -0
- package/dist/components/ui/carousel.js.map +1 -0
- package/dist/components/ui/chart.d.ts +47 -0
- package/dist/components/ui/chart.d.ts.map +1 -0
- package/dist/components/ui/chart.js +151 -0
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +6 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +22 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +8 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +26 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +27 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +164 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/command.d.ts +22 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +89 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +32 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +134 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +20 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +93 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/direction.d.ts +2 -0
- package/dist/components/ui/direction.js +3 -0
- package/dist/components/ui/drawer.d.ts +19 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/drawer.js +125 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +32 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +138 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/empty.d.ts +15 -0
- package/dist/components/ui/empty.d.ts.map +1 -0
- package/dist/components/ui/empty.js +62 -0
- package/dist/components/ui/empty.js.map +1 -0
- package/dist/components/ui/field.d.ts +28 -0
- package/dist/components/ui/field.d.ts.map +1 -0
- package/dist/components/ui/field.js +112 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +8 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +38 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/input-group.d.ts +21 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group.js +80 -0
- package/dist/components/ui/input-group.js.map +1 -0
- package/dist/components/ui/input-otp.d.ts +14 -0
- package/dist/components/ui/input-otp.d.ts.map +1 -0
- package/dist/components/ui/input-otp.js +49 -0
- package/dist/components/ui/input-otp.js.map +1 -0
- package/dist/components/ui/input.d.ts +6 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +17 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/item.d.ts +25 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/item.js +123 -0
- package/dist/components/ui/item.js.map +1 -0
- package/dist/components/ui/kbd.d.ts +7 -0
- package/dist/components/ui/kbd.d.ts.map +1 -0
- package/dist/components/ui/kbd.js +22 -0
- package/dist/components/ui/kbd.js.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +15 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/marker.d.ts +13 -0
- package/dist/components/ui/marker.d.ts.map +1 -0
- package/dist/components/ui/marker.js +45 -0
- package/dist/components/ui/marker.js.map +1 -0
- package/dist/components/ui/menubar.d.ts +32 -0
- package/dist/components/ui/menubar.d.ts.map +1 -0
- package/dist/components/ui/menubar.js +137 -0
- package/dist/components/ui/menubar.js.map +1 -0
- package/dist/components/ui/message-scroller.d.ts +13 -0
- package/dist/components/ui/message-scroller.d.ts.map +1 -0
- package/dist/components/ui/message-scroller.js +62 -0
- package/dist/components/ui/message-scroller.js.map +1 -0
- package/dist/components/ui/message.d.ts +13 -0
- package/dist/components/ui/message.d.ts.map +1 -0
- package/dist/components/ui/message.js +51 -0
- package/dist/components/ui/message.js.map +1 -0
- package/dist/components/ui/native-select.d.ts +11 -0
- package/dist/components/ui/native-select.d.ts.map +1 -0
- package/dist/components/ui/native-select.js +40 -0
- package/dist/components/ui/native-select.js.map +1 -0
- package/dist/components/ui/navigation-menu.d.ts +15 -0
- package/dist/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/components/ui/navigation-menu.js +85 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +20 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +81 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.d.ts +12 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +56 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +10 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +46 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +8 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +29 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/resizable.d.ts +10 -0
- package/dist/components/ui/resizable.d.ts.map +1 -0
- package/dist/components/ui/resizable.js +30 -0
- package/dist/components/ui/resizable.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +7 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +38 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select.d.ts +18 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +99 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/separator.d.ts +6 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +17 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +17 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +90 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +66 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +383 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +6 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/slider.d.ts +6 -0
- package/dist/components/ui/slider.d.ts.map +1 -0
- package/dist/components/ui/slider.js +36 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/sonner.d.ts +7 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +32 -0
- package/dist/components/ui/sonner.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +6 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +18 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/switch.d.ts +8 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +21 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +13 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +68 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +13 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +47 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +6 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +15 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toggle-group.d.ts +14 -0
- package/dist/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/components/ui/toggle-group.js +54 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +11 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +38 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +9 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +43 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/hooks/use-body-classes.d.ts +27 -0
- package/dist/hooks/use-body-classes.d.ts.map +1 -0
- package/dist/hooks/use-body-classes.js +52 -0
- package/dist/hooks/use-body-classes.js.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +43 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.js +69 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/hooks/use-file-upload.d.ts +49 -0
- package/dist/hooks/use-file-upload.d.ts.map +1 -0
- package/dist/hooks/use-file-upload.js +227 -0
- package/dist/hooks/use-file-upload.js.map +1 -0
- package/dist/hooks/use-hydrated.d.ts +37 -0
- package/dist/hooks/use-hydrated.d.ts.map +1 -0
- package/dist/hooks/use-hydrated.js +50 -0
- package/dist/hooks/use-hydrated.js.map +1 -0
- package/dist/hooks/use-intersection-observer.d.ts +55 -0
- package/dist/hooks/use-intersection-observer.d.ts.map +1 -0
- package/dist/hooks/use-intersection-observer.js +144 -0
- package/dist/hooks/use-intersection-observer.js.map +1 -0
- package/dist/hooks/use-is-mac.d.ts +28 -0
- package/dist/hooks/use-is-mac.d.ts.map +1 -0
- package/dist/hooks/use-is-mac.js +38 -0
- package/dist/hooks/use-is-mac.js.map +1 -0
- package/dist/hooks/use-media-query.d.ts +44 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +58 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-meta-color.d.ts +78 -0
- package/dist/hooks/use-meta-color.d.ts.map +1 -0
- package/dist/hooks/use-meta-color.js +138 -0
- package/dist/hooks/use-meta-color.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +5 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +21 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-mutation-observer.d.ts +61 -0
- package/dist/hooks/use-mutation-observer.d.ts.map +1 -0
- package/dist/hooks/use-mutation-observer.js +96 -0
- package/dist/hooks/use-mutation-observer.js.map +1 -0
- package/dist/hooks/use-scroll-position.d.ts +76 -0
- package/dist/hooks/use-scroll-position.d.ts.map +1 -0
- package/dist/hooks/use-scroll-position.js +97 -0
- package/dist/hooks/use-scroll-position.js.map +1 -0
- package/dist/hooks/use-slider-input.d.ts +94 -0
- package/dist/hooks/use-slider-input.d.ts.map +1 -0
- package/dist/hooks/use-slider-input.js +116 -0
- package/dist/hooks/use-slider-input.js.map +1 -0
- package/dist/hooks/use-viewport.d.ts +72 -0
- package/dist/hooks/use-viewport.d.ts.map +1 -0
- package/dist/hooks/use-viewport.js +91 -0
- package/dist/hooks/use-viewport.js.map +1 -0
- package/dist/style.css +0 -247
- package/dist/theme.css +244 -0
- package/dist/theme.css.d.ts +3 -0
- package/package.json +42 -40
- package/dist/hooks.d.ts +0 -957
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -1391
- package/dist/hooks.js.map +0 -1
- package/dist/index.d.ts +0 -1993
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10647
- package/dist/index.js.map +0 -1
- package/dist/source.css +0 -1
- package/dist/source.css.d.ts +0 -3
- package/dist/use-is-mobile-Dln4-L1O.js +0 -210
- package/dist/use-is-mobile-Dln4-L1O.js.map +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Label } from "../ui/label.js";
|
|
3
|
+
import { createContext, useContext, useId } from "react";
|
|
4
|
+
import { cn } from "@kumix/utils";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { MinusIcon, PlusIcon } from "lucide-react";
|
|
8
|
+
import { NumberField as NumberField$1 } from "@base-ui/react/number-field";
|
|
9
|
+
//#region src/components/reui/number-field.tsx
|
|
10
|
+
const NumberFieldContext = createContext(null);
|
|
11
|
+
const numberFieldGroupVariants = cva("relative flex w-full justify-between rounded-lg border border-input bg-transparent transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 focus-within:has-aria-invalid:border-destructive focus-within:has-aria-invalid:ring-destructive/20 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:focus-within:has-aria-invalid:ring-destructive/40", {
|
|
12
|
+
variants: { size: {
|
|
13
|
+
sm: "h-7 text-sm",
|
|
14
|
+
default: "h-8 text-sm",
|
|
15
|
+
lg: "h-9 text-sm"
|
|
16
|
+
} },
|
|
17
|
+
defaultVariants: { size: "default" }
|
|
18
|
+
});
|
|
19
|
+
const numberFieldButtonVariants = cva("relative flex shrink-0 cursor-pointer items-center justify-center transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:bg-accent [&_svg:not([class*='size-'])]:size-4", {
|
|
20
|
+
variants: { size: {
|
|
21
|
+
sm: "px-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
22
|
+
default: "px-2",
|
|
23
|
+
lg: "px-2.5"
|
|
24
|
+
} },
|
|
25
|
+
defaultVariants: { size: "default" }
|
|
26
|
+
});
|
|
27
|
+
const numberFieldInputVariants = cva("w-full min-w-0 flex-1 bg-transparent text-center tabular-nums outline-none", {
|
|
28
|
+
variants: { size: {
|
|
29
|
+
sm: "px-2 py-0.5",
|
|
30
|
+
default: "px-2.5 py-1",
|
|
31
|
+
lg: "px-2.5 py-1.5"
|
|
32
|
+
} },
|
|
33
|
+
defaultVariants: { size: "default" }
|
|
34
|
+
});
|
|
35
|
+
function NumberField({ id, className, size = "default", ...props }) {
|
|
36
|
+
const generatedId = useId();
|
|
37
|
+
const fieldId = id ?? generatedId;
|
|
38
|
+
const sizeValue = size ?? "default";
|
|
39
|
+
return /* @__PURE__ */ jsx(NumberFieldContext.Provider, {
|
|
40
|
+
value: {
|
|
41
|
+
fieldId,
|
|
42
|
+
size: sizeValue
|
|
43
|
+
},
|
|
44
|
+
children: /* @__PURE__ */ jsx(NumberField$1.Root, {
|
|
45
|
+
className: cn("flex w-full flex-col items-start gap-2", className),
|
|
46
|
+
"data-size": sizeValue,
|
|
47
|
+
"data-slot": "number-field",
|
|
48
|
+
id: fieldId,
|
|
49
|
+
...props
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function NumberFieldGroup({ className, size: sizeProp, ...props }) {
|
|
54
|
+
const context = useContext(NumberFieldContext);
|
|
55
|
+
if (!context) throw new Error("NumberFieldGroup must be used within a NumberField component.");
|
|
56
|
+
const size = sizeProp ?? context.size;
|
|
57
|
+
return /* @__PURE__ */ jsx(NumberField$1.Group, {
|
|
58
|
+
className: cn(numberFieldGroupVariants({ size }), className),
|
|
59
|
+
"data-slot": "number-field-group",
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function NumberFieldDecrement({ className, size: sizeProp, children, ...props }) {
|
|
64
|
+
const context = useContext(NumberFieldContext);
|
|
65
|
+
if (!context) throw new Error("NumberFieldDecrement must be used within a NumberField component.");
|
|
66
|
+
const size = sizeProp ?? context.size;
|
|
67
|
+
return /* @__PURE__ */ jsx(NumberField$1.Decrement, {
|
|
68
|
+
className: cn(numberFieldButtonVariants({ size }), "rounded-s-lg border-e-0", className),
|
|
69
|
+
"data-slot": "number-field-decrement",
|
|
70
|
+
...props,
|
|
71
|
+
children: children ?? /* @__PURE__ */ jsx(MinusIcon, {})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function NumberFieldIncrement({ className, size: sizeProp, children, ...props }) {
|
|
75
|
+
const context = useContext(NumberFieldContext);
|
|
76
|
+
if (!context) throw new Error("NumberFieldIncrement must be used within a NumberField component.");
|
|
77
|
+
const size = sizeProp ?? context.size;
|
|
78
|
+
return /* @__PURE__ */ jsx(NumberField$1.Increment, {
|
|
79
|
+
className: cn(numberFieldButtonVariants({ size }), "rounded-e-lg border-s-0", className),
|
|
80
|
+
"data-slot": "number-field-increment",
|
|
81
|
+
...props,
|
|
82
|
+
children: children ?? /* @__PURE__ */ jsx(PlusIcon, {})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function NumberFieldInput({ className, size: sizeProp, ...props }) {
|
|
86
|
+
const context = useContext(NumberFieldContext);
|
|
87
|
+
if (!context) throw new Error("NumberFieldInput must be used within a NumberField component.");
|
|
88
|
+
const size = sizeProp ?? context.size;
|
|
89
|
+
return /* @__PURE__ */ jsx(NumberField$1.Input, {
|
|
90
|
+
className: cn(numberFieldInputVariants({ size }), className),
|
|
91
|
+
"data-slot": "number-field-input",
|
|
92
|
+
...props
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function NumberFieldScrubArea({ className, label, ...props }) {
|
|
96
|
+
const context = useContext(NumberFieldContext);
|
|
97
|
+
if (!context) throw new Error("NumberFieldScrubArea must be used within a NumberField component for accessibility.");
|
|
98
|
+
return /* @__PURE__ */ jsxs(NumberField$1.ScrubArea, {
|
|
99
|
+
className: cn("flex cursor-ew-resize", className),
|
|
100
|
+
"data-slot": "number-field-scrub-area",
|
|
101
|
+
...props,
|
|
102
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
103
|
+
className: "cursor-ew-resize",
|
|
104
|
+
htmlFor: context.fieldId,
|
|
105
|
+
children: label
|
|
106
|
+
}), /* @__PURE__ */ jsx(NumberField$1.ScrubAreaCursor, {
|
|
107
|
+
className: "drop-shadow-[0_1px_1px_#0008] filter",
|
|
108
|
+
children: /* @__PURE__ */ jsx(CursorGrowIcon, {})
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function CursorGrowIcon(props) {
|
|
113
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
114
|
+
fill: "black",
|
|
115
|
+
height: "14",
|
|
116
|
+
stroke: "white",
|
|
117
|
+
viewBox: "0 0 24 14",
|
|
118
|
+
width: "26",
|
|
119
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
120
|
+
...props,
|
|
121
|
+
children: /* @__PURE__ */ jsx("path", { d: "M19.5 5.5L6.49737 5.51844V2L1 6.9999L6.5 12L6.49737 8.5L19.5 8.5V12L25 6.9999L19.5 2V5.5Z" })
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { NumberField, NumberFieldDecrement, NumberFieldGroup, NumberFieldIncrement, NumberFieldInput, NumberFieldScrubArea };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=number-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field.js","names":["NumberFieldPrimitive"],"sources":["../../../src/components/reui/number-field.tsx"],"sourcesContent":["\"use client\";\n\nimport type * as React from \"react\";\nimport { createContext, type ReactNode, useContext, useId } from \"react\";\nimport { NumberField as NumberFieldPrimitive } from \"@base-ui/react/number-field\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { MinusIcon, PlusIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { Label } from \"../ui/label\";\n\nconst NumberFieldContext = createContext<{\n fieldId: string;\n size: \"sm\" | \"default\" | \"lg\";\n} | null>(null);\n\nconst numberFieldGroupVariants = cva(\n \"relative flex w-full justify-between rounded-lg border border-input bg-transparent transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 focus-within:has-aria-invalid:border-destructive focus-within:has-aria-invalid:ring-destructive/20 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:focus-within:has-aria-invalid:ring-destructive/40\",\n {\n variants: {\n size: {\n sm: \"h-7 text-sm\",\n default: \"h-8 text-sm\",\n lg: \"h-9 text-sm\",\n },\n },\n defaultVariants: {\n size: \"default\",\n },\n },\n);\n\nconst numberFieldButtonVariants = cva(\n \"relative flex shrink-0 cursor-pointer items-center justify-center transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:bg-accent [&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n size: {\n sm: \"px-1.5 [&_svg:not([class*='size-'])]:size-3.5\",\n default: \"px-2\",\n lg: \"px-2.5\",\n },\n },\n defaultVariants: {\n size: \"default\",\n },\n },\n);\n\nconst numberFieldInputVariants = cva(\n \"w-full min-w-0 flex-1 bg-transparent text-center tabular-nums outline-none\",\n {\n variants: {\n size: {\n sm: \"px-2 py-0.5\",\n default: \"px-2.5 py-1\",\n lg: \"px-2.5 py-1.5\",\n },\n },\n defaultVariants: {\n size: \"default\",\n },\n },\n);\n\nfunction NumberField({\n id,\n className,\n size = \"default\",\n ...props\n}: NumberFieldPrimitive.Root.Props & VariantProps<typeof numberFieldGroupVariants>) {\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n const sizeValue = size ?? \"default\";\n\n return (\n <NumberFieldContext.Provider value={{ fieldId, size: sizeValue }}>\n <NumberFieldPrimitive.Root\n className={cn(\"flex w-full flex-col items-start gap-2\", className)}\n data-size={sizeValue}\n data-slot=\"number-field\"\n id={fieldId}\n {...props}\n />\n </NumberFieldContext.Provider>\n );\n}\n\nfunction NumberFieldGroup({\n className,\n size: sizeProp,\n ...props\n}: NumberFieldPrimitive.Group.Props & Partial<VariantProps<typeof numberFieldGroupVariants>>) {\n const context = useContext(NumberFieldContext);\n if (!context) {\n throw new Error(\"NumberFieldGroup must be used within a NumberField component.\");\n }\n const size = sizeProp ?? context.size;\n\n return (\n <NumberFieldPrimitive.Group\n className={cn(numberFieldGroupVariants({ size }), className)}\n data-slot=\"number-field-group\"\n {...props}\n />\n );\n}\n\nfunction NumberFieldDecrement({\n className,\n size: sizeProp,\n children,\n ...props\n}: NumberFieldPrimitive.Decrement.Props &\n Partial<VariantProps<typeof numberFieldButtonVariants>> & {\n children?: React.ReactNode;\n }) {\n const context = useContext(NumberFieldContext);\n if (!context) {\n throw new Error(\"NumberFieldDecrement must be used within a NumberField component.\");\n }\n const size = sizeProp ?? context.size;\n\n return (\n <NumberFieldPrimitive.Decrement\n className={cn(numberFieldButtonVariants({ size }), \"rounded-s-lg border-e-0\", className)}\n data-slot=\"number-field-decrement\"\n {...props}\n >\n {children ?? <MinusIcon />}\n </NumberFieldPrimitive.Decrement>\n );\n}\n\nfunction NumberFieldIncrement({\n className,\n size: sizeProp,\n children,\n ...props\n}: NumberFieldPrimitive.Increment.Props &\n Partial<VariantProps<typeof numberFieldButtonVariants>> & {\n children?: ReactNode;\n }) {\n const context = useContext(NumberFieldContext);\n if (!context) {\n throw new Error(\"NumberFieldIncrement must be used within a NumberField component.\");\n }\n const size = sizeProp ?? context.size;\n\n return (\n <NumberFieldPrimitive.Increment\n className={cn(numberFieldButtonVariants({ size }), \"rounded-e-lg border-s-0\", className)}\n data-slot=\"number-field-increment\"\n {...props}\n >\n {children ?? <PlusIcon />}\n </NumberFieldPrimitive.Increment>\n );\n}\n\nfunction NumberFieldInput({\n className,\n size: sizeProp,\n ...props\n}: NumberFieldPrimitive.Input.Props & Partial<VariantProps<typeof numberFieldInputVariants>>) {\n const context = useContext(NumberFieldContext);\n if (!context) {\n throw new Error(\"NumberFieldInput must be used within a NumberField component.\");\n }\n const size = sizeProp ?? context.size;\n\n return (\n <NumberFieldPrimitive.Input\n className={cn(numberFieldInputVariants({ size }), className)}\n data-slot=\"number-field-input\"\n {...props}\n />\n );\n}\n\nfunction NumberFieldScrubArea({\n className,\n label,\n ...props\n}: NumberFieldPrimitive.ScrubArea.Props & {\n label: string;\n}) {\n const context = useContext(NumberFieldContext);\n if (!context) {\n throw new Error(\n \"NumberFieldScrubArea must be used within a NumberField component for accessibility.\",\n );\n }\n\n return (\n <NumberFieldPrimitive.ScrubArea\n className={cn(\"flex cursor-ew-resize\", className)}\n data-slot=\"number-field-scrub-area\"\n {...props}\n >\n <Label className=\"cursor-ew-resize\" htmlFor={context.fieldId}>\n {label}\n </Label>\n <NumberFieldPrimitive.ScrubAreaCursor className=\"drop-shadow-[0_1px_1px_#0008] filter\">\n <CursorGrowIcon />\n </NumberFieldPrimitive.ScrubAreaCursor>\n </NumberFieldPrimitive.ScrubArea>\n );\n}\n\nfunction CursorGrowIcon(props: React.ComponentProps<\"svg\">) {\n return (\n <svg\n fill=\"black\"\n height=\"14\"\n stroke=\"white\"\n viewBox=\"0 0 24 14\"\n width=\"26\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path d=\"M19.5 5.5L6.49737 5.51844V2L1 6.9999L6.5 12L6.49737 8.5L19.5 8.5V12L25 6.9999L19.5 2V5.5Z\" />\n </svg>\n );\n}\n\nexport {\n NumberField,\n NumberFieldDecrement,\n NumberFieldGroup,\n NumberFieldIncrement,\n NumberFieldInput,\n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,iBAAtB;GAAsC,WAAU;GAC9C,UAAA,oBAAC,gBAAD,CAAiB,CAAA;EACmB,CAAA,CACR;;AAEpC;AAEA,SAAS,eAAe,OAAoC;CAC1D,OACE,oBAAC,OAAD;EACE,MAAK;EACL,QAAO;EACP,QAAO;EACP,SAAQ;EACR,OAAM;EACN,OAAM;EACN,GAAI;EAEJ,UAAA,oBAAC,QAAD,EAAM,GAAE,4FAA6F,CAAA;CAClG,CAAA;AAET"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as BasePhoneInput from "react-phone-number-input";
|
|
2
|
+
//#region src/components/reui/phone-input.d.ts
|
|
3
|
+
type PhoneInputSize = "sm" | "default" | "lg";
|
|
4
|
+
type PhoneInputProps = Omit<React.ComponentProps<"input">, "onChange" | "value" | "ref"> & Omit<BasePhoneInput.Props<typeof BasePhoneInput.default>, "onChange" | "variant" | "popupClassName" | "scrollAreaClassName"> & {
|
|
5
|
+
onChange?: (value: BasePhoneInput.Value) => void;
|
|
6
|
+
variant?: PhoneInputSize;
|
|
7
|
+
popupClassName?: string;
|
|
8
|
+
scrollAreaClassName?: string;
|
|
9
|
+
};
|
|
10
|
+
declare function PhoneInput({ className, variant, popupClassName, scrollAreaClassName, onChange, value, ...props }: PhoneInputProps): import("react").JSX.Element;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { PhoneInput };
|
|
13
|
+
//# sourceMappingURL=phone-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-input.d.ts","names":[],"sources":["../../../src/components/reui/phone-input.tsx"],"mappings":";;KAuBK;KAYA,kBAAkB,KAAK,MAAM,yDAChC,KACE,eAAe,aAAa,eAAe;EAG3C,YAAY,OAAO,eAAe;EAClC,UAAU;EACV;EACA;;iBAGK,aACP,WACA,SACA,gBACA,qBACA,UACA,UACG,SACF,kCAAe,IAAA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ScrollArea } from "../ui/scroll-area.js";
|
|
3
|
+
import { Button } from "../ui/button.js";
|
|
4
|
+
import { Input } from "../ui/input.js";
|
|
5
|
+
import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue } from "../ui/combobox.js";
|
|
6
|
+
import { createContext, useContext, useMemo, useState } from "react";
|
|
7
|
+
import { cn } from "@kumix/utils";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { GlobeIcon } from "lucide-react";
|
|
10
|
+
import * as BasePhoneInput from "react-phone-number-input";
|
|
11
|
+
import flags from "react-phone-number-input/flags";
|
|
12
|
+
//#region src/components/reui/phone-input.tsx
|
|
13
|
+
const PhoneInputContext = createContext({
|
|
14
|
+
variant: "default",
|
|
15
|
+
popupClassName: void 0,
|
|
16
|
+
scrollAreaClassName: void 0
|
|
17
|
+
});
|
|
18
|
+
function PhoneInput({ className, variant, popupClassName, scrollAreaClassName, onChange, value, ...props }) {
|
|
19
|
+
const phoneInputSize = variant || "default";
|
|
20
|
+
return /* @__PURE__ */ jsx(PhoneInputContext.Provider, {
|
|
21
|
+
value: {
|
|
22
|
+
variant: phoneInputSize,
|
|
23
|
+
popupClassName,
|
|
24
|
+
scrollAreaClassName
|
|
25
|
+
},
|
|
26
|
+
children: /* @__PURE__ */ jsx(BasePhoneInput.default, {
|
|
27
|
+
className: cn("flex", props["aria-invalid"] && "[&_*[data-slot=combobox-trigger]]:border-destructive [&_*[data-slot=combobox-trigger]]:ring-destructive/50", className),
|
|
28
|
+
flagComponent: FlagComponent,
|
|
29
|
+
countrySelectComponent: CountrySelect,
|
|
30
|
+
inputComponent: InputComponent,
|
|
31
|
+
smartCaret: false,
|
|
32
|
+
value: value || void 0,
|
|
33
|
+
onChange: (value) => onChange?.(value || ""),
|
|
34
|
+
...props
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function InputComponent({ className, ...props }) {
|
|
39
|
+
const { variant } = useContext(PhoneInputContext);
|
|
40
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
41
|
+
className: cn("rounded-s-none outline-none! ring-none! focus:z-1", variant === "sm" && "h-7", variant === "lg" && "h-9", className),
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function CountrySelect({ disabled, value: selectedCountry, options: countryList, onChange }) {
|
|
46
|
+
const { variant, popupClassName } = useContext(PhoneInputContext);
|
|
47
|
+
const [searchValue, setSearchValue] = useState("");
|
|
48
|
+
const filteredCountries = useMemo(() => {
|
|
49
|
+
if (!searchValue) return countryList;
|
|
50
|
+
return countryList.filter(({ label }) => label.toLowerCase().includes(searchValue.toLowerCase()));
|
|
51
|
+
}, [countryList, searchValue]);
|
|
52
|
+
return /* @__PURE__ */ jsxs(Combobox, {
|
|
53
|
+
items: filteredCountries,
|
|
54
|
+
value: selectedCountry || "",
|
|
55
|
+
onValueChange: (country) => {
|
|
56
|
+
if (country) onChange(country);
|
|
57
|
+
},
|
|
58
|
+
children: [/* @__PURE__ */ jsx(ComboboxTrigger, { render: /* @__PURE__ */ jsxs(Button, {
|
|
59
|
+
variant: "outline",
|
|
60
|
+
size: variant,
|
|
61
|
+
className: cn("flex gap-1 rounded-s-lg rounded-e-none border-e-0 px-2.5 py-0 leading-none hover:bg-transparent focus:z-10 data-pressed:bg-transparent", disabled && "opacity-50"),
|
|
62
|
+
disabled,
|
|
63
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
64
|
+
className: "sr-only",
|
|
65
|
+
children: /* @__PURE__ */ jsx(ComboboxValue, {})
|
|
66
|
+
}), /* @__PURE__ */ jsx(FlagComponent, {
|
|
67
|
+
country: selectedCountry,
|
|
68
|
+
countryName: selectedCountry
|
|
69
|
+
})]
|
|
70
|
+
}) }), /* @__PURE__ */ jsxs(ComboboxContent, {
|
|
71
|
+
className: cn("w-xs *:data-[slot=input-group]:bg-transparent", popupClassName),
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx(ComboboxInput, {
|
|
74
|
+
placeholder: "e.g. United States",
|
|
75
|
+
value: searchValue,
|
|
76
|
+
onChange: (e) => setSearchValue(e.target.value),
|
|
77
|
+
showTrigger: false,
|
|
78
|
+
className: "rounded-none border-0 border-input px-0 py-2.5 shadow-none outline-none! ring-0! focus-visible:border-border focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx(ComboboxSeparator, {}),
|
|
81
|
+
/* @__PURE__ */ jsx(ComboboxEmpty, {
|
|
82
|
+
className: "px-4 py-2.5 text-sm",
|
|
83
|
+
children: "No country found."
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx(ComboboxList, { children: /* @__PURE__ */ jsx("div", {
|
|
86
|
+
className: "relative flex max-h-full",
|
|
87
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
88
|
+
className: "flex max-h-[min(var(--available-height),24rem)] w-full scroll-pt-2 scroll-pb-2 flex-col overscroll-contain",
|
|
89
|
+
children: /* @__PURE__ */ jsx(ScrollArea, {
|
|
90
|
+
className: "size-full min-h-0 **:data-[slot=scroll-area-scrollbar]:m-0 **:data-[slot=scroll-area-viewport]:h-full **:data-[slot=scroll-area-viewport]:overscroll-contain",
|
|
91
|
+
children: filteredCountries.map((item) => item.value ? /* @__PURE__ */ jsxs(ComboboxItem, {
|
|
92
|
+
value: item.value,
|
|
93
|
+
className: "flex items-center gap-2",
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ jsx(FlagComponent, {
|
|
96
|
+
country: item.value,
|
|
97
|
+
countryName: item.label
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ jsx("span", {
|
|
100
|
+
className: "flex-1 text-sm",
|
|
101
|
+
children: item.label
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ jsx("span", {
|
|
104
|
+
className: "text-foreground/50 text-sm",
|
|
105
|
+
children: `+${BasePhoneInput.getCountryCallingCode(item.value)}`
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}, item.value) : null)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
}) })
|
|
112
|
+
]
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function FlagComponent({ country, countryName }) {
|
|
117
|
+
const Flag = flags[country];
|
|
118
|
+
return /* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: "flex h-4 w-4 items-center justify-center [&_svg:not([class*='size-'])]:size-full! [&_svg:not([class*='size-'])]:rounded-[5px]",
|
|
120
|
+
children: Flag ? /* @__PURE__ */ jsx(Flag, { title: countryName }) : /* @__PURE__ */ jsx(GlobeIcon, { className: "size-4 opacity-60" })
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { PhoneInput };
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=phone-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-input.js","names":[],"sources":["../../../src/components/reui/phone-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo, useState } from \"react\";\nimport { GlobeIcon } from \"lucide-react\";\nimport * as BasePhoneInput from \"react-phone-number-input\";\nimport flags from \"react-phone-number-input/flags\";\n\nimport { cn } from \"@kumix/utils\";\nimport { Button } from \"../ui/button\";\nimport {\n Combobox,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxInput,\n ComboboxItem,\n ComboboxList,\n ComboboxSeparator,\n ComboboxTrigger,\n ComboboxValue,\n} from \"../ui/combobox\";\nimport { Input } from \"../ui/input\";\nimport { ScrollArea } from \"../ui/scroll-area\";\n\ntype PhoneInputSize = \"sm\" | \"default\" | \"lg\";\n\nconst PhoneInputContext = createContext<{\n variant: PhoneInputSize;\n popupClassName?: string;\n scrollAreaClassName?: string;\n}>({\n variant: \"default\",\n popupClassName: undefined,\n scrollAreaClassName: undefined,\n});\n\ntype PhoneInputProps = Omit<React.ComponentProps<\"input\">, \"onChange\" | \"value\" | \"ref\"> &\n Omit<\n BasePhoneInput.Props<typeof BasePhoneInput.default>,\n \"onChange\" | \"variant\" | \"popupClassName\" | \"scrollAreaClassName\"\n > & {\n onChange?: (value: BasePhoneInput.Value) => void;\n variant?: PhoneInputSize;\n popupClassName?: string;\n scrollAreaClassName?: string;\n };\n\nfunction PhoneInput({\n className,\n variant,\n popupClassName,\n scrollAreaClassName,\n onChange,\n value,\n ...props\n}: PhoneInputProps) {\n const phoneInputSize = variant || \"default\";\n return (\n <PhoneInputContext.Provider\n value={{ variant: phoneInputSize, popupClassName, scrollAreaClassName }}\n >\n <BasePhoneInput.default\n className={cn(\n \"flex\",\n props[\"aria-invalid\"] &&\n \"[&_*[data-slot=combobox-trigger]]:border-destructive [&_*[data-slot=combobox-trigger]]:ring-destructive/50\",\n className,\n )}\n flagComponent={FlagComponent}\n countrySelectComponent={CountrySelect}\n inputComponent={InputComponent}\n smartCaret={false}\n value={value || undefined}\n onChange={(value) => onChange?.(value || (\"\" as BasePhoneInput.Value))}\n {...props}\n />\n </PhoneInputContext.Provider>\n );\n}\n\nfunction InputComponent({ className, ...props }: React.ComponentProps<typeof Input>) {\n const { variant } = useContext(PhoneInputContext);\n\n return (\n <Input\n className={cn(\n \"rounded-s-none outline-none! ring-none! focus:z-1\",\n variant === \"sm\" && \"h-7\",\n variant === \"lg\" && \"h-9\",\n className,\n )}\n {...props}\n />\n );\n}\n\ntype CountryEntry = { label: string; value: BasePhoneInput.Country | undefined };\n\ntype CountrySelectProps = {\n disabled?: boolean;\n value: BasePhoneInput.Country;\n options: CountryEntry[];\n onChange: (country: BasePhoneInput.Country) => void;\n};\n\nfunction CountrySelect({\n disabled,\n value: selectedCountry,\n options: countryList,\n onChange,\n}: CountrySelectProps) {\n const { variant, popupClassName } = useContext(PhoneInputContext);\n const [searchValue, setSearchValue] = useState(\"\");\n\n const filteredCountries = useMemo(() => {\n if (!searchValue) return countryList;\n return countryList.filter(({ label }) =>\n label.toLowerCase().includes(searchValue.toLowerCase()),\n );\n }, [countryList, searchValue]);\n\n return (\n <Combobox\n items={filteredCountries}\n value={selectedCountry || \"\"}\n onValueChange={(country: BasePhoneInput.Country | null) => {\n if (country) {\n onChange(country);\n }\n }}\n >\n <ComboboxTrigger\n render={\n <Button\n variant=\"outline\"\n size={variant}\n className={cn(\n \"flex gap-1 rounded-s-lg rounded-e-none border-e-0 px-2.5 py-0 leading-none hover:bg-transparent focus:z-10 data-pressed:bg-transparent\",\n disabled && \"opacity-50\",\n )}\n disabled={disabled}\n >\n <span className=\"sr-only\">\n <ComboboxValue />\n </span>\n <FlagComponent country={selectedCountry} countryName={selectedCountry} />\n </Button>\n }\n />\n <ComboboxContent\n className={cn(\"w-xs *:data-[slot=input-group]:bg-transparent\", popupClassName)}\n >\n <ComboboxInput\n placeholder=\"e.g. United States\"\n value={searchValue}\n onChange={(e) => setSearchValue(e.target.value)}\n showTrigger={false}\n className=\"rounded-none border-0 border-input px-0 py-2.5 shadow-none outline-none! ring-0! focus-visible:border-border focus-visible:ring-0 focus-visible:ring-offset-0\"\n />\n <ComboboxSeparator />\n <ComboboxEmpty className=\"px-4 py-2.5 text-sm\">No country found.</ComboboxEmpty>\n <ComboboxList>\n <div className=\"relative flex max-h-full\">\n <div className=\"flex max-h-[min(var(--available-height),24rem)] w-full scroll-pt-2 scroll-pb-2 flex-col overscroll-contain\">\n <ScrollArea className=\"size-full min-h-0 **:data-[slot=scroll-area-scrollbar]:m-0 **:data-[slot=scroll-area-viewport]:h-full **:data-[slot=scroll-area-viewport]:overscroll-contain\">\n {filteredCountries.map((item: CountryEntry) =>\n item.value ? (\n <ComboboxItem\n key={item.value}\n value={item.value}\n className=\"flex items-center gap-2\"\n >\n <FlagComponent country={item.value} countryName={item.label} />\n <span className=\"flex-1 text-sm\">{item.label}</span>\n <span className=\"text-foreground/50 text-sm\">\n {`+${BasePhoneInput.getCountryCallingCode(item.value)}`}\n </span>\n </ComboboxItem>\n ) : null,\n )}\n </ScrollArea>\n </div>\n </div>\n </ComboboxList>\n </ComboboxContent>\n </Combobox>\n );\n}\n\nfunction FlagComponent({ country, countryName }: BasePhoneInput.FlagProps) {\n const Flag = flags[country];\n\n return (\n <span className=\"flex h-4 w-4 items-center justify-center [&_svg:not([class*='size-'])]:size-full! [&_svg:not([class*='size-'])]:rounded-[5px]\">\n {Flag ? <Flag title={countryName} /> : <GlobeIcon className=\"size-4 opacity-60\" />}\n </span>\n );\n}\n\nexport { PhoneInput };\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,oBAAoB,cAIvB;CACD,SAAS;CACT,gBAAgB,KAAA;CAChB,qBAAqB,KAAA;AACvB,CAAC;AAaD,SAAS,WAAW,EAClB,WACA,SACA,gBACA,qBACA,UACA,OACA,GAAG,SACe;CAClB,MAAM,iBAAiB,WAAW;CAClC,OACE,oBAAC,kBAAkB,UAAnB;EACE,OAAO;GAAE,SAAS;GAAgB;GAAgB;EAAoB;EAEtE,UAAA,oBAAC,eAAe,SAAhB;GACE,WAAW,GACT,QACA,MAAM,mBACJ,8GACF,SACF;GACA,eAAe;GACf,wBAAwB;GACxB,gBAAgB;GAChB,YAAY;GACZ,OAAO,SAAS,KAAA;GAChB,WAAW,UAAU,WAAW,SAAU,EAA2B;GACrE,GAAI;EACL,CAAA;CACyB,CAAA;AAEhC;AAEA,SAAS,eAAe,EAAE,WAAW,GAAG,SAA6C;CACnF,MAAM,EAAE,YAAY,WAAW,iBAAiB;CAEhD,OACE,oBAAC,OAAD;EACE,WAAW,GACT,qDACA,YAAY,QAAQ,OACpB,YAAY,QAAQ,OACpB,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAWA,SAAS,cAAc,EACrB,UACA,OAAO,iBACP,SAAS,aACT,YACqB;CACrB,MAAM,EAAE,SAAS,mBAAmB,WAAW,iBAAiB;CAChE,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;CAEjD,MAAM,oBAAoB,cAAc;EACtC,I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,IAAI,eAAe,sBAAsB,KAAK,KAAK;SAChD,CAAA;QACM;OATP,GAAA,KAAK,KASE,IACZ,IACN;MACU,CAAA;KACT,CAAA;IACF,CAAA,EACO,CAAA;GACC;EACT,CAAA,CAAA;;AAEd;AAEA,SAAS,cAAc,EAAE,SAAS,eAAyC;CACzE,MAAM,OAAO,MAAM;CAEnB,OACE,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA,OAAO,oBAAC,MAAD,EAAM,OAAO,YAAc,CAAA,IAAI,oBAAC,WAAD,EAAW,WAAU,oBAAqB,CAAA;CAC7E,CAAA;AAEV"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
//#region src/components/reui/rating.d.ts
|
|
3
|
+
declare const ratingVariants: (props?: ({
|
|
4
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function Rating({ rating, maxRating, size, className, starClassName, showValue, editable, onRatingChange, ...props }: React.ComponentProps<"div"> & VariantProps<typeof ratingVariants> & {
|
|
7
|
+
/**
|
|
8
|
+
* Current rating value (supports decimal values for partial stars)
|
|
9
|
+
*/
|
|
10
|
+
rating: number;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum rating value (number of stars to show)
|
|
13
|
+
*/
|
|
14
|
+
maxRating?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to show the numeric rating value
|
|
17
|
+
*/
|
|
18
|
+
showValue?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Class name for the value span
|
|
21
|
+
*/
|
|
22
|
+
starClassName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the rating is editable (clickable)
|
|
25
|
+
*/
|
|
26
|
+
editable?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Callback function called when rating changes
|
|
29
|
+
*/
|
|
30
|
+
onRatingChange?: (rating: number) => void;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Rating };
|
|
34
|
+
//# sourceMappingURL=rating.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rating.d.ts","names":[],"sources":["../../../src/components/reui/rating.tsx"],"mappings":";;cAQM,iBAAc;;6CAWlB;iBA4BO,SACP,QACA,WACA,MACA,WACA,eACA,WACA,UACA,mBACG,SACF,MAAM,wBACP,oBAAoB;;;;EAIlB;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA,kBAAkB;oBACnB,IAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { cn } from "@kumix/utils";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { StarIcon } from "lucide-react";
|
|
7
|
+
//#region src/components/reui/rating.tsx
|
|
8
|
+
const ratingVariants = cva("flex items-center", {
|
|
9
|
+
variants: { size: {
|
|
10
|
+
sm: "gap-2",
|
|
11
|
+
default: "gap-2.5",
|
|
12
|
+
lg: "gap-3"
|
|
13
|
+
} },
|
|
14
|
+
defaultVariants: { size: "default" }
|
|
15
|
+
});
|
|
16
|
+
const starVariants = cva("", {
|
|
17
|
+
variants: { size: {
|
|
18
|
+
sm: "h-4 w-4",
|
|
19
|
+
default: "h-5 w-5",
|
|
20
|
+
lg: "h-6 w-6"
|
|
21
|
+
} },
|
|
22
|
+
defaultVariants: { size: "default" }
|
|
23
|
+
});
|
|
24
|
+
const valueVariants = cva("w-5 text-muted-foreground", {
|
|
25
|
+
variants: { size: {
|
|
26
|
+
sm: "text-xs",
|
|
27
|
+
default: "text-sm",
|
|
28
|
+
lg: "text-base"
|
|
29
|
+
} },
|
|
30
|
+
defaultVariants: { size: "default" }
|
|
31
|
+
});
|
|
32
|
+
function Rating({ rating, maxRating = 5, size, className, starClassName, showValue = false, editable = false, onRatingChange, ...props }) {
|
|
33
|
+
const [hoveredRating, setHoveredRating] = useState(null);
|
|
34
|
+
const displayRating = editable && hoveredRating !== null ? hoveredRating : rating;
|
|
35
|
+
const handleStarClick = (starRating) => {
|
|
36
|
+
if (editable && onRatingChange) onRatingChange(starRating);
|
|
37
|
+
};
|
|
38
|
+
const handleStarMouseEnter = (starRating) => {
|
|
39
|
+
if (editable) setHoveredRating(starRating);
|
|
40
|
+
};
|
|
41
|
+
const handleStarMouseLeave = () => {
|
|
42
|
+
if (editable) setHoveredRating(null);
|
|
43
|
+
};
|
|
44
|
+
const renderStars = () => {
|
|
45
|
+
const stars = [];
|
|
46
|
+
for (let i = 1; i <= maxRating; i++) {
|
|
47
|
+
const filled = displayRating >= i;
|
|
48
|
+
const fillPercentage = displayRating > i - 1 && displayRating < i ? (displayRating - (i - 1)) * 100 : 0;
|
|
49
|
+
stars.push(/* @__PURE__ */ jsxs("div", {
|
|
50
|
+
role: editable ? "button" : void 0,
|
|
51
|
+
tabIndex: editable ? 0 : void 0,
|
|
52
|
+
className: cn("relative", editable && "cursor-pointer"),
|
|
53
|
+
onClick: () => handleStarClick(i),
|
|
54
|
+
onKeyDown: editable ? (e) => {
|
|
55
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
handleStarClick(i);
|
|
58
|
+
}
|
|
59
|
+
} : void 0,
|
|
60
|
+
onMouseEnter: () => handleStarMouseEnter(i),
|
|
61
|
+
onMouseLeave: handleStarMouseLeave,
|
|
62
|
+
children: [/* @__PURE__ */ jsx(StarIcon, {
|
|
63
|
+
"data-slot": "rating-star-empty",
|
|
64
|
+
className: cn(starVariants({ size }), "text-muted-foreground/30")
|
|
65
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
66
|
+
className: "absolute inset-0 overflow-hidden",
|
|
67
|
+
style: { width: filled ? "100%" : `${fillPercentage}%` },
|
|
68
|
+
children: /* @__PURE__ */ jsx(StarIcon, {
|
|
69
|
+
"data-slot": "rating-star-filled",
|
|
70
|
+
className: cn(starVariants({ size }), "fill-yellow-400 text-yellow-400")
|
|
71
|
+
})
|
|
72
|
+
})]
|
|
73
|
+
}, i));
|
|
74
|
+
}
|
|
75
|
+
return stars;
|
|
76
|
+
};
|
|
77
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
78
|
+
"data-slot": "rating",
|
|
79
|
+
className: cn(ratingVariants({ size }), className),
|
|
80
|
+
...props,
|
|
81
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
82
|
+
className: "flex items-center",
|
|
83
|
+
children: renderStars()
|
|
84
|
+
}), showValue && /* @__PURE__ */ jsx("span", {
|
|
85
|
+
"data-slot": "rating-value",
|
|
86
|
+
className: cn(valueVariants({ size }), starClassName),
|
|
87
|
+
children: displayRating.toFixed(1)
|
|
88
|
+
})]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { Rating };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=rating.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rating.js","names":[],"sources":["../../../src/components/reui/rating.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { StarIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\n\nconst ratingVariants = cva(\"flex items-center\", {\n variants: {\n size: {\n sm: \"gap-2\",\n default: \"gap-2.5\",\n lg: \"gap-3\",\n },\n },\n defaultVariants: {\n size: \"default\",\n },\n});\n\nconst starVariants = cva(\"\", {\n variants: {\n size: {\n sm: \"h-4 w-4\",\n default: \"h-5 w-5\",\n lg: \"h-6 w-6\",\n },\n },\n defaultVariants: {\n size: \"default\",\n },\n});\n\nconst valueVariants = cva(\"w-5 text-muted-foreground\", {\n variants: {\n size: {\n sm: \"text-xs\",\n default: \"text-sm\",\n lg: \"text-base\",\n },\n },\n defaultVariants: {\n size: \"default\",\n },\n});\n\nfunction Rating({\n rating,\n maxRating = 5,\n size,\n className,\n starClassName,\n showValue = false,\n editable = false,\n onRatingChange,\n ...props\n}: React.ComponentProps<\"div\"> &\n VariantProps<typeof ratingVariants> & {\n /**\n * Current rating value (supports decimal values for partial stars)\n */\n rating: number;\n /**\n * Maximum rating value (number of stars to show)\n */\n maxRating?: number;\n /**\n * Whether to show the numeric rating value\n */\n showValue?: boolean;\n /**\n * Class name for the value span\n */\n starClassName?: string;\n /**\n * Whether the rating is editable (clickable)\n */\n editable?: boolean;\n /**\n * Callback function called when rating changes\n */\n onRatingChange?: (rating: number) => void;\n }) {\n const [hoveredRating, setHoveredRating] = useState<number | null>(null);\n const displayRating = editable && hoveredRating !== null ? hoveredRating : rating;\n\n const handleStarClick = (starRating: number) => {\n if (editable && onRatingChange) {\n onRatingChange(starRating);\n }\n };\n\n const handleStarMouseEnter = (starRating: number) => {\n if (editable) {\n setHoveredRating(starRating);\n }\n };\n\n const handleStarMouseLeave = () => {\n if (editable) {\n setHoveredRating(null);\n }\n };\n\n const renderStars = () => {\n const stars = [];\n\n for (let i = 1; i <= maxRating; i++) {\n const filled = displayRating >= i;\n const partiallyFilled = displayRating > i - 1 && displayRating < i;\n const fillPercentage = partiallyFilled ? (displayRating - (i - 1)) * 100 : 0;\n\n stars.push(\n <div\n key={i}\n role={editable ? \"button\" : undefined}\n tabIndex={editable ? 0 : undefined}\n className={cn(\"relative\", editable && \"cursor-pointer\")}\n onClick={() => handleStarClick(i)}\n onKeyDown={\n editable\n ? (e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n handleStarClick(i);\n }\n }\n : undefined\n }\n onMouseEnter={() => handleStarMouseEnter(i)}\n onMouseLeave={handleStarMouseLeave}\n >\n {/* Background star (empty) */}\n <StarIcon\n data-slot=\"rating-star-empty\"\n className={cn(starVariants({ size }), \"text-muted-foreground/30\")}\n />\n\n {/* Filled star */}\n <div\n className=\"absolute inset-0 overflow-hidden\"\n style={{\n width: filled ? \"100%\" : `${fillPercentage}%`,\n }}\n >\n <StarIcon\n data-slot=\"rating-star-filled\"\n className={cn(starVariants({ size }), \"fill-yellow-400 text-yellow-400\")}\n />\n </div>\n </div>,\n );\n }\n\n return stars;\n };\n\n return (\n <div data-slot=\"rating\" className={cn(ratingVariants({ size }), className)} {...props}>\n <div className=\"flex items-center\">{renderStars()}</div>\n {showValue && (\n <span data-slot=\"rating-value\" className={cn(valueVariants({ size }), starClassName)}>\n {displayRating.toFixed(1)}\n </span>\n )}\n </div>\n );\n}\n\nexport { Rating };\n"],"mappings":";;;;;;;AAQA,MAAM,iBAAiB,IAAI,qBAAqB;CAC9C,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,SAAS;EACT,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,UACR;AACF,CAAC;AAED,MAAM,eAAe,IAAI,IAAI;CAC3B,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,SAAS;EACT,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,UACR;AACF,CAAC;AAED,MAAM,gBAAgB,IAAI,6BAA6B;CACrD,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,SAAS;EACT,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,UACR;AACF,CAAC;AAED,SAAS,OAAO,EACd,QACA,YAAY,GACZ,MACA,WACA,eACA,YAAY,OACZ,WAAW,OACX,gBACA,GAAG,SA2BA;CACH,MAAM,CAAC,eAAe,oBAAoB,SAAwB,IAAI;CACtE,MAAM,gBAAgB,YAAY,kBAAkB,OAAO,gBAAgB;CAE3E,MAAM,mBAAmB,eAAuB;EAC9C,IAAI,YAAY,gBACd,eAAe,UAAU;CAE7B;CAEA,MAAM,wBAAwB,eAAuB;EACnD,IAAI,UACF,iBAAiB,UAAU;CAE/B;CAEA,MAAM,6BAA6B;EACjC,IAAI,UACF,iBAAiB,IAAI;CAEzB;CAEA,MAAM,oBAAoB;EACxB,MAAM,QAAQ,CAAC;EAEf,KAAK,IAAI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region src/components/reui/scrollspy.d.ts
|
|
3
|
+
type ScrollspyProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
targetRef?: RefObject<HTMLElement | HTMLDivElement | Document | null | undefined>;
|
|
6
|
+
onUpdate?: (id: string) => void;
|
|
7
|
+
offset?: number;
|
|
8
|
+
smooth?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
dataAttribute?: string;
|
|
11
|
+
history?: boolean;
|
|
12
|
+
throttleTime?: number;
|
|
13
|
+
};
|
|
14
|
+
declare function Scrollspy({ children, targetRef, onUpdate, className, offset, smooth, dataAttribute, history }: ScrollspyProps): import("react").JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Scrollspy };
|
|
17
|
+
//# sourceMappingURL=scrollspy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollspy.d.ts","names":[],"sources":["../../../src/components/reui/scrollspy.tsx"],"mappings":";;KAIK;EACH,UAAU;EACV,YAAY,UAAU,cAAc,iBAAiB;EACrD,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;;iBAGc,YACd,UACA,WACA,UACA,WACA,QACA,QACA,eACA,WACC,iCAAc,IAAA"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/reui/scrollspy.tsx
|
|
5
|
+
function Scrollspy({ children, targetRef, onUpdate, className, offset = 0, smooth = true, dataAttribute = "scrollspy", history = true }) {
|
|
6
|
+
const selfRef = useRef(null);
|
|
7
|
+
const anchorElementsRef = useRef(null);
|
|
8
|
+
const prevIdTracker = useRef(null);
|
|
9
|
+
const setActiveSection = useCallback((sectionId, force = false) => {
|
|
10
|
+
if (!sectionId) return;
|
|
11
|
+
anchorElementsRef.current?.forEach((item) => {
|
|
12
|
+
if (item.getAttribute(`data-${dataAttribute}-anchor`) === sectionId) item.setAttribute("data-active", "true");
|
|
13
|
+
else item.removeAttribute("data-active");
|
|
14
|
+
});
|
|
15
|
+
if (onUpdate) onUpdate(sectionId);
|
|
16
|
+
if (history && (force || prevIdTracker.current !== sectionId)) window.history.replaceState({}, "", `#${sectionId}`);
|
|
17
|
+
prevIdTracker.current = sectionId;
|
|
18
|
+
}, [
|
|
19
|
+
dataAttribute,
|
|
20
|
+
history,
|
|
21
|
+
onUpdate
|
|
22
|
+
]);
|
|
23
|
+
const handleScroll = useCallback(() => {
|
|
24
|
+
if (!anchorElementsRef.current || anchorElementsRef.current.length === 0) return;
|
|
25
|
+
let scrollElement = targetRef?.current === document ? document.documentElement : targetRef?.current;
|
|
26
|
+
if (!scrollElement) return;
|
|
27
|
+
const viewport = scrollElement.querySelector("[data-slot=\"scroll-area-viewport\"]");
|
|
28
|
+
if (viewport instanceof HTMLElement) scrollElement = viewport;
|
|
29
|
+
const scrollTop = scrollElement === document.documentElement ? window.scrollY || document.documentElement.scrollTop : scrollElement.scrollTop;
|
|
30
|
+
let activeIdx = 0;
|
|
31
|
+
let minDelta = Infinity;
|
|
32
|
+
anchorElementsRef.current.forEach((anchor, idx) => {
|
|
33
|
+
const sectionId = anchor.getAttribute(`data-${dataAttribute}-anchor`);
|
|
34
|
+
const sectionElement = document.getElementById(sectionId);
|
|
35
|
+
if (!sectionElement) return;
|
|
36
|
+
let customOffset = offset;
|
|
37
|
+
const dataOffset = anchor.getAttribute(`data-${dataAttribute}-offset`);
|
|
38
|
+
if (dataOffset) customOffset = parseInt(dataOffset, 10);
|
|
39
|
+
const delta = Math.abs(sectionElement.offsetTop - customOffset - scrollTop);
|
|
40
|
+
if (sectionElement.offsetTop - customOffset <= scrollTop && delta < minDelta) {
|
|
41
|
+
minDelta = delta;
|
|
42
|
+
activeIdx = idx;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const scrollHeight = scrollElement.scrollHeight;
|
|
46
|
+
if (scrollTop + scrollElement.clientHeight >= scrollHeight - 2) activeIdx = anchorElementsRef.current.length - 1;
|
|
47
|
+
const sectionId = anchorElementsRef.current[activeIdx]?.getAttribute(`data-${dataAttribute}-anchor`) || null;
|
|
48
|
+
setActiveSection(sectionId);
|
|
49
|
+
}, [
|
|
50
|
+
targetRef,
|
|
51
|
+
dataAttribute,
|
|
52
|
+
offset,
|
|
53
|
+
setActiveSection
|
|
54
|
+
]);
|
|
55
|
+
const scrollTo = useCallback((anchorElement) => (event) => {
|
|
56
|
+
if (event) event.preventDefault();
|
|
57
|
+
const sectionId = anchorElement.getAttribute(`data-${dataAttribute}-anchor`)?.replace("#", "") || null;
|
|
58
|
+
if (!sectionId) return;
|
|
59
|
+
const sectionElement = document.getElementById(sectionId);
|
|
60
|
+
if (!sectionElement) return;
|
|
61
|
+
let scrollToElement = targetRef?.current === document ? window : targetRef?.current;
|
|
62
|
+
if (scrollToElement instanceof HTMLElement) {
|
|
63
|
+
const viewport = scrollToElement.querySelector("[data-slot=\"scroll-area-viewport\"]");
|
|
64
|
+
if (viewport instanceof HTMLElement) scrollToElement = viewport;
|
|
65
|
+
}
|
|
66
|
+
let customOffset = offset;
|
|
67
|
+
const dataOffset = anchorElement.getAttribute(`data-${dataAttribute}-offset`);
|
|
68
|
+
if (dataOffset) customOffset = parseInt(dataOffset, 10);
|
|
69
|
+
const scrollTop = sectionElement.offsetTop - customOffset;
|
|
70
|
+
if (scrollToElement && "scrollTo" in scrollToElement) scrollToElement.scrollTo({
|
|
71
|
+
top: scrollTop,
|
|
72
|
+
left: 0,
|
|
73
|
+
behavior: smooth ? "smooth" : "auto"
|
|
74
|
+
});
|
|
75
|
+
setActiveSection(sectionId, true);
|
|
76
|
+
}, [
|
|
77
|
+
dataAttribute,
|
|
78
|
+
offset,
|
|
79
|
+
smooth,
|
|
80
|
+
targetRef,
|
|
81
|
+
setActiveSection
|
|
82
|
+
]);
|
|
83
|
+
const scrollToHashSection = useCallback(() => {
|
|
84
|
+
const hash = CSS.escape(window.location.hash.replace("#", ""));
|
|
85
|
+
if (hash) {
|
|
86
|
+
const targetElement = document.querySelector(`[data-${dataAttribute}-anchor="${hash}"]`);
|
|
87
|
+
if (targetElement) scrollTo(targetElement)();
|
|
88
|
+
}
|
|
89
|
+
}, [dataAttribute, scrollTo]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (selfRef.current) anchorElementsRef.current = Array.from(selfRef.current.querySelectorAll(`[data-${dataAttribute}-anchor]`));
|
|
92
|
+
const currentAnchors = anchorElementsRef.current;
|
|
93
|
+
currentAnchors?.forEach((item) => {
|
|
94
|
+
item.addEventListener("click", scrollTo(item));
|
|
95
|
+
});
|
|
96
|
+
const onScroll = (event) => {
|
|
97
|
+
const scrollElement = targetRef?.current === document ? window : targetRef?.current;
|
|
98
|
+
if (!scrollElement) return;
|
|
99
|
+
if (scrollElement === window || scrollElement instanceof HTMLElement && scrollElement.contains(event.target)) handleScroll();
|
|
100
|
+
};
|
|
101
|
+
window.addEventListener("scroll", onScroll, true);
|
|
102
|
+
const initialTimeout = setTimeout(() => {
|
|
103
|
+
scrollToHashSection();
|
|
104
|
+
handleScroll();
|
|
105
|
+
}, 100);
|
|
106
|
+
return () => {
|
|
107
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
108
|
+
currentAnchors?.forEach((item) => {
|
|
109
|
+
item.removeEventListener("click", scrollTo(item));
|
|
110
|
+
});
|
|
111
|
+
clearTimeout(initialTimeout);
|
|
112
|
+
};
|
|
113
|
+
}, [
|
|
114
|
+
targetRef,
|
|
115
|
+
handleScroll,
|
|
116
|
+
dataAttribute,
|
|
117
|
+
scrollTo,
|
|
118
|
+
scrollToHashSection
|
|
119
|
+
]);
|
|
120
|
+
return /* @__PURE__ */ jsx("div", {
|
|
121
|
+
"data-slot": "scrollspy",
|
|
122
|
+
className,
|
|
123
|
+
ref: selfRef,
|
|
124
|
+
children
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { Scrollspy };
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=scrollspy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollspy.js","names":[],"sources":["../../../src/components/reui/scrollspy.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, type RefObject, useCallback, useEffect, useRef } from \"react\";\n\ntype ScrollspyProps = {\n children: ReactNode;\n targetRef?: RefObject<HTMLElement | HTMLDivElement | Document | null | undefined>;\n onUpdate?: (id: string) => void;\n offset?: number;\n smooth?: boolean;\n className?: string;\n dataAttribute?: string;\n history?: boolean;\n throttleTime?: number;\n};\n\nexport function Scrollspy({\n children,\n targetRef,\n onUpdate,\n className,\n offset = 0,\n smooth = true,\n dataAttribute = \"scrollspy\",\n history = true,\n}: ScrollspyProps) {\n const selfRef = useRef<HTMLDivElement | null>(null);\n const anchorElementsRef = useRef<Element[] | null>(null);\n const prevIdTracker = useRef<string | null>(null);\n\n // Sets active nav, hash, prevIdTracker, and calls onUpdate\n const setActiveSection = useCallback(\n (sectionId: string | null, force = false) => {\n if (!sectionId) return;\n anchorElementsRef.current?.forEach((item) => {\n const id = item.getAttribute(`data-${dataAttribute}-anchor`);\n if (id === sectionId) {\n item.setAttribute(\"data-active\", \"true\");\n } else {\n item.removeAttribute(\"data-active\");\n }\n });\n if (onUpdate) onUpdate(sectionId);\n if (history && (force || prevIdTracker.current !== sectionId)) {\n window.history.replaceState({}, \"\", `#${sectionId}`);\n }\n prevIdTracker.current = sectionId;\n },\n [dataAttribute, history, onUpdate],\n );\n\n const handleScroll = useCallback(() => {\n if (!anchorElementsRef.current || anchorElementsRef.current.length === 0) return;\n\n let scrollElement =\n targetRef?.current === document\n ? document.documentElement\n : (targetRef?.current as HTMLElement);\n\n if (!scrollElement) return;\n\n // If the scrollElement has a data-slot=\"scroll-area-viewport\" inside, use that\n const viewport = scrollElement.querySelector('[data-slot=\"scroll-area-viewport\"]');\n if (viewport instanceof HTMLElement) {\n scrollElement = viewport;\n }\n\n const scrollTop =\n scrollElement === document.documentElement\n ? window.scrollY || document.documentElement.scrollTop\n : scrollElement.scrollTop;\n\n // Find the anchor whose section is closest to but not past the top\n let activeIdx = 0;\n let minDelta = Infinity;\n\n anchorElementsRef.current.forEach((anchor, idx) => {\n const sectionId = anchor.getAttribute(`data-${dataAttribute}-anchor`);\n const sectionElement = document.getElementById(sectionId!);\n if (!sectionElement) return;\n\n let customOffset = offset;\n const dataOffset = anchor.getAttribute(`data-${dataAttribute}-offset`);\n if (dataOffset) customOffset = parseInt(dataOffset, 10);\n\n const delta = Math.abs(sectionElement.offsetTop - customOffset - scrollTop);\n\n if (sectionElement.offsetTop - customOffset <= scrollTop && delta < minDelta) {\n minDelta = delta;\n activeIdx = idx;\n }\n });\n\n // If at bottom, force last anchor\n const scrollHeight = (scrollElement as HTMLElement).scrollHeight;\n const clientHeight = (scrollElement as HTMLElement).clientHeight;\n\n if (scrollTop + clientHeight >= scrollHeight - 2) {\n activeIdx = anchorElementsRef.current.length - 1;\n }\n\n // Set only one anchor active and sync the URL hash\n const activeAnchor = anchorElementsRef.current[activeIdx];\n const sectionId = activeAnchor?.getAttribute(`data-${dataAttribute}-anchor`) || null;\n\n setActiveSection(sectionId);\n }, [targetRef, dataAttribute, offset, setActiveSection]);\n\n const scrollTo = useCallback(\n (anchorElement: HTMLElement) => (event?: Event) => {\n if (event) event.preventDefault();\n const sectionId =\n anchorElement.getAttribute(`data-${dataAttribute}-anchor`)?.replace(\"#\", \"\") || null;\n if (!sectionId) return;\n const sectionElement = document.getElementById(sectionId);\n if (!sectionElement) return;\n\n let scrollToElement: HTMLElement | Window | null =\n targetRef?.current === document ? window : (targetRef?.current as HTMLElement);\n\n if (scrollToElement instanceof HTMLElement) {\n const viewport = scrollToElement.querySelector('[data-slot=\"scroll-area-viewport\"]');\n if (viewport instanceof HTMLElement) {\n scrollToElement = viewport;\n }\n }\n\n let customOffset = offset;\n const dataOffset = anchorElement.getAttribute(`data-${dataAttribute}-offset`);\n if (dataOffset) {\n customOffset = parseInt(dataOffset, 10);\n }\n\n const scrollTop = sectionElement.offsetTop - customOffset;\n\n if (scrollToElement && \"scrollTo\" in scrollToElement) {\n scrollToElement.scrollTo({\n top: scrollTop,\n left: 0,\n behavior: smooth ? \"smooth\" : \"auto\",\n });\n }\n setActiveSection(sectionId, true);\n },\n [dataAttribute, offset, smooth, targetRef, setActiveSection],\n );\n\n // Scroll to the section if the ID is present in the URL hash\n const scrollToHashSection = useCallback(() => {\n const hash = CSS.escape(window.location.hash.replace(\"#\", \"\"));\n\n if (hash) {\n const targetElement = document.querySelector(\n `[data-${dataAttribute}-anchor=\"${hash}\"]`,\n ) as HTMLElement;\n if (targetElement) {\n scrollTo(targetElement)();\n }\n }\n }, [dataAttribute, scrollTo]);\n\n useEffect(() => {\n // Query elements and store them in the ref, avoiding unnecessary re-renders\n if (selfRef.current) {\n anchorElementsRef.current = Array.from(\n selfRef.current.querySelectorAll(`[data-${dataAttribute}-anchor]`),\n );\n }\n\n const currentAnchors = anchorElementsRef.current;\n currentAnchors?.forEach((item) => {\n item.addEventListener(\"click\", scrollTo(item as HTMLElement));\n });\n\n const onScroll = (event: Event) => {\n const scrollElement =\n targetRef?.current === document ? window : (targetRef?.current as HTMLElement);\n if (!scrollElement) return;\n\n if (\n scrollElement === window ||\n (scrollElement instanceof HTMLElement && scrollElement.contains(event.target as Node))\n ) {\n handleScroll();\n }\n };\n\n // Use window listener with capture to catch scroll events from targetRef even if set later\n window.addEventListener(\"scroll\", onScroll, true);\n\n // Check if there's a hash in the URL and scroll to the corresponding section\n const initialTimeout = setTimeout(() => {\n scrollToHashSection();\n handleScroll();\n }, 100);\n\n return () => {\n window.removeEventListener(\"scroll\", onScroll, true);\n currentAnchors?.forEach((item) => {\n item.removeEventListener(\"click\", scrollTo(item as HTMLElement));\n });\n clearTimeout(initialTimeout);\n };\n }, [targetRef, handleScroll, dataAttribute, scrollTo, scrollToHashSection]);\n\n return (\n <div data-slot=\"scrollspy\" className={className} ref={selfRef}>\n {children}\n </div>\n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