@kumix/ui 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -88
- 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/theme.css +244 -0
- package/dist/theme.css.d.ts +3 -0
- package/package.json +105 -36
- 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/use-is-mobile-Dln4-L1O.js +0 -210
- package/dist/use-is-mobile-Dln4-L1O.js.map +0 -1
package/dist/hooks.js
DELETED
|
@@ -1,1391 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { n as useCopyToClipboard, t as useIsMobile } from "./use-is-mobile-Dln4-L1O.js";
|
|
3
|
-
import * as React$1 from "react";
|
|
4
|
-
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
5
|
-
import { META_THEME_COLORS, THEME_MODES } from "@kumix/utils";
|
|
6
|
-
import { useTheme } from "next-themes";
|
|
7
|
-
//#region src/hooks/use-body-classes.ts
|
|
8
|
-
/**
|
|
9
|
-
* Body class management hook for React components.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Adds classes to `document.body` while the component is mounted.
|
|
13
|
-
* Shared classes are reference-counted, so one component unmounting does not
|
|
14
|
-
* remove a class that another mounted component still owns.
|
|
15
|
-
*
|
|
16
|
-
* @param className - Space-separated string of CSS class names to apply to body
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* // Single class
|
|
21
|
-
* useBodyClasses('dark-theme');
|
|
22
|
-
*
|
|
23
|
-
* // Multiple classes
|
|
24
|
-
* useBodyClasses('modal-open overflow-hidden');
|
|
25
|
-
*
|
|
26
|
-
* // Conditional classes
|
|
27
|
-
* useBodyClasses(isModalOpen ? 'modal-open' : '');
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
const useBodyClasses = (className) => {
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (!className.trim()) return;
|
|
33
|
-
const classList = className.split(/\s+/).filter(Boolean);
|
|
34
|
-
classList.forEach((cls) => {
|
|
35
|
-
const count = bodyClassCounts.get(cls) ?? 0;
|
|
36
|
-
bodyClassCounts.set(cls, count + 1);
|
|
37
|
-
if (count === 0) document.body.classList.add(cls);
|
|
38
|
-
});
|
|
39
|
-
return () => {
|
|
40
|
-
classList.forEach((cls) => {
|
|
41
|
-
const nextCount = (bodyClassCounts.get(cls) ?? 1) - 1;
|
|
42
|
-
if (nextCount <= 0) {
|
|
43
|
-
bodyClassCounts.delete(cls);
|
|
44
|
-
document.body.classList.remove(cls);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
bodyClassCounts.set(cls, nextCount);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
}, [className]);
|
|
51
|
-
};
|
|
52
|
-
const bodyClassCounts = /* @__PURE__ */ new Map();
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/hooks/use-file-upload.ts
|
|
55
|
-
/**
|
|
56
|
-
* File upload functionality hook for React components
|
|
57
|
-
* Provides comprehensive file upload capabilities with drag & drop support
|
|
58
|
-
* Includes validation, preview generation, and state management
|
|
59
|
-
*/
|
|
60
|
-
const EMPTY_INITIAL_FILES = [];
|
|
61
|
-
/**
|
|
62
|
-
* Hook for comprehensive file upload functionality with drag & drop support
|
|
63
|
-
*
|
|
64
|
-
* Features:
|
|
65
|
-
* - Single and multiple file upload support
|
|
66
|
-
* - Drag and drop functionality
|
|
67
|
-
* - File validation (size, type, count)
|
|
68
|
-
* - Preview generation for images
|
|
69
|
-
* - Error handling and state management
|
|
70
|
-
* - Duplicate file detection
|
|
71
|
-
* - Memory cleanup for object URLs
|
|
72
|
-
*
|
|
73
|
-
* @param options - Configuration options for the file upload hook
|
|
74
|
-
* @returns Tuple containing current state and available actions
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```tsx
|
|
78
|
-
* const [state, actions] = useFileUpload({
|
|
79
|
-
* maxFiles: 5,
|
|
80
|
-
* maxSize: 10 * 1024 * 1024, // 10MB
|
|
81
|
-
* accept: 'image/*',
|
|
82
|
-
* multiple: true,
|
|
83
|
-
* onFilesChange: (files) => console.log('Files changed:', files),
|
|
84
|
-
* onFilesAdded: (newFiles) => console.log('New files added:', newFiles)
|
|
85
|
-
* });
|
|
86
|
-
*
|
|
87
|
-
* return (
|
|
88
|
-
* <div
|
|
89
|
-
* onDragEnter={actions.handleDragEnter}
|
|
90
|
-
* onDragLeave={actions.handleDragLeave}
|
|
91
|
-
* onDragOver={actions.handleDragOver}
|
|
92
|
-
* onDrop={actions.handleDrop}
|
|
93
|
-
* >
|
|
94
|
-
* <input {...actions.getInputProps()} />
|
|
95
|
-
* <button onClick={actions.openFileDialog}>
|
|
96
|
-
* Upload Files
|
|
97
|
-
* </button>
|
|
98
|
-
* {state.files.map(file => (
|
|
99
|
-
* <div key={file.id}>
|
|
100
|
-
* {file.file.name}
|
|
101
|
-
* <button onClick={() => actions.removeFile(file.id)}>
|
|
102
|
-
* Remove
|
|
103
|
-
* </button>
|
|
104
|
-
* </div>
|
|
105
|
-
* ))}
|
|
106
|
-
* </div>
|
|
107
|
-
* );
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
const useFileUpload = (options = {}) => {
|
|
111
|
-
const { maxFiles = Number.POSITIVE_INFINITY, maxSize = Number.POSITIVE_INFINITY, accept = "*", multiple = false, initialFiles = EMPTY_INITIAL_FILES, onFilesChange, onFilesAdded, onError } = options;
|
|
112
|
-
/** Current state of the file upload component */
|
|
113
|
-
const [state, setState] = useState({
|
|
114
|
-
files: initialFiles.map((file) => ({
|
|
115
|
-
file,
|
|
116
|
-
id: file.id,
|
|
117
|
-
preview: file.url
|
|
118
|
-
})),
|
|
119
|
-
isDragging: false,
|
|
120
|
-
errors: []
|
|
121
|
-
});
|
|
122
|
-
/** Reference to the hidden file input element */
|
|
123
|
-
const inputRef = useRef(null);
|
|
124
|
-
const filesRef = useRef([]);
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
filesRef.current = state.files;
|
|
127
|
-
}, [state.files]);
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
setState((prev) => ({
|
|
130
|
-
...prev,
|
|
131
|
-
files: initialFiles.map((file) => ({
|
|
132
|
-
file,
|
|
133
|
-
id: file.id,
|
|
134
|
-
preview: file.url
|
|
135
|
-
})),
|
|
136
|
-
errors: []
|
|
137
|
-
}));
|
|
138
|
-
}, [initialFiles]);
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
return () => {
|
|
141
|
-
filesRef.current.forEach((file) => {
|
|
142
|
-
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) URL.revokeObjectURL(file.preview);
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
}, []);
|
|
146
|
-
/**
|
|
147
|
-
* Validate a file against the configured constraints
|
|
148
|
-
*
|
|
149
|
-
* @param file - The file to validate (File object or FileMetadata)
|
|
150
|
-
* @returns Error message if validation fails, null if valid
|
|
151
|
-
*/
|
|
152
|
-
const validateFile = useCallback((file) => {
|
|
153
|
-
if (file.size > maxSize) return `File "${file.name}" exceeds the maximum size of ${formatBytes(maxSize)}.`;
|
|
154
|
-
if (accept !== "*") {
|
|
155
|
-
const acceptedTypes = accept.split(",").map((type) => type.trim());
|
|
156
|
-
const fileType = file instanceof File ? file.type || "" : file.type;
|
|
157
|
-
const fileExtension = `.${file.name.split(".").pop()}`;
|
|
158
|
-
if (!acceptedTypes.some((type) => {
|
|
159
|
-
if (type.startsWith(".")) return fileExtension.toLowerCase() === type.toLowerCase();
|
|
160
|
-
if (type.endsWith("/*")) {
|
|
161
|
-
const baseType = type.split("/")[0];
|
|
162
|
-
return fileType.startsWith(`${baseType}/`);
|
|
163
|
-
}
|
|
164
|
-
return fileType === type;
|
|
165
|
-
})) return `File "${file.name}" is not an accepted file type.`;
|
|
166
|
-
}
|
|
167
|
-
return null;
|
|
168
|
-
}, [accept, maxSize]);
|
|
169
|
-
/**
|
|
170
|
-
* Create a preview URL for a file
|
|
171
|
-
*
|
|
172
|
-
* @param file - The file to create a preview for
|
|
173
|
-
* @returns Preview URL string or undefined
|
|
174
|
-
*/
|
|
175
|
-
const createPreview = useCallback((file) => {
|
|
176
|
-
if (file instanceof File) {
|
|
177
|
-
if (file.type.startsWith("image/")) return URL.createObjectURL(file);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
return file.url;
|
|
181
|
-
}, []);
|
|
182
|
-
/**
|
|
183
|
-
* Generate a unique identifier for a file
|
|
184
|
-
*
|
|
185
|
-
* @param file - The file to generate an ID for
|
|
186
|
-
* @returns Unique identifier string
|
|
187
|
-
*/
|
|
188
|
-
const generateUniqueId = useCallback((file) => {
|
|
189
|
-
if (file instanceof File) return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
190
|
-
return file.id;
|
|
191
|
-
}, []);
|
|
192
|
-
/**
|
|
193
|
-
* Clear all files from the upload state
|
|
194
|
-
* Also cleans up object URLs to prevent memory leaks
|
|
195
|
-
*/
|
|
196
|
-
const clearFiles = useCallback(() => {
|
|
197
|
-
setState((prev) => {
|
|
198
|
-
for (const file of prev.files) if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) URL.revokeObjectURL(file.preview);
|
|
199
|
-
if (inputRef.current) inputRef.current.value = "";
|
|
200
|
-
const newState = {
|
|
201
|
-
...prev,
|
|
202
|
-
files: [],
|
|
203
|
-
errors: []
|
|
204
|
-
};
|
|
205
|
-
onFilesChange?.(newState.files);
|
|
206
|
-
return newState;
|
|
207
|
-
});
|
|
208
|
-
}, [onFilesChange]);
|
|
209
|
-
/**
|
|
210
|
-
* Add new files to the upload state
|
|
211
|
-
* Handles validation, duplicate detection, and state updates
|
|
212
|
-
*
|
|
213
|
-
* @param newFiles - FileList or array of File objects to add
|
|
214
|
-
*/
|
|
215
|
-
const addFiles = useCallback((newFiles) => {
|
|
216
|
-
if (!newFiles || newFiles.length === 0) return;
|
|
217
|
-
const newFilesArray = Array.from(newFiles);
|
|
218
|
-
const errors = [];
|
|
219
|
-
const validFiles = [];
|
|
220
|
-
for (const file of newFilesArray) {
|
|
221
|
-
const error = validateFile(file);
|
|
222
|
-
if (error) errors.push(error);
|
|
223
|
-
else validFiles.push({
|
|
224
|
-
file,
|
|
225
|
-
id: generateUniqueId(file),
|
|
226
|
-
preview: createPreview(file)
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
setState((prev) => {
|
|
230
|
-
const baseFiles = multiple ? prev.files : [];
|
|
231
|
-
const dedupedFiles = multiple ? validFiles.filter((file) => !baseFiles.some((existingFile) => existingFile.file.name === file.file.name && existingFile.file.size === file.file.size)) : validFiles;
|
|
232
|
-
if (multiple && maxFiles !== Number.POSITIVE_INFINITY && baseFiles.length + dedupedFiles.length > maxFiles) {
|
|
233
|
-
const nextErrors = [`You can only upload a maximum of ${maxFiles} files.`];
|
|
234
|
-
onError?.(nextErrors);
|
|
235
|
-
return {
|
|
236
|
-
...prev,
|
|
237
|
-
errors: nextErrors
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
if (!multiple) prev.files.forEach((file) => {
|
|
241
|
-
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) URL.revokeObjectURL(file.preview);
|
|
242
|
-
});
|
|
243
|
-
const nextFiles = !multiple ? dedupedFiles : [...baseFiles, ...dedupedFiles];
|
|
244
|
-
if (dedupedFiles.length > 0) {
|
|
245
|
-
onFilesAdded?.(dedupedFiles);
|
|
246
|
-
onFilesChange?.(nextFiles);
|
|
247
|
-
}
|
|
248
|
-
if (errors.length > 0) onError?.(errors);
|
|
249
|
-
return {
|
|
250
|
-
...prev,
|
|
251
|
-
files: nextFiles,
|
|
252
|
-
errors
|
|
253
|
-
};
|
|
254
|
-
});
|
|
255
|
-
if (inputRef.current) inputRef.current.value = "";
|
|
256
|
-
}, [
|
|
257
|
-
maxFiles,
|
|
258
|
-
multiple,
|
|
259
|
-
validateFile,
|
|
260
|
-
createPreview,
|
|
261
|
-
generateUniqueId,
|
|
262
|
-
onFilesChange,
|
|
263
|
-
onFilesAdded,
|
|
264
|
-
onError
|
|
265
|
-
]);
|
|
266
|
-
/**
|
|
267
|
-
* Remove a specific file from the upload state
|
|
268
|
-
* Also cleans up object URLs to prevent memory leaks
|
|
269
|
-
*
|
|
270
|
-
* @param id - The unique identifier of the file to remove
|
|
271
|
-
*/
|
|
272
|
-
const removeFile = useCallback((id) => {
|
|
273
|
-
setState((prev) => {
|
|
274
|
-
const fileToRemove = prev.files.find((file) => file.id === id);
|
|
275
|
-
if (fileToRemove?.preview && fileToRemove.file instanceof File && fileToRemove.file.type.startsWith("image/")) URL.revokeObjectURL(fileToRemove.preview);
|
|
276
|
-
const newFiles = prev.files.filter((file) => file.id !== id);
|
|
277
|
-
onFilesChange?.(newFiles);
|
|
278
|
-
return {
|
|
279
|
-
...prev,
|
|
280
|
-
files: newFiles,
|
|
281
|
-
errors: []
|
|
282
|
-
};
|
|
283
|
-
});
|
|
284
|
-
}, [onFilesChange]);
|
|
285
|
-
/**
|
|
286
|
-
* Clear all error messages from the state
|
|
287
|
-
*/
|
|
288
|
-
const clearErrors = useCallback(() => {
|
|
289
|
-
setState((prev) => ({
|
|
290
|
-
...prev,
|
|
291
|
-
errors: []
|
|
292
|
-
}));
|
|
293
|
-
}, []);
|
|
294
|
-
/**
|
|
295
|
-
* Handle drag enter event for the drop zone
|
|
296
|
-
* Sets the dragging state to true
|
|
297
|
-
*
|
|
298
|
-
* @param e - The drag event
|
|
299
|
-
*/
|
|
300
|
-
const handleDragEnter = useCallback((e) => {
|
|
301
|
-
e.preventDefault();
|
|
302
|
-
e.stopPropagation();
|
|
303
|
-
setState((prev) => ({
|
|
304
|
-
...prev,
|
|
305
|
-
isDragging: true
|
|
306
|
-
}));
|
|
307
|
-
}, []);
|
|
308
|
-
/**
|
|
309
|
-
* Handle drag leave event for the drop zone
|
|
310
|
-
* Sets the dragging state to false when leaving the drop zone
|
|
311
|
-
*
|
|
312
|
-
* @param e - The drag event
|
|
313
|
-
*/
|
|
314
|
-
const handleDragLeave = useCallback((e) => {
|
|
315
|
-
e.preventDefault();
|
|
316
|
-
e.stopPropagation();
|
|
317
|
-
if (e.currentTarget.contains(e.relatedTarget)) return;
|
|
318
|
-
setState((prev) => ({
|
|
319
|
-
...prev,
|
|
320
|
-
isDragging: false
|
|
321
|
-
}));
|
|
322
|
-
}, []);
|
|
323
|
-
/**
|
|
324
|
-
* Handle drag over event for the drop zone
|
|
325
|
-
* Prevents default behavior to allow dropping
|
|
326
|
-
*
|
|
327
|
-
* @param e - The drag event
|
|
328
|
-
*/
|
|
329
|
-
const handleDragOver = useCallback((e) => {
|
|
330
|
-
e.preventDefault();
|
|
331
|
-
e.stopPropagation();
|
|
332
|
-
}, []);
|
|
333
|
-
/**
|
|
334
|
-
* Handle drop event for the drop zone
|
|
335
|
-
* Processes dropped files and adds them to the upload state
|
|
336
|
-
*
|
|
337
|
-
* @param e - The drag event containing the dropped files
|
|
338
|
-
*/
|
|
339
|
-
const handleDrop = useCallback((e) => {
|
|
340
|
-
e.preventDefault();
|
|
341
|
-
e.stopPropagation();
|
|
342
|
-
setState((prev) => ({
|
|
343
|
-
...prev,
|
|
344
|
-
isDragging: false
|
|
345
|
-
}));
|
|
346
|
-
if (inputRef.current?.disabled) return;
|
|
347
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) if (!multiple) {
|
|
348
|
-
const file = e.dataTransfer.files[0];
|
|
349
|
-
addFiles([file]);
|
|
350
|
-
} else addFiles(e.dataTransfer.files);
|
|
351
|
-
}, [addFiles, multiple]);
|
|
352
|
-
/**
|
|
353
|
-
* Handle file input change event
|
|
354
|
-
* Processes selected files from the file input
|
|
355
|
-
*
|
|
356
|
-
* @param e - The change event from the file input
|
|
357
|
-
*/
|
|
358
|
-
const handleFileChange = useCallback((e) => {
|
|
359
|
-
if (e.target.files && e.target.files.length > 0) addFiles(e.target.files);
|
|
360
|
-
}, [addFiles]);
|
|
361
|
-
return [state, {
|
|
362
|
-
addFiles,
|
|
363
|
-
removeFile,
|
|
364
|
-
clearFiles,
|
|
365
|
-
clearErrors,
|
|
366
|
-
handleDragEnter,
|
|
367
|
-
handleDragLeave,
|
|
368
|
-
handleDragOver,
|
|
369
|
-
handleDrop,
|
|
370
|
-
handleFileChange,
|
|
371
|
-
openFileDialog: useCallback(() => {
|
|
372
|
-
if (inputRef.current) inputRef.current.click();
|
|
373
|
-
}, []),
|
|
374
|
-
getInputProps: useCallback((props = {}) => {
|
|
375
|
-
return {
|
|
376
|
-
...props,
|
|
377
|
-
type: "file",
|
|
378
|
-
onChange: handleFileChange,
|
|
379
|
-
accept: props.accept || accept,
|
|
380
|
-
multiple: props.multiple !== void 0 ? props.multiple : multiple,
|
|
381
|
-
ref: inputRef
|
|
382
|
-
};
|
|
383
|
-
}, [
|
|
384
|
-
accept,
|
|
385
|
-
multiple,
|
|
386
|
-
handleFileChange
|
|
387
|
-
])
|
|
388
|
-
}];
|
|
389
|
-
};
|
|
390
|
-
/**
|
|
391
|
-
* Helper function to format bytes to human-readable format
|
|
392
|
-
*
|
|
393
|
-
* @param bytes - The number of bytes to format
|
|
394
|
-
* @param decimals - Number of decimal places to show (default: 2)
|
|
395
|
-
* @returns Formatted string with appropriate unit (e.g., "1.5 MB")
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* ```tsx
|
|
399
|
-
* formatBytes(1024); // "1 KB"
|
|
400
|
-
* formatBytes(1536, 1); // "1.5 KB"
|
|
401
|
-
* formatBytes(1048576); // "1 MB"
|
|
402
|
-
* ```
|
|
403
|
-
*/
|
|
404
|
-
const formatBytes = (bytes, decimals = 2) => {
|
|
405
|
-
if (bytes === 0) return "0 Bytes";
|
|
406
|
-
const k = 1024;
|
|
407
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
408
|
-
const sizes = [
|
|
409
|
-
"Bytes",
|
|
410
|
-
"KB",
|
|
411
|
-
"MB",
|
|
412
|
-
"GB",
|
|
413
|
-
"TB",
|
|
414
|
-
"PB",
|
|
415
|
-
"EB",
|
|
416
|
-
"ZB",
|
|
417
|
-
"YB"
|
|
418
|
-
];
|
|
419
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
420
|
-
return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
421
|
-
};
|
|
422
|
-
//#endregion
|
|
423
|
-
//#region src/hooks/use-hydrated.ts
|
|
424
|
-
/**
|
|
425
|
-
* Hydration state hook for React components
|
|
426
|
-
* Returns a boolean indicating whether the component is running on the client
|
|
427
|
-
* with SSR-safe behavior to prevent hydration mismatches.
|
|
428
|
-
*
|
|
429
|
-
* This hook leverages `useSyncExternalStore` to provide a stable value between
|
|
430
|
-
* server and client renders: `false` during SSR, `true` after client hydration.
|
|
431
|
-
* The external store does not emit updates because the hydration state is static
|
|
432
|
-
* for the lifetime of the component.
|
|
433
|
-
*/
|
|
434
|
-
/**
|
|
435
|
-
* Hook that indicates whether code is executing on the client after hydration
|
|
436
|
-
*
|
|
437
|
-
* Features:
|
|
438
|
-
* - SSR-safe: returns `false` on the server to avoid hydration mismatches
|
|
439
|
-
* - Client-stable: returns `true` after hydration and remains stable
|
|
440
|
-
* - Minimal overhead: uses a no-op external store subscription
|
|
441
|
-
*
|
|
442
|
-
* @returns Boolean indicating hydration state (`true` on client, `false` on server)
|
|
443
|
-
*
|
|
444
|
-
* @example
|
|
445
|
-
* ```tsx
|
|
446
|
-
* // Conditionally render client-only components safely
|
|
447
|
-
* function ClientOnly() {
|
|
448
|
-
* const hydrated = useHydrated();
|
|
449
|
-
* if (!hydrated) return null;
|
|
450
|
-
* return <InteractiveChart />;
|
|
451
|
-
* }
|
|
452
|
-
* ```
|
|
453
|
-
*
|
|
454
|
-
* @since 1.0.0
|
|
455
|
-
*/
|
|
456
|
-
function useHydrated() {
|
|
457
|
-
return useSyncExternalStore(subscribe, () => true, () => false);
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* External store subscription used by `useHydrated`
|
|
461
|
-
* No updates are dispatched because hydration state is static.
|
|
462
|
-
* Returns an unsubscribe function for API conformity.
|
|
463
|
-
*/
|
|
464
|
-
function subscribe() {
|
|
465
|
-
return () => {};
|
|
466
|
-
}
|
|
467
|
-
//#endregion
|
|
468
|
-
//#region src/hooks/use-intersection-observer.ts
|
|
469
|
-
/**
|
|
470
|
-
* Intersection observer hook for React components
|
|
471
|
-
* Efficiently observes visibility of DOM elements using a shared IntersectionObserver instance.
|
|
472
|
-
* Ideal for lazy loading, infinite scrolling, and animating elements when they enter the viewport.
|
|
473
|
-
*/
|
|
474
|
-
/**
|
|
475
|
-
* A shared intersection observer to manage multiple targets with a single observer instance.
|
|
476
|
-
* Optimized for high-density lists (like the patterns grid).
|
|
477
|
-
*/
|
|
478
|
-
var SharedObserver = class {
|
|
479
|
-
observer = null;
|
|
480
|
-
callbacks = /* @__PURE__ */ new Map();
|
|
481
|
-
options;
|
|
482
|
-
constructor(options) {
|
|
483
|
-
this.options = options;
|
|
484
|
-
}
|
|
485
|
-
getObserver() {
|
|
486
|
-
if (!this.observer) this.observer = new IntersectionObserver((entries) => {
|
|
487
|
-
entries.forEach((entry) => {
|
|
488
|
-
const callback = this.callbacks.get(entry.target);
|
|
489
|
-
if (callback) callback(entry.isIntersecting);
|
|
490
|
-
});
|
|
491
|
-
}, this.options);
|
|
492
|
-
return this.observer;
|
|
493
|
-
}
|
|
494
|
-
observe(element, callback) {
|
|
495
|
-
this.callbacks.set(element, callback);
|
|
496
|
-
this.getObserver().observe(element);
|
|
497
|
-
}
|
|
498
|
-
unobserve(element) {
|
|
499
|
-
this.callbacks.delete(element);
|
|
500
|
-
this.observer?.unobserve(element);
|
|
501
|
-
}
|
|
502
|
-
get size() {
|
|
503
|
-
return this.callbacks.size;
|
|
504
|
-
}
|
|
505
|
-
disconnect() {
|
|
506
|
-
this.observer?.disconnect();
|
|
507
|
-
this.callbacks.clear();
|
|
508
|
-
this.observer = null;
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
const observers = /* @__PURE__ */ new Map();
|
|
512
|
-
const rootIds = /* @__PURE__ */ new WeakMap();
|
|
513
|
-
let rootId = 0;
|
|
514
|
-
function getRootKey(root) {
|
|
515
|
-
if (!root) return "null";
|
|
516
|
-
if (!rootIds.has(root)) rootIds.set(root, ++rootId);
|
|
517
|
-
return rootIds.get(root);
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Get or create a shared `IntersectionObserver` instance based on the provided options.
|
|
521
|
-
*
|
|
522
|
-
* Using a shared observer reduces the number of underlying `IntersectionObserver`
|
|
523
|
-
* instances created by the browser, which is especially beneficial for pages
|
|
524
|
-
* with many observed elements.
|
|
525
|
-
*
|
|
526
|
-
* @param options - Intersection observer configuration (threshold, root, rootMargin)
|
|
527
|
-
* @returns A shared `SharedObserver` instance for the given options
|
|
528
|
-
*/
|
|
529
|
-
function getSharedObserver(options) {
|
|
530
|
-
const threshold = Array.isArray(options.threshold) ? options.threshold.join(",") : options.threshold ?? 0;
|
|
531
|
-
const key = `${getRootKey(options.root)}|${options.rootMargin ?? "0px"}|${threshold}`;
|
|
532
|
-
if (!observers.has(key)) observers.set(key, new SharedObserver(options));
|
|
533
|
-
return {
|
|
534
|
-
key,
|
|
535
|
-
observer: observers.get(key)
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* React hook that tracks whether a DOM element is currently intersecting the viewport.
|
|
540
|
-
*
|
|
541
|
-
* Features:
|
|
542
|
-
* - Uses a shared `IntersectionObserver` instance for better performance.
|
|
543
|
-
* - Supports custom `threshold`, `root`, and `rootMargin` options.
|
|
544
|
-
* - Optional `freezeOnceVisible` flag to stop observing after first intersection.
|
|
545
|
-
*
|
|
546
|
-
* @param elementRef - React ref pointing to the DOM element to observe.
|
|
547
|
-
* @param options - Optional observer configuration and behavior flags.
|
|
548
|
-
* @param options.threshold - Intersection threshold(s) for triggering visibility changes.
|
|
549
|
-
* @param options.root - Scrollable ancestor element to use as the viewport (defaults to browser viewport).
|
|
550
|
-
* @param options.rootMargin - Margin around the root, expressed in CSS units (e.g. `"0px 0px -20% 0px"`).
|
|
551
|
-
* @param options.freezeOnceVisible - When `true`, stops observing after the element first becomes visible.
|
|
552
|
-
*
|
|
553
|
-
* @returns `true` when the element is intersecting based on the given options, otherwise `false`.
|
|
554
|
-
*
|
|
555
|
-
* @example
|
|
556
|
-
* ```tsx
|
|
557
|
-
* const ref = React.useRef<HTMLDivElement | null>(null);
|
|
558
|
-
* const isVisible = useIntersectionObserver(ref, {
|
|
559
|
-
* threshold: 0.2,
|
|
560
|
-
* rootMargin: "0px 0px -10% 0px",
|
|
561
|
-
* freezeOnceVisible: true,
|
|
562
|
-
* });
|
|
563
|
-
*
|
|
564
|
-
* return (
|
|
565
|
-
* <div ref={ref} className={isVisible ? "animate-in" : "opacity-0"}>
|
|
566
|
-
* I will animate when I enter the viewport.
|
|
567
|
-
* </div>
|
|
568
|
-
* );
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
function useIntersectionObserver(elementRef, { threshold = 0, root = null, rootMargin = "0%", freezeOnceVisible = false } = {}) {
|
|
572
|
-
const [isIntersecting, setIntersecting] = React$1.useState(false);
|
|
573
|
-
const frozen = React$1.useRef(false);
|
|
574
|
-
React$1.useEffect(() => {
|
|
575
|
-
const element = elementRef?.current;
|
|
576
|
-
if (!element || freezeOnceVisible && frozen.current) return;
|
|
577
|
-
if (typeof IntersectionObserver === "undefined") return;
|
|
578
|
-
const { key, observer } = getSharedObserver({
|
|
579
|
-
threshold,
|
|
580
|
-
root,
|
|
581
|
-
rootMargin
|
|
582
|
-
});
|
|
583
|
-
observer.observe(element, (intersecting) => {
|
|
584
|
-
setIntersecting(intersecting);
|
|
585
|
-
if (intersecting && freezeOnceVisible) {
|
|
586
|
-
frozen.current = true;
|
|
587
|
-
observer.unobserve(element);
|
|
588
|
-
}
|
|
589
|
-
});
|
|
590
|
-
return () => {
|
|
591
|
-
observer.unobserve(element);
|
|
592
|
-
if (observer.size === 0) {
|
|
593
|
-
observer.disconnect();
|
|
594
|
-
observers.delete(key);
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
}, [
|
|
598
|
-
elementRef,
|
|
599
|
-
threshold,
|
|
600
|
-
root,
|
|
601
|
-
rootMargin,
|
|
602
|
-
freezeOnceVisible
|
|
603
|
-
]);
|
|
604
|
-
return isIntersecting;
|
|
605
|
-
}
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region src/hooks/use-is-mac.ts
|
|
608
|
-
/**
|
|
609
|
-
* Platform detection hook for React components
|
|
610
|
-
* Determines whether the current user agent is running on a macOS device.
|
|
611
|
-
* Useful for rendering platform-specific keyboard shortcuts or UI variations.
|
|
612
|
-
*/
|
|
613
|
-
/**
|
|
614
|
-
* React hook that returns whether the current browser reports a macOS platform.
|
|
615
|
-
* It prefers `navigator.userAgentData.platform` when available and falls back
|
|
616
|
-
* to `navigator.userAgent`.
|
|
617
|
-
*
|
|
618
|
-
* @returns `true` if the current platform is macOS, otherwise `false`.
|
|
619
|
-
*
|
|
620
|
-
* @example
|
|
621
|
-
* ```tsx
|
|
622
|
-
* const isMac = useIsMac();
|
|
623
|
-
*
|
|
624
|
-
* return (
|
|
625
|
-
* <kbd>
|
|
626
|
-
* {isMac ? "⌘" : "Ctrl"} + K
|
|
627
|
-
* </kbd>
|
|
628
|
-
* );
|
|
629
|
-
* ```
|
|
630
|
-
*/
|
|
631
|
-
function useIsMac() {
|
|
632
|
-
const [isMac, setIsMac] = useState(false);
|
|
633
|
-
useEffect(() => {
|
|
634
|
-
const platform = navigator.userAgentData?.platform ?? navigator.userAgent ?? "";
|
|
635
|
-
setIsMac(platform.toUpperCase().includes("MAC"));
|
|
636
|
-
}, []);
|
|
637
|
-
return isMac;
|
|
638
|
-
}
|
|
639
|
-
//#endregion
|
|
640
|
-
//#region src/hooks/use-media-query.ts
|
|
641
|
-
/**
|
|
642
|
-
* Media query hook for responsive React components
|
|
643
|
-
* Provides real-time tracking of CSS media query matches
|
|
644
|
-
* with SSR-safe implementation and automatic cleanup
|
|
645
|
-
*/
|
|
646
|
-
/**
|
|
647
|
-
* Hook for tracking CSS media query matches in React components
|
|
648
|
-
*
|
|
649
|
-
* Features:
|
|
650
|
-
* - Real-time updates when media query state changes
|
|
651
|
-
* - SSR-safe implementation
|
|
652
|
-
* - Automatic event listener cleanup
|
|
653
|
-
* - Supports all standard CSS media queries
|
|
654
|
-
*
|
|
655
|
-
* @param query - CSS media query string (e.g., '(min-width: 768px)')
|
|
656
|
-
* @returns Boolean indicating whether the media query currently matches
|
|
657
|
-
*
|
|
658
|
-
* @example
|
|
659
|
-
* ```tsx
|
|
660
|
-
* // Basic responsive behavior
|
|
661
|
-
* const isMobile = useMediaQuery('(max-width: 768px)');
|
|
662
|
-
* const isTablet = useMediaQuery('(min-width: 769px) and (max-width: 1024px)');
|
|
663
|
-
* const isDesktop = useMediaQuery('(min-width: 1025px)');
|
|
664
|
-
*
|
|
665
|
-
* // Dark mode preference
|
|
666
|
-
* const prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
|
|
667
|
-
*
|
|
668
|
-
* // Reduced motion preference
|
|
669
|
-
* const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)');
|
|
670
|
-
*
|
|
671
|
-
* return (
|
|
672
|
-
* <div>
|
|
673
|
-
* {isMobile && <MobileLayout />}
|
|
674
|
-
* {isTablet && <TabletLayout />}
|
|
675
|
-
* {isDesktop && <DesktopLayout />}
|
|
676
|
-
* </div>
|
|
677
|
-
* );
|
|
678
|
-
* ```
|
|
679
|
-
*/
|
|
680
|
-
const useMediaQuery = (query) => {
|
|
681
|
-
const subscribe = useCallback((onChange) => {
|
|
682
|
-
const matchMedia = window.matchMedia(query);
|
|
683
|
-
matchMedia.addEventListener("change", onChange);
|
|
684
|
-
return () => {
|
|
685
|
-
matchMedia.removeEventListener("change", onChange);
|
|
686
|
-
};
|
|
687
|
-
}, [query]);
|
|
688
|
-
const getSnapshot = useCallback(() => window.matchMedia(query).matches, [query]);
|
|
689
|
-
const getServerSnapshot = () => false;
|
|
690
|
-
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
691
|
-
};
|
|
692
|
-
//#endregion
|
|
693
|
-
//#region src/hooks/use-menu.ts
|
|
694
|
-
/**
|
|
695
|
-
* Menu navigation utilities hook for dashboard layouts
|
|
696
|
-
* Provides comprehensive menu state management and navigation helpers
|
|
697
|
-
* Handles active states, breadcrumbs, and hierarchical menu structures
|
|
698
|
-
*/
|
|
699
|
-
/**
|
|
700
|
-
* Hook for managing menu navigation state and utilities
|
|
701
|
-
*
|
|
702
|
-
* This hook provides comprehensive menu management functionality including:
|
|
703
|
-
* - Active state detection for menu items and paths
|
|
704
|
-
* - Hierarchical menu navigation support
|
|
705
|
-
* - Breadcrumb generation for current navigation path
|
|
706
|
-
* - Child menu extraction at specific levels
|
|
707
|
-
* - Support for nested menu structures
|
|
708
|
-
*
|
|
709
|
-
* @param pathname - Current pathname from router or location
|
|
710
|
-
* @returns Object containing menu utility functions
|
|
711
|
-
*
|
|
712
|
-
* @example
|
|
713
|
-
* ```tsx
|
|
714
|
-
* const { isActive, getBreadcrumb, getCurrentItem } = useMenu(pathname);
|
|
715
|
-
*
|
|
716
|
-
* // Check if path is active
|
|
717
|
-
* const isHomeActive = isActive('/dashboard');
|
|
718
|
-
*
|
|
719
|
-
* // Get breadcrumb for current path
|
|
720
|
-
* const breadcrumb = getBreadcrumb(menuItems);
|
|
721
|
-
*
|
|
722
|
-
* // Get current active menu item
|
|
723
|
-
* const currentItem = getCurrentItem(menuItems);
|
|
724
|
-
* ```
|
|
725
|
-
*/
|
|
726
|
-
const useMenu = (pathname) => {
|
|
727
|
-
/**
|
|
728
|
-
* Check if a specific path matches the current pathname
|
|
729
|
-
* Handles root path ('/') as exact match, others as prefix match
|
|
730
|
-
*
|
|
731
|
-
* @param path - The path to check against current pathname
|
|
732
|
-
* @returns True if the path is currently active
|
|
733
|
-
*/
|
|
734
|
-
const isActive = (path) => {
|
|
735
|
-
if (path && path === "/") return path === pathname;
|
|
736
|
-
else return !!path && pathname.startsWith(path);
|
|
737
|
-
};
|
|
738
|
-
/**
|
|
739
|
-
* Recursively check if any child menu item is currently active
|
|
740
|
-
* Traverses through nested menu structures to find active children
|
|
741
|
-
*
|
|
742
|
-
* @param children - Array of child menu items to check
|
|
743
|
-
* @returns True if any child or nested child is active
|
|
744
|
-
*/
|
|
745
|
-
const hasActiveChild = (children) => {
|
|
746
|
-
if (!children || !Array.isArray(children)) return false;
|
|
747
|
-
return children.some((child) => child.path && isActive(child.path) || child.children && hasActiveChild(child.children));
|
|
748
|
-
};
|
|
749
|
-
/**
|
|
750
|
-
* Check if a menu item is active (either directly or through its children)
|
|
751
|
-
* Combines direct path matching with child activity detection
|
|
752
|
-
*
|
|
753
|
-
* @param item - The menu item to check for activity
|
|
754
|
-
* @returns True if the item or any of its children are active
|
|
755
|
-
*/
|
|
756
|
-
const isItemActive = (item) => {
|
|
757
|
-
return (item.path ? isActive(item.path) : false) || (item.children ? hasActiveChild(item.children) : false);
|
|
758
|
-
};
|
|
759
|
-
/**
|
|
760
|
-
* Find and return the currently active menu item from the menu configuration
|
|
761
|
-
* Recursively searches through menu hierarchy to find the most specific active item
|
|
762
|
-
* Prioritizes deeper nested items over parent items when both are active
|
|
763
|
-
*
|
|
764
|
-
* @param items - Array of menu items to search through
|
|
765
|
-
* @returns The currently active menu item, or undefined if none found
|
|
766
|
-
*/
|
|
767
|
-
const getCurrentItem = (items) => {
|
|
768
|
-
for (const item of items) {
|
|
769
|
-
if (item.path && isActive(item.path)) {
|
|
770
|
-
if (item.children && item.children.length > 0) return getCurrentItem(item.children) || item;
|
|
771
|
-
return item;
|
|
772
|
-
}
|
|
773
|
-
if (item.children && item.children.length > 0) {
|
|
774
|
-
const childMatch = getCurrentItem(item.children);
|
|
775
|
-
if (childMatch) return childMatch;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
};
|
|
779
|
-
/**
|
|
780
|
-
* Generate breadcrumb trail for the current active path
|
|
781
|
-
* Creates an array of menu items representing the navigation path from root to current item
|
|
782
|
-
* Useful for displaying navigation breadcrumbs in the UI
|
|
783
|
-
*
|
|
784
|
-
* @param items - Array of menu items to generate breadcrumb from
|
|
785
|
-
* @returns Array of menu items representing the breadcrumb trail
|
|
786
|
-
*/
|
|
787
|
-
const getBreadcrumb = (items) => {
|
|
788
|
-
const findBreadcrumb = (nodes, breadcrumb = []) => {
|
|
789
|
-
for (const item of nodes) {
|
|
790
|
-
const currentBreadcrumb = [...breadcrumb, item];
|
|
791
|
-
if (item.children && item.children.length > 0) {
|
|
792
|
-
const childBreadcrumb = findBreadcrumb(item.children, currentBreadcrumb);
|
|
793
|
-
if (childBreadcrumb.length > currentBreadcrumb.length) return childBreadcrumb;
|
|
794
|
-
}
|
|
795
|
-
if (item.path && isActive(item.path)) return currentBreadcrumb;
|
|
796
|
-
}
|
|
797
|
-
return breadcrumb;
|
|
798
|
-
};
|
|
799
|
-
const breadcrumb = findBreadcrumb(items);
|
|
800
|
-
return breadcrumb.length > 0 ? breadcrumb : [];
|
|
801
|
-
};
|
|
802
|
-
/**
|
|
803
|
-
* Get child menu items at a specific hierarchical level for the current active path
|
|
804
|
-
* Traverses the menu structure to find children at the specified depth level
|
|
805
|
-
* Useful for displaying sub-navigation menus at different levels
|
|
806
|
-
*
|
|
807
|
-
* @param items - Array of menu items to search through
|
|
808
|
-
* @param level - The hierarchical level to get children from (0-based)
|
|
809
|
-
* @returns Array of child menu items at the specified level, or null if none found
|
|
810
|
-
*/
|
|
811
|
-
const getChildren = (items, level) => {
|
|
812
|
-
const hasActiveChildAtLevel = (items) => {
|
|
813
|
-
for (const item of items) if (item.path && (item.path === pathname || item.path !== "/" && item.path !== "" && pathname.startsWith(item.path)) || item.children && hasActiveChildAtLevel(item.children)) return true;
|
|
814
|
-
return false;
|
|
815
|
-
};
|
|
816
|
-
const findChildren = (items, targetLevel, currentLevel = 0) => {
|
|
817
|
-
for (const item of items) if (item.children) {
|
|
818
|
-
if (targetLevel === currentLevel && hasActiveChildAtLevel(item.children)) return item.children;
|
|
819
|
-
const children = findChildren(item.children, targetLevel, currentLevel + 1);
|
|
820
|
-
if (children) return children;
|
|
821
|
-
} else if (targetLevel === currentLevel && item.path && (item.path === pathname || item.path !== "/" && item.path !== "" && pathname.startsWith(item.path))) return items;
|
|
822
|
-
return null;
|
|
823
|
-
};
|
|
824
|
-
return findChildren(items, level);
|
|
825
|
-
};
|
|
826
|
-
return {
|
|
827
|
-
isActive,
|
|
828
|
-
hasActiveChild,
|
|
829
|
-
isItemActive,
|
|
830
|
-
getCurrentItem,
|
|
831
|
-
getBreadcrumb,
|
|
832
|
-
getChildren
|
|
833
|
-
};
|
|
834
|
-
};
|
|
835
|
-
//#endregion
|
|
836
|
-
//#region src/hooks/use-meta-color.ts
|
|
837
|
-
/**
|
|
838
|
-
* Meta theme color management hook for React components.
|
|
839
|
-
*/
|
|
840
|
-
/**
|
|
841
|
-
* Calculates and applies the HTML `theme-color` meta tag from `next-themes`.
|
|
842
|
-
* The returned setter can be used for temporary manual overrides.
|
|
843
|
-
*
|
|
844
|
-
* @param defaultColors - Optional custom color configuration (defaults to META_THEME_COLORS)
|
|
845
|
-
* @returns Object containing current meta color and setter function.
|
|
846
|
-
*
|
|
847
|
-
* @example
|
|
848
|
-
* ```tsx
|
|
849
|
-
* // Basic usage with default colors (supports light, dark, and system)
|
|
850
|
-
* function App() {
|
|
851
|
-
* const { metaColor, setMetaColor } = useMetaColor();
|
|
852
|
-
*
|
|
853
|
-
* // metaColor automatically updates based on theme (light/dark/system)
|
|
854
|
-
* useEffect(() => {
|
|
855
|
-
* console.log('Current meta color:', metaColor);
|
|
856
|
-
* }, [metaColor]);
|
|
857
|
-
*
|
|
858
|
-
* return <div>App content</div>;
|
|
859
|
-
* }
|
|
860
|
-
*
|
|
861
|
-
* // Custom colors with system theme support
|
|
862
|
-
* function CustomThemeApp() {
|
|
863
|
-
* const customColors = {
|
|
864
|
-
* light: '#f0f0f0',
|
|
865
|
-
* dark: '#1a1a1a',
|
|
866
|
-
* system: 'auto' // Will resolve to light or dark based on OS preference
|
|
867
|
-
* };
|
|
868
|
-
* const { metaColor } = useMetaColor(customColors);
|
|
869
|
-
*
|
|
870
|
-
* return <div style={{ backgroundColor: metaColor }}>Custom themed app</div>;
|
|
871
|
-
* }
|
|
872
|
-
*
|
|
873
|
-
* // Manual meta color override for special pages
|
|
874
|
-
* function SpecialPage() {
|
|
875
|
-
* const { setMetaColor } = useMetaColor();
|
|
876
|
-
*
|
|
877
|
-
* useEffect(() => {
|
|
878
|
-
* // Override meta color for this page
|
|
879
|
-
* setMetaColor('#ff0000');
|
|
880
|
-
*
|
|
881
|
-
* // Cleanup: reset to theme color when leaving page
|
|
882
|
-
* return () => {
|
|
883
|
-
* setMetaColor(''); // This will revert to theme-based color
|
|
884
|
-
* };
|
|
885
|
-
* }, [setMetaColor]);
|
|
886
|
-
*
|
|
887
|
-
* return <div>Special page with red theme color</div>;
|
|
888
|
-
* }
|
|
889
|
-
*
|
|
890
|
-
* // Integration with theme switcher
|
|
891
|
-
* function ThemeAwareComponent() {
|
|
892
|
-
* const { theme, setTheme } = useTheme();
|
|
893
|
-
* const { metaColor } = useMetaColor();
|
|
894
|
-
*
|
|
895
|
-
* return (
|
|
896
|
-
* <div>
|
|
897
|
-
* <p>Current theme: {theme}</p>
|
|
898
|
-
* <p>Meta color: {metaColor}</p>
|
|
899
|
-
* <button onClick={() => setTheme('light')}>Light</button>
|
|
900
|
-
* <button onClick={() => setTheme('dark')}>Dark</button>
|
|
901
|
-
* <button onClick={() => setTheme('system')}>System</button>
|
|
902
|
-
* </div>
|
|
903
|
-
* );
|
|
904
|
-
* }
|
|
905
|
-
* ```
|
|
906
|
-
*/
|
|
907
|
-
function useMetaColor(defaultColors) {
|
|
908
|
-
/** Get resolved theme from next-themes */
|
|
909
|
-
const { resolvedTheme } = useTheme();
|
|
910
|
-
/**
|
|
911
|
-
* Helper function to detect system dark mode preference
|
|
912
|
-
*/
|
|
913
|
-
const isSystemDarkMode = React$1.useCallback(() => {
|
|
914
|
-
if (typeof window === "undefined") return false;
|
|
915
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
916
|
-
}, []);
|
|
917
|
-
/**
|
|
918
|
-
* Get effective theme mode (resolves 'system' to actual preference)
|
|
919
|
-
*/
|
|
920
|
-
const getEffectiveTheme = React$1.useCallback((theme) => {
|
|
921
|
-
if (theme === THEME_MODES.SYSTEM) return isSystemDarkMode() ? THEME_MODES.DARK : THEME_MODES.LIGHT;
|
|
922
|
-
return theme;
|
|
923
|
-
}, [isSystemDarkMode]);
|
|
924
|
-
/**
|
|
925
|
-
* Calculate appropriate meta color based on current theme
|
|
926
|
-
* Handles light, dark, and system themes properly
|
|
927
|
-
* Memoized to prevent unnecessary recalculations
|
|
928
|
-
*/
|
|
929
|
-
const metaColor = React$1.useMemo(() => {
|
|
930
|
-
const colorsToUse = defaultColors ?? META_THEME_COLORS;
|
|
931
|
-
const effectiveTheme = getEffectiveTheme(resolvedTheme);
|
|
932
|
-
if (effectiveTheme === THEME_MODES.DARK) return colorsToUse[THEME_MODES.DARK];
|
|
933
|
-
else if (effectiveTheme === THEME_MODES.LIGHT) return colorsToUse[THEME_MODES.LIGHT];
|
|
934
|
-
return colorsToUse[THEME_MODES.LIGHT];
|
|
935
|
-
}, [
|
|
936
|
-
resolvedTheme,
|
|
937
|
-
defaultColors,
|
|
938
|
-
getEffectiveTheme
|
|
939
|
-
]);
|
|
940
|
-
/**
|
|
941
|
-
* Manually set meta theme color in the document
|
|
942
|
-
* Useful for temporary color overrides or custom scenarios
|
|
943
|
-
*
|
|
944
|
-
* @param color - Hex color string to set as meta theme color
|
|
945
|
-
*/
|
|
946
|
-
const setMetaColor = React$1.useCallback((color) => {
|
|
947
|
-
const metaTag = document.querySelector("meta[name=\"theme-color\"]");
|
|
948
|
-
if (metaTag) metaTag.setAttribute("content", color);
|
|
949
|
-
else {
|
|
950
|
-
const newMetaTag = document.createElement("meta");
|
|
951
|
-
newMetaTag.name = "theme-color";
|
|
952
|
-
newMetaTag.content = color;
|
|
953
|
-
document.head.appendChild(newMetaTag);
|
|
954
|
-
}
|
|
955
|
-
}, []);
|
|
956
|
-
React$1.useEffect(() => {
|
|
957
|
-
setMetaColor(metaColor);
|
|
958
|
-
}, [metaColor, setMetaColor]);
|
|
959
|
-
return {
|
|
960
|
-
/** Current meta theme color based on resolved theme */
|
|
961
|
-
metaColor,
|
|
962
|
-
/** Function to manually set meta theme color */
|
|
963
|
-
setMetaColor
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
//#endregion
|
|
967
|
-
//#region src/hooks/use-mutation-observer.ts
|
|
968
|
-
/**
|
|
969
|
-
* DOM Mutation Observer hook for React components
|
|
970
|
-
* Provides a React-friendly interface for observing DOM changes
|
|
971
|
-
* with automatic cleanup and ref integration
|
|
972
|
-
*/
|
|
973
|
-
/**
|
|
974
|
-
* Default options for MutationObserver
|
|
975
|
-
* Observes all types of mutations by default
|
|
976
|
-
*/
|
|
977
|
-
const DEFAULT_OPTIONS = {
|
|
978
|
-
/** Watch for attribute changes */
|
|
979
|
-
attributes: true,
|
|
980
|
-
/** Watch for text content changes */
|
|
981
|
-
characterData: true,
|
|
982
|
-
/** Watch for child element additions/removals */
|
|
983
|
-
childList: true,
|
|
984
|
-
/** Watch for changes in descendant elements */
|
|
985
|
-
subtree: true
|
|
986
|
-
};
|
|
987
|
-
/**
|
|
988
|
-
* Hook to observe DOM mutations on a referenced element
|
|
989
|
-
*
|
|
990
|
-
* This hook provides a React-friendly way to use the MutationObserver API.
|
|
991
|
-
* It automatically handles observer creation, cleanup, and ref management.
|
|
992
|
-
* Useful for detecting DOM changes that occur outside of React's control.
|
|
993
|
-
*
|
|
994
|
-
* Features:
|
|
995
|
-
* - Automatic observer lifecycle management
|
|
996
|
-
* - Configurable observation options
|
|
997
|
-
* - Ref-based element targeting
|
|
998
|
-
* - Automatic cleanup on unmount
|
|
999
|
-
*
|
|
1000
|
-
* @param ref - React ref pointing to the element to observe
|
|
1001
|
-
* @param callback - Function called when mutations are detected
|
|
1002
|
-
* @param options - MutationObserver configuration options
|
|
1003
|
-
*
|
|
1004
|
-
* @example
|
|
1005
|
-
* ```tsx
|
|
1006
|
-
* function DynamicContent() {
|
|
1007
|
-
* const contentRef = useRef<HTMLDivElement>(null);
|
|
1008
|
-
*
|
|
1009
|
-
* // Watch for any changes to the content div
|
|
1010
|
-
* useMutationObserver(
|
|
1011
|
-
* contentRef,
|
|
1012
|
-
* (mutations) => {
|
|
1013
|
-
* mutations.forEach((mutation) => {
|
|
1014
|
-
* console.log('DOM changed:', mutation.type);
|
|
1015
|
-
* });
|
|
1016
|
-
* }
|
|
1017
|
-
* );
|
|
1018
|
-
*
|
|
1019
|
-
* return <div ref={contentRef}>Dynamic content here</div>;
|
|
1020
|
-
* }
|
|
1021
|
-
*
|
|
1022
|
-
* // Watch only for attribute changes
|
|
1023
|
-
* function AttributeWatcher() {
|
|
1024
|
-
* const elementRef = useRef<HTMLElement>(null);
|
|
1025
|
-
*
|
|
1026
|
-
* useMutationObserver(
|
|
1027
|
-
* elementRef,
|
|
1028
|
-
* (mutations) => {
|
|
1029
|
-
* mutations.forEach((mutation) => {
|
|
1030
|
-
* if (mutation.type === 'attributes') {
|
|
1031
|
-
* console.log('Attribute changed:', mutation.attributeName);
|
|
1032
|
-
* }
|
|
1033
|
-
* });
|
|
1034
|
-
* },
|
|
1035
|
-
* { attributes: true, childList: false, subtree: false }
|
|
1036
|
-
* );
|
|
1037
|
-
*
|
|
1038
|
-
* return <div ref={elementRef}>Watched element</div>;
|
|
1039
|
-
* }
|
|
1040
|
-
* ```
|
|
1041
|
-
*/
|
|
1042
|
-
const useMutationObserver = (ref, callback, options = DEFAULT_OPTIONS) => {
|
|
1043
|
-
React$1.useEffect(() => {
|
|
1044
|
-
if (ref.current) {
|
|
1045
|
-
const observer = new MutationObserver(callback);
|
|
1046
|
-
observer.observe(ref.current, options);
|
|
1047
|
-
return () => {
|
|
1048
|
-
observer.disconnect();
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
}, [
|
|
1052
|
-
ref,
|
|
1053
|
-
callback,
|
|
1054
|
-
options
|
|
1055
|
-
]);
|
|
1056
|
-
};
|
|
1057
|
-
//#endregion
|
|
1058
|
-
//#region src/hooks/use-remove-ga-params.ts
|
|
1059
|
-
/**
|
|
1060
|
-
* Google Analytics linker parameter cleanup hook for React
|
|
1061
|
-
* Safely removes the GA `_gl` query parameter from the URL after GA initialization.
|
|
1062
|
-
*/
|
|
1063
|
-
/**
|
|
1064
|
-
* Hook to remove the Google Analytics `_gl` query parameter from the current URL.
|
|
1065
|
-
*
|
|
1066
|
-
* GA's cross-domain linker temporarily appends `_gl` to URLs for attribution.
|
|
1067
|
-
* Removing it *too early* can break attribution, so this hook waits briefly
|
|
1068
|
-
* (≈2 seconds) to allow GA to read it, then strips the param using
|
|
1069
|
-
* `history.replaceState` without causing a page reload or React re-render.
|
|
1070
|
-
*
|
|
1071
|
-
* Behavior:
|
|
1072
|
-
* - Runs once on mount.
|
|
1073
|
-
* - If `_gl` is present, schedules its removal after ~2000ms.
|
|
1074
|
-
* - Uses `window.history.replaceState` to avoid navigation/re-render.
|
|
1075
|
-
*
|
|
1076
|
-
* @example
|
|
1077
|
-
* ```tsx
|
|
1078
|
-
* // app/layout.tsx or a top-level client component
|
|
1079
|
-
* import { useRemoveGAParams } from '@/hooks/use-remove-ga-params';
|
|
1080
|
-
*
|
|
1081
|
-
* export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
1082
|
-
* useRemoveGAParams();
|
|
1083
|
-
* return <>{children}</>;
|
|
1084
|
-
* }
|
|
1085
|
-
* ```
|
|
1086
|
-
*/
|
|
1087
|
-
function useRemoveGAParams() {
|
|
1088
|
-
useEffect(() => {
|
|
1089
|
-
if (new URL(window.location.href).searchParams.has("_gl")) {
|
|
1090
|
-
const timer = setTimeout(() => {
|
|
1091
|
-
const url = new URL(window.location.href);
|
|
1092
|
-
url.searchParams.delete("_gl");
|
|
1093
|
-
window.history.replaceState({}, "", url.toString());
|
|
1094
|
-
}, 2e3);
|
|
1095
|
-
return () => clearTimeout(timer);
|
|
1096
|
-
}
|
|
1097
|
-
}, []);
|
|
1098
|
-
}
|
|
1099
|
-
//#endregion
|
|
1100
|
-
//#region src/hooks/use-scroll-position.ts
|
|
1101
|
-
/**
|
|
1102
|
-
* Scroll position tracking hook for React components
|
|
1103
|
-
* Monitors scroll position of window or specific elements
|
|
1104
|
-
* with real-time updates and automatic cleanup
|
|
1105
|
-
*/
|
|
1106
|
-
/**
|
|
1107
|
-
* Hook to track scroll position of window or specific elements
|
|
1108
|
-
*
|
|
1109
|
-
* This hook provides real-time tracking of scroll position with support
|
|
1110
|
-
* for both window scrolling and element-specific scrolling. It automatically
|
|
1111
|
-
* handles event listener management and cleanup.
|
|
1112
|
-
*
|
|
1113
|
-
* Features:
|
|
1114
|
-
* - Real-time scroll position tracking
|
|
1115
|
-
* - Support for window and element scrolling
|
|
1116
|
-
* - Automatic event listener cleanup
|
|
1117
|
-
* - SSR-safe implementation
|
|
1118
|
-
* - Performance optimized
|
|
1119
|
-
*
|
|
1120
|
-
* @param options - Configuration options for the hook
|
|
1121
|
-
* @returns Current scroll position in pixels
|
|
1122
|
-
*
|
|
1123
|
-
* @example
|
|
1124
|
-
* ```tsx
|
|
1125
|
-
* // Track window scroll position
|
|
1126
|
-
* function ScrollIndicator() {
|
|
1127
|
-
* const scrollPosition = useScrollPosition();
|
|
1128
|
-
*
|
|
1129
|
-
* return (
|
|
1130
|
-
* <div className="scroll-indicator">
|
|
1131
|
-
* Scrolled: {scrollPosition}px
|
|
1132
|
-
* </div>
|
|
1133
|
-
* );
|
|
1134
|
-
* }
|
|
1135
|
-
*
|
|
1136
|
-
* // Track specific element scroll position
|
|
1137
|
-
* function ScrollableContent() {
|
|
1138
|
-
* const contentRef = useRef<HTMLDivElement>(null);
|
|
1139
|
-
* const scrollPosition = useScrollPosition({ targetRef: contentRef });
|
|
1140
|
-
*
|
|
1141
|
-
* return (
|
|
1142
|
-
* <div
|
|
1143
|
-
* ref={contentRef}
|
|
1144
|
-
* className="h-96 overflow-y-auto"
|
|
1145
|
-
* >
|
|
1146
|
-
* <div className="h-[1000px]">
|
|
1147
|
-
* <p>Scroll position: {scrollPosition}px</p>
|
|
1148
|
-
* <p>Long content here...</p>
|
|
1149
|
-
* </div>
|
|
1150
|
-
* </div>
|
|
1151
|
-
* );
|
|
1152
|
-
* }
|
|
1153
|
-
*
|
|
1154
|
-
* // Show/hide header based on scroll
|
|
1155
|
-
* function StickyHeader() {
|
|
1156
|
-
* const scrollPosition = useScrollPosition();
|
|
1157
|
-
* const isVisible = scrollPosition < 100;
|
|
1158
|
-
*
|
|
1159
|
-
* return (
|
|
1160
|
-
* <header className={`transition-transform ${
|
|
1161
|
-
* isVisible ? 'translate-y-0' : '-translate-y-full'
|
|
1162
|
-
* }`}>
|
|
1163
|
-
* Header content
|
|
1164
|
-
* </header>
|
|
1165
|
-
* );
|
|
1166
|
-
* }
|
|
1167
|
-
* ```
|
|
1168
|
-
*/
|
|
1169
|
-
const useScrollPosition = ({ targetRef } = {}) => {
|
|
1170
|
-
/** State to track current scroll position */
|
|
1171
|
-
const [scrollPosition, setScrollPosition] = useState(0);
|
|
1172
|
-
useEffect(() => {
|
|
1173
|
-
const target = targetRef?.current || document;
|
|
1174
|
-
const scrollable = target === document ? window : target;
|
|
1175
|
-
/**
|
|
1176
|
-
* Update scroll position state
|
|
1177
|
-
* Handles both window and element scrolling
|
|
1178
|
-
*/
|
|
1179
|
-
const updatePosition = () => {
|
|
1180
|
-
const scrollY = target === document ? window.scrollY || window.pageYOffset : target.scrollTop;
|
|
1181
|
-
setScrollPosition(scrollY);
|
|
1182
|
-
};
|
|
1183
|
-
scrollable.addEventListener("scroll", updatePosition, { passive: true });
|
|
1184
|
-
updatePosition();
|
|
1185
|
-
return () => {
|
|
1186
|
-
scrollable.removeEventListener("scroll", updatePosition);
|
|
1187
|
-
};
|
|
1188
|
-
}, [targetRef]);
|
|
1189
|
-
return scrollPosition;
|
|
1190
|
-
};
|
|
1191
|
-
//#endregion
|
|
1192
|
-
//#region src/hooks/use-slider-input.ts
|
|
1193
|
-
/**
|
|
1194
|
-
* Dual slider input management hook for React components
|
|
1195
|
-
* Provides synchronized state management between range slider and number inputs
|
|
1196
|
-
* with validation and boundary enforcement
|
|
1197
|
-
*/
|
|
1198
|
-
/**
|
|
1199
|
-
* Hook for managing dual slider input with synchronized state
|
|
1200
|
-
*
|
|
1201
|
-
* This hook provides state management for components that need both
|
|
1202
|
-
* a range slider and corresponding number inputs. It handles synchronization
|
|
1203
|
-
* between the two input types, validation, and boundary enforcement.
|
|
1204
|
-
*
|
|
1205
|
-
* Features:
|
|
1206
|
-
* - Synchronized slider and input values
|
|
1207
|
-
* - Automatic validation and boundary enforcement
|
|
1208
|
-
* - Prevents invalid range configurations (min > max)
|
|
1209
|
-
* - Optimized with useCallback for performance
|
|
1210
|
-
*
|
|
1211
|
-
* @param props - Configuration options for the hook
|
|
1212
|
-
* @returns Object containing state and handlers for slider and inputs
|
|
1213
|
-
*
|
|
1214
|
-
* @example
|
|
1215
|
-
* ```tsx
|
|
1216
|
-
* function PriceRangeFilter() {
|
|
1217
|
-
* const {
|
|
1218
|
-
* sliderValues,
|
|
1219
|
-
* inputValues,
|
|
1220
|
-
* handleSliderChange,
|
|
1221
|
-
* handleInputChange,
|
|
1222
|
-
* validateAndUpdateValue
|
|
1223
|
-
* } = useSliderInput({
|
|
1224
|
-
* minValue: 0,
|
|
1225
|
-
* maxValue: 1000,
|
|
1226
|
-
* initialValue: [100, 500]
|
|
1227
|
-
* });
|
|
1228
|
-
*
|
|
1229
|
-
* return (
|
|
1230
|
-
* <div className="price-range">
|
|
1231
|
-
* <div className="inputs">
|
|
1232
|
-
* <input
|
|
1233
|
-
* type="number"
|
|
1234
|
-
* value={inputValues[0]}
|
|
1235
|
-
* onChange={(e) => handleInputChange(e, 0)}
|
|
1236
|
-
* onBlur={() => validateAndUpdateValue(inputValues[0], 0)}
|
|
1237
|
-
* placeholder="Min price"
|
|
1238
|
-
* />
|
|
1239
|
-
* <input
|
|
1240
|
-
* type="number"
|
|
1241
|
-
* value={inputValues[1]}
|
|
1242
|
-
* onChange={(e) => handleInputChange(e, 1)}
|
|
1243
|
-
* onBlur={() => validateAndUpdateValue(inputValues[1], 1)}
|
|
1244
|
-
* placeholder="Max price"
|
|
1245
|
-
* />
|
|
1246
|
-
* </div>
|
|
1247
|
-
*
|
|
1248
|
-
* <Slider
|
|
1249
|
-
* value={sliderValues}
|
|
1250
|
-
* onValueChange={handleSliderChange}
|
|
1251
|
-
* min={0}
|
|
1252
|
-
* max={1000}
|
|
1253
|
-
* step={10}
|
|
1254
|
-
* />
|
|
1255
|
-
* </div>
|
|
1256
|
-
* );
|
|
1257
|
-
* }
|
|
1258
|
-
* ```
|
|
1259
|
-
*/
|
|
1260
|
-
function useSliderInput({ minValue, maxValue, initialValue }) {
|
|
1261
|
-
/** State for slider component values */
|
|
1262
|
-
const [sliderValues, setSliderValues] = useState(initialValue);
|
|
1263
|
-
/** State for input field values (may temporarily differ from slider) */
|
|
1264
|
-
const [inputValues, setInputValues] = useState(initialValue);
|
|
1265
|
-
return {
|
|
1266
|
-
/** Function to manually set slider values */
|
|
1267
|
-
setSliderValues,
|
|
1268
|
-
/** Function to manually set input values */
|
|
1269
|
-
setInputValues,
|
|
1270
|
-
/** Current slider values [min, max] */
|
|
1271
|
-
sliderValues,
|
|
1272
|
-
/** Current input values [min, max] */
|
|
1273
|
-
inputValues,
|
|
1274
|
-
/** Handler for slider value changes */
|
|
1275
|
-
handleSliderChange: useCallback((values) => {
|
|
1276
|
-
setSliderValues(values);
|
|
1277
|
-
setInputValues(values);
|
|
1278
|
-
}, []),
|
|
1279
|
-
/** Handler for input field changes */
|
|
1280
|
-
handleInputChange: useCallback((e, index) => {
|
|
1281
|
-
const newValue = parseFloat(e.target.value);
|
|
1282
|
-
if (!Number.isNaN(newValue)) {
|
|
1283
|
-
const updatedInputs = [...inputValues];
|
|
1284
|
-
updatedInputs[index] = newValue;
|
|
1285
|
-
setInputValues(updatedInputs);
|
|
1286
|
-
}
|
|
1287
|
-
}, [inputValues]),
|
|
1288
|
-
/** Function to validate and update values from inputs */
|
|
1289
|
-
validateAndUpdateValue: useCallback((value, index) => {
|
|
1290
|
-
const updatedSlider = [...sliderValues];
|
|
1291
|
-
if (index === 0) updatedSlider[0] = Math.max(minValue, Math.min(value, sliderValues[1]));
|
|
1292
|
-
else updatedSlider[1] = Math.min(maxValue, Math.max(value, sliderValues[0]));
|
|
1293
|
-
setSliderValues(updatedSlider);
|
|
1294
|
-
setInputValues(updatedSlider);
|
|
1295
|
-
}, [
|
|
1296
|
-
sliderValues,
|
|
1297
|
-
minValue,
|
|
1298
|
-
maxValue
|
|
1299
|
-
])
|
|
1300
|
-
};
|
|
1301
|
-
}
|
|
1302
|
-
//#endregion
|
|
1303
|
-
//#region src/hooks/use-viewport.ts
|
|
1304
|
-
/**
|
|
1305
|
-
* Viewport dimensions tracking hook for React components
|
|
1306
|
-
* Provides real-time viewport width and height with automatic updates
|
|
1307
|
-
* on window resize events with SSR-safe implementation
|
|
1308
|
-
*/
|
|
1309
|
-
/**
|
|
1310
|
-
* Hook to track viewport dimensions with real-time updates
|
|
1311
|
-
*
|
|
1312
|
-
* This hook provides the current viewport dimensions and automatically
|
|
1313
|
-
* updates when the window is resized. It's useful for responsive layouts,
|
|
1314
|
-
* conditional rendering based on screen size, and dynamic calculations.
|
|
1315
|
-
*
|
|
1316
|
-
* Features:
|
|
1317
|
-
* - Real-time viewport dimension tracking
|
|
1318
|
-
* - Automatic updates on window resize
|
|
1319
|
-
* - Performance optimized with passive event listeners
|
|
1320
|
-
* - SSR-safe implementation
|
|
1321
|
-
* - Returns both width and height
|
|
1322
|
-
*
|
|
1323
|
-
* @returns Tuple containing [width, height] in pixels
|
|
1324
|
-
*
|
|
1325
|
-
* @example
|
|
1326
|
-
* ```tsx
|
|
1327
|
-
* // Basic usage
|
|
1328
|
-
* function ResponsiveComponent() {
|
|
1329
|
-
* const [width, height] = useViewport();
|
|
1330
|
-
*
|
|
1331
|
-
* return (
|
|
1332
|
-
* <div>
|
|
1333
|
-
* <p>Viewport: {width}x{height}</p>
|
|
1334
|
-
* {width > 768 ? <DesktopLayout /> : <MobileLayout />}
|
|
1335
|
-
* </div>
|
|
1336
|
-
* );
|
|
1337
|
-
* }
|
|
1338
|
-
*
|
|
1339
|
-
* // Destructured usage
|
|
1340
|
-
* function ViewportInfo() {
|
|
1341
|
-
* const [width, height] = useViewport();
|
|
1342
|
-
* const aspectRatio = (width / height).toFixed(2);
|
|
1343
|
-
*
|
|
1344
|
-
* return (
|
|
1345
|
-
* <div className="viewport-info">
|
|
1346
|
-
* <p>Width: {width}px</p>
|
|
1347
|
-
* <p>Height: {height}px</p>
|
|
1348
|
-
* <p>Aspect Ratio: {aspectRatio}</p>
|
|
1349
|
-
* </div>
|
|
1350
|
-
* );
|
|
1351
|
-
* }
|
|
1352
|
-
*
|
|
1353
|
-
* // Conditional rendering based on viewport
|
|
1354
|
-
* function AdaptiveGrid() {
|
|
1355
|
-
* const [width] = useViewport();
|
|
1356
|
-
* const columns = width > 1200 ? 4 : width > 768 ? 3 : width > 480 ? 2 : 1;
|
|
1357
|
-
*
|
|
1358
|
-
* return (
|
|
1359
|
-
* <div className={`grid grid-cols-${columns} gap-4`}>
|
|
1360
|
-
* {items.map(item => <GridItem key={item.id} {...item} />)}
|
|
1361
|
-
* </div>
|
|
1362
|
-
* );
|
|
1363
|
-
* }
|
|
1364
|
-
* ```
|
|
1365
|
-
*/
|
|
1366
|
-
const useViewport = () => {
|
|
1367
|
-
/**
|
|
1368
|
-
* State to track viewport dimensions
|
|
1369
|
-
* Initialized with current window dimensions or fallback for SSR
|
|
1370
|
-
*/
|
|
1371
|
-
const [dimensions, setDimensions] = useState([0, 0]);
|
|
1372
|
-
useEffect(() => {
|
|
1373
|
-
/**
|
|
1374
|
-
* Handle window resize events
|
|
1375
|
-
* Updates dimensions state with current viewport size
|
|
1376
|
-
*/
|
|
1377
|
-
const handleResize = () => {
|
|
1378
|
-
setDimensions([window.innerWidth, window.innerHeight]);
|
|
1379
|
-
};
|
|
1380
|
-
handleResize();
|
|
1381
|
-
window.addEventListener("resize", handleResize, { passive: true });
|
|
1382
|
-
return () => {
|
|
1383
|
-
window.removeEventListener("resize", handleResize);
|
|
1384
|
-
};
|
|
1385
|
-
}, []);
|
|
1386
|
-
return dimensions;
|
|
1387
|
-
};
|
|
1388
|
-
//#endregion
|
|
1389
|
-
export { formatBytes, useBodyClasses, useCopyToClipboard, useFileUpload, useHydrated, useIntersectionObserver, useIsMac, useIsMobile, useMediaQuery, useMenu, useMetaColor, useMutationObserver, useRemoveGAParams, useScrollPosition, useSliderInput, useViewport };
|
|
1390
|
-
|
|
1391
|
-
//# sourceMappingURL=hooks.js.map
|