@kumix/ui 0.3.9 → 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 (77) hide show
  1. package/README.md +15 -14
  2. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  3. package/dist/components/motion/animated-sidebar.js.map +1 -1
  4. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  5. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
  6. package/dist/components/motion/availability-scheduler/day-row.js +15 -7
  7. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
  8. package/dist/components/motion/availability-scheduler/index.js +1 -1
  9. package/dist/components/motion/button/index.d.ts +2 -1
  10. package/dist/components/motion/button/index.js +2 -1
  11. package/dist/components/motion/button/metallic.d.ts +10 -0
  12. package/dist/components/motion/button/metallic.d.ts.map +1 -0
  13. package/dist/components/motion/button/metallic.js +71 -0
  14. package/dist/components/motion/button/metallic.js.map +1 -0
  15. package/dist/components/motion/expandable-control.d.ts +28 -0
  16. package/dist/components/motion/expandable-control.d.ts.map +1 -0
  17. package/dist/components/motion/expandable-control.js +149 -0
  18. package/dist/components/motion/expandable-control.js.map +1 -0
  19. package/dist/components/motion/expanding-arrow-button.d.ts +12 -0
  20. package/dist/components/motion/expanding-arrow-button.d.ts.map +1 -0
  21. package/dist/components/motion/expanding-arrow-button.js +142 -0
  22. package/dist/components/motion/expanding-arrow-button.js.map +1 -0
  23. package/dist/components/motion/file-tree.d.ts +42 -0
  24. package/dist/components/motion/file-tree.d.ts.map +1 -0
  25. package/dist/components/motion/file-tree.js +272 -0
  26. package/dist/components/motion/file-tree.js.map +1 -0
  27. package/dist/components/reui/alert.d.ts +1 -1
  28. package/dist/components/reui/badge.d.ts +1 -1
  29. package/dist/components/reui/code-block/code-block-highlight.d.ts +216 -0
  30. package/dist/components/reui/code-block/code-block-highlight.d.ts.map +1 -0
  31. package/dist/components/reui/code-block/code-block-highlight.js +792 -0
  32. package/dist/components/reui/code-block/code-block-highlight.js.map +1 -0
  33. package/dist/components/reui/code-block/code-block.d.ts +197 -0
  34. package/dist/components/reui/code-block/code-block.d.ts.map +1 -0
  35. package/dist/components/reui/code-block/code-block.js +1150 -0
  36. package/dist/components/reui/code-block/code-block.js.map +1 -0
  37. package/dist/components/reui/frame.d.ts +1 -1
  38. package/dist/components/reui/gantt/gantt-bar.js +42 -12
  39. package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
  40. package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -1
  41. package/dist/components/reui/gantt/gantt-dnd.js +22 -7
  42. package/dist/components/reui/gantt/gantt-dnd.js.map +1 -1
  43. package/dist/components/reui/gantt/gantt-i18n.d.ts +8 -0
  44. package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -1
  45. package/dist/components/reui/gantt/gantt-i18n.js +6 -1
  46. package/dist/components/reui/gantt/gantt-i18n.js.map +1 -1
  47. package/dist/components/reui/gantt/gantt-lib.d.ts +59 -2
  48. package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -1
  49. package/dist/components/reui/gantt/gantt-lib.js +67 -2
  50. package/dist/components/reui/gantt/gantt-lib.js.map +1 -1
  51. package/dist/components/reui/gantt/gantt-recurrence.js +3 -3
  52. package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -1
  53. package/dist/components/reui/gantt/gantt-types.d.ts +32 -1
  54. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  55. package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -1
  56. package/dist/components/reui/gantt/gantt-view.js +324 -35
  57. package/dist/components/reui/gantt/gantt-view.js.map +1 -1
  58. package/dist/components/reui/gantt/gantt.d.ts +71 -2
  59. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  60. package/dist/components/reui/gantt/gantt.js +8 -0
  61. package/dist/components/reui/gantt/gantt.js.map +1 -1
  62. package/dist/components/ui/attachment.d.ts +1 -1
  63. package/dist/components/ui/badge.d.ts +1 -1
  64. package/dist/components/ui/bubble.d.ts +1 -1
  65. package/dist/components/ui/button-group.d.ts +1 -1
  66. package/dist/components/ui/button.d.ts +1 -1
  67. package/dist/components/ui/field.d.ts +1 -1
  68. package/dist/components/ui/item.d.ts +2 -2
  69. package/dist/components/ui/marker.d.ts +1 -1
  70. package/dist/components/ui/sidebar.d.ts +1 -1
  71. package/dist/components/ui/tabs.d.ts +1 -1
  72. package/dist/components/ui/toggle.d.ts +1 -1
  73. package/dist/{copy-menu-1FKoMc9o.js → copy-menu-C5GaT4Z-.js} +67 -2
  74. package/dist/copy-menu-C5GaT4Z-.js.map +1 -0
  75. package/dist/types-smkWN_7x.d.ts.map +1 -1
  76. package/package.json +5 -11
  77. package/dist/copy-menu-1FKoMc9o.js.map +0 -1
