tempest-react-sdk 0.24.0 → 0.26.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 +25 -4
- package/bin/lib/alias/collect.mjs +94 -0
- package/bin/lib/alias/collect.test.mjs +95 -0
- package/bin/lib/alias/discover.mjs +77 -0
- package/bin/lib/alias/discover.test.mjs +189 -0
- package/bin/lib/alias/index.mjs +88 -0
- package/bin/lib/alias/index.test.mjs +138 -0
- package/bin/lib/alias/rewrite-css.mjs +76 -0
- package/bin/lib/alias/rewrite-css.test.mjs +85 -0
- package/bin/lib/alias/rewrite.mjs +141 -0
- package/bin/lib/alias/rewrite.test.mjs +148 -0
- package/bin/lib/alias/specifier.mjs +49 -0
- package/bin/lib/alias/specifier.test.mjs +85 -0
- package/bin/lib/alias/tsconfig.mjs +116 -0
- package/bin/lib/alias/typescript.mjs +23 -0
- package/bin/lib/icons/generate.mjs +156 -0
- package/bin/lib/icons/generate.test.mjs +125 -0
- package/bin/tempest.mjs +158 -13
- package/dist/audio/use-audio.cjs +1 -1
- package/dist/audio/use-audio.cjs.map +1 -1
- package/dist/audio/use-audio.js +12 -12
- package/dist/audio/use-audio.js.map +1 -1
- package/dist/charts/AreaChart.cjs +1 -1
- package/dist/charts/AreaChart.cjs.map +1 -1
- package/dist/charts/AreaChart.js +7 -7
- package/dist/charts/AreaChart.js.map +1 -1
- package/dist/charts/BarChart.cjs +1 -1
- package/dist/charts/BarChart.cjs.map +1 -1
- package/dist/charts/BarChart.js +7 -7
- package/dist/charts/BarChart.js.map +1 -1
- package/dist/charts/LineChart.cjs +1 -1
- package/dist/charts/LineChart.cjs.map +1 -1
- package/dist/charts/LineChart.js +6 -6
- package/dist/charts/LineChart.js.map +1 -1
- package/dist/charts/PieChart.cjs +1 -1
- package/dist/charts/PieChart.cjs.map +1 -1
- package/dist/charts/PieChart.js +6 -6
- package/dist/charts/PieChart.js.map +1 -1
- package/dist/charts/RadarChart.cjs +1 -1
- package/dist/charts/RadarChart.cjs.map +1 -1
- package/dist/charts/RadarChart.js +6 -6
- package/dist/charts/RadarChart.js.map +1 -1
- package/dist/charts/palette.cjs +1 -1
- package/dist/charts/palette.cjs.map +1 -1
- package/dist/charts/palette.js +19 -2
- package/dist/charts/palette.js.map +1 -1
- package/dist/charts/use-chart-colors.cjs +2 -0
- package/dist/charts/use-chart-colors.cjs.map +1 -0
- package/dist/charts/use-chart-colors.js +29 -0
- package/dist/charts/use-chart-colors.js.map +1 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +61 -10
- package/dist/charts.js +8 -7
- package/dist/components/AvatarGroup/AvatarGroup.cjs +2 -0
- package/dist/components/AvatarGroup/AvatarGroup.cjs.map +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +39 -0
- package/dist/components/AvatarGroup/AvatarGroup.js.map +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.module.cjs +2 -0
- package/dist/components/AvatarGroup/AvatarGroup.module.cjs.map +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.module.js +16 -0
- package/dist/components/AvatarGroup/AvatarGroup.module.js.map +1 -0
- package/dist/components/ClickOutside/ClickOutside.cjs +1 -1
- package/dist/components/ClickOutside/ClickOutside.cjs.map +1 -1
- package/dist/components/ClickOutside/ClickOutside.js +3 -1
- package/dist/components/ClickOutside/ClickOutside.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +21 -23
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/Kanban/Kanban.cjs +2 -0
- package/dist/components/Kanban/Kanban.cjs.map +1 -0
- package/dist/components/Kanban/Kanban.js +102 -0
- package/dist/components/Kanban/Kanban.js.map +1 -0
- package/dist/components/Kanban/Kanban.module.cjs +2 -0
- package/dist/components/Kanban/Kanban.module.cjs.map +1 -0
- package/dist/components/Kanban/Kanban.module.js +19 -0
- package/dist/components/Kanban/Kanban.module.js.map +1 -0
- package/dist/components/Lightbox/Lightbox.cjs +2 -0
- package/dist/components/Lightbox/Lightbox.cjs.map +1 -0
- package/dist/components/Lightbox/Lightbox.js +148 -0
- package/dist/components/Lightbox/Lightbox.js.map +1 -0
- package/dist/components/Lightbox/Lightbox.module.cjs +2 -0
- package/dist/components/Lightbox/Lightbox.module.cjs.map +1 -0
- package/dist/components/Lightbox/Lightbox.module.js +21 -0
- package/dist/components/Lightbox/Lightbox.module.js.map +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.cjs +2 -0
- package/dist/components/NotificationCenter/NotificationCenter.cjs.map +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +83 -0
- package/dist/components/NotificationCenter/NotificationCenter.js.map +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.module.cjs +2 -0
- package/dist/components/NotificationCenter/NotificationCenter.module.cjs.map +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.module.js +21 -0
- package/dist/components/NotificationCenter/NotificationCenter.module.js.map +1 -0
- package/dist/components/NotificationCenter/use-notification-inbox.cjs +2 -0
- package/dist/components/NotificationCenter/use-notification-inbox.cjs.map +1 -0
- package/dist/components/NotificationCenter/use-notification-inbox.js +63 -0
- package/dist/components/NotificationCenter/use-notification-inbox.js.map +1 -0
- package/dist/components/RefreshIndicator/RefreshIndicator.cjs +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.cjs.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.js +17 -17
- package/dist/components/RefreshIndicator/RefreshIndicator.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.cjs +2 -0
- package/dist/components/SignaturePad/SignaturePad.cjs.map +1 -0
- package/dist/components/SignaturePad/SignaturePad.js +115 -0
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -0
- package/dist/components/SignaturePad/SignaturePad.module.cjs +2 -0
- package/dist/components/SignaturePad/SignaturePad.module.cjs.map +1 -0
- package/dist/components/SignaturePad/SignaturePad.module.js +11 -0
- package/dist/components/SignaturePad/SignaturePad.module.js.map +1 -0
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.js +43 -19
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/Stepper/Stepper.module.cjs +1 -1
- package/dist/components/Stepper/Stepper.module.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.module.js +6 -3
- package/dist/components/Stepper/Stepper.module.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +26 -20
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/TreeView/TreeView.cjs +2 -0
- package/dist/components/TreeView/TreeView.cjs.map +1 -0
- package/dist/components/TreeView/TreeView.js +124 -0
- package/dist/components/TreeView/TreeView.js.map +1 -0
- package/dist/components/TreeView/TreeView.module.cjs +2 -0
- package/dist/components/TreeView/TreeView.module.cjs.map +1 -0
- package/dist/components/TreeView/TreeView.module.js +17 -0
- package/dist/components/TreeView/TreeView.module.js.map +1 -0
- package/dist/components/VirtualTable/VirtualTable.cjs +2 -0
- package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -0
- package/dist/components/VirtualTable/VirtualTable.js +116 -0
- package/dist/components/VirtualTable/VirtualTable.js.map +1 -0
- package/dist/components/VirtualTable/VirtualTable.module.cjs +2 -0
- package/dist/components/VirtualTable/VirtualTable.module.cjs.map +1 -0
- package/dist/components/VirtualTable/VirtualTable.module.js +20 -0
- package/dist/components/VirtualTable/VirtualTable.module.js.map +1 -0
- package/dist/components/Wizard/Wizard.cjs +2 -0
- package/dist/components/Wizard/Wizard.cjs.map +1 -0
- package/dist/components/Wizard/Wizard.js +111 -0
- package/dist/components/Wizard/Wizard.js.map +1 -0
- package/dist/components/Wizard/Wizard.module.cjs +2 -0
- package/dist/components/Wizard/Wizard.module.cjs.map +1 -0
- package/dist/components/Wizard/Wizard.module.js +10 -0
- package/dist/components/Wizard/Wizard.module.js.map +1 -0
- package/dist/geo/use-position-tracker.cjs +1 -1
- package/dist/geo/use-position-tracker.cjs.map +1 -1
- package/dist/geo/use-position-tracker.js +3 -1
- package/dist/geo/use-position-tracker.js.map +1 -1
- package/dist/hooks/use-async.cjs +1 -1
- package/dist/hooks/use-async.cjs.map +1 -1
- package/dist/hooks/use-async.js +3 -1
- package/dist/hooks/use-async.js.map +1 -1
- package/dist/hooks/use-click-outside.cjs +1 -1
- package/dist/hooks/use-click-outside.cjs.map +1 -1
- package/dist/hooks/use-click-outside.js +3 -1
- package/dist/hooks/use-click-outside.js.map +1 -1
- package/dist/hooks/use-deep-memo.cjs.map +1 -1
- package/dist/hooks/use-deep-memo.js.map +1 -1
- package/dist/hooks/use-event-listener.cjs +1 -1
- package/dist/hooks/use-event-listener.cjs.map +1 -1
- package/dist/hooks/use-event-listener.js +3 -1
- package/dist/hooks/use-event-listener.js.map +1 -1
- package/dist/hooks/use-interval.cjs +1 -1
- package/dist/hooks/use-interval.cjs.map +1 -1
- package/dist/hooks/use-interval.js +3 -1
- package/dist/hooks/use-interval.js.map +1 -1
- package/dist/hooks/use-is-first-render.cjs.map +1 -1
- package/dist/hooks/use-is-first-render.js.map +1 -1
- package/dist/hooks/use-long-press-handlers.cjs +1 -1
- package/dist/hooks/use-long-press-handlers.cjs.map +1 -1
- package/dist/hooks/use-long-press-handlers.js +25 -23
- package/dist/hooks/use-long-press-handlers.js.map +1 -1
- package/dist/hooks/use-long-press.cjs +1 -1
- package/dist/hooks/use-long-press.cjs.map +1 -1
- package/dist/hooks/use-long-press.js +3 -1
- package/dist/hooks/use-long-press.js.map +1 -1
- package/dist/hooks/use-online.cjs +1 -1
- package/dist/hooks/use-online.cjs.map +1 -1
- package/dist/hooks/use-online.js +6 -4
- package/dist/hooks/use-online.js.map +1 -1
- package/dist/hooks/use-previous.cjs.map +1 -1
- package/dist/hooks/use-previous.js.map +1 -1
- package/dist/hooks/use-service-worker-update.cjs +1 -1
- package/dist/hooks/use-service-worker-update.cjs.map +1 -1
- package/dist/hooks/use-service-worker-update.js +3 -1
- package/dist/hooks/use-service-worker-update.js.map +1 -1
- package/dist/hooks/use-sortable.cjs +2 -0
- package/dist/hooks/use-sortable.cjs.map +1 -0
- package/dist/hooks/use-sortable.js +169 -0
- package/dist/hooks/use-sortable.js.map +1 -0
- package/dist/hooks/use-stable-callback.cjs.map +1 -1
- package/dist/hooks/use-stable-callback.js.map +1 -1
- package/dist/hooks/use-timeout.cjs +1 -1
- package/dist/hooks/use-timeout.cjs.map +1 -1
- package/dist/hooks/use-timeout.js +3 -1
- package/dist/hooks/use-timeout.js.map +1 -1
- package/dist/icons/Icon.cjs +2 -0
- package/dist/icons/Icon.cjs.map +1 -0
- package/dist/icons/Icon.js +24 -0
- package/dist/icons/Icon.js.map +1 -0
- package/dist/icons/IconProvider.cjs +2 -0
- package/dist/icons/IconProvider.cjs.map +1 -0
- package/dist/icons/IconProvider.js +24 -0
- package/dist/icons/IconProvider.js.map +1 -0
- package/dist/icons/generated/aliases.cjs +2 -0
- package/dist/icons/generated/aliases.cjs.map +1 -0
- package/dist/icons/generated/aliases.js +255 -0
- package/dist/icons/generated/aliases.js.map +1 -0
- package/dist/icons/generated/icon-names.cjs +2 -0
- package/dist/icons/generated/icon-names.cjs.map +1 -0
- package/dist/icons/generated/icon-names.js +6 -0
- package/dist/icons/generated/icon-names.js.map +1 -0
- package/dist/icons/generated/loaders.cjs +2 -0
- package/dist/icons/generated/loaders.cjs.map +1 -0
- package/dist/icons/generated/loaders.js +32 -0
- package/dist/icons/generated/loaders.js.map +1 -0
- package/dist/icons/generated/shard-a.cjs +2 -0
- package/dist/icons/generated/shard-a.cjs.map +1 -0
- package/dist/icons/generated/shard-a.js +114 -0
- package/dist/icons/generated/shard-a.js.map +1 -0
- package/dist/icons/generated/shard-b.cjs +2 -0
- package/dist/icons/generated/shard-b.cjs.map +1 -0
- package/dist/icons/generated/shard-b.js +156 -0
- package/dist/icons/generated/shard-b.js.map +1 -0
- package/dist/icons/generated/shard-c.cjs +2 -0
- package/dist/icons/generated/shard-c.cjs.map +1 -0
- package/dist/icons/generated/shard-c.js +269 -0
- package/dist/icons/generated/shard-c.js.map +1 -0
- package/dist/icons/generated/shard-d.cjs +2 -0
- package/dist/icons/generated/shard-d.cjs.map +1 -0
- package/dist/icons/generated/shard-d.js +62 -0
- package/dist/icons/generated/shard-d.js.map +1 -0
- package/dist/icons/generated/shard-e.cjs +2 -0
- package/dist/icons/generated/shard-e.cjs.map +1 -0
- package/dist/icons/generated/shard-e.js +32 -0
- package/dist/icons/generated/shard-e.js.map +1 -0
- package/dist/icons/generated/shard-f.cjs +2 -0
- package/dist/icons/generated/shard-f.cjs.map +1 -0
- package/dist/icons/generated/shard-f.js +139 -0
- package/dist/icons/generated/shard-f.js.map +1 -0
- package/dist/icons/generated/shard-g.cjs +2 -0
- package/dist/icons/generated/shard-g.cjs.map +1 -0
- package/dist/icons/generated/shard-g.js +61 -0
- package/dist/icons/generated/shard-g.js.map +1 -0
- package/dist/icons/generated/shard-h.cjs +2 -0
- package/dist/icons/generated/shard-h.cjs.map +1 -0
- package/dist/icons/generated/shard-h.js +63 -0
- package/dist/icons/generated/shard-h.js.map +1 -0
- package/dist/icons/generated/shard-i.cjs +2 -0
- package/dist/icons/generated/shard-i.cjs.map +1 -0
- package/dist/icons/generated/shard-i.js +30 -0
- package/dist/icons/generated/shard-i.js.map +1 -0
- package/dist/icons/generated/shard-j.cjs +2 -0
- package/dist/icons/generated/shard-j.cjs.map +1 -0
- package/dist/icons/generated/shard-j.js +10 -0
- package/dist/icons/generated/shard-j.js.map +1 -0
- package/dist/icons/generated/shard-k.cjs +2 -0
- package/dist/icons/generated/shard-k.cjs.map +1 -0
- package/dist/icons/generated/shard-k.js +16 -0
- package/dist/icons/generated/shard-k.js.map +1 -0
- package/dist/icons/generated/shard-l.cjs +2 -0
- package/dist/icons/generated/shard-l.cjs.map +1 -0
- package/dist/icons/generated/shard-l.js +88 -0
- package/dist/icons/generated/shard-l.js.map +1 -0
- package/dist/icons/generated/shard-m.cjs +2 -0
- package/dist/icons/generated/shard-m.cjs.map +1 -0
- package/dist/icons/generated/shard-m.js +140 -0
- package/dist/icons/generated/shard-m.js.map +1 -0
- package/dist/icons/generated/shard-n.cjs +2 -0
- package/dist/icons/generated/shard-n.cjs.map +1 -0
- package/dist/icons/generated/shard-n.js +24 -0
- package/dist/icons/generated/shard-n.js.map +1 -0
- package/dist/icons/generated/shard-o.cjs +2 -0
- package/dist/icons/generated/shard-o.cjs.map +1 -0
- package/dist/icons/generated/shard-o.js +17 -0
- package/dist/icons/generated/shard-o.js.map +1 -0
- package/dist/icons/generated/shard-p.cjs +2 -0
- package/dist/icons/generated/shard-p.cjs.map +1 -0
- package/dist/icons/generated/shard-p.js +115 -0
- package/dist/icons/generated/shard-p.js.map +1 -0
- package/dist/icons/generated/shard-q.cjs +2 -0
- package/dist/icons/generated/shard-q.cjs.map +1 -0
- package/dist/icons/generated/shard-q.js +10 -0
- package/dist/icons/generated/shard-q.js.map +1 -0
- package/dist/icons/generated/shard-r.cjs +2 -0
- package/dist/icons/generated/shard-r.cjs.map +1 -0
- package/dist/icons/generated/shard-r.js +77 -0
- package/dist/icons/generated/shard-r.js.map +1 -0
- package/dist/icons/generated/shard-s.cjs +2 -0
- package/dist/icons/generated/shard-s.cjs.map +1 -0
- package/dist/icons/generated/shard-s.js +255 -0
- package/dist/icons/generated/shard-s.js.map +1 -0
- package/dist/icons/generated/shard-t.cjs +2 -0
- package/dist/icons/generated/shard-t.cjs.map +1 -0
- package/dist/icons/generated/shard-t.js +109 -0
- package/dist/icons/generated/shard-t.js.map +1 -0
- package/dist/icons/generated/shard-u.cjs +2 -0
- package/dist/icons/generated/shard-u.cjs.map +1 -0
- package/dist/icons/generated/shard-u.js +49 -0
- package/dist/icons/generated/shard-u.js.map +1 -0
- package/dist/icons/generated/shard-v.cjs +2 -0
- package/dist/icons/generated/shard-v.cjs.map +1 -0
- package/dist/icons/generated/shard-v.js +30 -0
- package/dist/icons/generated/shard-v.js.map +1 -0
- package/dist/icons/generated/shard-w.cjs +2 -0
- package/dist/icons/generated/shard-w.cjs.map +1 -0
- package/dist/icons/generated/shard-w.js +48 -0
- package/dist/icons/generated/shard-w.js.map +1 -0
- package/dist/icons/generated/shard-x.cjs +2 -0
- package/dist/icons/generated/shard-x.cjs.map +1 -0
- package/dist/icons/generated/shard-x.js +10 -0
- package/dist/icons/generated/shard-x.js.map +1 -0
- package/dist/icons/generated/shard-z.cjs +2 -0
- package/dist/icons/generated/shard-z.cjs.map +1 -0
- package/dist/icons/generated/shard-z.js +25 -0
- package/dist/icons/generated/shard-z.js.map +1 -0
- package/dist/icons/icon-context.cjs +2 -0
- package/dist/icons/icon-context.cjs.map +1 -0
- package/dist/icons/icon-context.js +13 -0
- package/dist/icons/icon-context.js.map +1 -0
- package/dist/icons/is-icon-name.cjs +2 -0
- package/dist/icons/is-icon-name.cjs.map +1 -0
- package/dist/icons/is-icon-name.js +10 -0
- package/dist/icons/is-icon-name.js.map +1 -0
- package/dist/icons/shard-cache.cjs +2 -0
- package/dist/icons/shard-cache.cjs.map +1 -0
- package/dist/icons/shard-cache.js +41 -0
- package/dist/icons/shard-cache.js.map +1 -0
- package/dist/icons/use-icon.cjs +2 -0
- package/dist/icons/use-icon.cjs.map +1 -0
- package/dist/icons/use-icon.js +20 -0
- package/dist/icons/use-icon.js.map +1 -0
- package/dist/icons-virtual.d.ts +22 -0
- package/dist/icons.cjs +1 -0
- package/dist/icons.d.ts +220 -0
- package/dist/icons.js +9 -0
- package/dist/offline/create-offline-sync.cjs +1 -1
- package/dist/offline/create-offline-sync.cjs.map +1 -1
- package/dist/offline/create-offline-sync.js +8 -2
- package/dist/offline/create-offline-sync.js.map +1 -1
- package/dist/offline/use-offline-sync.cjs +1 -1
- package/dist/offline/use-offline-sync.cjs.map +1 -1
- package/dist/offline/use-offline-sync.js +3 -1
- package/dist/offline/use-offline-sync.js.map +1 -1
- package/dist/push/use-push-subscription.cjs +1 -1
- package/dist/push/use-push-subscription.cjs.map +1 -1
- package/dist/push/use-push-subscription.js +3 -1
- package/dist/push/use-push-subscription.js.map +1 -1
- package/dist/sse/use-event-stream.cjs +1 -1
- package/dist/sse/use-event-stream.cjs.map +1 -1
- package/dist/sse/use-event-stream.js +3 -1
- package/dist/sse/use-event-stream.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +1187 -2
- package/dist/tempest-react-sdk.js +261 -246
- package/dist/theme/ThemeProvider.cjs +1 -1
- package/dist/theme/ThemeProvider.cjs.map +1 -1
- package/dist/theme/ThemeProvider.js +6 -2
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/apply-theme.cjs +2 -0
- package/dist/theme/apply-theme.cjs.map +1 -0
- package/dist/theme/apply-theme.js +24 -0
- package/dist/theme/apply-theme.js.map +1 -0
- package/dist/theme/color.cjs +2 -0
- package/dist/theme/color.cjs.map +1 -0
- package/dist/theme/color.js +161 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/create-theme.cjs +5 -0
- package/dist/theme/create-theme.cjs.map +1 -0
- package/dist/theme/create-theme.js +141 -0
- package/dist/theme/create-theme.js.map +1 -0
- package/dist/theme/theme-presets.cjs +2 -0
- package/dist/theme/theme-presets.cjs.map +1 -0
- package/dist/theme/theme-presets.js +82 -0
- package/dist/theme/theme-presets.js.map +1 -0
- package/dist/utilities.css +432 -0
- package/dist/utils/compare-values.cjs +2 -0
- package/dist/utils/compare-values.cjs.map +1 -0
- package/dist/utils/compare-values.js +8 -0
- package/dist/utils/compare-values.js.map +1 -0
- package/dist/vision/use-camera-stream.cjs +1 -1
- package/dist/vision/use-camera-stream.cjs.map +1 -1
- package/dist/vision/use-camera-stream.js +3 -1
- package/dist/vision/use-camera-stream.js.map +1 -1
- package/dist/vite/create-vite-config.cjs +1 -1
- package/dist/vite/create-vite-config.cjs.map +1 -1
- package/dist/vite/create-vite-config.js +30 -22
- package/dist/vite/create-vite-config.js.map +1 -1
- package/dist/vite/tempest-icons.cjs +9 -0
- package/dist/vite/tempest-icons.cjs.map +1 -0
- package/dist/vite/tempest-icons.js +99 -0
- package/dist/vite/tempest-icons.js.map +1 -0
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.ts +79 -0
- package/dist/vite.js +6 -5
- package/dist/ws/use-web-socket.cjs +1 -1
- package/dist/ws/use-web-socket.cjs.map +1 -1
- package/dist/ws/use-web-socket.js +3 -1
- package/dist/ws/use-web-socket.js.map +1 -1
- package/package.json +14 -4
- package/template/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wizard.cjs","names":[],"sources":["../../../src/components/Wizard/Wizard.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { Button } from \"../Button\";\nimport { Stepper } from \"../Stepper\";\nimport styles from \"./Wizard.module.css\";\n\n/** One step of the flow. */\nexport interface WizardStep {\n /** Stable identifier. */\n id: string;\n /** Step label shown in the indicator. */\n label: string;\n /** Optional description under the label. */\n description?: string;\n /** Step body. A function receives the flow controls, for a \"skip\" link inside the form. */\n content: ReactNode | ((controls: WizardControls) => ReactNode);\n /**\n * Gate for leaving this step forward. Return `false` (or a rejected/`false`\n * promise) to keep the user here — typically `() => form.trigger()`.\n * Async is supported: the Next button shows a pending state while it runs.\n */\n validate?: () => boolean | Promise<boolean>;\n /** Marks the step as optional, so `onComplete` can ignore it. */\n optional?: boolean;\n}\n\n/** Flow controls handed to a step body and to `renderActions`. */\nexport interface WizardControls {\n /** Zero-based index of the current step. */\n activeIndex: number;\n /** The current step. */\n step: WizardStep;\n /** `true` while a `validate` promise is pending. */\n validating: boolean;\n isFirst: boolean;\n isLast: boolean;\n /** Run the current step's `validate` and advance when it passes. */\n next: () => Promise<void>;\n /** Go back one step. No validation — going back never blocks. */\n back: () => void;\n /** Jump to an index. Forward jumps validate every step in between. */\n goTo: (index: number) => Promise<void>;\n}\n\nexport interface WizardProps {\n steps: WizardStep[];\n /** Controlled active index. */\n activeIndex?: number;\n /** Uncontrolled initial index. Default `0`. */\n defaultActiveIndex?: number;\n onStepChange?: (index: number, step: WizardStep) => void;\n /** Called when the last step passes validation. */\n onComplete?: () => void | Promise<void>;\n /** Label of the advance button. Default `\"Next\"`. */\n nextLabel?: string;\n /** Label of the back button. Default `\"Back\"`. */\n backLabel?: string;\n /** Label of the button on the last step. Default `\"Finish\"`. */\n finishLabel?: string;\n /**\n * Suffix appended to an optional step's description in the indicator.\n * Default `\"(optional)\"` — override it to localize, since the SDK ships no\n * translation for component-internal copy.\n */\n optionalLabel?: string;\n /**\n * Allow clicking the indicator to jump. Default `false` — a wizard exists\n * because order matters, and a free jump skips the gates.\n */\n clickableSteps?: boolean;\n /** Replace the default button row. */\n renderActions?: (controls: WizardControls) => ReactNode;\n className?: string;\n}\n\n/**\n * Multi-step flow: step indicator, one body at a time, and navigation that\n * respects per-step validation.\n *\n * `Stepper` draws the indicator; this owns the part every app was rewriting — the\n * active index, the async gate before advancing, the disabled/pending buttons and\n * the completion call.\n *\n * Only the active step's body is mounted. Uncommitted input in a step you leave is\n * therefore lost unless the state lives outside (react-hook-form's `FormProvider`,\n * a store, a parent `useState`) — which is the right place for it anyway, since\n * the last step usually needs to submit everything at once.\n *\n * @example\n * ```tsx\n * const form = useZodForm(schema);\n *\n * <FormProvider {...form}>\n * <Wizard\n * steps={[\n * {\n * id: \"dados\",\n * label: \"Dados\",\n * validate: () => form.trigger([\"nome\", \"email\"]),\n * content: (\n * <>\n * <FormField name=\"nome\" label=\"Nome\"><Input /></FormField>\n * <FormField name=\"email\" label=\"E-mail\"><Input type=\"email\" /></FormField>\n * </>\n * ),\n * },\n * { id: \"revisao\", label: \"Revisão\", content: <Review /> },\n * ]}\n * onComplete={form.handleSubmit(onSubmit)}\n * />\n * </FormProvider>\n * ```\n */\nexport function Wizard({\n steps,\n activeIndex,\n defaultActiveIndex = 0,\n onStepChange,\n onComplete,\n nextLabel = \"Next\",\n backLabel = \"Back\",\n finishLabel = \"Finish\",\n optionalLabel = \"(optional)\",\n clickableSteps = false,\n renderActions,\n className,\n}: WizardProps) {\n const isControlled = activeIndex !== undefined;\n const [internalIndex, setInternalIndex] = useState(defaultActiveIndex);\n const [validating, setValidating] = useState(false);\n\n const current = Math.min(isControlled ? activeIndex : internalIndex, steps.length - 1);\n const step = steps[current];\n\n const moveTo = useCallback(\n (index: number): void => {\n if (!isControlled) setInternalIndex(index);\n onStepChange?.(index, steps[index]);\n },\n [isControlled, onStepChange, steps],\n );\n\n /**\n * Run a step's gate. A gate that throws counts as \"not allowed\": a `validate`\n * wired to a network check should not strand the user on a half-advanced flow\n * when the request fails.\n */\n const runValidate = useCallback(async (candidate: WizardStep): Promise<boolean> => {\n if (!candidate.validate) return true;\n setValidating(true);\n try {\n return await candidate.validate();\n } catch {\n return false;\n } finally {\n setValidating(false);\n }\n }, []);\n\n const next = useCallback(async (): Promise<void> => {\n if (!(await runValidate(step))) return;\n if (current === steps.length - 1) {\n await onComplete?.();\n return;\n }\n moveTo(current + 1);\n }, [current, moveTo, onComplete, runValidate, step, steps.length]);\n\n const back = useCallback((): void => {\n if (current > 0) moveTo(current - 1);\n }, [current, moveTo]);\n\n const goTo = useCallback(\n async (index: number): Promise<void> => {\n const target = Math.max(0, Math.min(index, steps.length - 1));\n if (target === current) return;\n if (target < current) {\n moveTo(target);\n return;\n }\n for (let i = current; i < target; i += 1) {\n if (!(await runValidate(steps[i]))) return;\n }\n moveTo(target);\n },\n [current, moveTo, runValidate, steps],\n );\n\n const controls = useMemo<WizardControls>(\n () => ({\n activeIndex: current,\n step,\n validating,\n isFirst: current === 0,\n isLast: current === steps.length - 1,\n next,\n back,\n goTo,\n }),\n [back, current, goTo, next, step, steps.length, validating],\n );\n\n const indicatorSteps = useMemo(\n () =>\n steps.map((item) => ({\n label: item.label,\n description: item.optional\n ? `${item.description ?? \"\"} ${optionalLabel}`.trim()\n : item.description,\n })),\n [optionalLabel, steps],\n );\n\n return (\n <div className={cn(styles.wizard, className)}>\n <Stepper\n steps={indicatorSteps}\n current={current}\n onStepClick={clickableSteps ? (index) => void goTo(index) : undefined}\n />\n\n <div className={styles.body} role=\"group\" aria-label={step.label}>\n {typeof step.content === \"function\" ? step.content(controls) : step.content}\n </div>\n\n {renderActions ? (\n renderActions(controls)\n ) : (\n <div className={styles.actions}>\n <Button\n variant=\"secondary\"\n onClick={back}\n disabled={controls.isFirst || validating}\n >\n {backLabel}\n </Button>\n <Button onClick={() => void next()} loading={validating}>\n {controls.isLast ? finishLabel : nextLabel}\n </Button>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":"mMAkHA,SAAgB,EAAO,CACnB,QACA,cACA,qBAAqB,EACrB,eACA,aACA,YAAY,OACZ,YAAY,OACZ,cAAc,SACd,gBAAgB,aAChB,iBAAiB,GACjB,gBACA,aACY,CACZ,IAAM,EAAe,IAAgB,IAAA,GAC/B,CAAC,EAAe,IAAA,EAAA,EAAA,SAAA,CAA6B,CAAkB,EAC/D,CAAC,EAAY,IAAA,EAAA,EAAA,SAAA,CAA0B,EAAK,EAE5C,EAAU,KAAK,IAAI,EAAe,EAAc,EAAe,EAAM,OAAS,CAAC,EAC/E,EAAO,EAAM,GAEb,GAAA,EAAA,EAAA,YAAA,CACD,GAAwB,CAChB,GAAc,EAAiB,CAAK,EACzC,IAAe,EAAO,EAAM,EAAM,CACtC,EACA,CAAC,EAAc,EAAc,CAAK,CACtC,EAOM,GAAA,EAAA,EAAA,YAAA,CAA0B,KAAO,IAA4C,CAC/E,GAAI,CAAC,EAAU,SAAU,MAAO,GAChC,EAAc,EAAI,EAClB,GAAI,CACA,OAAO,MAAM,EAAU,SAAS,CACpC,MAAQ,CACJ,MAAO,EACX,QAAU,CACN,EAAc,EAAK,CACvB,CACJ,EAAG,CAAC,CAAC,EAEC,GAAA,EAAA,EAAA,YAAA,CAAmB,SAA2B,CAC1C,SAAM,EAAY,CAAI,EAC5B,IAAI,IAAY,EAAM,OAAS,EAAG,CAC9B,MAAM,IAAa,EACnB,MACJ,CACA,EAAO,EAAU,CAAC,CADlB,CAEJ,EAAG,CAAC,EAAS,EAAQ,EAAY,EAAa,EAAM,EAAM,MAAM,CAAC,EAE3D,GAAA,EAAA,EAAA,YAAA,KAA+B,CAC7B,EAAU,GAAG,EAAO,EAAU,CAAC,CACvC,EAAG,CAAC,EAAS,CAAM,CAAC,EAEd,GAAA,EAAA,EAAA,YAAA,CACF,KAAO,IAAiC,CACpC,IAAM,EAAS,KAAK,IAAI,EAAG,KAAK,IAAI,EAAO,EAAM,OAAS,CAAC,CAAC,EACxD,OAAW,EACf,IAAI,EAAS,EAAS,CAClB,EAAO,CAAM,EACb,MACJ,CACA,IAAK,IAAI,EAAI,EAAS,EAAI,EAAQ,GAAK,EACnC,GAAI,CAAE,MAAM,EAAY,EAAM,EAAE,EAAI,OAExC,EAAO,CAAM,CAJb,CAKJ,EACA,CAAC,EAAS,EAAQ,EAAa,CAAK,CACxC,EAEM,GAAA,EAAA,EAAA,QAAA,MACK,CACH,YAAa,EACb,OACA,aACA,QAAS,IAAY,EACrB,OAAQ,IAAY,EAAM,OAAS,EACnC,OACA,OACA,MACJ,GACA,CAAC,EAAM,EAAS,EAAM,EAAM,EAAM,EAAM,OAAQ,CAAU,CAC9D,EAEM,GAAA,EAAA,EAAA,QAAA,KAEE,EAAM,IAAK,IAAU,CACjB,MAAO,EAAK,MACZ,YAAa,EAAK,SACZ,GAAG,EAAK,aAAe,GAAG,GAAG,IAAgB,KAAK,EAClD,EAAK,WACf,EAAE,EACN,CAAC,EAAe,CAAK,CACzB,EAEA,OACI,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,OAAQ,CAAS,WAA3C,EACI,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACI,MAAO,EACE,UACT,YAAa,EAAkB,GAAU,KAAK,EAAK,CAAK,EAAI,IAAA,EAC/D,CAAA,GAED,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,QAAO,KAAM,KAAK,QAAQ,aAAY,EAAK,eACtD,OAAO,EAAK,SAAY,WAAa,EAAK,QAAQ,CAAQ,EAAI,EAAK,OACnE,CAAA,EAEJ,EACG,EAAc,CAAQ,GAEtB,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,QAAO,iBAAvB,EACI,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CACI,QAAQ,YACR,QAAS,EACT,SAAU,EAAS,SAAW,WAE7B,CACG,CAAA,GACR,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAQ,YAAe,KAAK,EAAK,EAAG,QAAS,WACxC,EAAS,OAAS,EAAc,CAC7B,CAAA,CACP,GAER,GAEb"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { cn as e } from "../../utils/cn.js";
|
|
2
|
+
import { Button as t } from "../Button/Button.js";
|
|
3
|
+
import { Stepper as n } from "../Stepper/Stepper.js";
|
|
4
|
+
import r from "./Wizard.module.js";
|
|
5
|
+
import { useCallback as i, useMemo as a, useState as o } from "react";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/Wizard/Wizard.tsx
|
|
8
|
+
function l({ steps: l, activeIndex: u, defaultActiveIndex: d = 0, onStepChange: f, onComplete: p, nextLabel: m = "Next", backLabel: h = "Back", finishLabel: g = "Finish", optionalLabel: _ = "(optional)", clickableSteps: v = !1, renderActions: y, className: b }) {
|
|
9
|
+
let x = u !== void 0, [S, C] = o(d), [w, T] = o(!1), E = Math.min(x ? u : S, l.length - 1), D = l[E], O = i((e) => {
|
|
10
|
+
x || C(e), f?.(e, l[e]);
|
|
11
|
+
}, [
|
|
12
|
+
x,
|
|
13
|
+
f,
|
|
14
|
+
l
|
|
15
|
+
]), k = i(async (e) => {
|
|
16
|
+
if (!e.validate) return !0;
|
|
17
|
+
T(!0);
|
|
18
|
+
try {
|
|
19
|
+
return await e.validate();
|
|
20
|
+
} catch {
|
|
21
|
+
return !1;
|
|
22
|
+
} finally {
|
|
23
|
+
T(!1);
|
|
24
|
+
}
|
|
25
|
+
}, []), A = i(async () => {
|
|
26
|
+
if (await k(D)) {
|
|
27
|
+
if (E === l.length - 1) {
|
|
28
|
+
await p?.();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
O(E + 1);
|
|
32
|
+
}
|
|
33
|
+
}, [
|
|
34
|
+
E,
|
|
35
|
+
O,
|
|
36
|
+
p,
|
|
37
|
+
k,
|
|
38
|
+
D,
|
|
39
|
+
l.length
|
|
40
|
+
]), j = i(() => {
|
|
41
|
+
E > 0 && O(E - 1);
|
|
42
|
+
}, [E, O]), M = i(async (e) => {
|
|
43
|
+
let t = Math.max(0, Math.min(e, l.length - 1));
|
|
44
|
+
if (t !== E) {
|
|
45
|
+
if (t < E) {
|
|
46
|
+
O(t);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
for (let e = E; e < t; e += 1) if (!await k(l[e])) return;
|
|
50
|
+
O(t);
|
|
51
|
+
}
|
|
52
|
+
}, [
|
|
53
|
+
E,
|
|
54
|
+
O,
|
|
55
|
+
k,
|
|
56
|
+
l
|
|
57
|
+
]), N = a(() => ({
|
|
58
|
+
activeIndex: E,
|
|
59
|
+
step: D,
|
|
60
|
+
validating: w,
|
|
61
|
+
isFirst: E === 0,
|
|
62
|
+
isLast: E === l.length - 1,
|
|
63
|
+
next: A,
|
|
64
|
+
back: j,
|
|
65
|
+
goTo: M
|
|
66
|
+
}), [
|
|
67
|
+
j,
|
|
68
|
+
E,
|
|
69
|
+
M,
|
|
70
|
+
A,
|
|
71
|
+
D,
|
|
72
|
+
l.length,
|
|
73
|
+
w
|
|
74
|
+
]), P = a(() => l.map((e) => ({
|
|
75
|
+
label: e.label,
|
|
76
|
+
description: e.optional ? `${e.description ?? ""} ${_}`.trim() : e.description
|
|
77
|
+
})), [_, l]);
|
|
78
|
+
return /* @__PURE__ */ c("div", {
|
|
79
|
+
className: e(r.wizard, b),
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ s(n, {
|
|
82
|
+
steps: P,
|
|
83
|
+
current: E,
|
|
84
|
+
onStepClick: v ? (e) => void M(e) : void 0
|
|
85
|
+
}),
|
|
86
|
+
/* @__PURE__ */ s("div", {
|
|
87
|
+
className: r.body,
|
|
88
|
+
role: "group",
|
|
89
|
+
"aria-label": D.label,
|
|
90
|
+
children: typeof D.content == "function" ? D.content(N) : D.content
|
|
91
|
+
}),
|
|
92
|
+
y ? y(N) : /* @__PURE__ */ c("div", {
|
|
93
|
+
className: r.actions,
|
|
94
|
+
children: [/* @__PURE__ */ s(t, {
|
|
95
|
+
variant: "secondary",
|
|
96
|
+
onClick: j,
|
|
97
|
+
disabled: N.isFirst || w,
|
|
98
|
+
children: h
|
|
99
|
+
}), /* @__PURE__ */ s(t, {
|
|
100
|
+
onClick: () => void A(),
|
|
101
|
+
loading: w,
|
|
102
|
+
children: N.isLast ? g : m
|
|
103
|
+
})]
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { l as Wizard };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=Wizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wizard.js","names":[],"sources":["../../../src/components/Wizard/Wizard.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { Button } from \"../Button\";\nimport { Stepper } from \"../Stepper\";\nimport styles from \"./Wizard.module.css\";\n\n/** One step of the flow. */\nexport interface WizardStep {\n /** Stable identifier. */\n id: string;\n /** Step label shown in the indicator. */\n label: string;\n /** Optional description under the label. */\n description?: string;\n /** Step body. A function receives the flow controls, for a \"skip\" link inside the form. */\n content: ReactNode | ((controls: WizardControls) => ReactNode);\n /**\n * Gate for leaving this step forward. Return `false` (or a rejected/`false`\n * promise) to keep the user here — typically `() => form.trigger()`.\n * Async is supported: the Next button shows a pending state while it runs.\n */\n validate?: () => boolean | Promise<boolean>;\n /** Marks the step as optional, so `onComplete` can ignore it. */\n optional?: boolean;\n}\n\n/** Flow controls handed to a step body and to `renderActions`. */\nexport interface WizardControls {\n /** Zero-based index of the current step. */\n activeIndex: number;\n /** The current step. */\n step: WizardStep;\n /** `true` while a `validate` promise is pending. */\n validating: boolean;\n isFirst: boolean;\n isLast: boolean;\n /** Run the current step's `validate` and advance when it passes. */\n next: () => Promise<void>;\n /** Go back one step. No validation — going back never blocks. */\n back: () => void;\n /** Jump to an index. Forward jumps validate every step in between. */\n goTo: (index: number) => Promise<void>;\n}\n\nexport interface WizardProps {\n steps: WizardStep[];\n /** Controlled active index. */\n activeIndex?: number;\n /** Uncontrolled initial index. Default `0`. */\n defaultActiveIndex?: number;\n onStepChange?: (index: number, step: WizardStep) => void;\n /** Called when the last step passes validation. */\n onComplete?: () => void | Promise<void>;\n /** Label of the advance button. Default `\"Next\"`. */\n nextLabel?: string;\n /** Label of the back button. Default `\"Back\"`. */\n backLabel?: string;\n /** Label of the button on the last step. Default `\"Finish\"`. */\n finishLabel?: string;\n /**\n * Suffix appended to an optional step's description in the indicator.\n * Default `\"(optional)\"` — override it to localize, since the SDK ships no\n * translation for component-internal copy.\n */\n optionalLabel?: string;\n /**\n * Allow clicking the indicator to jump. Default `false` — a wizard exists\n * because order matters, and a free jump skips the gates.\n */\n clickableSteps?: boolean;\n /** Replace the default button row. */\n renderActions?: (controls: WizardControls) => ReactNode;\n className?: string;\n}\n\n/**\n * Multi-step flow: step indicator, one body at a time, and navigation that\n * respects per-step validation.\n *\n * `Stepper` draws the indicator; this owns the part every app was rewriting — the\n * active index, the async gate before advancing, the disabled/pending buttons and\n * the completion call.\n *\n * Only the active step's body is mounted. Uncommitted input in a step you leave is\n * therefore lost unless the state lives outside (react-hook-form's `FormProvider`,\n * a store, a parent `useState`) — which is the right place for it anyway, since\n * the last step usually needs to submit everything at once.\n *\n * @example\n * ```tsx\n * const form = useZodForm(schema);\n *\n * <FormProvider {...form}>\n * <Wizard\n * steps={[\n * {\n * id: \"dados\",\n * label: \"Dados\",\n * validate: () => form.trigger([\"nome\", \"email\"]),\n * content: (\n * <>\n * <FormField name=\"nome\" label=\"Nome\"><Input /></FormField>\n * <FormField name=\"email\" label=\"E-mail\"><Input type=\"email\" /></FormField>\n * </>\n * ),\n * },\n * { id: \"revisao\", label: \"Revisão\", content: <Review /> },\n * ]}\n * onComplete={form.handleSubmit(onSubmit)}\n * />\n * </FormProvider>\n * ```\n */\nexport function Wizard({\n steps,\n activeIndex,\n defaultActiveIndex = 0,\n onStepChange,\n onComplete,\n nextLabel = \"Next\",\n backLabel = \"Back\",\n finishLabel = \"Finish\",\n optionalLabel = \"(optional)\",\n clickableSteps = false,\n renderActions,\n className,\n}: WizardProps) {\n const isControlled = activeIndex !== undefined;\n const [internalIndex, setInternalIndex] = useState(defaultActiveIndex);\n const [validating, setValidating] = useState(false);\n\n const current = Math.min(isControlled ? activeIndex : internalIndex, steps.length - 1);\n const step = steps[current];\n\n const moveTo = useCallback(\n (index: number): void => {\n if (!isControlled) setInternalIndex(index);\n onStepChange?.(index, steps[index]);\n },\n [isControlled, onStepChange, steps],\n );\n\n /**\n * Run a step's gate. A gate that throws counts as \"not allowed\": a `validate`\n * wired to a network check should not strand the user on a half-advanced flow\n * when the request fails.\n */\n const runValidate = useCallback(async (candidate: WizardStep): Promise<boolean> => {\n if (!candidate.validate) return true;\n setValidating(true);\n try {\n return await candidate.validate();\n } catch {\n return false;\n } finally {\n setValidating(false);\n }\n }, []);\n\n const next = useCallback(async (): Promise<void> => {\n if (!(await runValidate(step))) return;\n if (current === steps.length - 1) {\n await onComplete?.();\n return;\n }\n moveTo(current + 1);\n }, [current, moveTo, onComplete, runValidate, step, steps.length]);\n\n const back = useCallback((): void => {\n if (current > 0) moveTo(current - 1);\n }, [current, moveTo]);\n\n const goTo = useCallback(\n async (index: number): Promise<void> => {\n const target = Math.max(0, Math.min(index, steps.length - 1));\n if (target === current) return;\n if (target < current) {\n moveTo(target);\n return;\n }\n for (let i = current; i < target; i += 1) {\n if (!(await runValidate(steps[i]))) return;\n }\n moveTo(target);\n },\n [current, moveTo, runValidate, steps],\n );\n\n const controls = useMemo<WizardControls>(\n () => ({\n activeIndex: current,\n step,\n validating,\n isFirst: current === 0,\n isLast: current === steps.length - 1,\n next,\n back,\n goTo,\n }),\n [back, current, goTo, next, step, steps.length, validating],\n );\n\n const indicatorSteps = useMemo(\n () =>\n steps.map((item) => ({\n label: item.label,\n description: item.optional\n ? `${item.description ?? \"\"} ${optionalLabel}`.trim()\n : item.description,\n })),\n [optionalLabel, steps],\n );\n\n return (\n <div className={cn(styles.wizard, className)}>\n <Stepper\n steps={indicatorSteps}\n current={current}\n onStepClick={clickableSteps ? (index) => void goTo(index) : undefined}\n />\n\n <div className={styles.body} role=\"group\" aria-label={step.label}>\n {typeof step.content === \"function\" ? step.content(controls) : step.content}\n </div>\n\n {renderActions ? (\n renderActions(controls)\n ) : (\n <div className={styles.actions}>\n <Button\n variant=\"secondary\"\n onClick={back}\n disabled={controls.isFirst || validating}\n >\n {backLabel}\n </Button>\n <Button onClick={() => void next()} loading={validating}>\n {controls.isLast ? finishLabel : nextLabel}\n </Button>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAkHA,SAAgB,EAAO,EACnB,UACA,gBACA,wBAAqB,GACrB,iBACA,eACA,eAAY,QACZ,eAAY,QACZ,iBAAc,UACd,mBAAgB,cAChB,oBAAiB,IACjB,kBACA,gBACY;CACZ,IAAM,IAAe,MAAgB,KAAA,GAC/B,CAAC,GAAe,KAAoB,EAAS,CAAkB,GAC/D,CAAC,GAAY,KAAiB,EAAS,EAAK,GAE5C,IAAU,KAAK,IAAI,IAAe,IAAc,GAAe,EAAM,SAAS,CAAC,GAC/E,IAAO,EAAM,IAEb,IAAS,GACV,MAAwB;EAErB,AADK,KAAc,EAAiB,CAAK,GACzC,IAAe,GAAO,EAAM,EAAM;CACtC,GACA;EAAC;EAAc;EAAc;CAAK,CACtC,GAOM,IAAc,EAAY,OAAO,MAA4C;EAC/E,IAAI,CAAC,EAAU,UAAU,OAAO;EAChC,EAAc,EAAI;EAClB,IAAI;GACA,OAAO,MAAM,EAAU,SAAS;EACpC,QAAQ;GACJ,OAAO;EACX,UAAU;GACN,EAAc,EAAK;EACvB;CACJ,GAAG,CAAC,CAAC,GAEC,IAAO,EAAY,YAA2B;EAC1C,UAAM,EAAY,CAAI,GAC5B;OAAI,MAAY,EAAM,SAAS,GAAG;IAC9B,MAAM,IAAa;IACnB;GACJ;GACA,EAAO,IAAU,CAAC;EADlB;CAEJ,GAAG;EAAC;EAAS;EAAQ;EAAY;EAAa;EAAM,EAAM;CAAM,CAAC,GAE3D,IAAO,QAAwB;EACjC,AAAI,IAAU,KAAG,EAAO,IAAU,CAAC;CACvC,GAAG,CAAC,GAAS,CAAM,CAAC,GAEd,IAAO,EACT,OAAO,MAAiC;EACpC,IAAM,IAAS,KAAK,IAAI,GAAG,KAAK,IAAI,GAAO,EAAM,SAAS,CAAC,CAAC;EACxD,UAAW,GACf;OAAI,IAAS,GAAS;IAClB,EAAO,CAAM;IACb;GACJ;GACA,KAAK,IAAI,IAAI,GAAS,IAAI,GAAQ,KAAK,GACnC,IAAI,CAAE,MAAM,EAAY,EAAM,EAAE,GAAI;GAExC,EAAO,CAAM;EAJb;CAKJ,GACA;EAAC;EAAS;EAAQ;EAAa;CAAK,CACxC,GAEM,IAAW,SACN;EACH,aAAa;EACb;EACA;EACA,SAAS,MAAY;EACrB,QAAQ,MAAY,EAAM,SAAS;EACnC;EACA;EACA;CACJ,IACA;EAAC;EAAM;EAAS;EAAM;EAAM;EAAM,EAAM;EAAQ;CAAU,CAC9D,GAEM,IAAiB,QAEf,EAAM,KAAK,OAAU;EACjB,OAAO,EAAK;EACZ,aAAa,EAAK,WACZ,GAAG,EAAK,eAAe,GAAG,GAAG,IAAgB,KAAK,IAClD,EAAK;CACf,EAAE,GACN,CAAC,GAAe,CAAK,CACzB;CAEA,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,QAAQ,CAAS;YAA3C;GACI,kBAAC,GAAD;IACI,OAAO;IACE;IACT,aAAa,KAAkB,MAAU,KAAK,EAAK,CAAK,IAAI,KAAA;GAC/D,CAAA;GAED,kBAAC,OAAD;IAAK,WAAW,EAAO;IAAM,MAAK;IAAQ,cAAY,EAAK;cACtD,OAAO,EAAK,WAAY,aAAa,EAAK,QAAQ,CAAQ,IAAI,EAAK;GACnE,CAAA;GAEJ,IACG,EAAc,CAAQ,IAEtB,kBAAC,OAAD;IAAK,WAAW,EAAO;cAAvB,CACI,kBAAC,GAAD;KACI,SAAQ;KACR,SAAS;KACT,UAAU,EAAS,WAAW;eAE7B;IACG,CAAA,GACR,kBAAC,GAAD;KAAQ,eAAe,KAAK,EAAK;KAAG,SAAS;eACxC,EAAS,SAAS,IAAc;IAC7B,CAAA,CACP;;EAER;;AAEb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wizard.module.cjs","names":[],"sources":["../../../src/components/Wizard/Wizard.module.css"],"sourcesContent":[".wizard {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-6);\n width: 100%;\n}\n\n.body {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-4);\n min-height: var(--tempest-wizard-body-min-height, 0);\n}\n\n.actions {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--tempest-space-3);\n padding-top: var(--tempest-space-4);\n border-top: 1px solid var(--tempest-border);\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/Wizard/Wizard.module.css
|
|
2
|
+
var e = "tempest_wizard_2BkgZ", t = "tempest_body_ZDhtj", n = "tempest_actions_-VsgT", r = {
|
|
3
|
+
wizard: e,
|
|
4
|
+
body: t,
|
|
5
|
+
actions: n
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { n as actions, t as body, r as default, e as wizard };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=Wizard.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wizard.module.js","names":[],"sources":["../../../src/components/Wizard/Wizard.module.css"],"sourcesContent":[".wizard {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-6);\n width: 100%;\n}\n\n.body {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-4);\n min-height: var(--tempest-wizard-body-min-height, 0);\n}\n\n.actions {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--tempest-space-3);\n padding-top: var(--tempest-space-4);\n border-top: 1px solid var(--tempest-border);\n}\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./create-position-tracker.cjs");let t=require("react");function n(n={}){let{autoStart:r=!1,onError:i,...a}=n,[o,s]=(0,t.useState)([]),[c,l]=(0,t.useState)(0),[u,d]=(0,t.useState)(`idle`),f=(0,t.useRef)(null),p=(0,t.useRef)(i);p.current=i,(0,t.useEffect)(()=>{let t=e.createPositionTracker({...a,onUpdate:e=>{s([...e]),l(t.distanceKm)},onStatusChange:d,onError:e=>p.current?.(e)});return f.current=t,r&&t.start(),()=>{t.stop(),f.current=null}},[]);let m=(0,t.useCallback)(()=>f.current?.start(),[]),h=(0,t.useCallback)(()=>f.current?.stop(),[]),g=(0,t.useCallback)(()=>{f.current?.clear(),l(0)},[]);return{points:o,lastPoint:o.length>0?o[o.length-1]:null,distanceKm:c,status:u,isTracking:u===`tracking`,start:m,stop:h,clear:g}}exports.usePositionTracker=n;
|
|
1
|
+
const e=require("./create-position-tracker.cjs");let t=require("react");function n(n={}){let{autoStart:r=!1,onError:i,...a}=n,[o,s]=(0,t.useState)([]),[c,l]=(0,t.useState)(0),[u,d]=(0,t.useState)(`idle`),f=(0,t.useRef)(null),p=(0,t.useRef)(i);(0,t.useEffect)(()=>{p.current=i},[i]),(0,t.useEffect)(()=>{let t=e.createPositionTracker({...a,onUpdate:e=>{s([...e]),l(t.distanceKm)},onStatusChange:d,onError:e=>p.current?.(e)});return f.current=t,r&&t.start(),()=>{t.stop(),f.current=null}},[]);let m=(0,t.useCallback)(()=>f.current?.start(),[]),h=(0,t.useCallback)(()=>f.current?.stop(),[]),g=(0,t.useCallback)(()=>{f.current?.clear(),l(0)},[]);return{points:o,lastPoint:o.length>0?o[o.length-1]:null,distanceKm:c,status:u,isTracking:u===`tracking`,start:m,stop:h,clear:g}}exports.usePositionTracker=n;
|
|
2
2
|
//# sourceMappingURL=use-position-tracker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-position-tracker.cjs","names":[],"sources":["../../src/geo/use-position-tracker.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n createPositionTracker,\n type CreatePositionTrackerOptions,\n type PositionTracker,\n type TrackerStatus,\n} from \"./create-position-tracker\";\nimport type { TrackPoint } from \"./types\";\n\nexport interface UsePositionTrackerOptions extends Omit<\n CreatePositionTrackerOptions,\n \"onUpdate\" | \"onStatusChange\"\n> {\n /** Start tracking automatically on mount. Default: `false`. */\n autoStart?: boolean;\n}\n\nexport interface UsePositionTrackerResult {\n /** Recorded trajectory (newest last). */\n points: readonly TrackPoint[];\n /** Most recent point, or `null` before the first fix. */\n lastPoint: TrackPoint | null;\n /** Total distance of the trajectory in kilometers. */\n distanceKm: number;\n /** Current tracker status. */\n status: TrackerStatus;\n /** True while `status === \"tracking\"`. */\n isTracking: boolean;\n /** Begin watching position. */\n start: () => void;\n /** Stop watching, keeping the trajectory. */\n stop: () => void;\n /** Stop and discard the trajectory. */\n clear: () => void;\n}\n\n/**\n * React hook wrapping {@link createPositionTracker}. Records a live GPS\n * trajectory tied to the component lifecycle — the watch is torn down on\n * unmount. Fully browser-side; no external service.\n *\n * @example\n * const { points, distanceKm, isTracking, start, stop } = usePositionTracker({\n * minDistanceKm: 0.01,\n * });\n * return (\n * <>\n * <button onClick={isTracking ? stop : start}>{isTracking ? \"Parar\" : \"Rastrear\"}</button>\n * <TrajectoryMap points={points} />\n * <span>{distanceKm.toFixed(2)} km</span>\n * </>\n * );\n */\nexport function usePositionTracker(\n options: UsePositionTrackerOptions = {},\n): UsePositionTrackerResult {\n const { autoStart = false, onError, ...trackerOptions } = options;\n\n const [points, setPoints] = useState<readonly TrackPoint[]>([]);\n const [distanceKm, setDistanceKm] = useState<number>(0);\n const [status, setStatus] = useState<TrackerStatus>(\"idle\");\n\n const trackerRef = useRef<PositionTracker | null>(null);\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n\n useEffect(() => {\n const tracker = createPositionTracker({\n ...trackerOptions,\n onUpdate: (next) => {\n setPoints([...next]);\n setDistanceKm(tracker.distanceKm);\n },\n onStatusChange: setStatus,\n onError: (error) => onErrorRef.current?.(error),\n });\n trackerRef.current = tracker;\n if (autoStart) tracker.start();\n\n return () => {\n tracker.stop();\n trackerRef.current = null;\n };\n // Tracker options are read once at creation; changing them mid-track\n // would drop the recorded trajectory, so they are intentionally omitted.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const start = useCallback((): void => trackerRef.current?.start(), []);\n const stop = useCallback((): void => trackerRef.current?.stop(), []);\n const clear = useCallback((): void => {\n trackerRef.current?.clear();\n setDistanceKm(0);\n }, []);\n\n return {\n points,\n lastPoint: points.length > 0 ? points[points.length - 1] : null,\n distanceKm,\n status,\n isTracking: status === \"tracking\",\n start,\n stop,\n clear,\n };\n}\n"],"mappings":"wEAqDA,SAAgB,EACZ,EAAqC,CAAC,EACd,CACxB,GAAM,CAAE,YAAY,GAAO,UAAS,GAAG,GAAmB,EAEpD,CAAC,EAAQ,IAAA,EAAA,EAAA,SAAA,CAA6C,CAAC,CAAC,EACxD,CAAC,EAAY,IAAA,EAAA,EAAA,SAAA,CAAkC,CAAC,EAChD,CAAC,EAAQ,IAAA,EAAA,EAAA,SAAA,CAAqC,MAAM,EAEpD,GAAA,EAAA,EAAA,OAAA,CAA4C,IAAI,EAChD,GAAA,EAAA,EAAA,OAAA,CAAoB,CAAO,
|
|
1
|
+
{"version":3,"file":"use-position-tracker.cjs","names":[],"sources":["../../src/geo/use-position-tracker.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n createPositionTracker,\n type CreatePositionTrackerOptions,\n type PositionTracker,\n type TrackerStatus,\n} from \"./create-position-tracker\";\nimport type { TrackPoint } from \"./types\";\n\nexport interface UsePositionTrackerOptions extends Omit<\n CreatePositionTrackerOptions,\n \"onUpdate\" | \"onStatusChange\"\n> {\n /** Start tracking automatically on mount. Default: `false`. */\n autoStart?: boolean;\n}\n\nexport interface UsePositionTrackerResult {\n /** Recorded trajectory (newest last). */\n points: readonly TrackPoint[];\n /** Most recent point, or `null` before the first fix. */\n lastPoint: TrackPoint | null;\n /** Total distance of the trajectory in kilometers. */\n distanceKm: number;\n /** Current tracker status. */\n status: TrackerStatus;\n /** True while `status === \"tracking\"`. */\n isTracking: boolean;\n /** Begin watching position. */\n start: () => void;\n /** Stop watching, keeping the trajectory. */\n stop: () => void;\n /** Stop and discard the trajectory. */\n clear: () => void;\n}\n\n/**\n * React hook wrapping {@link createPositionTracker}. Records a live GPS\n * trajectory tied to the component lifecycle — the watch is torn down on\n * unmount. Fully browser-side; no external service.\n *\n * @example\n * const { points, distanceKm, isTracking, start, stop } = usePositionTracker({\n * minDistanceKm: 0.01,\n * });\n * return (\n * <>\n * <button onClick={isTracking ? stop : start}>{isTracking ? \"Parar\" : \"Rastrear\"}</button>\n * <TrajectoryMap points={points} />\n * <span>{distanceKm.toFixed(2)} km</span>\n * </>\n * );\n */\nexport function usePositionTracker(\n options: UsePositionTrackerOptions = {},\n): UsePositionTrackerResult {\n const { autoStart = false, onError, ...trackerOptions } = options;\n\n const [points, setPoints] = useState<readonly TrackPoint[]>([]);\n const [distanceKm, setDistanceKm] = useState<number>(0);\n const [status, setStatus] = useState<TrackerStatus>(\"idle\");\n\n const trackerRef = useRef<PositionTracker | null>(null);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n useEffect(() => {\n const tracker = createPositionTracker({\n ...trackerOptions,\n onUpdate: (next) => {\n setPoints([...next]);\n setDistanceKm(tracker.distanceKm);\n },\n onStatusChange: setStatus,\n onError: (error) => onErrorRef.current?.(error),\n });\n trackerRef.current = tracker;\n if (autoStart) tracker.start();\n\n return () => {\n tracker.stop();\n trackerRef.current = null;\n };\n // Tracker options are read once at creation; changing them mid-track\n // would drop the recorded trajectory, so they are intentionally omitted.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const start = useCallback((): void => trackerRef.current?.start(), []);\n const stop = useCallback((): void => trackerRef.current?.stop(), []);\n const clear = useCallback((): void => {\n trackerRef.current?.clear();\n setDistanceKm(0);\n }, []);\n\n return {\n points,\n lastPoint: points.length > 0 ? points[points.length - 1] : null,\n distanceKm,\n status,\n isTracking: status === \"tracking\",\n start,\n stop,\n clear,\n };\n}\n"],"mappings":"wEAqDA,SAAgB,EACZ,EAAqC,CAAC,EACd,CACxB,GAAM,CAAE,YAAY,GAAO,UAAS,GAAG,GAAmB,EAEpD,CAAC,EAAQ,IAAA,EAAA,EAAA,SAAA,CAA6C,CAAC,CAAC,EACxD,CAAC,EAAY,IAAA,EAAA,EAAA,SAAA,CAAkC,CAAC,EAChD,CAAC,EAAQ,IAAA,EAAA,EAAA,SAAA,CAAqC,MAAM,EAEpD,GAAA,EAAA,EAAA,OAAA,CAA4C,IAAI,EAChD,GAAA,EAAA,EAAA,OAAA,CAAoB,CAAO,GACjC,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAW,QAAU,CACzB,EAAG,CAAC,CAAO,CAAC,GAEZ,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EAAU,EAAA,sBAAsB,CAClC,GAAG,EACH,SAAW,GAAS,CAChB,EAAU,CAAC,GAAG,CAAI,CAAC,EACnB,EAAc,EAAQ,UAAU,CACpC,EACA,eAAgB,EAChB,QAAU,GAAU,EAAW,UAAU,CAAK,CAClD,CAAC,EAID,MAHA,GAAW,QAAU,EACjB,GAAW,EAAQ,MAAM,MAEhB,CACT,EAAQ,KAAK,EACb,EAAW,QAAU,IACzB,CAIJ,EAAG,CAAC,CAAC,EAEL,IAAM,GAAA,EAAA,EAAA,YAAA,KAAgC,EAAW,SAAS,MAAM,EAAG,CAAC,CAAC,EAC/D,GAAA,EAAA,EAAA,YAAA,KAA+B,EAAW,SAAS,KAAK,EAAG,CAAC,CAAC,EAC7D,GAAA,EAAA,EAAA,YAAA,KAAgC,CAClC,EAAW,SAAS,MAAM,EAC1B,EAAc,CAAC,CACnB,EAAG,CAAC,CAAC,EAEL,MAAO,CACH,SACA,UAAW,EAAO,OAAS,EAAI,EAAO,EAAO,OAAS,GAAK,KAC3D,aACA,SACA,WAAY,IAAW,WACvB,QACA,OACA,OACJ,CACJ"}
|
|
@@ -3,7 +3,9 @@ import { useCallback as t, useEffect as n, useRef as r, useState as i } from "re
|
|
|
3
3
|
//#region src/geo/use-position-tracker.ts
|
|
4
4
|
function a(a = {}) {
|
|
5
5
|
let { autoStart: o = !1, onError: s, ...c } = a, [l, u] = i([]), [d, f] = i(0), [p, m] = i("idle"), h = r(null), g = r(s);
|
|
6
|
-
|
|
6
|
+
n(() => {
|
|
7
|
+
g.current = s;
|
|
8
|
+
}, [s]), n(() => {
|
|
7
9
|
let t = e({
|
|
8
10
|
...c,
|
|
9
11
|
onUpdate: (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-position-tracker.js","names":[],"sources":["../../src/geo/use-position-tracker.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n createPositionTracker,\n type CreatePositionTrackerOptions,\n type PositionTracker,\n type TrackerStatus,\n} from \"./create-position-tracker\";\nimport type { TrackPoint } from \"./types\";\n\nexport interface UsePositionTrackerOptions extends Omit<\n CreatePositionTrackerOptions,\n \"onUpdate\" | \"onStatusChange\"\n> {\n /** Start tracking automatically on mount. Default: `false`. */\n autoStart?: boolean;\n}\n\nexport interface UsePositionTrackerResult {\n /** Recorded trajectory (newest last). */\n points: readonly TrackPoint[];\n /** Most recent point, or `null` before the first fix. */\n lastPoint: TrackPoint | null;\n /** Total distance of the trajectory in kilometers. */\n distanceKm: number;\n /** Current tracker status. */\n status: TrackerStatus;\n /** True while `status === \"tracking\"`. */\n isTracking: boolean;\n /** Begin watching position. */\n start: () => void;\n /** Stop watching, keeping the trajectory. */\n stop: () => void;\n /** Stop and discard the trajectory. */\n clear: () => void;\n}\n\n/**\n * React hook wrapping {@link createPositionTracker}. Records a live GPS\n * trajectory tied to the component lifecycle — the watch is torn down on\n * unmount. Fully browser-side; no external service.\n *\n * @example\n * const { points, distanceKm, isTracking, start, stop } = usePositionTracker({\n * minDistanceKm: 0.01,\n * });\n * return (\n * <>\n * <button onClick={isTracking ? stop : start}>{isTracking ? \"Parar\" : \"Rastrear\"}</button>\n * <TrajectoryMap points={points} />\n * <span>{distanceKm.toFixed(2)} km</span>\n * </>\n * );\n */\nexport function usePositionTracker(\n options: UsePositionTrackerOptions = {},\n): UsePositionTrackerResult {\n const { autoStart = false, onError, ...trackerOptions } = options;\n\n const [points, setPoints] = useState<readonly TrackPoint[]>([]);\n const [distanceKm, setDistanceKm] = useState<number>(0);\n const [status, setStatus] = useState<TrackerStatus>(\"idle\");\n\n const trackerRef = useRef<PositionTracker | null>(null);\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n\n useEffect(() => {\n const tracker = createPositionTracker({\n ...trackerOptions,\n onUpdate: (next) => {\n setPoints([...next]);\n setDistanceKm(tracker.distanceKm);\n },\n onStatusChange: setStatus,\n onError: (error) => onErrorRef.current?.(error),\n });\n trackerRef.current = tracker;\n if (autoStart) tracker.start();\n\n return () => {\n tracker.stop();\n trackerRef.current = null;\n };\n // Tracker options are read once at creation; changing them mid-track\n // would drop the recorded trajectory, so they are intentionally omitted.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const start = useCallback((): void => trackerRef.current?.start(), []);\n const stop = useCallback((): void => trackerRef.current?.stop(), []);\n const clear = useCallback((): void => {\n trackerRef.current?.clear();\n setDistanceKm(0);\n }, []);\n\n return {\n points,\n lastPoint: points.length > 0 ? points[points.length - 1] : null,\n distanceKm,\n status,\n isTracking: status === \"tracking\",\n start,\n stop,\n clear,\n };\n}\n"],"mappings":";;;AAqDA,SAAgB,EACZ,IAAqC,CAAC,GACd;CACxB,IAAM,EAAE,eAAY,IAAO,YAAS,GAAG,MAAmB,GAEpD,CAAC,GAAQ,KAAa,EAAgC,CAAC,CAAC,GACxD,CAAC,GAAY,KAAiB,EAAiB,CAAC,GAChD,CAAC,GAAQ,KAAa,EAAwB,MAAM,GAEpD,IAAa,EAA+B,IAAI,GAChD,IAAa,EAAO,CAAO;
|
|
1
|
+
{"version":3,"file":"use-position-tracker.js","names":[],"sources":["../../src/geo/use-position-tracker.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n createPositionTracker,\n type CreatePositionTrackerOptions,\n type PositionTracker,\n type TrackerStatus,\n} from \"./create-position-tracker\";\nimport type { TrackPoint } from \"./types\";\n\nexport interface UsePositionTrackerOptions extends Omit<\n CreatePositionTrackerOptions,\n \"onUpdate\" | \"onStatusChange\"\n> {\n /** Start tracking automatically on mount. Default: `false`. */\n autoStart?: boolean;\n}\n\nexport interface UsePositionTrackerResult {\n /** Recorded trajectory (newest last). */\n points: readonly TrackPoint[];\n /** Most recent point, or `null` before the first fix. */\n lastPoint: TrackPoint | null;\n /** Total distance of the trajectory in kilometers. */\n distanceKm: number;\n /** Current tracker status. */\n status: TrackerStatus;\n /** True while `status === \"tracking\"`. */\n isTracking: boolean;\n /** Begin watching position. */\n start: () => void;\n /** Stop watching, keeping the trajectory. */\n stop: () => void;\n /** Stop and discard the trajectory. */\n clear: () => void;\n}\n\n/**\n * React hook wrapping {@link createPositionTracker}. Records a live GPS\n * trajectory tied to the component lifecycle — the watch is torn down on\n * unmount. Fully browser-side; no external service.\n *\n * @example\n * const { points, distanceKm, isTracking, start, stop } = usePositionTracker({\n * minDistanceKm: 0.01,\n * });\n * return (\n * <>\n * <button onClick={isTracking ? stop : start}>{isTracking ? \"Parar\" : \"Rastrear\"}</button>\n * <TrajectoryMap points={points} />\n * <span>{distanceKm.toFixed(2)} km</span>\n * </>\n * );\n */\nexport function usePositionTracker(\n options: UsePositionTrackerOptions = {},\n): UsePositionTrackerResult {\n const { autoStart = false, onError, ...trackerOptions } = options;\n\n const [points, setPoints] = useState<readonly TrackPoint[]>([]);\n const [distanceKm, setDistanceKm] = useState<number>(0);\n const [status, setStatus] = useState<TrackerStatus>(\"idle\");\n\n const trackerRef = useRef<PositionTracker | null>(null);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n useEffect(() => {\n const tracker = createPositionTracker({\n ...trackerOptions,\n onUpdate: (next) => {\n setPoints([...next]);\n setDistanceKm(tracker.distanceKm);\n },\n onStatusChange: setStatus,\n onError: (error) => onErrorRef.current?.(error),\n });\n trackerRef.current = tracker;\n if (autoStart) tracker.start();\n\n return () => {\n tracker.stop();\n trackerRef.current = null;\n };\n // Tracker options are read once at creation; changing them mid-track\n // would drop the recorded trajectory, so they are intentionally omitted.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const start = useCallback((): void => trackerRef.current?.start(), []);\n const stop = useCallback((): void => trackerRef.current?.stop(), []);\n const clear = useCallback((): void => {\n trackerRef.current?.clear();\n setDistanceKm(0);\n }, []);\n\n return {\n points,\n lastPoint: points.length > 0 ? points[points.length - 1] : null,\n distanceKm,\n status,\n isTracking: status === \"tracking\",\n start,\n stop,\n clear,\n };\n}\n"],"mappings":";;;AAqDA,SAAgB,EACZ,IAAqC,CAAC,GACd;CACxB,IAAM,EAAE,eAAY,IAAO,YAAS,GAAG,MAAmB,GAEpD,CAAC,GAAQ,KAAa,EAAgC,CAAC,CAAC,GACxD,CAAC,GAAY,KAAiB,EAAiB,CAAC,GAChD,CAAC,GAAQ,KAAa,EAAwB,MAAM,GAEpD,IAAa,EAA+B,IAAI,GAChD,IAAa,EAAO,CAAO;CAKjC,AAJA,QAAgB;EACZ,EAAW,UAAU;CACzB,GAAG,CAAC,CAAO,CAAC,GAEZ,QAAgB;EACZ,IAAM,IAAU,EAAsB;GAClC,GAAG;GACH,WAAW,MAAS;IAEhB,AADA,EAAU,CAAC,GAAG,CAAI,CAAC,GACnB,EAAc,EAAQ,UAAU;GACpC;GACA,gBAAgB;GAChB,UAAU,MAAU,EAAW,UAAU,CAAK;EAClD,CAAC;EAID,OAHA,EAAW,UAAU,GACjB,KAAW,EAAQ,MAAM,SAEhB;GAET,AADA,EAAQ,KAAK,GACb,EAAW,UAAU;EACzB;CAIJ,GAAG,CAAC,CAAC;CAEL,IAAM,IAAQ,QAAwB,EAAW,SAAS,MAAM,GAAG,CAAC,CAAC,GAC/D,IAAO,QAAwB,EAAW,SAAS,KAAK,GAAG,CAAC,CAAC,GAC7D,IAAQ,QAAwB;EAElC,AADA,EAAW,SAAS,MAAM,GAC1B,EAAc,CAAC;CACnB,GAAG,CAAC,CAAC;CAEL,OAAO;EACH;EACA,WAAW,EAAO,SAAS,IAAI,EAAO,EAAO,SAAS,KAAK;EAC3D;EACA;EACA,YAAY,MAAW;EACvB;EACA;EACA;CACJ;AACJ"}
|
package/dist/hooks/use-async.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("react");function t(t,n=[],r={}){let{immediate:i=!1}=r,[a,o]=(0,e.useState)({status:`idle`,data:void 0,error:void 0}),s=(0,e.useRef)(t);s.current=t;let c=(0,e.useRef)(0),l=(0,e.useRef)(!0);(0,e.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);let u=(0,e.useCallback)(async()=>{let e=++c.current;o(e=>({...e,status:`pending`,error:void 0}));try{let t=await s.current();return l.current&&c.current===e&&o({status:`success`,data:t,error:void 0}),t}catch(t){throw l.current&&c.current===e&&o({status:`error`,data:void 0,error:t}),t}},[]),d=(0,e.useCallback)(()=>{c.current++,o({status:`idle`,data:void 0,error:void 0})},[]);return(0,e.useEffect)(()=>{i&&u().catch(()=>{})},[i,...n]),{status:a.status,data:a.data,error:a.error,isPending:a.status===`pending`,isSuccess:a.status===`success`,isError:a.status===`error`,run:u,reset:d}}exports.useAsync=t;
|
|
1
|
+
let e=require("react");function t(t,n=[],r={}){let{immediate:i=!1}=r,[a,o]=(0,e.useState)({status:`idle`,data:void 0,error:void 0}),s=(0,e.useRef)(t);(0,e.useEffect)(()=>{s.current=t},[t]);let c=(0,e.useRef)(0),l=(0,e.useRef)(!0);(0,e.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);let u=(0,e.useCallback)(async()=>{let e=++c.current;o(e=>({...e,status:`pending`,error:void 0}));try{let t=await s.current();return l.current&&c.current===e&&o({status:`success`,data:t,error:void 0}),t}catch(t){throw l.current&&c.current===e&&o({status:`error`,data:void 0,error:t}),t}},[]),d=(0,e.useCallback)(()=>{c.current++,o({status:`idle`,data:void 0,error:void 0})},[]);return(0,e.useEffect)(()=>{i&&u().catch(()=>{})},[i,...n]),{status:a.status,data:a.data,error:a.error,isPending:a.status===`pending`,isSuccess:a.status===`success`,isError:a.status===`error`,run:u,reset:d}}exports.useAsync=t;
|
|
2
2
|
//# sourceMappingURL=use-async.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-async.cjs","names":[],"sources":["../../src/hooks/use-async.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type AsyncStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport interface UseAsyncResult<T> {\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n isPending: boolean;\n isSuccess: boolean;\n isError: boolean;\n /** Trigger the async function. Resolves with the new data or rejects. */\n run: () => Promise<T>;\n /** Reset state back to idle. */\n reset: () => void;\n}\n\n/**\n * Run an async function and track its `idle/pending/success/error` state.\n *\n * - Discards results from stale runs (race-condition safe).\n * - `immediate` (default `false`) triggers the function on mount and when\n * `deps` change. With `false`, call `run()` manually.\n * - Returns a stable object so callers can destructure or pass around safely.\n *\n * For server data with caching, prefer React Query — `useAsync` is the\n * minimal one-shot primitive without dependencies.\n */\nexport function useAsync<T>(\n asyncFn: () => Promise<T>,\n deps: ReadonlyArray<unknown> = [],\n options: { immediate?: boolean } = {},\n): UseAsyncResult<T> {\n const { immediate = false } = options;\n const [state, setState] = useState<{\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n }>({ status: \"idle\", data: undefined, error: undefined });\n\n const fnRef = useRef(asyncFn);\n fnRef.current = asyncFn;\n const callIdRef = useRef<number>(0);\n const mountedRef = useRef<boolean>(true);\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n const run = useCallback(async (): Promise<T> => {\n const callId = ++callIdRef.current;\n setState((current) => ({ ...current, status: \"pending\", error: undefined }));\n try {\n const data = await fnRef.current();\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"success\", data, error: undefined });\n }\n return data;\n } catch (error) {\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"error\", data: undefined, error });\n }\n throw error;\n }\n }, []);\n\n const reset = useCallback((): void => {\n callIdRef.current++;\n setState({ status: \"idle\", data: undefined, error: undefined });\n }, []);\n\n useEffect(() => {\n if (!immediate) return;\n run().catch(() => {\n /* error already captured in state */\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [immediate, ...deps]);\n\n return {\n status: state.status,\n data: state.data,\n error: state.error,\n isPending: state.status === \"pending\",\n isSuccess: state.status === \"success\",\n isError: state.status === \"error\",\n run,\n reset,\n };\n}\n"],"mappings":"uBA4BA,SAAgB,EACZ,EACA,EAA+B,CAAC,EAChC,EAAmC,CAAC,EACnB,CACjB,GAAM,CAAE,YAAY,IAAU,EACxB,CAAC,EAAO,IAAA,EAAA,EAAA,SAAA,CAIX,CAAE,OAAQ,OAAQ,KAAM,IAAA,GAAW,MAAO,IAAA,EAAU,CAAC,EAElD,GAAA,EAAA,EAAA,OAAA,CAAe,CAAO,
|
|
1
|
+
{"version":3,"file":"use-async.cjs","names":[],"sources":["../../src/hooks/use-async.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type AsyncStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport interface UseAsyncResult<T> {\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n isPending: boolean;\n isSuccess: boolean;\n isError: boolean;\n /** Trigger the async function. Resolves with the new data or rejects. */\n run: () => Promise<T>;\n /** Reset state back to idle. */\n reset: () => void;\n}\n\n/**\n * Run an async function and track its `idle/pending/success/error` state.\n *\n * - Discards results from stale runs (race-condition safe).\n * - `immediate` (default `false`) triggers the function on mount and when\n * `deps` change. With `false`, call `run()` manually.\n * - Returns a stable object so callers can destructure or pass around safely.\n *\n * For server data with caching, prefer React Query — `useAsync` is the\n * minimal one-shot primitive without dependencies.\n */\nexport function useAsync<T>(\n asyncFn: () => Promise<T>,\n deps: ReadonlyArray<unknown> = [],\n options: { immediate?: boolean } = {},\n): UseAsyncResult<T> {\n const { immediate = false } = options;\n const [state, setState] = useState<{\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n }>({ status: \"idle\", data: undefined, error: undefined });\n\n const fnRef = useRef(asyncFn);\n useEffect(() => {\n fnRef.current = asyncFn;\n }, [asyncFn]);\n const callIdRef = useRef<number>(0);\n const mountedRef = useRef<boolean>(true);\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n const run = useCallback(async (): Promise<T> => {\n const callId = ++callIdRef.current;\n setState((current) => ({ ...current, status: \"pending\", error: undefined }));\n try {\n const data = await fnRef.current();\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"success\", data, error: undefined });\n }\n return data;\n } catch (error) {\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"error\", data: undefined, error });\n }\n throw error;\n }\n }, []);\n\n const reset = useCallback((): void => {\n callIdRef.current++;\n setState({ status: \"idle\", data: undefined, error: undefined });\n }, []);\n\n useEffect(() => {\n if (!immediate) return;\n run().catch(() => {\n /* error already captured in state */\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [immediate, ...deps]);\n\n return {\n status: state.status,\n data: state.data,\n error: state.error,\n isPending: state.status === \"pending\",\n isSuccess: state.status === \"success\",\n isError: state.status === \"error\",\n run,\n reset,\n };\n}\n"],"mappings":"uBA4BA,SAAgB,EACZ,EACA,EAA+B,CAAC,EAChC,EAAmC,CAAC,EACnB,CACjB,GAAM,CAAE,YAAY,IAAU,EACxB,CAAC,EAAO,IAAA,EAAA,EAAA,SAAA,CAIX,CAAE,OAAQ,OAAQ,KAAM,IAAA,GAAW,MAAO,IAAA,EAAU,CAAC,EAElD,GAAA,EAAA,EAAA,OAAA,CAAe,CAAO,GAC5B,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAM,QAAU,CACpB,EAAG,CAAC,CAAO,CAAC,EACZ,IAAM,GAAA,EAAA,EAAA,OAAA,CAA2B,CAAC,EAC5B,GAAA,EAAA,EAAA,OAAA,CAA6B,EAAI,GAEvC,EAAA,EAAA,UAAA,MACI,EAAW,QAAU,OACR,CACT,EAAW,QAAU,EACzB,GACD,CAAC,CAAC,EAEL,IAAM,GAAA,EAAA,EAAA,YAAA,CAAkB,SAAwB,CAC5C,IAAM,EAAS,EAAE,EAAU,QAC3B,EAAU,IAAa,CAAE,GAAG,EAAS,OAAQ,UAAW,MAAO,IAAA,EAAU,EAAE,EAC3E,GAAI,CACA,IAAM,EAAO,MAAM,EAAM,QAAQ,EAIjC,OAHI,EAAW,SAAW,EAAU,UAAY,GAC5C,EAAS,CAAE,OAAQ,UAAW,OAAM,MAAO,IAAA,EAAU,CAAC,EAEnD,CACX,OAAS,EAAO,CAIZ,MAHI,EAAW,SAAW,EAAU,UAAY,GAC5C,EAAS,CAAE,OAAQ,QAAS,KAAM,IAAA,GAAW,OAAM,CAAC,EAElD,CACV,CACJ,EAAG,CAAC,CAAC,EAEC,GAAA,EAAA,EAAA,YAAA,KAAgC,CAClC,EAAU,UACV,EAAS,CAAE,OAAQ,OAAQ,KAAM,IAAA,GAAW,MAAO,IAAA,EAAU,CAAC,CAClE,EAAG,CAAC,CAAC,EAUL,OARA,EAAA,EAAA,UAAA,KAAgB,CACP,GACL,EAAI,CAAC,CAAC,UAAY,CAElB,CAAC,CAEL,EAAG,CAAC,EAAW,GAAG,CAAI,CAAC,EAEhB,CACH,OAAQ,EAAM,OACd,KAAM,EAAM,KACZ,MAAO,EAAM,MACb,UAAW,EAAM,SAAW,UAC5B,UAAW,EAAM,SAAW,UAC5B,QAAS,EAAM,SAAW,QAC1B,MACA,OACJ,CACJ"}
|
package/dist/hooks/use-async.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-async.js","names":[],"sources":["../../src/hooks/use-async.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type AsyncStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport interface UseAsyncResult<T> {\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n isPending: boolean;\n isSuccess: boolean;\n isError: boolean;\n /** Trigger the async function. Resolves with the new data or rejects. */\n run: () => Promise<T>;\n /** Reset state back to idle. */\n reset: () => void;\n}\n\n/**\n * Run an async function and track its `idle/pending/success/error` state.\n *\n * - Discards results from stale runs (race-condition safe).\n * - `immediate` (default `false`) triggers the function on mount and when\n * `deps` change. With `false`, call `run()` manually.\n * - Returns a stable object so callers can destructure or pass around safely.\n *\n * For server data with caching, prefer React Query — `useAsync` is the\n * minimal one-shot primitive without dependencies.\n */\nexport function useAsync<T>(\n asyncFn: () => Promise<T>,\n deps: ReadonlyArray<unknown> = [],\n options: { immediate?: boolean } = {},\n): UseAsyncResult<T> {\n const { immediate = false } = options;\n const [state, setState] = useState<{\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n }>({ status: \"idle\", data: undefined, error: undefined });\n\n const fnRef = useRef(asyncFn);\n fnRef.current = asyncFn;\n const callIdRef = useRef<number>(0);\n const mountedRef = useRef<boolean>(true);\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n const run = useCallback(async (): Promise<T> => {\n const callId = ++callIdRef.current;\n setState((current) => ({ ...current, status: \"pending\", error: undefined }));\n try {\n const data = await fnRef.current();\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"success\", data, error: undefined });\n }\n return data;\n } catch (error) {\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"error\", data: undefined, error });\n }\n throw error;\n }\n }, []);\n\n const reset = useCallback((): void => {\n callIdRef.current++;\n setState({ status: \"idle\", data: undefined, error: undefined });\n }, []);\n\n useEffect(() => {\n if (!immediate) return;\n run().catch(() => {\n /* error already captured in state */\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [immediate, ...deps]);\n\n return {\n status: state.status,\n data: state.data,\n error: state.error,\n isPending: state.status === \"pending\",\n isSuccess: state.status === \"success\",\n isError: state.status === \"error\",\n run,\n reset,\n };\n}\n"],"mappings":";;AA4BA,SAAgB,EACZ,GACA,IAA+B,CAAC,GAChC,IAAmC,CAAC,GACnB;CACjB,IAAM,EAAE,eAAY,OAAU,GACxB,CAAC,GAAO,KAAY,EAIvB;EAAE,QAAQ;EAAQ,MAAM,KAAA;EAAW,OAAO,KAAA;CAAU,CAAC,GAElD,IAAQ,EAAO,CAAO;CAC5B,EAAM,UAAU;
|
|
1
|
+
{"version":3,"file":"use-async.js","names":[],"sources":["../../src/hooks/use-async.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type AsyncStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport interface UseAsyncResult<T> {\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n isPending: boolean;\n isSuccess: boolean;\n isError: boolean;\n /** Trigger the async function. Resolves with the new data or rejects. */\n run: () => Promise<T>;\n /** Reset state back to idle. */\n reset: () => void;\n}\n\n/**\n * Run an async function and track its `idle/pending/success/error` state.\n *\n * - Discards results from stale runs (race-condition safe).\n * - `immediate` (default `false`) triggers the function on mount and when\n * `deps` change. With `false`, call `run()` manually.\n * - Returns a stable object so callers can destructure or pass around safely.\n *\n * For server data with caching, prefer React Query — `useAsync` is the\n * minimal one-shot primitive without dependencies.\n */\nexport function useAsync<T>(\n asyncFn: () => Promise<T>,\n deps: ReadonlyArray<unknown> = [],\n options: { immediate?: boolean } = {},\n): UseAsyncResult<T> {\n const { immediate = false } = options;\n const [state, setState] = useState<{\n status: AsyncStatus;\n data: T | undefined;\n error: unknown;\n }>({ status: \"idle\", data: undefined, error: undefined });\n\n const fnRef = useRef(asyncFn);\n useEffect(() => {\n fnRef.current = asyncFn;\n }, [asyncFn]);\n const callIdRef = useRef<number>(0);\n const mountedRef = useRef<boolean>(true);\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n const run = useCallback(async (): Promise<T> => {\n const callId = ++callIdRef.current;\n setState((current) => ({ ...current, status: \"pending\", error: undefined }));\n try {\n const data = await fnRef.current();\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"success\", data, error: undefined });\n }\n return data;\n } catch (error) {\n if (mountedRef.current && callIdRef.current === callId) {\n setState({ status: \"error\", data: undefined, error });\n }\n throw error;\n }\n }, []);\n\n const reset = useCallback((): void => {\n callIdRef.current++;\n setState({ status: \"idle\", data: undefined, error: undefined });\n }, []);\n\n useEffect(() => {\n if (!immediate) return;\n run().catch(() => {\n /* error already captured in state */\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [immediate, ...deps]);\n\n return {\n status: state.status,\n data: state.data,\n error: state.error,\n isPending: state.status === \"pending\",\n isSuccess: state.status === \"success\",\n isError: state.status === \"error\",\n run,\n reset,\n };\n}\n"],"mappings":";;AA4BA,SAAgB,EACZ,GACA,IAA+B,CAAC,GAChC,IAAmC,CAAC,GACnB;CACjB,IAAM,EAAE,eAAY,OAAU,GACxB,CAAC,GAAO,KAAY,EAIvB;EAAE,QAAQ;EAAQ,MAAM,KAAA;EAAW,OAAO,KAAA;CAAU,CAAC,GAElD,IAAQ,EAAO,CAAO;CAC5B,QAAgB;EACZ,EAAM,UAAU;CACpB,GAAG,CAAC,CAAO,CAAC;CACZ,IAAM,IAAY,EAAe,CAAC,GAC5B,IAAa,EAAgB,EAAI;CAEvC,SACI,EAAW,UAAU,UACR;EACT,EAAW,UAAU;CACzB,IACD,CAAC,CAAC;CAEL,IAAM,IAAM,EAAY,YAAwB;EAC5C,IAAM,IAAS,EAAE,EAAU;EAC3B,GAAU,OAAa;GAAE,GAAG;GAAS,QAAQ;GAAW,OAAO,KAAA;EAAU,EAAE;EAC3E,IAAI;GACA,IAAM,IAAO,MAAM,EAAM,QAAQ;GAIjC,OAHI,EAAW,WAAW,EAAU,YAAY,KAC5C,EAAS;IAAE,QAAQ;IAAW;IAAM,OAAO,KAAA;GAAU,CAAC,GAEnD;EACX,SAAS,GAAO;GAIZ,MAHI,EAAW,WAAW,EAAU,YAAY,KAC5C,EAAS;IAAE,QAAQ;IAAS,MAAM,KAAA;IAAW;GAAM,CAAC,GAElD;EACV;CACJ,GAAG,CAAC,CAAC,GAEC,IAAQ,QAAwB;EAElC,AADA,EAAU,WACV,EAAS;GAAE,QAAQ;GAAQ,MAAM,KAAA;GAAW,OAAO,KAAA;EAAU,CAAC;CAClE,GAAG,CAAC,CAAC;CAUL,OARA,QAAgB;EACP,KACL,EAAI,CAAC,CAAC,YAAY,CAElB,CAAC;CAEL,GAAG,CAAC,GAAW,GAAG,CAAI,CAAC,GAEhB;EACH,QAAQ,EAAM;EACd,MAAM,EAAM;EACZ,OAAO,EAAM;EACb,WAAW,EAAM,WAAW;EAC5B,WAAW,EAAM,WAAW;EAC5B,SAAS,EAAM,WAAW;EAC1B;EACA;CACJ;AACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("react");function t(t){let n=(0,e.useRef)(null),r=(0,e.useRef)(t);return
|
|
1
|
+
let e=require("react");function t(t){let n=(0,e.useRef)(null),r=(0,e.useRef)(t);return(0,e.useEffect)(()=>{r.current=t},[t]),(0,e.useEffect)(()=>{if(typeof document>`u`)return;let e=e=>{let t=e.target;!n.current||t&&n.current.contains(t)||r.current()};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[]),n}exports.useClickOutside=t;
|
|
2
2
|
//# sourceMappingURL=use-click-outside.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-click-outside.cjs","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const listener = (event: MouseEvent | TouchEvent): void => {\n const target = event.target as Node | null;\n if (!ref.current || (target && ref.current.contains(target))) return;\n handlerRef.current();\n };\n\n document.addEventListener(\"mousedown\", listener);\n document.addEventListener(\"touchstart\", listener);\n return () => {\n document.removeEventListener(\"mousedown\", listener);\n document.removeEventListener(\"touchstart\", listener);\n };\n }, []);\n\n return ref;\n}\n"],"mappings":"uBAWA,SAAgB,EACZ,EACmB,CACnB,IAAM,GAAA,EAAA,EAAA,OAAA,CAAgB,IAAI,EACpB,GAAA,EAAA,EAAA,OAAA,CAAoB,CAAO,
|
|
1
|
+
{"version":3,"file":"use-click-outside.cjs","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef = useRef(handler);\n useEffect(() => {\n handlerRef.current = handler;\n }, [handler]);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const listener = (event: MouseEvent | TouchEvent): void => {\n const target = event.target as Node | null;\n if (!ref.current || (target && ref.current.contains(target))) return;\n handlerRef.current();\n };\n\n document.addEventListener(\"mousedown\", listener);\n document.addEventListener(\"touchstart\", listener);\n return () => {\n document.removeEventListener(\"mousedown\", listener);\n document.removeEventListener(\"touchstart\", listener);\n };\n }, []);\n\n return ref;\n}\n"],"mappings":"uBAWA,SAAgB,EACZ,EACmB,CACnB,IAAM,GAAA,EAAA,EAAA,OAAA,CAAgB,IAAI,EACpB,GAAA,EAAA,EAAA,OAAA,CAAoB,CAAO,EAsBjC,OArBA,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAW,QAAU,CACzB,EAAG,CAAC,CAAO,CAAC,GAEZ,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,OAAO,SAAa,IAAa,OAErC,IAAM,EAAY,GAAyC,CACvD,IAAM,EAAS,EAAM,OACjB,CAAC,EAAI,SAAY,GAAU,EAAI,QAAQ,SAAS,CAAM,GAC1D,EAAW,QAAQ,CACvB,EAIA,OAFA,SAAS,iBAAiB,YAAa,CAAQ,EAC/C,SAAS,iBAAiB,aAAc,CAAQ,MACnC,CACT,SAAS,oBAAoB,YAAa,CAAQ,EAClD,SAAS,oBAAoB,aAAc,CAAQ,CACvD,CACJ,EAAG,CAAC,CAAC,EAEE,CACX"}
|
|
@@ -2,7 +2,9 @@ import { useEffect as e, useRef as t } from "react";
|
|
|
2
2
|
//#region src/hooks/use-click-outside.ts
|
|
3
3
|
function n(n) {
|
|
4
4
|
let r = t(null), i = t(n);
|
|
5
|
-
return
|
|
5
|
+
return e(() => {
|
|
6
|
+
i.current = n;
|
|
7
|
+
}, [n]), e(() => {
|
|
6
8
|
if (typeof document > "u") return;
|
|
7
9
|
let e = (e) => {
|
|
8
10
|
let t = e.target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-click-outside.js","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const listener = (event: MouseEvent | TouchEvent): void => {\n const target = event.target as Node | null;\n if (!ref.current || (target && ref.current.contains(target))) return;\n handlerRef.current();\n };\n\n document.addEventListener(\"mousedown\", listener);\n document.addEventListener(\"touchstart\", listener);\n return () => {\n document.removeEventListener(\"mousedown\", listener);\n document.removeEventListener(\"touchstart\", listener);\n };\n }, []);\n\n return ref;\n}\n"],"mappings":";;AAWA,SAAgB,EACZ,GACmB;CACnB,IAAM,IAAM,EAAU,IAAI,GACpB,IAAa,EAAO,CAAO;
|
|
1
|
+
{"version":3,"file":"use-click-outside.js","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef = useRef(handler);\n useEffect(() => {\n handlerRef.current = handler;\n }, [handler]);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const listener = (event: MouseEvent | TouchEvent): void => {\n const target = event.target as Node | null;\n if (!ref.current || (target && ref.current.contains(target))) return;\n handlerRef.current();\n };\n\n document.addEventListener(\"mousedown\", listener);\n document.addEventListener(\"touchstart\", listener);\n return () => {\n document.removeEventListener(\"mousedown\", listener);\n document.removeEventListener(\"touchstart\", listener);\n };\n }, []);\n\n return ref;\n}\n"],"mappings":";;AAWA,SAAgB,EACZ,GACmB;CACnB,IAAM,IAAM,EAAU,IAAI,GACpB,IAAa,EAAO,CAAO;CAsBjC,OArBA,QAAgB;EACZ,EAAW,UAAU;CACzB,GAAG,CAAC,CAAO,CAAC,GAEZ,QAAgB;EACZ,IAAI,OAAO,WAAa,KAAa;EAErC,IAAM,KAAY,MAAyC;GACvD,IAAM,IAAS,EAAM;GACjB,CAAC,EAAI,WAAY,KAAU,EAAI,QAAQ,SAAS,CAAM,KAC1D,EAAW,QAAQ;EACvB;EAIA,OAFA,SAAS,iBAAiB,aAAa,CAAQ,GAC/C,SAAS,iBAAiB,cAAc,CAAQ,SACnC;GAET,AADA,SAAS,oBAAoB,aAAa,CAAQ,GAClD,SAAS,oBAAoB,cAAc,CAAQ;EACvD;CACJ,GAAG,CAAC,CAAC,GAEE;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-deep-memo.cjs","names":[],"sources":["../../src/hooks/use-deep-memo.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-deep-memo.cjs","names":[],"sources":["../../src/hooks/use-deep-memo.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- the structural cache is read and written during render by design (see the docstring) */\nimport { useRef } from \"react\";\n\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n return a.every((value, index) => deepEqual(value, b[index]));\n }\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n if (aKeys.length !== bKeys.length) return false;\n return aKeys.every((key) =>\n deepEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]),\n );\n}\n\n/**\n * Memoize a value with a structural equality check. Use when an object/array\n * created during render is fed to `useEffect` dependencies and you want to\n * avoid spurious effect runs when only the reference changes.\n *\n * The cache is a ref read and written during render. That is flagged by the React\n * Compiler rules and is nonetheless correct here: the write is idempotent — a\n * discarded render either wrote a structurally equal value or nothing at all — so\n * replaying the render cannot change the result.\n */\nexport function useDeepMemo<T>(value: T): T {\n const ref = useRef<T>(value);\n if (!deepEqual(ref.current, value)) {\n ref.current = value;\n }\n return ref.current;\n}\n"],"mappings":"uBAGA,SAAS,EAAU,EAAY,EAAqB,CAChD,GAAI,OAAO,GAAG,EAAG,CAAC,EAAG,MAAO,GAE5B,GADI,OAAO,GAAM,UAAY,OAAO,GAAM,UAAY,IAAM,MAAQ,IAAM,MACtE,MAAM,QAAQ,CAAC,IAAM,MAAM,QAAQ,CAAC,EAAG,MAAO,GAClD,GAAI,MAAM,QAAQ,CAAC,GAAK,MAAM,QAAQ,CAAC,EAEnC,OADI,EAAE,SAAW,EAAE,QACZ,EAAE,OAAO,EAAO,IAAU,EAAU,EAAO,EAAE,EAAM,CAAC,EAE/D,IAAM,EAAQ,OAAO,KAAK,CAAW,EAC/B,EAAQ,OAAO,KAAK,CAAW,EAErC,OADI,EAAM,SAAW,EAAM,QACpB,EAAM,MAAO,GAChB,EAAW,EAA8B,GAAO,EAA8B,EAAI,CACtF,CACJ,CAYA,SAAgB,EAAe,EAAa,CACxC,IAAM,GAAA,EAAA,EAAA,OAAA,CAAgB,CAAK,EAI3B,OAHK,EAAU,EAAI,QAAS,CAAK,IAC7B,EAAI,QAAU,GAEX,EAAI,OACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-deep-memo.js","names":[],"sources":["../../src/hooks/use-deep-memo.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-deep-memo.js","names":[],"sources":["../../src/hooks/use-deep-memo.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- the structural cache is read and written during render by design (see the docstring) */\nimport { useRef } from \"react\";\n\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n return a.every((value, index) => deepEqual(value, b[index]));\n }\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n if (aKeys.length !== bKeys.length) return false;\n return aKeys.every((key) =>\n deepEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]),\n );\n}\n\n/**\n * Memoize a value with a structural equality check. Use when an object/array\n * created during render is fed to `useEffect` dependencies and you want to\n * avoid spurious effect runs when only the reference changes.\n *\n * The cache is a ref read and written during render. That is flagged by the React\n * Compiler rules and is nonetheless correct here: the write is idempotent — a\n * discarded render either wrote a structurally equal value or nothing at all — so\n * replaying the render cannot change the result.\n */\nexport function useDeepMemo<T>(value: T): T {\n const ref = useRef<T>(value);\n if (!deepEqual(ref.current, value)) {\n ref.current = value;\n }\n return ref.current;\n}\n"],"mappings":";;AAGA,SAAS,EAAU,GAAY,GAAqB;CAChD,IAAI,OAAO,GAAG,GAAG,CAAC,GAAG,OAAO;CAE5B,IADI,OAAO,KAAM,YAAY,OAAO,KAAM,YAAY,MAAM,QAAQ,MAAM,QACtE,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,IAAI,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAEnC,OADI,EAAE,WAAW,EAAE,UACZ,EAAE,OAAO,GAAO,MAAU,EAAU,GAAO,EAAE,EAAM,CAAC;CAE/D,IAAM,IAAQ,OAAO,KAAK,CAAW,GAC/B,IAAQ,OAAO,KAAK,CAAW;CAErC,OADI,EAAM,WAAW,EAAM,UACpB,EAAM,OAAO,MAChB,EAAW,EAA8B,IAAO,EAA8B,EAAI,CACtF;AACJ;AAYA,SAAgB,EAAe,GAAa;CACxC,IAAM,IAAM,EAAU,CAAK;CAI3B,OAHK,EAAU,EAAI,SAAS,CAAK,MAC7B,EAAI,UAAU,IAEX,EAAI;AACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("react");function t(t,n,r,i){let a=(0,e.useRef)(n);a.current=n,(0,e.useEffect)(()=>{let e=r===void 0?typeof window>`u`?null:window:`current`in r?r.current??null:r;if(!e?.addEventListener)return;let n=e=>a.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[t,r,i])}exports.useEventListener=t;
|
|
1
|
+
let e=require("react");function t(t,n,r,i){let a=(0,e.useRef)(n);(0,e.useEffect)(()=>{a.current=n},[n]),(0,e.useEffect)(()=>{let e=r===void 0?typeof window>`u`?null:window:`current`in r?r.current??null:r;if(!e?.addEventListener)return;let n=e=>a.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[t,r,i])}exports.useEventListener=t;
|
|
2
2
|
//# sourceMappingURL=use-event-listener.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-listener.cjs","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\ntype AnyEventTarget = EventTarget | { current: EventTarget | null } | null | undefined;\n\n/**\n * Subscribe to a DOM event with React-friendly semantics.\n *\n * - Handler is stored in a ref so callers can pass inline functions without\n * resubscribing on every render.\n * - `target` defaults to `window`. Accepts a raw `EventTarget` (window, document,\n * element) OR a ref pointing at one.\n * - Returns nothing — cleanup is automatic on unmount or when `eventName`/`target` change.\n */\nexport function useEventListener<K extends keyof WindowEventMap>(\n eventName: K,\n handler: (event: WindowEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof DocumentEventMap>(\n eventName: K,\n handler: (event: DocumentEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof HTMLElementEventMap>(\n eventName: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener(\n eventName: string,\n handler: (event: Event) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void {\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n\n useEffect(() => {\n const resolvedTarget: EventTarget | null =\n target === undefined\n ? typeof window === \"undefined\"\n ? null\n : window\n : \"current\" in (target as { current: unknown })\n ? ((target as { current: EventTarget | null }).current ?? null)\n : (target as EventTarget | null);\n\n if (!resolvedTarget?.addEventListener) return;\n\n const listener: EventListener = (event) => handlerRef.current(event);\n resolvedTarget.addEventListener(eventName, listener, options);\n return () => resolvedTarget.removeEventListener(eventName, listener, options);\n }, [eventName, target, options]);\n}\n"],"mappings":"uBA+BA,SAAgB,EACZ,EACA,EACA,EACA,EACI,CACJ,IAAM,GAAA,EAAA,EAAA,OAAA,CAAoB,CAAO,
|
|
1
|
+
{"version":3,"file":"use-event-listener.cjs","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\ntype AnyEventTarget = EventTarget | { current: EventTarget | null } | null | undefined;\n\n/**\n * Subscribe to a DOM event with React-friendly semantics.\n *\n * - Handler is stored in a ref so callers can pass inline functions without\n * resubscribing on every render.\n * - `target` defaults to `window`. Accepts a raw `EventTarget` (window, document,\n * element) OR a ref pointing at one.\n * - Returns nothing — cleanup is automatic on unmount or when `eventName`/`target` change.\n */\nexport function useEventListener<K extends keyof WindowEventMap>(\n eventName: K,\n handler: (event: WindowEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof DocumentEventMap>(\n eventName: K,\n handler: (event: DocumentEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof HTMLElementEventMap>(\n eventName: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener(\n eventName: string,\n handler: (event: Event) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void {\n const handlerRef = useRef(handler);\n useEffect(() => {\n handlerRef.current = handler;\n }, [handler]);\n\n useEffect(() => {\n const resolvedTarget: EventTarget | null =\n target === undefined\n ? typeof window === \"undefined\"\n ? null\n : window\n : \"current\" in (target as { current: unknown })\n ? ((target as { current: EventTarget | null }).current ?? null)\n : (target as EventTarget | null);\n\n if (!resolvedTarget?.addEventListener) return;\n\n const listener: EventListener = (event) => handlerRef.current(event);\n resolvedTarget.addEventListener(eventName, listener, options);\n return () => resolvedTarget.removeEventListener(eventName, listener, options);\n }, [eventName, target, options]);\n}\n"],"mappings":"uBA+BA,SAAgB,EACZ,EACA,EACA,EACA,EACI,CACJ,IAAM,GAAA,EAAA,EAAA,OAAA,CAAoB,CAAO,GACjC,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAW,QAAU,CACzB,EAAG,CAAC,CAAO,CAAC,GAEZ,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EACF,IAAW,IAAA,GACL,OAAO,OAAW,IACd,KACA,OACJ,YAAc,EACV,EAA2C,SAAW,KACvD,EAEb,GAAI,CAAC,GAAgB,iBAAkB,OAEvC,IAAM,EAA2B,GAAU,EAAW,QAAQ,CAAK,EAEnE,OADA,EAAe,iBAAiB,EAAW,EAAU,CAAO,MAC/C,EAAe,oBAAoB,EAAW,EAAU,CAAO,CAChF,EAAG,CAAC,EAAW,EAAQ,CAAO,CAAC,CACnC"}
|
|
@@ -2,7 +2,9 @@ import { useEffect as e, useRef as t } from "react";
|
|
|
2
2
|
//#region src/hooks/use-event-listener.ts
|
|
3
3
|
function n(n, r, i, a) {
|
|
4
4
|
let o = t(r);
|
|
5
|
-
|
|
5
|
+
e(() => {
|
|
6
|
+
o.current = r;
|
|
7
|
+
}, [r]), e(() => {
|
|
6
8
|
let e = i === void 0 ? typeof window > "u" ? null : window : "current" in i ? i.current ?? null : i;
|
|
7
9
|
if (!e?.addEventListener) return;
|
|
8
10
|
let t = (e) => o.current(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-listener.js","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\ntype AnyEventTarget = EventTarget | { current: EventTarget | null } | null | undefined;\n\n/**\n * Subscribe to a DOM event with React-friendly semantics.\n *\n * - Handler is stored in a ref so callers can pass inline functions without\n * resubscribing on every render.\n * - `target` defaults to `window`. Accepts a raw `EventTarget` (window, document,\n * element) OR a ref pointing at one.\n * - Returns nothing — cleanup is automatic on unmount or when `eventName`/`target` change.\n */\nexport function useEventListener<K extends keyof WindowEventMap>(\n eventName: K,\n handler: (event: WindowEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof DocumentEventMap>(\n eventName: K,\n handler: (event: DocumentEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof HTMLElementEventMap>(\n eventName: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener(\n eventName: string,\n handler: (event: Event) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void {\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n\n useEffect(() => {\n const resolvedTarget: EventTarget | null =\n target === undefined\n ? typeof window === \"undefined\"\n ? null\n : window\n : \"current\" in (target as { current: unknown })\n ? ((target as { current: EventTarget | null }).current ?? null)\n : (target as EventTarget | null);\n\n if (!resolvedTarget?.addEventListener) return;\n\n const listener: EventListener = (event) => handlerRef.current(event);\n resolvedTarget.addEventListener(eventName, listener, options);\n return () => resolvedTarget.removeEventListener(eventName, listener, options);\n }, [eventName, target, options]);\n}\n"],"mappings":";;AA+BA,SAAgB,EACZ,GACA,GACA,GACA,GACI;CACJ,IAAM,IAAa,EAAO,CAAO;
|
|
1
|
+
{"version":3,"file":"use-event-listener.js","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\ntype AnyEventTarget = EventTarget | { current: EventTarget | null } | null | undefined;\n\n/**\n * Subscribe to a DOM event with React-friendly semantics.\n *\n * - Handler is stored in a ref so callers can pass inline functions without\n * resubscribing on every render.\n * - `target` defaults to `window`. Accepts a raw `EventTarget` (window, document,\n * element) OR a ref pointing at one.\n * - Returns nothing — cleanup is automatic on unmount or when `eventName`/`target` change.\n */\nexport function useEventListener<K extends keyof WindowEventMap>(\n eventName: K,\n handler: (event: WindowEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof DocumentEventMap>(\n eventName: K,\n handler: (event: DocumentEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof HTMLElementEventMap>(\n eventName: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener(\n eventName: string,\n handler: (event: Event) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void {\n const handlerRef = useRef(handler);\n useEffect(() => {\n handlerRef.current = handler;\n }, [handler]);\n\n useEffect(() => {\n const resolvedTarget: EventTarget | null =\n target === undefined\n ? typeof window === \"undefined\"\n ? null\n : window\n : \"current\" in (target as { current: unknown })\n ? ((target as { current: EventTarget | null }).current ?? null)\n : (target as EventTarget | null);\n\n if (!resolvedTarget?.addEventListener) return;\n\n const listener: EventListener = (event) => handlerRef.current(event);\n resolvedTarget.addEventListener(eventName, listener, options);\n return () => resolvedTarget.removeEventListener(eventName, listener, options);\n }, [eventName, target, options]);\n}\n"],"mappings":";;AA+BA,SAAgB,EACZ,GACA,GACA,GACA,GACI;CACJ,IAAM,IAAa,EAAO,CAAO;CAKjC,AAJA,QAAgB;EACZ,EAAW,UAAU;CACzB,GAAG,CAAC,CAAO,CAAC,GAEZ,QAAgB;EACZ,IAAM,IACF,MAAW,KAAA,IACL,OAAO,SAAW,MACd,OACA,SACJ,aAAc,IACV,EAA2C,WAAW,OACvD;EAEb,IAAI,CAAC,GAAgB,kBAAkB;EAEvC,IAAM,KAA2B,MAAU,EAAW,QAAQ,CAAK;EAEnE,OADA,EAAe,iBAAiB,GAAW,GAAU,CAAO,SAC/C,EAAe,oBAAoB,GAAW,GAAU,CAAO;CAChF,GAAG;EAAC;EAAW;EAAQ;CAAO,CAAC;AACnC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("react");function t(t,n){let r=(0,e.useRef)(t);r.current=t,(0,e.useEffect)(()=>{if(n===null)return;let e=setInterval(()=>r.current(),n);return()=>clearInterval(e)},[n])}exports.useInterval=t;
|
|
1
|
+
let e=require("react");function t(t,n){let r=(0,e.useRef)(t);(0,e.useEffect)(()=>{r.current=t},[t]),(0,e.useEffect)(()=>{if(n===null)return;let e=setInterval(()=>r.current(),n);return()=>clearInterval(e)},[n])}exports.useInterval=t;
|
|
2
2
|
//# sourceMappingURL=use-interval.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-interval.cjs","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\n/**\n * Reactive `setInterval`. Pass `null` as `delay` to pause. `fn` is stored in\n * a ref so inline callbacks don't reset the interval on every render.\n *\n * @example\n * useInterval(() => poll(), enabled ? 5000 : null);\n */\nexport function useInterval(fn: () => void, delay: number | null): void {\n const fnRef = useRef(fn);\n fnRef.current = fn;\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(() => fnRef.current(), delay);\n return () => clearInterval(id);\n }, [delay]);\n}\n"],"mappings":"uBASA,SAAgB,EAAY,EAAgB,EAA4B,CACpE,IAAM,GAAA,EAAA,EAAA,OAAA,CAAe,CAAE,
|
|
1
|
+
{"version":3,"file":"use-interval.cjs","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\n/**\n * Reactive `setInterval`. Pass `null` as `delay` to pause. `fn` is stored in\n * a ref so inline callbacks don't reset the interval on every render.\n *\n * @example\n * useInterval(() => poll(), enabled ? 5000 : null);\n */\nexport function useInterval(fn: () => void, delay: number | null): void {\n const fnRef = useRef(fn);\n useEffect(() => {\n fnRef.current = fn;\n }, [fn]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(() => fnRef.current(), delay);\n return () => clearInterval(id);\n }, [delay]);\n}\n"],"mappings":"uBASA,SAAgB,EAAY,EAAgB,EAA4B,CACpE,IAAM,GAAA,EAAA,EAAA,OAAA,CAAe,CAAE,GACvB,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAM,QAAU,CACpB,EAAG,CAAC,CAAE,CAAC,GAEP,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,IAAU,KAAM,OACpB,IAAM,EAAK,gBAAkB,EAAM,QAAQ,EAAG,CAAK,EACnD,UAAa,cAAc,CAAE,CACjC,EAAG,CAAC,CAAK,CAAC,CACd"}
|
|
@@ -2,7 +2,9 @@ import { useEffect as e, useRef as t } from "react";
|
|
|
2
2
|
//#region src/hooks/use-interval.ts
|
|
3
3
|
function n(n, r) {
|
|
4
4
|
let i = t(n);
|
|
5
|
-
|
|
5
|
+
e(() => {
|
|
6
|
+
i.current = n;
|
|
7
|
+
}, [n]), e(() => {
|
|
6
8
|
if (r === null) return;
|
|
7
9
|
let e = setInterval(() => i.current(), r);
|
|
8
10
|
return () => clearInterval(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-interval.js","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\n/**\n * Reactive `setInterval`. Pass `null` as `delay` to pause. `fn` is stored in\n * a ref so inline callbacks don't reset the interval on every render.\n *\n * @example\n * useInterval(() => poll(), enabled ? 5000 : null);\n */\nexport function useInterval(fn: () => void, delay: number | null): void {\n const fnRef = useRef(fn);\n fnRef.current = fn;\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(() => fnRef.current(), delay);\n return () => clearInterval(id);\n }, [delay]);\n}\n"],"mappings":";;AASA,SAAgB,EAAY,GAAgB,GAA4B;CACpE,IAAM,IAAQ,EAAO,CAAE;
|
|
1
|
+
{"version":3,"file":"use-interval.js","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\n/**\n * Reactive `setInterval`. Pass `null` as `delay` to pause. `fn` is stored in\n * a ref so inline callbacks don't reset the interval on every render.\n *\n * @example\n * useInterval(() => poll(), enabled ? 5000 : null);\n */\nexport function useInterval(fn: () => void, delay: number | null): void {\n const fnRef = useRef(fn);\n useEffect(() => {\n fnRef.current = fn;\n }, [fn]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(() => fnRef.current(), delay);\n return () => clearInterval(id);\n }, [delay]);\n}\n"],"mappings":";;AASA,SAAgB,EAAY,GAAgB,GAA4B;CACpE,IAAM,IAAQ,EAAO,CAAE;CAKvB,AAJA,QAAgB;EACZ,EAAM,UAAU;CACpB,GAAG,CAAC,CAAE,CAAC,GAEP,QAAgB;EACZ,IAAI,MAAU,MAAM;EACpB,IAAM,IAAK,kBAAkB,EAAM,QAAQ,GAAG,CAAK;EACnD,aAAa,cAAc,CAAE;CACjC,GAAG,CAAC,CAAK,CAAC;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-first-render.cjs","names":[],"sources":["../../src/hooks/use-is-first-render.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-is-first-render.cjs","names":[],"sources":["../../src/hooks/use-is-first-render.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- flipping the flag during render IS this hook */\nimport { useRef } from \"react\";\n\n/**\n * Return `true` on the first render of the component and `false` thereafter.\n *\n * Reads *and* flips a ref during render, which the React Compiler rules flag on\n * sight — here it is the entire hook. Under StrictMode's double render in dev the\n * second pass already sees `false`, so treat the result as \"first committed\n * render\" and not as a strict render counter.\n *\n * @returns Whether the current render is the first one.\n */\nexport function useIsFirstRender(): boolean {\n const isFirst = useRef<boolean>(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return false;\n}\n"],"mappings":"uBAaA,SAAgB,GAA4B,CACxC,IAAM,GAAA,EAAA,EAAA,OAAA,CAA0B,EAAI,EAKpC,OAJI,EAAQ,SACR,EAAQ,QAAU,GACX,IAEJ,EACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-is-first-render.js","names":[],"sources":["../../src/hooks/use-is-first-render.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-is-first-render.js","names":[],"sources":["../../src/hooks/use-is-first-render.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- flipping the flag during render IS this hook */\nimport { useRef } from \"react\";\n\n/**\n * Return `true` on the first render of the component and `false` thereafter.\n *\n * Reads *and* flips a ref during render, which the React Compiler rules flag on\n * sight — here it is the entire hook. Under StrictMode's double render in dev the\n * second pass already sees `false`, so treat the result as \"first committed\n * render\" and not as a strict render counter.\n *\n * @returns Whether the current render is the first one.\n */\nexport function useIsFirstRender(): boolean {\n const isFirst = useRef<boolean>(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return false;\n}\n"],"mappings":";;AAaA,SAAgB,IAA4B;CACxC,IAAM,IAAU,EAAgB,EAAI;CAKpC,OAJI,EAAQ,WACR,EAAQ,UAAU,IACX,MAEJ;AACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("react");function t(t,n={}){let{delayMs:r=500,disabled:i=!1}=n,a=(0,e.useRef)(null),o=(0,e.useRef)(!1),s=(0,e.useRef)(t);s.current=t;let c=(0,e.useCallback)(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},[]),l=(0,e.useCallback)(()=>{i||(o.current=!1,c(),a.current=window.setTimeout(()=>{o.current=!0,s.current()},r))},[i,c,r]);return{onMouseDown:l,onMouseUp:c,onMouseLeave:c,onTouchStart:l,onTouchEnd:c,onTouchMove:c,onContextMenu:(0,e.useCallback)(e=>{i||(e.preventDefault(),o.current=!0,s.current())},[i]),wasLongPress:()=>o.current}}exports.useLongPressHandlers=t;
|
|
1
|
+
let e=require("react");function t(t,n={}){let{delayMs:r=500,disabled:i=!1}=n,a=(0,e.useRef)(null),o=(0,e.useRef)(!1),s=(0,e.useRef)(t);(0,e.useEffect)(()=>{s.current=t},[t]);let c=(0,e.useCallback)(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},[]),l=(0,e.useCallback)(()=>{i||(o.current=!1,c(),a.current=window.setTimeout(()=>{o.current=!0,s.current()},r))},[i,c,r]);return{onMouseDown:l,onMouseUp:c,onMouseLeave:c,onTouchStart:l,onTouchEnd:c,onTouchMove:c,onContextMenu:(0,e.useCallback)(e=>{i||(e.preventDefault(),o.current=!0,s.current())},[i]),wasLongPress:()=>o.current}}exports.useLongPressHandlers=t;
|
|
2
2
|
//# sourceMappingURL=use-long-press-handlers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-long-press-handlers.cjs","names":[],"sources":["../../src/hooks/use-long-press-handlers.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport type { MouseEvent as ReactMouseEvent, TouchEvent as ReactTouchEvent } from \"react\";\n\n/**\n * DOM event handlers produced by {@link useLongPressHandlers}, ready to spread\n * onto a JSX element (`<div {...handlers}>`).\n */\nexport interface LongPressHandlers {\n /** Starts the hold timer on mouse press. */\n onMouseDown: (event: ReactMouseEvent) => void;\n /** Cancels the pending hold when the mouse is released. */\n onMouseUp: () => void;\n /** Cancels the pending hold when the pointer leaves the element. */\n onMouseLeave: () => void;\n /** Starts the hold timer on touch start. */\n onTouchStart: (event: ReactTouchEvent) => void;\n /** Cancels the pending hold when the touch ends. */\n onTouchEnd: () => void;\n /** Cancels the pending hold when the finger moves. */\n onTouchMove: () => void;\n /** Fires the long-press immediately (desktop right-click parity). */\n onContextMenu: (event: ReactMouseEvent) => void;\n}\n\n/** Options accepted by {@link useLongPressHandlers}. */\nexport interface UseLongPressHandlersOptions {\n /** Hold duration in ms before `onLongPress` fires. Defaults to `500`. */\n delayMs?: number;\n /** When `true`, the hook is inert and every handler is a no-op. */\n disabled?: boolean;\n}\n\n/** Return shape of {@link useLongPressHandlers}. */\nexport type UseLongPressHandlersResult = LongPressHandlers & {\n /**\n * Reads whether the most recent interaction fired a long-press. Use it in\n * the element's `onClick` to suppress the click that follows a long-press.\n */\n wasLongPress: () => boolean;\n};\n\n/**\n * Returns DOM event handlers that detect a long press (touch or mouse hold)\n * and invoke `onLongPress` once after `delayMs`.\n *\n * Cancels on touch movement or pointer release. Also wires `contextmenu` to\n * fire `onLongPress` immediately so a right-click on desktop opens selection\n * mode the same way an Android long-press does on mobile.\n *\n * The hook does not `preventDefault` on the underlying click — the consumer\n * decides whether the subsequent click should still fire. Track that with the\n * returned `wasLongPress()` guard to tell \"long-press fired\" apart from a\n * \"regular click\".\n *\n * Unlike {@link useLongPress}, which attaches pointer listeners to a `ref`,\n * this variant returns handler props you spread directly onto an element and\n * exposes a `wasLongPress()` guard.\n *\n * @param onLongPress - Callback invoked once the hold threshold is reached.\n * @param options - Optional `delayMs` and `disabled` flags.\n * @returns The spreadable handlers plus a `wasLongPress()` guard.\n *\n * @example\n * const longPress = useLongPressHandlers(() => enterSelectionMode(), { delayMs: 600 });\n * <button {...longPress} onClick={() => { if (!longPress.wasLongPress()) navigate(); }}>\n * Item\n * </button>\n */\nexport function useLongPressHandlers(\n onLongPress: () => void,\n options: UseLongPressHandlersOptions = {},\n): UseLongPressHandlersResult {\n const { delayMs = 500, disabled = false } = options;\n const timerRef = useRef<number | null>(null);\n const firedRef = useRef<boolean>(false);\n const callbackRef = useRef<() => void>(onLongPress);\n callbackRef.current = onLongPress;\n\n const clear = useCallback((): void => {\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n }, []);\n\n const start = useCallback((): void => {\n if (disabled) return;\n firedRef.current = false;\n clear();\n timerRef.current = window.setTimeout(() => {\n firedRef.current = true;\n callbackRef.current();\n }, delayMs);\n }, [disabled, clear, delayMs]);\n\n const onContextMenu = useCallback(\n (event: ReactMouseEvent): void => {\n if (disabled) return;\n event.preventDefault();\n firedRef.current = true;\n callbackRef.current();\n },\n [disabled],\n );\n\n return {\n onMouseDown: start,\n onMouseUp: clear,\n onMouseLeave: clear,\n onTouchStart: start,\n onTouchEnd: clear,\n onTouchMove: clear,\n onContextMenu,\n wasLongPress: () => firedRef.current,\n };\n}\n"],"mappings":"uBAoEA,SAAgB,EACZ,EACA,EAAuC,CAAC,EACd,CAC1B,GAAM,CAAE,UAAU,IAAK,WAAW,IAAU,EACtC,GAAA,EAAA,EAAA,OAAA,CAAiC,IAAI,EACrC,GAAA,EAAA,EAAA,OAAA,CAA2B,EAAK,EAChC,GAAA,EAAA,EAAA,OAAA,CAAiC,CAAW,
|
|
1
|
+
{"version":3,"file":"use-long-press-handlers.cjs","names":[],"sources":["../../src/hooks/use-long-press-handlers.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from \"react\";\nimport type { MouseEvent as ReactMouseEvent, TouchEvent as ReactTouchEvent } from \"react\";\n\n/**\n * DOM event handlers produced by {@link useLongPressHandlers}, ready to spread\n * onto a JSX element (`<div {...handlers}>`).\n */\nexport interface LongPressHandlers {\n /** Starts the hold timer on mouse press. */\n onMouseDown: (event: ReactMouseEvent) => void;\n /** Cancels the pending hold when the mouse is released. */\n onMouseUp: () => void;\n /** Cancels the pending hold when the pointer leaves the element. */\n onMouseLeave: () => void;\n /** Starts the hold timer on touch start. */\n onTouchStart: (event: ReactTouchEvent) => void;\n /** Cancels the pending hold when the touch ends. */\n onTouchEnd: () => void;\n /** Cancels the pending hold when the finger moves. */\n onTouchMove: () => void;\n /** Fires the long-press immediately (desktop right-click parity). */\n onContextMenu: (event: ReactMouseEvent) => void;\n}\n\n/** Options accepted by {@link useLongPressHandlers}. */\nexport interface UseLongPressHandlersOptions {\n /** Hold duration in ms before `onLongPress` fires. Defaults to `500`. */\n delayMs?: number;\n /** When `true`, the hook is inert and every handler is a no-op. */\n disabled?: boolean;\n}\n\n/** Return shape of {@link useLongPressHandlers}. */\nexport type UseLongPressHandlersResult = LongPressHandlers & {\n /**\n * Reads whether the most recent interaction fired a long-press. Use it in\n * the element's `onClick` to suppress the click that follows a long-press.\n */\n wasLongPress: () => boolean;\n};\n\n/**\n * Returns DOM event handlers that detect a long press (touch or mouse hold)\n * and invoke `onLongPress` once after `delayMs`.\n *\n * Cancels on touch movement or pointer release. Also wires `contextmenu` to\n * fire `onLongPress` immediately so a right-click on desktop opens selection\n * mode the same way an Android long-press does on mobile.\n *\n * The hook does not `preventDefault` on the underlying click — the consumer\n * decides whether the subsequent click should still fire. Track that with the\n * returned `wasLongPress()` guard to tell \"long-press fired\" apart from a\n * \"regular click\".\n *\n * Unlike {@link useLongPress}, which attaches pointer listeners to a `ref`,\n * this variant returns handler props you spread directly onto an element and\n * exposes a `wasLongPress()` guard.\n *\n * @param onLongPress - Callback invoked once the hold threshold is reached.\n * @param options - Optional `delayMs` and `disabled` flags.\n * @returns The spreadable handlers plus a `wasLongPress()` guard.\n *\n * @example\n * const longPress = useLongPressHandlers(() => enterSelectionMode(), { delayMs: 600 });\n * <button {...longPress} onClick={() => { if (!longPress.wasLongPress()) navigate(); }}>\n * Item\n * </button>\n */\nexport function useLongPressHandlers(\n onLongPress: () => void,\n options: UseLongPressHandlersOptions = {},\n): UseLongPressHandlersResult {\n const { delayMs = 500, disabled = false } = options;\n const timerRef = useRef<number | null>(null);\n const firedRef = useRef<boolean>(false);\n const callbackRef = useRef<() => void>(onLongPress);\n useEffect(() => {\n callbackRef.current = onLongPress;\n }, [onLongPress]);\n\n const clear = useCallback((): void => {\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n }, []);\n\n const start = useCallback((): void => {\n if (disabled) return;\n firedRef.current = false;\n clear();\n timerRef.current = window.setTimeout(() => {\n firedRef.current = true;\n callbackRef.current();\n }, delayMs);\n }, [disabled, clear, delayMs]);\n\n const onContextMenu = useCallback(\n (event: ReactMouseEvent): void => {\n if (disabled) return;\n event.preventDefault();\n firedRef.current = true;\n callbackRef.current();\n },\n [disabled],\n );\n\n return {\n onMouseDown: start,\n onMouseUp: clear,\n onMouseLeave: clear,\n onTouchStart: start,\n onTouchEnd: clear,\n onTouchMove: clear,\n onContextMenu,\n wasLongPress: () => firedRef.current,\n };\n}\n"],"mappings":"uBAoEA,SAAgB,EACZ,EACA,EAAuC,CAAC,EACd,CAC1B,GAAM,CAAE,UAAU,IAAK,WAAW,IAAU,EACtC,GAAA,EAAA,EAAA,OAAA,CAAiC,IAAI,EACrC,GAAA,EAAA,EAAA,OAAA,CAA2B,EAAK,EAChC,GAAA,EAAA,EAAA,OAAA,CAAiC,CAAW,GAClD,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAY,QAAU,CAC1B,EAAG,CAAC,CAAW,CAAC,EAEhB,IAAM,GAAA,EAAA,EAAA,YAAA,KAAgC,CAC9B,EAAS,UAAY,OACrB,OAAO,aAAa,EAAS,OAAO,EACpC,EAAS,QAAU,KAE3B,EAAG,CAAC,CAAC,EAEC,GAAA,EAAA,EAAA,YAAA,KAAgC,CAC9B,IACJ,EAAS,QAAU,GACnB,EAAM,EACN,EAAS,QAAU,OAAO,eAAiB,CACvC,EAAS,QAAU,GACnB,EAAY,QAAQ,CACxB,EAAG,CAAO,EACd,EAAG,CAAC,EAAU,EAAO,CAAO,CAAC,EAY7B,MAAO,CACH,YAAa,EACb,UAAW,EACX,aAAc,EACd,aAAc,EACd,WAAY,EACZ,YAAa,EACb,eAAA,EAAA,EAAA,YAAA,CAhBC,GAAiC,CAC1B,IACJ,EAAM,eAAe,EACrB,EAAS,QAAU,GACnB,EAAY,QAAQ,EACxB,EACA,CAAC,CAAQ,CAUT,EACA,iBAAoB,EAAS,OACjC,CACJ"}
|