@economic/taco 2.54.0 → 2.55.0-settings.1
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/Provider/Provider.d.ts +7 -6
- package/dist/components/Provider/TacoContext.d.ts +7 -0
- package/dist/components/Provider/useTacoSettings.d.ts +8 -0
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Provider.js +14 -7
- package/dist/esm/packages/taco/src/components/Provider/Provider.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/TacoContext.js +6 -0
- package/dist/esm/packages/taco/src/components/Provider/TacoContext.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js +39 -0
- package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/Report.js +8 -0
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +8 -0
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useTaco.js +9 -0
- package/dist/esm/packages/taco/src/hooks/useTaco.js.map +1 -0
- package/dist/esm/packages/taco/src/index.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js +6 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +9 -5
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js +18 -21
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js +57 -9
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +7 -5
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js +44 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +5 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/hooks/useTaco.d.ts +1 -0
- package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
- package/dist/primitives/Table/Core/useTable.d.ts +4 -4
- package/dist/primitives/Table/types.d.ts +16 -6
- package/dist/primitives/Table/useTableManager/features/useTablePrinting.d.ts +2 -8
- package/dist/primitives/Table/useTableManager/features/useTableRowActive.d.ts +2 -2
- package/dist/primitives/Table/useTableManager/listeners/useTableSettingsListener.d.ts +2 -2
- package/dist/primitives/Table/useTableManager/useTableSettingsPreloader.d.ts +3 -0
- package/dist/primitives/Table/useTableManager/util/settings.d.ts +2 -0
- package/dist/taco.cjs.development.js +195 -153
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/packages/taco/src/hooks/useLocalStorage.js +0 -44
- package/dist/esm/packages/taco/src/hooks/useLocalStorage.js.map +0 -1
- package/dist/esm/packages/taco/src/hooks/useTacoSettings.js +0 -9
- package/dist/esm/packages/taco/src/hooks/useTacoSettings.js.map +0 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js +0 -69
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +0 -1
- package/dist/hooks/useLocalStorage.d.ts +0 -2
- package/dist/hooks/useTacoSettings.d.ts +0 -1
- package/dist/primitives/Table/useTableManager/features/useTableSettings.d.ts +0 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n IsOneOf,\n IsNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType, filterState?: TableFilter[]) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'checkbox'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onKeyDown?: React.KeyboardEventHandler;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string | JSX.Element;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (\n row: TType,\n internalRowId: string,\n cleanup: (rowId: string) => void\n) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[], ids: string[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableSortHandler = (sorting: TableColumnSort[]) => Promise<void>;\nexport type TableFilterHandler = (filters: TableColumnFilter[], hiddenColumns: string[]) => Promise<void>;\nexport type TableSearchHandler = (search: string | undefined, hiddenColumns: string[]) => Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<void>;\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\nexport type TableEvent = 'editing-mode';\nexport type TableEventHandler = (event: TableEvent, data?: object) => void;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowExpansionAll?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityAccessor?: keyof TType;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onEvent?: TableEventHandler;\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n pages?: never;\n\n // experimental\n _experimentalDataLoader2?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n pages?: number[];\n\n // experimental\n _experimentalDataLoader2?: boolean;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isOneOf: string;\n isNoneOf: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;EACTA,wEAAO;EACPA,0EAAQ;AACZ,CAAC,EAjBWA,qBAAqB,KAArBA,qBAAqB;;;;"}
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n IsOneOf,\n IsNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType, filterState?: TableFilter[]) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'checkbox'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onKeyDown?: React.KeyboardEventHandler;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string | JSX.Element;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (\n row: TType,\n internalRowId: string,\n cleanup: (rowId: string) => void\n) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[], ids: string[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableSortHandler = (sorting: TableColumnSort[]) => Promise<void>;\nexport type TableFilterHandler = (filters: TableColumnFilter[], hiddenColumns: string[]) => Promise<void>;\nexport type TableSearchHandler = (search: string | undefined, hiddenColumns: string[]) => Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<void>;\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\nexport type TableEvent = 'editing-mode';\nexport type TableEventHandler = (event: TableEvent, data?: object) => void;\n\nexport type TablePrintSettings = {\n allRows: boolean;\n orientation: 'portrait' | 'landscape';\n size: 'A3' | 'A4' | 'A5' | 'letter' | 'legal';\n splitGroups: boolean;\n};\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n print?: TablePrintSettings;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\n\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowExpansionAll?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\nexport type TableToolbarRenderer = JSX.Element | ((settings: TableSettings) => JSX.Element);\nexport type TableDefaultColumnFreezingIndex = number | ((settings: TableSettings) => number | undefined);\nexport type TableDefaultRowActiveIndex = number | ((settings: TableSettings) => number | undefined);\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: TableDefaultColumnFreezingIndex;\n defaultRowActiveIndex?: TableDefaultRowActiveIndex;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityAccessor?: keyof TType;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: TableToolbarRenderer;\n toolbarRight?: TableToolbarRenderer;\n toolbarPanel?: TableToolbarRenderer;\n\n // handlers\n onEvent?: TableEventHandler;\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSort?: TableSortHandler;\n _DEPRECATED_DO_NOT_USE_onChangeSettings?: TableSettingsHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n pages?: never;\n\n // experimental\n _experimentalDataLoader2?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n pages?: number[];\n\n // experimental\n _experimentalDataLoader2?: boolean;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isOneOf: string;\n isNoneOf: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;EACTA,wEAAO;EACPA,0EAAQ;AACZ,CAAC,EAjBWA,qBAAqB,KAArBA,qBAAqB;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import { getSettingsId } from '../util/settings.js';
|
3
|
+
import { useTaco } from '../../../../hooks/useTaco.js';
|
4
4
|
|
5
|
-
function useTablePrinting(isEnabled = false, tableId) {
|
6
|
-
const [isPrinting, setIsPrinting] = React__default.useState(false);
|
7
|
-
const [settings, setSetting] = useTablePrintingSettings(tableId);
|
8
|
-
return {
|
9
|
-
isEnabled,
|
10
|
-
isPrinting,
|
11
|
-
setIsPrinting,
|
12
|
-
settings,
|
13
|
-
setSetting
|
14
|
-
};
|
15
|
-
}
|
16
5
|
const DEFAULT_PRINT_SETTINGS = {
|
17
6
|
size: 'A4',
|
18
7
|
orientation: 'portrait',
|
19
8
|
allRows: true,
|
20
9
|
splitGroups: true
|
21
10
|
};
|
22
|
-
function
|
23
|
-
|
24
|
-
const
|
25
|
-
const
|
26
|
-
|
27
|
-
|
11
|
+
function useTablePrinting(isEnabled = false, tableId) {
|
12
|
+
var _taco$settings$getSet, _taco$settings$getSet2;
|
13
|
+
const [isPrinting, setIsPrinting] = React__default.useState(false);
|
14
|
+
const taco = useTaco();
|
15
|
+
const key = getSettingsId(tableId);
|
16
|
+
const [settings, _setSettings] = React__default.useState((_taco$settings$getSet = (_taco$settings$getSet2 = taco.settings.getSetting(key)) === null || _taco$settings$getSet2 === void 0 ? void 0 : _taco$settings$getSet2.print) !== null && _taco$settings$getSet !== void 0 ? _taco$settings$getSet : DEFAULT_PRINT_SETTINGS);
|
17
|
+
function setSetting(path, value) {
|
18
|
+
_setSettings(currentSettings => ({
|
28
19
|
...currentSettings,
|
29
|
-
[
|
20
|
+
[path]: value
|
30
21
|
}));
|
31
22
|
}
|
32
|
-
return
|
23
|
+
return {
|
24
|
+
isEnabled,
|
25
|
+
isPrinting,
|
26
|
+
setIsPrinting,
|
27
|
+
settings,
|
28
|
+
setSetting
|
29
|
+
};
|
33
30
|
}
|
34
31
|
|
35
32
|
export { useTablePrinting };
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTablePrinting.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTablePrinting.ts"],"sourcesContent":["import React from 'react';\nimport {
|
1
|
+
{"version":3,"file":"useTablePrinting.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTablePrinting.ts"],"sourcesContent":["import React from 'react';\nimport { useTaco } from '../../../../hooks/useTaco';\nimport { TablePrintSettings, TableSettings } from '../../types';\nimport { getSettingsId } from '../util/settings';\n\nconst DEFAULT_PRINT_SETTINGS: TablePrintSettings = {\n size: 'A4',\n orientation: 'portrait',\n allRows: true,\n splitGroups: true,\n};\n\nexport function useTablePrinting(isEnabled = false, tableId: string) {\n const [isPrinting, setIsPrinting] = React.useState(false);\n const taco = useTaco();\n const key = getSettingsId(tableId);\n const [settings, _setSettings] = React.useState<TablePrintSettings>(\n taco.settings.getSetting<TableSettings>(key)?.print ?? DEFAULT_PRINT_SETTINGS\n );\n\n function setSetting(path: keyof TablePrintSettings, value: any) {\n _setSettings(currentSettings => ({ ...currentSettings, [path]: value }));\n }\n\n return {\n isEnabled,\n isPrinting,\n setIsPrinting,\n settings,\n setSetting,\n };\n}\n"],"names":["DEFAULT_PRINT_SETTINGS","size","orientation","allRows","splitGroups","useTablePrinting","isEnabled","tableId","isPrinting","setIsPrinting","React","useState","taco","useTaco","key","getSettingsId","settings","_setSettings","_taco$settings$getSet","_taco$settings$getSet2","getSetting","print","setSetting","path","value","currentSettings"],"mappings":";;;;AAKA,MAAMA,sBAAsB,GAAuB;EAC/CC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE,UAAU;EACvBC,OAAO,EAAE,IAAI;EACbC,WAAW,EAAE;CAChB;SAEeC,gBAAgBA,CAACC,SAAS,GAAG,KAAK,EAAEC,OAAe;;EAC/D,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACzD,MAAMC,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAMC,GAAG,GAAGC,aAAa,CAACR,OAAO,CAAC;EAClC,MAAM,CAACS,QAAQ,EAAEC,YAAY,CAAC,GAAGP,cAAK,CAACC,QAAQ,EAAAO,qBAAA,IAAAC,sBAAA,GAC3CP,IAAI,CAACI,QAAQ,CAACI,UAAU,CAAgBN,GAAG,CAAC,cAAAK,sBAAA,uBAA5CA,sBAAA,CAA8CE,KAAK,cAAAH,qBAAA,cAAAA,qBAAA,GAAIlB,sBAAsB,CAChF;EAED,SAASsB,UAAUA,CAACC,IAA8B,EAAEC,KAAU;IAC1DP,YAAY,CAACQ,eAAe,KAAK;MAAE,GAAGA,eAAe;MAAE,CAACF,IAAI,GAAGC;KAAO,CAAC,CAAC;;EAG5E,OAAO;IACHlB,SAAS;IACTE,UAAU;IACVC,aAAa;IACbO,QAAQ;IACRM;GACH;AACL;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js
CHANGED
@@ -2,8 +2,8 @@ import React__default from 'react';
|
|
2
2
|
import { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom.js';
|
3
3
|
import { useIsHoverStatePaused } from '../../../../hooks/useIsHoverStatePaused.js';
|
4
4
|
|
5
|
-
function useTableRowActive(isEnabled = false, initialRowActiveIndex) {
|
6
|
-
const [rowActiveIndex, setRowActiveIndex] = React__default.useState(initialRowActiveIndex);
|
5
|
+
function useTableRowActive(isEnabled = false, tableSettings, initialRowActiveIndex) {
|
6
|
+
const [rowActiveIndex, setRowActiveIndex] = React__default.useState(typeof initialRowActiveIndex === 'function' ? initialRowActiveIndex(tableSettings) : initialRowActiveIndex);
|
7
7
|
const [rowHoverIndex, setRowHoverIndex] = React__default.useState(undefined);
|
8
8
|
const [isHoverStatePaused, setHoverStatePaused] = useIsHoverStatePaused();
|
9
9
|
const move = (direction, length, scrollToIndex) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableRowActive.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowActive.ts"],"sourcesContent":["import React from 'react';\nimport { TableScrollToIndexHandler } from '../../types';\nimport { useIsHoverStatePaused } from '../../../../hooks/useIsHoverStatePaused';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom';\n\nexport function useTableRowActive(isEnabled = false
|
1
|
+
{"version":3,"file":"useTableRowActive.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowActive.ts"],"sourcesContent":["import React from 'react';\nimport { TableDefaultRowActiveIndex, TableScrollToIndexHandler, TableSettings } from '../../types';\nimport { useIsHoverStatePaused } from '../../../../hooks/useIsHoverStatePaused';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../utils/dom';\n\nexport function useTableRowActive(\n isEnabled = false,\n tableSettings: TableSettings,\n initialRowActiveIndex?: TableDefaultRowActiveIndex\n) {\n const [rowActiveIndex, setRowActiveIndex] = React.useState<number | undefined>(\n typeof initialRowActiveIndex === 'function' ? initialRowActiveIndex(tableSettings) : initialRowActiveIndex\n );\n const [rowHoverIndex, setRowHoverIndex] = React.useState<number | undefined>(undefined);\n const [isHoverStatePaused, setHoverStatePaused] = useIsHoverStatePaused();\n\n const move = (direction: -1 | 1, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n const nextIndex = rowActiveIndex !== undefined ? getNextIndex(direction, rowActiveIndex, length) : 0;\n scrollToIndex(nextIndex);\n setTimeout(() => setRowActiveIndex(nextIndex), 50);\n };\n\n const onKeyDown = React.useCallback(\n (event: KeyboardEvent, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n if (!isEnabled || event.defaultPrevented) {\n return;\n }\n\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n setHoverStatePaused(true);\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = 0;\n scrollToIndex(newIndex);\n setRowActiveIndex(newIndex);\n } else {\n move(-1, length, scrollToIndex);\n }\n\n return;\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (event.ctrlKey || event.metaKey) {\n const newIndex = length - 1;\n scrollToIndex(newIndex);\n setRowActiveIndex(newIndex);\n } else {\n move(+1, length, scrollToIndex);\n }\n return;\n }\n },\n [isEnabled, rowActiveIndex]\n );\n\n const onFocus = React.useCallback(\n (event: React.FocusEvent, length: number, scrollToIndex: TableScrollToIndexHandler) => {\n if (!isEnabled || event.isDefaultPrevented()) {\n return;\n }\n\n if (event.target.closest('tbody') || isElementInsideOrTriggeredFromContainer(event.target, event.currentTarget)) {\n return;\n }\n\n if (rowActiveIndex === undefined && length > 0) {\n setRowActiveIndex(index => {\n if (index === undefined) {\n scrollToIndex(0);\n return 0;\n }\n return index;\n });\n }\n },\n [rowActiveIndex, isEnabled]\n );\n\n return {\n isEnabled,\n rowActiveIndex,\n setRowActiveIndex: isEnabled ? setRowActiveIndex : () => undefined,\n rowHoverIndex,\n setRowHoverIndex,\n isHoverStatePaused,\n setHoverStatePaused: isEnabled ? setHoverStatePaused : () => undefined,\n handleFocus: isEnabled ? onFocus : () => undefined,\n handleKeyDown: isEnabled ? onKeyDown : () => undefined,\n };\n}\n\nfunction getNextIndex(direction: -1 | 1, currentIndex: number, length: number) {\n if (direction === -1) {\n return currentIndex - 1 > 0 ? currentIndex - 1 : 0;\n }\n\n return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;\n}\n"],"names":["useTableRowActive","isEnabled","tableSettings","initialRowActiveIndex","rowActiveIndex","setRowActiveIndex","React","useState","rowHoverIndex","setRowHoverIndex","undefined","isHoverStatePaused","setHoverStatePaused","useIsHoverStatePaused","move","direction","length","scrollToIndex","nextIndex","getNextIndex","setTimeout","onKeyDown","useCallback","event","defaultPrevented","key","preventDefault","ctrlKey","metaKey","newIndex","onFocus","isDefaultPrevented","target","closest","isElementInsideOrTriggeredFromContainer","currentTarget","index","handleFocus","handleKeyDown","currentIndex"],"mappings":";;;;SAKgBA,iBAAiBA,CAC7BC,SAAS,GAAG,KA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AAS;IACtE2B,WAAW,EAAEpC,SAAS,GAAG6B,OAAO,GAAG,MAAMpB,SAAS;IAClD4B,aAAa,EAAErC,SAAS,GAAGoB,SAAS,GAAG,MAAMX;GAChD;AACL;AAEA,SAASS,YAAYA,CAACJ,SAAiB,EAAEwB,YAAoB,EAAEvB,MAAc;EACzE,IAAID,SAAS,KAAK,CAAC,CAAC,EAAE;IAClB,OAAOwB,YAAY,GAAG,CAAC,GAAG,CAAC,GAAGA,YAAY,GAAG,CAAC,GAAG,CAAC;;EAGtD,OAAOA,YAAY,GAAG,CAAC,GAAGvB,MAAM,GAAGuB,YAAY,GAAG,CAAC,GAAGA,YAAY;AACtE;;;;"}
|
@@ -1,26 +1,74 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
-
import { getSettings } from '../util/settings.js';
|
2
|
+
import { getSettings, getSettingsId } from '../util/settings.js';
|
3
|
+
import { useTaco } from '../../../../hooks/useTaco.js';
|
3
4
|
|
4
|
-
function useTableSettingsListener(table, onChangeSettings) {
|
5
|
+
function useTableSettingsListener(table, tableId, onChangeSettings, isEnabled = false) {
|
6
|
+
const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
|
7
|
+
const taco = useTaco();
|
5
8
|
const meta = table.options.meta;
|
6
9
|
const state = table.getState();
|
7
10
|
React__default.useEffect(() => {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
const handler = setTimeout(() => {
|
12
|
+
if (!hasSomeEnabledSettings) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
const settings = removeDisabledSettings(getSettings(table), enabledSettings);
|
16
|
+
if (Object.keys(settings).length) {
|
11
17
|
// some settings shouldn't be persisted, but we comment them out here to highlight the intention
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
taco.settings.saveSetting(getSettingsId(tableId), settings);
|
19
|
+
if (onChangeSettings) {
|
20
|
+
onChangeSettings(getSettings(table));
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}, 250);
|
15
24
|
return () => clearTimeout(handler);
|
16
25
|
}, [
|
17
26
|
//state.columnFilters,
|
18
27
|
state.columnOrder, state.columnPinning, state.columnSizing, state.columnVisibility, table.options.enableGlobalFilter, meta.fontSize.size,
|
19
28
|
//state.grouping,
|
20
|
-
meta.rowHeight.height,
|
29
|
+
meta.printing.settings, meta.rowHeight.height,
|
21
30
|
//state.globalFilter,
|
22
31
|
state.sorting]);
|
23
32
|
}
|
33
|
+
const DEFAULT_ENABLED_OPTIONS = {
|
34
|
+
columnOrder: true,
|
35
|
+
columnPinning: true,
|
36
|
+
columnSizing: true,
|
37
|
+
columnVisibility: true,
|
38
|
+
excludeUnmatchedRecordsInSearch: true,
|
39
|
+
fontSize: true,
|
40
|
+
grouping: true,
|
41
|
+
rowHeight: true,
|
42
|
+
sorting: true
|
43
|
+
};
|
44
|
+
function useEnabledSettings(isEnabled) {
|
45
|
+
return React__default.useMemo(() => {
|
46
|
+
if (isEnabled === false) {
|
47
|
+
return [Object.keys(DEFAULT_ENABLED_OPTIONS).reduce((o, key) => ({
|
48
|
+
...o,
|
49
|
+
[key]: false
|
50
|
+
}), {}), false];
|
51
|
+
} else if (isEnabled === true) {
|
52
|
+
return [DEFAULT_ENABLED_OPTIONS, true];
|
53
|
+
}
|
54
|
+
const options = {
|
55
|
+
...DEFAULT_ENABLED_OPTIONS,
|
56
|
+
...isEnabled
|
57
|
+
};
|
58
|
+
return [options, Object.values(options).some(o => o === true)];
|
59
|
+
}, [isEnabled]);
|
60
|
+
}
|
61
|
+
function removeDisabledSettings(settings, enabledSettings) {
|
62
|
+
const sanitizedSettings = {
|
63
|
+
...settings
|
64
|
+
};
|
65
|
+
Object.keys(enabledSettings).forEach(setting => {
|
66
|
+
if (!enabledSettings[setting]) {
|
67
|
+
delete sanitizedSettings[setting];
|
68
|
+
}
|
69
|
+
});
|
70
|
+
return sanitizedSettings;
|
71
|
+
}
|
24
72
|
|
25
73
|
export { useTableSettingsListener };
|
26
74
|
//# sourceMappingURL=useTableSettingsListener.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableSettingsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSettingsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {
|
1
|
+
{"version":3,"file":"useTableSettingsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSettingsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { getSettings, getSettingsId } from '../util/settings';\nimport { useTaco } from '../../../../hooks/useTaco';\nimport { TableEnableSettingsOptions, TableSettings, TableSettingsHandler } from '../../types';\n\nexport function useTableSettingsListener<TType = unknown>(\n table: ReactTable<TType>,\n tableId: string,\n onChangeSettings: TableSettingsHandler | undefined,\n isEnabled: boolean | Partial<TableEnableSettingsOptions> = false\n) {\n const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);\n const taco = useTaco();\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n const handler = setTimeout(() => {\n if (!hasSomeEnabledSettings) {\n return;\n }\n\n const settings = removeDisabledSettings(getSettings(table), enabledSettings);\n\n if (Object.keys(settings).length) {\n // some settings shouldn't be persisted, but we comment them out here to highlight the intention\n taco.settings.saveSetting(getSettingsId(tableId), settings);\n\n if (onChangeSettings) {\n onChangeSettings(getSettings(table));\n }\n }\n }, 250);\n\n return () => clearTimeout(handler);\n }, [\n //state.columnFilters,\n state.columnOrder,\n state.columnPinning,\n state.columnSizing,\n state.columnVisibility,\n table.options.enableGlobalFilter,\n meta.fontSize.size,\n //state.grouping,\n meta.printing.settings,\n meta.rowHeight.height,\n //state.globalFilter,\n state.sorting,\n ]);\n}\n\nconst DEFAULT_ENABLED_OPTIONS = {\n columnOrder: true,\n columnPinning: true,\n columnSizing: true,\n columnVisibility: true,\n excludeUnmatchedRecordsInSearch: true,\n fontSize: true,\n grouping: true,\n rowHeight: true,\n sorting: true,\n};\n\nfunction useEnabledSettings(isEnabled: boolean | Partial<TableEnableSettingsOptions>): [TableEnableSettingsOptions, boolean] {\n return React.useMemo(() => {\n if (isEnabled === false) {\n return [\n Object.keys(DEFAULT_ENABLED_OPTIONS).reduce(\n (o, key) => ({ ...o, [key]: false }),\n {}\n ) as TableEnableSettingsOptions,\n false,\n ];\n } else if (isEnabled === true) {\n return [DEFAULT_ENABLED_OPTIONS, true];\n }\n\n const options = { ...DEFAULT_ENABLED_OPTIONS, ...isEnabled };\n return [options, Object.values(options).some(o => o === true)];\n }, [isEnabled]);\n}\n\nfunction removeDisabledSettings(settings: TableSettings, enabledSettings: TableEnableSettingsOptions) {\n const sanitizedSettings: TableSettings = { ...settings };\n\n Object.keys(enabledSettings).forEach(setting => {\n if (!enabledSettings[setting]) {\n delete sanitizedSettings[setting];\n }\n });\n\n return sanitizedSettings;\n}\n"],"names":["useTableSettingsListener","table","tableId","onChangeSettings","isEnabled","enabledSettings","hasSomeEnabledSettings","useEnabledSettings","taco","useTaco","meta","options","state","getState","React","useEffect","handler","setTimeout","settings","removeDisabledSettings","getSettings","Object","keys","length","saveSetting","getSettingsId","clearTimeout","columnOrder","columnPinning","columnSizing","columnVisibility","enableGlobalFilter","fontSize","size","printing","rowHeight","height","sorting","DEFAULT_ENABLED_OPTIONS","excludeUnmatchedRecordsInSearch","grouping","useMemo","reduce","o","key","values","some","sanitizedSettings","forEach","setting"],"mappings":";;;;SAMgBA,wBAAwBA,CACpCC,KAAwB,EACxBC,OAAe,EACfC,gBAAkD,EAClDC,YAA2D,KAAK;EAEhE,MAAM,CAACC,eAAe,EAAEC,sBAAsB,CAAC,GAAGC,kBAAkB,CAACH,SAAS,CAAC;EAC/E,MAAMI,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAMC,IAAI,GAAGT,KAAK,CAACU,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGX,KA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AS,KAAK,KAAK,EAAE;MACrB,OAAO,CACHiB,MAAM,CAACC,IAAI,CAACgB,uBAAuB,CAAC,CAACI,MAAM,CACvC,CAACC,CAAC,EAAEC,GAAG,MAAM;QAAE,GAAGD,CAAC;QAAE,CAACC,GAAG,GAAG;OAAO,CAAC,EACpC,EAAE,CACyB,EAC/B,KAAK,CACR;KACJ,MAAM,IAAIxC,SAAS,KAAK,IAAI,EAAE;MAC3B,OAAO,CAACkC,uBAAuB,EAAE,IAAI,CAAC;;IAG1C,MAAM3B,OAAO,GAAG;MAAE,GAAG2B,uBAAuB;MAAE,GAAGlC;KAAW;IAC5D,OAAO,CAACO,OAAO,EAAEU,MAAM,CAACwB,MAAM,CAAClC,OAAO,CAAC,CAACmC,IAAI,CAACH,CAAC,IAAIA,CAAC,KAAK,IAAI,CAAC,CAAC;GACjE,EAAE,CAACvC,SAAS,CAAC,CAAC;AACnB;AAEA,SAASe,sBAAsBA,CAACD,QAAuB,EAAEb,eAA2C;EAChG,MAAM0C,iBAAiB,GAAkB;IAAE,GAAG7B;GAAU;EAExDG,MAAM,CAACC,IAAI,CAACjB,eAAe,CAAC,CAAC2C,OAAO,CAACC,OAAO;IACxC,IAAI,CAAC5C,eAAe,CAAC4C,OAAO,CAAC,EAAE;MAC3B,OAAOF,iBAAiB,CAACE,OAAO,CAAC;;GAExC,CAAC;EAEF,OAAOF,iBAAiB;AAC5B;;;;"}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { useLocalization } from '../../../components/Provider/Localization.js';
|
2
2
|
import { useReactTable, getCoreRowModel } from '@tanstack/react-table';
|
3
|
+
import { getSettingsId } from './util/settings.js';
|
3
4
|
import { mapTableChildrenToColumns, useReactTableInitialState, configureReactTableOptions } from './util/setup.js';
|
4
5
|
import { getTableFeaturePreset } from './util/presets.js';
|
5
6
|
import { useTableColumnFreezing } from './features/useTableColumnFreezing.js';
|
6
7
|
import { useTableColumnOrdering } from './features/useTableColumnOrdering.js';
|
7
8
|
import { useTableFooter } from './features/useTableFooter.js';
|
8
9
|
import { useTableFontSize } from './features/useTableFontSize.js';
|
10
|
+
import { useTaco } from '../../../hooks/useTaco.js';
|
9
11
|
import { useTablePrinting } from './features/useTablePrinting.js';
|
10
12
|
import { useTableRowActions } from './features/useTableRowActions.js';
|
11
13
|
import { useTableRowActive } from './features/useTableRowActive.js';
|
@@ -17,7 +19,6 @@ import { useTableRowHeight } from './features/useTableRowHeight.js';
|
|
17
19
|
import { useTableRowSelection } from './features/useTableRowSelection.js';
|
18
20
|
import { useTableSearch } from './features/useTableSearch.js';
|
19
21
|
import { useTableServerLoading } from './features/useTableServerLoading.js';
|
20
|
-
import { useTableSettings } from './features/useTableSettings.js';
|
21
22
|
import { useTableDataListener } from './listeners/useTableDataListener.js';
|
22
23
|
import { useTableFilterListener } from './listeners/useTableFilterListener.js';
|
23
24
|
import { useTableFontSizeListener } from './listeners/useTableFontSizeListener.js';
|
@@ -34,14 +35,15 @@ import { useTableRowDrop } from './features/useTableRowDrop.js';
|
|
34
35
|
// Placed this array outside the hook to avoid creating a new array reference on each hook re-render
|
35
36
|
const DEFAULT_EMPTY_ARRAY = [];
|
36
37
|
function useTableManager(props, meta, internalColumns) {
|
37
|
-
var _props$data, _props$length, _meta$editing, _instance$options$met;
|
38
|
+
var _ref, _taco$settings$getSet, _props$data, _props$length, _meta$editing, _instance$options$met;
|
39
|
+
const taco = useTaco();
|
38
40
|
const localization = useLocalization();
|
39
41
|
// CSS.escape would be best here, but it doesn't seem to work very well
|
40
42
|
const safeId = props.id.replace('.', '_');
|
41
43
|
// configure table options, merging props with presets
|
42
44
|
const options = getTableFeaturePreset(props);
|
43
45
|
// load any persisted table settings and merge them with any defaults
|
44
|
-
const
|
46
|
+
const settings = (_ref = (_taco$settings$getSet = taco.settings.getSetting(getSettingsId(safeId))) !== null && _taco$settings$getSet !== void 0 ? _taco$settings$getSet : props.defaultSettings) !== null && _ref !== void 0 ? _ref : {};
|
45
47
|
// ensure data is always valid
|
46
48
|
const data = (_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : DEFAULT_EMPTY_ARRAY;
|
47
49
|
const length = (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : data.length;
|
@@ -51,7 +53,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
51
53
|
const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);
|
52
54
|
const footer = useTableFooter(options.enableFooter);
|
53
55
|
const printing = useTablePrinting(options.enablePrinting, safeId);
|
54
|
-
const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);
|
56
|
+
const rowActive = useTableRowActive(options.enableRowActive, settings, props.defaultRowActiveIndex);
|
55
57
|
const rowActions = useTableRowActions(options.enableRowActions, props.rowActions, props.rowActionsLength);
|
56
58
|
const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
|
57
59
|
const rowDrag = useTableRowDrag(options.enableRowDrag && !(meta !== null && meta !== void 0 && (_meta$editing = meta.editing) !== null && _meta$editing !== void 0 && _meta$editing.isEditing), props.onRowDrag);
|
@@ -116,7 +118,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
116
118
|
useTableRowSelectionListener(instance, props.onRowSelect);
|
117
119
|
useTableSearchListener(instance);
|
118
120
|
useTableServerLoadingListener(instance, server.loadPage);
|
119
|
-
useTableSettingsListener(instance,
|
121
|
+
useTableSettingsListener(instance, safeId, props._DEPRECATED_DO_NOT_USE_onChangeSettings, options.enableSaveSettings);
|
120
122
|
useTableShortcutsListener(instance, props.shortcuts);
|
121
123
|
useTableSortingListener(instance, props.onChangeSort);
|
122
124
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableEventHandler,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n onEvent: TableEventHandler;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(\n options.enableRowExpansion,\n options.enableRowExpansionAll,\n props.rowExpansionRenderer\n );\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, props.onChangeSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(\n length,\n data,\n props.loadPage,\n props.loadAll,\n props.pages,\n props.pageSize,\n props._experimentalDataLoader2\n );\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n onEvent: props.onEvent,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance, length);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","enableRowExpansionAll","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","onChangeSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pages","pageSize","_experimentalDataLoader2","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","onEvent","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkGA;AACA,MAAMA,mBAAmB,GAAG,EAAE;SAEdC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGL,KAAK,CAACM,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACT,KAAK,CAAC;;EAG5C,MAAM,CAACU,QAAQ,EAAEC,WAAW,CAAC,GAAG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,CAACrF,OAAO,CAACP,IAAI,cAAAiH,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
|
1
|
+
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableEventHandler,\n TableFilterComparator,\n TableProps,\n TableSettings,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\nimport { useTaco } from '../../../hooks/useTaco';\nimport { getSettingsId } from './util/settings';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n onEvent: TableEventHandler;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const taco = useTaco();\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const settings = taco.settings.getSetting<TableSettings>(getSettingsId(safeId)) ?? props.defaultSettings ?? {};\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, settings, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(\n options.enableRowExpansion,\n options.enableRowExpansionAll,\n props.rowExpansionRenderer\n );\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, props.onChangeSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(\n length,\n data,\n props.loadPage,\n props.loadAll,\n props.pages,\n props.pageSize,\n props._experimentalDataLoader2\n );\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n onEvent: props.onEvent,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance, length);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, safeId, props._DEPRECATED_DO_NOT_USE_onChangeSettings, options.enableSaveSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","taco","useTaco","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","_ref","_taco$settings$getSet","getSetting","getSettingsId","defaultSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","enableRowExpansionAll","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","onChangeSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pages","pageSize","_experimentalDataLoader2","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","onEvent","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","useTableServerLoadingListener","useTableSettingsListener","_DEPRECATED_DO_NOT_USE_onChangeSettings","enableSaveSettings","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA;AACA,MAAMA,mBAAmB,GAAG,EAAE;SAEdC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGP,KAAK,CAACQ,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACX,KAAK,CAAC;;EAG5C,MAAMY,QAAQ,IAAAC,IAAA,IAAAC,qBAAA,GAAGX,IAAI,CAACS,QAAQ,CAACG,UAAU,CAAgBC,aAAa,CAACT,MAAM,CAAC,CAAC,cAAAO,qBAAA,cAAAA,qBAAA,GAAId,KAAK,CAACiB,eAAe,cAAAJ,IAAA,cAAAA,IAAA,GAAI,EAAE;;EAG9G,MAAMK,IAAI,IAAAC,WAAA,GAAGnB,KAAK,CAACkB,IAAI,cAAAC,WAAA,cAAAA,WAAA,GAAIrB,mBAAmB;EAC9C,MAAMsB,MAAM,IAAAC,aAAA,GAAGrB,KAAK,CAACoB,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIH,IAAI,CAACE,MAAM;;EAG1C,MAAME,cAAc,GAAGC,sBAAsB,CAACb,OAAO,CAACc,oBAAoB,CAAC;EAC3E,MAAMC,cAAc,GAAGC,sBAAsB,CAAChB,OAAO,CAACiB,oBAAoB,CAAC;EAC3E,MAAMC,QAAQ,GAAGC,gBAAgB,CAACnB,OAAO,CAACoB,cAAc,EAAElB,QAAQ,CAACgB,QAAQ,CAAC;EAC5E,MAAMG,MAAM,GAAGC,cAAc,CAACtB,OAAO,CAACuB,YAAY,CA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mB,oBAAoB,CAACP,QAAQ,EAAE3E,MAAM,CAAC;EACtCmF,sBAAsB,CAACR,QAAQ,EAAE/F,KAAK,CAACwG,cAAc,CAAC;EACtDC,wBAAwB,CAACV,QAAQ,CAAC;EAClCW,yBAAyB,CAACX,QAAQ,CAAC;EACnCY,4BAA4B,CAACZ,QAAQ,EAAE/F,KAAK,CAAC4G,WAAW,CAAC;EACzDC,sBAAsB,CAACd,QAAQ,CAAC;EAChCe,6BAA6B,CAACf,QAAQ,EAAEZ,MAAM,CAACE,QAAQ,CAAC;EACxD0B,wBAAwB,CAAChB,QAAQ,EAAExF,MAAM,EAAEP,KAAK,CAACgH,uCAAuC,EAAEtG,OAAO,CAACuG,kBAAkB,CAAC;EACrHC,yBAAyB,CAACnB,QAAQ,EAAE/F,KAAK,CAACmH,SAAS,CAAC;EACpDC,uBAAuB,CAACrB,QAAQ,EAAE/F,KAAK,CAACqH,YAAY,CAAC;EAErD,OAAO;IACH7G,EAAE,EAAED,MAAM;IACVwF,QAAQ;IACR9F,IAAI,GAAAqH,qBAAA,GAAGvB,QAAQ,CAACrF,OAAO,CAACT,IAAI,cAAAqH,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAExB,QAAQ,CAACyB,QAAQ;GAC3B;AACL;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { getSettingsId } from './util/settings.js';
|
3
|
+
import { useTaco } from '../../../hooks/useTaco.js';
|
4
|
+
|
5
|
+
function getLegacySetting(currentKey) {
|
6
|
+
try {
|
7
|
+
const localStorageValue = localStorage.getItem(currentKey);
|
8
|
+
if (localStorageValue) {
|
9
|
+
const value = JSON.parse(localStorageValue || 'null');
|
10
|
+
if (value !== null) {
|
11
|
+
localStorage.removeItem(currentKey);
|
12
|
+
return value;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
} catch {
|
16
|
+
// If user is in private mode or has storage restriction
|
17
|
+
// localStorage can throw. JSON.parse can throw, too.
|
18
|
+
}
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
function useTableSettingsPreloader(tableId) {
|
22
|
+
const taco = useTaco();
|
23
|
+
const [loading, setLoading] = React__default.useState(true);
|
24
|
+
React__default.useLayoutEffect(() => {
|
25
|
+
const key = getSettingsId(tableId);
|
26
|
+
// migrate legacy settings if they exist, can be removed in the future
|
27
|
+
const legacySettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.settings`);
|
28
|
+
if (legacySettings) {
|
29
|
+
const legacyPrintSettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.print.settings`);
|
30
|
+
taco.settings.saveSetting(key, {
|
31
|
+
...legacySettings,
|
32
|
+
print: legacyPrintSettings !== null && legacyPrintSettings !== void 0 ? legacyPrintSettings : {}
|
33
|
+
}).finally(() => setLoading(false));
|
34
|
+
} else {
|
35
|
+
taco.settings.loadSetting(key).finally(() => setLoading(false));
|
36
|
+
}
|
37
|
+
}, []);
|
38
|
+
return {
|
39
|
+
loading
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
export { useTableSettingsPreloader };
|
44
|
+
//# sourceMappingURL=useTableSettingsPreloader.js.map
|
package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useTableSettingsPreloader.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableSettingsPreloader.ts"],"sourcesContent":["import React from 'react';\nimport { useTaco } from '../../../hooks/useTaco';\nimport { TablePrintSettings, TableSettings } from '../types';\nimport { getSettingsId } from './util/settings';\n\nfunction getLegacySetting<TType = unknown>(currentKey: string): TType | undefined {\n try {\n const localStorageValue = localStorage.getItem(currentKey);\n\n if (localStorageValue) {\n const value = JSON.parse(localStorageValue || 'null');\n\n if (value !== null) {\n localStorage.removeItem(currentKey);\n return value;\n }\n }\n } catch {\n // If user is in private mode or has storage restriction\n // localStorage can throw. JSON.parse can throw, too.\n }\n\n return undefined;\n}\n\nexport function useTableSettingsPreloader(tableId: string) {\n const taco = useTaco();\n const [loading, setLoading] = React.useState(true);\n\n React.useLayoutEffect(() => {\n const key = getSettingsId(tableId);\n\n // migrate legacy settings if they exist, can be removed in the future\n const legacySettings = getLegacySetting<TableSettings>(`taco.${taco.userId}.table.${tableId}.settings`);\n\n if (legacySettings) {\n const legacyPrintSettings = getLegacySetting<TablePrintSettings>(\n `taco.${taco.userId}.table.${tableId}.print.settings`\n );\n\n taco.settings\n .saveSetting(key, {\n ...legacySettings,\n print: legacyPrintSettings ?? {},\n })\n .finally(() => setLoading(false));\n } else {\n taco.settings.loadSetting<TableSettings>(key).finally(() => setLoading(false));\n }\n }, []);\n\n return { loading };\n}\n"],"names":["getLegacySetting","currentKey","localStorageValue","localStorage","getItem","value","JSON","parse","removeItem","undefined","useTableSettingsPreloader","tableId","taco","useTaco","loading","setLoading","React","useState","useLayoutEffect","key","getSettingsId","legacySettings","userId","legacyPrintSettings","settings","saveSetting","print","finally","loadSetting"],"mappings":";;;;AAKA,SAASA,gBAAgBA,CAAkBC,UAAkB;EACzD,IAAI;IACA,MAAMC,iBAAiB,GAAGC,YAAY,CAACC,OAAO,CAACH,UAAU,CAAC;IAE1D,IAAIC,iBAAiB,EAAE;MACnB,MAAMG,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACL,iBAAiB,IAAI,MAAM,CAAC;MAErD,IAAIG,KAAK,KAAK,IAAI,EAAE;QAChBF,YAAY,CAACK,UAAU,CAACP,UAAU,CAAC;QACnC,OAAOI,KAAK;;;GAGvB,CAAC,MAAM;;;;EAKR,OAAOI,SAAS;AACpB;SAEgBC,yBAAyBA,CAACC,OAAe;EACrD,MAAMC,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,IAAI,CAAC;EAElDD,cAAK,CAACE,eAAe,CAAC;IAClB,MAAMC,GAAG,GAAGC,aAAa,CAACT,OAAO,CAAC;;IAGlC,MAAMU,cAAc,GAAGrB,gBAAgB,CAAgB,QAAQY,IAAI,CAACU,MAAM,UAAUX,OAAO,WAAW,CAAC;IAEvG,IAAIU,cAAc,EAAE;MAChB,MAAME,mBAAmB,GAAGvB,gBAAgB,CACxC,QAAQY,IAAI,CAACU,MAAM,UAAUX,OAAO,iBAAiB,CACxD;MAEDC,IAAI,CAACY,QAAQ,CACRC,WAAW,CAACN,GAAG,EAAE;QACd,GAAGE,cAAc;QACjBK,KAAK,EAAEH,mBAAmB,aAAnBA,mBAAmB,cAAnBA,mBAAmB,GAAI;OACjC,CAAC,CACDI,OAAO,CAAC,MAAMZ,UAAU,CAAC,KAAK,CAAC,CAAC;KACxC,MAAM;MACHH,IAAI,CAACY,QAAQ,CAACI,WAAW,CAAgBT,GAAG,CAAC,CAACQ,OAAO,CAAC,MAAMZ,UAAU,CAAC,KAAK,CAAC,CAAC;;GAErF,EAAE,EAAE,CAAC;EAEN,OAAO;IAAED;GAAS;AACtB;;;;"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { isInternalColumn } from './columns.js';
|
2
2
|
|
3
|
+
const getSettingsId = tableId => `table.${tableId.replace('.', '_')}`;
|
3
4
|
function getSettings(table) {
|
4
5
|
const meta = table.options.meta;
|
5
6
|
const state = table.getState();
|
@@ -13,6 +14,7 @@ function getSettings(table) {
|
|
13
14
|
excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,
|
14
15
|
fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,
|
15
16
|
//grouping: table.options.enableGrouping ? state.grouping : undefined,
|
17
|
+
print: meta.printing.settings,
|
16
18
|
rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,
|
17
19
|
//searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,
|
18
20
|
sorting: state.sorting
|
@@ -30,5 +32,5 @@ function ignoreInternalColumns(data) {
|
|
30
32
|
}, {});
|
31
33
|
}
|
32
34
|
|
33
|
-
export { getSettings, ignoreInternalColumns };
|
35
|
+
export { getSettings, getSettingsId, ignoreInternalColumns };
|
34
36
|
//# sourceMappingURL=settings.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"settings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/settings.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from './columns';\n\nexport function getSettings<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n return {\n // commented out properties are here to highlight things we explicitly don't want them saved\n //columnFilters: table.options.enableColumnFilters ? state.columnFilters : undefined,\n columnOrder: meta.columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnPinning: state.columnPinning,\n columnSizing: ignoreInternalColumns(state.columnSizing),\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,\n fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,\n //grouping: table.options.enableGrouping ? state.grouping : undefined,\n rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,\n //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,\n sorting: state.sorting,\n };\n}\n\nexport function ignoreInternalColumns(data: object) {\n return Object.keys(data).reduce((accum, key) => {\n if (isInternalColumn(key)) {\n return accum;\n }\n\n return {\n ...accum,\n [key]: data[key],\n };\n }, {});\n}\n"],"names":["getSettings","table","meta","options","state","getState","columnOrder","columnOrdering","isEnabled","undefined","columnPinning","columnSizing","ignoreInternalColumns","columnVisibility","enableHiding","excludeUnmatchedRecordsInSearch","enableGlobalFilter","fontSize","size","rowHeight","height","sorting","data","Object","keys","reduce","accum","key","isInternalColumn"],"mappings":";;
|
1
|
+
{"version":3,"file":"settings.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/settings.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from './columns';\n\nexport const getSettingsId = (tableId: string) => `table.${tableId.replace('.', '_')}`;\n\nexport function getSettings<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n return {\n // commented out properties are here to highlight things we explicitly don't want them saved\n //columnFilters: table.options.enableColumnFilters ? state.columnFilters : undefined,\n columnOrder: meta.columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnPinning: state.columnPinning,\n columnSizing: ignoreInternalColumns(state.columnSizing),\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: table.options.enableGlobalFilter,\n fontSize: meta.fontSize.isEnabled ? meta.fontSize.size : undefined,\n //grouping: table.options.enableGrouping ? state.grouping : undefined,\n print: meta.printing.settings,\n rowHeight: meta.rowHeight.isEnabled ? meta.rowHeight.height : undefined,\n //searchQuery: table.options.enableGlobalFilter ? state.globalFilter : undefined,\n sorting: state.sorting,\n };\n}\n\nexport function ignoreInternalColumns(data: object) {\n return Object.keys(data).reduce((accum, key) => {\n if (isInternalColumn(key)) {\n return accum;\n }\n\n return {\n ...accum,\n [key]: data[key],\n };\n }, {});\n}\n"],"names":["getSettingsId","tableId","replace","getSettings","table","meta","options","state","getState","columnOrder","columnOrdering","isEnabled","undefined","columnPinning","columnSizing","ignoreInternalColumns","columnVisibility","enableHiding","excludeUnmatchedRecordsInSearch","enableGlobalFilter","fontSize","size","print","printing","settings","rowHeight","height","sorting","data","Object","keys","reduce","accum","key","isInternalColumn"],"mappings":";;MAGaA,aAAa,GAAIC,OAAe,IAAK,SAASA,OAAO,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SAEpEC,WAAWA,CAAkBC,KAAwB;EACjE,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGH,KAAK,CAACI,QAAQ,EAAE;EAE9B,OAAO;;;IAGHC,WAAW,EAAEJ,IAAI,CAACK,cAAc,CAACC,SAAS,GAAGJ,KAAK,CAACE,WAAW,GAAGG,SAAS;IAC1EC,aAAa,EAAEN,KAAK,CAACM,aAAa;IAClCC,YAAY,EAAEC,qBAAqB,CAACR,KAAK,CAACO,YAAY,CAAC;IACvDE,gBAAgB,EAAEZ,KAAK,CAACE,OAAO,CAACW,YAAY,GAAGV,KAAK,CAACS,gBAAgB,GAAGJ,SAAS;IACjFM,+BAA+B,EAAEd,KAAK,CAACE,OAAO,CAACa,kBAAkB;IACjEC,QAAQ,EAAEf,IAAI,CAACe,QAAQ,CAACT,SAAS,GAAGN,IAAI,CAACe,QAAQ,CAACC,IAAI,GAAGT,SAAS;;IAElEU,KAAK,EAAEjB,IAAI,CAACkB,QAAQ,CAACC,QAAQ;IAC7BC,SAAS,EAAEpB,IAAI,CAACoB,SAAS,CAACd,SAAS,GAAGN,IAAI,CAACoB,SAAS,CAACC,MAAM,GAAGd,SAAS;;IAEvEe,OAAO,EAAEpB,KAAK,CAACoB;GAClB;AACL;SAEgBZ,qBAAqBA,CAACa,IAAY;EAC9C,OAAOC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,MAAM,CAAC,CAACC,KAAK,EAAEC,GAAG;IACvC,IAAIC,gBAAgB,CAACD,GAAG,CAAC,EAAE;MACvB,OAAOD,KAAK;;IAGhB,OAAO;MACH,GAAGA,KAAK;MACR,CAACC,GAAG,GAAGL,IAAI,CAACK,GAAG;KAClB;GACJ,EAAE,EAAE,CAAC;AACV;;;;"}
|
@@ -297,8 +297,11 @@ function useReactTableInitialState(props, columns, persistedSettings, defaults)
|
|
297
297
|
if (columnPinning !== null && columnPinning !== void 0 && (_columnPinning$left = columnPinning.left) !== null && _columnPinning$left !== void 0 && _columnPinning$left.length) {
|
298
298
|
columnPinning.left = freezeUptoExternalColumn(columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]), columnOrder);
|
299
299
|
} else {
|
300
|
-
if (props.defaultColumnFreezingIndex) {
|
301
|
-
|
300
|
+
if (props.defaultColumnFreezingIndex !== undefined) {
|
301
|
+
const index = typeof props.defaultColumnFreezingIndex === 'function' ? props.defaultColumnFreezingIndex(persistedSettings) : props.defaultColumnFreezingIndex;
|
302
|
+
if (index !== undefined) {
|
303
|
+
columnPinning.left = freezeUptoExternalColumn(index, columnOrder);
|
304
|
+
}
|
302
305
|
} else {
|
303
306
|
columnPinning.left = unfreezeAllExternalColumns(columnOrder);
|
304
307
|
}
|