@tonyarbor/components 0.1.0 → 0.2.1
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/Banner.d.mts +59 -0
- package/dist/Banner.d.ts +59 -0
- package/dist/Banner.js +222 -0
- package/dist/Banner.js.map +1 -0
- package/dist/Banner.mjs +7 -0
- package/dist/Banner.mjs.map +1 -0
- package/dist/Checkbox.d.mts +52 -0
- package/dist/Checkbox.d.ts +52 -0
- package/dist/Checkbox.js +194 -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/DatePicker.d.mts +68 -0
- package/dist/DatePicker.d.ts +68 -0
- package/dist/DatePicker.js +490 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatePicker.mjs +7 -0
- package/dist/DatePicker.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/Pagination.d.mts +36 -0
- package/dist/Pagination.d.ts +36 -0
- package/dist/Pagination.js +301 -0
- package/dist/Pagination.js.map +1 -0
- package/dist/Pagination.mjs +7 -0
- package/dist/Pagination.mjs.map +1 -0
- package/dist/Radio.d.mts +48 -0
- package/dist/Radio.d.ts +48 -0
- package/dist/Radio.js +194 -0
- package/dist/Radio.js.map +1 -0
- package/dist/Radio.mjs +7 -0
- package/dist/Radio.mjs.map +1 -0
- package/dist/Table.d.mts +80 -0
- package/dist/Table.d.ts +80 -0
- package/dist/Table.js +347 -0
- package/dist/Table.js.map +1 -0
- package/dist/Table.mjs +8 -0
- package/dist/Table.mjs.map +1 -0
- package/dist/TableControls.d.mts +76 -0
- package/dist/TableControls.d.ts +76 -0
- package/dist/TableControls.js +461 -0
- package/dist/TableControls.js.map +1 -0
- package/dist/TableControls.mjs +7 -0
- package/dist/TableControls.mjs.map +1 -0
- package/dist/TableFooterPagination.d.mts +56 -0
- package/dist/TableFooterPagination.d.ts +56 -0
- package/dist/TableFooterPagination.js +499 -0
- package/dist/TableFooterPagination.js.map +1 -0
- package/dist/TableFooterPagination.mjs +7 -0
- package/dist/TableFooterPagination.mjs.map +1 -0
- package/dist/Tabs.d.mts +50 -0
- package/dist/Tabs.d.ts +50 -0
- package/dist/Tabs.js +187 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Tabs.mjs +7 -0
- package/dist/Tabs.mjs.map +1 -0
- package/dist/TextArea.d.mts +64 -0
- package/dist/TextArea.d.ts +64 -0
- package/dist/TextArea.js +171 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextArea.mjs +7 -0
- package/dist/TextArea.mjs.map +1 -0
- package/dist/Toast.d.mts +48 -0
- package/dist/Toast.d.ts +48 -0
- package/dist/Toast.js +169 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Toast.mjs +7 -0
- package/dist/Toast.mjs.map +1 -0
- package/dist/Toggle.d.mts +48 -0
- package/dist/Toggle.d.ts +48 -0
- package/dist/Toggle.js +291 -0
- package/dist/Toggle.js.map +1 -0
- package/dist/Toggle.mjs +7 -0
- package/dist/Toggle.mjs.map +1 -0
- package/dist/Tooltip.d.mts +32 -0
- package/dist/Tooltip.d.ts +32 -0
- package/dist/Tooltip.js +109 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/Tooltip.mjs +7 -0
- package/dist/Tooltip.mjs.map +1 -0
- package/dist/chunk-52TG3BFX.mjs +463 -0
- package/dist/chunk-52TG3BFX.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-AI2U34CF.mjs +159 -0
- package/dist/chunk-AI2U34CF.mjs.map +1 -0
- package/dist/chunk-C25FFMRQ.mjs +255 -0
- package/dist/chunk-C25FFMRQ.mjs.map +1 -0
- package/dist/chunk-CUTYEIFE.mjs +158 -0
- package/dist/chunk-CUTYEIFE.mjs.map +1 -0
- package/dist/chunk-DULH2KRW.mjs +133 -0
- package/dist/chunk-DULH2KRW.mjs.map +1 -0
- package/dist/chunk-G5NVKF2G.mjs +434 -0
- package/dist/chunk-G5NVKF2G.mjs.map +1 -0
- package/dist/chunk-M6DVBEEL.mjs +158 -0
- package/dist/chunk-M6DVBEEL.mjs.map +1 -0
- package/dist/chunk-MBUMR2XJ.mjs +135 -0
- package/dist/chunk-MBUMR2XJ.mjs.map +1 -0
- package/dist/chunk-MNH2TGUX.mjs +73 -0
- package/dist/chunk-MNH2TGUX.mjs.map +1 -0
- package/dist/chunk-RRMG2SSZ.mjs +265 -0
- package/dist/chunk-RRMG2SSZ.mjs.map +1 -0
- package/dist/chunk-U4JXKZZG.mjs +186 -0
- package/dist/chunk-U4JXKZZG.mjs.map +1 -0
- package/dist/chunk-W55QJIAN.mjs +467 -0
- package/dist/chunk-W55QJIAN.mjs.map +1 -0
- package/dist/chunk-YV4OXFIM.mjs +151 -0
- package/dist/chunk-YV4OXFIM.mjs.map +1 -0
- package/dist/index.d.mts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +3559 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -1
- package/package.json +81 -3
package/dist/Toast.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ToastProps {
|
|
4
|
+
/**
|
|
5
|
+
* The variant of the toast
|
|
6
|
+
*/
|
|
7
|
+
variant: 'information' | 'danger' | 'warning' | 'success' | 'caution';
|
|
8
|
+
/**
|
|
9
|
+
* The message to display
|
|
10
|
+
*/
|
|
11
|
+
message: string;
|
|
12
|
+
/**
|
|
13
|
+
* Callback when close button is clicked
|
|
14
|
+
*/
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Custom className
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Custom style
|
|
22
|
+
*/
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
/**
|
|
25
|
+
* Test ID for testing
|
|
26
|
+
*/
|
|
27
|
+
'data-testid'?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Toast component - Arbor Design System
|
|
31
|
+
*
|
|
32
|
+
* A notification toast with different variants for different message types.
|
|
33
|
+
*
|
|
34
|
+
* IMPORTANT: Toasts are designed to overlay content in the top-right corner.
|
|
35
|
+
* Use absolute/fixed positioning to display them above page content.
|
|
36
|
+
*
|
|
37
|
+
* For inline notifications that flow with page content, use the Banner component instead.
|
|
38
|
+
*
|
|
39
|
+
* Example usage with positioning:
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <div style={{ position: 'fixed', top: '24px', right: '24px', zIndex: 1000 }}>
|
|
42
|
+
* <Toast variant="success" message="Changes saved!" onClose={() => {}} />
|
|
43
|
+
* </div>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare const Toast: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLDivElement>>;
|
|
47
|
+
|
|
48
|
+
export { Toast, type ToastProps };
|
package/dist/Toast.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/Toast/index.ts
|
|
31
|
+
var Toast_exports = {};
|
|
32
|
+
__export(Toast_exports, {
|
|
33
|
+
Toast: () => Toast
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Toast_exports);
|
|
36
|
+
|
|
37
|
+
// src/Toast/Toast.tsx
|
|
38
|
+
var React = __toESM(require("react"));
|
|
39
|
+
var import_clsx = require("clsx");
|
|
40
|
+
var import_lucide_react = require("lucide-react");
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
var baseToastStyles = {
|
|
43
|
+
width: "360px",
|
|
44
|
+
padding: "16px",
|
|
45
|
+
borderRadius: "8px",
|
|
46
|
+
border: "1px solid",
|
|
47
|
+
display: "flex",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
gap: "12px",
|
|
50
|
+
boxShadow: "0px 4px 12px 0px rgba(32, 32, 32, 0.08)",
|
|
51
|
+
fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
52
|
+
};
|
|
53
|
+
var messageStyles = {
|
|
54
|
+
fontSize: "13px",
|
|
55
|
+
fontWeight: 600,
|
|
56
|
+
flex: 1
|
|
57
|
+
};
|
|
58
|
+
var closeButtonStyles = {
|
|
59
|
+
width: "24px",
|
|
60
|
+
height: "24px",
|
|
61
|
+
borderRadius: "50%",
|
|
62
|
+
border: "none",
|
|
63
|
+
background: "transparent",
|
|
64
|
+
cursor: "pointer",
|
|
65
|
+
display: "flex",
|
|
66
|
+
alignItems: "center",
|
|
67
|
+
justifyContent: "center",
|
|
68
|
+
flexShrink: 0,
|
|
69
|
+
transition: "background-color 0.2s ease-in-out"
|
|
70
|
+
};
|
|
71
|
+
var variantConfig = {
|
|
72
|
+
information: {
|
|
73
|
+
backgroundColor: "#f5fbff",
|
|
74
|
+
borderColor: "#2c8bca",
|
|
75
|
+
textColor: "#053a61",
|
|
76
|
+
icon: import_lucide_react.Info,
|
|
77
|
+
iconColor: "#2c8bca",
|
|
78
|
+
closeHoverBg: "#e0f3ff"
|
|
79
|
+
},
|
|
80
|
+
danger: {
|
|
81
|
+
backgroundColor: "#fff5f5",
|
|
82
|
+
borderColor: "#c93232",
|
|
83
|
+
textColor: "#610202",
|
|
84
|
+
icon: import_lucide_react.AlertCircle,
|
|
85
|
+
iconColor: "#c93232",
|
|
86
|
+
closeHoverBg: "#ffe0e0"
|
|
87
|
+
},
|
|
88
|
+
warning: {
|
|
89
|
+
backgroundColor: "#fffaf5",
|
|
90
|
+
borderColor: "#e4720d",
|
|
91
|
+
textColor: "#611f00",
|
|
92
|
+
icon: import_lucide_react.AlertTriangle,
|
|
93
|
+
iconColor: "#e4720d",
|
|
94
|
+
closeHoverBg: "#ffedd5"
|
|
95
|
+
},
|
|
96
|
+
success: {
|
|
97
|
+
backgroundColor: "#f0faf3",
|
|
98
|
+
borderColor: "#5ec171",
|
|
99
|
+
textColor: "#024002",
|
|
100
|
+
icon: import_lucide_react.CheckCircle,
|
|
101
|
+
iconColor: "#5ec171",
|
|
102
|
+
closeHoverBg: "#d9f2df"
|
|
103
|
+
},
|
|
104
|
+
caution: {
|
|
105
|
+
backgroundColor: "#fffdf5",
|
|
106
|
+
borderColor: "#edae06",
|
|
107
|
+
textColor: "#613f00",
|
|
108
|
+
icon: import_lucide_react.AlertOctagon,
|
|
109
|
+
iconColor: "#edae06",
|
|
110
|
+
closeHoverBg: "#fff8d5"
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var Toast = React.forwardRef(
|
|
114
|
+
({
|
|
115
|
+
variant,
|
|
116
|
+
message,
|
|
117
|
+
onClose,
|
|
118
|
+
className,
|
|
119
|
+
style,
|
|
120
|
+
"data-testid": dataTestId
|
|
121
|
+
}, ref) => {
|
|
122
|
+
const [isCloseHovered, setIsCloseHovered] = React.useState(false);
|
|
123
|
+
const config = variantConfig[variant];
|
|
124
|
+
const IconComponent = config.icon;
|
|
125
|
+
const toastStyle = {
|
|
126
|
+
...baseToastStyles,
|
|
127
|
+
backgroundColor: config.backgroundColor,
|
|
128
|
+
borderColor: config.borderColor,
|
|
129
|
+
...style
|
|
130
|
+
};
|
|
131
|
+
const closeStyle = {
|
|
132
|
+
...closeButtonStyles,
|
|
133
|
+
...isCloseHovered && { backgroundColor: config.closeHoverBg }
|
|
134
|
+
};
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
136
|
+
"div",
|
|
137
|
+
{
|
|
138
|
+
ref,
|
|
139
|
+
className: (0, import_clsx.clsx)("arbor-toast", `arbor-toast-${variant}`, className),
|
|
140
|
+
style: toastStyle,
|
|
141
|
+
"data-testid": dataTestId,
|
|
142
|
+
role: "alert",
|
|
143
|
+
"aria-live": "polite",
|
|
144
|
+
children: [
|
|
145
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconComponent, { size: 16, color: config.iconColor, style: { flexShrink: 0 } }),
|
|
146
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { ...messageStyles, color: config.textColor }, children: message }),
|
|
147
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
148
|
+
"button",
|
|
149
|
+
{
|
|
150
|
+
onClick: onClose,
|
|
151
|
+
onMouseEnter: () => setIsCloseHovered(true),
|
|
152
|
+
onMouseLeave: () => setIsCloseHovered(false),
|
|
153
|
+
style: closeStyle,
|
|
154
|
+
"aria-label": "Close notification",
|
|
155
|
+
type: "button",
|
|
156
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontSize: "18px", lineHeight: 1, color: "#595959", fontWeight: "bold" }, children: "\xD7" })
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
Toast.displayName = "Toast";
|
|
165
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
Toast
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=Toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Toast/index.ts","../src/Toast/Toast.tsx"],"sourcesContent":["export { Toast } from './Toast';\nexport type { ToastProps } from './Toast';\n","import * as React from 'react';\nimport { clsx } from 'clsx';\nimport { Info, AlertCircle, AlertTriangle, CheckCircle, AlertOctagon } from 'lucide-react';\n\nexport interface ToastProps {\n /**\n * The variant of the toast\n */\n variant: 'information' | 'danger' | 'warning' | 'success' | 'caution';\n /**\n * The message to display\n */\n message: string;\n /**\n * Callback when close button is clicked\n */\n onClose?: () => void;\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\nconst baseToastStyles: React.CSSProperties = {\n width: '360px',\n padding: '16px',\n borderRadius: '8px',\n border: '1px solid',\n display: 'flex',\n alignItems: 'center',\n gap: '12px',\n boxShadow: '0px 4px 12px 0px rgba(32, 32, 32, 0.08)',\n fontFamily: \"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",\n};\n\nconst messageStyles: React.CSSProperties = {\n fontSize: '13px',\n fontWeight: 600,\n flex: 1,\n};\n\nconst closeButtonStyles: React.CSSProperties = {\n width: '24px',\n height: '24px',\n borderRadius: '50%',\n border: 'none',\n background: 'transparent',\n cursor: 'pointer',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n flexShrink: 0,\n transition: 'background-color 0.2s ease-in-out',\n};\n\nconst variantConfig = {\n information: {\n backgroundColor: '#f5fbff',\n borderColor: '#2c8bca',\n textColor: '#053a61',\n icon: Info,\n iconColor: '#2c8bca',\n closeHoverBg: '#e0f3ff',\n },\n danger: {\n backgroundColor: '#fff5f5',\n borderColor: '#c93232',\n textColor: '#610202',\n icon: AlertCircle,\n iconColor: '#c93232',\n closeHoverBg: '#ffe0e0',\n },\n warning: {\n backgroundColor: '#fffaf5',\n borderColor: '#e4720d',\n textColor: '#611f00',\n icon: AlertTriangle,\n iconColor: '#e4720d',\n closeHoverBg: '#ffedd5',\n },\n success: {\n backgroundColor: '#f0faf3',\n borderColor: '#5ec171',\n textColor: '#024002',\n icon: CheckCircle,\n iconColor: '#5ec171',\n closeHoverBg: '#d9f2df',\n },\n caution: {\n backgroundColor: '#fffdf5',\n borderColor: '#edae06',\n textColor: '#613f00',\n icon: AlertOctagon,\n iconColor: '#edae06',\n closeHoverBg: '#fff8d5',\n },\n};\n\n/**\n * Toast component - Arbor Design System\n *\n * A notification toast with different variants for different message types.\n *\n * IMPORTANT: Toasts are designed to overlay content in the top-right corner.\n * Use absolute/fixed positioning to display them above page content.\n *\n * For inline notifications that flow with page content, use the Banner component instead.\n *\n * Example usage with positioning:\n * ```tsx\n * <div style={{ position: 'fixed', top: '24px', right: '24px', zIndex: 1000 }}>\n * <Toast variant=\"success\" message=\"Changes saved!\" onClose={() => {}} />\n * </div>\n * ```\n */\nexport const Toast = React.forwardRef<HTMLDivElement, ToastProps>(\n (\n {\n variant,\n message,\n onClose,\n className,\n style,\n 'data-testid': dataTestId,\n },\n ref\n ) => {\n const [isCloseHovered, setIsCloseHovered] = React.useState(false);\n const config = variantConfig[variant];\n const IconComponent = config.icon;\n\n const toastStyle: React.CSSProperties = {\n ...baseToastStyles,\n backgroundColor: config.backgroundColor,\n borderColor: config.borderColor,\n ...style,\n };\n\n const closeStyle: React.CSSProperties = {\n ...closeButtonStyles,\n ...(isCloseHovered && { backgroundColor: config.closeHoverBg }),\n };\n\n return (\n <div\n ref={ref}\n className={clsx('arbor-toast', `arbor-toast-${variant}`, className)}\n style={toastStyle}\n data-testid={dataTestId}\n role=\"alert\"\n aria-live=\"polite\"\n >\n <IconComponent size={16} color={config.iconColor} style={{ flexShrink: 0 }} />\n <span style={{ ...messageStyles, color: config.textColor }}>\n {message}\n </span>\n {onClose && (\n <button\n onClick={onClose}\n onMouseEnter={() => setIsCloseHovered(true)}\n onMouseLeave={() => setIsCloseHovered(false)}\n style={closeStyle}\n aria-label=\"Close notification\"\n type=\"button\"\n >\n <span style={{ fontSize: '18px', lineHeight: 1, color: '#595959', fontWeight: 'bold' }}>×</span>\n </button>\n )}\n </div>\n );\n }\n);\n\nToast.displayName = 'Toast';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,kBAAqB;AACrB,0BAA4E;AAsJtE;AAzHN,IAAM,kBAAuC;AAAA,EAC3C,OAAO;AAAA,EACP,SAAS;AAAA,EACT,cAAc;AAAA,EACd,QAAQ;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,gBAAgB,iBAAiB,IAAU,eAAS,KAAK;AAChE,UAAM,SAAS,cAAc,OAAO;AACpC,UAAM,gBAAgB,OAAO;AAE7B,UAAM,aAAkC;AAAA,MACtC,GAAG;AAAA,MACH,iBAAiB,OAAO;AAAA,MACxB,aAAa,OAAO;AAAA,MACpB,GAAG;AAAA,IACL;AAEA,UAAM,aAAkC;AAAA,MACtC,GAAG;AAAA,MACH,GAAI,kBAAkB,EAAE,iBAAiB,OAAO,aAAa;AAAA,IAC/D;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAW,kBAAK,eAAe,eAAe,OAAO,IAAI,SAAS;AAAA,QAClE,OAAO;AAAA,QACP,eAAa;AAAA,QACb,MAAK;AAAA,QACL,aAAU;AAAA,QAEV;AAAA,sDAAC,iBAAc,MAAM,IAAI,OAAO,OAAO,WAAW,OAAO,EAAE,YAAY,EAAE,GAAG;AAAA,UAC5E,4CAAC,UAAK,OAAO,EAAE,GAAG,eAAe,OAAO,OAAO,UAAU,GACtD,mBACH;AAAA,UACC,WACC;AAAA,YAAC;AAAA;AAAA,cACC,SAAS;AAAA,cACT,cAAc,MAAM,kBAAkB,IAAI;AAAA,cAC1C,cAAc,MAAM,kBAAkB,KAAK;AAAA,cAC3C,OAAO;AAAA,cACP,cAAW;AAAA,cACX,MAAK;AAAA,cAEL,sDAAC,UAAK,OAAO,EAAE,UAAU,QAAQ,YAAY,GAAG,OAAO,WAAW,YAAY,OAAO,GAAG,kBAAC;AAAA;AAAA,UAC3F;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc;","names":[]}
|
package/dist/Toast.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ToggleProps {
|
|
4
|
+
/**
|
|
5
|
+
* The label for the toggle
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the toggle is on
|
|
10
|
+
*/
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback when toggle state changes
|
|
14
|
+
*/
|
|
15
|
+
onChange?: (checked: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the toggle is disabled
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom className
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Custom style
|
|
26
|
+
*/
|
|
27
|
+
style?: React.CSSProperties;
|
|
28
|
+
/**
|
|
29
|
+
* Test ID for testing
|
|
30
|
+
*/
|
|
31
|
+
'data-testid'?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Name attribute for form submission
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Value attribute for form submission
|
|
38
|
+
*/
|
|
39
|
+
value?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Toggle component - Arbor Design System
|
|
43
|
+
*
|
|
44
|
+
* A toggle switch input with label support.
|
|
45
|
+
*/
|
|
46
|
+
declare const Toggle: React.ForwardRefExoticComponent<ToggleProps & React.RefAttributes<HTMLInputElement>>;
|
|
47
|
+
|
|
48
|
+
export { Toggle, type ToggleProps };
|
package/dist/Toggle.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ToggleProps {
|
|
4
|
+
/**
|
|
5
|
+
* The label for the toggle
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the toggle is on
|
|
10
|
+
*/
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Callback when toggle state changes
|
|
14
|
+
*/
|
|
15
|
+
onChange?: (checked: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the toggle is disabled
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom className
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Custom style
|
|
26
|
+
*/
|
|
27
|
+
style?: React.CSSProperties;
|
|
28
|
+
/**
|
|
29
|
+
* Test ID for testing
|
|
30
|
+
*/
|
|
31
|
+
'data-testid'?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Name attribute for form submission
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Value attribute for form submission
|
|
38
|
+
*/
|
|
39
|
+
value?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Toggle component - Arbor Design System
|
|
43
|
+
*
|
|
44
|
+
* A toggle switch input with label support.
|
|
45
|
+
*/
|
|
46
|
+
declare const Toggle: React.ForwardRefExoticComponent<ToggleProps & React.RefAttributes<HTMLInputElement>>;
|
|
47
|
+
|
|
48
|
+
export { Toggle, type ToggleProps };
|
package/dist/Toggle.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/Toggle/index.ts
|
|
31
|
+
var Toggle_exports = {};
|
|
32
|
+
__export(Toggle_exports, {
|
|
33
|
+
Toggle: () => Toggle
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Toggle_exports);
|
|
36
|
+
|
|
37
|
+
// src/Toggle/Toggle.tsx
|
|
38
|
+
var React = __toESM(require("react"));
|
|
39
|
+
var import_clsx = require("clsx");
|
|
40
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
var toggleContainerStyles = {
|
|
42
|
+
width: "40px",
|
|
43
|
+
height: "24px",
|
|
44
|
+
borderRadius: "16px",
|
|
45
|
+
border: "1px solid",
|
|
46
|
+
position: "relative",
|
|
47
|
+
cursor: "pointer",
|
|
48
|
+
transition: "all 0.2s ease-in-out"
|
|
49
|
+
};
|
|
50
|
+
var knobStyles = {
|
|
51
|
+
width: "18px",
|
|
52
|
+
height: "18px",
|
|
53
|
+
borderRadius: "50%",
|
|
54
|
+
position: "absolute",
|
|
55
|
+
top: "50%",
|
|
56
|
+
transform: "translateY(-50%)",
|
|
57
|
+
transition: "all 0.2s ease-in-out"
|
|
58
|
+
};
|
|
59
|
+
var labelStyles = {
|
|
60
|
+
fontSize: "13px",
|
|
61
|
+
color: "#2f2f2f",
|
|
62
|
+
cursor: "pointer",
|
|
63
|
+
userSelect: "none",
|
|
64
|
+
fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
65
|
+
};
|
|
66
|
+
var wrapperStyles = {
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
gap: "8px"
|
|
70
|
+
};
|
|
71
|
+
var Toggle = React.forwardRef(
|
|
72
|
+
({
|
|
73
|
+
label,
|
|
74
|
+
checked = false,
|
|
75
|
+
onChange,
|
|
76
|
+
disabled = false,
|
|
77
|
+
className,
|
|
78
|
+
style,
|
|
79
|
+
"data-testid": dataTestId,
|
|
80
|
+
name,
|
|
81
|
+
value
|
|
82
|
+
}, ref) => {
|
|
83
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
84
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
85
|
+
const [isActive, setIsActive] = React.useState(false);
|
|
86
|
+
const toggleId = React.useId();
|
|
87
|
+
const handleChange = (e) => {
|
|
88
|
+
if (!disabled) {
|
|
89
|
+
onChange?.(e.target.checked);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const getContainerStyles = () => {
|
|
93
|
+
if (disabled) {
|
|
94
|
+
return {
|
|
95
|
+
...toggleContainerStyles,
|
|
96
|
+
backgroundColor: checked ? "#d1d1d1" : "#ffffff",
|
|
97
|
+
borderColor: checked ? "#d1d1d1" : "#d1d1d1",
|
|
98
|
+
cursor: "not-allowed"
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (checked) {
|
|
102
|
+
if (isActive && isFocused) {
|
|
103
|
+
return {
|
|
104
|
+
...toggleContainerStyles,
|
|
105
|
+
backgroundColor: "#024002",
|
|
106
|
+
borderColor: "#024002",
|
|
107
|
+
boxShadow: "0px 0px 0px 3px #3cad51"
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (isActive) {
|
|
111
|
+
return {
|
|
112
|
+
...toggleContainerStyles,
|
|
113
|
+
backgroundColor: "#024002",
|
|
114
|
+
borderColor: "#024002"
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (isHovered) {
|
|
118
|
+
return {
|
|
119
|
+
...toggleContainerStyles,
|
|
120
|
+
backgroundColor: "#005700",
|
|
121
|
+
borderColor: "#005700"
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (isFocused) {
|
|
125
|
+
return {
|
|
126
|
+
...toggleContainerStyles,
|
|
127
|
+
backgroundColor: "#0b800b",
|
|
128
|
+
borderColor: "#0b800b",
|
|
129
|
+
boxShadow: "0px 0px 0px 3px #3cad51"
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
...toggleContainerStyles,
|
|
134
|
+
backgroundColor: "#0b800b",
|
|
135
|
+
borderColor: "#0b800b"
|
|
136
|
+
};
|
|
137
|
+
} else {
|
|
138
|
+
if (isActive && isFocused) {
|
|
139
|
+
return {
|
|
140
|
+
...toggleContainerStyles,
|
|
141
|
+
backgroundColor: "#efefef",
|
|
142
|
+
borderColor: "#2f2f2f",
|
|
143
|
+
boxShadow: "0px 0px 0px 3px #3cad51"
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (isActive) {
|
|
147
|
+
return {
|
|
148
|
+
...toggleContainerStyles,
|
|
149
|
+
backgroundColor: "#efefef",
|
|
150
|
+
borderColor: "#2f2f2f"
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (isHovered) {
|
|
154
|
+
return {
|
|
155
|
+
...toggleContainerStyles,
|
|
156
|
+
backgroundColor: "#f8f8f8",
|
|
157
|
+
borderColor: "#595959"
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (isFocused) {
|
|
161
|
+
return {
|
|
162
|
+
...toggleContainerStyles,
|
|
163
|
+
backgroundColor: "#ffffff",
|
|
164
|
+
borderColor: "#7e7e7e",
|
|
165
|
+
boxShadow: "0px 0px 0px 3px #3cad51"
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
...toggleContainerStyles,
|
|
170
|
+
backgroundColor: "#ffffff",
|
|
171
|
+
borderColor: "#7e7e7e"
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const getKnobStyles = () => {
|
|
176
|
+
const baseKnob = {
|
|
177
|
+
...knobStyles,
|
|
178
|
+
left: checked ? "18px" : "2px"
|
|
179
|
+
};
|
|
180
|
+
if (disabled) {
|
|
181
|
+
return {
|
|
182
|
+
...baseKnob,
|
|
183
|
+
backgroundColor: checked ? "#f8f8f8" : "#d1d1d1"
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (checked) {
|
|
187
|
+
if (isActive) {
|
|
188
|
+
return {
|
|
189
|
+
...baseKnob,
|
|
190
|
+
backgroundColor: "#efefef"
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (isHovered) {
|
|
194
|
+
return {
|
|
195
|
+
...baseKnob,
|
|
196
|
+
backgroundColor: "#f8f8f8"
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
...baseKnob,
|
|
201
|
+
backgroundColor: "#ffffff"
|
|
202
|
+
};
|
|
203
|
+
} else {
|
|
204
|
+
if (isActive) {
|
|
205
|
+
return {
|
|
206
|
+
...baseKnob,
|
|
207
|
+
backgroundColor: "#2f2f2f"
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
if (isHovered) {
|
|
211
|
+
return {
|
|
212
|
+
...baseKnob,
|
|
213
|
+
backgroundColor: "#595959"
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
...baseKnob,
|
|
218
|
+
backgroundColor: "#7e7e7e"
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
className: (0, import_clsx.clsx)("arbor-toggle-wrapper", className),
|
|
226
|
+
style: { ...wrapperStyles, ...style },
|
|
227
|
+
"data-testid": dataTestId,
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
|
+
"input",
|
|
231
|
+
{
|
|
232
|
+
ref,
|
|
233
|
+
id: toggleId,
|
|
234
|
+
type: "checkbox",
|
|
235
|
+
checked,
|
|
236
|
+
onChange: handleChange,
|
|
237
|
+
onFocus: () => setIsFocused(true),
|
|
238
|
+
onBlur: () => setIsFocused(false),
|
|
239
|
+
disabled,
|
|
240
|
+
name,
|
|
241
|
+
value,
|
|
242
|
+
style: {
|
|
243
|
+
position: "absolute",
|
|
244
|
+
opacity: 0,
|
|
245
|
+
width: 0,
|
|
246
|
+
height: 0
|
|
247
|
+
},
|
|
248
|
+
"aria-checked": checked
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
252
|
+
"label",
|
|
253
|
+
{
|
|
254
|
+
htmlFor: toggleId,
|
|
255
|
+
onMouseEnter: () => !disabled && setIsHovered(true),
|
|
256
|
+
onMouseLeave: () => !disabled && setIsHovered(false),
|
|
257
|
+
onMouseDown: () => !disabled && setIsActive(true),
|
|
258
|
+
onMouseUp: () => !disabled && setIsActive(false),
|
|
259
|
+
style: {
|
|
260
|
+
display: "flex",
|
|
261
|
+
alignItems: "center",
|
|
262
|
+
gap: "8px",
|
|
263
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
264
|
+
},
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: getContainerStyles(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: getKnobStyles() }) }),
|
|
267
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
268
|
+
"span",
|
|
269
|
+
{
|
|
270
|
+
style: {
|
|
271
|
+
...labelStyles,
|
|
272
|
+
color: disabled ? "#7e7e7e" : "#2f2f2f",
|
|
273
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
274
|
+
},
|
|
275
|
+
children: label
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
Toggle.displayName = "Toggle";
|
|
287
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
288
|
+
0 && (module.exports = {
|
|
289
|
+
Toggle
|
|
290
|
+
});
|
|
291
|
+
//# sourceMappingURL=Toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Toggle/index.ts","../src/Toggle/Toggle.tsx"],"sourcesContent":["export { Toggle } from './Toggle';\nexport type { ToggleProps } from './Toggle';\n","import * as React from 'react';\nimport { clsx } from 'clsx';\n\nexport interface ToggleProps {\n /**\n * The label for the toggle\n */\n label?: string;\n /**\n * Whether the toggle is on\n */\n checked?: boolean;\n /**\n * Callback when toggle state changes\n */\n onChange?: (checked: boolean) => void;\n /**\n * Whether the toggle 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 toggleContainerStyles: React.CSSProperties = {\n width: '40px',\n height: '24px',\n borderRadius: '16px',\n border: '1px solid',\n position: 'relative',\n cursor: 'pointer',\n transition: 'all 0.2s ease-in-out',\n};\n\nconst knobStyles: React.CSSProperties = {\n width: '18px',\n height: '18px',\n borderRadius: '50%',\n position: 'absolute',\n top: '50%',\n transform: 'translateY(-50%)',\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 * Toggle component - Arbor Design System\n *\n * A toggle switch input with label support.\n */\nexport const Toggle = React.forwardRef<HTMLInputElement, ToggleProps>(\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 [isHovered, setIsHovered] = React.useState(false);\n const [isActive, setIsActive] = React.useState(false);\n const toggleId = React.useId();\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!disabled) {\n onChange?.(e.target.checked);\n }\n };\n\n // Container styles based on state\n const getContainerStyles = (): React.CSSProperties => {\n if (disabled) {\n return {\n ...toggleContainerStyles,\n backgroundColor: checked ? '#d1d1d1' : '#ffffff',\n borderColor: checked ? '#d1d1d1' : '#d1d1d1',\n cursor: 'not-allowed',\n };\n }\n\n if (checked) {\n if (isActive && isFocused) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#024002',\n borderColor: '#024002',\n boxShadow: '0px 0px 0px 3px #3cad51',\n };\n }\n if (isActive) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#024002',\n borderColor: '#024002',\n };\n }\n if (isHovered) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#005700',\n borderColor: '#005700',\n };\n }\n if (isFocused) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#0b800b',\n borderColor: '#0b800b',\n boxShadow: '0px 0px 0px 3px #3cad51',\n };\n }\n return {\n ...toggleContainerStyles,\n backgroundColor: '#0b800b',\n borderColor: '#0b800b',\n };\n } else {\n if (isActive && isFocused) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#efefef',\n borderColor: '#2f2f2f',\n boxShadow: '0px 0px 0px 3px #3cad51',\n };\n }\n if (isActive) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#efefef',\n borderColor: '#2f2f2f',\n };\n }\n if (isHovered) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#f8f8f8',\n borderColor: '#595959',\n };\n }\n if (isFocused) {\n return {\n ...toggleContainerStyles,\n backgroundColor: '#ffffff',\n borderColor: '#7e7e7e',\n boxShadow: '0px 0px 0px 3px #3cad51',\n };\n }\n return {\n ...toggleContainerStyles,\n backgroundColor: '#ffffff',\n borderColor: '#7e7e7e',\n };\n }\n };\n\n // Knob styles based on state\n const getKnobStyles = (): React.CSSProperties => {\n const baseKnob = {\n ...knobStyles,\n left: checked ? '18px' : '2px',\n };\n\n if (disabled) {\n return {\n ...baseKnob,\n backgroundColor: checked ? '#f8f8f8' : '#d1d1d1',\n };\n }\n\n if (checked) {\n if (isActive) {\n return {\n ...baseKnob,\n backgroundColor: '#efefef',\n };\n }\n if (isHovered) {\n return {\n ...baseKnob,\n backgroundColor: '#f8f8f8',\n };\n }\n return {\n ...baseKnob,\n backgroundColor: '#ffffff',\n };\n } else {\n if (isActive) {\n return {\n ...baseKnob,\n backgroundColor: '#2f2f2f',\n };\n }\n if (isHovered) {\n return {\n ...baseKnob,\n backgroundColor: '#595959',\n };\n }\n return {\n ...baseKnob,\n backgroundColor: '#7e7e7e',\n };\n }\n };\n\n return (\n <div\n className={clsx('arbor-toggle-wrapper', className)}\n style={{ ...wrapperStyles, ...style }}\n data-testid={dataTestId}\n >\n <input\n ref={ref}\n id={toggleId}\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={toggleId}\n onMouseEnter={() => !disabled && setIsHovered(true)}\n onMouseLeave={() => !disabled && setIsHovered(false)}\n onMouseDown={() => !disabled && setIsActive(true)}\n onMouseUp={() => !disabled && setIsActive(false)}\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: '8px',\n cursor: disabled ? 'not-allowed' : 'pointer',\n }}\n >\n <div style={getContainerStyles()}>\n <div style={getKnobStyles()} />\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\nToggle.displayName = 'Toggle';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,kBAAqB;AAyPb;AAhNR,IAAM,wBAA6C;AAAA,EACjD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,YAAY;AACd;AAEA,IAAM,aAAkC;AAAA,EACtC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,UAAU;AAAA,EACV,KAAK;AAAA,EACL,WAAW;AAAA,EACX,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,SAAe;AAAA,EAC1B,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IAC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