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