@locus-ui/components 0.0.1
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/dist/index.css +9822 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +1236 -0
- package/dist/index.d.ts +1236 -0
- package/dist/index.js +3027 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3027 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +53 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3027 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/accordion/content/accordion-content.tsx
|
|
4
|
+
import clsx2 from "clsx";
|
|
5
|
+
|
|
6
|
+
// src/utils/get-component-props.ts
|
|
7
|
+
import clsx from "clsx";
|
|
8
|
+
function getComponentProps(props, ...propDefs) {
|
|
9
|
+
let style = props.style ?? {};
|
|
10
|
+
const classNames = props.className ? [props.className] : [];
|
|
11
|
+
const dataAttrs = {};
|
|
12
|
+
const extractedProps = {};
|
|
13
|
+
const allProps = Object.assign({}, ...propDefs);
|
|
14
|
+
const propKeys = Object.keys(allProps);
|
|
15
|
+
const restProps = { ...props };
|
|
16
|
+
delete restProps.className;
|
|
17
|
+
delete restProps.style;
|
|
18
|
+
for (const key of propKeys) {
|
|
19
|
+
const prop = allProps[key];
|
|
20
|
+
const value = props?.[key];
|
|
21
|
+
delete restProps[key];
|
|
22
|
+
if (prop.type === "boolean" || prop.type === "string" || prop.type === "value | array" || prop.type === "reactNode" || prop.type === "function") {
|
|
23
|
+
extractedProps[key] = value;
|
|
24
|
+
if (prop.cssProperty && value !== void 0 && value !== null) {
|
|
25
|
+
style = {
|
|
26
|
+
...style,
|
|
27
|
+
[prop.cssProperty]: prop.type === "boolean" ? value ? "1" : "0" : value
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (prop.dataAttr) {
|
|
31
|
+
if (value) dataAttrs[`data-${prop.dataAttr}`] = value;
|
|
32
|
+
else if (prop.default !== void 0) {
|
|
33
|
+
dataAttrs[`data-${prop.dataAttr}`] = prop.default;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const applyValue = (propValue, breakpoint) => {
|
|
39
|
+
const usedBreakpoint = breakpoint ? `-${breakpoint}` : "";
|
|
40
|
+
if (prop.type === "enum" || prop.type === "enum | string") {
|
|
41
|
+
if (propValue !== null && propValue !== void 0) {
|
|
42
|
+
if (!breakpoint) extractedProps[key] = propValue;
|
|
43
|
+
if (!prop.values.includes(propValue)) {
|
|
44
|
+
if (prop.className) {
|
|
45
|
+
classNames.push(
|
|
46
|
+
breakpoint ? `${prop.className}-${breakpoint}` : prop.className
|
|
47
|
+
);
|
|
48
|
+
style = {
|
|
49
|
+
...style,
|
|
50
|
+
[`--custom-${key}${usedBreakpoint}`]: propValue
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (prop.dataAttr) {
|
|
54
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;
|
|
55
|
+
}
|
|
56
|
+
} else if (prop.dataAttr) {
|
|
57
|
+
if (propValue === "inherit" && prop.className) {
|
|
58
|
+
classNames.push(prop.className);
|
|
59
|
+
}
|
|
60
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = propValue;
|
|
61
|
+
}
|
|
62
|
+
} else if (prop.dataAttr && prop.default) {
|
|
63
|
+
if (!breakpoint) extractedProps[key] = prop.default;
|
|
64
|
+
if (prop.dataAttr) {
|
|
65
|
+
dataAttrs[`data-${prop.dataAttr}${usedBreakpoint}`] = prop.default;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if ("responsive" in prop && prop.responsive && value && typeof value === "object" && !Array.isArray(value)) {
|
|
71
|
+
for (const [bp, bpValue] of Object.entries(value)) {
|
|
72
|
+
applyValue(bpValue, bp);
|
|
73
|
+
}
|
|
74
|
+
if ("dataAttr" in prop && prop.dataAttr) {
|
|
75
|
+
dataAttrs[`data-${prop.dataAttr}`] = "";
|
|
76
|
+
}
|
|
77
|
+
} else applyValue(value);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
...restProps,
|
|
81
|
+
...extractedProps,
|
|
82
|
+
style,
|
|
83
|
+
dataAttrs,
|
|
84
|
+
className: clsx(classNames)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/components/accordion/accordion-context.ts
|
|
89
|
+
import React from "react";
|
|
90
|
+
var AccordionContext = React.createContext(null);
|
|
91
|
+
function useAccordionContext() {
|
|
92
|
+
const context = React.useContext(AccordionContext);
|
|
93
|
+
if (!context) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
"Accordion components must be used within an Accordion.Root"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return context;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/components/accordion/content/accordion-content.props.ts
|
|
102
|
+
var AccordionContentPropDefs = {
|
|
103
|
+
//
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/components/accordion/content/accordion-content.tsx
|
|
107
|
+
import { jsx } from "react/jsx-runtime";
|
|
108
|
+
var AccordionContent = (props) => {
|
|
109
|
+
const context = useAccordionContext();
|
|
110
|
+
const { className, children, dataAttrs, ...rest } = getComponentProps(
|
|
111
|
+
props,
|
|
112
|
+
AccordionContentPropDefs
|
|
113
|
+
);
|
|
114
|
+
return /* @__PURE__ */ jsx(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
"data-variant": context.variant,
|
|
118
|
+
className: clsx2("accordion-content", className),
|
|
119
|
+
...rest,
|
|
120
|
+
children: /* @__PURE__ */ jsx("div", { className: "accordion-content-inner", children: /* @__PURE__ */ jsx("div", { children }) })
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
AccordionContent.displayName = "Accordion.Content";
|
|
125
|
+
|
|
126
|
+
// src/components/accordion/header/accordion-header.tsx
|
|
127
|
+
import clsx3 from "clsx";
|
|
128
|
+
|
|
129
|
+
// src/icons/icon-colors.ts
|
|
130
|
+
var colorMap = {
|
|
131
|
+
currentColor: "currentColor",
|
|
132
|
+
primary: "rgb(var(--primary))",
|
|
133
|
+
white: "white",
|
|
134
|
+
black: "black"
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// src/icons/chevron-down.icon.tsx
|
|
138
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
139
|
+
var ChevronDown = ({
|
|
140
|
+
color = "currentColor"
|
|
141
|
+
}) => {
|
|
142
|
+
return /* @__PURE__ */ jsx2(
|
|
143
|
+
"svg",
|
|
144
|
+
{
|
|
145
|
+
width: "20",
|
|
146
|
+
height: "20",
|
|
147
|
+
viewBox: "0 0 15 15",
|
|
148
|
+
fill: "none",
|
|
149
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
150
|
+
children: /* @__PURE__ */ jsx2(
|
|
151
|
+
"path",
|
|
152
|
+
{
|
|
153
|
+
fill: colorMap[color],
|
|
154
|
+
d: "M4.18179 6.18181C4.35753 6.00608 4.64245 6.00608 4.81819 6.18181L7.49999 8.86362L10.1818 6.18181C10.3575 6.00608 10.6424 6.00608 10.8182 6.18181C10.9939 6.35755 10.9939 6.64247 10.8182 6.81821L7.81819 9.81821C7.73379 9.9026 7.61934 9.95001 7.49999 9.95001C7.38064 9.95001 7.26618 9.9026 7.18179 9.81821L4.18179 6.81821C4.00605 6.64247 4.00605 6.35755 4.18179 6.18181Z",
|
|
155
|
+
fillRule: "evenodd",
|
|
156
|
+
clipRule: "evenodd"
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// src/components/accordion/header/accordion-header.props.ts
|
|
164
|
+
var AccordionHeaderPropDefs = {
|
|
165
|
+
/** The value of the parent AccordionItem — injected automatically */
|
|
166
|
+
value: {
|
|
167
|
+
type: "string"
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/components/accordion/header/accordion-header.tsx
|
|
172
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
173
|
+
var AccordionHeader = (props) => {
|
|
174
|
+
const context = useAccordionContext();
|
|
175
|
+
const { className, children, value, dataAttrs, ...rest } = getComponentProps(
|
|
176
|
+
props,
|
|
177
|
+
AccordionHeaderPropDefs
|
|
178
|
+
);
|
|
179
|
+
const itemOpen = context.multiple ? context.value?.includes(value ?? "") : context.value === value;
|
|
180
|
+
const handleClick = () => {
|
|
181
|
+
if (!value) return;
|
|
182
|
+
if (context.multiple) {
|
|
183
|
+
const current = context.value ?? [];
|
|
184
|
+
const next = current.includes(value) ? current.filter((v) => v !== value) : [...current, value];
|
|
185
|
+
context.setValue(next.length ? next : null);
|
|
186
|
+
} else {
|
|
187
|
+
context.setValue(context.value === value ? null : value);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
return /* @__PURE__ */ jsxs(
|
|
191
|
+
"div",
|
|
192
|
+
{
|
|
193
|
+
"data-open": itemOpen,
|
|
194
|
+
"data-variant": context.variant,
|
|
195
|
+
className: clsx3("accordion-header", className),
|
|
196
|
+
role: "button",
|
|
197
|
+
tabIndex: 0,
|
|
198
|
+
onClick: handleClick,
|
|
199
|
+
onKeyDown: (e) => {
|
|
200
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
handleClick();
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
...rest,
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ jsx3("span", { children }),
|
|
208
|
+
/* @__PURE__ */ jsx3("span", { className: "accordion-header-indicator", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(ChevronDown, {}) })
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
AccordionHeader.displayName = "Accordion.Header";
|
|
214
|
+
|
|
215
|
+
// src/components/accordion/item/accordion-item.tsx
|
|
216
|
+
import clsx4 from "clsx";
|
|
217
|
+
import React3, { useEffect, useMemo } from "react";
|
|
218
|
+
|
|
219
|
+
// src/utils/filter-children.ts
|
|
220
|
+
import * as React2 from "react";
|
|
221
|
+
function filterChildren(children, allowedDisplayNames, options = {}) {
|
|
222
|
+
const { parentDisplayName, strict = false } = options;
|
|
223
|
+
return React2.Children.toArray(children).filter((child) => {
|
|
224
|
+
if (!React2.isValidElement(child)) return false;
|
|
225
|
+
const childType = child.type;
|
|
226
|
+
const displayName = childType?.displayName;
|
|
227
|
+
if (!displayName || !allowedDisplayNames.includes(displayName)) {
|
|
228
|
+
const parent = parentDisplayName ?? "Component";
|
|
229
|
+
const childName = displayName || "Unknown";
|
|
230
|
+
const allowed = allowedDisplayNames.join(", ");
|
|
231
|
+
const message = `${parent}: Invalid child "${childName}"${strict ? "" : " was filtered out"}. Only ${allowed} are allowed as direct children.`;
|
|
232
|
+
if (strict) throw new Error(message);
|
|
233
|
+
console.warn(message);
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/components/accordion/item/accordion-item.props.ts
|
|
241
|
+
var AccordionItemPropDefs = {
|
|
242
|
+
/**
|
|
243
|
+
* Sets the accordion item to be open by default.
|
|
244
|
+
*/
|
|
245
|
+
open: {
|
|
246
|
+
type: "boolean"
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* The value of the accordion item. Automatically generated if not provided.
|
|
250
|
+
*/
|
|
251
|
+
value: {
|
|
252
|
+
type: "string"
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/components/accordion/item/accordion-item.tsx
|
|
257
|
+
import { jsxs as jsxs2 } from "react/jsx-runtime";
|
|
258
|
+
var ALLOWED_CHILDREN = [
|
|
259
|
+
AccordionHeader.displayName,
|
|
260
|
+
AccordionContent.displayName
|
|
261
|
+
];
|
|
262
|
+
var AccordionItem = (props) => {
|
|
263
|
+
const context = useAccordionContext();
|
|
264
|
+
const { open, value, className, dataAttrs, ...rest } = getComponentProps(
|
|
265
|
+
props,
|
|
266
|
+
AccordionItemPropDefs
|
|
267
|
+
);
|
|
268
|
+
const itemOpen = open ?? (context.multiple ? context.value?.includes(value ?? "") : context.value === value);
|
|
269
|
+
const validChildren = filterChildren(props.children, ALLOWED_CHILDREN, {
|
|
270
|
+
parentDisplayName: AccordionItem.displayName
|
|
271
|
+
});
|
|
272
|
+
const { header, content } = useMemo(() => {
|
|
273
|
+
const header2 = validChildren.find(
|
|
274
|
+
(child) => child.type.displayName === AccordionHeader.displayName
|
|
275
|
+
);
|
|
276
|
+
const content2 = validChildren.find(
|
|
277
|
+
(child) => child.type.displayName === AccordionContent.displayName
|
|
278
|
+
);
|
|
279
|
+
return { header: header2, content: content2 };
|
|
280
|
+
}, [validChildren]);
|
|
281
|
+
useEffect(() => {
|
|
282
|
+
if (!value) return;
|
|
283
|
+
return () => {
|
|
284
|
+
const values = context.itemValues.current;
|
|
285
|
+
const index = values.indexOf(value);
|
|
286
|
+
if (index > -1) values.splice(index, 1);
|
|
287
|
+
};
|
|
288
|
+
}, [value]);
|
|
289
|
+
const headerWithValue = header ? React3.cloneElement(header, {
|
|
290
|
+
value
|
|
291
|
+
}) : null;
|
|
292
|
+
return /* @__PURE__ */ jsxs2(
|
|
293
|
+
"div",
|
|
294
|
+
{
|
|
295
|
+
"data-variant": context.variant,
|
|
296
|
+
className: clsx4("accordion-item", className),
|
|
297
|
+
...rest,
|
|
298
|
+
"data-open": itemOpen,
|
|
299
|
+
children: [
|
|
300
|
+
headerWithValue,
|
|
301
|
+
content
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
};
|
|
306
|
+
AccordionItem.displayName = "Accordion.Item";
|
|
307
|
+
|
|
308
|
+
// src/components/accordion/root/accordion-root.tsx
|
|
309
|
+
import clsx5 from "clsx";
|
|
310
|
+
import { useMemo as useMemo2, useRef } from "react";
|
|
311
|
+
|
|
312
|
+
// src/props/align.prop.ts
|
|
313
|
+
var Alignments = ["start", "center", "end"];
|
|
314
|
+
var AlignPropDef = {
|
|
315
|
+
/**
|
|
316
|
+
* The alignment of the component.
|
|
317
|
+
*/
|
|
318
|
+
align: {
|
|
319
|
+
type: "enum",
|
|
320
|
+
values: Alignments,
|
|
321
|
+
dataAttr: "align"
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/props/margin.prop.ts
|
|
326
|
+
var marginValues = [
|
|
327
|
+
"auto",
|
|
328
|
+
"inherit",
|
|
329
|
+
"-8",
|
|
330
|
+
"-6",
|
|
331
|
+
"-5",
|
|
332
|
+
"-4",
|
|
333
|
+
"-3",
|
|
334
|
+
"-2",
|
|
335
|
+
"-1",
|
|
336
|
+
"0",
|
|
337
|
+
"1",
|
|
338
|
+
"2",
|
|
339
|
+
"3",
|
|
340
|
+
"4",
|
|
341
|
+
"5",
|
|
342
|
+
"6",
|
|
343
|
+
"8"
|
|
344
|
+
];
|
|
345
|
+
var MarginPropDefs = {
|
|
346
|
+
/**
|
|
347
|
+
* Sets margin on all sides of the element.
|
|
348
|
+
* Supports scale, auto, inherit, custom, and responsive values.
|
|
349
|
+
*
|
|
350
|
+
* @example m="4" // 16px margin on all sides
|
|
351
|
+
* @example m="-26px" // -26px negative margin custom value
|
|
352
|
+
* @example m={{ initial: "2", md: "4", lg: "8" }} // responsive margins
|
|
353
|
+
*
|
|
354
|
+
* @link
|
|
355
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin
|
|
356
|
+
*/
|
|
357
|
+
m: {
|
|
358
|
+
type: "enum | string",
|
|
359
|
+
values: marginValues,
|
|
360
|
+
dataAttr: "m",
|
|
361
|
+
className: "lcs-m",
|
|
362
|
+
responsive: true
|
|
363
|
+
},
|
|
364
|
+
/**
|
|
365
|
+
* Sets margin on the top of the element.
|
|
366
|
+
* Supports scale, auto, inherit, custom, and responsive values.
|
|
367
|
+
*
|
|
368
|
+
* @example mt="4" // 16px margin on all sides
|
|
369
|
+
* @example mt="-26px" // -26px negative margin custom value
|
|
370
|
+
* @example mt={{ initial: "2", md: "4", lg: "8" }} // responsive margins
|
|
371
|
+
*
|
|
372
|
+
* @link
|
|
373
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-top
|
|
374
|
+
*/
|
|
375
|
+
mt: {
|
|
376
|
+
type: "enum | string",
|
|
377
|
+
values: marginValues,
|
|
378
|
+
dataAttr: "mt",
|
|
379
|
+
className: "lcs-mt",
|
|
380
|
+
responsive: true
|
|
381
|
+
},
|
|
382
|
+
/**
|
|
383
|
+
* Sets margin on the bottom of the element.
|
|
384
|
+
* Supports scale, auto, inherit, custom, and responsive values.
|
|
385
|
+
*
|
|
386
|
+
* @example mb="4" // 16px margin on all sides
|
|
387
|
+
* @example mb="-26px" // -26px negative margin custom value
|
|
388
|
+
* @example mb={{ initial: "2", md: "4", lg: "8" }} // responsive margins
|
|
389
|
+
*
|
|
390
|
+
* @link
|
|
391
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom
|
|
392
|
+
*/
|
|
393
|
+
mb: {
|
|
394
|
+
type: "enum | string",
|
|
395
|
+
values: marginValues,
|
|
396
|
+
dataAttr: "mb",
|
|
397
|
+
className: "lcs-mb",
|
|
398
|
+
responsive: true
|
|
399
|
+
},
|
|
400
|
+
/**
|
|
401
|
+
* Sets margin on the left of the element.
|
|
402
|
+
* Supports scale, auto, inherit, custom, and responsive values.
|
|
403
|
+
*
|
|
404
|
+
* @example ml="4" // 16px margin on all sides
|
|
405
|
+
* @example ml="-26px" // -26px negative margin custom value
|
|
406
|
+
* @example ml={{ initial: "2", md: "4", lg: "8" }} // responsive margins
|
|
407
|
+
*
|
|
408
|
+
* @link
|
|
409
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-left
|
|
410
|
+
*/
|
|
411
|
+
ml: {
|
|
412
|
+
type: "enum | string",
|
|
413
|
+
values: marginValues,
|
|
414
|
+
dataAttr: "ml",
|
|
415
|
+
className: "lcs-ml",
|
|
416
|
+
responsive: true
|
|
417
|
+
},
|
|
418
|
+
/**
|
|
419
|
+
* Sets margin on the right of the element.
|
|
420
|
+
* Supports scale, auto, inherit, custom, and responsive values.
|
|
421
|
+
*
|
|
422
|
+
* @example mr="4" // 16px margin on all sides
|
|
423
|
+
* @example mr="-26px" // -26px negative margin custom value
|
|
424
|
+
* @example mr={{ initial: "2", md: "4", lg: "8" }} // responsive margins
|
|
425
|
+
*
|
|
426
|
+
* @link
|
|
427
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-right
|
|
428
|
+
*/
|
|
429
|
+
mr: {
|
|
430
|
+
type: "enum | string",
|
|
431
|
+
values: marginValues,
|
|
432
|
+
dataAttr: "mr",
|
|
433
|
+
className: "lcs-mr",
|
|
434
|
+
responsive: true
|
|
435
|
+
},
|
|
436
|
+
/**
|
|
437
|
+
* Sets margin on the left and right (horizontal) sides of the element.
|
|
438
|
+
* Supports scale, auto, inherit, custom, and responsive values.
|
|
439
|
+
*
|
|
440
|
+
* @example mx="4" // 16px horizontal margin
|
|
441
|
+
* @example mx="-26px" // -26px negative horizontal margin custom value
|
|
442
|
+
* @example mx={{ initial: "2", md: "4", lg: "8" }} // responsive horizontal margins
|
|
443
|
+
*
|
|
444
|
+
* @link
|
|
445
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-left
|
|
446
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-right
|
|
447
|
+
*/
|
|
448
|
+
mx: {
|
|
449
|
+
type: "enum | string",
|
|
450
|
+
values: marginValues,
|
|
451
|
+
dataAttr: "mx",
|
|
452
|
+
className: "lcs-mx",
|
|
453
|
+
responsive: true
|
|
454
|
+
},
|
|
455
|
+
/**
|
|
456
|
+
* Sets margin on the top and bottom (vertical) sides of the element.
|
|
457
|
+
* Supports scale, auto, inherit, custom, and responsive values.
|
|
458
|
+
*
|
|
459
|
+
* @example my="4" // 16px vertical margin
|
|
460
|
+
* @example my="-26px" // -26px negative vertical margin custom value
|
|
461
|
+
* @example my={{ initial: "2", md: "4", lg: "8" }} // responsive vertical margins
|
|
462
|
+
*
|
|
463
|
+
* @link
|
|
464
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-top
|
|
465
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom
|
|
466
|
+
*/
|
|
467
|
+
my: {
|
|
468
|
+
type: "enum | string",
|
|
469
|
+
values: marginValues,
|
|
470
|
+
dataAttr: "my",
|
|
471
|
+
className: "lcs-my",
|
|
472
|
+
responsive: true
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// src/props/padding.prop.ts
|
|
477
|
+
var paddingValues = [
|
|
478
|
+
"inherit",
|
|
479
|
+
"0",
|
|
480
|
+
"1",
|
|
481
|
+
"2",
|
|
482
|
+
"3",
|
|
483
|
+
"4",
|
|
484
|
+
"5",
|
|
485
|
+
"6",
|
|
486
|
+
"8"
|
|
487
|
+
];
|
|
488
|
+
var PaddingPropDefs = {
|
|
489
|
+
/**
|
|
490
|
+
* Sets padding on all sides of the element.
|
|
491
|
+
* Supports scale, inherit, custom, and responsive values.
|
|
492
|
+
*
|
|
493
|
+
* @example p="4" // 16px padding on all sides
|
|
494
|
+
* @example p="26px" // 26px padding custom value
|
|
495
|
+
* @example p={{ initial: "2", md: "4", lg: "8" }} // responsive padding
|
|
496
|
+
*
|
|
497
|
+
* @link
|
|
498
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding
|
|
499
|
+
*/
|
|
500
|
+
p: {
|
|
501
|
+
type: "enum | string",
|
|
502
|
+
values: paddingValues,
|
|
503
|
+
dataAttr: "p",
|
|
504
|
+
className: "lcs-p",
|
|
505
|
+
responsive: true
|
|
506
|
+
},
|
|
507
|
+
/**
|
|
508
|
+
* Sets padding on the top of the element.
|
|
509
|
+
* Supports scale, inherit, custom, and responsive values.
|
|
510
|
+
*
|
|
511
|
+
* @example pt="4" // 16px top padding
|
|
512
|
+
* @example pt="26px" // 26px top padding custom value
|
|
513
|
+
* @example pt={{ initial: "2", md: "4", lg: "8" }} // responsive top padding
|
|
514
|
+
*
|
|
515
|
+
* @link
|
|
516
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-top
|
|
517
|
+
*/
|
|
518
|
+
pt: {
|
|
519
|
+
type: "enum | string",
|
|
520
|
+
values: paddingValues,
|
|
521
|
+
dataAttr: "pt",
|
|
522
|
+
className: "lcs-pt",
|
|
523
|
+
responsive: true
|
|
524
|
+
},
|
|
525
|
+
/**
|
|
526
|
+
* Sets padding on the bottom of the element.
|
|
527
|
+
* Supports scale, inherit, custom, and responsive values.
|
|
528
|
+
*
|
|
529
|
+
* @example pb="4" // 16px bottom padding
|
|
530
|
+
* @example pb="26px" // 26px bottom padding custom value
|
|
531
|
+
* @example pb={{ initial: "2", md: "4", lg: "8" }} // responsive bottom padding
|
|
532
|
+
*
|
|
533
|
+
* @link
|
|
534
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-bottom
|
|
535
|
+
*/
|
|
536
|
+
pb: {
|
|
537
|
+
type: "enum | string",
|
|
538
|
+
values: paddingValues,
|
|
539
|
+
dataAttr: "pb",
|
|
540
|
+
className: "lcs-pb",
|
|
541
|
+
responsive: true
|
|
542
|
+
},
|
|
543
|
+
/**
|
|
544
|
+
* Sets padding on the left of the element.
|
|
545
|
+
* Supports scale, inherit, custom, and responsive values.
|
|
546
|
+
*
|
|
547
|
+
* @example pl="4" // 16px left padding
|
|
548
|
+
* @example pl="26px" // 26px left padding custom value
|
|
549
|
+
* @example pl={{ initial: "2", md: "4", lg: "8" }} // responsive left padding
|
|
550
|
+
*
|
|
551
|
+
* @link
|
|
552
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-left
|
|
553
|
+
*/
|
|
554
|
+
pl: {
|
|
555
|
+
type: "enum | string",
|
|
556
|
+
values: paddingValues,
|
|
557
|
+
dataAttr: "pl",
|
|
558
|
+
className: "lcs-pl",
|
|
559
|
+
responsive: true
|
|
560
|
+
},
|
|
561
|
+
/**
|
|
562
|
+
* Sets padding on the right of the element.
|
|
563
|
+
* Supports scale, inherit, custom, and responsive values.
|
|
564
|
+
*
|
|
565
|
+
* @example pr="4" // 16px right padding
|
|
566
|
+
* @example pr="26px" // 26px right padding custom value
|
|
567
|
+
* @example pr={{ initial: "2", md: "4", lg: "8" }} // responsive right padding
|
|
568
|
+
*
|
|
569
|
+
* @link
|
|
570
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-right
|
|
571
|
+
*/
|
|
572
|
+
pr: {
|
|
573
|
+
type: "enum | string",
|
|
574
|
+
values: paddingValues,
|
|
575
|
+
dataAttr: "pr",
|
|
576
|
+
className: "lcs-pr",
|
|
577
|
+
responsive: true
|
|
578
|
+
},
|
|
579
|
+
/**
|
|
580
|
+
* Sets padding on the left and right (horizontal) sides of the element.
|
|
581
|
+
* Supports scale, inherit, custom, and responsive values.
|
|
582
|
+
*
|
|
583
|
+
* @example px="4" // 16px horizontal padding
|
|
584
|
+
* @example px="26px" // 26px horizontal padding custom value
|
|
585
|
+
* @example px={{ initial: "2", md: "4", lg: "8" }} // responsive horizontal padding
|
|
586
|
+
*
|
|
587
|
+
* @link
|
|
588
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-left
|
|
589
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-right
|
|
590
|
+
*/
|
|
591
|
+
px: {
|
|
592
|
+
type: "enum | string",
|
|
593
|
+
values: paddingValues,
|
|
594
|
+
dataAttr: "px",
|
|
595
|
+
className: "lcs-px",
|
|
596
|
+
responsive: true
|
|
597
|
+
},
|
|
598
|
+
/**
|
|
599
|
+
* Sets padding on the top and bottom (vertical) sides of the element.
|
|
600
|
+
* Supports scale, inherit, custom, and responsive values.
|
|
601
|
+
*
|
|
602
|
+
* @example py="4" // 16px vertical padding
|
|
603
|
+
* @example py="26px" // 26px vertical padding custom value
|
|
604
|
+
* @example py={{ initial: "2", md: "4", lg: "8" }} // responsive vertical padding
|
|
605
|
+
*
|
|
606
|
+
* @link
|
|
607
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-top
|
|
608
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/padding-bottom
|
|
609
|
+
*/
|
|
610
|
+
py: {
|
|
611
|
+
type: "enum | string",
|
|
612
|
+
values: paddingValues,
|
|
613
|
+
dataAttr: "py",
|
|
614
|
+
className: "lcs-py",
|
|
615
|
+
responsive: true
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
// src/props/radius.prop.ts
|
|
620
|
+
var radii = [
|
|
621
|
+
"none",
|
|
622
|
+
"xs",
|
|
623
|
+
"sm",
|
|
624
|
+
"md",
|
|
625
|
+
"lg",
|
|
626
|
+
"xl",
|
|
627
|
+
"full",
|
|
628
|
+
"inherit"
|
|
629
|
+
];
|
|
630
|
+
var RadiusPropDefs = {
|
|
631
|
+
/**
|
|
632
|
+
* Sets the border-radius of the element.
|
|
633
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
634
|
+
*
|
|
635
|
+
* @example radius="md" // medium border-radius
|
|
636
|
+
* @example radius="26px" // 26px border-radius custom value
|
|
637
|
+
* @example radius={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
638
|
+
*
|
|
639
|
+
* @default "theme" // uses the theme's default border-radius value or none if not set
|
|
640
|
+
*
|
|
641
|
+
* @link
|
|
642
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius
|
|
643
|
+
*/
|
|
644
|
+
radius: {
|
|
645
|
+
type: "enum | string",
|
|
646
|
+
values: radii,
|
|
647
|
+
default: "theme",
|
|
648
|
+
dataAttr: "radius",
|
|
649
|
+
className: "lcs-radius",
|
|
650
|
+
responsive: true
|
|
651
|
+
},
|
|
652
|
+
/**
|
|
653
|
+
* Sets the top border-radius of the element.
|
|
654
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
655
|
+
*
|
|
656
|
+
* @example radius-t="md" // medium border-radius
|
|
657
|
+
* @example radius-t="26px" // 26px border-radius custom value
|
|
658
|
+
* @example radius-t={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
659
|
+
*
|
|
660
|
+
* @link
|
|
661
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-left-radius
|
|
662
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius
|
|
663
|
+
*/
|
|
664
|
+
"radius-t": {
|
|
665
|
+
type: "enum | string",
|
|
666
|
+
values: radii,
|
|
667
|
+
dataAttr: "radius-t",
|
|
668
|
+
className: "lcs-radius-t",
|
|
669
|
+
responsive: true
|
|
670
|
+
},
|
|
671
|
+
/**
|
|
672
|
+
* Sets the right border-radius of the element.
|
|
673
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
674
|
+
*
|
|
675
|
+
* @example radius-r="md" // medium border-radius
|
|
676
|
+
* @example radius-r="26px" // 26px border-radius custom value
|
|
677
|
+
* @example radius-r={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
678
|
+
*
|
|
679
|
+
* @link
|
|
680
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius
|
|
681
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-right-radius
|
|
682
|
+
*/
|
|
683
|
+
"radius-r": {
|
|
684
|
+
type: "enum | string",
|
|
685
|
+
values: radii,
|
|
686
|
+
dataAttr: "radius-r",
|
|
687
|
+
className: "lcs-radius-r",
|
|
688
|
+
responsive: true
|
|
689
|
+
},
|
|
690
|
+
/**
|
|
691
|
+
* Sets the bottom border-radius of the element.
|
|
692
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
693
|
+
*
|
|
694
|
+
* @example radius-b="md" // medium border-radius
|
|
695
|
+
* @example radius-b="26px" // 26px border-radius custom value
|
|
696
|
+
* @example radius-b={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
697
|
+
*
|
|
698
|
+
* @link
|
|
699
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-left-radius
|
|
700
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-right-radius
|
|
701
|
+
*/
|
|
702
|
+
"radius-b": {
|
|
703
|
+
type: "enum | string",
|
|
704
|
+
values: radii,
|
|
705
|
+
dataAttr: "radius-b",
|
|
706
|
+
className: "lcs-radius-b",
|
|
707
|
+
responsive: true
|
|
708
|
+
},
|
|
709
|
+
/**
|
|
710
|
+
* Sets the left border-radius of the element.
|
|
711
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
712
|
+
*
|
|
713
|
+
* @example radius-l="md" // medium border-radius
|
|
714
|
+
* @example radius-l="26px" // 26px border-radius custom value
|
|
715
|
+
* @example radius-l={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
716
|
+
*
|
|
717
|
+
* @link
|
|
718
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-top-radius
|
|
719
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-bottom-radius
|
|
720
|
+
*/
|
|
721
|
+
"radius-l": {
|
|
722
|
+
type: "enum | string",
|
|
723
|
+
values: radii,
|
|
724
|
+
dataAttr: "radius-l",
|
|
725
|
+
className: "lcs-radius-l",
|
|
726
|
+
responsive: true
|
|
727
|
+
},
|
|
728
|
+
/**
|
|
729
|
+
* Sets the top-left border-radius of the element.
|
|
730
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
731
|
+
*
|
|
732
|
+
* @example radius-tl="md" // medium border-radius
|
|
733
|
+
* @example radius-tl="26px" // 26px border-radius custom value
|
|
734
|
+
* @example radius-tl={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
735
|
+
*
|
|
736
|
+
* @link
|
|
737
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-left-radius
|
|
738
|
+
*/
|
|
739
|
+
"radius-tl": {
|
|
740
|
+
type: "enum | string",
|
|
741
|
+
values: radii,
|
|
742
|
+
dataAttr: "radius-tl",
|
|
743
|
+
className: "lcs-radius-tl",
|
|
744
|
+
responsive: true
|
|
745
|
+
},
|
|
746
|
+
/**
|
|
747
|
+
* Sets the top-right border-radius of the element.
|
|
748
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
749
|
+
*
|
|
750
|
+
* @example "radius-tr"="md" // medium border-radius
|
|
751
|
+
* @example "radius-tr"="26px" // 26px border-radius custom value
|
|
752
|
+
* @example "radius-tr"={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
753
|
+
*
|
|
754
|
+
* @link
|
|
755
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius
|
|
756
|
+
*/
|
|
757
|
+
"radius-tr": {
|
|
758
|
+
type: "enum | string",
|
|
759
|
+
values: radii,
|
|
760
|
+
dataAttr: "radius-tr",
|
|
761
|
+
className: "lcs-radius-tr",
|
|
762
|
+
responsive: true
|
|
763
|
+
},
|
|
764
|
+
/**
|
|
765
|
+
* Sets the bottom-right border-radius of the element.
|
|
766
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
767
|
+
*
|
|
768
|
+
* @example "radius-br"="md" // medium border-radius
|
|
769
|
+
* @example "radius-br"="26px" // 26px border-radius custom value
|
|
770
|
+
* @example "radius-br"={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
771
|
+
*
|
|
772
|
+
* @link
|
|
773
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-right-radius
|
|
774
|
+
*/
|
|
775
|
+
"radius-br": {
|
|
776
|
+
type: "enum | string",
|
|
777
|
+
values: radii,
|
|
778
|
+
dataAttr: "radius-br",
|
|
779
|
+
className: "lcs-radius-br",
|
|
780
|
+
responsive: true
|
|
781
|
+
},
|
|
782
|
+
/**
|
|
783
|
+
* Sets the bottom-left border-radius of the element.
|
|
784
|
+
* Supports scaled, inherit, custom, and responsive values.
|
|
785
|
+
*
|
|
786
|
+
* @example "radius-bl"="md" // medium border-radius
|
|
787
|
+
* @example "radius-bl"="26px" // 26px border-radius custom value
|
|
788
|
+
* @example "radius-bl"={{ initial: "none", lg: "full" }} // responsive border-radius
|
|
789
|
+
*
|
|
790
|
+
* @link
|
|
791
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-left-radius
|
|
792
|
+
*/
|
|
793
|
+
"radius-bl": {
|
|
794
|
+
type: "enum | string",
|
|
795
|
+
values: radii,
|
|
796
|
+
dataAttr: "radius-bl",
|
|
797
|
+
className: "lcs-radius-bl",
|
|
798
|
+
responsive: true
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
// src/props/roundness.prop.ts
|
|
803
|
+
var roundness = ["1", "2", "3", "4", "5", "6", "inherit"];
|
|
804
|
+
var RoundnessPropDef = {
|
|
805
|
+
/**
|
|
806
|
+
* Sets the roundness multiplier for the element's radius.
|
|
807
|
+
* Supports scaled and inherit values.
|
|
808
|
+
*
|
|
809
|
+
* @example roundness="4" // 8px base roundness
|
|
810
|
+
* @example roundness="inherit" // inherits roundness from parent
|
|
811
|
+
*
|
|
812
|
+
* @default "theme" // uses the theme's default roundness value or none if not set
|
|
813
|
+
*/
|
|
814
|
+
roundness: {
|
|
815
|
+
type: "enum",
|
|
816
|
+
values: roundness,
|
|
817
|
+
default: "theme",
|
|
818
|
+
dataAttr: "roundness"
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
// src/props/size.prop.ts
|
|
823
|
+
var Sizes = ["xs", "sm", "md", "lg", "xl"];
|
|
824
|
+
var SizePropDef = {
|
|
825
|
+
/**
|
|
826
|
+
* Sets the size of the component.
|
|
827
|
+
*
|
|
828
|
+
* @example size="md" // medium sized component
|
|
829
|
+
*/
|
|
830
|
+
size: {
|
|
831
|
+
type: "enum | string",
|
|
832
|
+
values: Sizes,
|
|
833
|
+
dataAttr: "size",
|
|
834
|
+
className: "size"
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/props/spacing.prop.ts
|
|
839
|
+
var spacingValues = ["xs", "sm", "md", "lg", "xl", "inherit"];
|
|
840
|
+
var SpacingPropDef = {
|
|
841
|
+
/**
|
|
842
|
+
* Sets the spacing scale for the component.
|
|
843
|
+
* This multiplier affects various layout properties such as margin, padding, and gap values.
|
|
844
|
+
*
|
|
845
|
+
* @example spacing="md" // medium spacing scale (1)
|
|
846
|
+
* @example spacing={{ initial: "sm", lg: "xl" }} // responsive spacing
|
|
847
|
+
*
|
|
848
|
+
* @default "theme" // uses the theme's default spacing value or none if not set
|
|
849
|
+
*/
|
|
850
|
+
spacing: {
|
|
851
|
+
type: "enum",
|
|
852
|
+
values: spacingValues,
|
|
853
|
+
dataAttr: "spacing",
|
|
854
|
+
default: "theme",
|
|
855
|
+
responsive: true
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
// src/utils/use-controllable-state.ts
|
|
860
|
+
import * as React4 from "react";
|
|
861
|
+
function useControllableState({
|
|
862
|
+
value,
|
|
863
|
+
defaultValue,
|
|
864
|
+
onChange
|
|
865
|
+
}) {
|
|
866
|
+
const [state, setState] = React4.useState(defaultValue);
|
|
867
|
+
const isControlled = value !== void 0;
|
|
868
|
+
const current = isControlled ? value : state;
|
|
869
|
+
const set = React4.useCallback(
|
|
870
|
+
(value2) => {
|
|
871
|
+
if (!isControlled) setState(value2);
|
|
872
|
+
onChange?.(value2);
|
|
873
|
+
},
|
|
874
|
+
[isControlled, onChange]
|
|
875
|
+
);
|
|
876
|
+
return [current, set];
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/components/accordion/root/accordion-root.props.ts
|
|
880
|
+
var AccordionVariants = ["solid", "outlined", "muted"];
|
|
881
|
+
var AccordionRootPropsDefs = {
|
|
882
|
+
/**
|
|
883
|
+
* Sets the variant style of the accordion ("solid", "outlined", or "muted").
|
|
884
|
+
*/
|
|
885
|
+
variant: {
|
|
886
|
+
type: "enum",
|
|
887
|
+
values: AccordionVariants,
|
|
888
|
+
dataAttr: "variant"
|
|
889
|
+
},
|
|
890
|
+
/**
|
|
891
|
+
* Allows multiple accordion items to be expanded simultaneously when set to true.
|
|
892
|
+
*/
|
|
893
|
+
multiple: {
|
|
894
|
+
type: "boolean"
|
|
895
|
+
},
|
|
896
|
+
/**
|
|
897
|
+
* The value of the accordion.
|
|
898
|
+
*/
|
|
899
|
+
value: {
|
|
900
|
+
type: "value | array"
|
|
901
|
+
},
|
|
902
|
+
/**
|
|
903
|
+
* Callback fired when the value of the accordion changes.
|
|
904
|
+
*/
|
|
905
|
+
onValueChange: {
|
|
906
|
+
type: "function"
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
// src/components/accordion/root/accordion-root.tsx
|
|
911
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
912
|
+
var ALLOWED_CHILDREN2 = [AccordionItem.displayName];
|
|
913
|
+
var AccordionRoot = (props) => {
|
|
914
|
+
const {
|
|
915
|
+
variant,
|
|
916
|
+
multiple,
|
|
917
|
+
size,
|
|
918
|
+
value: propValue,
|
|
919
|
+
onValueChange,
|
|
920
|
+
className,
|
|
921
|
+
dataAttrs,
|
|
922
|
+
...rest
|
|
923
|
+
} = getComponentProps(props, AccordionRootPropsDefs, SizePropDef);
|
|
924
|
+
const [value, setValue] = useControllableState({
|
|
925
|
+
value: propValue,
|
|
926
|
+
defaultValue: propValue ?? null,
|
|
927
|
+
onChange: onValueChange
|
|
928
|
+
});
|
|
929
|
+
const validChildren = filterChildren(props.children, ALLOWED_CHILDREN2, {
|
|
930
|
+
parentDisplayName: AccordionRoot.displayName
|
|
931
|
+
});
|
|
932
|
+
const itemsRef = useRef(/* @__PURE__ */ new Map());
|
|
933
|
+
const itemValues = useRef([]);
|
|
934
|
+
const contextValue = useMemo2(
|
|
935
|
+
() => ({
|
|
936
|
+
variant,
|
|
937
|
+
multiple,
|
|
938
|
+
value,
|
|
939
|
+
setValue,
|
|
940
|
+
onValueChange,
|
|
941
|
+
itemsRef,
|
|
942
|
+
itemValues
|
|
943
|
+
}),
|
|
944
|
+
[variant, multiple, value, setValue, onValueChange]
|
|
945
|
+
);
|
|
946
|
+
return /* @__PURE__ */ jsx4(AccordionContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx4(
|
|
947
|
+
"div",
|
|
948
|
+
{
|
|
949
|
+
className: clsx5("accordion-root", className),
|
|
950
|
+
...dataAttrs,
|
|
951
|
+
...rest,
|
|
952
|
+
children: validChildren.map((child, index) => /* @__PURE__ */ jsx4(
|
|
953
|
+
AccordionItem,
|
|
954
|
+
{
|
|
955
|
+
value: child.props.value ?? String(index),
|
|
956
|
+
...child.props,
|
|
957
|
+
children: child.props.children
|
|
958
|
+
},
|
|
959
|
+
index
|
|
960
|
+
))
|
|
961
|
+
}
|
|
962
|
+
) });
|
|
963
|
+
};
|
|
964
|
+
AccordionRoot.displayName = "Accordion";
|
|
965
|
+
|
|
966
|
+
// src/components/accordion/accordion.tsx
|
|
967
|
+
var Accordion = Object.assign(AccordionRoot, {
|
|
968
|
+
Root: AccordionRoot,
|
|
969
|
+
Item: AccordionItem,
|
|
970
|
+
Header: AccordionHeader,
|
|
971
|
+
Content: AccordionContent
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
// src/components/box/box.tsx
|
|
975
|
+
import clsx6 from "clsx";
|
|
976
|
+
import * as React5 from "react";
|
|
977
|
+
|
|
978
|
+
// src/components/box/box.props.ts
|
|
979
|
+
var BoxPropsDefs = {
|
|
980
|
+
/**
|
|
981
|
+
* Defines wether the Box is rendered as a **div** or **span**.
|
|
982
|
+
*
|
|
983
|
+
* @example
|
|
984
|
+
* as="div"
|
|
985
|
+
* as="span"
|
|
986
|
+
*/
|
|
987
|
+
// as: {
|
|
988
|
+
// type: "enum",
|
|
989
|
+
// values: boxAs,
|
|
990
|
+
// default: "div",
|
|
991
|
+
// } satisfies PropDef<(typeof boxAs)[number]>,
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
// src/components/box/box.tsx
|
|
995
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
996
|
+
var Box = React5.forwardRef((props, ref) => {
|
|
997
|
+
const { className, dataAttrs, children, ...rest } = getComponentProps(
|
|
998
|
+
props,
|
|
999
|
+
BoxPropsDefs,
|
|
1000
|
+
MarginPropDefs,
|
|
1001
|
+
PaddingPropDefs,
|
|
1002
|
+
SpacingPropDef,
|
|
1003
|
+
RadiusPropDefs,
|
|
1004
|
+
RoundnessPropDef
|
|
1005
|
+
);
|
|
1006
|
+
return /* @__PURE__ */ jsx5(
|
|
1007
|
+
"div",
|
|
1008
|
+
{
|
|
1009
|
+
ref,
|
|
1010
|
+
...dataAttrs,
|
|
1011
|
+
className: clsx6("lcs-box", className),
|
|
1012
|
+
...rest,
|
|
1013
|
+
children
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
});
|
|
1017
|
+
Box.displayName = "Box";
|
|
1018
|
+
|
|
1019
|
+
// src/components/button/button.tsx
|
|
1020
|
+
import clsx7 from "clsx";
|
|
1021
|
+
import { useState as useState2 } from "react";
|
|
1022
|
+
|
|
1023
|
+
// src/components/button/button.props.ts
|
|
1024
|
+
var ButtonVariants = ["solid", "outlined", "muted", "clear"];
|
|
1025
|
+
var ButtonRootPropsDefs = {
|
|
1026
|
+
/**
|
|
1027
|
+
* Sets the variant style of the button ("solid", "outlined", "muted", or "clear").
|
|
1028
|
+
*/
|
|
1029
|
+
variant: {
|
|
1030
|
+
type: "enum",
|
|
1031
|
+
values: ButtonVariants,
|
|
1032
|
+
dataAttr: "variant"
|
|
1033
|
+
},
|
|
1034
|
+
/**
|
|
1035
|
+
* Enables high contrast mode for better visibility.
|
|
1036
|
+
* @default undefined
|
|
1037
|
+
*/
|
|
1038
|
+
highContrast: {
|
|
1039
|
+
type: "boolean",
|
|
1040
|
+
dataAttr: "high-contrast"
|
|
1041
|
+
},
|
|
1042
|
+
/**
|
|
1043
|
+
* Disables the button component.
|
|
1044
|
+
* @default undefined
|
|
1045
|
+
*/
|
|
1046
|
+
disabled: {
|
|
1047
|
+
type: "boolean",
|
|
1048
|
+
dataAttr: "disabled"
|
|
1049
|
+
},
|
|
1050
|
+
/**
|
|
1051
|
+
* Makes the button read-only.
|
|
1052
|
+
* @default undefined
|
|
1053
|
+
*/
|
|
1054
|
+
readonly: {
|
|
1055
|
+
type: "boolean",
|
|
1056
|
+
dataAttr: "readonly"
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
// src/components/button/button.tsx
|
|
1061
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1062
|
+
var Button = (props) => {
|
|
1063
|
+
const {
|
|
1064
|
+
color,
|
|
1065
|
+
variant,
|
|
1066
|
+
className,
|
|
1067
|
+
dataAttrs,
|
|
1068
|
+
disabled,
|
|
1069
|
+
highContrast,
|
|
1070
|
+
readonly,
|
|
1071
|
+
...rest
|
|
1072
|
+
} = getComponentProps(
|
|
1073
|
+
props,
|
|
1074
|
+
ButtonRootPropsDefs,
|
|
1075
|
+
MarginPropDefs,
|
|
1076
|
+
PaddingPropDefs,
|
|
1077
|
+
RadiusPropDefs,
|
|
1078
|
+
SizePropDef
|
|
1079
|
+
);
|
|
1080
|
+
const [hovered, setHovered] = useState2(false);
|
|
1081
|
+
return /* @__PURE__ */ jsx6(
|
|
1082
|
+
"button",
|
|
1083
|
+
{
|
|
1084
|
+
className: clsx7("button", className),
|
|
1085
|
+
"data-color": color ?? true,
|
|
1086
|
+
"data-variant": variant,
|
|
1087
|
+
"data-disabled": disabled ? true : void 0,
|
|
1088
|
+
"data-high-contrast": highContrast ? true : void 0,
|
|
1089
|
+
"data-readonly": readonly ? true : void 0,
|
|
1090
|
+
"data-hovered": hovered ? true : void 0,
|
|
1091
|
+
...dataAttrs,
|
|
1092
|
+
disabled: disabled || readonly,
|
|
1093
|
+
onMouseEnter: () => setHovered(true),
|
|
1094
|
+
onMouseLeave: () => setHovered(false),
|
|
1095
|
+
...rest,
|
|
1096
|
+
children: /* @__PURE__ */ jsx6("span", { children: props.children })
|
|
1097
|
+
}
|
|
1098
|
+
);
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
// src/components/checkbox/indicator/checkbox-indicator.tsx
|
|
1102
|
+
import clsx8 from "clsx";
|
|
1103
|
+
import React7 from "react";
|
|
1104
|
+
|
|
1105
|
+
// src/icons/check-mark.icon.tsx
|
|
1106
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1107
|
+
var CheckMark = ({ color = "currentColor" }) => {
|
|
1108
|
+
return /* @__PURE__ */ jsx7(
|
|
1109
|
+
"svg",
|
|
1110
|
+
{
|
|
1111
|
+
width: "64",
|
|
1112
|
+
height: "64",
|
|
1113
|
+
viewBox: "0 0 15 15",
|
|
1114
|
+
fill: "none",
|
|
1115
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1116
|
+
children: /* @__PURE__ */ jsx7(
|
|
1117
|
+
"path",
|
|
1118
|
+
{
|
|
1119
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
|
1120
|
+
fill: colorMap[color],
|
|
1121
|
+
fillRule: "evenodd",
|
|
1122
|
+
clipRule: "evenodd"
|
|
1123
|
+
}
|
|
1124
|
+
)
|
|
1125
|
+
}
|
|
1126
|
+
);
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
// src/icons/minus.icon.tsx
|
|
1130
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1131
|
+
var Minus = ({ color = "currentColor" }) => {
|
|
1132
|
+
return /* @__PURE__ */ jsx8(
|
|
1133
|
+
"svg",
|
|
1134
|
+
{
|
|
1135
|
+
width: "64",
|
|
1136
|
+
height: "64",
|
|
1137
|
+
viewBox: "0 0 15 15",
|
|
1138
|
+
fill: "none",
|
|
1139
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1140
|
+
children: /* @__PURE__ */ jsx8(
|
|
1141
|
+
"path",
|
|
1142
|
+
{
|
|
1143
|
+
d: "M3.5 7.5C3.5 7.08579 3.83579 6.75 4.25 6.75H10.75C11.1642 6.75 11.5 7.08579 11.5 7.5C11.5 7.91421 11.1642 8.25 10.75 8.25H4.25C3.83579 8.25 3.5 7.91421 3.5 7.5Z",
|
|
1144
|
+
fill: colorMap[color],
|
|
1145
|
+
fillRule: "evenodd",
|
|
1146
|
+
clipRule: "evenodd"
|
|
1147
|
+
}
|
|
1148
|
+
)
|
|
1149
|
+
}
|
|
1150
|
+
);
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
// src/components/checkbox/checkbox-context.ts
|
|
1154
|
+
import React6 from "react";
|
|
1155
|
+
var CheckboxContext = React6.createContext(
|
|
1156
|
+
null
|
|
1157
|
+
);
|
|
1158
|
+
function useCheckboxContext() {
|
|
1159
|
+
const context = React6.useContext(CheckboxContext);
|
|
1160
|
+
if (!context) {
|
|
1161
|
+
throw new Error("Checkbox components must be used within a Checkbox.Root");
|
|
1162
|
+
}
|
|
1163
|
+
return context;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
// src/components/checkbox/root/checkbox-root.props.ts
|
|
1167
|
+
var CheckboxVariants = ["solid", "outlined", "muted"];
|
|
1168
|
+
var CheckboxRootPropsDefs = {
|
|
1169
|
+
/**
|
|
1170
|
+
* Sets the variant style of the checkbox ("solid" or "outlined").
|
|
1171
|
+
*/
|
|
1172
|
+
variant: {
|
|
1173
|
+
type: "enum",
|
|
1174
|
+
values: CheckboxVariants,
|
|
1175
|
+
dataAttr: "variant"
|
|
1176
|
+
},
|
|
1177
|
+
/**
|
|
1178
|
+
* Sets the checked state of the checkbox.
|
|
1179
|
+
*
|
|
1180
|
+
* When using an uncontrolled checkbox, use `defaultChecked` instead.
|
|
1181
|
+
* @default undefined
|
|
1182
|
+
*/
|
|
1183
|
+
checked: {
|
|
1184
|
+
type: "boolean",
|
|
1185
|
+
dataAttr: "checked"
|
|
1186
|
+
},
|
|
1187
|
+
/**
|
|
1188
|
+
* Sets the indeterminate state of the checkbox.
|
|
1189
|
+
* @default undefined
|
|
1190
|
+
*/
|
|
1191
|
+
indeterminate: {
|
|
1192
|
+
type: "boolean",
|
|
1193
|
+
dataAttr: "indeterminate"
|
|
1194
|
+
},
|
|
1195
|
+
/**
|
|
1196
|
+
* Enables high contrast mode for better visibility.
|
|
1197
|
+
* @default undefined
|
|
1198
|
+
*/
|
|
1199
|
+
highContrast: {
|
|
1200
|
+
type: "boolean",
|
|
1201
|
+
dataAttr: "high-contrast"
|
|
1202
|
+
},
|
|
1203
|
+
/**
|
|
1204
|
+
* The value of the checkbox (checked state).
|
|
1205
|
+
*/
|
|
1206
|
+
value: {
|
|
1207
|
+
type: "boolean"
|
|
1208
|
+
},
|
|
1209
|
+
/**
|
|
1210
|
+
* Sets the default checked state of the checkbox.
|
|
1211
|
+
* @default undefined
|
|
1212
|
+
*/
|
|
1213
|
+
defaultChecked: {
|
|
1214
|
+
type: "boolean"
|
|
1215
|
+
},
|
|
1216
|
+
/**
|
|
1217
|
+
* Disables the checkbox component.
|
|
1218
|
+
* @default undefined
|
|
1219
|
+
*/
|
|
1220
|
+
disabled: {
|
|
1221
|
+
type: "boolean",
|
|
1222
|
+
dataAttr: "disabled"
|
|
1223
|
+
},
|
|
1224
|
+
/**
|
|
1225
|
+
* Makes the checkbox read-only.
|
|
1226
|
+
* @default undefined
|
|
1227
|
+
*/
|
|
1228
|
+
readonly: {
|
|
1229
|
+
type: "boolean",
|
|
1230
|
+
dataAttr: "readonly"
|
|
1231
|
+
},
|
|
1232
|
+
/**
|
|
1233
|
+
* Marks the checkbox as required.
|
|
1234
|
+
* @default undefined
|
|
1235
|
+
*/
|
|
1236
|
+
required: {
|
|
1237
|
+
type: "boolean",
|
|
1238
|
+
dataAttr: "required"
|
|
1239
|
+
},
|
|
1240
|
+
/**
|
|
1241
|
+
* Sets the name attribute of the checkbox input for form control.
|
|
1242
|
+
* @default undefined
|
|
1243
|
+
*/
|
|
1244
|
+
name: {
|
|
1245
|
+
type: "string"
|
|
1246
|
+
},
|
|
1247
|
+
/**
|
|
1248
|
+
* Callback fired when the checked state changes.
|
|
1249
|
+
*
|
|
1250
|
+
* @param value - The new checked state.
|
|
1251
|
+
*/
|
|
1252
|
+
onCheckedChange: {
|
|
1253
|
+
type: "function"
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
// src/components/checkbox/indicator/checkbox-indicator.props.ts
|
|
1258
|
+
var CheckboxIndicatorPropDefs = {
|
|
1259
|
+
/**
|
|
1260
|
+
* Sets the variant style of the checkbox ("solid" or "outlined").
|
|
1261
|
+
*/
|
|
1262
|
+
variant: {
|
|
1263
|
+
type: "enum",
|
|
1264
|
+
values: CheckboxVariants,
|
|
1265
|
+
dataAttr: "variant"
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
|
|
1269
|
+
// src/components/checkbox/indicator/checkbox-indicator.tsx
|
|
1270
|
+
import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1271
|
+
var CheckboxIndicator = React7.forwardRef((props, ref) => {
|
|
1272
|
+
const {
|
|
1273
|
+
value,
|
|
1274
|
+
setValue,
|
|
1275
|
+
hovered,
|
|
1276
|
+
color,
|
|
1277
|
+
disabled,
|
|
1278
|
+
readonly,
|
|
1279
|
+
highContrast,
|
|
1280
|
+
indeterminate,
|
|
1281
|
+
variant: contextVariant
|
|
1282
|
+
} = useCheckboxContext();
|
|
1283
|
+
const { size, variant, className, style, dataAttrs } = getComponentProps(
|
|
1284
|
+
props,
|
|
1285
|
+
CheckboxIndicatorPropDefs,
|
|
1286
|
+
SizePropDef
|
|
1287
|
+
);
|
|
1288
|
+
const indicatorVariant = variant || contextVariant;
|
|
1289
|
+
const handleKeyDown = (event) => {
|
|
1290
|
+
if (disabled || readonly) return;
|
|
1291
|
+
if (event.key === " " || event.key === "Enter") {
|
|
1292
|
+
event.preventDefault();
|
|
1293
|
+
setValue(!value);
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
const indicatorProps = {
|
|
1297
|
+
...value && { "data-checked": true },
|
|
1298
|
+
...disabled && { "data-disabled": true },
|
|
1299
|
+
...readonly && { "data-readonly": true },
|
|
1300
|
+
...highContrast && { "data-high-contrast": true },
|
|
1301
|
+
...indeterminate && { "data-indeterminate": true },
|
|
1302
|
+
...(variant || contextVariant) && { "data-variant": indicatorVariant }
|
|
1303
|
+
};
|
|
1304
|
+
return /* @__PURE__ */ jsxs3(
|
|
1305
|
+
"span",
|
|
1306
|
+
{
|
|
1307
|
+
ref,
|
|
1308
|
+
style,
|
|
1309
|
+
role: "checkbox",
|
|
1310
|
+
"data-color": color,
|
|
1311
|
+
"data-hovered": hovered,
|
|
1312
|
+
"aria-disabled": disabled,
|
|
1313
|
+
"aria-readonly": readonly,
|
|
1314
|
+
"aria-checked": indeterminate ? "mixed" : value,
|
|
1315
|
+
onKeyDown: handleKeyDown,
|
|
1316
|
+
tabIndex: disabled || readonly ? -1 : 0,
|
|
1317
|
+
className: clsx8("checkbox-indicator", className),
|
|
1318
|
+
...indicatorProps,
|
|
1319
|
+
...dataAttrs,
|
|
1320
|
+
children: [
|
|
1321
|
+
indeterminate && !value && /* @__PURE__ */ jsx9(
|
|
1322
|
+
Minus,
|
|
1323
|
+
{
|
|
1324
|
+
color: highContrast && indicatorVariant === "solid" ? "black" : "white"
|
|
1325
|
+
}
|
|
1326
|
+
),
|
|
1327
|
+
value && /* @__PURE__ */ jsx9(
|
|
1328
|
+
CheckMark,
|
|
1329
|
+
{
|
|
1330
|
+
color: highContrast && indicatorVariant === "solid" ? "black" : "white"
|
|
1331
|
+
}
|
|
1332
|
+
)
|
|
1333
|
+
]
|
|
1334
|
+
}
|
|
1335
|
+
);
|
|
1336
|
+
});
|
|
1337
|
+
CheckboxIndicator.displayName = "Checkbox.Indicator";
|
|
1338
|
+
|
|
1339
|
+
// src/components/checkbox/label/checkbox-label.tsx
|
|
1340
|
+
import clsx10 from "clsx";
|
|
1341
|
+
import React9 from "react";
|
|
1342
|
+
|
|
1343
|
+
// src/components/text/text.tsx
|
|
1344
|
+
import clsx9 from "clsx";
|
|
1345
|
+
import React8 from "react";
|
|
1346
|
+
|
|
1347
|
+
// src/components/text/text.props.ts
|
|
1348
|
+
var TextPropsDefs = {
|
|
1349
|
+
disabled: {
|
|
1350
|
+
type: "boolean",
|
|
1351
|
+
default: false,
|
|
1352
|
+
dataAttr: "disabled"
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Defines wether the Text is rendered as a **p**, **span** or **div**.
|
|
1356
|
+
*
|
|
1357
|
+
* @example
|
|
1358
|
+
* as="p"
|
|
1359
|
+
* as="span"
|
|
1360
|
+
* as="div"
|
|
1361
|
+
*/
|
|
1362
|
+
// as: {
|
|
1363
|
+
// type: "enum",
|
|
1364
|
+
// values: textAs,
|
|
1365
|
+
// default: "p",
|
|
1366
|
+
// } satisfies PropDef<(typeof textAs)[number]>,
|
|
1367
|
+
};
|
|
1368
|
+
|
|
1369
|
+
// src/components/text/text.tsx
|
|
1370
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1371
|
+
var Text = React8.forwardRef(
|
|
1372
|
+
(props, ref) => {
|
|
1373
|
+
const { className, dataAttrs, children, ...rest } = getComponentProps(
|
|
1374
|
+
props,
|
|
1375
|
+
TextPropsDefs,
|
|
1376
|
+
MarginPropDefs,
|
|
1377
|
+
PaddingPropDefs
|
|
1378
|
+
);
|
|
1379
|
+
return /* @__PURE__ */ jsx10(
|
|
1380
|
+
"p",
|
|
1381
|
+
{
|
|
1382
|
+
ref,
|
|
1383
|
+
...dataAttrs,
|
|
1384
|
+
className: clsx9("lcs-text", className),
|
|
1385
|
+
...rest,
|
|
1386
|
+
children
|
|
1387
|
+
}
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
);
|
|
1391
|
+
|
|
1392
|
+
// src/components/checkbox/label/checkbox-label.props.ts
|
|
1393
|
+
var labelPositions = ["top", "left", "right", "bottom"];
|
|
1394
|
+
var CheckboxLabelPropDefs = {
|
|
1395
|
+
/**
|
|
1396
|
+
* Sets the position of the label relative to the checkbox.
|
|
1397
|
+
*
|
|
1398
|
+
* @example position="left" // positions the label to the left of the checkbox
|
|
1399
|
+
* @example position="top" // positions the label above the checkbox
|
|
1400
|
+
*/
|
|
1401
|
+
position: {
|
|
1402
|
+
type: "enum",
|
|
1403
|
+
values: labelPositions,
|
|
1404
|
+
dataAttr: "position"
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
// src/components/checkbox/label/checkbox-label.tsx
|
|
1409
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1410
|
+
var CheckboxLabel = React9.forwardRef(
|
|
1411
|
+
(props, ref) => {
|
|
1412
|
+
const context = useCheckboxContext();
|
|
1413
|
+
const { className, children, position } = getComponentProps(
|
|
1414
|
+
props,
|
|
1415
|
+
CheckboxLabelPropDefs
|
|
1416
|
+
);
|
|
1417
|
+
React9.useLayoutEffect(() => {
|
|
1418
|
+
context.setLabelPosition?.(position ?? "right");
|
|
1419
|
+
}, [position, context.setLabelPosition]);
|
|
1420
|
+
return /* @__PURE__ */ jsx11(
|
|
1421
|
+
"label",
|
|
1422
|
+
{
|
|
1423
|
+
ref,
|
|
1424
|
+
htmlFor: context.labelId,
|
|
1425
|
+
className: clsx10("checkbox-label", className),
|
|
1426
|
+
...position && { [`data-position`]: position },
|
|
1427
|
+
children: /* @__PURE__ */ jsx11(Text, { children })
|
|
1428
|
+
}
|
|
1429
|
+
);
|
|
1430
|
+
}
|
|
1431
|
+
);
|
|
1432
|
+
CheckboxLabel.displayName = "Checkbox.Label";
|
|
1433
|
+
|
|
1434
|
+
// src/components/checkbox/root/checkbox-root.tsx
|
|
1435
|
+
import clsx11 from "clsx";
|
|
1436
|
+
import {
|
|
1437
|
+
isValidElement as isValidElement2,
|
|
1438
|
+
useId,
|
|
1439
|
+
useMemo as useMemo3,
|
|
1440
|
+
useState as useState3
|
|
1441
|
+
} from "react";
|
|
1442
|
+
import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1443
|
+
var ALLOWED_CHILDREN3 = [
|
|
1444
|
+
CheckboxLabel.displayName,
|
|
1445
|
+
CheckboxIndicator.displayName
|
|
1446
|
+
];
|
|
1447
|
+
var CheckboxRoot = (props) => {
|
|
1448
|
+
const {
|
|
1449
|
+
name,
|
|
1450
|
+
size,
|
|
1451
|
+
color,
|
|
1452
|
+
variant,
|
|
1453
|
+
checked,
|
|
1454
|
+
dataAttrs,
|
|
1455
|
+
onCheckedChange,
|
|
1456
|
+
value: valueProp,
|
|
1457
|
+
disabled = false,
|
|
1458
|
+
required = false,
|
|
1459
|
+
readonly = false,
|
|
1460
|
+
highContrast = false,
|
|
1461
|
+
indeterminate = false,
|
|
1462
|
+
defaultChecked = false
|
|
1463
|
+
} = getComponentProps(
|
|
1464
|
+
props,
|
|
1465
|
+
CheckboxRootPropsDefs,
|
|
1466
|
+
AlignPropDef,
|
|
1467
|
+
MarginPropDefs,
|
|
1468
|
+
SizePropDef
|
|
1469
|
+
);
|
|
1470
|
+
const [value, setValue] = useControllableState({
|
|
1471
|
+
value: valueProp || checked,
|
|
1472
|
+
defaultValue: defaultChecked,
|
|
1473
|
+
onChange: onCheckedChange
|
|
1474
|
+
});
|
|
1475
|
+
const labelId = useId();
|
|
1476
|
+
const [labelPosition, setLabelPosition] = useState3("right");
|
|
1477
|
+
const [hovered, setHovered] = useState3(false);
|
|
1478
|
+
const validChildren = filterChildren(props.children, ALLOWED_CHILDREN3, {
|
|
1479
|
+
parentDisplayName: CheckboxRoot.displayName
|
|
1480
|
+
});
|
|
1481
|
+
const { indicator, otherChildren } = useMemo3(() => {
|
|
1482
|
+
const indicatorIndex = validChildren.findIndex(
|
|
1483
|
+
(child) => isValidElement2(child) && child.type.displayName === CheckboxIndicator.displayName
|
|
1484
|
+
);
|
|
1485
|
+
if (indicatorIndex > -1) {
|
|
1486
|
+
return {
|
|
1487
|
+
indicator: validChildren[indicatorIndex],
|
|
1488
|
+
otherChildren: validChildren.filter((_, i) => i !== indicatorIndex)
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
return {
|
|
1492
|
+
indicator: /* @__PURE__ */ jsx12(CheckboxIndicator, { size }),
|
|
1493
|
+
otherChildren: validChildren
|
|
1494
|
+
};
|
|
1495
|
+
}, [validChildren, size]);
|
|
1496
|
+
const contextValue = useMemo3(
|
|
1497
|
+
() => ({
|
|
1498
|
+
name,
|
|
1499
|
+
value,
|
|
1500
|
+
color,
|
|
1501
|
+
setValue,
|
|
1502
|
+
onCheckedChange,
|
|
1503
|
+
labelId,
|
|
1504
|
+
labelPosition,
|
|
1505
|
+
setLabelPosition,
|
|
1506
|
+
variant,
|
|
1507
|
+
hovered,
|
|
1508
|
+
setHovered,
|
|
1509
|
+
disabled,
|
|
1510
|
+
readonly,
|
|
1511
|
+
required,
|
|
1512
|
+
indeterminate,
|
|
1513
|
+
highContrast
|
|
1514
|
+
}),
|
|
1515
|
+
[
|
|
1516
|
+
name,
|
|
1517
|
+
value,
|
|
1518
|
+
color,
|
|
1519
|
+
onCheckedChange,
|
|
1520
|
+
setValue,
|
|
1521
|
+
labelId,
|
|
1522
|
+
labelPosition,
|
|
1523
|
+
hovered,
|
|
1524
|
+
disabled,
|
|
1525
|
+
readonly,
|
|
1526
|
+
required,
|
|
1527
|
+
indeterminate,
|
|
1528
|
+
highContrast
|
|
1529
|
+
]
|
|
1530
|
+
);
|
|
1531
|
+
const handleClick = () => {
|
|
1532
|
+
if (disabled || readonly) return;
|
|
1533
|
+
setValue(!value);
|
|
1534
|
+
};
|
|
1535
|
+
return /* @__PURE__ */ jsx12(CheckboxContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs4(
|
|
1536
|
+
"div",
|
|
1537
|
+
{
|
|
1538
|
+
className: clsx11("checkbox-root", props.className),
|
|
1539
|
+
onClick: () => handleClick(),
|
|
1540
|
+
onMouseEnter: () => setHovered(true),
|
|
1541
|
+
onMouseLeave: () => setHovered(false),
|
|
1542
|
+
...dataAttrs,
|
|
1543
|
+
children: [
|
|
1544
|
+
indicator,
|
|
1545
|
+
otherChildren,
|
|
1546
|
+
name && /* @__PURE__ */ jsx12("input", { type: "hidden", name, value: String(value) })
|
|
1547
|
+
]
|
|
1548
|
+
}
|
|
1549
|
+
) });
|
|
1550
|
+
};
|
|
1551
|
+
CheckboxRoot.displayName = "Checkbox";
|
|
1552
|
+
|
|
1553
|
+
// src/components/checkbox/checkbox.tsx
|
|
1554
|
+
var Checkbox = Object.assign(CheckboxRoot, {
|
|
1555
|
+
Root: CheckboxRoot,
|
|
1556
|
+
Label: CheckboxLabel,
|
|
1557
|
+
Indicator: CheckboxIndicator
|
|
1558
|
+
});
|
|
1559
|
+
|
|
1560
|
+
// src/components/container/container.tsx
|
|
1561
|
+
import clsx12 from "clsx";
|
|
1562
|
+
import * as React11 from "react";
|
|
1563
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1564
|
+
var Container = React11.forwardRef((props, ref) => {
|
|
1565
|
+
const { className, children, direction, ...rest } = props;
|
|
1566
|
+
return /* @__PURE__ */ jsx13(
|
|
1567
|
+
"div",
|
|
1568
|
+
{
|
|
1569
|
+
ref,
|
|
1570
|
+
"data-direction": direction,
|
|
1571
|
+
className: clsx12(className, "lcs-container"),
|
|
1572
|
+
...rest,
|
|
1573
|
+
children
|
|
1574
|
+
}
|
|
1575
|
+
);
|
|
1576
|
+
});
|
|
1577
|
+
Container.displayName = "Container";
|
|
1578
|
+
|
|
1579
|
+
// src/components/portal/backdrop/portal-backdrop.tsx
|
|
1580
|
+
import clsx13 from "clsx";
|
|
1581
|
+
import * as React13 from "react";
|
|
1582
|
+
|
|
1583
|
+
// src/components/portal/portal-context.tsx
|
|
1584
|
+
import * as React12 from "react";
|
|
1585
|
+
var PortalContext = React12.createContext(
|
|
1586
|
+
void 0
|
|
1587
|
+
);
|
|
1588
|
+
function usePortalContext() {
|
|
1589
|
+
const context = React12.useContext(PortalContext);
|
|
1590
|
+
if (!context) {
|
|
1591
|
+
throw new Error("`usePortalContext` must be used within a `Portal.Root`");
|
|
1592
|
+
}
|
|
1593
|
+
return context;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
// src/components/portal/backdrop/portal-backdrop.props.ts
|
|
1597
|
+
var variants = ["clear", "shadow", "blurred"];
|
|
1598
|
+
var PortalBackdropPropsDefs = {
|
|
1599
|
+
/**
|
|
1600
|
+
* The visual style variant of the backdrop.
|
|
1601
|
+
*
|
|
1602
|
+
* @example variant="blurred" // Applies a blurred effect to the backdrop
|
|
1603
|
+
* @default "clear"
|
|
1604
|
+
*/
|
|
1605
|
+
variant: {
|
|
1606
|
+
type: "enum",
|
|
1607
|
+
values: variants,
|
|
1608
|
+
default: "clear",
|
|
1609
|
+
dataAttr: "variant"
|
|
1610
|
+
},
|
|
1611
|
+
/**
|
|
1612
|
+
* The opacity level of the backdrop.
|
|
1613
|
+
*
|
|
1614
|
+
* @example opacity="0.5" // Sets the backdrop opacity to 50%
|
|
1615
|
+
* @default "0.3"
|
|
1616
|
+
*/
|
|
1617
|
+
opacity: {
|
|
1618
|
+
type: "string",
|
|
1619
|
+
default: "0.3",
|
|
1620
|
+
cssProperty: "--backdrop-opacity"
|
|
1621
|
+
},
|
|
1622
|
+
/**
|
|
1623
|
+
* The blur amount applied to the backdrop when the "blurred" variant is used.
|
|
1624
|
+
*
|
|
1625
|
+
* @example blur="4px" // Sets the backdrop blur to 4 pixels
|
|
1626
|
+
* @default "2px"
|
|
1627
|
+
*/
|
|
1628
|
+
blur: {
|
|
1629
|
+
type: "string",
|
|
1630
|
+
default: "2px",
|
|
1631
|
+
cssProperty: "--backdrop-blur"
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
// src/components/portal/backdrop/portal-backdrop.tsx
|
|
1636
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1637
|
+
var PortalBackdrop = React13.forwardRef(
|
|
1638
|
+
(props, ref) => {
|
|
1639
|
+
const context = usePortalContext();
|
|
1640
|
+
const { className, dataAttrs, ...rest } = getComponentProps(
|
|
1641
|
+
props,
|
|
1642
|
+
PortalBackdropPropsDefs
|
|
1643
|
+
);
|
|
1644
|
+
if (!context.open) return null;
|
|
1645
|
+
return /* @__PURE__ */ jsx14(
|
|
1646
|
+
"div",
|
|
1647
|
+
{
|
|
1648
|
+
ref,
|
|
1649
|
+
className: clsx13("portal-backdrop", className),
|
|
1650
|
+
...dataAttrs,
|
|
1651
|
+
...rest
|
|
1652
|
+
}
|
|
1653
|
+
);
|
|
1654
|
+
}
|
|
1655
|
+
);
|
|
1656
|
+
PortalBackdrop.displayName = "Portal.Backdrop";
|
|
1657
|
+
|
|
1658
|
+
// src/components/portal/content/portal-content.tsx
|
|
1659
|
+
import clsx14 from "clsx";
|
|
1660
|
+
import * as React16 from "react";
|
|
1661
|
+
import ReactDOM from "react-dom";
|
|
1662
|
+
|
|
1663
|
+
// src/components/theme/theme-context.tsx
|
|
1664
|
+
import * as React14 from "react";
|
|
1665
|
+
var ThemeContext = React14.createContext(
|
|
1666
|
+
void 0
|
|
1667
|
+
);
|
|
1668
|
+
function useTheme() {
|
|
1669
|
+
const context = React14.useContext(ThemeContext);
|
|
1670
|
+
if (!context) {
|
|
1671
|
+
throw new Error("`useTheme` must be used within a `Theme`");
|
|
1672
|
+
}
|
|
1673
|
+
return context;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
// src/components/portal/utils/use-anchor-position.ts
|
|
1677
|
+
import * as React15 from "react";
|
|
1678
|
+
function useAnchorPosition({
|
|
1679
|
+
anchorRef,
|
|
1680
|
+
contentRef,
|
|
1681
|
+
side = "bottom",
|
|
1682
|
+
align = "center",
|
|
1683
|
+
sideOffset = 0,
|
|
1684
|
+
alignOffset = 0,
|
|
1685
|
+
enabled = true
|
|
1686
|
+
}) {
|
|
1687
|
+
const [position, setPosition] = React15.useState(null);
|
|
1688
|
+
const [, _forceUpdate] = React15.useReducer((x) => x + 1, 0);
|
|
1689
|
+
const updatePosition = React15.useCallback(() => {
|
|
1690
|
+
const anchor = anchorRef.current;
|
|
1691
|
+
const content = contentRef.current;
|
|
1692
|
+
if (!anchor || !content || !enabled) {
|
|
1693
|
+
setPosition(null);
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
1697
|
+
const contentRect = content.getBoundingClientRect();
|
|
1698
|
+
let top = 0;
|
|
1699
|
+
let left = 0;
|
|
1700
|
+
switch (side) {
|
|
1701
|
+
case "top":
|
|
1702
|
+
top = anchorRect.top - contentRect.height - sideOffset;
|
|
1703
|
+
break;
|
|
1704
|
+
case "bottom":
|
|
1705
|
+
top = anchorRect.bottom + sideOffset;
|
|
1706
|
+
break;
|
|
1707
|
+
case "left":
|
|
1708
|
+
left = anchorRect.left - contentRect.width - sideOffset;
|
|
1709
|
+
break;
|
|
1710
|
+
case "right":
|
|
1711
|
+
left = anchorRect.right + sideOffset;
|
|
1712
|
+
break;
|
|
1713
|
+
}
|
|
1714
|
+
if (side === "top" || side === "bottom") {
|
|
1715
|
+
switch (align) {
|
|
1716
|
+
case "start":
|
|
1717
|
+
left = anchorRect.left + alignOffset;
|
|
1718
|
+
break;
|
|
1719
|
+
case "center":
|
|
1720
|
+
left = anchorRect.left + (anchorRect.width - contentRect.width) / 2 + alignOffset;
|
|
1721
|
+
break;
|
|
1722
|
+
case "end":
|
|
1723
|
+
left = anchorRect.right - contentRect.width + alignOffset;
|
|
1724
|
+
break;
|
|
1725
|
+
}
|
|
1726
|
+
} else {
|
|
1727
|
+
switch (align) {
|
|
1728
|
+
case "start":
|
|
1729
|
+
top = anchorRect.top + alignOffset;
|
|
1730
|
+
break;
|
|
1731
|
+
case "center":
|
|
1732
|
+
top = anchorRect.top + (anchorRect.height - contentRect.height) / 2 + alignOffset;
|
|
1733
|
+
break;
|
|
1734
|
+
case "end":
|
|
1735
|
+
top = anchorRect.bottom - contentRect.height + alignOffset;
|
|
1736
|
+
break;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
top += window.scrollY;
|
|
1740
|
+
left += window.scrollX;
|
|
1741
|
+
const viewportWidth = window.innerWidth;
|
|
1742
|
+
const viewportHeight = window.innerHeight;
|
|
1743
|
+
left = Math.max(0, Math.min(left, viewportWidth - contentRect.width));
|
|
1744
|
+
top = Math.max(
|
|
1745
|
+
0,
|
|
1746
|
+
Math.min(top, viewportHeight - contentRect.height + window.scrollY)
|
|
1747
|
+
);
|
|
1748
|
+
setPosition({ top, left });
|
|
1749
|
+
}, [anchorRef, contentRef, side, align, sideOffset, alignOffset, enabled]);
|
|
1750
|
+
React15.useEffect(() => {
|
|
1751
|
+
if (!enabled) {
|
|
1752
|
+
setPosition(null);
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
let attempts = 0;
|
|
1756
|
+
const maxAttempts = 10;
|
|
1757
|
+
const tryUpdate = () => {
|
|
1758
|
+
attempts++;
|
|
1759
|
+
if (anchorRef.current && contentRef.current) {
|
|
1760
|
+
updatePosition();
|
|
1761
|
+
} else if (attempts < maxAttempts) {
|
|
1762
|
+
requestAnimationFrame(tryUpdate);
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
requestAnimationFrame(tryUpdate);
|
|
1766
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
1767
|
+
window.addEventListener("resize", updatePosition);
|
|
1768
|
+
return () => {
|
|
1769
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
1770
|
+
window.removeEventListener("resize", updatePosition);
|
|
1771
|
+
};
|
|
1772
|
+
}, [enabled, updatePosition, anchorRef, contentRef]);
|
|
1773
|
+
return position;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
// src/components/portal/content/portal-content.props.ts
|
|
1777
|
+
var positions = [
|
|
1778
|
+
"tl",
|
|
1779
|
+
"top",
|
|
1780
|
+
"tr",
|
|
1781
|
+
"left",
|
|
1782
|
+
"center",
|
|
1783
|
+
"right",
|
|
1784
|
+
"bl",
|
|
1785
|
+
"bottom",
|
|
1786
|
+
"br"
|
|
1787
|
+
];
|
|
1788
|
+
var anchorSides = ["top", "right", "bottom", "left"];
|
|
1789
|
+
var PortalContentPropsDefs = {
|
|
1790
|
+
/**
|
|
1791
|
+
* The position of the portal content relative to the screen if no anchor is used.
|
|
1792
|
+
*
|
|
1793
|
+
* @example position="bl" // Portal renders at bottom-left of the screen
|
|
1794
|
+
*/
|
|
1795
|
+
position: {
|
|
1796
|
+
type: "enum",
|
|
1797
|
+
values: positions,
|
|
1798
|
+
default: "center",
|
|
1799
|
+
dataAttr: "position"
|
|
1800
|
+
},
|
|
1801
|
+
/**
|
|
1802
|
+
* Whether the portal content is anchored to an element.
|
|
1803
|
+
*
|
|
1804
|
+
* When anchored, the portal content is positioned relative to the trigger element unless a custom anchorRef is provided.
|
|
1805
|
+
*/
|
|
1806
|
+
anchored: {
|
|
1807
|
+
type: "boolean",
|
|
1808
|
+
dataAttr: "anchored"
|
|
1809
|
+
},
|
|
1810
|
+
/**
|
|
1811
|
+
* The side of the anchor element to position the portal content on.
|
|
1812
|
+
*
|
|
1813
|
+
* @default "bottom"
|
|
1814
|
+
*/
|
|
1815
|
+
side: {
|
|
1816
|
+
type: "enum",
|
|
1817
|
+
values: anchorSides,
|
|
1818
|
+
default: "bottom"
|
|
1819
|
+
},
|
|
1820
|
+
/** Offset in pixels from the anchor element along the side axis. */
|
|
1821
|
+
sideOffset: {
|
|
1822
|
+
type: "string"
|
|
1823
|
+
},
|
|
1824
|
+
/** Offset in pixels along the alignment axis. */
|
|
1825
|
+
alignOffset: {
|
|
1826
|
+
type: "string"
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
|
|
1830
|
+
// src/components/portal/content/portal-content.tsx
|
|
1831
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1832
|
+
var PortalContent = React16.forwardRef(
|
|
1833
|
+
(props, ref) => {
|
|
1834
|
+
const portalContext = usePortalContext();
|
|
1835
|
+
const themeContext = React16.useContext(ThemeContext);
|
|
1836
|
+
const contentRef = React16.useRef(null);
|
|
1837
|
+
const {
|
|
1838
|
+
side = "bottom",
|
|
1839
|
+
align = "center",
|
|
1840
|
+
sideOffset = "0",
|
|
1841
|
+
alignOffset = "0",
|
|
1842
|
+
anchored = false,
|
|
1843
|
+
children,
|
|
1844
|
+
className,
|
|
1845
|
+
dataAttrs,
|
|
1846
|
+
style
|
|
1847
|
+
} = getComponentProps(props, PortalContentPropsDefs, AlignPropDef);
|
|
1848
|
+
const anchorRef = portalContext.anchorRef ?? portalContext.triggerRef;
|
|
1849
|
+
const anchorPosition = useAnchorPosition({
|
|
1850
|
+
anchorRef,
|
|
1851
|
+
contentRef,
|
|
1852
|
+
side,
|
|
1853
|
+
align,
|
|
1854
|
+
sideOffset: parseInt(sideOffset, 10) || 0,
|
|
1855
|
+
alignOffset: parseInt(alignOffset, 10) || 0,
|
|
1856
|
+
enabled: anchored && portalContext.open
|
|
1857
|
+
});
|
|
1858
|
+
const setRefs = React16.useCallback(
|
|
1859
|
+
(node) => {
|
|
1860
|
+
contentRef.current = node;
|
|
1861
|
+
if (typeof ref === "function") {
|
|
1862
|
+
ref(node);
|
|
1863
|
+
} else if (ref) {
|
|
1864
|
+
ref.current = node;
|
|
1865
|
+
}
|
|
1866
|
+
},
|
|
1867
|
+
[ref]
|
|
1868
|
+
);
|
|
1869
|
+
React16.useEffect(() => {
|
|
1870
|
+
if (!portalContext.open) return;
|
|
1871
|
+
function onKeyDown(e) {
|
|
1872
|
+
if (e.key === "Escape") {
|
|
1873
|
+
portalContext.onOpenChange?.(false);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1877
|
+
return () => {
|
|
1878
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1879
|
+
};
|
|
1880
|
+
}, [portalContext.open, portalContext.onOpenChange]);
|
|
1881
|
+
React16.useEffect(() => {
|
|
1882
|
+
if (!portalContext.open || !anchored) return;
|
|
1883
|
+
function onClickOutside(e) {
|
|
1884
|
+
const target = e.target;
|
|
1885
|
+
const content2 = contentRef.current;
|
|
1886
|
+
const trigger = (portalContext.anchorRef ?? portalContext.triggerRef)?.current;
|
|
1887
|
+
if (content2?.contains(target) || trigger?.contains(target)) {
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
portalContext.onOpenChange?.(false);
|
|
1891
|
+
}
|
|
1892
|
+
const timeoutId = setTimeout(() => {
|
|
1893
|
+
document.addEventListener("click", onClickOutside);
|
|
1894
|
+
}, 0);
|
|
1895
|
+
return () => {
|
|
1896
|
+
clearTimeout(timeoutId);
|
|
1897
|
+
document.removeEventListener("click", onClickOutside);
|
|
1898
|
+
};
|
|
1899
|
+
}, [
|
|
1900
|
+
portalContext.open,
|
|
1901
|
+
portalContext.onOpenChange,
|
|
1902
|
+
portalContext.anchorRef,
|
|
1903
|
+
portalContext.triggerRef,
|
|
1904
|
+
anchored
|
|
1905
|
+
]);
|
|
1906
|
+
const container = portalContext.open && globalThis?.document?.body;
|
|
1907
|
+
if (!container) return null;
|
|
1908
|
+
const combinedStyle = {
|
|
1909
|
+
...style,
|
|
1910
|
+
...anchored && anchorPosition ? {
|
|
1911
|
+
position: "absolute",
|
|
1912
|
+
top: anchorPosition.top,
|
|
1913
|
+
left: anchorPosition.left
|
|
1914
|
+
} : {}
|
|
1915
|
+
};
|
|
1916
|
+
const portalContent = /* @__PURE__ */ jsx15(
|
|
1917
|
+
"div",
|
|
1918
|
+
{
|
|
1919
|
+
ref: setRefs,
|
|
1920
|
+
className: clsx14("portal", className),
|
|
1921
|
+
"data-appearance": themeContext?.appearance,
|
|
1922
|
+
"data-radius": themeContext?.radius,
|
|
1923
|
+
"data-roundness": themeContext?.roundness ?? "theme",
|
|
1924
|
+
"data-spacing": themeContext?.spacing ?? "theme",
|
|
1925
|
+
"data-theme-radius": themeContext?.radius,
|
|
1926
|
+
"data-theme-roundness": themeContext?.roundness,
|
|
1927
|
+
"data-theme-spacing": themeContext?.spacing,
|
|
1928
|
+
onClick: anchored ? void 0 : () => portalContext.onOpenChange?.(false),
|
|
1929
|
+
style: combinedStyle,
|
|
1930
|
+
...dataAttrs,
|
|
1931
|
+
children: /* @__PURE__ */ jsx15(
|
|
1932
|
+
"div",
|
|
1933
|
+
{
|
|
1934
|
+
className: "portal-content",
|
|
1935
|
+
onClick: (e) => e.stopPropagation(),
|
|
1936
|
+
children
|
|
1937
|
+
}
|
|
1938
|
+
)
|
|
1939
|
+
}
|
|
1940
|
+
);
|
|
1941
|
+
const content = themeContext ? /* @__PURE__ */ jsx15(ThemeContext.Provider, { value: themeContext, children: portalContent }) : portalContent;
|
|
1942
|
+
return ReactDOM.createPortal(content, container);
|
|
1943
|
+
}
|
|
1944
|
+
);
|
|
1945
|
+
PortalContent.displayName = "Portal.Content";
|
|
1946
|
+
|
|
1947
|
+
// src/components/portal/root/portal-root.tsx
|
|
1948
|
+
import * as React18 from "react";
|
|
1949
|
+
|
|
1950
|
+
// src/components/portal/trigger/portal-trigger.tsx
|
|
1951
|
+
import * as React17 from "react";
|
|
1952
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1953
|
+
var PortalTrigger = React17.forwardRef(
|
|
1954
|
+
({ children, asChild, onClick, ...props }, ref) => {
|
|
1955
|
+
const context = usePortalContext();
|
|
1956
|
+
const internalRef = React17.useRef(null);
|
|
1957
|
+
React17.useEffect(() => {
|
|
1958
|
+
if (internalRef.current) {
|
|
1959
|
+
context.triggerRef.current = internalRef.current;
|
|
1960
|
+
}
|
|
1961
|
+
}, [context.triggerRef]);
|
|
1962
|
+
const handleClick = (event) => {
|
|
1963
|
+
context.onOpenChange?.(!context.open);
|
|
1964
|
+
onClick?.(event);
|
|
1965
|
+
};
|
|
1966
|
+
const setRefs = React17.useCallback(
|
|
1967
|
+
(node) => {
|
|
1968
|
+
internalRef.current = node;
|
|
1969
|
+
if (typeof ref === "function") {
|
|
1970
|
+
ref(node);
|
|
1971
|
+
} else if (ref) {
|
|
1972
|
+
ref.current = node;
|
|
1973
|
+
}
|
|
1974
|
+
context.triggerRef.current = node;
|
|
1975
|
+
},
|
|
1976
|
+
[ref, context.triggerRef]
|
|
1977
|
+
);
|
|
1978
|
+
if (asChild && React17.isValidElement(children)) {
|
|
1979
|
+
return React17.cloneElement(children, {
|
|
1980
|
+
ref: setRefs,
|
|
1981
|
+
onClick: handleClick,
|
|
1982
|
+
...props
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
return /* @__PURE__ */ jsx16(
|
|
1986
|
+
"button",
|
|
1987
|
+
{
|
|
1988
|
+
ref: setRefs,
|
|
1989
|
+
type: "button",
|
|
1990
|
+
onClick: handleClick,
|
|
1991
|
+
"aria-expanded": context.open,
|
|
1992
|
+
"aria-haspopup": "dialog",
|
|
1993
|
+
...props,
|
|
1994
|
+
children
|
|
1995
|
+
}
|
|
1996
|
+
);
|
|
1997
|
+
}
|
|
1998
|
+
);
|
|
1999
|
+
PortalTrigger.displayName = "Portal.Trigger";
|
|
2000
|
+
|
|
2001
|
+
// src/components/portal/root/portal-root.props.ts
|
|
2002
|
+
var PortalRootPropsDefs = {
|
|
2003
|
+
/** Whether the portal is open. */
|
|
2004
|
+
open: {
|
|
2005
|
+
type: "boolean",
|
|
2006
|
+
default: false
|
|
2007
|
+
},
|
|
2008
|
+
/** Callback fired when the open state changes. */
|
|
2009
|
+
onOpenChange: {
|
|
2010
|
+
type: "function"
|
|
2011
|
+
},
|
|
2012
|
+
/** Whether the portal is open by default (uncontrolled). */
|
|
2013
|
+
defaultOpen: {
|
|
2014
|
+
type: "boolean",
|
|
2015
|
+
default: false
|
|
2016
|
+
},
|
|
2017
|
+
/** Custom anchor element ref. If not provided, the trigger is used as anchor. */
|
|
2018
|
+
anchorRef: {
|
|
2019
|
+
type: "reactNode"
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
|
|
2023
|
+
// src/components/portal/root/portal-root.tsx
|
|
2024
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
2025
|
+
var ALLOWED_CHILDREN4 = [
|
|
2026
|
+
PortalTrigger.displayName,
|
|
2027
|
+
PortalBackdrop.displayName,
|
|
2028
|
+
PortalContent.displayName
|
|
2029
|
+
];
|
|
2030
|
+
var PortalRoot = (props) => {
|
|
2031
|
+
const {
|
|
2032
|
+
defaultOpen = false,
|
|
2033
|
+
open: portalOpen,
|
|
2034
|
+
onOpenChange,
|
|
2035
|
+
anchorRef,
|
|
2036
|
+
children
|
|
2037
|
+
} = getComponentProps(props, PortalRootPropsDefs);
|
|
2038
|
+
const [open, setOpen] = useControllableState({
|
|
2039
|
+
value: portalOpen,
|
|
2040
|
+
defaultValue: defaultOpen,
|
|
2041
|
+
onChange: onOpenChange
|
|
2042
|
+
});
|
|
2043
|
+
const triggerRef = React18.useRef(null);
|
|
2044
|
+
const value = React18.useMemo(
|
|
2045
|
+
() => ({
|
|
2046
|
+
open,
|
|
2047
|
+
onOpenChange: setOpen,
|
|
2048
|
+
triggerRef,
|
|
2049
|
+
anchorRef
|
|
2050
|
+
}),
|
|
2051
|
+
[open, setOpen, anchorRef]
|
|
2052
|
+
);
|
|
2053
|
+
const validChildren = filterChildren(children, ALLOWED_CHILDREN4, {
|
|
2054
|
+
parentDisplayName: PortalRoot.displayName
|
|
2055
|
+
});
|
|
2056
|
+
return /* @__PURE__ */ jsx17(PortalContext.Provider, { value, children: validChildren });
|
|
2057
|
+
};
|
|
2058
|
+
PortalRoot.displayName = "Portal.Root";
|
|
2059
|
+
|
|
2060
|
+
// src/components/portal/portal.tsx
|
|
2061
|
+
var Portal = {
|
|
2062
|
+
/** The root component that provides context for the portal. */
|
|
2063
|
+
Root: PortalRoot,
|
|
2064
|
+
/** The trigger element that opens the portal when interacted with. */
|
|
2065
|
+
Trigger: PortalTrigger,
|
|
2066
|
+
/** The content displayed inside the portal when open. */
|
|
2067
|
+
Content: PortalContent,
|
|
2068
|
+
/** A backdrop optionally displayed behind portal content when open. */
|
|
2069
|
+
Backdrop: PortalBackdrop
|
|
2070
|
+
};
|
|
2071
|
+
|
|
2072
|
+
// src/components/select/content/select-content.tsx
|
|
2073
|
+
import clsx16 from "clsx";
|
|
2074
|
+
import * as React22 from "react";
|
|
2075
|
+
|
|
2076
|
+
// src/components/select/select-context.tsx
|
|
2077
|
+
import * as React19 from "react";
|
|
2078
|
+
var SelectContext = React19.createContext(
|
|
2079
|
+
null
|
|
2080
|
+
);
|
|
2081
|
+
function useSelectContext() {
|
|
2082
|
+
const context = React19.useContext(SelectContext);
|
|
2083
|
+
if (!context) {
|
|
2084
|
+
throw new Error("Select components must be used within a Select.Root");
|
|
2085
|
+
}
|
|
2086
|
+
return context;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
// src/components/select/utils/user-composed-refs.ts
|
|
2090
|
+
import * as React20 from "react";
|
|
2091
|
+
function useComposedRefs(...refs) {
|
|
2092
|
+
return React20.useCallback(
|
|
2093
|
+
(node) => {
|
|
2094
|
+
refs.forEach((ref) => {
|
|
2095
|
+
if (typeof ref === "function") {
|
|
2096
|
+
ref(node);
|
|
2097
|
+
} else if (ref != null) {
|
|
2098
|
+
ref.current = node;
|
|
2099
|
+
}
|
|
2100
|
+
});
|
|
2101
|
+
},
|
|
2102
|
+
[refs]
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
// src/components/select/viewport/select-viewport.tsx
|
|
2107
|
+
import clsx15 from "clsx";
|
|
2108
|
+
import * as React21 from "react";
|
|
2109
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2110
|
+
var SelectViewport = React21.forwardRef(
|
|
2111
|
+
(props, ref) => {
|
|
2112
|
+
const { className, children, ...rest } = props;
|
|
2113
|
+
return /* @__PURE__ */ jsx18("div", { ref, className: clsx15("select-viewport", className), ...rest, children });
|
|
2114
|
+
}
|
|
2115
|
+
);
|
|
2116
|
+
SelectViewport.displayName = "Select.Viewport";
|
|
2117
|
+
|
|
2118
|
+
// src/components/select/content/select-content.tsx
|
|
2119
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
2120
|
+
var SelectContent = React22.forwardRef(
|
|
2121
|
+
(props, forwardedRef) => {
|
|
2122
|
+
const {
|
|
2123
|
+
className,
|
|
2124
|
+
children,
|
|
2125
|
+
position = "popper",
|
|
2126
|
+
side = "bottom",
|
|
2127
|
+
offset,
|
|
2128
|
+
align = "center",
|
|
2129
|
+
...rest
|
|
2130
|
+
} = props;
|
|
2131
|
+
const context = useSelectContext();
|
|
2132
|
+
const composedRef = useComposedRefs(forwardedRef, context.contentRef);
|
|
2133
|
+
React22.useEffect(() => {
|
|
2134
|
+
context.itemValues.current = [];
|
|
2135
|
+
}, [context.open]);
|
|
2136
|
+
React22.useEffect(() => {
|
|
2137
|
+
if (!context.open) return;
|
|
2138
|
+
const handleClickOutside = (event) => {
|
|
2139
|
+
const target = event.target;
|
|
2140
|
+
if (context.contentRef.current && !context.contentRef.current.contains(target) && context.triggerRef.current && !context.triggerRef.current.contains(target)) {
|
|
2141
|
+
context.onOpenChange(false);
|
|
2142
|
+
}
|
|
2143
|
+
};
|
|
2144
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2145
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2146
|
+
}, [context.open]);
|
|
2147
|
+
React22.useEffect(() => {
|
|
2148
|
+
if (!context.open) return;
|
|
2149
|
+
const handleKeyDown = (event) => {
|
|
2150
|
+
const items = context.itemValues.current;
|
|
2151
|
+
const itemCount = items.length;
|
|
2152
|
+
switch (event.key) {
|
|
2153
|
+
case "ArrowDown":
|
|
2154
|
+
event.preventDefault();
|
|
2155
|
+
context.setHighlightedIndex(
|
|
2156
|
+
(prev) => prev < itemCount - 1 ? prev + 1 : 0
|
|
2157
|
+
);
|
|
2158
|
+
break;
|
|
2159
|
+
case "ArrowUp":
|
|
2160
|
+
event.preventDefault();
|
|
2161
|
+
context.setHighlightedIndex(
|
|
2162
|
+
(prev) => prev > 0 ? prev - 1 : itemCount - 1
|
|
2163
|
+
);
|
|
2164
|
+
break;
|
|
2165
|
+
case "Tab":
|
|
2166
|
+
event.preventDefault();
|
|
2167
|
+
if (event.shiftKey) {
|
|
2168
|
+
context.setHighlightedIndex(
|
|
2169
|
+
(prev) => prev > 0 ? prev - 1 : itemCount - 1
|
|
2170
|
+
);
|
|
2171
|
+
} else {
|
|
2172
|
+
context.setHighlightedIndex(
|
|
2173
|
+
(prev) => prev < itemCount - 1 ? prev + 1 : 0
|
|
2174
|
+
);
|
|
2175
|
+
}
|
|
2176
|
+
break;
|
|
2177
|
+
case "Enter":
|
|
2178
|
+
case " ":
|
|
2179
|
+
event.preventDefault();
|
|
2180
|
+
if (context.highlightedIndex >= 0) {
|
|
2181
|
+
const selectedValue = items[context.highlightedIndex];
|
|
2182
|
+
if (selectedValue) {
|
|
2183
|
+
context.onValueChange(selectedValue);
|
|
2184
|
+
const displayText = children;
|
|
2185
|
+
if (displayText) context.setDisplayValue(displayText);
|
|
2186
|
+
context.onOpenChange(false);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
break;
|
|
2190
|
+
case "Escape":
|
|
2191
|
+
event.preventDefault();
|
|
2192
|
+
context.onOpenChange(false);
|
|
2193
|
+
context.triggerRef.current?.focus();
|
|
2194
|
+
break;
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
2197
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
2198
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
2199
|
+
}, [context.open, context.highlightedIndex]);
|
|
2200
|
+
const [contentWidth, setContentWidth] = React22.useState();
|
|
2201
|
+
const labelInside = context.labelPosition === "inside";
|
|
2202
|
+
const anchorRef = labelInside ? context.rootRef : context.triggerRef;
|
|
2203
|
+
React22.useLayoutEffect(() => {
|
|
2204
|
+
if (context.open && anchorRef.current) {
|
|
2205
|
+
setContentWidth(anchorRef.current.getBoundingClientRect().width);
|
|
2206
|
+
}
|
|
2207
|
+
}, [context.open, context.labelPosition, anchorRef]);
|
|
2208
|
+
if (!context.open) {
|
|
2209
|
+
return /* @__PURE__ */ jsx19("div", { style: { display: "none" }, "aria-hidden": "true", children });
|
|
2210
|
+
}
|
|
2211
|
+
return /* @__PURE__ */ jsx19(
|
|
2212
|
+
Portal.Root,
|
|
2213
|
+
{
|
|
2214
|
+
open: context.open,
|
|
2215
|
+
onOpenChange: context.onOpenChange,
|
|
2216
|
+
anchorRef,
|
|
2217
|
+
children: /* @__PURE__ */ jsx19(Portal.Content, { anchored: true, side, align, sideOffset: offset, children: /* @__PURE__ */ jsx19(
|
|
2218
|
+
"div",
|
|
2219
|
+
{
|
|
2220
|
+
ref: composedRef,
|
|
2221
|
+
role: "listbox",
|
|
2222
|
+
"data-state": context.open ? "open" : "closed",
|
|
2223
|
+
"data-side": side,
|
|
2224
|
+
"data-align": align,
|
|
2225
|
+
"data-trigger-variant": context.triggerVariant,
|
|
2226
|
+
className: clsx16("select-content", className),
|
|
2227
|
+
style: { width: contentWidth },
|
|
2228
|
+
...rest,
|
|
2229
|
+
children: /* @__PURE__ */ jsx19(SelectViewport, { children })
|
|
2230
|
+
}
|
|
2231
|
+
) })
|
|
2232
|
+
}
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
2235
|
+
);
|
|
2236
|
+
SelectContent.displayName = "Select.Content";
|
|
2237
|
+
|
|
2238
|
+
// src/components/select/group/select-group.tsx
|
|
2239
|
+
import clsx17 from "clsx";
|
|
2240
|
+
import * as React23 from "react";
|
|
2241
|
+
|
|
2242
|
+
// src/components/select/group/select-group.props.ts
|
|
2243
|
+
var SelectGroupsPropDefs = {
|
|
2244
|
+
title: {
|
|
2245
|
+
type: "string"
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
// src/components/select/group/select-group.tsx
|
|
2250
|
+
import { jsx as jsx20, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2251
|
+
var SelectGroup = React23.forwardRef(
|
|
2252
|
+
(props, ref) => {
|
|
2253
|
+
const { className, children, dataAttrs, ...rest } = getComponentProps(
|
|
2254
|
+
props,
|
|
2255
|
+
SelectGroupsPropDefs
|
|
2256
|
+
);
|
|
2257
|
+
return /* @__PURE__ */ jsxs5(
|
|
2258
|
+
"div",
|
|
2259
|
+
{
|
|
2260
|
+
ref,
|
|
2261
|
+
role: "group",
|
|
2262
|
+
className: clsx17("select-group", className),
|
|
2263
|
+
...rest,
|
|
2264
|
+
children: [
|
|
2265
|
+
/* @__PURE__ */ jsx20(Text, { className: "select-group-label", disabled: true, children: props.title }),
|
|
2266
|
+
children
|
|
2267
|
+
]
|
|
2268
|
+
}
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
);
|
|
2272
|
+
SelectGroup.displayName = "Select.Group";
|
|
2273
|
+
|
|
2274
|
+
// src/components/select/item/select-item.tsx
|
|
2275
|
+
import clsx18 from "clsx";
|
|
2276
|
+
import * as React24 from "react";
|
|
2277
|
+
|
|
2278
|
+
// src/components/select/item/select-item-indicator.tsx
|
|
2279
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
2280
|
+
var SelectItemIndicator = () => {
|
|
2281
|
+
return /* @__PURE__ */ jsx21("span", { className: "select-item-indicator", children: /* @__PURE__ */ jsx21(
|
|
2282
|
+
"svg",
|
|
2283
|
+
{
|
|
2284
|
+
width: "20",
|
|
2285
|
+
height: "20",
|
|
2286
|
+
viewBox: "0 0 15 15",
|
|
2287
|
+
fill: "none",
|
|
2288
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2289
|
+
children: /* @__PURE__ */ jsx21(
|
|
2290
|
+
"path",
|
|
2291
|
+
{
|
|
2292
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
|
2293
|
+
fill: "currentColor",
|
|
2294
|
+
fillRule: "evenodd",
|
|
2295
|
+
clipRule: "evenodd"
|
|
2296
|
+
}
|
|
2297
|
+
)
|
|
2298
|
+
}
|
|
2299
|
+
) });
|
|
2300
|
+
};
|
|
2301
|
+
|
|
2302
|
+
// src/components/select/item/select-item.props.ts
|
|
2303
|
+
var SelectItemPropDefs = {
|
|
2304
|
+
value: {
|
|
2305
|
+
type: "string"
|
|
2306
|
+
},
|
|
2307
|
+
disabled: {
|
|
2308
|
+
type: "boolean",
|
|
2309
|
+
default: false
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
|
|
2313
|
+
// src/components/select/item/select-item.tsx
|
|
2314
|
+
import { jsx as jsx22, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2315
|
+
var SelectItem = React24.forwardRef(
|
|
2316
|
+
(props, ref) => {
|
|
2317
|
+
const context = useSelectContext();
|
|
2318
|
+
const { value, disabled, children, className, ...rest } = getComponentProps(
|
|
2319
|
+
props,
|
|
2320
|
+
SelectItemPropDefs
|
|
2321
|
+
);
|
|
2322
|
+
const selected = context.value === value;
|
|
2323
|
+
React24.useEffect(() => {
|
|
2324
|
+
if (selected && children) {
|
|
2325
|
+
context.setDisplayValue(children);
|
|
2326
|
+
}
|
|
2327
|
+
}, [selected]);
|
|
2328
|
+
React24.useEffect(() => {
|
|
2329
|
+
if (!value) return;
|
|
2330
|
+
if (!disabled) {
|
|
2331
|
+
const values = context.itemValues.current;
|
|
2332
|
+
if (!values.includes(value)) values.push(value);
|
|
2333
|
+
}
|
|
2334
|
+
return () => {
|
|
2335
|
+
const values = context.itemValues.current;
|
|
2336
|
+
const index = values.indexOf(value);
|
|
2337
|
+
if (index > -1) values.splice(index, 1);
|
|
2338
|
+
};
|
|
2339
|
+
}, [value, disabled]);
|
|
2340
|
+
const itemIndex = value ? context.itemValues.current.indexOf(value) : -1;
|
|
2341
|
+
const isHighlighted = context.highlightedIndex >= 0 && context.highlightedIndex === itemIndex;
|
|
2342
|
+
const handleClick = () => {
|
|
2343
|
+
if (!disabled) {
|
|
2344
|
+
if (value) {
|
|
2345
|
+
context.onValueChange(value);
|
|
2346
|
+
context.setDisplayValue(children);
|
|
2347
|
+
}
|
|
2348
|
+
context.onOpenChange(false);
|
|
2349
|
+
context.triggerRef.current?.focus();
|
|
2350
|
+
}
|
|
2351
|
+
};
|
|
2352
|
+
const handleMouseEnter = () => {
|
|
2353
|
+
if (!disabled) context.setHighlightedIndex(itemIndex);
|
|
2354
|
+
};
|
|
2355
|
+
return /* @__PURE__ */ jsxs6(
|
|
2356
|
+
Box,
|
|
2357
|
+
{
|
|
2358
|
+
ref,
|
|
2359
|
+
role: "option",
|
|
2360
|
+
radius: "none",
|
|
2361
|
+
"aria-selected": selected,
|
|
2362
|
+
"aria-disabled": disabled,
|
|
2363
|
+
"data-variant": context.triggerVariant,
|
|
2364
|
+
"data-state": selected ? "checked" : "unchecked",
|
|
2365
|
+
"data-highlighted": isHighlighted ? "" : void 0,
|
|
2366
|
+
"data-disabled": disabled ? "" : void 0,
|
|
2367
|
+
className: clsx18("select-item", className),
|
|
2368
|
+
onClick: handleClick,
|
|
2369
|
+
onMouseEnter: handleMouseEnter,
|
|
2370
|
+
...rest,
|
|
2371
|
+
children: [
|
|
2372
|
+
/* @__PURE__ */ jsx22(
|
|
2373
|
+
Box,
|
|
2374
|
+
{
|
|
2375
|
+
style: { width: 24, height: 24, justifyContent: "center" },
|
|
2376
|
+
className: "flex items-center",
|
|
2377
|
+
children: selected && /* @__PURE__ */ jsx22(SelectItemIndicator, {})
|
|
2378
|
+
}
|
|
2379
|
+
),
|
|
2380
|
+
/* @__PURE__ */ jsx22(Text, { disabled, children })
|
|
2381
|
+
]
|
|
2382
|
+
}
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2385
|
+
);
|
|
2386
|
+
SelectItem.displayName = "Select.Item";
|
|
2387
|
+
|
|
2388
|
+
// src/components/select/label/select-label.tsx
|
|
2389
|
+
import clsx19 from "clsx";
|
|
2390
|
+
import * as React25 from "react";
|
|
2391
|
+
|
|
2392
|
+
// src/components/select/label/select-label.props.ts
|
|
2393
|
+
var labelPositions2 = ["top", "left", "inside"];
|
|
2394
|
+
var SelectLabelPropDefs = {
|
|
2395
|
+
position: {
|
|
2396
|
+
type: "enum",
|
|
2397
|
+
values: labelPositions2,
|
|
2398
|
+
default: "top",
|
|
2399
|
+
dataAttr: "position"
|
|
2400
|
+
}
|
|
2401
|
+
};
|
|
2402
|
+
|
|
2403
|
+
// src/components/select/label/select-label.tsx
|
|
2404
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
2405
|
+
var SelectLabel = React25.forwardRef(
|
|
2406
|
+
(props, ref) => {
|
|
2407
|
+
const context = useSelectContext();
|
|
2408
|
+
const { className, children, position, dataAttrs } = getComponentProps(
|
|
2409
|
+
props,
|
|
2410
|
+
SelectLabelPropDefs
|
|
2411
|
+
);
|
|
2412
|
+
React25.useLayoutEffect(() => {
|
|
2413
|
+
context.setLabelPosition?.(position ?? "top");
|
|
2414
|
+
}, [position, context.setLabelPosition]);
|
|
2415
|
+
return /* @__PURE__ */ jsx23(
|
|
2416
|
+
"label",
|
|
2417
|
+
{
|
|
2418
|
+
ref,
|
|
2419
|
+
htmlFor: context.labelId,
|
|
2420
|
+
className: clsx19("select-label", className),
|
|
2421
|
+
...dataAttrs,
|
|
2422
|
+
children: /* @__PURE__ */ jsx23(Text, { disabled: context.disabled, children })
|
|
2423
|
+
}
|
|
2424
|
+
);
|
|
2425
|
+
}
|
|
2426
|
+
);
|
|
2427
|
+
SelectLabel.displayName = "Select.Label";
|
|
2428
|
+
|
|
2429
|
+
// src/components/select/root/select-root.tsx
|
|
2430
|
+
import clsx23 from "clsx";
|
|
2431
|
+
import {
|
|
2432
|
+
useId as useId2,
|
|
2433
|
+
useLayoutEffect as useLayoutEffect3,
|
|
2434
|
+
useMemo as useMemo5,
|
|
2435
|
+
useRef as useRef5,
|
|
2436
|
+
useState as useState6
|
|
2437
|
+
} from "react";
|
|
2438
|
+
|
|
2439
|
+
// src/components/select/trigger/select-trigger.tsx
|
|
2440
|
+
import clsx22 from "clsx";
|
|
2441
|
+
import * as React27 from "react";
|
|
2442
|
+
|
|
2443
|
+
// src/components/select/value/select-value.tsx
|
|
2444
|
+
import clsx20 from "clsx";
|
|
2445
|
+
import * as React26 from "react";
|
|
2446
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
2447
|
+
var SelectValue = React26.forwardRef(
|
|
2448
|
+
(props, ref) => {
|
|
2449
|
+
const { className, placeholder: placeholderProp, ...rest } = props;
|
|
2450
|
+
const context = useSelectContext();
|
|
2451
|
+
const placeholder = placeholderProp ?? context.placeholder;
|
|
2452
|
+
return /* @__PURE__ */ jsx24(
|
|
2453
|
+
"span",
|
|
2454
|
+
{
|
|
2455
|
+
ref,
|
|
2456
|
+
className: clsx20("select-value", className),
|
|
2457
|
+
"data-placeholder": !context.value ? "" : void 0,
|
|
2458
|
+
...rest,
|
|
2459
|
+
children: /* @__PURE__ */ jsx24(Text, { disabled: context.disabled, children: context.displayValue || placeholder })
|
|
2460
|
+
}
|
|
2461
|
+
);
|
|
2462
|
+
}
|
|
2463
|
+
);
|
|
2464
|
+
SelectValue.displayName = "Select.Value";
|
|
2465
|
+
|
|
2466
|
+
// src/components/select/trigger/select-trigger-icon.tsx
|
|
2467
|
+
import clsx21 from "clsx";
|
|
2468
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
2469
|
+
var SelectTriggerIcon = (props) => {
|
|
2470
|
+
const { className, ...rest } = props;
|
|
2471
|
+
return /* @__PURE__ */ jsx25(
|
|
2472
|
+
"svg",
|
|
2473
|
+
{
|
|
2474
|
+
className: clsx21("select-trigger-icon", className),
|
|
2475
|
+
width: "20",
|
|
2476
|
+
height: "20",
|
|
2477
|
+
viewBox: "0 0 15 15",
|
|
2478
|
+
fill: "none",
|
|
2479
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2480
|
+
...rest,
|
|
2481
|
+
children: /* @__PURE__ */ jsx25(
|
|
2482
|
+
"path",
|
|
2483
|
+
{
|
|
2484
|
+
d: "M4.18179 6.18181C4.35753 6.00608 4.64245 6.00608 4.81819 6.18181L7.49999 8.86362L10.1818 6.18181C10.3575 6.00608 10.6424 6.00608 10.8182 6.18181C10.9939 6.35755 10.9939 6.64247 10.8182 6.81821L7.81819 9.81821C7.73379 9.9026 7.61934 9.95001 7.49999 9.95001C7.38064 9.95001 7.26618 9.9026 7.18179 9.81821L4.18179 6.81821C4.00605 6.64247 4.00605 6.35755 4.18179 6.18181Z",
|
|
2485
|
+
fill: "currentColor",
|
|
2486
|
+
fillRule: "evenodd",
|
|
2487
|
+
clipRule: "evenodd"
|
|
2488
|
+
}
|
|
2489
|
+
)
|
|
2490
|
+
}
|
|
2491
|
+
);
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
// src/components/select/trigger/select-trigger.props.ts
|
|
2495
|
+
var SelectTriggerPropsDefs = {};
|
|
2496
|
+
|
|
2497
|
+
// src/components/select/trigger/select-trigger.tsx
|
|
2498
|
+
import { jsx as jsx26, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2499
|
+
var SelectTrigger = React27.forwardRef(
|
|
2500
|
+
(props, forwardedRef) => {
|
|
2501
|
+
const {
|
|
2502
|
+
className,
|
|
2503
|
+
disabled: disabledProp,
|
|
2504
|
+
dataAttrs
|
|
2505
|
+
} = getComponentProps(props, SelectTriggerPropsDefs);
|
|
2506
|
+
const context = useSelectContext();
|
|
2507
|
+
const disabled = disabledProp ?? context.disabled;
|
|
2508
|
+
const isInsideLabel = context.labelPosition === "inside";
|
|
2509
|
+
const composedRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
2510
|
+
const handleClick = () => {
|
|
2511
|
+
if (!disabled) {
|
|
2512
|
+
context.onOpenChange(!context.open);
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
const handleKeyDown = (event) => {
|
|
2516
|
+
if (disabled) return;
|
|
2517
|
+
switch (event.key) {
|
|
2518
|
+
case "Enter":
|
|
2519
|
+
case " ":
|
|
2520
|
+
case "ArrowDown":
|
|
2521
|
+
case "ArrowUp":
|
|
2522
|
+
event.preventDefault();
|
|
2523
|
+
context.onOpenChange(true);
|
|
2524
|
+
break;
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
if (isInsideLabel) {
|
|
2528
|
+
return /* @__PURE__ */ jsxs7(
|
|
2529
|
+
"div",
|
|
2530
|
+
{
|
|
2531
|
+
ref: composedRef,
|
|
2532
|
+
"data-state": context.open ? "open" : "closed",
|
|
2533
|
+
"data-disabled": disabled ? "" : void 0,
|
|
2534
|
+
"data-variant": context.triggerVariant,
|
|
2535
|
+
className: clsx22("select-trigger", className),
|
|
2536
|
+
...dataAttrs,
|
|
2537
|
+
children: [
|
|
2538
|
+
/* @__PURE__ */ jsx26(SelectValue, {}),
|
|
2539
|
+
/* @__PURE__ */ jsx26(SelectTriggerIcon, {})
|
|
2540
|
+
]
|
|
2541
|
+
}
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2544
|
+
return /* @__PURE__ */ jsxs7(
|
|
2545
|
+
"button",
|
|
2546
|
+
{
|
|
2547
|
+
ref: composedRef,
|
|
2548
|
+
type: "button",
|
|
2549
|
+
role: "combobox",
|
|
2550
|
+
"aria-expanded": context.open,
|
|
2551
|
+
"aria-haspopup": "listbox",
|
|
2552
|
+
"aria-disabled": disabled,
|
|
2553
|
+
disabled,
|
|
2554
|
+
"data-state": context.open ? "open" : "closed",
|
|
2555
|
+
"data-disabled": disabled ? "" : void 0,
|
|
2556
|
+
className: clsx22("select-trigger", className),
|
|
2557
|
+
onClick: handleClick,
|
|
2558
|
+
onKeyDown: handleKeyDown,
|
|
2559
|
+
"data-variant": context.triggerVariant,
|
|
2560
|
+
...dataAttrs,
|
|
2561
|
+
children: [
|
|
2562
|
+
/* @__PURE__ */ jsx26(SelectValue, {}),
|
|
2563
|
+
/* @__PURE__ */ jsx26(SelectTriggerIcon, {})
|
|
2564
|
+
]
|
|
2565
|
+
}
|
|
2566
|
+
);
|
|
2567
|
+
}
|
|
2568
|
+
);
|
|
2569
|
+
SelectTrigger.displayName = "Select.Trigger";
|
|
2570
|
+
|
|
2571
|
+
// src/components/select/root/select-root.props.ts
|
|
2572
|
+
var selectVariants = ["outlined", "solid", "clear"];
|
|
2573
|
+
var SelectRootPropsDefs = {
|
|
2574
|
+
variant: {
|
|
2575
|
+
type: "enum",
|
|
2576
|
+
values: selectVariants,
|
|
2577
|
+
dataAttr: "variant"
|
|
2578
|
+
},
|
|
2579
|
+
value: {
|
|
2580
|
+
type: "string"
|
|
2581
|
+
},
|
|
2582
|
+
defaultValue: {
|
|
2583
|
+
type: "string"
|
|
2584
|
+
},
|
|
2585
|
+
disabled: {
|
|
2586
|
+
type: "boolean"
|
|
2587
|
+
},
|
|
2588
|
+
required: {
|
|
2589
|
+
type: "boolean"
|
|
2590
|
+
},
|
|
2591
|
+
placeholder: {
|
|
2592
|
+
type: "string"
|
|
2593
|
+
},
|
|
2594
|
+
name: {
|
|
2595
|
+
type: "string"
|
|
2596
|
+
},
|
|
2597
|
+
onValueChange: {
|
|
2598
|
+
type: "function"
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
|
|
2602
|
+
// src/components/select/root/select-root.tsx
|
|
2603
|
+
import { jsx as jsx27, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2604
|
+
var ALLOWED_CHILDREN5 = [
|
|
2605
|
+
SelectLabel.displayName,
|
|
2606
|
+
SelectTrigger.displayName,
|
|
2607
|
+
SelectContent.displayName
|
|
2608
|
+
];
|
|
2609
|
+
var SelectRoot = (props) => {
|
|
2610
|
+
const {
|
|
2611
|
+
children,
|
|
2612
|
+
className,
|
|
2613
|
+
dataAttrs,
|
|
2614
|
+
value: valueProp,
|
|
2615
|
+
defaultValue = "",
|
|
2616
|
+
onValueChange,
|
|
2617
|
+
disabled = false,
|
|
2618
|
+
required = false,
|
|
2619
|
+
placeholder,
|
|
2620
|
+
variant,
|
|
2621
|
+
name
|
|
2622
|
+
} = getComponentProps(
|
|
2623
|
+
props,
|
|
2624
|
+
SelectRootPropsDefs,
|
|
2625
|
+
MarginPropDefs,
|
|
2626
|
+
RadiusPropDefs,
|
|
2627
|
+
RoundnessPropDef
|
|
2628
|
+
);
|
|
2629
|
+
const [value, setValue] = useControllableState({
|
|
2630
|
+
value: valueProp,
|
|
2631
|
+
defaultValue,
|
|
2632
|
+
onChange: onValueChange
|
|
2633
|
+
});
|
|
2634
|
+
const [open, setOpen] = useState6(false);
|
|
2635
|
+
const [highlightedIndex, setHighlightedIndex] = useState6(-1);
|
|
2636
|
+
const [labelPosition, setLabelPosition] = useState6("top");
|
|
2637
|
+
const [triggerVariant, setTriggerVariant] = useState6("outlined");
|
|
2638
|
+
const [displayValue, setDisplayValue] = useState6(null);
|
|
2639
|
+
const labelId = useId2();
|
|
2640
|
+
const rootRef = useRef5(null);
|
|
2641
|
+
const triggerRef = useRef5(null);
|
|
2642
|
+
const contentRef = useRef5(null);
|
|
2643
|
+
const itemsRef = useRef5(/* @__PURE__ */ new Map());
|
|
2644
|
+
const itemValues = useRef5([]);
|
|
2645
|
+
const contextValue = useMemo5(
|
|
2646
|
+
() => ({
|
|
2647
|
+
open,
|
|
2648
|
+
value,
|
|
2649
|
+
displayValue,
|
|
2650
|
+
onOpenChange: setOpen,
|
|
2651
|
+
onValueChange: setValue,
|
|
2652
|
+
setDisplayValue,
|
|
2653
|
+
rootRef,
|
|
2654
|
+
triggerRef,
|
|
2655
|
+
contentRef,
|
|
2656
|
+
labelPosition,
|
|
2657
|
+
setLabelPosition,
|
|
2658
|
+
triggerVariant,
|
|
2659
|
+
setTriggerVariant,
|
|
2660
|
+
disabled,
|
|
2661
|
+
required,
|
|
2662
|
+
placeholder,
|
|
2663
|
+
name,
|
|
2664
|
+
labelId,
|
|
2665
|
+
highlightedIndex,
|
|
2666
|
+
setHighlightedIndex,
|
|
2667
|
+
itemsRef,
|
|
2668
|
+
itemValues
|
|
2669
|
+
}),
|
|
2670
|
+
[
|
|
2671
|
+
open,
|
|
2672
|
+
value,
|
|
2673
|
+
displayValue,
|
|
2674
|
+
disabled,
|
|
2675
|
+
required,
|
|
2676
|
+
name,
|
|
2677
|
+
placeholder,
|
|
2678
|
+
labelId,
|
|
2679
|
+
highlightedIndex,
|
|
2680
|
+
labelPosition,
|
|
2681
|
+
triggerVariant
|
|
2682
|
+
]
|
|
2683
|
+
);
|
|
2684
|
+
useLayoutEffect3(() => {
|
|
2685
|
+
setTriggerVariant?.(variant ?? "outlined");
|
|
2686
|
+
}, [variant, setTriggerVariant]);
|
|
2687
|
+
const validChildren = filterChildren(children, ALLOWED_CHILDREN5, {
|
|
2688
|
+
parentDisplayName: SelectRoot.displayName
|
|
2689
|
+
});
|
|
2690
|
+
const labelInside = labelPosition === "inside";
|
|
2691
|
+
const handleClick = () => {
|
|
2692
|
+
if (!disabled) {
|
|
2693
|
+
setOpen(!open);
|
|
2694
|
+
}
|
|
2695
|
+
};
|
|
2696
|
+
const handleKeyDown = (event) => {
|
|
2697
|
+
if (disabled) return;
|
|
2698
|
+
switch (event.key) {
|
|
2699
|
+
case "Enter":
|
|
2700
|
+
case " ":
|
|
2701
|
+
case "ArrowDown":
|
|
2702
|
+
case "ArrowUp":
|
|
2703
|
+
event.preventDefault();
|
|
2704
|
+
setOpen(true);
|
|
2705
|
+
break;
|
|
2706
|
+
}
|
|
2707
|
+
};
|
|
2708
|
+
if (labelInside) {
|
|
2709
|
+
return /* @__PURE__ */ jsx27(SelectContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs8(
|
|
2710
|
+
"button",
|
|
2711
|
+
{
|
|
2712
|
+
type: "button",
|
|
2713
|
+
role: "combobox",
|
|
2714
|
+
"aria-expanded": open,
|
|
2715
|
+
"aria-haspopup": "listbox",
|
|
2716
|
+
"aria-disabled": disabled,
|
|
2717
|
+
disabled,
|
|
2718
|
+
ref: rootRef,
|
|
2719
|
+
"data-state": open ? "open" : "closed",
|
|
2720
|
+
"data-disabled": disabled ? "" : void 0,
|
|
2721
|
+
className: clsx23("select-root", className),
|
|
2722
|
+
onClick: handleClick,
|
|
2723
|
+
onKeyDown: handleKeyDown,
|
|
2724
|
+
...dataAttrs,
|
|
2725
|
+
children: [
|
|
2726
|
+
validChildren,
|
|
2727
|
+
name && /* @__PURE__ */ jsx27("input", { type: "hidden", name, value })
|
|
2728
|
+
]
|
|
2729
|
+
}
|
|
2730
|
+
) });
|
|
2731
|
+
}
|
|
2732
|
+
return /* @__PURE__ */ jsx27(SelectContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs8(
|
|
2733
|
+
Box,
|
|
2734
|
+
{
|
|
2735
|
+
ref: rootRef,
|
|
2736
|
+
className: clsx23("select-root", className),
|
|
2737
|
+
...dataAttrs,
|
|
2738
|
+
children: [
|
|
2739
|
+
validChildren,
|
|
2740
|
+
name && /* @__PURE__ */ jsx27("input", { type: "hidden", name, value })
|
|
2741
|
+
]
|
|
2742
|
+
}
|
|
2743
|
+
) });
|
|
2744
|
+
};
|
|
2745
|
+
SelectRoot.displayName = "Select.Root";
|
|
2746
|
+
|
|
2747
|
+
// src/components/select/separator/select-separator.tsx
|
|
2748
|
+
import clsx24 from "clsx";
|
|
2749
|
+
import * as React28 from "react";
|
|
2750
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
2751
|
+
var SelectSeparator = React28.forwardRef(
|
|
2752
|
+
(props, ref) => {
|
|
2753
|
+
const { className, ...rest } = props;
|
|
2754
|
+
return /* @__PURE__ */ jsx28(
|
|
2755
|
+
"div",
|
|
2756
|
+
{
|
|
2757
|
+
ref,
|
|
2758
|
+
className: clsx24("select-separator", className),
|
|
2759
|
+
...rest
|
|
2760
|
+
}
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
);
|
|
2764
|
+
SelectSeparator.displayName = "Select.Separator";
|
|
2765
|
+
|
|
2766
|
+
// src/components/select/select.tsx
|
|
2767
|
+
var Select = {
|
|
2768
|
+
Root: SelectRoot,
|
|
2769
|
+
Trigger: SelectTrigger,
|
|
2770
|
+
Content: SelectContent,
|
|
2771
|
+
Viewport: SelectViewport,
|
|
2772
|
+
Group: SelectGroup,
|
|
2773
|
+
Label: SelectLabel,
|
|
2774
|
+
Item: SelectItem,
|
|
2775
|
+
Separator: SelectSeparator
|
|
2776
|
+
};
|
|
2777
|
+
|
|
2778
|
+
// src/components/separator/separator.tsx
|
|
2779
|
+
import clsx25 from "clsx";
|
|
2780
|
+
|
|
2781
|
+
// src/components/separator/separator.props.ts
|
|
2782
|
+
var directions = ["horizontal", "vertical"];
|
|
2783
|
+
var variants2 = ["solid", "dashed", "dotted"];
|
|
2784
|
+
var SeparatorPropsDefs = {
|
|
2785
|
+
/**
|
|
2786
|
+
* The direction of the separator.
|
|
2787
|
+
*
|
|
2788
|
+
* @example direction="vertical" // positions the separator vertically
|
|
2789
|
+
*/
|
|
2790
|
+
direction: {
|
|
2791
|
+
type: "enum",
|
|
2792
|
+
values: directions,
|
|
2793
|
+
default: "horizontal",
|
|
2794
|
+
dataAttr: "direction"
|
|
2795
|
+
},
|
|
2796
|
+
/**
|
|
2797
|
+
* The variant of the separator.
|
|
2798
|
+
*
|
|
2799
|
+
* @example variant="dashed" // makes the separator dashed
|
|
2800
|
+
*/
|
|
2801
|
+
variant: {
|
|
2802
|
+
type: "enum",
|
|
2803
|
+
values: variants2,
|
|
2804
|
+
default: "solid",
|
|
2805
|
+
dataAttr: "variant"
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
|
|
2809
|
+
// src/components/separator/separator.tsx
|
|
2810
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
2811
|
+
var Separator = (props) => {
|
|
2812
|
+
const { className, dataAttrs, style } = getComponentProps(
|
|
2813
|
+
props,
|
|
2814
|
+
SeparatorPropsDefs
|
|
2815
|
+
);
|
|
2816
|
+
return /* @__PURE__ */ jsx29(
|
|
2817
|
+
"div",
|
|
2818
|
+
{
|
|
2819
|
+
className: clsx25("separator", className),
|
|
2820
|
+
style,
|
|
2821
|
+
...dataAttrs
|
|
2822
|
+
}
|
|
2823
|
+
);
|
|
2824
|
+
};
|
|
2825
|
+
Separator.displayName = "Separator";
|
|
2826
|
+
|
|
2827
|
+
// src/components/theme/theme.tsx
|
|
2828
|
+
import * as React29 from "react";
|
|
2829
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2830
|
+
var Theme = React29.forwardRef((props, ref) => {
|
|
2831
|
+
const context = React29.useContext(ThemeContext);
|
|
2832
|
+
const isRoot = context === void 0;
|
|
2833
|
+
if (isRoot) return /* @__PURE__ */ jsx30(ThemeRoot, { ...props, ref });
|
|
2834
|
+
return /* @__PURE__ */ jsx30(ThemeSub, { ...props, ref });
|
|
2835
|
+
});
|
|
2836
|
+
Theme.displayName = "Theme";
|
|
2837
|
+
var ThemeRoot = React29.forwardRef((props, ref) => {
|
|
2838
|
+
const {
|
|
2839
|
+
appearance: themeAppearance,
|
|
2840
|
+
radius: themeRadius,
|
|
2841
|
+
roundness: themeRoundness,
|
|
2842
|
+
spacing: themeSpacing,
|
|
2843
|
+
children,
|
|
2844
|
+
...rest
|
|
2845
|
+
} = props;
|
|
2846
|
+
const [appearance, setAppearance] = React29.useState(
|
|
2847
|
+
themeAppearance ?? "light"
|
|
2848
|
+
);
|
|
2849
|
+
const [radius, setRadius] = React29.useState(themeRadius ?? "md");
|
|
2850
|
+
const [roundness2, setRoundness] = React29.useState(
|
|
2851
|
+
themeRoundness ?? "3"
|
|
2852
|
+
);
|
|
2853
|
+
const [spacing, setSpacing] = React29.useState(themeSpacing ?? "md");
|
|
2854
|
+
const value = React29.useMemo(
|
|
2855
|
+
() => ({
|
|
2856
|
+
appearance,
|
|
2857
|
+
radius,
|
|
2858
|
+
roundness: roundness2,
|
|
2859
|
+
spacing,
|
|
2860
|
+
onAppearanceChange: setAppearance,
|
|
2861
|
+
onRadiusChange: setRadius,
|
|
2862
|
+
onRoundnessChange: setRoundness,
|
|
2863
|
+
onSpacingChange: setSpacing
|
|
2864
|
+
}),
|
|
2865
|
+
[appearance, radius, roundness2, spacing]
|
|
2866
|
+
);
|
|
2867
|
+
return /* @__PURE__ */ jsx30(ThemeContext.Provider, { value, children: /* @__PURE__ */ jsx30(
|
|
2868
|
+
"div",
|
|
2869
|
+
{
|
|
2870
|
+
ref,
|
|
2871
|
+
"data-appearance": appearance,
|
|
2872
|
+
"data-theme-radius": radius,
|
|
2873
|
+
"data-theme-roundness": roundness2,
|
|
2874
|
+
"data-theme-spacing": spacing,
|
|
2875
|
+
...rest,
|
|
2876
|
+
children
|
|
2877
|
+
}
|
|
2878
|
+
) });
|
|
2879
|
+
});
|
|
2880
|
+
ThemeRoot.displayName = "ThemeRoot";
|
|
2881
|
+
var ThemeSub = React29.forwardRef((props, ref) => {
|
|
2882
|
+
const context = React29.useContext(ThemeContext);
|
|
2883
|
+
const {
|
|
2884
|
+
appearance,
|
|
2885
|
+
radius,
|
|
2886
|
+
roundness: roundness2,
|
|
2887
|
+
spacing,
|
|
2888
|
+
onAppearanceChange,
|
|
2889
|
+
onRadiusChange,
|
|
2890
|
+
onRoundnessChange,
|
|
2891
|
+
onSpacingChange,
|
|
2892
|
+
children,
|
|
2893
|
+
...rest
|
|
2894
|
+
} = props;
|
|
2895
|
+
const contextProps = {
|
|
2896
|
+
appearance: appearance ?? context.appearance,
|
|
2897
|
+
radius: radius ?? context.radius,
|
|
2898
|
+
roundness: roundness2 ?? context.roundness,
|
|
2899
|
+
spacing: spacing ?? context.spacing,
|
|
2900
|
+
onAppearanceChange: context.onAppearanceChange,
|
|
2901
|
+
onRadiusChange: context.onRadiusChange,
|
|
2902
|
+
onRoundnessChange: context.onRoundnessChange,
|
|
2903
|
+
onSpacingChange: context.onSpacingChange
|
|
2904
|
+
};
|
|
2905
|
+
return /* @__PURE__ */ jsx30(ThemeContext.Provider, { value: contextProps, children: /* @__PURE__ */ jsx30(
|
|
2906
|
+
"div",
|
|
2907
|
+
{
|
|
2908
|
+
ref,
|
|
2909
|
+
"data-appearance": appearance,
|
|
2910
|
+
"data-theme-radius": radius,
|
|
2911
|
+
"data-theme-roundness": roundness2,
|
|
2912
|
+
"data-theme-spacing": spacing,
|
|
2913
|
+
...rest,
|
|
2914
|
+
className: "flex",
|
|
2915
|
+
children
|
|
2916
|
+
}
|
|
2917
|
+
) });
|
|
2918
|
+
});
|
|
2919
|
+
ThemeSub.displayName = "ThemeSub";
|
|
2920
|
+
|
|
2921
|
+
// src/components/theme/theme-control.tsx
|
|
2922
|
+
import { jsx as jsx31, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2923
|
+
function ThemeControl() {
|
|
2924
|
+
const {
|
|
2925
|
+
appearance,
|
|
2926
|
+
onAppearanceChange,
|
|
2927
|
+
radius,
|
|
2928
|
+
onRadiusChange,
|
|
2929
|
+
roundness: roundness2,
|
|
2930
|
+
onRoundnessChange,
|
|
2931
|
+
spacing,
|
|
2932
|
+
onSpacingChange
|
|
2933
|
+
} = useTheme();
|
|
2934
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-2", children: [
|
|
2935
|
+
/* @__PURE__ */ jsxs9(
|
|
2936
|
+
Select.Root,
|
|
2937
|
+
{
|
|
2938
|
+
variant: "solid",
|
|
2939
|
+
value: appearance,
|
|
2940
|
+
onValueChange: (change) => onAppearanceChange?.(change),
|
|
2941
|
+
children: [
|
|
2942
|
+
/* @__PURE__ */ jsx31(Select.Label, { position: "inside", children: "Theme Settings" }),
|
|
2943
|
+
/* @__PURE__ */ jsx31(Select.Trigger, {}),
|
|
2944
|
+
/* @__PURE__ */ jsxs9(Select.Content, { children: [
|
|
2945
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "light", children: "Light" }),
|
|
2946
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "dark", children: "Dark" })
|
|
2947
|
+
] })
|
|
2948
|
+
]
|
|
2949
|
+
}
|
|
2950
|
+
),
|
|
2951
|
+
/* @__PURE__ */ jsxs9(
|
|
2952
|
+
Select.Root,
|
|
2953
|
+
{
|
|
2954
|
+
variant: "solid",
|
|
2955
|
+
value: radius,
|
|
2956
|
+
onValueChange: (change) => onRadiusChange?.(change),
|
|
2957
|
+
children: [
|
|
2958
|
+
/* @__PURE__ */ jsx31(Select.Label, { position: "inside", children: "Radius" }),
|
|
2959
|
+
/* @__PURE__ */ jsx31(Select.Trigger, {}),
|
|
2960
|
+
/* @__PURE__ */ jsxs9(Select.Content, { children: [
|
|
2961
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "none", children: "None" }),
|
|
2962
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "xs", children: "XS" }),
|
|
2963
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "sm", children: "SM" }),
|
|
2964
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "md", children: "MD" }),
|
|
2965
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "lg", children: "LG" }),
|
|
2966
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "xl", children: "XL" }),
|
|
2967
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "full", children: "FULL" })
|
|
2968
|
+
] })
|
|
2969
|
+
]
|
|
2970
|
+
}
|
|
2971
|
+
),
|
|
2972
|
+
/* @__PURE__ */ jsxs9(
|
|
2973
|
+
Select.Root,
|
|
2974
|
+
{
|
|
2975
|
+
variant: "solid",
|
|
2976
|
+
value: roundness2,
|
|
2977
|
+
onValueChange: (change) => onRoundnessChange?.(change),
|
|
2978
|
+
children: [
|
|
2979
|
+
/* @__PURE__ */ jsx31(Select.Label, { className: "min-w-40!", position: "inside", children: "Roundness" }),
|
|
2980
|
+
/* @__PURE__ */ jsx31(Select.Trigger, {}),
|
|
2981
|
+
/* @__PURE__ */ jsxs9(Select.Content, { children: [
|
|
2982
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "1", children: "1" }),
|
|
2983
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "2", children: "2" }),
|
|
2984
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "3", children: "3" }),
|
|
2985
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "4", children: "4" }),
|
|
2986
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "5", children: "5" }),
|
|
2987
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "6", children: "6" })
|
|
2988
|
+
] })
|
|
2989
|
+
]
|
|
2990
|
+
}
|
|
2991
|
+
),
|
|
2992
|
+
/* @__PURE__ */ jsxs9(
|
|
2993
|
+
Select.Root,
|
|
2994
|
+
{
|
|
2995
|
+
variant: "solid",
|
|
2996
|
+
value: spacing,
|
|
2997
|
+
onValueChange: (change) => onSpacingChange?.(change),
|
|
2998
|
+
children: [
|
|
2999
|
+
/* @__PURE__ */ jsx31(Select.Label, { position: "inside", children: "Spacing" }),
|
|
3000
|
+
/* @__PURE__ */ jsx31(Select.Trigger, {}),
|
|
3001
|
+
/* @__PURE__ */ jsxs9(Select.Content, { children: [
|
|
3002
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "xs", children: "XS" }),
|
|
3003
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "sm", children: "SM" }),
|
|
3004
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "md", children: "MD" }),
|
|
3005
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "lg", children: "LG" }),
|
|
3006
|
+
/* @__PURE__ */ jsx31(Select.Item, { value: "xl", children: "XL" })
|
|
3007
|
+
] })
|
|
3008
|
+
]
|
|
3009
|
+
}
|
|
3010
|
+
)
|
|
3011
|
+
] });
|
|
3012
|
+
}
|
|
3013
|
+
export {
|
|
3014
|
+
Accordion,
|
|
3015
|
+
Box,
|
|
3016
|
+
Button,
|
|
3017
|
+
Checkbox,
|
|
3018
|
+
Container,
|
|
3019
|
+
Portal,
|
|
3020
|
+
Select,
|
|
3021
|
+
Separator,
|
|
3022
|
+
Text,
|
|
3023
|
+
Theme,
|
|
3024
|
+
ThemeControl,
|
|
3025
|
+
useTheme
|
|
3026
|
+
};
|
|
3027
|
+
//# sourceMappingURL=index.mjs.map
|