@xsolla/xui-checkbox 0.64.0-pr56.1768440195

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/web/index.mjs ADDED
@@ -0,0 +1,711 @@
1
+ // src/Checkbox.tsx
2
+ import {
3
+ forwardRef as forwardRef3,
4
+ useRef,
5
+ useState,
6
+ useImperativeHandle
7
+ } from "react";
8
+
9
+ // ../primitives-web/src/Box.tsx
10
+ import React from "react";
11
+ import styled from "styled-components";
12
+ import { jsx } from "react/jsx-runtime";
13
+ var StyledBox = styled.div`
14
+ display: flex;
15
+ box-sizing: border-box;
16
+ background-color: ${(props) => props.backgroundColor || "transparent"};
17
+ border-color: ${(props) => props.borderColor || "transparent"};
18
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
19
+
20
+ ${(props) => props.borderBottomWidth !== void 0 && `
21
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
22
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
23
+ border-bottom-style: solid;
24
+ `}
25
+ ${(props) => props.borderTopWidth !== void 0 && `
26
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
27
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
28
+ border-top-style: solid;
29
+ `}
30
+ ${(props) => props.borderLeftWidth !== void 0 && `
31
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
32
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
33
+ border-left-style: solid;
34
+ `}
35
+ ${(props) => props.borderRightWidth !== void 0 && `
36
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
37
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
38
+ border-right-style: solid;
39
+ `}
40
+
41
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
42
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
43
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
44
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
45
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
46
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
47
+
48
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
49
+ ${(props) => props.paddingHorizontal && `
50
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
51
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
52
+ `}
53
+ ${(props) => props.paddingVertical && `
54
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
55
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
56
+ `}
57
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
58
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
59
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
60
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
61
+
62
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
63
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
64
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
65
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
66
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
67
+
68
+ flex-direction: ${(props) => props.flexDirection || "column"};
69
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
70
+ align-items: ${(props) => props.alignItems || "stretch"};
71
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
72
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
73
+ position: ${(props) => props.position || "static"};
74
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
75
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
76
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
77
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
78
+ flex: ${(props) => props.flex};
79
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
80
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
81
+ align-self: ${(props) => props.alignSelf || "auto"};
82
+ overflow: ${(props) => props.overflow || "visible"};
83
+ overflow-x: ${(props) => props.overflowX || "visible"};
84
+ overflow-y: ${(props) => props.overflowY || "visible"};
85
+ z-index: ${(props) => props.zIndex};
86
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
87
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
88
+
89
+ &:hover {
90
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
91
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
92
+ }
93
+
94
+ &:active {
95
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
96
+ }
97
+ `;
98
+ var Box = React.forwardRef(
99
+ ({
100
+ children,
101
+ onPress,
102
+ onKeyDown,
103
+ onKeyUp,
104
+ role,
105
+ "aria-label": ariaLabel,
106
+ "aria-labelledby": ariaLabelledBy,
107
+ "aria-current": ariaCurrent,
108
+ "aria-disabled": ariaDisabled,
109
+ "aria-live": ariaLive,
110
+ "aria-busy": ariaBusy,
111
+ "aria-describedby": ariaDescribedBy,
112
+ "aria-expanded": ariaExpanded,
113
+ "aria-haspopup": ariaHasPopup,
114
+ "aria-pressed": ariaPressed,
115
+ "aria-controls": ariaControls,
116
+ tabIndex,
117
+ as,
118
+ src,
119
+ alt,
120
+ type,
121
+ disabled,
122
+ id,
123
+ ...props
124
+ }, ref) => {
125
+ if (as === "img" && src) {
126
+ return /* @__PURE__ */ jsx(
127
+ "img",
128
+ {
129
+ src,
130
+ alt: alt || "",
131
+ style: {
132
+ display: "block",
133
+ objectFit: "cover",
134
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
135
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
136
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
137
+ position: props.position,
138
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
139
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
140
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
141
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
142
+ }
143
+ }
144
+ );
145
+ }
146
+ return /* @__PURE__ */ jsx(
147
+ StyledBox,
148
+ {
149
+ ref,
150
+ as,
151
+ id,
152
+ type: as === "button" ? type || "button" : void 0,
153
+ disabled: as === "button" ? disabled : void 0,
154
+ onClick: onPress,
155
+ onKeyDown,
156
+ onKeyUp,
157
+ role,
158
+ "aria-label": ariaLabel,
159
+ "aria-labelledby": ariaLabelledBy,
160
+ "aria-current": ariaCurrent,
161
+ "aria-disabled": ariaDisabled,
162
+ "aria-busy": ariaBusy,
163
+ "aria-describedby": ariaDescribedBy,
164
+ "aria-expanded": ariaExpanded,
165
+ "aria-haspopup": ariaHasPopup,
166
+ "aria-pressed": ariaPressed,
167
+ "aria-controls": ariaControls,
168
+ "aria-live": ariaLive,
169
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
170
+ ...props,
171
+ children
172
+ }
173
+ );
174
+ }
175
+ );
176
+ Box.displayName = "Box";
177
+
178
+ // ../primitives-web/src/Text.tsx
179
+ import styled2 from "styled-components";
180
+ import { jsx as jsx2 } from "react/jsx-runtime";
181
+ var StyledText = styled2.span`
182
+ color: ${(props) => props.color || "inherit"};
183
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
184
+ font-weight: ${(props) => props.fontWeight || "normal"};
185
+ font-family: ${(props) => props.fontFamily || '"Pilat Wide Bold", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important'};
186
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
187
+ white-space: ${(props) => props.whiteSpace || "normal"};
188
+ text-align: ${(props) => props.textAlign || "inherit"};
189
+ text-decoration: ${(props) => props.textDecoration || "none"};
190
+ `;
191
+ var Text = ({
192
+ style,
193
+ className,
194
+ id,
195
+ role,
196
+ ...props
197
+ }) => {
198
+ return /* @__PURE__ */ jsx2(
199
+ StyledText,
200
+ {
201
+ ...props,
202
+ style,
203
+ className,
204
+ id,
205
+ role
206
+ }
207
+ );
208
+ };
209
+
210
+ // ../primitives-web/src/Spinner.tsx
211
+ import styled3, { keyframes } from "styled-components";
212
+ import { jsx as jsx3 } from "react/jsx-runtime";
213
+ var rotate = keyframes`
214
+ from {
215
+ transform: rotate(0deg);
216
+ }
217
+ to {
218
+ transform: rotate(360deg);
219
+ }
220
+ `;
221
+ var StyledSpinner = styled3.div`
222
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
223
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
224
+ border: ${(props) => props.strokeWidth || 2}px solid
225
+ ${(props) => props.color || "currentColor"};
226
+ border-bottom-color: transparent;
227
+ border-radius: 50%;
228
+ display: inline-block;
229
+ box-sizing: border-box;
230
+ animation: ${rotate} 1s linear infinite;
231
+ `;
232
+ var Spinner = ({
233
+ role = "status",
234
+ "aria-label": ariaLabel,
235
+ "aria-live": ariaLive = "polite",
236
+ "aria-describedby": ariaDescribedBy,
237
+ testID,
238
+ ...props
239
+ }) => {
240
+ return /* @__PURE__ */ jsx3(
241
+ StyledSpinner,
242
+ {
243
+ role,
244
+ "aria-label": ariaLabel,
245
+ "aria-live": ariaLive,
246
+ "aria-describedby": ariaDescribedBy,
247
+ "data-testid": testID,
248
+ ...props
249
+ }
250
+ );
251
+ };
252
+ Spinner.displayName = "Spinner";
253
+
254
+ // ../primitives-web/src/Icon.tsx
255
+ import styled4 from "styled-components";
256
+ import { jsx as jsx4 } from "react/jsx-runtime";
257
+ var StyledIcon = styled4.div`
258
+ display: flex;
259
+ align-items: center;
260
+ justify-content: center;
261
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
262
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
263
+ color: ${(props) => props.color || "currentColor"};
264
+
265
+ svg {
266
+ width: 100%;
267
+ height: 100%;
268
+ fill: none;
269
+ stroke: currentColor;
270
+ }
271
+ `;
272
+
273
+ // ../primitives-web/src/Divider.tsx
274
+ import styled5 from "styled-components";
275
+ import { jsx as jsx5 } from "react/jsx-runtime";
276
+ var StyledDivider = styled5.div`
277
+ background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
278
+ width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
279
+ height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
280
+
281
+ ${(props) => props.dashStroke && `
282
+ border-style: dashed;
283
+ border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
284
+ border-width: 0;
285
+ ${props.vertical ? `
286
+ border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
287
+ height: 100%;
288
+ ` : `
289
+ border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
290
+ width: 100%;
291
+ `}
292
+ `}
293
+ `;
294
+
295
+ // ../primitives-web/src/Input.tsx
296
+ import { forwardRef } from "react";
297
+ import styled6 from "styled-components";
298
+ import { jsx as jsx6 } from "react/jsx-runtime";
299
+ var StyledInput = styled6.input`
300
+ background: transparent;
301
+ border: none;
302
+ outline: none;
303
+ width: 100%;
304
+ height: 100%;
305
+ padding: 0;
306
+ margin: 0;
307
+ color: ${(props) => props.color || "inherit"};
308
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
309
+ font-family: inherit;
310
+ text-align: inherit;
311
+
312
+ &::placeholder {
313
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
314
+ }
315
+
316
+ &:disabled {
317
+ cursor: not-allowed;
318
+ }
319
+ `;
320
+ var InputPrimitive = forwardRef(
321
+ ({
322
+ value,
323
+ placeholder,
324
+ onChange,
325
+ onChangeText,
326
+ onFocus,
327
+ onBlur,
328
+ onKeyDown,
329
+ disabled,
330
+ secureTextEntry,
331
+ style,
332
+ color,
333
+ fontSize,
334
+ placeholderTextColor,
335
+ maxLength,
336
+ name,
337
+ type,
338
+ inputMode,
339
+ autoComplete,
340
+ id,
341
+ "aria-invalid": ariaInvalid,
342
+ "aria-describedby": ariaDescribedBy,
343
+ "aria-labelledby": ariaLabelledBy,
344
+ "aria-label": ariaLabel,
345
+ "aria-disabled": ariaDisabled,
346
+ "data-testid": dataTestId,
347
+ ...rest
348
+ }, ref) => {
349
+ const handleChange = (e) => {
350
+ if (onChange) {
351
+ onChange(e);
352
+ }
353
+ if (onChangeText) {
354
+ onChangeText(e.target.value);
355
+ }
356
+ };
357
+ const inputValue = value !== void 0 ? value : "";
358
+ return /* @__PURE__ */ jsx6(
359
+ StyledInput,
360
+ {
361
+ ref,
362
+ id,
363
+ value: inputValue,
364
+ name,
365
+ placeholder,
366
+ onChange: handleChange,
367
+ onFocus,
368
+ onBlur,
369
+ onKeyDown,
370
+ disabled,
371
+ type: secureTextEntry ? "password" : type || "text",
372
+ inputMode,
373
+ autoComplete,
374
+ style,
375
+ color,
376
+ fontSize,
377
+ placeholderTextColor,
378
+ maxLength,
379
+ "aria-invalid": ariaInvalid,
380
+ "aria-describedby": ariaDescribedBy,
381
+ "aria-labelledby": ariaLabelledBy,
382
+ "aria-label": ariaLabel,
383
+ "aria-disabled": ariaDisabled,
384
+ "data-testid": dataTestId,
385
+ ...rest
386
+ }
387
+ );
388
+ }
389
+ );
390
+ InputPrimitive.displayName = "InputPrimitive";
391
+
392
+ // ../primitives-web/src/TextArea.tsx
393
+ import { forwardRef as forwardRef2 } from "react";
394
+ import styled7 from "styled-components";
395
+ import { jsx as jsx7 } from "react/jsx-runtime";
396
+ var StyledTextArea = styled7.textarea`
397
+ background: transparent;
398
+ border: none;
399
+ outline: none;
400
+ width: 100%;
401
+ height: 100%;
402
+ padding: 0;
403
+ margin: 0;
404
+ color: ${(props) => props.color || "inherit"};
405
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
406
+ font-family: inherit;
407
+ text-align: inherit;
408
+ resize: none;
409
+
410
+ &::placeholder {
411
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
412
+ }
413
+
414
+ &:disabled {
415
+ cursor: not-allowed;
416
+ }
417
+ `;
418
+ var TextAreaPrimitive = forwardRef2(
419
+ ({
420
+ value,
421
+ placeholder,
422
+ onChangeText,
423
+ onFocus,
424
+ onBlur,
425
+ onKeyDown,
426
+ disabled,
427
+ style,
428
+ color,
429
+ fontSize,
430
+ placeholderTextColor,
431
+ maxLength,
432
+ rows
433
+ }, ref) => {
434
+ return /* @__PURE__ */ jsx7(
435
+ StyledTextArea,
436
+ {
437
+ ref,
438
+ value,
439
+ placeholder,
440
+ onChange: (e) => onChangeText?.(e.target.value),
441
+ onFocus,
442
+ onBlur,
443
+ onKeyDown,
444
+ disabled,
445
+ style,
446
+ color,
447
+ fontSize,
448
+ placeholderTextColor,
449
+ maxLength,
450
+ rows
451
+ }
452
+ );
453
+ }
454
+ );
455
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
456
+
457
+ // src/Checkbox.tsx
458
+ import { useDesignSystem, useId } from "@xsolla/xui-core";
459
+ import { Check, Minus } from "@xsolla/xui-icons";
460
+ import { jsx as jsx8, jsxs } from "react/jsx-runtime";
461
+ var iconSizeMap = {
462
+ s: 12,
463
+ m: 14,
464
+ l: 16,
465
+ xl: 18
466
+ };
467
+ var checkboxSizeMap = {
468
+ s: 16,
469
+ m: 18,
470
+ l: 20,
471
+ xl: 22
472
+ };
473
+ var labelGapMap = {
474
+ s: 8,
475
+ m: 8,
476
+ l: 10,
477
+ xl: 12
478
+ };
479
+ var textGapMap = {
480
+ s: 0,
481
+ m: 2,
482
+ l: 2,
483
+ xl: 4
484
+ };
485
+ var fontSizeMap = {
486
+ s: 14,
487
+ m: 16,
488
+ l: 18,
489
+ xl: 18
490
+ };
491
+ var lineHeightMap = {
492
+ s: 16,
493
+ m: 18,
494
+ l: 20,
495
+ xl: 22
496
+ };
497
+ var descriptionFontSizeMap = {
498
+ s: 12,
499
+ m: 14,
500
+ l: 16,
501
+ xl: 16
502
+ };
503
+ var descriptionLineHeightMap = {
504
+ s: 14,
505
+ m: 16,
506
+ l: 18,
507
+ xl: 18
508
+ };
509
+ var Checkbox = forwardRef3(
510
+ function Checkbox2({
511
+ children,
512
+ size = "m",
513
+ checked,
514
+ indeterminate = false,
515
+ description,
516
+ errorMessage,
517
+ error,
518
+ disabled,
519
+ name,
520
+ value,
521
+ onChange,
522
+ id: providedId,
523
+ "aria-label": ariaLabel
524
+ }, ref) {
525
+ const { theme } = useDesignSystem();
526
+ const containerRef = useRef(null);
527
+ const [internalChecked, setInternalChecked] = useState(false);
528
+ const rawId = useId();
529
+ const safeId = rawId.replace(/:/g, "");
530
+ const checkboxId = providedId || `checkbox-${safeId}`;
531
+ const labelId = `${checkboxId}-label`;
532
+ const descriptionId = `${checkboxId}-description`;
533
+ const errorId = `${checkboxId}-error`;
534
+ const isControlled = checked !== void 0;
535
+ const isChecked = isControlled ? checked : internalChecked;
536
+ useImperativeHandle(
537
+ ref,
538
+ () => ({
539
+ focus: () => containerRef.current?.focus(),
540
+ blur: () => containerRef.current?.blur()
541
+ }),
542
+ []
543
+ );
544
+ const handleToggle = () => {
545
+ if (disabled) return;
546
+ const newChecked = indeterminate ? true : !isChecked;
547
+ if (!isControlled) {
548
+ setInternalChecked(newChecked);
549
+ }
550
+ onChange?.({
551
+ target: {
552
+ checked: newChecked,
553
+ name,
554
+ value
555
+ }
556
+ });
557
+ };
558
+ const handleKeyDown = (event) => {
559
+ const key = event.key;
560
+ const isSpace = key === " " || key === "Spacebar" || key === "Space";
561
+ if (isSpace || key === "Enter") {
562
+ event.preventDefault();
563
+ handleToggle();
564
+ }
565
+ };
566
+ const isError = !!(errorMessage || error);
567
+ const hasTexts = !!children || !!description;
568
+ const isShowErrorMessage = !!errorMessage && hasTexts;
569
+ const isCheckedOrIndeterminate = isChecked || indeterminate;
570
+ const ariaDescribedByParts = [];
571
+ if (description) ariaDescribedByParts.push(descriptionId);
572
+ if (isShowErrorMessage) ariaDescribedByParts.push(errorId);
573
+ const ariaDescribedBy = ariaDescribedByParts.length > 0 ? ariaDescribedByParts.join(" ") : void 0;
574
+ const checkColors = theme.colors.control.check;
575
+ const faintColors = theme.colors.control.faint;
576
+ const textColors = theme.colors.control.text;
577
+ const contentColors = theme.colors.content;
578
+ const borderColors = theme.colors.border;
579
+ const getCheckboxBgColor = () => {
580
+ if (disabled) {
581
+ return checkColors.bgDisable;
582
+ }
583
+ if (isCheckedOrIndeterminate) {
584
+ return checkColors.bg;
585
+ }
586
+ return faintColors.bg;
587
+ };
588
+ const getBorderColor = () => {
589
+ if (isError && !isCheckedOrIndeterminate) {
590
+ return borderColors.alert;
591
+ }
592
+ if (isCheckedOrIndeterminate && !disabled) {
593
+ return checkColors.bg;
594
+ }
595
+ return faintColors.border;
596
+ };
597
+ const getLabelColor = () => {
598
+ if (disabled) return textColors.disable;
599
+ return textColors.primary;
600
+ };
601
+ const getDescriptionColor = () => {
602
+ if (disabled) return textColors.disable;
603
+ return contentColors.tertiary;
604
+ };
605
+ const getErrorMessageColor = () => {
606
+ return contentColors.alert.primary;
607
+ };
608
+ const getIconColor = () => {
609
+ if (disabled) return textColors.disable;
610
+ return textColors.faint;
611
+ };
612
+ const getAriaChecked = () => {
613
+ if (indeterminate) return "mixed";
614
+ return isChecked ? "true" : "false";
615
+ };
616
+ return /* @__PURE__ */ jsxs(
617
+ Box,
618
+ {
619
+ id: checkboxId,
620
+ ref: containerRef,
621
+ flexDirection: "row",
622
+ alignItems: "flex-start",
623
+ gap: labelGapMap[size],
624
+ onPress: handleToggle,
625
+ disabled,
626
+ role: "checkbox",
627
+ "aria-checked": getAriaChecked(),
628
+ "aria-disabled": disabled || void 0,
629
+ "aria-invalid": isError || void 0,
630
+ "aria-describedby": ariaDescribedBy,
631
+ "aria-labelledby": children ? labelId : void 0,
632
+ "aria-label": !children ? ariaLabel : void 0,
633
+ tabIndex: disabled ? -1 : 0,
634
+ onKeyDown: handleKeyDown,
635
+ "data-testid": "checkbox",
636
+ children: [
637
+ /* @__PURE__ */ jsx8(
638
+ Box,
639
+ {
640
+ width: checkboxSizeMap[size],
641
+ height: checkboxSizeMap[size],
642
+ backgroundColor: getCheckboxBgColor(),
643
+ borderColor: getBorderColor(),
644
+ borderWidth: 2,
645
+ borderRadius: 2,
646
+ alignItems: "center",
647
+ justifyContent: "center",
648
+ flexShrink: 0,
649
+ hoverStyle: !disabled ? {
650
+ backgroundColor: isCheckedOrIndeterminate ? checkColors.bgHover : faintColors.bgHover,
651
+ borderColor: isError && !isCheckedOrIndeterminate ? borderColors.alert : isCheckedOrIndeterminate ? checkColors.bgHover : faintColors.borderHover
652
+ } : void 0,
653
+ "data-testid": "checkbox__box",
654
+ children: isCheckedOrIndeterminate && (indeterminate ? /* @__PURE__ */ jsx8(Minus, { size: iconSizeMap[size], color: getIconColor() }) : /* @__PURE__ */ jsx8(Check, { size: iconSizeMap[size], color: getIconColor() }))
655
+ }
656
+ ),
657
+ hasTexts && /* @__PURE__ */ jsxs(
658
+ Box,
659
+ {
660
+ flexDirection: "column",
661
+ alignItems: "flex-start",
662
+ gap: textGapMap[size],
663
+ children: [
664
+ children && /* @__PURE__ */ jsx8(
665
+ Text,
666
+ {
667
+ id: labelId,
668
+ color: getLabelColor(),
669
+ fontSize: fontSizeMap[size],
670
+ lineHeight: lineHeightMap[size],
671
+ fontWeight: 400,
672
+ "data-testid": "checkbox__label",
673
+ children
674
+ }
675
+ ),
676
+ description && /* @__PURE__ */ jsx8(
677
+ Text,
678
+ {
679
+ id: descriptionId,
680
+ color: getDescriptionColor(),
681
+ fontSize: descriptionFontSizeMap[size],
682
+ lineHeight: descriptionLineHeightMap[size],
683
+ "data-testid": "checkbox__description",
684
+ children: description
685
+ }
686
+ ),
687
+ isShowErrorMessage && /* @__PURE__ */ jsx8(
688
+ Text,
689
+ {
690
+ id: errorId,
691
+ role: "alert",
692
+ color: getErrorMessageColor(),
693
+ fontSize: descriptionFontSizeMap[size],
694
+ lineHeight: descriptionLineHeightMap[size],
695
+ "data-testid": "checkbox__error",
696
+ children: errorMessage
697
+ }
698
+ )
699
+ ]
700
+ }
701
+ )
702
+ ]
703
+ }
704
+ );
705
+ }
706
+ );
707
+ Checkbox.displayName = "Checkbox";
708
+ export {
709
+ Checkbox
710
+ };
711
+ //# sourceMappingURL=index.mjs.map