@economic/taco 2.22.2 → 2.24.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +2 -0
- package/dist/components/OverflowGroup/OverflowGroup.d.ts +1 -1
- package/dist/components/Provider/Localization.d.ts +4 -0
- package/dist/components/Report/Report.d.ts +2 -0
- package/dist/components/Report/components/Body/Body.d.ts +0 -1
- package/dist/components/Report/components/Body/EmptyStateBody.d.ts +7 -0
- package/dist/components/Report/components/Cell/util.d.ts +1 -1
- package/dist/components/Report/components/Footer/Summary.d.ts +0 -1
- package/dist/components/Report/components/Toolbar/components/Filters/components/Filter.d.ts +2 -2
- package/dist/components/Report/components/Toolbar/components/Filters/components/FilterColumn.d.ts +5 -2
- package/dist/components/Report/types.d.ts +2 -0
- package/dist/components/Report/useReport.d.ts +1 -1
- package/dist/components/Select2/Select2.d.ts +4 -0
- package/dist/components/Select2/components/Trigger.d.ts +1 -0
- package/dist/components/Select2/hooks/useChildren.d.ts +1 -0
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +2 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +5 -2
- package/dist/components/Truncate/Truncate.d.ts +2 -2
- package/dist/esm/index.css +128 -121
- package/dist/esm/packages/taco/src/components/Button/util.js +8 -8
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js +8 -4
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +11 -2
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js +4 -15
- package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +2 -2
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +1 -1
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js +13 -6
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/Report.js +11 -13
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js +1 -2
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js +18 -0
- package/dist/esm/packages/taco/src/components/Report/components/Body/EmptyStateBody.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js +6 -2
- package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js +14 -2
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js +2 -2
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js +47 -11
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js +28 -43
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js +14 -7
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js +4 -3
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js +10 -8
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js +2 -2
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +10 -6
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js +3 -10
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +2 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +44 -4
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +9 -4
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +4 -6
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +66 -14
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +27 -44
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +14 -7
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +4 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +2 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +3 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +10 -3
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js +4 -3
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +34 -0
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +1 -0
- package/dist/esm/packages/taco/src/hooks/useLocalStorage.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +2 -1
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Button.js +1 -0
- package/dist/esm/packages/taco/src/primitives/Button.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/useTable/features/useTablePrinting.js +24 -4
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +48 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +11 -6
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js +33 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js +5 -5
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js +14 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js +0 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +127 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +12 -3
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +4 -4
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/keyboard.js +2 -2
- package/dist/esm/packages/taco/src/utils/keyboard.js.map +1 -1
- package/dist/hooks/useLocalStorage.d.ts +2 -1
- package/dist/index.css +128 -121
- package/dist/index.d.ts +1 -0
- package/dist/primitives/Table/types.d.ts +12 -2
- package/dist/primitives/Table/useTable/features/useTablePrinting.d.ts +10 -3
- package/dist/primitives/Table/useTable/features/useTableSettings.d.ts +2 -2
- package/dist/primitives/Table/useTable/useTable.d.ts +2 -1
- package/dist/primitives/Table/useTable/util/settings.d.ts +0 -1
- package/dist/taco.cjs.development.js +814 -455
- 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/dist/utils/dom.d.ts +3 -1
- package/dist/utils/hooks/useTruncated.d.ts +1 -1
- package/package.json +2 -2
- package/types.json +9339 -9261
- package/dist/components/Report/components/Toolbar/components/Filters/components/Placeholder.d.ts +0 -12
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +0 -12
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js +0 -41
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +0 -41
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Filters.js","sources":["../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/Filters.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Table as RTable, Column as RTColumn } from '@tanstack/react-table';\nimport { Button } from '../../../../../Button/Button';\nimport { Icon } from '../../../../../Icon/Icon';\nimport { Popover } from '../../../../../Popover/Popover';\nimport { Table3FilterValue, Table3FilterComparator, Table3Filter, ColumnFilter } from '../../../../types';\nimport { Shortcut } from '../../../../../Shortcut/Shortcut';\nimport { useLocalization } from '../../../../../Provider/Localization';\nimport { isInternalColumn } from '../../../../util/columns';\nimport { Placeholder } from './components/Placeholder';\nimport { Filter } from './components/Filter';\nimport { Group } from '../../../../../Group/Group';\nimport { useIsLargeScreen } from '../../../../../../hooks/useIsLargeScreen';\nimport { IconButton } from '../../../../../IconButton/IconButton';\n\nfunction sortByHeader<TType = unknown>(a: RTColumn<TType>, b: RTColumn<TType>) {\n return (a.columnDef.meta?.header as string)?.localeCompare?.(b.columnDef.meta?.header as string);\n}\n\nexport type FiltersProps<TType = unknown> = {\n total: number;\n table: RTable<TType>;\n};\n\nexport function FiltersButton<TType = unknown>(props: FiltersProps<TType>) {\n const { total, table } = props;\n const { locale, texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const isLargeScreen = useIsLargeScreen();\n const allColumns = table\n .getAllLeafColumns()\n .filter(column => !isInternalColumn(column.id))\n .sort(sortByHeader);\n const appliedFilters = table.getState().columnFilters as Table3Filter[];\n\n const shortcut = { key: 'f', meta: true, shift: true };\n\n // state, since we \"apply\" filters\n const [filters, setFilters] = React.useState<Table3Filter[]>(appliedFilters);\n const [placeholderCount, setPlaceholderCount] = React.useState(1);\n\n // filters\n const handleChangeFilter = (currentId: string | null, filter: { id: string | null; value: Table3FilterValue }) => {\n setFilters(currentFilters => {\n const nextFilters = [...currentFilters];\n const index = nextFilters.findIndex(f => f.id === currentId);\n nextFilters[index] = filter;\n return nextFilters;\n });\n };\n\n const handleRemoveFilter = (columnId: string | null) => {\n if (filters.length === 1 && placeholderCount === 0) {\n setPlaceholderCount(count => count + 1);\n }\n\n setFilters(currentFilters => currentFilters.filter(f => f.id !== columnId));\n };\n\n // placeholders\n const handleCreateFilterFromPlaceholder = (columnId: string) => {\n setFilters(currentFilters => [\n ...currentFilters,\n {\n id: columnId,\n value: {\n comparator: Table3FilterComparator.Contains,\n value: undefined,\n },\n },\n ]);\n handleRemovePlaceholder();\n };\n\n const handleCreatePlaceholder = () => {\n setPlaceholderCount(count => count + 1);\n };\n\n const handleRemovePlaceholder = () => {\n setPlaceholderCount(count => count - 1);\n };\n\n //\n const handleApply = () => {\n table.setColumnFilters(() => {\n const newFilters = filters.filter(f => {\n if (f.id === null) {\n return false;\n }\n\n const controlRenderer = (allColumns.find(c => c.id === f.id) as RTColumn<TType, unknown>)?.columnDef.meta\n ?.control;\n if (\n f.value.comparator === Table3FilterComparator.IsEmpty ||\n f.value.comparator === Table3FilterComparator.IsNotEmpty ||\n controlRenderer === 'switch'\n ) {\n return true;\n }\n return !!f.value.value;\n });\n // Compiler didn't get that we stripped out filters with null ids, so we still need to cast a ColumnFilter type here\n return newFilters as ColumnFilter[];\n });\n };\n\n const handleClear = () => {\n table.resetColumnFilters();\n setFilters([]);\n setPlaceholderCount(1);\n };\n\n const handleClose = React.useCallback(\n (open: boolean) => {\n if (!open) {\n setFilters(appliedFilters);\n setPlaceholderCount(appliedFilters.length === 0 ? 1 : 0);\n }\n },\n [appliedFilters]\n );\n\n // Because filters can be reset from outside\n React.useEffect(() => {\n if (appliedFilters.length === 0) {\n setFilters([]);\n setPlaceholderCount(1);\n }\n }, [appliedFilters]);\n\n const buttonProps = {\n 'aria-label': texts.table3.filters.tooltip,\n className: cn({ '!wcag-blue-100': appliedFilters.length }),\n shortcut,\n popover: popoverProps => (\n <Popover {...popoverProps} onChange={handleClose}>\n <Popover.Content>\n <div className=\"flex w-[40rem] flex-col gap-4\">\n <div className=\"flex h-8\">\n <div className=\"flex w-full items-center gap-2\">\n <h4 className=\"mb-0 inline-flex\">{texts.table3.filters.button}</h4>\n <p className=\"text-grey-700 mb-0 mr-auto mt-px inline-flex\">\n {texts.table3.filters.total\n .replace(\n '[CURRENT]',\n new Intl.NumberFormat(locale).format(table.getFilteredRowModel().rows.length)\n )\n .replace('[TOTAL]', new Intl.NumberFormat(locale).format(total))}\n </p>\n </div>\n </div>\n <div className=\"flex flex-col gap-2\">\n {filters.map((filter, index) => (\n <Filter\n key={`filter_${index}`}\n allColumns={allColumns as RTColumn<unknown, unknown>[]}\n filter={filter}\n filters={filters}\n position={index}\n onChange={handleChangeFilter}\n onRemove={handleRemoveFilter}\n />\n ))}\n {[...Array(placeholderCount)].map((_, index) => (\n <Placeholder\n key={`placeholder_${index}`}\n allColumns={allColumns as RTColumn<unknown, unknown>[]}\n filters={filters}\n position={filters.length + index}\n onCreate={handleCreateFilterFromPlaceholder as any}\n onRemove={placeholderCount > 1 || filters.length > 0 ? handleRemovePlaceholder : undefined}\n />\n ))}\n <div className=\"justify-start\">\n <Button appearance=\"discrete\" onClick={handleCreatePlaceholder}>\n + {texts.table3.filters.buttons.addFilter}\n </Button>\n </div>\n </div>\n <Group className=\"ml-auto\">\n <Popover.Close>\n <Button>Cancel</Button>\n </Popover.Close>\n <Button onClick={handleClear}>Clear</Button>\n <Button appearance=\"primary\" onClick={handleApply}>\n Apply\n </Button>\n </Group>\n </div>\n </Popover.Content>\n </Popover>\n ),\n ref,\n tooltip: (\n <>\n {texts.table3.filters.tooltip}\n <Shortcut className=\"ml-2\" keys={{ key: 'f', meta: true, shift: true }} />\n </>\n ),\n };\n\n if (!isLargeScreen && !appliedFilters.length) {\n return <IconButton {...buttonProps} icon=\"filter\" />;\n }\n return (\n <Button {...buttonProps}>\n <Icon className={cn({ '-mr-1.5': !isLargeScreen })} name={appliedFilters.length ? 'filter-solid' : 'filter'} />\n {isLargeScreen ? texts.table3.filters.button : ''}\n {appliedFilters.length ? `(${appliedFilters.length})` : ''}\n </Button>\n );\n}\n"],"names":["sortByHeader","a","b","_a$columnDef$meta","columnDef","meta","_a$columnDef$meta$hea","header","_a$columnDef$meta$hea2","localeCompare","call","_b$columnDef$meta","FiltersButton","props","total","table","locale","texts","useLocalization","ref","React","useRef","isLargeScreen","useIsLargeScreen","allColumns","getAllLeafColumns","filter","column","isInternalColumn","id","sort","appliedFilters","getState","columnFilters","shortcut","key","shift","filters","setFilters","useState","placeholderCount","setPlaceholderCount","handleChangeFilter","currentId","currentFilters","nextFilters","index","findIndex","f","handleRemoveFilter","columnId","length","count","handleCreateFilterFromPlaceholder","value","comparator","Table3FilterComparator","Contains","undefined","handleRemovePlaceholder","handleCreatePlaceholder","handleApply","setColumnFilters","newFilters","controlRenderer","_allColumns$find","find","c","_allColumns$find$colu","control","IsEmpty","IsNotEmpty","handleClear","resetColumnFilters","handleClose","useCallback","open","useEffect","buttonProps","table3","tooltip","className","cn","popover","popoverProps","Popover","onChange","Content","button","replace","Intl","NumberFormat","format","getFilteredRowModel","rows","map","Filter","position","onRemove","Array","_","Placeholder","onCreate","Button","appearance","onClick","buttons","addFilter","Group","Close","Shortcut","keys","IconButton","icon","Icon","name"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAASA,YAAYA,CAAkBC,CAAkB,EAAEC,CAAkB;;EACzE,QAAAC,iBAAA,GAAQF,CAAC,CAACG,SAAS,CAACC,IAAI,cAAAF,iBAAA,wBAAAG,qBAAA,GAAhBH,iBAAA,CAAkBI,MAAiB,cAAAD,qBAAA,wBAAAE,sBAAA,GAAnCF,qBAAA,CAAqCG,aAAa,cAAAD,sBAAA,uBAAlDA,sBAAA,CAAAE,IAAA,CAAAJ,qBAAA,GAAAK,iBAAA,GAAqDT,CAAC,CAACE,SAAS,CAACC,IAAI,cAAAM,iBAAA,uBAAhBA,iBAAA,CAAkBJ,MAAgB,CAAC;AACpG;SAOgBK,aAAaA,CAAkBC,KAA0B;EACrE,MAAM;IAAEC,KAAK;IAAEC;GAAO,GAAGF,KAAK;EAC9B,MAAM;IAAEG,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAC3C,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,aAAa,GAAGC,gBAAgB,EAAE;EACxC,MAAMC,UAAU,GAAGT,KAAK,CACnBU,iBAAiB,EAAE,CACnBC,MAAM,CAACC,MAAM,IAAI,CAACC,gBAAgB,CAACD,MAAM,CAACE,EAAE,CAAC,CAAC,CAC9CC,IAAI,CAAC9B,YAAY,CAAC;EACvB,MAAM+B,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;MAAC7B,SAAS,EAAC,MAAM;MAAC8B,IAAI,EAAE;QAAE5E,GAAG,EAAE,GAAG;QAAE9B,IAAI,EAAE,IAAI;QAAE+B,KAAK,EAAE;;MAAU,CAC3E;GAEV;EAED,IAAI,CAACd,aAAa,IAAI,CAACS,cAAc,CAACoB,MAAM,EAAE;IAC1C,oBAAO/B,6BAAC4F,UAAU,oBAAKlC,WAAW;MAAEmC,IAAI,EAAC;OAAW;;EAExD,oBACI7F,6BAACmF,MAAM,oBAAKzB,WAAW,gBACnB1D,6BAAC8F,IAAI;IAACjC,SAAS,EAAEC,EAAE,CAAC;MAAE,SAAS,EAAE,CAAC5D;KAAe,CAAC;IAAE6F,IAAI,EAAEpF,cAAc,CAACoB,MAAM,GAAG,cAAc,GAAG;IAAY,EAC9G7B,aAAa,GAAGL,KAAK,CAAC8D,MAAM,CAAC1C,OAAO,CAACmD,MAAM,GAAG,EAAE,EAChDzD,cAAc,CAACoB,MAAM,OAAOpB,cAAc,CAACoB,SAAS,GAAG,EAAE,CACrD;AAEjB;;;;"}
|
1
|
+
{"version":3,"file":"Filters.js","sources":["../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/Filters.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Table as RTable, Column as RTColumn } from '@tanstack/react-table';\nimport { Button } from '../../../../../Button/Button';\nimport { Icon } from '../../../../../Icon/Icon';\nimport { Popover } from '../../../../../Popover/Popover';\nimport { Table3FilterValue, Table3FilterComparator, Table3Filter, ColumnFilter } from '../../../../types';\nimport { Shortcut } from '../../../../../Shortcut/Shortcut';\nimport { useLocalization } from '../../../../../Provider/Localization';\nimport { isInternalColumn } from '../../../../util/columns';\nimport { Filter } from './components/Filter';\nimport { Group } from '../../../../../Group/Group';\nimport { useIsLargeScreen } from '../../../../../../hooks/useIsLargeScreen';\nimport { IconButton } from '../../../../../IconButton/IconButton';\n\nfunction sortByHeader<TType = unknown>(a: RTColumn<TType>, b: RTColumn<TType>) {\n return (a.columnDef.meta?.header as string)?.localeCompare?.(b.columnDef.meta?.header as string);\n}\n\nexport type FiltersProps<TType = unknown> = {\n total: number;\n table: RTable<TType>;\n};\n\nconst placeholderFilter: Table3Filter = { id: null, value: { comparator: Table3FilterComparator.Contains, value: undefined } };\n\nexport function FiltersButton<TType = unknown>(props: FiltersProps<TType>) {\n const { total, table } = props;\n const { locale, texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const isLargeScreen = useIsLargeScreen();\n const allColumns = table\n .getAllLeafColumns()\n .filter(column => !isInternalColumn(column.id))\n .sort(sortByHeader);\n\n const appliedFilters = table.getState().columnFilters as Table3Filter[];\n const shortcut = { key: 'f', meta: true, shift: true };\n\n // state, since we \"apply\" filters\n const [filters, setFilters] = React.useState<Table3Filter[]>(appliedFilters.length ? appliedFilters : [placeholderFilter]);\n\n // filters\n const handleChangeFilter = (position: number, filter: { id: string | null; value: Table3FilterValue }) => {\n setFilters(currentFilters => {\n return currentFilters.map((current, index) => {\n if (index === position) {\n return filter;\n }\n return current;\n });\n });\n };\n\n const handleRemoveFilter = position => {\n if (filters.length === 1) {\n setFilters([placeholderFilter]);\n return;\n }\n\n setFilters(currentFilters => currentFilters.filter((_, index) => index !== position));\n };\n\n const handleCreateNew = () => {\n setFilters(filters.concat(placeholderFilter));\n };\n\n const handleApply = () => {\n table.setColumnFilters(() => {\n const newFilters = filters.filter(f => {\n if (f.id === null) {\n return false;\n }\n\n const controlRenderer = (allColumns.find(c => c.id === f.id) as RTColumn<TType, unknown>)?.columnDef.meta\n ?.control;\n if (\n f.value.comparator === Table3FilterComparator.IsEmpty ||\n f.value.comparator === Table3FilterComparator.IsNotEmpty ||\n controlRenderer === 'switch'\n ) {\n return true;\n }\n return !!f.value.value;\n });\n // Compiler didn't get that we stripped out filters with null ids, so we still need to cast a ColumnFilter type here\n return newFilters as ColumnFilter[];\n });\n };\n\n const handleClear = () => {\n table.resetColumnFilters();\n setFilters([placeholderFilter]);\n };\n\n const handleClose = React.useCallback(\n (open: boolean) => {\n if (!open) {\n setFilters(appliedFilters.length === 0 ? [placeholderFilter] : appliedFilters);\n }\n },\n [appliedFilters]\n );\n\n // Because filters can be reset from outside\n React.useEffect(() => {\n if (appliedFilters.length === 0) {\n setFilters([placeholderFilter]);\n }\n }, [appliedFilters]);\n\n const buttonProps = {\n 'aria-label': texts.table3.filters.tooltip,\n className: cn({ '!wcag-blue-100': appliedFilters.length }),\n shortcut,\n popover: popoverProps => (\n <Popover {...popoverProps} onChange={handleClose}>\n <Popover.Content>\n <div className=\"flex w-[40rem] flex-col gap-4\">\n <div className=\"flex h-8\">\n <div className=\"flex w-full items-center gap-2\">\n <h4 className=\"mb-0 inline-flex\">{texts.table3.filters.button}</h4>\n <p className=\"text-grey-700 mb-0 mr-auto mt-px inline-flex\">\n {texts.table3.filters.total\n .replace(\n '[CURRENT]',\n new Intl.NumberFormat(locale).format(table.getFilteredRowModel().rows.length)\n )\n .replace('[TOTAL]', new Intl.NumberFormat(locale).format(total))}\n </p>\n </div>\n </div>\n <div className=\"flex flex-col gap-2\">\n {filters.map((filter, index) => (\n <Filter\n key={`filter_${index}`}\n allColumns={allColumns}\n filter={filter}\n filters={filters}\n position={index}\n onChange={handleChangeFilter}\n onRemove={\n (filters.length > 0 && filters.some(f => f.id)) || filters.length > 1\n ? handleRemoveFilter\n : undefined\n }\n />\n ))}\n <div className=\"justify-start\">\n <Button appearance=\"discrete\" onClick={handleCreateNew}>\n + {texts.table3.filters.buttons.addFilter}\n </Button>\n </div>\n </div>\n <Group className=\"ml-auto\">\n <Popover.Close>\n <Button>Cancel</Button>\n </Popover.Close>\n <Button onClick={handleClear}>Clear</Button>\n <Button appearance=\"primary\" onClick={handleApply}>\n Apply\n </Button>\n </Group>\n </div>\n </Popover.Content>\n </Popover>\n ),\n ref,\n tooltip: (\n <>\n {texts.table3.filters.tooltip}\n <Shortcut className=\"ml-2\" keys={{ key: 'f', meta: true, shift: true }} />\n </>\n ),\n };\n\n if (!isLargeScreen && !appliedFilters.length) {\n return <IconButton {...buttonProps} icon=\"filter\" />;\n }\n return (\n <Button {...buttonProps}>\n <Icon className={cn({ '-mr-1.5': !isLargeScreen })} name={appliedFilters.length ? 'filter-solid' : 'filter'} />\n {isLargeScreen ? texts.table3.filters.button : ''}\n {appliedFilters.length ? `(${appliedFilters.length})` : ''}\n </Button>\n );\n}\n"],"names":["sortByHeader","a","b","_a$columnDef$meta","columnDef","meta","_a$columnDef$meta$hea","header","_a$columnDef$meta$hea2","localeCompare","call","_b$columnDef$meta","placeholderFilter","id","value","comparator","Table3FilterComparator","Contains","undefined","FiltersButton","props","total","table","locale","texts","useLocalization","ref","React","useRef","isLargeScreen","useIsLargeScreen","allColumns","getAllLeafColumns","filter","column","isInternalColumn","sort","appliedFilters","getState","columnFilters","shortcut","key","shift","filters","setFilters","useState","length","handleChangeFilter","position","currentFilters","map","current","index","handleRemoveFilter","_","handleCreateNew","concat","handleApply","setColumnFilters","newFilters","f","controlRenderer","_allColumns$find","find","c","_allColumns$find$colu","control","IsEmpty","IsNotEmpty","handleClear","resetColumnFilters","handleClose","useCallback","open","useEffect","buttonProps","table3","tooltip","className","cn","popover","popoverProps","Popover","onChange","Content","button","replace","Intl","NumberFormat","format","getFilteredRowModel","rows","Filter","onRemove","some","Button","appearance","onClick","buttons","addFilter","Group","Close","Shortcut","keys","IconButton","icon","Icon","name"],"mappings":";;;;;;;;;;;;;;AAeA,SAASA,YAAYA,CAAkBC,CAAkB,EAAEC,CAAkB;;EACzE,QAAAC,iBAAA,GAAQF,CAAC,CAACG,SAAS,CAACC,IAAI,cAAAF,iBAAA,wBAAAG,qBAAA,GAAhBH,iBAAA,CAAkBI,MAAiB,cAAAD,qBAAA,wBAAAE,sBAAA,GAAnCF,qBAAA,CAAqCG,aAAa,cAAAD,sBAAA,uBAAlDA,sBAAA,CAAAE,IAAA,CAAAJ,qBAAA,GAAAK,iBAAA,GAAqDT,CAAC,CAACE,SAAS,CAACC,IAAI,cAAAM,iBA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,EAAE;IAC1C,oBAAOnB,6BAAC6E,UAAU,oBAAK7B,WAAW;MAAE8B,IAAI,EAAC;OAAW;;EAExD,oBACI9E,6BAACoE,MAAM,oBAAKpB,WAAW,gBACnBhD,6BAAC+E,IAAI;IAAC5B,SAAS,EAAEC,EAAE,CAAC;MAAE,SAAS,EAAE,CAAClD;KAAe,CAAC;IAAE8E,IAAI,EAAEtE,cAAc,CAACS,MAAM,GAAG,cAAc,GAAG;IAAY,EAC9GjB,aAAa,GAAGL,KAAK,CAACoD,MAAM,CAACjC,OAAO,CAAC0C,MAAM,GAAG,EAAE,EAChDhD,cAAc,CAACS,MAAM,OAAOT,cAAc,CAACS,SAAS,GAAG,EAAE,CACrD;AAEjB;;;;"}
|
@@ -19,6 +19,7 @@ function Filter(props) {
|
|
19
19
|
texts
|
20
20
|
} = useLocalization();
|
21
21
|
const column = allColumns.find(c => c.id === filter.id);
|
22
|
+
const ref = React__default.useRef(null);
|
22
23
|
const {
|
23
24
|
id,
|
24
25
|
value: {
|
@@ -37,7 +38,7 @@ function Filter(props) {
|
|
37
38
|
comparator: null,
|
38
39
|
value: null
|
39
40
|
};
|
40
|
-
handleChange(
|
41
|
+
handleChange(position, {
|
41
42
|
id: columnId,
|
42
43
|
value
|
43
44
|
});
|
@@ -47,7 +48,7 @@ function Filter(props) {
|
|
47
48
|
if (comparator === Table3FilterComparator.IsEmpty || comparator === Table3FilterComparator.IsNotEmpty) {
|
48
49
|
nextValue = undefined;
|
49
50
|
}
|
50
|
-
handleChange(
|
51
|
+
handleChange(position, {
|
51
52
|
id,
|
52
53
|
value: {
|
53
54
|
comparator,
|
@@ -56,7 +57,7 @@ function Filter(props) {
|
|
56
57
|
});
|
57
58
|
};
|
58
59
|
const handleChangeValue = value => {
|
59
|
-
handleChange(
|
60
|
+
handleChange(position, {
|
60
61
|
id,
|
61
62
|
value: {
|
62
63
|
...filter.value,
|
@@ -64,7 +65,12 @@ function Filter(props) {
|
|
64
65
|
}
|
65
66
|
});
|
66
67
|
};
|
67
|
-
const handleRemove = () => onRemove(
|
68
|
+
const handleRemove = () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(position);
|
69
|
+
React__default.useEffect(() => {
|
70
|
+
if (ref.current && !id) {
|
71
|
+
ref.current.focus(); // after adding a new filter placeholder, we want to focus it right way.
|
72
|
+
}
|
73
|
+
}, [id]);
|
68
74
|
return /*#__PURE__*/React__default.createElement("div", {
|
69
75
|
className: "flex items-start gap-2"
|
70
76
|
}, /*#__PURE__*/React__default.createElement("div", {
|
@@ -73,7 +79,8 @@ function Filter(props) {
|
|
73
79
|
allColumns: allColumns,
|
74
80
|
filters: filters,
|
75
81
|
onChange: handleChangeColumn,
|
76
|
-
value: id
|
82
|
+
value: id,
|
83
|
+
ref: ref
|
77
84
|
}), /*#__PURE__*/React__default.createElement(FilterComparator, {
|
78
85
|
column: column,
|
79
86
|
onChange: handleChangeComparator,
|
@@ -83,12 +90,12 @@ function Filter(props) {
|
|
83
90
|
comparator: comparator,
|
84
91
|
onChange: handleChangeValue,
|
85
92
|
value: value
|
86
|
-
}), /*#__PURE__*/React__default.createElement(IconButton, {
|
93
|
+
}), onRemove ? /*#__PURE__*/React__default.createElement(IconButton, {
|
87
94
|
appearance: "discrete",
|
88
95
|
className: "ml-auto",
|
89
96
|
icon: "close",
|
90
97
|
onClick: handleRemove
|
91
|
-
}));
|
98
|
+
}) : null);
|
92
99
|
}
|
93
100
|
|
94
101
|
export { Filter };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Filter.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/Filter.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../IconButton/IconButton';\nimport { Table3Filter, Table3FilterComparator } from '../../../../../types';\nimport { useLocalization } from '../../../../../../Provider/Localization';\nimport { FilterColumn } from './FilterColumn';\nimport { FilterComparator } from './FilterComparator';\nimport { FilterValue } from './FilterValue';\n\nexport type FilterProps<TType = unknown> = {\n allColumns: RTColumn<TType, unknown>[];\n filter: Table3Filter;\n filters: Table3Filter[];\n position: number;\n onChange: (
|
1
|
+
{"version":3,"file":"Filter.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/Filter.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../IconButton/IconButton';\nimport { Table3Filter, Table3FilterComparator } from '../../../../../types';\nimport { useLocalization } from '../../../../../../Provider/Localization';\nimport { FilterColumn } from './FilterColumn';\nimport { FilterComparator } from './FilterComparator';\nimport { FilterValue } from './FilterValue';\n\nexport type FilterProps<TType = unknown> = {\n allColumns: RTColumn<TType, unknown>[];\n filter: Table3Filter;\n filters: Table3Filter[];\n position: number;\n onChange: (position: number, value: Table3Filter) => void;\n onRemove?: (position: number) => void;\n};\n\nexport function Filter<TType = unknown>(props: FilterProps<TType>) {\n const { allColumns, filter, filters, onChange: handleChange, onRemove, position } = props;\n const { texts } = useLocalization();\n const column = allColumns.find(c => c.id === filter.id) as RTColumn<TType, unknown>;\n const ref = React.useRef<HTMLButtonElement>(null);\n\n const {\n id,\n value: { comparator, value },\n } = filter;\n\n const handleChangeColumn = (columnId: string | null) => {\n const columnPrev = allColumns.find(column => column.id === id);\n const columnNext = allColumns.find(column => column.id === columnId);\n // UX requirement: if old column data type is the same as next column data type,\n // then we applying the same filter value for the next column,\n // but when data types are different, we're reseting comparator ans value for the next column\n const value =\n columnPrev?.columnDef.meta?.dataType === columnNext?.columnDef.meta?.dataType\n ? filter.value\n : { comparator: null, value: null };\n\n handleChange(position, { id: columnId, value });\n };\n\n const handleChangeComparator = (comparator: Table3FilterComparator) => {\n let nextValue = filter.value.value;\n\n if (comparator === Table3FilterComparator.IsEmpty || comparator === Table3FilterComparator.IsNotEmpty) {\n nextValue = undefined;\n }\n handleChange(position, { id, value: { comparator, value: nextValue } });\n };\n\n const handleChangeValue = (value: any) => {\n handleChange(position, { id, value: { ...filter.value, value } });\n };\n\n const handleRemove = () => onRemove?.(position);\n\n React.useEffect(() => {\n if (ref.current && !id) {\n ref.current.focus(); // after adding a new filter placeholder, we want to focus it right way.\n }\n }, [id]);\n\n return (\n <div className=\"flex items-start gap-2\">\n <div className=\"flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right\">\n {position > 0 ? texts.table3.filters.conditions.and : texts.table3.filters.conditions.where}\n </div>\n <FilterColumn\n allColumns={allColumns as any}\n filters={filters}\n onChange={handleChangeColumn as any}\n value={id}\n ref={ref}\n />\n <FilterComparator column={column} onChange={handleChangeComparator as any} value={comparator} />\n <FilterValue column={column} comparator={comparator} onChange={handleChangeValue} value={value} />\n {onRemove ? <IconButton appearance=\"discrete\" className=\"ml-auto\" icon=\"close\" onClick={handleRemove} /> : null}\n </div>\n );\n}\n"],"names":["Filter","props","allColumns","filter","filters","onChange","handleChange","onRemove","position","texts","useLocalization","column","find","c","id","ref","React","useRef","value","comparator","handleChangeColumn","columnId","columnPrev","columnNext","_columnPrev$columnDef","columnDef","meta","dataType","_columnNext$columnDef","handleChangeComparator","nextValue","Table3FilterComparator","IsEmpty","IsNotEmpty","undefined","handleChangeValue","handleRemove","useEffect","current","focus","className","table3","conditions","and","where","FilterColumn","FilterComparator","FilterValue","IconButton","appearance","icon","onClick"],"mappings":";;;;;;;;SAkBgBA,MAAMA,CAAkBC,KAAyB;EAC7D,MAAM;IAAEC,UAAU;IAAEC,MAAM;IAAEC,OAAO;IAAEC,QAAQ,EAAEC,YAAY;IAAEC,QAAQ;IAAEC;GAAU,GAAGP,KAAK;EACzF,MAAM;IAAEQ;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,MAAM,GAAGT,UAAU,CAACU,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,EAAE,KAAKX,MAAM,CAACW,EAAE,CAA6B;EACnF,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAA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E,GAAGf,MAAM,CAACe,KAAK;QAAEA;;KAAS,CAAC;GACpE;EAED,MAAMkB,YAAY,GAAGA,MAAM7B,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGC,QAAQ,CAAC;EAE/CQ,cAAK,CAACqB,SAAS,CAAC;IACZ,IAAItB,GAAG,CAACuB,OAAO,IAAI,CAACxB,EAAE,EAAE;MACpBC,GAAG,CAACuB,OAAO,CAACC,KAAK,EAAE,CAAC;;GAE3B,EAAE,CAACzB,EAAE,CAAC,CAAC;EAER,oBACIE;IAAKwB,SAAS,EAAC;kBACXxB;IAAKwB,SAAS,EAAC;KACVhC,QAAQ,GAAG,CAAC,GAAGC,KAAK,CAACgC,MAAM,CAACrC,OAAO,CAACsC,UAAU,CAACC,GAAG,GAAGlC,KAAK,CAACgC,MAAM,CAACrC,OAAO,CAACsC,UAAU,CAACE,KAAK,CACzF,eACN5B,6BAAC6B,YAAY;IACT3C,UAAU,EAAEA,UAAiB;IAC7BE,OAAO,EAAEA,OAAO;IAChBC,QAAQ,EAAEe,kBAAyB;IACnCF,KAAK,EAAEJ,EAAE;IACTC,GAAG,EAAEA;IACP,eACFC,6BAAC8B,gBAAgB;IAACnC,MAAM,EAAEA,MAAM;IAAEN,QAAQ,EAAEwB,sBAA6B;IAAEX,KAAK,EAAEC;IAAc,eAChGH,6BAAC+B,WAAW;IAACpC,MAAM,EAAEA,MAAM;IAAEQ,UAAU,EAAEA,UAAU;IAAEd,QAAQ,EAAE8B,iBAAiB;IAAEjB,KAAK,EAAEA;IAAS,EACjGX,QAAQ,gBAAGS,6BAACgC,UAAU;IAACC,UAAU,EAAC,UAAU;IAACT,SAAS,EAAC,SAAS;IAACU,IAAI,EAAC,OAAO;IAACC,OAAO,EAAEf;IAAgB,GAAG,IAAI,CAC7G;AAEd;;;;"}
|
@@ -5,7 +5,7 @@ import { useLocalization } from '../../../../../../Provider/Localization.js';
|
|
5
5
|
import { Field } from '../../../../../../Field/Field.js';
|
6
6
|
import { Select2 } from '../../../../../../Select2/Select2.js';
|
7
7
|
|
8
|
-
|
8
|
+
const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
9
9
|
const {
|
10
10
|
allColumns,
|
11
11
|
filters,
|
@@ -25,7 +25,8 @@ function FilterColumn(props) {
|
|
25
25
|
warning: warning,
|
26
26
|
className: "min-h-[theme(spacing.8)]"
|
27
27
|
}, /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
|
28
|
-
|
28
|
+
ref: ref,
|
29
|
+
className: "focus:yt-focus !w-32 flex-shrink-0",
|
29
30
|
emptyValue: null,
|
30
31
|
onChange: handleChange,
|
31
32
|
value: value
|
@@ -43,7 +44,7 @@ function FilterColumn(props) {
|
|
43
44
|
disabled: column.id !== value && (!column.getCanFilter() || !!filters.find(f => f.id === column.id))
|
44
45
|
}, ((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header) + (column.parent ? ` (${(_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : (_column$parent$column = _column$parent.columnDef.meta) === null || _column$parent$column === void 0 ? void 0 : _column$parent$column.header})` : ''));
|
45
46
|
}))));
|
46
|
-
}
|
47
|
+
});
|
47
48
|
|
48
49
|
export { FilterColumn };
|
49
50
|
//# sourceMappingURL=FilterColumn.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FilterColumn.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn } from '@tanstack/react-table';\nimport { Select2, Select2Props } from '../../../../../../Select2/Select2';\nimport { Icon } from '../../../../../../Icon/Icon';\nimport { Tooltip } from '../../../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../../../Provider/Localization';\nimport { Field } from '../../../../../../Field/Field';\nimport { Table3Filter } from '../../../../../types';\n\nexport type FilterColumnProps<TType = unknown> = Omit<Select2Props, 'children'> & {\n allColumns: RTColumn<TType, unknown>[];\n filters: Table3Filter[];\n};\n\nexport
|
1
|
+
{"version":3,"file":"FilterColumn.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn } from '@tanstack/react-table';\nimport { Select2, Select2Props } from '../../../../../../Select2/Select2';\nimport { Icon } from '../../../../../../Icon/Icon';\nimport { Tooltip } from '../../../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../../../Provider/Localization';\nimport { Field } from '../../../../../../Field/Field';\nimport { Table3Filter } from '../../../../../types';\n\nexport type FilterColumnProps<TType = unknown> = Omit<Select2Props, 'children'> & {\n allColumns: RTColumn<TType, unknown>[];\n filters: Table3Filter[];\n};\n\nexport const FilterColumn = React.forwardRef<HTMLButtonElement, FilterColumnProps>((props, ref) => {\n const { allColumns, filters, onChange: handleChange, value = null, ...attributes } = props;\n const { texts } = useLocalization();\n const selectedColumn = allColumns.find(column => column.id === value);\n const warning = selectedColumn && !selectedColumn.getIsVisible();\n\n return (\n <div className=\"flex flex-col\">\n <Field\n message={warning ? texts.table3.filters.hiddenColumn : undefined}\n warning={warning}\n className=\"min-h-[theme(spacing.8)]\">\n <Select2\n {...attributes}\n ref={ref}\n className=\"focus:yt-focus !w-32 flex-shrink-0\"\n emptyValue={null}\n onChange={handleChange}\n value={value}>\n {allColumns.map(column => (\n <Select2.Option\n key={column.id}\n value={column.id}\n postfix={\n !column.getIsVisible() ? (\n <Tooltip title={texts.table3.filters.hiddenColumn}>\n <Icon name=\"eye-off\" className=\"text-grey-500 !h-5 !w-5\" />\n </Tooltip>\n ) : undefined\n }\n disabled={column.id !== value && (!column.getCanFilter() || !!filters.find(f => f.id === column.id))}>\n {(column.columnDef.meta?.header as string) +\n (column.parent ? ` (${column.parent?.columnDef.meta?.header})` : '')}\n </Select2.Option>\n ))}\n </Select2>\n </Field>\n </div>\n );\n});\n"],"names":["FilterColumn","React","forwardRef","props","ref","allColumns","filters","onChange","handleChange","value","attributes","texts","useLocalization","selectedColumn","find","column","id","warning","getIsVisible","className","Field","message","table3","hiddenColumn","undefined","Select2","emptyValue","map","_column$columnDef$met","_column$parent","_column$parent$column","Option","key","postfix","Tooltip","title","Icon","name","disabled","getCanFilter","f","columnDef","meta","header","parent"],"mappings":";;;;;;;MAcaA,YAAY,gBAAGC,cAAK,CAACC,UAAU,CAAuC,CAACC,KAAK,EAAEC,GAAG;EAC1F,MAAM;IAAEC,UAAU;IAAEC,OAAO;IAAEC,QAAQ,EAAEC,YAAY;IAAEC,KAAK,GAAG,IAAI;IAAE,GAAGC;GAAY,GAAGP,KAAK;EAC1F,MAAM;IAAEQ;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,cAAc,GAAGR,UAAU,CAACS,IAAI,CAACC,MAAM,IAAIA,MAAM,CAACC,EAAE,KAAKP,KAAK,CAAC;EACrE,MAAMQ,OAAO,GAAGJ,cAAc,IAAI,CAACA,cAAc,CAACK,YAAY,EAAE;EAEhE,oBACIjB;IAAKkB,SAAS,EAAC;kBACXlB,6BAACmB,KAAK;IACFC,OAAO,EAAEJ,OAAO,GAAGN,KAAK,CAACW,MAAM,CAAChB,OAAO,CAACiB,YAAY,GAAGC,SAAS;IAChEP,OAAO,EAAEA,OAAO;IAChBE,SAAS,EAAC;kBACVlB,6BAACwB,OAAO,oBACAf,UAAU;IACdN,GAAG,EAAEA,GAAG;IACRe,SAAS,EAAC,oCAAoC;IAC9CO,UAAU,EAAE,IAAI;IAChBnB,QAAQ,EAAEC,YAAY;IACtBC,KAAK,EAAEA;MACNJ,UAAU,CAACsB,GAAG,CAACZ,MAAM;IAAA,IAAAa,qBAAA,EAAAC,cAAA,EAAAC,qBAAA;IAAA,oBAClB7B,6BAACwB,OAAO,CAACM,MAAM;MACXC,GAAG,EAAEjB,MAAM,CAACC,EAAE;MACdP,KAAK,EAAEM,MAAM,CAACC,EAAE;MAChBiB,OAAO,EACH,CAAClB,MAAM,CAACG,YAAY,EAAE,kBAClBjB,6BAACiC,OAAO;QAACC,KAAK,EAAExB,KAAK,CAACW,MAAM,CAAChB,OAAO,CAACiB;sBACjCtB,6BAACmC,IAAI;QAACC,IAAI,EAAC,SAAS;QAAClB,SAAS,EAAC;QAA4B,CACrD,IACVK,SAAS;MAEjBc,QAAQ,EAAEvB,MAAM,CAACC,EAAE,KAAKP,KAAK,KAAK,CAACM,MAAM,CAACwB,YAAY,EAAE,IAAI,CAAC,CAACjC,OAAO,CAACQ,IAAI,CAAC0B,CAAC,IAAIA,CAAC,CAACxB,EAAE,KAAKD,MAAM,CAACC,EAAE,CAAC;OACjG,EAAAY,qBAAA,GAAAb,MAAM,CAAC0B,SAAS,CAACC,IAAI,cAAAd,qBAAA,uBAArBA,qBAAA,CAAuBe,MAAiB,KACrC5B,MAAM,CAAC6B,MAAM,0BAAQ7B,MAAM,CAAC6B,MAAM,cAAAf,cAAA,wBAAAC,qBAAA,GAAbD,cAAA,CAAeY,SAAS,CAACC,IAAI,cAAAZ,qBAAA,uBAA7BA,qBAAA,CAA+Ba,SAAS,GAAG,EAAE,CAAC,CAC3D;GACpB,CAAC,CACI,CACN,CACN;AAEd,CAAC;;;;"}
|
@@ -20,7 +20,7 @@ function FilterComparator(props) {
|
|
20
20
|
}
|
21
21
|
}, [validComparators]);
|
22
22
|
return /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
|
23
|
-
className: "!w-32 flex-shrink-0",
|
23
|
+
className: "focus:yt-focus !w-32 flex-shrink-0",
|
24
24
|
disabled: !column,
|
25
25
|
onChange: handleChange,
|
26
26
|
value: value
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FilterComparator.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn, ColumnMeta } from '@tanstack/react-table';\nimport { Select2, Select2Props } from '../../../../../../Select2/Select2';\nimport { Table3FilterComparator } from '../../../../../types';\nimport { LocalizationTexts, useLocalization } from '../../../../../../Provider/Localization';\n\nexport type FilterComparatorProps<TType = unknown> = Omit<Select2Props, 'children'> & {\n column?: RTColumn<TType, unknown>;\n};\n\nexport function FilterComparator<TType = unknown>(props: FilterComparatorProps<TType>) {\n const { column, onChange: handleChange, value, ...attributes } = props;\n const { texts } = useLocalization();\n\n const validComparators = guessComparatorsBasedOnControl(column);\n\n React.useEffect(() => {\n if (value === undefined || !validComparators.includes(value as Table3FilterComparator)) {\n handleChange?.(validComparators[0]);\n }\n }, [validComparators]);\n\n return (\n <Select2 {...attributes} className=\"!w-32 flex-shrink-0\" disabled={!column} onChange={handleChange} value={value}>\n {validComparators.map(comparator => (\n <Select2.Option key={comparator} value={comparator}>\n {getComparatorText(comparator, texts, column)}\n </Select2.Option>\n ))}\n </Select2>\n );\n}\n\nfunction guessComparatorsBasedOnControl<TType = unknown>(column?: RTColumn<TType, unknown>): Table3FilterComparator[] {\n const columnMeta = (column?.columnDef.meta ?? {}) as ColumnMeta<TType, unknown>;\n\n if (Array.isArray(columnMeta.filters)) {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n return columnMeta.filters;\n }\n\n if (typeof columnMeta.control === 'function') {\n const renderedControl = columnMeta.control({\n onBlur: () => undefined,\n onFocus: () => undefined,\n setValue: () => undefined,\n value: undefined,\n disabled: false,\n readOnly: false,\n ref: undefined as any,\n });\n\n if (React.isValidElement(renderedControl)) {\n const { props, type } = renderedControl as any;\n\n if (type.displayName === 'Select2') {\n if (props.multiple) {\n return [\n Table3FilterComparator.HasAnyOf,\n Table3FilterComparator.HasAllOf,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.HasNoneOf,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n }\n }\n\n if (columnMeta.dataType === 'number') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n if (columnMeta.control === 'datepicker' || columnMeta.dataType === 'datetime') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n Table3FilterComparator.IsLessThanOrEqualTo,\n Table3FilterComparator.IsGreaterThanOrEqualTo,\n ];\n }\n\n if (columnMeta.control === 'switch') {\n return [Table3FilterComparator.IsEqualTo];\n }\n\n return [\n Table3FilterComparator.Contains,\n Table3FilterComparator.DoesNotContain,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n}\n\nfunction getComparatorText<TType = unknown>(\n comparator: Table3FilterComparator,\n texts: LocalizationTexts,\n column?: RTColumn<TType, unknown>\n) {\n const isDate = column?.columnDef?.meta?.control === 'datepicker';\n\n switch (comparator) {\n case Table3FilterComparator.Contains:\n return texts.table3.filters.comparators.contains;\n\n case Table3FilterComparator.DoesNotContain:\n return texts.table3.filters.comparators.doesNotContain;\n\n case Table3FilterComparator.IsEqualTo:\n return texts.table3.filters.comparators.isEqualTo;\n\n case Table3FilterComparator.IsNotEqualTo:\n return texts.table3.filters.comparators.isNotEqualTo;\n\n case Table3FilterComparator.IsGreaterThan:\n return isDate ? texts.table3.filters.comparators.isAfter : texts.table3.filters.comparators.isGreaterThan;\n\n case Table3FilterComparator.IsLessThan:\n return isDate ? texts.table3.filters.comparators.isBefore : texts.table3.filters.comparators.isLessThan;\n\n case Table3FilterComparator.IsBetween:\n return texts.table3.filters.comparators.isBetween;\n\n case Table3FilterComparator.IsEmpty:\n return texts.table3.filters.comparators.isEmpty;\n\n case Table3FilterComparator.IsNotEmpty:\n return texts.table3.filters.comparators.isNotEmpty;\n\n case Table3FilterComparator.IsLessThanOrEqualTo:\n return isDate ? texts.table3.filters.comparators.isOnOrBefore : texts.table3.filters.comparators.isLessThanOrEqualTo;\n\n case Table3FilterComparator.IsGreaterThanOrEqualTo:\n return isDate\n ? texts.table3.filters.comparators.isOnOrAfter\n : texts.table3.filters.comparators.isGreaterThanOrEqualTo;\n\n case Table3FilterComparator.HasAnyOf:\n return texts.table3.filters.comparators.hasAnyOf;\n\n case Table3FilterComparator.HasAllOf:\n return texts.table3.filters.comparators.hasAllOf;\n\n case Table3FilterComparator.HasNoneOf:\n return texts.table3.filters.comparators.hasNoneOf;\n\n default:\n return '';\n }\n}\n"],"names":["FilterComparator","props","column","onChange","handleChange","value","attributes","texts","useLocalization","validComparators","guessComparatorsBasedOnControl","React","useEffect","undefined","includes","Select2","className","disabled","map","comparator","Option","key","getComparatorText","columnMeta","_column$columnDef$met","columnDef","meta","Array","isArray","filters","control","renderedControl","onBlur","onFocus","setValue","readOnly","ref","isValidElement","type","displayName","multiple","Table3FilterComparator","HasAnyOf","HasAllOf","IsEqualTo","HasNoneOf","IsEmpty","IsNotEmpty","IsNotEqualTo","dataType","IsGreaterThan","IsLessThan","IsBetween","IsLessThanOrEqualTo","IsGreaterThanOrEqualTo","Contains","DoesNotContain","isDate","_column$columnDef","_column$columnDef$met2","table3","comparators","contains","doesNotContain","isEqualTo","isNotEqualTo","isAfter","isGreaterThan","isBefore","isLessThan","isBetween","isEmpty","isNotEmpty","isOnOrBefore","isLessThanOrEqualTo","isOnOrAfter","isGreaterThanOrEqualTo","hasAnyOf","hasAllOf","hasNoneOf"],"mappings":";;;;;SAUgBA,gBAAgBA,CAAkBC,KAAmC;EACjF,MAAM;IAAEC,MAAM;IAAEC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KrC,sBAAsB,CAACI,SAAS;MACjC,OAAOtC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACkB,SAAS;IAErD;MACI,OAAO,EAAE;;AAErB;;;;"}
|
1
|
+
{"version":3,"file":"FilterComparator.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn, ColumnMeta } from '@tanstack/react-table';\nimport { Select2, Select2Props } from '../../../../../../Select2/Select2';\nimport { Table3FilterComparator } from '../../../../../types';\nimport { LocalizationTexts, useLocalization } from '../../../../../../Provider/Localization';\n\nexport type FilterComparatorProps<TType = unknown> = Omit<Select2Props, 'children'> & {\n column?: RTColumn<TType, unknown>;\n};\n\nexport function FilterComparator<TType = unknown>(props: FilterComparatorProps<TType>) {\n const { column, onChange: handleChange, value, ...attributes } = props;\n const { texts } = useLocalization();\n\n const validComparators = guessComparatorsBasedOnControl(column);\n\n React.useEffect(() => {\n if (value === undefined || !validComparators.includes(value as Table3FilterComparator)) {\n handleChange?.(validComparators[0]);\n }\n }, [validComparators]);\n\n return (\n <Select2\n {...attributes}\n className=\"focus:yt-focus !w-32 flex-shrink-0\"\n disabled={!column}\n onChange={handleChange}\n value={value}>\n {validComparators.map(comparator => (\n <Select2.Option key={comparator} value={comparator}>\n {getComparatorText(comparator, texts, column)}\n </Select2.Option>\n ))}\n </Select2>\n );\n}\n\nfunction guessComparatorsBasedOnControl<TType = unknown>(column?: RTColumn<TType, unknown>): Table3FilterComparator[] {\n const columnMeta = (column?.columnDef.meta ?? {}) as ColumnMeta<TType, unknown>;\n\n if (Array.isArray(columnMeta.filters)) {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n return columnMeta.filters;\n }\n\n if (typeof columnMeta.control === 'function') {\n const renderedControl = columnMeta.control({\n onBlur: () => undefined,\n onFocus: () => undefined,\n setValue: () => undefined,\n value: undefined,\n disabled: false,\n readOnly: false,\n ref: undefined as any,\n });\n\n if (React.isValidElement(renderedControl)) {\n const { props, type } = renderedControl as any;\n\n if (type.displayName === 'Select2') {\n if (props.multiple) {\n return [\n Table3FilterComparator.HasAnyOf,\n Table3FilterComparator.HasAllOf,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.HasNoneOf,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n }\n }\n\n if (columnMeta.dataType === 'number') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n if (columnMeta.control === 'datepicker' || columnMeta.dataType === 'datetime') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n Table3FilterComparator.IsLessThanOrEqualTo,\n Table3FilterComparator.IsGreaterThanOrEqualTo,\n ];\n }\n\n if (columnMeta.control === 'switch') {\n return [Table3FilterComparator.IsEqualTo];\n }\n\n return [\n Table3FilterComparator.Contains,\n Table3FilterComparator.DoesNotContain,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n}\n\nfunction getComparatorText<TType = unknown>(\n comparator: Table3FilterComparator,\n texts: LocalizationTexts,\n column?: RTColumn<TType, unknown>\n) {\n const isDate = column?.columnDef?.meta?.control === 'datepicker';\n\n switch (comparator) {\n case Table3FilterComparator.Contains:\n return texts.table3.filters.comparators.contains;\n\n case Table3FilterComparator.DoesNotContain:\n return texts.table3.filters.comparators.doesNotContain;\n\n case Table3FilterComparator.IsEqualTo:\n return texts.table3.filters.comparators.isEqualTo;\n\n case Table3FilterComparator.IsNotEqualTo:\n return texts.table3.filters.comparators.isNotEqualTo;\n\n case Table3FilterComparator.IsGreaterThan:\n return isDate ? texts.table3.filters.comparators.isAfter : texts.table3.filters.comparators.isGreaterThan;\n\n case Table3FilterComparator.IsLessThan:\n return isDate ? texts.table3.filters.comparators.isBefore : texts.table3.filters.comparators.isLessThan;\n\n case Table3FilterComparator.IsBetween:\n return texts.table3.filters.comparators.isBetween;\n\n case Table3FilterComparator.IsEmpty:\n return texts.table3.filters.comparators.isEmpty;\n\n case Table3FilterComparator.IsNotEmpty:\n return texts.table3.filters.comparators.isNotEmpty;\n\n case Table3FilterComparator.IsLessThanOrEqualTo:\n return isDate ? texts.table3.filters.comparators.isOnOrBefore : texts.table3.filters.comparators.isLessThanOrEqualTo;\n\n case Table3FilterComparator.IsGreaterThanOrEqualTo:\n return isDate\n ? texts.table3.filters.comparators.isOnOrAfter\n : texts.table3.filters.comparators.isGreaterThanOrEqualTo;\n\n case Table3FilterComparator.HasAnyOf:\n return texts.table3.filters.comparators.hasAnyOf;\n\n case Table3FilterComparator.HasAllOf:\n return texts.table3.filters.comparators.hasAllOf;\n\n case Table3FilterComparator.HasNoneOf:\n return texts.table3.filters.comparators.hasNoneOf;\n\n default:\n return '';\n }\n}\n"],"names":["FilterComparator","props","column","onChange","handleChange","value","attributes","texts","useLocalization","validComparators","guessComparatorsBasedOnControl","React","useEffect","undefined","includes","Select2","className","disabled","map","comparator","Option","key","getComparatorText","columnMeta","_column$columnDef$met","columnDef","meta","Array","isArray","filters","control","renderedControl","onBlur","onFocus","setValue","readOnly","ref","isValidElement","type","displayName","multiple","Table3FilterComparator","HasAnyOf","HasAllOf","IsEqualTo","HasNoneOf","IsEmpty","IsNotEmpty","IsNotEqualTo","dataType","IsGreaterThan","IsLessThan","IsBetween","IsLessThanOrEqualTo","IsGreaterThanOrEqualTo","Contains","DoesNotContain","isDate","_column$columnDef","_column$columnDef$met2","table3","comparators","contains","doesNotContain","isEqualTo","isNotEqualTo","isAfter","isGreaterThan","isBefore","isLessThan","isBetween","isEmpty","isNotEmpty","isOnOrBefore","isLessThanOrEqualTo","isOnOrAfter","isGreaterThanOrEqualTo","hasAnyOf","hasAllOf","hasNoneOf"],"mappings":";;;;;SAUgBA,gBAAgBA,CAAkBC,KAAmC;EACjF,MAAM;IAAEC,MAAM;IAAEC,QAAQ,EAAEC,YAAY;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGL,KAAK;EACtE,MAAM;IAAEM;GAAO,GAAGC,eAAe,EAAE;EAEnC,MAAMC,gBAAgB,GAAGC,8BAA8B,CAACR,MAAM,CAAC;EAE/DS,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,KAAK,KAAKQ,SAAS,IAAI,CAACJ,gBAAgB,CAACK,QAAQ,CAACT,KAA+B,CAAC,EAAE;MACpFD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAGK,gBAAgB,CAAC,CAAC,CAAC,CAAC;;GAE1C,EAAE,CAACA,gBAAgB,CAAC,CAAC;EAEtB,oBACIE,6BAACI,OAAO,oBACAT,UAAU;IACdU,SAAS,EAAC,oCAAoC;IAC9CC,QAAQ,EAAE,CAACf,MAAM;IACjBC,QAAQ,EAAEC,YAAY;IACtBC,KAAK,EAAEA;MACNI,gBAAgB,CAACS,GAAG,CAACC,UAAU,mBAC5BR,6BAACI,OAAO,CAACK,MAAM;IAACC,GAAG,EAAEF,UAAU;IAAEd,KAAK,EAAEc;KACnCG,iBAAiB,CAACH,UAAU,EAAEZ,KAAK,EAAEL,MAAM,CAAC,CAChC,CACpB,CAAC,CACI;AAElB;AAEA,SAASQ,8BAA8BA,CAAkBR,MAAiC;;EACtF,MAAMqB,UAAU,IAAAC,qBAAA,GAAItB,MAA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lD,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACc,WAAW,GAC5CpE,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACe,sBAAsB;IAEjE,KAAKnC,sBAAsB,CAACC,QAAQ;MAChC,OAAOnC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACgB,QAAQ;IAEpD,KAAKpC,sBAAsB,CAACE,QAAQ;MAChC,OAAOpC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACiB,QAAQ;IAEpD,KAAKrC,sBAAsB,CAACI,SAAS;MACjC,OAAOtC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACkB,SAAS;IAErD;MACI,OAAO,EAAE;;AAErB;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js
CHANGED
@@ -23,6 +23,7 @@ function PrintButton(props) {
|
|
23
23
|
const buttonRef = React__default.useRef(null);
|
24
24
|
const tableMeta = table.options.meta;
|
25
25
|
const state = table.getState();
|
26
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
26
27
|
const {
|
27
28
|
isWarningVisibleForLargeDatasets
|
28
29
|
} = tableMeta.printing;
|
@@ -201,6 +202,7 @@ function PrintButton(props) {
|
|
201
202
|
onAccept: handleWarningDialogAccept,
|
202
203
|
onClose: handleWarningDialogClose,
|
203
204
|
onCancel: handleWarningDialogCancel,
|
205
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
204
206
|
onVisibilityChange: tableMeta.printing.setIsWarningVisibleForLargeDatasets
|
205
207
|
}));
|
206
208
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PrintButton.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { ToastReference, useToast } from '../../../../Toast/Toaster';\nimport { PrintIFrame } from './PrintIFrame';\nimport { Table3ColumnProps, Table3Props } from '../../../types';\nimport { WarningDialog } from './WarningDialog';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\n\nconst SAFE_PRINT_CELL_COUNT = 10000;\n\nexport type PrintButtonProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n table: RTable<TType>;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintButton<TType = unknown>(props: PrintButtonProps<TType>) {\n const { table, tableProps } = props;\n const { texts } = useLocalization();\n const toast = useToast();\n\n const [isCurrentlyPrinting, setIsCurrentlyPrinting] = React.useState(false);\n const [showWarningDialog, setShowWarningDialog] = React.useState(false);\n const loadingToastRef = React.useRef<ToastReference | null>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n const { isWarningVisibleForLargeDatasets } = tableMeta.printing;\n\n // When changing printTableId, update packages/taco/src/components/Table3/Table3.tsx file and other usages where\n // printTableId is used to figure out whether the table is a print table or not.\n const printTableId = `${tableProps.id}_print`;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const excludeUnmatchedResults = tableMeta.search.excludeUnmatchedResults;\n\n const defaultSettings = React.useMemo(\n () => ({\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n columnFreezingIndex: tableMeta.columnFreezing.frozenColumnIndex,\n columnOrder: state.columnOrder,\n columnSizing: state.columnSizing,\n columnVisibility: state.columnVisibility,\n excludeUnmatchedRecordsInSearch: excludeUnmatchedResults,\n fontSize: tableMeta.fontSize.size,\n rowHeight: tableMeta.rowHeight.height,\n sorting: state.sorting,\n // we don't save these, but we must pass them to print\n columnFilters: state.columnFilters,\n globalFilter: state.globalFilter,\n }),\n [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n excludeUnmatchedResults,\n tableMeta.fontSize.size,\n tableMeta.rowHeight.height,\n state.sorting,\n state.columnFilters,\n state.globalFilter,\n ]\n );\n\n const iframeTableChildren = React.useMemo(\n () =>\n (React.Children.toArray(tableProps.children) as React.ReactElement<Table3ColumnProps<TType>>[]).filter(child => {\n const enableColumnInPrinting = child.props?.enablePrinting;\n\n // For table children, only include columns doesn't have 'false' value for enablePrinting prop.\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && enableColumnInPrinting === false) {\n return false;\n }\n\n return true;\n }),\n [tableProps.children]\n );\n\n const iframeTableProps = {\n ...tableProps,\n children: iframeTableChildren,\n defaultSettings,\n id: printTableId,\n };\n\n const handleLoadingError = (error: any) => {\n const errorMessage = `${texts.table3.print.error}: ${error}`;\n\n console.error(errorMessage);\n loadingToastRef.current?.error(errorMessage);\n };\n\n const restoreTableDataWithoutSearch = async () => {\n try {\n await tableMeta.server.loadAll?.(table.getState().sorting, table.getState().columnFilters, undefined);\n } catch (error) {\n handleLoadingError(error);\n return;\n }\n };\n\n const handleAfterPrint = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n setIsCurrentlyPrinting(false);\n loadingToastRef.current?.close();\n };\n\n const handleBeforePrint = () => {\n loadingToastRef.current?.close();\n };\n\n const handlePrint = async () => {\n loadingToastRef.current = toast.loading(texts.table3.print.loading as any);\n\n const getCellCount = (data: TType[]) => (data.length ? data.length * Object.keys(data[0]).length : 0);\n let hasNonSafeCellCount = false;\n\n // if loadAll is not defined, just print with what we've got\n // don't compare length to data.length because the api might be choosing not to return all for performance\n if (!tableMeta.server.loadAll) {\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } else {\n try {\n await tableMeta.server.loadAll(\n table.getState().sorting,\n table.getState().columnFilters,\n // We need to pass search query to the server when printing, to be able to render correct data set in iFrame,\n // But in \"display\" table, search is performed only on client side, so we'll need to request data again without search query,\n // when printing will be finished.\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n excludeUnmatchedResults ? tableMeta.search.query : undefined\n );\n\n // After the loadAll call above, the data changes. Hence, it becomes essential to acquire the data after\n // this call rather than before it.\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } catch (error) {\n handleLoadingError(error);\n\n // in case of error, we return early\n return;\n }\n }\n\n if (hasNonSafeCellCount && isWarningVisibleForLargeDatasets) {\n setShowWarningDialog(true);\n } else {\n // only set printing (mount the iframe) when the data has loaded, it prevents repaint performance slow downs\n setIsCurrentlyPrinting(true);\n }\n };\n\n const shortcut = { key: 'p', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table3.print.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n const handleWarningDialogAccept = () => {\n setIsCurrentlyPrinting(true);\n };\n\n const handleWarningDialogCancel = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n };\n\n const handleWarningDialogClose = () => {\n loadingToastRef.current?.close();\n setShowWarningDialog(false);\n };\n\n return (\n <>\n <IconButton\n disabled={isCurrentlyPrinting}\n icon=\"print\"\n onClick={handlePrint}\n aria-label={texts.table3.print.tooltip}\n tooltip={tooltip}\n ref={buttonRef}\n shortcut={shortcut}\n />\n {isCurrentlyPrinting && iframeTableProps.data !== null && (\n <PrintIFrame\n onAfterPrint={handleAfterPrint}\n onBeforePrint={handleBeforePrint}\n tableProps={iframeTableProps as Table3Props<TType>}\n />\n )}\n <WarningDialog\n open={showWarningDialog}\n onAccept={handleWarningDialogAccept}\n onClose={handleWarningDialogClose}\n onCancel={handleWarningDialogCancel}\n onVisibilityChange={tableMeta.printing.setIsWarningVisibleForLargeDatasets}\n />\n </>\n );\n}\n"],"names":["SAFE_PRINT_CELL_COUNT","PrintButton","props","table","tableProps","texts","useLocalization","toast","useToast","isCurrentlyPrinting","setIsCurrentlyPrinting","React","useState","showWarningDialog","setShowWarningDialog","loadingToastRef","useRef","buttonRef","tableMeta","options","meta","state","getState","isWarningVisibleForLargeDatasets","printing","printTableId","id","excludeUnmatchedResults","search","defaultSettings","useMemo","columnFreezingIndex","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","size","rowHeight","height","sorting","columnFilters","globalFilter","iframeTableChildren","Children","toArray","children","filter","child","enableColumnInPrinting","_child$props","enablePrinting","isValidElement","iframeTableProps","handleLoadingError","error","errorMessage","table3","print","console","_loadingToastRef$curr","current","restoreTableDataWithoutSearch","_tableMeta$server$loa","_tableMeta$server","Promise","resolve","server","loadAll","call","undefined","then","_temp","e","reject","handleAfterPrint","_loadingToastRef$curr2","close","_temp2","_temp3","handleBeforePrint","_loadingToastRef$curr3","handlePrint","hasNonSafeCellCount","loading","getCellCount","data","length","Object","keys","_temp5","cellCount","_temp4","_catch","query","_exit","_temp6","shortcut","key","shift","tooltip","Shortcut","className","handleWarningDialogAccept","handleWarningDialogCancel","_temp7","handleWarningDialogClose","_loadingToastRef$curr4","IconButton","disabled","icon","onClick","ref","PrintIFrame","onAfterPrint","onBeforePrint","WarningDialog","open","onAccept","onClose","onCancel","onVisibilityChange","setIsWarningVisibleForLargeDatasets"],"mappings":";;;;;;;;;AAWA,MAAMA,qBAAqB,GAAG,KAAK;SAOnBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,KAAK;IAAEC;GAAY,GAAGF,KAAK;EACnC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,KAAK,GAAGC,QAAQ,EAAE;EAExB,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,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BwC,aAAa,EAAEnC,iBAAiB;IAChC9E,UAAU,EAAEmD;IACd,CACL,eACD5C,6BAAC2G,aAAa;IACVC,IAAI,EAAE1G,iBAAiB;IACvB2G,QAAQ,EAAEf,yBAAyB;IACnCgB,OAAO,EAAEb,wBAAwB;IACjCc,QAAQ,EAAEhB,yBAAyB;IACnCiB,kBAAkB,EAAEzG,SAAS,CAACM,QAAQ,CAACoG;IACzC,CACH;AAEX;;;;"}
|
1
|
+
{"version":3,"file":"PrintButton.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { ToastReference, useToast } from '../../../../Toast/Toaster';\nimport { PrintIFrame } from './PrintIFrame';\nimport { Table3ColumnProps, Table3Props } from '../../../types';\nimport { WarningDialog } from './WarningDialog';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\n\nconst SAFE_PRINT_CELL_COUNT = 10000;\n\nexport type PrintButtonProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n table: RTable<TType>;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintButton<TType = unknown>(props: PrintButtonProps<TType>) {\n const { table, tableProps } = props;\n const { texts } = useLocalization();\n const toast = useToast();\n\n const [isCurrentlyPrinting, setIsCurrentlyPrinting] = React.useState(false);\n const [showWarningDialog, setShowWarningDialog] = React.useState(false);\n const loadingToastRef = React.useRef<ToastReference | null>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const { isWarningVisibleForLargeDatasets } = tableMeta.printing;\n\n // When changing printTableId, update packages/taco/src/components/Table3/Table3.tsx file and other usages where\n // printTableId is used to figure out whether the table is a print table or not.\n const printTableId = `${tableProps.id}_print`;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const excludeUnmatchedResults = tableMeta.search.excludeUnmatchedResults;\n\n const defaultSettings = React.useMemo(\n () => ({\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n columnFreezingIndex: tableMeta.columnFreezing.frozenColumnIndex,\n columnOrder: state.columnOrder,\n columnSizing: state.columnSizing,\n columnVisibility: state.columnVisibility,\n excludeUnmatchedRecordsInSearch: excludeUnmatchedResults,\n fontSize: tableMeta.fontSize.size,\n rowHeight: tableMeta.rowHeight.height,\n sorting: state.sorting,\n // we don't save these, but we must pass them to print\n columnFilters: state.columnFilters,\n globalFilter: state.globalFilter,\n }),\n [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n excludeUnmatchedResults,\n tableMeta.fontSize.size,\n tableMeta.rowHeight.height,\n state.sorting,\n state.columnFilters,\n state.globalFilter,\n ]\n );\n\n const iframeTableChildren = React.useMemo(\n () =>\n (React.Children.toArray(tableProps.children) as React.ReactElement<Table3ColumnProps<TType>>[]).filter(child => {\n const enableColumnInPrinting = child.props?.enablePrinting;\n\n // For table children, only include columns doesn't have 'false' value for enablePrinting prop.\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && enableColumnInPrinting === false) {\n return false;\n }\n\n return true;\n }),\n [tableProps.children]\n );\n\n const iframeTableProps = {\n ...tableProps,\n children: iframeTableChildren,\n defaultSettings,\n id: printTableId,\n };\n\n const handleLoadingError = (error: any) => {\n const errorMessage = `${texts.table3.print.error}: ${error}`;\n\n console.error(errorMessage);\n loadingToastRef.current?.error(errorMessage);\n };\n\n const restoreTableDataWithoutSearch = async () => {\n try {\n await tableMeta.server.loadAll?.(table.getState().sorting, table.getState().columnFilters, undefined);\n } catch (error) {\n handleLoadingError(error);\n return;\n }\n };\n\n const handleAfterPrint = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n setIsCurrentlyPrinting(false);\n loadingToastRef.current?.close();\n };\n\n const handleBeforePrint = () => {\n loadingToastRef.current?.close();\n };\n\n const handlePrint = async () => {\n loadingToastRef.current = toast.loading(texts.table3.print.loading as any);\n\n const getCellCount = (data: TType[]) => (data.length ? data.length * Object.keys(data[0]).length : 0);\n let hasNonSafeCellCount = false;\n\n // if loadAll is not defined, just print with what we've got\n // don't compare length to data.length because the api might be choosing not to return all for performance\n if (!tableMeta.server.loadAll) {\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } else {\n try {\n await tableMeta.server.loadAll(\n table.getState().sorting,\n table.getState().columnFilters,\n // We need to pass search query to the server when printing, to be able to render correct data set in iFrame,\n // But in \"display\" table, search is performed only on client side, so we'll need to request data again without search query,\n // when printing will be finished.\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n excludeUnmatchedResults ? tableMeta.search.query : undefined\n );\n\n // After the loadAll call above, the data changes. Hence, it becomes essential to acquire the data after\n // this call rather than before it.\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } catch (error) {\n handleLoadingError(error);\n\n // in case of error, we return early\n return;\n }\n }\n\n if (hasNonSafeCellCount && isWarningVisibleForLargeDatasets) {\n setShowWarningDialog(true);\n } else {\n // only set printing (mount the iframe) when the data has loaded, it prevents repaint performance slow downs\n setIsCurrentlyPrinting(true);\n }\n };\n\n const shortcut = { key: 'p', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table3.print.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n const handleWarningDialogAccept = () => {\n setIsCurrentlyPrinting(true);\n };\n\n const handleWarningDialogCancel = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n };\n\n const handleWarningDialogClose = () => {\n loadingToastRef.current?.close();\n setShowWarningDialog(false);\n };\n\n return (\n <>\n <IconButton\n disabled={isCurrentlyPrinting}\n icon=\"print\"\n onClick={handlePrint}\n aria-label={texts.table3.print.tooltip}\n tooltip={tooltip}\n ref={buttonRef}\n shortcut={shortcut}\n />\n {isCurrentlyPrinting && iframeTableProps.data !== null && (\n <PrintIFrame\n onAfterPrint={handleAfterPrint}\n onBeforePrint={handleBeforePrint}\n tableProps={iframeTableProps as Table3Props<TType>}\n />\n )}\n <WarningDialog\n open={showWarningDialog}\n onAccept={handleWarningDialogAccept}\n onClose={handleWarningDialogClose}\n onCancel={handleWarningDialogCancel}\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n onVisibilityChange={tableMeta.printing.setIsWarningVisibleForLargeDatasets}\n />\n </>\n );\n}\n"],"names":["SAFE_PRINT_CELL_COUNT","PrintButton","props","table","tableProps","texts","useLocalization","toast","useToast","isCurrentlyPrinting","setIsCurrentlyPrinting","React","useState","showWarningDialog","setShowWarningDialog","loadingToastRef","useRef","buttonRef","tableMeta","options","meta","state","getState","isWarningVisibleForLargeDatasets","printing","printTableId","id","excludeUnmatchedResults","search","defaultSettings","useMemo","columnFreezingIndex","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","size","rowHeight","height","sorting","columnFilters","globalFilter","iframeTableChildren","Children","toArray","children","filter","child","enableColumnInPrinting","_child$props","enablePrinting","isValidElement","iframeTableProps","handleLoadingError","error","errorMessage","table3","print","console","_loadingToastRef$curr","current","restoreTableDataWithoutSearch","_tableMeta$server$loa","_tableMeta$server","Promise","resolve","server","loadAll","call","undefined","then","_temp","e","reject","handleAfterPrint","_loadingToastRef$curr2","close","_temp2","_temp3","handleBeforePrint","_loadingToastRef$curr3","handlePrint","hasNonSafeCellCount","loading","getCellCount","data","length","Object","keys","_temp5","cellCount","_temp4","_catch","query","_exit","_temp6","shortcut","key","shift","tooltip","Shortcut","className","handleWarningDialogAccept","handleWarningDialogCancel","_temp7","handleWarningDialogClose","_loadingToastRef$curr4","IconButton","disabled","icon","onClick","ref","PrintIFrame","onAfterPrint","onBeforePrint","WarningDialog","open","onAccept","onClose","onCancel","onVisibilityChange","setIsWarningVisibleForLargeDatasets"],"mappings":";;;;;;;;;AAWA,MAAMA,qBAAqB,GAAG,KAAK;SAOnBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,KAAK;IAAEC;GAAY,GAAGF,KAAK;EACnC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,KAAK,GAAGC,QAAQ,EAAE;EAExB,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAC3E,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACvE,MAAMG,eAAe,GAAGJ,cAAK,CAACK,MAAM,CAAwB,IAAI,CAAC;EACjE,MAAMC,SAAS,GAAGN,cAAK,CAACK,MAAM,CAAoB,IAAI,CAAC;EAEvD,MAAME,SAAS,GAAGf,KAAK,CAACgB,OAAO,CAACC,IAAwB;EACxD,MAAMC,KAAK,GAAGlB,KAAK,CAACmB,QAAQ,EAAE;;EAE9B,MAAM;IAAEC;GAAkC,GAAGL,SAAS,CAACM,QAAQ;;;EAI/D,MAAMC,YAAY,MAAMrB,UAAU,CAACsB,UAAU;;EAE7C,MAAMC,uBAAuB,GAAGT,SAAS,CAACU,MAAM,CAACD,uBAAuB;EAExE,MAAME,eAAe,GAAGlB,cAAK,CAACmB,OAAO,CACjC,OAAO;;IAEHC,mBAAmB,EAAEb,SAAS,CAACc,cAAc,CAACC,iBAAiB;IAC/DC,WAAW,EAAEb,KAAK,CAACa,WAAW;IAC9BC,YAAY,EAAEd,KAAK,CAACc,YAAY;IAChCC,gB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A;;IAC7B,CAAAC,sBAAA,GAAA9F,eAAe,CAACgD,OAAO,cAAA8C,sBAAA,uBAAvBA,sBAAA,CAAyB9B,KAAK,EAAE;IAChCjE,oBAAoB,CAAC,KAAK,CAAC;GAC9B;EAED,oBACIH,yEACIA,6BAACmG,UAAU;IACPC,QAAQ,EAAEtG,mBAAmB;IAC7BuG,IAAI,EAAC,OAAO;IACZC,OAAO,EAAE7B,WAAW;kBACR/E,KAAK,CAACsD,MAAM,CAACC,KAAK,CAAC0C,OAAO;IACtCA,OAAO,EAAEA,OAAO;IAChBY,GAAG,EAAEjG,SAAS;IACdkF,QAAQ,EAAEA;IACZ,EACD1F,mBAAmB,IAAI8C,gBAAgB,CAACiC,IAAI,KAAK,IAAI,mBAClD7E,6BAACwG,WAAW;IACRC,YAAY,EAAEvC,gBAAgB;IAC9BwC,aAAa,EAAEnC,iBAAiB;IAChC9E,UAAU,EAAEmD;IACd,CACL,eACD5C,6BAAC2G,aAAa;IACVC,IAAI,EAAE1G,iBAAiB;IACvB2G,QAAQ,EAAEf,yBAAyB;IACnCgB,OAAO,EAAEb,wBAAwB;IACjCc,QAAQ,EAAEhB,yBAAyB;;IAEnCiB,kBAAkB,EAAEzG,SAAS,CAACM,QAAQ,CAACoG;IACzC,CACH;AAEX;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js
CHANGED
@@ -18,12 +18,12 @@ import '../../../../Banner/Banner.js';
|
|
18
18
|
import '../../../../Button/Button.js';
|
19
19
|
import '../../../../Calendar/Calendar.js';
|
20
20
|
import '../../../../Card/Card.js';
|
21
|
+
import '../../../../Spinner/Spinner.js';
|
21
22
|
import '../../../../Checkbox/Checkbox.js';
|
22
23
|
import '../../../../../hooks/useBoundingClientRectListener.js';
|
23
24
|
import '../../../../Input/Input.js';
|
24
25
|
import '../../../../../utils/hooks/useListKeyboardNavigation.js';
|
25
26
|
import '../../../../../utils/hooks/useListScrollTo.js';
|
26
|
-
import '../../../../Spinner/Spinner.js';
|
27
27
|
import '../../../../Combobox/Combobox.js';
|
28
28
|
import '../../../../../utils/date.js';
|
29
29
|
import '../../../../Popover/Popover.js';
|
@@ -52,6 +52,7 @@ import '../../../../Progress/Progress.js';
|
|
52
52
|
import '../../../../Toast/Toaster.js';
|
53
53
|
import '../../../../Provider/Provider.js';
|
54
54
|
import '../../../../../types.js';
|
55
|
+
import '../../../../../primitives/Table/useTableDataLoader.js';
|
55
56
|
import '../../../../../hooks/useLazyEffect.js';
|
56
57
|
import '../../../../SearchInput/SearchInput.js';
|
57
58
|
import '../../../../SearchInput2/SearchInput2.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PrintIFrame.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintIFrame.tsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Table3 } from '../../../../..';\nimport { Table3Props } from '../../../types';\nimport { useParentStylesheets } from './hooks/useParentStylesheets';\n\nexport type PrintIFrameProps<TType = unknown> = {\n onAfterPrint?: () => void;\n onBeforePrint?: () => void;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintIFrame<TType = unknown>({ onAfterPrint, onBeforePrint, tableProps }: PrintIFrameProps<TType>) {\n const [contentRef, setContentRef] = React.useState<HTMLIFrameElement | null>(null);\n const [mountNode, setMountNode] = React.useState<HTMLElement | null>(null);\n\n const isFirefoxBrowser = React.useMemo(() => navigator.userAgent.toLowerCase().includes('firefox'), []);\n const isSafariBrowser = React.useMemo(\n () => navigator.userAgent.toLowerCase().includes('safari') && !navigator.userAgent.toLowerCase().includes('chrome'),\n []\n );\n\n const iframeWindow = contentRef?.contentWindow;\n\n const stylesReady = useParentStylesheets(iframeWindow);\n\n // Calls print method when table has loaded in the iframe.\n React.useEffect(() => {\n let intervalId: ReturnType<typeof setInterval>;\n let timeoutId: ReturnType<typeof setTimeout>;\n\n // Invoke the print functionality on the window once the table has finished rendering and all print styles are\n // added.\n if (mountNode && stylesReady) {\n intervalId = setInterval(async () => {\n const tableWrapper = mountNode;\n const table = tableWrapper.querySelector('[role=\"table\"]') as HTMLElement;\n const hasTableRendered = !!table;\n\n if (hasTableRendered && intervalId) {\n clearInterval(intervalId);\n\n // Calling the onBeforePrint method here as a fallback because certain browsers, like Safari,\n // do not call the beforeprint event.\n // Bug - Even though onBeforePrint is called before printing, the execution doesn't finish before\n // the print dialog shows up, which results into having a visible loading toast.\n onBeforePrint?.();\n\n // By adding height to the tableWrapper, we make sure the content below absolutely positioned table\n // doesn't hide\n if (isFirefoxBrowser) {\n const tableHeight = `${table.offsetHeight}px`;\n tableWrapper.style.height = tableHeight;\n }\n\n contentRef?.contentWindow?.print();\n\n // Calling the onAfterPrint method here as a fallback to do the cleanup, as certain browsers,\n // like Safari, do not trigger the beforeprint or afterprint events when a confirmation dialog\n // asking if the user wants to print the document, is cancelled.\n\n // Added a setTimeout to prevent calling onAfterPrint immediately after the print function\n // to ensure that the print dialog doesn't close abruptly. Although this behavior is uncommon,\n // there are cases where the print function may not run synchronously, causing onAfterPrint to be\n // invoked right after it.\n timeoutId = setTimeout(() => {\n onAfterPrint?.();\n }, 0);\n }\n }, 1000);\n }\n\n return () => {\n clearInterval(intervalId);\n clearTimeout(timeoutId);\n };\n }, [mountNode, stylesReady]);\n\n React.useEffect(() => {\n if (!contentRef || !iframeWindow || !stylesReady) {\n return;\n }\n\n // get the closest parent/container of the table, and the table itself\n const parentElement = contentRef?.closest('[role=dialog], [data-taco=drawer], main') ?? iframeWindow.parent.document.body;\n\n const iframeDocument = iframeWindow.document;\n iframeDocument.body.innerHTML = parentElement?.innerHTML ?? '';\n\n const tableElement = iframeDocument.querySelector('[role=\"table\"]');\n const tableColumnFreezingStyles = iframeDocument.querySelector('[data-taco=\"table3-column-freezing-styles\"]');\n const tableWrapper = iframeDocument.createElement('div');\n\n tableWrapper.setAttribute('data-role', 'table-wrapper');\n // Adding h-fit class makes sure that table is rendered with the whole content.\n tableWrapper.classList.add('h-fit');\n tableWrapper.classList.add('[&>[role=\"table\"]]:!h-fit');\n\n if (isFirefoxBrowser) {\n // Fix for firefox bug which adds page-long whitespace between page's top content and table.\n tableWrapper.classList.add('[&>[role=\"table\"]]:!absolute');\n }\n\n // Makes sure table takes the full screen width.\n if (isSafariBrowser) {\n // Safari browser doesn't apply correct width to the columns when w-screen is used.\n tableWrapper.classList.add('w-full');\n } else {\n tableWrapper.classList.add('w-screen');\n }\n\n if (tableElement) {\n tableElement.parentNode?.insertBefore(tableWrapper, tableElement);\n tableElement.remove();\n } else {\n iframeDocument.body.append(tableWrapper);\n }\n\n // Remove the already existing column freezing styles.\n if (tableColumnFreezingStyles) {\n tableColumnFreezingStyles.remove();\n }\n\n let currentNode = tableWrapper.parentNode as HTMLElement | null;\n\n while (currentNode !== null && currentNode !== iframeDocument.body) {\n // Add the 'h-fit' class to the 'table-wrapper' element's parent chain.\n // This ensures that the table is not cropped and fits within its container.\n currentNode?.classList.add('!h-fit');\n currentNode = currentNode.parentNode as HTMLElement | null;\n }\n\n setMountNode(tableWrapper);\n }, [iframeWindow, stylesReady]);\n\n const printTableProps: Table3Props<TType> = {\n ...tableProps,\n actionsForRow: undefined,\n // Not the best way to remove the active/current row styles, but a temporary solution for now\n defaultCurrentRowIndex: -1,\n defaultSettings: {\n ...tableProps?.defaultSettings,\n rowHeight: 'short',\n },\n enableColumnFreezing: false,\n enableRowHeight: true,\n enableRowSelection: false,\n enableEditing: false,\n enablePrinting: false,\n enableRowDrag: false,\n enableRowDrop: false,\n enableRowSelectionSingle: false,\n preset: undefined,\n // The presence of the onChangeSettings prop ensures that settings won't be stored in local storage.\n onChangeSettings: () => undefined,\n };\n\n // -top-60 -left-60 styles make sure that iframe is added outside of the viewport\n return (\n <iframe\n className=\"fixed -left-[6000px] -top-[6000px] -z-50 !h-0 !w-0\"\n ref={setContentRef}\n // Temporary fix to support printing in firefox: Find another solution while upgrading React\n src=\"javascript:void(0);\">\n {mountNode && stylesReady ? ReactDOM.createPortal(<Table3 {...printTableProps} />, mountNode) : null}\n </iframe>\n );\n}\n"],"names":["PrintIFrame","onAfterPrint","onBeforePrint","tableProps","contentRef","setContentRef","React","useState","mountNode","setMountNode","isFirefoxBrowser","useMemo","navigator","userAgent","toLowerCase","includes","isSafariBrowser","iframeWindow","contentWindow","stylesReady","useParentStylesheets","useEffect","intervalId","timeoutId","setInterval","tableWrapper","table","querySelector","hasTableRendered","_contentRef$contentWi","clearInterval","tableHeight","offsetHeight","style","height","print","setTimeout","Promise","resolve","e","reject","clearTimeout","parentElement","_contentRef$closest","closest","parent","document","body","iframeDocument","innerHTML","_parentElement$innerH","tableElement","tableColumnFreezingStyles","createElement","setAttribute","classList","add","_tableElement$parentN","parentNode","insertBefore","remove","append","currentNode","_currentNode","printTableProps","actionsForRow","undefined","defaultCurrentRowIndex","defaultSettings","rowHeight","enableColumnFreezing","enableRowHeight","enableRowSelection","enableEditing","enablePrinting","enableRowDrag","enableRowDrop","enableRowSelectionSingle","preset","onChangeSettings","className","ref","src","ReactDOM","createPortal","Table3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAagBA,WAAWA,CAAkB;EAAEC,YAAY;EAAEC,aAAa;EAAEC;CAAqC;EAC7G,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAA2B,IAAI,CAAC;EAClF,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAqB,IAAI,CAAC;EAE1E,MAAMG,gBAAgB,GAAGJ,cAAK,CAACK,OAAO,CAAC,MAAMC,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;EACvG,MAAMC,eAAe,GAAGV,cAAK,CAACK,OAAO,CACjC,MAAMC,SAAS,CAACC,SAAS,CAACC,WA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GAC3B;;EAGD,oBACI5D;IACI0E,SAAS,EAAC,oDAAoD;IAC9DC,GAAG,EAAE5E,aAAa;;IAElB6E,GAAG,EAAC;KACH1E,SAAS,IAAIW,WAAW,gBAAGgE,QAAQ,CAACC,YAAY,eAAC9E,6BAAC+E,MAAM,oBAAKrB,eAAe,EAAI,EAAExD,SAAS,CAAC,GAAG,IAAI,CAC/F;AAEjB;;;;"}
|
1
|
+
{"version":3,"file":"PrintIFrame.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintIFrame.tsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Table3 } from '../../../../..';\nimport { Table3Props } from '../../../types';\nimport { useParentStylesheets } from './hooks/useParentStylesheets';\n\nexport type PrintIFrameProps<TType = unknown> = {\n onAfterPrint?: () => void;\n onBeforePrint?: () => void;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintIFrame<TType = unknown>({ onAfterPrint, onBeforePrint, tableProps }: PrintIFrameProps<TType>) {\n const [contentRef, setContentRef] = React.useState<HTMLIFrameElement | null>(null);\n const [mountNode, setMountNode] = React.useState<HTMLElement | null>(null);\n\n const isFirefoxBrowser = React.useMemo(() => navigator.userAgent.toLowerCase().includes('firefox'), []);\n const isSafariBrowser = React.useMemo(\n () => navigator.userAgent.toLowerCase().includes('safari') && !navigator.userAgent.toLowerCase().includes('chrome'),\n []\n );\n\n const iframeWindow = contentRef?.contentWindow;\n\n const stylesReady = useParentStylesheets(iframeWindow);\n\n // Calls print method when table has loaded in the iframe.\n React.useEffect(() => {\n let intervalId: ReturnType<typeof setInterval>;\n let timeoutId: ReturnType<typeof setTimeout>;\n\n // Invoke the print functionality on the window once the table has finished rendering and all print styles are\n // added.\n if (mountNode && stylesReady) {\n intervalId = setInterval(async () => {\n const tableWrapper = mountNode;\n const table = tableWrapper.querySelector('[role=\"table\"]') as HTMLElement;\n const hasTableRendered = !!table;\n\n if (hasTableRendered && intervalId) {\n clearInterval(intervalId);\n\n // Calling the onBeforePrint method here as a fallback because certain browsers, like Safari,\n // do not call the beforeprint event.\n // Bug - Even though onBeforePrint is called before printing, the execution doesn't finish before\n // the print dialog shows up, which results into having a visible loading toast.\n onBeforePrint?.();\n\n // By adding height to the tableWrapper, we make sure the content below absolutely positioned table\n // doesn't hide\n if (isFirefoxBrowser) {\n const tableHeight = `${table.offsetHeight}px`;\n tableWrapper.style.height = tableHeight;\n }\n\n contentRef?.contentWindow?.print();\n\n // Calling the onAfterPrint method here as a fallback to do the cleanup, as certain browsers,\n // like Safari, do not trigger the beforeprint or afterprint events when a confirmation dialog\n // asking if the user wants to print the document, is cancelled.\n\n // Added a setTimeout to prevent calling onAfterPrint immediately after the print function\n // to ensure that the print dialog doesn't close abruptly. Although this behavior is uncommon,\n // there are cases where the print function may not run synchronously, causing onAfterPrint to be\n // invoked right after it.\n timeoutId = setTimeout(() => {\n onAfterPrint?.();\n }, 0);\n }\n }, 1000);\n }\n\n return () => {\n clearInterval(intervalId);\n clearTimeout(timeoutId);\n };\n }, [mountNode, stylesReady]);\n\n React.useEffect(() => {\n if (!contentRef || !iframeWindow || !stylesReady) {\n return;\n }\n\n // get the closest parent/container of the table, and the table itself\n const parentElement = contentRef?.closest('[role=dialog], [data-taco=drawer], main') ?? iframeWindow.parent.document.body;\n\n const iframeDocument = iframeWindow.document;\n iframeDocument.body.innerHTML = parentElement?.innerHTML ?? '';\n\n const tableElement = iframeDocument.querySelector('[role=\"table\"]');\n const tableColumnFreezingStyles = iframeDocument.querySelector('[data-taco=\"table3-column-freezing-styles\"]');\n const tableWrapper = iframeDocument.createElement('div');\n\n tableWrapper.setAttribute('data-role', 'table-wrapper');\n // Adding h-fit class makes sure that table is rendered with the whole content.\n tableWrapper.classList.add('h-fit');\n tableWrapper.classList.add('[&>[role=\"table\"]]:!h-fit');\n\n if (isFirefoxBrowser) {\n // Fix for firefox bug which adds page-long whitespace between page's top content and table.\n tableWrapper.classList.add('[&>[role=\"table\"]]:!absolute');\n }\n\n // Makes sure table takes the full screen width.\n if (isSafariBrowser) {\n // Safari browser doesn't apply correct width to the columns when w-screen is used.\n tableWrapper.classList.add('w-full');\n } else {\n tableWrapper.classList.add('w-screen');\n }\n\n if (tableElement) {\n tableElement.parentNode?.insertBefore(tableWrapper, tableElement);\n tableElement.remove();\n } else {\n iframeDocument.body.append(tableWrapper);\n }\n\n // Remove the already existing column freezing styles.\n if (tableColumnFreezingStyles) {\n tableColumnFreezingStyles.remove();\n }\n\n let currentNode = tableWrapper.parentNode as HTMLElement | null;\n\n while (currentNode !== null && currentNode !== iframeDocument.body) {\n // Add the 'h-fit' class to the 'table-wrapper' element's parent chain.\n // This ensures that the table is not cropped and fits within its container.\n currentNode?.classList.add('!h-fit');\n currentNode = currentNode.parentNode as HTMLElement | null;\n }\n\n setMountNode(tableWrapper);\n }, [iframeWindow, stylesReady]);\n\n const printTableProps: Table3Props<TType> = {\n ...tableProps,\n actionsForRow: undefined,\n // Not the best way to remove the active/current row styles, but a temporary solution for now\n defaultCurrentRowIndex: -1,\n defaultSettings: {\n ...tableProps?.defaultSettings,\n rowHeight: 'short',\n },\n enableColumnFreezing: false,\n enableRowHeight: true,\n enableRowSelection: false,\n enableEditing: false,\n enablePrinting: false,\n enableRowDrag: false,\n enableRowDrop: false,\n enableRowSelectionSingle: false,\n preset: undefined,\n // The presence of the onChangeSettings prop ensures that settings won't be stored in local storage.\n onChangeSettings: () => undefined,\n };\n\n // -top-60 -left-60 styles make sure that iframe is added outside of the viewport\n return (\n <iframe\n className=\"fixed -left-[6000px] -top-[6000px] -z-50 !h-0 !w-0\"\n ref={setContentRef}\n // Temporary fix to support printing in firefox: Find another solution while upgrading React\n src=\"javascript:void(0);\">\n {mountNode && stylesReady ? ReactDOM.createPortal(<Table3 {...printTableProps} />, mountNode) : null}\n </iframe>\n );\n}\n"],"names":["PrintIFrame","onAfterPrint","onBeforePrint","tableProps","contentRef","setContentRef","React","useState","mountNode","setMountNode","isFirefoxBrowser","useMemo","navigator","userAgent","toLowerCase","includes","isSafariBrowser","iframeWindow","contentWindow","stylesReady","useParentStylesheets","useEffect","intervalId","timeoutId","setInterval","tableWrapper","table","querySelector","hasTableRendered","_contentRef$contentWi","clearInterval","tableHeight","offsetHeight","style","height","print","setTimeout","Promise","resolve","e","reject","clearTimeout","parentElement","_contentRef$closest","closest","parent","document","body","iframeDocument","innerHTML","_parentElement$innerH","tableElement","tableColumnFreezingStyles","createElement","setAttribute","classList","add","_tableElement$parentN","parentNode","insertBefore","remove","append","currentNode","_currentNode","printTableProps","actionsForRow","undefined","defaultCurrentRowIndex","defaultSettings","rowHeight","enableColumnFreezing","enableRowHeight","enableRowSelection","enableEditing","enablePrinting","enableRowDrag","enableRowDrop","enableRowSelectionSingle","preset","onChangeSettings","className","ref","src","ReactDOM","createPortal","Table3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAagBA,WAAWA,CAAkB;EAAEC,YAAY;EAAEC,aAAa;EAAEC;CAAqC;EAC7G,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAA2B,IAAI,CAAC;EAClF,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAqB,IAAI,CAAC;EAE1E,MAAMG,gBAAgB,GAAGJ,cAAK,CAACK,OAAO,CAAC,MAAMC,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;EACvG,MAAMC,eAAe,GAAGV,cAAK,CAACK,OAAO,CACjC,MAAMC,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAACH,SAAS,CAACC,SAAS,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,EACnH,EAAE,CACL;EAED,MAA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C,YAAY,eAAC9E,6BAAC+E,MAAM,oBAAKrB,eAAe,EAAI,EAAExD,SAAS,CAAC,GAAG,IAAI,CAC/F;AAEjB;;;;"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { useLocalStorage } from '../../../../hooks/useLocalStorage.js';
|
2
1
|
import { useTacoSettings } from '../../../../hooks/useTacoSettings.js';
|
2
|
+
import { useLocalStorage } from '../../../../hooks/useLocalStorage.js';
|
3
3
|
import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
|
4
4
|
|
5
5
|
function useUniqueTableId(tableId) {
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js
CHANGED
@@ -15,7 +15,9 @@ function useSettingsStateListener(table, onChangeSettings) {
|
|
15
15
|
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
16
16
|
meta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility,
|
17
17
|
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
18
|
-
meta.search.excludeUnmatchedResults, meta.fontSize.size, meta.rowHeight.height,
|
18
|
+
meta.search.excludeUnmatchedResults, meta.fontSize.size, meta.rowHeight.height,
|
19
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
20
|
+
meta.printing.isWarningVisibleForLargeDatasets, state.sorting]);
|
19
21
|
}
|
20
22
|
|
21
23
|
export { useSettingsStateListener };
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useSettingsStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useSettingsStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { Table3SettingsHandler } from '../../types';\n\nexport function useSettingsStateListener<TType = unknown>(\n table: RTable<TType>,\n onChangeSettings: Table3SettingsHandler | undefined\n) {\n const meta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n onChangeSettings(meta.getSettings());\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.search.excludeUnmatchedResults,\n meta.fontSize.size,\n meta.rowHeight.height,\n meta.printing.isWarningVisibleForLargeDatasets,\n state.sorting,\n ]);\n}\n"],"names":["useSettingsStateListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","search","excludeUnmatchedResults","fontSize","size","rowHeight","height","printing","isWarningVisibleForLargeDatasets","sorting"],"mappings":";;SAIgBA,wBAAwBA,CACpCC,KAAoB,EACpBC,gBAAmD;EAEnD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;QACjBR,gBAAgB,CAACC,IAAI,CAACQ,WAAW,EAAE,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMC,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE;;EAECN,IAAI,CAACU,cAAc,CAACC,iBAAiB,EACrCT,KAAK,CAACU,WAAW,EACjBV,KAAK,CAACW,YAAY,EAClBX,KAAK,CAACY,gBAAgB;;EAEtBd,IAAI,CAACe,MAAM,CAACC,uBAAuB,EACnChB,IAAI,CAACiB,QAAQ,CAACC,IAAI,EAClBlB,IAAI,CAACmB,SAAS,CAACC,MAAM,
|
1
|
+
{"version":3,"file":"useSettingsStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useSettingsStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { Table3SettingsHandler } from '../../types';\n\nexport function useSettingsStateListener<TType = unknown>(\n table: RTable<TType>,\n onChangeSettings: Table3SettingsHandler | undefined\n) {\n const meta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n onChangeSettings(meta.getSettings());\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.search.excludeUnmatchedResults,\n meta.fontSize.size,\n meta.rowHeight.height,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.printing.isWarningVisibleForLargeDatasets,\n state.sorting,\n ]);\n}\n"],"names":["useSettingsStateListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","search","excludeUnmatchedResults","fontSize","size","rowHeight","height","printing","isWarningVisibleForLargeDatasets","sorting"],"mappings":";;SAIgBA,wBAAwBA,CACpCC,KAAoB,EACpBC,gBAAmD;EAEnD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;QACjBR,gBAAgB,CAACC,IAAI,CAACQ,WAAW,EAAE,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMC,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE;;EAECN,IAAI,CAACU,cAAc,CAACC,iBAAiB,EACrCT,KAAK,CAACU,WAAW,EACjBV,KAAK,CAACW,YAAY,EAClBX,KAAK,CAACY,gBAAgB;;EAEtBd,IAAI,CAACe,MAAM,CAACC,uBAAuB,EACnChB,IAAI,CAACiB,QAAQ,CAACC,IAAI,EAClBlB,IAAI,CAACmB,SAAS,CAACC,MAAM;;EAErBpB,IAAI,CAACqB,QAAQ,CAACC,gCAAgC,EAC9CpB,KAAK,CAACqB,OAAO,CAChB,CAAC;AACN;;;;"}
|