@kumix/ui 0.3.9 → 0.3.11

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 (169) hide show
  1. package/README.md +15 -14
  2. package/dist/components/motion/adaptive-stepper.d.ts +32 -0
  3. package/dist/components/motion/adaptive-stepper.d.ts.map +1 -0
  4. package/dist/components/motion/adaptive-stepper.js +302 -0
  5. package/dist/components/motion/adaptive-stepper.js.map +1 -0
  6. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  7. package/dist/components/motion/animated-sidebar.js.map +1 -1
  8. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  9. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
  10. package/dist/components/motion/availability-scheduler/day-row.js +15 -7
  11. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
  12. package/dist/components/motion/availability-scheduler/index.js +1 -1
  13. package/dist/components/motion/button/index.d.ts +2 -1
  14. package/dist/components/motion/button/index.js +2 -1
  15. package/dist/components/motion/button/metallic.d.ts +10 -0
  16. package/dist/components/motion/button/metallic.d.ts.map +1 -0
  17. package/dist/components/motion/button/metallic.js +71 -0
  18. package/dist/components/motion/button/metallic.js.map +1 -0
  19. package/dist/components/motion/combobox/content.js +1 -1
  20. package/dist/components/motion/combobox/context.js +216 -1
  21. package/dist/components/motion/combobox/context.js.map +1 -0
  22. package/dist/components/motion/combobox/list.js +1 -1
  23. package/dist/components/motion/combobox/trigger.js +1 -1
  24. package/dist/components/motion/combobox.js +1 -1
  25. package/dist/components/motion/expandable-control.d.ts +28 -0
  26. package/dist/components/motion/expandable-control.d.ts.map +1 -0
  27. package/dist/components/motion/expandable-control.js +149 -0
  28. package/dist/components/motion/expandable-control.js.map +1 -0
  29. package/dist/components/motion/expanding-arrow-button.d.ts +12 -0
  30. package/dist/components/motion/expanding-arrow-button.d.ts.map +1 -0
  31. package/dist/components/motion/expanding-arrow-button.js +142 -0
  32. package/dist/components/motion/expanding-arrow-button.js.map +1 -0
  33. package/dist/components/motion/file-tree.d.ts +42 -0
  34. package/dist/components/motion/file-tree.d.ts.map +1 -0
  35. package/dist/components/motion/file-tree.js +272 -0
  36. package/dist/components/motion/file-tree.js.map +1 -0
  37. package/dist/components/motion/input.d.ts +2 -0
  38. package/dist/components/motion/input.d.ts.map +1 -1
  39. package/dist/components/motion/input.js +28 -25
  40. package/dist/components/motion/input.js.map +1 -1
  41. package/dist/components/motion/liquid.d.ts +30 -0
  42. package/dist/components/motion/liquid.d.ts.map +1 -0
  43. package/dist/components/motion/liquid.js +248 -0
  44. package/dist/components/motion/liquid.js.map +1 -0
  45. package/dist/components/motion/multi-select/content.d.ts +16 -0
  46. package/dist/components/motion/multi-select/content.d.ts.map +1 -0
  47. package/dist/components/motion/multi-select/content.js +91 -0
  48. package/dist/components/motion/multi-select/content.js.map +1 -0
  49. package/dist/components/motion/multi-select/context.d.ts +64 -0
  50. package/dist/components/motion/multi-select/context.d.ts.map +1 -0
  51. package/dist/{context-BizvUNZv.js → components/motion/multi-select/context.js} +44 -114
  52. package/dist/components/motion/multi-select/context.js.map +1 -0
  53. package/dist/components/motion/multi-select/index.d.ts +5 -0
  54. package/dist/components/motion/multi-select/index.js +6 -0
  55. package/dist/components/motion/multi-select/list.d.ts +40 -0
  56. package/dist/components/motion/multi-select/list.d.ts.map +1 -0
  57. package/dist/components/motion/multi-select/list.js +144 -0
  58. package/dist/components/motion/multi-select/list.js.map +1 -0
  59. package/dist/components/motion/multi-select/trigger.d.ts +22 -0
  60. package/dist/components/motion/multi-select/trigger.d.ts.map +1 -0
  61. package/dist/components/motion/multi-select/trigger.js +185 -0
  62. package/dist/components/motion/multi-select/trigger.js.map +1 -0
  63. package/dist/components/motion/signup-form.js +6 -2
  64. package/dist/components/motion/signup-form.js.map +1 -1
  65. package/dist/components/motion/table/index.js.map +1 -1
  66. package/dist/components/reui/alert.d.ts +1 -1
  67. package/dist/components/reui/badge.d.ts +1 -1
  68. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
  69. package/dist/components/reui/cascader/cascader-async.js.map +1 -1
  70. package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -1
  71. package/dist/components/reui/cascader/cascader-virtual.js.map +1 -1
  72. package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
  73. package/dist/components/reui/cascader/cascader.js.map +1 -1
  74. package/dist/components/reui/code-block/code-block-highlight.d.ts +216 -0
  75. package/dist/components/reui/code-block/code-block-highlight.d.ts.map +1 -0
  76. package/dist/components/reui/code-block/code-block-highlight.js +792 -0
  77. package/dist/components/reui/code-block/code-block-highlight.js.map +1 -0
  78. package/dist/components/reui/code-block/code-block.d.ts +197 -0
  79. package/dist/components/reui/code-block/code-block.d.ts.map +1 -0
  80. package/dist/components/reui/code-block/code-block.js +1150 -0
  81. package/dist/components/reui/code-block/code-block.js.map +1 -0
  82. package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts +117 -0
  83. package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -0
  84. package/dist/components/reui/data-grid/data-grid-cell-selection.js +1554 -0
  85. package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -0
  86. package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
  87. package/dist/components/reui/data-grid/data-grid-column-filter.js +6 -4
  88. package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
  89. package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
  90. package/dist/components/reui/data-grid/data-grid-column-header.js +10 -7
  91. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
  92. package/dist/components/reui/data-grid/data-grid-column-visibility.js +3 -2
  93. package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
  94. package/dist/components/reui/data-grid/data-grid-i18n.d.ts +2 -0
  95. package/dist/components/reui/data-grid/data-grid-i18n.js +53 -0
  96. package/dist/components/reui/data-grid/data-grid-i18n.js.map +1 -0
  97. package/dist/components/reui/data-grid/data-grid-pagination.js +14 -8
  98. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
  99. package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
  100. package/dist/components/reui/data-grid/data-grid-scroll-area.js +3 -3
  101. package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
  102. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
  103. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +6 -4
  104. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
  105. package/dist/components/reui/data-grid/data-grid-table-dnd.js +2 -2
  106. package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
  107. package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +17 -1
  108. package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
  109. package/dist/components/reui/data-grid/data-grid-table-virtual.js +146 -50
  110. package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
  111. package/dist/components/reui/data-grid/data-grid-table.d.ts +23 -4
  112. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
  113. package/dist/components/reui/data-grid/data-grid-table.js +215 -68
  114. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  115. package/dist/components/reui/data-grid/data-grid.d.ts +276 -6
  116. package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
  117. package/dist/components/reui/data-grid/data-grid.js +150 -15
  118. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  119. package/dist/components/reui/filters/filters-advanced.js.map +1 -1
  120. package/dist/components/reui/filters/filters-chip.js.map +1 -1
  121. package/dist/components/reui/filters/filters.d.ts.map +1 -1
  122. package/dist/components/reui/filters/filters.js.map +1 -1
  123. package/dist/components/reui/frame.d.ts +1 -1
  124. package/dist/components/reui/gantt/gantt-bar.js +42 -12
  125. package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
  126. package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -1
  127. package/dist/components/reui/gantt/gantt-dnd.js +22 -7
  128. package/dist/components/reui/gantt/gantt-dnd.js.map +1 -1
  129. package/dist/components/reui/gantt/gantt-i18n.d.ts +8 -0
  130. package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -1
  131. package/dist/components/reui/gantt/gantt-i18n.js +6 -1
  132. package/dist/components/reui/gantt/gantt-i18n.js.map +1 -1
  133. package/dist/components/reui/gantt/gantt-lib.d.ts +59 -2
  134. package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -1
  135. package/dist/components/reui/gantt/gantt-lib.js +67 -2
  136. package/dist/components/reui/gantt/gantt-lib.js.map +1 -1
  137. package/dist/components/reui/gantt/gantt-recurrence.js +3 -3
  138. package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -1
  139. package/dist/components/reui/gantt/gantt-types.d.ts +32 -1
  140. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  141. package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -1
  142. package/dist/components/reui/gantt/gantt-view.js +324 -35
  143. package/dist/components/reui/gantt/gantt-view.js.map +1 -1
  144. package/dist/components/reui/gantt/gantt.d.ts +71 -2
  145. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  146. package/dist/components/reui/gantt/gantt.js +8 -0
  147. package/dist/components/reui/gantt/gantt.js.map +1 -1
  148. package/dist/components/reui/icon-tile.d.ts +1 -1
  149. package/dist/components/ui/attachment.d.ts +1 -1
  150. package/dist/components/ui/badge.d.ts +1 -1
  151. package/dist/components/ui/bubble.d.ts +1 -1
  152. package/dist/components/ui/button-group.d.ts +1 -1
  153. package/dist/components/ui/button.d.ts +1 -1
  154. package/dist/components/ui/field.d.ts +1 -1
  155. package/dist/components/ui/item.d.ts +1 -1
  156. package/dist/components/ui/message-scroller.js +1 -1
  157. package/dist/components/ui/message-scroller.js.map +1 -1
  158. package/dist/components/ui/sidebar.d.ts +1 -1
  159. package/dist/components/ui/toggle.d.ts +1 -1
  160. package/dist/{copy-menu-1FKoMc9o.js → copy-menu-C5GaT4Z-.js} +67 -2
  161. package/dist/copy-menu-C5GaT4Z-.js.map +1 -0
  162. package/dist/data-grid-i18n-52UUYPbr.d.ts +66 -0
  163. package/dist/data-grid-i18n-52UUYPbr.d.ts.map +1 -0
  164. package/dist/types-smkWN_7x.d.ts.map +1 -1
  165. package/dist/use-active-option-CmX6Z-4S.js +86 -0
  166. package/dist/use-active-option-CmX6Z-4S.js.map +1 -0
  167. package/package.json +7 -13
  168. package/dist/context-BizvUNZv.js.map +0 -1
  169. package/dist/copy-menu-1FKoMc9o.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expanding-arrow-button.js","names":[],"sources":["../../../src/components/motion/expanding-arrow-button.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FocusEvent, forwardRef, type MouseEvent, type ReactNode, useState } from \"react\";\nimport { type HTMLMotionProps, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\nexport interface ExpandingArrowButtonProps extends Omit<HTMLMotionProps<\"button\">, \"children\"> {\n children: ReactNode;\n accentClassName?: string;\n labelClassName?: string;\n}\n\nconst ARROW_OPACITY = [1, 0.78, 0.54, 0.32, 0.16] as const;\n\nfunction DottedChevron({ className }: { className?: string }) {\n return (\n <svg viewBox=\"0 0 20 28\" fill=\"none\" aria-hidden=\"true\" className={className}>\n <circle cx=\"4\" cy=\"4\" r=\"2\" fill=\"currentColor\" />\n <circle cx=\"10\" cy=\"9\" r=\"2\" fill=\"currentColor\" />\n <circle cx=\"16\" cy=\"14\" r=\"2\" fill=\"currentColor\" />\n <circle cx=\"10\" cy=\"19\" r=\"2\" fill=\"currentColor\" />\n <circle cx=\"4\" cy=\"24\" r=\"2\" fill=\"currentColor\" />\n </svg>\n );\n}\n\nexport const ExpandingArrowButton = forwardRef<HTMLButtonElement, ExpandingArrowButtonProps>(\n function ExpandingArrowButton(\n {\n children,\n className,\n accentClassName,\n labelClassName,\n disabled,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n ...rest\n },\n ref,\n ) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const active = !disabled && ((canHover && hovered) || focused);\n const layoutTransition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n\n const handleMouseEnter = (event: MouseEvent<HTMLButtonElement>) => {\n setHovered(true);\n onMouseEnter?.(event);\n };\n\n const handleMouseLeave = (event: MouseEvent<HTMLButtonElement>) => {\n setHovered(false);\n onMouseLeave?.(event);\n };\n\n const handleFocus = (event: FocusEvent<HTMLButtonElement>) => {\n setFocused(true);\n onFocus?.(event);\n };\n\n const handleBlur = (event: FocusEvent<HTMLButtonElement>) => {\n setFocused(false);\n onBlur?.(event);\n };\n\n return (\n <motion.button\n ref={ref}\n type=\"button\"\n disabled={disabled}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onFocus={handleFocus}\n onBlur={handleBlur}\n whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n transition={SPRING_PRESS}\n className={cn(\n \"relative inline-flex h-16 min-w-72 select-none items-center overflow-hidden rounded-[22px] bg-neutral-950 p-1.5 text-white\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-lime-300 focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n {...rest}\n >\n <motion.span\n layout=\"size\"\n aria-hidden=\"true\"\n transition={layoutTransition}\n style={{\n width: active ? \"calc(100% - 12px)\" : 52,\n borderRadius: 16,\n }}\n className={cn(\n \"absolute inset-y-1.5 left-1.5 z-10 overflow-hidden bg-lime-300 text-neutral-950\",\n accentClassName,\n )}\n >\n <motion.span\n animate={{ opacity: active ? 0 : 1 }}\n transition={{ duration: reduce ? 0 : 0.1, ease: EASE_OUT }}\n className=\"absolute inset-0 grid place-items-center\"\n >\n <DottedChevron className=\"h-7 w-5\" />\n </motion.span>\n\n <span className=\"absolute inset-0 flex items-center justify-around px-3\">\n {ARROW_OPACITY.map((opacity, index) => (\n <motion.span\n key={opacity}\n animate={{\n opacity: active ? 1 : 0,\n transform: active && !reduce ? \"translateX(0px)\" : \"translateX(-6px)\",\n }}\n transition={{\n duration: reduce ? 0 : 0.18,\n delay: active && !reduce ? 0.04 + index * 0.025 : 0,\n ease: EASE_OUT,\n }}\n style={{ color: `rgb(10 10 10 / ${opacity})` }}\n className=\"inline-grid place-items-center\"\n >\n <DottedChevron className=\"h-7 w-5\" />\n </motion.span>\n ))}\n </span>\n </motion.span>\n\n <motion.span\n animate={{\n opacity: active ? 0 : 1,\n transform: active && !reduce ? \"translateX(6px)\" : \"translateX(0px)\",\n }}\n transition={{ duration: reduce ? 0 : 0.12, ease: EASE_OUT }}\n className={cn(\n \"relative z-0 mr-5 ml-[76px] whitespace-nowrap font-medium text-lg tracking-[-0.02em]\",\n labelClassName,\n )}\n >\n {children}\n </motion.span>\n </motion.button>\n );\n },\n);\n"],"mappings":";;;;;;;;AAeA,MAAM,gBAAgB;CAAC;CAAG;CAAM;CAAM;CAAM;AAAI;AAEhD,SAAS,cAAc,EAAE,aAAqC;CAC5D,OACE,qBAAC,OAAD;EAAK,SAAQ;EAAY,MAAK;EAAO,eAAY;EAAkB;EAAnE,UAAA;GACE,oBAAC,UAAD;IAAQ,IAAG;IAAI,IAAG;IAAI,GAAE;IAAI,MAAK;GAAgB,CAAA;GACjD,oBAAC,UAAD;IAAQ,IAAG;IAAK,IAAG;IAAI,GAAE;IAAI,MAAK;GAAgB,CAAA;GAClD,oBAAC,UAAD;IAAQ,IAAG;IAAK,IAAG;IAAK,GAAE;IAAI,MAAK;GAAgB,CAAA;GACnD,oBAAC,UAAD;IAAQ,IAAG;IAAK,IAAG;IAAK,GAAE;IAAI,MAAK;GAAg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UAAA,oBAAC,eAAD,EAAe,WAAU,UAAW,CAAA;GACzB,CAAA,GAEb,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,cAAc,KAAK,SAAS,UAC3B,oBAAC,OAAO,MAAR;KAEE,SAAS;MACP,SAAS,SAAS,IAAI;MACtB,WAAW,UAAU,CAAC,SAAS,oBAAoB;KACrD;KACA,YAAY;MACV,UAAU,SAAS,IAAI;MACvB,OAAO,UAAU,CAAC,SAAS,MAAO,QAAQ,OAAQ;MAClD,MAAM;KACR;KACA,OAAO,EAAE,OAAO,kBAAkB,QAAQ,GAAG;KAC7C,WAAU;KAEV,UAAA,oBAAC,eAAD,EAAe,WAAU,UAAW,CAAA;IACzB,GAdN,OAcM,CACd;GACG,CAAA,CACK;EAEb,CAAA,GAAA,oBAAC,OAAO,MAAR;GACE,SAAS;IACP,SAAS,SAAS,IAAI;IACtB,WAAW,UAAU,CAAC,SAAS,oBAAoB;GACrD;GACA,YAAY;IAAE,UAAU,SAAS,IAAI;IAAM,MAAM;GAAS;GAC1D,WAAW,GACT,wFACA,cACF;GAEC;EACU,CAAA,CACA;;AAEnB,CACF"}
