@justanarthur/modo-ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSE.beui +21 -0
- package/LICENSE.fluid-functionalism +21 -0
- package/LICENSE.motion-primitives +21 -0
- package/LICENSE.sileo +21 -0
- package/README.md +608 -2
- package/dist/base.css +994 -0
- package/dist/blocks/sidebar-app/index.d.ts +34 -0
- package/dist/blocks/sidebar-app/index.js +34 -0
- package/dist/components/badge/index.d.ts +59 -0
- package/dist/components/badge/index.js +18 -0
- package/dist/components/button/index.d.ts +59 -0
- package/dist/components/button/index.js +16 -0
- package/dist/components/card/index.d.ts +141 -0
- package/dist/components/card/index.js +44 -0
- package/dist/components/inputs/checkbox-group/index.d.ts +50 -0
- package/dist/components/inputs/checkbox-group/index.js +23 -0
- package/dist/components/inputs/color-picker/index.d.ts +137 -0
- package/dist/components/inputs/color-picker/index.js +37 -0
- package/dist/components/inputs/combobox/index.d.ts +161 -0
- package/dist/components/inputs/combobox/index.js +41 -0
- package/dist/components/inputs/date-time/calendar/index.d.ts +45 -0
- package/dist/components/inputs/date-time/calendar/index.js +20 -0
- package/dist/components/inputs/date-time/date-picker/index.d.ts +82 -0
- package/dist/components/inputs/date-time/date-picker/index.js +34 -0
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +64 -0
- package/dist/components/inputs/date-time/date-range-picker/index.js +33 -0
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/duration-picker/index.js +33 -0
- package/dist/components/inputs/date-time/month-picker/index.d.ts +57 -0
- package/dist/components/inputs/date-time/month-picker/index.js +32 -0
- package/dist/components/inputs/date-time/time-picker/index.d.ts +59 -0
- package/dist/components/inputs/date-time/time-picker/index.js +33 -0
- package/dist/components/inputs/input/index.d.ts +84 -0
- package/dist/components/inputs/input/index.js +20 -0
- package/dist/components/inputs/input-copy/index.d.ts +44 -0
- package/dist/components/inputs/input-copy/index.js +18 -0
- package/dist/components/inputs/input-message/index.d.ts +125 -0
- package/dist/components/inputs/input-message/index.js +27 -0
- package/dist/components/inputs/radio-group/index.d.ts +58 -0
- package/dist/components/inputs/radio-group/index.js +22 -0
- package/dist/components/inputs/search/index.d.ts +83 -0
- package/dist/components/inputs/search/index.js +28 -0
- package/dist/components/inputs/select/index.d.ts +105 -0
- package/dist/components/inputs/select/index.js +37 -0
- package/dist/components/inputs/slider/index.d.ts +108 -0
- package/dist/components/inputs/slider/index.js +16 -0
- package/dist/components/inputs/switch/index.d.ts +43 -0
- package/dist/components/inputs/switch/index.js +16 -0
- package/dist/components/navigation/accordion/index.d.ts +117 -0
- package/dist/components/navigation/accordion/index.js +30 -0
- package/dist/components/navigation/sidebar/index.d.ts +388 -0
- package/dist/components/navigation/sidebar/index.js +101 -0
- package/dist/components/navigation/tabs/index.d.ts +70 -0
- package/dist/components/navigation/tabs/index.js +25 -0
- package/dist/components/navigation/tabs-subtle/index.d.ts +73 -0
- package/dist/components/navigation/tabs-subtle/index.js +23 -0
- package/dist/components/overlays/alert-dialog/index.d.ts +67 -0
- package/dist/components/overlays/alert-dialog/index.js +24 -0
- package/dist/components/overlays/command/index.d.ts +121 -0
- package/dist/components/overlays/command/index.js +39 -0
- package/dist/components/overlays/context-menu/index.d.ts +97 -0
- package/dist/components/overlays/context-menu/index.js +32 -0
- package/dist/components/overlays/dialog/index.d.ts +130 -0
- package/dist/components/overlays/dialog/index.js +39 -0
- package/dist/components/overlays/dropdown/index.d.ts +222 -0
- package/dist/components/overlays/dropdown/index.js +47 -0
- package/dist/components/overlays/popover/index.d.ts +87 -0
- package/dist/components/overlays/popover/index.js +28 -0
- package/dist/components/overlays/preview-card/index.d.ts +75 -0
- package/dist/components/overlays/preview-card/index.js +21 -0
- package/dist/components/overlays/sheet/index.d.ts +67 -0
- package/dist/components/overlays/sheet/index.js +26 -0
- package/dist/components/overlays/toast/index.d.ts +107 -0
- package/dist/components/overlays/toast/index.js +23 -0
- package/dist/components/overlays/tooltip/index.d.ts +75 -0
- package/dist/components/overlays/tooltip/index.js +19 -0
- package/dist/components/table/index.d.ts +44 -0
- package/dist/components/table/index.js +28 -0
- package/dist/components/thinking-indicator/index.d.ts +32 -0
- package/dist/components/thinking-indicator/index.js +15 -0
- package/dist/index.d.ts +3926 -0
- package/dist/index.js +513 -0
- package/dist/preset.d.ts +104 -0
- package/dist/preset.js +124 -0
- package/dist/primitives/code/index.d.ts +23 -0
- package/dist/primitives/code/index.js +12 -0
- package/dist/primitives/craft/index.d.ts +31 -0
- package/dist/primitives/craft/index.js +13 -0
- package/dist/primitives/fluid-hover/index.d.ts +233 -0
- package/dist/primitives/fluid-hover/index.js +27 -0
- package/dist/primitives/morph/index.d.ts +127 -0
- package/dist/primitives/morph/index.js +21 -0
- package/dist/primitives/motion/index.d.ts +115 -0
- package/dist/primitives/motion/index.js +20 -0
- package/dist/primitives/scroll-area/index.d.ts +41 -0
- package/dist/primitives/scroll-area/index.js +13 -0
- package/dist/primitives/sizes/index.d.ts +128 -0
- package/dist/primitives/sizes/index.js +22 -0
- package/dist/primitives/surface/index.d.ts +69 -0
- package/dist/primitives/surface/index.js +18 -0
- package/dist/shared/components-0f0as45n.js +17 -0
- package/dist/shared/components-40j34hdb.js +986 -0
- package/dist/shared/components-4hh0gm0v.js +292 -0
- package/dist/shared/components-4xxddc44.js +15 -0
- package/dist/shared/components-4xxtggzp.js +110 -0
- package/dist/shared/components-54nf2x99.js +293 -0
- package/dist/shared/components-5pkcfprd.js +232 -0
- package/dist/shared/components-5vxtcp88.js +9 -0
- package/dist/shared/components-5zry9te1.js +152 -0
- package/dist/shared/components-61ckf42z.js +220 -0
- package/dist/shared/components-6hzwfmfd.js +58 -0
- package/dist/shared/components-6phwsry6.js +361 -0
- package/dist/shared/components-6t6nr33r.js +86 -0
- package/dist/shared/components-6y1th6k4.js +111 -0
- package/dist/shared/components-74c20v2f.js +32 -0
- package/dist/shared/components-7cqq1sqy.js +193 -0
- package/dist/shared/components-7gv95yfy.js +496 -0
- package/dist/shared/components-7nww01w4.js +375 -0
- package/dist/shared/components-7zp99w5d.js +62 -0
- package/dist/shared/components-8hk9ve3r.js +1200 -0
- package/dist/shared/components-8hzbsfbd.js +123 -0
- package/dist/shared/components-9p8s8n5q.js +171 -0
- package/dist/shared/components-aaq3yk4f.js +304 -0
- package/dist/shared/components-bf2d9k02.js +484 -0
- package/dist/shared/components-bkvb6nem.js +63 -0
- package/dist/shared/components-brnzrp2t.js +262 -0
- package/dist/shared/components-csxz9f52.js +42 -0
- package/dist/shared/components-de8xsm9y.js +22 -0
- package/dist/shared/components-dg0w8g5p.js +26 -0
- package/dist/shared/components-dphg9gjr.js +42 -0
- package/dist/shared/components-e46kf6cp.js +298 -0
- package/dist/shared/components-ed7cmssr.js +105 -0
- package/dist/shared/components-ess3ch6w.js +137 -0
- package/dist/shared/components-gjfrycb5.js +984 -0
- package/dist/shared/components-gndm6am4.js +128 -0
- package/dist/shared/components-hjkrv00c.js +191 -0
- package/dist/shared/components-hzfp4tjb.js +270 -0
- package/dist/shared/components-j65qt1mq.js +719 -0
- package/dist/shared/components-jw16snbn.js +19 -0
- package/dist/shared/components-jxgznftn.js +146 -0
- package/dist/shared/components-kf2ehztc.js +216 -0
- package/dist/shared/components-kpbcms10.js +9 -0
- package/dist/shared/components-m5br529r.js +141 -0
- package/dist/shared/components-nn6xezy2.js +1828 -0
- package/dist/shared/components-nnnd2xef.js +9 -0
- package/dist/shared/components-p2vmyfe1.js +345 -0
- package/dist/shared/components-peg09pzs.js +79 -0
- package/dist/shared/components-r22vtgqc.js +45 -0
- package/dist/shared/components-r2gke5p6.js +1759 -0
- package/dist/shared/components-r43mqnd6.js +160 -0
- package/dist/shared/components-r4jt6hgd.js +58 -0
- package/dist/shared/components-rc63qsy6.js +159 -0
- package/dist/shared/components-s3yfvfkr.js +149 -0
- package/dist/shared/components-s5pkbjx1.js +445 -0
- package/dist/shared/components-tad5h7ta.js +346 -0
- package/dist/shared/components-taxmgbnh.js +120 -0
- package/dist/shared/components-tm88ghva.js +215 -0
- package/dist/shared/components-v7es8aan.js +144 -0
- package/dist/shared/components-vb033rns.js +28 -0
- package/dist/shared/components-vc1k7yv2.js +30 -0
- package/dist/shared/components-vktws5r6.js +667 -0
- package/dist/shared/components-x2xyckd5.js +198 -0
- package/dist/shared/components-x3rz4cyn.js +61 -0
- package/dist/shared/components-xszag63d.js +141 -0
- package/dist/shared/components-y3cqdrgy.js +291 -0
- package/dist/shared/components-zvb11ker.js +288 -0
- package/dist/shared/components-zx2hr57f.js +124 -0
- package/dist/styles.css +1949 -0
- package/dist/tailwind.css +219 -0
- package/dist/tokens.css +345 -0
- package/package.json +102 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
button_default
|
|
3
|
+
} from "./components-5pkcfprd.js";
|
|
4
|
+
import {
|
|
5
|
+
SURFACE_BG,
|
|
6
|
+
SURFACE_SHADOW,
|
|
7
|
+
SurfaceProvider,
|
|
8
|
+
useSurface
|
|
9
|
+
} from "./components-csxz9f52.js";
|
|
10
|
+
import {
|
|
11
|
+
MorphPart,
|
|
12
|
+
MorphSurface
|
|
13
|
+
} from "./components-jxgznftn.js";
|
|
14
|
+
import {
|
|
15
|
+
useShape
|
|
16
|
+
} from "./components-7zp99w5d.js";
|
|
17
|
+
import {
|
|
18
|
+
useControllableState
|
|
19
|
+
} from "./components-dg0w8g5p.js";
|
|
20
|
+
import {
|
|
21
|
+
opensInPlace,
|
|
22
|
+
useMorph,
|
|
23
|
+
useMorphOrigin
|
|
24
|
+
} from "./components-7nww01w4.js";
|
|
25
|
+
import {
|
|
26
|
+
cn
|
|
27
|
+
} from "./components-0f0as45n.js";
|
|
28
|
+
|
|
29
|
+
// primitives/morph/index.tsx
|
|
30
|
+
import { useState } from "react";
|
|
31
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
32
|
+
function Morph({
|
|
33
|
+
from = "trigger",
|
|
34
|
+
effect = "goo",
|
|
35
|
+
tier = "slow",
|
|
36
|
+
hideSource = false,
|
|
37
|
+
open,
|
|
38
|
+
defaultOpen = false,
|
|
39
|
+
onOpenChange,
|
|
40
|
+
label = "Open",
|
|
41
|
+
className,
|
|
42
|
+
children
|
|
43
|
+
}) {
|
|
44
|
+
const [shown, setShown] = useControllableState(open, defaultOpen, onOpenChange);
|
|
45
|
+
const [mounted, setMounted] = useState(shown);
|
|
46
|
+
if (shown && !mounted)
|
|
47
|
+
setMounted(true);
|
|
48
|
+
const { origin, capture } = useMorphOrigin();
|
|
49
|
+
const morph = useMorph(shown, origin, { from, effect, tier, hideSource }, () => setMounted(false));
|
|
50
|
+
const shape = useShape();
|
|
51
|
+
const level = Math.min(useSurface() + 2, 8);
|
|
52
|
+
const inPlace = opensInPlace({ effect, hideSource });
|
|
53
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
54
|
+
className: cn("relative inline-flex flex-col items-center", className),
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsx(button_default, {
|
|
57
|
+
variant: "secondary",
|
|
58
|
+
"aria-expanded": shown,
|
|
59
|
+
onClick: (event) => {
|
|
60
|
+
if (!shown)
|
|
61
|
+
capture({ trigger: event.currentTarget, event: event.nativeEvent });
|
|
62
|
+
setShown(!shown);
|
|
63
|
+
},
|
|
64
|
+
children: shown ? "Close" : label
|
|
65
|
+
}),
|
|
66
|
+
mounted && /* @__PURE__ */ jsx("div", {
|
|
67
|
+
ref: morph.popupRef,
|
|
68
|
+
className: inPlace ? "absolute top-0 left-0 z-10" : "absolute top-full left-1/2 z-10 mt-3 -translate-x-1/2",
|
|
69
|
+
onClick: inPlace ? () => setShown(false) : undefined,
|
|
70
|
+
children: /* @__PURE__ */ jsx(SurfaceProvider, {
|
|
71
|
+
value: level,
|
|
72
|
+
children: /* @__PURE__ */ jsx(MorphSurface, {
|
|
73
|
+
morph,
|
|
74
|
+
bg: SURFACE_BG[level],
|
|
75
|
+
shadow: SURFACE_SHADOW[level],
|
|
76
|
+
radius: shape.container,
|
|
77
|
+
className: "w-56 p-4",
|
|
78
|
+
children
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
Morph.Part = MorphPart;
|
|
86
|
+
export { Morph };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SURFACE_BG,
|
|
3
|
+
SURFACE_SHADOW,
|
|
4
|
+
SurfaceProvider,
|
|
5
|
+
useSurface
|
|
6
|
+
} from "./components-csxz9f52.js";
|
|
7
|
+
import {
|
|
8
|
+
MorphSurface
|
|
9
|
+
} from "./components-jxgznftn.js";
|
|
10
|
+
import {
|
|
11
|
+
useShape
|
|
12
|
+
} from "./components-7zp99w5d.js";
|
|
13
|
+
import {
|
|
14
|
+
useControllableState
|
|
15
|
+
} from "./components-dg0w8g5p.js";
|
|
16
|
+
import {
|
|
17
|
+
inPlaceOffset,
|
|
18
|
+
opensInPlace,
|
|
19
|
+
useMorph,
|
|
20
|
+
useMorphOrigin
|
|
21
|
+
} from "./components-7nww01w4.js";
|
|
22
|
+
import {
|
|
23
|
+
cn
|
|
24
|
+
} from "./components-0f0as45n.js";
|
|
25
|
+
|
|
26
|
+
// components/overlays/preview-card/index.tsx
|
|
27
|
+
import { PreviewCard as PreviewCardPrimitive } from "@base-ui/react/preview-card";
|
|
28
|
+
import {
|
|
29
|
+
createContext,
|
|
30
|
+
forwardRef,
|
|
31
|
+
useContext,
|
|
32
|
+
useImperativeHandle,
|
|
33
|
+
useMemo
|
|
34
|
+
} from "react";
|
|
35
|
+
import { jsx } from "react/jsx-runtime";
|
|
36
|
+
var PreviewCardContext = createContext({ open: false, origin: { current: {} } });
|
|
37
|
+
var PreviewCardTrigger = forwardRef(({ render, className, ...props }, ref) => /* @__PURE__ */ jsx(PreviewCardPrimitive.Trigger, {
|
|
38
|
+
ref,
|
|
39
|
+
render,
|
|
40
|
+
className: cn(!render && "weight-medium text-foreground underline decoration-border underline-offset-4 transition-colors duration-fast hover:decoration-foreground", className),
|
|
41
|
+
...props
|
|
42
|
+
}));
|
|
43
|
+
PreviewCardTrigger.displayName = "PreviewCardTrigger";
|
|
44
|
+
var PreviewCardContent = forwardRef(({
|
|
45
|
+
side = "bottom",
|
|
46
|
+
align,
|
|
47
|
+
sideOffset = 12,
|
|
48
|
+
from,
|
|
49
|
+
effect,
|
|
50
|
+
hideSource,
|
|
51
|
+
tier,
|
|
52
|
+
container,
|
|
53
|
+
className,
|
|
54
|
+
children,
|
|
55
|
+
...props
|
|
56
|
+
}, ref) => {
|
|
57
|
+
const { open, origin } = useContext(PreviewCardContext);
|
|
58
|
+
const morph = useMorph(open, origin, { from, effect, hideSource, tier });
|
|
59
|
+
const inPlace = opensInPlace({ effect, hideSource });
|
|
60
|
+
useImperativeHandle(ref, () => morph.popup, [morph.popup]);
|
|
61
|
+
const shape = useShape();
|
|
62
|
+
const level = Math.min(useSurface() + 2, 8);
|
|
63
|
+
return /* @__PURE__ */ jsx(PreviewCardPrimitive.Portal, {
|
|
64
|
+
container: container ?? undefined,
|
|
65
|
+
children: /* @__PURE__ */ jsx(PreviewCardPrimitive.Positioner, {
|
|
66
|
+
side,
|
|
67
|
+
align: align ?? (inPlace ? "start" : "center"),
|
|
68
|
+
sideOffset: inPlace ? inPlaceOffset : sideOffset,
|
|
69
|
+
className: "z-50 outline-none",
|
|
70
|
+
children: /* @__PURE__ */ jsx(PreviewCardPrimitive.Popup, {
|
|
71
|
+
ref: morph.popupRef,
|
|
72
|
+
className: "relative outline-none",
|
|
73
|
+
...props,
|
|
74
|
+
children: /* @__PURE__ */ jsx(SurfaceProvider, {
|
|
75
|
+
value: level,
|
|
76
|
+
children: /* @__PURE__ */ jsx(MorphSurface, {
|
|
77
|
+
morph,
|
|
78
|
+
bg: SURFACE_BG[level],
|
|
79
|
+
shadow: SURFACE_SHADOW[3],
|
|
80
|
+
radius: shape.container,
|
|
81
|
+
className: cn("flex w-max max-w-[min(92vw,20rem)] flex-col gap-3 p-4", className),
|
|
82
|
+
children
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
PreviewCardContent.displayName = "PreviewCardContent";
|
|
90
|
+
function PreviewCard({ open, defaultOpen = false, onOpenChange, children }) {
|
|
91
|
+
const [current, setCurrent] = useControllableState(open, defaultOpen, onOpenChange);
|
|
92
|
+
const { origin, capture } = useMorphOrigin();
|
|
93
|
+
const ctx = useMemo(() => ({ open: current, origin }), [current, origin]);
|
|
94
|
+
return /* @__PURE__ */ jsx(PreviewCardContext.Provider, {
|
|
95
|
+
value: ctx,
|
|
96
|
+
children: /* @__PURE__ */ jsx(PreviewCardPrimitive.Root, {
|
|
97
|
+
open: current,
|
|
98
|
+
onOpenChange: (next, details) => {
|
|
99
|
+
if (next)
|
|
100
|
+
capture(details);
|
|
101
|
+
setCurrent(next);
|
|
102
|
+
},
|
|
103
|
+
children
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
PreviewCard.Trigger = PreviewCardTrigger;
|
|
108
|
+
PreviewCard.Content = PreviewCardContent;
|
|
109
|
+
var preview_card_default = PreviewCard;
|
|
110
|
+
|
|
111
|
+
export { PreviewCardTrigger, PreviewCardContent, PreviewCard, preview_card_default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SurfaceProvider,
|
|
3
|
+
surfaceClasses,
|
|
4
|
+
useSurface
|
|
5
|
+
} from "./components-csxz9f52.js";
|
|
6
|
+
import {
|
|
7
|
+
cn
|
|
8
|
+
} from "./components-0f0as45n.js";
|
|
9
|
+
|
|
10
|
+
// primitives/surface/index.tsx
|
|
11
|
+
import {
|
|
12
|
+
forwardRef
|
|
13
|
+
} from "react";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
var Elevated = forwardRef(({ offset, shadowLevel, className, children, ...props }, ref) => {
|
|
16
|
+
const substrate = useSurface();
|
|
17
|
+
const level = Math.min(substrate + offset, 8);
|
|
18
|
+
return /* @__PURE__ */ jsx(SurfaceProvider, {
|
|
19
|
+
value: level,
|
|
20
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
21
|
+
ref,
|
|
22
|
+
className: cn(surfaceClasses(level, shadowLevel ?? level), className),
|
|
23
|
+
...props,
|
|
24
|
+
children
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
Elevated.displayName = "Elevated";
|
|
29
|
+
Object.assign(Elevated, { Provider: SurfaceProvider });
|
|
30
|
+
var surface_default = Elevated;
|
|
31
|
+
|
|
32
|
+
export { Elevated, surface_default };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fieldIconClasses,
|
|
3
|
+
fieldVariants
|
|
4
|
+
} from "./components-de8xsm9y.js";
|
|
5
|
+
import {
|
|
6
|
+
SizeProvider
|
|
7
|
+
} from "./components-vb033rns.js";
|
|
8
|
+
import {
|
|
9
|
+
useFluidHover,
|
|
10
|
+
useRegisterFluidHoverItem
|
|
11
|
+
} from "./components-e46kf6cp.js";
|
|
12
|
+
import {
|
|
13
|
+
useShape
|
|
14
|
+
} from "./components-7zp99w5d.js";
|
|
15
|
+
import {
|
|
16
|
+
useControllableState
|
|
17
|
+
} from "./components-dg0w8g5p.js";
|
|
18
|
+
import {
|
|
19
|
+
useSize
|
|
20
|
+
} from "./components-x3rz4cyn.js";
|
|
21
|
+
import {
|
|
22
|
+
cn
|
|
23
|
+
} from "./components-0f0as45n.js";
|
|
24
|
+
|
|
25
|
+
// components/inputs/input/index.tsx
|
|
26
|
+
import { Field } from "@base-ui/react/field";
|
|
27
|
+
import {
|
|
28
|
+
createContext,
|
|
29
|
+
forwardRef,
|
|
30
|
+
useContext,
|
|
31
|
+
useMemo,
|
|
32
|
+
useRef
|
|
33
|
+
} from "react";
|
|
34
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
35
|
+
var InputGroupContext = createContext(null);
|
|
36
|
+
function useInputGroup() {
|
|
37
|
+
const ctx = useContext(InputGroupContext);
|
|
38
|
+
if (!ctx)
|
|
39
|
+
throw new Error("useInputGroup must be used within an InputGroup");
|
|
40
|
+
return ctx;
|
|
41
|
+
}
|
|
42
|
+
var FieldStateContext = createContext(null);
|
|
43
|
+
var Input = forwardRef(({
|
|
44
|
+
icon: Icon,
|
|
45
|
+
value: valueProp,
|
|
46
|
+
defaultValue = "",
|
|
47
|
+
onChange: onChangeProp,
|
|
48
|
+
invalid,
|
|
49
|
+
disabled,
|
|
50
|
+
size,
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
}, ref) => {
|
|
54
|
+
const [value, onChange] = useControllableState(valueProp, defaultValue, onChangeProp);
|
|
55
|
+
const inputRef = useRef(null);
|
|
56
|
+
const field = useContext(FieldStateContext);
|
|
57
|
+
const shape = useShape();
|
|
58
|
+
const sizeClasses = useSize(size);
|
|
59
|
+
const compact = sizeClasses.variant === "compact";
|
|
60
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
61
|
+
onMouseDown: (e) => {
|
|
62
|
+
if (e.target === inputRef.current)
|
|
63
|
+
return;
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
inputRef.current?.focus();
|
|
66
|
+
},
|
|
67
|
+
"data-active": field?.active || undefined,
|
|
68
|
+
"data-invalid": invalid || undefined,
|
|
69
|
+
"data-disabled": disabled || undefined,
|
|
70
|
+
className: cn(fieldVariants(), "flex items-center", sizeClasses.gap, shape.input, compact ? "px-2" : "px-2.5", sizeClasses.control, className),
|
|
71
|
+
children: [
|
|
72
|
+
Icon && /* @__PURE__ */ jsx(Icon, {
|
|
73
|
+
size: sizeClasses.icon,
|
|
74
|
+
strokeWidth: 1.5,
|
|
75
|
+
className: fieldIconClasses
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ jsx(Field.Control, {
|
|
78
|
+
ref: (node) => {
|
|
79
|
+
const input = node;
|
|
80
|
+
inputRef.current = input;
|
|
81
|
+
if (typeof ref === "function")
|
|
82
|
+
ref(input);
|
|
83
|
+
else if (ref)
|
|
84
|
+
ref.current = input;
|
|
85
|
+
},
|
|
86
|
+
type: "text",
|
|
87
|
+
value,
|
|
88
|
+
onChange: (e) => onChange(e.target.value),
|
|
89
|
+
disabled,
|
|
90
|
+
"aria-invalid": invalid || undefined,
|
|
91
|
+
className: cn("w-full rounded-none bg-transparent text-foreground placeholder:text-muted-foreground outline-none font-[inherit]", sizeClasses.text, "weight-normal"),
|
|
92
|
+
...props
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
Input.displayName = "Input";
|
|
98
|
+
var Label = forwardRef(({ children, invalid, size, className, ...props }, ref) => {
|
|
99
|
+
const sizeClasses = useSize(size);
|
|
100
|
+
const compact = sizeClasses.variant === "compact";
|
|
101
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
102
|
+
ref,
|
|
103
|
+
className: cn("inline-grid", sizeClasses.text, "data-[disabled]:opacity-50", compact ? "pl-2" : "pl-2.5", className),
|
|
104
|
+
...props,
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: "col-start-1 row-start-1 invisible weight-semibold",
|
|
108
|
+
"aria-hidden": "true",
|
|
109
|
+
children
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx("span", {
|
|
112
|
+
className: cn("col-start-1 row-start-1", invalid ? "text-destructive" : "text-muted-foreground", "weight-normal"),
|
|
113
|
+
children
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
Label.displayName = "Label";
|
|
119
|
+
var InputGroup = forwardRef(({ children, size, className, ...props }, ref) => {
|
|
120
|
+
const containerRef = useRef(null);
|
|
121
|
+
const { activeIndex, handlers, registerItem } = useFluidHover(containerRef);
|
|
122
|
+
const contextValue = useMemo(() => ({ registerItem, activeIndex }), [registerItem, activeIndex]);
|
|
123
|
+
const group = /* @__PURE__ */ jsx(InputGroupContext.Provider, {
|
|
124
|
+
value: contextValue,
|
|
125
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
126
|
+
ref: (node) => {
|
|
127
|
+
containerRef.current = node;
|
|
128
|
+
if (typeof ref === "function")
|
|
129
|
+
ref(node);
|
|
130
|
+
else if (ref)
|
|
131
|
+
ref.current = node;
|
|
132
|
+
},
|
|
133
|
+
onMouseEnter: handlers.onMouseEnter,
|
|
134
|
+
onMouseMove: handlers.onMouseMove,
|
|
135
|
+
onMouseLeave: handlers.onMouseLeave,
|
|
136
|
+
className: cn("relative flex flex-col gap-3 w-72 max-w-full", className),
|
|
137
|
+
...props,
|
|
138
|
+
children
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
return size ? /* @__PURE__ */ jsx(SizeProvider, {
|
|
142
|
+
size,
|
|
143
|
+
children: group
|
|
144
|
+
}) : group;
|
|
145
|
+
});
|
|
146
|
+
InputGroup.displayName = "InputGroup";
|
|
147
|
+
var InputField = forwardRef(({ label, labelHidden, index, error, disabled, className, ...props }, ref) => {
|
|
148
|
+
const internalRef = useRef(null);
|
|
149
|
+
const { registerItem, activeIndex } = useInputGroup();
|
|
150
|
+
const sizeClasses = useSize();
|
|
151
|
+
const compact = sizeClasses.variant === "compact";
|
|
152
|
+
useRegisterFluidHoverItem(registerItem, index, internalRef);
|
|
153
|
+
const fieldState = useMemo(() => ({ active: activeIndex === index }), [activeIndex, index]);
|
|
154
|
+
return /* @__PURE__ */ jsxs(Field.Root, {
|
|
155
|
+
ref: (node) => {
|
|
156
|
+
internalRef.current = node;
|
|
157
|
+
if (typeof ref === "function")
|
|
158
|
+
ref(node);
|
|
159
|
+
else if (ref)
|
|
160
|
+
ref.current = node;
|
|
161
|
+
},
|
|
162
|
+
invalid: !!error,
|
|
163
|
+
disabled,
|
|
164
|
+
className: cn("flex flex-col gap-1 cursor-text", disabled && "pointer-events-none", className),
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx(Field.Label, {
|
|
167
|
+
render: /* @__PURE__ */ jsx(Label, {
|
|
168
|
+
invalid: !!error,
|
|
169
|
+
className: labelHidden ? "sr-only" : undefined,
|
|
170
|
+
children: label
|
|
171
|
+
})
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ jsx(FieldStateContext.Provider, {
|
|
174
|
+
value: fieldState,
|
|
175
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
176
|
+
invalid: !!error,
|
|
177
|
+
disabled,
|
|
178
|
+
...props
|
|
179
|
+
})
|
|
180
|
+
}),
|
|
181
|
+
error && /* @__PURE__ */ jsx(Field.Error, {
|
|
182
|
+
match: true,
|
|
183
|
+
className: cn("text-destructive", compact ? "text-caption-compact pl-2" : "text-caption pl-2.5", "weight-medium"),
|
|
184
|
+
children: error
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
InputField.displayName = "InputField";
|
|
190
|
+
Object.assign(InputGroup, { Field: InputField });
|
|
191
|
+
var input_default = Input;
|
|
192
|
+
|
|
193
|
+
export { Input, Label, InputGroup, input_default };
|