@sustaina/shared-ui 1.30.1 → 1.30.2
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.d.mts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.js +32 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -369,6 +369,10 @@ declare function booleanToSelectValue(value: boolean | undefined, options?: {
|
|
|
369
369
|
fallbackUndefinedValue?: string;
|
|
370
370
|
}): string;
|
|
371
371
|
declare function selectValueToBoolean(value: string): boolean | undefined;
|
|
372
|
+
declare function resetVisibleTableState(payload: {
|
|
373
|
+
table: Table$1<any> | null;
|
|
374
|
+
visibility: Record<string, boolean>;
|
|
375
|
+
}): void;
|
|
372
376
|
|
|
373
377
|
type SorterProps = {
|
|
374
378
|
show?: boolean;
|
|
@@ -659,6 +663,16 @@ type TanstackTableInstance = {
|
|
|
659
663
|
getAllColumns(): any[];
|
|
660
664
|
getVisibleLeafColumns(): any[];
|
|
661
665
|
};
|
|
666
|
+
type SyncColumnsStateOptions<TData> = {
|
|
667
|
+
excludeColumns?: KeyOrString<TData>[];
|
|
668
|
+
labelMap?: Partial<Record<KeyOrString<TData>, string>>;
|
|
669
|
+
visibility?: Partial<Record<KeyOrString<TData>, boolean>>;
|
|
670
|
+
ordering?: KeyOrString<TData>[];
|
|
671
|
+
pinning?: {
|
|
672
|
+
left?: KeyOrString<TData>[];
|
|
673
|
+
};
|
|
674
|
+
};
|
|
675
|
+
type SyncColumnsStateFn = <TData = RowData$1>(table: Table$1<TData>, options?: SyncColumnsStateOptions<TData>) => void;
|
|
662
676
|
type UseGridSettingsStoreActions = {
|
|
663
677
|
setAvailableColumns: (cols: Column[]) => void;
|
|
664
678
|
setCurrentColumns: (cols: Column[]) => void;
|
|
@@ -668,11 +682,7 @@ type UseGridSettingsStoreActions = {
|
|
|
668
682
|
availableColumns: Column[];
|
|
669
683
|
currentColumns: Column[];
|
|
670
684
|
};
|
|
671
|
-
syncColumnsState:
|
|
672
|
-
excludeColumns: KeyOrString<TData>[];
|
|
673
|
-
labelMap?: Partial<Record<KeyOrString<TData>, string>>;
|
|
674
|
-
visibility?: Record<keyof TData, boolean>;
|
|
675
|
-
}) => void;
|
|
685
|
+
syncColumnsState: SyncColumnsStateFn;
|
|
676
686
|
};
|
|
677
687
|
type UseGridSettingsStoreState = {
|
|
678
688
|
availableColumns: Column[];
|
|
@@ -1433,4 +1443,16 @@ type UseTruncatedOptions<T> = {
|
|
|
1433
1443
|
type UseTruncatedResult = boolean;
|
|
1434
1444
|
declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
|
|
1435
1445
|
|
|
1436
|
-
|
|
1446
|
+
type ExtractObjects<T> = T extends infer U ? U extends object ? U : never : never;
|
|
1447
|
+
type BrowserNativeObject = Date | FileList | File | null;
|
|
1448
|
+
type EmptyObject = {
|
|
1449
|
+
[K in string | number]: never;
|
|
1450
|
+
};
|
|
1451
|
+
type DeepPartial<T> = T extends BrowserNativeObject ? T : {
|
|
1452
|
+
[K in keyof T]?: ExtractObjects<T[K]> extends never ? T[K] : DeepPartial<T[K]>;
|
|
1453
|
+
};
|
|
1454
|
+
type DeepPartialNullish<T> = T extends BrowserNativeObject ? T | null : {
|
|
1455
|
+
[K in keyof T]?: ExtractObjects<T[K]> extends never ? T[K] | null : DeepPartialNullish<T[K]> | null;
|
|
1456
|
+
};
|
|
1457
|
+
|
|
1458
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, type BrowserNativeObject, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, CropperModalError, type CropperModalErrorType, type CropperModalProps, DIALOG_ALERT_I18N_SUBNAMESPACE, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSeparatorProps, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DatePicker, type DatePickerProps, type DebounceOptions, type DebouncedFunction, type DeepPartial, type DeepPartialNullish, Dialog, DialogAlert, type DialogAlertI18nResource, type DialogAlertProps, DialogAlertProvider, type DialogAlertTemplateUnit, type DialogAlertTemplates, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, type EllipsisConfig, type EmptyObject, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, type ExtractObjects, type FieldSchema, type FieldType, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormulaEditor, type FormulaEditorProps, type FormulaOperator, type FormulaTokenAttributes, type FormulaTokenConfig, type FormulaTokenSuggestion, type FormulaTokenType, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, Image, type ImageLoader, type ImageLoaderProps, type ImageProps, Input, type InputCustomInputProps, InputNumber, type InputNumberProps, type InputProps$1 as InputProps, Label, List, ListContainer, type ListContainerProps, ListHeader, type ListHeaderProps, type ListProps, ListTable, type ListTableProps, LookupSelect, type LookupSelectOption, type LookupSelectProps, MonthPicker, type MonthPickerProps, _default as Navbar, type NavbarProps, NotFoundIcon, type Params, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, type PrefixMap, PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, type RawFormulaSegment, RichText, type RowClickType, type RowState, type ScrollInfo, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, type SorterProps, Spinner, type SpinnerProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, type TemplateKeys, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, Truncated, type TruncatedProps, index as UI, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buildPrefixMap, buttonVariants, cn, compareAlphanumeric, debounce, defaultOperatorShortcuts, defaultOperators, formatISODate, getDialogAlertControls, getDialogTemplates, inputVariants$1 as inputVariants, isDefined, isEmptyObject, isValidParentheses, mapTokensToOutput, parseFormula, parseFormulaToToken, resetVisibleTableState, selectValueToBoolean, spinnerVariants, splitOperators, stripNullishObject, throttle, tokenizeFormulaString, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated, validateTokenPrefixes };
|
package/dist/index.d.ts
CHANGED
|
@@ -369,6 +369,10 @@ declare function booleanToSelectValue(value: boolean | undefined, options?: {
|
|
|
369
369
|
fallbackUndefinedValue?: string;
|
|
370
370
|
}): string;
|
|
371
371
|
declare function selectValueToBoolean(value: string): boolean | undefined;
|
|
372
|
+
declare function resetVisibleTableState(payload: {
|
|
373
|
+
table: Table$1<any> | null;
|
|
374
|
+
visibility: Record<string, boolean>;
|
|
375
|
+
}): void;
|
|
372
376
|
|
|
373
377
|
type SorterProps = {
|
|
374
378
|
show?: boolean;
|
|
@@ -659,6 +663,16 @@ type TanstackTableInstance = {
|
|
|
659
663
|
getAllColumns(): any[];
|
|
660
664
|
getVisibleLeafColumns(): any[];
|
|
661
665
|
};
|
|
666
|
+
type SyncColumnsStateOptions<TData> = {
|
|
667
|
+
excludeColumns?: KeyOrString<TData>[];
|
|
668
|
+
labelMap?: Partial<Record<KeyOrString<TData>, string>>;
|
|
669
|
+
visibility?: Partial<Record<KeyOrString<TData>, boolean>>;
|
|
670
|
+
ordering?: KeyOrString<TData>[];
|
|
671
|
+
pinning?: {
|
|
672
|
+
left?: KeyOrString<TData>[];
|
|
673
|
+
};
|
|
674
|
+
};
|
|
675
|
+
type SyncColumnsStateFn = <TData = RowData$1>(table: Table$1<TData>, options?: SyncColumnsStateOptions<TData>) => void;
|
|
662
676
|
type UseGridSettingsStoreActions = {
|
|
663
677
|
setAvailableColumns: (cols: Column[]) => void;
|
|
664
678
|
setCurrentColumns: (cols: Column[]) => void;
|
|
@@ -668,11 +682,7 @@ type UseGridSettingsStoreActions = {
|
|
|
668
682
|
availableColumns: Column[];
|
|
669
683
|
currentColumns: Column[];
|
|
670
684
|
};
|
|
671
|
-
syncColumnsState:
|
|
672
|
-
excludeColumns: KeyOrString<TData>[];
|
|
673
|
-
labelMap?: Partial<Record<KeyOrString<TData>, string>>;
|
|
674
|
-
visibility?: Record<keyof TData, boolean>;
|
|
675
|
-
}) => void;
|
|
685
|
+
syncColumnsState: SyncColumnsStateFn;
|
|
676
686
|
};
|
|
677
687
|
type UseGridSettingsStoreState = {
|
|
678
688
|
availableColumns: Column[];
|
|
@@ -1433,4 +1443,16 @@ type UseTruncatedOptions<T> = {
|
|
|
1433
1443
|
type UseTruncatedResult = boolean;
|
|
1434
1444
|
declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
|
|
1435
1445
|
|
|
1436
|
-
|
|
1446
|
+
type ExtractObjects<T> = T extends infer U ? U extends object ? U : never : never;
|
|
1447
|
+
type BrowserNativeObject = Date | FileList | File | null;
|
|
1448
|
+
type EmptyObject = {
|
|
1449
|
+
[K in string | number]: never;
|
|
1450
|
+
};
|
|
1451
|
+
type DeepPartial<T> = T extends BrowserNativeObject ? T : {
|
|
1452
|
+
[K in keyof T]?: ExtractObjects<T[K]> extends never ? T[K] : DeepPartial<T[K]>;
|
|
1453
|
+
};
|
|
1454
|
+
type DeepPartialNullish<T> = T extends BrowserNativeObject ? T | null : {
|
|
1455
|
+
[K in keyof T]?: ExtractObjects<T[K]> extends never ? T[K] | null : DeepPartialNullish<T[K]> | null;
|
|
1456
|
+
};
|
|
1457
|
+
|
|
1458
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, type BrowserNativeObject, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, CropperModalError, type CropperModalErrorType, type CropperModalProps, DIALOG_ALERT_I18N_SUBNAMESPACE, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSeparatorProps, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DatePicker, type DatePickerProps, type DebounceOptions, type DebouncedFunction, type DeepPartial, type DeepPartialNullish, Dialog, DialogAlert, type DialogAlertI18nResource, type DialogAlertProps, DialogAlertProvider, type DialogAlertTemplateUnit, type DialogAlertTemplates, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, type EllipsisConfig, type EmptyObject, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, type ExtractObjects, type FieldSchema, type FieldType, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormulaEditor, type FormulaEditorProps, type FormulaOperator, type FormulaTokenAttributes, type FormulaTokenConfig, type FormulaTokenSuggestion, type FormulaTokenType, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, Image, type ImageLoader, type ImageLoaderProps, type ImageProps, Input, type InputCustomInputProps, InputNumber, type InputNumberProps, type InputProps$1 as InputProps, Label, List, ListContainer, type ListContainerProps, ListHeader, type ListHeaderProps, type ListProps, ListTable, type ListTableProps, LookupSelect, type LookupSelectOption, type LookupSelectProps, MonthPicker, type MonthPickerProps, _default as Navbar, type NavbarProps, NotFoundIcon, type Params, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, type PrefixMap, PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, type RawFormulaSegment, RichText, type RowClickType, type RowState, type ScrollInfo, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, type SorterProps, Spinner, type SpinnerProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, type TemplateKeys, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, Truncated, type TruncatedProps, index as UI, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buildPrefixMap, buttonVariants, cn, compareAlphanumeric, debounce, defaultOperatorShortcuts, defaultOperators, formatISODate, getDialogAlertControls, getDialogTemplates, inputVariants$1 as inputVariants, isDefined, isEmptyObject, isValidParentheses, mapTokensToOutput, parseFormula, parseFormulaToToken, resetVisibleTableState, selectValueToBoolean, spinnerVariants, splitOperators, stripNullishObject, throttle, tokenizeFormulaString, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated, validateTokenPrefixes };
|
package/dist/index.js
CHANGED
|
@@ -3861,6 +3861,15 @@ function selectValueToBoolean(value) {
|
|
|
3861
3861
|
if (value === "false") return false;
|
|
3862
3862
|
return void 0;
|
|
3863
3863
|
}
|
|
3864
|
+
function resetVisibleTableState(payload) {
|
|
3865
|
+
const { table, visibility } = payload;
|
|
3866
|
+
if (!table) return;
|
|
3867
|
+
table.setColumnVisibility(visibility);
|
|
3868
|
+
const isVisible = (id) => payload.visibility?.[id] === true;
|
|
3869
|
+
const prevState = table.getState();
|
|
3870
|
+
table.setColumnFilters(prevState.columnFilters.filter((f) => isVisible(f.id)));
|
|
3871
|
+
table.setSorting(prevState.sorting.filter((s) => isVisible(s.id)));
|
|
3872
|
+
}
|
|
3864
3873
|
var useHover = () => {
|
|
3865
3874
|
const [hovering, setHovering] = React4.useState(false);
|
|
3866
3875
|
const prevRef = React4.useRef(null);
|
|
@@ -6907,8 +6916,15 @@ var useGridSettingsStore = zustand.create(
|
|
|
6907
6916
|
return { availableColumns, currentColumns };
|
|
6908
6917
|
},
|
|
6909
6918
|
syncColumnsState: (table, options) => {
|
|
6919
|
+
const {
|
|
6920
|
+
excludeColumns = [],
|
|
6921
|
+
labelMap = {},
|
|
6922
|
+
visibility = {},
|
|
6923
|
+
ordering = [],
|
|
6924
|
+
pinning
|
|
6925
|
+
} = options || {};
|
|
6910
6926
|
const { availableColumns, currentColumns } = get().extractColumns(table);
|
|
6911
|
-
const
|
|
6927
|
+
const orderMap = new Map(ordering.map((columnId, index) => [columnId, index]));
|
|
6912
6928
|
const filteredExcludeColumnFn = (column) => !excludeColumns.includes(column.id);
|
|
6913
6929
|
const mapLabel = (col) => ({
|
|
6914
6930
|
id: col.id,
|
|
@@ -6923,7 +6939,20 @@ var useGridSettingsStore = zustand.create(
|
|
|
6923
6939
|
}
|
|
6924
6940
|
}
|
|
6925
6941
|
return true;
|
|
6926
|
-
}).map(mapLabel)
|
|
6942
|
+
}).map(mapLabel).sort((a, b) => {
|
|
6943
|
+
const columnIdA = a.id;
|
|
6944
|
+
const columnIdB = b.id;
|
|
6945
|
+
const aOrder = orderMap.get(columnIdA) ?? Infinity;
|
|
6946
|
+
const bOrder = orderMap.get(columnIdB) ?? Infinity;
|
|
6947
|
+
return aOrder - bOrder;
|
|
6948
|
+
}),
|
|
6949
|
+
payload: {
|
|
6950
|
+
ordering,
|
|
6951
|
+
pinning: {
|
|
6952
|
+
left: pinning?.left || []
|
|
6953
|
+
},
|
|
6954
|
+
visibility
|
|
6955
|
+
}
|
|
6927
6956
|
});
|
|
6928
6957
|
}
|
|
6929
6958
|
})
|
|
@@ -10254,6 +10283,7 @@ exports.isValidParentheses = isValidParentheses;
|
|
|
10254
10283
|
exports.mapTokensToOutput = mapTokensToOutput;
|
|
10255
10284
|
exports.parseFormula = parseFormula;
|
|
10256
10285
|
exports.parseFormulaToToken = parseFormulaToToken;
|
|
10286
|
+
exports.resetVisibleTableState = resetVisibleTableState;
|
|
10257
10287
|
exports.selectValueToBoolean = selectValueToBoolean;
|
|
10258
10288
|
exports.spinnerVariants = spinnerVariants;
|
|
10259
10289
|
exports.splitOperators = splitOperators;
|