@@ -0,0 +1,42 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/motion/file-tree.d.ts
3
+ interface FileTreeFolderProps {
4
+ value: string;
5
+ name: string;
6
+ icon?: ReactNode;
7
+ disabled?: boolean;
8
+ children?: ReactNode;
9
+ className?: string;
10
+ }
11
+ interface FileTreeFileProps {
12
+ value: string;
13
+ name: string;
14
+ icon?: ReactNode;
15
+ disabled?: boolean;
16
+ className?: string;
17
+ }
18
+ type FileTreeClassNames = {
19
+ tree?: string;
20
+ item?: string;
21
+ icon?: string;
22
+ label?: string;
23
+ };
24
+ interface FileTreeProps {
25
+ children: ReactNode;
26
+ value?: string | null;
27
+ defaultValue?: string | null;
28
+ onValueChange?: (value: string) => void;
29
+ expandedIds?: string[];
30
+ defaultExpandedIds?: string[];
31
+ onExpandedChange?: (expandedIds: string[]) => void;
32
+ ariaLabel?: string;
33
+ indent?: number;
34
+ className?: string;
35
+ classNames?: FileTreeClassNames;
36
+ }
37
+ declare function FileTreeFolder(_props: FileTreeFolderProps): null;
38
+ declare function FileTreeFile(_props: FileTreeFileProps): null;
39
+ declare function FileTree({ children, value, defaultValue, onValueChange, expandedIds, defaultExpandedIds, onExpandedChange, ariaLabel, indent, className, classNames }: FileTreeProps): import("react").JSX.Element;
40
+ //#endregion
41
+ export { FileTree, FileTreeClassNames, FileTreeFile, FileTreeFileProps, FileTreeFolder, FileTreeFolderProps, FileTreeProps };
42
+ //# sourceMappingURL=file-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tree.d.ts","names":[],"sources":["../../../src/components/motion/file-tree.tsx"],"mappings":";;UA8BiB;EACf;EACA;EACA,OAAO;EACP;EACA,WAAW;EACX;;UAGe;EACf;EACA;EACA,OAAO;EACP;EACA;;KAGU;EACV;EACA;EACA;EACA;;UAGe;EACf,UAAU;EACV;EACA;EACA,iBAAiB;EACjB;EACA;EACA,oBAAoB;EACpB;EACA;EACA;EACA,aAAa;;iBAaC,eAAe,QAAQ;iBAIvB,aAAa,QAAQ;iBAsGrB,WACd,UACA,OACA,cACA,eACA,aACA,oBACA,kBACA,WACA,QACA,WACA,cACC,gCAAa,IAAA"}
@@ -0,0 +1,272 @@
1
+ "use client";
2
+ import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../lib/ease.js";
3
+ import { SharedLayoutBg } from "./shared-layout-bg.js";
4
+ import { Children, Fragment, isValidElement, useCallback, useMemo, useRef, useState } from "react";
5
+ import { cn } from "@kumix/utils";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
8
+ import { ChevronRight, File, Folder, FolderOpen } from "lucide-react";
9
+ //#region src/components/motion/file-tree.tsx
10
+ function FileTreeFolder(_props) {
11
+ return null;
12
+ }
13
+ function FileTreeFile(_props) {
14
+ return null;
15
+ }
16
+ const ROW_ENTER = {
17
+ duration: .22,
18
+ ease: EASE_OUT
19
+ };
20
+ const BRANCH_DRAW = {
21
+ duration: .3,
22
+ ease: EASE_OUT
23
+ };
24
+ function flattenItems(items, expanded, depth = 0, parentId = null) {
25
+ return items.flatMap((item, index) => {
26
+ const row = {
27
+ item,
28
+ depth,
29
+ parentId,
30
+ position: index + 1,
31
+ setSize: items.length
32
+ };
33
+ if (item.type !== "folder" || !expanded.has(item.value) || !item.children?.length) return [row];
34
+ return [row, ...flattenItems(item.children, expanded, depth + 1, item.value)];
35
+ });
36
+ }
37
+ function itemsFromChildren(children) {
38
+ const items = [];
39
+ Children.forEach(children, (child) => {
40
+ if (!isValidElement(child)) return;
41
+ if (child.type === Fragment) {
42
+ const props = child.props;
43
+ items.push(...itemsFromChildren(props.children));
44
+ return;
45
+ }
46
+ if (child.type === FileTreeFolder) {
47
+ const props = child.props;
48
+ items.push({
49
+ value: props.value,
50
+ name: props.name,
51
+ type: "folder",
52
+ icon: props.icon,
53
+ disabled: props.disabled,
54
+ className: props.className,
55
+ children: itemsFromChildren(props.children)
56
+ });
57
+ return;
58
+ }
59
+ if (child.type === FileTreeFile) {
60
+ const props = child.props;
61
+ items.push({
62
+ value: props.value,
63
+ name: props.name,
64
+ type: "file",
65
+ icon: props.icon,
66
+ disabled: props.disabled,
67
+ className: props.className
68
+ });
69
+ }
70
+ });
71
+ return items;
72
+ }
73
+ function DefaultIcon({ item, open, reduce }) {
74
+ if (item.type === "file") return /* @__PURE__ */ jsx(File, { className: "size-4" });
75
+ if (reduce) return open ? /* @__PURE__ */ jsx(FolderOpen, { className: "size-4" }) : /* @__PURE__ */ jsx(Folder, { className: "size-4" });
76
+ return /* @__PURE__ */ jsx(AnimatePresence, {
77
+ initial: false,
78
+ mode: "popLayout",
79
+ children: /* @__PURE__ */ jsx(motion.span, {
80
+ initial: {
81
+ opacity: 0,
82
+ scale: .75,
83
+ rotate: open ? -8 : 8
84
+ },
85
+ animate: {
86
+ opacity: 1,
87
+ scale: 1,
88
+ rotate: 0
89
+ },
90
+ exit: {
91
+ opacity: 0,
92
+ scale: .75,
93
+ rotate: open ? 8 : -8
94
+ },
95
+ transition: SPRING_SWAP,
96
+ className: "absolute inset-0 grid place-items-center",
97
+ children: open ? /* @__PURE__ */ jsx(FolderOpen, { className: "size-4" }) : /* @__PURE__ */ jsx(Folder, { className: "size-4" })
98
+ }, open ? "open" : "closed")
99
+ });
100
+ }
101
+ function FileTree({ children, value, defaultValue = null, onValueChange, expandedIds, defaultExpandedIds = [], onExpandedChange, ariaLabel = "Files", indent = 18, className, classNames }) {
102
+ const reduce = useReducedMotion() ?? false;
103
+ const [internalValue, setInternalValue] = useState(defaultValue);
104
+ const [internalExpandedIds, setInternalExpandedIds] = useState(defaultExpandedIds);
105
+ const [focusedId, setFocusedId] = useState(value ?? defaultValue);
106
+ const rowRefs = useRef(/* @__PURE__ */ new Map());
107
+ const selectedId = value === void 0 ? internalValue : value;
108
+ const currentExpandedIds = expandedIds ?? internalExpandedIds;
109
+ const expanded = useMemo(() => new Set(currentExpandedIds), [currentExpandedIds]);
110
+ const items = useMemo(() => itemsFromChildren(children), [children]);
111
+ const rows = useMemo(() => flattenItems(items, expanded), [expanded, items]);
112
+ const focusedRow = focusedId !== null && rows.some(({ item }) => item.value === focusedId) ? focusedId : rows[0]?.item.value ?? null;
113
+ if (focusedId !== focusedRow) setFocusedId(focusedRow);
114
+ const focusRow = useCallback((id) => {
115
+ setFocusedId(id);
116
+ const row = rowRefs.current.get(id);
117
+ if (row) row.focus();
118
+ else requestAnimationFrame(() => rowRefs.current.get(id)?.focus());
119
+ }, []);
120
+ const selectItem = useCallback((item) => {
121
+ if (item.disabled) return;
122
+ if (value === void 0) setInternalValue(item.value);
123
+ onValueChange?.(item.value);
124
+ }, [onValueChange, value]);
125
+ const setExpanded = useCallback((next) => {
126
+ if (expandedIds === void 0) setInternalExpandedIds(next);
127
+ onExpandedChange?.(next);
128
+ }, [expandedIds, onExpandedChange]);
129
+ const toggleFolder = useCallback((id) => {
130
+ const next = new Set(currentExpandedIds);
131
+ if (next.has(id)) next.delete(id);
132
+ else next.add(id);
133
+ setExpanded(Array.from(next));
134
+ }, [currentExpandedIds, setExpanded]);
135
+ const handleKeyDown = useCallback((event, row) => {
136
+ const index = rows.findIndex(({ item }) => item.value === row.item.value);
137
+ const previous = rows[index - 1];
138
+ const next = rows[index + 1];
139
+ const isFolder = row.item.type === "folder";
140
+ const isOpen = expanded.has(row.item.value);
141
+ if (event.key === "ArrowDown" && next) {
142
+ event.preventDefault();
143
+ focusRow(next.item.value);
144
+ } else if (event.key === "ArrowUp" && previous) {
145
+ event.preventDefault();
146
+ focusRow(previous.item.value);
147
+ } else if (event.key === "Home" && rows[0]) {
148
+ event.preventDefault();
149
+ focusRow(rows[0].item.value);
150
+ } else if (event.key === "End" && rows.at(-1)) {
151
+ event.preventDefault();
152
+ focusRow(rows.at(-1)?.item.value ?? row.item.value);
153
+ } else if (event.key === "ArrowRight" && isFolder) {
154
+ event.preventDefault();
155
+ if (!isOpen && !row.item.disabled) toggleFolder(row.item.value);
156
+ else if (next?.parentId === row.item.value) focusRow(next.item.value);
157
+ } else if (event.key === "ArrowLeft") {
158
+ event.preventDefault();
159
+ if (isFolder && isOpen && !row.item.disabled) toggleFolder(row.item.value);
160
+ else if (row.parentId) focusRow(row.parentId);
161
+ } else if (event.key === "Enter" || event.key === " ") {
162
+ event.preventDefault();
163
+ if (row.item.disabled) return;
164
+ selectItem(row.item);
165
+ if (isFolder) toggleFolder(row.item.value);
166
+ }
167
+ }, [
168
+ expanded,
169
+ focusRow,
170
+ rows,
171
+ selectItem,
172
+ toggleFolder
173
+ ]);
174
+ return /* @__PURE__ */ jsx(SharedLayoutBg, {
175
+ role: "tree",
176
+ "aria-label": ariaLabel,
177
+ "aria-multiselectable": "false",
178
+ inset: 0,
179
+ pillClassName: "rounded-xl bg-muted",
180
+ pillContainerClassName: "inset-y-auto top-0 h-9",
181
+ className: cn("min-w-0", className, classNames?.tree),
182
+ children: rows.map((row) => {
183
+ const isFolder = row.item.type === "folder";
184
+ const isOpen = isFolder && expanded.has(row.item.value);
185
+ const isSelected = selectedId === row.item.value;
186
+ return /* @__PURE__ */ jsx(motion.div, {
187
+ layout: reduce ? false : "position",
188
+ initial: reduce ? false : {
189
+ opacity: 0,
190
+ y: -6
191
+ },
192
+ animate: {
193
+ opacity: row.item.disabled ? .42 : 1,
194
+ y: 0,
195
+ transition: reduce ? { duration: 0 } : {
196
+ ...ROW_ENTER,
197
+ delay: Math.min(row.position * .025, .1)
198
+ }
199
+ },
200
+ transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
201
+ children: /* @__PURE__ */ jsxs("button", {
202
+ ref: (node) => {
203
+ if (node) rowRefs.current.set(row.item.value, node);
204
+ else rowRefs.current.delete(row.item.value);
205
+ },
206
+ type: "button",
207
+ role: "treeitem",
208
+ "aria-level": row.depth + 1,
209
+ "aria-posinset": row.position,
210
+ "aria-setsize": row.setSize,
211
+ "aria-selected": isSelected,
212
+ "aria-expanded": isFolder ? isOpen : void 0,
213
+ "aria-disabled": row.item.disabled || void 0,
214
+ tabIndex: focusedRow === row.item.value ? 0 : -1,
215
+ onFocus: () => setFocusedId(row.item.value),
216
+ onKeyDown: (event) => handleKeyDown(event, row),
217
+ onClick: () => {
218
+ if (row.item.disabled) return;
219
+ selectItem(row.item);
220
+ if (isFolder) toggleFolder(row.item.value);
221
+ },
222
+ className: cn("group/file-tree relative flex h-9 w-full items-center gap-2 overflow-hidden rounded-lg pr-2 text-left text-muted-foreground text-sm outline-none", "transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", "aria-disabled:cursor-not-allowed", isSelected && "bg-muted font-medium text-foreground", classNames?.item, row.item.className),
223
+ style: { paddingLeft: 8 + row.depth * indent },
224
+ children: [
225
+ row.depth > 0 ? /* @__PURE__ */ jsx(motion.span, {
226
+ "aria-hidden": "true",
227
+ initial: reduce ? false : {
228
+ opacity: 0,
229
+ scaleY: 0
230
+ },
231
+ animate: {
232
+ opacity: 1,
233
+ scaleY: 1
234
+ },
235
+ exit: {
236
+ opacity: 0,
237
+ scaleY: 0
238
+ },
239
+ transition: reduce ? { duration: 0 } : BRANCH_DRAW,
240
+ className: "absolute top-0 bottom-0 w-px origin-top bg-border/70",
241
+ style: { left: 16 + (row.depth - 1) * indent }
242
+ }) : null,
243
+ /* @__PURE__ */ jsx(motion.span, {
244
+ "aria-hidden": "true",
245
+ animate: { rotate: isOpen ? 90 : 0 },
246
+ transition: reduce ? { duration: 0 } : SPRING_SWAP,
247
+ className: cn("relative z-10 grid size-4 shrink-0 place-items-center", !isFolder && "opacity-0"),
248
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5" })
249
+ }),
250
+ /* @__PURE__ */ jsx("span", {
251
+ "aria-hidden": "true",
252
+ className: cn("relative z-10 grid size-4 shrink-0 place-items-center text-muted-foreground transition-colors group-hover/file-tree:text-foreground", isFolder && isOpen && "text-foreground", classNames?.icon),
253
+ children: row.item.icon ?? /* @__PURE__ */ jsx(DefaultIcon, {
254
+ item: row.item,
255
+ open: isOpen,
256
+ reduce
257
+ })
258
+ }),
259
+ /* @__PURE__ */ jsx("span", {
260
+ className: cn("relative z-10 min-w-0 flex-1 truncate", classNames?.label),
261
+ children: row.item.name
262
+ })
263
+ ]
264
+ })
265
+ }, row.item.value);
266
+ })
267
+ });
268
+ }
269
+ //#endregion
270
+ export { FileTree, FileTreeFile, FileTreeFolder };
271
+
272
+ //# sourceMappingURL=file-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tree.js","names":[],"sources":["../../../src/components/motion/file-tree.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Children,\n Fragment,\n isValidElement,\n type KeyboardEvent,\n type ReactNode,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronRight, File, Folder, FolderOpen } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from \"../../lib/ease\";\nimport { SharedLayoutBg } from \"./shared-layout-bg\";\n\ntype FileTreeItem = {\n value: string;\n name: string;\n type: \"file\" | \"folder\";\n children?: FileTreeItem[];\n icon?: ReactNode;\n disabled?: boolean;\n className?: string;\n};\n\nexport interface FileTreeFolderProps {\n value: string;\n name: string;\n icon?: ReactNode;\n disabled?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\nexport interface FileTreeFileProps {\n value: string;\n name: string;\n icon?: ReactNode;\n disabled?: boolean;\n className?: string;\n}\n\nexport type FileTreeClassNames = {\n tree?: string;\n item?: string;\n icon?: string;\n label?: string;\n};\n\nexport interface FileTreeProps {\n children: ReactNode;\n value?: string | null;\n defaultValue?: string | null;\n onValueChange?: (value: string) => void;\n expandedIds?: string[];\n defaultExpandedIds?: string[];\n onExpandedChange?: (expandedIds: string[]) => void;\n ariaLabel?: string;\n indent?: number;\n className?: string;\n classNames?: FileTreeClassNames;\n}\n\ntype FlatFileTreeItem = {\n item: FileTreeItem;\n depth: number;\n parentId: string | null;\n position: number;\n setSize: number;\n};\n\n// These declarative parts are read by FileTree and turned into one flattened,\n// keyboard-navigable collection. They intentionally render nothing alone.\nexport function FileTreeFolder(_props: FileTreeFolderProps) {\n return null;\n}\n\nexport function FileTreeFile(_props: FileTreeFileProps) {\n return null;\n}\n\nconst ROW_ENTER = { duration: 0.22, ease: EASE_OUT } as const;\nconst BRANCH_DRAW = { duration: 0.3, ease: EASE_OUT } as const;\n\nfunction flattenItems(\n items: FileTreeItem[],\n expanded: ReadonlySet<string>,\n depth = 0,\n parentId: string | null = null,\n): FlatFileTreeItem[] {\n return items.flatMap((item, index) => {\n const row = {\n item,\n depth,\n parentId,\n position: index + 1,\n setSize: items.length,\n };\n\n if (item.type !== \"folder\" || !expanded.has(item.value) || !item.children?.length) {\n return [row];\n }\n\n return [row, ...flattenItems(item.children, expanded, depth + 1, item.value)];\n });\n}\n\nfunction itemsFromChildren(children: ReactNode): FileTreeItem[] {\n const items: FileTreeItem[] = [];\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) return;\n\n if (child.type === Fragment) {\n const props = child.props as { children?: ReactNode };\n items.push(...itemsFromChildren(props.children));\n return;\n }\n\n if (child.type === FileTreeFolder) {\n const props = child.props as FileTreeFolderProps;\n items.push({\n value: props.value,\n name: props.name,\n type: \"folder\",\n icon: props.icon,\n disabled: props.disabled,\n className: props.className,\n children: itemsFromChildren(props.children),\n });\n return;\n }\n\n if (child.type === FileTreeFile) {\n const props = child.props as FileTreeFileProps;\n items.push({\n value: props.value,\n name: props.name,\n type: \"file\",\n icon: props.icon,\n disabled: props.disabled,\n className: props.className,\n });\n }\n });\n\n return items;\n}\n\nfunction DefaultIcon({\n item,\n open,\n reduce,\n}: {\n item: FileTreeItem;\n open: boolean;\n reduce: boolean;\n}) {\n if (item.type === \"file\") return <File className=\"size-4\" />;\n if (reduce) {\n return open ? <FolderOpen className=\"size-4\" /> : <Folder className=\"size-4\" />;\n }\n\n return (\n <AnimatePresence initial={false} mode=\"popLayout\">\n <motion.span\n key={open ? \"open\" : \"closed\"}\n initial={{ opacity: 0, scale: 0.75, rotate: open ? -8 : 8 }}\n animate={{ opacity: 1, scale: 1, rotate: 0 }}\n exit={{ opacity: 0, scale: 0.75, rotate: open ? 8 : -8 }}\n transition={SPRING_SWAP}\n className=\"absolute inset-0 grid place-items-center\"\n >\n {open ? <FolderOpen className=\"size-4\" /> : <Folder className=\"size-4\" />}\n </motion.span>\n </AnimatePresence>\n );\n}\n\nexport function FileTree({\n children,\n value,\n defaultValue = null,\n onValueChange,\n expandedIds,\n defaultExpandedIds = [],\n onExpandedChange,\n ariaLabel = \"Files\",\n indent = 18,\n className,\n classNames,\n}: FileTreeProps) {\n const reduce = useReducedMotion() ?? false;\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [internalExpandedIds, setInternalExpandedIds] = useState(defaultExpandedIds);\n const [focusedId, setFocusedId] = useState<string | null>(value ?? defaultValue);\n const rowRefs = useRef(new Map<string, HTMLButtonElement>());\n const selectedId = value === undefined ? internalValue : value;\n const currentExpandedIds = expandedIds ?? internalExpandedIds;\n const expanded = useMemo(() => new Set(currentExpandedIds), [currentExpandedIds]);\n const items = useMemo(() => itemsFromChildren(children), [children]);\n const rows = useMemo(() => flattenItems(items, expanded), [expanded, items]);\n\n // Keep a real row tabbable in the first commit and immediately after a\n // collapse removes the previously focused descendant.\n const focusedRow =\n focusedId !== null && rows.some(({ item }) => item.value === focusedId)\n ? focusedId\n : (rows[0]?.item.value ?? null);\n if (focusedId !== focusedRow) setFocusedId(focusedRow);\n\n const focusRow = useCallback((id: string) => {\n setFocusedId(id);\n const row = rowRefs.current.get(id);\n if (row) row.focus();\n else requestAnimationFrame(() => rowRefs.current.get(id)?.focus());\n }, []);\n\n const selectItem = useCallback(\n (item: FileTreeItem) => {\n if (item.disabled) return;\n if (value === undefined) setInternalValue(item.value);\n onValueChange?.(item.value);\n },\n [onValueChange, value],\n );\n\n const setExpanded = useCallback(\n (next: string[]) => {\n if (expandedIds === undefined) setInternalExpandedIds(next);\n onExpandedChange?.(next);\n },\n [expandedIds, onExpandedChange],\n );\n\n const toggleFolder = useCallback(\n (id: string) => {\n const next = new Set(currentExpandedIds);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n setExpanded(Array.from(next));\n },\n [currentExpandedIds, setExpanded],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLButtonElement>, row: FlatFileTreeItem) => {\n const index = rows.findIndex(({ item }) => item.value === row.item.value);\n const previous = rows[index - 1];\n const next = rows[index + 1];\n const isFolder = row.item.type === \"folder\";\n const isOpen = expanded.has(row.item.value);\n\n if (event.key === \"ArrowDown\" && next) {\n event.preventDefault();\n focusRow(next.item.value);\n } else if (event.key === \"ArrowUp\" && previous) {\n event.preventDefault();\n focusRow(previous.item.value);\n } else if (event.key === \"Home\" && rows[0]) {\n event.preventDefault();\n focusRow(rows[0].item.value);\n } else if (event.key === \"End\" && rows.at(-1)) {\n event.preventDefault();\n focusRow(rows.at(-1)?.item.value ?? row.item.value);\n } else if (event.key === \"ArrowRight\" && isFolder) {\n event.preventDefault();\n if (!isOpen && !row.item.disabled) toggleFolder(row.item.value);\n else if (next?.parentId === row.item.value) focusRow(next.item.value);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (isFolder && isOpen && !row.item.disabled) toggleFolder(row.item.value);\n else if (row.parentId) focusRow(row.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (row.item.disabled) return;\n selectItem(row.item);\n if (isFolder) toggleFolder(row.item.value);\n }\n },\n [expanded, focusRow, rows, selectItem, toggleFolder],\n );\n\n return (\n <SharedLayoutBg\n role=\"tree\"\n aria-label={ariaLabel}\n aria-multiselectable=\"false\"\n inset={0}\n pillClassName=\"rounded-xl bg-muted\"\n pillContainerClassName=\"inset-y-auto top-0 h-9\"\n className={cn(\"min-w-0\", className, classNames?.tree)}\n >\n {rows.map((row) => {\n const isFolder = row.item.type === \"folder\";\n const isOpen = isFolder && expanded.has(row.item.value);\n const isSelected = selectedId === row.item.value;\n\n return (\n <motion.div\n layout={reduce ? false : \"position\"}\n key={row.item.value}\n initial={reduce ? false : { opacity: 0, y: -6 }}\n animate={{\n opacity: row.item.disabled ? 0.42 : 1,\n y: 0,\n transition: reduce\n ? { duration: 0 }\n : {\n ...ROW_ENTER,\n delay: Math.min(row.position * 0.025, 0.1),\n },\n }}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n >\n <button\n ref={(node) => {\n if (node) rowRefs.current.set(row.item.value, node);\n else rowRefs.current.delete(row.item.value);\n }}\n type=\"button\"\n role=\"treeitem\"\n aria-level={row.depth + 1}\n aria-posinset={row.position}\n aria-setsize={row.setSize}\n aria-selected={isSelected}\n aria-expanded={isFolder ? isOpen : undefined}\n aria-disabled={row.item.disabled || undefined}\n tabIndex={focusedRow === row.item.value ? 0 : -1}\n onFocus={() => setFocusedId(row.item.value)}\n onKeyDown={(event) => handleKeyDown(event, row)}\n onClick={() => {\n if (row.item.disabled) return;\n selectItem(row.item);\n if (isFolder) toggleFolder(row.item.value);\n }}\n className={cn(\n \"group/file-tree relative flex h-9 w-full items-center gap-2 overflow-hidden rounded-lg pr-2 text-left text-muted-foreground text-sm outline-none\",\n \"transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset\",\n \"aria-disabled:cursor-not-allowed\",\n isSelected && \"bg-muted font-medium text-foreground\",\n classNames?.item,\n row.item.className,\n )}\n style={{ paddingLeft: 8 + row.depth * indent }}\n >\n {row.depth > 0 ? (\n <motion.span\n aria-hidden=\"true\"\n initial={reduce ? false : { opacity: 0, scaleY: 0 }}\n animate={{ opacity: 1, scaleY: 1 }}\n exit={{ opacity: 0, scaleY: 0 }}\n transition={reduce ? { duration: 0 } : BRANCH_DRAW}\n className=\"absolute top-0 bottom-0 w-px origin-top bg-border/70\"\n style={{ left: 16 + (row.depth - 1) * indent }}\n />\n ) : null}\n\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotate: isOpen ? 90 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_SWAP}\n className={cn(\n \"relative z-10 grid size-4 shrink-0 place-items-center\",\n !isFolder && \"opacity-0\",\n )}\n >\n <ChevronRight className=\"size-3.5\" />\n </motion.span>\n\n <span\n aria-hidden=\"true\"\n className={cn(\n \"relative z-10 grid size-4 shrink-0 place-items-center text-muted-foreground transition-colors group-hover/file-tree:text-foreground\",\n isFolder && isOpen && \"text-foreground\",\n classNames?.icon,\n )}\n >\n {row.item.icon ?? <DefaultIcon item={row.item} open={isOpen} reduce={reduce} />}\n </span>\n\n <span className={cn(\"relative z-10 min-w-0 flex-1 truncate\", classNames?.label)}>\n {row.item.name}\n </span>\n </button>\n </motion.div>\n );\n })}\n </SharedLayoutBg>\n );\n}\n"],"mappings":";;;;;;;;;AA8EA,SAAgB,eAAe,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,SAAS;QAAE,SAAS;QAAG,QAAQ;OAAE;OACjC,MAAM;QAAE,SAAS;QAAG,QAAQ;OAAE;OAC9B,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;OACvC,WAAU;OACV,OAAO,EAAE,MAAM,MAAM,IAAI,QAAQ,KAAK,OAAO;MAC9C,CAAA,IACC;MAEJ,oBAAC,OAAO,MAAR;OACE,eAAY;OACZ,SAAS,EAAE,QAAQ,SAAS,KAAK,EAAE;OACnC,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;OACvC,WAAW,GACT,yDACA,CAAC,YAAY,WACf;OAEA,UAAA,oBAAC,cAAD,EAAc,WAAU,WAAY,CAAA;MACzB,CAAA;MAEb,oBAAC,QAAD;OACE,eAAY;OACZ,WAAW,GACT,uIACA,YAAY,UAAU,mBACtB,YAAY,IACd;OAEC,UAAA,IAAI,KAAK,QAAQ,oBAAC,aAAD;QAAa,MAAM,IAAI;QAAM,MAAM;QAAgB;OAAS,CAAA;MAC1E,CAAA;MAEN,oBAAC,QAAD;OAAM,WAAW,GAAG,yCAAyC,YAAY,KAAK;OAC3E,UAAA,IAAI,KAAK;MACN,CAAA;KACA;;GACE,GApFL,IAAI,KAAK,KAoFJ;EAEhB,CAAC;CACa,CAAA;AAEpB"}
@@ -17,6 +17,8 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value"
17
17
  onChange?: (value: string) => void;
