@flikk/ui 1.0.0-beta.23 → 1.0.0-beta.24
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/components/charts/AreaChart/AreaChart.types.d.ts +2 -2
- package/dist/components/charts/BarChart/BarChart.types.d.ts +2 -2
- package/dist/components/charts/ComboChart/ComboChart.types.d.ts +2 -2
- package/dist/components/charts/LineChart/LineChart.types.d.ts +2 -2
- package/dist/components/charts/ScatterPlot/ScatterPlot.types.d.ts +2 -2
- package/dist/components/charts/StackedBarChart/StackedBarChart.types.d.ts +2 -2
- package/dist/components/core/Accordion/AccordionTrigger.js +28 -1
- package/dist/components/core/Alert/Alert.js +2 -1
- package/dist/components/core/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/core/Badge/Badge.js +6 -17
- package/dist/components/core/Breadcrumbs/Breadcrumbs.js +17 -28
- package/dist/components/core/Calendar/Calendar.js +1 -1
- package/dist/components/core/Carousel/CarouselBody.js +6 -1
- package/dist/components/core/ContextMenu/ContextMenuBody.js +6 -3
- package/dist/components/core/ContextMenu/ContextMenuSubBody.js +6 -3
- package/dist/components/core/DragDrop/DragDrop.js +170 -17
- package/dist/components/core/DragDrop/DragDrop.types.d.ts +6 -0
- package/dist/components/core/Drawer/Drawer.d.ts +1 -1
- package/dist/components/core/Drawer/Drawer.js +2 -0
- package/dist/components/core/Drawer/Drawer.types.d.ts +2 -0
- package/dist/components/core/Drawer/DrawerTitle.d.ts +1 -1
- package/dist/components/core/Drawer/DrawerTitle.js +2 -2
- package/dist/components/core/Dropdown/DropdownMenu.js +2 -30
- package/dist/components/core/Masonry/Masonry.js +7 -2
- package/dist/components/core/Modal/Modal.d.ts +1 -1
- package/dist/components/core/Modal/Modal.js +3 -3
- package/dist/components/core/Modal/Modal.types.d.ts +2 -0
- package/dist/components/core/Modal/ModalTitle.d.ts +1 -1
- package/dist/components/core/Modal/ModalTitle.js +2 -2
- package/dist/components/core/NavItem/NavItem.js +13 -8
- package/dist/components/core/Pagination/Pagination.js +1 -1
- package/dist/components/core/Popover/PopoverBody.js +3 -27
- package/dist/components/core/Popover/PopoverTrigger.js +1 -1
- package/dist/components/core/Progress/Progress.js +4 -4
- package/dist/components/core/Rating/Rating.js +1 -1
- package/dist/components/core/ScrollArea/ScrollArea.js +3 -2
- package/dist/components/core/Segmented/Segmented.js +6 -6
- package/dist/components/core/Segmented/SegmentedItem.js +28 -2
- package/dist/components/core/Skeleton/Skeleton.js +2 -2
- package/dist/components/core/Sortable/Sortable.d.ts +1 -1
- package/dist/components/core/Sortable/Sortable.js +20 -4
- package/dist/components/core/Sortable/Sortable.types.d.ts +2 -0
- package/dist/components/core/Tabs/Tabs.js +6 -4
- package/dist/components/core/Tabs/Tabs.types.d.ts +2 -0
- package/dist/components/core/Tabs/TabsBody.js +3 -3
- package/dist/components/core/Tabs/TabsList.js +19 -21
- package/dist/components/core/Tabs/TabsTrigger.js +47 -28
- package/dist/components/core/Toast/Toast.js +1 -1
- package/dist/components/core/Toast/ToastProvider.js +3 -2
- package/dist/components/core/Tooltip/Tooltip.js +25 -34
- package/dist/components/core/Tree/Tree.js +178 -8
- package/dist/components/data-display/GanttChart/GanttSplitter.js +15 -1
- package/dist/components/data-display/Table/Table.js +2 -2
- package/dist/components/data-display/Table/Table.types.d.ts +2 -0
- package/dist/components/data-display/Table/TableFilter.js +21 -18
- package/dist/components/effects/CustomCursor/CustomCursor.js +3 -7
- package/dist/components/effects/Overlay/Overlay.js +4 -9
- package/dist/components/effects/PageTransition/PageTransition.js +17 -6
- package/dist/components/effects/SpotlightBorder/SpotlightBorder.js +3 -4
- package/dist/components/forms/Checkbox/Checkbox.js +11 -1
- package/dist/components/forms/Checkbox/Checkbox.theme.js +4 -1
- package/dist/components/forms/Checkbox/Checkbox.types.d.ts +7 -5
- package/dist/components/forms/Checkbox/CheckboxGroup.js +9 -4
- package/dist/components/forms/ColorPicker/ColorPicker.js +7 -4
- package/dist/components/forms/ColorPicker/ColorPicker.types.d.ts +2 -2
- package/dist/components/forms/ColorPicker/ColorPickerBody.js +5 -3
- package/dist/components/forms/ColorPicker/ColorPickerEyeDropper.js +3 -3
- package/dist/components/forms/ColorPicker/ColorPickerGradient.js +8 -8
- package/dist/components/forms/ColorPicker/ColorPickerInput.js +1 -1
- package/dist/components/forms/ColorPicker/index.d.ts +1 -1
- package/dist/components/forms/Combobox/Combobox.js +20 -45
- package/dist/components/forms/Combobox/Combobox.types.d.ts +4 -2
- package/dist/components/forms/CronInput/CronInput.js +10 -4
- package/dist/components/forms/CronInput/CronInput.types.d.ts +12 -1
- package/dist/components/forms/DatePicker/DatePicker.js +2 -2
- package/dist/components/forms/DatePicker/DatePicker.types.d.ts +4 -2
- package/dist/components/forms/DatePicker/DatePickerBody.js +1 -29
- package/dist/components/forms/DatePicker/DatePickerTrigger.js +2 -2
- package/dist/components/forms/DateRangePicker/DateRangePicker.js +3 -3
- package/dist/components/forms/DateRangePicker/DateRangePicker.types.d.ts +4 -2
- package/dist/components/forms/DateRangePicker/DateRangePickerBody.js +1 -28
- package/dist/components/forms/DateRangePicker/DateRangePickerTrigger.js +2 -2
- package/dist/components/forms/FileUpload/FileUpload.js +14 -10
- package/dist/components/forms/FileUpload/FileUpload.types.d.ts +15 -0
- package/dist/components/forms/FormLabel/FormLabel.js +2 -2
- package/dist/components/forms/Input/Input.js +5 -3
- package/dist/components/forms/Input/Input.types.d.ts +2 -0
- package/dist/components/forms/InputAddress/InputAddress.d.ts +1 -1
- package/dist/components/forms/InputAddress/InputAddress.js +8 -9
- package/dist/components/forms/InputCounter/InputCounter.js +25 -18
- package/dist/components/forms/InputCounter/InputCounter.types.d.ts +8 -1
- package/dist/components/forms/InputCreditCard/InputCreditCard.d.ts +1 -1
- package/dist/components/forms/InputCreditCard/InputCreditCard.js +27 -9
- package/dist/components/forms/InputCreditCard/InputCreditCard.types.d.ts +5 -0
- package/dist/components/forms/InputOTP/InputOTP.js +26 -17
- package/dist/components/forms/InputOTP/InputOTP.types.d.ts +21 -4
- package/dist/components/forms/InputTag/InputTag.js +12 -39
- package/dist/components/forms/InputTag/InputTag.types.d.ts +2 -2
- package/dist/components/forms/Mention/Mention.js +13 -6
- package/dist/components/forms/Mention/Mention.types.d.ts +9 -0
- package/dist/components/forms/Radio/Radio.js +12 -2
- package/dist/components/forms/Radio/Radio.theme.js +5 -1
- package/dist/components/forms/Radio/Radio.types.d.ts +7 -5
- package/dist/components/forms/Radio/RadioGroup.js +8 -3
- package/dist/components/forms/RichTextEditor/RichTextEditor.js +21 -21
- package/dist/components/forms/RichTextEditor/RichTextEditor.types.d.ts +2 -2
- package/dist/components/forms/Select/Select.d.ts +2 -0
- package/dist/components/forms/Select/Select.js +26 -56
- package/dist/components/forms/Select/Select.types.d.ts +14 -0
- package/dist/components/forms/Signature/Signature.js +1 -1
- package/dist/components/forms/Signature/Signature.types.d.ts +3 -3
- package/dist/components/forms/Slider/Slider.js +18 -4
- package/dist/components/forms/Slider/Slider.types.d.ts +2 -2
- package/dist/components/forms/Switch/Switch.js +12 -19
- package/dist/components/forms/Switch/Switch.theme.js +12 -2
- package/dist/components/forms/Switch/Switch.types.d.ts +20 -2
- package/dist/components/forms/Textarea/Textarea.js +8 -3
- package/dist/components/forms/Textarea/Textarea.types.d.ts +2 -0
- package/dist/components/forms/TimePicker/TimePicker.js +1 -1
- package/dist/components/forms/TimePicker/TimePicker.types.d.ts +6 -2
- package/dist/components/forms/TimePicker/TimePickerContent.js +2 -29
- package/dist/components/forms/TimePicker/TimePickerTrigger.js +2 -2
- package/dist/components/forms/index.js +1 -1
- package/dist/components/layout/index.js +4 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useClickOutside.d.ts +10 -4
- package/dist/hooks/useClickOutside.js +44 -24
- package/dist/hooks/useDarkMode.d.ts +1 -0
- package/dist/hooks/useDarkMode.js +42 -0
- package/dist/hooks/useFormStateMachine.d.ts +1 -1
- package/dist/hooks/useNetworkStatus.js +1 -1
- package/dist/hooks/useOverlay.js +4 -0
- package/dist/hooks/useScaleBackground.js +5 -2
- package/dist/hooks/useSelectPortal.js +14 -5
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -57
- package/dist/shadcn-compat.css +80 -0
- package/dist/styles.css +1 -1
- package/dist/utils/stateMachine.d.ts +4 -4
- package/package.json +11 -10
- package/tailwind.preset.cjs +32 -3
- /package/{src/theme-plugin.css → dist/theme.css} +0 -0
|
@@ -24,12 +24,15 @@ const checkboxTheme = {
|
|
|
24
24
|
"data-[state=disabled]:border-[var(--color-border)] data-[state=disabled]:bg-[var(--color-background-disabled)] data-[state=disabled]:cursor-not-allowed " +
|
|
25
25
|
// Disabled state - dark
|
|
26
26
|
"dark:disabled:bg-[var(--color-neutral-800)] dark:disabled:border-[var(--color-neutral-600)] " +
|
|
27
|
-
"dark:data-[state=disabled]:bg-[var(--color-neutral-700)] dark:data-[state=disabled]:border-[var(--color-neutral-600)]"
|
|
27
|
+
"dark:data-[state=disabled]:bg-[var(--color-neutral-700)] dark:data-[state=disabled]:border-[var(--color-neutral-600)] " +
|
|
28
|
+
// Invalid state
|
|
29
|
+
"data-[state=invalid]:border-[var(--color-danger)] data-[state=invalid]:focus-visible:outline-[var(--color-danger)]",
|
|
28
30
|
// Description text - light and dark
|
|
29
31
|
descriptionStyle: "text-sm mt-0.5 " + "text-[var(--color-text-secondary)]/80 " + " ",
|
|
30
32
|
sizes: {
|
|
31
33
|
sm: "size-5 mt-0.25",
|
|
32
34
|
md: "size-6",
|
|
35
|
+
lg: "size-7",
|
|
33
36
|
},
|
|
34
37
|
// Group styles
|
|
35
38
|
groupStyle: "flex flex-col gap-1.5",
|
|
@@ -2,11 +2,11 @@ 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' | 'invalid';
|
|
6
6
|
/**
|
|
7
7
|
* Size variants for the checkbox component
|
|
8
8
|
*/
|
|
9
|
-
export type CheckboxSize = 'sm' | 'md';
|
|
9
|
+
export type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
10
10
|
/**
|
|
11
11
|
* Orientation for Checkbox.Group layout
|
|
12
12
|
*/
|
|
@@ -14,11 +14,9 @@ export type CheckboxGroupOrientation = 'vertical' | 'horizontal';
|
|
|
14
14
|
/**
|
|
15
15
|
* Checkbox component props
|
|
16
16
|
*/
|
|
17
|
-
export interface CheckboxProps extends Omit<React.
|
|
17
|
+
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size'> {
|
|
18
18
|
id?: string;
|
|
19
|
-
name?: string;
|
|
20
19
|
value: string;
|
|
21
|
-
checked?: boolean;
|
|
22
20
|
indeterminate?: boolean;
|
|
23
21
|
onChange?: (checked: boolean, value: string) => void;
|
|
24
22
|
label?: React.ReactNode;
|
|
@@ -40,7 +38,11 @@ export interface CheckboxGroupProps extends Omit<React.HTMLAttributes<HTMLFieldS
|
|
|
40
38
|
orientation?: CheckboxGroupOrientation;
|
|
41
39
|
label?: React.ReactNode;
|
|
42
40
|
description?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `state='invalid'` with `errorMessage` instead.
|
|
43
|
+
*/
|
|
43
44
|
error?: React.ReactNode;
|
|
45
|
+
errorMessage?: React.ReactNode;
|
|
44
46
|
required?: boolean;
|
|
45
47
|
className?: string;
|
|
46
48
|
}
|
|
@@ -5,7 +5,12 @@ import { checkboxTheme } from './Checkbox.theme.js';
|
|
|
5
5
|
import { formLabelTheme } from '../FormLabel/FormLabel.theme.js';
|
|
6
6
|
import { CheckboxGroupContext } from './CheckboxContext.js';
|
|
7
7
|
|
|
8
|
-
const CheckboxGroup = React__default.forwardRef(({ value: controlledValue, defaultValue, onChange, name, size = "md", state = "default", orientation = "vertical", label, description, error, required, className, children, ...props }, ref) => {
|
|
8
|
+
const CheckboxGroup = React__default.forwardRef(({ value: controlledValue, defaultValue, onChange, name, size = "md", state: stateProp = "default", orientation = "vertical", label, description, error, errorMessage, required, className, children, ...props }, ref) => {
|
|
9
|
+
// Prefer errorMessage; fall back to deprecated error prop
|
|
10
|
+
const resolvedError = errorMessage !== null && errorMessage !== void 0 ? errorMessage : error;
|
|
11
|
+
// If error (deprecated) is provided and state not explicitly set to something else,
|
|
12
|
+
// implicitly treat the group as invalid
|
|
13
|
+
const state = resolvedError && stateProp === "default" ? "invalid" : stateProp;
|
|
9
14
|
const autoId = useId();
|
|
10
15
|
const groupName = name !== null && name !== void 0 ? name : `checkbox-group-${autoId}`;
|
|
11
16
|
const labelId = `${autoId}-label`;
|
|
@@ -31,9 +36,9 @@ const CheckboxGroup = React__default.forwardRef(({ value: controlledValue, defau
|
|
|
31
36
|
size,
|
|
32
37
|
state,
|
|
33
38
|
}), [groupName, currentValue, size, state]);
|
|
34
|
-
const labelState =
|
|
35
|
-
return (jsx(CheckboxGroupContext.Provider, { value: contextValue, children: jsxs("fieldset", { ref: ref, role: "group", "aria-labelledby": label ? labelId : undefined, "aria-describedby": description ? descriptionId : undefined, "aria-required": required || undefined, "aria-invalid":
|
|
36
|
-
checkboxTheme.groupHorizontalStyle), children: children }),
|
|
39
|
+
const labelState = state === "invalid" ? "invalid" : state === "disabled" ? "disabled" : "default";
|
|
40
|
+
return (jsx(CheckboxGroupContext.Provider, { value: contextValue, children: jsxs("fieldset", { ref: ref, role: "group", "aria-labelledby": label ? labelId : undefined, "aria-describedby": description ? descriptionId : undefined, "aria-required": required || undefined, "aria-invalid": resolvedError ? true : undefined, "aria-errormessage": resolvedError ? errorId : undefined, className: cn("border-0 p-0 m-0", checkboxTheme.groupStyle, className), ...props, children: [label && (typeof label === 'string' ? (jsxs("legend", { id: labelId, className: cn(formLabelTheme.baseStyle, formLabelTheme.stateStyles[labelState]), children: [label, required && (jsx("span", { className: formLabelTheme.requiredIndicatorStyle, children: "*" }))] })) : (label)), description && (typeof description === 'string' ? (jsx("p", { id: descriptionId, className: checkboxTheme.groupDescriptionStyle, children: description })) : (description)), jsx("div", { className: cn(checkboxTheme.groupItemsStyle, orientation === "horizontal" &&
|
|
41
|
+
checkboxTheme.groupHorizontalStyle), children: children }), resolvedError && (typeof resolvedError === 'string' ? (jsx("p", { id: errorId, role: "alert", className: checkboxTheme.groupErrorStyle, children: resolvedError })) : (resolvedError))] }) }));
|
|
37
42
|
});
|
|
38
43
|
CheckboxGroup.displayName = "Checkbox.Group";
|
|
39
44
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import React__default, { useMemo, useState, useCallback,
|
|
2
|
+
import React__default, { useRef, useMemo, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { cn } from '../../../utils/cn.js';
|
|
4
4
|
import { FormLabel } from '../FormLabel/FormLabel.js';
|
|
5
5
|
import { colorPickerTheme } from './ColorPicker.theme.js';
|
|
@@ -31,7 +31,10 @@ const DEFAULT_GRADIENT = {
|
|
|
31
31
|
* ColorPicker Root Component
|
|
32
32
|
* Follows Flikkui compound component pattern (similar to Accordion, Tabs, Popover)
|
|
33
33
|
*/
|
|
34
|
-
const ColorPickerRoot = React__default.forwardRef(({ value, defaultValue = '#000000', onChange, format: initialFormat = 'hex', showAlpha = true, showEyeDropper = true, presetColors, savedColors: savedColorsProp, onSavedColorsChange, defaultMode = 'solid', mode: modeProp, onModeChange, gradientValue: gradientProp, onGradientChange, size = 'md', state = 'default', disabled = false, label, helperText, required = false, theme, className, children, ...props }, ref) => {
|
|
34
|
+
const ColorPickerRoot = React__default.forwardRef(({ value, defaultValue = '#000000', onChange, format: initialFormat = 'hex', showAlpha = true, showEyeDropper = true, presetColors, savedColors: savedColorsProp, onSavedColorsChange, defaultMode = 'solid', mode: modeProp, onModeChange, gradientValue: gradientProp, onGradientChange, size = 'md', state = 'default', disabled = false, label, helperText, required = false, theme, className, id, children, ...props }, ref) => {
|
|
35
|
+
const generatedId = React__default.useId();
|
|
36
|
+
const componentId = id || generatedId;
|
|
37
|
+
const stopIdRef = useRef(0);
|
|
35
38
|
// Parse initial color value
|
|
36
39
|
const initialColor = useMemo(() => {
|
|
37
40
|
const parsed = parseColor(value || defaultValue);
|
|
@@ -71,7 +74,7 @@ const ColorPickerRoot = React__default.forwardRef(({ value, defaultValue = '#000
|
|
|
71
74
|
}, [gradient, setGradient]);
|
|
72
75
|
const addGradientStop = useCallback((position) => {
|
|
73
76
|
const newStop = {
|
|
74
|
-
id: `stop-${
|
|
77
|
+
id: `stop-${++stopIdRef.current}`,
|
|
75
78
|
color: formatHex(color.h, color.s, color.l),
|
|
76
79
|
position: Math.round(position),
|
|
77
80
|
};
|
|
@@ -252,7 +255,7 @@ const ColorPickerRoot = React__default.forwardRef(({ value, defaultValue = '#000
|
|
|
252
255
|
addSavedColor,
|
|
253
256
|
removeSavedColor,
|
|
254
257
|
]);
|
|
255
|
-
return (jsx(ColorPickerContext.Provider, { value: contextValue, children: jsxs("div", { ref: ref, className: cn(mergedTheme.baseStyle, className), ...props, children: [label && (jsx(FormLabel, { htmlFor:
|
|
258
|
+
return (jsx(ColorPickerContext.Provider, { value: contextValue, children: jsxs("div", { ref: ref, className: cn(mergedTheme.baseStyle, className), ...props, children: [label && (typeof label === 'string' ? (jsx(FormLabel, { htmlFor: componentId, required: required, state: state, children: label })) : (label)), children, helperText && (typeof helperText === 'string' ? (jsx("div", { id: `${componentId}-helper`, className: cn('mt-1.5 text-sm text-[var(--color-text-secondary)]', state === 'invalid' && 'text-[var(--color-danger)]'), children: helperText })) : (helperText))] }) }));
|
|
256
259
|
});
|
|
257
260
|
ColorPickerRoot.displayName = 'ColorPicker';
|
|
258
261
|
/**
|
|
@@ -83,11 +83,11 @@ export interface ColorPickerProps extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
83
83
|
/**
|
|
84
84
|
* Label for the color picker
|
|
85
85
|
*/
|
|
86
|
-
label?:
|
|
86
|
+
label?: React.ReactNode;
|
|
87
87
|
/**
|
|
88
88
|
* Helper text displayed below the picker
|
|
89
89
|
*/
|
|
90
|
-
helperText?:
|
|
90
|
+
helperText?: React.ReactNode;
|
|
91
91
|
/**
|
|
92
92
|
* Whether the picker is required
|
|
93
93
|
* @default false
|
|
@@ -66,9 +66,11 @@ const ColorPickerBody = ({ children, className, portal = true, animation = true,
|
|
|
66
66
|
damping: 30,
|
|
67
67
|
}, "data-state": isOpen ? 'open' : 'closed', ...domProps, children: children })) }));
|
|
68
68
|
// Use portal if specified (same as Dropdown)
|
|
69
|
-
|
|
70
|
-
?
|
|
71
|
-
:
|
|
69
|
+
if (portal) {
|
|
70
|
+
const target = isClient ? document.body : null;
|
|
71
|
+
return target ? createPortal(content, target) : null;
|
|
72
|
+
}
|
|
73
|
+
return content;
|
|
72
74
|
};
|
|
73
75
|
ColorPickerBody.displayName = 'ColorPicker.Body';
|
|
74
76
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { EyeDropperIcon } from '@heroicons/react/20/solid';
|
|
3
|
-
import { useContext } from 'react';
|
|
3
|
+
import { useContext, useMemo } from 'react';
|
|
4
4
|
import { cn } from '../../../utils/cn.js';
|
|
5
5
|
import { Button } from '../../core/Button/Button.js';
|
|
6
6
|
import { ColorPickerContext } from './ColorPickerContext.js';
|
|
7
7
|
import { parseColor } from './colorUtils.js';
|
|
8
8
|
|
|
9
|
-
// Check if browser supports EyeDropper API
|
|
10
|
-
const supportsEyeDropper = typeof window !== 'undefined' && 'EyeDropper' in window;
|
|
11
9
|
/**
|
|
12
10
|
* ColorPickerEyeDropper - Eyedropper tool to pick colors from screen
|
|
13
11
|
* Uses browser EyeDropper API (if available)
|
|
14
12
|
*/
|
|
15
13
|
const ColorPickerEyeDropper = ({ className, ...props }) => {
|
|
16
14
|
const context = useContext(ColorPickerContext);
|
|
15
|
+
// Check if browser supports EyeDropper API (inside component to avoid SSR module-caching issues)
|
|
16
|
+
const supportsEyeDropper = useMemo(() => typeof window !== 'undefined' && 'EyeDropper' in window, []);
|
|
17
17
|
if (!context) {
|
|
18
18
|
throw new Error('ColorPickerEyeDropper must be used within a ColorPicker');
|
|
19
19
|
}
|
|
@@ -113,14 +113,14 @@ const ColorPickerGradient = ({ className, ...props }) => {
|
|
|
113
113
|
setDragStopId(null);
|
|
114
114
|
}, []);
|
|
115
115
|
useEffect(() => {
|
|
116
|
-
if (dragStopId)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
116
|
+
if (!dragStopId)
|
|
117
|
+
return; // no listeners to add; no cleanup needed
|
|
118
|
+
window.addEventListener('pointermove', handlePointerMove);
|
|
119
|
+
window.addEventListener('pointerup', handlePointerUp);
|
|
120
|
+
return () => {
|
|
121
|
+
window.removeEventListener('pointermove', handlePointerMove);
|
|
122
|
+
window.removeEventListener('pointerup', handlePointerUp);
|
|
123
|
+
};
|
|
124
124
|
}, [dragStopId, handlePointerMove, handlePointerUp]);
|
|
125
125
|
// --- Selected stop color input editing ---
|
|
126
126
|
const [colorInput, setColorInput] = useState((_c = selectedStop === null || selectedStop === void 0 ? void 0 : selectedStop.color) !== null && _c !== void 0 ? _c : '');
|
|
@@ -20,7 +20,7 @@ const ColorPickerInput = ({ className, ...props }) => {
|
|
|
20
20
|
if (!isInvalid) {
|
|
21
21
|
setInputValue(getFormattedValue());
|
|
22
22
|
}
|
|
23
|
-
}, [color, format]);
|
|
23
|
+
}, [color, format, getFormattedValue, isInvalid]);
|
|
24
24
|
const handleCopy = async () => {
|
|
25
25
|
try {
|
|
26
26
|
await navigator.clipboard.writeText(getFormattedValue());
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Compound component following Flikkui patterns
|
|
4
4
|
*/
|
|
5
5
|
export { ColorPicker } from './ColorPicker';
|
|
6
|
-
export { useColorPicker
|
|
6
|
+
export { useColorPicker } from './ColorPickerContext';
|
|
7
7
|
export { ColorPickerTrigger } from './ColorPickerTrigger';
|
|
8
8
|
export { ColorPickerBody } from './ColorPickerBody';
|
|
9
9
|
export { ColorPicker2DCanvas } from './ColorPicker2DCanvas';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import React__default, { useId, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import { AnimatePresence, motion } from 'motion/react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
@@ -11,43 +11,16 @@ import { cn } from '../../../utils/cn.js';
|
|
|
11
11
|
import { SelectProvider, useSelectContext } from '../Select/Select.js';
|
|
12
12
|
import '../Select/Select.theme.js';
|
|
13
13
|
import { useIsClient } from '../../../hooks/useIsClient.js';
|
|
14
|
+
import { useDarkMode } from '../../../hooks/useDarkMode.js';
|
|
14
15
|
import { useSelectState } from '../Select/useSelectState.js';
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
* Hook to detect dark mode state from document
|
|
18
|
-
*/
|
|
19
|
-
const useDarkMode = () => {
|
|
20
|
-
const [isDark, setIsDark] = React__default.useState(false);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (typeof document === "undefined")
|
|
23
|
-
return;
|
|
24
|
-
const checkDarkMode = () => {
|
|
25
|
-
const hasDarkClass = document.documentElement.classList.contains("dark") ||
|
|
26
|
-
document.body.classList.contains("dark") ||
|
|
27
|
-
document.querySelector(".dark") !== null;
|
|
28
|
-
setIsDark(hasDarkClass);
|
|
29
|
-
};
|
|
30
|
-
checkDarkMode();
|
|
31
|
-
const observer = new MutationObserver(checkDarkMode);
|
|
32
|
-
observer.observe(document.documentElement, {
|
|
33
|
-
attributes: true,
|
|
34
|
-
attributeFilter: ["class"],
|
|
35
|
-
});
|
|
36
|
-
observer.observe(document.body, {
|
|
37
|
-
attributes: true,
|
|
38
|
-
attributeFilter: ["class"],
|
|
39
|
-
});
|
|
40
|
-
return () => observer.disconnect();
|
|
41
|
-
}, []);
|
|
42
|
-
return isDark;
|
|
43
|
-
};
|
|
44
17
|
/**
|
|
45
18
|
* Default filter function for options
|
|
46
19
|
*/
|
|
47
20
|
const defaultFilterFn = (option, inputValue) => {
|
|
48
21
|
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
49
22
|
};
|
|
50
|
-
const ComboboxOptions = ({ isOpen, onClose, triggerRef, portal, placement, offset, emptyMessage, className, }) => {
|
|
23
|
+
const ComboboxOptions = ({ isOpen, onClose, triggerRef, portal, placement, offset, emptyMessage, className, listboxId, comboboxId, }) => {
|
|
51
24
|
var _a;
|
|
52
25
|
const { filteredOptions, highlightedIndex, setHighlightedIndex, selectedValue, selectOption, optionsRef, theme, } = useSelectContext();
|
|
53
26
|
const isDarkMode = useDarkMode();
|
|
@@ -105,7 +78,7 @@ const ComboboxOptions = ({ isOpen, onClose, triggerRef, portal, placement, offse
|
|
|
105
78
|
const disabledOptionStyle = theme.disabledOptionStyle || comboboxTheme.disabledOptionStyle;
|
|
106
79
|
const createOptionStyleTheme = theme.createOptionStyle || comboboxTheme.createOptionStyle;
|
|
107
80
|
const emptyMessageStyle = comboboxTheme.emptyMessageStyle;
|
|
108
|
-
const optionsContent = (jsx(AnimatePresence, { mode: "wait", children: isOpen && (jsx(motion.div, { ref: combinedRef, role: "listbox", className: cn(dropdownStyle, className), style: {
|
|
81
|
+
const optionsContent = (jsx(AnimatePresence, { mode: "wait", children: isOpen && (jsx(motion.div, { ref: combinedRef, id: listboxId, role: "listbox", className: cn(dropdownStyle, className), style: {
|
|
109
82
|
...cssVariables,
|
|
110
83
|
overscrollBehavior: "contain",
|
|
111
84
|
...(portal
|
|
@@ -115,17 +88,17 @@ const ComboboxOptions = ({ isOpen, onClose, triggerRef, portal, placement, offse
|
|
|
115
88
|
width: `${position.width}px`,
|
|
116
89
|
}
|
|
117
90
|
: {}),
|
|
118
|
-
}, tabIndex: -1, variants: animations, initial: "initial", animate: "visible", exit: "exit", children: filteredOptions.length === 0 ? (jsx("div", { className: emptyMessageStyle, children: emptyMessage })) : (filteredOptions.map((option, index) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
91
|
+
}, tabIndex: -1, variants: animations, initial: "initial", animate: "visible", exit: "exit", children: filteredOptions.length === 0 ? (jsx("div", { className: emptyMessageStyle, children: emptyMessage })) : (jsxs(Fragment, { children: [(filteredOptions.length > 100 ? filteredOptions.slice(0, 100) : filteredOptions).map((option, index) => {
|
|
92
|
+
const isSelected = option.value === selectedValue;
|
|
93
|
+
const isHighlighted = index === highlightedIndex;
|
|
94
|
+
const isCreateOption = option.id === "__create__";
|
|
95
|
+
return (jsx("div", { id: comboboxId ? `${comboboxId}-option-${option.id}` : undefined, role: "option", "aria-selected": isSelected, "aria-disabled": option.disabled, "data-option-index": index, className: cn(optionStyle, isSelected && selectedOptionStyle, isHighlighted && highlightedOptionStyle, option.disabled && disabledOptionStyle, isCreateOption && createOptionStyleTheme), onMouseEnter: () => !option.disabled && setHighlightedIndex(index), onClick: () => {
|
|
96
|
+
if (!option.disabled) {
|
|
97
|
+
selectOption(option.value, isCreateOption);
|
|
98
|
+
onClose();
|
|
99
|
+
}
|
|
100
|
+
}, children: isCreateOption ? (jsxs("span", { className: "flex items-center gap-1", children: [jsx(PlusIcon, { className: "size-4 shrink-0", strokeWidth: 2 }), jsx("span", { className: "block truncate", children: option.label })] })) : (jsx("span", { className: "block truncate", children: option.label })) }, option.id));
|
|
101
|
+
}), filteredOptions.length > 100 && (jsxs("div", { className: "px-3 py-2 text-xs text-[var(--color-text-muted)] text-center border-t border-[var(--color-border)]", children: ["Showing 100 of ", filteredOptions.length, " results \u2014 refine your search"] }))] })) })) }));
|
|
129
102
|
if (portal && isClient) {
|
|
130
103
|
return createPortal(jsx("div", { className: isDarkMode ? "dark" : undefined, children: optionsContent }), document.body);
|
|
131
104
|
}
|
|
@@ -153,7 +126,7 @@ const ComboboxOptions = ({ isOpen, onClose, triggerRef, portal, placement, offse
|
|
|
153
126
|
* />
|
|
154
127
|
* ```
|
|
155
128
|
*/
|
|
156
|
-
const ComboboxInner = ({ options, value, onChange, placeholder = "Search...", label, helperText, size = "md", state = "default", clearable = true, iconStart, openOnFocus = true, filterFn = defaultFilterFn, emptyMessage = "No results found", creatable = false, onCreateOption, createLabel, required = false, name, className, wrapperClassName, inputClassName, dropdownClassName, theme: themeOverrides, portal = true, placement = "bottom-start", offset = 8, id, ...props }, ref) => {
|
|
129
|
+
const ComboboxInner = ({ options, value, onChange, placeholder = "Search...", label, helperText, size = "md", state = "default", clearable = true, iconStart, iconEnd, openOnFocus = true, filterFn = defaultFilterFn, emptyMessage = "No results found", creatable = false, onCreateOption, createLabel, required = false, name, className, wrapperClassName, inputClassName, dropdownClassName, theme: themeOverrides, portal = true, placement = "bottom-start", offset = 8, id, ...props }, ref) => {
|
|
157
130
|
var _a;
|
|
158
131
|
// Merge theme
|
|
159
132
|
const theme = React__default.useMemo(() => ({ ...comboboxTheme, ...(themeOverrides || {}) }), [themeOverrides]);
|
|
@@ -385,17 +358,19 @@ const ComboboxInner = ({ options, value, onChange, placeholder = "Search...", la
|
|
|
385
358
|
const showClearButton = clearable && value !== undefined && !isDisabled;
|
|
386
359
|
// Icon padding
|
|
387
360
|
const hasLeftIcon = Boolean(iconStart);
|
|
361
|
+
const hasRightIcon = Boolean(iconEnd);
|
|
388
362
|
const iconStartPadding = hasLeftIcon ? theme.iconPadding.left : "";
|
|
363
|
+
const iconEndPadding = hasRightIcon ? theme.iconPadding.right : "";
|
|
389
364
|
// Create a modified selectState for the provider with our custom filtered options
|
|
390
365
|
const modifiedSelectState = React__default.useMemo(() => ({
|
|
391
366
|
...selectState,
|
|
392
367
|
filteredOptions: customFilteredOptions,
|
|
393
368
|
selectOption: handleSelectOption,
|
|
394
369
|
}), [selectState, customFilteredOptions, handleSelectOption]);
|
|
395
|
-
return (jsx(SelectProvider, { selectState: modifiedSelectState, size: size, componentState: state, theme: theme, searchable: true, enableTypeahead: false, children: jsxs("div", { ref: ref, className: cn("relative", containerClasses, stateClass, wrapperClassName), ...props, children: [label && (jsx(FormLabel, { htmlFor: comboboxId, required: required, children: label })), jsxs("div", { ref: wrapperRef, className: theme.wrapperStyle, children: [jsx("div", { className: cn(inputGroupClasses, stateClasses, className), children: jsxs("div", { className: "relative flex-1", children: [jsx("input", { ref: inputRef, id: comboboxId, type: "text", role: "combobox", "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-controls": listboxId, "aria-activedescendant": highlightedIndex >= 0 &&
|
|
370
|
+
return (jsx(SelectProvider, { selectState: modifiedSelectState, size: size, componentState: state, theme: theme, searchable: true, enableTypeahead: false, children: jsxs("div", { ref: ref, className: cn("relative", containerClasses, stateClass, wrapperClassName), ...props, children: [label && (typeof label === 'string' ? (jsx(FormLabel, { htmlFor: comboboxId, state: state, required: required, children: label })) : (label)), jsxs("div", { ref: wrapperRef, className: theme.wrapperStyle, children: [jsx("div", { className: cn(inputGroupClasses, stateClasses, className), children: jsxs("div", { className: "relative flex-1", children: [jsx("input", { ref: inputRef, id: comboboxId, type: "text", role: "combobox", "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-controls": listboxId, "aria-activedescendant": highlightedIndex >= 0 &&
|
|
396
371
|
customFilteredOptions[highlightedIndex]
|
|
397
372
|
? `${comboboxId}-option-${customFilteredOptions[highlightedIndex].id}`
|
|
398
|
-
: undefined, "aria-autocomplete": "list", "aria-invalid": isInvalid, autoComplete: "off", className: cn(inputClasses, sizeClasses, iconStartPadding, showClearButton && "pr-8", inputClassName), value: searchValue, onChange: handleInputChange, onFocus: handleInputFocus, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isDisabled, required: required }), hasLeftIcon && (jsx("div", { className: theme.iconStartStyle, children: iconStart })), showClearButton && (jsx("button", { type: "button", className: theme.clearButtonStyle, onClick: handleClear, "aria-label": "Clear selection", tabIndex: -1, children: jsx(XMarkIcon, { className: theme.clearIconStyle }) }))] }) }), jsx(ComboboxOptions, { isOpen: isOpen, onClose: () => setIsOpen(false), triggerRef: wrapperRef, portal: portal, placement: placement, offset: offset, emptyMessage: emptyMessage, className: dropdownClassName })] }), helperText && (jsx("p", { className: cn(helperTextClasses, helperTextStateClasses), children: helperText })), name && (jsx("input", { type: "hidden", name: name, value: value !== undefined ? String(value) : "" }))] }) }));
|
|
373
|
+
: undefined, "aria-autocomplete": "list", "aria-invalid": isInvalid, "aria-describedby": helperText ? `${comboboxId}-helper` : undefined, autoComplete: "off", className: cn(inputClasses, sizeClasses, iconStartPadding, (hasRightIcon || showClearButton) && iconEndPadding, showClearButton && "pr-8", inputClassName), value: searchValue, onChange: handleInputChange, onFocus: handleInputFocus, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isDisabled, required: required }), hasLeftIcon && (jsx("div", { className: theme.iconStartStyle, children: iconStart })), showClearButton && (jsx("button", { type: "button", className: theme.clearButtonStyle, onClick: handleClear, "aria-label": "Clear selection", tabIndex: -1, children: jsx(XMarkIcon, { className: theme.clearIconStyle }) })), hasRightIcon && !showClearButton && (jsx("div", { className: theme.iconEndStyle, children: iconEnd }))] }) }), jsx(ComboboxOptions, { isOpen: isOpen, onClose: () => setIsOpen(false), triggerRef: wrapperRef, portal: portal, placement: placement, offset: offset, emptyMessage: emptyMessage, className: dropdownClassName, listboxId: listboxId, comboboxId: comboboxId })] }), helperText && (typeof helperText === 'string' ? (jsx("p", { id: `${comboboxId}-helper`, className: cn(helperTextClasses, helperTextStateClasses), children: helperText })) : (helperText)), name && (jsx("input", { type: "hidden", name: name, value: value !== undefined ? String(value) : "" }))] }) }));
|
|
399
374
|
};
|
|
400
375
|
const ComboboxForwarded = React__default.forwardRef(ComboboxInner);
|
|
401
376
|
ComboboxForwarded.displayName = "Combobox";
|
|
@@ -33,9 +33,9 @@ export interface ComboboxProps<T = string> extends Omit<React.HTMLAttributes<HTM
|
|
|
33
33
|
/** Placeholder text when no value is selected */
|
|
34
34
|
placeholder?: string;
|
|
35
35
|
/** Label text displayed above the input */
|
|
36
|
-
label?:
|
|
36
|
+
label?: React.ReactNode;
|
|
37
37
|
/** Helper text displayed below the input */
|
|
38
|
-
helperText?:
|
|
38
|
+
helperText?: React.ReactNode;
|
|
39
39
|
/** Size variant */
|
|
40
40
|
size?: ComboboxSize;
|
|
41
41
|
/** State variant (controls styling) */
|
|
@@ -44,6 +44,8 @@ export interface ComboboxProps<T = string> extends Omit<React.HTMLAttributes<HTM
|
|
|
44
44
|
clearable?: boolean;
|
|
45
45
|
/** Icon displayed at the start of the input */
|
|
46
46
|
iconStart?: React.ReactNode;
|
|
47
|
+
/** Icon displayed at the end of the input */
|
|
48
|
+
iconEnd?: React.ReactNode;
|
|
47
49
|
/** Whether to open dropdown on focus (default: true) */
|
|
48
50
|
openOnFocus?: boolean;
|
|
49
51
|
/** Custom filter function */
|
|
@@ -13,9 +13,12 @@ const FieldSelect = ({ label, value, options, onChange, disabled, size = "md", c
|
|
|
13
13
|
// ============================================================================
|
|
14
14
|
// Main CronInput Component
|
|
15
15
|
// ============================================================================
|
|
16
|
-
const CronInput = React__default.forwardRef(({ value: controlledValue, defaultValue = "* * * * *", onChange, showPresets = true, showDescription = true, showNextRuns = true, nextRunCount = 3, size = "md", mode = "both", className, theme: themeOverrides, disabled = false, label, ...props }, ref) => {
|
|
16
|
+
const CronInput = React__default.forwardRef(({ value: controlledValue, defaultValue = "* * * * *", onChange, showPresets = true, showDescription = true, showNextRuns = true, nextRunCount = 3, size = "md", mode = "both", className, theme: themeOverrides, state = "default", disabled = false, label, helperText, ...props }, ref) => {
|
|
17
17
|
// Unique ID for accessibility
|
|
18
18
|
const generatedId = useId();
|
|
19
|
+
// Derive disabled/invalid from `state` prop (with deprecated `disabled` as fallback)
|
|
20
|
+
const isDisabled = state === "disabled" || disabled;
|
|
21
|
+
const isInvalid = state === "invalid";
|
|
19
22
|
// Controlled vs uncontrolled state
|
|
20
23
|
const isControlled = controlledValue !== undefined;
|
|
21
24
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
@@ -88,10 +91,10 @@ const CronInput = React__default.forwardRef(({ value: controlledValue, defaultVa
|
|
|
88
91
|
}, [rawInput, cronValue, updateValue]);
|
|
89
92
|
// Handle preset click
|
|
90
93
|
const handlePresetClick = useCallback((presetValue) => {
|
|
91
|
-
if (
|
|
94
|
+
if (isDisabled)
|
|
92
95
|
return;
|
|
93
96
|
updateValue(presetValue);
|
|
94
|
-
}, [
|
|
97
|
+
}, [isDisabled, updateValue]);
|
|
95
98
|
// Handle Enter key in raw input
|
|
96
99
|
const handleRawKeyDown = useCallback((e) => {
|
|
97
100
|
if (e.key === "Enter") {
|
|
@@ -100,7 +103,10 @@ const CronInput = React__default.forwardRef(({ value: controlledValue, defaultVa
|
|
|
100
103
|
}, [handleRawInputBlur]);
|
|
101
104
|
const showVisual = mode === "visual" || (mode === "both" && activeMode === "visual");
|
|
102
105
|
const showRaw = mode === "raw" || (mode === "both" && activeMode === "raw");
|
|
103
|
-
|
|
106
|
+
const helperId = `${generatedId}-helper`;
|
|
107
|
+
return (jsxs("div", { ref: ref, className: cn(theme.baseStyle, className), role: "group", "aria-label": label || "Cron expression builder", ...props, children: [label && (jsx(FormLabel, { htmlFor: `${generatedId}-cron`, state: isDisabled ? "disabled" : isInvalid ? "invalid" : "default", children: label })), mode === "both" && (jsxs("div", { className: "flex items-center gap-1.5", children: [jsxs("button", { type: "button", onClick: () => setActiveMode("visual"), disabled: isDisabled, className: cn(theme.modeToggleStyle, activeMode === "visual" && theme.modeToggleActiveStyle), "aria-pressed": activeMode === "visual", children: [jsx(CalendarIcon, { className: "w-3.5 h-3.5 mr-1", "aria-hidden": "true" }), "Visual"] }), jsxs("button", { type: "button", onClick: () => setActiveMode("raw"), disabled: isDisabled, className: cn(theme.modeToggleStyle, activeMode === "raw" && theme.modeToggleActiveStyle), "aria-pressed": activeMode === "raw", children: [jsx(ClockIcon, { className: "w-3.5 h-3.5 mr-1", "aria-hidden": "true" }), "Cron"] })] })), showPresets && (jsxs("div", { children: [jsx("div", { className: cn(theme.sectionHeadingStyle, "mb-1.5"), children: "Presets" }), jsx("div", { className: "flex flex-wrap gap-1.5", children: CRON_PRESETS.map((preset) => (jsx("button", { type: "button", onClick: () => handlePresetClick(preset.value), disabled: isDisabled, className: cn(theme.presetButtonStyle, activePreset === preset.value && theme.presetButtonActiveStyle), title: preset.description, "aria-pressed": activePreset === preset.value, children: preset.label }, preset.value))) })] })), showVisual && (jsxs("div", { className: cn(theme.builderStyle, isInvalid && "ring-1 ring-[var(--color-danger)] rounded-[var(--form-radius)]"), children: [jsx(FieldSelect, { label: "Minute", value: fields.minute, options: minuteOptions, onChange: (v) => handleFieldChange("minute", v), disabled: isDisabled, size: size }), jsx(FieldSelect, { label: "Hour", value: fields.hour, options: hourOptions, onChange: (v) => handleFieldChange("hour", v), disabled: isDisabled, size: size }), jsx(FieldSelect, { label: "Day of Month", value: fields.dayOfMonth, options: dayOfMonthOptions, onChange: (v) => handleFieldChange("dayOfMonth", v), disabled: isDisabled, size: size }), jsx(FieldSelect, { label: "Month", value: fields.month, options: monthOptions, onChange: (v) => handleFieldChange("month", v), disabled: isDisabled, size: size }), jsx(FieldSelect, { label: "Day of Week", value: fields.dayOfWeek, options: dayOfWeekOptions, onChange: (v) => handleFieldChange("dayOfWeek", v), disabled: isDisabled, size: size })] })), showRaw && (jsxs("div", { children: [jsx("div", { className: cn(theme.sectionHeadingStyle, "mb-1.5"), children: "Cron Expression" }), jsx("input", { type: "text", value: rawInput, onChange: handleRawInputChange, onBlur: handleRawInputBlur, onKeyDown: handleRawKeyDown, disabled: isDisabled, placeholder: "* * * * *", className: cn(theme.rawInputStyle, theme.rawInputSizes[size], isInvalid && "border-[var(--color-danger)] focus:border-[var(--color-danger)] focus:ring-[var(--color-danger)]"), id: `${generatedId}-cron`, "aria-label": "Cron expression", "aria-invalid": isInvalid || !validateCron(rawInput), "aria-describedby": helperText ? helperId : undefined, spellCheck: false, autoComplete: "off" }), !validateCron(rawInput) && rawInput !== cronValue && (jsx("div", { className: cn(theme.errorStyle, "mt-1"), children: "Invalid cron expression. Format: minute hour day month weekday" }))] })), showVisual && !showRaw && (jsxs("div", { className: "flex items-center gap-2", children: [jsx("span", { className: cn(theme.fieldLabelStyle, "shrink-0"), children: "Expression:" }), jsx("code", { className: cn("font-mono text-sm px-2 py-1 rounded-[var(--form-radius)]", "bg-[var(--color-background-secondary)] text-[var(--color-text-primary)]", "dark:bg-[var(--color-neutral-800)] dark:text-[var(--color-neutral-200)]"), children: cronValue })] })), showDescription && isValid && (jsxs("div", { className: theme.descriptionStyle, children: [jsx(ClockIcon, { className: "w-4 h-4 shrink-0", "aria-hidden": "true" }), jsx("span", { children: description })] })), showNextRuns && isValid && nextRuns.length > 0 && (jsxs("div", { className: theme.nextRunsStyle, children: [jsx("div", { className: cn(theme.sectionHeadingStyle, "mb-1"), children: "Next runs" }), nextRuns.map((date, index) => (jsxs("div", { className: theme.nextRunItemStyle, children: [jsx(CalendarIcon, { className: "w-3.5 h-3.5 shrink-0", "aria-hidden": "true" }), jsx("span", { children: formatNextRun(date) })] }, index)))] })), helperText && (jsx("div", { id: helperId, className: cn("text-sm mt-1", isInvalid
|
|
108
|
+
? "text-[var(--color-danger)]"
|
|
109
|
+
: "text-[var(--color-text-muted)]"), children: helperText }))] }));
|
|
104
110
|
});
|
|
105
111
|
CronInput.displayName = "CronInput";
|
|
106
112
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
export type CronInputState = "default" | "disabled" | "invalid";
|
|
2
3
|
/**
|
|
3
4
|
* CronInput component props
|
|
4
5
|
* A visual cron expression builder that outputs standard cron syntax
|
|
@@ -26,10 +27,20 @@ export interface CronInputProps extends Omit<React.HTMLAttributes<HTMLDivElement
|
|
|
26
27
|
className?: string;
|
|
27
28
|
/** Theme overrides for sub-component styling */
|
|
28
29
|
theme?: CronInputThemeOverrides;
|
|
29
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Validation/interaction state
|
|
32
|
+
* @default "default"
|
|
33
|
+
*/
|
|
34
|
+
state?: CronInputState;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the input is disabled
|
|
37
|
+
* @deprecated Use `state="disabled"` instead
|
|
38
|
+
*/
|
|
30
39
|
disabled?: boolean;
|
|
31
40
|
/** Label text for the component */
|
|
32
41
|
label?: string;
|
|
42
|
+
/** Helper text displayed below the component */
|
|
43
|
+
helperText?: React.ReactNode;
|
|
33
44
|
}
|
|
34
45
|
export type CronInputSize = "sm" | "md" | "lg";
|
|
35
46
|
export type CronInputMode = "visual" | "raw" | "both";
|
|
@@ -23,7 +23,7 @@ const formatDate = (date, formatString, options = {
|
|
|
23
23
|
return formatDateCustom(date, formatString);
|
|
24
24
|
}
|
|
25
25
|
// Otherwise use the Intl API
|
|
26
|
-
return date.toLocaleDateString(
|
|
26
|
+
return date.toLocaleDateString('en-US', options);
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* Format date range for display
|
|
@@ -120,7 +120,7 @@ const DatePickerComponent = React__default.forwardRef(({ id, name, mode = "singl
|
|
|
120
120
|
theme,
|
|
121
121
|
triggerRef,
|
|
122
122
|
contentRef,
|
|
123
|
-
}), [mode, isOpen, selectedValue, minDate, maxDate, isDateDisabled, showToday, selectTodayByDefault, weekdays, months, yearRange, handleDateSelect, handleRangeSelect, size, state, theme]), children: jsxs("div", { ref: ref, className: cn(containerStyle, wrapperClassName), children: [label && (jsx(FormLabel, { htmlFor: datePickerId, required: required, children: label })), jsx(DatePickerTrigger, { id: datePickerId, disabled: disabled, isOpen: isOpen, state: state, size: size, onClick: handleButtonClick, onFocus: onFocus, onBlur: onBlur, className: className, children: jsx("span", { className: cn("block truncate", selectedValue ? theme.valueTextStyle : theme.placeholderTextStyle), children: displayValue }) }), jsx(DatePickerBody, { isOpen: isOpen, onClose: () => setIsOpen(false), portal: portal, placement: placement, offset: offset, presets: presets, children: children }), helperText && (jsx("p", { className: cn(helperTextStyle, helperTextStateStyle), children: helperText })), name && mode === "single" && selectedValue instanceof Date && (jsx("input", { type: "hidden", name: name, value: selectedValue.toISOString() })), name &&
|
|
123
|
+
}), [mode, isOpen, selectedValue, minDate, maxDate, isDateDisabled, showToday, selectTodayByDefault, weekdays, months, yearRange, handleDateSelect, handleRangeSelect, size, state, theme]), children: jsxs("div", { ref: ref, className: cn(containerStyle, wrapperClassName), children: [label && (typeof label === 'string' ? (jsx(FormLabel, { htmlFor: datePickerId, state: state, required: required, children: label })) : (label)), jsx(DatePickerTrigger, { id: datePickerId, disabled: disabled, isOpen: isOpen, state: state, size: size, onClick: handleButtonClick, onFocus: onFocus, onBlur: onBlur, className: className, "aria-invalid": state === 'invalid' || undefined, "aria-describedby": helperText ? `${datePickerId}-helper` : undefined, children: jsx("span", { className: cn("block truncate", selectedValue ? theme.valueTextStyle : theme.placeholderTextStyle), children: displayValue }) }), jsx(DatePickerBody, { isOpen: isOpen, onClose: () => setIsOpen(false), portal: portal, placement: placement, offset: offset, presets: presets, children: children }), helperText && (typeof helperText === 'string' ? (jsx("p", { id: `${datePickerId}-helper`, className: cn(helperTextStyle, helperTextStateStyle), children: helperText })) : (helperText)), name && mode === "single" && selectedValue instanceof Date && (jsx("input", { type: "hidden", name: name, value: selectedValue.toISOString() })), name &&
|
|
124
124
|
mode === "range" &&
|
|
125
125
|
selectedValue &&
|
|
126
126
|
typeof selectedValue === "object" &&
|
|
@@ -49,9 +49,9 @@ export interface DatePickerProps extends Omit<React.HTMLAttributes<HTMLDivElemen
|
|
|
49
49
|
/** Whether the field is required */
|
|
50
50
|
required?: boolean;
|
|
51
51
|
/** Label for the field */
|
|
52
|
-
label?:
|
|
52
|
+
label?: React.ReactNode;
|
|
53
53
|
/** Helper text below the field */
|
|
54
|
-
helperText?:
|
|
54
|
+
helperText?: React.ReactNode;
|
|
55
55
|
/** Callback fired when a date is selected - type depends on mode */
|
|
56
56
|
onChange?: (value: Date | DateRange | null) => void;
|
|
57
57
|
/** Array of preset date ranges (only for range mode) */
|
|
@@ -110,6 +110,8 @@ export interface DatePickerTriggerProps {
|
|
|
110
110
|
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
111
111
|
onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
112
112
|
children?: React.ReactNode;
|
|
113
|
+
"aria-invalid"?: boolean;
|
|
114
|
+
"aria-describedby"?: string;
|
|
113
115
|
}
|
|
114
116
|
/**
|
|
115
117
|
* DatePicker body props (calendar dropdown content)
|
|
@@ -12,36 +12,8 @@ import { useSelectPortal } from '../../../hooks/useSelectPortal.js';
|
|
|
12
12
|
import { formatDateCustom } from '../../../utils/dateUtils.js';
|
|
13
13
|
import { createDropdownAnimations } from './DatePicker.animations.js';
|
|
14
14
|
import { useIsClient } from '../../../hooks/useIsClient.js';
|
|
15
|
+
import { useDarkMode } from '../../../hooks/useDarkMode.js';
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
* Hook to detect dark mode state from document
|
|
18
|
-
*/
|
|
19
|
-
const useDarkMode = () => {
|
|
20
|
-
const [isDark, setIsDark] = useState(false);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (typeof document === "undefined")
|
|
23
|
-
return;
|
|
24
|
-
const checkDarkMode = () => {
|
|
25
|
-
const hasDarkClass = document.documentElement.classList.contains("dark") ||
|
|
26
|
-
document.body.classList.contains("dark") ||
|
|
27
|
-
document.querySelector(".dark") !== null;
|
|
28
|
-
setIsDark(hasDarkClass);
|
|
29
|
-
};
|
|
30
|
-
checkDarkMode();
|
|
31
|
-
// Observe class changes on html and body
|
|
32
|
-
const observer = new MutationObserver(checkDarkMode);
|
|
33
|
-
observer.observe(document.documentElement, {
|
|
34
|
-
attributes: true,
|
|
35
|
-
attributeFilter: ["class"],
|
|
36
|
-
});
|
|
37
|
-
observer.observe(document.body, {
|
|
38
|
-
attributes: true,
|
|
39
|
-
attributeFilter: ["class"],
|
|
40
|
-
});
|
|
41
|
-
return () => observer.disconnect();
|
|
42
|
-
}, []);
|
|
43
|
-
return isDark;
|
|
44
|
-
};
|
|
45
17
|
/**
|
|
46
18
|
* DatePicker Body Component - contains the Calendar and optional Presets
|
|
47
19
|
* Uses portal positioning like Select component
|
|
@@ -8,7 +8,7 @@ import { DatePickerContext } from './DatePicker.js';
|
|
|
8
8
|
* DatePicker Trigger Component - styled like form input
|
|
9
9
|
* Displays selected date or placeholder text
|
|
10
10
|
*/
|
|
11
|
-
const DatePickerTrigger = ({ id, disabled, isOpen, state = "default", size = "md", className, onClick, onFocus, onBlur, children, }) => {
|
|
11
|
+
const DatePickerTrigger = ({ id, disabled, isOpen, state = "default", size = "md", className, onClick, onFocus, onBlur, children, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedby, }) => {
|
|
12
12
|
var _a, _b, _c, _d;
|
|
13
13
|
const context = useContext(DatePickerContext);
|
|
14
14
|
if (!context) {
|
|
@@ -28,7 +28,7 @@ const DatePickerTrigger = ({ id, disabled, isOpen, state = "default", size = "md
|
|
|
28
28
|
? focusStateStyle ||
|
|
29
29
|
"outline-2 outline-primary-600 -outline-offset-1 ring-4 ring-[var(--color-primary)]/10"
|
|
30
30
|
: "";
|
|
31
|
-
return (jsx("div", { className: "relative w-full", children: jsxs("button", { ref: triggerRef, id: id, type: "button", className: cn(baseStyle, sizeStyle, stateStyle, hoverStateStyle, activeFocusState, iconEndPadding, triggerButtonStyle, "text-left", className), onClick: onClick, onFocus: onFocus, onBlur: onBlur, disabled: disabled, "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-label": "Open calendar", children: [children, jsx("span", { className: iconEndStyle, children: jsx(CalendarIcon, { className: "h-4 w-4" }) })] }) }));
|
|
31
|
+
return (jsx("div", { className: "relative w-full", children: jsxs("button", { ref: triggerRef, id: id, type: "button", className: cn(baseStyle, sizeStyle, stateStyle, hoverStateStyle, activeFocusState, iconEndPadding, triggerButtonStyle, "text-left", className), onClick: onClick, onFocus: onFocus, onBlur: onBlur, disabled: disabled, "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-label": "Open calendar", "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedby, children: [children, jsx("span", { className: iconEndStyle, children: jsx(CalendarIcon, { className: "h-4 w-4" }) })] }) }));
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export { DatePickerTrigger };
|
|
@@ -21,7 +21,7 @@ const formatDate = (date, formatString, options = {
|
|
|
21
21
|
if (formatString) {
|
|
22
22
|
return formatDateCustom(date, formatString);
|
|
23
23
|
}
|
|
24
|
-
return date.toLocaleDateString(
|
|
24
|
+
return date.toLocaleDateString('en-US', options);
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
27
|
* Format date range for display
|
|
@@ -96,9 +96,9 @@ const DateRangePickerComponent = React__default.forwardRef(({ id, name, size = "
|
|
|
96
96
|
size,
|
|
97
97
|
state,
|
|
98
98
|
theme,
|
|
99
|
-
]), children: jsxs("div", { ref: ref, className: cn(theme.containerStyle, wrapperClassName), ...rest, children: [label && (jsx(FormLabel, { htmlFor: pickerId, required: required, children: label })), jsx(DateRangePickerTrigger, { id: pickerId, disabled: disabled, isOpen: isOpen, state: state, size: size, onClick: handleButtonClick, onFocus: onFocus, onBlur: onBlur, className: className, children: jsx("span", { className: cn("block truncate", selectedRange && (selectedRange.start || selectedRange.end)
|
|
99
|
+
]), children: jsxs("div", { ref: ref, className: cn(theme.containerStyle, wrapperClassName), ...rest, children: [label && (typeof label === 'string' ? (jsx(FormLabel, { htmlFor: pickerId, state: state, required: required, children: label })) : (label)), jsx(DateRangePickerTrigger, { id: pickerId, disabled: disabled, isOpen: isOpen, state: state, size: size, onClick: handleButtonClick, onFocus: onFocus, onBlur: onBlur, className: className, "aria-invalid": state === 'invalid' || undefined, "aria-describedby": helperText ? `${pickerId}-helper` : undefined, children: jsx("span", { className: cn("block truncate", selectedRange && (selectedRange.start || selectedRange.end)
|
|
100
100
|
? theme.valueTextStyle
|
|
101
|
-
: theme.placeholderTextStyle), children: displayValue }) }), jsx(DateRangePickerBody, { isOpen: isOpen, onClose: () => setIsOpen(false), portal: portal, placement: placement, offset: offset, presets: presets, showPresets: showPresets }), helperText && (jsx("p", { className: cn(theme.helperTextStyle, theme.helperTextStates[state]), children: helperText })), name && selectedRange && (jsxs(Fragment, { children: [jsx("input", { type: "hidden", name: `${name}[start]`, value: ((_a = selectedRange.start) === null || _a === void 0 ? void 0 : _a.toISOString()) || "" }), jsx("input", { type: "hidden", name: `${name}[end]`, value: ((_b = selectedRange.end) === null || _b === void 0 ? void 0 : _b.toISOString()) || "" })] }))] }) }));
|
|
101
|
+
: theme.placeholderTextStyle), children: displayValue }) }), jsx(DateRangePickerBody, { isOpen: isOpen, onClose: () => setIsOpen(false), portal: portal, placement: placement, offset: offset, presets: presets, showPresets: showPresets }), helperText && (typeof helperText === 'string' ? (jsx("p", { id: `${pickerId}-helper`, className: cn(theme.helperTextStyle, theme.helperTextStates[state]), children: helperText })) : (helperText)), name && selectedRange && (jsxs(Fragment, { children: [jsx("input", { type: "hidden", name: `${name}[start]`, value: ((_a = selectedRange.start) === null || _a === void 0 ? void 0 : _a.toISOString()) || "" }), jsx("input", { type: "hidden", name: `${name}[end]`, value: ((_b = selectedRange.end) === null || _b === void 0 ? void 0 : _b.toISOString()) || "" })] }))] }) }));
|
|
102
102
|
});
|
|
103
103
|
DateRangePickerComponent.displayName = "DateRangePicker";
|
|
104
104
|
// Compound component
|