@splenddev/kreativ-ui 0.2.9 → 0.3.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/README.md +143 -1511
- package/dist/index.cjs +2450 -1255
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +328 -908
- package/dist/index.d.ts +328 -908
- package/dist/index.js +2306 -1149
- package/dist/index.js.map +1 -1
- package/dist/styles/index.css +2 -2
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -1,229 +1,167 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { useReducedMotion, motion, AnimatePresence } from 'framer-motion';
|
|
3
|
+
import { forwardRef, createContext, useMemo, useId, useRef, useState, useEffect, useCallback, useLayoutEffect, Children, isValidElement, Fragment as Fragment$1, useContext, useReducer } from 'react';
|
|
5
4
|
import { clsx } from 'clsx';
|
|
6
5
|
import { twMerge } from 'tailwind-merge';
|
|
7
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
import { useTheme, defineToken, defineSemanticToken, defineTypography, defineSizes, defineRecipe as defineRecipe$1, defineTheme, ThemeContext, deepMerge } from '@splenddev/kreativ-core';
|
|
8
|
+
export { ThemeContext } from '@splenddev/kreativ-core';
|
|
9
|
+
import * as hooks_star from '@splenddev/kreativ-core/hooks';
|
|
10
|
+
import { useSizeToken, useTypography, useSizeStyle, useResponsiveStyles } from '@splenddev/kreativ-core/hooks';
|
|
11
|
+
import { motion } from 'framer-motion';
|
|
8
12
|
import { ChevronDown, X, Heading, Bold, Italic, ListOrdered, ClipboardList, Code, Link, Minus, Check, Lock, Hash, Search, Link2, Phone, Mail, EyeOff, Eye, Sun, Moon, Monitor } from 'lucide-react';
|
|
9
13
|
import { cva } from 'class-variance-authority';
|
|
14
|
+
import * as types_star from '@splenddev/kreativ-core/types';
|
|
10
15
|
|
|
11
16
|
console.log("BANNER TEST");
|
|
12
17
|
var __defProp = Object.defineProperty;
|
|
18
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
21
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
|
|
35
|
+
|
|
36
|
+
// src/index.ts
|
|
37
|
+
var index_exports = {};
|
|
38
|
+
__export(index_exports, {
|
|
39
|
+
Adornment: () => Adornment,
|
|
40
|
+
Button: () => Button,
|
|
41
|
+
ButtonGroup: () => ButtonGroup,
|
|
42
|
+
ButtonGroupContext: () => ButtonGroupContext,
|
|
43
|
+
ButtonGroupItemContext: () => ButtonGroupItemContext,
|
|
44
|
+
Card: () => Card,
|
|
45
|
+
Checkbox: () => Checkbox,
|
|
46
|
+
Combobox: () => Combobox,
|
|
47
|
+
ComboboxContent: () => ComboboxContent,
|
|
48
|
+
ComboboxInput: () => ComboboxInput,
|
|
49
|
+
ComboboxItem: () => ComboboxItem,
|
|
50
|
+
Container: () => Container,
|
|
51
|
+
Flex: () => Flex,
|
|
52
|
+
FormField: () => FormField,
|
|
53
|
+
FormFieldControl: () => FormFieldControl,
|
|
54
|
+
FormFieldDescription: () => FormFieldDescription,
|
|
55
|
+
FormFieldLabel: () => FormFieldLabel,
|
|
56
|
+
FormFieldMessage: () => FormFieldMessage,
|
|
57
|
+
Grid: () => Grid,
|
|
58
|
+
Input: () => Input,
|
|
59
|
+
InputField: () => InputField,
|
|
60
|
+
MarkdownEditor: () => MarkdownEditor,
|
|
61
|
+
MultiSelect: () => MultiSelect,
|
|
62
|
+
MultiSelectContent: () => MultiSelectContent,
|
|
63
|
+
MultiSelectItem: () => MultiSelectItem,
|
|
64
|
+
MultiSelectTrigger: () => MultiSelectTrigger,
|
|
65
|
+
Radio: () => Radio,
|
|
66
|
+
RadioGroup: () => RadioGroup,
|
|
67
|
+
Select: () => Select,
|
|
68
|
+
SelectContent: () => SelectContent,
|
|
69
|
+
SelectGroup: () => SelectGroup,
|
|
70
|
+
SelectItem: () => SelectItem,
|
|
71
|
+
SelectTrigger: () => SelectTrigger,
|
|
72
|
+
SelectValue: () => SelectValue,
|
|
73
|
+
Stack: () => Stack,
|
|
74
|
+
Switch: () => Switch,
|
|
75
|
+
Textarea: () => Textarea,
|
|
76
|
+
ThemeContext: () => ThemeContext,
|
|
77
|
+
ThemeToggler: () => ThemeToggler,
|
|
78
|
+
UIProvider: () => UIProvider,
|
|
79
|
+
cardSkeleton: () => cardSkeleton,
|
|
80
|
+
cn: () => cn,
|
|
81
|
+
defineRecipe: () => defineRecipe,
|
|
82
|
+
defineSemanticToken: () => defineSemanticToken2,
|
|
83
|
+
defineSemanticTokens: () => defineSemanticTokens,
|
|
84
|
+
defineTheme: () => defineTheme2,
|
|
85
|
+
defineToken: () => defineToken2,
|
|
86
|
+
defineTokens: () => defineTokens,
|
|
87
|
+
defineTypography: () => defineTypography2,
|
|
88
|
+
extendRecipe: () => extendRecipe,
|
|
89
|
+
extendRecipes: () => extendRecipes,
|
|
90
|
+
extendSemanticTokens: () => extendSemanticTokens,
|
|
91
|
+
extendTheme: () => extendTheme,
|
|
92
|
+
extendTokens: () => extendTokens,
|
|
93
|
+
extendTypography: () => extendTypography,
|
|
94
|
+
getRecipeNames: () => getRecipeNames,
|
|
95
|
+
hexToRgbString: () => hexToRgbString,
|
|
96
|
+
rgbToHex: () => rgbToHex,
|
|
97
|
+
useButtonGroupContext: () => useButtonGroupContext,
|
|
98
|
+
useButtonGroupItemContext: () => useButtonGroupItemContext,
|
|
99
|
+
useClearableField: () => useClearableField,
|
|
100
|
+
useFloatingSide: () => useFloatingSide,
|
|
101
|
+
useKeyboardShortcuts: () => useKeyboardShortcuts,
|
|
102
|
+
useOptionalButtonGroupContext: () => useOptionalButtonGroupContext,
|
|
103
|
+
useOptionalButtonGroupItemContext: () => useOptionalButtonGroupItemContext,
|
|
104
|
+
useStatusTransition: () => useStatusTransition
|
|
105
|
+
});
|
|
14
106
|
function cn(...inputs) {
|
|
15
107
|
return twMerge(clsx(inputs));
|
|
16
108
|
}
|
|
17
109
|
__name(cn, "cn");
|
|
18
|
-
var ThemeContext = createContext(null);
|
|
19
|
-
|
|
20
|
-
// src/hooks/useTheme.ts
|
|
21
|
-
function useTheme() {
|
|
22
|
-
const ctx = useContext(ThemeContext);
|
|
23
|
-
if (!ctx) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
"useTheme() was called outside <UIProvider>. Wrap your app in <UIProvider> from 'kreativ-ui'."
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return ctx;
|
|
29
|
-
}
|
|
30
|
-
__name(useTheme, "useTheme");
|
|
31
|
-
var applySizeOffset = /* @__PURE__ */ __name((value, offset) => {
|
|
32
|
-
if (!value || !offset) return value;
|
|
33
|
-
return `calc(${value} - ${offset})`;
|
|
34
|
-
}, "applySizeOffset");
|
|
35
|
-
function useSizeStyle(size, iconOnly = false, componentName = "componentName", options = {}) {
|
|
36
|
-
const { widthFromHeight = false, includeHeight = true, sizeOffset, fontSizeOffset } = options;
|
|
37
|
-
const { theme, fallbackSize } = useTheme();
|
|
38
|
-
return useMemo(() => {
|
|
39
|
-
const scale = theme.sizes;
|
|
40
|
-
const token = scale[size] ?? scale[fallbackSize] ?? Object.values(scale)[0] ?? {};
|
|
41
|
-
const style = {};
|
|
42
|
-
if (includeHeight && token.height) {
|
|
43
|
-
style.height = applySizeOffset(token.height, sizeOffset);
|
|
44
|
-
}
|
|
45
|
-
if (token.width) {
|
|
46
|
-
style.width = applySizeOffset(token.width, sizeOffset);
|
|
47
|
-
} else if ((iconOnly || widthFromHeight) && includeHeight && token.height) {
|
|
48
|
-
style.width = applySizeOffset(token.height, sizeOffset);
|
|
49
|
-
}
|
|
50
|
-
if (!iconOnly && token.paddingX) {
|
|
51
|
-
style.paddingLeft = token.paddingX;
|
|
52
|
-
style.paddingRight = token.paddingX;
|
|
53
|
-
}
|
|
54
|
-
if (token.paddingY) {
|
|
55
|
-
style.paddingTop = token.paddingY;
|
|
56
|
-
style.paddingBottom = token.paddingY;
|
|
57
|
-
}
|
|
58
|
-
if (token.fontSize) {
|
|
59
|
-
style.fontSize = applySizeOffset(token.fontSize, fontSizeOffset);
|
|
60
|
-
}
|
|
61
|
-
if (token.gap) {
|
|
62
|
-
style.gap = iconOnly ? 0 : token.gap;
|
|
63
|
-
}
|
|
64
|
-
if (token.radius) {
|
|
65
|
-
const varName = `--kui-${componentName}-radius`;
|
|
66
|
-
style[varName] = token.radius;
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
style,
|
|
70
|
-
iconSize: token.iconSize,
|
|
71
|
-
fontSize: applySizeOffset(token.fontSize, fontSizeOffset),
|
|
72
|
-
gap: token.gap
|
|
73
|
-
};
|
|
74
|
-
}, [
|
|
75
|
-
theme.sizes,
|
|
76
|
-
size,
|
|
77
|
-
fallbackSize,
|
|
78
|
-
iconOnly,
|
|
79
|
-
includeHeight,
|
|
80
|
-
componentName,
|
|
81
|
-
widthFromHeight
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
__name(useSizeStyle, "useSizeStyle");
|
|
85
|
-
var BREAKPOINTS = {
|
|
86
|
-
sm: 640,
|
|
87
|
-
md: 768,
|
|
88
|
-
lg: 1024,
|
|
89
|
-
xl: 1280,
|
|
90
|
-
"2xl": 1536
|
|
91
|
-
};
|
|
92
|
-
function useBreakpoint(breakpoint) {
|
|
93
|
-
const query = `(min-width: ${BREAKPOINTS[breakpoint]}px)`;
|
|
94
|
-
const [matches, setMatches] = useState(
|
|
95
|
-
() => typeof window !== "undefined" && window.matchMedia(query).matches
|
|
96
|
-
);
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
const mql = window.matchMedia(query);
|
|
99
|
-
const listener = /* @__PURE__ */ __name((e) => setMatches(e.matches), "listener");
|
|
100
|
-
mql.addEventListener("change", listener);
|
|
101
|
-
setMatches(mql.matches);
|
|
102
|
-
return () => mql.removeEventListener("change", listener);
|
|
103
|
-
}, [query]);
|
|
104
|
-
return matches;
|
|
105
|
-
}
|
|
106
|
-
__name(useBreakpoint, "useBreakpoint");
|
|
107
|
-
var VIEWPORT_PADDING = 8;
|
|
108
|
-
function useFloatingSide(triggerRef, open) {
|
|
109
|
-
const contentRef = useRef(null);
|
|
110
|
-
const [side, setSide] = useState("bottom");
|
|
111
|
-
useLayoutEffect(() => {
|
|
112
|
-
if (!open) return;
|
|
113
|
-
const trigger = triggerRef.current;
|
|
114
|
-
const content = contentRef.current;
|
|
115
|
-
if (!trigger || !content) return;
|
|
116
|
-
function measure() {
|
|
117
|
-
const triggerRect = trigger.getBoundingClientRect();
|
|
118
|
-
const contentHeight = content.offsetHeight;
|
|
119
|
-
const spaceBelow = window.innerHeight - triggerRect.bottom - VIEWPORT_PADDING;
|
|
120
|
-
const spaceAbove = triggerRect.top - VIEWPORT_PADDING;
|
|
121
|
-
setSide(contentHeight > spaceBelow && spaceAbove > spaceBelow ? "top" : "bottom");
|
|
122
|
-
}
|
|
123
|
-
__name(measure, "measure");
|
|
124
|
-
measure();
|
|
125
|
-
window.addEventListener("resize", measure);
|
|
126
|
-
window.addEventListener("scroll", measure, true);
|
|
127
|
-
return () => {
|
|
128
|
-
window.removeEventListener("resize", measure);
|
|
129
|
-
window.removeEventListener("scroll", measure, true);
|
|
130
|
-
};
|
|
131
|
-
}, [open, triggerRef]);
|
|
132
|
-
return { contentRef, side };
|
|
133
|
-
}
|
|
134
|
-
__name(useFloatingSide, "useFloatingSide");
|
|
135
|
-
var TRANSITION_DURATION = 1500;
|
|
136
|
-
function useStatusTransition(status) {
|
|
137
|
-
const previousStatus = useRef(status);
|
|
138
|
-
const [transitionStatus, setTransitionStatus] = useState();
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
if (status === previousStatus.current) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
previousStatus.current = status;
|
|
144
|
-
if (status === "none") {
|
|
145
|
-
setTransitionStatus(void 0);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
setTransitionStatus(status);
|
|
149
|
-
const timeout = window.setTimeout(() => {
|
|
150
|
-
setTransitionStatus(void 0);
|
|
151
|
-
}, TRANSITION_DURATION);
|
|
152
|
-
return () => window.clearTimeout(timeout);
|
|
153
|
-
}, [status]);
|
|
154
|
-
return transitionStatus;
|
|
155
|
-
}
|
|
156
|
-
__name(useStatusTransition, "useStatusTransition");
|
|
157
110
|
|
|
158
|
-
// src/utils/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const path = match[1].split(".");
|
|
168
|
-
let current = tokens;
|
|
169
|
-
for (const key of path) {
|
|
170
|
-
if (typeof current !== "object" || current === null || !(key in current)) {
|
|
171
|
-
return "";
|
|
111
|
+
// src/utils/color.ts
|
|
112
|
+
var HEX_RE = /^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
|
|
113
|
+
function rgbToHex(value) {
|
|
114
|
+
const trimmed = value.trim();
|
|
115
|
+
if (HEX_RE.test(trimmed)) {
|
|
116
|
+
if (trimmed.length === 4 || trimmed.length === 3 && !trimmed.startsWith("#")) {
|
|
117
|
+
const clean = trimmed.replace("#", "");
|
|
118
|
+
const expanded = clean.split("").map((ch) => ch + ch).join("");
|
|
119
|
+
return `#${expanded.toUpperCase()}`;
|
|
172
120
|
}
|
|
173
|
-
|
|
121
|
+
return trimmed.startsWith("#") ? trimmed.toUpperCase() : `#${trimmed.toUpperCase()}`;
|
|
174
122
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
123
|
+
const stripped = trimmed.replace(/^rgba?\(/i, "").replace(/\)$/, "").trim();
|
|
124
|
+
const parts = stripped.split(/[\s,]+/).filter(Boolean);
|
|
125
|
+
const numbers = parts.slice(0, 3).map((p) => {
|
|
126
|
+
const cleaned = p.replace(/%$/, "");
|
|
127
|
+
return Number(cleaned);
|
|
128
|
+
}).filter((n) => Number.isFinite(n) && n >= 0 && n <= 255);
|
|
129
|
+
if (numbers.length !== 3) {
|
|
130
|
+
return "#000000";
|
|
181
131
|
}
|
|
182
|
-
|
|
132
|
+
const hex = numbers.map((n) => Math.round(n).toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
133
|
+
return `#${hex}`;
|
|
183
134
|
}
|
|
184
|
-
__name(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
fontWeight: resolveTokenReference(typography.fontWeight, tokens),
|
|
193
|
-
lineHeight: resolveTokenReference(typography.lineHeight, tokens),
|
|
194
|
-
letterSpacing: resolveTokenReference(
|
|
195
|
-
typography.letterSpacing,
|
|
196
|
-
tokens
|
|
197
|
-
)
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
__name(resolveTypography, "resolveTypography");
|
|
201
|
-
|
|
202
|
-
// src/hooks/useTypography.ts
|
|
203
|
-
function useTypography(name) {
|
|
204
|
-
const { theme } = useTheme();
|
|
205
|
-
return resolveTypography(
|
|
206
|
-
name ? theme.typography[name] : void 0,
|
|
207
|
-
theme.tokens
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
__name(useTypography, "useTypography");
|
|
211
|
-
function useClearableField(elementRef, initialValue, onClear) {
|
|
212
|
-
const [hasValue, setHasValue] = useState(() => Boolean(initialValue ?? ""));
|
|
213
|
-
const clear = useCallback(() => {
|
|
214
|
-
const element = elementRef.current;
|
|
215
|
-
if (!element) return;
|
|
216
|
-
const prototype = element instanceof HTMLTextAreaElement ? window.HTMLTextAreaElement.prototype : window.HTMLInputElement.prototype;
|
|
217
|
-
const setter = Object.getOwnPropertyDescriptor(prototype, "value")?.set;
|
|
218
|
-
setter?.call(element, "");
|
|
219
|
-
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
220
|
-
element.focus();
|
|
221
|
-
setHasValue(false);
|
|
222
|
-
onClear?.();
|
|
223
|
-
}, [elementRef, onClear]);
|
|
224
|
-
return { hasValue, setHasValue, clear };
|
|
135
|
+
__name(rgbToHex, "rgbToHex");
|
|
136
|
+
function hexToRgbString(hex) {
|
|
137
|
+
if (!HEX_RE.test(hex)) return null;
|
|
138
|
+
const full = hex.length === 4 ? "#" + [...hex.slice(1)].map((c) => c + c).join("") : hex;
|
|
139
|
+
const r = parseInt(full.slice(1, 3), 16);
|
|
140
|
+
const g = parseInt(full.slice(3, 5), 16);
|
|
141
|
+
const b = parseInt(full.slice(5, 7), 16);
|
|
142
|
+
return `${r} ${g} ${b}`;
|
|
225
143
|
}
|
|
226
|
-
__name(
|
|
144
|
+
__name(hexToRgbString, "hexToRgbString");
|
|
145
|
+
var Adornment = forwardRef(
|
|
146
|
+
({ children, position, className, ...props }, ref) => {
|
|
147
|
+
return /* @__PURE__ */ jsx(
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
ref,
|
|
151
|
+
"data-kui-adornment": true,
|
|
152
|
+
"data-kui-adornment-position": position,
|
|
153
|
+
className: cn(
|
|
154
|
+
"flex shrink-0 items-center justify-center",
|
|
155
|
+
position === "end" && "gap-1.5",
|
|
156
|
+
className
|
|
157
|
+
),
|
|
158
|
+
...props,
|
|
159
|
+
children
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
Adornment.displayName = "Adornment";
|
|
227
165
|
|
|
228
166
|
// src/theme/recipes/resolveRecipe.ts
|
|
229
167
|
function matchesConditions(conditions, props) {
|
|
@@ -264,51 +202,198 @@ function resolveRecipe(recipe, props = {}) {
|
|
|
264
202
|
return cn(...classes);
|
|
265
203
|
}
|
|
266
204
|
__name(resolveRecipe, "resolveRecipe");
|
|
267
|
-
|
|
205
|
+
function ResponsiveStyle({ css }) {
|
|
206
|
+
if (!css) return null;
|
|
207
|
+
return /* @__PURE__ */ jsx("style", { "data-kui-responsive-style": true, children: css });
|
|
208
|
+
}
|
|
209
|
+
__name(ResponsiveStyle, "ResponsiveStyle");
|
|
210
|
+
var defaultButtonGroupContext = {
|
|
211
|
+
orientation: "horizontal",
|
|
212
|
+
attached: false,
|
|
213
|
+
spacing: "md",
|
|
214
|
+
size: "md"
|
|
215
|
+
};
|
|
216
|
+
var ButtonGroupContext = createContext(
|
|
217
|
+
defaultButtonGroupContext
|
|
218
|
+
);
|
|
219
|
+
var ButtonGroupItemContext = createContext(null);
|
|
220
|
+
function useButtonGroupContext() {
|
|
221
|
+
const context = useContext(ButtonGroupContext);
|
|
222
|
+
if (context === void 0) {
|
|
223
|
+
throw new Error(
|
|
224
|
+
"useButtonGroupContext must be used inside a <ButtonGroup /> provider"
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
return context;
|
|
228
|
+
}
|
|
229
|
+
__name(useButtonGroupContext, "useButtonGroupContext");
|
|
230
|
+
function useOptionalButtonGroupContext() {
|
|
231
|
+
return useContext(ButtonGroupContext);
|
|
232
|
+
}
|
|
233
|
+
__name(useOptionalButtonGroupContext, "useOptionalButtonGroupContext");
|
|
234
|
+
function useButtonGroupItemContext() {
|
|
235
|
+
const context = useContext(ButtonGroupItemContext);
|
|
236
|
+
return context !== null;
|
|
237
|
+
}
|
|
238
|
+
__name(useButtonGroupItemContext, "useButtonGroupItemContext");
|
|
239
|
+
function useOptionalButtonGroupItemContext() {
|
|
240
|
+
return useContext(ButtonGroupItemContext);
|
|
241
|
+
}
|
|
242
|
+
__name(useOptionalButtonGroupItemContext, "useOptionalButtonGroupItemContext");
|
|
243
|
+
var ButtonGroupSeparator = forwardRef(({ orientation: explicitOrientation, className, ...rest }, ref) => {
|
|
244
|
+
const context = useButtonGroupContext();
|
|
245
|
+
const orientation = explicitOrientation ?? context?.orientation ?? "horizontal";
|
|
246
|
+
return /* @__PURE__ */ jsx(
|
|
247
|
+
"div",
|
|
248
|
+
{
|
|
249
|
+
ref,
|
|
250
|
+
role: "separator",
|
|
251
|
+
"aria-orientation": orientation,
|
|
252
|
+
"data-kui-button-group-separator": "",
|
|
253
|
+
"data-orientation": orientation,
|
|
254
|
+
className: cn(
|
|
255
|
+
"bg-kui-border",
|
|
256
|
+
className
|
|
257
|
+
),
|
|
258
|
+
...rest
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
ButtonGroupSeparator.displayName = "ButtonGroup.Separator";
|
|
263
|
+
var ButtonGroupText = forwardRef(({ className, children, ...rest }, ref) => {
|
|
264
|
+
return /* @__PURE__ */ jsx(
|
|
265
|
+
"span",
|
|
266
|
+
{
|
|
267
|
+
ref,
|
|
268
|
+
"data-kui-button-group-text": "",
|
|
269
|
+
className: cn(
|
|
270
|
+
"inline-flex items-center text-sm text-muted-foreground",
|
|
271
|
+
className
|
|
272
|
+
),
|
|
273
|
+
...rest,
|
|
274
|
+
children
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
ButtonGroupText.displayName = "ButtonGroup.Text";
|
|
279
|
+
var ButtonGroupLabel = forwardRef(({ className, children, ...rest }, ref) => {
|
|
280
|
+
return /* @__PURE__ */ jsx(
|
|
281
|
+
"span",
|
|
282
|
+
{
|
|
283
|
+
ref,
|
|
284
|
+
"data-kui-button-group-label": "",
|
|
285
|
+
className: cn("text-sm font-medium text-foreground", className),
|
|
286
|
+
...rest,
|
|
287
|
+
children
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
});
|
|
291
|
+
ButtonGroupLabel.displayName = "ButtonGroup.Label";
|
|
292
|
+
var ButtonGroupItem = forwardRef(
|
|
293
|
+
({ className, children, ...props }, ref) => {
|
|
294
|
+
const { orientation, attached } = useButtonGroupContext();
|
|
295
|
+
return /* @__PURE__ */ jsx(ButtonGroupItemContext.Provider, { value: { embedded: true }, children: /* @__PURE__ */ jsx(
|
|
296
|
+
"div",
|
|
297
|
+
{
|
|
298
|
+
ref,
|
|
299
|
+
"data-kui-button-group-item": "true",
|
|
300
|
+
"data-orientation": orientation,
|
|
301
|
+
"data-attached": attached || void 0,
|
|
302
|
+
className: cn(
|
|
303
|
+
"relative flex min-w-0 items-center",
|
|
304
|
+
"transition-[background-color,box-shadow]",
|
|
305
|
+
className
|
|
306
|
+
),
|
|
307
|
+
...props,
|
|
308
|
+
children
|
|
309
|
+
}
|
|
310
|
+
) });
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
ButtonGroupItem.displayName = "ButtonGroup.Item";
|
|
314
|
+
var ButtonGroupRoot = forwardRef(
|
|
315
|
+
({
|
|
316
|
+
orientation = "horizontal",
|
|
317
|
+
attached = false,
|
|
318
|
+
spacing = "md",
|
|
319
|
+
className,
|
|
320
|
+
children,
|
|
321
|
+
size,
|
|
322
|
+
...rest
|
|
323
|
+
}, ref) => {
|
|
324
|
+
const { theme } = useTheme();
|
|
325
|
+
const recipeClasses = resolveRecipe(theme.recipes.ButtonGroup, {
|
|
326
|
+
orientation,
|
|
327
|
+
attached,
|
|
328
|
+
spacing
|
|
329
|
+
});
|
|
330
|
+
const contextValue = useMemo(
|
|
331
|
+
() => ({
|
|
332
|
+
orientation,
|
|
333
|
+
attached,
|
|
334
|
+
spacing,
|
|
335
|
+
size
|
|
336
|
+
}),
|
|
337
|
+
[orientation, attached, spacing, size]
|
|
338
|
+
);
|
|
339
|
+
const separatorSizeToken = useSizeToken(size, "separatorSize");
|
|
340
|
+
return /* @__PURE__ */ jsx(ButtonGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
341
|
+
"div",
|
|
342
|
+
{
|
|
343
|
+
ref,
|
|
344
|
+
role: "group",
|
|
345
|
+
"data-kui-button-group": "",
|
|
346
|
+
"data-orientation": orientation,
|
|
347
|
+
"data-attached": attached || void 0,
|
|
348
|
+
className: cn(recipeClasses, className),
|
|
349
|
+
style: {
|
|
350
|
+
"--kui-button-group-separator-size": separatorSizeToken
|
|
351
|
+
},
|
|
352
|
+
...rest,
|
|
353
|
+
children
|
|
354
|
+
}
|
|
355
|
+
) });
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
ButtonGroupRoot.displayName = "ButtonGroup";
|
|
359
|
+
var ButtonGroup = Object.assign(ButtonGroupRoot, {
|
|
360
|
+
Separator: ButtonGroupSeparator,
|
|
361
|
+
Text: ButtonGroupText,
|
|
362
|
+
Label: ButtonGroupLabel,
|
|
363
|
+
Item: ButtonGroupItem
|
|
364
|
+
});
|
|
365
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
268
366
|
var Button = forwardRef(
|
|
269
367
|
({
|
|
270
368
|
variant = "solid",
|
|
271
369
|
color = "brand",
|
|
272
|
-
size
|
|
370
|
+
size,
|
|
273
371
|
isLoading = false,
|
|
274
372
|
leftIcon,
|
|
275
373
|
rightIcon,
|
|
276
374
|
fullWidth = false,
|
|
277
|
-
disabled,
|
|
375
|
+
disabled = false,
|
|
278
376
|
typography: typographyName = "body",
|
|
279
377
|
className,
|
|
280
378
|
style,
|
|
281
379
|
iconOnly,
|
|
282
380
|
children,
|
|
283
381
|
render,
|
|
284
|
-
onKeyDown,
|
|
285
|
-
onKeyUp,
|
|
286
382
|
...rest
|
|
287
383
|
}, ref) => {
|
|
288
384
|
const { theme } = useTheme();
|
|
289
385
|
const typography = useTypography(typographyName);
|
|
290
|
-
const
|
|
291
|
-
|
|
386
|
+
const group = useOptionalButtonGroupContext();
|
|
387
|
+
const resolvedSize = size ?? group?.size ?? "md";
|
|
388
|
+
const { style: sizeStyle, responsiveStyles } = useSizeStyle(
|
|
389
|
+
resolvedSize,
|
|
292
390
|
iconOnly,
|
|
293
391
|
"button"
|
|
294
392
|
);
|
|
295
|
-
const
|
|
296
|
-
const
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
onKeyDown?.(e);
|
|
300
|
-
if (isInteractive && ACTIVATION_KEYS.has(e.key)) {
|
|
301
|
-
setIsKeyboardPressed(true);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
__name(handleKeyDown, "handleKeyDown");
|
|
305
|
-
function handleKeyUp(e) {
|
|
306
|
-
onKeyUp?.(e);
|
|
307
|
-
if (ACTIVATION_KEYS.has(e.key)) {
|
|
308
|
-
setIsKeyboardPressed(false);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
__name(handleKeyUp, "handleKeyUp");
|
|
393
|
+
const { attribute: responsiveAttribute, style: responsiveCss } = useResponsiveStyles(responsiveStyles);
|
|
394
|
+
const iconSize = useSizeToken(resolvedSize, "iconSize");
|
|
395
|
+
const isDisabled = disabled || isLoading;
|
|
396
|
+
const isInButtonGroup = !!group;
|
|
312
397
|
const recipeClasses = resolveRecipe(theme.recipes.Button, {
|
|
313
398
|
variant,
|
|
314
399
|
color
|
|
@@ -316,7 +401,7 @@ var Button = forwardRef(
|
|
|
316
401
|
const resolvedClassName = cn(
|
|
317
402
|
recipeClasses,
|
|
318
403
|
fullWidth && "w-full",
|
|
319
|
-
isLoading && "
|
|
404
|
+
isLoading && "opacity-90 pointer-events-none",
|
|
320
405
|
className
|
|
321
406
|
);
|
|
322
407
|
const resolvedStyle = {
|
|
@@ -324,6 +409,11 @@ var Button = forwardRef(
|
|
|
324
409
|
...sizeStyle,
|
|
325
410
|
...style
|
|
326
411
|
};
|
|
412
|
+
const groupDataAttributes = {
|
|
413
|
+
"data-kui-button-group-item": isInButtonGroup || void 0,
|
|
414
|
+
"data-kui-group-attached": group?.attached || void 0,
|
|
415
|
+
"data-kui-group-orientation": group?.orientation || void 0
|
|
416
|
+
};
|
|
327
417
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
328
418
|
isLoading && /* @__PURE__ */ jsx(
|
|
329
419
|
"span",
|
|
@@ -336,81 +426,72 @@ var Button = forwardRef(
|
|
|
336
426
|
"aria-hidden": "true"
|
|
337
427
|
}
|
|
338
428
|
),
|
|
339
|
-
!isLoading && leftIcon
|
|
429
|
+
!isLoading && leftIcon && /* @__PURE__ */ jsx(
|
|
430
|
+
"span",
|
|
431
|
+
{
|
|
432
|
+
className: "inline-flex shrink-0 items-center justify-center",
|
|
433
|
+
style: {
|
|
434
|
+
width: iconSize,
|
|
435
|
+
height: iconSize
|
|
436
|
+
},
|
|
437
|
+
"aria-hidden": "true",
|
|
438
|
+
children: leftIcon
|
|
439
|
+
}
|
|
440
|
+
),
|
|
340
441
|
iconOnly && isLoading ? null : children,
|
|
341
|
-
!isLoading && rightIcon
|
|
442
|
+
!isLoading && rightIcon && /* @__PURE__ */ jsx(
|
|
443
|
+
"span",
|
|
444
|
+
{
|
|
445
|
+
className: "inline-flex shrink-0 items-center justify-center",
|
|
446
|
+
style: {
|
|
447
|
+
width: iconSize,
|
|
448
|
+
height: iconSize
|
|
449
|
+
},
|
|
450
|
+
"aria-hidden": "true",
|
|
451
|
+
children: rightIcon
|
|
452
|
+
}
|
|
453
|
+
)
|
|
342
454
|
] });
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
motion.button,
|
|
455
|
+
const buttonElement = render ? render({
|
|
456
|
+
...rest,
|
|
457
|
+
className: resolvedClassName,
|
|
458
|
+
style: resolvedStyle,
|
|
459
|
+
disabled: isDisabled,
|
|
460
|
+
"aria-disabled": isDisabled || void 0,
|
|
461
|
+
"aria-busy": isLoading || void 0,
|
|
462
|
+
"data-kui-responsive": responsiveAttribute,
|
|
463
|
+
children: content
|
|
464
|
+
}) : /* @__PURE__ */ jsx(
|
|
465
|
+
"button",
|
|
355
466
|
{
|
|
356
467
|
ref,
|
|
357
|
-
disabled:
|
|
468
|
+
disabled: isDisabled,
|
|
358
469
|
className: resolvedClassName,
|
|
359
470
|
style: resolvedStyle,
|
|
360
471
|
"aria-busy": isLoading || void 0,
|
|
361
|
-
"aria-disabled":
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
},
|
|
472
|
+
"aria-disabled": isDisabled || void 0,
|
|
473
|
+
"data-kui-themeable": true,
|
|
474
|
+
"data-kui-responsive": responsiveAttribute,
|
|
365
475
|
type: "button",
|
|
366
|
-
|
|
367
|
-
whileTap: isInteractive ? { scale: 0.975 } : void 0,
|
|
368
|
-
transition: prefersReducedMotion ? { duration: 0 } : {
|
|
369
|
-
type: "spring",
|
|
370
|
-
stiffness: 500,
|
|
371
|
-
damping: 30
|
|
372
|
-
},
|
|
373
|
-
onKeyDown: handleKeyDown,
|
|
374
|
-
onKeyUp: handleKeyUp,
|
|
476
|
+
...groupDataAttributes,
|
|
375
477
|
...rest,
|
|
376
478
|
children: content
|
|
377
479
|
}
|
|
378
480
|
);
|
|
481
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
482
|
+
responsiveCss && /* @__PURE__ */ jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
483
|
+
buttonElement
|
|
484
|
+
] });
|
|
379
485
|
}
|
|
380
486
|
);
|
|
381
487
|
Button.displayName = "Button";
|
|
382
488
|
|
|
383
|
-
// src/
|
|
384
|
-
var HEX_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
385
|
-
function rgbToHex(value) {
|
|
386
|
-
const trimmed = value.trim();
|
|
387
|
-
if (HEX_RE.test(trimmed)) {
|
|
388
|
-
if (trimmed.length === 4) {
|
|
389
|
-
return ("#" + [...trimmed.slice(1)].map((char) => char + char).join("")).toUpperCase();
|
|
390
|
-
}
|
|
391
|
-
return trimmed.toUpperCase();
|
|
392
|
-
}
|
|
393
|
-
const values = trimmed.replace(/[^\d,]/g, "").split(",").map(Number);
|
|
394
|
-
if (values.length !== 3 || values.some(Number.isNaN)) {
|
|
395
|
-
return "#000000";
|
|
396
|
-
}
|
|
397
|
-
return "#" + values.map((x) => x.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
398
|
-
}
|
|
399
|
-
__name(rgbToHex, "rgbToHex");
|
|
400
|
-
function hexToRgbString(hex) {
|
|
401
|
-
if (!HEX_RE.test(hex)) return null;
|
|
402
|
-
const full = hex.length === 4 ? "#" + [...hex.slice(1)].map((c) => c + c).join("") : hex;
|
|
403
|
-
const r = parseInt(full.slice(1, 3), 16);
|
|
404
|
-
const g = parseInt(full.slice(3, 5), 16);
|
|
405
|
-
const b = parseInt(full.slice(5, 7), 16);
|
|
406
|
-
return `${r} ${g} ${b}`;
|
|
407
|
-
}
|
|
408
|
-
__name(hexToRgbString, "hexToRgbString");
|
|
489
|
+
// src/components/ThemeToggler/ThemeToggler.constants.ts
|
|
409
490
|
var defaultTransition = {
|
|
410
|
-
type: "
|
|
491
|
+
type: "rotate",
|
|
411
492
|
duration: 300,
|
|
412
493
|
delay: 0,
|
|
413
|
-
easing: "
|
|
494
|
+
easing: "easeInOut"
|
|
414
495
|
};
|
|
415
496
|
var getIconVariants = /* @__PURE__ */ __name((type) => {
|
|
416
497
|
switch (type) {
|
|
@@ -434,9 +515,21 @@ var getIconVariants = /* @__PURE__ */ __name((type) => {
|
|
|
434
515
|
};
|
|
435
516
|
case "rotate":
|
|
436
517
|
return {
|
|
437
|
-
initial: {
|
|
438
|
-
|
|
439
|
-
|
|
518
|
+
initial: {
|
|
519
|
+
opacity: 0,
|
|
520
|
+
rotate: -90,
|
|
521
|
+
scale: 0.8
|
|
522
|
+
},
|
|
523
|
+
animate: {
|
|
524
|
+
opacity: 1,
|
|
525
|
+
rotate: 0,
|
|
526
|
+
scale: 1
|
|
527
|
+
},
|
|
528
|
+
exit: {
|
|
529
|
+
opacity: 0,
|
|
530
|
+
rotate: 90,
|
|
531
|
+
scale: 0.8
|
|
532
|
+
}
|
|
440
533
|
};
|
|
441
534
|
case "none":
|
|
442
535
|
default:
|
|
@@ -447,10 +540,233 @@ var getIconVariants = /* @__PURE__ */ __name((type) => {
|
|
|
447
540
|
};
|
|
448
541
|
}
|
|
449
542
|
}, "getIconVariants");
|
|
543
|
+
var CycleMode = /* @__PURE__ */ __name(({
|
|
544
|
+
size,
|
|
545
|
+
variant,
|
|
546
|
+
color,
|
|
547
|
+
iconOnly,
|
|
548
|
+
buttonProps,
|
|
549
|
+
animated,
|
|
550
|
+
transition = { type: "none" },
|
|
551
|
+
rounded,
|
|
552
|
+
currentMode,
|
|
553
|
+
onCycle
|
|
554
|
+
}) => {
|
|
555
|
+
const animateIcon = animated && transition.type !== "none";
|
|
556
|
+
const iconVariants = getIconVariants(transition.type ?? "none");
|
|
557
|
+
const motionTransition = {
|
|
558
|
+
duration: (transition.duration ?? 300) / 1e3,
|
|
559
|
+
delay: (transition.delay ?? 0) / 1e3,
|
|
560
|
+
ease: transition.easing
|
|
561
|
+
};
|
|
562
|
+
return /* @__PURE__ */ jsxs(
|
|
563
|
+
Button,
|
|
564
|
+
{
|
|
565
|
+
size,
|
|
566
|
+
variant,
|
|
567
|
+
color,
|
|
568
|
+
onClick: onCycle,
|
|
569
|
+
"aria-label": `Current theme: ${currentMode.label}`,
|
|
570
|
+
className: cn(rounded && "rounded-full", "py-5 overflow-hidden", buttonProps?.className),
|
|
571
|
+
...buttonProps,
|
|
572
|
+
children: [
|
|
573
|
+
/* @__PURE__ */ jsx(
|
|
574
|
+
motion.span,
|
|
575
|
+
{
|
|
576
|
+
initial: animateIcon ? iconVariants.initial : void 0,
|
|
577
|
+
animate: animateIcon ? iconVariants.animate : void 0,
|
|
578
|
+
exit: animateIcon ? iconVariants.exit : void 0,
|
|
579
|
+
transition: motionTransition,
|
|
580
|
+
children: currentMode.icon
|
|
581
|
+
},
|
|
582
|
+
currentMode.key
|
|
583
|
+
),
|
|
584
|
+
!iconOnly && currentMode.label
|
|
585
|
+
]
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
}, "CycleMode");
|
|
589
|
+
var useIndicator = /* @__PURE__ */ __name((activeKey, deps = []) => {
|
|
590
|
+
const groupRef = useRef(null);
|
|
591
|
+
const buttonRefs = useRef(/* @__PURE__ */ new Map());
|
|
592
|
+
const [indicatorRect, setIndicatorRect] = useState(
|
|
593
|
+
null
|
|
594
|
+
);
|
|
595
|
+
const measure = useCallback(() => {
|
|
596
|
+
const group = groupRef.current;
|
|
597
|
+
const activeEl = buttonRefs.current.get(activeKey);
|
|
598
|
+
if (!group || !activeEl) return;
|
|
599
|
+
const groupBox = group.getBoundingClientRect();
|
|
600
|
+
const activeBox = activeEl.getBoundingClientRect();
|
|
601
|
+
const style = getComputedStyle(group);
|
|
602
|
+
const borderLeft = parseFloat(style.borderLeftWidth) || 0;
|
|
603
|
+
const borderTop = parseFloat(style.borderTopWidth) || 0;
|
|
604
|
+
setIndicatorRect({
|
|
605
|
+
top: activeBox.top - groupBox.top - borderTop,
|
|
606
|
+
left: activeBox.left - groupBox.left - borderLeft,
|
|
607
|
+
width: activeBox.width,
|
|
608
|
+
height: activeBox.height
|
|
609
|
+
});
|
|
610
|
+
}, [activeKey]);
|
|
611
|
+
useLayoutEffect(() => {
|
|
612
|
+
measure();
|
|
613
|
+
}, [activeKey, ...deps]);
|
|
614
|
+
useLayoutEffect(() => {
|
|
615
|
+
window.addEventListener("resize", measure);
|
|
616
|
+
return () => {
|
|
617
|
+
window.removeEventListener("resize", measure);
|
|
618
|
+
};
|
|
619
|
+
}, [measure]);
|
|
620
|
+
return {
|
|
621
|
+
groupRef,
|
|
622
|
+
buttonRefs,
|
|
623
|
+
indicatorRect,
|
|
624
|
+
measure
|
|
625
|
+
};
|
|
626
|
+
}, "useIndicator");
|
|
627
|
+
var ButtonsMode = /* @__PURE__ */ __name(({
|
|
628
|
+
size,
|
|
629
|
+
color,
|
|
630
|
+
iconOnly,
|
|
631
|
+
buttonProps,
|
|
632
|
+
rounded,
|
|
633
|
+
unstyled,
|
|
634
|
+
className,
|
|
635
|
+
modes,
|
|
636
|
+
activeMode,
|
|
637
|
+
onSelect,
|
|
638
|
+
containerStyle,
|
|
639
|
+
isActive,
|
|
640
|
+
orientation,
|
|
641
|
+
indicatorClasses,
|
|
642
|
+
indicatorRadius,
|
|
643
|
+
buttonWidth,
|
|
644
|
+
indicatorTransition
|
|
645
|
+
}) => {
|
|
646
|
+
const { groupRef, buttonRefs, indicatorRect } = useIndicator(activeMode, [
|
|
647
|
+
size,
|
|
648
|
+
orientation,
|
|
649
|
+
iconOnly,
|
|
650
|
+
unstyled,
|
|
651
|
+
rounded
|
|
652
|
+
]);
|
|
653
|
+
const effectiveRounded = rounded && !(orientation === "vertical" && !iconOnly && !unstyled);
|
|
654
|
+
const containerClasses = cn(
|
|
655
|
+
"inline-flex gap-1",
|
|
656
|
+
orientation === "vertical" && "flex-col",
|
|
657
|
+
!unstyled && [
|
|
658
|
+
"border border-kui-border bg-kui-surface p-1",
|
|
659
|
+
effectiveRounded ? "rounded-full" : "rounded-[var(--kui-theme-toggler-radius)]"
|
|
660
|
+
],
|
|
661
|
+
className
|
|
662
|
+
);
|
|
663
|
+
const isVerticalIconOnly = orientation === "vertical" && iconOnly;
|
|
664
|
+
const buttons = modes.map(({ key, label, icon }) => {
|
|
665
|
+
const active = isActive(key);
|
|
666
|
+
return /* @__PURE__ */ jsx(
|
|
667
|
+
"div",
|
|
668
|
+
{
|
|
669
|
+
ref: (element) => {
|
|
670
|
+
if (element) {
|
|
671
|
+
buttonRefs.current.set(key, element);
|
|
672
|
+
} else {
|
|
673
|
+
buttonRefs.current.delete(key);
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
className: cn(
|
|
677
|
+
"relative flex",
|
|
678
|
+
orientation === "vertical" && "w-full",
|
|
679
|
+
isVerticalIconOnly && "justify-start"
|
|
680
|
+
),
|
|
681
|
+
children: /* @__PURE__ */ jsx(
|
|
682
|
+
Button,
|
|
683
|
+
{
|
|
684
|
+
size,
|
|
685
|
+
variant: "ghost",
|
|
686
|
+
color,
|
|
687
|
+
onClick: () => onSelect(key),
|
|
688
|
+
fullWidth: orientation === "vertical" && !iconOnly,
|
|
689
|
+
className: cn(
|
|
690
|
+
"relative z-10",
|
|
691
|
+
"bg-transparent hover:bg-transparent",
|
|
692
|
+
!effectiveRounded && "rounded-(--kui-theme-toggler-radius)",
|
|
693
|
+
effectiveRounded && "rounded-full",
|
|
694
|
+
active && "text-kui-brand-fg",
|
|
695
|
+
iconOnly && "aspect-square",
|
|
696
|
+
buttonProps?.className
|
|
697
|
+
),
|
|
698
|
+
"aria-pressed": active,
|
|
699
|
+
leftIcon: icon,
|
|
700
|
+
...buttonProps,
|
|
701
|
+
children: !iconOnly && label
|
|
702
|
+
}
|
|
703
|
+
)
|
|
704
|
+
},
|
|
705
|
+
key
|
|
706
|
+
);
|
|
707
|
+
});
|
|
708
|
+
return /* @__PURE__ */ jsxs(
|
|
709
|
+
"div",
|
|
710
|
+
{
|
|
711
|
+
ref: groupRef,
|
|
712
|
+
role: "group",
|
|
713
|
+
"aria-label": "Theme selector",
|
|
714
|
+
className: cn(containerClasses, "relative"),
|
|
715
|
+
style: containerStyle,
|
|
716
|
+
"data-kui-theme-toggler": "",
|
|
717
|
+
"data-kui-display": "buttons",
|
|
718
|
+
"data-kui-orientation": orientation,
|
|
719
|
+
children: [
|
|
720
|
+
indicatorRect && /* @__PURE__ */ jsx(
|
|
721
|
+
motion.div,
|
|
722
|
+
{
|
|
723
|
+
"data-kui-theme-transition": "none",
|
|
724
|
+
className: cn("pointer-events-none absolute z-0", indicatorClasses),
|
|
725
|
+
style: {
|
|
726
|
+
borderRadius: effectiveRounded ? "999px" : indicatorRadius
|
|
727
|
+
},
|
|
728
|
+
initial: false,
|
|
729
|
+
animate: {
|
|
730
|
+
top: indicatorRect.top,
|
|
731
|
+
left: indicatorRect.left,
|
|
732
|
+
width: isVerticalIconOnly ? buttonWidth : indicatorRect.width,
|
|
733
|
+
height: indicatorRect.height
|
|
734
|
+
},
|
|
735
|
+
transition: { duration: 0 },
|
|
736
|
+
"aria-hidden": "true"
|
|
737
|
+
}
|
|
738
|
+
),
|
|
739
|
+
buttons
|
|
740
|
+
]
|
|
741
|
+
}
|
|
742
|
+
);
|
|
743
|
+
}, "ButtonsMode");
|
|
744
|
+
var getModeIcons = /* @__PURE__ */ __name((allowSystem, labels, icons) => {
|
|
745
|
+
const modes = [
|
|
746
|
+
{
|
|
747
|
+
key: "light",
|
|
748
|
+
label: labels?.light ?? "Light",
|
|
749
|
+
icon: icons?.light ?? /* @__PURE__ */ jsx(Sun, {})
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
key: "dark",
|
|
753
|
+
label: labels?.dark ?? "Dark",
|
|
754
|
+
icon: icons?.dark ?? /* @__PURE__ */ jsx(Moon, {})
|
|
755
|
+
}
|
|
756
|
+
];
|
|
757
|
+
if (allowSystem) {
|
|
758
|
+
modes.push({
|
|
759
|
+
key: "system",
|
|
760
|
+
label: labels?.system ?? "System",
|
|
761
|
+
icon: icons?.system ?? /* @__PURE__ */ jsx(Monitor, {})
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
return modes;
|
|
765
|
+
}, "getModeIcons");
|
|
450
766
|
function ThemeToggler({
|
|
451
767
|
variant = "ghost",
|
|
452
|
-
activeVariant = "solid",
|
|
453
768
|
color = "neutral",
|
|
769
|
+
activeVariant = "solid",
|
|
454
770
|
activeColor = "brand",
|
|
455
771
|
size = "sm",
|
|
456
772
|
iconOnly = false,
|
|
@@ -463,130 +779,236 @@ function ThemeToggler({
|
|
|
463
779
|
className,
|
|
464
780
|
buttonProps = {},
|
|
465
781
|
display = "buttons",
|
|
782
|
+
animated = false,
|
|
466
783
|
transition = defaultTransition
|
|
467
784
|
}) {
|
|
468
|
-
const { mode, setMode, resolvedMode } = useTheme();
|
|
785
|
+
const { mode, setMode, resolvedMode, theme } = useTheme();
|
|
786
|
+
const resolvedSize = size;
|
|
787
|
+
const wrapperRadius = useSizeToken(resolvedSize, "radius");
|
|
788
|
+
const indicatorRadius = useSizeToken(resolvedSize, "radius", "4px");
|
|
789
|
+
const buttonWidth = useSizeToken(resolvedSize, "width");
|
|
469
790
|
const activeMode = allowSystem ? mode : resolvedMode;
|
|
470
|
-
const modes =
|
|
471
|
-
{
|
|
472
|
-
key: "light",
|
|
473
|
-
label: labels?.light ?? "Light",
|
|
474
|
-
icon: icons?.light ?? /* @__PURE__ */ jsx(Sun, { size: 16 })
|
|
475
|
-
},
|
|
476
|
-
{
|
|
477
|
-
key: "dark",
|
|
478
|
-
label: labels?.dark ?? "Dark",
|
|
479
|
-
icon: icons?.dark ?? /* @__PURE__ */ jsx(Moon, { size: 16 })
|
|
480
|
-
},
|
|
481
|
-
...allowSystem ? [
|
|
482
|
-
{
|
|
483
|
-
key: "system",
|
|
484
|
-
label: labels?.system ?? "System",
|
|
485
|
-
icon: icons?.system ?? /* @__PURE__ */ jsx(Monitor, { size: 16 })
|
|
486
|
-
}
|
|
487
|
-
] : []
|
|
488
|
-
];
|
|
791
|
+
const modes = getModeIcons(allowSystem, labels, icons);
|
|
489
792
|
const allowedModes = modes.map((item) => item.key);
|
|
490
793
|
const currentMode = modes.find(({ key }) => key === activeMode) ?? modes[0];
|
|
491
|
-
const
|
|
794
|
+
const indicatorClasses = resolveRecipe(theme.recipes.Button, {
|
|
795
|
+
variant: activeVariant,
|
|
796
|
+
color: activeColor
|
|
797
|
+
});
|
|
798
|
+
const effectiveRounded = rounded && !(orientation === "vertical" && !iconOnly && !unstyled);
|
|
492
799
|
useEffect(() => {
|
|
493
|
-
if (rounded
|
|
800
|
+
if (!rounded || effectiveRounded) return;
|
|
801
|
+
const reasons = [];
|
|
802
|
+
if (orientation === "vertical" && !iconOnly) {
|
|
803
|
+
reasons.push("orientation='vertical' with iconOnly={false}");
|
|
804
|
+
}
|
|
805
|
+
if (unstyled) reasons.push("unstyled={true}");
|
|
806
|
+
if (reasons.length > 0) {
|
|
494
807
|
console.warn(
|
|
495
|
-
|
|
808
|
+
`[kreativ-ui/ThemeToggler] \`rounded\` is ignored when ${reasons.join(" and ")}.`
|
|
496
809
|
);
|
|
497
810
|
}
|
|
498
|
-
}, [rounded, effectiveRounded]);
|
|
811
|
+
}, [rounded, effectiveRounded, orientation, iconOnly, unstyled]);
|
|
499
812
|
const handleCycle = /* @__PURE__ */ __name(() => {
|
|
500
|
-
const index = allowedModes.indexOf(
|
|
501
|
-
activeMode
|
|
502
|
-
);
|
|
813
|
+
const index = allowedModes.indexOf(activeMode);
|
|
503
814
|
setMode(allowedModes[(index + 1) % allowedModes.length]);
|
|
504
815
|
}, "handleCycle");
|
|
505
816
|
const isActive = /* @__PURE__ */ __name((key) => key === "system" ? mode === "system" : activeMode === key, "isActive");
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
"border border-border bg-surface p-1",
|
|
511
|
-
effectiveRounded ? "rounded-full" : "rounded-lg"
|
|
512
|
-
],
|
|
513
|
-
className
|
|
514
|
-
);
|
|
515
|
-
const buttonRadius = effectiveRounded ? "rounded-full" : "rounded-lg";
|
|
516
|
-
const animateIcon = display === "cycle" && transition.type !== "none";
|
|
517
|
-
const iconVariants = getIconVariants(transition.type || "none");
|
|
518
|
-
const motionTransition = {
|
|
519
|
-
duration: (transition.duration || 300) / 1e3,
|
|
520
|
-
delay: (transition.delay || 0) / 1e3,
|
|
521
|
-
ease: transition.easing || "ease-in-out"
|
|
817
|
+
const containerStyle = {
|
|
818
|
+
...!effectiveRounded && {
|
|
819
|
+
"--kui-theme-toggler-radius": wrapperRadius
|
|
820
|
+
}
|
|
522
821
|
};
|
|
822
|
+
const indicatorTransition = animated ? { type: "spring", stiffness: 300, damping: 30, mass: 0.8 } : { duration: 0 };
|
|
523
823
|
if (display === "cycle") {
|
|
524
|
-
return /* @__PURE__ */
|
|
525
|
-
|
|
824
|
+
return /* @__PURE__ */ jsx(
|
|
825
|
+
CycleMode,
|
|
526
826
|
{
|
|
527
|
-
size,
|
|
827
|
+
size: resolvedSize,
|
|
528
828
|
variant,
|
|
529
829
|
color,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
children: [
|
|
538
|
-
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsx(
|
|
539
|
-
motion.span,
|
|
540
|
-
{
|
|
541
|
-
initial: animateIcon ? iconVariants.initial : void 0,
|
|
542
|
-
animate: animateIcon ? iconVariants.animate : void 0,
|
|
543
|
-
exit: animateIcon ? iconVariants.exit : void 0,
|
|
544
|
-
transition: motionTransition,
|
|
545
|
-
children: currentMode.icon
|
|
546
|
-
},
|
|
547
|
-
currentMode.key
|
|
548
|
-
) }),
|
|
549
|
-
!iconOnly && currentMode.label
|
|
550
|
-
]
|
|
551
|
-
}
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
const buttons = modes.map(({ key, label, icon }) => {
|
|
555
|
-
const active = isActive(key);
|
|
556
|
-
return /* @__PURE__ */ jsx(
|
|
557
|
-
Button,
|
|
558
|
-
{
|
|
559
|
-
size,
|
|
560
|
-
variant: active ? activeVariant : variant,
|
|
561
|
-
color: active ? activeColor : color,
|
|
562
|
-
onClick: () => setMode(key),
|
|
563
|
-
className: cn(buttonRadius, buttonProps.className),
|
|
564
|
-
leftIcon: icon,
|
|
565
|
-
"aria-pressed": active,
|
|
566
|
-
...buttonProps,
|
|
567
|
-
children: !iconOnly && label
|
|
568
|
-
},
|
|
569
|
-
key
|
|
570
|
-
);
|
|
571
|
-
});
|
|
572
|
-
if (unstyled) {
|
|
573
|
-
return /* @__PURE__ */ jsx(
|
|
574
|
-
"div",
|
|
575
|
-
{
|
|
576
|
-
role: "group",
|
|
577
|
-
"aria-label": "Theme selector",
|
|
578
|
-
className: cn(
|
|
579
|
-
"inline-flex gap-1",
|
|
580
|
-
orientation === "vertical" && "flex-col",
|
|
581
|
-
className
|
|
582
|
-
),
|
|
583
|
-
children: buttons
|
|
830
|
+
iconOnly,
|
|
831
|
+
buttonProps,
|
|
832
|
+
animated,
|
|
833
|
+
transition,
|
|
834
|
+
rounded: effectiveRounded,
|
|
835
|
+
currentMode,
|
|
836
|
+
onCycle: handleCycle
|
|
584
837
|
}
|
|
585
838
|
);
|
|
586
839
|
}
|
|
587
|
-
return /* @__PURE__ */ jsx(
|
|
840
|
+
return /* @__PURE__ */ jsx(
|
|
841
|
+
ButtonsMode,
|
|
842
|
+
{
|
|
843
|
+
size: resolvedSize,
|
|
844
|
+
color,
|
|
845
|
+
iconOnly,
|
|
846
|
+
buttonProps,
|
|
847
|
+
rounded,
|
|
848
|
+
unstyled,
|
|
849
|
+
className,
|
|
850
|
+
modes,
|
|
851
|
+
activeMode,
|
|
852
|
+
onSelect: setMode,
|
|
853
|
+
containerStyle,
|
|
854
|
+
isActive,
|
|
855
|
+
orientation,
|
|
856
|
+
indicatorClasses,
|
|
857
|
+
indicatorRadius,
|
|
858
|
+
buttonWidth,
|
|
859
|
+
indicatorTransition
|
|
860
|
+
}
|
|
861
|
+
);
|
|
588
862
|
}
|
|
589
863
|
__name(ThemeToggler, "ThemeToggler");
|
|
864
|
+
|
|
865
|
+
// src/hooks/index.ts
|
|
866
|
+
var hooks_exports = {};
|
|
867
|
+
__export(hooks_exports, {
|
|
868
|
+
useClearableField: () => useClearableField,
|
|
869
|
+
useFloatingSide: () => useFloatingSide,
|
|
870
|
+
useKeyboardShortcuts: () => useKeyboardShortcuts,
|
|
871
|
+
useStatusTransition: () => useStatusTransition
|
|
872
|
+
});
|
|
873
|
+
var VIEWPORT_PADDING = 8;
|
|
874
|
+
function useFloatingSide(triggerRef, open) {
|
|
875
|
+
const contentRef = useRef(null);
|
|
876
|
+
const [side, setSide] = useState("bottom");
|
|
877
|
+
useLayoutEffect(() => {
|
|
878
|
+
if (!open) return;
|
|
879
|
+
const trigger = triggerRef.current;
|
|
880
|
+
const content = contentRef.current;
|
|
881
|
+
if (!trigger || !content) return;
|
|
882
|
+
function measure() {
|
|
883
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
884
|
+
const contentHeight = content.offsetHeight;
|
|
885
|
+
const spaceBelow = window.innerHeight - triggerRect.bottom - VIEWPORT_PADDING;
|
|
886
|
+
const spaceAbove = triggerRect.top - VIEWPORT_PADDING;
|
|
887
|
+
setSide(contentHeight > spaceBelow && spaceAbove > spaceBelow ? "top" : "bottom");
|
|
888
|
+
}
|
|
889
|
+
__name(measure, "measure");
|
|
890
|
+
measure();
|
|
891
|
+
window.addEventListener("resize", measure);
|
|
892
|
+
window.addEventListener("scroll", measure, true);
|
|
893
|
+
return () => {
|
|
894
|
+
window.removeEventListener("resize", measure);
|
|
895
|
+
window.removeEventListener("scroll", measure, true);
|
|
896
|
+
};
|
|
897
|
+
}, [open, triggerRef]);
|
|
898
|
+
return { contentRef, side };
|
|
899
|
+
}
|
|
900
|
+
__name(useFloatingSide, "useFloatingSide");
|
|
901
|
+
var TRANSITION_DURATION = 1500;
|
|
902
|
+
function useStatusTransition(status) {
|
|
903
|
+
const previousStatus = useRef(status);
|
|
904
|
+
const [transitionStatus, setTransitionStatus] = useState();
|
|
905
|
+
useEffect(() => {
|
|
906
|
+
if (status === previousStatus.current) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
previousStatus.current = status;
|
|
910
|
+
if (status === "none") {
|
|
911
|
+
setTransitionStatus(void 0);
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
setTransitionStatus(status);
|
|
915
|
+
const timeout = window.setTimeout(() => {
|
|
916
|
+
setTransitionStatus(void 0);
|
|
917
|
+
}, TRANSITION_DURATION);
|
|
918
|
+
return () => window.clearTimeout(timeout);
|
|
919
|
+
}, [status]);
|
|
920
|
+
return transitionStatus;
|
|
921
|
+
}
|
|
922
|
+
__name(useStatusTransition, "useStatusTransition");
|
|
923
|
+
function useClearableField(elementRef, initialValue, { onClear, onUndo, onRedo } = {}) {
|
|
924
|
+
const initial = String(initialValue ?? "");
|
|
925
|
+
const [hasValue, setHasValue] = useState(Boolean(initial));
|
|
926
|
+
const [history, setHistory] = useState(
|
|
927
|
+
() => initial ? [initial] : []
|
|
928
|
+
);
|
|
929
|
+
const [historyIndex, setHistoryIndex] = useState(initial ? 0 : -1);
|
|
930
|
+
const setElementValue = useCallback(
|
|
931
|
+
(value) => {
|
|
932
|
+
const element = elementRef.current;
|
|
933
|
+
if (!element) return;
|
|
934
|
+
const prototype = element instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
935
|
+
const setter = Object.getOwnPropertyDescriptor(prototype, "value")?.set;
|
|
936
|
+
setter?.call(element, value);
|
|
937
|
+
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
938
|
+
setHasValue(Boolean(value));
|
|
939
|
+
},
|
|
940
|
+
[elementRef]
|
|
941
|
+
);
|
|
942
|
+
const clear = useCallback(() => {
|
|
943
|
+
const element = elementRef.current;
|
|
944
|
+
if (!element) return;
|
|
945
|
+
const currentValue = element.value;
|
|
946
|
+
if (!currentValue) return;
|
|
947
|
+
setHistory((current) => {
|
|
948
|
+
const next = current.slice(0, historyIndex + 1);
|
|
949
|
+
next.push(currentValue);
|
|
950
|
+
return next;
|
|
951
|
+
});
|
|
952
|
+
setHistoryIndex((index) => index + 1);
|
|
953
|
+
setElementValue("");
|
|
954
|
+
element.focus();
|
|
955
|
+
onClear?.();
|
|
956
|
+
}, [elementRef, historyIndex, onClear, setElementValue]);
|
|
957
|
+
const undo = useCallback(() => {
|
|
958
|
+
if (historyIndex < 0) return;
|
|
959
|
+
const previousValue = history[historyIndex];
|
|
960
|
+
setElementValue(previousValue ?? "");
|
|
961
|
+
setHistoryIndex((index) => index - 1);
|
|
962
|
+
onUndo?.(previousValue ?? "");
|
|
963
|
+
}, [history, historyIndex, onUndo, setElementValue]);
|
|
964
|
+
const redo = useCallback(() => {
|
|
965
|
+
const nextIndex = historyIndex + 1;
|
|
966
|
+
if (nextIndex >= history.length) return;
|
|
967
|
+
const nextValue = history[nextIndex];
|
|
968
|
+
setElementValue(nextValue);
|
|
969
|
+
setHistoryIndex(nextIndex);
|
|
970
|
+
onRedo?.(nextValue);
|
|
971
|
+
}, [history, historyIndex, onRedo, setElementValue]);
|
|
972
|
+
return {
|
|
973
|
+
hasValue,
|
|
974
|
+
setHasValue,
|
|
975
|
+
clear,
|
|
976
|
+
undo,
|
|
977
|
+
redo,
|
|
978
|
+
canUndo: historyIndex >= 0,
|
|
979
|
+
canRedo: historyIndex < history.length - 1
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
__name(useClearableField, "useClearableField");
|
|
983
|
+
|
|
984
|
+
// src/hooks/index.ts
|
|
985
|
+
__reExport(hooks_exports, hooks_star);
|
|
986
|
+
function useKeyboardShortcuts(enabled, shortcuts, deps = []) {
|
|
987
|
+
const ref = useRef(null);
|
|
988
|
+
useEffect(() => {
|
|
989
|
+
if (!enabled) return;
|
|
990
|
+
const handleKeyDown = /* @__PURE__ */ __name((e) => {
|
|
991
|
+
const isCtrlOrMeta = e.ctrlKey || e.metaKey;
|
|
992
|
+
const key = e.key.toLowerCase();
|
|
993
|
+
let keyStr = "";
|
|
994
|
+
if (isCtrlOrMeta) keyStr += "ctrl+";
|
|
995
|
+
if (e.shiftKey) keyStr += "shift+";
|
|
996
|
+
keyStr += key;
|
|
997
|
+
const handler = shortcuts[keyStr];
|
|
998
|
+
if (handler) {
|
|
999
|
+
e.preventDefault();
|
|
1000
|
+
handler(e);
|
|
1001
|
+
}
|
|
1002
|
+
}, "handleKeyDown");
|
|
1003
|
+
const input = ref.current;
|
|
1004
|
+
if (input) {
|
|
1005
|
+
input.addEventListener("keydown", handleKeyDown);
|
|
1006
|
+
return () => input.removeEventListener("keydown", handleKeyDown);
|
|
1007
|
+
}
|
|
1008
|
+
}, [enabled, ...deps]);
|
|
1009
|
+
return ref;
|
|
1010
|
+
}
|
|
1011
|
+
__name(useKeyboardShortcuts, "useKeyboardShortcuts");
|
|
590
1012
|
var inputKindIcons = {
|
|
591
1013
|
email: Mail,
|
|
592
1014
|
tel: Phone,
|
|
@@ -608,7 +1030,7 @@ function Spinner({ size = 14 }) {
|
|
|
608
1030
|
}
|
|
609
1031
|
__name(Spinner, "Spinner");
|
|
610
1032
|
|
|
611
|
-
// src/components/Input/Input.constants.ts
|
|
1033
|
+
// src/components/forms/Input/Input.constants.ts
|
|
612
1034
|
var inputKindDefaults = {
|
|
613
1035
|
text: { placeholder: "Type something..." },
|
|
614
1036
|
email: {
|
|
@@ -722,6 +1144,7 @@ var Input = forwardRef(
|
|
|
722
1144
|
error,
|
|
723
1145
|
success,
|
|
724
1146
|
warning,
|
|
1147
|
+
scrollIntoViewOnError,
|
|
725
1148
|
startIcon,
|
|
726
1149
|
endIcon,
|
|
727
1150
|
fullWidth = true,
|
|
@@ -730,6 +1153,8 @@ var Input = forwardRef(
|
|
|
730
1153
|
isLoading = false,
|
|
731
1154
|
clearable = false,
|
|
732
1155
|
onClear,
|
|
1156
|
+
onUndo,
|
|
1157
|
+
onRedo,
|
|
733
1158
|
kind = "text",
|
|
734
1159
|
hideKindIcon = false,
|
|
735
1160
|
id: externalId,
|
|
@@ -744,25 +1169,39 @@ var Input = forwardRef(
|
|
|
744
1169
|
value,
|
|
745
1170
|
defaultValue,
|
|
746
1171
|
style,
|
|
1172
|
+
typography: typographyName = "body",
|
|
747
1173
|
...props
|
|
748
1174
|
}, ref) => {
|
|
749
1175
|
const autoId = useId();
|
|
750
1176
|
const internalRef = useRef(null);
|
|
1177
|
+
const { hasValue, setHasValue, clear, undo, redo, canUndo, canRedo } = useClearableField(internalRef, value ?? defaultValue, {
|
|
1178
|
+
onClear,
|
|
1179
|
+
onRedo,
|
|
1180
|
+
onUndo
|
|
1181
|
+
});
|
|
1182
|
+
const shortcutRef = useKeyboardShortcuts(
|
|
1183
|
+
clearable,
|
|
1184
|
+
{
|
|
1185
|
+
"ctrl+z": undo,
|
|
1186
|
+
"ctrl+shift+z": redo
|
|
1187
|
+
},
|
|
1188
|
+
[clearable, canUndo, canRedo, undo, redo]
|
|
1189
|
+
);
|
|
751
1190
|
const { theme } = useTheme();
|
|
752
1191
|
const field = useOptionalFormField();
|
|
1192
|
+
const group = useOptionalButtonGroupContext();
|
|
1193
|
+
const groupItem = useOptionalButtonGroupItemContext();
|
|
1194
|
+
const typography = useTypography(typographyName);
|
|
753
1195
|
const id = externalId ?? field?.id ?? autoId;
|
|
754
1196
|
const isRequired = field?.required ?? props.required;
|
|
1197
|
+
const isInButtonGroup = !!group;
|
|
1198
|
+
const isGroupItem = groupItem?.embedded;
|
|
755
1199
|
const describedBy = field?.describedBy;
|
|
756
1200
|
const state = error ? "error" : success ? "success" : warning ? "warning" : field?.status ?? "none";
|
|
757
1201
|
const isInvalid = state === "error";
|
|
758
1202
|
const statusTransition = useStatusTransition(state);
|
|
759
1203
|
const { style: sizeStyle, iconSize } = useSizeStyle(size, false, "input");
|
|
760
1204
|
const [visible, setVisible] = useState(false);
|
|
761
|
-
const { hasValue, setHasValue, clear } = useClearableField(
|
|
762
|
-
internalRef,
|
|
763
|
-
value ?? defaultValue,
|
|
764
|
-
onClear
|
|
765
|
-
);
|
|
766
1205
|
useEffect(() => {
|
|
767
1206
|
if (value !== void 0) {
|
|
768
1207
|
setHasValue(Boolean(value));
|
|
@@ -774,21 +1213,7 @@ var Input = forwardRef(
|
|
|
774
1213
|
const effectiveType = isPasswordField ? visible ? "text" : "password" : resolvedType;
|
|
775
1214
|
const KindIcon = inputKindIcons[kind];
|
|
776
1215
|
const defaultStartIcon = !hideKindIcon && KindIcon ? /* @__PURE__ */ jsx(KindIcon, {}) : void 0;
|
|
777
|
-
const startAdornment =
|
|
778
|
-
const icon = startIcon ?? defaultStartIcon;
|
|
779
|
-
if (!icon) return null;
|
|
780
|
-
return /* @__PURE__ */ jsx(
|
|
781
|
-
"span",
|
|
782
|
-
{
|
|
783
|
-
className: "flex shrink-0 items-center justify-center",
|
|
784
|
-
style: {
|
|
785
|
-
width: iconSize,
|
|
786
|
-
height: iconSize
|
|
787
|
-
},
|
|
788
|
-
children: icon
|
|
789
|
-
}
|
|
790
|
-
);
|
|
791
|
-
}, [startIcon, defaultStartIcon, iconSize]);
|
|
1216
|
+
const startAdornment = startIcon ?? defaultStartIcon;
|
|
792
1217
|
const builtInEnd = [];
|
|
793
1218
|
if (isPasswordField) {
|
|
794
1219
|
builtInEnd.push(
|
|
@@ -799,7 +1224,7 @@ var Input = forwardRef(
|
|
|
799
1224
|
onClick: () => setVisible((current) => !current),
|
|
800
1225
|
"aria-label": visible ? "Hide password" : "Show password",
|
|
801
1226
|
"aria-pressed": visible,
|
|
802
|
-
className: "\
|
|
1227
|
+
className: "\n flex items-center justify-center\n text-kui-text-muted\n transition-colors\n hover:text-kui-text\n focus-visible:outline\n focus-visible:outline-2\n focus-visible:outline-offset-2\n ",
|
|
803
1228
|
children: visible ? /* @__PURE__ */ jsx(
|
|
804
1229
|
EyeOff,
|
|
805
1230
|
{
|
|
@@ -830,7 +1255,7 @@ var Input = forwardRef(
|
|
|
830
1255
|
type: "button",
|
|
831
1256
|
onClick: clear,
|
|
832
1257
|
"aria-label": "Clear input",
|
|
833
|
-
className: "\
|
|
1258
|
+
className: "\n flex items-center justify-center\n text-kui-text-muted\n transition-colors\n hover:text-kui-text\n focus-visible:outline\n focus-visible:outline-2\n focus-visible:outline-offset-2\n ",
|
|
834
1259
|
children: /* @__PURE__ */ jsx(
|
|
835
1260
|
X,
|
|
836
1261
|
{
|
|
@@ -845,15 +1270,16 @@ var Input = forwardRef(
|
|
|
845
1270
|
)
|
|
846
1271
|
);
|
|
847
1272
|
}
|
|
848
|
-
const endAdornment = isLoading ? /* @__PURE__ */ jsx(Spinner, { size: iconSize || 14 }) : endIcon || builtInEnd.length > 0 ? /* @__PURE__ */ jsxs(
|
|
1273
|
+
const endAdornment = isLoading ? /* @__PURE__ */ jsx(Adornment, { position: "end", children: /* @__PURE__ */ jsx(Spinner, { size: iconSize || 14 }) }) : endIcon || builtInEnd.length > 0 ? /* @__PURE__ */ jsxs(Adornment, { position: "end", children: [
|
|
849
1274
|
endIcon && /* @__PURE__ */ jsx(
|
|
850
1275
|
"span",
|
|
851
1276
|
{
|
|
852
|
-
className: "flex items-center justify-center",
|
|
1277
|
+
className: "flex shrink-0 items-center justify-center",
|
|
853
1278
|
style: {
|
|
854
1279
|
width: iconSize,
|
|
855
1280
|
height: iconSize
|
|
856
1281
|
},
|
|
1282
|
+
"aria-hidden": "true",
|
|
857
1283
|
children: endIcon
|
|
858
1284
|
}
|
|
859
1285
|
),
|
|
@@ -867,7 +1293,9 @@ var Input = forwardRef(
|
|
|
867
1293
|
rounded,
|
|
868
1294
|
fullWidth,
|
|
869
1295
|
disabled: disabled || isLoading,
|
|
870
|
-
hasAdornment
|
|
1296
|
+
hasAdornment,
|
|
1297
|
+
attached: group?.attached
|
|
1298
|
+
// groupItem: !!groupItem,
|
|
871
1299
|
}),
|
|
872
1300
|
className
|
|
873
1301
|
);
|
|
@@ -878,9 +1306,16 @@ var Input = forwardRef(
|
|
|
878
1306
|
inputClassName
|
|
879
1307
|
);
|
|
880
1308
|
const resolvedStyle = {
|
|
1309
|
+
...typography,
|
|
881
1310
|
...sizeStyle,
|
|
882
1311
|
...style
|
|
883
1312
|
};
|
|
1313
|
+
const groupDataAttributes = {
|
|
1314
|
+
"data-kui-button-group-item": isInButtonGroup && isGroupItem ? true : void 0,
|
|
1315
|
+
"data-kui-button-group-item-embedded": isGroupItem || void 0,
|
|
1316
|
+
"data-kui-group-attached": group?.attached || void 0,
|
|
1317
|
+
"data-kui-group-orientation": group?.orientation || void 0
|
|
1318
|
+
};
|
|
884
1319
|
function handleChange(event) {
|
|
885
1320
|
setHasValue(Boolean(event.target.value));
|
|
886
1321
|
onChangeProp?.(event);
|
|
@@ -903,14 +1338,14 @@ var Input = forwardRef(
|
|
|
903
1338
|
useEffect(() => {
|
|
904
1339
|
const justBecameInvalid = isInvalid && !wasInvalidRef.current;
|
|
905
1340
|
wasInvalidRef.current = isInvalid;
|
|
906
|
-
if (!justBecameInvalid) {
|
|
1341
|
+
if (!justBecameInvalid || !scrollIntoViewOnError) {
|
|
907
1342
|
return;
|
|
908
1343
|
}
|
|
909
1344
|
internalRef.current?.scrollIntoView({
|
|
910
1345
|
behavior: "smooth",
|
|
911
1346
|
block: "center"
|
|
912
1347
|
});
|
|
913
|
-
}, [isInvalid]);
|
|
1348
|
+
}, [isInvalid, scrollIntoViewOnError]);
|
|
914
1349
|
return /* @__PURE__ */ jsxs(
|
|
915
1350
|
"div",
|
|
916
1351
|
{
|
|
@@ -918,13 +1353,24 @@ var Input = forwardRef(
|
|
|
918
1353
|
style: resolvedStyle,
|
|
919
1354
|
"data-state": state,
|
|
920
1355
|
"data-state-transition": statusTransition,
|
|
1356
|
+
...groupDataAttributes,
|
|
921
1357
|
children: [
|
|
922
|
-
startAdornment,
|
|
1358
|
+
startAdornment && /* @__PURE__ */ jsx(Adornment, { position: "start", children: /* @__PURE__ */ jsx(
|
|
1359
|
+
"span",
|
|
1360
|
+
{
|
|
1361
|
+
className: "flex shrink-0 items-center justify-center",
|
|
1362
|
+
style: {
|
|
1363
|
+
width: iconSize,
|
|
1364
|
+
height: iconSize
|
|
1365
|
+
},
|
|
1366
|
+
children: startAdornment
|
|
1367
|
+
}
|
|
1368
|
+
) }),
|
|
923
1369
|
/* @__PURE__ */ jsx(
|
|
924
1370
|
"input",
|
|
925
1371
|
{
|
|
926
1372
|
...props,
|
|
927
|
-
ref: mergeRefs(internalRef, ref),
|
|
1373
|
+
ref: mergeRefs(internalRef, ref, shortcutRef),
|
|
928
1374
|
id,
|
|
929
1375
|
type: effectiveType,
|
|
930
1376
|
inputMode: inputModeProp ?? kindDefaults.inputMode,
|
|
@@ -1078,10 +1524,10 @@ function FormFieldLabel({
|
|
|
1078
1524
|
{
|
|
1079
1525
|
id: field.labelId,
|
|
1080
1526
|
htmlFor: field.id,
|
|
1081
|
-
className: cn("font-medium text-text text-sm", className),
|
|
1527
|
+
className: cn("font-medium text-kui-text text-sm", className),
|
|
1082
1528
|
children: [
|
|
1083
1529
|
children,
|
|
1084
|
-
field.required && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "ml-1 text-destructive", children: "*" })
|
|
1530
|
+
field.required && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "ml-1 text-kui-destructive", children: "*" })
|
|
1085
1531
|
]
|
|
1086
1532
|
}
|
|
1087
1533
|
);
|
|
@@ -1090,23 +1536,14 @@ __name(FormFieldLabel, "FormFieldLabel");
|
|
|
1090
1536
|
function FormFieldDescription({
|
|
1091
1537
|
children
|
|
1092
1538
|
}) {
|
|
1093
|
-
const {
|
|
1094
|
-
|
|
1095
|
-
} = useFormField();
|
|
1096
|
-
return /* @__PURE__ */ jsx(
|
|
1097
|
-
"p",
|
|
1098
|
-
{
|
|
1099
|
-
id: descriptionId,
|
|
1100
|
-
className: "text-sm text-text-muted",
|
|
1101
|
-
children
|
|
1102
|
-
}
|
|
1103
|
-
);
|
|
1539
|
+
const { descriptionId } = useFormField();
|
|
1540
|
+
return /* @__PURE__ */ jsx("p", { id: descriptionId, className: "text-sm text-kui-text-muted", children });
|
|
1104
1541
|
}
|
|
1105
1542
|
__name(FormFieldDescription, "FormFieldDescription");
|
|
1106
1543
|
var statusClasses = {
|
|
1107
|
-
error: "text-destructive animate-kui-shake [animation-delay:500ms]",
|
|
1108
|
-
success: "text-success",
|
|
1109
|
-
warning: "text-warning"
|
|
1544
|
+
error: "text-kui-destructive animate-kui-shake [animation-delay:500ms]",
|
|
1545
|
+
success: "text-kui-success",
|
|
1546
|
+
warning: "text-kui-warning"
|
|
1110
1547
|
};
|
|
1111
1548
|
function FormFieldMessage({ children }) {
|
|
1112
1549
|
const { messageId, message, status, invalid } = useFormField();
|
|
@@ -1265,7 +1702,7 @@ var SelectTrigger = forwardRef(
|
|
|
1265
1702
|
"span",
|
|
1266
1703
|
{
|
|
1267
1704
|
"aria-hidden": true,
|
|
1268
|
-
className: "pointer-events-none absolute right-0 top-1/2 flex -translate-y-1/2 items-center gap-1.5 text-text-muted",
|
|
1705
|
+
className: "pointer-events-none absolute right-0 top-1/2 flex -translate-y-1/2 items-center gap-1.5 text-kui-text-muted",
|
|
1269
1706
|
children: /* @__PURE__ */ jsx(
|
|
1270
1707
|
ChevronDown,
|
|
1271
1708
|
{
|
|
@@ -1296,7 +1733,7 @@ var SelectTrigger = forwardRef(
|
|
|
1296
1733
|
e.preventDefault();
|
|
1297
1734
|
e.stopPropagation();
|
|
1298
1735
|
},
|
|
1299
|
-
className: "flex h-4 w-4 items-center justify-center text-text-muted transition-colors hover:text-text",
|
|
1736
|
+
className: "flex h-4 w-4 items-center justify-center text-kui-text-muted transition-colors hover:text-kui-text",
|
|
1300
1737
|
children: /* @__PURE__ */ jsx(X, { size: Number(iconSize) || 14 })
|
|
1301
1738
|
}
|
|
1302
1739
|
)
|
|
@@ -1336,7 +1773,6 @@ function SelectContent({
|
|
|
1336
1773
|
window.removeEventListener("scroll", measure, true);
|
|
1337
1774
|
};
|
|
1338
1775
|
}, [ctx.open, ctx.triggerRef]);
|
|
1339
|
-
if (!ctx.open) return null;
|
|
1340
1776
|
return /* @__PURE__ */ jsx(
|
|
1341
1777
|
"div",
|
|
1342
1778
|
{
|
|
@@ -1347,10 +1783,16 @@ function SelectContent({
|
|
|
1347
1783
|
"data-state": ctx.open ? "open" : "closed",
|
|
1348
1784
|
"data-side": side,
|
|
1349
1785
|
className: cn(
|
|
1350
|
-
"
|
|
1786
|
+
"absolute z-50 max-h-64 w-full overflow-auto rounded-(--kui-radii-md) border border-kui-border bg-kui-surface p-1 shadow-lg kui-scrollbar space-y-0.75",
|
|
1787
|
+
"pointer-events-none opacity-0 scale-95",
|
|
1788
|
+
"data-[state=open]:pointer-events-auto data-[state=open]:opacity-100 data-[state=open]:scale-100",
|
|
1789
|
+
"transition-[opacity,transform] duration-150 ease-out",
|
|
1351
1790
|
side === "bottom" ? "top-full mt-1" : "bottom-full mb-1",
|
|
1352
1791
|
className
|
|
1353
1792
|
),
|
|
1793
|
+
onMouseLeave: () => {
|
|
1794
|
+
ctx.setActiveValue(void 0);
|
|
1795
|
+
},
|
|
1354
1796
|
...props,
|
|
1355
1797
|
children
|
|
1356
1798
|
}
|
|
@@ -1369,10 +1811,17 @@ function SelectItem({
|
|
|
1369
1811
|
const active = ctx.activeValue === value;
|
|
1370
1812
|
const ref = useRef(null);
|
|
1371
1813
|
useLayoutEffect(() => {
|
|
1372
|
-
return ctx.registerItem(value, {
|
|
1814
|
+
return ctx.registerItem(value, {
|
|
1815
|
+
label: children,
|
|
1816
|
+
disabled
|
|
1817
|
+
});
|
|
1373
1818
|
}, [value, disabled, children]);
|
|
1374
1819
|
useEffect(() => {
|
|
1375
|
-
if (active)
|
|
1820
|
+
if (active) {
|
|
1821
|
+
ref.current?.scrollIntoView({
|
|
1822
|
+
block: "nearest"
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1376
1825
|
}, [active]);
|
|
1377
1826
|
return /* @__PURE__ */ jsx(
|
|
1378
1827
|
"div",
|
|
@@ -1385,12 +1834,20 @@ function SelectItem({
|
|
|
1385
1834
|
"data-state": selected ? "selected" : void 0,
|
|
1386
1835
|
"data-active": active || void 0,
|
|
1387
1836
|
"data-disabled": disabled || void 0,
|
|
1388
|
-
onMouseEnter: () =>
|
|
1389
|
-
|
|
1837
|
+
onMouseEnter: () => {
|
|
1838
|
+
if (!disabled) {
|
|
1839
|
+
ctx.setActiveValue(value);
|
|
1840
|
+
}
|
|
1841
|
+
},
|
|
1842
|
+
onClick: () => {
|
|
1843
|
+
if (!disabled) {
|
|
1844
|
+
ctx.onValueChange(value);
|
|
1845
|
+
}
|
|
1846
|
+
},
|
|
1390
1847
|
className: cn(
|
|
1391
|
-
"flex cursor-pointer items-center rounded-[calc(var(--kui-radii-md)-2px)] px-2.5 py-1.5 text-sm text-text transition-colors",
|
|
1392
|
-
|
|
1393
|
-
|
|
1848
|
+
"flex cursor-pointer items-center rounded-[calc(var(--kui-radii-md)-2px)] px-2.5 py-1.5 text-sm text-kui-text transition-colors",
|
|
1849
|
+
selected && "bg-kui-brand/10 text-kui-brand hover:bg-kui-brand/20",
|
|
1850
|
+
active && !selected && "bg-kui-surface-sunken",
|
|
1394
1851
|
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
1395
1852
|
className
|
|
1396
1853
|
),
|
|
@@ -1418,7 +1875,7 @@ function SelectLabel({ children, className }) {
|
|
|
1418
1875
|
useEffect(() => {
|
|
1419
1876
|
group?.setHasLabel(id);
|
|
1420
1877
|
}, [group, id]);
|
|
1421
|
-
return /* @__PURE__ */ jsx("div", { id, className: cn("px-2.5 py-1.5 font-mono text-[11px] text-text-muted", className), children });
|
|
1878
|
+
return /* @__PURE__ */ jsx("div", { id, className: cn("px-2.5 py-1.5 font-mono text-[11px] text-kui-text-muted", className), children });
|
|
1422
1879
|
}
|
|
1423
1880
|
__name(SelectLabel, "SelectLabel");
|
|
1424
1881
|
function Select({
|
|
@@ -1595,19 +2052,6 @@ Select.Item = SelectItem;
|
|
|
1595
2052
|
Select.Value = SelectValue;
|
|
1596
2053
|
Select.Group = SelectGroup;
|
|
1597
2054
|
Select.Label = SelectLabel;
|
|
1598
|
-
function mergeRefs2(...refs) {
|
|
1599
|
-
return (node) => {
|
|
1600
|
-
refs.forEach((ref) => {
|
|
1601
|
-
if (!ref) return;
|
|
1602
|
-
if (typeof ref === "function") {
|
|
1603
|
-
ref(node);
|
|
1604
|
-
} else {
|
|
1605
|
-
ref.current = node;
|
|
1606
|
-
}
|
|
1607
|
-
});
|
|
1608
|
-
};
|
|
1609
|
-
}
|
|
1610
|
-
__name(mergeRefs2, "mergeRefs");
|
|
1611
2055
|
function resolveFieldState({
|
|
1612
2056
|
error,
|
|
1613
2057
|
success,
|
|
@@ -1632,6 +2076,7 @@ var TextareaCore = forwardRef(
|
|
|
1632
2076
|
onBlur: onBlurProp,
|
|
1633
2077
|
className,
|
|
1634
2078
|
style: customStyle,
|
|
2079
|
+
typography: typographyName = "body",
|
|
1635
2080
|
size = "md",
|
|
1636
2081
|
variant = "outline",
|
|
1637
2082
|
resize = "vertical",
|
|
@@ -1663,7 +2108,7 @@ var TextareaCore = forwardRef(
|
|
|
1663
2108
|
const id = field?.id ?? externalId ?? autoId;
|
|
1664
2109
|
const internalRef = useRef(null);
|
|
1665
2110
|
const debounceTimer = useRef(null);
|
|
1666
|
-
const typography = useTypography(
|
|
2111
|
+
const typography = useTypography(typographyName);
|
|
1667
2112
|
const { style: sizeStyle } = useSizeStyle(size, false, "textarea", {
|
|
1668
2113
|
includeHeight: false
|
|
1669
2114
|
});
|
|
@@ -1846,13 +2291,13 @@ var TextareaCore = forwardRef(
|
|
|
1846
2291
|
"pointer-events-none absolute",
|
|
1847
2292
|
"bottom-1.5 right-2.5",
|
|
1848
2293
|
"font-mono text-[11px]",
|
|
1849
|
-
maxLengthExceeded ? "text-destructive" : hasReachedMaxLength ? "text-warning" : nearLimit ? "text-warning" : "text-text-muted"
|
|
2294
|
+
maxLengthExceeded ? "text-kui-destructive" : hasReachedMaxLength ? "text-kui-warning" : nearLimit ? "text-kui-warning" : "text-kui-text-muted"
|
|
1850
2295
|
);
|
|
1851
|
-
return /* @__PURE__ */ jsxs("div", { className: cn(wrapperClassName, "items-start"), children: [
|
|
2296
|
+
return /* @__PURE__ */ jsxs("div", { className: cn(wrapperClassName, "items-start py-2"), children: [
|
|
1852
2297
|
/* @__PURE__ */ jsx(
|
|
1853
2298
|
"textarea",
|
|
1854
2299
|
{
|
|
1855
|
-
ref:
|
|
2300
|
+
ref: mergeRefs(internalRef, ref),
|
|
1856
2301
|
id,
|
|
1857
2302
|
value: draft,
|
|
1858
2303
|
onChange: handleChange,
|
|
@@ -1865,7 +2310,7 @@ var TextareaCore = forwardRef(
|
|
|
1865
2310
|
"aria-required": required,
|
|
1866
2311
|
required,
|
|
1867
2312
|
style: textareaStyle,
|
|
1868
|
-
className: cn(textareaClasses,
|
|
2313
|
+
className: cn(textareaClasses, className),
|
|
1869
2314
|
"data-size": size,
|
|
1870
2315
|
"data-invalid": isInvalid || void 0,
|
|
1871
2316
|
"data-success": isSuccess || void 0,
|
|
@@ -1885,9 +2330,9 @@ var TextareaCore = forwardRef(
|
|
|
1885
2330
|
className: cn(
|
|
1886
2331
|
"absolute right-2 top-2",
|
|
1887
2332
|
"flex items-center justify-center",
|
|
1888
|
-
"text-text-muted",
|
|
2333
|
+
"text-kui-text-muted",
|
|
1889
2334
|
"transition-colors",
|
|
1890
|
-
"hover:text-text"
|
|
2335
|
+
"hover:text-kui-text"
|
|
1891
2336
|
),
|
|
1892
2337
|
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
1893
2338
|
}
|
|
@@ -1901,7 +2346,7 @@ var TextareaCore = forwardRef(
|
|
|
1901
2346
|
{
|
|
1902
2347
|
id: messageId,
|
|
1903
2348
|
role: "alert",
|
|
1904
|
-
className: cn("mt-1.5 px-0.5", "text-xs text-destructive"),
|
|
2349
|
+
className: cn("mt-1.5 px-0.5", "text-xs text-kui-destructive"),
|
|
1905
2350
|
children: internalValidation.message
|
|
1906
2351
|
}
|
|
1907
2352
|
)
|
|
@@ -1910,7 +2355,7 @@ var TextareaCore = forwardRef(
|
|
|
1910
2355
|
);
|
|
1911
2356
|
TextareaCore.displayName = "TextareaCore";
|
|
1912
2357
|
|
|
1913
|
-
// src/components/MarkdownEditor/markdownActions.ts
|
|
2358
|
+
// src/components/forms/MarkdownEditor/markdownActions.ts
|
|
1914
2359
|
function lineBounds(value, index) {
|
|
1915
2360
|
const start = value.lastIndexOf("\n", index - 1) + 1;
|
|
1916
2361
|
const nextBreak = value.indexOf("\n", index);
|
|
@@ -2112,7 +2557,7 @@ var MarkdownEditor = forwardRef(
|
|
|
2112
2557
|
role: "tablist",
|
|
2113
2558
|
"aria-label": "Markdown editor mode",
|
|
2114
2559
|
id: tablistId,
|
|
2115
|
-
className: "flex items-center gap-4 border-b border-border px-3",
|
|
2560
|
+
className: "flex items-center gap-4 border-b border-kui-border px-3",
|
|
2116
2561
|
children: [
|
|
2117
2562
|
["write", "preview"].map((t) => /* @__PURE__ */ jsx(
|
|
2118
2563
|
"button",
|
|
@@ -2127,7 +2572,7 @@ var MarkdownEditor = forwardRef(
|
|
|
2127
2572
|
className: cn(
|
|
2128
2573
|
"border-b-2 py-2.5 text-sm capitalize transition-colors",
|
|
2129
2574
|
"disabled:pointer-events-none disabled:cursor-not-allowed",
|
|
2130
|
-
tab === t ? "border-brand text-text" : "border-transparent text-text-muted hover:text-text"
|
|
2575
|
+
tab === t ? "border-kui-brand text-kui-text" : "border-transparent text-kui-text-muted hover:text-kui-text"
|
|
2131
2576
|
),
|
|
2132
2577
|
children: t
|
|
2133
2578
|
},
|
|
@@ -2140,7 +2585,7 @@ var MarkdownEditor = forwardRef(
|
|
|
2140
2585
|
"aria-label": label,
|
|
2141
2586
|
onClick: () => runAction(action),
|
|
2142
2587
|
disabled,
|
|
2143
|
-
className: "rounded-(--kui-radii-sm) p-1.5 text-text-muted transition-colors hover:bg-surface-raised hover:text-text disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
2588
|
+
className: "rounded-(--kui-radii-sm) p-1.5 text-kui-text-muted transition-colors hover:bg-kui-surface-raised hover:text-kui-text disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
2144
2589
|
children: /* @__PURE__ */ jsx(Icon, { size: 15 })
|
|
2145
2590
|
},
|
|
2146
2591
|
label
|
|
@@ -2184,11 +2629,11 @@ var MarkdownEditor = forwardRef(
|
|
|
2184
2629
|
role: "tabpanel",
|
|
2185
2630
|
"aria-labelledby": `${baseId}-preview-tab`,
|
|
2186
2631
|
hidden: tab !== "preview",
|
|
2187
|
-
className: "min-h-32 p-3 text-sm text-text",
|
|
2188
|
-
children: renderMarkdown ? renderedPreview : /* @__PURE__ */ jsx("span", { className: "text-text-muted", children: "No renderMarkdown provided \u2014 showing raw text." })
|
|
2632
|
+
className: "min-h-32 p-3 text-sm text-kui-text",
|
|
2633
|
+
children: renderMarkdown ? renderedPreview : /* @__PURE__ */ jsx("span", { className: "text-kui-text-muted", children: "No renderMarkdown provided \u2014 showing raw text." })
|
|
2189
2634
|
}
|
|
2190
2635
|
),
|
|
2191
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-t border-border px-3 py-2 text-xs z-1", children: footerMessage })
|
|
2636
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-t border-kui-border px-3 py-2 text-xs z-1", children: footerMessage })
|
|
2192
2637
|
] });
|
|
2193
2638
|
}
|
|
2194
2639
|
);
|
|
@@ -2196,7 +2641,14 @@ MarkdownEditor.displayName = "MarkdownEditor";
|
|
|
2196
2641
|
var Textarea = forwardRef(
|
|
2197
2642
|
({ allowMarkdown, ...props }, ref) => {
|
|
2198
2643
|
if (allowMarkdown) {
|
|
2199
|
-
return /* @__PURE__ */ jsx(
|
|
2644
|
+
return /* @__PURE__ */ jsx(
|
|
2645
|
+
MarkdownEditor,
|
|
2646
|
+
{
|
|
2647
|
+
ref,
|
|
2648
|
+
...props,
|
|
2649
|
+
embedded: true
|
|
2650
|
+
}
|
|
2651
|
+
);
|
|
2200
2652
|
}
|
|
2201
2653
|
return /* @__PURE__ */ jsx(TextareaCore, { ref, ...props });
|
|
2202
2654
|
}
|
|
@@ -2338,12 +2790,12 @@ var Checkbox = forwardRef(
|
|
|
2338
2790
|
!disabled && "cursor-pointer"
|
|
2339
2791
|
),
|
|
2340
2792
|
children: [
|
|
2341
|
-
label && /* @__PURE__ */ jsx("span", { className: "text-text", style: { fontSize }, children: label }),
|
|
2793
|
+
label && /* @__PURE__ */ jsx("span", { className: "text-kui-text", style: { fontSize }, children: label }),
|
|
2342
2794
|
description && /* @__PURE__ */ jsx(
|
|
2343
2795
|
"span",
|
|
2344
2796
|
{
|
|
2345
2797
|
id: descriptionId,
|
|
2346
|
-
className: "text-text-muted",
|
|
2798
|
+
className: "text-kui-text-muted",
|
|
2347
2799
|
style: {
|
|
2348
2800
|
fontSize: fontSize ? `calc(${fontSize} - 1px)` : void 0
|
|
2349
2801
|
},
|
|
@@ -2401,7 +2853,15 @@ function RadioGroup({
|
|
|
2401
2853
|
return /* @__PURE__ */ jsx(
|
|
2402
2854
|
RadioGroupContext.Provider,
|
|
2403
2855
|
{
|
|
2404
|
-
value: {
|
|
2856
|
+
value: {
|
|
2857
|
+
name,
|
|
2858
|
+
value,
|
|
2859
|
+
onValueChange: handleValueChange,
|
|
2860
|
+
disabled,
|
|
2861
|
+
size,
|
|
2862
|
+
state,
|
|
2863
|
+
groupRequired
|
|
2864
|
+
},
|
|
2405
2865
|
children: /* @__PURE__ */ jsx(
|
|
2406
2866
|
"div",
|
|
2407
2867
|
{
|
|
@@ -2433,12 +2893,12 @@ var radioBubbleVariants = cva(
|
|
|
2433
2893
|
},
|
|
2434
2894
|
state: {
|
|
2435
2895
|
none: "",
|
|
2436
|
-
error: "border-destructive",
|
|
2437
|
-
success: "border-success"
|
|
2896
|
+
error: "border-kui-destructive",
|
|
2897
|
+
success: "border-kui-success"
|
|
2438
2898
|
},
|
|
2439
2899
|
checked: {
|
|
2440
|
-
true: "border-brand",
|
|
2441
|
-
false: "border-border bg-transparent"
|
|
2900
|
+
true: "border-kui-brand",
|
|
2901
|
+
false: "border-kui-border bg-transparent"
|
|
2442
2902
|
},
|
|
2443
2903
|
disabled: {
|
|
2444
2904
|
true: "cursor-not-allowed",
|
|
@@ -2447,138 +2907,49 @@ var radioBubbleVariants = cva(
|
|
|
2447
2907
|
},
|
|
2448
2908
|
defaultVariants: {
|
|
2449
2909
|
size: "md",
|
|
2450
|
-
state: "none",
|
|
2451
|
-
checked: false,
|
|
2452
|
-
disabled: false
|
|
2453
|
-
},
|
|
2454
|
-
compoundVariants: [
|
|
2455
|
-
{ checked: false, state: "error", class: "border-destructive" },
|
|
2456
|
-
{ checked: false, state: "success", class: "border-success" }
|
|
2457
|
-
]
|
|
2458
|
-
}
|
|
2459
|
-
);
|
|
2460
|
-
var radioDotSizes = {
|
|
2461
|
-
sm: "h-1.5 w-1.5",
|
|
2462
|
-
md: "h-2 w-2",
|
|
2463
|
-
lg: "h-2.5 w-2.5"
|
|
2464
|
-
};
|
|
2465
|
-
function Radio({
|
|
2466
|
-
value,
|
|
2467
|
-
disabled: itemDisabled,
|
|
2468
|
-
label,
|
|
2469
|
-
description,
|
|
2470
|
-
className,
|
|
2471
|
-
...props
|
|
2472
|
-
}) {
|
|
2473
|
-
const group = useRadioGroupContext();
|
|
2474
|
-
const id = `${group.name}-${value}`;
|
|
2475
|
-
const checked = group.value === value;
|
|
2476
|
-
const disabled = itemDisabled || group.disabled;
|
|
2477
|
-
const descriptionId = description ? `${id}-description` : void 0;
|
|
2478
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("flex gap-2.5", disabled && "cursor-not-allowed opacity-50", className), children: [
|
|
2479
|
-
/* @__PURE__ */ jsxs("div", { className: "relative mt-0.5 inline-flex", children: [
|
|
2480
|
-
/* @__PURE__ */ jsx(
|
|
2481
|
-
"input",
|
|
2482
|
-
{
|
|
2483
|
-
type: "radio",
|
|
2484
|
-
id,
|
|
2485
|
-
name: group.name,
|
|
2486
|
-
value,
|
|
2487
|
-
checked,
|
|
2488
|
-
disabled,
|
|
2489
|
-
onChange: () => group.onValueChange(value),
|
|
2490
|
-
"aria-describedby": descriptionId,
|
|
2491
|
-
className: "peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
|
|
2492
|
-
"data-invalid": group.state === "error" || void 0,
|
|
2493
|
-
...props
|
|
2494
|
-
}
|
|
2495
|
-
),
|
|
2496
|
-
/* @__PURE__ */ jsx(
|
|
2497
|
-
"div",
|
|
2498
|
-
{
|
|
2499
|
-
"aria-hidden": "true",
|
|
2500
|
-
className: cn(
|
|
2501
|
-
radioBubbleVariants({ size: group.size, state: group.state, checked, disabled }),
|
|
2502
|
-
"peer-focus-visible:ring-2 peer-focus-visible:ring-brand peer-focus-visible:ring-offset-1"
|
|
2503
|
-
),
|
|
2504
|
-
children: checked && /* @__PURE__ */ jsx("div", { className: cn("rounded-full bg-brand", radioDotSizes[group.size]) })
|
|
2505
|
-
}
|
|
2506
|
-
)
|
|
2507
|
-
] }),
|
|
2508
|
-
(label || description) && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
2509
|
-
label && /* @__PURE__ */ jsx("label", { htmlFor: id, className: cn("text-sm text-text", !disabled && "cursor-pointer", group.size === "sm" && "text-xs"), children: label }),
|
|
2510
|
-
description && /* @__PURE__ */ jsx("p", { id: descriptionId, className: cn("text-xs text-text-muted", group.size === "sm" && "text-[10px]"), children: description })
|
|
2511
|
-
] })
|
|
2512
|
-
] });
|
|
2513
|
-
}
|
|
2514
|
-
__name(Radio, "Radio");
|
|
2515
|
-
var switchTrackVariants = cva(
|
|
2516
|
-
"relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-colors duration-[var(--kui-duration-fast)]",
|
|
2517
|
-
{
|
|
2518
|
-
variants: {
|
|
2519
|
-
size: {
|
|
2520
|
-
sm: "h-4 w-7",
|
|
2521
|
-
md: "h-5 w-9",
|
|
2522
|
-
lg: "h-6 w-11"
|
|
2523
|
-
},
|
|
2524
|
-
checked: {
|
|
2525
|
-
true: "bg-brand",
|
|
2526
|
-
false: "bg-surface-raised"
|
|
2527
|
-
},
|
|
2528
|
-
disabled: {
|
|
2529
|
-
true: "cursor-not-allowed",
|
|
2530
|
-
false: "cursor-pointer"
|
|
2531
|
-
}
|
|
2910
|
+
state: "none",
|
|
2911
|
+
checked: false,
|
|
2912
|
+
disabled: false
|
|
2532
2913
|
},
|
|
2533
|
-
|
|
2914
|
+
compoundVariants: [
|
|
2915
|
+
{ checked: false, state: "error", class: "border-kui-destructive" },
|
|
2916
|
+
{ checked: false, state: "success", class: "border-kui-success" }
|
|
2917
|
+
]
|
|
2534
2918
|
}
|
|
2535
2919
|
);
|
|
2536
|
-
var
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
lg: { thumb: "h-5 w-5", translate: "translate-x-5" }
|
|
2920
|
+
var radioDotSizes = {
|
|
2921
|
+
sm: "h-1.5 w-1.5",
|
|
2922
|
+
md: "h-2 w-2",
|
|
2923
|
+
lg: "h-2.5 w-2.5"
|
|
2541
2924
|
};
|
|
2542
|
-
function
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
onCheckedChange,
|
|
2546
|
-
size = "md",
|
|
2547
|
-
disabled,
|
|
2925
|
+
function Radio({
|
|
2926
|
+
value,
|
|
2927
|
+
disabled: itemDisabled,
|
|
2548
2928
|
label,
|
|
2549
2929
|
description,
|
|
2550
2930
|
className,
|
|
2551
|
-
id: externalId,
|
|
2552
|
-
onChange: onChangeProp,
|
|
2553
2931
|
...props
|
|
2554
2932
|
}) {
|
|
2555
|
-
const
|
|
2556
|
-
const
|
|
2557
|
-
const
|
|
2558
|
-
const
|
|
2559
|
-
const checked = checkedProp !== void 0 ? checkedProp : internalChecked;
|
|
2560
|
-
function handleChange(e) {
|
|
2561
|
-
const next = e.target.checked;
|
|
2562
|
-
if (checkedProp === void 0) setInternalChecked(next);
|
|
2563
|
-
onCheckedChange?.(next);
|
|
2564
|
-
onChangeProp?.(e);
|
|
2565
|
-
}
|
|
2566
|
-
__name(handleChange, "handleChange");
|
|
2933
|
+
const group = useRadioGroupContext();
|
|
2934
|
+
const id = `${group.name}-${value}`;
|
|
2935
|
+
const checked = group.value === value;
|
|
2936
|
+
const disabled = itemDisabled || group.disabled;
|
|
2567
2937
|
const descriptionId = description ? `${id}-description` : void 0;
|
|
2568
|
-
const { thumb, translate } = switchThumbConfig[size];
|
|
2569
2938
|
return /* @__PURE__ */ jsxs("div", { className: cn("flex gap-2.5", disabled && "cursor-not-allowed opacity-50", className), children: [
|
|
2570
|
-
/* @__PURE__ */ jsxs("div", { className: "relative inline-flex", children: [
|
|
2939
|
+
/* @__PURE__ */ jsxs("div", { className: "relative mt-0.5 inline-flex", children: [
|
|
2571
2940
|
/* @__PURE__ */ jsx(
|
|
2572
2941
|
"input",
|
|
2573
2942
|
{
|
|
2574
|
-
type: "
|
|
2575
|
-
role: "switch",
|
|
2943
|
+
type: "radio",
|
|
2576
2944
|
id,
|
|
2945
|
+
name: group.name,
|
|
2946
|
+
value,
|
|
2577
2947
|
checked,
|
|
2578
2948
|
disabled,
|
|
2579
|
-
onChange:
|
|
2580
|
-
"aria-describedby":
|
|
2949
|
+
onChange: () => group.onValueChange(value),
|
|
2950
|
+
"aria-describedby": descriptionId,
|
|
2581
2951
|
className: "peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
|
|
2952
|
+
"data-invalid": group.state === "error" || void 0,
|
|
2582
2953
|
...props
|
|
2583
2954
|
}
|
|
2584
2955
|
),
|
|
@@ -2587,107 +2958,181 @@ function Switch({
|
|
|
2587
2958
|
{
|
|
2588
2959
|
"aria-hidden": "true",
|
|
2589
2960
|
className: cn(
|
|
2590
|
-
|
|
2591
|
-
"peer-focus-visible:ring-2 peer-focus-visible:ring-brand peer-focus-visible:ring-offset-1"
|
|
2961
|
+
radioBubbleVariants({ size: group.size, state: group.state, checked, disabled }),
|
|
2962
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-kui-brand peer-focus-visible:ring-offset-1"
|
|
2592
2963
|
),
|
|
2593
|
-
children: /* @__PURE__ */ jsx(
|
|
2594
|
-
"div",
|
|
2595
|
-
{
|
|
2596
|
-
className: cn(
|
|
2597
|
-
"absolute left-0.5 rounded-full bg-white shadow transition-transform duration-[var(--kui-duration-fast)]",
|
|
2598
|
-
thumb,
|
|
2599
|
-
checked && translate
|
|
2600
|
-
)
|
|
2601
|
-
}
|
|
2602
|
-
)
|
|
2964
|
+
children: checked && /* @__PURE__ */ jsx("div", { className: cn("rounded-full bg-kui-brand", radioDotSizes[group.size]) })
|
|
2603
2965
|
}
|
|
2604
2966
|
)
|
|
2605
2967
|
] }),
|
|
2606
2968
|
(label || description) && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
2607
|
-
label && /* @__PURE__ */ jsx("label", { htmlFor: id, className: cn("text-sm text-text", !disabled && "cursor-pointer"), children: label }),
|
|
2608
|
-
description && /* @__PURE__ */ jsx("p", { id: descriptionId, className: "text-xs text-text-muted", children: description })
|
|
2969
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: id, className: cn("text-sm text-kui-text", !disabled && "cursor-pointer", group.size === "sm" && "text-xs"), children: label }),
|
|
2970
|
+
description && /* @__PURE__ */ jsx("p", { id: descriptionId, className: cn("text-xs text-kui-text-muted", group.size === "sm" && "text-[10px]"), children: description })
|
|
2609
2971
|
] })
|
|
2610
2972
|
] });
|
|
2611
2973
|
}
|
|
2612
|
-
__name(
|
|
2974
|
+
__name(Radio, "Radio");
|
|
2975
|
+
|
|
2976
|
+
// src/components/forms/Switch/Switch.constants.ts
|
|
2977
|
+
var switchThumbConfig = {
|
|
2978
|
+
xs: { thumb: "h-3 w-3", translate: "translate-x-3" },
|
|
2979
|
+
sm: { thumb: "h-3 w-3", translate: "translate-x-3" },
|
|
2980
|
+
md: { thumb: "h-4 w-4", translate: "translate-x-4" },
|
|
2981
|
+
lg: { thumb: "h-5 w-5", translate: "translate-x-5" }
|
|
2982
|
+
};
|
|
2983
|
+
var Switch = forwardRef(
|
|
2984
|
+
({
|
|
2985
|
+
checked: checkedProp,
|
|
2986
|
+
defaultChecked = false,
|
|
2987
|
+
onCheckedChange,
|
|
2988
|
+
size = "md",
|
|
2989
|
+
disabled = false,
|
|
2990
|
+
label,
|
|
2991
|
+
description,
|
|
2992
|
+
className,
|
|
2993
|
+
id: externalId,
|
|
2994
|
+
onChange: onChangeProp,
|
|
2995
|
+
error,
|
|
2996
|
+
success,
|
|
2997
|
+
children,
|
|
2998
|
+
...props
|
|
2999
|
+
}, ref) => {
|
|
3000
|
+
const autoId = useId();
|
|
3001
|
+
const field = useOptionalFormField();
|
|
3002
|
+
const { theme } = useTheme();
|
|
3003
|
+
const id = externalId ?? field?.id ?? autoId;
|
|
3004
|
+
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
3005
|
+
const checked = checkedProp !== void 0 ? checkedProp : internalChecked;
|
|
3006
|
+
const descriptionId = description ? `${id}-description` : void 0;
|
|
3007
|
+
const { thumb, translate } = switchThumbConfig[size];
|
|
3008
|
+
const state = error ? "error" : success ? "success" : "none";
|
|
3009
|
+
const switchClasses = resolveRecipe(theme.recipes.Switch, {
|
|
3010
|
+
checked,
|
|
3011
|
+
disabled,
|
|
3012
|
+
state
|
|
3013
|
+
});
|
|
3014
|
+
const fontSize = useSizeToken(size, "fontSize");
|
|
3015
|
+
const width = useSizeToken(size, "width", "-2px");
|
|
3016
|
+
const height = useSizeToken(size, "height", "12px");
|
|
3017
|
+
function handleChange(event) {
|
|
3018
|
+
const next = event.target.checked;
|
|
3019
|
+
if (checkedProp === void 0) {
|
|
3020
|
+
setInternalChecked(next);
|
|
3021
|
+
}
|
|
3022
|
+
onCheckedChange?.(next);
|
|
3023
|
+
onChangeProp?.(event);
|
|
3024
|
+
}
|
|
3025
|
+
__name(handleChange, "handleChange");
|
|
3026
|
+
return /* @__PURE__ */ jsxs(
|
|
3027
|
+
"div",
|
|
3028
|
+
{
|
|
3029
|
+
className: cn(
|
|
3030
|
+
"flex gap-2.5",
|
|
3031
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
3032
|
+
className
|
|
3033
|
+
),
|
|
3034
|
+
children: [
|
|
3035
|
+
/* @__PURE__ */ jsxs("div", { className: "relative inline-flex shrink-0", children: [
|
|
3036
|
+
/* @__PURE__ */ jsx(
|
|
3037
|
+
"input",
|
|
3038
|
+
{
|
|
3039
|
+
...props,
|
|
3040
|
+
type: "checkbox",
|
|
3041
|
+
role: "switch",
|
|
3042
|
+
ref,
|
|
3043
|
+
id,
|
|
3044
|
+
checked,
|
|
3045
|
+
disabled,
|
|
3046
|
+
onChange: handleChange,
|
|
3047
|
+
"aria-describedby": field?.describedBy ?? descriptionId,
|
|
3048
|
+
"aria-invalid": field?.status === "error" || void 0,
|
|
3049
|
+
className: "peer absolute inset-0 z-10 m-0\r\n cursor-pointer opacity-0 disabled:cursor-not-allowed"
|
|
3050
|
+
}
|
|
3051
|
+
),
|
|
3052
|
+
/* @__PURE__ */ jsx(
|
|
3053
|
+
"div",
|
|
3054
|
+
{
|
|
3055
|
+
"aria-hidden": "true",
|
|
3056
|
+
className: cn(switchClasses, ""),
|
|
3057
|
+
style: { width, height },
|
|
3058
|
+
children: /* @__PURE__ */ jsx(
|
|
3059
|
+
"div",
|
|
3060
|
+
{
|
|
3061
|
+
className: cn(
|
|
3062
|
+
"absolute left-1 rounded-full bg-white shadow top-1/2 -translate-y-1/2",
|
|
3063
|
+
"transition-transform duration-(--kui-duration-fast)",
|
|
3064
|
+
thumb,
|
|
3065
|
+
checked && translate
|
|
3066
|
+
)
|
|
3067
|
+
}
|
|
3068
|
+
)
|
|
3069
|
+
}
|
|
3070
|
+
)
|
|
3071
|
+
] }),
|
|
3072
|
+
(label || description) && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
3073
|
+
label && /* @__PURE__ */ jsx(
|
|
3074
|
+
"label",
|
|
3075
|
+
{
|
|
3076
|
+
htmlFor: id,
|
|
3077
|
+
className: cn("text-kui-text", !disabled && "cursor-pointer"),
|
|
3078
|
+
style: { fontSize },
|
|
3079
|
+
children: label
|
|
3080
|
+
}
|
|
3081
|
+
),
|
|
3082
|
+
description && /* @__PURE__ */ jsx(
|
|
3083
|
+
"p",
|
|
3084
|
+
{
|
|
3085
|
+
id: descriptionId,
|
|
3086
|
+
className: "text-kui-text-muted",
|
|
3087
|
+
style: {
|
|
3088
|
+
fontSize: fontSize ? `calc(${fontSize} - 3px)` : void 0
|
|
3089
|
+
},
|
|
3090
|
+
children: description
|
|
3091
|
+
}
|
|
3092
|
+
)
|
|
3093
|
+
] }),
|
|
3094
|
+
children && /* @__PURE__ */ jsx(
|
|
3095
|
+
"label",
|
|
3096
|
+
{
|
|
3097
|
+
htmlFor: id,
|
|
3098
|
+
className: cn("text-kui-text inline-flex items-center", !disabled && "cursor-pointer"),
|
|
3099
|
+
style: { fontSize },
|
|
3100
|
+
children
|
|
3101
|
+
}
|
|
3102
|
+
)
|
|
3103
|
+
]
|
|
3104
|
+
}
|
|
3105
|
+
);
|
|
3106
|
+
}
|
|
3107
|
+
);
|
|
3108
|
+
Switch.displayName = "Switch";
|
|
2613
3109
|
var ComboboxContext = createContext(null);
|
|
2614
3110
|
function useComboboxContext(componentName) {
|
|
2615
3111
|
const ctx = useContext(ComboboxContext);
|
|
2616
|
-
if (!ctx)
|
|
3112
|
+
if (!ctx)
|
|
3113
|
+
throw new Error(`<${componentName} /> must be rendered inside <Combobox>.`);
|
|
2617
3114
|
return ctx;
|
|
2618
3115
|
}
|
|
2619
3116
|
__name(useComboboxContext, "useComboboxContext");
|
|
2620
|
-
var inputBase = [
|
|
2621
|
-
"flex",
|
|
2622
|
-
"items-center",
|
|
2623
|
-
"font-sans",
|
|
2624
|
-
"transition-colors",
|
|
2625
|
-
"duration-[var(--kui-duration-fast)]",
|
|
2626
|
-
"outline-none",
|
|
2627
|
-
"placeholder:text-text-muted",
|
|
2628
|
-
"disabled:opacity-50",
|
|
2629
|
-
"disabled:pointer-events-none",
|
|
2630
|
-
"disabled:cursor-not-allowed"
|
|
2631
|
-
].join(" ");
|
|
2632
|
-
var inputWrapperVariants = cva(
|
|
2633
|
-
"group relative inline-flex items-center gap-2 transition-colors",
|
|
2634
|
-
{
|
|
2635
|
-
variants: {
|
|
2636
|
-
variant: {
|
|
2637
|
-
outline: "border border-border bg-transparent text-text hover:border-brand",
|
|
2638
|
-
filled: "border border-transparent bg-surface-raised text-text hover:bg-surface",
|
|
2639
|
-
ghost: "border border-transparent bg-transparent text-text hover:bg-surface-raised"
|
|
2640
|
-
},
|
|
2641
|
-
state: {
|
|
2642
|
-
none: "focus-within:ring-2 focus-within:ring-brand/20",
|
|
2643
|
-
error: "border-destructive focus-within:ring-2 focus-within:ring-destructive/20",
|
|
2644
|
-
success: "border-success focus-within:ring-2 focus-within:ring-success/20"
|
|
2645
|
-
},
|
|
2646
|
-
rounded: {
|
|
2647
|
-
true: "rounded-full",
|
|
2648
|
-
false: "rounded-[var(--kui-radii-md)]"
|
|
2649
|
-
},
|
|
2650
|
-
fullWidth: {
|
|
2651
|
-
true: "w-full",
|
|
2652
|
-
false: ""
|
|
2653
|
-
},
|
|
2654
|
-
hasIcon: {
|
|
2655
|
-
true: "px-2",
|
|
2656
|
-
false: ""
|
|
2657
|
-
},
|
|
2658
|
-
disabled: {
|
|
2659
|
-
true: "pointer-events-none cursor-not-allowed opacity-50",
|
|
2660
|
-
false: ""
|
|
2661
|
-
}
|
|
2662
|
-
},
|
|
2663
|
-
defaultVariants: {
|
|
2664
|
-
variant: "outline",
|
|
2665
|
-
state: "none",
|
|
2666
|
-
rounded: false,
|
|
2667
|
-
fullWidth: true,
|
|
2668
|
-
hasIcon: false,
|
|
2669
|
-
disabled: false
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
);
|
|
2673
|
-
var inputSizeVariants = {
|
|
2674
|
-
xs: "h-8 px-2 text-xs",
|
|
2675
|
-
sm: "h-8 px-2 text-xs",
|
|
2676
|
-
md: "h-10 px-3 text-sm",
|
|
2677
|
-
lg: "h-12 px-4 text-base"
|
|
2678
|
-
};
|
|
2679
3117
|
function orderedFilteredValues(ctx, query) {
|
|
2680
3118
|
const q = query.trim().toLowerCase();
|
|
2681
3119
|
return [...ctx.items.entries()].filter(([, meta]) => !meta.disabled).filter(([, meta]) => !q || String(meta.label).toLowerCase().includes(q)).map(([val]) => val);
|
|
2682
3120
|
}
|
|
2683
3121
|
__name(orderedFilteredValues, "orderedFilteredValues");
|
|
2684
3122
|
var ComboboxInput = forwardRef(
|
|
2685
|
-
({
|
|
3123
|
+
({
|
|
3124
|
+
variant = "outline",
|
|
3125
|
+
size = "md",
|
|
3126
|
+
placeholder,
|
|
3127
|
+
clearable = false,
|
|
3128
|
+
allowFreeText = false,
|
|
3129
|
+
className,
|
|
3130
|
+
rounded,
|
|
3131
|
+
...props
|
|
3132
|
+
}, ref) => {
|
|
2686
3133
|
const ctx = useComboboxContext("ComboboxInput");
|
|
2687
|
-
const
|
|
2688
|
-
const showClear = clearable && ctx.inputValue.length > 0 && !ctx.disabled;
|
|
3134
|
+
const showClear = clearable && ctx?.inputValue?.length > 0 && !ctx.disabled;
|
|
2689
3135
|
useEffect(() => {
|
|
2690
|
-
console.log(ctx);
|
|
2691
3136
|
if (ctx.value === void 0) return;
|
|
2692
3137
|
const meta = ctx.items.get(ctx.value);
|
|
2693
3138
|
if (meta && !ctx.open) {
|
|
@@ -2743,61 +3188,43 @@ var ComboboxInput = forwardRef(
|
|
|
2743
3188
|
setTimeout(() => ctx.setOpen(false), 120);
|
|
2744
3189
|
}
|
|
2745
3190
|
__name(handleBlur, "handleBlur");
|
|
2746
|
-
return /* @__PURE__ */
|
|
2747
|
-
|
|
3191
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
3192
|
+
Input,
|
|
2748
3193
|
{
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
"
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
}
|
|
2782
|
-
),
|
|
2783
|
-
showClear && /* @__PURE__ */ jsx(
|
|
2784
|
-
"button",
|
|
2785
|
-
{
|
|
2786
|
-
type: "button",
|
|
2787
|
-
tabIndex: -1,
|
|
2788
|
-
"aria-label": "Clear",
|
|
2789
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
2790
|
-
onClick: () => {
|
|
2791
|
-
ctx.setInputValue("");
|
|
2792
|
-
ctx.onValueChange(void 0);
|
|
2793
|
-
},
|
|
2794
|
-
className: "flex items-center justify-center text-text-muted transition-colors hover:text-text",
|
|
2795
|
-
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
2796
|
-
}
|
|
2797
|
-
)
|
|
2798
|
-
]
|
|
3194
|
+
ref: (node) => {
|
|
3195
|
+
ctx.triggerRef.current = node;
|
|
3196
|
+
if (typeof ref === "function") ref(node);
|
|
3197
|
+
else if (ref)
|
|
3198
|
+
ref.current = node;
|
|
3199
|
+
},
|
|
3200
|
+
id: ctx.triggerId,
|
|
3201
|
+
role: "combobox",
|
|
3202
|
+
"aria-autocomplete": "list",
|
|
3203
|
+
"aria-haspopup": "listbox",
|
|
3204
|
+
"aria-expanded": ctx.open,
|
|
3205
|
+
"aria-controls": ctx.contentId,
|
|
3206
|
+
"aria-activedescendant": ctx.open && ctx.activeValue ? ctx.optionId(ctx.activeValue) : void 0,
|
|
3207
|
+
variant,
|
|
3208
|
+
size,
|
|
3209
|
+
className,
|
|
3210
|
+
"aria-invalid": ctx.isInvalid || void 0,
|
|
3211
|
+
"aria-describedby": ctx.describedBy,
|
|
3212
|
+
disabled: ctx.disabled,
|
|
3213
|
+
value: ctx.inputValue,
|
|
3214
|
+
placeholder,
|
|
3215
|
+
defaultValue: ctx.defaultValue,
|
|
3216
|
+
onChange: handleChange,
|
|
3217
|
+
onFocus: () => ctx.setOpen(true),
|
|
3218
|
+
onKeyDown: handleKeyDown,
|
|
3219
|
+
onBlur: handleBlur,
|
|
3220
|
+
error: ctx.isInvalid,
|
|
3221
|
+
success: ctx.isSuccess,
|
|
3222
|
+
warning: ctx.isWarning,
|
|
3223
|
+
clearable: showClear,
|
|
3224
|
+
"data-state": ctx.open ? "open" : "closed",
|
|
3225
|
+
...props
|
|
2799
3226
|
}
|
|
2800
|
-
);
|
|
3227
|
+
) });
|
|
2801
3228
|
}
|
|
2802
3229
|
);
|
|
2803
3230
|
ComboboxInput.displayName = "ComboboxInput";
|
|
@@ -2836,9 +3263,9 @@ function ComboboxItem({
|
|
|
2836
3263
|
onMouseDown: (e) => e.preventDefault(),
|
|
2837
3264
|
onClick: () => !disabled && ctx.onValueChange(value),
|
|
2838
3265
|
className: cn(
|
|
2839
|
-
"flex cursor-pointer items-center rounded-[calc(var(--kui-radii-md)-2px)] px-2.5 py-1.5 text-sm text-text transition-colors",
|
|
2840
|
-
active && "bg-brand/15 text-brand",
|
|
2841
|
-
selected && !active && "bg-surface-raised",
|
|
3266
|
+
"flex cursor-pointer items-center rounded-[calc(var(--kui-radii-md)-2px)] px-2.5 py-1.5 text-sm text-kui-text transition-colors",
|
|
3267
|
+
active && "bg-kui-brand/15 text-kui-brand",
|
|
3268
|
+
selected && !active && "bg-kui-surface-raised",
|
|
2842
3269
|
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
2843
3270
|
className
|
|
2844
3271
|
),
|
|
@@ -2863,7 +3290,7 @@ function ComboboxContent({
|
|
|
2863
3290
|
"aria-labelledby": ctx.triggerId,
|
|
2864
3291
|
"data-side": side,
|
|
2865
3292
|
className: cn(
|
|
2866
|
-
"animate-kui-scale-in absolute z-50 max-h-64 w-full overflow-auto rounded-[var(--kui-radii-md)] border border-border bg-surface p-1 shadow-lg",
|
|
3293
|
+
"animate-kui-scale-in absolute z-50 max-h-64 w-full overflow-auto rounded-[var(--kui-radii-md)] border border-kui-border bg-kui-surface p-1 shadow-lg",
|
|
2867
3294
|
side === "bottom" ? "top-full mt-1" : "bottom-full mb-1",
|
|
2868
3295
|
className
|
|
2869
3296
|
),
|
|
@@ -2876,7 +3303,7 @@ function ComboboxEmpty({ children }) {
|
|
|
2876
3303
|
const ctx = useComboboxContext("ComboboxEmpty");
|
|
2877
3304
|
const visibleCount = [...ctx.items.values()].filter((item) => item.visible && !item.disabled).length;
|
|
2878
3305
|
if (visibleCount > 0) return null;
|
|
2879
|
-
return /* @__PURE__ */ jsx("div", { className: "px-2 py-3 text-center text-sm text-text-muted", children: children ?? "No results found" });
|
|
3306
|
+
return /* @__PURE__ */ jsx("div", { className: "px-2 py-3 text-center text-sm text-kui-text-muted", children: children ?? "No results found" });
|
|
2880
3307
|
}
|
|
2881
3308
|
__name(ComboboxEmpty, "ComboboxEmpty");
|
|
2882
3309
|
function ComboboxLoading({
|
|
@@ -2889,7 +3316,7 @@ function ComboboxLoading({
|
|
|
2889
3316
|
role: "status",
|
|
2890
3317
|
"aria-live": "polite",
|
|
2891
3318
|
className: cn(
|
|
2892
|
-
"px-2 py-3 text-center text-sm text-text-muted",
|
|
3319
|
+
"px-2 py-3 text-center text-sm text-kui-text-muted",
|
|
2893
3320
|
className
|
|
2894
3321
|
),
|
|
2895
3322
|
children
|
|
@@ -2909,6 +3336,7 @@ function Combobox({
|
|
|
2909
3336
|
success,
|
|
2910
3337
|
rounded,
|
|
2911
3338
|
className,
|
|
3339
|
+
// status,
|
|
2912
3340
|
children
|
|
2913
3341
|
}) {
|
|
2914
3342
|
const autoId = useId();
|
|
@@ -2928,22 +3356,19 @@ function Combobox({
|
|
|
2928
3356
|
const [activeValue, setActiveValue] = useState(void 0);
|
|
2929
3357
|
const itemsRef = useRef(/* @__PURE__ */ new Map());
|
|
2930
3358
|
const [items, setItems] = useState(/* @__PURE__ */ new Map());
|
|
2931
|
-
const registerItem = useCallback(
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
},
|
|
2945
|
-
[]
|
|
2946
|
-
);
|
|
3359
|
+
const registerItem = useCallback((value2, meta) => {
|
|
3360
|
+
const item = {
|
|
3361
|
+
...meta,
|
|
3362
|
+
visible: true
|
|
3363
|
+
};
|
|
3364
|
+
itemsRef.current.set(value2, item);
|
|
3365
|
+
setItems((prev) => {
|
|
3366
|
+
const next = new Map(prev);
|
|
3367
|
+
next.set(value2, item);
|
|
3368
|
+
return next;
|
|
3369
|
+
});
|
|
3370
|
+
return () => unregisterItem(value2);
|
|
3371
|
+
}, []);
|
|
2947
3372
|
function setItemVisibility(value2, visible) {
|
|
2948
3373
|
setItems((prev) => {
|
|
2949
3374
|
const item2 = prev.get(value2);
|
|
@@ -2981,13 +3406,17 @@ function Combobox({
|
|
|
2981
3406
|
useEffect(() => {
|
|
2982
3407
|
if (!open) return;
|
|
2983
3408
|
function handlePointerDown(e) {
|
|
2984
|
-
if (rootRef.current && !rootRef.current.contains(e.target))
|
|
3409
|
+
if (rootRef.current && !rootRef.current.contains(e.target))
|
|
3410
|
+
setOpen(false);
|
|
2985
3411
|
}
|
|
2986
3412
|
__name(handlePointerDown, "handlePointerDown");
|
|
2987
3413
|
document.addEventListener("mousedown", handlePointerDown);
|
|
2988
3414
|
return () => document.removeEventListener("mousedown", handlePointerDown);
|
|
2989
3415
|
}, [open]);
|
|
2990
|
-
const optionId = useCallback(
|
|
3416
|
+
const optionId = useCallback(
|
|
3417
|
+
(val) => `${contentId}-option-${val}`,
|
|
3418
|
+
[contentId]
|
|
3419
|
+
);
|
|
2991
3420
|
useEffect(() => {
|
|
2992
3421
|
if (!value) {
|
|
2993
3422
|
setInputValue("");
|
|
@@ -3001,6 +3430,7 @@ function Combobox({
|
|
|
3001
3430
|
const ctxValue = useMemo(
|
|
3002
3431
|
() => ({
|
|
3003
3432
|
value,
|
|
3433
|
+
defaultValue: "",
|
|
3004
3434
|
inputValue,
|
|
3005
3435
|
setInputValue,
|
|
3006
3436
|
onValueChange: /* @__PURE__ */ __name((v) => {
|
|
@@ -3029,11 +3459,37 @@ function Combobox({
|
|
|
3029
3459
|
setItemVisibility,
|
|
3030
3460
|
unregisterItem
|
|
3031
3461
|
}),
|
|
3032
|
-
[
|
|
3462
|
+
[
|
|
3463
|
+
value,
|
|
3464
|
+
inputValue,
|
|
3465
|
+
onValueChange,
|
|
3466
|
+
disabled,
|
|
3467
|
+
open,
|
|
3468
|
+
triggerId,
|
|
3469
|
+
contentId,
|
|
3470
|
+
field?.invalid,
|
|
3471
|
+
field?.describedBy,
|
|
3472
|
+
activeValue,
|
|
3473
|
+
registerItem,
|
|
3474
|
+
optionId,
|
|
3475
|
+
success,
|
|
3476
|
+
rounded,
|
|
3477
|
+
items,
|
|
3478
|
+
setItemVisibility,
|
|
3479
|
+
unregisterItem
|
|
3480
|
+
]
|
|
3033
3481
|
);
|
|
3034
3482
|
return /* @__PURE__ */ jsx(ComboboxContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsxs("div", { ref: rootRef, className: className ?? "relative w-full", children: [
|
|
3035
3483
|
children,
|
|
3036
|
-
name && /* @__PURE__ */ jsx(
|
|
3484
|
+
name && /* @__PURE__ */ jsx(
|
|
3485
|
+
"input",
|
|
3486
|
+
{
|
|
3487
|
+
type: "hidden",
|
|
3488
|
+
name,
|
|
3489
|
+
value: value ?? "",
|
|
3490
|
+
disabled
|
|
3491
|
+
}
|
|
3492
|
+
)
|
|
3037
3493
|
] }) });
|
|
3038
3494
|
}
|
|
3039
3495
|
__name(Combobox, "Combobox");
|
|
@@ -3042,13 +3498,59 @@ Combobox.Item = ComboboxItem;
|
|
|
3042
3498
|
Combobox.Content = ComboboxContent;
|
|
3043
3499
|
Combobox.Empty = ComboboxEmpty;
|
|
3044
3500
|
Combobox.Loading = ComboboxLoading;
|
|
3045
|
-
var MultiSelectContext = createContext(
|
|
3501
|
+
var MultiSelectContext = createContext(
|
|
3502
|
+
null
|
|
3503
|
+
);
|
|
3046
3504
|
function useMultiSelectContext(componentName) {
|
|
3047
3505
|
const ctx = useContext(MultiSelectContext);
|
|
3048
|
-
if (!ctx)
|
|
3506
|
+
if (!ctx)
|
|
3507
|
+
throw new Error(
|
|
3508
|
+
`<${componentName} /> must be rendered inside <MultiSelect>.`
|
|
3509
|
+
);
|
|
3049
3510
|
return ctx;
|
|
3050
3511
|
}
|
|
3051
3512
|
__name(useMultiSelectContext, "useMultiSelectContext");
|
|
3513
|
+
var inputWrapperVariants = cva(
|
|
3514
|
+
"group relative inline-flex items-center gap-2 transition-colors",
|
|
3515
|
+
{
|
|
3516
|
+
variants: {
|
|
3517
|
+
variant: {
|
|
3518
|
+
outline: "border border-kui-border bg-transparent text-kui-text hover:border-kui-brand",
|
|
3519
|
+
filled: "border border-transparent bg-kui-surface-raised text-kui-text hover:bg-kui-surface",
|
|
3520
|
+
ghost: "border border-transparent bg-transparent text-kui-text hover:bg-kui-surface-raised"
|
|
3521
|
+
},
|
|
3522
|
+
state: {
|
|
3523
|
+
none: "focus-within:ring-2 focus-within:ring-kui-brand/20",
|
|
3524
|
+
error: "border-kui-destructive focus-within:ring-2 focus-within:ring-kui-destructive/20",
|
|
3525
|
+
success: "border-kui-success focus-within:ring-2 focus-within:ring-kui-success/20"
|
|
3526
|
+
},
|
|
3527
|
+
rounded: {
|
|
3528
|
+
true: "rounded-full",
|
|
3529
|
+
false: "rounded-[var(--kui-radii-md)]"
|
|
3530
|
+
},
|
|
3531
|
+
fullWidth: {
|
|
3532
|
+
true: "w-full",
|
|
3533
|
+
false: ""
|
|
3534
|
+
},
|
|
3535
|
+
hasIcon: {
|
|
3536
|
+
true: "px-2",
|
|
3537
|
+
false: ""
|
|
3538
|
+
},
|
|
3539
|
+
disabled: {
|
|
3540
|
+
true: "pointer-events-none cursor-not-allowed opacity-50",
|
|
3541
|
+
false: ""
|
|
3542
|
+
}
|
|
3543
|
+
},
|
|
3544
|
+
defaultVariants: {
|
|
3545
|
+
variant: "outline",
|
|
3546
|
+
state: "none",
|
|
3547
|
+
rounded: false,
|
|
3548
|
+
fullWidth: true,
|
|
3549
|
+
hasIcon: false,
|
|
3550
|
+
disabled: false
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
);
|
|
3052
3554
|
var multiSelectSizeVariants = cva("", {
|
|
3053
3555
|
variants: {
|
|
3054
3556
|
size: {
|
|
@@ -3077,141 +3579,148 @@ function orderedEnabledValues2(items) {
|
|
|
3077
3579
|
return [...items.entries()].filter(([, meta]) => !meta.disabled).map(([val]) => val);
|
|
3078
3580
|
}
|
|
3079
3581
|
__name(orderedEnabledValues2, "orderedEnabledValues");
|
|
3080
|
-
var MultiSelectTrigger = forwardRef(
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3582
|
+
var MultiSelectTrigger = forwardRef(({ className }, ref) => {
|
|
3583
|
+
const ctx = useMultiSelectContext("MultiSelectTrigger");
|
|
3584
|
+
const state = ctx.isInvalid ? "error" : ctx.isSuccess ? "success" : "none";
|
|
3585
|
+
const showClear = ctx.clearable && ctx.value.length > 0 && !ctx.disabled;
|
|
3586
|
+
const visible = ctx.maxVisibleChips ? ctx.value.slice(0, ctx.maxVisibleChips) : ctx.value;
|
|
3587
|
+
const overflow = ctx.value.length - visible.length;
|
|
3588
|
+
function move(delta) {
|
|
3589
|
+
const order = orderedEnabledValues2(ctx.items);
|
|
3590
|
+
if (!order.length) return;
|
|
3591
|
+
const i = ctx.activeValue ? order.indexOf(ctx.activeValue) : -1;
|
|
3592
|
+
ctx.setActiveValue(order[(i + delta + order.length) % order.length]);
|
|
3593
|
+
}
|
|
3594
|
+
__name(move, "move");
|
|
3595
|
+
function handleKeyDown(e) {
|
|
3596
|
+
switch (e.key) {
|
|
3597
|
+
case "ArrowDown":
|
|
3598
|
+
e.preventDefault();
|
|
3599
|
+
ctx.open ? move(1) : ctx.setOpen(true);
|
|
3600
|
+
break;
|
|
3601
|
+
case "ArrowUp":
|
|
3602
|
+
e.preventDefault();
|
|
3603
|
+
ctx.open ? move(-1) : ctx.setOpen(true);
|
|
3604
|
+
break;
|
|
3605
|
+
case "Enter":
|
|
3606
|
+
case " ":
|
|
3607
|
+
e.preventDefault();
|
|
3608
|
+
if (!ctx.open) ctx.setOpen(true);
|
|
3609
|
+
else if (ctx.activeValue) ctx.toggleValue(ctx.activeValue);
|
|
3610
|
+
break;
|
|
3611
|
+
case "Escape":
|
|
3612
|
+
if (ctx.open) {
|
|
3106
3613
|
e.preventDefault();
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
case "Escape":
|
|
3111
|
-
if (ctx.open) {
|
|
3112
|
-
e.preventDefault();
|
|
3113
|
-
ctx.setOpen(false);
|
|
3114
|
-
}
|
|
3115
|
-
break;
|
|
3116
|
-
}
|
|
3614
|
+
ctx.setOpen(false);
|
|
3615
|
+
}
|
|
3616
|
+
break;
|
|
3117
3617
|
}
|
|
3118
|
-
__name(handleKeyDown, "handleKeyDown");
|
|
3119
|
-
return /* @__PURE__ */ jsxs(
|
|
3120
|
-
"div",
|
|
3121
|
-
{
|
|
3122
|
-
ref: ctx.triggerRef,
|
|
3123
|
-
className: cn(
|
|
3124
|
-
inputWrapperVariants({ variant: ctx.variant, state, fullWidth: true, disabled: ctx.disabled, rounded: ctx.rounded }),
|
|
3125
|
-
multiSelectSizeVariants({}),
|
|
3126
|
-
"flex flex-wrap items-center gap-1",
|
|
3127
|
-
className
|
|
3128
|
-
),
|
|
3129
|
-
children: [
|
|
3130
|
-
/* @__PURE__ */ jsxs(
|
|
3131
|
-
"button",
|
|
3132
|
-
{
|
|
3133
|
-
ref,
|
|
3134
|
-
type: "button",
|
|
3135
|
-
id: ctx.triggerId,
|
|
3136
|
-
role: "combobox",
|
|
3137
|
-
"aria-haspopup": "listbox",
|
|
3138
|
-
"aria-expanded": ctx.open,
|
|
3139
|
-
"aria-controls": ctx.contentId,
|
|
3140
|
-
"aria-invalid": ctx.isInvalid || void 0,
|
|
3141
|
-
"aria-describedby": ctx.describedBy,
|
|
3142
|
-
"aria-required": ctx.required || void 0,
|
|
3143
|
-
disabled: ctx.disabled,
|
|
3144
|
-
onClick: () => !ctx.disabled && ctx.setOpen(!ctx.open),
|
|
3145
|
-
onKeyDown: handleKeyDown,
|
|
3146
|
-
className: "flex flex-1 flex-wrap items-center gap-1 bg-transparent text-left outline-none cursor-pointer disabled:cursor-not-allowed",
|
|
3147
|
-
children: [
|
|
3148
|
-
ctx.value.length === 0 && /* @__PURE__ */ jsx("span", { className: "text-text-muted", children: ctx.placeholder }),
|
|
3149
|
-
visible.map((v) => {
|
|
3150
|
-
const meta = ctx.items.get(v);
|
|
3151
|
-
return /* @__PURE__ */ jsxs(
|
|
3152
|
-
"span",
|
|
3153
|
-
{
|
|
3154
|
-
className: cn(
|
|
3155
|
-
chipSizeVariants({}),
|
|
3156
|
-
"bg-brand/15 text-brand"
|
|
3157
|
-
),
|
|
3158
|
-
children: [
|
|
3159
|
-
meta?.label ?? v,
|
|
3160
|
-
/* @__PURE__ */ jsx(
|
|
3161
|
-
"span",
|
|
3162
|
-
{
|
|
3163
|
-
role: "button",
|
|
3164
|
-
tabIndex: -1,
|
|
3165
|
-
"aria-label": `Remove ${meta?.label ?? v}`,
|
|
3166
|
-
onClick: (e) => {
|
|
3167
|
-
e.stopPropagation();
|
|
3168
|
-
ctx.removeValue(v);
|
|
3169
|
-
},
|
|
3170
|
-
className: "hover:opacity-70",
|
|
3171
|
-
children: /* @__PURE__ */ jsx(
|
|
3172
|
-
X,
|
|
3173
|
-
{
|
|
3174
|
-
size: ctx.size === "sm" ? 8 : ctx.size === "md" ? 10 : 12
|
|
3175
|
-
}
|
|
3176
|
-
)
|
|
3177
|
-
}
|
|
3178
|
-
)
|
|
3179
|
-
]
|
|
3180
|
-
},
|
|
3181
|
-
v
|
|
3182
|
-
);
|
|
3183
|
-
}),
|
|
3184
|
-
overflow > 0 && /* @__PURE__ */ jsxs("span", { className: cn(
|
|
3185
|
-
"text-text-muted",
|
|
3186
|
-
ctx.size === "sm" ? "text-[10px]" : ctx.size === "md" ? "text-xs" : "text-sm"
|
|
3187
|
-
), children: [
|
|
3188
|
-
"+",
|
|
3189
|
-
overflow,
|
|
3190
|
-
" more"
|
|
3191
|
-
] })
|
|
3192
|
-
]
|
|
3193
|
-
}
|
|
3194
|
-
),
|
|
3195
|
-
showClear && /* @__PURE__ */ jsx(
|
|
3196
|
-
"button",
|
|
3197
|
-
{
|
|
3198
|
-
type: "button",
|
|
3199
|
-
tabIndex: -1,
|
|
3200
|
-
"aria-label": "Clear selection",
|
|
3201
|
-
onClick: (e) => {
|
|
3202
|
-
e.preventDefault();
|
|
3203
|
-
e.stopPropagation();
|
|
3204
|
-
ctx.onClear();
|
|
3205
|
-
},
|
|
3206
|
-
className: "flex h-4 w-4 shrink-0 items-center justify-center text-text-muted transition-colors hover:text-text",
|
|
3207
|
-
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
3208
|
-
}
|
|
3209
|
-
)
|
|
3210
|
-
]
|
|
3211
|
-
}
|
|
3212
|
-
);
|
|
3213
3618
|
}
|
|
3214
|
-
);
|
|
3619
|
+
__name(handleKeyDown, "handleKeyDown");
|
|
3620
|
+
return /* @__PURE__ */ jsxs(
|
|
3621
|
+
"div",
|
|
3622
|
+
{
|
|
3623
|
+
ref: ctx.triggerRef,
|
|
3624
|
+
className: cn(
|
|
3625
|
+
inputWrapperVariants({
|
|
3626
|
+
variant: ctx.variant,
|
|
3627
|
+
state,
|
|
3628
|
+
fullWidth: true,
|
|
3629
|
+
disabled: ctx.disabled,
|
|
3630
|
+
rounded: ctx.rounded
|
|
3631
|
+
}),
|
|
3632
|
+
multiSelectSizeVariants({}),
|
|
3633
|
+
"flex flex-wrap items-center gap-1",
|
|
3634
|
+
className
|
|
3635
|
+
),
|
|
3636
|
+
children: [
|
|
3637
|
+
/* @__PURE__ */ jsxs(
|
|
3638
|
+
"button",
|
|
3639
|
+
{
|
|
3640
|
+
ref,
|
|
3641
|
+
type: "button",
|
|
3642
|
+
id: ctx.triggerId,
|
|
3643
|
+
role: "combobox",
|
|
3644
|
+
"aria-haspopup": "listbox",
|
|
3645
|
+
"aria-expanded": ctx.open,
|
|
3646
|
+
"aria-controls": ctx.contentId,
|
|
3647
|
+
"aria-invalid": ctx.isInvalid || void 0,
|
|
3648
|
+
"aria-describedby": ctx.describedBy,
|
|
3649
|
+
"aria-required": ctx.required || void 0,
|
|
3650
|
+
disabled: ctx.disabled,
|
|
3651
|
+
onClick: () => !ctx.disabled && ctx.setOpen(!ctx.open),
|
|
3652
|
+
onKeyDown: handleKeyDown,
|
|
3653
|
+
className: "flex flex-1 flex-wrap items-center gap-1 bg-transparent text-left outline-none cursor-pointer disabled:cursor-not-allowed",
|
|
3654
|
+
children: [
|
|
3655
|
+
ctx.value.length === 0 && /* @__PURE__ */ jsx("span", { className: "text-kui-text-muted", children: ctx.placeholder }),
|
|
3656
|
+
visible.map((v) => {
|
|
3657
|
+
const meta = ctx.items.get(v);
|
|
3658
|
+
return /* @__PURE__ */ jsxs(
|
|
3659
|
+
"span",
|
|
3660
|
+
{
|
|
3661
|
+
className: cn(chipSizeVariants({}), "bg-kui-brand/15 text-kui-brand"),
|
|
3662
|
+
children: [
|
|
3663
|
+
meta?.label ?? v,
|
|
3664
|
+
/* @__PURE__ */ jsx(
|
|
3665
|
+
"span",
|
|
3666
|
+
{
|
|
3667
|
+
role: "button",
|
|
3668
|
+
tabIndex: -1,
|
|
3669
|
+
"aria-label": `Remove ${meta?.label ?? v}`,
|
|
3670
|
+
onClick: (e) => {
|
|
3671
|
+
e.stopPropagation();
|
|
3672
|
+
ctx.removeValue(v);
|
|
3673
|
+
},
|
|
3674
|
+
className: "hover:opacity-70",
|
|
3675
|
+
children: /* @__PURE__ */ jsx(
|
|
3676
|
+
X,
|
|
3677
|
+
{
|
|
3678
|
+
size: ctx.size === "sm" ? 8 : ctx.size === "md" ? 10 : 12
|
|
3679
|
+
}
|
|
3680
|
+
)
|
|
3681
|
+
}
|
|
3682
|
+
)
|
|
3683
|
+
]
|
|
3684
|
+
},
|
|
3685
|
+
v
|
|
3686
|
+
);
|
|
3687
|
+
}),
|
|
3688
|
+
overflow > 0 && /* @__PURE__ */ jsxs(
|
|
3689
|
+
"span",
|
|
3690
|
+
{
|
|
3691
|
+
className: cn(
|
|
3692
|
+
"text-kui-text-muted",
|
|
3693
|
+
ctx.size === "sm" ? "text-[10px]" : ctx.size === "md" ? "text-xs" : "text-sm"
|
|
3694
|
+
),
|
|
3695
|
+
children: [
|
|
3696
|
+
"+",
|
|
3697
|
+
overflow,
|
|
3698
|
+
" more"
|
|
3699
|
+
]
|
|
3700
|
+
}
|
|
3701
|
+
)
|
|
3702
|
+
]
|
|
3703
|
+
}
|
|
3704
|
+
),
|
|
3705
|
+
showClear && /* @__PURE__ */ jsx(
|
|
3706
|
+
"button",
|
|
3707
|
+
{
|
|
3708
|
+
type: "button",
|
|
3709
|
+
tabIndex: -1,
|
|
3710
|
+
"aria-label": "Clear selection",
|
|
3711
|
+
onClick: (e) => {
|
|
3712
|
+
e.preventDefault();
|
|
3713
|
+
e.stopPropagation();
|
|
3714
|
+
ctx.onClear();
|
|
3715
|
+
},
|
|
3716
|
+
className: "flex h-4 w-4 shrink-0 items-center justify-center text-kui-text-muted transition-colors hover:text-kui-text",
|
|
3717
|
+
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
3718
|
+
}
|
|
3719
|
+
)
|
|
3720
|
+
]
|
|
3721
|
+
}
|
|
3722
|
+
);
|
|
3723
|
+
});
|
|
3215
3724
|
MultiSelectTrigger.displayName = "MultiSelectTrigger";
|
|
3216
3725
|
function MultiSelectContent({
|
|
3217
3726
|
className,
|
|
@@ -3231,7 +3740,7 @@ function MultiSelectContent({
|
|
|
3231
3740
|
"data-state": ctx.open ? "open" : "closed",
|
|
3232
3741
|
"data-side": side,
|
|
3233
3742
|
className: cn(
|
|
3234
|
-
"animate-kui-scale-in absolute z-50 max-h-64 w-full overflow-auto rounded-[var(--kui-radii-md)] border border-border bg-surface p-1 shadow-lg",
|
|
3743
|
+
"animate-kui-scale-in absolute z-50 max-h-64 w-full overflow-auto rounded-[var(--kui-radii-md)] border border-kui-border bg-kui-surface p-1 shadow-lg",
|
|
3235
3744
|
side === "bottom" ? "top-full mt-1" : "bottom-full mb-1",
|
|
3236
3745
|
className
|
|
3237
3746
|
),
|
|
@@ -3286,8 +3795,8 @@ function MultiSelectItem({
|
|
|
3286
3795
|
onMouseEnter: () => !disabled && ctx.setActiveValue(value),
|
|
3287
3796
|
onClick: () => !disabled && ctx.toggleValue(value),
|
|
3288
3797
|
className: cn(
|
|
3289
|
-
"flex cursor-pointer items-center justify-between rounded-[calc(var(--kui-radii-md)-2px)] px-2.5 py-1.5 text-sm text-text transition-colors",
|
|
3290
|
-
active && "bg-brand/15 text-brand",
|
|
3798
|
+
"flex cursor-pointer items-center justify-between rounded-[calc(var(--kui-radii-md)-2px)] px-2.5 py-1.5 text-sm text-kui-text transition-colors",
|
|
3799
|
+
active && "bg-kui-brand/15 text-kui-brand",
|
|
3291
3800
|
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
3292
3801
|
className
|
|
3293
3802
|
),
|
|
@@ -3346,7 +3855,10 @@ function MultiSelect({
|
|
|
3346
3855
|
(v) => commit(value.includes(v) ? value.filter((x) => x !== v) : [...value, v]),
|
|
3347
3856
|
[value, commit]
|
|
3348
3857
|
);
|
|
3349
|
-
const removeValue = useCallback(
|
|
3858
|
+
const removeValue = useCallback(
|
|
3859
|
+
(v) => commit(value.filter((x) => x !== v)),
|
|
3860
|
+
[value, commit]
|
|
3861
|
+
);
|
|
3350
3862
|
const handleClear = useCallback(() => {
|
|
3351
3863
|
commit([]);
|
|
3352
3864
|
}, [commit]);
|
|
@@ -3355,13 +3867,17 @@ function MultiSelect({
|
|
|
3355
3867
|
useEffect(() => {
|
|
3356
3868
|
if (!open) return;
|
|
3357
3869
|
function handlePointerDown(e) {
|
|
3358
|
-
if (rootRef.current && !rootRef.current.contains(e.target))
|
|
3870
|
+
if (rootRef.current && !rootRef.current.contains(e.target))
|
|
3871
|
+
setOpen(false);
|
|
3359
3872
|
}
|
|
3360
3873
|
__name(handlePointerDown, "handlePointerDown");
|
|
3361
3874
|
document.addEventListener("mousedown", handlePointerDown);
|
|
3362
3875
|
return () => document.removeEventListener("mousedown", handlePointerDown);
|
|
3363
3876
|
}, [open]);
|
|
3364
|
-
const optionId = useCallback(
|
|
3877
|
+
const optionId = useCallback(
|
|
3878
|
+
(val) => `${contentId}-option-${val}`,
|
|
3879
|
+
[contentId]
|
|
3880
|
+
);
|
|
3365
3881
|
const ctxValue = useMemo(
|
|
3366
3882
|
() => ({
|
|
3367
3883
|
value,
|
|
@@ -3390,17 +3906,326 @@ function MultiSelect({
|
|
|
3390
3906
|
clearable,
|
|
3391
3907
|
onClear: handleClear
|
|
3392
3908
|
}),
|
|
3393
|
-
[
|
|
3909
|
+
[
|
|
3910
|
+
value,
|
|
3911
|
+
toggleValue,
|
|
3912
|
+
removeValue,
|
|
3913
|
+
disabled,
|
|
3914
|
+
variant,
|
|
3915
|
+
size,
|
|
3916
|
+
open,
|
|
3917
|
+
triggerId,
|
|
3918
|
+
contentId,
|
|
3919
|
+
field?.invalid,
|
|
3920
|
+
field?.describedBy,
|
|
3921
|
+
field?.required,
|
|
3922
|
+
required,
|
|
3923
|
+
placeholder,
|
|
3924
|
+
maxVisibleChips,
|
|
3925
|
+
activeValue,
|
|
3926
|
+
registerItem,
|
|
3927
|
+
optionId,
|
|
3928
|
+
error,
|
|
3929
|
+
success,
|
|
3930
|
+
rounded,
|
|
3931
|
+
clearable,
|
|
3932
|
+
handleClear
|
|
3933
|
+
]
|
|
3394
3934
|
);
|
|
3395
3935
|
return /* @__PURE__ */ jsx(MultiSelectContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsxs("div", { ref: rootRef, className: className ?? "relative w-full", children: [
|
|
3396
3936
|
children,
|
|
3397
|
-
name && value.map((v) => /* @__PURE__ */ jsx(
|
|
3937
|
+
name && value.map((v) => /* @__PURE__ */ jsx(
|
|
3938
|
+
"input",
|
|
3939
|
+
{
|
|
3940
|
+
type: "hidden",
|
|
3941
|
+
name: `${name}[]`,
|
|
3942
|
+
value: v,
|
|
3943
|
+
disabled
|
|
3944
|
+
},
|
|
3945
|
+
v
|
|
3946
|
+
))
|
|
3398
3947
|
] }) });
|
|
3399
3948
|
}
|
|
3400
3949
|
__name(MultiSelect, "MultiSelect");
|
|
3401
3950
|
MultiSelect.Trigger = MultiSelectTrigger;
|
|
3402
3951
|
MultiSelect.Content = MultiSelectContent;
|
|
3403
3952
|
MultiSelect.Item = MultiSelectItem;
|
|
3953
|
+
|
|
3954
|
+
// src/utils/responsive.ts
|
|
3955
|
+
function resolveResponsiveValue(value) {
|
|
3956
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3957
|
+
return {
|
|
3958
|
+
base: value,
|
|
3959
|
+
responsive: {}
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
const responsiveValue = value;
|
|
3963
|
+
const { base, ...responsive } = responsiveValue;
|
|
3964
|
+
return {
|
|
3965
|
+
base,
|
|
3966
|
+
responsive: Object.fromEntries(
|
|
3967
|
+
Object.entries(responsive).filter(([, value2]) => value2 !== void 0)
|
|
3968
|
+
)
|
|
3969
|
+
};
|
|
3970
|
+
}
|
|
3971
|
+
__name(resolveResponsiveValue, "resolveResponsiveValue");
|
|
3972
|
+
var Container = forwardRef(
|
|
3973
|
+
({
|
|
3974
|
+
maxWidth = "lg",
|
|
3975
|
+
padding,
|
|
3976
|
+
centered = true,
|
|
3977
|
+
as: Tag = "div",
|
|
3978
|
+
className,
|
|
3979
|
+
style,
|
|
3980
|
+
unstyled,
|
|
3981
|
+
children,
|
|
3982
|
+
...rest
|
|
3983
|
+
}, ref) => {
|
|
3984
|
+
const { theme } = useTheme();
|
|
3985
|
+
const recipeClassName = unstyled ? "" : resolveRecipe(theme.recipes.Container, { maxWidth });
|
|
3986
|
+
const responsiveStyles = {};
|
|
3987
|
+
if (padding !== void 0) {
|
|
3988
|
+
const { base, responsive } = resolveResponsiveValue(padding);
|
|
3989
|
+
if (base !== void 0) {
|
|
3990
|
+
responsiveStyles.base = { paddingInline: `var(--kui-spacing-${base})` };
|
|
3991
|
+
}
|
|
3992
|
+
for (const [bp, value] of Object.entries(responsive)) {
|
|
3993
|
+
responsiveStyles[bp] = { paddingInline: `var(--kui-spacing-${value})` };
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
|
|
3997
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3998
|
+
/* @__PURE__ */ jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
3999
|
+
/* @__PURE__ */ jsx(
|
|
4000
|
+
Tag,
|
|
4001
|
+
{
|
|
4002
|
+
ref,
|
|
4003
|
+
"data-kui-responsive": attribute,
|
|
4004
|
+
className: cn(recipeClassName, centered && "mx-auto", className),
|
|
4005
|
+
style,
|
|
4006
|
+
...rest,
|
|
4007
|
+
children
|
|
4008
|
+
}
|
|
4009
|
+
)
|
|
4010
|
+
] });
|
|
4011
|
+
}
|
|
4012
|
+
);
|
|
4013
|
+
Container.displayName = "Container";
|
|
4014
|
+
function spaceVar(value) {
|
|
4015
|
+
return `var(--kui-spacing-${value})`;
|
|
4016
|
+
}
|
|
4017
|
+
__name(spaceVar, "spaceVar");
|
|
4018
|
+
var Flex = forwardRef(
|
|
4019
|
+
({
|
|
4020
|
+
direction = "row",
|
|
4021
|
+
wrap = "nowrap",
|
|
4022
|
+
align,
|
|
4023
|
+
justify,
|
|
4024
|
+
gap,
|
|
4025
|
+
as: Tag = "div",
|
|
4026
|
+
className,
|
|
4027
|
+
style,
|
|
4028
|
+
unstyled,
|
|
4029
|
+
children,
|
|
4030
|
+
...rest
|
|
4031
|
+
}, ref) => {
|
|
4032
|
+
const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
|
|
4033
|
+
[direction, (v) => ({ flexDirection: v })],
|
|
4034
|
+
[wrap, (v) => ({ flexWrap: v })],
|
|
4035
|
+
[align, (v) => ({ alignItems: v })],
|
|
4036
|
+
[justify, (v) => ({ justifyContent: v })],
|
|
4037
|
+
[gap, (v) => ({ gap: spaceVar(v) })]
|
|
4038
|
+
]);
|
|
4039
|
+
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
|
|
4040
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4041
|
+
/* @__PURE__ */ jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
4042
|
+
/* @__PURE__ */ jsx(
|
|
4043
|
+
Tag,
|
|
4044
|
+
{
|
|
4045
|
+
ref,
|
|
4046
|
+
"data-kui-responsive": attribute,
|
|
4047
|
+
className: cn(!unstyled && "flex", className),
|
|
4048
|
+
style,
|
|
4049
|
+
...rest,
|
|
4050
|
+
children
|
|
4051
|
+
}
|
|
4052
|
+
)
|
|
4053
|
+
] });
|
|
4054
|
+
}
|
|
4055
|
+
);
|
|
4056
|
+
Flex.displayName = "Flex";
|
|
4057
|
+
var Stack = forwardRef(
|
|
4058
|
+
({ orientation = "vertical", divider, children, ...rest }, ref) => {
|
|
4059
|
+
const direction = orientation === "horizontal" ? "row" : "column";
|
|
4060
|
+
if (!divider) {
|
|
4061
|
+
return /* @__PURE__ */ jsx(Flex, { ref, direction, ...rest, children });
|
|
4062
|
+
}
|
|
4063
|
+
const items = Children.toArray(children).filter(isValidElement);
|
|
4064
|
+
return /* @__PURE__ */ jsx(Flex, { ref, direction, ...rest, children: items.map((child, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
4065
|
+
child,
|
|
4066
|
+
index < items.length - 1 && divider
|
|
4067
|
+
] }, child.key ?? index)) });
|
|
4068
|
+
}
|
|
4069
|
+
);
|
|
4070
|
+
Stack.displayName = "Stack";
|
|
4071
|
+
function spaceVar2(value) {
|
|
4072
|
+
return `var(--kui-spacing-${value})`;
|
|
4073
|
+
}
|
|
4074
|
+
__name(spaceVar2, "spaceVar");
|
|
4075
|
+
var Grid = forwardRef(
|
|
4076
|
+
({
|
|
4077
|
+
columns,
|
|
4078
|
+
templateColumns,
|
|
4079
|
+
templateRows,
|
|
4080
|
+
templateAreas,
|
|
4081
|
+
gap,
|
|
4082
|
+
columnGap,
|
|
4083
|
+
rowGap,
|
|
4084
|
+
align,
|
|
4085
|
+
justify,
|
|
4086
|
+
as: Tag = "div",
|
|
4087
|
+
className,
|
|
4088
|
+
style,
|
|
4089
|
+
unstyled,
|
|
4090
|
+
children,
|
|
4091
|
+
...rest
|
|
4092
|
+
}, ref) => {
|
|
4093
|
+
const responsiveStyles = (0, hooks_exports.useMergedResponsiveStyles)([
|
|
4094
|
+
[
|
|
4095
|
+
templateColumns ?? columns,
|
|
4096
|
+
(v) => typeof v === "number" ? { gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))` } : { gridTemplateColumns: v }
|
|
4097
|
+
],
|
|
4098
|
+
[templateRows, (v) => ({ gridTemplateRows: v })],
|
|
4099
|
+
[gap, (v) => ({ gap: spaceVar2(v) })],
|
|
4100
|
+
[columnGap, (v) => ({ columnGap: spaceVar2(v) })],
|
|
4101
|
+
[rowGap, (v) => ({ rowGap: spaceVar2(v) })],
|
|
4102
|
+
[align, (v) => ({ alignItems: v })],
|
|
4103
|
+
[justify, (v) => ({ justifyContent: v })]
|
|
4104
|
+
]);
|
|
4105
|
+
const { attribute, style: responsiveCss } = (0, hooks_exports.useResponsiveStyles)(responsiveStyles);
|
|
4106
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4107
|
+
/* @__PURE__ */ jsx(ResponsiveStyle, { css: responsiveCss }),
|
|
4108
|
+
/* @__PURE__ */ jsx(
|
|
4109
|
+
Tag,
|
|
4110
|
+
{
|
|
4111
|
+
ref,
|
|
4112
|
+
"data-kui-responsive": attribute,
|
|
4113
|
+
className: cn(!unstyled && "grid", className),
|
|
4114
|
+
style: { ...style, gridTemplateAreas: templateAreas },
|
|
4115
|
+
...rest,
|
|
4116
|
+
children
|
|
4117
|
+
}
|
|
4118
|
+
)
|
|
4119
|
+
] });
|
|
4120
|
+
}
|
|
4121
|
+
);
|
|
4122
|
+
Grid.displayName = "Grid";
|
|
4123
|
+
var cardVariants = {
|
|
4124
|
+
solid: "bg-kui-surface",
|
|
4125
|
+
outline: "border border-kui-border bg-kui-surface",
|
|
4126
|
+
ghost: "bg-transparent",
|
|
4127
|
+
elevated: "bg-kui-surface shadow-md",
|
|
4128
|
+
compact: "bg-kui-surface"
|
|
4129
|
+
};
|
|
4130
|
+
var cardSizes = {
|
|
4131
|
+
sm: "p-3",
|
|
4132
|
+
md: "p-4",
|
|
4133
|
+
lg: "p-6"
|
|
4134
|
+
};
|
|
4135
|
+
function Card({
|
|
4136
|
+
variant = "outline",
|
|
4137
|
+
size = "md",
|
|
4138
|
+
hasImage = false,
|
|
4139
|
+
fullWidth = false,
|
|
4140
|
+
noPadding = false,
|
|
4141
|
+
className,
|
|
4142
|
+
children,
|
|
4143
|
+
...props
|
|
4144
|
+
}) {
|
|
4145
|
+
const basePadding = variant === "compact" ? "p-3" : hasImage ? "p-0" : cardSizes[size];
|
|
4146
|
+
return /* @__PURE__ */ jsx(
|
|
4147
|
+
"div",
|
|
4148
|
+
{
|
|
4149
|
+
className: cn(
|
|
4150
|
+
"overflow-hidden rounded-(--kui-radii-lg)",
|
|
4151
|
+
cardVariants[variant],
|
|
4152
|
+
fullWidth && "w-full",
|
|
4153
|
+
className
|
|
4154
|
+
),
|
|
4155
|
+
...props,
|
|
4156
|
+
children: /* @__PURE__ */ jsx("div", { className: cn(!noPadding && basePadding), children })
|
|
4157
|
+
}
|
|
4158
|
+
);
|
|
4159
|
+
}
|
|
4160
|
+
__name(Card, "Card");
|
|
4161
|
+
function CardHeader({ className, children, ...props }) {
|
|
4162
|
+
return /* @__PURE__ */ jsx(
|
|
4163
|
+
"div",
|
|
4164
|
+
{
|
|
4165
|
+
className: cn(
|
|
4166
|
+
"flex items-center justify-between gap-(--kui-spacing-md)",
|
|
4167
|
+
className
|
|
4168
|
+
),
|
|
4169
|
+
...props,
|
|
4170
|
+
children
|
|
4171
|
+
}
|
|
4172
|
+
);
|
|
4173
|
+
}
|
|
4174
|
+
__name(CardHeader, "CardHeader");
|
|
4175
|
+
function CardBody({ className, children, ...props }) {
|
|
4176
|
+
return /* @__PURE__ */ jsx("div", { className: cn("min-w-0", className), ...props, children });
|
|
4177
|
+
}
|
|
4178
|
+
__name(CardBody, "CardBody");
|
|
4179
|
+
function CardFooter({ className, children, ...props }) {
|
|
4180
|
+
return /* @__PURE__ */ jsx(
|
|
4181
|
+
"div",
|
|
4182
|
+
{
|
|
4183
|
+
className: cn("flex items-center gap-(--kui-spacing-md)", className),
|
|
4184
|
+
...props,
|
|
4185
|
+
children
|
|
4186
|
+
}
|
|
4187
|
+
);
|
|
4188
|
+
}
|
|
4189
|
+
__name(CardFooter, "CardFooter");
|
|
4190
|
+
Card.Header = CardHeader;
|
|
4191
|
+
Card.Body = CardBody;
|
|
4192
|
+
Card.Footer = CardFooter;
|
|
4193
|
+
|
|
4194
|
+
// src/components/internal/loader/skeletonRegistry.ts
|
|
4195
|
+
var registry = /* @__PURE__ */ new WeakMap();
|
|
4196
|
+
function registerSkeleton(component, definition) {
|
|
4197
|
+
registry.set(component, definition);
|
|
4198
|
+
}
|
|
4199
|
+
__name(registerSkeleton, "registerSkeleton");
|
|
4200
|
+
|
|
4201
|
+
// src/components/Loader/Loader.types.ts
|
|
4202
|
+
var KUI_COMPONENT_METADATA = /* @__PURE__ */ Symbol("kui.component.metadata");
|
|
4203
|
+
function tagKuiComponent(component, metadata) {
|
|
4204
|
+
component[KUI_COMPONENT_METADATA] = metadata;
|
|
4205
|
+
}
|
|
4206
|
+
__name(tagKuiComponent, "tagKuiComponent");
|
|
4207
|
+
|
|
4208
|
+
// src/components/Loader/defineSkeleton.ts
|
|
4209
|
+
function defineSkeleton(resolve, options) {
|
|
4210
|
+
return { resolve, defaults: options?.defaults };
|
|
4211
|
+
}
|
|
4212
|
+
__name(defineSkeleton, "defineSkeleton");
|
|
4213
|
+
|
|
4214
|
+
// src/components/layout/Card/Card.skeleton.tsx
|
|
4215
|
+
tagKuiComponent(Card, {
|
|
4216
|
+
name: "Card",
|
|
4217
|
+
usesSizeScale: true,
|
|
4218
|
+
slots: ["avatar", "text"]
|
|
4219
|
+
});
|
|
4220
|
+
var cardSkeleton = defineSkeleton(
|
|
4221
|
+
(props) => ({
|
|
4222
|
+
avatar: props.hasImage ? { size: "md", shape: "square" } : false,
|
|
4223
|
+
rows: props.variant === "compact" ? 1 : 3,
|
|
4224
|
+
width: props.fullWidth ? "100%" : props.size === "sm" ? 200 : 320
|
|
4225
|
+
}),
|
|
4226
|
+
{ defaults: { rows: 2, avatar: false, width: 280 } }
|
|
4227
|
+
);
|
|
4228
|
+
registerSkeleton(Card, cardSkeleton);
|
|
3404
4229
|
var InputField = forwardRef(
|
|
3405
4230
|
({
|
|
3406
4231
|
id,
|
|
@@ -3422,7 +4247,7 @@ var InputField = forwardRef(
|
|
|
3422
4247
|
label && /* @__PURE__ */ jsxs(FormField.Label, { className: labelClassName, children: [
|
|
3423
4248
|
labelStart,
|
|
3424
4249
|
label,
|
|
3425
|
-
optional && /* @__PURE__ */ jsx("span", { className: "text-text-muted", children: " (optional)" }),
|
|
4250
|
+
optional && /* @__PURE__ */ jsx("span", { className: "text-kui-text-muted", children: " (optional)" }),
|
|
3426
4251
|
labelEnd
|
|
3427
4252
|
] }),
|
|
3428
4253
|
/* @__PURE__ */ jsx(FormField.Control, { children: /* @__PURE__ */ jsx(
|
|
@@ -3499,7 +4324,7 @@ __name(getTokenValue, "getTokenValue");
|
|
|
3499
4324
|
function resolveReference(reference, tokens, seen = /* @__PURE__ */ new Set()) {
|
|
3500
4325
|
if (seen.has(reference)) {
|
|
3501
4326
|
console.error(
|
|
3502
|
-
`[kreativ-
|
|
4327
|
+
`[kreativ-core] Circular token reference detected: ${reference}`
|
|
3503
4328
|
);
|
|
3504
4329
|
return void 0;
|
|
3505
4330
|
}
|
|
@@ -3508,7 +4333,7 @@ function resolveReference(reference, tokens, seen = /* @__PURE__ */ new Set()) {
|
|
|
3508
4333
|
const value = getTokenValue(reference, tokens);
|
|
3509
4334
|
if (value === void 0) {
|
|
3510
4335
|
console.warn(
|
|
3511
|
-
`[kreativ-
|
|
4336
|
+
`[kreativ-core] Unable to resolve token reference: ${reference}`
|
|
3512
4337
|
);
|
|
3513
4338
|
return void 0;
|
|
3514
4339
|
}
|
|
@@ -3598,20 +4423,20 @@ function resolveTokens(tokens, semanticTokens, mode) {
|
|
|
3598
4423
|
};
|
|
3599
4424
|
}
|
|
3600
4425
|
__name(resolveTokens, "resolveTokens");
|
|
3601
|
-
function tokensToCssVars(tokens, mode, intensity) {
|
|
4426
|
+
function tokensToCssVars(tokens, mode, intensity, prefix = "kui") {
|
|
3602
4427
|
const cssVars = {};
|
|
3603
4428
|
for (const [path, value] of Object.entries(tokens)) {
|
|
3604
4429
|
const parts = path.split(".");
|
|
3605
4430
|
const isSemanticColor = parts.length === 2 && parts[0] === "colors";
|
|
3606
4431
|
const isPrimitiveColor = parts.length >= 3 && parts[0] === "colors";
|
|
3607
|
-
const varName = isSemanticColor ?
|
|
4432
|
+
const varName = isSemanticColor ? `--${prefix}-${toKebabCase(parts[1])}` : `--${prefix}-${parts.map(toKebabCase).join("-")}`;
|
|
3608
4433
|
const outputValue = isSemanticColor || isPrimitiveColor ? colorToRgbChannels(value) : value;
|
|
3609
4434
|
cssVars[varName] = outputValue;
|
|
3610
4435
|
}
|
|
3611
4436
|
return {
|
|
3612
4437
|
...cssVars,
|
|
3613
|
-
|
|
3614
|
-
|
|
4438
|
+
[`--${prefix}-mode`]: mode,
|
|
4439
|
+
[`--${prefix}-intensity`]: String(intensity)
|
|
3615
4440
|
};
|
|
3616
4441
|
}
|
|
3617
4442
|
__name(tokensToCssVars, "tokensToCssVars");
|
|
@@ -3621,8 +4446,6 @@ function defineRecipe(recipe) {
|
|
|
3621
4446
|
return recipe;
|
|
3622
4447
|
}
|
|
3623
4448
|
__name(defineRecipe, "defineRecipe");
|
|
3624
|
-
|
|
3625
|
-
// src/theme/defaults/tokens.ts
|
|
3626
4449
|
var defaultTokens = {
|
|
3627
4450
|
colors: {
|
|
3628
4451
|
blue: {
|
|
@@ -3655,6 +4478,36 @@ var defaultTokens = {
|
|
|
3655
4478
|
500: defineToken("#1791CF"),
|
|
3656
4479
|
600: defineToken("#137BAE")
|
|
3657
4480
|
},
|
|
4481
|
+
indigo: {
|
|
4482
|
+
300: defineToken("#818CF8"),
|
|
4483
|
+
400: defineToken("#6366F1"),
|
|
4484
|
+
500: defineToken("#4F46E5"),
|
|
4485
|
+
600: defineToken("#4338CA")
|
|
4486
|
+
},
|
|
4487
|
+
emerald: {
|
|
4488
|
+
300: defineToken("#6EE7B7"),
|
|
4489
|
+
400: defineToken("#34D399"),
|
|
4490
|
+
500: defineToken("#10B981"),
|
|
4491
|
+
600: defineToken("#059669")
|
|
4492
|
+
},
|
|
4493
|
+
violet: {
|
|
4494
|
+
300: defineToken("#A78BFA"),
|
|
4495
|
+
400: defineToken("#8B5CF6"),
|
|
4496
|
+
500: defineToken("#7C3AED"),
|
|
4497
|
+
600: defineToken("#6D28D9")
|
|
4498
|
+
},
|
|
4499
|
+
rose: {
|
|
4500
|
+
300: defineToken("#FDA4AF"),
|
|
4501
|
+
400: defineToken("#FB7185"),
|
|
4502
|
+
500: defineToken("#F43F5E"),
|
|
4503
|
+
600: defineToken("#E11D48")
|
|
4504
|
+
},
|
|
4505
|
+
orange: {
|
|
4506
|
+
300: defineToken("#FDBA74"),
|
|
4507
|
+
400: defineToken("#FB923C"),
|
|
4508
|
+
500: defineToken("#F97316"),
|
|
4509
|
+
600: defineToken("#EA580C")
|
|
4510
|
+
},
|
|
3658
4511
|
gray: {
|
|
3659
4512
|
50: defineToken("#FAFAFA"),
|
|
3660
4513
|
100: defineToken("#EBEBEB"),
|
|
@@ -3682,7 +4535,12 @@ var defaultTokens = {
|
|
|
3682
4535
|
8: defineToken("2rem"),
|
|
3683
4536
|
10: defineToken("2.5rem"),
|
|
3684
4537
|
12: defineToken("3rem"),
|
|
3685
|
-
16: defineToken("4rem")
|
|
4538
|
+
16: defineToken("4rem"),
|
|
4539
|
+
xs: defineToken("0.25rem"),
|
|
4540
|
+
sm: defineToken("0.5rem"),
|
|
4541
|
+
md: defineToken("1rem"),
|
|
4542
|
+
lg: defineToken("1.5rem"),
|
|
4543
|
+
xl: defineToken("2rem")
|
|
3686
4544
|
},
|
|
3687
4545
|
radii: {
|
|
3688
4546
|
none: defineToken("0"),
|
|
@@ -3725,18 +4583,44 @@ var defaultTokens = {
|
|
|
3725
4583
|
wide: defineToken("0.025em")
|
|
3726
4584
|
},
|
|
3727
4585
|
animations: {
|
|
3728
|
-
|
|
4586
|
+
spin: defineToken("kui-spin 0.6s linear infinite"),
|
|
4587
|
+
"fade-in": defineToken("kui-fade-in 0.15s ease-out"),
|
|
4588
|
+
"fade-out": defineToken("kui-fade-out 0.15s ease-in"),
|
|
4589
|
+
"scale-in": defineToken("kui-scale-in 0.15s ease-out"),
|
|
4590
|
+
"scale-out": defineToken("kui-scale-out 0.15s ease-in"),
|
|
4591
|
+
"slide-up": defineToken("kui-slide-up 0.2s ease-out"),
|
|
4592
|
+
"slide-down": defineToken("kui-slide-down 0.2s ease-out"),
|
|
4593
|
+
"slide-left": defineToken("kui-slide-left 0.2s ease-out"),
|
|
4594
|
+
"slide-right": defineToken("kui-slide-right 0.2s ease-out"),
|
|
4595
|
+
"slide-in-next": defineToken("kui-slide-in-next 0.2s ease-out"),
|
|
4596
|
+
"slide-in-prev": defineToken("kui-slide-in-prev 0.2s ease-out"),
|
|
4597
|
+
bounce: defineToken("kui-bounce 0.8s infinite"),
|
|
4598
|
+
pulse: defineToken("kui-pulse 1.5s ease-in-out infinite"),
|
|
4599
|
+
shake: defineToken("kui-shake 0.25s ease-in-out"),
|
|
4600
|
+
shimmer: defineToken("kui-shimmer 1.5s linear infinite"),
|
|
4601
|
+
expand: defineToken("kui-expand 0.2s ease-out"),
|
|
4602
|
+
collapse: defineToken("kui-collapse 0.2s ease-in"),
|
|
4603
|
+
ping: defineToken("kui-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"),
|
|
4604
|
+
"state-error": defineToken("kui-state-error 500ms ease-out 3 500ms"),
|
|
4605
|
+
"state-success": defineToken("kui-state-success 500ms ease-out 2 500ms"),
|
|
4606
|
+
"state-warning": defineToken("kui-state-warning 500ms ease-out 2 500ms")
|
|
4607
|
+
},
|
|
4608
|
+
breakpoints: {
|
|
4609
|
+
sm: defineToken("640px"),
|
|
4610
|
+
md: defineToken("768px"),
|
|
4611
|
+
lg: defineToken("1024px"),
|
|
4612
|
+
xl: defineToken("1280px"),
|
|
4613
|
+
"2xl": defineToken("1536px")
|
|
3729
4614
|
}
|
|
3730
4615
|
};
|
|
3731
|
-
|
|
3732
|
-
// src/theme/defaults/semanticTokens.ts
|
|
3733
4616
|
var defaultSemanticTokens = {
|
|
3734
4617
|
colors: {
|
|
3735
4618
|
brand: defineSemanticToken("{colors.blue.500}", "{colors.blue.400}"),
|
|
3736
4619
|
brandHover: defineSemanticToken("{colors.blue.600}", "{colors.blue.300}"),
|
|
3737
|
-
brandFg:
|
|
3738
|
-
|
|
3739
|
-
|
|
4620
|
+
brandFg: defineSemanticToken("{colors.white}"),
|
|
4621
|
+
background: defineSemanticToken("{colors.gray.50}", "{colors.gray.950}"),
|
|
4622
|
+
surface: defineSemanticToken("{colors.white}", "{colors.gray.900}"),
|
|
4623
|
+
surfaceRaised: defineSemanticToken("{colors.gray.50}", "{colors.gray.800}"),
|
|
3740
4624
|
surfaceSunken: defineSemanticToken(
|
|
3741
4625
|
"{colors.gray.100}",
|
|
3742
4626
|
"{colors.gray.950}"
|
|
@@ -3745,53 +4629,29 @@ var defaultSemanticTokens = {
|
|
|
3745
4629
|
text: defineSemanticToken("{colors.gray.900}", "{colors.gray.50}"),
|
|
3746
4630
|
textMuted: defineSemanticToken("{colors.gray.500}", "{colors.gray.400}"),
|
|
3747
4631
|
destructive: defineSemanticToken("{colors.red.500}", "{colors.red.400}"),
|
|
3748
|
-
destructiveFg:
|
|
4632
|
+
destructiveFg: defineSemanticToken("{colors.white}"),
|
|
3749
4633
|
destructiveHover: defineSemanticToken(
|
|
3750
4634
|
"{colors.red.600}",
|
|
3751
4635
|
"{colors.red.300}"
|
|
3752
4636
|
),
|
|
3753
4637
|
success: defineSemanticToken("{colors.green.500}", "{colors.green.400}"),
|
|
3754
|
-
successFg:
|
|
4638
|
+
successFg: defineSemanticToken("{colors.white}"),
|
|
3755
4639
|
successHover: defineSemanticToken(
|
|
3756
4640
|
"{colors.green.600}",
|
|
3757
4641
|
"{colors.green.300}"
|
|
3758
4642
|
),
|
|
3759
4643
|
warning: defineSemanticToken("{colors.amber.500}", "{colors.amber.400}"),
|
|
3760
|
-
warningFg:
|
|
4644
|
+
warningFg: defineSemanticToken("{colors.black}"),
|
|
3761
4645
|
warningHover: defineSemanticToken(
|
|
3762
4646
|
"{colors.amber.600}",
|
|
3763
4647
|
"{colors.amber.300}"
|
|
3764
4648
|
),
|
|
3765
|
-
info: defineSemanticToken("{colors.cyan.500}", "{colors.cyan.400}"),
|
|
3766
|
-
infoFg:
|
|
3767
|
-
infoHover: defineSemanticToken("{colors.cyan.600}", "{colors.cyan.300}")
|
|
3768
|
-
|
|
3769
|
-
}
|
|
3770
|
-
|
|
3771
|
-
// src/theme/typography/defineTypography.ts
|
|
3772
|
-
function defineTypography(typography) {
|
|
3773
|
-
return typography;
|
|
3774
|
-
}
|
|
3775
|
-
__name(defineTypography, "defineTypography");
|
|
3776
|
-
|
|
3777
|
-
// src/theme/typography/extendTypography.ts
|
|
3778
|
-
function extendTypography(override) {
|
|
3779
|
-
if (!override) {
|
|
3780
|
-
return { ...defaultTypography };
|
|
3781
|
-
}
|
|
3782
|
-
const result = { ...defaultTypography };
|
|
3783
|
-
for (const key of Object.keys(override)) {
|
|
3784
|
-
const variant = key;
|
|
3785
|
-
result[variant] = {
|
|
3786
|
-
...defaultTypography[variant],
|
|
3787
|
-
...override[variant]
|
|
3788
|
-
};
|
|
3789
|
-
}
|
|
3790
|
-
return result;
|
|
3791
|
-
}
|
|
3792
|
-
__name(extendTypography, "extendTypography");
|
|
3793
|
-
|
|
3794
|
-
// src/theme/defaults/typography.ts
|
|
4649
|
+
info: defineSemanticToken("{colors.cyan.500}", "{colors.cyan.400}"),
|
|
4650
|
+
infoFg: defineSemanticToken("{colors.white}"),
|
|
4651
|
+
infoHover: defineSemanticToken("{colors.cyan.600}", "{colors.cyan.300}"),
|
|
4652
|
+
shadowColor: defineSemanticToken("{colors.gray.200}", "{colors.gray.600}")
|
|
4653
|
+
}
|
|
4654
|
+
};
|
|
3795
4655
|
var defaultTypography = defineTypography({
|
|
3796
4656
|
body: {
|
|
3797
4657
|
fontFamily: "{fonts.body}",
|
|
@@ -3831,53 +4691,133 @@ var defaultTypography = defineTypography({
|
|
|
3831
4691
|
fontSize: "{fontSizes.xs}",
|
|
3832
4692
|
fontWeight: "{fontWeights.normal}",
|
|
3833
4693
|
lineHeight: "{lineHeights.normal}"
|
|
4694
|
+
},
|
|
4695
|
+
sizeXs: {
|
|
4696
|
+
fontFamily: "{fonts.body}",
|
|
4697
|
+
fontSize: "{fontSizes.xs}",
|
|
4698
|
+
fontWeight: "{fontWeights.normal}",
|
|
4699
|
+
lineHeight: "{lineHeights.normal}"
|
|
4700
|
+
},
|
|
4701
|
+
sizeSm: {
|
|
4702
|
+
fontFamily: "{fonts.body}",
|
|
4703
|
+
fontSize: "{fontSizes.sm}",
|
|
4704
|
+
fontWeight: "{fontWeights.normal}",
|
|
4705
|
+
lineHeight: "{lineHeights.normal}"
|
|
4706
|
+
},
|
|
4707
|
+
sizeMd: {
|
|
4708
|
+
fontFamily: "{fonts.body}",
|
|
4709
|
+
fontSize: "{fontSizes.sm}",
|
|
4710
|
+
fontWeight: "{fontWeights.normal}",
|
|
4711
|
+
lineHeight: "{lineHeights.normal}"
|
|
4712
|
+
},
|
|
4713
|
+
sizeLg: {
|
|
4714
|
+
fontFamily: "{fonts.body}",
|
|
4715
|
+
fontSize: "{fontSizes.md}",
|
|
4716
|
+
fontWeight: "{fontWeights.normal}",
|
|
4717
|
+
lineHeight: "{lineHeights.normal}"
|
|
4718
|
+
},
|
|
4719
|
+
sizeXl: {
|
|
4720
|
+
fontFamily: "{fonts.body}",
|
|
4721
|
+
fontSize: "{fontSizes.xl}",
|
|
4722
|
+
fontWeight: "{fontWeights.medium}",
|
|
4723
|
+
lineHeight: "{lineHeights.tight}"
|
|
3834
4724
|
}
|
|
3835
4725
|
});
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
4726
|
+
var defaultSizes = defineSizes({
|
|
4727
|
+
xs: {
|
|
4728
|
+
height: "1.75rem",
|
|
4729
|
+
width: "1.75rem",
|
|
4730
|
+
paddingX: "0.5rem",
|
|
4731
|
+
fontSize: "{typography.sizeXs}",
|
|
4732
|
+
gap: "0.25rem",
|
|
4733
|
+
iconSize: "0.75rem",
|
|
4734
|
+
radius: "0.65rem",
|
|
4735
|
+
separatorSize: "15px"
|
|
4736
|
+
},
|
|
4737
|
+
sm: {
|
|
4738
|
+
height: "2rem",
|
|
4739
|
+
width: "2rem",
|
|
4740
|
+
paddingX: "0.75rem",
|
|
4741
|
+
fontSize: "{typography.sizeSm}",
|
|
4742
|
+
gap: "0.375rem",
|
|
4743
|
+
iconSize: "0.875rem",
|
|
4744
|
+
radius: "0.8rem",
|
|
4745
|
+
separatorSize: "20px"
|
|
4746
|
+
},
|
|
4747
|
+
md: {
|
|
4748
|
+
height: "2.5rem",
|
|
4749
|
+
width: "2.5rem",
|
|
4750
|
+
paddingX: "1rem",
|
|
4751
|
+
fontSize: "{typography.sizeMd}",
|
|
4752
|
+
gap: "0.5rem",
|
|
4753
|
+
iconSize: "1rem",
|
|
4754
|
+
radius: "1rem",
|
|
4755
|
+
separatorSize: "25px"
|
|
4756
|
+
},
|
|
4757
|
+
lg: {
|
|
4758
|
+
height: "3rem",
|
|
4759
|
+
width: "3rem",
|
|
4760
|
+
paddingX: "1.25rem",
|
|
4761
|
+
fontSize: "{typography.sizeLg}",
|
|
4762
|
+
gap: "0.625rem",
|
|
4763
|
+
iconSize: "1.25rem",
|
|
4764
|
+
radius: "1.15rem",
|
|
4765
|
+
separatorSize: "30px"
|
|
4766
|
+
},
|
|
4767
|
+
xl: {
|
|
4768
|
+
height: "3.5rem",
|
|
4769
|
+
width: "3.5rem",
|
|
4770
|
+
paddingX: "1.5rem",
|
|
4771
|
+
fontSize: "{typography.sizeXl}",
|
|
4772
|
+
gap: "0.875rem",
|
|
4773
|
+
iconSize: "1.5rem",
|
|
4774
|
+
radius: "1.3rem",
|
|
4775
|
+
separatorSize: "35px"
|
|
4776
|
+
}
|
|
4777
|
+
});
|
|
4778
|
+
var buttonBase = "inline-flex items-center justify-center rounded-[var(--kui-button-radius,var(--kui-radius))] font-medium transition-[background-color,border-color,color,transform,opacity] duration-200 will-change-transform focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kui-brand focus-visible:ring-offset-2 focus-visible:ring-offset-surface disabled:opacity-60 disabled:pointer-events-none disabled:active:scale-100";
|
|
3839
4779
|
var buttonVariants = {
|
|
3840
|
-
solid: "",
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
link: "bg-transparent p-0 h-auto hover:underline"
|
|
4780
|
+
solid: "ease-[cubic-bezier(0.34,1.56,0.64,1)] active:scale-[0.97]",
|
|
4781
|
+
soft: "ease-[cubic-bezier(0.34,1.56,0.64,1)] active:scale-[0.97]",
|
|
4782
|
+
outline: "border bg-transparent ease-out active:scale-[0.98]",
|
|
4783
|
+
ghost: "bg-transparent ease-out active:scale-[0.98]",
|
|
4784
|
+
link: "bg-transparent p-0 h-auto hover:underline ease-out"
|
|
3845
4785
|
};
|
|
3846
4786
|
var buttonColors = {
|
|
3847
4787
|
brand: {
|
|
3848
|
-
solid: "bg-brand text-brand-fg hover:bg-brand-hover",
|
|
3849
|
-
outline: "border-brand text-brand hover:bg-brand/10",
|
|
3850
|
-
ghost: "text-brand hover:bg-brand/10",
|
|
3851
|
-
soft: "bg-brand/10 text-brand hover:bg-brand/20",
|
|
3852
|
-
link: "text-brand"
|
|
4788
|
+
solid: "bg-kui-brand text-kui-brand-fg hover:bg-kui-brand-hover",
|
|
4789
|
+
outline: "border-kui-brand text-kui-brand hover:bg-kui-brand/10",
|
|
4790
|
+
ghost: "text-kui-brand hover:bg-kui-brand/10",
|
|
4791
|
+
soft: "bg-kui-brand/10 text-kui-brand hover:bg-kui-brand/20",
|
|
4792
|
+
link: "text-kui-brand"
|
|
3853
4793
|
},
|
|
3854
4794
|
destructive: {
|
|
3855
|
-
solid: "bg-destructive text-destructive-fg hover:bg-destructive-hover",
|
|
3856
|
-
outline: "border-destructive text-destructive hover:bg-destructive/10",
|
|
3857
|
-
ghost: "text-destructive hover:bg-destructive/10",
|
|
3858
|
-
soft: "bg-destructive/10 text-destructive hover:bg-destructive/20",
|
|
3859
|
-
link: "text-destructive"
|
|
4795
|
+
solid: "bg-kui-destructive text-kui-destructive-fg hover:bg-kui-destructive-hover",
|
|
4796
|
+
outline: "border-kui-destructive text-kui-destructive hover:bg-kui-destructive/10",
|
|
4797
|
+
ghost: "text-kui-destructive hover:bg-kui-destructive/10",
|
|
4798
|
+
soft: "bg-kui-destructive/10 text-kui-destructive hover:bg-kui-destructive/20",
|
|
4799
|
+
link: "text-kui-destructive"
|
|
3860
4800
|
},
|
|
3861
4801
|
success: {
|
|
3862
|
-
solid: "bg-success text-success-fg hover:bg-success-hover",
|
|
3863
|
-
outline: "border-success text-success hover:bg-success/10",
|
|
3864
|
-
ghost: "text-success hover:bg-success/10",
|
|
3865
|
-
soft: "bg-success/10 text-success hover:bg-success/20",
|
|
3866
|
-
link: "text-success"
|
|
4802
|
+
solid: "bg-kui-success text-kui-success-fg hover:bg-kui-success-hover",
|
|
4803
|
+
outline: "border-kui-success text-kui-success hover:bg-kui-success/10",
|
|
4804
|
+
ghost: "text-kui-success hover:bg-kui-success/10",
|
|
4805
|
+
soft: "bg-kui-success/10 text-kui-success hover:bg-kui-success/20",
|
|
4806
|
+
link: "text-kui-success"
|
|
3867
4807
|
},
|
|
3868
4808
|
warning: {
|
|
3869
|
-
solid: "bg-warning text-warning-fg hover:bg-warning-hover",
|
|
3870
|
-
outline: "border-warning text-warning hover:bg-warning/10",
|
|
3871
|
-
ghost: "text-warning hover:bg-warning/10",
|
|
3872
|
-
soft: "bg-warning/10 text-warning hover:bg-warning/20",
|
|
3873
|
-
link: "text-warning"
|
|
4809
|
+
solid: "bg-kui-warning text-kui-warning-fg hover:bg-kui-warning-hover",
|
|
4810
|
+
outline: "border-kui-warning text-kui-warning hover:bg-kui-warning/10",
|
|
4811
|
+
ghost: "text-kui-warning hover:bg-kui-warning/10",
|
|
4812
|
+
soft: "bg-kui-warning/10 text-kui-warning hover:bg-kui-warning/20",
|
|
4813
|
+
link: "text-kui-warning"
|
|
3874
4814
|
},
|
|
3875
4815
|
info: {
|
|
3876
|
-
solid: "bg-info text-info-fg hover:bg-info-hover",
|
|
3877
|
-
outline: "border-info text-info hover:bg-info/10",
|
|
3878
|
-
ghost: "text-info hover:bg-info/10",
|
|
3879
|
-
soft: "bg-info/10 text-info hover:bg-info/20",
|
|
3880
|
-
link: "text-info"
|
|
4816
|
+
solid: "bg-kui-info text-kui-info-fg hover:bg-kui-info-hover",
|
|
4817
|
+
outline: "border-kui-info text-kui-info hover:bg-kui-info/10",
|
|
4818
|
+
ghost: "text-kui-info hover:bg-kui-info/10",
|
|
4819
|
+
soft: "bg-kui-info/10 text-kui-info hover:bg-kui-info/20",
|
|
4820
|
+
link: "text-kui-info"
|
|
3881
4821
|
},
|
|
3882
4822
|
white: {
|
|
3883
4823
|
solid: "bg-white text-black hover:bg-gray-50",
|
|
@@ -3887,11 +4827,18 @@ var buttonColors = {
|
|
|
3887
4827
|
link: "text-white"
|
|
3888
4828
|
},
|
|
3889
4829
|
neutral: {
|
|
3890
|
-
solid: "bg-surface-raised text-text hover:bg-surface-sunken",
|
|
3891
|
-
outline: "border-border text-text hover:bg-surface-raised",
|
|
3892
|
-
ghost: "text-text hover:bg-surface-raised",
|
|
3893
|
-
soft: "bg-surface-raised text-text hover:bg-surface-sunken",
|
|
3894
|
-
link: "text-text"
|
|
4830
|
+
solid: "bg-kui-surface-raised text-kui-text hover:bg-kui-surface-sunken",
|
|
4831
|
+
outline: "border-kui-border text-kui-text hover:bg-kui-surface-raised",
|
|
4832
|
+
ghost: "text-kui-text hover:bg-kui-surface-raised",
|
|
4833
|
+
soft: "bg-kui-surface-raised text-kui-text hover:bg-kui-surface-sunken",
|
|
4834
|
+
link: "text-kui-text"
|
|
4835
|
+
},
|
|
4836
|
+
inherit: {
|
|
4837
|
+
solid: "[background-color:var(--kui-inherit-bg)] [color:var(--kui-inherit-fg)]",
|
|
4838
|
+
outline: "[border-color:var(--kui-inherit-border)] [color:var(--kui-inherit-fg)] bg-transparent",
|
|
4839
|
+
ghost: "[color:var(--kui-inherit-fg)] bg-transparent",
|
|
4840
|
+
soft: "[background-color:var(--kui-inherit-soft-bg)] [color:var(--kui-inherit-fg)]",
|
|
4841
|
+
link: "[color:var(--kui-inherit-fg)] bg-transparent"
|
|
3895
4842
|
}
|
|
3896
4843
|
};
|
|
3897
4844
|
var buildCompoundVariants = /* @__PURE__ */ __name(() => {
|
|
@@ -3906,7 +4853,7 @@ var buildCompoundVariants = /* @__PURE__ */ __name(() => {
|
|
|
3906
4853
|
}
|
|
3907
4854
|
return compounds;
|
|
3908
4855
|
}, "buildCompoundVariants");
|
|
3909
|
-
var buttonRecipe = defineRecipe({
|
|
4856
|
+
var buttonRecipe = defineRecipe$1({
|
|
3910
4857
|
base: buttonBase,
|
|
3911
4858
|
variants: {
|
|
3912
4859
|
variant: buttonVariants,
|
|
@@ -3920,26 +4867,29 @@ var buttonRecipe = defineRecipe({
|
|
|
3920
4867
|
},
|
|
3921
4868
|
compoundVariants: buildCompoundVariants()
|
|
3922
4869
|
});
|
|
3923
|
-
|
|
3924
|
-
// src/theme/defaults/recipes/formControl.ts
|
|
3925
4870
|
var formControlBase = "group relative inline-flex items-center rounded-[var(--kui-radii-md)] transition-[border-color,box-shadow] duration-[var(--kui-duration-fast)] focus-within:outline-none focus-within:ring-offset-2 focus-within:ring-offset-surface";
|
|
3926
4871
|
var formControlVariants = {
|
|
3927
|
-
outline: "border border-border bg-transparent text-text",
|
|
3928
|
-
filled: "border border-transparent bg-surface-raised text-text",
|
|
3929
|
-
ghost: "border border-transparent bg-transparent text-text"
|
|
4872
|
+
outline: "border border-kui-border bg-transparent text-kui-text",
|
|
4873
|
+
filled: "border border-transparent bg-kui-surface-raised text-kui-text",
|
|
4874
|
+
ghost: "border border-transparent bg-transparent text-kui-text"
|
|
3930
4875
|
};
|
|
3931
4876
|
var standaloneStates = {
|
|
3932
|
-
none: "hover:border-brand focus-within:ring-2 focus-within:ring-brand/20",
|
|
3933
|
-
error: "border-destructive hover:border-destructive focus-within:ring-2 focus-within:ring-destructive/20",
|
|
3934
|
-
success: "border-success hover:border-success focus-within:ring-2 focus-within:ring-success/20",
|
|
3935
|
-
warning: "border-warning hover:border-warning focus-within:ring-2 focus-within:ring-warning/20"
|
|
4877
|
+
none: "hover:border-kui-brand focus-within:ring-2 focus-within:ring-kui-brand/20",
|
|
4878
|
+
error: "border-kui-destructive hover:border-kui-destructive focus-within:ring-2 focus-within:ring-kui-destructive/20",
|
|
4879
|
+
success: "border-kui-success hover:border-kui-success focus-within:ring-2 focus-within:ring-kui-success/20",
|
|
4880
|
+
warning: "border-kui-warning hover:border-kui-warning focus-within:ring-2 focus-within:ring-kui-warning/20"
|
|
3936
4881
|
};
|
|
3937
|
-
var
|
|
4882
|
+
var borderlessControl = "rounded-none border-0! shadow-none! hover:border-0! hover:bg-transparent! focus-within:ring-0! focus-within:ring-offset-0! focus-within-outline-none!";
|
|
4883
|
+
var formControlRecipe = defineRecipe$1({
|
|
3938
4884
|
base: formControlBase,
|
|
3939
4885
|
variants: {
|
|
3940
4886
|
variant: formControlVariants,
|
|
3941
4887
|
embedded: {
|
|
3942
|
-
true:
|
|
4888
|
+
true: borderlessControl,
|
|
4889
|
+
false: ""
|
|
4890
|
+
},
|
|
4891
|
+
groupItem: {
|
|
4892
|
+
true: borderlessControl,
|
|
3943
4893
|
false: ""
|
|
3944
4894
|
},
|
|
3945
4895
|
state: standaloneStates,
|
|
@@ -3952,7 +4902,11 @@ var formControlRecipe = defineRecipe({
|
|
|
3952
4902
|
false: ""
|
|
3953
4903
|
},
|
|
3954
4904
|
disabled: {
|
|
3955
|
-
true: "cursor-not-allowed opacity-50 border-border hover:border-border focus-within:ring-0",
|
|
4905
|
+
true: "cursor-not-allowed opacity-50 border-kui-border hover:border-kui-border focus-within:ring-0",
|
|
4906
|
+
false: ""
|
|
4907
|
+
},
|
|
4908
|
+
attached: {
|
|
4909
|
+
true: "rounded-r-none",
|
|
3956
4910
|
false: ""
|
|
3957
4911
|
},
|
|
3958
4912
|
hasAdornment: {
|
|
@@ -3962,19 +4916,59 @@ var formControlRecipe = defineRecipe({
|
|
|
3962
4916
|
},
|
|
3963
4917
|
compoundVariants: [
|
|
3964
4918
|
{
|
|
3965
|
-
conditions: {
|
|
4919
|
+
conditions: {
|
|
4920
|
+
embedded: true,
|
|
4921
|
+
state: "none"
|
|
4922
|
+
},
|
|
4923
|
+
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
4924
|
+
},
|
|
4925
|
+
{
|
|
4926
|
+
conditions: {
|
|
4927
|
+
embedded: true,
|
|
4928
|
+
state: "error"
|
|
4929
|
+
},
|
|
4930
|
+
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
4931
|
+
},
|
|
4932
|
+
{
|
|
4933
|
+
conditions: {
|
|
4934
|
+
embedded: true,
|
|
4935
|
+
state: "success"
|
|
4936
|
+
},
|
|
4937
|
+
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
4938
|
+
},
|
|
4939
|
+
{
|
|
4940
|
+
conditions: {
|
|
4941
|
+
embedded: true,
|
|
4942
|
+
state: "warning"
|
|
4943
|
+
},
|
|
4944
|
+
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
4945
|
+
},
|
|
4946
|
+
{
|
|
4947
|
+
conditions: {
|
|
4948
|
+
groupItem: true,
|
|
4949
|
+
state: "none"
|
|
4950
|
+
},
|
|
3966
4951
|
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
3967
4952
|
},
|
|
3968
4953
|
{
|
|
3969
|
-
conditions: {
|
|
4954
|
+
conditions: {
|
|
4955
|
+
groupItem: true,
|
|
4956
|
+
state: "error"
|
|
4957
|
+
},
|
|
3970
4958
|
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
3971
4959
|
},
|
|
3972
4960
|
{
|
|
3973
|
-
conditions: {
|
|
4961
|
+
conditions: {
|
|
4962
|
+
groupItem: true,
|
|
4963
|
+
state: "success"
|
|
4964
|
+
},
|
|
3974
4965
|
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
3975
4966
|
},
|
|
3976
4967
|
{
|
|
3977
|
-
conditions: {
|
|
4968
|
+
conditions: {
|
|
4969
|
+
groupItem: true,
|
|
4970
|
+
state: "warning"
|
|
4971
|
+
},
|
|
3978
4972
|
className: "border-0! shadow-none! focus-within:ring-0! hover:border-0!"
|
|
3979
4973
|
},
|
|
3980
4974
|
{
|
|
@@ -3982,21 +4976,21 @@ var formControlRecipe = defineRecipe({
|
|
|
3982
4976
|
disabled: true,
|
|
3983
4977
|
state: "error"
|
|
3984
4978
|
},
|
|
3985
|
-
className: "border-border hover:border-border focus-within:ring-0"
|
|
4979
|
+
className: "border-kui-border hover:border-kui-border focus-within:ring-0"
|
|
3986
4980
|
},
|
|
3987
4981
|
{
|
|
3988
4982
|
conditions: {
|
|
3989
4983
|
disabled: true,
|
|
3990
4984
|
state: "success"
|
|
3991
4985
|
},
|
|
3992
|
-
className: "border-border hover:border-border focus-within:ring-0"
|
|
4986
|
+
className: "border-kui-border hover:border-kui-border focus-within:ring-0"
|
|
3993
4987
|
},
|
|
3994
4988
|
{
|
|
3995
4989
|
conditions: {
|
|
3996
4990
|
disabled: true,
|
|
3997
4991
|
state: "warning"
|
|
3998
4992
|
},
|
|
3999
|
-
className: "border-border hover:border-border focus-within:ring-0"
|
|
4993
|
+
className: "border-kui-border hover:border-kui-border focus-within:ring-0"
|
|
4000
4994
|
},
|
|
4001
4995
|
{
|
|
4002
4996
|
conditions: {
|
|
@@ -4004,22 +4998,29 @@ var formControlRecipe = defineRecipe({
|
|
|
4004
4998
|
disabled: true
|
|
4005
4999
|
},
|
|
4006
5000
|
className: "border-0! hover:border-0! focus-within:ring-0! cursor-default"
|
|
5001
|
+
},
|
|
5002
|
+
{
|
|
5003
|
+
conditions: {
|
|
5004
|
+
groupItem: true,
|
|
5005
|
+
disabled: true
|
|
5006
|
+
},
|
|
5007
|
+
className: "border-0! hover:border-0! focus-within:ring-0! cursor-default"
|
|
4007
5008
|
}
|
|
4008
5009
|
],
|
|
4009
5010
|
defaultVariants: {
|
|
4010
5011
|
variant: "outline",
|
|
4011
5012
|
state: "none",
|
|
4012
5013
|
embedded: false,
|
|
5014
|
+
groupItem: false,
|
|
4013
5015
|
rounded: false,
|
|
4014
5016
|
fullWidth: true,
|
|
4015
5017
|
disabled: false,
|
|
4016
|
-
hasAdornment: false
|
|
5018
|
+
hasAdornment: false,
|
|
5019
|
+
attached: false
|
|
4017
5020
|
}
|
|
4018
5021
|
});
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
var inputBase2 = "flex min-w-0 flex-1 font-sans bg-transparent border-0 outline-none transition-colors duration-[var(--kui-duration-fast)] placeholder:text-text-muted disabled:cursor-not-allowed";
|
|
4022
|
-
var inputRecipe = defineRecipe({
|
|
5022
|
+
var inputBase2 = "flex min-w-0 flex-1 font-sans bg-transparent border-0 outline-none transition-colors duration-[var(--kui-duration-fast)] placeholder:text-kui-text-muted disabled:cursor-not-allowed";
|
|
5023
|
+
var inputRecipe = defineRecipe$1({
|
|
4023
5024
|
base: inputBase2,
|
|
4024
5025
|
variants: {
|
|
4025
5026
|
variant: {
|
|
@@ -4032,10 +5033,8 @@ var inputRecipe = defineRecipe({
|
|
|
4032
5033
|
variant: "outline"
|
|
4033
5034
|
}
|
|
4034
5035
|
});
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
var textareaRecipe = defineRecipe({
|
|
4038
|
-
base: "flex w-full min-w-0 bg-transparent outline-none border-0 text-text placeholder:text-text-muted transition-colors duration-[var(--kui-duration-fast)] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 kui-scrollbar",
|
|
5036
|
+
var textareaRecipe = defineRecipe$1({
|
|
5037
|
+
base: "flex w-full min-w-0 bg-transparent outline-none border-0 text-kui-text placeholder:text-kui-text-muted transition-colors duration-[var(--kui-duration-fast)] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 kui-scrollbar",
|
|
4039
5038
|
variants: {
|
|
4040
5039
|
variant: {
|
|
4041
5040
|
outline: "",
|
|
@@ -4059,24 +5058,22 @@ var textareaRecipe = defineRecipe({
|
|
|
4059
5058
|
autoResize: false
|
|
4060
5059
|
}
|
|
4061
5060
|
});
|
|
4062
|
-
|
|
4063
|
-
// src/theme/defaults/recipes/markdownEditor.ts
|
|
4064
|
-
var markdownEditorRecipe = defineRecipe({
|
|
5061
|
+
var markdownEditorRecipe = defineRecipe$1({
|
|
4065
5062
|
base: "group relative w-full overflow-hidden rounded-[var(--kui-radii-md)] transition-[border-color,box-shadow] duration-[var(--kui-duration-fast)]",
|
|
4066
5063
|
variants: {
|
|
4067
5064
|
variant: {
|
|
4068
|
-
outline: "border border-border bg-transparent",
|
|
4069
|
-
filled: "border border-transparent bg-surface-raised",
|
|
5065
|
+
outline: "border border-kui-border bg-transparent",
|
|
5066
|
+
filled: "border border-transparent bg-kui-surface-raised",
|
|
4070
5067
|
ghost: "border border-transparent bg-transparent"
|
|
4071
5068
|
},
|
|
4072
5069
|
state: {
|
|
4073
|
-
none: "hover:border-brand focus-within:ring-2 focus-within:ring-brand/20",
|
|
4074
|
-
error: "border-destructive focus-within:ring-2 focus-within:ring-destructive/20",
|
|
4075
|
-
success: "border-success focus-within:ring-2 focus-within:ring-success/20",
|
|
4076
|
-
warning: "border-warning focus-within:ring-2 focus-within:ring-warning/20"
|
|
5070
|
+
none: "hover:border-kui-brand focus-within:ring-2 focus-within:ring-kui-brand/20",
|
|
5071
|
+
error: "border-kui-destructive focus-within:ring-2 focus-within:ring-kui-destructive/20",
|
|
5072
|
+
success: "border-kui-success focus-within:ring-2 focus-within:ring-kui-success/20",
|
|
5073
|
+
warning: "border-kui-warning focus-within:ring-2 focus-within:ring-kui-warning/20"
|
|
4077
5074
|
},
|
|
4078
5075
|
disabled: {
|
|
4079
|
-
true: "cursor-not-allowed opacity-50 border-border hover:border-border focus-within:ring-0",
|
|
5076
|
+
true: "cursor-not-allowed opacity-50 border-kui-border hover:border-kui-border focus-within:ring-0",
|
|
4080
5077
|
false: ""
|
|
4081
5078
|
},
|
|
4082
5079
|
fullWidth: {
|
|
@@ -4090,61 +5087,17 @@ var markdownEditorRecipe = defineRecipe({
|
|
|
4090
5087
|
fullWidth: true
|
|
4091
5088
|
}
|
|
4092
5089
|
});
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
function defineSizes(sizes) {
|
|
4096
|
-
return sizes;
|
|
4097
|
-
}
|
|
4098
|
-
__name(defineSizes, "defineSizes");
|
|
4099
|
-
|
|
4100
|
-
// src/theme/defaults/sizes.ts
|
|
4101
|
-
var defaultSizes = defineSizes({
|
|
4102
|
-
xs: {
|
|
4103
|
-
height: "1.75rem",
|
|
4104
|
-
paddingX: "0.5rem",
|
|
4105
|
-
fontSize: "0.75rem",
|
|
4106
|
-
gap: "0.25rem",
|
|
4107
|
-
iconSize: "0.875rem",
|
|
4108
|
-
radius: "0.65rem"
|
|
4109
|
-
},
|
|
4110
|
-
sm: {
|
|
4111
|
-
height: "2rem",
|
|
4112
|
-
paddingX: "0.75rem",
|
|
4113
|
-
fontSize: "0.8125rem",
|
|
4114
|
-
gap: "0.375rem",
|
|
4115
|
-
iconSize: "1rem",
|
|
4116
|
-
radius: "0.8rem"
|
|
4117
|
-
},
|
|
4118
|
-
md: {
|
|
4119
|
-
height: "2.5rem",
|
|
4120
|
-
paddingX: "1rem",
|
|
4121
|
-
fontSize: "0.875rem",
|
|
4122
|
-
gap: "0.5rem",
|
|
4123
|
-
iconSize: "1.125rem",
|
|
4124
|
-
radius: "1rem"
|
|
4125
|
-
},
|
|
4126
|
-
lg: {
|
|
4127
|
-
height: "3.5rem",
|
|
4128
|
-
paddingX: "1.5rem",
|
|
4129
|
-
fontSize: "1rem",
|
|
4130
|
-
gap: "0.625rem",
|
|
4131
|
-
iconSize: "1.25rem",
|
|
4132
|
-
radius: "1.15rem"
|
|
4133
|
-
}
|
|
4134
|
-
});
|
|
4135
|
-
|
|
4136
|
-
// src/theme/defaults/recipes/checkbox.ts
|
|
4137
|
-
var checkboxRecipe = defineRecipe({
|
|
4138
|
-
base: "relative inline-flex shrink-0 items-center justify-center border transition-colors duration-[var(--kui-duration-fast)] peer-focus-visible:ring-2 peer-focus-visible:ring-brand peer-focus-visible:ring-offset-1",
|
|
5090
|
+
var checkboxRecipe = defineRecipe$1({
|
|
5091
|
+
base: "relative inline-flex shrink-0 items-center justify-center border transition-colors duration-[var(--kui-duration-fast)] peer-focus-visible:ring-2 peer-focus-visible:ring-kui-brand peer-focus-visible:ring-offset-1",
|
|
4139
5092
|
variants: {
|
|
4140
5093
|
state: {
|
|
4141
|
-
none: "border-border",
|
|
4142
|
-
error: "border-destructive",
|
|
4143
|
-
success: "border-success",
|
|
4144
|
-
warning: "border-warning"
|
|
5094
|
+
none: "border-kui-border",
|
|
5095
|
+
error: "border-kui-destructive",
|
|
5096
|
+
success: "border-kui-success",
|
|
5097
|
+
warning: "border-kui-warning"
|
|
4145
5098
|
},
|
|
4146
5099
|
checked: {
|
|
4147
|
-
true: "border-brand bg-brand text-brand-fg",
|
|
5100
|
+
true: "border-kui-brand bg-kui-brand text-kui-brand-fg",
|
|
4148
5101
|
false: "bg-transparent"
|
|
4149
5102
|
},
|
|
4150
5103
|
disabled: {
|
|
@@ -4162,21 +5115,21 @@ var checkboxRecipe = defineRecipe({
|
|
|
4162
5115
|
checked: false,
|
|
4163
5116
|
state: "error"
|
|
4164
5117
|
},
|
|
4165
|
-
className: "border-destructive"
|
|
5118
|
+
className: "border-kui-destructive"
|
|
4166
5119
|
},
|
|
4167
5120
|
{
|
|
4168
5121
|
conditions: {
|
|
4169
5122
|
checked: false,
|
|
4170
5123
|
state: "success"
|
|
4171
5124
|
},
|
|
4172
|
-
className: "border-success"
|
|
5125
|
+
className: "border-kui-success"
|
|
4173
5126
|
},
|
|
4174
5127
|
{
|
|
4175
5128
|
conditions: {
|
|
4176
5129
|
checked: false,
|
|
4177
5130
|
state: "warning"
|
|
4178
5131
|
},
|
|
4179
|
-
className: "border-warning"
|
|
5132
|
+
className: "border-kui-warning"
|
|
4180
5133
|
}
|
|
4181
5134
|
],
|
|
4182
5135
|
defaultVariants: {
|
|
@@ -4186,95 +5139,269 @@ var checkboxRecipe = defineRecipe({
|
|
|
4186
5139
|
rounded: false
|
|
4187
5140
|
}
|
|
4188
5141
|
});
|
|
4189
|
-
|
|
4190
|
-
|
|
5142
|
+
var buttonGroupRecipe = defineRecipe$1({
|
|
5143
|
+
base: ["inline-flex items-center relative isolate", "kui-button-group"].join(
|
|
5144
|
+
" "
|
|
5145
|
+
),
|
|
5146
|
+
variants: {
|
|
5147
|
+
orientation: {
|
|
5148
|
+
horizontal: "flex-row",
|
|
5149
|
+
vertical: "flex-col items-stretch"
|
|
5150
|
+
},
|
|
5151
|
+
attached: {
|
|
5152
|
+
true: "gap-0",
|
|
5153
|
+
false: ""
|
|
5154
|
+
},
|
|
5155
|
+
spacing: {
|
|
5156
|
+
none: "gap-0",
|
|
5157
|
+
sm: "gap-1",
|
|
5158
|
+
md: "gap-2",
|
|
5159
|
+
lg: "gap-3"
|
|
5160
|
+
}
|
|
5161
|
+
},
|
|
5162
|
+
defaultVariants: {
|
|
5163
|
+
orientation: "horizontal",
|
|
5164
|
+
attached: false,
|
|
5165
|
+
spacing: "md"
|
|
5166
|
+
},
|
|
5167
|
+
compoundVariants: [
|
|
5168
|
+
{
|
|
5169
|
+
conditions: {
|
|
5170
|
+
orientation: "horizontal",
|
|
5171
|
+
attached: true
|
|
5172
|
+
},
|
|
5173
|
+
className: [
|
|
5174
|
+
"[&>[data-kui-button-group-item]]:rounded-none",
|
|
5175
|
+
"[&>[data-kui-button-group-item]:first-child]:rounded-l-md",
|
|
5176
|
+
"[&>[data-kui-button-group-item]:last-child]:rounded-r-md",
|
|
5177
|
+
"[&>[data-kui-button-group-item]+[data-kui-button-group-item]]:-ml-px",
|
|
5178
|
+
"[&>[data-kui-button-group-separator]]:h-[var(--kui-button-group-separator-size)]",
|
|
5179
|
+
"[&>[data-kui-button-group-separator]]:w-px",
|
|
5180
|
+
"[&>[data-kui-button-group-separator]]:mx-1",
|
|
5181
|
+
"[&>[data-kui-button-group-separator]]:shrink-0"
|
|
5182
|
+
].join(" ")
|
|
5183
|
+
},
|
|
5184
|
+
{
|
|
5185
|
+
conditions: {
|
|
5186
|
+
orientation: "vertical"
|
|
5187
|
+
},
|
|
5188
|
+
className: [
|
|
5189
|
+
"[&>[data-kui-button-group-item]]:w-full",
|
|
5190
|
+
"[&>[data-kui-button-group-separator]]:h-px",
|
|
5191
|
+
"[&>[data-kui-button-group-separator]]:w-[var(--kui-button-group-separator-size)]",
|
|
5192
|
+
"[&>[data-kui-button-group-separator]]:shrink-0"
|
|
5193
|
+
].join(" ")
|
|
5194
|
+
},
|
|
5195
|
+
{
|
|
5196
|
+
conditions: {
|
|
5197
|
+
orientation: "vertical",
|
|
5198
|
+
attached: true
|
|
5199
|
+
},
|
|
5200
|
+
className: [
|
|
5201
|
+
"[&>[data-kui-button-group-item]]:rounded-none",
|
|
5202
|
+
"[&>[data-kui-button-group-item]:first-child]:rounded-t-md",
|
|
5203
|
+
"[&>[data-kui-button-group-item]:last-child]:rounded-b-md",
|
|
5204
|
+
"[&>[data-kui-button-group-item]+[data-kui-button-group-item]]:-mt-px"
|
|
5205
|
+
].join(" ")
|
|
5206
|
+
}
|
|
5207
|
+
]
|
|
5208
|
+
});
|
|
5209
|
+
var switchRecipe = defineRecipe$1({
|
|
5210
|
+
base: [
|
|
5211
|
+
"relative inline-flex shrink-0 items-center",
|
|
5212
|
+
"rounded-full",
|
|
5213
|
+
"transition-[background-color,border-color,box-shadow]",
|
|
5214
|
+
"duration-[var(--kui-duration-fast)]",
|
|
5215
|
+
"peer-focus-visible:ring-2",
|
|
5216
|
+
"peer-focus-visible:ring-kui-brand",
|
|
5217
|
+
"peer-focus-visible:ring-offset-1",
|
|
5218
|
+
"peer-focus-visible:ring-offset-surface"
|
|
5219
|
+
].join(" "),
|
|
5220
|
+
variants: {
|
|
5221
|
+
checked: {
|
|
5222
|
+
true: "bg-kui-brand",
|
|
5223
|
+
false: "bg-kui-border"
|
|
5224
|
+
},
|
|
5225
|
+
state: {
|
|
5226
|
+
none: "",
|
|
5227
|
+
error: "bg-kui-destructive",
|
|
5228
|
+
success: "bg-kui-success",
|
|
5229
|
+
warning: "bg-kui-warning"
|
|
5230
|
+
},
|
|
5231
|
+
disabled: {
|
|
5232
|
+
true: "cursor-not-allowed opacity-50",
|
|
5233
|
+
false: ""
|
|
5234
|
+
}
|
|
5235
|
+
},
|
|
5236
|
+
defaultVariants: {
|
|
5237
|
+
checked: false,
|
|
5238
|
+
state: "none",
|
|
5239
|
+
disabled: false
|
|
5240
|
+
}
|
|
5241
|
+
});
|
|
5242
|
+
var containerReccipe = defineRecipe$1({
|
|
5243
|
+
base: "w-full",
|
|
5244
|
+
variants: {
|
|
5245
|
+
maxWidth: {
|
|
5246
|
+
xs: "max-w-screen-xs",
|
|
5247
|
+
sm: "max-w-screen-sm",
|
|
5248
|
+
md: "max-w-screen-md",
|
|
5249
|
+
lg: "max-w-screen-lg",
|
|
5250
|
+
xl: "max-w-screen-xl",
|
|
5251
|
+
full: "max-w-full"
|
|
5252
|
+
}
|
|
5253
|
+
},
|
|
5254
|
+
defaultVariants: {
|
|
5255
|
+
maxWidth: "lg"
|
|
5256
|
+
}
|
|
5257
|
+
});
|
|
5258
|
+
var linkRecipe = defineRecipe$1({
|
|
5259
|
+
base: "kui-link",
|
|
5260
|
+
variants: {
|
|
5261
|
+
variant: {
|
|
5262
|
+
solid: "text-kui-brand hover:text-kui-brand-hover",
|
|
5263
|
+
outline: "text-kui-text-secondary hover:text-kui-brand",
|
|
5264
|
+
ghost: "text-kui-text-secondary hover:text-kui-text",
|
|
5265
|
+
soft: "text-kui-brand hover:text-kui-brand-hover"
|
|
5266
|
+
},
|
|
5267
|
+
underline: {
|
|
5268
|
+
always: "underline",
|
|
5269
|
+
hover: "no-underline hover:underline",
|
|
5270
|
+
none: "no-underline"
|
|
5271
|
+
},
|
|
5272
|
+
disabled: {
|
|
5273
|
+
true: "pointer-events-none opacity-50 cursor-not-allowed",
|
|
5274
|
+
false: ""
|
|
5275
|
+
}
|
|
5276
|
+
},
|
|
5277
|
+
defaultVariants: {
|
|
5278
|
+
variant: "solid",
|
|
5279
|
+
underline: "hover",
|
|
5280
|
+
disabled: false
|
|
5281
|
+
}
|
|
5282
|
+
});
|
|
4191
5283
|
var defaultRecipes = {
|
|
4192
5284
|
Button: buttonRecipe,
|
|
4193
5285
|
FormControl: formControlRecipe,
|
|
4194
5286
|
Input: inputRecipe,
|
|
4195
5287
|
Textarea: textareaRecipe,
|
|
4196
5288
|
MarkdownEditor: markdownEditorRecipe,
|
|
4197
|
-
Checkbox: checkboxRecipe
|
|
5289
|
+
Checkbox: checkboxRecipe,
|
|
5290
|
+
ButtonGroup: buttonGroupRecipe,
|
|
5291
|
+
Switch: switchRecipe,
|
|
5292
|
+
Container: containerReccipe,
|
|
5293
|
+
Link: linkRecipe
|
|
4198
5294
|
};
|
|
4199
|
-
var defaultTheme = {
|
|
5295
|
+
var defaultTheme = defineTheme({
|
|
4200
5296
|
tokens: defaultTokens,
|
|
4201
5297
|
semanticTokens: defaultSemanticTokens,
|
|
4202
5298
|
typography: defaultTypography,
|
|
4203
5299
|
recipes: defaultRecipes,
|
|
4204
5300
|
intensity: 50,
|
|
4205
5301
|
sizes: defaultSizes
|
|
4206
|
-
};
|
|
5302
|
+
});
|
|
4207
5303
|
|
|
4208
5304
|
// src/theme/recipes/extendRecipe.ts
|
|
5305
|
+
var defaultRecipes2 = defaultRecipes;
|
|
5306
|
+
function extendRecipe(name, override) {
|
|
5307
|
+
const base = defaultRecipes2[name];
|
|
5308
|
+
if (!override) {
|
|
5309
|
+
return base;
|
|
5310
|
+
}
|
|
5311
|
+
return {
|
|
5312
|
+
...base,
|
|
5313
|
+
...override,
|
|
5314
|
+
...override?.compoundVariants ? { compoundVariants: override.compoundVariants } : {},
|
|
5315
|
+
...base?.variants || override?.variants ? {
|
|
5316
|
+
variants: {
|
|
5317
|
+
...base?.variants,
|
|
5318
|
+
...override?.variants
|
|
5319
|
+
}
|
|
5320
|
+
} : {}
|
|
5321
|
+
};
|
|
5322
|
+
}
|
|
5323
|
+
__name(extendRecipe, "extendRecipe");
|
|
4209
5324
|
function extendRecipes(override) {
|
|
4210
5325
|
if (!override) {
|
|
4211
|
-
return
|
|
5326
|
+
return defaultRecipes2;
|
|
4212
5327
|
}
|
|
4213
|
-
const result = { ...
|
|
4214
|
-
for (const
|
|
4215
|
-
|
|
4216
|
-
const base = defaultRecipes[key];
|
|
4217
|
-
result[key] = {
|
|
4218
|
-
...base,
|
|
4219
|
-
...recipeOverride,
|
|
4220
|
-
...base?.compoundVariants || recipeOverride?.compoundVariants ? {
|
|
4221
|
-
compoundVariants: [
|
|
4222
|
-
...base?.compoundVariants ?? [],
|
|
4223
|
-
...recipeOverride?.compoundVariants ?? []
|
|
4224
|
-
]
|
|
4225
|
-
} : {},
|
|
4226
|
-
...base?.variants || recipeOverride?.variants ? {
|
|
4227
|
-
variants: {
|
|
4228
|
-
...base?.variants,
|
|
4229
|
-
...recipeOverride?.variants
|
|
4230
|
-
}
|
|
4231
|
-
} : {}
|
|
4232
|
-
};
|
|
5328
|
+
const result = { ...defaultRecipes2 };
|
|
5329
|
+
for (const name of Object.keys(override)) {
|
|
5330
|
+
result[name] = extendRecipe(name, override[name]);
|
|
4233
5331
|
}
|
|
4234
5332
|
return result;
|
|
4235
5333
|
}
|
|
4236
5334
|
__name(extendRecipes, "extendRecipes");
|
|
4237
5335
|
|
|
5336
|
+
// src/theme/recipes/helpers.ts
|
|
5337
|
+
function getRecipeNames() {
|
|
5338
|
+
return Object.keys(defaultRecipes);
|
|
5339
|
+
}
|
|
5340
|
+
__name(getRecipeNames, "getRecipeNames");
|
|
5341
|
+
|
|
5342
|
+
// src/theme/typography/defineTypography.ts
|
|
5343
|
+
function defineTypography2(typography) {
|
|
5344
|
+
return typography;
|
|
5345
|
+
}
|
|
5346
|
+
__name(defineTypography2, "defineTypography");
|
|
5347
|
+
|
|
5348
|
+
// src/theme/typography/extendTypography.ts
|
|
5349
|
+
function extendTypography(override) {
|
|
5350
|
+
if (!override) {
|
|
5351
|
+
return { ...defaultTypography };
|
|
5352
|
+
}
|
|
5353
|
+
const result = { ...defaultTypography };
|
|
5354
|
+
for (const key of Object.keys(override)) {
|
|
5355
|
+
const variant = key;
|
|
5356
|
+
result[variant] = {
|
|
5357
|
+
...defaultTypography[variant],
|
|
5358
|
+
...override[variant]
|
|
5359
|
+
};
|
|
5360
|
+
}
|
|
5361
|
+
return result;
|
|
5362
|
+
}
|
|
5363
|
+
__name(extendTypography, "extendTypography");
|
|
5364
|
+
|
|
4238
5365
|
// src/theme/token/defineToken.ts
|
|
4239
|
-
function
|
|
5366
|
+
function defineToken2(value) {
|
|
4240
5367
|
return {
|
|
4241
5368
|
value
|
|
4242
5369
|
};
|
|
4243
5370
|
}
|
|
4244
|
-
__name(
|
|
4245
|
-
function
|
|
4246
|
-
return
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
// src/utils/deepMerge.ts
|
|
4251
|
-
function isPlainObject(value) {
|
|
4252
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5371
|
+
__name(defineToken2, "defineToken");
|
|
5372
|
+
function defineTokens(tokens) {
|
|
5373
|
+
return Object.fromEntries(
|
|
5374
|
+
Object.entries(tokens).map(([key, value]) => [key, defineToken2(value)])
|
|
5375
|
+
);
|
|
4253
5376
|
}
|
|
4254
|
-
__name(
|
|
4255
|
-
function
|
|
4256
|
-
if (
|
|
4257
|
-
return
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
5377
|
+
__name(defineTokens, "defineTokens");
|
|
5378
|
+
function defineSemanticToken2(lightOrValue, dark) {
|
|
5379
|
+
if (dark === void 0) {
|
|
5380
|
+
return {
|
|
5381
|
+
value: {
|
|
5382
|
+
sameForBothModes: true,
|
|
5383
|
+
value: lightOrValue
|
|
5384
|
+
}
|
|
5385
|
+
};
|
|
4261
5386
|
}
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
if (isPlainObject(existing) && isPlainObject(value)) {
|
|
4268
|
-
result[key] = deepMerge(existing, value);
|
|
4269
|
-
} else {
|
|
4270
|
-
result[key] = value;
|
|
5387
|
+
return {
|
|
5388
|
+
value: {
|
|
5389
|
+
sameForBothModes: false,
|
|
5390
|
+
light: lightOrValue,
|
|
5391
|
+
dark
|
|
4271
5392
|
}
|
|
4272
|
-
}
|
|
4273
|
-
return result;
|
|
5393
|
+
};
|
|
4274
5394
|
}
|
|
4275
|
-
__name(
|
|
4276
|
-
|
|
4277
|
-
|
|
5395
|
+
__name(defineSemanticToken2, "defineSemanticToken");
|
|
5396
|
+
function defineSemanticTokens(tokens) {
|
|
5397
|
+
return Object.fromEntries(
|
|
5398
|
+
Object.entries(tokens).map(([key, entry]) => [
|
|
5399
|
+
key,
|
|
5400
|
+
entry !== null && typeof entry === "object" && "light" in entry && "dark" in entry ? defineSemanticToken2(entry.light, entry.dark) : defineSemanticToken2(entry)
|
|
5401
|
+
])
|
|
5402
|
+
);
|
|
5403
|
+
}
|
|
5404
|
+
__name(defineSemanticTokens, "defineSemanticTokens");
|
|
4278
5405
|
function extendTokens(override) {
|
|
4279
5406
|
return deepMerge(defaultTokens, override);
|
|
4280
5407
|
}
|
|
@@ -4310,24 +5437,28 @@ function extendTheme(override) {
|
|
|
4310
5437
|
return {
|
|
4311
5438
|
...defaultTheme,
|
|
4312
5439
|
...override,
|
|
5440
|
+
tokens: extendTokens(override.tokens),
|
|
5441
|
+
semanticTokens: extendSemanticTokens(override.semanticTokens),
|
|
4313
5442
|
sizes: extendSizes(override.sizes),
|
|
4314
5443
|
typography: extendTypography(override.typography),
|
|
4315
5444
|
recipes: extendRecipes(override.recipes)
|
|
4316
5445
|
};
|
|
4317
5446
|
}
|
|
4318
5447
|
__name(extendTheme, "extendTheme");
|
|
5448
|
+
|
|
5449
|
+
// src/theme/defineTheme.ts
|
|
5450
|
+
function defineTheme2(theme) {
|
|
5451
|
+
return theme;
|
|
5452
|
+
}
|
|
5453
|
+
__name(defineTheme2, "defineTheme");
|
|
4319
5454
|
function useSystemPrefersDark() {
|
|
4320
5455
|
const [prefersDark, setPrefersDark] = useState(false);
|
|
4321
5456
|
useEffect(() => {
|
|
4322
|
-
const
|
|
4323
|
-
setPrefersDark(
|
|
4324
|
-
const
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
mediaQuery.addEventListener("change", handleChange);
|
|
4328
|
-
return () => {
|
|
4329
|
-
mediaQuery.removeEventListener("change", handleChange);
|
|
4330
|
-
};
|
|
5457
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
5458
|
+
setPrefersDark(mq.matches);
|
|
5459
|
+
const handler = /* @__PURE__ */ __name((e) => setPrefersDark(e.matches), "handler");
|
|
5460
|
+
mq.addEventListener("change", handler);
|
|
5461
|
+
return () => mq.removeEventListener("change", handler);
|
|
4331
5462
|
}, []);
|
|
4332
5463
|
return prefersDark;
|
|
4333
5464
|
}
|
|
@@ -4337,9 +5468,12 @@ function UIProvider({
|
|
|
4337
5468
|
theme: themeOverride,
|
|
4338
5469
|
defaultMode = "system",
|
|
4339
5470
|
as = "div",
|
|
4340
|
-
fallbackSize = "md"
|
|
5471
|
+
fallbackSize = "md",
|
|
5472
|
+
themeTransition = true,
|
|
5473
|
+
themeTransitionDuration = 300
|
|
4341
5474
|
}) {
|
|
4342
5475
|
const [mode, setMode] = useState(defaultMode);
|
|
5476
|
+
const [transitioning, setTransitioning] = useState(false);
|
|
4343
5477
|
const systemPrefersDark = useSystemPrefersDark();
|
|
4344
5478
|
const resolvedMode = mode === "system" ? systemPrefersDark ? "dark" : "light" : mode;
|
|
4345
5479
|
const theme = useMemo(() => extendTheme(themeOverride), [themeOverride]);
|
|
@@ -4354,10 +5488,19 @@ function UIProvider({
|
|
|
4354
5488
|
useEffect(() => {
|
|
4355
5489
|
if (isDev() && !theme.sizes[fallbackSize]) {
|
|
4356
5490
|
console.error(
|
|
4357
|
-
`[kreativ-ui] fallbackSize="${fallbackSize}" is not a registered size in theme.sizes
|
|
5491
|
+
`[kreativ-ui] fallbackSize="${fallbackSize}" is not a registered size in theme.sizes.`
|
|
4358
5492
|
);
|
|
4359
5493
|
}
|
|
4360
5494
|
}, [theme.sizes, fallbackSize]);
|
|
5495
|
+
useEffect(() => {
|
|
5496
|
+
if (!themeTransition) return;
|
|
5497
|
+
setTransitioning(true);
|
|
5498
|
+
const timeout = setTimeout(
|
|
5499
|
+
() => setTransitioning(false),
|
|
5500
|
+
themeTransitionDuration
|
|
5501
|
+
);
|
|
5502
|
+
return () => clearTimeout(timeout);
|
|
5503
|
+
}, [resolvedMode, themeTransition, themeTransitionDuration]);
|
|
4361
5504
|
const contextValue = useMemo(
|
|
4362
5505
|
() => ({
|
|
4363
5506
|
theme,
|
|
@@ -4374,14 +5517,28 @@ function UIProvider({
|
|
|
4374
5517
|
Tag,
|
|
4375
5518
|
{
|
|
4376
5519
|
"data-kreativ-theme": resolvedMode,
|
|
5520
|
+
"data-kui-transitioning": transitioning ? "true" : void 0,
|
|
4377
5521
|
className: resolvedMode === "dark" ? "dark" : void 0,
|
|
4378
|
-
style:
|
|
5522
|
+
style: {
|
|
5523
|
+
...cssVars,
|
|
5524
|
+
["--kui-theme-transition-duration"]: `${themeTransitionDuration}ms`
|
|
5525
|
+
},
|
|
4379
5526
|
children
|
|
4380
5527
|
}
|
|
4381
5528
|
) });
|
|
4382
5529
|
}
|
|
4383
5530
|
__name(UIProvider, "UIProvider");
|
|
4384
5531
|
|
|
4385
|
-
|
|
5532
|
+
// src/index.ts
|
|
5533
|
+
__reExport(index_exports, hooks_exports);
|
|
5534
|
+
|
|
5535
|
+
// src/types/index.ts
|
|
5536
|
+
var types_exports = {};
|
|
5537
|
+
__reExport(types_exports, types_star);
|
|
5538
|
+
|
|
5539
|
+
// src/index.ts
|
|
5540
|
+
__reExport(index_exports, types_exports);
|
|
5541
|
+
|
|
5542
|
+
export { Adornment, Button, ButtonGroup, ButtonGroupContext, ButtonGroupItemContext, Card, Checkbox, Combobox, ComboboxContent, ComboboxInput, ComboboxItem, Container, Flex, FormField, FormFieldControl, FormFieldDescription, FormFieldLabel, FormFieldMessage, Grid, Input, InputField, MarkdownEditor, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTrigger, Radio, RadioGroup, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Stack, Switch, Textarea, ThemeToggler, UIProvider, cardSkeleton, cn, defineRecipe, defineSemanticToken2 as defineSemanticToken, defineSemanticTokens, defineTheme2 as defineTheme, defineToken2 as defineToken, defineTokens, defineTypography2 as defineTypography, extendRecipe, extendRecipes, extendSemanticTokens, extendTheme, extendTokens, extendTypography, getRecipeNames, hexToRgbString, rgbToHex, useButtonGroupContext, useButtonGroupItemContext, useClearableField, useFloatingSide, useKeyboardShortcuts, useOptionalButtonGroupContext, useOptionalButtonGroupItemContext, useStatusTransition };
|
|
4386
5543
|
//# sourceMappingURL=index.js.map
|
|
4387
5544
|
//# sourceMappingURL=index.js.map
|