@kumix/ui 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -17
- package/dist/components/agents/agent-activity/activity-row.d.ts +8 -0
- package/dist/components/agents/agent-activity/activity-row.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/activity-row.js +228 -0
- package/dist/components/agents/agent-activity/activity-row.js.map +1 -0
- package/dist/components/agents/agent-activity/index.d.ts +6 -0
- package/dist/components/agents/agent-activity/index.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/index.js +182 -0
- package/dist/components/agents/agent-activity/index.js.map +1 -0
- package/dist/components/agents/agent-code.d.ts +25 -0
- package/dist/components/agents/agent-code.d.ts.map +1 -0
- package/dist/components/agents/agent-code.js +117 -0
- package/dist/components/agents/agent-code.js.map +1 -0
- package/dist/components/agents/agent-disclosure.d.ts +12 -0
- package/dist/components/agents/agent-disclosure.d.ts.map +1 -0
- package/dist/components/agents/agent-disclosure.js +36 -0
- package/dist/components/agents/agent-disclosure.js.map +1 -0
- package/dist/components/agents/ai-sidebar.d.ts +41 -0
- package/dist/components/agents/ai-sidebar.d.ts.map +1 -0
- package/dist/components/agents/ai-sidebar.js +576 -0
- package/dist/components/agents/ai-sidebar.js.map +1 -0
- package/dist/components/agents/approval-card/index.d.ts +51 -0
- package/dist/components/agents/approval-card/index.d.ts.map +1 -0
- package/dist/components/agents/approval-card/index.js +317 -0
- package/dist/components/agents/approval-card/index.js.map +1 -0
- package/dist/components/agents/chat-app.d.ts +10 -0
- package/dist/components/agents/chat-app.d.ts.map +1 -0
- package/dist/components/agents/chat-app.js +20 -0
- package/dist/components/agents/chat-app.js.map +1 -0
- package/dist/components/agents/citations.d.ts +45 -0
- package/dist/components/agents/citations.d.ts.map +1 -0
- package/dist/components/agents/citations.js +175 -0
- package/dist/components/agents/citations.js.map +1 -0
- package/dist/components/agents/code-block.d.ts +21 -0
- package/dist/components/agents/code-block.d.ts.map +1 -0
- package/dist/components/agents/code-block.js +113 -0
- package/dist/components/agents/code-block.js.map +1 -0
- package/dist/components/agents/file-diff.d.ts +30 -0
- package/dist/components/agents/file-diff.d.ts.map +1 -0
- package/dist/components/agents/file-diff.js +186 -0
- package/dist/components/agents/file-diff.js.map +1 -0
- package/dist/components/agents/image-generation.d.ts +27 -0
- package/dist/components/agents/image-generation.d.ts.map +1 -0
- package/dist/components/agents/image-generation.js +308 -0
- package/dist/components/agents/image-generation.js.map +1 -0
- package/dist/components/agents/loading-states/agent-progress.d.ts +16 -0
- package/dist/components/agents/loading-states/agent-progress.d.ts.map +1 -0
- package/dist/components/agents/loading-states/agent-progress.js +117 -0
- package/dist/components/agents/loading-states/agent-progress.js.map +1 -0
- package/dist/components/agents/loading-states/reasoning-text.d.ts +20 -0
- package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -0
- package/dist/components/agents/loading-states/reasoning-text.js +184 -0
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -0
- package/dist/components/agents/loading-states/thinking-shimmer.d.ts +13 -0
- package/dist/components/agents/loading-states/thinking-shimmer.d.ts.map +1 -0
- package/dist/components/agents/loading-states/thinking-shimmer.js +17 -0
- package/dist/components/agents/loading-states/thinking-shimmer.js.map +1 -0
- package/dist/components/agents/message-bubble.d.ts +38 -0
- package/dist/components/agents/message-bubble.d.ts.map +1 -0
- package/dist/components/agents/message-bubble.js +182 -0
- package/dist/components/agents/message-bubble.js.map +1 -0
- package/dist/components/agents/message-context.d.ts +6 -0
- package/dist/components/agents/message-context.d.ts.map +1 -0
- package/dist/components/agents/message-context.js +8 -0
- package/dist/components/agents/message-context.js.map +1 -0
- package/dist/components/agents/message-scroller.d.ts +30 -0
- package/dist/components/agents/message-scroller.d.ts.map +1 -0
- package/dist/components/agents/message-scroller.js +314 -0
- package/dist/components/agents/message-scroller.js.map +1 -0
- package/dist/components/agents/message.d.ts +37 -0
- package/dist/components/agents/message.d.ts.map +1 -0
- package/dist/components/agents/message.js +139 -0
- package/dist/components/agents/message.js.map +1 -0
- package/dist/components/agents/prompt-input.d.ts +37 -0
- package/dist/components/agents/prompt-input.d.ts.map +1 -0
- package/dist/components/agents/prompt-input.js +216 -0
- package/dist/components/agents/prompt-input.js.map +1 -0
- package/dist/components/agents/streaming-response.d.ts +35 -0
- package/dist/components/agents/streaming-response.d.ts.map +1 -0
- package/dist/components/agents/streaming-response.js +151 -0
- package/dist/components/agents/streaming-response.js.map +1 -0
- package/dist/components/agents/todo-list.d.ts +24 -0
- package/dist/components/agents/todo-list.d.ts.map +1 -0
- package/dist/components/agents/todo-list.js +334 -0
- package/dist/components/agents/todo-list.js.map +1 -0
- package/dist/components/agents/tool-approval.d.ts +33 -0
- package/dist/components/agents/tool-approval.d.ts.map +1 -0
- package/dist/components/agents/tool-approval.js +166 -0
- package/dist/components/agents/tool-approval.js.map +1 -0
- package/dist/components/agents/tool-result.d.ts +34 -0
- package/dist/components/agents/tool-result.d.ts.map +1 -0
- package/dist/components/agents/tool-result.js +220 -0
- package/dist/components/agents/tool-result.js.map +1 -0
- package/dist/components/custom/confirm-dialog.js +1 -1
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
- package/dist/components/motion/animated-sidebar.js +3 -3
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +3 -3
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.js +2 -2
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/button/stateful.js +1 -1
- package/dist/components/motion/center-morph-modal.js +3 -3
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/chromatic-text-reveal.js +1 -1
- package/dist/components/motion/chromatic-text-reveal.js.map +1 -1
- package/dist/components/motion/command-palette.js +8 -4
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/preview-rail.d.ts +10 -2
- package/dist/components/motion/preview-rail.d.ts.map +1 -1
- package/dist/components/motion/preview-rail.js +58 -27
- package/dist/components/motion/preview-rail.js.map +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/text-shimmer.d.ts.map +1 -1
- package/dist/components/motion/text-shimmer.js +4 -3
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts +4 -3
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -2
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts +15 -4
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +36 -8
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts +3 -2
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +0 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +3 -4
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +12 -7
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts +71 -4
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +147 -40
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +5 -6
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +6 -5
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +9 -10
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +60 -33
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +152 -68
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +105 -20
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +83 -10
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +47 -44
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-dnd.js +20 -2
- package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js +7 -5
- package/dist/components/reui/event-calendar/event-calendar-recurrence.js.map +1 -1
- package/dist/components/reui/filters.js +26 -21
- package/dist/components/reui/filters.js.map +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/frame.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/reui/icon-tile.d.ts.map +1 -1
- package/dist/components/reui/icon-tile.js +8 -1
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/sortable.js +13 -11
- package/dist/components/reui/sortable.js.map +1 -1
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/questionnaire.d.ts +21 -0
- package/dist/components/ui/questionnaire.d.ts.map +1 -0
- package/dist/components/ui/questionnaire.js +164 -0
- package/dist/components/ui/questionnaire.js.map +1 -0
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/{copy-menu-BJ-MXnkN.js → copy-menu-Bk5GP9Gp.js} +3 -3
- package/dist/{copy-menu-BJ-MXnkN.js.map → copy-menu-Bk5GP9Gp.js.map} +1 -1
- package/dist/hooks/use-body-classes.d.ts +0 -3
- package/dist/hooks/use-body-classes.d.ts.map +1 -1
- package/dist/hooks/use-body-classes.js +0 -3
- package/dist/hooks/use-body-classes.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +0 -3
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +0 -3
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-file-upload.js +6 -4
- package/dist/hooks/use-file-upload.js.map +1 -1
- package/dist/hooks/use-hydrated.d.ts +0 -10
- package/dist/hooks/use-hydrated.d.ts.map +1 -1
- package/dist/hooks/use-hydrated.js +0 -10
- package/dist/hooks/use-hydrated.js.map +1 -1
- package/dist/hooks/use-intersection-observer.d.ts.map +1 -1
- package/dist/hooks/use-intersection-observer.js +0 -5
- package/dist/hooks/use-intersection-observer.js.map +1 -1
- package/dist/hooks/use-is-mac.d.ts +0 -5
- package/dist/hooks/use-is-mac.d.ts.map +1 -1
- package/dist/hooks/use-is-mac.js +0 -5
- package/dist/hooks/use-is-mac.js.map +1 -1
- package/dist/hooks/use-media-query.d.ts +0 -5
- package/dist/hooks/use-media-query.d.ts.map +1 -1
- package/dist/hooks/use-media-query.js +0 -5
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-meta-color.d.ts.map +1 -1
- package/dist/hooks/use-meta-color.js +0 -3
- package/dist/hooks/use-meta-color.js.map +1 -1
- package/dist/hooks/use-mutation-observer.d.ts.map +1 -1
- package/dist/hooks/use-mutation-observer.js +0 -5
- package/dist/hooks/use-mutation-observer.js.map +1 -1
- package/dist/hooks/use-scroll-position.d.ts.map +1 -1
- package/dist/hooks/use-scroll-position.js +0 -5
- package/dist/hooks/use-scroll-position.js.map +1 -1
- package/dist/hooks/use-slider-input.d.ts.map +1 -1
- package/dist/hooks/use-slider-input.js +0 -5
- package/dist/hooks/use-slider-input.js.map +1 -1
- package/dist/hooks/use-viewport.d.ts +0 -5
- package/dist/hooks/use-viewport.d.ts.map +1 -1
- package/dist/hooks/use-viewport.js +0 -5
- package/dist/hooks/use-viewport.js.map +1 -1
- package/dist/lib/favicon.d.ts +5 -0
- package/dist/lib/favicon.d.ts.map +1 -0
- package/dist/lib/favicon.js +12 -0
- package/dist/lib/favicon.js.map +1 -0
- package/dist/lib/text-shimmer.d.ts +8 -0
- package/dist/lib/text-shimmer.d.ts.map +1 -0
- package/dist/lib/text-shimmer.js +10 -0
- package/dist/lib/text-shimmer.js.map +1 -0
- package/dist/types-j36vVGtZ.d.ts +78 -0
- package/dist/types-j36vVGtZ.d.ts.map +1 -0
- package/package.json +18 -13
- package/dist/components/ui/sonner.d.ts +0 -7
- package/dist/components/ui/sonner.d.ts.map +0 -1
- package/dist/components/ui/sonner.js +0 -32
- package/dist/components/ui/sonner.js.map +0 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { buttonVariants } from "./button.js";
|
|
3
|
+
import { cn } from "@kumix/utils";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { CheckIcon } from "lucide-react";
|
|
6
|
+
import { Questionnaire as Questionnaire$1 } from "@shadcn/react/questionnaire";
|
|
7
|
+
//#region src/components/ui/questionnaire.tsx
|
|
8
|
+
function Questionnaire({ className, ...props }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Root, {
|
|
10
|
+
"data-slot": "questionnaire",
|
|
11
|
+
className: cn("flex w-full min-w-0 flex-col gap-4", className),
|
|
12
|
+
...props
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function QuestionnaireProgress({ className, ...props }) {
|
|
16
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Progress, {
|
|
17
|
+
"data-slot": "questionnaire-progress",
|
|
18
|
+
className: cn("min-h-lh w-fit min-w-[14ch] font-medium text-muted-foreground text-xs tabular-nums", className),
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function QuestionnaireItem({ className, ...props }) {
|
|
23
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Item, {
|
|
24
|
+
"data-slot": "questionnaire-item",
|
|
25
|
+
className: cn("flex min-w-0 flex-col gap-4 border-0 p-0 outline-none", className),
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function QuestionnaireTitle({ className, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Title, {
|
|
31
|
+
"data-slot": "questionnaire-title",
|
|
32
|
+
className: cn("text-pretty font-heading font-medium text-base leading-snug [&:not(:has(~[data-slot=questionnaire-description]))]:mb-4", className),
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function QuestionnaireDescription({ className, ...props }) {
|
|
37
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Description, {
|
|
38
|
+
"data-slot": "questionnaire-description",
|
|
39
|
+
className: cn("text-pretty text-muted-foreground text-sm", className),
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function QuestionnaireChoices({ className, ...props }) {
|
|
44
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Choices, {
|
|
45
|
+
"data-slot": "questionnaire-choices",
|
|
46
|
+
className: cn("group/questionnaire-choices grid min-w-0 gap-2", className),
|
|
47
|
+
...props
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function QuestionnaireChoice({ children, className, ...props }) {
|
|
51
|
+
return /* @__PURE__ */ jsxs(Questionnaire$1.Choice, {
|
|
52
|
+
"data-slot": "questionnaire-choice",
|
|
53
|
+
className: cn("group/questionnaire-choice relative flex min-h-11 cursor-pointer select-none items-start gap-2.5 rounded-lg border border-input bg-transparent px-3 py-2.5 text-start text-sm outline-none transition-colors hover:bg-muted/50 has-[>input:focus-visible]:border-ring has-[>input:focus-visible]:ring-3 has-[>input:focus-visible]:ring-ring/50 data-checked:border-primary/40 data-invalid:border-destructive data-checked:bg-muted dark:bg-input/20 dark:data-checked:bg-muted", "data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50", className),
|
|
54
|
+
...props,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsx(Questionnaire$1.ChoiceInput, {
|
|
57
|
+
"data-slot": "questionnaire-choice-input",
|
|
58
|
+
className: "absolute inset-0 z-10 size-full cursor-pointer opacity-0"
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ jsxs("span", {
|
|
61
|
+
"aria-hidden": "true",
|
|
62
|
+
"data-slot": "questionnaire-choice-indicator",
|
|
63
|
+
className: "pointer-events-none relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input group-data-[type=radio]/questionnaire-choice:rounded-full group-data-checked/questionnaire-choice:border-primary group-data-checked/questionnaire-choice:bg-primary group-data-checked/questionnaire-choice:text-primary-foreground dark:bg-input/30 dark:group-data-checked/questionnaire-choice:bg-primary",
|
|
64
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
65
|
+
"data-slot": "questionnaire-choice-indicator-dot",
|
|
66
|
+
className: "hidden size-2 rounded-full bg-primary-foreground group-data-checked/questionnaire-choice:block group-data-[type=checkbox]/questionnaire-choice:hidden"
|
|
67
|
+
}), /* @__PURE__ */ jsx(CheckIcon, {
|
|
68
|
+
"data-slot": "questionnaire-choice-indicator-check",
|
|
69
|
+
className: "hidden size-3.5 group-data-checked/questionnaire-choice:block group-data-[type=radio]/questionnaire-choice:hidden"
|
|
70
|
+
})]
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(Questionnaire$1.ChoiceLabel, {
|
|
73
|
+
"data-slot": "questionnaire-choice-label",
|
|
74
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5 leading-snug",
|
|
75
|
+
children
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ jsx(Questionnaire$1.ChoiceShortcut, {
|
|
78
|
+
"data-slot": "questionnaire-choice-shortcut",
|
|
79
|
+
className: "pointer-events-none ms-auto mt-0.5 hidden size-5 shrink-0 items-center justify-center rounded-md border border-input bg-background font-medium font-mono text-[0.625rem] text-muted-foreground leading-none group-data-shortcut/questionnaire-choice:inline-flex"
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function QuestionnaireInput({ className, ...props }) {
|
|
85
|
+
return /* @__PURE__ */ jsx("div", {
|
|
86
|
+
"data-slot": "questionnaire-input-wrapper",
|
|
87
|
+
className: "group/questionnaire-input relative w-full min-w-0",
|
|
88
|
+
children: /* @__PURE__ */ jsx(Questionnaire$1.Input, {
|
|
89
|
+
"data-slot": "questionnaire-input",
|
|
90
|
+
className: cn("h-8 min-h-11 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base outline-none transition-[color,box-shadow,background-color] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 sm:min-h-0 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:disabled:bg-input/80", "selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground", className),
|
|
91
|
+
...props
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function QuestionnaireError({ className, ...props }) {
|
|
96
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Error, {
|
|
97
|
+
"data-slot": "questionnaire-error",
|
|
98
|
+
className: cn("text-destructive text-sm", className),
|
|
99
|
+
...props
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function QuestionnaireActions({ className, ...props }) {
|
|
103
|
+
return /* @__PURE__ */ jsx("div", {
|
|
104
|
+
"data-slot": "questionnaire-actions",
|
|
105
|
+
className: cn("grid min-h-11 w-full grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:min-h-8", className),
|
|
106
|
+
...props
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function QuestionnairePrevious({ children, className, size = "default", variant = "outline", ...props }) {
|
|
110
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Previous, {
|
|
111
|
+
"data-slot": "questionnaire-previous",
|
|
112
|
+
"data-size": size,
|
|
113
|
+
"data-variant": variant,
|
|
114
|
+
className: cn(buttonVariants({
|
|
115
|
+
size,
|
|
116
|
+
variant
|
|
117
|
+
}), "col-start-1 row-start-1 min-h-11 justify-self-start sm:min-h-0", className),
|
|
118
|
+
...props,
|
|
119
|
+
children: children ?? "Previous"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function QuestionnaireSkip({ children, className, size = "default", variant = "outline", ...props }) {
|
|
123
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Skip, {
|
|
124
|
+
"data-slot": "questionnaire-skip",
|
|
125
|
+
"data-size": size,
|
|
126
|
+
"data-variant": variant,
|
|
127
|
+
className: cn(buttonVariants({
|
|
128
|
+
size,
|
|
129
|
+
variant
|
|
130
|
+
}), "col-start-2 row-start-1 min-h-11 justify-self-end sm:min-h-0", className),
|
|
131
|
+
...props,
|
|
132
|
+
children: children ?? "Skip"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function QuestionnaireNext({ children, className, size = "default", variant = "default", ...props }) {
|
|
136
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Next, {
|
|
137
|
+
"data-slot": "questionnaire-next",
|
|
138
|
+
"data-size": size,
|
|
139
|
+
"data-variant": variant,
|
|
140
|
+
className: cn(buttonVariants({
|
|
141
|
+
size,
|
|
142
|
+
variant
|
|
143
|
+
}), "col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0", className),
|
|
144
|
+
...props,
|
|
145
|
+
children: children ?? "Next"
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function QuestionnaireSubmit({ children, className, size = "default", variant = "default", ...props }) {
|
|
149
|
+
return /* @__PURE__ */ jsx(Questionnaire$1.Submit, {
|
|
150
|
+
"data-slot": "questionnaire-submit",
|
|
151
|
+
"data-size": size,
|
|
152
|
+
"data-variant": variant,
|
|
153
|
+
className: cn(buttonVariants({
|
|
154
|
+
size,
|
|
155
|
+
variant
|
|
156
|
+
}), "col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0", className),
|
|
157
|
+
...props,
|
|
158
|
+
children: children ?? "Submit"
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
export { Questionnaire, QuestionnaireActions, QuestionnaireChoice, QuestionnaireChoices, QuestionnaireDescription, QuestionnaireError, QuestionnaireInput, QuestionnaireItem, QuestionnaireNext, QuestionnairePrevious, QuestionnaireProgress, QuestionnaireSkip, QuestionnaireSubmit, QuestionnaireTitle };
|
|
163
|
+
|
|
164
|
+
//# sourceMappingURL=questionnaire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"questionnaire.js","names":["QuestionnairePrimitive"],"sources":["../../../src/components/ui/questionnaire.tsx"],"sourcesContent":["\"use client\";\n\nimport type * as React from \"react\";\nimport { Questionnaire as QuestionnairePrimitive } from \"@shadcn/react/questionnaire\";\nimport { CheckIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { type Button, buttonVariants } from \"./button\";\n\nfunction Questionnaire({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Root>) {\n return (\n <QuestionnairePrimitive.Root\n data-slot=\"questionnaire\"\n className={cn(\"flex w-full min-w-0 flex-col gap-4\", className)}\n {...props}\n />\n );\n}\n\nfunction QuestionnaireProgress({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Progress>) {\n return (\n <QuestionnairePrimitive.Progress\n data-slot=\"questionnaire-progress\"\n className={cn(\n \"min-h-lh w-fit min-w-[14ch] font-medium text-muted-foreground text-xs tabular-nums\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction QuestionnaireItem({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Item>) {\n return (\n <QuestionnairePrimitive.Item\n data-slot=\"questionnaire-item\"\n className={cn(\"flex min-w-0 flex-col gap-4 border-0 p-0 outline-none\", className)}\n {...props}\n />\n );\n}\n\nfunction QuestionnaireTitle({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Title>) {\n return (\n <QuestionnairePrimitive.Title\n data-slot=\"questionnaire-title\"\n className={cn(\n \"text-pretty font-heading font-medium text-base leading-snug [&:not(:has(~[data-slot=questionnaire-description]))]:mb-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction QuestionnaireDescription({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Description>) {\n return (\n <QuestionnairePrimitive.Description\n data-slot=\"questionnaire-description\"\n className={cn(\"text-pretty text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n}\n\nfunction QuestionnaireChoices({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Choices>) {\n return (\n <QuestionnairePrimitive.Choices\n data-slot=\"questionnaire-choices\"\n className={cn(\"group/questionnaire-choices grid min-w-0 gap-2\", className)}\n {...props}\n />\n );\n}\n\nfunction QuestionnaireChoice({\n children,\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Choice>) {\n return (\n <QuestionnairePrimitive.Choice\n data-slot=\"questionnaire-choice\"\n className={cn(\n \"group/questionnaire-choice relative flex min-h-11 cursor-pointer select-none items-start gap-2.5 rounded-lg border border-input bg-transparent px-3 py-2.5 text-start text-sm outline-none transition-colors hover:bg-muted/50 has-[>input:focus-visible]:border-ring has-[>input:focus-visible]:ring-3 has-[>input:focus-visible]:ring-ring/50 data-checked:border-primary/40 data-invalid:border-destructive data-checked:bg-muted dark:bg-input/20 dark:data-checked:bg-muted\",\n \"data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n <QuestionnairePrimitive.ChoiceInput\n data-slot=\"questionnaire-choice-input\"\n className=\"absolute inset-0 z-10 size-full cursor-pointer opacity-0\"\n />\n <span\n aria-hidden=\"true\"\n data-slot=\"questionnaire-choice-indicator\"\n className=\"pointer-events-none relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input group-data-[type=radio]/questionnaire-choice:rounded-full group-data-checked/questionnaire-choice:border-primary group-data-checked/questionnaire-choice:bg-primary group-data-checked/questionnaire-choice:text-primary-foreground dark:bg-input/30 dark:group-data-checked/questionnaire-choice:bg-primary\"\n >\n <span\n data-slot=\"questionnaire-choice-indicator-dot\"\n className=\"hidden size-2 rounded-full bg-primary-foreground group-data-checked/questionnaire-choice:block group-data-[type=checkbox]/questionnaire-choice:hidden\"\n />\n <CheckIcon\n data-slot=\"questionnaire-choice-indicator-check\"\n className=\"hidden size-3.5 group-data-checked/questionnaire-choice:block group-data-[type=radio]/questionnaire-choice:hidden\"\n />\n </span>\n <QuestionnairePrimitive.ChoiceLabel\n data-slot=\"questionnaire-choice-label\"\n className=\"flex min-w-0 flex-1 flex-col gap-0.5 leading-snug\"\n >\n {children}\n </QuestionnairePrimitive.ChoiceLabel>\n <QuestionnairePrimitive.ChoiceShortcut\n data-slot=\"questionnaire-choice-shortcut\"\n className=\"pointer-events-none ms-auto mt-0.5 hidden size-5 shrink-0 items-center justify-center rounded-md border border-input bg-background font-medium font-mono text-[0.625rem] text-muted-foreground leading-none group-data-shortcut/questionnaire-choice:inline-flex\"\n />\n </QuestionnairePrimitive.Choice>\n );\n}\n\nfunction QuestionnaireInput({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Input>) {\n return (\n <div\n data-slot=\"questionnaire-input-wrapper\"\n className=\"group/questionnaire-input relative w-full min-w-0\"\n >\n <QuestionnairePrimitive.Input\n data-slot=\"questionnaire-input\"\n className={cn(\n \"h-8 min-h-11 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base outline-none transition-[color,box-shadow,background-color] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 sm:min-h-0 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:disabled:bg-input/80\",\n \"selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground\",\n className,\n )}\n {...props}\n />\n </div>\n );\n}\n\nfunction QuestionnaireError({\n className,\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Error>) {\n return (\n <QuestionnairePrimitive.Error\n data-slot=\"questionnaire-error\"\n className={cn(\"text-destructive text-sm\", className)}\n {...props}\n />\n );\n}\n\nfunction QuestionnaireActions({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"questionnaire-actions\"\n className={cn(\n \"grid min-h-11 w-full grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:min-h-8\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction QuestionnairePrevious({\n children,\n className,\n size = \"default\",\n variant = \"outline\",\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Previous> &\n Pick<React.ComponentProps<typeof Button>, \"size\" | \"variant\">) {\n return (\n <QuestionnairePrimitive.Previous\n data-slot=\"questionnaire-previous\"\n data-size={size}\n data-variant={variant}\n className={cn(\n buttonVariants({ size, variant }),\n \"col-start-1 row-start-1 min-h-11 justify-self-start sm:min-h-0\",\n className,\n )}\n {...props}\n >\n {children ?? \"Previous\"}\n </QuestionnairePrimitive.Previous>\n );\n}\n\nfunction QuestionnaireSkip({\n children,\n className,\n size = \"default\",\n variant = \"outline\",\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Skip> &\n Pick<React.ComponentProps<typeof Button>, \"size\" | \"variant\">) {\n return (\n <QuestionnairePrimitive.Skip\n data-slot=\"questionnaire-skip\"\n data-size={size}\n data-variant={variant}\n className={cn(\n buttonVariants({ size, variant }),\n \"col-start-2 row-start-1 min-h-11 justify-self-end sm:min-h-0\",\n className,\n )}\n {...props}\n >\n {children ?? \"Skip\"}\n </QuestionnairePrimitive.Skip>\n );\n}\n\nfunction QuestionnaireNext({\n children,\n className,\n size = \"default\",\n variant = \"default\",\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Next> &\n Pick<React.ComponentProps<typeof Button>, \"size\" | \"variant\">) {\n return (\n <QuestionnairePrimitive.Next\n data-slot=\"questionnaire-next\"\n data-size={size}\n data-variant={variant}\n className={cn(\n buttonVariants({ size, variant }),\n \"col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0\",\n className,\n )}\n {...props}\n >\n {children ?? \"Next\"}\n </QuestionnairePrimitive.Next>\n );\n}\n\nfunction QuestionnaireSubmit({\n children,\n className,\n size = \"default\",\n variant = \"default\",\n ...props\n}: React.ComponentProps<typeof QuestionnairePrimitive.Submit> &\n Pick<React.ComponentProps<typeof Button>, \"size\" | \"variant\">) {\n return (\n <QuestionnairePrimitive.Submit\n data-slot=\"questionnaire-submit\"\n data-size={size}\n data-variant={variant}\n className={cn(\n buttonVariants({ size, variant }),\n \"col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0\",\n className,\n )}\n {...props}\n >\n {children ?? \"Submit\"}\n </QuestionnairePrimitive.Submit>\n );\n}\n\nexport {\n Questionnaire,\n QuestionnaireActions,\n QuestionnaireChoice,\n QuestionnaireChoices,\n QuestionnaireDescription,\n QuestionnaireError,\n QuestionnaireInput,\n QuestionnaireItem,\n QuestionnaireNext,\n QuestionnairePrevious,\n QuestionnaireProgress,\n QuestionnaireSkip,\n QuestionnaireSubmit,\n QuestionnaireTitle,\n};\n"],"mappings":";;;;;;;AASA,SAAS,cAAc,EACrB,WACA,GAAG,SACwD;CAC3D,OACE,oBAACA,gBAAuB,MAAxB;EACE,aAAU;EACV,WAAW,GAAG,sCAAsC,SAAS;EAC7D,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,sBAAsB,EAC7B,WACA,GAAG,SAC4D;CAC/D,OACE,oBAACA,gBAAuB,UAAxB;EACE,aAAU;EACV,WAAW,GACT,sFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,kBAAkB,EACzB,WACA,GAAG,SACwD;CAC3D,OACE,oBA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,eAAe;GAAE;GAAM;EAAQ,CAAC,GAChC,gEACA,SACF;EACA,GAAI;EAEH,UAAA,YAAY;CACgB,CAAA;AAEnC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "@kumix/utils";
|
|
3
|
-
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
|
4
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
|
5
5
|
import { Select as Select$1 } from "@base-ui/react/select";
|
|
6
6
|
//#region src/components/ui/select.tsx
|
|
7
7
|
const Select = Select$1.Root;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Button } from "./button.js";
|
|
3
3
|
import { cn } from "@kumix/utils";
|
|
4
|
-
import { XIcon } from "lucide-react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { XIcon } from "lucide-react";
|
|
6
6
|
import { Dialog } from "@base-ui/react/dialog";
|
|
7
7
|
//#region src/components/ui/sheet.tsx
|
|
8
8
|
function Sheet({ ...props }) {
|
|
@@ -41,7 +41,7 @@ declare function SidebarGroupContent({ className, ...props }: React$1.ComponentP
|
|
|
41
41
|
declare function SidebarMenu({ className, ...props }: React$1.ComponentProps<"ul">): React$1.JSX.Element;
|
|
42
42
|
declare function SidebarMenuItem({ className, ...props }: React$1.ComponentProps<"li">): React$1.JSX.Element;
|
|
43
43
|
declare const sidebarMenuButtonVariants: (props?: ({
|
|
44
|
-
variant?: "
|
|
44
|
+
variant?: "default" | "outline" | null | undefined;
|
|
45
45
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
46
46
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
47
47
|
declare function SidebarMenuButton({ render, isActive, variant, size, tooltip, className, ...props }: useRender.ComponentProps<"button"> & React$1.ComponentProps<"button"> & {
|
|
@@ -8,9 +8,9 @@ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "
|
|
|
8
8
|
import { Skeleton } from "./skeleton.js";
|
|
9
9
|
import * as React$1 from "react";
|
|
10
10
|
import { cn } from "@kumix/utils";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { PanelLeftIcon } from "lucide-react";
|
|
12
13
|
import { cva } from "class-variance-authority";
|
|
13
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
15
15
|
import { useRender } from "@base-ui/react/use-render";
|
|
16
16
|
//#region src/components/ui/sidebar.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "@kumix/utils";
|
|
3
|
-
import { Loader2Icon } from "lucide-react";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Loader2Icon } from "lucide-react";
|
|
5
5
|
//#region src/components/ui/spinner.tsx
|
|
6
6
|
function Spinner({ className, ...props }) {
|
|
7
7
|
return /* @__PURE__ */ jsx(Loader2Icon, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "@kumix/utils";
|
|
3
|
-
import { cva } from "class-variance-authority";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
5
|
import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
|
|
6
6
|
//#region src/components/ui/tabs.tsx
|
|
7
7
|
function Tabs({ className, orientation = "horizontal", ...props }) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Button } from "./button.js";
|
|
3
3
|
import { cn } from "@kumix/utils";
|
|
4
|
-
import { CircleCheckIcon, InfoIcon, Loader2Icon, OctagonXIcon, TriangleAlertIcon, XIcon } from "lucide-react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { CircleCheckIcon, InfoIcon, Loader2Icon, OctagonXIcon, TriangleAlertIcon, XIcon } from "lucide-react";
|
|
6
6
|
import { Toast as Toast$1 } from "@base-ui/react/toast";
|
|
7
7
|
//#region src/components/ui/toast.tsx
|
|
8
8
|
const toast = Toast$1.createToastManager();
|
|
@@ -2,7 +2,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
3
3
|
//#region src/components/ui/toggle.d.ts
|
|
4
4
|
declare const toggleVariants: (props?: ({
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "default" | "outline" | null | undefined;
|
|
6
6
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
declare function Toggle({ className, variant, size, ...props }: Toggle$1.Props & VariantProps<typeof toggleVariants>): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "@kumix/utils";
|
|
3
|
-
import { cva } from "class-variance-authority";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
5
|
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
6
6
|
//#region src/components/ui/toggle.tsx
|
|
7
7
|
const toggleVariants = cva("group/toggle inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-lg font-medium text-sm outline-none transition-all hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-pressed:bg-muted aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SPRING_PRESS } from "./lib/ease.js";
|
|
2
|
+
import { MorphPopover, MorphPopoverContent } from "./components/motion/popover-morph.js";
|
|
2
3
|
import { Tooltip } from "./components/motion/tooltip.js";
|
|
3
4
|
import { Checkbox } from "./components/motion/checkbox.js";
|
|
4
|
-
import { MorphPopover, MorphPopoverContent } from "./components/motion/popover-morph.js";
|
|
5
5
|
import { IconButton } from "./components/motion/availability-scheduler/icon-button.js";
|
|
6
6
|
import { useState } from "react";
|
|
7
|
-
import { Check, Copy } from "lucide-react";
|
|
8
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
8
|
import { AnimatePresence, motion } from "motion/react";
|
|
9
|
+
import { Check, Copy } from "lucide-react";
|
|
10
10
|
//#region src/components/motion/availability-scheduler/types.ts
|
|
11
11
|
const WEEKDAYS = [
|
|
12
12
|
{
|
|
@@ -198,4 +198,4 @@ function CopyMenu({ fromLabel, reduce, onApply }) {
|
|
|
198
198
|
//#endregion
|
|
199
199
|
export { toMinutes as a, defaultWeek as i, WEEKDAYS as n, toValue as o, buildOptions as r, CopyMenu as t };
|
|
200
200
|
|
|
201
|
-
//# sourceMappingURL=copy-menu-
|
|
201
|
+
//# sourceMappingURL=copy-menu-Bk5GP9Gp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-menu-BJ-MXnkN.js","names":[],"sources":["../src/components/motion/availability-scheduler/types.ts","../src/components/motion/availability-scheduler/copy-menu.tsx"],"sourcesContent":["export type DayKey = \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\" | \"sun\";\n\nexport type TimeRange = { id: string; start: string; end: string };\nexport type DayAvailability = { enabled: boolean; ranges: TimeRange[] };\nexport type WeekAvailability = Record<DayKey, DayAvailability>;\nexport type TimeOption = { value: string; label: string };\n\nexport const WEEKDAYS: { key: DayKey; label: string }[] = [\n { key: \"mon\", label: \"Monday\" },\n { key: \"tue\", label: \"Tuesday\" },\n { key: \"wed\", label: \"Wednesday\" },\n { key: \"thu\", label: \"Thursday\" },\n { key: \"fri\", label: \"Friday\" },\n { key: \"sat\", label: \"Saturday\" },\n { key: \"sun\", label: \"Sunday\" },\n];\n\n// ─── time helpers ────────────────────────────────────────────────────────────\n\nexport const toMinutes = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n return h * 60 + m;\n};\n\nexport const toValue = (mins: number) => {\n const clamped = Math.max(0, Math.min(24 * 60 - 1, mins));\n const h = Math.floor(clamped / 60);\n const m = clamped % 60;\n return `${String(h).padStart(2, \"0\")}:${String(m).padStart(2, \"0\")}`;\n};\n\nexport const label12 = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n const ap = h < 12 ? \"AM\" : \"PM\";\n const h12 = h % 12 === 0 ? 12 : h % 12;\n return `${h12}:${String(m).padStart(2, \"0\")} ${ap}`;\n};\n\nexport function buildOptions(step: number): TimeOption[] {\n const out: TimeOption[] = [];\n for (let m = 0; m < 24 * 60; m += step) {\n const value = toValue(m);\n out.push({ value, label: label12(value) });\n }\n return out;\n}\n\n// Default: Mon–Fri 9–5, weekend off. Fixed ids so SSR and first client render\n// agree (new ranges get counter ids afterwards).\nexport function defaultWeek(): WeekAvailability {\n const workday = (day: DayKey): DayAvailability => ({\n enabled: true,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n const off = (day: DayKey): DayAvailability => ({\n enabled: false,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n return {\n mon: workday(\"mon\"),\n tue: workday(\"tue\"),\n wed: workday(\"wed\"),\n thu: workday(\"thu\"),\n fri: workday(\"fri\"),\n sat: off(\"sat\"),\n sun: off(\"sun\"),\n };\n}\n","\"use client\";\n\nimport { useState } from \"react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { AnimatePresence, motion } from \"motion/react\";\n\nimport { SPRING_PRESS } from \"../../../lib/ease\";\nimport { Checkbox } from \"../checkbox\";\nimport { MorphPopover, MorphPopoverContent } from \"../popover-morph\";\nimport { Tooltip } from \"../tooltip\";\nimport { IconButton } from \"./icon-button\";\nimport { type DayKey, WEEKDAYS } from \"./types\";\n\n// Copy this day's hours to other days: a morph popover with a day picker.\nexport function CopyMenu({\n fromLabel,\n reduce,\n onApply,\n}: {\n fromLabel: string;\n reduce: boolean;\n onApply: (targets: DayKey[]) => void;\n}) {\n const [open, setOpen] = useState(false);\n const [copied, setCopied] = useState(false);\n const [picked, setPicked] = useState<Set<DayKey>>(new Set());\n const others = WEEKDAYS.filter((d) => d.label !== fromLabel);\n\n const toggle = (k: DayKey) =>\n setPicked((prev) => {\n const next = new Set(prev);\n if (next.has(k)) next.delete(k);\n else next.add(k);\n return next;\n });\n\n const apply = (targets: DayKey[]) => {\n if (!targets.length) return;\n onApply(targets);\n setOpen(false);\n setPicked(new Set());\n setCopied(true);\n window.setTimeout(() => setCopied(false), 1200);\n };\n\n return (\n <MorphPopover open={open} onOpenChange={setOpen}>\n <Tooltip content=\"Copy times\">\n <IconButton\n label={`Copy ${fromLabel} hours to other days`}\n reduce={reduce}\n expanded={open}\n onClick={() => setOpen(!open)}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {copied ? (\n <motion.span\n key=\"done\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n className=\"text-foreground\"\n >\n <Check className=\"h-4 w-4\" />\n </motion.span>\n ) : (\n <motion.span\n key=\"copy\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n >\n <Copy className=\"h-4 w-4\" />\n </motion.span>\n )}\n </AnimatePresence>\n </IconButton>\n </Tooltip>\n\n <MorphPopoverContent align=\"end\" className=\"w-52 p-2\">\n <p className=\"px-2 py-1.5 font-medium text-muted-foreground text-xs\">Copy times to</p>\n <div className=\"flex flex-col\">\n {others.map((d) => (\n <Checkbox\n key={d.key}\n checked={picked.has(d.key)}\n onCheckedChange={() => toggle(d.key)}\n label={d.label}\n className=\"w-full flex-row-reverse justify-between rounded-lg px-2 py-1.5 transition-colors hover:bg-muted [&_button[data-state=unchecked]]:border-border-strong [&_button]:size-4 [&_button]:rounded-[5px] [&_button]:border\"\n />\n ))}\n </div>\n <div className=\"mt-1 flex items-center gap-2 border-border border-t px-1 pt-2\">\n <button\n type=\"button\"\n onClick={() => apply(others.map((d) => d.key))}\n className=\"flex-1 rounded-lg px-2 py-1.5 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted\"\n >\n Every day\n </button>\n <button\n type=\"button\"\n onClick={() => apply([...picked])}\n disabled={picked.size === 0}\n className=\"flex-1 rounded-lg bg-primary px-2 py-1.5 font-semibold text-primary-foreground text-xs outline-none transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40\"\n >\n Apply\n </button>\n </div>\n </MorphPopoverContent>\n </MorphPopover>\n );\n}\n"],"mappings":";;;;;;;;;;AAOA,MAAa,WAA6C;CACxD;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAU;CAC/B;EAAE,KAAK;EAAO,OAAO;CAAY;CACjC;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;AAChC;AAIA,MAAa,aAAa,MAAc;CACtC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtC,OAAO,IAAI,KAAK;AAClB;AAEA,MAAa,WAAW,SAAiB;CACvC,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,MAAa,IAAI,CAAC;CACvD,MAAM,IAAI,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AG,OAAO;MAAI;MACzD,YAAY;MAEZ,UAAA,oBAAC,MAAD,EAAM,WAAU,UAAW,CAAA;KAChB,GAPP,MAOO;IAEA,CAAA;GACP,CAAA;EACL,CAAA,GAET,qBAAC,qBAAD;GAAqB,OAAM;GAAM,WAAU;GAA3C,UAAA;IACE,oBAAC,KAAD;KAAG,WAAU;KAAwD,UAAA;IAAgB,CAAA;IACrF,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,OAAO,KAAK,MACX,oBAAC,UAAD;MAEE,SAAS,OAAO,IAAI,EAAE,GAAG;MACzB,uBAAuB,OAAO,EAAE,GAAG;MACnC,OAAO,EAAE;MACT,WAAU;KACX,GALM,EAAE,GAKR,CACF;IACE,CAAA;IACL,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,OAAO,KAAK,MAAM,EAAE,GAAG,CAAC;MAC7C,WAAU;MACX,UAAA;KAEO,CAAA,GACR,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,CAAC,GAAG,MAAM,CAAC;MAChC,UAAU,OAAO,SAAS;MAC1B,WAAU;MACX,UAAA;KAEO,CAAA,CACL;;GACc;EACT,CAAA,CAAA;;AAElB"}
|
|
1
|
+
{"version":3,"file":"copy-menu-Bk5GP9Gp.js","names":[],"sources":["../src/components/motion/availability-scheduler/types.ts","../src/components/motion/availability-scheduler/copy-menu.tsx"],"sourcesContent":["export type DayKey = \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\" | \"sun\";\n\nexport type TimeRange = { id: string; start: string; end: string };\nexport type DayAvailability = { enabled: boolean; ranges: TimeRange[] };\nexport type WeekAvailability = Record<DayKey, DayAvailability>;\nexport type TimeOption = { value: string; label: string };\n\nexport const WEEKDAYS: { key: DayKey; label: string }[] = [\n { key: \"mon\", label: \"Monday\" },\n { key: \"tue\", label: \"Tuesday\" },\n { key: \"wed\", label: \"Wednesday\" },\n { key: \"thu\", label: \"Thursday\" },\n { key: \"fri\", label: \"Friday\" },\n { key: \"sat\", label: \"Saturday\" },\n { key: \"sun\", label: \"Sunday\" },\n];\n\n// ─── time helpers ────────────────────────────────────────────────────────────\n\nexport const toMinutes = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n return h * 60 + m;\n};\n\nexport const toValue = (mins: number) => {\n const clamped = Math.max(0, Math.min(24 * 60 - 1, mins));\n const h = Math.floor(clamped / 60);\n const m = clamped % 60;\n return `${String(h).padStart(2, \"0\")}:${String(m).padStart(2, \"0\")}`;\n};\n\nexport const label12 = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n const ap = h < 12 ? \"AM\" : \"PM\";\n const h12 = h % 12 === 0 ? 12 : h % 12;\n return `${h12}:${String(m).padStart(2, \"0\")} ${ap}`;\n};\n\nexport function buildOptions(step: number): TimeOption[] {\n const out: TimeOption[] = [];\n for (let m = 0; m < 24 * 60; m += step) {\n const value = toValue(m);\n out.push({ value, label: label12(value) });\n }\n return out;\n}\n\n// Default: Mon–Fri 9–5, weekend off. Fixed ids so SSR and first client render\n// agree (new ranges get counter ids afterwards).\nexport function defaultWeek(): WeekAvailability {\n const workday = (day: DayKey): DayAvailability => ({\n enabled: true,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n const off = (day: DayKey): DayAvailability => ({\n enabled: false,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n return {\n mon: workday(\"mon\"),\n tue: workday(\"tue\"),\n wed: workday(\"wed\"),\n thu: workday(\"thu\"),\n fri: workday(\"fri\"),\n sat: off(\"sat\"),\n sun: off(\"sun\"),\n };\n}\n","\"use client\";\n\nimport { useState } from \"react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { AnimatePresence, motion } from \"motion/react\";\n\nimport { SPRING_PRESS } from \"../../../lib/ease\";\nimport { Checkbox } from \"../checkbox\";\nimport { MorphPopover, MorphPopoverContent } from \"../popover-morph\";\nimport { Tooltip } from \"../tooltip\";\nimport { IconButton } from \"./icon-button\";\nimport { type DayKey, WEEKDAYS } from \"./types\";\n\n// Copy this day's hours to other days: a morph popover with a day picker.\nexport function CopyMenu({\n fromLabel,\n reduce,\n onApply,\n}: {\n fromLabel: string;\n reduce: boolean;\n onApply: (targets: DayKey[]) => void;\n}) {\n const [open, setOpen] = useState(false);\n const [copied, setCopied] = useState(false);\n const [picked, setPicked] = useState<Set<DayKey>>(new Set());\n const others = WEEKDAYS.filter((d) => d.label !== fromLabel);\n\n const toggle = (k: DayKey) =>\n setPicked((prev) => {\n const next = new Set(prev);\n if (next.has(k)) next.delete(k);\n else next.add(k);\n return next;\n });\n\n const apply = (targets: DayKey[]) => {\n if (!targets.length) return;\n onApply(targets);\n setOpen(false);\n setPicked(new Set());\n setCopied(true);\n window.setTimeout(() => setCopied(false), 1200);\n };\n\n return (\n <MorphPopover open={open} onOpenChange={setOpen}>\n <Tooltip content=\"Copy times\">\n <IconButton\n label={`Copy ${fromLabel} hours to other days`}\n reduce={reduce}\n expanded={open}\n onClick={() => setOpen(!open)}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {copied ? (\n <motion.span\n key=\"done\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n className=\"text-foreground\"\n >\n <Check className=\"h-4 w-4\" />\n </motion.span>\n ) : (\n <motion.span\n key=\"copy\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n >\n <Copy className=\"h-4 w-4\" />\n </motion.span>\n )}\n </AnimatePresence>\n </IconButton>\n </Tooltip>\n\n <MorphPopoverContent align=\"end\" className=\"w-52 p-2\">\n <p className=\"px-2 py-1.5 font-medium text-muted-foreground text-xs\">Copy times to</p>\n <div className=\"flex flex-col\">\n {others.map((d) => (\n <Checkbox\n key={d.key}\n checked={picked.has(d.key)}\n onCheckedChange={() => toggle(d.key)}\n label={d.label}\n className=\"w-full flex-row-reverse justify-between rounded-lg px-2 py-1.5 transition-colors hover:bg-muted [&_button[data-state=unchecked]]:border-border-strong [&_button]:size-4 [&_button]:rounded-[5px] [&_button]:border\"\n />\n ))}\n </div>\n <div className=\"mt-1 flex items-center gap-2 border-border border-t px-1 pt-2\">\n <button\n type=\"button\"\n onClick={() => apply(others.map((d) => d.key))}\n className=\"flex-1 rounded-lg px-2 py-1.5 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted\"\n >\n Every day\n </button>\n <button\n type=\"button\"\n onClick={() => apply([...picked])}\n disabled={picked.size === 0}\n className=\"flex-1 rounded-lg bg-primary px-2 py-1.5 font-semibold text-primary-foreground text-xs outline-none transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40\"\n >\n Apply\n </button>\n </div>\n </MorphPopoverContent>\n </MorphPopover>\n );\n}\n"],"mappings":";;;;;;;;;;AAOA,MAAa,WAA6C;CACxD;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAU;CAC/B;EAAE,KAAK;EAAO,OAAO;CAAY;CACjC;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;AAChC;AAIA,MAAa,aAAa,MAAc;CACtC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtC,OAAO,IAAI,KAAK;AAClB;AAEA,MAAa,WAAW,SAAiB;CACvC,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,MAAa,IAAI,CAAC;CACvD,M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E,SAAS;OAAG,OAAO;MAAI;MACzD,YAAY;MAEZ,UAAA,oBAAC,MAAD,EAAM,WAAU,UAAW,CAAA;KAChB,GAPP,MAOO;IAEA,CAAA;GACP,CAAA;EACL,CAAA,GAET,qBAAC,qBAAD;GAAqB,OAAM;GAAM,WAAU;GAA3C,UAAA;IACE,oBAAC,KAAD;KAAG,WAAU;KAAwD,UAAA;IAAgB,CAAA;IACrF,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,OAAO,KAAK,MACX,oBAAC,UAAD;MAEE,SAAS,OAAO,IAAI,EAAE,GAAG;MACzB,uBAAuB,OAAO,EAAE,GAAG;MACnC,OAAO,EAAE;MACT,WAAU;KACX,GALM,EAAE,GAKR,CACF;IACE,CAAA;IACL,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,OAAO,KAAK,MAAM,EAAE,GAAG,CAAC;MAC7C,WAAU;MACX,UAAA;KAEO,CAAA,GACR,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,CAAC,GAAG,MAAM,CAAC;MAChC,UAAU,OAAO,SAAS;MAC1B,WAAU;MACX,UAAA;KAEO,CAAA,CACL;;GACc;EACT,CAAA,CAAA;;AAElB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-body-classes.d.ts","names":[],"sources":["../../src/hooks/use-body-classes.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-body-classes.d.ts","names":[],"sources":["../../src/hooks/use-body-classes.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;cAuBa,iBAAkB"}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
//#region src/hooks/use-body-classes.ts
|
|
4
4
|
/**
|
|
5
|
-
* Body class management hook for React components.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
5
|
* Adds classes to `document.body` while the component is mounted.
|
|
9
6
|
* Shared classes are reference-counted, so one component unmounting does not
|
|
10
7
|
* remove a class that another mounted component still owns.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-body-classes.js","names":[],"sources":["../../src/hooks/use-body-classes.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-body-classes.js","names":[],"sources":["../../src/hooks/use-body-classes.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\n\n/**\n * Adds classes to `document.body` while the component is mounted.\n * Shared classes are reference-counted, so one component unmounting does not\n * remove a class that another mounted component still owns.\n *\n * @param className - Space-separated string of CSS class names to apply to body\n *\n * @example\n * ```tsx\n * // Single class\n * useBodyClasses('dark-theme');\n *\n * // Multiple classes\n * useBodyClasses('modal-open overflow-hidden');\n *\n * // Conditional classes\n * useBodyClasses(isModalOpen ? 'modal-open' : '');\n * ```\n */\nexport const useBodyClasses = (className: string) => {\n useEffect(() => {\n if (!className.trim()) return;\n\n const classList = className.split(/\\s+/).filter(Boolean);\n\n classList.forEach((cls) => {\n const count = bodyClassCounts.get(cls) ?? 0;\n bodyClassCounts.set(cls, count + 1);\n if (count === 0) {\n document.body.classList.add(cls);\n }\n });\n\n return () => {\n classList.forEach((cls) => {\n const nextCount = (bodyClassCounts.get(cls) ?? 1) - 1;\n if (nextCount <= 0) {\n bodyClassCounts.delete(cls);\n document.body.classList.remove(cls);\n return;\n }\n bodyClassCounts.set(cls, nextCount);\n });\n };\n }, [className]);\n};\n\nconst bodyClassCounts = new Map<string, number>();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAAkB,cAAsB;CACnD,gBAAgB;EACd,IAAI,CAAC,UAAU,KAAK,GAAG;EAEvB,MAAM,YAAY,UAAU,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;EAEvD,UAAU,SAAS,QAAQ;GACzB,MAAM,QAAQ,gBAAgB,IAAI,GAAG,KAAK;GAC1C,gBAAgB,IAAI,KAAK,QAAQ,CAAC;GAClC,IAAI,UAAU,GACZ,SAAS,KAAK,UAAU,IAAI,GAAG;EAEnC,CAAC;EAED,aAAa;GACX,UAAU,SAAS,QAAQ;IACzB,MAAM,aAAa,gBAAgB,IAAI,GAAG,KAAK,KAAK;IACpD,IAAI,aAAa,GAAG;KAClB,gBAAgB,OAAO,GAAG;KAC1B,SAAS,KAAK,UAAU,OAAO,GAAG;KAClC;IACF;IACA,gBAAgB,IAAI,KAAK,SAAS;GACpC,CAAC;EACH;CACF,GAAG,CAAC,SAAS,CAAC;AAChB;AAEA,MAAM,kCAAkB,IAAI,IAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-copy-to-clipboard.d.ts","names":[],"sources":["../../src/hooks/use-copy-to-clipboard.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-copy-to-clipboard.d.ts","names":[],"sources":["../../src/hooks/use-copy-to-clipboard.ts"],"mappings":";;;;UASU;;EAER;;EAEA;;;;;;;;;;;;;;;;;;;;;;;iBAwBc,qBAAqB,SAAgB,WAAU;;;;EAW7C,OAAA,kBAAM"}
|
|
@@ -3,9 +3,6 @@ import * as React$1 from "react";
|
|
|
3
3
|
import { isDevelopment } from "@kumix/utils";
|
|
4
4
|
//#region src/hooks/use-copy-to-clipboard.ts
|
|
5
5
|
/**
|
|
6
|
-
* Clipboard copy functionality hook for React components.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
6
|
* Copies text to the clipboard and exposes temporary copied state.
|
|
10
7
|
*
|
|
11
8
|
* @param options - Configuration options for the hook
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-copy-to-clipboard.js","names":["React"],"sources":["../../src/hooks/use-copy-to-clipboard.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-copy-to-clipboard.js","names":["React"],"sources":["../../src/hooks/use-copy-to-clipboard.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { isDevelopment } from \"@kumix/utils\";\n\n/**\n * Configuration options for the copy to clipboard hook\n */\ninterface UseCopyToClipboardOptions {\n /** Duration in milliseconds to show the copied state (default: 2000ms) */\n timeout?: number;\n /** Callback function executed after successful copy operation */\n onCopy?: () => void;\n}\n\n/**\n * Copies text to the clipboard and exposes temporary copied state.\n *\n * @param options - Configuration options for the hook\n * @returns Object containing copied state and an async copy function. The copy\n * function resolves to `true` when text is copied and `false` otherwise.\n *\n * @example\n * ```tsx\n * const { copied, copy } = useCopyToClipboard({\n * timeout: 3000,\n * onCopy: () => toast.success('Copied to clipboard!')\n * });\n *\n * return (\n * <button onClick={() => copy('Hello World')}>\n * {copied ? 'Copied!' : 'Copy Text'}\n * </button>\n * );\n * ```\n */\nexport function useCopyToClipboard({ timeout = 2000, onCopy }: UseCopyToClipboardOptions = {}) {\n const [copied, setCopied] = React.useState(false);\n const timerRef = React.useRef<ReturnType<typeof setTimeout>>(null);\n\n React.useEffect(() => {\n return () => {\n if (timerRef.current) clearTimeout(timerRef.current);\n };\n }, []);\n\n const copy = React.useCallback(\n async (value: string) => {\n if (typeof window === \"undefined\" || !navigator.clipboard?.writeText) {\n if (isDevelopment) {\n console.warn(\"Clipboard API not supported in this environment\");\n }\n return false;\n }\n\n if (!value) {\n if (isDevelopment) {\n console.warn(\"Cannot copy empty value to clipboard\");\n }\n return false;\n }\n\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n onCopy?.();\n\n if (timerRef.current) clearTimeout(timerRef.current);\n timerRef.current = setTimeout(() => {\n setCopied(false);\n }, timeout);\n return true;\n } catch (error) {\n if (isDevelopment) {\n console.error(\"Failed to copy text to clipboard:\", error);\n }\n return false;\n }\n },\n [timeout, onCopy],\n );\n\n return {\n /** Whether text was recently copied (true for timeout duration) */\n copied,\n /** Function to copy text to clipboard */\n copy,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,mBAAmB,EAAE,UAAU,KAAM,WAAsC,CAAC,GAAG;CAC7F,MAAM,CAAC,QAAQ,aAAaA,QAAM,SAAS,KAAK;CAChD,MAAM,WAAWA,QAAM,OAAsC,IAAI;CAEjE,QAAM,gBAAgB;EACpB,aAAa;GACX,IAAI,SAAS,SAAS,aAAa,SAAS,OAAO;EACrD;CACF,GAAG,CAAC,CAAC;CAsCL,OAAO;;EAEL;;EAEA,MAxCWA,QAAM,YACjB,OAAO,UAAkB;GACvB,IAAI,OAAO,WAAW,eAAe,CAAC,UAAU,WAAW,WAAW;IACpE,IAAI,eACF,QAAQ,KAAK,iDAAiD;IAEhE,OAAO;GACT;GAEA,IAAI,CAAC,OAAO;IACV,IAAI,eACF,QAAQ,KAAK,sCAAsC;IAErD,OAAO;GACT;GAEA,IAAI;IACF,MAAM,UAAU,UAAU,UAAU,KAAK;IACzC,UAAU,IAAI;IACd,SAAS;IAET,IAAI,SAAS,SAAS,aAAa,SAAS,OAAO;IACnD,SAAS,UAAU,iBAAiB;KAClC,UAAU,KAAK;IACjB,GAAG,OAAO;IACV,OAAO;GACT,SAAS,OAAO;IACd,IAAI,eACF,QAAQ,MAAM,qCAAqC,KAAK;IAE1D,OAAO;GACT;EACF,GACA,CAAC,SAAS,MAAM,CAOb;CACL;AACF"}
|
|
@@ -166,10 +166,12 @@ const useFileUpload = (options = {}) => {
|
|
|
166
166
|
isDragging: false
|
|
167
167
|
}));
|
|
168
168
|
if (inputRef.current?.disabled) return;
|
|
169
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
170
|
+
if (!multiple) {
|
|
171
|
+
const file = e.dataTransfer.files[0];
|
|
172
|
+
addFiles([file]);
|
|
173
|
+
} else addFiles(e.dataTransfer.files);
|
|
174
|
+
}
|
|
173
175
|
}, [addFiles, multiple]);
|
|
174
176
|
const handleFileChange = useCallback((e) => {
|
|
175
177
|
if (e.target.files && e.target.files.length > 0) addFiles(e.target.files);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-file-upload.js","names":[],"sources":["../../src/hooks/use-file-upload.ts"],"sourcesContent":["\"use client\";\n\nimport type React from \"react\";\nimport {\n type ChangeEvent,\n type DragEvent,\n type InputHTMLAttributes,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nexport type FileMetadata = {\n name: string;\n size: number;\n type: string;\n url: string;\n id: string;\n};\n\nexport type FileWithPreview = {\n file: File | FileMetadata;\n id: string;\n preview?: string;\n};\n\nexport type FileUploadOptions = {\n maxFiles?: number; // Only used when multiple is true, defaults to Infinity\n maxSize?: number; // in bytes\n accept?: string;\n multiple?: boolean; // Defaults to false\n initialFiles?: FileMetadata[];\n onFilesChange?: (files: FileWithPreview[]) => void; // Callback when files change\n onFilesAdded?: (addedFiles: FileWithPreview[]) => void; // Callback when new files are added\n onError?: (errors: string[]) => void;\n};\n\nexport type FileUploadState = {\n files: FileWithPreview[];\n isDragging: boolean;\n errors: string[];\n};\n\nexport type FileUploadActions = {\n addFiles: (files: FileList | File[]) => void;\n removeFile: (id: string) => void;\n clearFiles: () => void;\n clearErrors: () => void;\n handleDragEnter: (e: DragEvent<HTMLElement>) => void;\n handleDragLeave: (e: DragEvent<HTMLElement>) => void;\n handleDragOver: (e: DragEvent<HTMLElement>) => void;\n handleDrop: (e: DragEvent<HTMLElement>) => void;\n handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void;\n openFileDialog: () => void;\n getInputProps: (\n props?: InputHTMLAttributes<HTMLInputElement>,\n ) => InputHTMLAttributes<HTMLInputElement> & {\n ref: React.Ref<HTMLInputElement>;\n };\n};\n\nexport const useFileUpload = (\n options: FileUploadOptions = {},\n): [FileUploadState, FileUploadActions] => {\n const {\n maxFiles = Number.POSITIVE_INFINITY,\n maxSize = Number.POSITIVE_INFINITY,\n accept = \"*\",\n multiple = false,\n initialFiles = [],\n onFilesChange,\n onFilesAdded,\n onError,\n } = options;\n\n const [state, setState] = useState<FileUploadState>({\n files: initialFiles.map((file) => ({\n file,\n id: file.id,\n preview: file.url,\n })),\n isDragging: false,\n errors: [],\n });\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const validateFile = useCallback(\n (file: File | FileMetadata): string | null => {\n if (file.size > maxSize) {\n return `File \"${file.name}\" exceeds the maximum size of ${formatBytes(maxSize)}.`;\n }\n\n if (accept !== \"*\") {\n const acceptedTypes = accept.split(\",\").map((type) => type.trim());\n const fileType = file.type || \"\";\n const fileExtension = `.${file.name.split(\".\").pop()}`;\n\n const isAccepted = acceptedTypes.some((type) => {\n if (type.startsWith(\".\")) {\n return fileExtension.toLowerCase() === type.toLowerCase();\n }\n if (type.endsWith(\"/*\")) {\n const baseType = type.split(\"/\")[0];\n return fileType.startsWith(`${baseType}/`);\n }\n return fileType === type;\n });\n\n if (!isAccepted) {\n return `File \"${file.name}\" is not an accepted file type.`;\n }\n }\n\n return null;\n },\n [accept, maxSize],\n );\n\n const createPreview = useCallback((file: File | FileMetadata): string | undefined => {\n if (file instanceof File) {\n return URL.createObjectURL(file);\n }\n return file.url;\n }, []);\n\n const generateUniqueId = useCallback((file: File | FileMetadata): string => {\n if (file instanceof File) {\n return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n }\n return file.id;\n }, []);\n\n const clearFiles = useCallback(() => {\n setState((prev) => {\n // Clean up object URLs\n for (const file of prev.files) {\n if (file.preview && file.file instanceof File && file.file.type.startsWith(\"image/\")) {\n URL.revokeObjectURL(file.preview);\n }\n }\n\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n\n const newState = {\n ...prev,\n files: [],\n errors: [],\n };\n\n onFilesChange?.(newState.files);\n return newState;\n });\n }, [onFilesChange]);\n\n const addFiles = useCallback(\n (newFiles: FileList | File[]) => {\n if (!newFiles || newFiles.length === 0) return;\n\n const newFilesArray = Array.from(newFiles);\n const errors: string[] = [];\n\n // Clear existing errors when new files are uploaded\n setState((prev) => ({ ...prev, errors: [] }));\n\n // In single file mode, clear existing files first\n if (!multiple) {\n clearFiles();\n }\n\n // Check if adding these files would exceed maxFiles (only in multiple mode)\n if (\n multiple &&\n maxFiles !== Number.POSITIVE_INFINITY &&\n state.files.length + newFilesArray.length > maxFiles\n ) {\n errors.push(`You can only upload a maximum of ${maxFiles} files.`);\n onError?.(errors);\n setState((prev) => ({ ...prev, errors }));\n return;\n }\n\n const validFiles: FileWithPreview[] = [];\n\n for (const file of newFilesArray) {\n // Only check for duplicates if multiple files are allowed\n if (multiple) {\n const isDuplicate = state.files.some(\n (existingFile) =>\n existingFile.file.name === file.name && existingFile.file.size === file.size,\n );\n\n // Skip duplicate files silently\n if (isDuplicate) {\n continue;\n }\n }\n\n // Check file size\n if (file.size > maxSize) {\n errors.push(\n multiple\n ? `Some files exceed the maximum size of ${formatBytes(maxSize)}.`\n : `File exceeds the maximum size of ${formatBytes(maxSize)}.`,\n );\n continue;\n }\n\n const error = validateFile(file);\n if (error) {\n errors.push(error);\n } else {\n validFiles.push({\n file,\n id: generateUniqueId(file),\n preview: createPreview(file),\n });\n }\n }\n\n // Only update state if we have valid files to add\n if (validFiles.length > 0) {\n // Call the onFilesAdded callback with the newly added valid files\n onFilesAdded?.(validFiles);\n\n setState((prev) => {\n const newFiles = !multiple ? validFiles : [...prev.files, ...validFiles];\n onFilesChange?.(newFiles);\n return {\n ...prev,\n files: newFiles,\n errors,\n };\n });\n } else if (errors.length > 0) {\n onError?.(errors);\n setState((prev) => ({\n ...prev,\n errors,\n }));\n }\n\n // Reset input value after handling files\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n },\n [\n state.files,\n maxFiles,\n multiple,\n maxSize,\n validateFile,\n createPreview,\n generateUniqueId,\n clearFiles,\n onFilesChange,\n onFilesAdded,\n onError,\n ],\n );\n\n const removeFile = useCallback(\n (id: string) => {\n setState((prev) => {\n const fileToRemove = prev.files.find((file) => file.id === id);\n if (\n fileToRemove?.preview &&\n fileToRemove.file instanceof File &&\n fileToRemove.file.type.startsWith(\"image/\")\n ) {\n URL.revokeObjectURL(fileToRemove.preview);\n }\n\n const newFiles = prev.files.filter((file) => file.id !== id);\n onFilesChange?.(newFiles);\n\n return {\n ...prev,\n files: newFiles,\n errors: [],\n };\n });\n },\n [onFilesChange],\n );\n\n const clearErrors = useCallback(() => {\n setState((prev) => ({\n ...prev,\n errors: [],\n }));\n }, []);\n\n const handleDragEnter = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setState((prev) => ({ ...prev, isDragging: true }));\n }, []);\n\n const handleDragLeave = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (e.currentTarget.contains(e.relatedTarget as Node)) {\n return;\n }\n\n setState((prev) => ({ ...prev, isDragging: false }));\n }, []);\n\n const handleDragOver = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n }, []);\n\n const handleDrop = useCallback(\n (e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setState((prev) => ({ ...prev, isDragging: false }));\n\n // Don't process files if the input is disabled\n if (inputRef.current?.disabled) {\n return;\n }\n\n if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {\n // In single file mode, only use the first file\n if (!multiple) {\n const file = e.dataTransfer.files[0];\n addFiles([file]);\n } else {\n addFiles(e.dataTransfer.files);\n }\n }\n },\n [addFiles, multiple],\n );\n\n const handleFileChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files && e.target.files.length > 0) {\n addFiles(e.target.files);\n }\n },\n [addFiles],\n );\n\n const openFileDialog = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.click();\n }\n }, []);\n\n const getInputProps = useCallback(\n (props: InputHTMLAttributes<HTMLInputElement> = {}) => {\n return {\n ...props,\n type: \"file\" as const,\n onChange: handleFileChange,\n accept: props.accept || accept,\n multiple: props.multiple !== undefined ? props.multiple : multiple,\n ref: inputRef,\n };\n },\n [accept, multiple, handleFileChange],\n );\n\n return [\n state,\n {\n addFiles,\n removeFile,\n clearFiles,\n clearErrors,\n handleDragEnter,\n handleDragLeave,\n handleDragOver,\n handleDrop,\n handleFileChange,\n openFileDialog,\n getInputProps,\n },\n ];\n};\n\n// Helper function to format bytes to human-readable format\nexport const formatBytes = (bytes: number, decimals = 2): string => {\n if (bytes === 0) return \"0 Bytes\";\n\n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;\n};\n"],"mappings":";;;AA6DA,MAAa,iBACX,UAA6B,CAAC,MACW;CACzC,MAAM,EACJ,WAAW,OAAO,mBAClB,UAAU,OAAO,mBACjB,SAAS,KACT,WAAW,OACX,eAAe,CAAC,GAChB,eACA,cACA,YACE;CAEJ,MAAM,CAAC,OAAO,YAAY,SAA0B;EAClD,OAAO,aAAa,KAAK,UAAU;GACjC;GACA,IAAI,KAAK;GACT,SAAS,KAAK;EAChB,EAAE;EACF,YAAY;EACZ,QAAQ,CAAC;CACX,CAAC;CAED,MAAM,WAAW,OAAyB,IAAI;CAE9C,MAAM,eAAe,aAClB,SAA6C;EAC5C,IAAI,KAAK,OAAO,SACd,OAAO,SAAS,KAAK,KAAK,gCAAgC,YAAY,OAAO,EAAE;EAGjF,IAAI,WAAW,KAAK;GAClB,MAAM,gBAAgB,OAAO,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC;GACjE,MAAM,WAAW,KAAK,QAAQ;GAC9B,MAAM,gBAAgB,IAAI,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI;GAanD,IAAI,CAXe,cAAc,MAAM,SAAS;IAC9C,IAAI,KAAK,WAAW,GAAG,GACrB,OAAO,cAAc,YAAY,MAAM,KAAK,YAAY;IAE1D,IAAI,KAAK,SAAS,IAAI,GAA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GAC5C,SAAS,EAAE,OAAO,KAAK;CAE3B,GACA,CAAC,QAAQ,CACX;CAsBA,OAAO,CACL,OACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAhCmB,kBAAkB;GACvC,IAAI,SAAS,SACX,SAAS,QAAQ,MAAM;EAE3B,GAAG,CAAC,CA4Ba;EACb,eA3BkB,aACnB,QAA+C,CAAC,MAAM;GACrD,OAAO;IACL,GAAG;IACH,MAAM;IACN,UAAU;IACV,QAAQ,MAAM,UAAU;IACxB,UAAU,MAAM,aAAa,KAAA,IAAY,MAAM,WAAW;IAC1D,KAAK;GACP;EACF,GACA;GAAC;GAAQ;GAAU;EAAgB,CAgBrB;CACd,CACF;AACF;AAGA,MAAa,eAAe,OAAe,WAAW,MAAc;CAClE,IAAI,UAAU,GAAG,OAAO;CAExB,MAAM,IAAI;CACV,MAAM,KAAK,WAAW,IAAI,IAAI;CAC9B,MAAM,QAAQ;EAAC;EAAS;EAAM;EAAM;EAAM;EAAM;EAAM;EAAM;EAAM;CAAI;CAEtE,MAAM,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC;CAElD,OAAO,GAAG,OAAO,YAAY,QAAQ,KAAK,EAAA,CAAG,QAAQ,EAAE,CAAC,EAAE,GAAG,MAAM;AACrE"}
|
|
1
|
+
{"version":3,"file":"use-file-upload.js","names":[],"sources":["../../src/hooks/use-file-upload.ts"],"sourcesContent":["\"use client\";\n\nimport type React from \"react\";\nimport {\n type ChangeEvent,\n type DragEvent,\n type InputHTMLAttributes,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nexport type FileMetadata = {\n name: string;\n size: number;\n type: string;\n url: string;\n id: string;\n};\n\nexport type FileWithPreview = {\n file: File | FileMetadata;\n id: string;\n preview?: string;\n};\n\nexport type FileUploadOptions = {\n maxFiles?: number; // Only used when multiple is true, defaults to Infinity\n maxSize?: number; // in bytes\n accept?: string;\n multiple?: boolean; // Defaults to false\n initialFiles?: FileMetadata[];\n onFilesChange?: (files: FileWithPreview[]) => void; // Callback when files change\n onFilesAdded?: (addedFiles: FileWithPreview[]) => void; // Callback when new files are added\n onError?: (errors: string[]) => void;\n};\n\nexport type FileUploadState = {\n files: FileWithPreview[];\n isDragging: boolean;\n errors: string[];\n};\n\nexport type FileUploadActions = {\n addFiles: (files: FileList | File[]) => void;\n removeFile: (id: string) => void;\n clearFiles: () => void;\n clearErrors: () => void;\n handleDragEnter: (e: DragEvent<HTMLElement>) => void;\n handleDragLeave: (e: DragEvent<HTMLElement>) => void;\n handleDragOver: (e: DragEvent<HTMLElement>) => void;\n handleDrop: (e: DragEvent<HTMLElement>) => void;\n handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void;\n openFileDialog: () => void;\n getInputProps: (\n props?: InputHTMLAttributes<HTMLInputElement>,\n ) => InputHTMLAttributes<HTMLInputElement> & {\n ref: React.Ref<HTMLInputElement>;\n };\n};\n\nexport const useFileUpload = (\n options: FileUploadOptions = {},\n): [FileUploadState, FileUploadActions] => {\n const {\n maxFiles = Number.POSITIVE_INFINITY,\n maxSize = Number.POSITIVE_INFINITY,\n accept = \"*\",\n multiple = false,\n initialFiles = [],\n onFilesChange,\n onFilesAdded,\n onError,\n } = options;\n\n const [state, setState] = useState<FileUploadState>({\n files: initialFiles.map((file) => ({\n file,\n id: file.id,\n preview: file.url,\n })),\n isDragging: false,\n errors: [],\n });\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const validateFile = useCallback(\n (file: File | FileMetadata): string | null => {\n if (file.size > maxSize) {\n return `File \"${file.name}\" exceeds the maximum size of ${formatBytes(maxSize)}.`;\n }\n\n if (accept !== \"*\") {\n const acceptedTypes = accept.split(\",\").map((type) => type.trim());\n const fileType = file.type || \"\";\n const fileExtension = `.${file.name.split(\".\").pop()}`;\n\n const isAccepted = acceptedTypes.some((type) => {\n if (type.startsWith(\".\")) {\n return fileExtension.toLowerCase() === type.toLowerCase();\n }\n if (type.endsWith(\"/*\")) {\n const baseType = type.split(\"/\")[0];\n return fileType.startsWith(`${baseType}/`);\n }\n return fileType === type;\n });\n\n if (!isAccepted) {\n return `File \"${file.name}\" is not an accepted file type.`;\n }\n }\n\n return null;\n },\n [accept, maxSize],\n );\n\n const createPreview = useCallback((file: File | FileMetadata): string | undefined => {\n if (file instanceof File) {\n return URL.createObjectURL(file);\n }\n return file.url;\n }, []);\n\n const generateUniqueId = useCallback((file: File | FileMetadata): string => {\n if (file instanceof File) {\n return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n }\n return file.id;\n }, []);\n\n const clearFiles = useCallback(() => {\n setState((prev) => {\n // Clean up object URLs\n for (const file of prev.files) {\n if (file.preview && file.file instanceof File && file.file.type.startsWith(\"image/\")) {\n URL.revokeObjectURL(file.preview);\n }\n }\n\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n\n const newState = {\n ...prev,\n files: [],\n errors: [],\n };\n\n onFilesChange?.(newState.files);\n return newState;\n });\n }, [onFilesChange]);\n\n const addFiles = useCallback(\n (newFiles: FileList | File[]) => {\n if (!newFiles || newFiles.length === 0) return;\n\n const newFilesArray = Array.from(newFiles);\n const errors: string[] = [];\n\n // Clear existing errors when new files are uploaded\n setState((prev) => ({ ...prev, errors: [] }));\n\n // In single file mode, clear existing files first\n if (!multiple) {\n clearFiles();\n }\n\n // Check if adding these files would exceed maxFiles (only in multiple mode)\n if (\n multiple &&\n maxFiles !== Number.POSITIVE_INFINITY &&\n state.files.length + newFilesArray.length > maxFiles\n ) {\n errors.push(`You can only upload a maximum of ${maxFiles} files.`);\n onError?.(errors);\n setState((prev) => ({ ...prev, errors }));\n return;\n }\n\n const validFiles: FileWithPreview[] = [];\n\n for (const file of newFilesArray) {\n // Only check for duplicates if multiple files are allowed\n if (multiple) {\n const isDuplicate = state.files.some(\n (existingFile) =>\n existingFile.file.name === file.name && existingFile.file.size === file.size,\n );\n\n // Skip duplicate files silently\n if (isDuplicate) {\n continue;\n }\n }\n\n // Check file size\n if (file.size > maxSize) {\n errors.push(\n multiple\n ? `Some files exceed the maximum size of ${formatBytes(maxSize)}.`\n : `File exceeds the maximum size of ${formatBytes(maxSize)}.`,\n );\n continue;\n }\n\n const error = validateFile(file);\n if (error) {\n errors.push(error);\n } else {\n validFiles.push({\n file,\n id: generateUniqueId(file),\n preview: createPreview(file),\n });\n }\n }\n\n // Only update state if we have valid files to add\n if (validFiles.length > 0) {\n // Call the onFilesAdded callback with the newly added valid files\n onFilesAdded?.(validFiles);\n\n setState((prev) => {\n const newFiles = !multiple ? validFiles : [...prev.files, ...validFiles];\n onFilesChange?.(newFiles);\n return {\n ...prev,\n files: newFiles,\n errors,\n };\n });\n } else if (errors.length > 0) {\n onError?.(errors);\n setState((prev) => ({\n ...prev,\n errors,\n }));\n }\n\n // Reset input value after handling files\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n },\n [\n state.files,\n maxFiles,\n multiple,\n maxSize,\n validateFile,\n createPreview,\n generateUniqueId,\n clearFiles,\n onFilesChange,\n onFilesAdded,\n onError,\n ],\n );\n\n const removeFile = useCallback(\n (id: string) => {\n setState((prev) => {\n const fileToRemove = prev.files.find((file) => file.id === id);\n if (\n fileToRemove?.preview &&\n fileToRemove.file instanceof File &&\n fileToRemove.file.type.startsWith(\"image/\")\n ) {\n URL.revokeObjectURL(fileToRemove.preview);\n }\n\n const newFiles = prev.files.filter((file) => file.id !== id);\n onFilesChange?.(newFiles);\n\n return {\n ...prev,\n files: newFiles,\n errors: [],\n };\n });\n },\n [onFilesChange],\n );\n\n const clearErrors = useCallback(() => {\n setState((prev) => ({\n ...prev,\n errors: [],\n }));\n }, []);\n\n const handleDragEnter = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setState((prev) => ({ ...prev, isDragging: true }));\n }, []);\n\n const handleDragLeave = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (e.currentTarget.contains(e.relatedTarget as Node)) {\n return;\n }\n\n setState((prev) => ({ ...prev, isDragging: false }));\n }, []);\n\n const handleDragOver = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n }, []);\n\n const handleDrop = useCallback(\n (e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setState((prev) => ({ ...prev, isDragging: false }));\n\n // Don't process files if the input is disabled\n if (inputRef.current?.disabled) {\n return;\n }\n\n if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {\n // In single file mode, only use the first file\n if (!multiple) {\n const file = e.dataTransfer.files[0];\n addFiles([file]);\n } else {\n addFiles(e.dataTransfer.files);\n }\n }\n },\n [addFiles, multiple],\n );\n\n const handleFileChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files && e.target.files.length > 0) {\n addFiles(e.target.files);\n }\n },\n [addFiles],\n );\n\n const openFileDialog = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.click();\n }\n }, []);\n\n const getInputProps = useCallback(\n (props: InputHTMLAttributes<HTMLInputElement> = {}) => {\n return {\n ...props,\n type: \"file\" as const,\n onChange: handleFileChange,\n accept: props.accept || accept,\n multiple: props.multiple !== undefined ? props.multiple : multiple,\n ref: inputRef,\n };\n },\n [accept, multiple, handleFileChange],\n );\n\n return [\n state,\n {\n addFiles,\n removeFile,\n clearFiles,\n clearErrors,\n handleDragEnter,\n handleDragLeave,\n handleDragOver,\n handleDrop,\n handleFileChange,\n openFileDialog,\n getInputProps,\n },\n ];\n};\n\n// Helper function to format bytes to human-readable format\nexport const formatBytes = (bytes: number, decimals = 2): string => {\n if (bytes === 0) return \"0 Bytes\";\n\n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i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EACF,GACA;GAAC;GAAQ;GAAU;EAAgB,CAgBrB;CACd,CACF;AACF;AAGA,MAAa,eAAe,OAAe,WAAW,MAAc;CAClE,IAAI,UAAU,GAAG,OAAO;CAExB,MAAM,IAAI;CACV,MAAM,KAAK,WAAW,IAAI,IAAI;CAC9B,MAAM,QAAQ;EAAC;EAAS;EAAM;EAAM;EAAM;EAAM;EAAM;EAAM;EAAM;CAAI;CAEtE,MAAM,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC;CAElD,OAAO,GAAG,OAAO,YAAY,QAAQ,KAAK,EAAA,CAAG,QAAQ,EAAE,CAAC,EAAE,GAAG,MAAM;AACrE"}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
//#region src/hooks/use-hydrated.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Hydration state hook for React components
|
|
4
|
-
* Returns a boolean indicating whether the component is running on the client
|
|
5
|
-
* with SSR-safe behavior to prevent hydration mismatches.
|
|
6
|
-
*
|
|
7
|
-
* This hook leverages `useSyncExternalStore` to provide a stable value between
|
|
8
|
-
* server and client renders: `false` during SSR, `true` after client hydration.
|
|
9
|
-
* The external store does not emit updates because the hydration state is static
|
|
10
|
-
* for the lifetime of the component.
|
|
11
|
-
*/
|
|
12
2
|
/**
|
|
13
3
|
* Hook that indicates whether code is executing on the client after hydration
|
|
14
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hydrated.d.ts","names":[],"sources":["../../src/hooks/use-hydrated.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-hydrated.d.ts","names":[],"sources":["../../src/hooks/use-hydrated.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBA0BgB"}
|
|
@@ -2,16 +2,6 @@
|
|
|
2
2
|
import { useSyncExternalStore } from "react";
|
|
3
3
|
//#region src/hooks/use-hydrated.ts
|
|
4
4
|
/**
|
|
5
|
-
* Hydration state hook for React components
|
|
6
|
-
* Returns a boolean indicating whether the component is running on the client
|
|
7
|
-
* with SSR-safe behavior to prevent hydration mismatches.
|
|
8
|
-
*
|
|
9
|
-
* This hook leverages `useSyncExternalStore` to provide a stable value between
|
|
10
|
-
* server and client renders: `false` during SSR, `true` after client hydration.
|
|
11
|
-
* The external store does not emit updates because the hydration state is static
|
|
12
|
-
* for the lifetime of the component.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
5
|
* Hook that indicates whether code is executing on the client after hydration
|
|
16
6
|
*
|
|
17
7
|
* Features:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hydrated.js","names":[],"sources":["../../src/hooks/use-hydrated.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-hydrated.js","names":[],"sources":["../../src/hooks/use-hydrated.ts"],"sourcesContent":["\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n/**\n * Hook that indicates whether code is executing on the client after hydration\n *\n * Features:\n * - SSR-safe: returns `false` on the server to avoid hydration mismatches\n * - Client-stable: returns `true` after hydration and remains stable\n * - Minimal overhead: uses a no-op external store subscription\n *\n * @returns Boolean indicating hydration state (`true` on client, `false` on server)\n *\n * @example\n * ```tsx\n * // Conditionally render client-only components safely\n * function ClientOnly() {\n * const hydrated = useHydrated();\n * if (!hydrated) return null;\n * return <InteractiveChart />;\n * }\n * ```\n *\n * @since 1.0.0\n */\nexport function useHydrated() {\n return useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * External store subscription used by `useHydrated`\n * No updates are dispatched because hydration state is static.\n * Returns an unsubscribe function for API conformity.\n */\nfunction subscribe() {\n return () => {};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,cAAc;CAC5B,OAAO,qBACL,iBACM,YACA,KACR;AACF;;;;;;AAOA,SAAS,YAAY;CACnB,aAAa,CAAC;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intersection-observer.d.ts","names":[],"sources":["../../src/hooks/use-intersection-observer.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"use-intersection-observer.d.ts","names":[],"sources":["../../src/hooks/use-intersection-observer.ts"],"mappings":";;;;;;;;UAUU,oCAAoC;;;;;;;;EAQ5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsHc,wBACd,YAAY,QAAM,UAAU,mBAE1B,WACA,MACA,YACA,sBACC"}
|