@kumix/ui 0.3.8 → 0.3.10

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.
Files changed (102) hide show
  1. package/README.md +16 -15
  2. package/dist/components/agents/ai-sidebar.js +3 -5
  3. package/dist/components/agents/ai-sidebar.js.map +1 -1
  4. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  5. package/dist/components/motion/animated-sidebar.js.map +1 -1
  6. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  7. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
  8. package/dist/components/motion/availability-scheduler/day-row.js +15 -7
  9. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
  10. package/dist/components/motion/availability-scheduler/index.js +1 -1
  11. package/dist/components/motion/button/index.d.ts +2 -1
  12. package/dist/components/motion/button/index.js +2 -1
  13. package/dist/components/motion/button/metallic.d.ts +10 -0
  14. package/dist/components/motion/button/metallic.d.ts.map +1 -0
  15. package/dist/components/motion/button/metallic.js +71 -0
  16. package/dist/components/motion/button/metallic.js.map +1 -0
  17. package/dist/components/motion/combobox/content.js +1 -1
  18. package/dist/components/motion/combobox/context.d.ts +6 -0
  19. package/dist/components/motion/combobox/context.d.ts.map +1 -1
  20. package/dist/components/motion/combobox/context.js +1 -233
  21. package/dist/components/motion/combobox/list.js +1 -1
  22. package/dist/components/motion/combobox/trigger.js +7 -8
  23. package/dist/components/motion/combobox/trigger.js.map +1 -1
  24. package/dist/components/motion/combobox.js +1 -1
  25. package/dist/components/motion/command-palette.d.ts.map +1 -1
  26. package/dist/components/motion/command-palette.js +21 -26
  27. package/dist/components/motion/command-palette.js.map +1 -1
  28. package/dist/components/motion/expandable-control.d.ts +28 -0
  29. package/dist/components/motion/expandable-control.d.ts.map +1 -0
  30. package/dist/components/motion/expandable-control.js +149 -0
  31. package/dist/components/motion/expandable-control.js.map +1 -0
  32. package/dist/components/motion/expanding-arrow-button.d.ts +12 -0
  33. package/dist/components/motion/expanding-arrow-button.d.ts.map +1 -0
  34. package/dist/components/motion/expanding-arrow-button.js +142 -0
  35. package/dist/components/motion/expanding-arrow-button.js.map +1 -0
  36. package/dist/components/motion/file-tree.d.ts +42 -0
  37. package/dist/components/motion/file-tree.d.ts.map +1 -0
  38. package/dist/components/motion/file-tree.js +272 -0
  39. package/dist/components/motion/file-tree.js.map +1 -0
  40. package/dist/components/motion/morphing-search.d.ts.map +1 -1
  41. package/dist/components/motion/morphing-search.js +27 -23
  42. package/dist/components/motion/morphing-search.js.map +1 -1
  43. package/dist/components/reui/alert.d.ts +1 -1
  44. package/dist/components/reui/badge.d.ts +1 -1
  45. package/dist/components/reui/code-block/code-block-highlight.d.ts +216 -0
  46. package/dist/components/reui/code-block/code-block-highlight.d.ts.map +1 -0
  47. package/dist/components/reui/code-block/code-block-highlight.js +792 -0
  48. package/dist/components/reui/code-block/code-block-highlight.js.map +1 -0
  49. package/dist/components/reui/code-block/code-block.d.ts +197 -0
  50. package/dist/components/reui/code-block/code-block.d.ts.map +1 -0
  51. package/dist/components/reui/code-block/code-block.js +1150 -0
  52. package/dist/components/reui/code-block/code-block.js.map +1 -0
  53. package/dist/components/reui/filters/filters-builder.js +1 -1
  54. package/dist/components/reui/filters/filters-chip.js.map +1 -1
  55. package/dist/components/reui/filters/filters-editors.js +2 -2
  56. package/dist/components/reui/filters/filters-editors.js.map +1 -1
  57. package/dist/components/reui/gantt/gantt-bar.js +42 -12
  58. package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
  59. package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -1
  60. package/dist/components/reui/gantt/gantt-dnd.js +22 -7
  61. package/dist/components/reui/gantt/gantt-dnd.js.map +1 -1
  62. package/dist/components/reui/gantt/gantt-i18n.d.ts +8 -0
  63. package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -1
  64. package/dist/components/reui/gantt/gantt-i18n.js +6 -1
  65. package/dist/components/reui/gantt/gantt-i18n.js.map +1 -1
  66. package/dist/components/reui/gantt/gantt-lib.d.ts +59 -2
  67. package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -1
  68. package/dist/components/reui/gantt/gantt-lib.js +67 -2
  69. package/dist/components/reui/gantt/gantt-lib.js.map +1 -1
  70. package/dist/components/reui/gantt/gantt-recurrence.js +3 -3
  71. package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -1
  72. package/dist/components/reui/gantt/gantt-types.d.ts +32 -1
  73. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  74. package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -1
  75. package/dist/components/reui/gantt/gantt-view.js +324 -35
  76. package/dist/components/reui/gantt/gantt-view.js.map +1 -1
  77. package/dist/components/reui/gantt/gantt.d.ts +71 -2
  78. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  79. package/dist/components/reui/gantt/gantt.js +8 -0
  80. package/dist/components/reui/gantt/gantt.js.map +1 -1
  81. package/dist/components/ui/badge.d.ts +1 -1
  82. package/dist/components/ui/bubble.d.ts +1 -1
  83. package/dist/components/ui/button.d.ts +1 -1
  84. package/dist/components/ui/item.d.ts +1 -1
  85. package/dist/components/ui/marker.d.ts +1 -1
  86. package/dist/components/ui/tabs.d.ts +1 -1
  87. package/dist/context-BizvUNZv.js +298 -0
  88. package/dist/context-BizvUNZv.js.map +1 -0
  89. package/dist/{copy-menu-1FKoMc9o.js → copy-menu-C5GaT4Z-.js} +67 -2
  90. package/dist/copy-menu-C5GaT4Z-.js.map +1 -0
  91. package/dist/hooks/use-on-open.d.ts +18 -0
  92. package/dist/hooks/use-on-open.d.ts.map +1 -0
  93. package/dist/hooks/use-on-open.js +27 -0
  94. package/dist/hooks/use-on-open.js.map +1 -0
  95. package/dist/hooks/use-row-cursor.d.ts +39 -0
  96. package/dist/hooks/use-row-cursor.d.ts.map +1 -0
  97. package/dist/hooks/use-row-cursor.js +77 -0
  98. package/dist/hooks/use-row-cursor.js.map +1 -0
  99. package/dist/types-smkWN_7x.d.ts.map +1 -1
  100. package/package.json +7 -13
  101. package/dist/components/motion/combobox/context.js.map +0 -1
  102. package/dist/copy-menu-1FKoMc9o.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ import { useCallback, useLayoutEffect, useRef, useState } from "react";