18
18
  /** Truthy error triggers a shake, red border and (if a string) a message. */
19
19
  error?: string | boolean;
20
+ /** Reserve one message line so validation does not shift nearby content. */
21
+ reserveErrorLine?: boolean;
20
22
  success?: boolean;
21
23
  leftIcon?: ReactNode;
22
24
  rightIcon?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","names":[],"sources":["../../../src/components/motion/input.tsx"],"mappings":";;KAeY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe,mBACP,KAAK,oBAAoB;EACjC;EACA;EACA;EACA,YAAY;;EAEZ;EACA;EACA,WAAW;EACX,YAAY;EACZ;EACA,aAAa;;cAGF,uBAAK,0BAAA,6BAAA,cAAA"}
1
+ {"version":3,"file":"input.d.ts","names":[],"sources":["../../../src/components/motion/input.tsx"],"mappings":";;KAeY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe,mBACP,KAAK,oBAAoB;EACjC;EACA;EACA;EACA,YAAY;;EAEZ;;EAEA;EACA;EACA,WAAW;EACX,YAAY;EACZ;EACA,aAAa;;cAGF,uBAAK,0BAAA,6BAAA,cAAA"}
@@ -4,7 +4,7 @@ import { cn } from "@kumix/utils";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { AnimatePresence, animate, motion, useReducedMotion } from "motion/react";
6
6
  //#region src/components/motion/input.tsx
