twico-ui 1.17.2 → 1.18.0
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/CHANGELOG.md +12 -0
- package/dist/index.cjs +114 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.mjs +114 -9
- package/dist/index.mjs.map +1 -1
- package/llms.txt +4 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1901,6 +1901,19 @@ interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
1901
1901
|
* column. Use it to trim a wide grid's editor **without** touching `editable` (which would also
|
|
1902
1902
|
* disable inline cell editing). */
|
|
1903
1903
|
batchEditFields?: string[];
|
|
1904
|
+
/** Persist the full view state (filters, sort, quick-search, page, page size, column order / widths /
|
|
1905
|
+
* visibility / pinning, density) to `localStorage` under this key, and restore it on mount (#259).
|
|
1906
|
+
* SSR-safe: storage is never read during render — the server and first client render start from the
|
|
1907
|
+
* defaults, then the saved state is applied in a mount effect (so hydration never mismatches). Unknown
|
|
1908
|
+
* columns in a saved snapshot are ignored, so a later column change won't break restore. */
|
|
1909
|
+
stateKey?: string;
|
|
1910
|
+
/** Seed the view state on first mount (used only when `stateKey` has nothing stored yet). A partial
|
|
1911
|
+
* `DatatableState` — omitted keys keep their defaults. */
|
|
1912
|
+
initialState?: Partial<DatatableState>;
|
|
1913
|
+
/** Fired whenever the view state changes, with the complete `DatatableState`. Use it to persist the
|
|
1914
|
+
* state yourself (URL query, server, …) instead of — or in addition to — `stateKey`. Not fired on
|
|
1915
|
+
* the initial mount for the default state; fires once after a `stateKey`/`initialState` restore. */
|
|
1916
|
+
onStateChange?: (state: DatatableState) => void;
|
|
1904
1917
|
/** Show a "Go to" page jumper in the footer when there are more than 5 pages. @default true */
|
|
1905
1918
|
showPageJumper?: boolean;
|
|
1906
1919
|
/** Click-to-select mode: "row" highlights the clicked row, "cell" highlights a single cell. @default "none" */
|
|
@@ -1991,6 +2004,37 @@ interface DatatableQuery {
|
|
|
1991
2004
|
hiddenColumns?: string[];
|
|
1992
2005
|
}
|
|
1993
2006
|
|
|
2007
|
+
/**
|
|
2008
|
+
* The complete, serializable view state of a `Datatable` (#259) — everything the user can adjust
|
|
2009
|
+
* from the toolbar and column headers. Persisted by `stateKey`, seeded by `initialState`, and
|
|
2010
|
+
* reported by `onStateChange`. Every field is optional in `initialState`/a stored snapshot: unknown
|
|
2011
|
+
* columns are dropped and missing keys fall back to the table's defaults, so a snapshot survives a
|
|
2012
|
+
* schema change. `columnVisibility` lists only hidden columns (`{ field: false }`; absent = visible);
|
|
2013
|
+
* `columnPinning` lists only pinned columns (`{ field: "left" | "right" }`).
|
|
2014
|
+
*/
|
|
2015
|
+
interface DatatableState {
|
|
2016
|
+
/** Active per-column filters (without the internal row id). */
|
|
2017
|
+
filters: DatatableFilter[];
|
|
2018
|
+
/** Active sort, or null. */
|
|
2019
|
+
sort: { field: string; dir: "asc" | "desc" } | null;
|
|
2020
|
+
/** Quick-search text. */
|
|
2021
|
+
quickFilter: string;
|
|
2022
|
+
/** Zero-based current page. */
|
|
2023
|
+
page: number;
|
|
2024
|
+
/** Rows per page. */
|
|
2025
|
+
pageSize: number;
|
|
2026
|
+
/** Column `field`s in their current left-to-right order. */
|
|
2027
|
+
columnOrder: string[];
|
|
2028
|
+
/** User-resized column widths in px, keyed by `field`. */
|
|
2029
|
+
columnWidths: Record<string, number>;
|
|
2030
|
+
/** Hidden columns, keyed by `field` (`false` = hidden; a visible column is simply absent). */
|
|
2031
|
+
columnVisibility: Record<string, boolean>;
|
|
2032
|
+
/** Pinned columns, keyed by `field`. */
|
|
2033
|
+
columnPinning: Record<string, "left" | "right">;
|
|
2034
|
+
/** Row-density preset. */
|
|
2035
|
+
density: "compact" | "standard" | "comfortable";
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1994
2038
|
interface DatatableColumn<T = any> {
|
|
1995
2039
|
/** Row object key (also the default sort/filter/search/group/export key). */
|
|
1996
2040
|
field: string;
|
|
@@ -4174,7 +4218,9 @@ declare function useLocalStorage<T>(
|
|
|
4174
4218
|
initialValue: T
|
|
4175
4219
|
): [T, (value: T | ((prev: T) => T)) => void];
|
|
4176
4220
|
|
|
4177
|
-
/** Copy text to the clipboard with a `copied` flag that auto-resets.
|
|
4221
|
+
/** Copy text to the clipboard with a `copied` flag that auto-resets. Uses the async Clipboard API in a
|
|
4222
|
+
* secure context and falls back to a legacy `execCommand("copy")` path over plain HTTP on a LAN IP
|
|
4223
|
+
* (where `navigator.clipboard` is undefined) and in older browsers, so `copy()` works off-secure-origin. */
|
|
4178
4224
|
declare function useCopyToClipboard(timeout?: number): {
|
|
4179
4225
|
copied: boolean;
|
|
4180
4226
|
copy: (text: string) => Promise<boolean>;
|
|
@@ -4239,4 +4285,4 @@ declare function useFocusTrap<T extends HTMLElement = HTMLElement>(
|
|
|
4239
4285
|
*/
|
|
4240
4286
|
declare function usePortal(): (node: React.ReactNode) => React.ReactPortal | React.ReactNode | null;
|
|
4241
4287
|
|
|
4242
|
-
export { Accordion, type AccordionItem, type AccordionProps, type ActionTone, Alert, type AlertProps, Anchor, type AnchorProps, AppShell, type AppShellProps, Avatar, AvatarMenu, type AvatarMenuProps, type AvatarProps, Badge, type BadgeProps, type BarTone, Box, type BoxOwnProps, type BoxProps, Boxplot, type BoxplotDatum, type BoxplotProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BubbleChart, type BubbleChartProps, Button, type ButtonProps, Candlestick, type CandlestickDatum, type CandlestickProps, Card, CardGrid, type CardGridFilter, type CardGridProps, type CardGridQuery, type CardGridSort, type CardGridSortOption, type CardProps, Carousel, type CarouselProps, Chart, type ChartDatum, type ChartProps, Checkbox, type CheckboxProps, Code, type CodeProps, ColorPicker, type ColorPickerProps, ColorSchemeScript, type ColorSchemeScriptOptions, type ColorSchemeScriptProps, Combobox, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type Command, CommandPalette, type CommandPaletteProps, Container, type ContainerOwnProps, type ContainerProps, Currency, CurrencyField, type CurrencyFieldProps, type CurrencyOption, type CurrencyProps, Datatable, type DatatableBatchAction, type DatatableBatchActionContext, type DatatableColumn, type DatatableFilter, type DatatableFilterOp, type DatatableNumberOp, type DatatableProps, type DatatableQuery, type DatatableRowAction, type DatatableStringOp, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, DateTimePicker, type DateTimePickerProps, Dialog, type DialogProps, type DiffOp, DiffTable, type DiffTableColumn, type DiffTableProps, Divider, type DividerProps, DonutChart, type DonutChartDatum, type DonutChartProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, Field, type FieldProps, FileUpload, type FileUploadProps, FilterBar, type FilterBarProps, type FilterClause, type FilterField, type FilterFieldType, type FilterValues, Form, type FormProps, FunnelChart, type FunnelChartProps, type FunnelDatum, Gauge, type GaugeProps, type GaugeSeries, Grid, type GridOwnProps, type GridProps, Heading, type HeadingOwnProps, type HeadingProps, type HeadingSize, Heatmap, type HeatmapDatum, type HeatmapProps, IconButton, type IconButtonProps, Image, type ImageProps, Input, type InputProps, Kanban, type KanbanCard, type KanbanColumn, type KanbanProps, Kbd, type KbdProps, Label, type LabelProps, List, type ListItemData, type ListProps, Menu, type MenuItemDef, type MenuProps, MultiSelect, type MultiSelectGroup, type MultiSelectOption, type MultiSelectProps, Navbar, type NavbarLink, type NavbarProps, type Option, type OptionGroup, Pagination, type PaginationProps, PieChart, type PieChartDatum, type PieChartProps, PolarAreaChart, type PolarAreaChartProps, type PolarAreaDatum, type PolymorphicAs, type PolymorphicComponent, type PolymorphicProps, type PolymorphicPropsWithRef, type PolymorphicRef, Popover, type PopoverProps, Portal, type PortalProps, Pre, type PreProps, Progress, type ProgressProps, RadarChart, type RadarChartProps, type RadarDatum, Radio, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioProps, RangeChart, type RangeChartProps, type RangeDatum, Rating, type RatingProps, type ResponsiveColumns, ScatterChart, type ScatterChartProps, type ScatterPoint, type ScatterSeries, Select, type SelectGroup, type SelectOption, type SelectProps, Sidebar, type SidebarItem, type SidebarProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Sparkline, type SparklineDatum, type SparklineProps, Spinner, type SpinnerProps, Stack, type StackOwnProps, type StackProps, Stat, type StatProps, type Step, Stepper, type StepperProps, Switch, type SwitchProps, type Sx, type TabItem, Table, type TableColumn, type TableProps, Tabs, type TabsProps, Tag, type TagProps, Text, type TextOwnProps, type TextProps, type TextTone, Textarea, type TextareaProps, type Theme, ThemeProvider, type ThemeProviderProps, type ThemeTokens, TimePicker, type TimePickerProps, Timeline, type TimelineItem, type TimelineProps, Toast, type ToastApi, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastTone, ToastViewport, type ToastViewportProps, type Tone, Tooltip, type TooltipProps, type TreeNode, TreeView, type TreeViewProps, Treemap, type TreemapDatum, type TreemapProps, TwicoProvider, type TwicoProviderProps, type UseColorSchemeOptions, type UseFocusTrapOptions, type UseKeyPressOptions, type UseMediaQueryOptions, VisuallyHidden, type VisuallyHiddenProps, type WithSx, createTheme, getColorSchemeScript, runDatatableQuery, useClickOutside, useColorScheme, useControllableState, useCopyToClipboard, useDebouncedCallback, useDebouncedValue, useDisclosure, useEventListener, useFocusTrap, useHover, useId, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyPress, useLocalStorage, useMediaQuery, useMounted, usePortal, usePrefersReducedMotion, usePrevious, useScrollLock, useTimeout, useToast, useToggle, useWindowSize };
|
|
4288
|
+
export { Accordion, type AccordionItem, type AccordionProps, type ActionTone, Alert, type AlertProps, Anchor, type AnchorProps, AppShell, type AppShellProps, Avatar, AvatarMenu, type AvatarMenuProps, type AvatarProps, Badge, type BadgeProps, type BarTone, Box, type BoxOwnProps, type BoxProps, Boxplot, type BoxplotDatum, type BoxplotProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BubbleChart, type BubbleChartProps, Button, type ButtonProps, Candlestick, type CandlestickDatum, type CandlestickProps, Card, CardGrid, type CardGridFilter, type CardGridProps, type CardGridQuery, type CardGridSort, type CardGridSortOption, type CardProps, Carousel, type CarouselProps, Chart, type ChartDatum, type ChartProps, Checkbox, type CheckboxProps, Code, type CodeProps, ColorPicker, type ColorPickerProps, ColorSchemeScript, type ColorSchemeScriptOptions, type ColorSchemeScriptProps, Combobox, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type Command, CommandPalette, type CommandPaletteProps, Container, type ContainerOwnProps, type ContainerProps, Currency, CurrencyField, type CurrencyFieldProps, type CurrencyOption, type CurrencyProps, Datatable, type DatatableBatchAction, type DatatableBatchActionContext, type DatatableColumn, type DatatableFilter, type DatatableFilterOp, type DatatableNumberOp, type DatatableProps, type DatatableQuery, type DatatableRowAction, type DatatableState, type DatatableStringOp, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, DateTimePicker, type DateTimePickerProps, Dialog, type DialogProps, type DiffOp, DiffTable, type DiffTableColumn, type DiffTableProps, Divider, type DividerProps, DonutChart, type DonutChartDatum, type DonutChartProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, Field, type FieldProps, FileUpload, type FileUploadProps, FilterBar, type FilterBarProps, type FilterClause, type FilterField, type FilterFieldType, type FilterValues, Form, type FormProps, FunnelChart, type FunnelChartProps, type FunnelDatum, Gauge, type GaugeProps, type GaugeSeries, Grid, type GridOwnProps, type GridProps, Heading, type HeadingOwnProps, type HeadingProps, type HeadingSize, Heatmap, type HeatmapDatum, type HeatmapProps, IconButton, type IconButtonProps, Image, type ImageProps, Input, type InputProps, Kanban, type KanbanCard, type KanbanColumn, type KanbanProps, Kbd, type KbdProps, Label, type LabelProps, List, type ListItemData, type ListProps, Menu, type MenuItemDef, type MenuProps, MultiSelect, type MultiSelectGroup, type MultiSelectOption, type MultiSelectProps, Navbar, type NavbarLink, type NavbarProps, type Option, type OptionGroup, Pagination, type PaginationProps, PieChart, type PieChartDatum, type PieChartProps, PolarAreaChart, type PolarAreaChartProps, type PolarAreaDatum, type PolymorphicAs, type PolymorphicComponent, type PolymorphicProps, type PolymorphicPropsWithRef, type PolymorphicRef, Popover, type PopoverProps, Portal, type PortalProps, Pre, type PreProps, Progress, type ProgressProps, RadarChart, type RadarChartProps, type RadarDatum, Radio, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioProps, RangeChart, type RangeChartProps, type RangeDatum, Rating, type RatingProps, type ResponsiveColumns, ScatterChart, type ScatterChartProps, type ScatterPoint, type ScatterSeries, Select, type SelectGroup, type SelectOption, type SelectProps, Sidebar, type SidebarItem, type SidebarProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Sparkline, type SparklineDatum, type SparklineProps, Spinner, type SpinnerProps, Stack, type StackOwnProps, type StackProps, Stat, type StatProps, type Step, Stepper, type StepperProps, Switch, type SwitchProps, type Sx, type TabItem, Table, type TableColumn, type TableProps, Tabs, type TabsProps, Tag, type TagProps, Text, type TextOwnProps, type TextProps, type TextTone, Textarea, type TextareaProps, type Theme, ThemeProvider, type ThemeProviderProps, type ThemeTokens, TimePicker, type TimePickerProps, Timeline, type TimelineItem, type TimelineProps, Toast, type ToastApi, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastTone, ToastViewport, type ToastViewportProps, type Tone, Tooltip, type TooltipProps, type TreeNode, TreeView, type TreeViewProps, Treemap, type TreemapDatum, type TreemapProps, TwicoProvider, type TwicoProviderProps, type UseColorSchemeOptions, type UseFocusTrapOptions, type UseKeyPressOptions, type UseMediaQueryOptions, VisuallyHidden, type VisuallyHiddenProps, type WithSx, createTheme, getColorSchemeScript, runDatatableQuery, useClickOutside, useColorScheme, useControllableState, useCopyToClipboard, useDebouncedCallback, useDebouncedValue, useDisclosure, useEventListener, useFocusTrap, useHover, useId, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyPress, useLocalStorage, useMediaQuery, useMounted, usePortal, usePrefersReducedMotion, usePrevious, useScrollLock, useTimeout, useToast, useToggle, useWindowSize };
|
package/dist/index.d.ts
CHANGED
|
@@ -1901,6 +1901,19 @@ interface DatatableProps<T = any> extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
1901
1901
|
* column. Use it to trim a wide grid's editor **without** touching `editable` (which would also
|
|
1902
1902
|
* disable inline cell editing). */
|
|
1903
1903
|
batchEditFields?: string[];
|
|
1904
|
+
/** Persist the full view state (filters, sort, quick-search, page, page size, column order / widths /
|
|
1905
|
+
* visibility / pinning, density) to `localStorage` under this key, and restore it on mount (#259).
|
|
1906
|
+
* SSR-safe: storage is never read during render — the server and first client render start from the
|
|
1907
|
+
* defaults, then the saved state is applied in a mount effect (so hydration never mismatches). Unknown
|
|
1908
|
+
* columns in a saved snapshot are ignored, so a later column change won't break restore. */
|
|
1909
|
+
stateKey?: string;
|
|
1910
|
+
/** Seed the view state on first mount (used only when `stateKey` has nothing stored yet). A partial
|
|
1911
|
+
* `DatatableState` — omitted keys keep their defaults. */
|
|
1912
|
+
initialState?: Partial<DatatableState>;
|
|
1913
|
+
/** Fired whenever the view state changes, with the complete `DatatableState`. Use it to persist the
|
|
1914
|
+
* state yourself (URL query, server, …) instead of — or in addition to — `stateKey`. Not fired on
|
|
1915
|
+
* the initial mount for the default state; fires once after a `stateKey`/`initialState` restore. */
|
|
1916
|
+
onStateChange?: (state: DatatableState) => void;
|
|
1904
1917
|
/** Show a "Go to" page jumper in the footer when there are more than 5 pages. @default true */
|
|
1905
1918
|
showPageJumper?: boolean;
|
|
1906
1919
|
/** Click-to-select mode: "row" highlights the clicked row, "cell" highlights a single cell. @default "none" */
|
|
@@ -1991,6 +2004,37 @@ interface DatatableQuery {
|
|
|
1991
2004
|
hiddenColumns?: string[];
|
|
1992
2005
|
}
|
|
1993
2006
|
|
|
2007
|
+
/**
|
|
2008
|
+
* The complete, serializable view state of a `Datatable` (#259) — everything the user can adjust
|
|
2009
|
+
* from the toolbar and column headers. Persisted by `stateKey`, seeded by `initialState`, and
|
|
2010
|
+
* reported by `onStateChange`. Every field is optional in `initialState`/a stored snapshot: unknown
|
|
2011
|
+
* columns are dropped and missing keys fall back to the table's defaults, so a snapshot survives a
|
|
2012
|
+
* schema change. `columnVisibility` lists only hidden columns (`{ field: false }`; absent = visible);
|
|
2013
|
+
* `columnPinning` lists only pinned columns (`{ field: "left" | "right" }`).
|
|
2014
|
+
*/
|
|
2015
|
+
interface DatatableState {
|
|
2016
|
+
/** Active per-column filters (without the internal row id). */
|
|
2017
|
+
filters: DatatableFilter[];
|
|
2018
|
+
/** Active sort, or null. */
|
|
2019
|
+
sort: { field: string; dir: "asc" | "desc" } | null;
|
|
2020
|
+
/** Quick-search text. */
|
|
2021
|
+
quickFilter: string;
|
|
2022
|
+
/** Zero-based current page. */
|
|
2023
|
+
page: number;
|
|
2024
|
+
/** Rows per page. */
|
|
2025
|
+
pageSize: number;
|
|
2026
|
+
/** Column `field`s in their current left-to-right order. */
|
|
2027
|
+
columnOrder: string[];
|
|
2028
|
+
/** User-resized column widths in px, keyed by `field`. */
|
|
2029
|
+
columnWidths: Record<string, number>;
|
|
2030
|
+
/** Hidden columns, keyed by `field` (`false` = hidden; a visible column is simply absent). */
|
|
2031
|
+
columnVisibility: Record<string, boolean>;
|
|
2032
|
+
/** Pinned columns, keyed by `field`. */
|
|
2033
|
+
columnPinning: Record<string, "left" | "right">;
|
|
2034
|
+
/** Row-density preset. */
|
|
2035
|
+
density: "compact" | "standard" | "comfortable";
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1994
2038
|
interface DatatableColumn<T = any> {
|
|
1995
2039
|
/** Row object key (also the default sort/filter/search/group/export key). */
|
|
1996
2040
|
field: string;
|
|
@@ -4174,7 +4218,9 @@ declare function useLocalStorage<T>(
|
|
|
4174
4218
|
initialValue: T
|
|
4175
4219
|
): [T, (value: T | ((prev: T) => T)) => void];
|
|
4176
4220
|
|
|
4177
|
-
/** Copy text to the clipboard with a `copied` flag that auto-resets.
|
|
4221
|
+
/** Copy text to the clipboard with a `copied` flag that auto-resets. Uses the async Clipboard API in a
|
|
4222
|
+
* secure context and falls back to a legacy `execCommand("copy")` path over plain HTTP on a LAN IP
|
|
4223
|
+
* (where `navigator.clipboard` is undefined) and in older browsers, so `copy()` works off-secure-origin. */
|
|
4178
4224
|
declare function useCopyToClipboard(timeout?: number): {
|
|
4179
4225
|
copied: boolean;
|
|
4180
4226
|
copy: (text: string) => Promise<boolean>;
|
|
@@ -4239,4 +4285,4 @@ declare function useFocusTrap<T extends HTMLElement = HTMLElement>(
|
|
|
4239
4285
|
*/
|
|
4240
4286
|
declare function usePortal(): (node: React.ReactNode) => React.ReactPortal | React.ReactNode | null;
|
|
4241
4287
|
|
|
4242
|
-
export { Accordion, type AccordionItem, type AccordionProps, type ActionTone, Alert, type AlertProps, Anchor, type AnchorProps, AppShell, type AppShellProps, Avatar, AvatarMenu, type AvatarMenuProps, type AvatarProps, Badge, type BadgeProps, type BarTone, Box, type BoxOwnProps, type BoxProps, Boxplot, type BoxplotDatum, type BoxplotProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BubbleChart, type BubbleChartProps, Button, type ButtonProps, Candlestick, type CandlestickDatum, type CandlestickProps, Card, CardGrid, type CardGridFilter, type CardGridProps, type CardGridQuery, type CardGridSort, type CardGridSortOption, type CardProps, Carousel, type CarouselProps, Chart, type ChartDatum, type ChartProps, Checkbox, type CheckboxProps, Code, type CodeProps, ColorPicker, type ColorPickerProps, ColorSchemeScript, type ColorSchemeScriptOptions, type ColorSchemeScriptProps, Combobox, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type Command, CommandPalette, type CommandPaletteProps, Container, type ContainerOwnProps, type ContainerProps, Currency, CurrencyField, type CurrencyFieldProps, type CurrencyOption, type CurrencyProps, Datatable, type DatatableBatchAction, type DatatableBatchActionContext, type DatatableColumn, type DatatableFilter, type DatatableFilterOp, type DatatableNumberOp, type DatatableProps, type DatatableQuery, type DatatableRowAction, type DatatableStringOp, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, DateTimePicker, type DateTimePickerProps, Dialog, type DialogProps, type DiffOp, DiffTable, type DiffTableColumn, type DiffTableProps, Divider, type DividerProps, DonutChart, type DonutChartDatum, type DonutChartProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, Field, type FieldProps, FileUpload, type FileUploadProps, FilterBar, type FilterBarProps, type FilterClause, type FilterField, type FilterFieldType, type FilterValues, Form, type FormProps, FunnelChart, type FunnelChartProps, type FunnelDatum, Gauge, type GaugeProps, type GaugeSeries, Grid, type GridOwnProps, type GridProps, Heading, type HeadingOwnProps, type HeadingProps, type HeadingSize, Heatmap, type HeatmapDatum, type HeatmapProps, IconButton, type IconButtonProps, Image, type ImageProps, Input, type InputProps, Kanban, type KanbanCard, type KanbanColumn, type KanbanProps, Kbd, type KbdProps, Label, type LabelProps, List, type ListItemData, type ListProps, Menu, type MenuItemDef, type MenuProps, MultiSelect, type MultiSelectGroup, type MultiSelectOption, type MultiSelectProps, Navbar, type NavbarLink, type NavbarProps, type Option, type OptionGroup, Pagination, type PaginationProps, PieChart, type PieChartDatum, type PieChartProps, PolarAreaChart, type PolarAreaChartProps, type PolarAreaDatum, type PolymorphicAs, type PolymorphicComponent, type PolymorphicProps, type PolymorphicPropsWithRef, type PolymorphicRef, Popover, type PopoverProps, Portal, type PortalProps, Pre, type PreProps, Progress, type ProgressProps, RadarChart, type RadarChartProps, type RadarDatum, Radio, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioProps, RangeChart, type RangeChartProps, type RangeDatum, Rating, type RatingProps, type ResponsiveColumns, ScatterChart, type ScatterChartProps, type ScatterPoint, type ScatterSeries, Select, type SelectGroup, type SelectOption, type SelectProps, Sidebar, type SidebarItem, type SidebarProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Sparkline, type SparklineDatum, type SparklineProps, Spinner, type SpinnerProps, Stack, type StackOwnProps, type StackProps, Stat, type StatProps, type Step, Stepper, type StepperProps, Switch, type SwitchProps, type Sx, type TabItem, Table, type TableColumn, type TableProps, Tabs, type TabsProps, Tag, type TagProps, Text, type TextOwnProps, type TextProps, type TextTone, Textarea, type TextareaProps, type Theme, ThemeProvider, type ThemeProviderProps, type ThemeTokens, TimePicker, type TimePickerProps, Timeline, type TimelineItem, type TimelineProps, Toast, type ToastApi, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastTone, ToastViewport, type ToastViewportProps, type Tone, Tooltip, type TooltipProps, type TreeNode, TreeView, type TreeViewProps, Treemap, type TreemapDatum, type TreemapProps, TwicoProvider, type TwicoProviderProps, type UseColorSchemeOptions, type UseFocusTrapOptions, type UseKeyPressOptions, type UseMediaQueryOptions, VisuallyHidden, type VisuallyHiddenProps, type WithSx, createTheme, getColorSchemeScript, runDatatableQuery, useClickOutside, useColorScheme, useControllableState, useCopyToClipboard, useDebouncedCallback, useDebouncedValue, useDisclosure, useEventListener, useFocusTrap, useHover, useId, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyPress, useLocalStorage, useMediaQuery, useMounted, usePortal, usePrefersReducedMotion, usePrevious, useScrollLock, useTimeout, useToast, useToggle, useWindowSize };
|
|
4288
|
+
export { Accordion, type AccordionItem, type AccordionProps, type ActionTone, Alert, type AlertProps, Anchor, type AnchorProps, AppShell, type AppShellProps, Avatar, AvatarMenu, type AvatarMenuProps, type AvatarProps, Badge, type BadgeProps, type BarTone, Box, type BoxOwnProps, type BoxProps, Boxplot, type BoxplotDatum, type BoxplotProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, BubbleChart, type BubbleChartProps, Button, type ButtonProps, Candlestick, type CandlestickDatum, type CandlestickProps, Card, CardGrid, type CardGridFilter, type CardGridProps, type CardGridQuery, type CardGridSort, type CardGridSortOption, type CardProps, Carousel, type CarouselProps, Chart, type ChartDatum, type ChartProps, Checkbox, type CheckboxProps, Code, type CodeProps, ColorPicker, type ColorPickerProps, ColorSchemeScript, type ColorSchemeScriptOptions, type ColorSchemeScriptProps, Combobox, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type Command, CommandPalette, type CommandPaletteProps, Container, type ContainerOwnProps, type ContainerProps, Currency, CurrencyField, type CurrencyFieldProps, type CurrencyOption, type CurrencyProps, Datatable, type DatatableBatchAction, type DatatableBatchActionContext, type DatatableColumn, type DatatableFilter, type DatatableFilterOp, type DatatableNumberOp, type DatatableProps, type DatatableQuery, type DatatableRowAction, type DatatableState, type DatatableStringOp, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, DateTimePicker, type DateTimePickerProps, Dialog, type DialogProps, type DiffOp, DiffTable, type DiffTableColumn, type DiffTableProps, Divider, type DividerProps, DonutChart, type DonutChartDatum, type DonutChartProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, Field, type FieldProps, FileUpload, type FileUploadProps, FilterBar, type FilterBarProps, type FilterClause, type FilterField, type FilterFieldType, type FilterValues, Form, type FormProps, FunnelChart, type FunnelChartProps, type FunnelDatum, Gauge, type GaugeProps, type GaugeSeries, Grid, type GridOwnProps, type GridProps, Heading, type HeadingOwnProps, type HeadingProps, type HeadingSize, Heatmap, type HeatmapDatum, type HeatmapProps, IconButton, type IconButtonProps, Image, type ImageProps, Input, type InputProps, Kanban, type KanbanCard, type KanbanColumn, type KanbanProps, Kbd, type KbdProps, Label, type LabelProps, List, type ListItemData, type ListProps, Menu, type MenuItemDef, type MenuProps, MultiSelect, type MultiSelectGroup, type MultiSelectOption, type MultiSelectProps, Navbar, type NavbarLink, type NavbarProps, type Option, type OptionGroup, Pagination, type PaginationProps, PieChart, type PieChartDatum, type PieChartProps, PolarAreaChart, type PolarAreaChartProps, type PolarAreaDatum, type PolymorphicAs, type PolymorphicComponent, type PolymorphicProps, type PolymorphicPropsWithRef, type PolymorphicRef, Popover, type PopoverProps, Portal, type PortalProps, Pre, type PreProps, Progress, type ProgressProps, RadarChart, type RadarChartProps, type RadarDatum, Radio, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioProps, RangeChart, type RangeChartProps, type RangeDatum, Rating, type RatingProps, type ResponsiveColumns, ScatterChart, type ScatterChartProps, type ScatterPoint, type ScatterSeries, Select, type SelectGroup, type SelectOption, type SelectProps, Sidebar, type SidebarItem, type SidebarProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Sparkline, type SparklineDatum, type SparklineProps, Spinner, type SpinnerProps, Stack, type StackOwnProps, type StackProps, Stat, type StatProps, type Step, Stepper, type StepperProps, Switch, type SwitchProps, type Sx, type TabItem, Table, type TableColumn, type TableProps, Tabs, type TabsProps, Tag, type TagProps, Text, type TextOwnProps, type TextProps, type TextTone, Textarea, type TextareaProps, type Theme, ThemeProvider, type ThemeProviderProps, type ThemeTokens, TimePicker, type TimePickerProps, Timeline, type TimelineItem, type TimelineProps, Toast, type ToastApi, type ToastOptions, type ToastProps, ToastProvider, type ToastProviderProps, type ToastTone, ToastViewport, type ToastViewportProps, type Tone, Tooltip, type TooltipProps, type TreeNode, TreeView, type TreeViewProps, Treemap, type TreemapDatum, type TreemapProps, TwicoProvider, type TwicoProviderProps, type UseColorSchemeOptions, type UseFocusTrapOptions, type UseKeyPressOptions, type UseMediaQueryOptions, VisuallyHidden, type VisuallyHiddenProps, type WithSx, createTheme, getColorSchemeScript, runDatatableQuery, useClickOutside, useColorScheme, useControllableState, useCopyToClipboard, useDebouncedCallback, useDebouncedValue, useDisclosure, useEventListener, useFocusTrap, useHover, useId, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyPress, useLocalStorage, useMediaQuery, useMounted, usePortal, usePrefersReducedMotion, usePrevious, useScrollLock, useTimeout, useToast, useToggle, useWindowSize };
|
package/dist/index.mjs
CHANGED
|
@@ -8990,6 +8990,9 @@ function Datatable({
|
|
|
8990
8990
|
onBatchUpdate,
|
|
8991
8991
|
showBatchEdit = true,
|
|
8992
8992
|
batchEditFields = null,
|
|
8993
|
+
stateKey,
|
|
8994
|
+
initialState,
|
|
8995
|
+
onStateChange,
|
|
8993
8996
|
showPageJumper = true,
|
|
8994
8997
|
selectionMode = "none",
|
|
8995
8998
|
onRowClick,
|
|
@@ -9152,6 +9155,75 @@ function Datatable({
|
|
|
9152
9155
|
const [rowGrab, setRowGrab] = React51__default.useState(null);
|
|
9153
9156
|
const [reorderMsg, setReorderMsg] = React51__default.useState("");
|
|
9154
9157
|
const rowFocusRef = React51__default.useRef(null);
|
|
9158
|
+
const serializeState = () => ({
|
|
9159
|
+
filters: filters.map(({ id, ...f }) => f),
|
|
9160
|
+
// strip the internal row id
|
|
9161
|
+
sort,
|
|
9162
|
+
quickFilter: quick,
|
|
9163
|
+
page: pageVal,
|
|
9164
|
+
pageSize: sizeVal,
|
|
9165
|
+
columnOrder: order,
|
|
9166
|
+
columnWidths: widths,
|
|
9167
|
+
columnVisibility: Object.fromEntries([...hidden].map((f) => [f, false])),
|
|
9168
|
+
// absent = visible
|
|
9169
|
+
columnPinning: Object.fromEntries([...pins.left.map((f) => [f, "left"]), ...pins.right.map((f) => [f, "right"])]),
|
|
9170
|
+
density
|
|
9171
|
+
});
|
|
9172
|
+
const applyState = (s) => {
|
|
9173
|
+
if (!s || typeof s !== "object") return;
|
|
9174
|
+
const known = new Set(cols.map((c) => c.field).filter(Boolean));
|
|
9175
|
+
if (Array.isArray(s.filters)) setFilters(s.filters.filter((f) => f && known.has(f.field)).map((f, i) => ({ id: Date.now() + Math.random() + i, field: f.field, op: f.op, value: f.value })));
|
|
9176
|
+
if ("sort" in s) setSort(s.sort && known.has(s.sort.field) ? { field: s.sort.field, dir: s.sort.dir === "desc" ? "desc" : "asc" } : null);
|
|
9177
|
+
if (typeof s.quickFilter === "string" && quickFilter === void 0) setInternalQuick(s.quickFilter);
|
|
9178
|
+
if (typeof s.page === "number" && !pageControlled) setInternalPage(Math.max(0, Math.floor(s.page)));
|
|
9179
|
+
if (typeof s.pageSize === "number" && !pageSizeControlled) setInternalRpp(s.pageSize > 0 ? s.pageSize : 10);
|
|
9180
|
+
if (Array.isArray(s.columnOrder)) {
|
|
9181
|
+
const savedOrder = s.columnOrder.filter((f) => known.has(f));
|
|
9182
|
+
const missing = cols.map((c) => c.field).filter((f) => f && !savedOrder.includes(f));
|
|
9183
|
+
setOrder([...savedOrder, ...missing]);
|
|
9184
|
+
}
|
|
9185
|
+
if (s.columnWidths && typeof s.columnWidths === "object") setWidths(Object.fromEntries(Object.entries(s.columnWidths).filter(([f, w]) => known.has(f) && typeof w === "number")));
|
|
9186
|
+
if (s.columnVisibility && typeof s.columnVisibility === "object") setHidden(new Set(Object.keys(s.columnVisibility).filter((f) => known.has(f) && s.columnVisibility[f] === false)));
|
|
9187
|
+
if (s.columnPinning && typeof s.columnPinning === "object") {
|
|
9188
|
+
const l = [], r2 = [];
|
|
9189
|
+
for (const [f, side] of Object.entries(s.columnPinning)) {
|
|
9190
|
+
if (!known.has(f)) continue;
|
|
9191
|
+
if (side === "left") l.push(f);
|
|
9192
|
+
else if (side === "right") r2.push(f);
|
|
9193
|
+
}
|
|
9194
|
+
setPins({ left: l, right: r2 });
|
|
9195
|
+
}
|
|
9196
|
+
if (s.density === "compact" || s.density === "standard" || s.density === "comfortable") setDensity(s.density);
|
|
9197
|
+
};
|
|
9198
|
+
const stateReadyRef = React51__default.useRef(false);
|
|
9199
|
+
const onStateChangeRef = React51__default.useRef(onStateChange);
|
|
9200
|
+
onStateChangeRef.current = onStateChange;
|
|
9201
|
+
React51__default.useEffect(() => {
|
|
9202
|
+
if (!stateReadyRef.current) return void 0;
|
|
9203
|
+
if (!stateKey && !onStateChange) return void 0;
|
|
9204
|
+
const state = serializeState();
|
|
9205
|
+
onStateChangeRef.current?.(state);
|
|
9206
|
+
if (stateKey) {
|
|
9207
|
+
try {
|
|
9208
|
+
window.localStorage.setItem(stateKey, JSON.stringify(state));
|
|
9209
|
+
} catch {
|
|
9210
|
+
}
|
|
9211
|
+
}
|
|
9212
|
+
return void 0;
|
|
9213
|
+
}, [filters, sort, quick, pageVal, sizeVal, order, widths, hidden, pins, density, stateKey]);
|
|
9214
|
+
React51__default.useEffect(() => {
|
|
9215
|
+
let saved = null;
|
|
9216
|
+
if (stateKey) {
|
|
9217
|
+
try {
|
|
9218
|
+
const raw = window.localStorage.getItem(stateKey);
|
|
9219
|
+
if (raw) saved = JSON.parse(raw);
|
|
9220
|
+
} catch {
|
|
9221
|
+
}
|
|
9222
|
+
}
|
|
9223
|
+
if (!saved && initialState) saved = initialState;
|
|
9224
|
+
if (saved) applyState(saved);
|
|
9225
|
+
stateReadyRef.current = true;
|
|
9226
|
+
}, []);
|
|
9155
9227
|
const rootRef = React51__default.useRef(null);
|
|
9156
9228
|
const [compact, setCompact] = React51__default.useState(false);
|
|
9157
9229
|
React51__default.useEffect(() => {
|
|
@@ -9193,13 +9265,20 @@ function Datatable({
|
|
|
9193
9265
|
return [...kept, ...added];
|
|
9194
9266
|
});
|
|
9195
9267
|
}, [columns]);
|
|
9268
|
+
const densitySyncedRef = React51__default.useRef(false);
|
|
9196
9269
|
React51__default.useEffect(() => {
|
|
9197
|
-
setDensity(densityProp);
|
|
9270
|
+
if (densitySyncedRef.current) setDensity(densityProp);
|
|
9271
|
+
else densitySyncedRef.current = true;
|
|
9198
9272
|
}, [densityProp]);
|
|
9199
9273
|
React51__default.useEffect(() => {
|
|
9200
9274
|
setAggOn(showAggregation);
|
|
9201
9275
|
}, [showAggregation]);
|
|
9276
|
+
const pageSizeSyncedRef = React51__default.useRef(false);
|
|
9202
9277
|
React51__default.useEffect(() => {
|
|
9278
|
+
if (!pageSizeSyncedRef.current) {
|
|
9279
|
+
pageSizeSyncedRef.current = true;
|
|
9280
|
+
return;
|
|
9281
|
+
}
|
|
9203
9282
|
if (pageSizeControlled) return;
|
|
9204
9283
|
setInternalRpp(pageSize > 0 ? pageSize : 10);
|
|
9205
9284
|
setInternalPage(0);
|
|
@@ -17788,21 +17867,47 @@ function useLocalStorage(key, initialValue) {
|
|
|
17788
17867
|
);
|
|
17789
17868
|
return [stored, setValue];
|
|
17790
17869
|
}
|
|
17870
|
+
function legacyCopy(text) {
|
|
17871
|
+
try {
|
|
17872
|
+
const ta = document.createElement("textarea");
|
|
17873
|
+
ta.value = text;
|
|
17874
|
+
ta.setAttribute("readonly", "");
|
|
17875
|
+
ta.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:none;opacity:0;pointer-events:none;";
|
|
17876
|
+
document.body.appendChild(ta);
|
|
17877
|
+
const sel = document.getSelection();
|
|
17878
|
+
const prev = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
|
|
17879
|
+
ta.focus();
|
|
17880
|
+
ta.select();
|
|
17881
|
+
ta.setSelectionRange(0, ta.value.length);
|
|
17882
|
+
const ok = document.execCommand("copy");
|
|
17883
|
+
document.body.removeChild(ta);
|
|
17884
|
+
if (prev && sel) {
|
|
17885
|
+
sel.removeAllRanges();
|
|
17886
|
+
sel.addRange(prev);
|
|
17887
|
+
}
|
|
17888
|
+
return ok;
|
|
17889
|
+
} catch {
|
|
17890
|
+
return false;
|
|
17891
|
+
}
|
|
17892
|
+
}
|
|
17791
17893
|
function useCopyToClipboard(timeout = 1500) {
|
|
17792
17894
|
const [copied, setCopied] = React51__default.useState(false);
|
|
17793
17895
|
const copy = React51__default.useCallback(async (text) => {
|
|
17794
|
-
if (!canUseDOM2
|
|
17896
|
+
if (!canUseDOM2) {
|
|
17795
17897
|
setCopied(false);
|
|
17796
17898
|
return false;
|
|
17797
17899
|
}
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17900
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
17901
|
+
try {
|
|
17902
|
+
await navigator.clipboard.writeText(text);
|
|
17903
|
+
setCopied(true);
|
|
17904
|
+
return true;
|
|
17905
|
+
} catch {
|
|
17906
|
+
}
|
|
17805
17907
|
}
|
|
17908
|
+
const ok = legacyCopy(String(text ?? ""));
|
|
17909
|
+
setCopied(ok);
|
|
17910
|
+
return ok;
|
|
17806
17911
|
}, []);
|
|
17807
17912
|
React51__default.useEffect(() => {
|
|
17808
17913
|
if (!copied) return void 0;
|