@tonyarbor/components 0.1.0 → 0.2.0
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/Checkbox.d.mts +48 -0
- package/dist/Checkbox.d.ts +48 -0
- package/dist/Checkbox.js +165 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Checkbox.mjs +7 -0
- package/dist/Checkbox.mjs.map +1 -0
- package/dist/Combobox.d.mts +67 -0
- package/dist/Combobox.d.ts +67 -0
- package/dist/Combobox.js +329 -0
- package/dist/Combobox.js.map +1 -0
- package/dist/Combobox.mjs +7 -0
- package/dist/Combobox.mjs.map +1 -0
- package/dist/NumericInput.d.mts +68 -0
- package/dist/NumericInput.d.ts +68 -0
- package/dist/NumericInput.js +319 -0
- package/dist/NumericInput.js.map +1 -0
- package/dist/NumericInput.mjs +7 -0
- package/dist/NumericInput.mjs.map +1 -0
- package/dist/Radio.d.mts +48 -0
- package/dist/Radio.d.ts +48 -0
- package/dist/Radio.js +174 -0
- package/dist/Radio.js.map +1 -0
- package/dist/Radio.mjs +7 -0
- package/dist/Radio.mjs.map +1 -0
- package/dist/chunk-5BUXFTPW.mjs +283 -0
- package/dist/chunk-5BUXFTPW.mjs.map +1 -0
- package/dist/chunk-7OWLBYNM.mjs +293 -0
- package/dist/chunk-7OWLBYNM.mjs.map +1 -0
- package/dist/chunk-ARBHNHO7.mjs +138 -0
- package/dist/chunk-ARBHNHO7.mjs.map +1 -0
- package/dist/chunk-BCYJIUQX.mjs +129 -0
- package/dist/chunk-BCYJIUQX.mjs.map +1 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +835 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -0
- package/package.json +24 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// src/Radio/Radio.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var radioStyles = {
|
|
6
|
+
width: "20px",
|
|
7
|
+
height: "20px",
|
|
8
|
+
border: "2px solid #d1d1d1",
|
|
9
|
+
// grey-300
|
|
10
|
+
borderRadius: "50%",
|
|
11
|
+
display: "flex",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
justifyContent: "center",
|
|
14
|
+
cursor: "pointer",
|
|
15
|
+
transition: "all 0.2s ease-in-out",
|
|
16
|
+
flexShrink: 0,
|
|
17
|
+
backgroundColor: "#ffffff"
|
|
18
|
+
};
|
|
19
|
+
var checkedStyles = {
|
|
20
|
+
borderColor: "#3cad51"
|
|
21
|
+
// brand-500
|
|
22
|
+
};
|
|
23
|
+
var innerDotStyles = {
|
|
24
|
+
width: "10px",
|
|
25
|
+
height: "10px",
|
|
26
|
+
borderRadius: "50%",
|
|
27
|
+
backgroundColor: "#3cad51",
|
|
28
|
+
// brand-500
|
|
29
|
+
transition: "all 0.2s ease-in-out"
|
|
30
|
+
};
|
|
31
|
+
var labelStyles = {
|
|
32
|
+
fontSize: "13px",
|
|
33
|
+
color: "#2f2f2f",
|
|
34
|
+
cursor: "pointer",
|
|
35
|
+
userSelect: "none",
|
|
36
|
+
fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
37
|
+
};
|
|
38
|
+
var wrapperStyles = {
|
|
39
|
+
display: "flex",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
gap: "8px"
|
|
42
|
+
};
|
|
43
|
+
var Radio = React.forwardRef(
|
|
44
|
+
({
|
|
45
|
+
label,
|
|
46
|
+
checked = false,
|
|
47
|
+
onChange,
|
|
48
|
+
disabled = false,
|
|
49
|
+
className,
|
|
50
|
+
style,
|
|
51
|
+
"data-testid": dataTestId,
|
|
52
|
+
name,
|
|
53
|
+
value
|
|
54
|
+
}, ref) => {
|
|
55
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
56
|
+
const radioId = React.useId();
|
|
57
|
+
const handleChange = (e) => {
|
|
58
|
+
if (!disabled) {
|
|
59
|
+
onChange?.(e.target.checked);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const circleStyle = {
|
|
63
|
+
...radioStyles,
|
|
64
|
+
...checked && !disabled && checkedStyles,
|
|
65
|
+
...disabled && !checked && { backgroundColor: "#f8f8f8", borderColor: "#efefef" },
|
|
66
|
+
...disabled && checked && { borderColor: "#7e7e7e" },
|
|
67
|
+
...isFocused && !disabled && { borderColor: "#3cad51", outline: "2px solid rgba(60, 173, 81, 0.2)" }
|
|
68
|
+
};
|
|
69
|
+
const dotStyle = {
|
|
70
|
+
...innerDotStyles,
|
|
71
|
+
backgroundColor: disabled ? "#7e7e7e" : "#3cad51"
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ jsxs(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
className: clsx("arbor-radio-wrapper", className),
|
|
77
|
+
style: { ...wrapperStyles, ...style },
|
|
78
|
+
"data-testid": dataTestId,
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
"input",
|
|
82
|
+
{
|
|
83
|
+
ref,
|
|
84
|
+
id: radioId,
|
|
85
|
+
type: "radio",
|
|
86
|
+
checked,
|
|
87
|
+
onChange: handleChange,
|
|
88
|
+
onFocus: () => setIsFocused(true),
|
|
89
|
+
onBlur: () => setIsFocused(false),
|
|
90
|
+
disabled,
|
|
91
|
+
name,
|
|
92
|
+
value,
|
|
93
|
+
style: {
|
|
94
|
+
position: "absolute",
|
|
95
|
+
opacity: 0,
|
|
96
|
+
width: 0,
|
|
97
|
+
height: 0
|
|
98
|
+
},
|
|
99
|
+
"aria-checked": checked
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ jsxs(
|
|
103
|
+
"label",
|
|
104
|
+
{
|
|
105
|
+
htmlFor: radioId,
|
|
106
|
+
style: {
|
|
107
|
+
display: "flex",
|
|
108
|
+
alignItems: "center",
|
|
109
|
+
gap: "8px",
|
|
110
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
111
|
+
},
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx("div", { style: circleStyle, children: checked && /* @__PURE__ */ jsx("div", { style: dotStyle }) }),
|
|
114
|
+
label && /* @__PURE__ */ jsx(
|
|
115
|
+
"span",
|
|
116
|
+
{
|
|
117
|
+
style: {
|
|
118
|
+
...labelStyles,
|
|
119
|
+
color: disabled ? "#7e7e7e" : "#2f2f2f",
|
|
120
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
121
|
+
},
|
|
122
|
+
children: label
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
Radio.displayName = "Radio";
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
Radio
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=chunk-ARBHNHO7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Radio/Radio.tsx"],"sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\n\nexport interface RadioProps {\n /**\n * The label for the radio button\n */\n label?: string;\n /**\n * Whether the radio is selected\n */\n checked?: boolean;\n /**\n * Callback when selection changes\n */\n onChange?: (checked: boolean) => void;\n /**\n * Whether the radio is disabled\n */\n disabled?: boolean;\n /**\n * Custom className\n */\n className?: string;\n /**\n * Custom style\n */\n style?: React.CSSProperties;\n /**\n * Test ID for testing\n */\n 'data-testid'?: string;\n /**\n * Name attribute for form submission (groups radios together)\n */\n name?: string;\n /**\n * Value attribute for form submission\n */\n value?: string;\n}\n\nconst radioStyles: React.CSSProperties = {\n width: '20px',\n height: '20px',\n border: '2px solid #d1d1d1', // grey-300\n borderRadius: '50%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n cursor: 'pointer',\n transition: 'all 0.2s ease-in-out',\n flexShrink: 0,\n backgroundColor: '#ffffff',\n};\n\nconst checkedStyles: React.CSSProperties = {\n borderColor: '#3cad51', // brand-500\n};\n\nconst innerDotStyles: React.CSSProperties = {\n width: '10px',\n height: '10px',\n borderRadius: '50%',\n backgroundColor: '#3cad51', // brand-500\n transition: 'all 0.2s ease-in-out',\n};\n\nconst labelStyles: React.CSSProperties = {\n fontSize: '13px',\n color: '#2f2f2f',\n cursor: 'pointer',\n userSelect: 'none' as const,\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n};\n\nconst wrapperStyles: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n};\n\n/**\n * Radio component - Arbor Design System\n *\n * A radio button input with label support.\n */\nexport const Radio = React.forwardRef<HTMLInputElement, RadioProps>(\n (\n {\n label,\n checked = false,\n onChange,\n disabled = false,\n className,\n style,\n 'data-testid': dataTestId,\n name,\n value,\n },\n ref\n ) => {\n const [isFocused, setIsFocused] = React.useState(false);\n const radioId = React.useId();\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!disabled) {\n onChange?.(e.target.checked);\n }\n };\n\n const circleStyle: React.CSSProperties = {\n ...radioStyles,\n ...(checked && !disabled && checkedStyles),\n ...(disabled && !checked && { backgroundColor: '#f8f8f8', borderColor: '#efefef' }),\n ...(disabled && checked && { borderColor: '#7e7e7e' }),\n ...(isFocused && !disabled && { borderColor: '#3cad51', outline: '2px solid rgba(60, 173, 81, 0.2)' }),\n };\n\n const dotStyle: React.CSSProperties = {\n ...innerDotStyles,\n backgroundColor: disabled ? '#7e7e7e' : '#3cad51',\n };\n\n return (\n <div\n className={clsx('arbor-radio-wrapper', className)}\n style={{ ...wrapperStyles, ...style }}\n data-testid={dataTestId}\n >\n <input\n ref={ref}\n id={radioId}\n type=\"radio\"\n checked={checked}\n onChange={handleChange}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n disabled={disabled}\n name={name}\n value={value}\n style={{\n position: 'absolute',\n opacity: 0,\n width: 0,\n height: 0,\n }}\n aria-checked={checked}\n />\n <label\n htmlFor={radioId}\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n cursor: disabled ? 'not-allowed' : 'pointer',\n }}\n >\n <div style={circleStyle}>\n {checked && <div style={dotStyle} />}\n </div>\n {label && (\n <span\n style={{\n ...labelStyles,\n color: disabled ? '#7e7e7e' : '#2f2f2f',\n cursor: disabled ? 'not-allowed' : 'pointer',\n }}\n >\n {label}\n </span>\n )}\n </label>\n </div>\n );\n }\n);\n\nRadio.displayName = 'Radio';\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,YAAY;AAiIb,cAmBA,YAnBA;AAxFR,IAAM,cAAmC;AAAA,EACvC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA;AAAA,EACR,cAAc;AAAA,EACd,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,iBAAiB;AACnB;AAEA,IAAM,gBAAqC;AAAA,EACzC,aAAa;AAAA;AACf;AAEA,IAAM,iBAAsC;AAAA,EAC1C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,iBAAiB;AAAA;AAAA,EACjB,YAAY;AACd;AAEA,IAAM,cAAmC;AAAA,EACvC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AACd;AAEA,IAAM,gBAAqC;AAAA,EACzC,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,KAAK;AACP;AAOO,IAAM,QAAc;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,eAA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AA,cAEA;AAAA,oCAAC,SAAI,OAAO,aACT,qBAAW,oBAAC,SAAI,OAAO,UAAU,GACpC;AAAA,gBACC,SACC;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAO;AAAA,sBACL,GAAG;AAAA,sBACH,OAAO,WAAW,YAAY;AAAA,sBAC9B,QAAQ,WAAW,gBAAgB;AAAA,oBACrC;AAAA,oBAEC;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UAEJ;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc;","names":[]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// src/Checkbox/Checkbox.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
|
+
import { Check } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var checkboxStyles = {
|
|
7
|
+
width: "20px",
|
|
8
|
+
height: "20px",
|
|
9
|
+
border: "2px solid #d1d1d1",
|
|
10
|
+
// grey-300
|
|
11
|
+
borderRadius: "4px",
|
|
12
|
+
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
cursor: "pointer",
|
|
16
|
+
transition: "all 0.2s ease-in-out",
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
backgroundColor: "#ffffff"
|
|
19
|
+
};
|
|
20
|
+
var checkedStyles = {
|
|
21
|
+
backgroundColor: "#3cad51",
|
|
22
|
+
// brand-500
|
|
23
|
+
borderColor: "#3cad51"
|
|
24
|
+
};
|
|
25
|
+
var labelStyles = {
|
|
26
|
+
fontSize: "13px",
|
|
27
|
+
color: "#2f2f2f",
|
|
28
|
+
cursor: "pointer",
|
|
29
|
+
userSelect: "none",
|
|
30
|
+
fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
31
|
+
};
|
|
32
|
+
var wrapperStyles = {
|
|
33
|
+
display: "flex",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
gap: "8px"
|
|
36
|
+
};
|
|
37
|
+
var Checkbox = React.forwardRef(
|
|
38
|
+
({
|
|
39
|
+
label,
|
|
40
|
+
checked = false,
|
|
41
|
+
onChange,
|
|
42
|
+
disabled = false,
|
|
43
|
+
className,
|
|
44
|
+
style,
|
|
45
|
+
"data-testid": dataTestId,
|
|
46
|
+
name,
|
|
47
|
+
value
|
|
48
|
+
}, ref) => {
|
|
49
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
50
|
+
const checkboxId = React.useId();
|
|
51
|
+
const handleChange = (e) => {
|
|
52
|
+
if (!disabled) {
|
|
53
|
+
onChange?.(e.target.checked);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const boxStyle = {
|
|
57
|
+
...checkboxStyles,
|
|
58
|
+
...checked && !disabled && checkedStyles,
|
|
59
|
+
...disabled && !checked && { backgroundColor: "#f8f8f8", borderColor: "#efefef" },
|
|
60
|
+
...disabled && checked && { backgroundColor: "#7e7e7e", borderColor: "#7e7e7e" },
|
|
61
|
+
...isFocused && !disabled && { borderColor: "#3cad51", outline: "2px solid rgba(60, 173, 81, 0.2)" }
|
|
62
|
+
};
|
|
63
|
+
const checkmarkColor = disabled ? "#d1d1d1" : "#ffffff";
|
|
64
|
+
return /* @__PURE__ */ jsxs(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
className: clsx("arbor-checkbox-wrapper", className),
|
|
68
|
+
style: { ...wrapperStyles, ...style },
|
|
69
|
+
"data-testid": dataTestId,
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
72
|
+
"input",
|
|
73
|
+
{
|
|
74
|
+
ref,
|
|
75
|
+
id: checkboxId,
|
|
76
|
+
type: "checkbox",
|
|
77
|
+
checked,
|
|
78
|
+
onChange: handleChange,
|
|
79
|
+
onFocus: () => setIsFocused(true),
|
|
80
|
+
onBlur: () => setIsFocused(false),
|
|
81
|
+
disabled,
|
|
82
|
+
name,
|
|
83
|
+
value,
|
|
84
|
+
style: {
|
|
85
|
+
position: "absolute",
|
|
86
|
+
opacity: 0,
|
|
87
|
+
width: 0,
|
|
88
|
+
height: 0
|
|
89
|
+
},
|
|
90
|
+
"aria-checked": checked
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ jsxs(
|
|
94
|
+
"label",
|
|
95
|
+
{
|
|
96
|
+
htmlFor: checkboxId,
|
|
97
|
+
style: {
|
|
98
|
+
display: "flex",
|
|
99
|
+
alignItems: "center",
|
|
100
|
+
gap: "8px",
|
|
101
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
102
|
+
},
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsx("div", { style: boxStyle, children: checked && /* @__PURE__ */ jsx(Check, { size: 14, color: checkmarkColor, strokeWidth: 3 }) }),
|
|
105
|
+
label && /* @__PURE__ */ jsx(
|
|
106
|
+
"span",
|
|
107
|
+
{
|
|
108
|
+
style: {
|
|
109
|
+
...labelStyles,
|
|
110
|
+
color: disabled ? "#7e7e7e" : "#2f2f2f",
|
|
111
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
112
|
+
},
|
|
113
|
+
children: label
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
Checkbox.displayName = "Checkbox";
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
Checkbox
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=chunk-BCYJIUQX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport { Check } from 'lucide-react';\n\nexport interface CheckboxProps {\n /**\n * The label for the checkbox\n */\n label?: string;\n /**\n * Whether the checkbox is checked\n */\n checked?: boolean;\n /**\n * Callback when checked state changes\n */\n onChange?: (checked: boolean) => void;\n /**\n * Whether the checkbox is disabled\n */\n disabled?: boolean;\n /**\n * Custom className\n */\n className?: string;\n /**\n * Custom style\n */\n style?: React.CSSProperties;\n /**\n * Test ID for testing\n */\n 'data-testid'?: string;\n /**\n * Name attribute for form submission\n */\n name?: string;\n /**\n * Value attribute for form submission\n */\n value?: string;\n}\n\nconst checkboxStyles: React.CSSProperties = {\n width: '20px',\n height: '20px',\n border: '2px solid #d1d1d1', // grey-300\n borderRadius: '4px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n cursor: 'pointer',\n transition: 'all 0.2s ease-in-out',\n flexShrink: 0,\n backgroundColor: '#ffffff',\n};\n\nconst checkedStyles: React.CSSProperties = {\n backgroundColor: '#3cad51', // brand-500\n borderColor: '#3cad51',\n};\n\nconst labelStyles: React.CSSProperties = {\n fontSize: '13px',\n color: '#2f2f2f',\n cursor: 'pointer',\n userSelect: 'none' as const,\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n};\n\nconst wrapperStyles: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n};\n\n/**\n * Checkbox component - Arbor Design System\n *\n * A checkbox input with label support.\n */\nexport const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n label,\n checked = false,\n onChange,\n disabled = false,\n className,\n style,\n 'data-testid': dataTestId,\n name,\n value,\n },\n ref\n ) => {\n const [isFocused, setIsFocused] = React.useState(false);\n const checkboxId = React.useId();\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!disabled) {\n onChange?.(e.target.checked);\n }\n };\n\n const boxStyle: React.CSSProperties = {\n ...checkboxStyles,\n ...(checked && !disabled && checkedStyles),\n ...(disabled && !checked && { backgroundColor: '#f8f8f8', borderColor: '#efefef' }),\n ...(disabled && checked && { backgroundColor: '#7e7e7e', borderColor: '#7e7e7e' }),\n ...(isFocused && !disabled && { borderColor: '#3cad51', outline: '2px solid rgba(60, 173, 81, 0.2)' }),\n };\n\n const checkmarkColor = disabled ? '#d1d1d1' : '#ffffff';\n\n return (\n <div\n className={clsx('arbor-checkbox-wrapper', className)}\n style={{ ...wrapperStyles, ...style }}\n data-testid={dataTestId}\n >\n <input\n ref={ref}\n id={checkboxId}\n type=\"checkbox\"\n checked={checked}\n onChange={handleChange}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n disabled={disabled}\n name={name}\n value={value}\n style={{\n position: 'absolute',\n opacity: 0,\n width: 0,\n height: 0,\n }}\n aria-checked={checked}\n />\n <label\n htmlFor={checkboxId}\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n cursor: disabled ? 'not-allowed' : 'pointer',\n }}\n >\n <div style={boxStyle}>\n {checked && (\n <Check size={14} color={checkmarkColor} strokeWidth={3} />\n )}\n </div>\n {label && (\n <span\n style={{\n ...labelStyles,\n color: disabled ? '#7e7e7e' : '#2f2f2f',\n cursor: disabled ? 'not-allowed' : 'pointer',\n }}\n >\n {label}\n </span>\n )}\n </label>\n </div>\n );\n }\n);\n\nCheckbox.displayName = 'Checkbox';\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,aAAa;AAuHd,cAmBA,YAnBA;AA9ER,IAAM,iBAAsC;AAAA,EAC1C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA;AAAA,EACR,cAAc;AAAA,EACd,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,iBAAiB;AACnB;AAEA,IAAM,gBAAqC;AAAA,EACzC,iBAAiB;AAAA;AAAA,EACjB,aAAa;AACf;AAEA,IAAM,cAAmC;AAAA,EACvC,UAAU;AAAA,EACV,OAAO;AAAA,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BACP,QAAQ;AAAA,cACV;AAAA,cACA,gBAAc;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,SAAS;AAAA,cACT,OAAO;AAAA,gBACL,SAAS;AAAA,gBACT,YAAY;AAAA,gBACZ,KAAK;AAAA,gBACL,QAAQ,WAAW,gBAAgB;AAAA,cACrC;AAAA,cAEA;AAAA,oCAAC,SAAI,OAAO,UACT,qBACC,oBAAC,SAAM,MAAM,IAAI,OAAO,gBAAgB,aAAa,GAAG,GAE5D;AAAA,gBACC,SACC;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAO;AAAA,sBACL,GAAG;AAAA,sBACH,OAAO,WAAW,YAAY;AAAA,sBAC9B,QAAQ,WAAW,gBAAgB;AAAA,oBACrC;AAAA,oBAEC;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UAEJ;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,SAAS,cAAc;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,10 @@ export { Button, ButtonProps } from './Button.mjs';
|
|
|
2
2
|
export { Card, CardProps } from './Card.mjs';
|
|
3
3
|
export { Input, InputProps } from './Input.mjs';
|
|
4
4
|
export { Tag, TagProps } from './Tag.mjs';
|
|
5
|
+
export { Combobox, ComboboxProps } from './Combobox.mjs';
|
|
6
|
+
export { NumericInput, NumericInputProps } from './NumericInput.mjs';
|
|
7
|
+
export { Checkbox, CheckboxProps } from './Checkbox.mjs';
|
|
8
|
+
export { Radio, RadioProps } from './Radio.mjs';
|
|
5
9
|
import 'react';
|
|
6
10
|
|
|
7
11
|
/**
|
|
@@ -13,5 +17,11 @@ type InputSize = 'small' | 'medium';
|
|
|
13
17
|
type ValidationState = 'default' | 'error' | 'success';
|
|
14
18
|
type CardPadding = 'none' | 'small' | 'medium' | 'large';
|
|
15
19
|
type TagVariant = 'default' | 'success' | 'error' | 'info' | 'neutral';
|
|
20
|
+
type ComboboxState = 'default' | 'error' | 'success';
|
|
21
|
+
type ComboboxOption = {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
type NumericInputState = 'default' | 'error' | 'success';
|
|
16
26
|
|
|
17
|
-
export type { ButtonSize, ButtonVariant, CardPadding, InputSize, TagVariant, ValidationState };
|
|
27
|
+
export type { ButtonSize, ButtonVariant, CardPadding, ComboboxOption, ComboboxState, InputSize, NumericInputState, TagVariant, ValidationState };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export { Button, ButtonProps } from './Button.js';
|
|
|
2
2
|
export { Card, CardProps } from './Card.js';
|
|
3
3
|
export { Input, InputProps } from './Input.js';
|
|
4
4
|
export { Tag, TagProps } from './Tag.js';
|
|
5
|
+
export { Combobox, ComboboxProps } from './Combobox.js';
|
|
6
|
+
export { NumericInput, NumericInputProps } from './NumericInput.js';
|
|
7
|
+
export { Checkbox, CheckboxProps } from './Checkbox.js';
|
|
8
|
+
export { Radio, RadioProps } from './Radio.js';
|
|
5
9
|
import 'react';
|
|
6
10
|
|
|
7
11
|
/**
|
|
@@ -13,5 +17,11 @@ type InputSize = 'small' | 'medium';
|
|
|
13
17
|
type ValidationState = 'default' | 'error' | 'success';
|
|
14
18
|
type CardPadding = 'none' | 'small' | 'medium' | 'large';
|
|
15
19
|
type TagVariant = 'default' | 'success' | 'error' | 'info' | 'neutral';
|
|
20
|
+
type ComboboxState = 'default' | 'error' | 'success';
|
|
21
|
+
type ComboboxOption = {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
type NumericInputState = 'default' | 'error' | 'success';
|
|
16
26
|
|
|
17
|
-
export type { ButtonSize, ButtonVariant, CardPadding, InputSize, TagVariant, ValidationState };
|
|
27
|
+
export type { ButtonSize, ButtonVariant, CardPadding, ComboboxOption, ComboboxState, InputSize, NumericInputState, TagVariant, ValidationState };
|