7
- const Input = forwardRef(function Input({ label, value: valueProp, defaultValue, onChange, onFocus, onBlur, error, success, leftIcon, rightIcon, className, classNames, disabled, id: idProp, type, ...rest }, ref) {
7
+ const Input = forwardRef(function Input({ label, value: valueProp, defaultValue, onChange, onFocus, onBlur, error, reserveErrorLine = false, success, leftIcon, rightIcon, className, classNames, disabled, id: idProp, type, ...rest }, ref) {
8
8
  const reactId = useId();
9
9
  const id = idProp ?? reactId;
10
10
  const reduce = useReducedMotion();
@@ -92,30 +92,33 @@ const Input = forwardRef(function Input({ label, value: valueProp, defaultValue,
92
92
  }) : null
93
93
  ]
94
94
  }),
95
- /* @__PURE__ */ jsx(AnimatePresence, {
96
- initial: false,
97
- children: errorMessage ? /* @__PURE__ */ jsx(motion.p, {
98
- id: `${id}-error`,
99
- role: "alert",
100
- initial: reduce ? { opacity: 0 } : {
101
- opacity: 0,
102
- y: -4,
103
- filter: "blur(4px)"
104
- },
105
- animate: {
106
- opacity: 1,
107
- y: 0,
108
- filter: "blur(0px)"
109
- },
110
- exit: reduce ? { opacity: 0 } : {
111
- opacity: 0,
112
- y: -4,
113
- filter: "blur(4px)"
114
- },
115
- transition: { duration: .2 },
116
- className: cn("px-1 text-destructive text-xs", classNames?.errorMessage),
117
- children: errorMessage
118
- }) : null
95
+ /* @__PURE__ */ jsx("div", {
96
+ className: reserveErrorLine ? "min-h-4" : "contents",
97
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
98
+ initial: false,
99
+ children: errorMessage ? /* @__PURE__ */ jsx(motion.p, {
100
+ id: `${id}-error`,
101
+ role: "alert",
102
+ initial: reduce ? { opacity: 0 } : {
103
+ opacity: 0,
104
+ y: -4,
105
+ filter: "blur(4px)"
106
+ },
107
+ animate: {
108
+ opacity: 1,
109
+ y: 0,
110
+ filter: "blur(0px)"
111
+ },
112
+ exit: reduce ? { opacity: 0 } : {
113
+ opacity: 0,
114
+ y: -4,
115
+ filter: "blur(4px)"
116
+ },
117
+ transition: { duration: .2 },
118
+ className: cn("px-1 text-destructive text-xs", classNames?.errorMessage),
119
+ children: errorMessage
120
+ }) : null
121
+ })
119
122
  })
120
123
  ]
121
124
  });
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","names":[],"sources":["../../../src/components/motion/input.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n type InputHTMLAttributes,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\nexport type InputClassNames = {\n root?: string;\n label?: string;\n field?: string;\n input?: string;\n leftIcon?: string;\n rightIcon?: string;\n successIcon?: string;\n errorMessage?: string;\n};\n\nexport interface InputProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"value\" | \"defaultValue\" | \"onChange\"> {\n label?: string;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Truthy error triggers a shake, red border and (if a string) a message. */\n error?: string | boolean;\n success?: boolean;\n leftIcon?: ReactNode;\n rightIcon?: ReactNode;\n className?: string;\n classNames?: InputClassNames;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n label,\n value: valueProp,\n defaultValue,\n onChange,\n onFocus,\n onBlur,\n error,\n success,\n leftIcon,\n rightIcon,\n className,\n classNames,\n disabled,\n id: idProp,\n type,\n ...rest\n },\n ref,\n) {\n const reactId = useId();\n const id = idProp ?? reactId;\n const reduce = useReducedMotion();\n\n const controlled = valueProp !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? \"\");\n const value = controlled ? (valueProp ?? \"\") : internal;\n\n const [focused, setFocused] = useState(false);\n\n const fieldRef = useRef<HTMLDivElement>(null);\n\n const hasError = Boolean(error);\n const errorMessage = typeof error === \"string\" ? error : null;\n\n // Right edge shows the success check, otherwise the caller's right icon.\n const rightSlot = success ? null : rightIcon;\n\n // Shake the field when an error appears.\n useEffect(() => {\n if (!fieldRef.current || reduce || !hasError) return;\n animate(fieldRef.current, { x: [0, -6, 6, -4, 4, -2, 0] }, { duration: 0.45 });\n }, [hasError, reduce]);\n\n const handleChange = (next: string) => {\n if (!controlled) setInternal(next);\n onChange?.(next);\n };\n\n return (\n <div className={cn(\"flex flex-col gap-1.5\", className, classNames?.root)}>\n {label ? (\n <label\n htmlFor={id}\n className={cn(\"px-1 font-medium text-foreground text-sm\", classNames?.label)}\n >\n {label}\n </label>\n ) : null}\n\n <div\n ref={fieldRef}\n data-state={hasError ? \"error\" : success ? \"success\" : focused ? \"focused\" : \"idle\"}\n className={cn(\n \"relative h-11 overflow-hidden rounded-full border transition-colors duration-200\",\n \"border-border\",\n focused && !hasError && \"border-foreground/40 ring-2 ring-ring/40\",\n hasError && \"border-destructive ring-2 ring-destructive/25\",\n disabled && \"opacity-60\",\n classNames?.field,\n )}\n >\n {leftIcon ? (\n <span\n className={cn(\n \"pointer-events-none absolute top-1/2 left-3 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:h-4 [&_svg]:w-4\",\n classNames?.leftIcon,\n )}\n >\n {leftIcon}\n </span>\n ) : null}\n\n <input\n ref={ref}\n id={id}\n type={type}\n value={value}\n disabled={disabled}\n aria-invalid={hasError || undefined}\n aria-describedby={errorMessage ? `${id}-error` : undefined}\n {...rest}\n onChange={(e) => handleChange(e.target.value)}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onBlur={(event) => {\n setFocused(false);\n onBlur?.(event);\n }}\n className={cn(\n \"peer h-full w-full bg-transparent text-base text-foreground leading-6 caret-foreground outline-none\",\n \"placeholder:text-muted-foreground/60\",\n leftIcon ? \"pl-10\" : \"pl-3.5\",\n rightSlot || success ? \"pr-10\" : \"pr-3.5\",\n disabled && \"cursor-not-allowed\",\n classNames?.input,\n )}\n />\n\n {success ? (\n <motion.svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n className={cn(\n \"absolute top-1/2 right-3.5 h-5 w-5 -translate-y-1/2 text-(--color-success)\",\n classNames?.successIcon,\n )}\n >\n <motion.path\n d=\"M5 12.5l4.5 4.5L19 7.5\"\n stroke=\"currentColor\"\n strokeWidth={2.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={{ duration: 0.35, ease: \"easeOut\" }}\n />\n </motion.svg>\n ) : rightSlot ? (\n <span\n className={cn(\n \"absolute top-0 right-0 flex h-full items-center text-muted-foreground [&_button]:grid [&_button]:size-11 [&_button]:place-items-center [&_svg]:h-4 [&_svg]:w-4\",\n classNames?.rightIcon,\n )}\n >\n {rightSlot}\n </span>\n ) : null}\n </div>\n\n <AnimatePresence initial={false}>\n {errorMessage ? (\n <motion.p\n id={`${id}-error`}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n transition={{ duration: 0.2 }}\n className={cn(\"px-1 text-destructive text-xs\", classNames?.errorMessage)}\n >\n {errorMessage}\n </motion.p>\n ) : null}\n </AnimatePresence>\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,EAAE,UAAU,GAAI;KAC5B,WAAW,GAAG,iCAAiC,YAAY,YAAY;KAEtE,UAAA;IACO,CAAA,IACR;GACW,CAAA;EACd;;AAET,CAAC"}
1
+ {"version":3,"file":"input.js","names":[],"sources":["../../../src/components/motion/input.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n type InputHTMLAttributes,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { AnimatePresence, animate, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\nexport type InputClassNames = {\n root?: string;\n label?: string;\n field?: string;\n input?: string;\n leftIcon?: string;\n rightIcon?: string;\n successIcon?: string;\n errorMessage?: string;\n};\n\nexport interface InputProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"value\" | \"defaultValue\" | \"onChange\"> {\n label?: string;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Truthy error triggers a shake, red border and (if a string) a message. */\n error?: string | boolean;\n /** Reserve one message line so validation does not shift nearby content. */\n reserveErrorLine?: boolean;\n success?: boolean;\n leftIcon?: ReactNode;\n rightIcon?: ReactNode;\n className?: string;\n classNames?: InputClassNames;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n label,\n value: valueProp,\n defaultValue,\n onChange,\n onFocus,\n onBlur,\n error,\n reserveErrorLine = false,\n success,\n leftIcon,\n rightIcon,\n className,\n classNames,\n disabled,\n id: idProp,\n type,\n ...rest\n },\n ref,\n) {\n const reactId = useId();\n const id = idProp ?? reactId;\n const reduce = useReducedMotion();\n\n const controlled = valueProp !== undefined;\n const [internal, setInternal] = useState(defaultValue ?? \"\");\n const value = controlled ? (valueProp ?? \"\") : internal;\n\n const [focused, setFocused] = useState(false);\n\n const fieldRef = useRef<HTMLDivElement>(null);\n\n const hasError = Boolean(error);\n const errorMessage = typeof error === \"string\" ? error : null;\n\n // Right edge shows the success check, otherwise the caller's right icon.\n const rightSlot = success ? null : rightIcon;\n\n // Shake the field when an error appears.\n useEffect(() => {\n if (!fieldRef.current || reduce || !hasError) return;\n animate(fieldRef.current, { x: [0, -6, 6, -4, 4, -2, 0] }, { duration: 0.45 });\n }, [hasError, reduce]);\n\n const handleChange = (next: string) => {\n if (!controlled) setInternal(next);\n onChange?.(next);\n };\n\n return (\n <div className={cn(\"flex flex-col gap-1.5\", className, classNames?.root)}>\n {label ? (\n <label\n htmlFor={id}\n className={cn(\"px-1 font-medium text-foreground text-sm\", classNames?.label)}\n >\n {label}\n </label>\n ) : null}\n\n <div\n ref={fieldRef}\n data-state={hasError ? \"error\" : success ? \"success\" : focused ? \"focused\" : \"idle\"}\n className={cn(\n \"relative h-11 overflow-hidden rounded-full border transition-colors duration-200\",\n \"border-border\",\n focused && !hasError && \"border-foreground/40 ring-2 ring-ring/40\",\n hasError && \"border-destructive ring-2 ring-destructive/25\",\n disabled && \"opacity-60\",\n classNames?.field,\n )}\n >\n {leftIcon ? (\n <span\n className={cn(\n \"pointer-events-none absolute top-1/2 left-3 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:h-4 [&_svg]:w-4\",\n classNames?.leftIcon,\n )}\n >\n {leftIcon}\n </span>\n ) : null}\n\n <input\n ref={ref}\n id={id}\n type={type}\n value={value}\n disabled={disabled}\n aria-invalid={hasError || undefined}\n aria-describedby={errorMessage ? `${id}-error` : undefined}\n {...rest}\n onChange={(e) => handleChange(e.target.value)}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onBlur={(event) => {\n setFocused(false);\n onBlur?.(event);\n }}\n className={cn(\n \"peer h-full w-full bg-transparent text-base text-foreground leading-6 caret-foreground outline-none\",\n \"placeholder:text-muted-foreground/60\",\n leftIcon ? \"pl-10\" : \"pl-3.5\",\n rightSlot || success ? \"pr-10\" : \"pr-3.5\",\n disabled && \"cursor-not-allowed\",\n classNames?.input,\n )}\n />\n\n {success ? (\n <motion.svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n className={cn(\n \"absolute top-1/2 right-3.5 h-5 w-5 -translate-y-1/2 text-(--color-success)\",\n classNames?.successIcon,\n )}\n >\n <motion.path\n d=\"M5 12.5l4.5 4.5L19 7.5\"\n stroke=\"currentColor\"\n strokeWidth={2.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n animate={{ pathLength: 1 }}\n transition={{ duration: 0.35, ease: \"easeOut\" }}\n />\n </motion.svg>\n ) : rightSlot ? (\n <span\n className={cn(\n \"absolute top-0 right-0 flex h-full items-center text-muted-foreground [&_button]:grid [&_button]:size-11 [&_button]:place-items-center [&_svg]:h-4 [&_svg]:w-4\",\n classNames?.rightIcon,\n )}\n >\n {rightSlot}\n </span>\n ) : null}\n </div>\n\n <div className={reserveErrorLine ? \"min-h-4\" : \"contents\"}>\n <AnimatePresence initial={false}>\n {errorMessage ? (\n <motion.p\n id={`${id}-error`}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n transition={{ duration: 0.2 }}\n className={cn(\"px-1 text-destructive text-xs\", classNames?.errorMessage)}\n >\n {errorMessage}\n </motion.p>\n ) : null}\n </AnimatePresence>\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;;AA2CA,MAAa,QAAQ,WAAyC,SAAS,MACrE,EACE,OACA,OAAO,WACP,cACA,UACA,SACA,QACA,OACA,mBAAmB,OACnB,SACA,UACA,WACA,WACA,YACA,UACA,IAAI,QACJ,MACA,GAAG,QAEL,KACA;CACA,MAAM,UAAU,MAAM;CACtB,MAAM,KAAK,UAAU;CACrB,MAAM,SAAS,iBAAiB;CAEhC,MAAM,aAAa,cAAc,KAAA;CACjC,MAAM,CAAC,UAAU,eAAe,SAAS,gBAAgB,EAAE;CAC3D,MAAM,QA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ChB,SAAS,KAAK;MAChB;MACA,WAAW,GACT,uGACA,wCACA,WAAW,UAAU,UACrB,aAAa,UAAU,UAAU,UACjC,YAAY,sBACZ,YAAY,KACd;KACD,CAAA;KAEA,UACC,oBAAC,OAAO,KAAR;MACE,SAAQ;MACR,MAAK;MACL,WAAW,GACT,8EACA,YAAY,WACd;MAEA,UAAA,oBAAC,OAAO,MAAR;OACE,GAAE;OACF,QAAO;OACP,aAAa;OACb,eAAc;OACd,gBAAe;OACf,SAAS,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;OACtD,SAAS,EAAE,YAAY,EAAE;OACzB,YAAY;QAAE,UAAU;QAAM,MAAM;OAAU;MAC/C,CAAA;KACS,CAAA,IACV,YACF,oBAAC,QAAD;MACE,WAAW,GACT,kKACA,YAAY,SACd;MAEC,UAAA;KACG,CAAA,IACJ;IACD;;GAEL,oBAAC,OAAD;IAAK,WAAW,mBAAmB,YAAY;IAC7C,UAAA,oBAAC,iBAAD;KAAiB,SAAS;KACvB,UAAA,eACC,oBAAC,OAAO,GAAR;MACE,IAAI,GAAG,GAAG;MACV,MAAK;MACL,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;OAAE,SAAS;OAAG,GAAG;OAAI,QAAQ;MAAY;MAC5E,SAAS;OAAE,SAAS;OAAG,GAAG;OAAG,QAAQ;MAAY;MACjD,MAAM,SAAS,EAAE,SAAS,EAAE,IAAI;OAAE,SAAS;OAAG,GAAG;OAAI,QAAQ;MAAY;MACzE,YAAY,EAAE,UAAU,GAAI;MAC5B,WAAW,GAAG,iCAAiC,YAAY,YAAY;MAEtE,UAAA;KACO,CAAA,IACR;IACW,CAAA;GACd,CAAA;EACF;;AAET,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { HTMLAttributes, ReactNode } from "react";
2
+ //#region src/components/motion/liquid.d.ts
3
+ type LiquidEase = readonly [number, number, number, number];
4
+ type LiquidTransition = {
5
+ duration?: number;
6
+ ease?: LiquidEase;
7
+ };
8
+ interface LiquidProps extends HTMLAttributes<HTMLDivElement> {
9
+ blur?: number;
10
+ contrast?: number;
11
+ fill?: string;
12
+ edgeColor?: string;
13
+ edgeOpacity?: number;
14
+ edgeWidth?: number;
15
+ filterPadding?: number;
16
+ }
17
+ declare const Liquid: import("react").ForwardRefExoticComponent<LiquidProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ interface LiquidItemProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
19
+ children: ReactNode;
20
+ x: number;
21
+ y: number;
22
+ width: number;
23
+ height: number;
24
+ radius?: number;
25
+ transition?: LiquidTransition;
26
+ }
27
+ declare function LiquidItem({ children, x, y, width, height, radius, transition, className, style, ...props }: LiquidItemProps): import("react").JSX.Element;
28
+ //#endregion
29
+ export { Liquid, LiquidEase, LiquidItem, LiquidItemProps, LiquidProps, LiquidTransition };
30
+ //# sourceMappingURL=liquid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liquid.d.ts","names":[],"sources":["../../../src/components/motion/liquid.tsx"],"mappings":";;KAkCY;KAEA;EACV;EACA,OAAO;;UAGQ,oBAAoB,eAAe;EAClD;EACA;EACA;EACA;EACA;EACA;EACA;;cAGW,wBAAM,0BAAA,8BAAA,cAAA;UA6HF,wBAAwB,KAAK,eAAe;EAC3D,UAAU;EACV;EACA;EACA;EACA;EACA;EACA,aAAa;;iBA4BC,aACd,UACA,GACA,GACA,OACA,QACA,QACA,YACA,WACA,UACG,SACF,kCAAe,IAAA"}