3
+ //#region src/hooks/use-row-cursor.ts
4
+ /** The cursor's row, or -1 once the query has moved on or the row has left. */
5
+ function indexOfCursor(rows, query, cursor) {
6
+ if (cursor === null || cursor.query !== query) return -1;
7
+ return rows.findIndex((row) => row.id === cursor.id);
8
+ }
9
+ /**
10
+ * The highlighted row of a list whose rows can change under it.
11
+ *
12
+ * Which row is highlighted is resolved during render, never in a passive
13
+ * effect: a passive effect runs after the commit, so a list that had just
14
+ * changed would carry an `aria-activedescendant` naming a row that has left it,
15
+ * and a key pressed in that window would commit the wrong row or nothing at
16
+ * all.
17
+ *
18
+ * The cursor holds the row's id, not its position. A position alone cannot tell
19
+ * a list that shrank from one that swapped its rows for a different set of the
20
+ * same length, and the second case is the one that silently hands Enter to a
21
+ * row the user never chose. A cursor whose row has left the list returns the
22
+ * highlight to the first row rather than to the nearest surviving one: the row
23
+ * the user aimed at is gone, and the first row is where a new query already
24
+ * puts the highlight.
25
+ *
26
+ * Pass the query the list is filtered by. The cursor is stamped with it and
27
+ * dropped when it changes, so a caller cannot forget to clear it — including a
28
+ * caller whose query arrives as a prop and so never runs its own handler. Rows
29
+ * that come back under a query that has moved on cannot revive it either.
30
+ * `moveTo(null)` is for deliberate resets, such as reopening the list.
31
+ *
32
+ * Both callbacks keep one identity for the life of the component, and read the
33
+ * rows and the query through a ref to do it. A caller will put them in an
34
+ * effect's dependencies — the exhaustive-deps rule makes it — and a `moveTo`
35
+ * rebuilt on every keystroke would re-run that effect on every keystroke.
36
+ */
37
+ function useRowCursor(rows, query) {
38
+ const [cursor, setCursor] = useState(null);
39
+ const latest = useRef({
40
+ rows,
41
+ query
42
+ });
43
+ useLayoutEffect(() => {
44
+ latest.current = {
45
+ rows,
46
+ query
47
+ };
48
+ });
49
+ const cursorRow = indexOfCursor(rows, query, cursor);
50
+ if (cursor !== null && cursorRow < 0) setCursor(null);
51
+ const moveTo = useCallback((id) => setCursor(id === null ? null : {
52
+ id,
53
+ query: latest.current.query
54
+ }), []);
55
+ const moveActive = useCallback((direction) => {
56
+ const { rows: live, query: liveQuery } = latest.current;
57
+ const last = live.length - 1;
58
+ if (last < 0) return;
59
+ setCursor((current) => {
60
+ const at = Math.max(indexOfCursor(live, liveQuery, current), 0);
61
+ const next = Math.min(Math.max(at + direction, 0), last);
62
+ return {
63
+ id: live[next].id,
64
+ query: liveQuery
65
+ };
66
+ });
67
+ }, []);
68
+ return {
69
+ activeIndex: cursorRow < 0 ? 0 : cursorRow,
70
+ moveTo,
71
+ moveActive
72
+ };
73
+ }
74
+ //#endregion
75
+ export { useRowCursor };
76
+
77
+ //# sourceMappingURL=use-row-cursor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-row-cursor.js","names":[],"sources":["../../src/hooks/use-row-cursor.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useLayoutEffect, useRef, useState } from \"react\";\n\n/**\n * Where the keyboard or the pointer last moved to: the row's id, stamped with\n * the query it was placed under.\n */\ntype RowCursor = { id: string; query: string };\n\n/** The cursor's row, or -1 once the query has moved on or the row has left. */\nfunction indexOfCursor(rows: readonly { id: string }[], query: string, cursor: RowCursor | null) {\n if (cursor === null || cursor.query !== query) return -1;\n return rows.findIndex((row) => row.id === cursor.id);\n}\n\n/**\n * The highlighted row of a list whose rows can change under it.\n *\n * Which row is highlighted is resolved during render, never in a passive\n * effect: a passive effect runs after the commit, so a list that had just\n * changed would carry an `aria-activedescendant` naming a row that has left it,\n * and a key pressed in that window would commit the wrong row or nothing at\n * all.\n *\n * The cursor holds the row's id, not its position. A position alone cannot tell\n * a list that shrank from one that swapped its rows for a different set of the\n * same length, and the second case is the one that silently hands Enter to a\n * row the user never chose. A cursor whose row has left the list returns the\n * highlight to the first row rather than to the nearest surviving one: the row\n * the user aimed at is gone, and the first row is where a new query already\n * puts the highlight.\n *\n * Pass the query the list is filtered by. The cursor is stamped with it and\n * dropped when it changes, so a caller cannot forget to clear it — including a\n * caller whose query arrives as a prop and so never runs its own handler. Rows\n * that come back under a query that has moved on cannot revive it either.\n * `moveTo(null)` is for deliberate resets, such as reopening the list.\n *\n * Both callbacks keep one identity for the life of the component, and read the\n * rows and the query through a ref to do it. A caller will put them in an\n * effect's dependencies — the exhaustive-deps rule makes it — and a `moveTo`\n * rebuilt on every keystroke would re-run that effect on every keystroke.\n */\nexport function useRowCursor(rows: readonly { id: string }[], query: string) {\n const [cursor, setCursor] = useState<RowCursor | null>(null);\n // Written after commit, not during render: a render React discards or has not\n // finished still runs the component body, and an event handler that read this\n // in that window would stamp the cursor with a query the committed tree does\n // not have.\n const latest = useRef({ rows, query });\n useLayoutEffect(() => {\n latest.current = { rows, query };\n });\n\n const cursorRow = indexOfCursor(rows, query, cursor);\n // Cleared rather than ignored: React re-runs this render with the cursor\n // already gone, so rows that come back cannot revive a highlight the user has\n // stopped aiming at.\n if (cursor !== null && cursorRow < 0) setCursor(null);\n\n const moveTo = useCallback(\n (id: string | null) => setCursor(id === null ? null : { id, query: latest.current.query }),\n [],\n );\n\n const moveActive = useCallback((direction: 1 | -1) => {\n const { rows: live, query: liveQuery } = latest.current;\n const last = live.length - 1;\n if (last < 0) return;\n // Steps from the row the cursor is really on, inside the update, so that\n // two keys landing in one batch move two rows rather than one.\n setCursor((current) => {\n const at = Math.max(indexOfCursor(live, liveQuery, current), 0);\n const next = Math.min(Math.max(at + direction, 0), last);\n return { id: live[next].id, query: liveQuery };\n });\n }, []);\n\n return { activeIndex: cursorRow < 0 ? 0 : cursorRow, moveTo, moveActive };\n}\n"],"mappings":";;;;AAWA,SAAS,cAAc,MAAiC,OAAe,QAA0B;CAC/F,IAAI,WAAW,QAAQ,OAAO,UAAU,OAAO,OAAO;CACtD,OAAO,KAAK,WAAW,QAAQ,IAAI,OAAO,OAAO,EAAE;AACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,aAAa,MAAiC,OAAe;CAC3E,MAAM,CAAC,QAAQ,aAAa,SAA2B,IAAI;CAK3D,MAAM,SAAS,OAAO;EAAE;EAAM;CAAM,CAAC;CACrC,sBAAsB;EACpB,OAAO,UAAU;GAAE;GAAM;EAAM;CACjC,CAAC;CAED,MAAM,YAAY,cAAc,MAAM,OAAO,MAAM;CAInD,IAAI,WAAW,QAAQ,YAAY,GAAG,UAAU,IAAI;CAEpD,MAAM,SAAS,aACZ,OAAsB,UAAU,OAAO,OAAO,OAAO;EAAE;EAAI,OAAO,OAAO,QAAQ;CAAM,CAAC,GACzF,CAAC,CACH;CAEA,MAAM,aAAa,aAAa,cAAsB;EACpD,MAAM,EAAE,MAAM,MAAM,OAAO,cAAc,OAAO;EAChD,MAAM,OAAO,KAAK,SAAS;EAC3B,IAAI,OAAO,GAAG;EAGd,WAAW,YAAY;GACrB,MAAM,KAAK,KAAK,IAAI,cAAc,MAAM,WAAW,OAAO,GAAG,CAAC;GAC9D,MAAM,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,WAAW,CAAC,GAAG,IAAI;GACvD,OAAO;IAAE,IAAI,KAAK,KAAK,CAAC;IAAI,OAAO;GAAU;EAC/C,CAAC;CACH,GAAG,CAAC,CAAC;CAEL,OAAO;EAAE,aAAa,YAAY,IAAI,IAAI;EAAW;EAAQ;CAAW;AAC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"types-smkWN_7x.d.ts","names":[],"sources":["../src/components/motion/availability-scheduler/types.ts"],"mappings":";KAAY;KAEA;EAAc;EAAY;EAAe;;KACzC;EAAoB;EAAkB,QAAQ;;KAC9C,mBAAmB,OAAO,QAAQ;KAClC;EAAe;EAAe;;iBAuD1B,eAAe"}
1
+ {"version":3,"file":"types-smkWN_7x.d.ts","names":[],"sources":["../src/components/motion/availability-scheduler/types.ts"],"mappings":";KAAY;KAEA;EAAc;EAAY;EAAe;;KACzC;EAAoB;EAAkB,QAAQ;;KAC9C,mBAAmB,OAAO,QAAQ;KAClC;EAAe;EAAe;;iBA2I1B,eAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumix/ui",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "Kumix React UI kit: shadcn/ui (Base UI, base-nova) + ReUI components, Tailwind tokens, and hooks. Per-file ESM exports.",
5
5
  "author": "Kumix Labs <hai@kumix.io>",
6
6
  "license": "MIT",
@@ -36,13 +36,7 @@
36
36
  "dev": "tsdown --watch",
37
37
  "build:css": "cp src/style.css dist/style.css && cp src/theme.css dist/theme.css && cp src/style.css.d.ts dist/style.css.d.ts && cp src/theme.css.d.ts dist/theme.css.d.ts",
38
38
  "build": "rimraf dist && mkdir -p dist && bun run build:css && tsdown && publint",
39
- "types:check": "tsc --noEmit",
40
- "add:shadcn": "shadcn add --all --overwrite",
41
- "add:reui": "shadcn add @reui/alert @reui/autocomplete @reui/badge @reui/cascader @reui/data-grid @reui/date-selector @reui/event-calendar @reui/use-file-upload @reui/filters @reui/frame @reui/gantt @reui/icon-stack @reui/icon-tile @reui/kanban @reui/number-field @reui/phone-input @reui/rating @reui/scrollspy @reui/sortable @reui/stepper @reui/timeline @reui/tree --overwrite",
42
- "add:beui:ai-agents": "shadcn add @beui/prompt-input @beui/todo-list @beui/code-block @beui/approval-card @beui/file-diff @beui/tool-result @beui/streaming-response @beui/image-generation @beui/tool-approval @beui/citations @beui/agent-activity @beui/reasoning-text @beui/thinking-shimmer @beui/agent-progress @beui/ai-sidebar @beui/chat-app @beui/message-bubble @beui/message @beui/message-scroller --overwrite",
43
- "add:beui:components": "shadcn add @beui/marquee @beui/tabs @beui/switch @beui/input @beui/select @beui/select-morph @beui/combobox @beui/checkbox @beui/radio @beui/bottom-sheet @beui/pull-to-refresh @beui/shared-layout-bg @beui/bounce-sidebar @beui/animated-sidebar @beui/preview-rail @beui/dock @beui/tooltip @beui/context-menu @beui/popover @beui/popover-morph @beui/morphing-modal @beui/center-morph-modal @beui/chromatic-text-reveal @beui/text-reveal @beui/text-shimmer @beui/text-cascade @beui/number-ticker @beui/animated-number @beui/animated-badge @beui/action-swap-cascade @beui/action-swap-blur @beui/action-swap-roll @beui/animated-toast-stack @beui/theme-toggle @beui/bouncy-accordion @beui/drawer @beui/smooth-scroll @beui/scroll-progress @beui/parallax @beui/scroll-to @beui/scroll-reveal @beui/range-slider @beui/range-slider-fluid @beui/range-slider-wave @beui/range-slider-bubble @beui/range-slider-ruler @beui/wheel-picker @beui/table @beui/table-editable @beui/table-async @beui/shader-background @beui/cylinder-carousel @beui/loader @beui/tilt-card @beui/button-base @beui/button-stateful @beui/button-magnetic @beui/hold-action-button @beui/slide-action-button --overwrite",
44
- "add:beui:blocks": "shadcn add @beui/availability-scheduler @beui/dynamic-island @beui/command-palette @beui/morphing-search @beui/expandable-action-bar @beui/overflow-actions @beui/expandable-tabs @beui/morphing-tabs @beui/swipeable-list @beui/attachment-upload @beui/file-upload @beui/otp-input @beui/signup-form @beui/bloom-menu @beui/feedback-widget @beui/not-found-glitch @beui/not-found-magnetic @beui/not-found-spotlight @beui/not-found-stacked @beui/not-found-terminal @beui/infinite-masonry @beui/notification-stack @beui/project-folder --overwrite",
45
- "add:beui": "bun run add:beui:ai-agents && bun run add:beui:components && bun run add:beui:blocks"
39
+ "types:check": "tsc --noEmit"
46
40
  },
