flikkui 0.1.0-beta.2 → 0.1.0-beta.4
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/README.md +155 -0
- package/dist/components/charts/index.d.ts +2 -0
- package/dist/components/charts/shared/ChartLegend/ChartLegend.d.ts +7 -0
- package/dist/components/charts/shared/ChartLegend/ChartLegendContent.d.ts +7 -0
- package/dist/components/charts/shared/ChartLegend/index.d.ts +2 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.animations.d.ts +1 -1
- package/dist/components/core/AvatarGroup/AvatarGroup.theme.d.ts +1 -0
- package/dist/components/core/Breadcrumbs/Breadcrumbs.js +8 -7
- package/dist/components/core/Button/Button.animations.d.ts +0 -12
- package/dist/components/core/Button/Button.animations.js +4 -19
- package/dist/components/core/Button/Button.js +40 -37
- package/dist/components/core/Button/Button.theme.d.ts +0 -4
- package/dist/components/core/Button/Button.theme.js +14 -9
- package/dist/components/core/Button/Button.types.d.ts +1 -1
- package/dist/components/core/Divider/Divider.types.d.ts +8 -2
- package/dist/components/core/Drawer/Drawer.types.d.ts +1 -1
- package/dist/components/core/Modal/Modal.types.d.ts +1 -1
- package/dist/components/core/Pagination/Pagination.types.d.ts +25 -13
- package/dist/components/core/Popover/Popover.animations.d.ts +34 -3
- package/dist/components/core/Popover/Popover.animations.js +19 -0
- package/dist/components/core/Popover/Popover.theme.js +2 -2
- package/dist/components/core/Popover/PopoverContent.js +5 -14
- package/dist/components/core/Segmented/Segmented.types.d.ts +17 -0
- package/dist/components/core/Tabs/Tabs.js +2 -8
- package/dist/components/core/Tabs/Tabs.theme.d.ts +8 -45
- package/dist/components/core/Tabs/Tabs.theme.js +14 -64
- package/dist/components/core/Tabs/Tabs.types.d.ts +4 -36
- package/dist/components/core/Tabs/TabsContent.js +3 -8
- package/dist/components/core/Tabs/TabsList.js +3 -10
- package/dist/components/core/Tabs/TabsTrigger.js +3 -15
- package/dist/components/core/Tabs/index.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.animations.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.theme.d.ts +0 -1
- package/dist/components/core/Tooltip/Tooltip.types.d.ts +15 -15
- package/dist/components/core/Tooltip/useTooltipPositioning.d.ts +12 -0
- package/dist/components/core/Tree/Tree.types.d.ts +8 -45
- package/dist/components/core/Tree/index.d.ts +1 -3
- package/dist/components/data-display/Table/Table.animations.d.ts +21 -0
- package/dist/components/data-display/Table/Table.types.d.ts +56 -13
- package/dist/components/data-display/Table/components/TableActionsMenu.d.ts +1 -1
- package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.theme.d.ts +16 -0
- package/dist/components/data-display/Table/components/TablePagination/TablePagination.d.ts +17 -0
- package/dist/components/data-display/Table/components/TablePagination/TablePagination.types.d.ts +21 -0
- package/dist/components/data-display/Table/components/TablePagination/index.d.ts +2 -0
- package/dist/components/data-display/Table/index.d.ts +6 -3
- package/dist/components/feedback/Alert/Alert.types.d.ts +4 -0
- package/dist/components/feedback/ChatMessage/ChatMessage.types.d.ts +20 -14
- package/dist/components/feedback/Empty/Empty.theme.d.ts +4 -14
- package/dist/components/feedback/Empty/Empty.types.d.ts +8 -20
- package/dist/components/feedback/Empty/index.d.ts +2 -2
- package/dist/components/feedback/Notification/Notification.theme.d.ts +16 -1
- package/dist/components/feedback/Notification/Notification.types.d.ts +18 -40
- package/dist/components/feedback/Notification/index.d.ts +2 -2
- package/dist/components/feedback/Toast/Toast.animations.d.ts +31 -0
- package/dist/components/feedback/Toast/Toast.types.d.ts +1 -1
- package/dist/components/feedback/index.d.ts +3 -3
- package/dist/components/forms/Checkbox/Checkbox.js +10 -16
- package/dist/components/forms/Checkbox/Checkbox.theme.js +8 -6
- package/dist/components/forms/Checkbox/Checkbox.types.d.ts +13 -30
- package/dist/components/forms/FormLabel/FormLabel.d.ts +1 -2
- package/dist/components/forms/FormLabel/FormLabel.js +7 -14
- package/dist/components/forms/FormLabel/FormLabel.theme.d.ts +3 -4
- package/dist/components/forms/FormLabel/FormLabel.theme.js +6 -6
- package/dist/components/forms/FormLabel/FormLabel.types.d.ts +10 -18
- package/dist/components/forms/FormLabel/index.d.ts +3 -3
- package/dist/components/forms/Input/Input.d.ts +0 -1
- package/dist/components/forms/Input/Input.js +51 -85
- package/dist/components/forms/Input/Input.theme.d.ts +4 -4
- package/dist/components/forms/Input/Input.theme.js +26 -26
- package/dist/components/forms/Input/Input.types.d.ts +41 -64
- package/dist/components/forms/Input/index.d.ts +1 -1
- package/dist/components/forms/InputAddress/InputAddress.theme.d.ts +2 -2
- package/dist/components/forms/InputAddress/InputAddress.types.d.ts +3 -3
- package/dist/components/forms/InputCreditCard/InputCreditCard.theme.d.ts +3 -3
- package/dist/components/forms/InputCreditCard/InputCreditCard.types.d.ts +4 -4
- package/dist/components/forms/Radio/Radio.js +12 -18
- package/dist/components/forms/Radio/Radio.theme.d.ts +2 -18
- package/dist/components/forms/Radio/Radio.theme.js +10 -19
- package/dist/components/forms/Radio/Radio.types.d.ts +16 -32
- package/dist/components/forms/Select/Select.js +1 -9
- package/dist/components/forms/Signature/Signature.js +5 -4
- package/dist/components/forms/Signature/Signature.theme.js +1 -3
- package/dist/components/forms/Signature/Signature.types.d.ts +0 -4
- package/dist/components/layout/DragDrop/DragDrop.js +62 -0
- package/dist/components/layout/DragDrop/DragDrop.theme.js +8 -0
- package/dist/components/layout/Sortable/Sortable.animations.js +81 -0
- package/dist/components/layout/Sortable/Sortable.js +165 -0
- package/dist/components/layout/Sortable/Sortable.theme.js +7 -0
- package/dist/components/navigation/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/Bars3Icon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/LockClosedIcon.js +28 -0
- package/dist/styles.css +1 -1
- package/dist/utils/debounce.d.ts +9 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +4 -4
- package/dist/components/core/Popover/test-popover.d.ts +0 -3
- package/dist/components/core/Tabs/test-tabs.d.ts +0 -3
- package/dist/components/core/Tree/TreeIcon.d.ts +0 -3
- package/dist/components/core/Tree/TreeNode.d.ts +0 -6
- package/dist/components/forms/Input/Input.AdvancedStories.d.ts +0 -13
- package/dist/node_modules/framer-motion/dist/es/animation/hooks/animation-controls.js +0 -80
- package/dist/node_modules/framer-motion/dist/es/animation/hooks/use-animation.js +0 -41
|
@@ -3,9 +3,9 @@ export type { AlertProps, AlertTheme, AlertThemeOverrides } from './Alert';
|
|
|
3
3
|
export { Toast, ToastProvider, useToast, useToastContext } from './Toast';
|
|
4
4
|
export type { ToastProps, ToastData, ToastProviderProps, ToastTheme, ToastThemeOverrides, UseToastReturn, UseToastOptions, } from './Toast';
|
|
5
5
|
export { Notification } from './Notification';
|
|
6
|
-
export type { NotificationProps,
|
|
7
|
-
export { Spinner } from './Spinner';
|
|
6
|
+
export type { NotificationProps, NotificationVariant, NotificationTheme } from './Notification';
|
|
7
|
+
export { default as Spinner } from './Spinner';
|
|
8
8
|
export { ChatMessage } from './ChatMessage';
|
|
9
9
|
export type { ChatMessageProps, ChatMessageVariant, ChatMessageAvatarProps, ChatMessageTheme, ChatMessageThemeOverrides } from './ChatMessage';
|
|
10
10
|
export { default as Empty } from './Empty';
|
|
11
|
-
export type { EmptyProps,
|
|
11
|
+
export type { EmptyProps, EmptyTheme } from './Empty';
|
|
@@ -10,8 +10,8 @@ import ForwardRef$1 from '../../../node_modules/@heroicons/react/24/outline/esm/
|
|
|
10
10
|
* Checkbox component for selecting one or more options
|
|
11
11
|
*/
|
|
12
12
|
var Checkbox = function (_a) {
|
|
13
|
-
var id = _a.id, name = _a.name, value = _a.value, controlledChecked = _a.checked, _b = _a.indeterminate, indeterminate = _b === void 0 ? false : _b, onChange = _a.onChange, label = _a.label, description = _a.description, _c = _a.state, state = _c === void 0 ? "default" : _c,
|
|
14
|
-
var
|
|
13
|
+
var id = _a.id, name = _a.name, value = _a.value, controlledChecked = _a.checked, _b = _a.indeterminate, indeterminate = _b === void 0 ? false : _b, onChange = _a.onChange, label = _a.label, description = _a.description, _c = _a.state, state = _c === void 0 ? "default" : _c, _d = _a.size, size = _d === void 0 ? "md" : _d, className = _a.className, restProps = __rest(_a, ["id", "name", "value", "checked", "indeterminate", "onChange", "label", "description", "state", "size", "className"]);
|
|
14
|
+
var _e = useState(false), internalChecked = _e[0], setInternalChecked = _e[1];
|
|
15
15
|
var inputRef = useRef(null);
|
|
16
16
|
// Determine if component is controlled or uncontrolled
|
|
17
17
|
var isControlled = controlledChecked !== undefined;
|
|
@@ -24,7 +24,6 @@ var Checkbox = function (_a) {
|
|
|
24
24
|
}, [indeterminate]);
|
|
25
25
|
// Derive state flags
|
|
26
26
|
var isDisabled = state === "disabled";
|
|
27
|
-
var isInvalid = state === "invalid";
|
|
28
27
|
var handleChange = function (e) {
|
|
29
28
|
if (isDisabled)
|
|
30
29
|
return;
|
|
@@ -33,19 +32,14 @@ var Checkbox = function (_a) {
|
|
|
33
32
|
}
|
|
34
33
|
onChange === null || onChange === void 0 ? void 0 : onChange(e.target.checked, value);
|
|
35
34
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? "
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
React__default.createElement("input", { ref: inputRef, type: "checkbox", id: id, name: name, value: value, checked: isChecked, onChange: handleChange, disabled: isDisabled, "aria-describedby": description ? "".concat(id, "-description") : undefined, "aria-invalid": isInvalid, className: cn(checkboxTheme.input, themeOverrides === null || themeOverrides === void 0 ? void 0 : themeOverrides.input) }),
|
|
45
|
-
(isChecked || indeterminate) && (indeterminate ? (React__default.createElement(ForwardRef, { className: cn(checkboxTheme.checkmark, themeOverrides === null || themeOverrides === void 0 ? void 0 : themeOverrides.checkmark), strokeWidth: 3 })) : isDisabled ? (React__default.createElement(ForwardRef, { className: cn(checkboxTheme.checkmark, themeOverrides === null || themeOverrides === void 0 ? void 0 : themeOverrides.checkmark), strokeWidth: 3 })) : (React__default.createElement(ForwardRef$1, { className: cn(checkboxTheme.checkmark, themeOverrides === null || themeOverrides === void 0 ? void 0 : themeOverrides.checkmark), strokeWidth: 3 })))),
|
|
46
|
-
(label || description) && (React__default.createElement("div", { className: cn(checkboxTheme.labelContainer, themeOverrides === null || themeOverrides === void 0 ? void 0 : themeOverrides.labelContainer) },
|
|
47
|
-
label && React__default.createElement(FormLabel, { htmlFor: id, className: "!mb-0", state: state }, label),
|
|
48
|
-
description && (React__default.createElement("div", { id: "".concat(id, "-description"), className: cn(checkboxTheme.description, themeOverrides === null || themeOverrides === void 0 ? void 0 : themeOverrides.description) }, description))))));
|
|
35
|
+
return (React__default.createElement("div", __assign({ className: cn(checkboxTheme.baseStyle, className) }, restProps),
|
|
36
|
+
React__default.createElement("div", { className: cn(checkboxTheme.inputContainerStyle, checkboxTheme.sizes[size]) },
|
|
37
|
+
React__default.createElement("input", { ref: inputRef, type: "checkbox", id: id, name: name, value: value, checked: isChecked, onChange: handleChange, disabled: isDisabled, "aria-describedby": description ? "".concat(id, "-description") : undefined, "data-state": isDisabled ? "disabled" : "default", className: cn(checkboxTheme.inputStyle, checkboxTheme.sizes[size], indeterminate && "bg-neutral-200") }),
|
|
38
|
+
indeterminate && (React__default.createElement(ForwardRef, { className: cn("pointer-events-none col-start-1 row-start-1 self-center justify-self-center opacity-100 stroke-neutral-600 transition-opacity duration-200", size === "sm" ? "size-3" : "size-4"), strokeWidth: 3 })),
|
|
39
|
+
isChecked && !indeterminate && (React__default.createElement(ForwardRef$1, { className: cn("pointer-events-none col-start-1 row-start-1 self-center justify-self-center opacity-100 stroke-white transition-opacity duration-200", size === "sm" ? "size-3" : "size-4"), strokeWidth: 3 }))),
|
|
40
|
+
(label || description) && (React__default.createElement("div", { className: "cursor-pointer" },
|
|
41
|
+
label && (React__default.createElement(FormLabel, { htmlFor: id, className: "!mb-0", state: state }, label)),
|
|
42
|
+
description && (React__default.createElement("div", { id: "".concat(id, "-description"), className: checkboxTheme.descriptionStyle }, description))))));
|
|
49
43
|
};
|
|
50
44
|
|
|
51
45
|
export { Checkbox, Checkbox as default };
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Default theme configuration for the Checkbox component
|
|
3
3
|
*/
|
|
4
4
|
var checkboxTheme = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
baseStyle: "relative flex items-start gap-3",
|
|
6
|
+
inputContainerStyle: "relative flex-shrink-0 group grid grid-cols-1",
|
|
7
|
+
inputStyle: "col-start-1 row-start-1 appearance-none rounded-md border-2 border-gray-300 bg-white checked:border-primary-base checked:bg-primary-base disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 checked:outline-2 checked:outline-primary-100 checked:outline-offset-1 transition-all duration-400 data-[state=disabled]:border-gray-300 data-[state=disabled]:bg-gray-100",
|
|
8
|
+
descriptionStyle: "text-base text-text-secondary mt-0.5",
|
|
9
|
+
sizes: {
|
|
10
|
+
sm: "size-5 mt-0.25",
|
|
11
|
+
md: "size-6"
|
|
12
|
+
}
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export { checkboxTheme };
|
|
@@ -2,21 +2,15 @@ import React from 'react';
|
|
|
2
2
|
/**
|
|
3
3
|
* State variants for the checkbox component
|
|
4
4
|
*/
|
|
5
|
-
export type CheckboxState = 'default' | 'disabled'
|
|
5
|
+
export type CheckboxState = 'default' | 'disabled';
|
|
6
|
+
/**
|
|
7
|
+
* Size variants for the checkbox component
|
|
8
|
+
*/
|
|
9
|
+
export type CheckboxSize = 'sm' | 'md';
|
|
6
10
|
/**
|
|
7
11
|
* Checkbox component props
|
|
8
|
-
* @property {string} id - Unique identifier for the checkbox input
|
|
9
|
-
* @property {string} name - Name for the checkbox input
|
|
10
|
-
* @property {string} value - Value for the checkbox input
|
|
11
|
-
* @property {boolean} checked - Whether the checkbox is checked
|
|
12
|
-
* @property {(checked: boolean, value: string) => void} onChange - Function called when the checkbox state changes
|
|
13
|
-
* @property {string} label - Label text for the checkbox
|
|
14
|
-
* @property {string} description - Optional description text
|
|
15
|
-
* @property {CheckboxState} state - The state of the checkbox (default, disabled, invalid)
|
|
16
|
-
* @property {CheckboxThemeOverrides} theme - Optional theme overrides
|
|
17
|
-
* @property {string} className - Additional class names for styling override
|
|
18
12
|
*/
|
|
19
|
-
export interface CheckboxProps extends Omit<React.HTMLAttributes<
|
|
13
|
+
export interface CheckboxProps extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange' | 'size'> {
|
|
20
14
|
id: string;
|
|
21
15
|
name: string;
|
|
22
16
|
value: string;
|
|
@@ -26,27 +20,16 @@ export interface CheckboxProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
26
20
|
label?: string;
|
|
27
21
|
description?: string;
|
|
28
22
|
state?: CheckboxState;
|
|
29
|
-
|
|
23
|
+
size?: CheckboxSize;
|
|
24
|
+
className?: string;
|
|
30
25
|
}
|
|
31
26
|
/**
|
|
32
27
|
* Checkbox theme configuration
|
|
33
28
|
*/
|
|
34
29
|
export interface CheckboxTheme {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
description: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Checkbox theme overrides
|
|
44
|
-
*/
|
|
45
|
-
export interface CheckboxThemeOverrides {
|
|
46
|
-
container?: string;
|
|
47
|
-
inputContainer?: string;
|
|
48
|
-
labelContainer?: string;
|
|
49
|
-
input?: string;
|
|
50
|
-
checkmark?: string;
|
|
51
|
-
description?: string;
|
|
30
|
+
baseStyle: string;
|
|
31
|
+
inputContainerStyle: string;
|
|
32
|
+
inputStyle: string;
|
|
33
|
+
descriptionStyle: string;
|
|
34
|
+
sizes: Record<CheckboxSize, string>;
|
|
52
35
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormLabelProps } from './FormLabel.types';
|
|
3
3
|
/**
|
|
4
|
-
* FormLabel component for providing
|
|
4
|
+
* FormLabel component for providing consistent labeling for form elements
|
|
5
5
|
*/
|
|
6
6
|
export declare const FormLabel: React.FC<FormLabelProps>;
|
|
7
|
-
export default FormLabel;
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
+
import { __rest, __assign } from '../../../node_modules/tslib/tslib.es6.js';
|
|
1
2
|
import React__default from 'react';
|
|
2
3
|
import { formLabelTheme } from './FormLabel.theme.js';
|
|
4
|
+
import { cn } from '../../../utils/cn.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
* FormLabel component for providing
|
|
7
|
+
* FormLabel component for providing consistent labeling for form elements
|
|
6
8
|
*/
|
|
7
9
|
var FormLabel = function (_a) {
|
|
8
|
-
var _b, _c;
|
|
9
|
-
|
|
10
|
-
// Get base classes from theme or use defaults
|
|
11
|
-
var baseClasses = theme.baseStyle || formLabelTheme.baseStyle;
|
|
12
|
-
// Define state classes
|
|
13
|
-
var stateClasses = ((_b = theme.states) === null || _b === void 0 ? void 0 : _b[state]) || ((_c = formLabelTheme.states) === null || _c === void 0 ? void 0 : _c[state]) || '';
|
|
14
|
-
// Required indicator style
|
|
15
|
-
var requiredIndicatorStyle = theme.requiredIndicatorStyle || formLabelTheme.requiredIndicatorStyle;
|
|
16
|
-
// Combine all classes for label
|
|
17
|
-
var combinedClassName = "".concat(baseClasses, " ").concat(stateClasses, " ").concat(className).trim();
|
|
18
|
-
return (React__default.createElement("label", { htmlFor: htmlFor, className: combinedClassName },
|
|
10
|
+
var htmlFor = _a.htmlFor, children = _a.children, className = _a.className, _b = _a.required, required = _b === void 0 ? false : _b, _c = _a.state, state = _c === void 0 ? 'default' : _c, props = __rest(_a, ["htmlFor", "children", "className", "required", "state"]);
|
|
11
|
+
return (React__default.createElement("label", __assign({ htmlFor: htmlFor, className: cn(formLabelTheme.baseStyle, formLabelTheme.stateStyles[state], className) }, props),
|
|
19
12
|
children,
|
|
20
|
-
required && React__default.createElement("span", { className: requiredIndicatorStyle }, "*")));
|
|
13
|
+
required && (React__default.createElement("span", { className: formLabelTheme.requiredIndicatorStyle }, "*"))));
|
|
21
14
|
};
|
|
22
15
|
|
|
23
|
-
export { FormLabel
|
|
16
|
+
export { FormLabel };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FormLabelTheme } from './FormLabel.types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Clean theme structure for FormLabel component
|
|
4
4
|
*/
|
|
5
|
-
export declare const formLabelTheme:
|
|
6
|
-
export default formLabelTheme;
|
|
5
|
+
export declare const formLabelTheme: FormLabelTheme;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Clean theme structure for FormLabel component
|
|
3
3
|
*/
|
|
4
4
|
var formLabelTheme = {
|
|
5
5
|
// Base styles for the label element
|
|
6
|
-
baseStyle: "block text-sm/6 font-medium
|
|
7
|
-
// State variants
|
|
8
|
-
|
|
9
|
-
default: "",
|
|
6
|
+
baseStyle: "block text-sm/6 font-medium mb-2",
|
|
7
|
+
// State variants - using design tokens from global.scss
|
|
8
|
+
stateStyles: {
|
|
9
|
+
default: "text-text-primary",
|
|
10
10
|
disabled: "text-text-disabled",
|
|
11
11
|
invalid: "text-danger-base",
|
|
12
12
|
},
|
|
@@ -14,4 +14,4 @@ var formLabelTheme = {
|
|
|
14
14
|
requiredIndicatorStyle: "text-danger-base ml-1",
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export { formLabelTheme
|
|
17
|
+
export { formLabelTheme };
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* State variants for the FormLabel component
|
|
4
|
+
*/
|
|
5
|
+
export type FormLabelState = 'default' | 'disabled' | 'invalid';
|
|
2
6
|
/**
|
|
3
7
|
* FormLabel component props
|
|
4
|
-
* @property {string} htmlFor - The ID of the form element the label is associated with
|
|
5
|
-
* @property {React.ReactNode} children - The content of the label
|
|
6
|
-
* @property {string} className - Additional class name for the label
|
|
7
|
-
* @property {boolean} required - Whether the associated form element is required
|
|
8
|
-
* @property {'default' | 'disabled' | 'invalid'} state - The state of the label
|
|
9
|
-
* @property {FormLabelThemeOverrides} theme - Component-level theme overrides
|
|
10
8
|
*/
|
|
11
|
-
export interface FormLabelProps {
|
|
9
|
+
export interface FormLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
12
10
|
/** The ID of the form element the label is associated with */
|
|
13
11
|
htmlFor: string;
|
|
14
12
|
/** The content of the label */
|
|
@@ -19,18 +17,12 @@ export interface FormLabelProps {
|
|
|
19
17
|
required?: boolean;
|
|
20
18
|
/** The state of the label */
|
|
21
19
|
state?: FormLabelState;
|
|
22
|
-
/** Component-level theme overrides */
|
|
23
|
-
theme?: FormLabelThemeOverrides;
|
|
24
20
|
}
|
|
25
|
-
export type FormLabelState = 'default' | 'disabled' | 'invalid';
|
|
26
21
|
/**
|
|
27
|
-
*
|
|
22
|
+
* FormLabel theme configuration
|
|
28
23
|
*/
|
|
29
|
-
export interface
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
states?: Partial<Record<FormLabelState, string>>;
|
|
34
|
-
/** Style for the required indicator */
|
|
35
|
-
requiredIndicatorStyle?: string;
|
|
24
|
+
export interface FormLabelTheme {
|
|
25
|
+
baseStyle: string;
|
|
26
|
+
stateStyles: Record<FormLabelState, string>;
|
|
27
|
+
requiredIndicatorStyle: string;
|
|
36
28
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
1
|
+
export { FormLabel } from './FormLabel';
|
|
2
|
+
export { formLabelTheme } from './FormLabel.theme';
|
|
3
|
+
export type { FormLabelProps, FormLabelState, FormLabelTheme } from './FormLabel.types';
|
|
@@ -2,6 +2,7 @@ import { __rest, __assign, __spreadArray } from '../../../node_modules/tslib/tsl
|
|
|
2
2
|
import React__default, { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { FormLabel } from '../FormLabel/FormLabel.js';
|
|
4
4
|
import { inputTheme } from './Input.theme.js';
|
|
5
|
+
import { cn } from '../../../utils/cn.js';
|
|
5
6
|
import { PlusIcon } from '../../../icons/core/PlusIcon.js';
|
|
6
7
|
import { MinusIcon } from '../../../icons/core/MinusIcon.js';
|
|
7
8
|
import { SearchIcon } from '../../../icons/core/SearchIcon.js';
|
|
@@ -14,29 +15,22 @@ import ForwardRef$1 from '../../../node_modules/@heroicons/react/24/solid/esm/Ey
|
|
|
14
15
|
import ForwardRef$2 from '../../../node_modules/@heroicons/react/24/solid/esm/EyeIcon.js';
|
|
15
16
|
|
|
16
17
|
var Input = React__default.forwardRef(function (_a, ref) {
|
|
17
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m,
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
_w = _a.theme,
|
|
21
|
-
// TODO: whats the diff between theme and classname? i want to use classname tooverride stying since this library is being build using tailwindcss
|
|
22
|
-
theme = _w === void 0 ? {} : _w, required = _a.required, _x = _a.type, type = _x === void 0 ? "text" : _x, _y = _a.passwordToggle, passwordToggle = _y === void 0 ? type === "password" : _y, passwordStrengthIndicator = _a.passwordStrengthIndicator, _z = _a.showNumberControls, showNumberControls = _z === void 0 ? false : _z, min = _a.min, max = _a.max, _0 = _a.step, step = _0 === void 0 ? 1 : _0, onChange = _a.onChange, value = _a.value, currencyDecimalPlaces = _a.currencyDecimalPlaces, props = __rest(_a, ["size", "state", "className", "label", "labelClassName", "helperText", "helperTextClassName", "wrapperClassName", "inputGroupClassName", "leftIcon", "rightIcon", "addonPrefix", "addonSuffix", "keyboardShortcut", "id", "theme", "required", "type", "passwordToggle", "passwordStrengthIndicator", "showNumberControls", "min", "max", "step", "onChange", "value", "currencyDecimalPlaces"]);
|
|
23
|
-
var _1 = useState(false), isFocused = _1[0], setIsFocused = _1[1];
|
|
24
|
-
var _2 = useState(false), showPassword = _2[0], setShowPassword = _2[1];
|
|
18
|
+
var _b = _a.size, size = _b === void 0 ? "md" : _b, _c = _a.state, state = _c === void 0 ? "default" : _c, _d = _a.className, className = _d === void 0 ? "" : _d, label = _a.label, _e = _a.labelClassName, labelClassName = _e === void 0 ? "" : _e, helperText = _a.helperText, _f = _a.helperTextClassName, helperTextClassName = _f === void 0 ? "" : _f, _g = _a.wrapperClassName, wrapperClassName = _g === void 0 ? "" : _g, _h = _a.inputGroupClassName, inputGroupClassName = _h === void 0 ? "" : _h, leftIcon = _a.leftIcon, rightIcon = _a.rightIcon, addonPrefix = _a.addonPrefix, addonSuffix = _a.addonSuffix, keyboardShortcut = _a.keyboardShortcut, id = _a.id, required = _a.required, _j = _a.type, type = _j === void 0 ? "text" : _j, _k = _a.passwordToggle, passwordToggle = _k === void 0 ? type === "password" : _k, passwordStrengthIndicator = _a.passwordStrengthIndicator, _l = _a.showNumberControls, showNumberControls = _l === void 0 ? false : _l, min = _a.min, max = _a.max, _m = _a.step, step = _m === void 0 ? 1 : _m, onChange = _a.onChange, value = _a.value, currencyDecimalPlaces = _a.currencyDecimalPlaces, props = __rest(_a, ["size", "state", "className", "label", "labelClassName", "helperText", "helperTextClassName", "wrapperClassName", "inputGroupClassName", "leftIcon", "rightIcon", "addonPrefix", "addonSuffix", "keyboardShortcut", "id", "required", "type", "passwordToggle", "passwordStrengthIndicator", "showNumberControls", "min", "max", "step", "onChange", "value", "currencyDecimalPlaces"]);
|
|
19
|
+
var _o = useState(false), isFocused = _o[0], setIsFocused = _o[1];
|
|
20
|
+
var _p = useState(false), showPassword = _p[0], setShowPassword = _p[1];
|
|
25
21
|
var inputId = id || "input-".concat(Math.random().toString(36).substring(2, 9));
|
|
26
|
-
var
|
|
22
|
+
var _q = useState(value !== undefined
|
|
27
23
|
? typeof value === "number"
|
|
28
24
|
? value
|
|
29
25
|
: typeof value === "string"
|
|
30
26
|
? parseFloat(value) || undefined
|
|
31
27
|
: undefined
|
|
32
|
-
: undefined), numberValue =
|
|
28
|
+
: undefined), numberValue = _q[0], setNumberValue = _q[1];
|
|
33
29
|
var inputRef = useRef(null);
|
|
34
30
|
var cursorPositionRef = useRef(null);
|
|
35
31
|
// Default icons based on input type
|
|
36
|
-
var defaultPasswordIcon = type === "password" && !leftIcon ? (React__default.createElement(ForwardRef, { className: "size-5 text-
|
|
37
|
-
var defaultSearchIcon = type === "search" && !leftIcon ? (React__default.createElement(SearchIcon, { size: "sm", className:
|
|
38
|
-
((_e = (_d = inputTheme.typeStyles) === null || _d === void 0 ? void 0 : _d.search) === null || _e === void 0 ? void 0 : _e.iconStyle) ||
|
|
39
|
-
"text-neutral-500" })) : null;
|
|
32
|
+
var defaultPasswordIcon = type === "password" && !leftIcon ? (React__default.createElement(ForwardRef, { className: "size-5 text-text-muted" })) : null;
|
|
33
|
+
var defaultSearchIcon = type === "search" && !leftIcon ? (React__default.createElement(SearchIcon, { size: "sm", className: inputTheme.typeStyles.search.iconStyle })) : null;
|
|
40
34
|
// Use the provided leftIcon or the default icon based on input type
|
|
41
35
|
var finalLeftIcon = leftIcon || defaultPasswordIcon || defaultSearchIcon;
|
|
42
36
|
// Derived state flags for internal use
|
|
@@ -182,40 +176,32 @@ var Input = React__default.forwardRef(function (_a, ref) {
|
|
|
182
176
|
onChange(e);
|
|
183
177
|
}
|
|
184
178
|
};
|
|
185
|
-
//
|
|
186
|
-
var wrapperClasses =
|
|
187
|
-
var inputGroupClasses =
|
|
188
|
-
var baseClasses =
|
|
189
|
-
var sizeClasses =
|
|
190
|
-
var stateClasses =
|
|
191
|
-
var helperTextClasses =
|
|
192
|
-
// Icon
|
|
193
|
-
var leftIconClasses =
|
|
194
|
-
var rightIconClasses =
|
|
195
|
-
var leftIconPadding =
|
|
196
|
-
var rightIconPadding =
|
|
197
|
-
// Addon
|
|
198
|
-
var addonStyle =
|
|
199
|
-
var addonPrefixStyle =
|
|
200
|
-
var addonSuffixStyle =
|
|
201
|
-
//
|
|
202
|
-
var passwordToggleClasses =
|
|
203
|
-
|
|
204
|
-
var
|
|
205
|
-
inputTheme.numberButtonsContainerStyle ||
|
|
206
|
-
"";
|
|
207
|
-
var numberButtonClasses = theme.numberButtonStyle || inputTheme.numberButtonStyle || "";
|
|
179
|
+
// Theme classes - using simplified approach with design tokens
|
|
180
|
+
var wrapperClasses = inputTheme.wrapperStyle;
|
|
181
|
+
var inputGroupClasses = inputTheme.inputGroupStyle;
|
|
182
|
+
var baseClasses = inputTheme.baseStyle;
|
|
183
|
+
var sizeClasses = inputTheme.sizes[size];
|
|
184
|
+
var stateClasses = inputTheme.states[state];
|
|
185
|
+
var helperTextClasses = inputTheme.helperText;
|
|
186
|
+
// Icon classes using design tokens
|
|
187
|
+
var leftIconClasses = inputTheme.leftIconStyle;
|
|
188
|
+
var rightIconClasses = inputTheme.rightIconStyle;
|
|
189
|
+
var leftIconPadding = inputTheme.iconPadding.left;
|
|
190
|
+
var rightIconPadding = inputTheme.iconPadding.right;
|
|
191
|
+
// Addon classes
|
|
192
|
+
var addonStyle = inputTheme.addonStyle;
|
|
193
|
+
var addonPrefixStyle = inputTheme.addonPrefixStyle;
|
|
194
|
+
var addonSuffixStyle = inputTheme.addonSuffixStyle;
|
|
195
|
+
// Interactive element classes
|
|
196
|
+
var passwordToggleClasses = inputTheme.passwordToggleStyle;
|
|
197
|
+
var numberButtonsContainerClasses = inputTheme.numberButtonsContainerStyle;
|
|
198
|
+
var numberButtonClasses = inputTheme.numberButtonStyle;
|
|
208
199
|
// Password toggle button component
|
|
209
200
|
var PasswordToggleButton = function () {
|
|
210
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
211
201
|
if (!isPasswordField)
|
|
212
202
|
return null;
|
|
213
|
-
var toggleIconActive =
|
|
214
|
-
|
|
215
|
-
"w-5 h-5 text-neutral-700";
|
|
216
|
-
var toggleIconInactive = ((_f = (_e = theme.typeStyles) === null || _e === void 0 ? void 0 : _e.password) === null || _f === void 0 ? void 0 : _f.toggleIconInactive) ||
|
|
217
|
-
((_h = (_g = inputTheme.typeStyles) === null || _g === void 0 ? void 0 : _g.password) === null || _h === void 0 ? void 0 : _h.toggleIconInactive) ||
|
|
218
|
-
"w-5 h-5 text-neutral-500";
|
|
203
|
+
var toggleIconActive = inputTheme.typeStyles.password.toggleIconActive;
|
|
204
|
+
var toggleIconInactive = inputTheme.typeStyles.password.toggleIconInactive;
|
|
219
205
|
return (React__default.createElement("div", { className: passwordToggleClasses, onClick: function (e) {
|
|
220
206
|
e.stopPropagation(); // Prevent parent click handler
|
|
221
207
|
handleTogglePassword();
|
|
@@ -228,7 +214,6 @@ var Input = React__default.forwardRef(function (_a, ref) {
|
|
|
228
214
|
};
|
|
229
215
|
// Number input buttons component
|
|
230
216
|
var NumberButtons = function () {
|
|
231
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
232
217
|
if (!isNumberField)
|
|
233
218
|
return null;
|
|
234
219
|
var isAtMax = max !== undefined &&
|
|
@@ -239,12 +224,8 @@ var Input = React__default.forwardRef(function (_a, ref) {
|
|
|
239
224
|
numberValue !== undefined &&
|
|
240
225
|
typeof min === "number" &&
|
|
241
226
|
numberValue <= min;
|
|
242
|
-
var incrementIconStyle =
|
|
243
|
-
|
|
244
|
-
"text-neutral-500";
|
|
245
|
-
var decrementIconStyle = ((_f = (_e = theme.typeStyles) === null || _e === void 0 ? void 0 : _e.number) === null || _f === void 0 ? void 0 : _f.decrementIconStyle) ||
|
|
246
|
-
((_h = (_g = inputTheme.typeStyles) === null || _g === void 0 ? void 0 : _g.number) === null || _h === void 0 ? void 0 : _h.decrementIconStyle) ||
|
|
247
|
-
"text-neutral-500";
|
|
227
|
+
var incrementIconStyle = inputTheme.typeStyles.number.incrementIconStyle;
|
|
228
|
+
var decrementIconStyle = inputTheme.typeStyles.number.decrementIconStyle;
|
|
248
229
|
return (React__default.createElement("div", { className: numberButtonsContainerClasses },
|
|
249
230
|
React__default.createElement("button", { type: "button", className: "".concat(numberButtonClasses), onClick: function (e) {
|
|
250
231
|
e.stopPropagation(); // Prevent parent click handler
|
|
@@ -259,35 +240,23 @@ var Input = React__default.forwardRef(function (_a, ref) {
|
|
|
259
240
|
};
|
|
260
241
|
// Password Strength Indicator component
|
|
261
242
|
var PasswordStrengthIndicator = function (_a) {
|
|
262
|
-
var _b
|
|
263
|
-
var _r = _a.inline, inline = _r === void 0 ? false : _r;
|
|
243
|
+
var _b = _a.inline, inline = _b === void 0 ? false : _b;
|
|
264
244
|
if (!hasPasswordStrength) {
|
|
265
245
|
return null;
|
|
266
246
|
}
|
|
267
247
|
var strength = passwordStrengthIndicator.strength || "strong";
|
|
268
248
|
var customLabel = passwordStrengthIndicator.customLabel;
|
|
269
249
|
var indicatorClassName = passwordStrengthIndicator.className || "";
|
|
270
|
-
// Get theme values
|
|
271
|
-
var containerStyle = (
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var
|
|
278
|
-
((_g = inputTheme.passwordStrengthIndicator) === null || _g === void 0 ? void 0 : _g.dotStyle) ||
|
|
279
|
-
"size-1.5 rounded-full";
|
|
280
|
-
var dotActiveStyle = ((_h = theme.passwordStrengthIndicator) === null || _h === void 0 ? void 0 : _h.dotActiveStyle) ||
|
|
281
|
-
((_j = inputTheme.passwordStrengthIndicator) === null || _j === void 0 ? void 0 : _j.dotActiveStyle) ||
|
|
282
|
-
"bg-current";
|
|
283
|
-
var dotInactiveStyle = ((_k = theme.passwordStrengthIndicator) === null || _k === void 0 ? void 0 : _k.dotInactiveStyle) ||
|
|
284
|
-
((_l = inputTheme.passwordStrengthIndicator) === null || _l === void 0 ? void 0 : _l.dotInactiveStyle) ||
|
|
285
|
-
"bg-neutral-200";
|
|
286
|
-
// Get color and label based on strength
|
|
287
|
-
var strengthConfig = ((_o = (_m = theme.passwordStrengthIndicator) === null || _m === void 0 ? void 0 : _m.strengthStyles) === null || _o === void 0 ? void 0 : _o[strength]) ||
|
|
288
|
-
((_q = (_p = inputTheme.passwordStrengthIndicator) === null || _p === void 0 ? void 0 : _p.strengthStyles) === null || _q === void 0 ? void 0 : _q[strength]) || {
|
|
250
|
+
// Get theme values using design tokens
|
|
251
|
+
var containerStyle = "".concat(inputTheme.passwordStrengthIndicator.containerStyle, " ").concat(inline ? "" : "mt-2");
|
|
252
|
+
var labelStyle = inputTheme.passwordStrengthIndicator.labelStyle;
|
|
253
|
+
var dotStyle = inputTheme.passwordStrengthIndicator.dotStyle;
|
|
254
|
+
var dotActiveStyle = inputTheme.passwordStrengthIndicator.dotActiveStyle;
|
|
255
|
+
var dotInactiveStyle = inputTheme.passwordStrengthIndicator.dotInactiveStyle;
|
|
256
|
+
// Get color and label based on strength using design tokens
|
|
257
|
+
var strengthConfig = inputTheme.passwordStrengthIndicator.strengthStyles[strength] || {
|
|
289
258
|
label: "Password",
|
|
290
|
-
color: "text-
|
|
259
|
+
color: "text-text-muted",
|
|
291
260
|
};
|
|
292
261
|
var colorClass = strengthConfig.color || "text-neutral-500";
|
|
293
262
|
var label = customLabel || strengthConfig.label || "Password";
|
|
@@ -311,17 +280,16 @@ var Input = React__default.forwardRef(function (_a, ref) {
|
|
|
311
280
|
React__default.createElement("div", { className: labelStyle }, label),
|
|
312
281
|
__spreadArray([], Array(5), true).map(function (_, index) { return (React__default.createElement("div", { key: index, className: "".concat(dotStyle, " ").concat(index < activeDots ? dotActiveStyle : dotInactiveStyle) })); })));
|
|
313
282
|
};
|
|
314
|
-
return (React__default.createElement("div", { className:
|
|
283
|
+
return (React__default.createElement("div", { className: cn(wrapperClasses, stateClass, wrapperClassName) },
|
|
315
284
|
label && (React__default.createElement("div", { className: "flex justify-between items-center" },
|
|
316
285
|
React__default.createElement(FormLabel, { htmlFor: inputId, className: labelClassName, state: state, required: required }, label),
|
|
317
286
|
showStrengthWithLabel && (React__default.createElement(PasswordStrengthIndicator, { inline: true })))),
|
|
318
287
|
React__default.createElement("div", null,
|
|
319
|
-
React__default.createElement("div", { className:
|
|
320
|
-
hasAddonPrefix && (React__default.createElement("div", { className:
|
|
288
|
+
React__default.createElement("div", { className: cn(inputGroupClasses, stateClasses, inputGroupClassName), onClick: handleInputGroupClick, role: "presentation" },
|
|
289
|
+
hasAddonPrefix && (React__default.createElement("div", { className: cn(addonStyle, addonPrefixStyle) }, addonPrefix)),
|
|
321
290
|
React__default.createElement("div", { className: "relative flex-1" },
|
|
322
|
-
React__default.createElement("input", __assign({ ref: setInputRef, id: inputId, type: actualInputType, className:
|
|
323
|
-
|
|
324
|
-
: "", "\n ").concat(className, "\n "), disabled: isDisabled, "aria-invalid": isInvalid, required: required, min: min, max: max, step: step, value: value, onChange: handleInputChange, onFocus: function (e) {
|
|
291
|
+
React__default.createElement("input", __assign({ ref: setInputRef, id: inputId, type: actualInputType, className: cn(baseClasses, sizeClasses, hasLeftIcon && leftIconPadding, (hasRightIcon || isPasswordField || displayNumberControls) && rightIconPadding, className // User className has highest priority
|
|
292
|
+
), disabled: isDisabled, "aria-invalid": isInvalid, required: required, min: min, max: max, step: step, value: value, onChange: handleInputChange, onFocus: function (e) {
|
|
325
293
|
var _a;
|
|
326
294
|
setIsFocused(true);
|
|
327
295
|
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
@@ -334,13 +302,11 @@ var Input = React__default.forwardRef(function (_a, ref) {
|
|
|
334
302
|
hasRightIcon && !isPasswordField && !displayNumberControls && (React__default.createElement("div", { className: rightIconClasses }, rightIcon)),
|
|
335
303
|
isPasswordField && React__default.createElement(PasswordToggleButton, null),
|
|
336
304
|
displayNumberControls && React__default.createElement(NumberButtons, null),
|
|
337
|
-
hasKeyboardShortcut && (React__default.createElement("div", { className:
|
|
338
|
-
|
|
339
|
-
"" }, keyboardShortcut))),
|
|
340
|
-
hasAddonSuffix && (React__default.createElement("div", { className: "".concat(addonStyle, " ").concat(addonSuffixStyle) }, addonSuffix)))),
|
|
305
|
+
hasKeyboardShortcut && (React__default.createElement("div", { className: inputTheme.keyboardShortcutStyle }, keyboardShortcut))),
|
|
306
|
+
hasAddonSuffix && (React__default.createElement("div", { className: cn(addonStyle, addonSuffixStyle) }, addonSuffix)))),
|
|
341
307
|
showStrengthBelow && (React__default.createElement(PasswordStrengthIndicator, { inline: false })),
|
|
342
|
-
helperText && (React__default.createElement("div", { className:
|
|
308
|
+
helperText && (React__default.createElement("div", { className: cn(helperTextClasses, helperTextClassName) }, helperText))));
|
|
343
309
|
});
|
|
344
310
|
Input.displayName = "Input";
|
|
345
311
|
|
|
346
|
-
export { Input
|
|
312
|
+
export { Input };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputTheme } from "./Input.types";
|
|
2
2
|
/**
|
|
3
|
-
* Default theme for the Input component
|
|
4
|
-
*
|
|
3
|
+
* Default theme for the Input component - Clean & Organized
|
|
4
|
+
* Uses flat structure with design tokens
|
|
5
5
|
*/
|
|
6
|
-
export declare const inputTheme:
|
|
6
|
+
export declare const inputTheme: InputTheme;
|
|
7
7
|
export default inputTheme;
|