atelier-ui-react 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/index.cjs +909 -0
- package/dist/index.css +962 -0
- package/dist/index.mjs +876 -0
- package/package.json +52 -0
- package/src/Button/Button.css +169 -0
- package/src/Button/Button.tsx +57 -0
- package/src/Button/Button.types.ts +19 -0
- package/src/Button/index.ts +2 -0
- package/src/Card/Card.css +73 -0
- package/src/Card/Card.tsx +79 -0
- package/src/Card/Card.types.ts +25 -0
- package/src/Card/index.ts +2 -0
- package/src/Checkbox/Checkbox.css +101 -0
- package/src/Checkbox/Checkbox.tsx +85 -0
- package/src/Checkbox/Checkbox.types.ts +9 -0
- package/src/Checkbox/index.ts +2 -0
- package/src/Divider/Divider.css +47 -0
- package/src/Divider/Divider.tsx +53 -0
- package/src/Divider/Divider.types.ts +12 -0
- package/src/Divider/index.ts +2 -0
- package/src/Heading/Heading.css +30 -0
- package/src/Heading/Heading.tsx +50 -0
- package/src/Heading/Heading.types.ts +16 -0
- package/src/Heading/index.ts +2 -0
- package/src/Icon/Icon.css +26 -0
- package/src/Icon/Icon.tsx +79 -0
- package/src/Icon/Icon.types.ts +13 -0
- package/src/Icon/index.ts +2 -0
- package/src/Input/Input.css +145 -0
- package/src/Input/Input.tsx +86 -0
- package/src/Input/Input.types.ts +15 -0
- package/src/Input/index.ts +2 -0
- package/src/Link/Link.css +50 -0
- package/src/Link/Link.tsx +64 -0
- package/src/Link/Link.types.ts +13 -0
- package/src/Link/index.ts +2 -0
- package/src/Select/Select.css +115 -0
- package/src/Select/Select.tsx +109 -0
- package/src/Select/Select.types.ts +19 -0
- package/src/Select/index.ts +2 -0
- package/src/Text/Text.css +49 -0
- package/src/Text/Text.tsx +46 -0
- package/src/Text/Text.types.ts +19 -0
- package/src/Text/index.ts +2 -0
- package/src/index.ts +34 -0
- package/src/layout/Container/Container.css +16 -0
- package/src/layout/Container/Container.tsx +51 -0
- package/src/layout/Container/Container.types.ts +12 -0
- package/src/layout/Container/index.ts +2 -0
- package/src/layout/Flex/Flex.css +34 -0
- package/src/layout/Flex/Flex.tsx +56 -0
- package/src/layout/Flex/Flex.types.ts +18 -0
- package/src/layout/Flex/index.ts +2 -0
- package/src/layout/Grid/Grid.css +18 -0
- package/src/layout/Grid/Grid.tsx +61 -0
- package/src/layout/Grid/Grid.types.ts +17 -0
- package/src/layout/Grid/index.ts +2 -0
- package/src/layout/Stack/Stack.css +50 -0
- package/src/layout/Stack/Stack.tsx +70 -0
- package/src/layout/Stack/Stack.types.ts +17 -0
- package/src/layout/Stack/index.ts +2 -0
- package/src/styles/globals.css +28 -0
- package/src/styles/reset.css +44 -0
- package/src/theme/ThemeProvider.tsx +83 -0
- package/src/theme/dark.css +62 -0
- package/src/theme/index.ts +2 -0
- package/src/theme/light.css +62 -0
- package/src/theme/theme.types.ts +19 -0
- package/src/theme/tokens.css +61 -0
- package/src/utils/index.ts +44 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,876 @@
|
|
|
1
|
+
// src/Text/Text.tsx
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
// src/utils/index.ts
|
|
5
|
+
function cx(...classes) {
|
|
6
|
+
const result = [];
|
|
7
|
+
for (const item of classes) {
|
|
8
|
+
if (!item) continue;
|
|
9
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
10
|
+
result.push(String(item));
|
|
11
|
+
} else if (Array.isArray(item)) {
|
|
12
|
+
const inner = cx(...item);
|
|
13
|
+
if (inner) result.push(inner);
|
|
14
|
+
} else if (typeof item === "object") {
|
|
15
|
+
for (const [key, value] of Object.entries(item)) {
|
|
16
|
+
if (value) result.push(key);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result.join(" ");
|
|
21
|
+
}
|
|
22
|
+
function getSpaceValue(val) {
|
|
23
|
+
if (val === void 0) return void 0;
|
|
24
|
+
if (typeof val === "number") return `${val}px`;
|
|
25
|
+
const tokenList = ["2xs", "xs", "sm", "md", "lg", "xl", "2xl", "3xl"];
|
|
26
|
+
if (tokenList.includes(val)) {
|
|
27
|
+
return `var(--ui-space-${val})`;
|
|
28
|
+
}
|
|
29
|
+
return val;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/Text/Text.tsx
|
|
33
|
+
var Text = forwardRef(function Text2({
|
|
34
|
+
as: Component = "p",
|
|
35
|
+
size = "md",
|
|
36
|
+
weight = "normal",
|
|
37
|
+
color = "default",
|
|
38
|
+
muted = false,
|
|
39
|
+
align,
|
|
40
|
+
truncate = false,
|
|
41
|
+
mono = false,
|
|
42
|
+
className,
|
|
43
|
+
children,
|
|
44
|
+
...rest
|
|
45
|
+
}, ref) {
|
|
46
|
+
const resolvedColor = muted ? "muted" : color;
|
|
47
|
+
const classes = cx(
|
|
48
|
+
"ui-text",
|
|
49
|
+
`ui-text--size-${size}`,
|
|
50
|
+
`ui-text--weight-${weight}`,
|
|
51
|
+
`ui-text--color-${resolvedColor}`,
|
|
52
|
+
align && `ui-text--align-${align}`,
|
|
53
|
+
truncate && "ui-text--truncate",
|
|
54
|
+
mono && "ui-text--mono",
|
|
55
|
+
className
|
|
56
|
+
);
|
|
57
|
+
return React.createElement(
|
|
58
|
+
Component,
|
|
59
|
+
{
|
|
60
|
+
ref,
|
|
61
|
+
className: classes,
|
|
62
|
+
...rest
|
|
63
|
+
},
|
|
64
|
+
children
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
Text.displayName = "Text";
|
|
68
|
+
|
|
69
|
+
// src/Heading/Heading.tsx
|
|
70
|
+
import React2, { forwardRef as forwardRef2 } from "react";
|
|
71
|
+
var defaultLevelSizeMap = {
|
|
72
|
+
1: "3xl",
|
|
73
|
+
2: "2xl",
|
|
74
|
+
3: "xl",
|
|
75
|
+
4: "lg",
|
|
76
|
+
5: "md",
|
|
77
|
+
6: "sm"
|
|
78
|
+
};
|
|
79
|
+
var Heading = forwardRef2(function Heading2({
|
|
80
|
+
level = 2,
|
|
81
|
+
as,
|
|
82
|
+
size,
|
|
83
|
+
weight = "semibold",
|
|
84
|
+
align,
|
|
85
|
+
className,
|
|
86
|
+
children,
|
|
87
|
+
...rest
|
|
88
|
+
}, ref) {
|
|
89
|
+
const Component = as || `h${level}`;
|
|
90
|
+
const resolvedSize = size || defaultLevelSizeMap[level] || "xl";
|
|
91
|
+
const classes = cx(
|
|
92
|
+
"ui-heading",
|
|
93
|
+
`ui-heading--size-${resolvedSize}`,
|
|
94
|
+
`ui-heading--weight-${weight}`,
|
|
95
|
+
align && `ui-heading--align-${align}`,
|
|
96
|
+
className
|
|
97
|
+
);
|
|
98
|
+
return React2.createElement(
|
|
99
|
+
Component,
|
|
100
|
+
{
|
|
101
|
+
ref,
|
|
102
|
+
className: classes,
|
|
103
|
+
...rest
|
|
104
|
+
},
|
|
105
|
+
children
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
Heading.displayName = "Heading";
|
|
109
|
+
|
|
110
|
+
// src/Icon/Icon.tsx
|
|
111
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
112
|
+
import { jsx } from "react/jsx-runtime";
|
|
113
|
+
var sizeMap = {
|
|
114
|
+
xs: 14,
|
|
115
|
+
sm: 16,
|
|
116
|
+
md: 20,
|
|
117
|
+
lg: 24,
|
|
118
|
+
xl: 32
|
|
119
|
+
};
|
|
120
|
+
var Icon = forwardRef3(function Icon2({
|
|
121
|
+
icon: Component,
|
|
122
|
+
size = "md",
|
|
123
|
+
color = "inherit",
|
|
124
|
+
spin = false,
|
|
125
|
+
className,
|
|
126
|
+
style,
|
|
127
|
+
children,
|
|
128
|
+
...rest
|
|
129
|
+
}, ref) {
|
|
130
|
+
const pixelSize = typeof size === "number" ? size : sizeMap[size] || 20;
|
|
131
|
+
let resolvedColor = color;
|
|
132
|
+
const tokenColors = {
|
|
133
|
+
default: "var(--ui-color-foreground)",
|
|
134
|
+
muted: "var(--ui-color-foreground-muted)",
|
|
135
|
+
subtle: "var(--ui-color-foreground-subtle)",
|
|
136
|
+
primary: "var(--ui-color-primary)",
|
|
137
|
+
success: "var(--ui-color-success)",
|
|
138
|
+
warning: "var(--ui-color-warning)",
|
|
139
|
+
danger: "var(--ui-color-danger)",
|
|
140
|
+
inherit: "currentColor"
|
|
141
|
+
};
|
|
142
|
+
if (tokenColors[color]) {
|
|
143
|
+
resolvedColor = tokenColors[color];
|
|
144
|
+
}
|
|
145
|
+
const classes = cx(
|
|
146
|
+
"ui-icon",
|
|
147
|
+
spin && "ui-icon--spin",
|
|
148
|
+
className
|
|
149
|
+
);
|
|
150
|
+
const combinedStyle = {
|
|
151
|
+
width: `${pixelSize}px`,
|
|
152
|
+
height: `${pixelSize}px`,
|
|
153
|
+
color: resolvedColor,
|
|
154
|
+
...style
|
|
155
|
+
};
|
|
156
|
+
if (Component) {
|
|
157
|
+
return /* @__PURE__ */ jsx("span", { className: classes, style: combinedStyle, children: /* @__PURE__ */ jsx(
|
|
158
|
+
Component,
|
|
159
|
+
{
|
|
160
|
+
ref,
|
|
161
|
+
width: pixelSize,
|
|
162
|
+
height: pixelSize,
|
|
163
|
+
"aria-hidden": "true",
|
|
164
|
+
...rest
|
|
165
|
+
}
|
|
166
|
+
) });
|
|
167
|
+
}
|
|
168
|
+
return /* @__PURE__ */ jsx("span", { className: classes, style: combinedStyle, "aria-hidden": "true", children });
|
|
169
|
+
});
|
|
170
|
+
Icon.displayName = "Icon";
|
|
171
|
+
|
|
172
|
+
// src/Divider/Divider.tsx
|
|
173
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
174
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
175
|
+
var Divider = forwardRef4(function Divider2({
|
|
176
|
+
orientation = "horizontal",
|
|
177
|
+
spacing = "md",
|
|
178
|
+
label,
|
|
179
|
+
align = "center",
|
|
180
|
+
className,
|
|
181
|
+
style,
|
|
182
|
+
children,
|
|
183
|
+
...rest
|
|
184
|
+
}, ref) {
|
|
185
|
+
const content = label || children;
|
|
186
|
+
const spacingVal = getSpaceValue(spacing);
|
|
187
|
+
const classes = cx(
|
|
188
|
+
"ui-divider",
|
|
189
|
+
`ui-divider--${orientation}`,
|
|
190
|
+
content && `ui-divider--align-${align}`,
|
|
191
|
+
className
|
|
192
|
+
);
|
|
193
|
+
const combinedStyle = {
|
|
194
|
+
marginTop: orientation === "horizontal" ? spacingVal : void 0,
|
|
195
|
+
marginBottom: orientation === "horizontal" ? spacingVal : void 0,
|
|
196
|
+
marginLeft: orientation === "vertical" ? spacingVal : void 0,
|
|
197
|
+
marginRight: orientation === "vertical" ? spacingVal : void 0,
|
|
198
|
+
...style
|
|
199
|
+
};
|
|
200
|
+
return /* @__PURE__ */ jsxs(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
ref,
|
|
204
|
+
role: "separator",
|
|
205
|
+
"aria-orientation": orientation,
|
|
206
|
+
className: classes,
|
|
207
|
+
style: combinedStyle,
|
|
208
|
+
...rest,
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx2("div", { className: "ui-divider__line" }),
|
|
211
|
+
content && /* @__PURE__ */ jsx2("span", { className: "ui-divider__content", children: content }),
|
|
212
|
+
content && /* @__PURE__ */ jsx2("div", { className: "ui-divider__line" })
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
Divider.displayName = "Divider";
|
|
218
|
+
|
|
219
|
+
// src/Button/Button.tsx
|
|
220
|
+
import React5, { forwardRef as forwardRef5 } from "react";
|
|
221
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
222
|
+
var Button = forwardRef5(function Button2({
|
|
223
|
+
variant = "primary",
|
|
224
|
+
size = "md",
|
|
225
|
+
loading = false,
|
|
226
|
+
disabled = false,
|
|
227
|
+
iconLeft,
|
|
228
|
+
iconRight,
|
|
229
|
+
fullWidth = false,
|
|
230
|
+
as: Component = "button",
|
|
231
|
+
type = "button",
|
|
232
|
+
className,
|
|
233
|
+
children,
|
|
234
|
+
...rest
|
|
235
|
+
}, ref) {
|
|
236
|
+
const isActuallyDisabled = disabled || loading;
|
|
237
|
+
const classes = cx(
|
|
238
|
+
"ui-btn",
|
|
239
|
+
`ui-btn--variant-${variant}`,
|
|
240
|
+
`ui-btn--size-${size}`,
|
|
241
|
+
fullWidth && "ui-btn--full-width",
|
|
242
|
+
isActuallyDisabled && "ui-btn--disabled",
|
|
243
|
+
loading && "ui-btn--loading",
|
|
244
|
+
className
|
|
245
|
+
);
|
|
246
|
+
const buttonProps = Component === "button" ? { type, disabled: isActuallyDisabled } : { "aria-disabled": isActuallyDisabled };
|
|
247
|
+
return React5.createElement(
|
|
248
|
+
Component,
|
|
249
|
+
{
|
|
250
|
+
ref,
|
|
251
|
+
className: classes,
|
|
252
|
+
...buttonProps,
|
|
253
|
+
...rest
|
|
254
|
+
},
|
|
255
|
+
/* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
256
|
+
loading ? /* @__PURE__ */ jsx3("span", { className: "ui-btn__spinner", "aria-hidden": "true" }) : iconLeft && /* @__PURE__ */ jsx3("span", { className: "ui-btn__icon-left", children: iconLeft }),
|
|
257
|
+
children && /* @__PURE__ */ jsx3("span", { className: "ui-btn__label", children }),
|
|
258
|
+
!loading && iconRight && /* @__PURE__ */ jsx3("span", { className: "ui-btn__icon-right", children: iconRight })
|
|
259
|
+
] })
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
Button.displayName = "Button";
|
|
263
|
+
|
|
264
|
+
// src/Link/Link.tsx
|
|
265
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
266
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
267
|
+
var Link = forwardRef6(function Link2({
|
|
268
|
+
variant = "default",
|
|
269
|
+
size = "md",
|
|
270
|
+
external = false,
|
|
271
|
+
iconLeft,
|
|
272
|
+
iconRight,
|
|
273
|
+
className,
|
|
274
|
+
target,
|
|
275
|
+
rel,
|
|
276
|
+
children,
|
|
277
|
+
...rest
|
|
278
|
+
}, ref) {
|
|
279
|
+
const classes = cx(
|
|
280
|
+
"ui-link",
|
|
281
|
+
`ui-link--variant-${variant}`,
|
|
282
|
+
`ui-link--size-${size}`,
|
|
283
|
+
className
|
|
284
|
+
);
|
|
285
|
+
const resolvedTarget = external ? "_blank" : target;
|
|
286
|
+
const resolvedRel = external ? rel ? `${rel} noopener noreferrer` : "noopener noreferrer" : rel;
|
|
287
|
+
return /* @__PURE__ */ jsxs3(
|
|
288
|
+
"a",
|
|
289
|
+
{
|
|
290
|
+
ref,
|
|
291
|
+
className: classes,
|
|
292
|
+
target: resolvedTarget,
|
|
293
|
+
rel: resolvedRel,
|
|
294
|
+
...rest,
|
|
295
|
+
children: [
|
|
296
|
+
iconLeft && /* @__PURE__ */ jsx4("span", { className: "ui-link__icon-left", children: iconLeft }),
|
|
297
|
+
/* @__PURE__ */ jsx4("span", { children }),
|
|
298
|
+
iconRight && /* @__PURE__ */ jsx4("span", { className: "ui-link__icon-right", children: iconRight }),
|
|
299
|
+
external && !iconRight && /* @__PURE__ */ jsxs3(
|
|
300
|
+
"svg",
|
|
301
|
+
{
|
|
302
|
+
width: "12",
|
|
303
|
+
height: "12",
|
|
304
|
+
viewBox: "0 0 24 24",
|
|
305
|
+
fill: "none",
|
|
306
|
+
stroke: "currentColor",
|
|
307
|
+
strokeWidth: "2",
|
|
308
|
+
strokeLinecap: "round",
|
|
309
|
+
strokeLinejoin: "round",
|
|
310
|
+
className: "ui-link__external-icon",
|
|
311
|
+
"aria-hidden": "true",
|
|
312
|
+
children: [
|
|
313
|
+
/* @__PURE__ */ jsx4("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
314
|
+
/* @__PURE__ */ jsx4("polyline", { points: "15 3 21 3 21 9" }),
|
|
315
|
+
/* @__PURE__ */ jsx4("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
)
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
Link.displayName = "Link";
|
|
324
|
+
|
|
325
|
+
// src/Input/Input.tsx
|
|
326
|
+
import { forwardRef as forwardRef7, useId } from "react";
|
|
327
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
328
|
+
var Input = forwardRef7(function Input2({
|
|
329
|
+
size = "md",
|
|
330
|
+
variant = "default",
|
|
331
|
+
label,
|
|
332
|
+
helperText,
|
|
333
|
+
error,
|
|
334
|
+
leftIcon,
|
|
335
|
+
rightIcon,
|
|
336
|
+
fullWidth = false,
|
|
337
|
+
disabled = false,
|
|
338
|
+
id: explicitId,
|
|
339
|
+
className,
|
|
340
|
+
...rest
|
|
341
|
+
}, ref) {
|
|
342
|
+
const generatedId = useId();
|
|
343
|
+
const id = explicitId || generatedId;
|
|
344
|
+
const helperId = `${id}-helper`;
|
|
345
|
+
const hasError = Boolean(error);
|
|
346
|
+
const errorMessage = typeof error === "string" ? error : void 0;
|
|
347
|
+
const isReadOnly = rest.readOnly !== void 0 ? rest.readOnly : rest.value !== void 0 && !rest.onChange ? true : void 0;
|
|
348
|
+
const wrapperClasses = cx(
|
|
349
|
+
"ui-input-wrapper",
|
|
350
|
+
fullWidth && "ui-input-wrapper--full-width"
|
|
351
|
+
);
|
|
352
|
+
const inputClasses = cx(
|
|
353
|
+
"ui-input",
|
|
354
|
+
`ui-input--size-${size}`,
|
|
355
|
+
`ui-input--variant-${variant}`,
|
|
356
|
+
leftIcon && "ui-input--has-left-icon",
|
|
357
|
+
rightIcon && "ui-input--has-right-icon",
|
|
358
|
+
hasError && "ui-input--error",
|
|
359
|
+
className
|
|
360
|
+
);
|
|
361
|
+
return /* @__PURE__ */ jsxs4("div", { className: wrapperClasses, children: [
|
|
362
|
+
label && /* @__PURE__ */ jsx5(
|
|
363
|
+
"label",
|
|
364
|
+
{
|
|
365
|
+
htmlFor: id,
|
|
366
|
+
className: cx("ui-input-label", disabled && "ui-input-label--disabled"),
|
|
367
|
+
children: label
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
/* @__PURE__ */ jsxs4("div", { className: "ui-input-container", children: [
|
|
371
|
+
leftIcon && /* @__PURE__ */ jsx5("span", { className: "ui-input__icon ui-input__icon--left", children: leftIcon }),
|
|
372
|
+
/* @__PURE__ */ jsx5(
|
|
373
|
+
"input",
|
|
374
|
+
{
|
|
375
|
+
ref,
|
|
376
|
+
id,
|
|
377
|
+
disabled,
|
|
378
|
+
readOnly: isReadOnly,
|
|
379
|
+
"aria-invalid": hasError,
|
|
380
|
+
"aria-describedby": helperText || errorMessage ? helperId : void 0,
|
|
381
|
+
className: inputClasses,
|
|
382
|
+
...rest
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
rightIcon && /* @__PURE__ */ jsx5("span", { className: "ui-input__icon ui-input__icon--right", children: rightIcon })
|
|
386
|
+
] }),
|
|
387
|
+
(errorMessage || helperText) && /* @__PURE__ */ jsx5(
|
|
388
|
+
"span",
|
|
389
|
+
{
|
|
390
|
+
id: helperId,
|
|
391
|
+
className: cx("ui-input-helper", hasError && "ui-input-helper--error"),
|
|
392
|
+
children: errorMessage || helperText
|
|
393
|
+
}
|
|
394
|
+
)
|
|
395
|
+
] });
|
|
396
|
+
});
|
|
397
|
+
Input.displayName = "Input";
|
|
398
|
+
|
|
399
|
+
// src/Checkbox/Checkbox.tsx
|
|
400
|
+
import { forwardRef as forwardRef8, useEffect, useRef } from "react";
|
|
401
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
402
|
+
var Checkbox = forwardRef8(function Checkbox2({
|
|
403
|
+
size = "md",
|
|
404
|
+
label,
|
|
405
|
+
description,
|
|
406
|
+
indeterminate = false,
|
|
407
|
+
checked,
|
|
408
|
+
defaultChecked,
|
|
409
|
+
disabled = false,
|
|
410
|
+
error,
|
|
411
|
+
className,
|
|
412
|
+
onChange,
|
|
413
|
+
readOnly,
|
|
414
|
+
...rest
|
|
415
|
+
}, forwardedRef) {
|
|
416
|
+
const innerRef = useRef(null);
|
|
417
|
+
const inputRef = forwardedRef || innerRef;
|
|
418
|
+
useEffect(() => {
|
|
419
|
+
if (inputRef.current) {
|
|
420
|
+
inputRef.current.indeterminate = Boolean(indeterminate);
|
|
421
|
+
}
|
|
422
|
+
}, [indeterminate, inputRef]);
|
|
423
|
+
const isChecked = checked !== void 0 ? checked : void 0;
|
|
424
|
+
const isReadOnly = readOnly !== void 0 ? readOnly : checked !== void 0 && !onChange ? true : void 0;
|
|
425
|
+
const wrapperClasses = cx(
|
|
426
|
+
"ui-checkbox-wrapper",
|
|
427
|
+
disabled && "ui-checkbox-wrapper--disabled",
|
|
428
|
+
className
|
|
429
|
+
);
|
|
430
|
+
const boxClasses = cx(
|
|
431
|
+
"ui-checkbox-box",
|
|
432
|
+
`ui-checkbox-box--${size}`,
|
|
433
|
+
(isChecked || defaultChecked) && "ui-checkbox-box--checked",
|
|
434
|
+
indeterminate && "ui-checkbox-box--indeterminate",
|
|
435
|
+
error && "ui-checkbox-box--error"
|
|
436
|
+
);
|
|
437
|
+
return /* @__PURE__ */ jsxs5("label", { className: wrapperClasses, children: [
|
|
438
|
+
/* @__PURE__ */ jsx6(
|
|
439
|
+
"input",
|
|
440
|
+
{
|
|
441
|
+
ref: inputRef,
|
|
442
|
+
type: "checkbox",
|
|
443
|
+
checked,
|
|
444
|
+
defaultChecked,
|
|
445
|
+
disabled,
|
|
446
|
+
readOnly: isReadOnly,
|
|
447
|
+
onChange,
|
|
448
|
+
className: "ui-checkbox-input",
|
|
449
|
+
...rest
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ jsx6("span", { className: boxClasses, "aria-hidden": "true", children: indeterminate ? /* @__PURE__ */ jsx6("svg", { className: "ui-checkbox-icon", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx6("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) }) : /* @__PURE__ */ jsx6("svg", { className: "ui-checkbox-icon", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx6("polyline", { points: "20 6 9 17 4 12" }) }) }),
|
|
453
|
+
(label || description) && /* @__PURE__ */ jsxs5("span", { className: "ui-checkbox-content", children: [
|
|
454
|
+
label && /* @__PURE__ */ jsx6("span", { className: "ui-checkbox-label", children: label }),
|
|
455
|
+
description && /* @__PURE__ */ jsx6("span", { className: "ui-checkbox-desc", children: description })
|
|
456
|
+
] })
|
|
457
|
+
] });
|
|
458
|
+
});
|
|
459
|
+
Checkbox.displayName = "Checkbox";
|
|
460
|
+
|
|
461
|
+
// src/Select/Select.tsx
|
|
462
|
+
import { forwardRef as forwardRef9, useId as useId2 } from "react";
|
|
463
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
464
|
+
var Select = forwardRef9(function Select2({
|
|
465
|
+
options,
|
|
466
|
+
placeholder,
|
|
467
|
+
size = "md",
|
|
468
|
+
label,
|
|
469
|
+
helperText,
|
|
470
|
+
error,
|
|
471
|
+
fullWidth = false,
|
|
472
|
+
disabled = false,
|
|
473
|
+
id: explicitId,
|
|
474
|
+
className,
|
|
475
|
+
children,
|
|
476
|
+
value,
|
|
477
|
+
defaultValue,
|
|
478
|
+
...rest
|
|
479
|
+
}, ref) {
|
|
480
|
+
const generatedId = useId2();
|
|
481
|
+
const id = explicitId || generatedId;
|
|
482
|
+
const helperId = `${id}-helper`;
|
|
483
|
+
const hasError = Boolean(error);
|
|
484
|
+
const errorMessage = typeof error === "string" ? error : void 0;
|
|
485
|
+
const wrapperClasses = cx(
|
|
486
|
+
"ui-select-wrapper",
|
|
487
|
+
fullWidth && "ui-select-wrapper--full-width"
|
|
488
|
+
);
|
|
489
|
+
const selectClasses = cx(
|
|
490
|
+
"ui-select",
|
|
491
|
+
`ui-select--size-${size}`,
|
|
492
|
+
hasError && "ui-select--error",
|
|
493
|
+
className
|
|
494
|
+
);
|
|
495
|
+
return /* @__PURE__ */ jsxs6("div", { className: wrapperClasses, children: [
|
|
496
|
+
label && /* @__PURE__ */ jsx7(
|
|
497
|
+
"label",
|
|
498
|
+
{
|
|
499
|
+
htmlFor: id,
|
|
500
|
+
className: cx("ui-select-label", disabled && "ui-select-label--disabled"),
|
|
501
|
+
children: label
|
|
502
|
+
}
|
|
503
|
+
),
|
|
504
|
+
/* @__PURE__ */ jsxs6("div", { className: "ui-select-container", children: [
|
|
505
|
+
/* @__PURE__ */ jsxs6(
|
|
506
|
+
"select",
|
|
507
|
+
{
|
|
508
|
+
ref,
|
|
509
|
+
id,
|
|
510
|
+
disabled,
|
|
511
|
+
value,
|
|
512
|
+
defaultValue,
|
|
513
|
+
"aria-invalid": hasError,
|
|
514
|
+
"aria-describedby": helperText || errorMessage ? helperId : void 0,
|
|
515
|
+
className: selectClasses,
|
|
516
|
+
...rest,
|
|
517
|
+
children: [
|
|
518
|
+
placeholder && /* @__PURE__ */ jsx7("option", { value: "", disabled: true, children: placeholder }),
|
|
519
|
+
options ? options.map((opt) => /* @__PURE__ */ jsx7("option", { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value)) : children
|
|
520
|
+
]
|
|
521
|
+
}
|
|
522
|
+
),
|
|
523
|
+
/* @__PURE__ */ jsx7("span", { className: "ui-select-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx7(
|
|
524
|
+
"svg",
|
|
525
|
+
{
|
|
526
|
+
width: "16",
|
|
527
|
+
height: "16",
|
|
528
|
+
viewBox: "0 0 24 24",
|
|
529
|
+
fill: "none",
|
|
530
|
+
stroke: "currentColor",
|
|
531
|
+
strokeWidth: "2",
|
|
532
|
+
strokeLinecap: "round",
|
|
533
|
+
strokeLinejoin: "round",
|
|
534
|
+
children: /* @__PURE__ */ jsx7("polyline", { points: "6 9 12 15 18 9" })
|
|
535
|
+
}
|
|
536
|
+
) })
|
|
537
|
+
] }),
|
|
538
|
+
(errorMessage || helperText) && /* @__PURE__ */ jsx7(
|
|
539
|
+
"span",
|
|
540
|
+
{
|
|
541
|
+
id: helperId,
|
|
542
|
+
className: cx("ui-select-helper", hasError && "ui-select-helper--error"),
|
|
543
|
+
children: errorMessage || helperText
|
|
544
|
+
}
|
|
545
|
+
)
|
|
546
|
+
] });
|
|
547
|
+
});
|
|
548
|
+
Select.displayName = "Select";
|
|
549
|
+
|
|
550
|
+
// src/Card/Card.tsx
|
|
551
|
+
import React10, { forwardRef as forwardRef10 } from "react";
|
|
552
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
553
|
+
var CardBase = forwardRef10(function Card({
|
|
554
|
+
as: Component = "div",
|
|
555
|
+
variant = "outlined",
|
|
556
|
+
padding = "lg",
|
|
557
|
+
interactive = false,
|
|
558
|
+
className,
|
|
559
|
+
children,
|
|
560
|
+
...rest
|
|
561
|
+
}, ref) {
|
|
562
|
+
const classes = cx(
|
|
563
|
+
"ui-card",
|
|
564
|
+
`ui-card--variant-${variant}`,
|
|
565
|
+
`ui-card--padding-${padding}`,
|
|
566
|
+
interactive && "ui-card--interactive",
|
|
567
|
+
className
|
|
568
|
+
);
|
|
569
|
+
return React10.createElement(
|
|
570
|
+
Component,
|
|
571
|
+
{
|
|
572
|
+
ref,
|
|
573
|
+
className: classes,
|
|
574
|
+
...rest
|
|
575
|
+
},
|
|
576
|
+
children
|
|
577
|
+
);
|
|
578
|
+
});
|
|
579
|
+
var CardHeader = forwardRef10(function CardHeader2({ className, children, ...rest }, ref) {
|
|
580
|
+
return /* @__PURE__ */ jsx8("div", { ref, className: cx("ui-card__header", className), ...rest, children });
|
|
581
|
+
});
|
|
582
|
+
CardHeader.displayName = "Card.Header";
|
|
583
|
+
var CardBody = forwardRef10(function CardBody2({ className, children, ...rest }, ref) {
|
|
584
|
+
return /* @__PURE__ */ jsx8("div", { ref, className: cx("ui-card__body", className), ...rest, children });
|
|
585
|
+
});
|
|
586
|
+
CardBody.displayName = "Card.Body";
|
|
587
|
+
var CardFooter = forwardRef10(function CardFooter2({ className, children, ...rest }, ref) {
|
|
588
|
+
return /* @__PURE__ */ jsx8("div", { ref, className: cx("ui-card__footer", className), ...rest, children });
|
|
589
|
+
});
|
|
590
|
+
CardFooter.displayName = "Card.Footer";
|
|
591
|
+
var Card2 = Object.assign(CardBase, {
|
|
592
|
+
Header: CardHeader,
|
|
593
|
+
Body: CardBody,
|
|
594
|
+
Footer: CardFooter
|
|
595
|
+
});
|
|
596
|
+
Card2.displayName = "Card";
|
|
597
|
+
|
|
598
|
+
// src/layout/Stack/Stack.tsx
|
|
599
|
+
import React11, { forwardRef as forwardRef11, Children } from "react";
|
|
600
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
601
|
+
var Stack = forwardRef11(function Stack2({
|
|
602
|
+
as: Component = "div",
|
|
603
|
+
direction = "vertical",
|
|
604
|
+
gap = "md",
|
|
605
|
+
align,
|
|
606
|
+
justify,
|
|
607
|
+
wrap = false,
|
|
608
|
+
divider,
|
|
609
|
+
className,
|
|
610
|
+
style,
|
|
611
|
+
children,
|
|
612
|
+
...rest
|
|
613
|
+
}, ref) {
|
|
614
|
+
const resolvedGap = gap === "none" ? "0px" : getSpaceValue(gap);
|
|
615
|
+
const classes = cx(
|
|
616
|
+
"ui-stack",
|
|
617
|
+
`ui-stack--${direction}`,
|
|
618
|
+
align && `ui-stack--align-${align}`,
|
|
619
|
+
justify && `ui-stack--justify-${justify}`,
|
|
620
|
+
wrap && "ui-stack--wrap",
|
|
621
|
+
className
|
|
622
|
+
);
|
|
623
|
+
const combinedStyle = {
|
|
624
|
+
gap: resolvedGap,
|
|
625
|
+
...style
|
|
626
|
+
};
|
|
627
|
+
let renderedChildren = children;
|
|
628
|
+
if (divider) {
|
|
629
|
+
const validChildren = Children.toArray(children).filter(Boolean);
|
|
630
|
+
renderedChildren = validChildren.map((child, index) => {
|
|
631
|
+
const isLast = index === validChildren.length - 1;
|
|
632
|
+
return /* @__PURE__ */ jsxs7(React11.Fragment, { children: [
|
|
633
|
+
child,
|
|
634
|
+
!isLast && (React11.isValidElement(divider) ? divider : /* @__PURE__ */ jsx9("div", { className: "ui-stack-divider", role: "separator" }))
|
|
635
|
+
] }, index);
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
return React11.createElement(
|
|
639
|
+
Component,
|
|
640
|
+
{
|
|
641
|
+
ref,
|
|
642
|
+
className: classes,
|
|
643
|
+
style: combinedStyle,
|
|
644
|
+
...rest
|
|
645
|
+
},
|
|
646
|
+
renderedChildren
|
|
647
|
+
);
|
|
648
|
+
});
|
|
649
|
+
Stack.displayName = "Stack";
|
|
650
|
+
|
|
651
|
+
// src/layout/Flex/Flex.tsx
|
|
652
|
+
import React12, { forwardRef as forwardRef12 } from "react";
|
|
653
|
+
var Flex = forwardRef12(function Flex2({
|
|
654
|
+
as: Component = "div",
|
|
655
|
+
direction = "row",
|
|
656
|
+
align,
|
|
657
|
+
justify,
|
|
658
|
+
gap,
|
|
659
|
+
wrap,
|
|
660
|
+
inline = false,
|
|
661
|
+
className,
|
|
662
|
+
style,
|
|
663
|
+
children,
|
|
664
|
+
...rest
|
|
665
|
+
}, ref) {
|
|
666
|
+
const resolvedGap = getSpaceValue(gap);
|
|
667
|
+
const wrapClass = typeof wrap === "boolean" ? wrap ? "ui-flex--wrap" : "ui-flex--wrap-nowrap" : wrap ? `ui-flex--wrap-${wrap}` : void 0;
|
|
668
|
+
const classes = cx(
|
|
669
|
+
"ui-flex",
|
|
670
|
+
inline && "ui-flex--inline",
|
|
671
|
+
direction && `ui-flex--direction-${direction}`,
|
|
672
|
+
align && `ui-flex--align-${align}`,
|
|
673
|
+
justify && `ui-flex--justify-${justify}`,
|
|
674
|
+
wrapClass,
|
|
675
|
+
className
|
|
676
|
+
);
|
|
677
|
+
const combinedStyle = {
|
|
678
|
+
gap: resolvedGap,
|
|
679
|
+
...style
|
|
680
|
+
};
|
|
681
|
+
return React12.createElement(
|
|
682
|
+
Component,
|
|
683
|
+
{
|
|
684
|
+
ref,
|
|
685
|
+
className: classes,
|
|
686
|
+
style: combinedStyle,
|
|
687
|
+
...rest
|
|
688
|
+
},
|
|
689
|
+
children
|
|
690
|
+
);
|
|
691
|
+
});
|
|
692
|
+
Flex.displayName = "Flex";
|
|
693
|
+
|
|
694
|
+
// src/layout/Grid/Grid.tsx
|
|
695
|
+
import React13, { forwardRef as forwardRef13 } from "react";
|
|
696
|
+
var Grid = forwardRef13(function Grid2({
|
|
697
|
+
as: Component = "div",
|
|
698
|
+
columns,
|
|
699
|
+
minChildWidth,
|
|
700
|
+
gap = "md",
|
|
701
|
+
rowGap,
|
|
702
|
+
columnGap,
|
|
703
|
+
align,
|
|
704
|
+
justify,
|
|
705
|
+
className,
|
|
706
|
+
style,
|
|
707
|
+
children,
|
|
708
|
+
...rest
|
|
709
|
+
}, ref) {
|
|
710
|
+
let gridTemplateColumns;
|
|
711
|
+
if (minChildWidth) {
|
|
712
|
+
const minWidth = typeof minChildWidth === "number" ? `${minChildWidth}px` : minChildWidth;
|
|
713
|
+
gridTemplateColumns = `repeat(auto-fit, minmax(${minWidth}, 1fr))`;
|
|
714
|
+
} else if (typeof columns === "number") {
|
|
715
|
+
gridTemplateColumns = `repeat(${columns}, minmax(0, 1fr))`;
|
|
716
|
+
} else if (typeof columns === "string") {
|
|
717
|
+
gridTemplateColumns = columns;
|
|
718
|
+
}
|
|
719
|
+
const classes = cx(
|
|
720
|
+
"ui-grid",
|
|
721
|
+
align && `ui-grid--align-${align}`,
|
|
722
|
+
justify && `ui-grid--justify-${justify}`,
|
|
723
|
+
className
|
|
724
|
+
);
|
|
725
|
+
const combinedStyle = {
|
|
726
|
+
gridTemplateColumns,
|
|
727
|
+
gap: getSpaceValue(gap),
|
|
728
|
+
rowGap: getSpaceValue(rowGap),
|
|
729
|
+
columnGap: getSpaceValue(columnGap),
|
|
730
|
+
...style
|
|
731
|
+
};
|
|
732
|
+
return React13.createElement(
|
|
733
|
+
Component,
|
|
734
|
+
{
|
|
735
|
+
ref,
|
|
736
|
+
className: classes,
|
|
737
|
+
style: combinedStyle,
|
|
738
|
+
...rest
|
|
739
|
+
},
|
|
740
|
+
children
|
|
741
|
+
);
|
|
742
|
+
});
|
|
743
|
+
Grid.displayName = "Grid";
|
|
744
|
+
|
|
745
|
+
// src/layout/Container/Container.tsx
|
|
746
|
+
import React14, { forwardRef as forwardRef14 } from "react";
|
|
747
|
+
var Container = forwardRef14(function Container2({
|
|
748
|
+
as: Component = "div",
|
|
749
|
+
size = "lg",
|
|
750
|
+
centered = true,
|
|
751
|
+
padding = "md",
|
|
752
|
+
className,
|
|
753
|
+
style,
|
|
754
|
+
children,
|
|
755
|
+
...rest
|
|
756
|
+
}, ref) {
|
|
757
|
+
const classes = cx(
|
|
758
|
+
"ui-container",
|
|
759
|
+
`ui-container--size-${size}`,
|
|
760
|
+
centered && "ui-container--centered",
|
|
761
|
+
className
|
|
762
|
+
);
|
|
763
|
+
let paddingValue;
|
|
764
|
+
if (typeof padding === "boolean") {
|
|
765
|
+
paddingValue = padding ? "var(--ui-space-md)" : "0";
|
|
766
|
+
} else if (padding) {
|
|
767
|
+
paddingValue = getSpaceValue(padding);
|
|
768
|
+
}
|
|
769
|
+
const combinedStyle = {
|
|
770
|
+
paddingLeft: paddingValue,
|
|
771
|
+
paddingRight: paddingValue,
|
|
772
|
+
...style
|
|
773
|
+
};
|
|
774
|
+
return React14.createElement(
|
|
775
|
+
Component,
|
|
776
|
+
{
|
|
777
|
+
ref,
|
|
778
|
+
className: classes,
|
|
779
|
+
style: combinedStyle,
|
|
780
|
+
...rest
|
|
781
|
+
},
|
|
782
|
+
children
|
|
783
|
+
);
|
|
784
|
+
});
|
|
785
|
+
Container.displayName = "Container";
|
|
786
|
+
|
|
787
|
+
// src/theme/ThemeProvider.tsx
|
|
788
|
+
import { createContext, useContext, useEffect as useEffect2, useState, useMemo } from "react";
|
|
789
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
790
|
+
var ThemeContext = createContext(void 0);
|
|
791
|
+
function ThemeProvider({
|
|
792
|
+
children,
|
|
793
|
+
defaultTheme = "light",
|
|
794
|
+
storageKey = "atelier-ui-theme",
|
|
795
|
+
attribute = "data-theme",
|
|
796
|
+
enableSystem = true
|
|
797
|
+
}) {
|
|
798
|
+
const [theme, setThemeState] = useState(() => {
|
|
799
|
+
if (typeof window === "undefined") return defaultTheme;
|
|
800
|
+
try {
|
|
801
|
+
const stored = localStorage.getItem(storageKey);
|
|
802
|
+
if (stored === "light" || stored === "dark" || stored === "system") {
|
|
803
|
+
return stored;
|
|
804
|
+
}
|
|
805
|
+
} catch {
|
|
806
|
+
}
|
|
807
|
+
return defaultTheme;
|
|
808
|
+
});
|
|
809
|
+
const [resolvedTheme, setResolvedTheme] = useState("light");
|
|
810
|
+
useEffect2(() => {
|
|
811
|
+
const root = document.documentElement;
|
|
812
|
+
const getSystemTheme = () => {
|
|
813
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
814
|
+
};
|
|
815
|
+
const active = theme === "system" && enableSystem ? getSystemTheme() : theme === "dark" ? "dark" : "light";
|
|
816
|
+
setResolvedTheme(active);
|
|
817
|
+
root.setAttribute(attribute, active);
|
|
818
|
+
if (theme === "system" && enableSystem) {
|
|
819
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
820
|
+
const listener = (e) => {
|
|
821
|
+
const nextTheme = e.matches ? "dark" : "light";
|
|
822
|
+
setResolvedTheme(nextTheme);
|
|
823
|
+
root.setAttribute(attribute, nextTheme);
|
|
824
|
+
};
|
|
825
|
+
mediaQuery.addEventListener("change", listener);
|
|
826
|
+
return () => mediaQuery.removeEventListener("change", listener);
|
|
827
|
+
}
|
|
828
|
+
}, [theme, attribute, enableSystem]);
|
|
829
|
+
const setTheme = (newTheme) => {
|
|
830
|
+
try {
|
|
831
|
+
localStorage.setItem(storageKey, newTheme);
|
|
832
|
+
} catch {
|
|
833
|
+
}
|
|
834
|
+
setThemeState(newTheme);
|
|
835
|
+
};
|
|
836
|
+
const toggleTheme = () => {
|
|
837
|
+
setTheme(resolvedTheme === "light" ? "dark" : "light");
|
|
838
|
+
};
|
|
839
|
+
const value = useMemo(
|
|
840
|
+
() => ({
|
|
841
|
+
theme,
|
|
842
|
+
resolvedTheme,
|
|
843
|
+
setTheme,
|
|
844
|
+
toggleTheme
|
|
845
|
+
}),
|
|
846
|
+
[theme, resolvedTheme]
|
|
847
|
+
);
|
|
848
|
+
return /* @__PURE__ */ jsx10(ThemeContext.Provider, { value, children });
|
|
849
|
+
}
|
|
850
|
+
function useTheme() {
|
|
851
|
+
const context = useContext(ThemeContext);
|
|
852
|
+
if (!context) {
|
|
853
|
+
throw new Error("useTheme must be used within an Atelier UI ThemeProvider");
|
|
854
|
+
}
|
|
855
|
+
return context;
|
|
856
|
+
}
|
|
857
|
+
export {
|
|
858
|
+
Button,
|
|
859
|
+
Card2 as Card,
|
|
860
|
+
Checkbox,
|
|
861
|
+
Container,
|
|
862
|
+
Divider,
|
|
863
|
+
Flex,
|
|
864
|
+
Grid,
|
|
865
|
+
Heading,
|
|
866
|
+
Icon,
|
|
867
|
+
Input,
|
|
868
|
+
Link,
|
|
869
|
+
Select,
|
|
870
|
+
Stack,
|
|
871
|
+
Text,
|
|
872
|
+
ThemeProvider,
|
|
873
|
+
cx,
|
|
874
|
+
getSpaceValue,
|
|
875
|
+
useTheme
|
|
876
|
+
};
|