47
41
  "homepage": "https://github.com/kumixlabs/ui",
48
42
  "repository": {
@@ -80,10 +74,10 @@
80
74
  "@dnd-kit/utilities": "^3.2.2",
81
75
  "@headless-tree/core": "^1.7.0",
82
76
  "@kumix/tsconfig": "^0.1.0",
83
- "@kumix/utils": "^0.1.3",
77
+ "@kumix/utils": "^0.2.0",
84
78
  "@paper-design/shaders-react": "^0.0.80",
85
79
  "@shadcn/react": "^0.3.0",
86
- "@tanstack/react-table": "^9.1.2",
80
+ "@tanstack/react-table": "^9.2.3",
87
81
  "@tanstack/react-virtual": "^3.14.10",
88
82
  "@types/react": "^19.2.18",
89
83
  "class-variance-authority": "^0.7.1",
@@ -93,7 +87,7 @@
93
87
  "embla-carousel-react": "^8.6.0",
94
88
  "input-otp": "^1.5.0",
95
89
  "lenis": "^1.3.26",
96
- "lucide-react": "^1.33.0",
90
+ "lucide-react": "^1.34.0",
97
91
  "motion": "^13.1.1",
98
92
  "next-themes": "^0.4.6",
99
93
  "react": "^19.2.8",
@@ -114,10 +108,10 @@
114
108
  "@dnd-kit/sortable": ">=10.0.0",
115
109
  "@dnd-kit/utilities": ">=3.2.0",
116
110
  "@headless-tree/core": ">=1.7.0",
117
- "@kumix/utils": ">=0.1.0",
111
+ "@kumix/utils": ">=0.2.0",
118
112
  "@paper-design/shaders-react": ">=0.0.75",
119
113
  "@shadcn/react": ">=0.3.0",
120
- "@tanstack/react-table": ">=9.0.0",
114
+ "@tanstack/react-table": ">=9.2.0",
121
115
  "@tanstack/react-virtual": ">=3.10.0",
122
116
  "class-variance-authority": ">=0.7.0",
123
117
  "cmdk": ">=1.1.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../../../../src/components/motion/combobox/context.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type MutableRefObject,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\nexport type RegisteredItem = {\n value: string;\n label: string;\n keywords: string[];\n disabled: boolean;\n groupId: string | null;\n id: string;\n ref: MutableRefObject<HTMLButtonElement | null>;\n};\n\nexport type ComboboxFilter = (value: string, query: string, keywords: string[]) => boolean;\n\nconst defaultFilter: ComboboxFilter = (value, query, keywords) => {\n const needle = query.trim().toLocaleLowerCase();\n if (!needle) return true;\n\n const haystack = [value, ...keywords].join(\" \").toLocaleLowerCase();\n let queryIndex = 0;\n for (const character of haystack) {\n if (character === needle[queryIndex]) queryIndex += 1;\n if (queryIndex === needle.length) return true;\n }\n return false;\n};\n\nexport type ComboboxContextValue = {\n open: boolean;\n setOpen: (open: boolean, restoreFocus?: boolean) => void;\n value: string | undefined;\n select: (value: string) => void;\n query: string;\n setQuery: (query: string) => void;\n activeValue: string | null;\n setActiveValue: (value: string | null) => void;\n moveActive: (direction: 1 | -1 | \"first\" | \"last\") => void;\n selectActive: () => void;\n registerItem: (item: RegisteredItem) => void;\n unregisterItem: (value: string) => void;\n labelFor: (value: string | undefined) => string | undefined;\n isVisible: (value: string) => boolean;\n hasVisibleItems: (groupId: string) => boolean;\n visibleCount: number;\n activeItemId: string | undefined;\n triggerId: string;\n listId: string;\n inputId: string;\n disabled: boolean;\n reduce: boolean;\n triggerRef: MutableRefObject<HTMLDivElement | null>;\n contentRef: MutableRefObject<HTMLDivElement | null>;\n inputRef: MutableRefObject<HTMLInputElement | null>;\n activeLayoutId: string;\n};\n\nexport const ComboboxContext = createContext<ComboboxContextValue | null>(null);\nexport const ComboboxGroupContext = createContext<string | null>(null);\n\nexport function useComboboxContext(component: string) {\n const context = useContext(ComboboxContext);\n if (!context) throw new Error(`${component} must be used within <Combobox>`);\n return context;\n}\n\nexport function mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\") (ref as MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nexport interface ComboboxProps {\n children: ReactNode;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n query?: string;\n defaultQuery?: string;\n onQueryChange?: (query: string) => void;\n filter?: ComboboxFilter;\n disabled?: boolean;\n className?: string;\n}\n\nexport function Combobox({\n children,\n value: controlledValue,\n defaultValue,\n onValueChange,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n query: controlledQuery,\n defaultQuery = \"\",\n onQueryChange,\n filter = defaultFilter,\n disabled = false,\n className,\n}: ComboboxProps) {\n const reduce = useReducedMotion() ?? false;\n const baseId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internalQuery, setInternalQuery] = useState(defaultQuery);\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const [items, setItems] = useState<Map<string, RegisteredItem>>(new Map());\n\n const valueControlled = controlledValue !== undefined;\n const openControlled = controlledOpen !== undefined;\n const queryControlled = controlledQuery !== undefined;\n const value = valueControlled ? controlledValue : internalValue;\n const open = openControlled ? controlledOpen : internalOpen;\n const query = queryControlled ? controlledQuery : internalQuery;\n\n const updateQuery = useCallback(\n (next: string) => {\n if (!queryControlled) setInternalQuery(next);\n onQueryChange?.(next);\n },\n [onQueryChange, queryControlled],\n );\n\n const updateOpen = useCallback(\n (next: boolean, restoreFocus = false) => {\n if (disabled && next) return;\n if (!openControlled) setInternalOpen(next);\n onOpenChange?.(next);\n if (!next) updateQuery(\"\");\n if (restoreFocus)\n requestAnimationFrame(() => inputRef.current?.focus({ preventScroll: true }));\n },\n [disabled, onOpenChange, openControlled, updateQuery],\n );\n\n const registerItem = useCallback((item: RegisteredItem) => {\n setItems((current) => {\n const existing = current.get(item.value);\n if (\n existing?.label === item.label &&\n existing.disabled === item.disabled &&\n existing.id === item.id &&\n existing.ref === item.ref &&\n existing.groupId === item.groupId &&\n existing.keywords.join(\"\\u0000\") === item.keywords.join(\"\\u0000\")\n ) {\n return current;\n }\n const next = new Map(current);\n next.set(item.value, item);\n return next;\n });\n }, []);\n\n const unregisterItem = useCallback((itemValue: string) => {\n setItems((current) => {\n if (!current.has(itemValue)) return current;\n const next = new Map(current);\n next.delete(itemValue);\n return next;\n });\n }, []);\n\n const visibleItems = useMemo(\n () =>\n Array.from(items.values()).filter((item) =>\n filter(item.value, query, [item.label, ...item.keywords]),\n ),\n [filter, items, query],\n );\n const enabledVisibleItems = useMemo(\n () => visibleItems.filter((item) => !item.disabled),\n [visibleItems],\n );\n const visibleValues = useMemo(\n () => new Set(visibleItems.map((item) => item.value)),\n [visibleItems],\n );\n const visibleGroupIds = useMemo(\n () => new Set(visibleItems.map((item) => item.groupId)),\n [visibleItems],\n );\n\n const select = useCallback(\n (next: string) => {\n if (items.get(next)?.disabled) return;\n if (!valueControlled) setInternalValue(next);\n onValueChange?.(next);\n updateOpen(false, true);\n },\n [items, onValueChange, updateOpen, valueControlled],\n );\n\n const moveActive = useCallback(\n (direction: 1 | -1 | \"first\" | \"last\") => {\n if (!enabledVisibleItems.length) {\n setActiveValue(null);\n return;\n }\n if (direction === \"first\") {\n setActiveValue(enabledVisibleItems[0].value);\n return;\n }\n if (direction === \"last\") {\n setActiveValue(enabledVisibleItems.at(-1)?.value ?? null);\n return;\n }\n\n const currentIndex = enabledVisibleItems.findIndex((item) => item.value === activeValue);\n const nextIndex =\n currentIndex < 0\n ? direction === 1\n ? 0\n : enabledVisibleItems.length - 1\n : (currentIndex + direction + enabledVisibleItems.length) % enabledVisibleItems.length;\n setActiveValue(enabledVisibleItems[nextIndex].value);\n },\n [activeValue, enabledVisibleItems],\n );\n\n const selectActive = useCallback(() => {\n if (activeValue) select(activeValue);\n }, [activeValue, select]);\n\n useEffect(() => {\n if (!open) return;\n const selectedVisible = value && visibleValues.has(value) ? value : null;\n const activeVisible = activeValue && visibleValues.has(activeValue) ? activeValue : null;\n setActiveValue(activeVisible ?? selectedVisible ?? enabledVisibleItems[0]?.value ?? null);\n }, [activeValue, enabledVisibleItems, open, value, visibleValues]);\n\n useEffect(() => {\n if (!open) return;\n requestAnimationFrame(() => inputRef.current?.focus({ preventScroll: true }));\n }, [open]);\n\n useEffect(() => {\n if (!activeValue || !open) return;\n const item = items.get(activeValue)?.ref.current;\n const list = item?.closest<HTMLElement>(\"[role='listbox']\");\n if (!item || !list) return;\n const itemRect = item.getBoundingClientRect();\n const listRect = list.getBoundingClientRect();\n if (itemRect.top < listRect.top) list.scrollTop -= listRect.top - itemRect.top;\n else if (itemRect.bottom > listRect.bottom) list.scrollTop += itemRect.bottom - listRect.bottom;\n }, [activeValue, items, open]);\n\n useEffect(() => {\n if (!open) return;\n const isInside = (target: Node) =>\n rootRef.current?.contains(target) || contentRef.current?.contains(target);\n const onPointerDown = (event: PointerEvent) => {\n if (!isInside(event.target as Node)) updateOpen(false);\n };\n const onFocusIn = (event: FocusEvent) => {\n if (!isInside(event.target as Node)) updateOpen(false);\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n updateOpen(false, true);\n };\n window.addEventListener(\"pointerdown\", onPointerDown);\n window.addEventListener(\"focusin\", onFocusIn);\n window.addEventListener(\"keydown\", onKeyDown);\n return () => {\n window.removeEventListener(\"pointerdown\", onPointerDown);\n window.removeEventListener(\"focusin\", onFocusIn);\n window.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [open, updateOpen]);\n\n const activeItem = activeValue ? items.get(activeValue) : undefined;\n const context = useMemo<ComboboxContextValue>(\n () => ({\n open,\n setOpen: updateOpen,\n value,\n select,\n query,\n setQuery: updateQuery,\n activeValue,\n setActiveValue,\n moveActive,\n selectActive,\n registerItem,\n unregisterItem,\n labelFor: (itemValue) => (itemValue === undefined ? undefined : items.get(itemValue)?.label),\n isVisible: (itemValue) => !query.trim() || visibleValues.has(itemValue),\n hasVisibleItems: (groupId) => visibleGroupIds.has(groupId),\n visibleCount: visibleItems.length,\n activeItemId: activeItem?.id,\n triggerId: `${baseId}-trigger`,\n listId: `${baseId}-list`,\n inputId: `${baseId}-input`,\n disabled,\n reduce,\n triggerRef,\n contentRef,\n inputRef,\n activeLayoutId: `${baseId}-active`,\n }),\n [\n activeItem?.id,\n activeValue,\n baseId,\n disabled,\n items,\n moveActive,\n open,\n query,\n reduce,\n registerItem,\n select,\n selectActive,\n unregisterItem,\n updateOpen,\n updateQuery,\n value,\n visibleItems.length,\n visibleGroupIds,\n visibleValues,\n ],\n );\n\n return (\n <ComboboxContext.Provider value={context}>\n <div ref={rootRef} className={cn(\"relative w-full\", className)}>\n {children}\n </div>\n </ComboboxContext.Provider>\n );\n}\n"],"mappings":";;;;;;AA+BA,MAAM,iBAAiC,OAAO,OAAO,aAAa;CAChE,MAAM,SAAS,MAAM,KAAK,CAAC,CAAC,kBAAkB;CAC9C,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,kBAAkB;CAClE,IAAI,aAAa;CACjB,KAAK,MAAM,aAAa,UAAU;EAChC,IAAI,cAAc,OAAO,aAAa,cAAc;EACpD,IAAI,eAAe,OAAO,QAAQ,OAAO;CAC3C;CACA,OAAO;AACT;AA+BA,MAAa,kBAAkB,cAA2C,IAAI;AAC9E,MAAa,uBAAuB,cAA6B,IAAI;AAErE,SAAgB,mBAAmB,WAAmB;CACpD,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,GAAG,UAAU,gCAAgC;CAC3E,OAAO;AACT;AAEA,SAAgB,UAAa,GAAG,MAAiC;CAC/D,QAAQ,SAAmB;EACzB,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,OAAO,OAAO,QAAQ,UAAU,IAAoC,UAAU;CAE3F;AACF;AAkBA,SAAgB,SAAS,EACvB,UACA,OAAO,iBACP,cACA,eACA,MAAM,gBACN,cAAc,OACd,cACA,OAAO,iBACP,eAAe,IACf,eACA,SAAS,eACT,WAAW,OACX,aACgB;CAChB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,SAAS,MAAM;CACrB,MAAM,UAAU,OAAuB,IAAI;CAC3C,MAAM,aAAa,OAAuB,IAAI;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AAC,gBAAgB,UAAjB;EAA0B,OAAO;EAC/B,UAAA,oBAAC,OAAD;GAAK,KAAK;GAAS,WAAW,GAAG,mBAAmB,SAAS;GAC1D;EACE,CAAA;CACmB,CAAA;AAE9B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"copy-menu-1FKoMc9o.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// ─── panels ──────────────────────────────────────────────────────────────────\n\n/**\n * Names one time field week-wide, because the scheduler holds a single open\n * panel for the whole week. Range ids belong to the value and are only unique\n * within a day, so the day is part of the name — and the scheduler builds the\n * same keys to ask whether the panel it is holding is still on screen.\n */\nexport const panelKey = (day: DayKey, rangeId: string, edge: \"start\" | \"end\") =>\n `${day}:${rangeId}:${edge}`;\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;;;;;;;AAUA,MAAa,YAAY,KAAa,SAAiB,SACrD,GAAG,IAAI,GAAG,QAAQ,GAAG;AAIvB,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,KAAK,MAAM,UAAU,EAAE;CACjC,MAAM,IAAI,UAAU;CACpB,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AACnE;AAEA,MAAa,WAAW,MAAc;CACpC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtC,MAAM,KAAK,IAAI,KAAK,OAAO;CAE3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