@causw/core 0.0.8 → 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.mjs CHANGED
@@ -1,8 +1,13 @@
1
- import React from 'react';
1
+ import React4, { createContext, useId, useState, useContext } from 'react';
2
2
  import { clsx } from 'clsx';
3
3
  import { twMerge } from 'tailwind-merge';
4
+ import { jsx, jsxs } from 'react/jsx-runtime';
5
+ import { Slot } from '@radix-ui/react-slot';
4
6
 
5
7
  // src/components/Text/Text.tsx
8
+ function mergeStyles(...inputs) {
9
+ return twMerge(clsx(inputs));
10
+ }
6
11
 
7
12
  // src/components/Text/Text.styles.ts
8
13
  var colorClasses = {
@@ -24,245 +29,73 @@ var colorClasses = {
24
29
  white: "text-white-main",
25
30
  black: "text-black-main"
26
31
  };
27
- var variantStyles = {
28
- caption: {
29
- sm: {
30
- normal: {
31
- fontSize: "text-12",
32
- lineHeight: "leading-normal",
33
- fontWeight: "font-regular"
34
- },
35
- point: {
36
- fontSize: "text-12",
37
- lineHeight: "leading-normal",
38
- fontWeight: "font-semibold"
39
- }
40
- },
41
- md: {
42
- normal: {
43
- fontSize: "text-14",
44
- lineHeight: "leading-normal",
45
- fontWeight: "font-medium"
46
- },
47
- point: {
48
- fontSize: "text-14",
49
- lineHeight: "leading-normal",
50
- fontWeight: "font-semibold"
51
- }
52
- }
53
- },
54
- body2: {
55
- sm: {
56
- normal: {
57
- fontSize: "text-14",
58
- lineHeight: "leading-normal",
59
- fontWeight: "font-regular"
60
- },
61
- point: {
62
- fontSize: "text-14",
63
- lineHeight: "leading-normal",
64
- fontWeight: "font-semibold"
65
- }
66
- },
67
- md: {
68
- normal: {
69
- fontSize: "text-16",
70
- lineHeight: "leading-normal",
71
- fontWeight: "font-medium"
72
- },
73
- point: {
74
- fontSize: "text-16",
75
- lineHeight: "leading-normal",
76
- fontWeight: "font-semibold"
77
- }
78
- }
79
- },
80
- body: {
81
- sm: {
82
- normal: {
83
- fontSize: "text-16",
84
- lineHeight: "leading-tight",
85
- fontWeight: "font-regular"
86
- },
87
- point: {
88
- fontSize: "text-16",
89
- lineHeight: "leading-normal",
90
- fontWeight: "font-bold"
91
- }
92
- },
93
- md: {
94
- normal: {
95
- fontSize: "text-18",
96
- lineHeight: "leading-normal",
97
- fontWeight: "font-medium"
98
- },
99
- point: {
100
- fontSize: "text-18",
101
- lineHeight: "leading-normal",
102
- fontWeight: "font-bold"
103
- }
104
- }
105
- },
106
- subtitle: {
107
- sm: {
108
- normal: {
109
- fontSize: "text-18",
110
- lineHeight: "leading-normal",
111
- fontWeight: "font-medium"
112
- },
113
- point: {
114
- fontSize: "text-18",
115
- lineHeight: "leading-normal",
116
- fontWeight: "font-bold"
117
- }
118
- },
119
- md: {
120
- normal: {
121
- fontSize: "text-20",
122
- lineHeight: "leading-normal",
123
- fontWeight: "font-medium"
124
- },
125
- point: {
126
- fontSize: "text-20",
127
- lineHeight: "leading-normal",
128
- fontWeight: "font-bold"
129
- }
130
- }
131
- },
132
- title: {
133
- sm: {
134
- normal: {
135
- fontSize: "text-22",
136
- lineHeight: "leading-normal",
137
- fontWeight: "font-bold"
138
- },
139
- point: {
140
- fontSize: "text-22",
141
- lineHeight: "leading-normal",
142
- fontWeight: "font-bold"
143
- }
144
- },
145
- md: {
146
- normal: {
147
- fontSize: "text-32",
148
- lineHeight: "leading-normal",
149
- fontWeight: "font-bold"
150
- },
151
- point: {
152
- fontSize: "text-32",
153
- lineHeight: "leading-normal",
154
- fontWeight: "font-bold"
155
- }
156
- }
157
- },
158
- head: {
159
- sm: {
160
- normal: {
161
- fontSize: "text-30",
162
- lineHeight: "leading-normal",
163
- fontWeight: "font-bold"
164
- },
165
- point: {
166
- fontSize: "text-30",
167
- lineHeight: "leading-normal",
168
- fontWeight: "font-bold"
169
- }
170
- },
171
- md: {
172
- normal: {
173
- fontSize: "text-48",
174
- lineHeight: "leading-normal",
175
- fontWeight: "font-bold"
176
- },
177
- point: {
178
- fontSize: "text-48",
179
- lineHeight: "leading-normal",
180
- fontWeight: "font-bold"
181
- }
182
- }
183
- }
32
+ var alignClasses = {
33
+ left: "text-left",
34
+ center: "text-center",
35
+ right: "text-right",
36
+ justify: "text-justify"
184
37
  };
185
- var fixedStyles = {
186
- 12: {
187
- fontSize: "text-12",
188
- lineHeight: "leading-normal",
189
- fontWeight: "font-medium"
190
- },
191
- 14: {
192
- fontSize: "text-14",
193
- lineHeight: "leading-normal",
194
- fontWeight: "font-medium"
195
- },
196
- 15: {
197
- fontSize: "text-15",
198
- lineHeight: "leading-normal",
199
- fontWeight: "font-semibold"
200
- },
201
- 16: {
202
- fontSize: "text-16",
203
- lineHeight: "leading-normal",
204
- fontWeight: "font-medium"
205
- },
206
- 18: {
207
- fontSize: "text-18",
208
- lineHeight: "leading-normal",
209
- fontWeight: "font-medium"
210
- },
211
- 20: {
212
- fontSize: "text-20",
213
- lineHeight: "leading-normal",
214
- fontWeight: "font-semibold"
215
- },
216
- 24: {
217
- fontSize: "text-24",
218
- lineHeight: "leading-normal",
219
- fontWeight: "font-bold"
220
- }
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"
221
73
  };
222
74
  function textStyles({
223
- variant,
224
- size,
225
- fixedSize,
226
- point,
227
- color
75
+ typography,
76
+ textColor,
77
+ align
228
78
  }) {
229
79
  const baseStyles = "font-sans";
230
- const colorClass = colorClasses[color];
231
- let config;
232
- if (variant === "fixed" && fixedSize) {
233
- config = fixedStyles[fixedSize];
234
- } else if (variant !== "fixed") {
235
- const variantConfig = variantStyles[variant][size];
236
- config = point ? variantConfig.point : variantConfig.normal;
237
- } else {
238
- config = fixedStyles[16];
239
- }
240
- return `${baseStyles} ${colorClass} ${config.fontSize} ${config.lineHeight} ${config.fontWeight}`.trim();
241
- }
242
- function mergeStyles(...inputs) {
243
- return twMerge(clsx(inputs));
80
+ const colorClass = colorClasses[textColor];
81
+ const typographyClass = typographyStyles[typography];
82
+ const alignClass = align ? alignClasses[align] : "";
83
+ return mergeStyles([baseStyles, colorClass, typographyClass, alignClass]);
244
84
  }
245
85
 
246
86
  // src/components/Text/Text.tsx
247
87
  var Text = ({
248
- variant = "body",
249
- size = "sm",
250
- fixedSize,
251
- point = false,
252
- color = "gray-700",
253
- as: Component = "span",
88
+ typography = "body-sm",
89
+ textColor = "gray-700",
90
+ align,
91
+ as,
254
92
  children,
255
93
  className = "",
256
94
  ...props
257
95
  }) => {
258
- const classes = textStyles({
259
- variant,
260
- size,
261
- fixedSize,
262
- point,
263
- color
264
- });
265
- return React.createElement(
96
+ const Component = as || "span";
97
+ const classes = textStyles({ typography, textColor, align });
98
+ return React4.createElement(
266
99
  Component,
267
100
  {
268
101
  className: mergeStyles(classes, className),
@@ -272,5 +105,555 @@ var Text = ({
272
105
  );
273
106
  };
274
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
+ });
275
658
 
276
- export { Text, mergeStyles };
659
+ export { Checkbox, Field, Radio, RadioGroup, Text, TextArea, TextInput, Toggle, mergeStyles, useRadioGroupContext };