@optilogic/core 1.0.0-beta.16 → 1.0.0-beta.18
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/index.cjs +145 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +145 -43
- package/dist/index.js.map +1 -1
- package/dist/styles.css +8 -0
- package/dist/tailwind-preset.cjs +9 -1
- package/dist/tailwind-preset.cjs.map +1 -1
- package/dist/tailwind-preset.js +9 -1
- package/dist/tailwind-preset.js.map +1 -1
- package/package.json +1 -1
- package/src/components/autocomplete.tsx +2 -1
- package/src/components/button.tsx +10 -8
- package/src/components/calendar.tsx +7 -7
- package/src/components/data-grid/DataGrid.tsx +6 -1
- package/src/components/data-grid/components/CellEditor.tsx +3 -3
- package/src/components/data-grid/hooks/useDataGridState.ts +18 -3
- package/src/components/data-grid/types.ts +4 -0
- package/src/components/data-grid/utils/dataProcessing.ts +40 -11
- package/src/components/date-picker.tsx +2 -1
- package/src/components/dropdown-menu.tsx +1 -1
- package/src/components/file-view/components/HtmlRenderer.tsx +1 -1
- package/src/components/input.tsx +1 -1
- package/src/components/popover.tsx +1 -1
- package/src/components/select.tsx +1 -1
- package/src/components/switch.tsx +5 -3
- package/src/components/textarea.tsx +1 -1
- package/src/styles.css +8 -0
- package/src/tailwind-preset.ts +10 -1
- package/src/theme/index.ts +5 -0
- package/src/theme/presets.ts +35 -2
- package/src/theme/types.ts +14 -0
- package/src/theme/utils.ts +203 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClassValue } from 'clsx';
|
|
2
2
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
+
import { MutableRefObject } from 'react';
|
|
4
5
|
import { VariantProps } from 'class-variance-authority';
|
|
5
6
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
6
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -1488,6 +1489,8 @@ interface ColumnDef<T = Record<string, CellValue>> {
|
|
|
1488
1489
|
cell?: (row: T, rowIndex: number) => React$1.ReactNode;
|
|
1489
1490
|
/** Accessor function to get cell value (defaults to row[key]) */
|
|
1490
1491
|
accessor?: (row: T) => CellValue;
|
|
1492
|
+
/** Data type hint for sorting/comparison (auto-detected from values if omitted) */
|
|
1493
|
+
dataType?: "string" | "number" | "date" | "boolean";
|
|
1491
1494
|
/** Whether this column is sortable */
|
|
1492
1495
|
sortable?: boolean;
|
|
1493
1496
|
/** Custom sort comparator function */
|
|
@@ -1874,6 +1877,8 @@ interface UseDataGridStateReturn {
|
|
|
1874
1877
|
commitEdit: (value?: CellValue) => void;
|
|
1875
1878
|
cancelEdit: () => void;
|
|
1876
1879
|
};
|
|
1880
|
+
/** Ref that DataGrid should populate with the current processedData array */
|
|
1881
|
+
processedDataRef: MutableRefObject<unknown[]>;
|
|
1877
1882
|
isControlled: {
|
|
1878
1883
|
sorting: boolean;
|
|
1879
1884
|
filters: boolean;
|
|
@@ -2223,12 +2228,18 @@ interface Theme {
|
|
|
2223
2228
|
border: string;
|
|
2224
2229
|
input: string;
|
|
2225
2230
|
ring: string;
|
|
2231
|
+
/** Interactive control colors (optional, with fallbacks) */
|
|
2232
|
+
toggleTrack?: string;
|
|
2233
|
+
toggleTrackForeground?: string;
|
|
2234
|
+
inputHover?: string;
|
|
2226
2235
|
/** Chart colors */
|
|
2227
2236
|
chart1: string;
|
|
2228
2237
|
chart2: string;
|
|
2229
2238
|
chart3: string;
|
|
2230
2239
|
chart4: string;
|
|
2231
2240
|
chart5: string;
|
|
2241
|
+
/** Disabled state */
|
|
2242
|
+
disabledOpacity?: string;
|
|
2232
2243
|
/** Border radius */
|
|
2233
2244
|
radius?: string;
|
|
2234
2245
|
}
|
|
@@ -2270,6 +2281,9 @@ interface ThemeHSL extends Omit<Theme, keyof ThemeColorFields> {
|
|
|
2270
2281
|
border: string;
|
|
2271
2282
|
input: string;
|
|
2272
2283
|
ring: string;
|
|
2284
|
+
toggleTrack?: string;
|
|
2285
|
+
toggleTrackForeground?: string;
|
|
2286
|
+
inputHover?: string;
|
|
2273
2287
|
chart1: string;
|
|
2274
2288
|
chart2: string;
|
|
2275
2289
|
chart3: string;
|
|
@@ -2302,6 +2316,9 @@ type ThemeColorFields = {
|
|
|
2302
2316
|
border: string;
|
|
2303
2317
|
input: string;
|
|
2304
2318
|
ring: string;
|
|
2319
|
+
toggleTrack?: string;
|
|
2320
|
+
toggleTrackForeground?: string;
|
|
2321
|
+
inputHover?: string;
|
|
2305
2322
|
chart1: string;
|
|
2306
2323
|
chart2: string;
|
|
2307
2324
|
chart3: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClassValue } from 'clsx';
|
|
2
2
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
|
+
import { MutableRefObject } from 'react';
|
|
4
5
|
import { VariantProps } from 'class-variance-authority';
|
|
5
6
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
6
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -1488,6 +1489,8 @@ interface ColumnDef<T = Record<string, CellValue>> {
|
|
|
1488
1489
|
cell?: (row: T, rowIndex: number) => React$1.ReactNode;
|
|
1489
1490
|
/** Accessor function to get cell value (defaults to row[key]) */
|
|
1490
1491
|
accessor?: (row: T) => CellValue;
|
|
1492
|
+
/** Data type hint for sorting/comparison (auto-detected from values if omitted) */
|
|
1493
|
+
dataType?: "string" | "number" | "date" | "boolean";
|
|
1491
1494
|
/** Whether this column is sortable */
|
|
1492
1495
|
sortable?: boolean;
|
|
1493
1496
|
/** Custom sort comparator function */
|
|
@@ -1874,6 +1877,8 @@ interface UseDataGridStateReturn {
|
|
|
1874
1877
|
commitEdit: (value?: CellValue) => void;
|
|
1875
1878
|
cancelEdit: () => void;
|
|
1876
1879
|
};
|
|
1880
|
+
/** Ref that DataGrid should populate with the current processedData array */
|
|
1881
|
+
processedDataRef: MutableRefObject<unknown[]>;
|
|
1877
1882
|
isControlled: {
|
|
1878
1883
|
sorting: boolean;
|
|
1879
1884
|
filters: boolean;
|
|
@@ -2223,12 +2228,18 @@ interface Theme {
|
|
|
2223
2228
|
border: string;
|
|
2224
2229
|
input: string;
|
|
2225
2230
|
ring: string;
|
|
2231
|
+
/** Interactive control colors (optional, with fallbacks) */
|
|
2232
|
+
toggleTrack?: string;
|
|
2233
|
+
toggleTrackForeground?: string;
|
|
2234
|
+
inputHover?: string;
|
|
2226
2235
|
/** Chart colors */
|
|
2227
2236
|
chart1: string;
|
|
2228
2237
|
chart2: string;
|
|
2229
2238
|
chart3: string;
|
|
2230
2239
|
chart4: string;
|
|
2231
2240
|
chart5: string;
|
|
2241
|
+
/** Disabled state */
|
|
2242
|
+
disabledOpacity?: string;
|
|
2232
2243
|
/** Border radius */
|
|
2233
2244
|
radius?: string;
|
|
2234
2245
|
}
|
|
@@ -2270,6 +2281,9 @@ interface ThemeHSL extends Omit<Theme, keyof ThemeColorFields> {
|
|
|
2270
2281
|
border: string;
|
|
2271
2282
|
input: string;
|
|
2272
2283
|
ring: string;
|
|
2284
|
+
toggleTrack?: string;
|
|
2285
|
+
toggleTrackForeground?: string;
|
|
2286
|
+
inputHover?: string;
|
|
2273
2287
|
chart1: string;
|
|
2274
2288
|
chart2: string;
|
|
2275
2289
|
chart3: string;
|
|
@@ -2302,6 +2316,9 @@ type ThemeColorFields = {
|
|
|
2302
2316
|
border: string;
|
|
2303
2317
|
input: string;
|
|
2304
2318
|
ring: string;
|
|
2319
|
+
toggleTrack?: string;
|
|
2320
|
+
toggleTrackForeground?: string;
|
|
2321
|
+
inputHover?: string;
|
|
2305
2322
|
chart1: string;
|
|
2306
2323
|
chart2: string;
|
|
2307
2324
|
chart3: string;
|
package/dist/index.js
CHANGED
|
@@ -30,17 +30,17 @@ function cn(...inputs) {
|
|
|
30
30
|
return twMerge(clsx(inputs));
|
|
31
31
|
}
|
|
32
32
|
var buttonVariants = cva(
|
|
33
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none
|
|
33
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
34
34
|
{
|
|
35
35
|
variants: {
|
|
36
36
|
variant: {
|
|
37
|
-
default: "bg-muted text-
|
|
38
|
-
primary: "bg-accent text-accent-foreground shadow hover:shadow-md",
|
|
39
|
-
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 hover:shadow-md",
|
|
40
|
-
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
41
|
-
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
42
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
43
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
37
|
+
default: "bg-muted text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:text-muted-foreground",
|
|
38
|
+
primary: "bg-accent text-accent-foreground shadow hover:shadow-md disabled:opacity-50",
|
|
39
|
+
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 hover:shadow-md disabled:opacity-50",
|
|
40
|
+
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:bg-muted/20 disabled:text-muted-foreground",
|
|
41
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 disabled:opacity-50",
|
|
42
|
+
ghost: "text-foreground hover:bg-accent hover:text-accent-foreground disabled:text-muted-foreground disabled:bg-muted/30 disabled:opacity-70",
|
|
43
|
+
link: "text-primary underline-offset-4 hover:underline disabled:opacity-50 disabled:text-muted-foreground"
|
|
44
44
|
},
|
|
45
45
|
size: {
|
|
46
46
|
default: "h-9 px-4 py-2",
|
|
@@ -76,7 +76,7 @@ var Input = React20.forwardRef(
|
|
|
76
76
|
{
|
|
77
77
|
type,
|
|
78
78
|
className: cn(
|
|
79
|
-
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
79
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground hover:border-input-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-input md:text-sm",
|
|
80
80
|
className
|
|
81
81
|
),
|
|
82
82
|
ref,
|
|
@@ -104,7 +104,7 @@ var Textarea = React20.forwardRef(
|
|
|
104
104
|
"textarea",
|
|
105
105
|
{
|
|
106
106
|
className: cn(
|
|
107
|
-
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
107
|
+
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground hover:border-input-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-input md:text-sm",
|
|
108
108
|
className
|
|
109
109
|
),
|
|
110
110
|
ref,
|
|
@@ -192,9 +192,11 @@ var Switch = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
192
192
|
// Focus styles
|
|
193
193
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
194
194
|
// Disabled styles
|
|
195
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
195
|
+
"disabled:cursor-not-allowed disabled:opacity-50 disabled:bg-muted",
|
|
196
196
|
// Unchecked state
|
|
197
|
-
"bg-
|
|
197
|
+
"bg-toggle-track",
|
|
198
|
+
// Hover
|
|
199
|
+
"hover:bg-toggle-track/80 data-[state=checked]:hover:bg-primary/80",
|
|
198
200
|
// Checked state
|
|
199
201
|
"data-[state=checked]:bg-primary",
|
|
200
202
|
className
|
|
@@ -207,7 +209,7 @@ var Switch = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
207
209
|
className: cn(
|
|
208
210
|
// Base styles
|
|
209
211
|
"pointer-events-none block h-4 w-4 rounded-full",
|
|
210
|
-
"bg-
|
|
212
|
+
"bg-toggle-track-foreground shadow-lg ring-0",
|
|
211
213
|
"transition-transform",
|
|
212
214
|
// Position based on state
|
|
213
215
|
"data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
@@ -270,7 +272,7 @@ var SelectTrigger = React20.forwardRef(({ className, children, ...props }, ref)
|
|
|
270
272
|
{
|
|
271
273
|
ref,
|
|
272
274
|
className: cn(
|
|
273
|
-
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
275
|
+
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border-input-hover focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-input [&>span]:line-clamp-1",
|
|
274
276
|
className
|
|
275
277
|
),
|
|
276
278
|
...props,
|
|
@@ -606,7 +608,7 @@ var PopoverContent = React20.forwardRef(({ className, align = "center", sideOffs
|
|
|
606
608
|
align,
|
|
607
609
|
sideOffset,
|
|
608
610
|
className: cn(
|
|
609
|
-
"z-50 w-
|
|
611
|
+
"z-50 w-auto max-w-[90vw] rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none",
|
|
610
612
|
// Animation
|
|
611
613
|
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
612
614
|
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
@@ -667,7 +669,7 @@ var DropdownMenuContent = React20.forwardRef(({ className, sideOffset = 4, ...pr
|
|
|
667
669
|
ref,
|
|
668
670
|
sideOffset,
|
|
669
671
|
className: cn(
|
|
670
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",
|
|
672
|
+
"z-50 min-w-[8rem] max-w-[90vw] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",
|
|
671
673
|
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
672
674
|
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
673
675
|
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
@@ -2704,19 +2706,19 @@ function Calendar({
|
|
|
2704
2706
|
className: cn("p-3", className),
|
|
2705
2707
|
classNames: {
|
|
2706
2708
|
months: "flex flex-col sm:flex-row gap-4",
|
|
2707
|
-
month: "flex flex-col gap-
|
|
2708
|
-
month_caption: "flex justify-center pt-1
|
|
2709
|
+
month: "flex flex-col gap-2 relative px-8",
|
|
2710
|
+
month_caption: "flex justify-center pt-1 items-center h-7",
|
|
2709
2711
|
caption_label: "text-sm font-medium hidden",
|
|
2710
2712
|
nav: "flex items-center gap-1",
|
|
2711
2713
|
button_previous: cn(
|
|
2712
2714
|
buttonVariants({ variant: "outline" }),
|
|
2713
|
-
"absolute left-1 h-
|
|
2715
|
+
"absolute left-1 top-1/2 -translate-y-1/2 h-6 w-6 bg-transparent p-0 opacity-50 hover:opacity-100 z-10"
|
|
2714
2716
|
),
|
|
2715
2717
|
button_next: cn(
|
|
2716
2718
|
buttonVariants({ variant: "outline" }),
|
|
2717
|
-
"absolute right-1 h-
|
|
2719
|
+
"absolute right-1 top-1/2 -translate-y-1/2 h-6 w-6 bg-transparent p-0 opacity-50 hover:opacity-100 z-10"
|
|
2718
2720
|
),
|
|
2719
|
-
month_grid: "
|
|
2721
|
+
month_grid: "border-collapse mx-auto",
|
|
2720
2722
|
weekdays: "flex",
|
|
2721
2723
|
weekday: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
|
|
2722
2724
|
week: "flex w-full mt-2",
|
|
@@ -2741,12 +2743,12 @@ function Calendar({
|
|
|
2741
2743
|
components: {
|
|
2742
2744
|
Chevron: ({ orientation }) => {
|
|
2743
2745
|
const Icon2 = orientation === "left" ? ChevronLeft : ChevronRight;
|
|
2744
|
-
return /* @__PURE__ */ jsx(Icon2, { className: "h-
|
|
2746
|
+
return /* @__PURE__ */ jsx(Icon2, { className: "h-3.5 w-3.5" });
|
|
2745
2747
|
},
|
|
2746
2748
|
MonthCaption: ({ calendarMonth }) => {
|
|
2747
2749
|
const month = calendarMonth.date.getMonth();
|
|
2748
2750
|
const year = calendarMonth.date.getFullYear();
|
|
2749
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-1
|
|
2751
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-1", children: [
|
|
2750
2752
|
/* @__PURE__ */ jsxs(
|
|
2751
2753
|
Select,
|
|
2752
2754
|
{
|
|
@@ -2982,8 +2984,9 @@ function DatePickerInput({
|
|
|
2982
2984
|
{
|
|
2983
2985
|
className: cn(
|
|
2984
2986
|
"flex items-center rounded-md border border-input bg-background ring-offset-background",
|
|
2987
|
+
"hover:border-input-hover",
|
|
2985
2988
|
"focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
|
|
2986
|
-
disabled && "opacity-50 cursor-not-allowed",
|
|
2989
|
+
disabled && "opacity-50 cursor-not-allowed hover:border-input",
|
|
2987
2990
|
sizeClasses[size]
|
|
2988
2991
|
),
|
|
2989
2992
|
children: [
|
|
@@ -3615,7 +3618,7 @@ function CellEditor({
|
|
|
3615
3618
|
onKeyDown: handleKeyDown,
|
|
3616
3619
|
onBlur: handleBlur,
|
|
3617
3620
|
className: cn(
|
|
3618
|
-
"h-full w-full border-0 rounded-none
|
|
3621
|
+
"h-full w-full border-0 rounded-none bg-background focus:ring-0 text-sm px-2",
|
|
3619
3622
|
validationError && "ring-2 ring-destructive focus:ring-destructive",
|
|
3620
3623
|
className
|
|
3621
3624
|
),
|
|
@@ -3633,7 +3636,7 @@ function CellEditor({
|
|
|
3633
3636
|
onKeyDown: handleKeyDown,
|
|
3634
3637
|
onBlur: handleBlur,
|
|
3635
3638
|
className: cn(
|
|
3636
|
-
"h-full w-full border-0 rounded-none
|
|
3639
|
+
"h-full w-full border-0 rounded-none bg-background focus:ring-0 text-sm px-2",
|
|
3637
3640
|
validationError && "ring-2 ring-destructive focus:ring-destructive",
|
|
3638
3641
|
className
|
|
3639
3642
|
),
|
|
@@ -3703,7 +3706,7 @@ function CellEditor({
|
|
|
3703
3706
|
{
|
|
3704
3707
|
ref: selectRef,
|
|
3705
3708
|
className: cn(
|
|
3706
|
-
"h-full w-full border-0 rounded-none
|
|
3709
|
+
"h-full w-full border-0 rounded-none bg-background focus:ring-0 text-sm",
|
|
3707
3710
|
validationError && "ring-2 ring-destructive focus:ring-destructive",
|
|
3708
3711
|
className
|
|
3709
3712
|
),
|
|
@@ -3848,6 +3851,7 @@ function useDataGridState(options) {
|
|
|
3848
3851
|
const [internalColumnWidths, setInternalColumnWidths] = useState(defaultColumnWidths);
|
|
3849
3852
|
const [internalFocusedCell, setInternalFocusedCell] = useState(null);
|
|
3850
3853
|
const [editingCell, setEditingCell] = useState(null);
|
|
3854
|
+
const processedDataRef = useRef([]);
|
|
3851
3855
|
const sorting = isControlled.sorting ? controlledSorting : internalSorting;
|
|
3852
3856
|
const filters = isControlled.filters ? controlledFilters : internalFilters;
|
|
3853
3857
|
const focusedCell = isControlled.focusedCell ? controlledFocusedCell : internalFocusedCell;
|
|
@@ -3968,7 +3972,8 @@ function useDataGridState(options) {
|
|
|
3968
3972
|
}
|
|
3969
3973
|
const column = columns.find((c) => c.key === columnKey);
|
|
3970
3974
|
if (!column || !column.editable) return;
|
|
3971
|
-
const
|
|
3975
|
+
const resolvedData = processedDataRef.current.length > 0 ? processedDataRef.current : data;
|
|
3976
|
+
const row = resolvedData[rowIndex];
|
|
3972
3977
|
if (!row) return;
|
|
3973
3978
|
const value = getCellValue2(row, column);
|
|
3974
3979
|
setEditingCell({
|
|
@@ -3990,7 +3995,8 @@ function useDataGridState(options) {
|
|
|
3990
3995
|
const value = valueOverride !== void 0 ? valueOverride : editingCell.value;
|
|
3991
3996
|
const column = columns.find((c) => c.key === columnKey);
|
|
3992
3997
|
if (column?.validator) {
|
|
3993
|
-
const
|
|
3998
|
+
const resolvedData = processedDataRef.current.length > 0 ? processedDataRef.current : data;
|
|
3999
|
+
const row = resolvedData[rowIndex];
|
|
3994
4000
|
const validationResult = column.validator(value, row);
|
|
3995
4001
|
if (validationResult !== true && typeof validationResult === "string") {
|
|
3996
4002
|
return;
|
|
@@ -4022,6 +4028,7 @@ function useDataGridState(options) {
|
|
|
4022
4028
|
commitEdit,
|
|
4023
4029
|
cancelEdit
|
|
4024
4030
|
},
|
|
4031
|
+
processedDataRef,
|
|
4025
4032
|
isControlled
|
|
4026
4033
|
};
|
|
4027
4034
|
}
|
|
@@ -4475,16 +4482,44 @@ function applySorting(data, sorting, columns) {
|
|
|
4475
4482
|
if (aVal == null) return sort.direction === "asc" ? 1 : -1;
|
|
4476
4483
|
if (bVal == null) return sort.direction === "asc" ? -1 : 1;
|
|
4477
4484
|
let comparison = 0;
|
|
4478
|
-
if (
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
} else {
|
|
4485
|
+
if (column.dataType === "number") {
|
|
4486
|
+
const aNum = Number(aVal);
|
|
4487
|
+
const bNum = Number(bVal);
|
|
4488
|
+
if (!isNaN(aNum) && !isNaN(bNum)) {
|
|
4489
|
+
comparison = aNum - bNum;
|
|
4490
|
+
} else {
|
|
4491
|
+
comparison = String(aVal).localeCompare(String(bVal));
|
|
4492
|
+
}
|
|
4493
|
+
} else if (column.dataType === "date") {
|
|
4494
|
+
const aDate = aVal instanceof Date ? aVal : new Date(aVal);
|
|
4495
|
+
const bDate = bVal instanceof Date ? bVal : new Date(bVal);
|
|
4496
|
+
const aTime = isNaN(aDate.getTime()) ? 0 : aDate.getTime();
|
|
4497
|
+
const bTime = isNaN(bDate.getTime()) ? 0 : bDate.getTime();
|
|
4498
|
+
comparison = aTime - bTime;
|
|
4499
|
+
} else if (column.dataType === "boolean") {
|
|
4500
|
+
const aBool = aVal === true || aVal === "true" || aVal === 1;
|
|
4501
|
+
const bBool = bVal === true || bVal === "true" || bVal === 1;
|
|
4502
|
+
comparison = aBool === bBool ? 0 : aBool ? 1 : -1;
|
|
4503
|
+
} else if (column.dataType === "string") {
|
|
4487
4504
|
comparison = String(aVal).localeCompare(String(bVal));
|
|
4505
|
+
} else {
|
|
4506
|
+
if (typeof aVal === "number" && typeof bVal === "number") {
|
|
4507
|
+
comparison = aVal - bVal;
|
|
4508
|
+
} else if (aVal instanceof Date && bVal instanceof Date) {
|
|
4509
|
+
comparison = aVal.getTime() - bVal.getTime();
|
|
4510
|
+
} else if (typeof aVal === "boolean" && typeof bVal === "boolean") {
|
|
4511
|
+
comparison = aVal === bVal ? 0 : aVal ? 1 : -1;
|
|
4512
|
+
} else {
|
|
4513
|
+
const aStr = String(aVal);
|
|
4514
|
+
const bStr = String(bVal);
|
|
4515
|
+
const aNum = Number(aStr);
|
|
4516
|
+
const bNum = Number(bStr);
|
|
4517
|
+
if (!isNaN(aNum) && !isNaN(bNum) && aStr !== "" && bStr !== "") {
|
|
4518
|
+
comparison = aNum - bNum;
|
|
4519
|
+
} else {
|
|
4520
|
+
comparison = aStr.localeCompare(bStr);
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4488
4523
|
}
|
|
4489
4524
|
return sort.direction === "asc" ? comparison : -comparison;
|
|
4490
4525
|
});
|
|
@@ -4706,7 +4741,7 @@ function DataGrid({
|
|
|
4706
4741
|
},
|
|
4707
4742
|
[]
|
|
4708
4743
|
);
|
|
4709
|
-
const { state, actions, isControlled } = useDataGridState({
|
|
4744
|
+
const { state, actions, processedDataRef, isControlled } = useDataGridState({
|
|
4710
4745
|
sorting: controlledSorting,
|
|
4711
4746
|
filters: controlledFilters,
|
|
4712
4747
|
columnWidths: controlledColumnWidths,
|
|
@@ -4745,6 +4780,7 @@ function DataGrid({
|
|
|
4745
4780
|
state.sorting,
|
|
4746
4781
|
visibleColumns
|
|
4747
4782
|
]);
|
|
4783
|
+
processedDataRef.current = processedData;
|
|
4748
4784
|
const { resizingColumn, getResizeProps } = useColumnResizeManager({
|
|
4749
4785
|
columns: visibleColumns,
|
|
4750
4786
|
columnWidths: state.columnWidths,
|
|
@@ -5080,6 +5116,7 @@ function DataGrid({
|
|
|
5080
5116
|
"flex-shrink-0 px-3 py-2 text-sm overflow-hidden",
|
|
5081
5117
|
showColumnBorders && "border-r border-border last:border-r-0",
|
|
5082
5118
|
isFocused && !isEditingThisCell && "ring-2 ring-inset ring-primary",
|
|
5119
|
+
isEditingThisCell && "ring-2 ring-inset ring-primary bg-background",
|
|
5083
5120
|
column.align === "center" && "text-center",
|
|
5084
5121
|
column.align === "right" && "text-right"
|
|
5085
5122
|
),
|
|
@@ -5249,6 +5286,7 @@ function DataGrid({
|
|
|
5249
5286
|
"flex-shrink-0 px-3 py-2 text-sm overflow-hidden",
|
|
5250
5287
|
showColumnBorders && "border-r border-border last:border-r-0",
|
|
5251
5288
|
isFocused && !isEditingThisCell && "ring-2 ring-inset ring-primary",
|
|
5289
|
+
isEditingThisCell && "ring-2 ring-inset ring-primary bg-background",
|
|
5252
5290
|
column.align === "center" && "text-center",
|
|
5253
5291
|
column.align === "right" && "text-right"
|
|
5254
5292
|
),
|
|
@@ -5504,8 +5542,9 @@ function Autocomplete({
|
|
|
5504
5542
|
disabled,
|
|
5505
5543
|
className: cn(
|
|
5506
5544
|
"flex h-9 w-full items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background",
|
|
5545
|
+
"hover:border-input-hover",
|
|
5507
5546
|
"focus:outline-none focus:ring-1 focus:ring-ring",
|
|
5508
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
5547
|
+
"disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-input",
|
|
5509
5548
|
!selectedOption && "text-muted-foreground",
|
|
5510
5549
|
className
|
|
5511
5550
|
),
|
|
@@ -5736,6 +5775,9 @@ var GREEN_THEME = {
|
|
|
5736
5775
|
border: "#243630",
|
|
5737
5776
|
input: "#243630",
|
|
5738
5777
|
ring: "#6FCF97",
|
|
5778
|
+
toggleTrack: "#354840",
|
|
5779
|
+
toggleTrackForeground: "#E6F5EC",
|
|
5780
|
+
inputHover: "#6FCF97",
|
|
5739
5781
|
chart1: "#6FCF97",
|
|
5740
5782
|
chart2: "#8FE3B0",
|
|
5741
5783
|
chart3: "#9DB8A8",
|
|
@@ -5771,8 +5813,11 @@ var OPTILOGIC_LEGACY_THEME = {
|
|
|
5771
5813
|
chip: "#B8C5F9",
|
|
5772
5814
|
chipForeground: "#0C0A5A",
|
|
5773
5815
|
border: "#D0D0D0",
|
|
5774
|
-
input: "#
|
|
5816
|
+
input: "#D0D0D0",
|
|
5775
5817
|
ring: "#5766F2",
|
|
5818
|
+
toggleTrack: "#D0D0D0",
|
|
5819
|
+
toggleTrackForeground: "#FFFFFF",
|
|
5820
|
+
inputHover: "#5766F2",
|
|
5776
5821
|
chart1: "#78D237",
|
|
5777
5822
|
chart2: "#F5CF47",
|
|
5778
5823
|
chart3: "#5766F2",
|
|
@@ -5810,6 +5855,9 @@ var FUTURISTIC_THEME = {
|
|
|
5810
5855
|
border: "#1e293b",
|
|
5811
5856
|
input: "#1e293b",
|
|
5812
5857
|
ring: "#6366f1",
|
|
5858
|
+
toggleTrack: "#334155",
|
|
5859
|
+
toggleTrackForeground: "#e0e7ff",
|
|
5860
|
+
inputHover: "#6366f1",
|
|
5813
5861
|
chart1: "#6366f1",
|
|
5814
5862
|
chart2: "#8b5cf6",
|
|
5815
5863
|
chart3: "#a855f7",
|
|
@@ -5847,6 +5895,9 @@ var NATURE_THEME = {
|
|
|
5847
5895
|
border: "#243824",
|
|
5848
5896
|
input: "#243824",
|
|
5849
5897
|
ring: "#4caf50",
|
|
5898
|
+
toggleTrack: "#3d5a3d",
|
|
5899
|
+
toggleTrackForeground: "#e8f5e9",
|
|
5900
|
+
inputHover: "#4caf50",
|
|
5850
5901
|
chart1: "#4caf50",
|
|
5851
5902
|
chart2: "#66bb6a",
|
|
5852
5903
|
chart3: "#81c784",
|
|
@@ -5884,6 +5935,9 @@ var SCIFI_THEME = {
|
|
|
5884
5935
|
border: "#30363d",
|
|
5885
5936
|
input: "#21262d",
|
|
5886
5937
|
ring: "#00d9ff",
|
|
5938
|
+
toggleTrack: "#30363d",
|
|
5939
|
+
toggleTrackForeground: "#c9d1d9",
|
|
5940
|
+
inputHover: "#00d9ff",
|
|
5887
5941
|
chart1: "#00d9ff",
|
|
5888
5942
|
chart2: "#ff00ff",
|
|
5889
5943
|
chart3: "#00ff88",
|
|
@@ -5921,6 +5975,9 @@ var OCEAN_THEME = {
|
|
|
5921
5975
|
border: "#1e3a5f",
|
|
5922
5976
|
input: "#1e3a5f",
|
|
5923
5977
|
ring: "#2196f3",
|
|
5978
|
+
toggleTrack: "#264a6e",
|
|
5979
|
+
toggleTrackForeground: "#e3f2fd",
|
|
5980
|
+
inputHover: "#2196f3",
|
|
5924
5981
|
chart1: "#2196f3",
|
|
5925
5982
|
chart2: "#00bcd4",
|
|
5926
5983
|
chart3: "#03a9f4",
|
|
@@ -5958,6 +6015,9 @@ var SUNSET_THEME = {
|
|
|
5958
6015
|
border: "#241424",
|
|
5959
6016
|
input: "#241424",
|
|
5960
6017
|
ring: "#ff6b35",
|
|
6018
|
+
toggleTrack: "#3d2a3d",
|
|
6019
|
+
toggleTrackForeground: "#ffe0e6",
|
|
6020
|
+
inputHover: "#ff6b35",
|
|
5961
6021
|
chart1: "#ff6b35",
|
|
5962
6022
|
chart2: "#c44569",
|
|
5963
6023
|
chart3: "#f7931e",
|
|
@@ -5995,6 +6055,9 @@ var FOREST_THEME = {
|
|
|
5995
6055
|
border: "#1b5e20",
|
|
5996
6056
|
input: "#1a2e1a",
|
|
5997
6057
|
ring: "#2e7d32",
|
|
6058
|
+
toggleTrack: "#2d4a2d",
|
|
6059
|
+
toggleTrackForeground: "#e8f5e9",
|
|
6060
|
+
inputHover: "#2e7d32",
|
|
5998
6061
|
chart1: "#2e7d32",
|
|
5999
6062
|
chart2: "#388e3c",
|
|
6000
6063
|
chart3: "#43a047",
|
|
@@ -6032,6 +6095,9 @@ var CYBERPUNK_THEME = {
|
|
|
6032
6095
|
border: "#1a1a2e",
|
|
6033
6096
|
input: "#16213e",
|
|
6034
6097
|
ring: "#ff00ff",
|
|
6098
|
+
toggleTrack: "#2a2a4e",
|
|
6099
|
+
toggleTrackForeground: "#f0f0f0",
|
|
6100
|
+
inputHover: "#ff00ff",
|
|
6035
6101
|
chart1: "#ff00ff",
|
|
6036
6102
|
chart2: "#00ffff",
|
|
6037
6103
|
chart3: "#00ff88",
|
|
@@ -6067,8 +6133,11 @@ var MINIMALIST_LIGHT_THEME = {
|
|
|
6067
6133
|
chip: "#e9ecef",
|
|
6068
6134
|
chipForeground: "#495057",
|
|
6069
6135
|
border: "#dee2e6",
|
|
6070
|
-
input: "#
|
|
6136
|
+
input: "#dee2e6",
|
|
6071
6137
|
ring: "#000000",
|
|
6138
|
+
toggleTrack: "#ced4da",
|
|
6139
|
+
toggleTrackForeground: "#ffffff",
|
|
6140
|
+
inputHover: "#6c757d",
|
|
6072
6141
|
chart1: "#000000",
|
|
6073
6142
|
chart2: "#6c757d",
|
|
6074
6143
|
chart3: "#adb5bd",
|
|
@@ -6106,6 +6175,9 @@ var DARK_ELEGANT_THEME = {
|
|
|
6106
6175
|
border: "#2d2d2d",
|
|
6107
6176
|
input: "#1e1e1e",
|
|
6108
6177
|
ring: "#bb86fc",
|
|
6178
|
+
toggleTrack: "#3d3d3d",
|
|
6179
|
+
toggleTrackForeground: "#e0e0e0",
|
|
6180
|
+
inputHover: "#bb86fc",
|
|
6109
6181
|
chart1: "#bb86fc",
|
|
6110
6182
|
chart2: "#03dac6",
|
|
6111
6183
|
chart3: "#4caf50",
|
|
@@ -6196,6 +6268,9 @@ function themeToHsl(theme) {
|
|
|
6196
6268
|
border: hexToHsl(theme.border),
|
|
6197
6269
|
input: hexToHsl(theme.input),
|
|
6198
6270
|
ring: hexToHsl(theme.ring),
|
|
6271
|
+
toggleTrack: theme.toggleTrack ? hexToHsl(theme.toggleTrack) : void 0,
|
|
6272
|
+
toggleTrackForeground: theme.toggleTrackForeground ? hexToHsl(theme.toggleTrackForeground) : void 0,
|
|
6273
|
+
inputHover: theme.inputHover ? hexToHsl(theme.inputHover) : void 0,
|
|
6199
6274
|
chart1: hexToHsl(theme.chart1),
|
|
6200
6275
|
chart2: hexToHsl(theme.chart2),
|
|
6201
6276
|
chart3: hexToHsl(theme.chart3),
|
|
@@ -6203,6 +6278,15 @@ function themeToHsl(theme) {
|
|
|
6203
6278
|
chart5: hexToHsl(theme.chart5)
|
|
6204
6279
|
};
|
|
6205
6280
|
}
|
|
6281
|
+
function deriveInputHoverHsl(hslTheme) {
|
|
6282
|
+
const parts = hslTheme.foreground.split(/\s+/);
|
|
6283
|
+
if (parts.length >= 3) {
|
|
6284
|
+
const h = parts[0];
|
|
6285
|
+
const s = parts[1];
|
|
6286
|
+
return `${h} ${s} 50%`;
|
|
6287
|
+
}
|
|
6288
|
+
return hslTheme.foreground;
|
|
6289
|
+
}
|
|
6206
6290
|
function applyTheme(theme, targetElement) {
|
|
6207
6291
|
const element = targetElement || document.documentElement;
|
|
6208
6292
|
const hslTheme = themeToHsl(theme);
|
|
@@ -6237,11 +6321,26 @@ function applyTheme(theme, targetElement) {
|
|
|
6237
6321
|
element.style.setProperty("--border", hslTheme.border);
|
|
6238
6322
|
element.style.setProperty("--input", hslTheme.input);
|
|
6239
6323
|
element.style.setProperty("--ring", hslTheme.ring);
|
|
6324
|
+
element.style.setProperty(
|
|
6325
|
+
"--toggle-track",
|
|
6326
|
+
hslTheme.toggleTrack ?? hslTheme.muted
|
|
6327
|
+
);
|
|
6328
|
+
element.style.setProperty(
|
|
6329
|
+
"--toggle-track-foreground",
|
|
6330
|
+
hslTheme.toggleTrackForeground ?? hslTheme.background
|
|
6331
|
+
);
|
|
6332
|
+
element.style.setProperty(
|
|
6333
|
+
"--input-hover",
|
|
6334
|
+
hslTheme.inputHover ?? deriveInputHoverHsl(hslTheme)
|
|
6335
|
+
);
|
|
6240
6336
|
element.style.setProperty("--chart-1", hslTheme.chart1);
|
|
6241
6337
|
element.style.setProperty("--chart-2", hslTheme.chart2);
|
|
6242
6338
|
element.style.setProperty("--chart-3", hslTheme.chart3);
|
|
6243
6339
|
element.style.setProperty("--chart-4", hslTheme.chart4);
|
|
6244
6340
|
element.style.setProperty("--chart-5", hslTheme.chart5);
|
|
6341
|
+
if (theme.disabledOpacity) {
|
|
6342
|
+
element.style.setProperty("--disabled-opacity", theme.disabledOpacity);
|
|
6343
|
+
}
|
|
6245
6344
|
if (theme.radius) {
|
|
6246
6345
|
element.style.setProperty("--radius", theme.radius);
|
|
6247
6346
|
}
|
|
@@ -6332,6 +6431,9 @@ function areThemesEqual(theme1, theme2) {
|
|
|
6332
6431
|
"border",
|
|
6333
6432
|
"input",
|
|
6334
6433
|
"ring",
|
|
6434
|
+
"toggleTrack",
|
|
6435
|
+
"toggleTrackForeground",
|
|
6436
|
+
"inputHover",
|
|
6335
6437
|
"chart1",
|
|
6336
6438
|
"chart2",
|
|
6337
6439
|
"chart3",
|
|
@@ -7512,7 +7614,7 @@ function HtmlRenderer({
|
|
|
7512
7614
|
"iframe",
|
|
7513
7615
|
{
|
|
7514
7616
|
srcDoc: content ?? "",
|
|
7515
|
-
sandbox: "",
|
|
7617
|
+
sandbox: "allow-scripts",
|
|
7516
7618
|
title: fileName,
|
|
7517
7619
|
className: cn("h-full w-full border-0", className)
|
|
7518
7620
|
}
|