@@ -0,0 +1,149 @@
1
+ "use client";
2
+ import { useCallback, useRef, useState } from "react";
3
+ import { cn } from "@kumix/utils";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
6
+ //#region src/components/motion/expandable-control.tsx
7
+ const CONTINUITY_SPRING = {
8
+ type: "spring",
9
+ stiffness: 220,
10
+ damping: 17,
11
+ mass: .85
12
+ };
13
+ const CONTINUITY_LABEL = {
14
+ hidden: {
15
+ opacity: 0,
16
+ filter: "blur(4px)"
17
+ },
18
+ visible: {
19
+ opacity: 1,
20
+ filter: "blur(0px)"
21
+ },
22
+ exit: {
23
+ opacity: 0,
24
+ filter: "blur(4px)"
25
+ }
26
+ };
27
+ function useExpandableState({ expanded, defaultExpanded = false, onExpandedChange }) {
28
+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
29
+ const isControlled = expanded !== void 0;
30
+ return [expanded ?? internalExpanded, useCallback((nextExpanded) => {
31
+ if (!isControlled) setInternalExpanded(nextExpanded);
32
+ onExpandedChange?.(nextExpanded);
33
+ }, [isControlled, onExpandedChange])];
34
+ }
35
+ function ExpandableButton({ icon, label, expanded, defaultExpanded, onExpandedChange, className, onClick, disabled, type = "button", "aria-label": ariaLabel, ...props }) {
36
+ const reduce = useReducedMotion();
37
+ const [isExpanded, setExpanded] = useExpandableState({
38
+ expanded,
39
+ defaultExpanded,
40
+ onExpandedChange
41
+ });
42
+ const handleClick = (event) => {
43
+ onClick?.(event);
44
+ if (!event.defaultPrevented) setExpanded(!isExpanded);
45
+ };
46
+ const transition = reduce ? { duration: 0 } : CONTINUITY_SPRING;
47
+ return /* @__PURE__ */ jsx(motion.span, {
48
+ layout: true,
49
+ transition,
50
+ className: "inline-flex",
51
+ children: /* @__PURE__ */ jsxs(motion.button, {
52
+ ...props,
53
+ layout: true,
54
+ type,
55
+ "aria-label": ariaLabel ?? (typeof label === "string" ? label : void 0),
56
+ "aria-expanded": isExpanded,
57
+ disabled,
58
+ className: cn("relative inline-flex h-11 min-w-11 items-center overflow-hidden rounded-full border border-border bg-transparent p-1 pr-1 font-medium text-foreground text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-50", className),
59
+ style: { borderRadius: 9999 },
60
+ onClick: handleClick,
61
+ whileTap: reduce || disabled ? void 0 : { scale: .97 },
62
+ transition,
63
+ children: [/* @__PURE__ */ jsx(motion.span, {
64
+ layout: "position",
65
+ className: "grid size-9 shrink-0 place-items-center",
66
+ "aria-hidden": "true",
67
+ transition,
68
+ children: icon
69
+ }), /* @__PURE__ */ jsx(AnimatePresence, {
70
+ mode: "popLayout",
71
+ initial: false,
72
+ children: isExpanded ? /* @__PURE__ */ jsx(motion.span, {
73
+ layout: true,
74
+ variants: CONTINUITY_LABEL,
75
+ initial: reduce ? { opacity: 0 } : "hidden",
76
+ animate: reduce ? { opacity: 1 } : "visible",
77
+ exit: reduce ? { opacity: 0 } : "exit",
78
+ transition,
79
+ className: "relative inline-flex w-max items-center whitespace-nowrap pr-3",
80
+ "aria-hidden": "true",
81
+ children: label
82
+ }, "label") : null
83
+ })]
84
+ })
85
+ });
86
+ }
87
+ function ExpandableChip({ label, actionIcon, actionLabel, onAction, collapseOnAction = true, expanded, defaultExpanded, onExpandedChange, disabled, className, labelClassName, actionClassName }) {
88
+ const reduce = useReducedMotion();
89
+ const triggerRef = useRef(null);
90
+ const [isExpanded, setExpanded] = useExpandableState({
91
+ expanded,
92
+ defaultExpanded,
93
+ onExpandedChange
94
+ });
95
+ const handleAction = () => {
96
+ onAction?.();
97
+ if (collapseOnAction) {
98
+ setExpanded(false);
99
+ triggerRef.current?.focus();
100
+ }
101
+ };
102
+ const transition = reduce ? { duration: 0 } : CONTINUITY_SPRING;
103
+ return /* @__PURE__ */ jsx(motion.span, {
104
+ layout: true,
105
+ transition,
106
+ className: "inline-flex",
107
+ children: /* @__PURE__ */ jsxs(motion.div, {
108
+ layout: true,
109
+ className: cn("inline-flex h-10 items-center overflow-hidden rounded-full border border-border bg-transparent text-foreground text-sm has-focus-visible:ring-2 has-focus-visible:ring-ring has-focus-visible:ring-inset", className),
110
+ style: { borderRadius: 9999 },
111
+ transition,
112
+ children: [/* @__PURE__ */ jsx(motion.button, {
113
+ layout: "position",
114
+ ref: triggerRef,
115
+ type: "button",
116
+ "aria-expanded": isExpanded,
117
+ disabled,
118
+ className: cn("h-full whitespace-nowrap py-0 pl-3 font-medium outline-none disabled:pointer-events-none disabled:opacity-50", isExpanded ? "pr-1" : "pr-3", labelClassName),
119
+ onClick: () => setExpanded(!isExpanded),
120
+ transition,
121
+ children: label
122
+ }), /* @__PURE__ */ jsx(motion.span, {
123
+ variants: CONTINUITY_LABEL,
124
+ className: cn("relative inline-flex h-10 shrink-0 items-center overflow-hidden", isExpanded ? "w-8" : "w-0"),
125
+ "aria-hidden": !isExpanded,
126
+ initial: false,
127
+ animate: reduce ? { opacity: isExpanded ? 1 : 0 } : isExpanded ? "visible" : "hidden",
128
+ transition,
129
+ children: /* @__PURE__ */ jsx(motion.button, {
130
+ type: "button",
131
+ "aria-label": actionLabel,
132
+ disabled: disabled || !isExpanded,
133
+ className: cn("flex h-10 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground disabled:pointer-events-none", disabled && "opacity-50", actionClassName),
134
+ onClick: handleAction,
135
+ whileTap: reduce || disabled ? void 0 : { scale: .97 },
136
+ transition,
137
+ children: /* @__PURE__ */ jsx("span", {
138
+ "aria-hidden": "true",
139
+ children: actionIcon
140
+ })
141
+ })
142
+ })]
143
+ })
144
+ });
145
+ }
146
+ //#endregion
147
+ export { ExpandableButton, ExpandableChip };
148
+
149
+ //# sourceMappingURL=expandable-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expandable-control.js","names":[],"sources":["../../../src/components/motion/expandable-control.tsx"],"sourcesContent":["\"use client\";\n\nimport { type MouseEvent, type ReactNode, useCallback, useRef, useState } from \"react\";\nimport {\n AnimatePresence,\n type HTMLMotionProps,\n motion,\n type Transition,\n useReducedMotion,\n type Variants,\n} from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\n// Matches the Motion Patterns \"Layout continuity\" recipe so the surface\n// keeps its identity while its footprint changes.\nconst CONTINUITY_SPRING: Transition = {\n type: \"spring\",\n stiffness: 220,\n damping: 17,\n mass: 0.85,\n};\n\nconst CONTINUITY_LABEL: Variants = {\n hidden: { opacity: 0, filter: \"blur(4px)\" },\n visible: { opacity: 1, filter: \"blur(0px)\" },\n exit: { opacity: 0, filter: \"blur(4px)\" },\n};\n\ntype ExpandableStateProps = {\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n};\n\nexport interface ExpandableButtonProps\n extends Omit<HTMLMotionProps<\"button\">, \"children\">,\n ExpandableStateProps {\n icon: ReactNode;\n label: ReactNode;\n}\n\nexport interface ExpandableChipProps extends ExpandableStateProps {\n label: ReactNode;\n actionIcon: ReactNode;\n actionLabel: string;\n onAction?: () => void;\n collapseOnAction?: boolean;\n disabled?: boolean;\n className?: string;\n labelClassName?: string;\n actionClassName?: string;\n}\n\nfunction useExpandableState({\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n}: ExpandableStateProps) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const isControlled = expanded !== undefined;\n const currentExpanded = expanded ?? internalExpanded;\n\n const setExpanded = useCallback(\n (nextExpanded: boolean) => {\n if (!isControlled) {\n setInternalExpanded(nextExpanded);\n }\n onExpandedChange?.(nextExpanded);\n },\n [isControlled, onExpandedChange],\n );\n\n return [currentExpanded, setExpanded] as const;\n}\n\nexport function ExpandableButton({\n icon,\n label,\n expanded,\n defaultExpanded,\n onExpandedChange,\n className,\n onClick,\n disabled,\n type = \"button\",\n \"aria-label\": ariaLabel,\n ...props\n}: ExpandableButtonProps) {\n const reduce = useReducedMotion();\n const [isExpanded, setExpanded] = useExpandableState({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n setExpanded(!isExpanded);\n }\n };\n\n const transition = reduce ? { duration: 0 } : CONTINUITY_SPRING;\n\n return (\n <motion.span layout transition={transition} className=\"inline-flex\">\n <motion.button\n {...props}\n layout\n type={type}\n aria-label={ariaLabel ?? (typeof label === \"string\" ? label : undefined)}\n aria-expanded={isExpanded}\n disabled={disabled}\n className={cn(\n \"relative inline-flex h-11 min-w-11 items-center overflow-hidden rounded-full border border-border bg-transparent p-1 pr-1 font-medium text-foreground text-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-50\",\n className,\n )}\n style={{ borderRadius: 9999 }}\n onClick={handleClick}\n whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n transition={transition}\n >\n <motion.span\n layout=\"position\"\n className=\"grid size-9 shrink-0 place-items-center\"\n aria-hidden=\"true\"\n transition={transition}\n >\n {icon}\n </motion.span>\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {isExpanded ? (\n <motion.span\n key=\"label\"\n layout\n variants={CONTINUITY_LABEL}\n initial={reduce ? { opacity: 0 } : \"hidden\"}\n animate={reduce ? { opacity: 1 } : \"visible\"}\n exit={reduce ? { opacity: 0 } : \"exit\"}\n transition={transition}\n className=\"relative inline-flex w-max items-center whitespace-nowrap pr-3\"\n aria-hidden=\"true\"\n >\n {label}\n </motion.span>\n ) : null}\n </AnimatePresence>\n </motion.button>\n </motion.span>\n );\n}\n\nexport function ExpandableChip({\n label,\n actionIcon,\n actionLabel,\n onAction,\n collapseOnAction = true,\n expanded,\n defaultExpanded,\n onExpandedChange,\n disabled,\n className,\n labelClassName,\n actionClassName,\n}: ExpandableChipProps) {\n const reduce = useReducedMotion();\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [isExpanded, setExpanded] = useExpandableState({\n expanded,\n defaultExpanded,\n onExpandedChange,\n });\n\n const handleAction = () => {\n onAction?.();\n if (collapseOnAction) {\n setExpanded(false);\n triggerRef.current?.focus();\n }\n };\n\n const transition = reduce ? { duration: 0 } : CONTINUITY_SPRING;\n\n return (\n <motion.span layout transition={transition} className=\"inline-flex\">\n <motion.div\n layout\n className={cn(\n \"inline-flex h-10 items-center overflow-hidden rounded-full border border-border bg-transparent text-foreground text-sm has-focus-visible:ring-2 has-focus-visible:ring-ring has-focus-visible:ring-inset\",\n className,\n )}\n style={{ borderRadius: 9999 }}\n transition={transition}\n >\n <motion.button\n layout=\"position\"\n ref={triggerRef}\n type=\"button\"\n aria-expanded={isExpanded}\n disabled={disabled}\n className={cn(\n \"h-full whitespace-nowrap py-0 pl-3 font-medium outline-none disabled:pointer-events-none disabled:opacity-50\",\n isExpanded ? \"pr-1\" : \"pr-3\",\n labelClassName,\n )}\n onClick={() => setExpanded(!isExpanded)}\n transition={transition}\n >\n {label}\n </motion.button>\n <motion.span\n variants={CONTINUITY_LABEL}\n className={cn(\n \"relative inline-flex h-10 shrink-0 items-center overflow-hidden\",\n isExpanded ? \"w-8\" : \"w-0\",\n )}\n aria-hidden={!isExpanded}\n initial={false}\n animate={reduce ? { opacity: isExpanded ? 1 : 0 } : isExpanded ? \"visible\" : \"hidden\"}\n transition={transition}\n >\n <motion.button\n type=\"button\"\n aria-label={actionLabel}\n disabled={disabled || !isExpanded}\n className={cn(\n \"flex h-10 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground disabled:pointer-events-none\",\n disabled && \"opacity-50\",\n actionClassName,\n )}\n onClick={handleAction}\n whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n transition={transition}\n >\n <span aria-hidden=\"true\">{actionIcon}</span>\n </motion.button>\n </motion.span>\n </motion.div>\n </motion.span>\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from "react";
2
+ import { HTMLMotionProps } from "motion/react";
3
+ //#region src/components/motion/expanding-arrow-button.d.ts
4
+ interface ExpandingArrowButtonProps extends Omit<HTMLMotionProps<"button">, "children"> {
5
+ children: ReactNode;
6
+ accentClassName?: string;
7
+ labelClassName?: string;
8
+ }
9
+ declare const ExpandingArrowButton: import("react").ForwardRefExoticComponent<Omit<ExpandingArrowButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
10
+ //#endregion
11
+ export { ExpandingArrowButton, ExpandingArrowButtonProps };
12
+ //# sourceMappingURL=expanding-arrow-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expanding-arrow-button.d.ts","names":[],"sources":["../../../src/components/motion/expanding-arrow-button.tsx"],"mappings":";;;UASiB,kCAAkC,KAAK;EACtD,UAAU;EACV;EACA;;cAiBW,sCAAoB,0BAAA,KAAA,oDAAA,cAAA"}
@@ -0,0 +1,142 @@
1
+ "use client";
2
+ import { useHoverCapable } from "../../hooks/use-hover-capable.js";
3
+ import { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
4
+ import { forwardRef, useState } from "react";
5
+ import { cn } from "@kumix/utils";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { motion, useReducedMotion } from "motion/react";
8
+ //#region src/components/motion/expanding-arrow-button.tsx
9
+ const ARROW_OPACITY = [
10
+ 1,
11
+ .78,
12
+ .54,
13
+ .32,
14
+ .16
15
+ ];
16
+ function DottedChevron({ className }) {
17
+ return /* @__PURE__ */ jsxs("svg", {
18
+ viewBox: "0 0 20 28",
19
+ fill: "none",
20
+ "aria-hidden": "true",
21
+ className,
22
+ children: [
23
+ /* @__PURE__ */ jsx("circle", {
24
+ cx: "4",
25
+ cy: "4",
26
+ r: "2",
27
+ fill: "currentColor"
28
+ }),
29
+ /* @__PURE__ */ jsx("circle", {
30
+ cx: "10",
31
+ cy: "9",
32
+ r: "2",
33
+ fill: "currentColor"
34
+ }),
35
+ /* @__PURE__ */ jsx("circle", {
36
+ cx: "16",
37
+ cy: "14",
38
+ r: "2",
39
+ fill: "currentColor"
40
+ }),
41
+ /* @__PURE__ */ jsx("circle", {
42
+ cx: "10",
43
+ cy: "19",
44
+ r: "2",
45
+ fill: "currentColor"
46
+ }),
47
+ /* @__PURE__ */ jsx("circle", {
48
+ cx: "4",
49
+ cy: "24",
50
+ r: "2",
51
+ fill: "currentColor"
52
+ })
53
+ ]
54
+ });
55
+ }
56
+ const ExpandingArrowButton = forwardRef(function ExpandingArrowButton({ children, className, accentClassName, labelClassName, disabled, onMouseEnter, onMouseLeave, onFocus, onBlur, ...rest }, ref) {
57
+ const reduce = useReducedMotion();
58
+ const canHover = useHoverCapable();
59
+ const [hovered, setHovered] = useState(false);
60
+ const [focused, setFocused] = useState(false);
61
+ const active = !disabled && (canHover && hovered || focused);
62
+ const layoutTransition = reduce ? { duration: 0 } : SPRING_LAYOUT;
63
+ const handleMouseEnter = (event) => {
64
+ setHovered(true);
65
+ onMouseEnter?.(event);
66
+ };
67
+ const handleMouseLeave = (event) => {
68
+ setHovered(false);
69
+ onMouseLeave?.(event);
70
+ };
71
+ const handleFocus = (event) => {
72
+ setFocused(true);
73
+ onFocus?.(event);
74
+ };
75
+ const handleBlur = (event) => {
76
+ setFocused(false);
77
+ onBlur?.(event);
78
+ };
79
+ return /* @__PURE__ */ jsxs(motion.button, {
80
+ ref,
81
+ type: "button",
82
+ disabled,
83
+ onMouseEnter: handleMouseEnter,
84
+ onMouseLeave: handleMouseLeave,
85
+ onFocus: handleFocus,
86
+ onBlur: handleBlur,
87
+ whileTap: reduce || disabled ? void 0 : { scale: .97 },
88
+ transition: SPRING_PRESS,
89
+ className: cn("relative inline-flex h-16 min-w-72 select-none items-center overflow-hidden rounded-[22px] bg-neutral-950 p-1.5 text-white", "outline-none focus-visible:ring-2 focus-visible:ring-lime-300 focus-visible:ring-offset-2 focus-visible:ring-offset-background", "disabled:pointer-events-none disabled:opacity-50", className),
90
+ ...rest,
91
+ children: [/* @__PURE__ */ jsxs(motion.span, {
92
+ layout: "size",
93
+ "aria-hidden": "true",
94
+ transition: layoutTransition,
95
+ style: {
96
+ width: active ? "calc(100% - 12px)" : 52,
97
+ borderRadius: 16
98
+ },
99
+ className: cn("absolute inset-y-1.5 left-1.5 z-10 overflow-hidden bg-lime-300 text-neutral-950", accentClassName),
100
+ children: [/* @__PURE__ */ jsx(motion.span, {
101
+ animate: { opacity: active ? 0 : 1 },
102
+ transition: {
103
+ duration: reduce ? 0 : .1,
104
+ ease: EASE_OUT
105
+ },
106
+ className: "absolute inset-0 grid place-items-center",
107
+ children: /* @__PURE__ */ jsx(DottedChevron, { className: "h-7 w-5" })
108
+ }), /* @__PURE__ */ jsx("span", {
109
+ className: "absolute inset-0 flex items-center justify-around px-3",
110
+ children: ARROW_OPACITY.map((opacity, index) => /* @__PURE__ */ jsx(motion.span, {
111
+ animate: {
112
+ opacity: active ? 1 : 0,
113
+ transform: active && !reduce ? "translateX(0px)" : "translateX(-6px)"
114
+ },
115
+ transition: {
116
+ duration: reduce ? 0 : .18,
117
+ delay: active && !reduce ? .04 + index * .025 : 0,
118
+ ease: EASE_OUT
119
+ },
120
+ style: { color: `rgb(10 10 10 / ${opacity})` },
121
+ className: "inline-grid place-items-center",
122
+ children: /* @__PURE__ */ jsx(DottedChevron, { className: "h-7 w-5" })
123
+ }, opacity))
124
+ })]
125
+ }), /* @__PURE__ */ jsx(motion.span, {
126
+ animate: {
127
+ opacity: active ? 0 : 1,
128
+ transform: active && !reduce ? "translateX(6px)" : "translateX(0px)"
129
+ },
130
+ transition: {
131
+ duration: reduce ? 0 : .12,
132
+ ease: EASE_OUT
133
+ },
134
+ className: cn("relative z-0 mr-5 ml-[76px] whitespace-nowrap font-medium text-lg tracking-[-0.02em]", labelClassName),
135
+ children
136
+ })]
137
+ });
138
+ });
139
+ //#endregion
140
+ export { ExpandingArrowButton };
141
+
142
+ //# sourceMappingURL=expanding-arrow-button.js.map
@@ -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":"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"}
@@ -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