@causw/core 0.0.6 → 0.0.9
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.d.mts +206 -1
- package/dist/index.d.ts +206 -1
- package/dist/index.js +672 -0
- package/dist/index.mjs +658 -0
- package/package.json +21 -5
- package/src/styles/global.css +125 -0
package/dist/index.js
CHANGED
|
@@ -1,2 +1,674 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var React4 = require('react');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var tailwindMerge = require('tailwind-merge');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var reactSlot = require('@radix-ui/react-slot');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var React4__default = /*#__PURE__*/_interopDefault(React4);
|
|
12
|
+
|
|
13
|
+
// src/components/Text/Text.tsx
|
|
14
|
+
function mergeStyles(...inputs) {
|
|
15
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/components/Text/Text.styles.ts
|
|
19
|
+
var colorClasses = {
|
|
20
|
+
"gray-50": "text-gray-50",
|
|
21
|
+
"gray-100": "text-gray-100",
|
|
22
|
+
"gray-200": "text-gray-200",
|
|
23
|
+
"gray-300": "text-gray-300",
|
|
24
|
+
"gray-400": "text-gray-400",
|
|
25
|
+
"gray-500": "text-gray-500",
|
|
26
|
+
"gray-600": "text-gray-600",
|
|
27
|
+
"gray-700": "text-gray-700",
|
|
28
|
+
"gray-800": "text-gray-800",
|
|
29
|
+
"gray-900": "text-gray-900",
|
|
30
|
+
"blue-50": "text-blue-50",
|
|
31
|
+
"blue-500": "text-blue-500",
|
|
32
|
+
"blue-700": "text-blue-700",
|
|
33
|
+
"red-100": "text-red-100",
|
|
34
|
+
"red-400": "text-red-400",
|
|
35
|
+
white: "text-white-main",
|
|
36
|
+
black: "text-black-main"
|
|
37
|
+
};
|
|
38
|
+
var alignClasses = {
|
|
39
|
+
left: "text-left",
|
|
40
|
+
center: "text-center",
|
|
41
|
+
right: "text-right",
|
|
42
|
+
justify: "text-justify"
|
|
43
|
+
};
|
|
44
|
+
var typographyStyles = {
|
|
45
|
+
// Caption variants
|
|
46
|
+
"caption-sm": "typo-caption-sm",
|
|
47
|
+
"caption-sm-point": "typo-caption-sm-point",
|
|
48
|
+
"caption-md": "typo-caption-md",
|
|
49
|
+
"caption-md-point": "typo-caption-md-point",
|
|
50
|
+
// Body2 variants
|
|
51
|
+
"body2-sm": "typo-body2-sm",
|
|
52
|
+
"body2-sm-point": "typo-body2-sm-point",
|
|
53
|
+
"body2-md": "typo-body2-md",
|
|
54
|
+
"body2-md-point": "typo-body2-md-point",
|
|
55
|
+
// Body variants
|
|
56
|
+
"body-sm": "typo-body-sm",
|
|
57
|
+
"body-sm-point": "typo-body-sm-point",
|
|
58
|
+
"body-md": "typo-body-md",
|
|
59
|
+
"body-md-point": "typo-body-md-point",
|
|
60
|
+
// Subtitle variants
|
|
61
|
+
"subtitle-sm": "typo-subtitle-sm",
|
|
62
|
+
"subtitle-sm-point": "typo-subtitle-sm-point",
|
|
63
|
+
"subtitle-md": "typo-subtitle-md",
|
|
64
|
+
"subtitle-md-point": "typo-subtitle-md-point",
|
|
65
|
+
// Title variants (always bold)
|
|
66
|
+
"title-sm": "typo-title-sm",
|
|
67
|
+
"title-md": "typo-title-md",
|
|
68
|
+
// Head variants (always bold)
|
|
69
|
+
"head-sm": "typo-head-sm",
|
|
70
|
+
"head-md": "typo-head-md",
|
|
71
|
+
// Fixed size variants
|
|
72
|
+
"fixed-12": "typo-fixed-12",
|
|
73
|
+
"fixed-14": "typo-fixed-14",
|
|
74
|
+
"fixed-15": "typo-fixed-15",
|
|
75
|
+
"fixed-16": "typo-fixed-16",
|
|
76
|
+
"fixed-18": "typo-fixed-18",
|
|
77
|
+
"fixed-20": "typo-fixed-20",
|
|
78
|
+
"fixed-24": "typo-fixed-24"
|
|
79
|
+
};
|
|
80
|
+
function textStyles({
|
|
81
|
+
typography,
|
|
82
|
+
textColor,
|
|
83
|
+
align
|
|
84
|
+
}) {
|
|
85
|
+
const baseStyles = "font-sans";
|
|
86
|
+
const colorClass = colorClasses[textColor];
|
|
87
|
+
const typographyClass = typographyStyles[typography];
|
|
88
|
+
const alignClass = align ? alignClasses[align] : "";
|
|
89
|
+
return mergeStyles([baseStyles, colorClass, typographyClass, alignClass]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/components/Text/Text.tsx
|
|
93
|
+
var Text = ({
|
|
94
|
+
typography = "body-sm",
|
|
95
|
+
textColor = "gray-700",
|
|
96
|
+
align,
|
|
97
|
+
as,
|
|
98
|
+
children,
|
|
99
|
+
className = "",
|
|
100
|
+
...props
|
|
101
|
+
}) => {
|
|
102
|
+
const Component = as || "span";
|
|
103
|
+
const classes = textStyles({ typography, textColor, align });
|
|
104
|
+
return React4__default.default.createElement(
|
|
105
|
+
Component,
|
|
106
|
+
{
|
|
107
|
+
className: mergeStyles(classes, className),
|
|
108
|
+
...props
|
|
109
|
+
},
|
|
110
|
+
children
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
Text.displayName = "Text";
|
|
114
|
+
var FieldContext = React4.createContext(null);
|
|
115
|
+
var useFieldContext = () => {
|
|
116
|
+
const context = React4.useContext(FieldContext);
|
|
117
|
+
if (!context) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return context;
|
|
121
|
+
};
|
|
122
|
+
var FieldRoot = ({
|
|
123
|
+
children,
|
|
124
|
+
disabled = false,
|
|
125
|
+
error = false,
|
|
126
|
+
className,
|
|
127
|
+
...props
|
|
128
|
+
}) => {
|
|
129
|
+
const id = React4.useId();
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FieldContext.Provider, { value: { id, disabled, error }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: mergeStyles("flex flex-col gap-2", className), ...props, children }) });
|
|
131
|
+
};
|
|
132
|
+
var FieldLabel = ({
|
|
133
|
+
children,
|
|
134
|
+
className,
|
|
135
|
+
typography = "body-sm-point",
|
|
136
|
+
textColor = "gray-700",
|
|
137
|
+
...labelProps
|
|
138
|
+
}) => {
|
|
139
|
+
const fieldContext = useFieldContext();
|
|
140
|
+
const id = fieldContext?.id;
|
|
141
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
142
|
+
Text,
|
|
143
|
+
{
|
|
144
|
+
typography,
|
|
145
|
+
textColor,
|
|
146
|
+
htmlFor: id,
|
|
147
|
+
className: mergeStyles("px-1", className),
|
|
148
|
+
...labelProps,
|
|
149
|
+
children
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
var FieldDescription = ({
|
|
154
|
+
children,
|
|
155
|
+
className,
|
|
156
|
+
...props
|
|
157
|
+
}) => {
|
|
158
|
+
const fieldContext = useFieldContext();
|
|
159
|
+
const id = fieldContext?.id;
|
|
160
|
+
const error = fieldContext?.error;
|
|
161
|
+
if (error) return null;
|
|
162
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
163
|
+
Text,
|
|
164
|
+
{
|
|
165
|
+
typography: "body2-sm",
|
|
166
|
+
textColor: "gray-400",
|
|
167
|
+
id: id ? `${id}-description` : void 0,
|
|
168
|
+
className,
|
|
169
|
+
...props,
|
|
170
|
+
children
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
var FieldErrorDescription = ({
|
|
175
|
+
children,
|
|
176
|
+
className,
|
|
177
|
+
...props
|
|
178
|
+
}) => {
|
|
179
|
+
const fieldContext = useFieldContext();
|
|
180
|
+
const id = fieldContext?.id;
|
|
181
|
+
const error = fieldContext?.error;
|
|
182
|
+
if (!error) return null;
|
|
183
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
184
|
+
Text,
|
|
185
|
+
{
|
|
186
|
+
typography: "body2-sm",
|
|
187
|
+
textColor: "red-400",
|
|
188
|
+
id: id ? `${id}-error` : void 0,
|
|
189
|
+
className,
|
|
190
|
+
...props,
|
|
191
|
+
children
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
FieldRoot.displayName = "Field";
|
|
196
|
+
FieldLabel.displayName = "Field.Label";
|
|
197
|
+
FieldDescription.displayName = "Field.Description";
|
|
198
|
+
FieldErrorDescription.displayName = "Field.ErrorDescription";
|
|
199
|
+
var Field = Object.assign(FieldRoot, {
|
|
200
|
+
Label: FieldLabel,
|
|
201
|
+
Description: FieldDescription,
|
|
202
|
+
ErrorDescription: FieldErrorDescription
|
|
203
|
+
});
|
|
204
|
+
var TextInput = ({
|
|
205
|
+
id: idProp,
|
|
206
|
+
disabled: disabledProp,
|
|
207
|
+
error: errorProp,
|
|
208
|
+
className,
|
|
209
|
+
leftIcon,
|
|
210
|
+
rightIcon,
|
|
211
|
+
variant = "default",
|
|
212
|
+
typography = "body2-sm",
|
|
213
|
+
textColor = "gray-700",
|
|
214
|
+
...props
|
|
215
|
+
}) => {
|
|
216
|
+
const field = useFieldContext();
|
|
217
|
+
const id = idProp ?? field?.id;
|
|
218
|
+
const disabled = disabledProp ?? field?.disabled ?? false;
|
|
219
|
+
const error = errorProp ?? field?.error ?? false;
|
|
220
|
+
const classes = textStyles({ typography, textColor });
|
|
221
|
+
const inputStyles = mergeStyles(
|
|
222
|
+
"w-full bg-transparent outline-none",
|
|
223
|
+
"placeholder:text-gray-400",
|
|
224
|
+
"caret-gray-600"
|
|
225
|
+
);
|
|
226
|
+
const variantStyles = {
|
|
227
|
+
default: mergeStyles(
|
|
228
|
+
"rounded-md p-4",
|
|
229
|
+
"bg-white",
|
|
230
|
+
"focus-within:ring-2 focus-within:ring-gray-600"
|
|
231
|
+
),
|
|
232
|
+
underline: mergeStyles(
|
|
233
|
+
"py-2 px-0",
|
|
234
|
+
"border-b border-gray-400",
|
|
235
|
+
"bg-transparent",
|
|
236
|
+
"focus-within:border-gray-600"
|
|
237
|
+
)
|
|
238
|
+
};
|
|
239
|
+
const wrapperStyles = mergeStyles(
|
|
240
|
+
"flex items-center gap-2 self-stretch",
|
|
241
|
+
variantStyles[variant],
|
|
242
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
243
|
+
error && variant === "default" && "ring-2 ring-red-400 focus-within:ring-red-400",
|
|
244
|
+
error && variant === "underline" && "border-red-400 focus-within:border-red-400",
|
|
245
|
+
className
|
|
246
|
+
);
|
|
247
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperStyles, children: [
|
|
248
|
+
leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0 text-gray-400", children: leftIcon }),
|
|
249
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
250
|
+
"input",
|
|
251
|
+
{
|
|
252
|
+
id,
|
|
253
|
+
disabled,
|
|
254
|
+
className: mergeStyles(inputStyles, classes),
|
|
255
|
+
...props
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
rightIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0 text-gray-400", children: rightIcon })
|
|
259
|
+
] });
|
|
260
|
+
};
|
|
261
|
+
TextInput.displayName = "TextInput";
|
|
262
|
+
function createPrimitive(node) {
|
|
263
|
+
const Node = (props) => {
|
|
264
|
+
const { asChild, ...primitiveProps } = props;
|
|
265
|
+
const Comp = asChild ? reactSlot.Slot : node;
|
|
266
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Comp, { ...primitiveProps });
|
|
267
|
+
};
|
|
268
|
+
Node.displayName = `Primitive.${node}`;
|
|
269
|
+
return Node;
|
|
270
|
+
}
|
|
271
|
+
var Primitive = {
|
|
272
|
+
div: createPrimitive("div"),
|
|
273
|
+
span: createPrimitive("span"),
|
|
274
|
+
img: createPrimitive("img"),
|
|
275
|
+
button: createPrimitive("button"),
|
|
276
|
+
label: createPrimitive("label"),
|
|
277
|
+
input: createPrimitive("input"),
|
|
278
|
+
textarea: createPrimitive("textarea"),
|
|
279
|
+
a: createPrimitive("a"),
|
|
280
|
+
p: createPrimitive("p"),
|
|
281
|
+
h2: createPrimitive("h2"),
|
|
282
|
+
ul: createPrimitive("ul"),
|
|
283
|
+
li: createPrimitive("li"),
|
|
284
|
+
svg: createPrimitive("svg"),
|
|
285
|
+
circle: createPrimitive("circle")
|
|
286
|
+
};
|
|
287
|
+
var TextAreaRoot = ({ className, children, ...props }) => {
|
|
288
|
+
const field = useFieldContext();
|
|
289
|
+
const wrapperStyles = mergeStyles(
|
|
290
|
+
"rounded-md p-4",
|
|
291
|
+
"bg-white",
|
|
292
|
+
"focus-within:ring-2 focus-within:ring-gray-600",
|
|
293
|
+
field?.disabled && "cursor-not-allowed opacity-50",
|
|
294
|
+
field?.error && "ring-2 ring-red-400 focus-within:ring-red-400",
|
|
295
|
+
className
|
|
296
|
+
);
|
|
297
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Primitive.div, { className: wrapperStyles, ...props, children });
|
|
298
|
+
};
|
|
299
|
+
var TextAreaInput = ({
|
|
300
|
+
resize = true,
|
|
301
|
+
disabled: disabledProp,
|
|
302
|
+
className,
|
|
303
|
+
...props
|
|
304
|
+
}) => {
|
|
305
|
+
const field = useFieldContext();
|
|
306
|
+
const disabled = disabledProp ?? field?.disabled ?? false;
|
|
307
|
+
const textareaStyles = mergeStyles(
|
|
308
|
+
"w-full min-w-0 min-h-10 bg-transparent outline-none",
|
|
309
|
+
"typo-body-sm",
|
|
310
|
+
"text-gray-700 placeholder:text-gray-400",
|
|
311
|
+
"caret-gray-600",
|
|
312
|
+
resize ? "resize-y" : "resize-none",
|
|
313
|
+
disabled && "cursor-not-allowed",
|
|
314
|
+
className
|
|
315
|
+
);
|
|
316
|
+
return /* @__PURE__ */ jsxRuntime.jsx("textarea", { className: textareaStyles, disabled, ...props });
|
|
317
|
+
};
|
|
318
|
+
var TextAreaFooter = ({
|
|
319
|
+
className,
|
|
320
|
+
children,
|
|
321
|
+
...props
|
|
322
|
+
}) => {
|
|
323
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Primitive.div, { className: mergeStyles("mt-2", className), ...props, children });
|
|
324
|
+
};
|
|
325
|
+
TextAreaRoot.displayName = "TextArea";
|
|
326
|
+
TextAreaInput.displayName = "TextArea.Input";
|
|
327
|
+
TextAreaFooter.displayName = "TextArea.Footer";
|
|
328
|
+
var TextArea = Object.assign(TextAreaRoot, {
|
|
329
|
+
Input: TextAreaInput,
|
|
330
|
+
Footer: TextAreaFooter
|
|
331
|
+
});
|
|
332
|
+
var RadioGroupContext = React4.createContext(null);
|
|
333
|
+
var useRadioGroupContext = () => {
|
|
334
|
+
return React4.useContext(RadioGroupContext);
|
|
335
|
+
};
|
|
336
|
+
var RadioGroup = ({
|
|
337
|
+
name,
|
|
338
|
+
value,
|
|
339
|
+
defaultValue,
|
|
340
|
+
onValueChange,
|
|
341
|
+
className,
|
|
342
|
+
children,
|
|
343
|
+
...props
|
|
344
|
+
}) => {
|
|
345
|
+
const [internalValue, setInternalValue] = React4__default.default.useState(defaultValue);
|
|
346
|
+
const currentValue = value ?? internalValue;
|
|
347
|
+
const handleChange = (newValue) => {
|
|
348
|
+
if (value === void 0) {
|
|
349
|
+
setInternalValue(newValue);
|
|
350
|
+
}
|
|
351
|
+
onValueChange?.(newValue);
|
|
352
|
+
};
|
|
353
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
354
|
+
RadioGroupContext.Provider,
|
|
355
|
+
{
|
|
356
|
+
value: { name, value: currentValue, onChange: handleChange },
|
|
357
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
358
|
+
Primitive.div,
|
|
359
|
+
{
|
|
360
|
+
role: "radiogroup",
|
|
361
|
+
className: mergeStyles("flex flex-col gap-5", className),
|
|
362
|
+
...props,
|
|
363
|
+
children
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
};
|
|
369
|
+
var RadioIcon = ({ checked }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
370
|
+
"svg",
|
|
371
|
+
{
|
|
372
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
373
|
+
width: "20",
|
|
374
|
+
height: "20",
|
|
375
|
+
viewBox: "0 0 20 20",
|
|
376
|
+
fill: "none",
|
|
377
|
+
className: "transition-all duration-150 ease-in-out",
|
|
378
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
379
|
+
"circle",
|
|
380
|
+
{
|
|
381
|
+
cx: "10",
|
|
382
|
+
cy: "10",
|
|
383
|
+
r: checked ? 7 : 7.5,
|
|
384
|
+
stroke: "currentColor",
|
|
385
|
+
strokeWidth: checked ? 6 : 5,
|
|
386
|
+
className: "transition-all duration-150 ease-in-out"
|
|
387
|
+
}
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
var Radio = ({
|
|
392
|
+
value,
|
|
393
|
+
children,
|
|
394
|
+
className,
|
|
395
|
+
checked: checkedProp,
|
|
396
|
+
onChange,
|
|
397
|
+
...props
|
|
398
|
+
}) => {
|
|
399
|
+
const group = useRadioGroupContext();
|
|
400
|
+
const isChecked = group ? group.value === value : checkedProp;
|
|
401
|
+
const name = group?.name ?? props.name;
|
|
402
|
+
const handleChange = (e) => {
|
|
403
|
+
group?.onChange?.(value);
|
|
404
|
+
onChange?.(e);
|
|
405
|
+
};
|
|
406
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
407
|
+
"label",
|
|
408
|
+
{
|
|
409
|
+
className: mergeStyles(
|
|
410
|
+
"flex cursor-pointer items-center gap-2",
|
|
411
|
+
"transition-opacity duration-150 hover:opacity-80",
|
|
412
|
+
className
|
|
413
|
+
),
|
|
414
|
+
children: [
|
|
415
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
416
|
+
"input",
|
|
417
|
+
{
|
|
418
|
+
type: "radio",
|
|
419
|
+
name,
|
|
420
|
+
value,
|
|
421
|
+
checked: isChecked,
|
|
422
|
+
onChange: handleChange,
|
|
423
|
+
className: "sr-only",
|
|
424
|
+
...props
|
|
425
|
+
}
|
|
426
|
+
),
|
|
427
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
428
|
+
"span",
|
|
429
|
+
{
|
|
430
|
+
className: mergeStyles(
|
|
431
|
+
"flex-shrink-0 transition-colors duration-150",
|
|
432
|
+
isChecked ? "text-gray-800 hover:text-gray-800" : "text-gray-200 hover:text-gray-400"
|
|
433
|
+
),
|
|
434
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RadioIcon, { checked: !!isChecked })
|
|
435
|
+
}
|
|
436
|
+
),
|
|
437
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { typography: "body-sm", textColor: "gray-800", children })
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
};
|
|
442
|
+
RadioGroup.displayName = "RadioGroup";
|
|
443
|
+
Radio.displayName = "Radio";
|
|
444
|
+
var ToggleContext = React4__default.default.createContext(null);
|
|
445
|
+
var useToggleContext = () => {
|
|
446
|
+
const context = React4__default.default.useContext(ToggleContext);
|
|
447
|
+
if (!context) {
|
|
448
|
+
throw new Error(
|
|
449
|
+
"Toggle \uC11C\uBE0C \uCEF4\uD3EC\uB10C\uD2B8\uB294 <Toggle> \uCEF4\uD3EC\uB10C\uD2B8 \uB0B4\uBD80\uC5D0\uC11C \uC0AC\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4. ex) <Toggle><Toggle.Switch /></Toggle>"
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
return context;
|
|
453
|
+
};
|
|
454
|
+
var ToggleRoot = ({
|
|
455
|
+
checked: checkedProp,
|
|
456
|
+
defaultChecked = false,
|
|
457
|
+
onCheckedChange,
|
|
458
|
+
disabled,
|
|
459
|
+
children,
|
|
460
|
+
className,
|
|
461
|
+
...props
|
|
462
|
+
}) => {
|
|
463
|
+
const [internalChecked, setInternalChecked] = React4.useState(defaultChecked);
|
|
464
|
+
const isChecked = checkedProp !== void 0 ? checkedProp : internalChecked;
|
|
465
|
+
const handleChange = () => {
|
|
466
|
+
if (disabled) return;
|
|
467
|
+
const newChecked = !isChecked;
|
|
468
|
+
if (checkedProp === void 0) {
|
|
469
|
+
setInternalChecked(newChecked);
|
|
470
|
+
}
|
|
471
|
+
onCheckedChange?.(newChecked);
|
|
472
|
+
};
|
|
473
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ToggleContext.Provider, { value: { checked: isChecked, disabled }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
474
|
+
"label",
|
|
475
|
+
{
|
|
476
|
+
className: mergeStyles(
|
|
477
|
+
"inline-flex cursor-pointer items-center gap-2",
|
|
478
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
479
|
+
className
|
|
480
|
+
),
|
|
481
|
+
...props,
|
|
482
|
+
children: [
|
|
483
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
484
|
+
"input",
|
|
485
|
+
{
|
|
486
|
+
type: "checkbox",
|
|
487
|
+
checked: isChecked,
|
|
488
|
+
onChange: handleChange,
|
|
489
|
+
disabled,
|
|
490
|
+
className: "sr-only"
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
children
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
) });
|
|
497
|
+
};
|
|
498
|
+
var ToggleSwitch = () => {
|
|
499
|
+
const { checked } = useToggleContext();
|
|
500
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
501
|
+
"span",
|
|
502
|
+
{
|
|
503
|
+
className: mergeStyles(
|
|
504
|
+
"relative inline-flex items-center rounded-full p-1 transition-colors duration-200 ease-in-out",
|
|
505
|
+
"h-7 w-12",
|
|
506
|
+
// 48px x 28px
|
|
507
|
+
checked ? "bg-gray-600" : "bg-gray-200"
|
|
508
|
+
),
|
|
509
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
510
|
+
"span",
|
|
511
|
+
{
|
|
512
|
+
className: mergeStyles(
|
|
513
|
+
"pointer-events-none inline-block rounded-full bg-white shadow-sm transition-transform duration-200 ease-in-out",
|
|
514
|
+
"h-5 w-5",
|
|
515
|
+
// 20px
|
|
516
|
+
checked ? "translate-x-5" : "translate-x-0"
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
};
|
|
523
|
+
var ToggleLabel = ({
|
|
524
|
+
children,
|
|
525
|
+
typography = "fixed-16",
|
|
526
|
+
textColor = "gray-700",
|
|
527
|
+
...props
|
|
528
|
+
}) => {
|
|
529
|
+
const { disabled } = useToggleContext();
|
|
530
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
531
|
+
Text,
|
|
532
|
+
{
|
|
533
|
+
typography,
|
|
534
|
+
textColor: disabled ? "gray-400" : textColor,
|
|
535
|
+
...props,
|
|
536
|
+
children
|
|
537
|
+
}
|
|
538
|
+
);
|
|
539
|
+
};
|
|
540
|
+
ToggleRoot.displayName = "Toggle";
|
|
541
|
+
ToggleSwitch.displayName = "Toggle.Switch";
|
|
542
|
+
ToggleLabel.displayName = "Toggle.Label";
|
|
543
|
+
var Toggle = Object.assign(ToggleRoot, {
|
|
544
|
+
Switch: ToggleSwitch,
|
|
545
|
+
Label: ToggleLabel
|
|
546
|
+
});
|
|
547
|
+
var CheckboxContext = React4__default.default.createContext(null);
|
|
548
|
+
var useCheckboxContext = () => {
|
|
549
|
+
const context = React4__default.default.useContext(CheckboxContext);
|
|
550
|
+
if (!context) {
|
|
551
|
+
throw new Error(
|
|
552
|
+
"Checkbox \uC11C\uBE0C \uCEF4\uD3EC\uB10C\uD2B8\uB294 <Checkbox> \uCEF4\uD3EC\uB10C\uD2B8 \uB0B4\uBD80\uC5D0\uC11C \uC0AC\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4. ex) <Checkbox><Checkbox.Indicator /></Checkbox>"
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
return context;
|
|
556
|
+
};
|
|
557
|
+
var CheckboxRoot = ({
|
|
558
|
+
checked: checkedProp,
|
|
559
|
+
defaultChecked = false,
|
|
560
|
+
onCheckedChange,
|
|
561
|
+
disabled,
|
|
562
|
+
children,
|
|
563
|
+
className,
|
|
564
|
+
...props
|
|
565
|
+
}) => {
|
|
566
|
+
const [internalChecked, setInternalChecked] = React4.useState(defaultChecked);
|
|
567
|
+
const isChecked = checkedProp !== void 0 ? checkedProp : internalChecked;
|
|
568
|
+
const handleChange = () => {
|
|
569
|
+
if (disabled) return;
|
|
570
|
+
const newChecked = !isChecked;
|
|
571
|
+
if (checkedProp === void 0) {
|
|
572
|
+
setInternalChecked(newChecked);
|
|
573
|
+
}
|
|
574
|
+
onCheckedChange?.(newChecked);
|
|
575
|
+
};
|
|
576
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxContext.Provider, { value: { checked: isChecked, disabled }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
577
|
+
"label",
|
|
578
|
+
{
|
|
579
|
+
className: mergeStyles(
|
|
580
|
+
"inline-flex cursor-pointer items-center gap-2",
|
|
581
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
582
|
+
className
|
|
583
|
+
),
|
|
584
|
+
...props,
|
|
585
|
+
children: [
|
|
586
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
587
|
+
"input",
|
|
588
|
+
{
|
|
589
|
+
type: "checkbox",
|
|
590
|
+
checked: isChecked,
|
|
591
|
+
onChange: handleChange,
|
|
592
|
+
disabled,
|
|
593
|
+
className: "sr-only"
|
|
594
|
+
}
|
|
595
|
+
),
|
|
596
|
+
children
|
|
597
|
+
]
|
|
598
|
+
}
|
|
599
|
+
) });
|
|
600
|
+
};
|
|
601
|
+
var CheckboxIndicator = () => {
|
|
602
|
+
const { checked } = useCheckboxContext();
|
|
603
|
+
if (checked) {
|
|
604
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
605
|
+
"svg",
|
|
606
|
+
{
|
|
607
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
608
|
+
width: "18",
|
|
609
|
+
height: "18",
|
|
610
|
+
viewBox: "0 0 18 18",
|
|
611
|
+
fill: "none",
|
|
612
|
+
className: "flex-shrink-0",
|
|
613
|
+
children: [
|
|
614
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "18", height: "18", rx: "4", fill: "#1E2939" }),
|
|
615
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
616
|
+
"path",
|
|
617
|
+
{
|
|
618
|
+
d: "M5 9.08333L7.94737 12L13 7",
|
|
619
|
+
stroke: "white",
|
|
620
|
+
strokeWidth: "2",
|
|
621
|
+
strokeLinecap: "round",
|
|
622
|
+
strokeLinejoin: "round"
|
|
623
|
+
}
|
|
624
|
+
)
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
630
|
+
"span",
|
|
631
|
+
{
|
|
632
|
+
className: mergeStyles(
|
|
633
|
+
"flex-shrink-0",
|
|
634
|
+
"aspect-square h-[18px] w-[18px]",
|
|
635
|
+
"rounded border-2 border-gray-200 bg-white"
|
|
636
|
+
)
|
|
637
|
+
}
|
|
638
|
+
);
|
|
639
|
+
};
|
|
640
|
+
var CheckboxLabel = ({
|
|
641
|
+
children,
|
|
642
|
+
typography = "body-sm",
|
|
643
|
+
textColor = "gray-600",
|
|
644
|
+
...props
|
|
645
|
+
}) => {
|
|
646
|
+
const { disabled } = useCheckboxContext();
|
|
647
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
648
|
+
Text,
|
|
649
|
+
{
|
|
650
|
+
typography,
|
|
651
|
+
textColor: disabled ? "gray-400" : textColor,
|
|
652
|
+
...props,
|
|
653
|
+
children
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
};
|
|
657
|
+
CheckboxRoot.displayName = "Checkbox";
|
|
658
|
+
CheckboxIndicator.displayName = "Checkbox.Indicator";
|
|
659
|
+
CheckboxLabel.displayName = "Checkbox.Label";
|
|
660
|
+
var Checkbox = Object.assign(CheckboxRoot, {
|
|
661
|
+
Indicator: CheckboxIndicator,
|
|
662
|
+
Label: CheckboxLabel
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
exports.Checkbox = Checkbox;
|
|
666
|
+
exports.Field = Field;
|
|
667
|
+
exports.Radio = Radio;
|
|
668
|
+
exports.RadioGroup = RadioGroup;
|
|
669
|
+
exports.Text = Text;
|
|
670
|
+
exports.TextArea = TextArea;
|
|
671
|
+
exports.TextInput = TextInput;
|
|
672
|
+
exports.Toggle = Toggle;
|
|
673
|
+
exports.mergeStyles = mergeStyles;
|
|
674
|
+
exports.useRadioGroupContext = useRadioGroupContext;
|