analytica-frontend-lib 1.0.21 → 1.0.23
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/Alert/Alert.d.mts +13 -0
- package/dist/Alert/Alert.d.ts +13 -0
- package/dist/Alert/Alert.js +158 -0
- package/dist/Alert/Alert.mjs +85 -0
- package/dist/Badge/Badge.d.mts +47 -0
- package/dist/Badge/Badge.d.ts +47 -0
- package/dist/Badge/Badge.js +117 -0
- package/dist/Badge/Badge.mjs +92 -0
- package/dist/Button/Button.d.mts +46 -0
- package/dist/Button/Button.d.ts +46 -0
- package/dist/Button/Button.js +84 -0
- package/dist/Button/Button.mjs +59 -0
- package/dist/CheckBox/CheckBox.d.mts +74 -0
- package/dist/CheckBox/CheckBox.d.ts +74 -0
- package/dist/CheckBox/CheckBox.js +264 -0
- package/dist/CheckBox/CheckBox.mjs +195 -0
- package/dist/DropdownMenu/DropdownMenu.d.mts +29 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts +29 -0
- package/dist/DropdownMenu/DropdownMenu.js +262 -0
- package/dist/DropdownMenu/DropdownMenu.mjs +242 -0
- package/dist/IconButton/IconButton.d.mts +77 -0
- package/dist/IconButton/IconButton.d.ts +77 -0
- package/dist/IconButton/IconButton.js +79 -0
- package/dist/IconButton/IconButton.mjs +54 -0
- package/dist/IconRoundedButton/IconRoundedButton.d.mts +35 -0
- package/dist/IconRoundedButton/IconRoundedButton.d.ts +35 -0
- package/dist/IconRoundedButton/IconRoundedButton.js +68 -0
- package/dist/IconRoundedButton/IconRoundedButton.mjs +43 -0
- package/dist/NavButton/NavButton.d.mts +58 -0
- package/dist/NavButton/NavButton.d.ts +58 -0
- package/dist/NavButton/NavButton.js +76 -0
- package/dist/NavButton/NavButton.mjs +51 -0
- package/dist/SelectionButton/SelectionButton.d.mts +58 -0
- package/dist/SelectionButton/SelectionButton.d.ts +58 -0
- package/dist/SelectionButton/SelectionButton.js +81 -0
- package/dist/SelectionButton/SelectionButton.mjs +56 -0
- package/dist/Table/Table.d.mts +17 -0
- package/dist/Table/Table.d.ts +17 -0
- package/dist/Table/Table.js +139 -0
- package/dist/Table/Table.mjs +107 -0
- package/dist/Text/Text.d.mts +59 -0
- package/dist/Text/Text.d.ts +59 -0
- package/dist/Text/Text.js +77 -0
- package/dist/Text/Text.mjs +6 -0
- package/dist/TextArea/TextArea.d.mts +69 -0
- package/dist/TextArea/TextArea.d.ts +69 -0
- package/dist/TextArea/TextArea.js +211 -0
- package/dist/TextArea/TextArea.mjs +142 -0
- package/dist/Toast/Toast.d.mts +17 -0
- package/dist/Toast/Toast.d.ts +17 -0
- package/dist/Toast/Toast.js +100 -0
- package/dist/Toast/Toast.mjs +7 -0
- package/dist/Toast/utils/ToastStore.d.mts +19 -0
- package/dist/Toast/utils/ToastStore.d.ts +19 -0
- package/dist/Toast/utils/ToastStore.js +44 -0
- package/dist/Toast/utils/ToastStore.mjs +6 -0
- package/dist/Toast/utils/Toaster.d.mts +11 -0
- package/dist/Toast/utils/Toaster.d.ts +11 -0
- package/dist/Toast/utils/Toaster.js +145 -0
- package/dist/Toast/utils/Toaster.mjs +35 -0
- package/dist/chunk-MI5FIRHM.mjs +75 -0
- package/dist/chunk-TT3VCQGR.mjs +53 -0
- package/dist/chunk-WIOCQOM7.mjs +20 -0
- package/dist/index.css +103 -0
- package/dist/index.d.mts +68 -2
- package/dist/index.d.ts +68 -2
- package/dist/index.js +217 -84
- package/dist/index.mjs +215 -79
- package/package.json +71 -3
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/Button/Button.tsx
|
|
21
|
+
var Button_exports = {};
|
|
22
|
+
__export(Button_exports, {
|
|
23
|
+
Button: () => Button
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Button_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var VARIANT_ACTION_CLASSES = {
|
|
28
|
+
solid: {
|
|
29
|
+
primary: "bg-primary-950 text-text border border-primary-950 hover:bg-primary-800 hover:border-primary-800 focus-visible:outline-none focus-visible:bg-primary-950 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-primary-700 active:border-primary-700 disabled:bg-primary-500 disabled:border-primary-500 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
30
|
+
positive: "bg-success-500 text-text border border-success-500 hover:bg-success-600 hover:border-success-600 focus-visible:outline-none focus-visible:bg-success-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-success-700 active:border-success-700 disabled:bg-success-500 disabled:border-success-500 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
31
|
+
negative: "bg-error-500 text-text border border-error-500 hover:bg-error-600 hover:border-error-600 focus-visible:outline-none focus-visible:bg-error-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-error-700 active:border-error-700 disabled:bg-error-500 disabled:border-error-500 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
32
|
+
},
|
|
33
|
+
outline: {
|
|
34
|
+
primary: "bg-transparent text-primary-950 border border-primary-950 hover:bg-background-50 hover:text-primary-400 hover:border-primary-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 active:border-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
35
|
+
positive: "bg-transparent text-success-500 border border-success-300 hover:bg-background-50 hover:text-success-400 hover:border-success-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 active:border-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
36
|
+
negative: "bg-transparent text-error-500 border border-error-300 hover:bg-background-50 hover:text-error-400 hover:border-error-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 active:border-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
37
|
+
},
|
|
38
|
+
link: {
|
|
39
|
+
primary: "bg-transparent text-primary-950 hover:text-primary-400 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
40
|
+
positive: "bg-transparent text-success-500 hover:text-success-400 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
41
|
+
negative: "bg-transparent text-error-500 hover:text-error-400 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var SIZE_CLASSES = {
|
|
45
|
+
"extra-small": "text-xs px-3.5 py-2",
|
|
46
|
+
small: "text-sm px-4 py-2.5",
|
|
47
|
+
medium: "text-md px-5 py-2.5",
|
|
48
|
+
large: "text-lg px-6 py-3",
|
|
49
|
+
"extra-large": "text-lg px-7 py-3.5"
|
|
50
|
+
};
|
|
51
|
+
var Button = ({
|
|
52
|
+
children,
|
|
53
|
+
iconLeft,
|
|
54
|
+
iconRight,
|
|
55
|
+
size = "medium",
|
|
56
|
+
variant = "solid",
|
|
57
|
+
action = "primary",
|
|
58
|
+
className = "",
|
|
59
|
+
disabled,
|
|
60
|
+
type = "button",
|
|
61
|
+
...props
|
|
62
|
+
}) => {
|
|
63
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
64
|
+
const variantClasses = VARIANT_ACTION_CLASSES[variant][action];
|
|
65
|
+
const baseClasses = "inline-flex items-center justify-center rounded-full cursor-pointer font-medium";
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
67
|
+
"button",
|
|
68
|
+
{
|
|
69
|
+
className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
|
|
70
|
+
disabled,
|
|
71
|
+
type,
|
|
72
|
+
...props,
|
|
73
|
+
children: [
|
|
74
|
+
iconLeft && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mr-2 flex items-center", children: iconLeft }),
|
|
75
|
+
children,
|
|
76
|
+
iconRight && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ml-2 flex items-center", children: iconRight })
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
Button
|
|
84
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/components/Button/Button.tsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
var VARIANT_ACTION_CLASSES = {
|
|
4
|
+
solid: {
|
|
5
|
+
primary: "bg-primary-950 text-text border border-primary-950 hover:bg-primary-800 hover:border-primary-800 focus-visible:outline-none focus-visible:bg-primary-950 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-primary-700 active:border-primary-700 disabled:bg-primary-500 disabled:border-primary-500 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
6
|
+
positive: "bg-success-500 text-text border border-success-500 hover:bg-success-600 hover:border-success-600 focus-visible:outline-none focus-visible:bg-success-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-success-700 active:border-success-700 disabled:bg-success-500 disabled:border-success-500 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
7
|
+
negative: "bg-error-500 text-text border border-error-500 hover:bg-error-600 hover:border-error-600 focus-visible:outline-none focus-visible:bg-error-500 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:bg-error-700 active:border-error-700 disabled:bg-error-500 disabled:border-error-500 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
8
|
+
},
|
|
9
|
+
outline: {
|
|
10
|
+
primary: "bg-transparent text-primary-950 border border-primary-950 hover:bg-background-50 hover:text-primary-400 hover:border-primary-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 active:border-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
11
|
+
positive: "bg-transparent text-success-500 border border-success-300 hover:bg-background-50 hover:text-success-400 hover:border-success-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 active:border-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
12
|
+
negative: "bg-transparent text-error-500 border border-error-300 hover:bg-background-50 hover:text-error-400 hover:border-error-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 active:border-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
13
|
+
},
|
|
14
|
+
link: {
|
|
15
|
+
primary: "bg-transparent text-primary-950 hover:text-primary-400 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
16
|
+
positive: "bg-transparent text-success-500 hover:text-success-400 focus-visible:outline-none focus-visible:text-success-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-success-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
17
|
+
negative: "bg-transparent text-error-500 hover:text-error-400 focus-visible:outline-none focus-visible:text-error-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-error-700 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var SIZE_CLASSES = {
|
|
21
|
+
"extra-small": "text-xs px-3.5 py-2",
|
|
22
|
+
small: "text-sm px-4 py-2.5",
|
|
23
|
+
medium: "text-md px-5 py-2.5",
|
|
24
|
+
large: "text-lg px-6 py-3",
|
|
25
|
+
"extra-large": "text-lg px-7 py-3.5"
|
|
26
|
+
};
|
|
27
|
+
var Button = ({
|
|
28
|
+
children,
|
|
29
|
+
iconLeft,
|
|
30
|
+
iconRight,
|
|
31
|
+
size = "medium",
|
|
32
|
+
variant = "solid",
|
|
33
|
+
action = "primary",
|
|
34
|
+
className = "",
|
|
35
|
+
disabled,
|
|
36
|
+
type = "button",
|
|
37
|
+
...props
|
|
38
|
+
}) => {
|
|
39
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
40
|
+
const variantClasses = VARIANT_ACTION_CLASSES[variant][action];
|
|
41
|
+
const baseClasses = "inline-flex items-center justify-center rounded-full cursor-pointer font-medium";
|
|
42
|
+
return /* @__PURE__ */ jsxs(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
|
|
46
|
+
disabled,
|
|
47
|
+
type,
|
|
48
|
+
...props,
|
|
49
|
+
children: [
|
|
50
|
+
iconLeft && /* @__PURE__ */ jsx("span", { className: "mr-2 flex items-center", children: iconLeft }),
|
|
51
|
+
children,
|
|
52
|
+
iconRight && /* @__PURE__ */ jsx("span", { className: "ml-2 flex items-center", children: iconRight })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
Button
|
|
59
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, InputHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CheckBox size variants
|
|
6
|
+
*/
|
|
7
|
+
type CheckBoxSize = 'small' | 'medium' | 'large';
|
|
8
|
+
/**
|
|
9
|
+
* CheckBox visual state
|
|
10
|
+
*/
|
|
11
|
+
type CheckBoxState = 'default' | 'hovered' | 'focused' | 'invalid' | 'disabled';
|
|
12
|
+
/**
|
|
13
|
+
* CheckBox component props interface
|
|
14
|
+
*/
|
|
15
|
+
type CheckBoxProps = {
|
|
16
|
+
/** Label text to display next to the checkbox */
|
|
17
|
+
label?: ReactNode;
|
|
18
|
+
/** Size variant of the checkbox */
|
|
19
|
+
size?: CheckBoxSize;
|
|
20
|
+
/** Visual state of the checkbox */
|
|
21
|
+
state?: CheckBoxState;
|
|
22
|
+
/** Indeterminate state for partial selections */
|
|
23
|
+
indeterminate?: boolean;
|
|
24
|
+
/** Error message to display */
|
|
25
|
+
errorMessage?: string;
|
|
26
|
+
/** Helper text to display */
|
|
27
|
+
helperText?: string;
|
|
28
|
+
/** Additional CSS classes */
|
|
29
|
+
className?: string;
|
|
30
|
+
/** Label CSS classes */
|
|
31
|
+
labelClassName?: string;
|
|
32
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'>;
|
|
33
|
+
/**
|
|
34
|
+
* CheckBox component for Analytica Ensino platforms
|
|
35
|
+
*
|
|
36
|
+
* A checkbox component with essential states, sizes and themes.
|
|
37
|
+
* Uses the Analytica Ensino Design System colors from styles.css with automatic
|
|
38
|
+
* light/dark mode support. Includes Text component integration for consistent typography.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Basic checkbox
|
|
43
|
+
* <CheckBox label="Option" />
|
|
44
|
+
*
|
|
45
|
+
* // Small size
|
|
46
|
+
* <CheckBox size="small" label="Small option" />
|
|
47
|
+
*
|
|
48
|
+
* // Invalid state
|
|
49
|
+
* <CheckBox state="invalid" label="Required field" />
|
|
50
|
+
*
|
|
51
|
+
* // Disabled state
|
|
52
|
+
* <CheckBox disabled label="Disabled option" />
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare const CheckBox: react.ForwardRefExoticComponent<{
|
|
56
|
+
/** Label text to display next to the checkbox */
|
|
57
|
+
label?: ReactNode;
|
|
58
|
+
/** Size variant of the checkbox */
|
|
59
|
+
size?: CheckBoxSize;
|
|
60
|
+
/** Visual state of the checkbox */
|
|
61
|
+
state?: CheckBoxState;
|
|
62
|
+
/** Indeterminate state for partial selections */
|
|
63
|
+
indeterminate?: boolean;
|
|
64
|
+
/** Error message to display */
|
|
65
|
+
errorMessage?: string;
|
|
66
|
+
/** Helper text to display */
|
|
67
|
+
helperText?: string;
|
|
68
|
+
/** Additional CSS classes */
|
|
69
|
+
className?: string;
|
|
70
|
+
/** Label CSS classes */
|
|
71
|
+
labelClassName?: string;
|
|
72
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & react.RefAttributes<HTMLInputElement>>;
|
|
73
|
+
|
|
74
|
+
export { CheckBox, type CheckBoxProps };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, InputHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CheckBox size variants
|
|
6
|
+
*/
|
|
7
|
+
type CheckBoxSize = 'small' | 'medium' | 'large';
|
|
8
|
+
/**
|
|
9
|
+
* CheckBox visual state
|
|
10
|
+
*/
|
|
11
|
+
type CheckBoxState = 'default' | 'hovered' | 'focused' | 'invalid' | 'disabled';
|
|
12
|
+
/**
|
|
13
|
+
* CheckBox component props interface
|
|
14
|
+
*/
|
|
15
|
+
type CheckBoxProps = {
|
|
16
|
+
/** Label text to display next to the checkbox */
|
|
17
|
+
label?: ReactNode;
|
|
18
|
+
/** Size variant of the checkbox */
|
|
19
|
+
size?: CheckBoxSize;
|
|
20
|
+
/** Visual state of the checkbox */
|
|
21
|
+
state?: CheckBoxState;
|
|
22
|
+
/** Indeterminate state for partial selections */
|
|
23
|
+
indeterminate?: boolean;
|
|
24
|
+
/** Error message to display */
|
|
25
|
+
errorMessage?: string;
|
|
26
|
+
/** Helper text to display */
|
|
27
|
+
helperText?: string;
|
|
28
|
+
/** Additional CSS classes */
|
|
29
|
+
className?: string;
|
|
30
|
+
/** Label CSS classes */
|
|
31
|
+
labelClassName?: string;
|
|
32
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'>;
|
|
33
|
+
/**
|
|
34
|
+
* CheckBox component for Analytica Ensino platforms
|
|
35
|
+
*
|
|
36
|
+
* A checkbox component with essential states, sizes and themes.
|
|
37
|
+
* Uses the Analytica Ensino Design System colors from styles.css with automatic
|
|
38
|
+
* light/dark mode support. Includes Text component integration for consistent typography.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Basic checkbox
|
|
43
|
+
* <CheckBox label="Option" />
|
|
44
|
+
*
|
|
45
|
+
* // Small size
|
|
46
|
+
* <CheckBox size="small" label="Small option" />
|
|
47
|
+
*
|
|
48
|
+
* // Invalid state
|
|
49
|
+
* <CheckBox state="invalid" label="Required field" />
|
|
50
|
+
*
|
|
51
|
+
* // Disabled state
|
|
52
|
+
* <CheckBox disabled label="Disabled option" />
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare const CheckBox: react.ForwardRefExoticComponent<{
|
|
56
|
+
/** Label text to display next to the checkbox */
|
|
57
|
+
label?: ReactNode;
|
|
58
|
+
/** Size variant of the checkbox */
|
|
59
|
+
size?: CheckBoxSize;
|
|
60
|
+
/** Visual state of the checkbox */
|
|
61
|
+
state?: CheckBoxState;
|
|
62
|
+
/** Indeterminate state for partial selections */
|
|
63
|
+
indeterminate?: boolean;
|
|
64
|
+
/** Error message to display */
|
|
65
|
+
errorMessage?: string;
|
|
66
|
+
/** Helper text to display */
|
|
67
|
+
helperText?: string;
|
|
68
|
+
/** Additional CSS classes */
|
|
69
|
+
className?: string;
|
|
70
|
+
/** Label CSS classes */
|
|
71
|
+
labelClassName?: string;
|
|
72
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & react.RefAttributes<HTMLInputElement>>;
|
|
73
|
+
|
|
74
|
+
export { CheckBox, type CheckBoxProps };
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/CheckBox/CheckBox.tsx
|
|
22
|
+
var CheckBox_exports = {};
|
|
23
|
+
__export(CheckBox_exports, {
|
|
24
|
+
CheckBox: () => CheckBox
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(CheckBox_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
|
|
29
|
+
// src/components/Text/Text.tsx
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var Text = ({
|
|
32
|
+
children,
|
|
33
|
+
size = "md",
|
|
34
|
+
weight = "normal",
|
|
35
|
+
color = "text-text-950",
|
|
36
|
+
as,
|
|
37
|
+
className = "",
|
|
38
|
+
...props
|
|
39
|
+
}) => {
|
|
40
|
+
let sizeClasses = "";
|
|
41
|
+
let weightClasses = "";
|
|
42
|
+
const sizeClassMap = {
|
|
43
|
+
"2xs": "text-2xs",
|
|
44
|
+
xs: "text-xs",
|
|
45
|
+
sm: "text-sm",
|
|
46
|
+
md: "text-md",
|
|
47
|
+
lg: "text-lg",
|
|
48
|
+
xl: "text-xl",
|
|
49
|
+
"2xl": "text-2xl",
|
|
50
|
+
"3xl": "text-3xl",
|
|
51
|
+
"4xl": "text-4xl",
|
|
52
|
+
"5xl": "text-5xl",
|
|
53
|
+
"6xl": "text-6xl"
|
|
54
|
+
};
|
|
55
|
+
sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
|
|
56
|
+
const weightClassMap = {
|
|
57
|
+
hairline: "font-hairline",
|
|
58
|
+
light: "font-light",
|
|
59
|
+
normal: "font-normal",
|
|
60
|
+
medium: "font-medium",
|
|
61
|
+
semibold: "font-semibold",
|
|
62
|
+
bold: "font-bold",
|
|
63
|
+
extrabold: "font-extrabold",
|
|
64
|
+
black: "font-black"
|
|
65
|
+
};
|
|
66
|
+
weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
|
|
67
|
+
const baseClasses = "font-primary";
|
|
68
|
+
const Component = as ?? "p";
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
70
|
+
Component,
|
|
71
|
+
{
|
|
72
|
+
className: `${baseClasses} ${sizeClasses} ${weightClasses} ${color} ${className}`,
|
|
73
|
+
...props,
|
|
74
|
+
children
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/components/CheckBox/CheckBox.tsx
|
|
80
|
+
var import_phosphor_react = require("phosphor-react");
|
|
81
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
82
|
+
var SIZE_CLASSES = {
|
|
83
|
+
small: {
|
|
84
|
+
checkbox: "w-4 h-4",
|
|
85
|
+
// 16px x 16px
|
|
86
|
+
textSize: "sm",
|
|
87
|
+
spacing: "gap-1.5",
|
|
88
|
+
// 6px
|
|
89
|
+
borderWidth: "border-2",
|
|
90
|
+
iconSize: 14,
|
|
91
|
+
// pixels for Phosphor icons
|
|
92
|
+
labelHeight: "h-[21px]"
|
|
93
|
+
},
|
|
94
|
+
medium: {
|
|
95
|
+
checkbox: "w-5 h-5",
|
|
96
|
+
// 20px x 20px
|
|
97
|
+
textSize: "md",
|
|
98
|
+
spacing: "gap-2",
|
|
99
|
+
// 8px
|
|
100
|
+
borderWidth: "border-2",
|
|
101
|
+
iconSize: 16,
|
|
102
|
+
// pixels for Phosphor icons
|
|
103
|
+
labelHeight: "h-6"
|
|
104
|
+
},
|
|
105
|
+
large: {
|
|
106
|
+
checkbox: "w-6 h-6",
|
|
107
|
+
// 24px x 24px
|
|
108
|
+
textSize: "lg",
|
|
109
|
+
spacing: "gap-2",
|
|
110
|
+
// 8px
|
|
111
|
+
borderWidth: "border-[3px]",
|
|
112
|
+
// 3px border
|
|
113
|
+
iconSize: 20,
|
|
114
|
+
// pixels for Phosphor icons
|
|
115
|
+
labelHeight: "h-[27px]"
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var BASE_CHECKBOX_CLASSES = "rounded border cursor-pointer transition-all duration-200 flex items-center justify-center focus:outline-none";
|
|
119
|
+
var STATE_CLASSES = {
|
|
120
|
+
default: {
|
|
121
|
+
unchecked: "border-border-400 bg-background hover:border-border-500",
|
|
122
|
+
checked: "border-primary-950 bg-primary-950 text-text hover:border-primary-800 hover:bg-primary-800"
|
|
123
|
+
},
|
|
124
|
+
hovered: {
|
|
125
|
+
unchecked: "border-border-500 bg-background",
|
|
126
|
+
checked: "border-primary-800 bg-primary-800 text-text"
|
|
127
|
+
},
|
|
128
|
+
focused: {
|
|
129
|
+
unchecked: "border-indicator-info bg-background ring-2 ring-indicator-info/20",
|
|
130
|
+
checked: "border-indicator-info bg-primary-950 text-text ring-2 ring-indicator-info/20"
|
|
131
|
+
},
|
|
132
|
+
invalid: {
|
|
133
|
+
unchecked: "border-error-700 bg-background hover:border-error-600",
|
|
134
|
+
checked: "border-error-700 bg-primary-950 text-text"
|
|
135
|
+
},
|
|
136
|
+
disabled: {
|
|
137
|
+
unchecked: "border-border-400 bg-background cursor-not-allowed opacity-40",
|
|
138
|
+
checked: "border-primary-600 bg-primary-600 text-text cursor-not-allowed opacity-40"
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var CheckBox = (0, import_react.forwardRef)(
|
|
142
|
+
({
|
|
143
|
+
label,
|
|
144
|
+
size = "medium",
|
|
145
|
+
state = "default",
|
|
146
|
+
indeterminate = false,
|
|
147
|
+
errorMessage,
|
|
148
|
+
helperText,
|
|
149
|
+
className = "",
|
|
150
|
+
labelClassName = "",
|
|
151
|
+
checked: checkedProp,
|
|
152
|
+
disabled,
|
|
153
|
+
id,
|
|
154
|
+
onChange,
|
|
155
|
+
...props
|
|
156
|
+
}, ref) => {
|
|
157
|
+
const generatedId = (0, import_react.useId)();
|
|
158
|
+
const inputId = id ?? `checkbox-${generatedId}`;
|
|
159
|
+
const [internalChecked, setInternalChecked] = (0, import_react.useState)(false);
|
|
160
|
+
const isControlled = checkedProp !== void 0;
|
|
161
|
+
const checked = isControlled ? checkedProp : internalChecked;
|
|
162
|
+
const handleChange = (event) => {
|
|
163
|
+
if (!isControlled) {
|
|
164
|
+
setInternalChecked(event.target.checked);
|
|
165
|
+
}
|
|
166
|
+
onChange?.(event);
|
|
167
|
+
};
|
|
168
|
+
const currentState = disabled ? "disabled" : state;
|
|
169
|
+
const sizeClasses = SIZE_CLASSES[size];
|
|
170
|
+
const checkVariant = checked || indeterminate ? "checked" : "unchecked";
|
|
171
|
+
const stylingClasses = STATE_CLASSES[currentState][checkVariant];
|
|
172
|
+
const borderWidthClass = state === "focused" || state === "hovered" && size === "large" ? "border-[3px]" : sizeClasses.borderWidth;
|
|
173
|
+
const checkboxClasses = `${BASE_CHECKBOX_CLASSES} ${sizeClasses.checkbox} ${borderWidthClass} ${stylingClasses} ${className}`;
|
|
174
|
+
const renderIcon = () => {
|
|
175
|
+
if (indeterminate) {
|
|
176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
177
|
+
import_phosphor_react.Minus,
|
|
178
|
+
{
|
|
179
|
+
size: sizeClasses.iconSize,
|
|
180
|
+
weight: "bold",
|
|
181
|
+
color: "currentColor"
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
if (checked) {
|
|
186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
187
|
+
import_phosphor_react.Check,
|
|
188
|
+
{
|
|
189
|
+
size: sizeClasses.iconSize,
|
|
190
|
+
weight: "bold",
|
|
191
|
+
color: "currentColor"
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
};
|
|
197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col", children: [
|
|
198
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
199
|
+
"div",
|
|
200
|
+
{
|
|
201
|
+
className: `flex flex-row items-center ${sizeClasses.spacing} ${disabled ? "opacity-40" : ""}`,
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
204
|
+
"input",
|
|
205
|
+
{
|
|
206
|
+
ref,
|
|
207
|
+
type: "checkbox",
|
|
208
|
+
id: inputId,
|
|
209
|
+
checked,
|
|
210
|
+
disabled,
|
|
211
|
+
onChange: handleChange,
|
|
212
|
+
className: "sr-only",
|
|
213
|
+
...props
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: inputId, className: checkboxClasses, children: renderIcon() }),
|
|
217
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
|
|
221
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
222
|
+
Text,
|
|
223
|
+
{
|
|
224
|
+
as: "label",
|
|
225
|
+
htmlFor: inputId,
|
|
226
|
+
size: sizeClasses.textSize,
|
|
227
|
+
weight: "normal",
|
|
228
|
+
className: `cursor-pointer select-none leading-[150%] flex items-center font-roboto ${labelClassName}`,
|
|
229
|
+
children: label
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
238
|
+
Text,
|
|
239
|
+
{
|
|
240
|
+
size: "sm",
|
|
241
|
+
weight: "normal",
|
|
242
|
+
className: "mt-1.5",
|
|
243
|
+
color: "text-error-600",
|
|
244
|
+
children: errorMessage
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
helperText && !errorMessage && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
248
|
+
Text,
|
|
249
|
+
{
|
|
250
|
+
size: "sm",
|
|
251
|
+
weight: "normal",
|
|
252
|
+
className: "mt-1.5",
|
|
253
|
+
color: "text-text-500",
|
|
254
|
+
children: helperText
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
] });
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
CheckBox.displayName = "CheckBox";
|
|
261
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
262
|
+
0 && (module.exports = {
|
|
263
|
+
CheckBox
|
|
264
|
+
});
|