@economic/taco 2.51.3-alpha.1 → 2.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/components/Report/Report.d.ts +1 -1
  2. package/dist/esm/index.css +40 -4
  3. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +33 -26
  4. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  5. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +4 -0
  6. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  7. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +0 -1
  8. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Toast/Toaster.js +16 -2
  10. package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
  11. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +16 -4
  12. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  13. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  14. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -0
  15. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  16. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +4 -2
  17. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  18. package/dist/index.css +40 -4
  19. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +2 -2
  20. package/dist/primitives/Table/types.d.ts +4 -0
  21. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +2 -1
  22. package/dist/taco.cjs.development.js +73 -35
  23. package/dist/taco.cjs.development.js.map +1 -1
  24. package/dist/taco.cjs.production.min.js +1 -1
  25. package/dist/taco.cjs.production.min.js.map +1 -1
  26. package/package.json +3 -2
  27. package/tailwind.config.js +1 -0
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ReportRef, ReportProps, ReportColumnProps, ReportGroupProps } from './types';
3
3
  declare function Column<TType = unknown>(_: ReportColumnProps<TType>): null;
4
4
  declare function Group(_: ReportGroupProps): null;
5
- export declare const Report: (<TType = unknown>(props: Pick<import("../..").TableProps<TType>, "length" | "loadAll" | "loadPage" | "pageSize" | "pages" | "_experimentalDataLoader2" | "enableFiltering" | "enableSearch" | "enableSorting" | "enableColumnFreezing" | "enableColumnHiding" | "enableColumnResizing" | "enableRowExpansion" | "enableRowExpansionAll" | "enableRowSelection" | "enableColumnOrdering" | "enableFontSize" | "enableFooter" | "enablePrinting" | "enableRowActions" | "enableRowActive" | "enableRowClick" | "enableRowDrag" | "enableRowDrop" | "enableRowGoto" | "enableRowHeight" | "enableSaveSettings" | "children" | "data" | "id" | "customSettings" | "defaultColumnFreezingIndex" | "defaultRowActiveIndex" | "defaultRowGroupColumnId" | "defaultSettings" | "emptyState" | "rowActions" | "rowActionsForGroup" | "rowActionsLength" | "rowExpansionRenderer" | "rowIdentityAccessor" | "shortcuts" | "toolbarLeft" | "toolbarRight" | "toolbarPanel" | "onRowClick" | "onRowDrag" | "onRowDrop" | "onRowGoto" | "onRowSelect" | "onChangeFilter" | "onChangeSearch" | "onChangeSettings" | "onChangeSort"> & React.RefAttributes<import("../..").TableRef>) => JSX.Element) & {
5
+ export declare const Report: (<TType = unknown>(props: Pick<import("../..").TableProps<TType>, "length" | "loadAll" | "loadPage" | "pageSize" | "pages" | "_experimentalDataLoader2" | "enableFiltering" | "enableSearch" | "enableSorting" | "enableColumnFreezing" | "enableColumnHiding" | "enableColumnResizing" | "enableRowExpansion" | "enableRowExpansionAll" | "enableRowSelection" | "enableColumnOrdering" | "enableFontSize" | "enableFooter" | "enablePrinting" | "enableRowActions" | "enableRowActive" | "enableRowClick" | "enableRowDrag" | "enableRowDrop" | "enableRowGoto" | "enableRowHeight" | "enableSaveSettings" | "children" | "data" | "id" | "customSettings" | "defaultColumnFreezingIndex" | "defaultRowActiveIndex" | "defaultRowGroupColumnId" | "defaultSettings" | "emptyState" | "rowActions" | "rowActionsForGroup" | "rowActionsLength" | "rowExpansionRenderer" | "rowIdentityAccessor" | "shortcuts" | "toolbarLeft" | "toolbarRight" | "toolbarPanel" | "onEvent" | "onRowClick" | "onRowDrag" | "onRowDrop" | "onRowGoto" | "onRowSelect" | "onChangeFilter" | "onChangeSearch" | "onChangeSettings" | "onChangeSort"> & React.RefAttributes<import("../..").TableRef>) => JSX.Element) & {
6
6
  Column: typeof Column;
7
7
  Group: typeof Group;
8
8
  };
@@ -890,7 +890,7 @@ table[data-taco^='table'][data-table-font-size='small'] td [data-taco='input-con
890
890
  }
891
891
 
892
892
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='input-container']:has([data-taco='input']) [data-taco='input'] {
893
- @apply !-my-[4px] !min-h-[theme(spacing.6)] !w-[calc(100%_+_14px)] !pl-[3px] text-xs focus:z-10;
893
+ @apply !-my-[4px] !min-h-[theme(spacing.6)] !w-[calc(100%_+_14px)] !pl-[6px] text-xs focus:z-10;
894
894
  }
895
895
 
896
896
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='Select2'],
@@ -908,7 +908,19 @@ table[data-taco^='table'][data-table-font-size='small'] td [data-taco='Select2']
908
908
  }
909
909
 
910
910
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='textarea'] {
911
- @apply !mb-1.5 !py-[3px] !leading-4;
911
+ @apply !-mt-[4px] !mb-[1px] !pt-[3px] !leading-4;
912
+ }
913
+
914
+ table[data-taco^='table'][data-table-row-height='medium'][data-table-font-size='small'] td [data-taco='textarea'] {
915
+ @apply !mb-[5px];
916
+ }
917
+
918
+ table[data-taco^='table'][data-table-row-height='tall'][data-table-font-size='small'] td [data-taco='textarea'] {
919
+ @apply !mb-[9px];
920
+ }
921
+
922
+ table[data-taco^='table'][data-table-row-height='extra-tall'][data-table-font-size='small'] td [data-taco='textarea'] {
923
+ @apply !mb-[15px];
912
924
  }
913
925
 
914
926
  table[data-taco^='table'][data-table-font-size='small'] td [data-taco='input-container'] [data-affix-type='postfix'] button {
@@ -1004,6 +1016,18 @@ table[data-taco^='table'][data-table-font-size='medium'] td [data-taco='textarea
1004
1016
  @apply !mb-[3px] !pr-[5px];
1005
1017
  }
1006
1018
 
1019
+ table[data-taco^='table'][data-table-row-height='short'][data-table-font-size='medium'] td [data-taco='textarea'] {
1020
+ @apply !-mb-[1px];
1021
+ }
1022
+
1023
+ table[data-taco^='table'][data-table-row-height='tall'][data-table-font-size='medium'] td [data-taco='textarea'] {
1024
+ @apply !mb-[7px];
1025
+ }
1026
+
1027
+ table[data-taco^='table'][data-table-row-height='extra-tall'][data-table-font-size='medium'] td [data-taco='textarea'] {
1028
+ @apply !mb-[13px];
1029
+ }
1030
+
1007
1031
  table[data-taco^='table'][data-table-font-size='medium'] td[data-cell-truncate='true'] [data-taco='textarea'] {
1008
1032
  @apply !pb-[5px];
1009
1033
  }
@@ -1057,7 +1081,7 @@ table[data-taco^='table'][data-table-font-size='large'] td [data-taco='select2-c
1057
1081
  }
1058
1082
 
1059
1083
  table[data-taco^='table'][data-table-font-size='large'] td [data-taco='Select2'] {
1060
- @apply !px-2.5;
1084
+ @apply !px-2.5 !pt-[1px];
1061
1085
  }
1062
1086
 
1063
1087
  table[data-taco^='table'][data-table-font-size='large'] td [data-taco='Select2'] [data-taco='tag'] {
@@ -1065,7 +1089,19 @@ table[data-taco^='table'][data-table-font-size='large'] td [data-taco='Select2']
1065
1089
  }
1066
1090
 
1067
1091
  table[data-taco^='table'][data-table-font-size='large'] td [data-taco='textarea'] {
1068
- @apply !-mb-[1px] !py-[7.5px];
1092
+ @apply !pt-[7.5px];
1093
+ }
1094
+
1095
+ table[data-taco^='table'][data-table-row-height='medium'][data-table-font-size='large'] td [data-taco='textarea'] {
1096
+ @apply !-mb-[0.5px];
1097
+ }
1098
+
1099
+ table[data-taco^='table'][data-table-row-height='tall'][data-table-font-size='large'] td [data-taco='textarea'] {
1100
+ @apply !mb-[3.5px];
1101
+ }
1102
+
1103
+ table[data-taco^='table'][data-table-row-height='extra-tall'][data-table-font-size='large'] td [data-taco='textarea'] {
1104
+ @apply !mb-[9.5px];
1069
1105
  }
1070
1106
 
1071
1107
  table[data-taco^='table'][data-table-font-size='large'] td:not([data-cell-truncate='true']) > [data-taco='textarea'] {
@@ -124,32 +124,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
124
124
  ref: controlRef,
125
125
  tabIndex
126
126
  };
127
- if (typeof type === 'function') {
128
- const controlFnProps = {
129
- ...commonProps,
130
- invalid,
131
- setValue: onChange,
132
- value
133
- };
134
- return type(controlFnProps, {
135
- ...row,
136
- ...rowPendingChanges
137
- });
138
- }
139
- if (type === 'switch') {
140
- return /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, commonProps, {
141
- checked: Boolean(value),
142
- onChange: onChange,
143
- ref: controlRef
144
- }));
145
- }
146
- if (type === 'checkbox') {
147
- return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, commonProps, {
148
- checked: Boolean(value),
149
- onChange: onChange,
150
- ref: controlRef
151
- }));
152
- }
153
127
  const handleInputKeyDown = event => {
154
128
  const target = event.target;
155
129
  if (target.readOnly) {
@@ -197,6 +171,39 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
197
171
  toggleDetailedMode(true);
198
172
  }
199
173
  };
174
+ if (typeof type === 'function') {
175
+ const controlFnProps = {
176
+ ...commonProps,
177
+ invalid,
178
+ setValue: onChange,
179
+ onKeyDown: event => {
180
+ const target = event.target || null;
181
+ // it make sense to handle keydown for the custom edititng controls only if target is either input or textarea
182
+ if (target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')) {
183
+ handleInputKeyDown(event);
184
+ }
185
+ },
186
+ value
187
+ };
188
+ return type(controlFnProps, {
189
+ ...row,
190
+ ...rowPendingChanges
191
+ });
192
+ }
193
+ if (type === 'switch') {
194
+ return /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, commonProps, {
195
+ checked: Boolean(value),
196
+ onChange: onChange,
197
+ ref: controlRef
198
+ }));
199
+ }
200
+ if (type === 'checkbox') {
201
+ return /*#__PURE__*/React__default.createElement(Checkbox, Object.assign({}, commonProps, {
202
+ checked: Boolean(value),
203
+ onChange: onChange,
204
+ ref: controlRef
205
+ }));
206
+ }
200
207
  const handleFocus = event => {
201
208
  if (!isDetailedMode) {
202
209
  event.target.select();
@@ -1 +1 @@
1
- {"version":3,"file":"EditingControlCell.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/EditingControlCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { TableColumnDataType, TableColumnRendererControl, TableFontSize } from '../../../../../primitives/Table/types';\nimport * as date from '../../../../../utils/date';\nimport { RowMoveIndicator } from './Editing/RowMoveIndicator';\nimport { TextareaWithAutosizing } from './Editing/TextareaWithAutosizing';\nimport { Field } from '../../../../Field/Field';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\nimport { getCellAttributes } from '../../../../../primitives/Table/Core/components/Columns/Cell/util';\nimport { useEditingCellAutofocus } from './util';\nimport { isPressingMetaKey } from '../../../../../utils/keyboard';\nimport { Checkbox } from '../../../../Checkbox/Checkbox';\n\nexport function EditingControlCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, isHighlighted, index } = props;\n const { rowIndex } = React.useContext(RowContext);\n const { table } = cell.getContext();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const type = columnMeta.control ?? 'input';\n const handleFocus = useEditingCellAutofocus<TType>(props);\n const value = cell.getValue();\n\n // some controls, like select2, should trigger cell changed (validation, updates) as the value changes\n const hasNonTextControl = React.useMemo(() => {\n return (\n typeof type === 'function' &&\n !!cellRef.current?.querySelector('[data-taco=\"Select2\"],[data-taco=\"switch\"],[data-taco=\"checkbox\"]')\n );\n }, [cellRef.current]);\n\n const handleChange = React.useCallback(\n (nextValue: unknown) => {\n if (nextValue !== value) {\n tableMeta.editing.setCellValue(cell, rowIndex, nextValue);\n\n if (hasNonTextControl) {\n requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));\n }\n }\n },\n [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value]\n );\n\n const blur = React.useCallback(\n function blur() {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.onCellChanged(cell, rowIndex, undefined, !hasNonTextControl);\n },\n [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex]\n );\n\n const handleBlur = React.useCallback(\n (event: React.FocusEvent) => {\n if (isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {\n return;\n }\n blur();\n },\n [blur]\n );\n\n // ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)\n React.useEffect(() => {\n const ref = cellRef.current;\n\n return () => {\n if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {\n blur();\n }\n };\n }, []);\n\n const error = tableMeta.editing.getCellError<TType>(cell);\n\n const controlProps = {\n dataType: columnMeta.dataType,\n fontSize: tableMeta.fontSize.size,\n id: cell.column.id,\n invalid: !!error,\n isDetailedMode: tableMeta.editing.isDetailedMode,\n isTruncated: !!columnMeta.enableTruncate,\n onBlur: handleBlur,\n onChange: handleChange,\n row: cell.row.original,\n rowPendingChanges: tableMeta.editing.getRowValue(cell.row.id),\n tabIndex: isActiveRow ? 0 : -1,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type,\n value,\n };\n\n const cellAttributes = {\n ...getCellAttributes(cell, index, isHighlighted),\n 'data-cell-editing-invalid': error ? true : undefined,\n 'data-taco': 'cell-control',\n onFocus: handleFocus,\n ref: cellRef,\n tabIndex: -1,\n };\n\n return (\n <td {...cellAttributes}>\n <Field invalid={!!error} message={error}>\n <MemoedEditingCell<TType> {...controlProps} />\n </Field>\n {\n // we show row move indicator here within the cell rather than the row because it is\n // an editing only feature, and we don't want to leak editing into the shared row component\n }\n <RowMoveIndicator cell={cell} cellRef={cellRef} isActiveRow={isActiveRow} />\n </td>\n );\n}\n\ntype MemoedEditingCellProps<TType = unknown, TValue = unknown> = {\n dataType?: TableColumnDataType;\n fontSize: TableFontSize;\n id: string;\n invalid: boolean;\n isDetailedMode: boolean;\n isTruncated: boolean;\n onBlur: (event: React.FocusEvent) => void;\n onChange: (value: TValue) => void;\n row: TType;\n rowPendingChanges: Partial<TType> | undefined;\n tabIndex?: number;\n toggleDetailedMode: (detailed: React.SetStateAction<boolean>) => void;\n type: TableColumnRendererControl<TType>;\n value: TValue;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const {\n dataType,\n fontSize,\n id,\n invalid,\n isDetailedMode,\n isTruncated,\n onBlur,\n onChange,\n row,\n rowPendingChanges,\n tabIndex = -1,\n toggleDetailedMode,\n type = 'input',\n value,\n } = props;\n const controlRef = React.useRef<HTMLElement>(null);\n const currentValue = row[id];\n const commonProps = {\n onBlur,\n ref: controlRef,\n tabIndex,\n };\n\n if (typeof type === 'function') {\n const controlFnProps = {\n ...commonProps,\n invalid,\n setValue: onChange,\n value,\n };\n\n return type(controlFnProps, { ...row, ...rowPendingChanges });\n }\n\n if (type === 'switch') {\n return (\n <Switch\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n if (type === 'checkbox') {\n return (\n <Checkbox\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n\n if (target.readOnly) {\n return;\n }\n\n // prevent active row navigation while in detailed mode\n if (\n isDetailedMode &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight')\n ) {\n event.stopPropagation();\n }\n\n // enter or exit detail mode when pressing enter\n if (event.key === 'Enter') {\n // textareas support shift and enter, don't prevent default in that case\n if (event.shiftKey && isDetailedMode) {\n return;\n }\n\n event.preventDefault();\n\n if (isDetailedMode) {\n target.select?.();\n } else {\n target.setSelectionRange?.(target.value?.length, target.value?.length);\n }\n\n toggleDetailedMode(editing => !editing);\n return;\n }\n\n // reset the value, or exit edit mode when pressing escape\n if (event.key === 'Escape') {\n if (isDetailedMode) {\n event.preventDefault();\n toggleDetailedMode(false);\n\n if (value !== currentValue) {\n props.onChange(currentValue);\n }\n\n // have to let onChange run before selecting, otherwise the value changes\n requestAnimationFrame(() => target.select?.());\n }\n\n return;\n }\n\n // toggle into detailed mode when actually inputting something\n if (!isPressingMetaKey(event) && (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace')) {\n toggleDetailedMode(true);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (!isDetailedMode) {\n event.target.select();\n }\n };\n\n if (type === 'datepicker') {\n const valueAsDate = date.parse(value as Date | string | undefined);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDate = (event as any).detail as Date;\n\n if (!valueAsDate || !newDate || (isDate(valueAsDate) && isDate(newDate) && !date.isWeakEqual(valueAsDate, newDate))) {\n props.onChange(newDate);\n }\n };\n\n const handleDatepickerInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n // When in detailed mode, we want to handle the change, when 'Enter' is pressed.\n // To make it possible, we just need to prevent handleInputKeyDown from being executed, and give the full control to Datepicker,\n // by doing this, Datepicker will exit \"detailed mode\" by itself when a valid date change event is triggered.\n // In any other cases we'll just execute the \"handleInputKeyDown\" handler.\n if (isDetailedMode && event.key === 'Enter' && (event.target as HTMLInputElement).value !== '') {\n return;\n }\n\n handleInputKeyDown(event);\n };\n\n return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleDatepickerInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n value={valueAsDate}\n />\n );\n }\n\n if (type === 'textarea') {\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n onChange(event.target.value);\n };\n\n return (\n <TextareaWithAutosizing\n {...commonProps}\n fontSize={fontSize}\n invalid={invalid}\n isTruncated={isTruncated}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLTextAreaElement>}\n value={String(value ?? '')}\n />\n );\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(dataType === 'number' && event.target.value ? Number.parseInt(event.target.value) : event.target.value);\n };\n\n return (\n <Input\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n type={dataType === 'number' ? 'number' : undefined}\n value={dataType === 'number' ? (value as number) : String(value ?? '')}\n />\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n"],"names":["EditingControlCell","props","cell","cellRef","isHighlighted","index","rowIndex","React","useContext","RowContext","table","getContext","tableMeta","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","type","_columnMeta$control","control","handleFocus","useEditingCellAutofocus","value","getValue","hasNonTextControl","useMemo","_cellRef$current","current","querySelector","handleChange","useCallback","nextValue","editing","setCellValue","requestAnimationFrame","onCellChanged","row","id","original","blur","toggleDetailedMode","undefined","handleBlur","event","isElementInsideOrTriggeredFromContainer","relatedTarget","currentTarget","useEffect","ref","document","activeElement","error","getCellError","controlProps","dataType","fontSize","size","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","rowPendingChanges","getRowValue","tabIndex","cellAttributes","getCellAttributes","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","controlFnProps","setValue","Switch","checked","Boolean","Checkbox","handleInputKeyDown","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","_target$select2","isPressingMetaKey","test","valueAsDate","date","newDate","detail","isDate","handleDatepickerInputKeyDown","Datepicker","onKeyDown","TextareaWithAutosizing","String","Number","parseInt","Input"],"mappings":";;;;;;;;;;;;;;;;SAmBgBA,kBAAkBA,CAAkBC,KAAoC;;EACpF,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,aAAa;IAAEC;GAAO,GAAGJ,KAAK;EACrD,MAAM;IAAEK;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EACjD,MAAM;IAAEC;GAAO,GAAGR,IAAI,CAACS,UAAU,EAAE;EACnC,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,UAAU,GAAGb,IAAI,CAACc,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,WAAW,GAAGN,SAAS,CAACO,SAAS,CAACC,cAAc,KAAKd,QAAQ;EACnE,MAAMe,IAAI,IAAAC,mBAAA,GAAGP,UAAU,CAACQ,OAAO,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,OAAO;EAC1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KAAK,QAAQ,IAAIX,KAAK,CAAC0C,MAAM,CAAC/D,KAAK,GAAG0F,MAAM,CAACC,QAAQ,CAACtE,KAAK,CAAC0C,MAAM,CAAC/D,KAAK,CAAC,GAAGqB,KAAK,CAAC0C,MAAM,CAAC/D,KAAK,CAAC;GACnH;EAED,oBACInB,6BAAC+G,KAAK,oBACErC,WAAW;IACfpB,OAAO,EAAEA,OAAO;IAChBK,QAAQ,EAAEjC,YAAY;IACtBuC,OAAO,EAAEhD,WAAW;IACpByF,SAAS,EAAEzB,kBAAkB;IAC7BpC,GAAG,EAAE0B,UAA+C;IACpDzD,IAAI,EAAEqC,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAGb,SAAS;IAClDnB,KAAK,EAAEgC,QAAQ,KAAK,QAAQ,GAAIhC,KAAgB,GAAGyF,MAAM,CAACzF,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KACvE;AAEV,CAAC,CAA2E;;;;"}
1
+ {"version":3,"file":"EditingControlCell.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/EditingControlCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { TableColumnDataType, TableColumnRendererControl, TableFontSize } from '../../../../../primitives/Table/types';\nimport * as date from '../../../../../utils/date';\nimport { RowMoveIndicator } from './Editing/RowMoveIndicator';\nimport { TextareaWithAutosizing } from './Editing/TextareaWithAutosizing';\nimport { Field } from '../../../../Field/Field';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\nimport { getCellAttributes } from '../../../../../primitives/Table/Core/components/Columns/Cell/util';\nimport { useEditingCellAutofocus } from './util';\nimport { isPressingMetaKey } from '../../../../../utils/keyboard';\nimport { Checkbox } from '../../../../Checkbox/Checkbox';\n\nexport function EditingControlCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, isHighlighted, index } = props;\n const { rowIndex } = React.useContext(RowContext);\n const { table } = cell.getContext();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const type = columnMeta.control ?? 'input';\n const handleFocus = useEditingCellAutofocus<TType>(props);\n const value = cell.getValue();\n\n // some controls, like select2, should trigger cell changed (validation, updates) as the value changes\n const hasNonTextControl = React.useMemo(() => {\n return (\n typeof type === 'function' &&\n !!cellRef.current?.querySelector('[data-taco=\"Select2\"],[data-taco=\"switch\"],[data-taco=\"checkbox\"]')\n );\n }, [cellRef.current]);\n\n const handleChange = React.useCallback(\n (nextValue: unknown) => {\n if (nextValue !== value) {\n tableMeta.editing.setCellValue(cell, rowIndex, nextValue);\n\n if (hasNonTextControl) {\n requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));\n }\n }\n },\n [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value]\n );\n\n const blur = React.useCallback(\n function blur() {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.onCellChanged(cell, rowIndex, undefined, !hasNonTextControl);\n },\n [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex]\n );\n\n const handleBlur = React.useCallback(\n (event: React.FocusEvent) => {\n if (isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {\n return;\n }\n blur();\n },\n [blur]\n );\n\n // ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)\n React.useEffect(() => {\n const ref = cellRef.current;\n\n return () => {\n if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {\n blur();\n }\n };\n }, []);\n\n const error = tableMeta.editing.getCellError<TType>(cell);\n\n const controlProps = {\n dataType: columnMeta.dataType,\n fontSize: tableMeta.fontSize.size,\n id: cell.column.id,\n invalid: !!error,\n isDetailedMode: tableMeta.editing.isDetailedMode,\n isTruncated: !!columnMeta.enableTruncate,\n onBlur: handleBlur,\n onChange: handleChange,\n row: cell.row.original,\n rowPendingChanges: tableMeta.editing.getRowValue(cell.row.id),\n tabIndex: isActiveRow ? 0 : -1,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type,\n value,\n };\n\n const cellAttributes = {\n ...getCellAttributes(cell, index, isHighlighted),\n 'data-cell-editing-invalid': error ? true : undefined,\n 'data-taco': 'cell-control',\n onFocus: handleFocus,\n ref: cellRef,\n tabIndex: -1,\n };\n\n return (\n <td {...cellAttributes}>\n <Field invalid={!!error} message={error}>\n <MemoedEditingCell<TType> {...controlProps} />\n </Field>\n {\n // we show row move indicator here within the cell rather than the row because it is\n // an editing only feature, and we don't want to leak editing into the shared row component\n }\n <RowMoveIndicator cell={cell} cellRef={cellRef} isActiveRow={isActiveRow} />\n </td>\n );\n}\n\ntype MemoedEditingCellProps<TType = unknown, TValue = unknown> = {\n dataType?: TableColumnDataType;\n fontSize: TableFontSize;\n id: string;\n invalid: boolean;\n isDetailedMode: boolean;\n isTruncated: boolean;\n onBlur: (event: React.FocusEvent) => void;\n onChange: (value: TValue) => void;\n row: TType;\n rowPendingChanges: Partial<TType> | undefined;\n tabIndex?: number;\n toggleDetailedMode: (detailed: React.SetStateAction<boolean>) => void;\n type: TableColumnRendererControl<TType>;\n value: TValue;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const {\n dataType,\n fontSize,\n id,\n invalid,\n isDetailedMode,\n isTruncated,\n onBlur,\n onChange,\n row,\n rowPendingChanges,\n tabIndex = -1,\n toggleDetailedMode,\n type = 'input',\n value,\n } = props;\n const controlRef = React.useRef<HTMLElement>(null);\n const currentValue = row[id];\n const commonProps = {\n onBlur,\n ref: controlRef,\n tabIndex,\n };\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n\n if (target.readOnly) {\n return;\n }\n\n // prevent active row navigation while in detailed mode\n if (\n isDetailedMode &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight')\n ) {\n event.stopPropagation();\n }\n\n // enter or exit detail mode when pressing enter\n if (event.key === 'Enter') {\n // textareas support shift and enter, don't prevent default in that case\n if (event.shiftKey && isDetailedMode) {\n return;\n }\n\n event.preventDefault();\n\n if (isDetailedMode) {\n target.select?.();\n } else {\n target.setSelectionRange?.(target.value?.length, target.value?.length);\n }\n\n toggleDetailedMode(editing => !editing);\n return;\n }\n\n // reset the value, or exit edit mode when pressing escape\n if (event.key === 'Escape') {\n if (isDetailedMode) {\n event.preventDefault();\n toggleDetailedMode(false);\n\n if (value !== currentValue) {\n props.onChange(currentValue);\n }\n\n // have to let onChange run before selecting, otherwise the value changes\n requestAnimationFrame(() => target.select?.());\n }\n\n return;\n }\n\n // toggle into detailed mode when actually inputting something\n if (!isPressingMetaKey(event) && (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace')) {\n toggleDetailedMode(true);\n }\n };\n\n if (typeof type === 'function') {\n const controlFnProps = {\n ...commonProps,\n invalid,\n setValue: onChange,\n onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => {\n const target = (event.target as HTMLElement) || null;\n // it make sense to handle keydown for the custom edititng controls only if target is either input or textarea\n if (target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')) {\n handleInputKeyDown(event as React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>);\n }\n },\n value,\n };\n\n return type(controlFnProps, { ...row, ...rowPendingChanges });\n }\n\n if (type === 'switch') {\n return (\n <Switch\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n if (type === 'checkbox') {\n return (\n <Checkbox\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (!isDetailedMode) {\n event.target.select();\n }\n };\n\n if (type === 'datepicker') {\n const valueAsDate = date.parse(value as Date | string | undefined);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDate = (event as any).detail as Date;\n\n if (!valueAsDate || !newDate || (isDate(valueAsDate) && isDate(newDate) && !date.isWeakEqual(valueAsDate, newDate))) {\n props.onChange(newDate);\n }\n };\n\n const handleDatepickerInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n // When in detailed mode, we want to handle the change, when 'Enter' is pressed.\n // To make it possible, we just need to prevent handleInputKeyDown from being executed, and give the full control to Datepicker,\n // by doing this, Datepicker will exit \"detailed mode\" by itself when a valid date change event is triggered.\n // In any other cases we'll just execute the \"handleInputKeyDown\" handler.\n if (isDetailedMode && event.key === 'Enter' && (event.target as HTMLInputElement).value !== '') {\n return;\n }\n\n handleInputKeyDown(event);\n };\n\n return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleDatepickerInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n value={valueAsDate}\n />\n );\n }\n\n if (type === 'textarea') {\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n onChange(event.target.value);\n };\n\n return (\n <TextareaWithAutosizing\n {...commonProps}\n fontSize={fontSize}\n invalid={invalid}\n isTruncated={isTruncated}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLTextAreaElement>}\n value={String(value ?? '')}\n />\n );\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(dataType === 'number' && event.target.value ? Number.parseInt(event.target.value) : event.target.value);\n };\n\n return (\n <Input\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n type={dataType === 'number' ? 'number' : undefined}\n value={dataType === 'number' ? (value as number) : String(value ?? '')}\n />\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n"],"names":["EditingControlCell","props","cell","cellRef","isHighlighted","index","rowIndex","React","useContext","RowContext","table","getContext","tableMeta","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","type","_columnMeta$control","control","handleFocus","useEditingCellAutofocus","value","getValue","hasNonTextControl","useMemo","_cellRef$current","current","querySelector","handleChange","useCallback","nextValue","editing","setCellValue","requestAnimationFrame","onCellChanged","row","id","original","blur","toggleDetailedMode","undefined","handleBlur","event","isElementInsideOrTriggeredFromContainer","relatedTarget","currentTarget","useEffect","ref","document","activeElement","error","getCellError","controlProps","dataType","fontSize","size","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","rowPendingChanges","getRowValue","tabIndex","cellAttributes","getCellAttributes","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","handleInputKeyDown","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","_target$select2","isPressingMetaKey","test","controlFnProps","setValue","onKeyDown","tagName","Switch","checked","Boolean","Checkbox","valueAsDate","date","newDate","detail","isDate","handleDatepickerInputKeyDown","Datepicker","TextareaWithAutosizing","String","Number","parseInt","Input"],"mappings":";;;;;;;;;;;;;;;;SAmBgBA,kBAAkBA,CAAkBC,KAAoC;;EACpF,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,aAAa;IAAEC;GAAO,GAAGJ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,CAA2E;;;;"}
@@ -16,7 +16,11 @@ function Editing(props) {
16
16
  const ref = React__default.useRef(null);
17
17
  const tableMeta = table.options.meta;
18
18
  const handleChange = enabled => {
19
+ var _tableMeta$onEvent;
19
20
  tableMeta.editing.toggleEditing(enabled, table, scrollToIndex);
21
+ (_tableMeta$onEvent = tableMeta.onEvent) === null || _tableMeta$onEvent === void 0 ? void 0 : _tableMeta$onEvent.call(tableMeta, 'editing-mode', {
22
+ enabled
23
+ });
20
24
  };
21
25
  const tooltip = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, texts.table3.editing.buttons.edit.tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
22
26
  className: "ml-2",
@@ -1 +1 @@
1
- {"version":3,"file":"Editing.js","sources":["../../../../../../../../../../src/components/Table3/components/Toolbar/Editing/Editing.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { ModeSwitch } from '../../../../ModeSwitch/ModeSwitch';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { shortcut } from '../../../util/editing';\n\ntype EditingProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n scrollToIndex: any;\n table: ReactTable<TType>;\n};\n\nexport function Editing<TType = unknown>(props: EditingProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const handleChange = (enabled: boolean) => {\n tableMeta.editing.toggleEditing(enabled, table, scrollToIndex);\n };\n\n const tooltip = (\n <>\n {texts.table3.editing.buttons.edit.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n return (\n <Tooltip title={tooltip}>\n <ModeSwitch data-table=\"editing-toggle\" checked={tableMeta.editing.isEditing} onChange={handleChange} ref={ref} />\n </Tooltip>\n );\n}\n"],"names":["Editing","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","handleChange","enabled","editing","toggleEditing","tooltip","table3","buttons","edit","Shortcut","className","keys","shortcut","Tooltip","title","ModeSwitch","checked","isEditing","onChange"],"mappings":";;;;;;;SAagBA,OAAOA,CAAkBC,KAA0B;EAC/D,MAAM;IAAEC,aAAa;IAAEC;GAAO,GAAGF,KAAK;EACtC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAA6B;EAE7D,MAAMC,YAAY,GAAIC,OAAgB;IAClCJ,SAAS,CAACK,OAAO,CAACC,aAAa,CAACF,OAAO,EAAEV,KAAK,EAAED,aAAa,CAAC;GACjE;EAED,MAAMc,OAAO,gBACTT,4DACKH,KAAK,CAACa,MAAM,CAACH,OAAO,CAACI,OAAO,CAACC,IAAI,CAACH,OAAO,eAC1CT,6BAACa,QAAQ;IAACC,SAAS,EAAC,MAAM;IAACC,IAAI,EAAEC;IAAY,CAEpD;EAED,oBACIhB,6BAACiB,OAAO;IAACC,KAAK,EAAET;kBACZT,6BAACmB,UAAU;kBAAY,gBAAgB;IAACC,OAAO,EAAElB,SAAS,CAACK,OAAO,CAACc,SAAS;IAAEC,QAAQ,EAAEjB,YAAY;IAAEN,GAAG,EAAEA;IAAO,CAC5G;AAElB;;;;"}
1
+ {"version":3,"file":"Editing.js","sources":["../../../../../../../../../../src/components/Table3/components/Toolbar/Editing/Editing.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { ModeSwitch } from '../../../../ModeSwitch/ModeSwitch';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { shortcut } from '../../../util/editing';\n\ntype EditingProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n scrollToIndex: any;\n table: ReactTable<TType>;\n};\n\nexport function Editing<TType = unknown>(props: EditingProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const handleChange = (enabled: boolean) => {\n tableMeta.editing.toggleEditing(enabled, table, scrollToIndex);\n tableMeta.onEvent?.('editing-mode', { enabled });\n };\n\n const tooltip = (\n <>\n {texts.table3.editing.buttons.edit.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n return (\n <Tooltip title={tooltip}>\n <ModeSwitch data-table=\"editing-toggle\" checked={tableMeta.editing.isEditing} onChange={handleChange} ref={ref} />\n </Tooltip>\n );\n}\n"],"names":["Editing","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","handleChange","enabled","editing","toggleEditing","_tableMeta$onEvent","onEvent","call","tooltip","table3","buttons","edit","Shortcut","className","keys","shortcut","Tooltip","title","ModeSwitch","checked","isEditing","onChange"],"mappings":";;;;;;;SAagBA,OAAOA,CAAkBC,KAA0B;EAC/D,MAAM;IAAEC,aAAa;IAAEC;GAAO,GAAGF,KAAK;EACtC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAA6B;EAE7D,MAAMC,YAAY,GAAIC,OAAgB;;IAClCJ,SAAS,CAACK,OAAO,CAACC,aAAa,CAACF,OAAO,EAAEV,KAAK,EAAED,aAAa,CAAC;IAC9D,CAAAc,kBAAA,GAAAP,SAAS,CAACQ,OAAO,cAAAD,kBAAA,uBAAjBA,kBAAA,CAAAE,IAAA,CAAAT,SAAS,EAAW,cAAc,EAAE;MAAEI;KAAS,CAAC;GACnD;EAED,MAAMM,OAAO,gBACTZ,4DACKH,KAAK,CAACgB,MAAM,CAACN,OAAO,CAACO,OAAO,CAACC,IAAI,CAACH,OAAO,eAC1CZ,6BAACgB,QAAQ;IAACC,SAAS,EAAC,MAAM;IAACC,IAAI,EAAEC;IAAY,CAEpD;EAED,oBACInB,6BAACoB,OAAO;IAACC,KAAK,EAAET;kBACZZ,6BAACsB,UAAU;kBAAY,gBAAgB;IAACC,OAAO,EAAErB,SAAS,CAACK,OAAO,CAACiB,SAAS;IAAEC,QAAQ,EAAEpB,YAAY;IAAEN,GAAG,EAAEA;IAAO,CAC5G;AAElB;;;;"}
@@ -72,7 +72,6 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
72
72
  var _tableMeta$rowActive$, _table$getRowModel$ro;
73
73
  const index = (_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0;
74
74
  if (tableMeta.rowActive.rowActiveIndex === undefined) {
75
- console.log('edit toggle active', index);
76
75
  tableMeta.rowActive.setRowActiveIndex(index);
77
76
  }
78
77
  if (!isTemporaryRow((_table$getRowModel$ro = table.getRowModel().rows[index]) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.id)) {
@@ -1 +1 @@
1
- {"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n Table3EditingChangeHandler,\n Table3EditingCreateHandler,\n Table3EditingDiscardHandler,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n} from '../types';\nimport { usePendingChangesState } from './useEditingState';\nimport { isTemporaryRow } from '../util/editing';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n handleCreate: Table3EditingCreateHandler<TType> | undefined,\n handleDiscard: Table3EditingDiscardHandler | undefined,\n rowIdentityAccessor: keyof TType | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, setEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // used to contain ref to the create button\n const createRowButtonRef = React.useRef<HTMLButtonElement>(null);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = React.useState<number | undefined>(undefined);\n\n const pendingChangesFns = usePendingChangesState<TType>(\n handleSave,\n handleChange,\n handleDiscard,\n rowIdentityAccessor as keyof TType,\n validator\n );\n\n function toggleEditing<T extends TType>(\n enabled: React.SetStateAction<boolean>,\n table: ReactTable<T>,\n scrollToIndex: (index: number) => void\n ) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (enabled) {\n const index = tableMeta.rowActive.rowActiveIndex ?? 0;\n\n if (tableMeta.rowActive.rowActiveIndex === undefined) {\n console.log('edit toggle active', index);\n tableMeta.rowActive.setRowActiveIndex(index);\n }\n\n if (!isTemporaryRow(table.getRowModel().rows[index]?.id)) {\n scrollToIndex(index);\n }\n } else if (!enabled) {\n // reset detailed mode\n toggleDetailedMode(false);\n // reset the last index back to the first focusable element, when editing gets turned off\n setLastFocusedCellIndex(undefined);\n }\n\n setEditing(enabled);\n pendingChangesFns.saveChanges(table);\n }\n\n async function createRow<T extends TType>(table: ReactTable<T>, row?: Partial<T>) {\n if (!handleCreate) {\n return;\n }\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n const saved = await tableMeta.editing.saveChanges(table);\n\n if (!saved) {\n return;\n }\n }\n\n const changeset = row ?? handleCreate();\n\n try {\n if (changeset) {\n // set the active row to the new row before toggling editing on\n const temporaryRows = tableMeta.editing.temporaryRows as TType[];\n const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;\n\n const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);\n\n // prep the row\n table.setRowPinning(currentState => ({\n ...currentState,\n bottom: (currentState.bottom ?? [])?.concat(newRowId),\n }));\n\n // prep editing mode\n toggleDetailedMode(false);\n setLastFocusedCellIndex(undefined);\n\n // wait until set states have run\n requestAnimationFrame(() => {\n tableMeta.rowActive.setRowActiveIndex(nextRowIndex);\n table.resetRowSelection();\n\n if (!tableMeta.editing.isEditing) {\n setEditing(true);\n }\n });\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n createRow,\n createRowButtonRef,\n ...pendingChangesFns,\n };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","handleChange","handleCreate","handleDiscard","rowIdentityAccessor","validator","createRow","table","row","changeset","temporaryRows","tableMeta","editing","nextRowIndex","length","newRowId","pendingChangesFns","insertTemporaryRow","setRowPinning","currentState","_ref","_currentState$bottom","bottom","concat","toggleDetailedMode","setLastFocusedCellIndex","undefined","requestAnimationFrame","rowActive","setRowActiveIndex","resetRowSelection","isEditing","setEditing","error","console","Promise","resolve","options","meta","_temp","rowActiveIndex","saveChanges","then","saved","_exit","_temp2","e","reject","React","useState","isDetailedMode","createRowButtonRef","useRef","lastFocusedCellIndex","usePendingChangesState","toggleEditing","enabled","scrollToIndex","_tableMeta$rowActive$","_table$getRowModel$ro","index","log","isTemporaryRow","getRowModel","rows","id"],"mappings":";;;;SAYgBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,YAA2D,EAC3DC,YAA2D,EAC3DC,aAAsD,EACtDC,mBAA4C,EAC5CC,SAAsD;QAmDvCC,SA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cAAc,KAAKd,SAAS,EAAE;QAClDQ,OAAO,CAAC2B,GAAG,CAAC,oBAAoB,EAAED,KAAK,CAAC;QACxCjD,SAAS,CAACiB,SAAS,CAACC,iBAAiB,CAAC+B,KAAK,CAAC;;MAGhD,IAAI,CAACE,cAAc,EAAAH,qBAAA,GAACpD,KAAK,CAACwD,WAAW,EAAE,CAACC,IAAI,CAACJ,KAAK,CAAC,cAAAD,qBAAA,uBAA/BA,qBAAA,CAAiCM,EAAE,CAAC,EAAE;QACtDR,aAAa,CAACG,KAAK,CAAC;;KAE3B,MAAM,IAAI,CAACJ,OAAO,EAAE;;MAEjBhC,kBAAkB,CAAC,KAAK,CAAC;;MAEzBC,uBAAuB,CAACC,SAAS,CAAC;;IAGtCM,UAAU,CAACwB,OAAO,CAAC;IACnBxC,iBAAiB,CAACyB,WAAW,CAAClC,KAAK,CAAC;;EAqDxC,OAAO;IACHR,SAAS;IACTgC,SAAS;IACTmB,cAAc;IACd1B,kBAAkB,EAAEzB,SAAS,GAAGyB,kBAAkB,GAAG,MAAME,SAAS;IACpE6B,aAAa,EAAExD,SAAS,GAAGwD,aAAa,GAAG,MAAM7B,SAAS;IAC1D2B,oBAAoB;IACpB5B,uBAAuB;IACvBnB,SAAS;IACT6C,kBAAkB;IAClB,GAAGnC;GACN;AACL;;;;"}
1
+ {"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n Table3EditingChangeHandler,\n Table3EditingCreateHandler,\n Table3EditingDiscardHandler,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n} from '../types';\nimport { usePendingChangesState } from './useEditingState';\nimport { isTemporaryRow } from '../util/editing';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n handleCreate: Table3EditingCreateHandler<TType> | undefined,\n handleDiscard: Table3EditingDiscardHandler | undefined,\n rowIdentityAccessor: keyof TType | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, setEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // used to contain ref to the create button\n const createRowButtonRef = React.useRef<HTMLButtonElement>(null);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = React.useState<number | undefined>(undefined);\n\n const pendingChangesFns = usePendingChangesState<TType>(\n handleSave,\n handleChange,\n handleDiscard,\n rowIdentityAccessor as keyof TType,\n validator\n );\n\n function toggleEditing<T extends TType>(\n enabled: React.SetStateAction<boolean>,\n table: ReactTable<T>,\n scrollToIndex: (index: number) => void\n ) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (enabled) {\n const index = tableMeta.rowActive.rowActiveIndex ?? 0;\n\n if (tableMeta.rowActive.rowActiveIndex === undefined) {\n tableMeta.rowActive.setRowActiveIndex(index);\n }\n\n if (!isTemporaryRow(table.getRowModel().rows[index]?.id)) {\n scrollToIndex(index);\n }\n } else if (!enabled) {\n // reset detailed mode\n toggleDetailedMode(false);\n // reset the last index back to the first focusable element, when editing gets turned off\n setLastFocusedCellIndex(undefined);\n }\n\n setEditing(enabled);\n pendingChangesFns.saveChanges(table);\n }\n\n async function createRow<T extends TType>(table: ReactTable<T>, row?: Partial<T>) {\n if (!handleCreate) {\n return;\n }\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n const saved = await tableMeta.editing.saveChanges(table);\n\n if (!saved) {\n return;\n }\n }\n\n const changeset = row ?? handleCreate();\n\n try {\n if (changeset) {\n // set the active row to the new row before toggling editing on\n const temporaryRows = tableMeta.editing.temporaryRows as TType[];\n const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;\n\n const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);\n\n // prep the row\n table.setRowPinning(currentState => ({\n ...currentState,\n bottom: (currentState.bottom ?? [])?.concat(newRowId),\n }));\n\n // prep editing mode\n toggleDetailedMode(false);\n setLastFocusedCellIndex(undefined);\n\n // wait until set states have run\n requestAnimationFrame(() => {\n tableMeta.rowActive.setRowActiveIndex(nextRowIndex);\n table.resetRowSelection();\n\n if (!tableMeta.editing.isEditing) {\n setEditing(true);\n }\n });\n }\n } catch (error) {\n console.error(error);\n }\n }\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n createRow,\n createRowButtonRef,\n ...pendingChangesFns,\n };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","handleChange","handleCreate","handleDiscard","rowIdentityAccessor","validator","createRow","table","row","changeset","temporaryRows","tableMeta","editing","nextRowIndex","length","newRowId","pendingChangesFns","insertTemporaryRow","setRowPinning","currentState","_ref","_currentState$bottom","bottom","concat","toggleDetailedMode","setLastFocusedCellIndex","undefined","requestAnimationFrame","rowActive","setRowActiveIndex","resetRowSelection","isEditing","setEditing","error","console","Promise","resolve","options","meta","_temp","rowActiveIndex","saveChanges","then","saved","_exit","_temp2","e","reject","React","useState","isDetailedMode","createRowButtonRef","useRef","lastFocusedCellIndex","usePendingChangesState","toggleEditing","enabled","scrollToIndex","_tableMeta$rowActive$","_table$getRowModel$ro","index","isTemporaryRow","getRowModel","rows","id"],"mappings":";;;;SAYgBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,YAA2D,EAC3DC,YAA2D,EAC3DC,aAAsD,EACtDC,mBAA4C,EAC5CC,SAAsD;QAkDvCC,SAAS,aAAkBC,KAAoB,EAAEC,GAAgB;IAAA;;;;QA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SAAS,CAACC,iBAAiB,CAAC+B,KAAK,CAAC;;MAGhD,IAAI,CAACC,cAAc,EAAAF,qBAAA,GAACpD,KAAK,CAACuD,WAAW,EAAE,CAACC,IAAI,CAACH,KAAK,CAAC,cAAAD,qBAAA,uBAA/BA,qBAAA,CAAiCK,EAAE,CAAC,EAAE;QACtDP,aAAa,CAACG,KAAK,CAAC;;KAE3B,MAAM,IAAI,CAACJ,OAAO,EAAE;;MAEjBhC,kBAAkB,CAAC,KAAK,CAAC;;MAEzBC,uBAAuB,CAACC,SAAS,CAAC;;IAGtCM,UAAU,CAACwB,OAAO,CAAC;IACnBxC,iBAAiB,CAACyB,WAAW,CAAClC,KAAK,CAAC;;EAqDxC,OAAO;IACHR,SAAS;IACTgC,SAAS;IACTmB,cAAc;IACd1B,kBAAkB,EAAEzB,SAAS,GAAGyB,kBAAkB,GAAG,MAAME,SAAS;IACpE6B,aAAa,EAAExD,SAAS,GAAGwD,aAAa,GAAG,MAAM7B,SAAS;IAC1D2B,oBAAoB;IACpB5B,uBAAuB;IACvBnB,SAAS;IACT6C,kBAAkB;IAClB,GAAGnC;GACN;AACL;;;;"}
@@ -1,7 +1,7 @@
1
- import { useState, useCallback, useEffect, createElement, useContext, createContext } from 'react';
1
+ import { useState, useCallback, useEffect, createElement, useContext, createContext, useLayoutEffect } from 'react';
2
2
  import { v4 } from 'uuid';
3
3
  import { AnimatePresence, motion } from 'framer-motion';
4
- import { Portal } from '@radix-ui/react-portal';
4
+ import ReactDOM from 'react-dom';
5
5
  import { Toast } from './Toast.js';
6
6
 
7
7
  const DEFAULT_AUTO_CLOSE_TIMEOUT = 7500;
@@ -21,6 +21,20 @@ const insertToastWithoutDuplicates = (currentToasts, id, content, options, close
21
21
  }
22
22
  return nextToasts;
23
23
  };
24
+ const Portal = props => {
25
+ var _globalThis$document;
26
+ const {
27
+ children,
28
+ container: containerProp,
29
+ ...portalProps
30
+ } = props;
31
+ const [mounted, setMounted] = useState(false);
32
+ useLayoutEffect(() => setMounted(true), []);
33
+ const container = containerProp || mounted && (globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body);
34
+ return container ? /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/createElement("div", Object.assign({}, portalProps, {
35
+ "data-taco": "portal"
36
+ }), children), container) : null;
37
+ };
24
38
  const ToastProvider = ({
25
39
  children,
26
40
  ...props
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.js","sources":["../../../../../../../src/components/Toast/Toaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { Portal } from '@radix-ui/react-portal';\n\nimport { ToastOptions, Toast, ToastProps, ToastContent } from './Toast';\nimport './Toast.css';\n\nconst DEFAULT_AUTO_CLOSE_TIMEOUT = 7500;\n\ntype ToastCreator<T> = (content: ToastContent | ((close: () => void) => ToastContent), options?: ToastOptions) => T;\n\nexport interface Toaster<T> extends ToastCreator<T> {\n success: ToastCreator<T>;\n error: ToastCreator<T>;\n warning: ToastCreator<T>;\n information: ToastCreator<T>;\n loading: ToastCreator<T>;\n}\n\nexport interface ToastReference {\n /** Show a success toast */\n success: ToastCreator<void>;\n /** Show an error toast */\n error: ToastCreator<void>;\n /** Show a warning toast */\n warning: ToastCreator<void>;\n /** Show an information toast */\n information: ToastCreator<void>;\n /** Show a loading toast */\n loading: ToastCreator<void>;\n /**\n * Close an existing toast.\n * The toast function returns a reference to the active toast,\n * allowing you to programmatically close it when needed\n */\n close: () => void;\n}\n\nconst ToastContext = React.createContext<Toaster<ToastReference>>({} as Toaster<ToastReference>);\n\nexport interface ToastProviderProps {\n children: React.ReactNode;\n}\n\ntype InternalToast = Omit<ToastProps, 'onClose'>;\n\nconst insertToastWithoutDuplicates = (\n currentToasts: InternalToast[],\n id: string,\n content: ToastContent,\n options: ToastOptions,\n close: () => void\n): InternalToast[] => {\n const nextToasts = [...currentToasts];\n const existingToastIndex = currentToasts.findIndex(toast => JSON.stringify(toast.content) === JSON.stringify(content));\n\n if (existingToastIndex > -1) {\n nextToasts[existingToastIndex].lastDuplicateId = id;\n nextToasts[existingToastIndex].lastUpdated = Date.now();\n } else {\n nextToasts.push({\n id,\n content: typeof content === 'function' ? content(close) : content,\n options,\n });\n }\n\n return nextToasts;\n};\n\nexport const ToastProvider = ({ children, ...props }: ToastProviderProps): JSX.Element => {\n const [toasts, setToasts] = React.useState<InternalToast[]>([]);\n\n const handleClose = (id: string): void => {\n setToasts(currentToasts => currentToasts.filter(toast => toast.id !== id));\n };\n\n // memoize (useCallback) this function,\n // it is the value of the context provider and we don't want it to trigger state tree re-renders on provider children\n const toaster = React.useCallback((content: ToastContent, options: ToastOptions): ToastReference => {\n const id = uuid();\n const close = (): void => handleClose(id);\n\n setToasts(currentToasts => insertToastWithoutDuplicates(currentToasts, id, content, options, close));\n\n const update = (content: ToastContent, options: ToastOptions): void => {\n setToasts(currentToasts => {\n const nextToasts = currentToasts.filter(toast => {\n if (toast.lastDuplicateId) {\n return toast.lastDuplicateId !== id;\n }\n\n return toast.id !== id;\n });\n return insertToastWithoutDuplicates(nextToasts, uuid(), content, options, close);\n });\n };\n\n const success = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT, ...options, type: 'success' });\n };\n const error = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'error' });\n };\n const warning = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'warning' });\n };\n const information = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'information' });\n };\n const loading = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'loading' });\n };\n\n return {\n success,\n error,\n warning,\n information,\n loading,\n close,\n };\n }, []) as Toaster<ToastReference>;\n\n // no need to rebind these every render, do them once in an effect\n React.useEffect(() => {\n toaster.success = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT, ...options, type: 'success' });\n toaster.error = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'error' });\n toaster.warning = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'warning' });\n toaster.information = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'information' });\n toaster.loading = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'loading' });\n }, []);\n\n return (\n <ToastContext.Provider {...props} value={toaster}>\n {children}\n <Portal>\n <div\n id=\"yt-toast__container\"\n className=\"pointer-events-all absolute !left-auto bottom-0 right-0 z-[1000] mb-4 mr-4 flex max-w-md flex-col items-end justify-end\"\n role=\"log\">\n <AnimatePresence initial={false}>\n {toasts.map((toast: InternalToast) => (\n <motion.div\n key={toast.id}\n transition={{\n type: 'spring',\n damping: 20,\n stiffness: 300,\n }}\n initial={{ opacity: 0, y: 10, scale: 0.5 }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{ opacity: 0, scale: 0.5, transition: { duration: 0.2 } }}>\n <Toast {...toast} onClose={() => handleClose(toast.id)} />\n </motion.div>\n ))}\n </AnimatePresence>\n </div>\n </Portal>\n </ToastContext.Provider>\n );\n};\n\nexport const useToast = (): Toaster<ToastReference> => React.useContext(ToastContext);\n"],"names":["DEFAULT_AUTO_CLOSE_TIMEOUT","ToastContext","React","insertToastWithoutDuplicates","currentToasts","id","content","options","close","nextToasts","existingToastIndex","findIndex","toast","JSON","stringify","lastDuplicateId","lastUpdated","Date","now","push","ToastProvider","children","props","toasts","setToasts","handleClose","filter","toaster","uuid","update","success","autoClose","type","error","warning","information","loading","Provider","value","Portal","className","role","AnimatePresence","initial","map","motion","div","key","transition","damping","stiffness","opacity","y","scale","animate","exit","duration","Toast","onClose","useToast"],"mappings":";;;;;;AAQA,MAAMA,0BAA0B,GAAG,IAAI;AA+BvC,MAAMC,YAAY,gBAAGC,aAAmB,CAA0B,EAA6B,CAAC;AAQhG,MAAMC,4BAA4B,GAAGA,CACjCC,aAA8B,EAC9BC,EAAU,EACVC,OAAqB,EACrBC,OAAqB,EACrBC,KAAiB;EAEjB,MAAMC,UAAU,GAAG,CAAC,GAAGL,aAAa,CAAC;EACrC,MAAMM,kBAAkB,GAAGN,aAAa,CAACO,SAAS,CAACC,KAAK,IAAIC,IAAI,CAACC,SAAS,CAACF,KAAK,CAACN,OAAO,CAAC,KAAKO,IAAI,CAACC,SAAS,CAACR,OAAO,CAAC,CAAC;EAEtH,IAAII,kBAAkB,GAAG,CAAC,CAAC,EAAE;IACzBD,UAAU,CAACC,kBAAkB,CAAC,CAACK,eAAe,GAAGV,EAAE;IACnDI,UAAU,CAACC,kBAAkB,CAAC,CAACM,WAAW,GAAGC,IAAI,CAACC,GAAG,EAAE;GAC1D,MAAM;IACHT,UAAU,CAACU,IAAI,CAAC;MACZd,EAAE;MACFC,OAAO,EAAE,OAAOA,OAAO,KAAK,UAAU,GAAGA,OAAO,CAACE,KAAK,CAAC,GAAGF,OAAO;MACjEC;KACH,CAAC;;EAGN,OAAOE,UAAU;AACrB,CAAC;MAEYW,aAAa,GAAGA,CAAC;EAAEC,QAAQ;EAAE,GAAGC;CAA2B;EACpE,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGtB,QAAc,CAAkB,EAAE,CAAC;EAE/D,MAAMuB,WAAW,GAAIpB,EAAU;IAC3BmB,SAAS,CAACpB,aAAa,IAAIA,aAAa,CAACsB,MAAM,CAACd,KAAK,IAAIA,KAAK,CAACP,EAAE,KAAKA,EAAE,CAAC,CAAC;GAC7E;;;EAID,MAAMsB,OAAO,GAAGzB,WAAiB,CAAC,CAACI,OAAqB,EAAEC,OAAqB;IA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mC,SAAS,EAAC,yHAAyH;IACnIC,IAAI,EAAC;kBACLvC,cAACwC,eAAe;IAACC,OAAO,EAAE;KACrBpB,MAAM,CAACqB,GAAG,CAAEhC,KAAoB,kBAC7BV,cAAC2C,MAAM,CAACC,GAAG;IACPC,GAAG,EAAEnC,KAAK,CAACP,EAAE;IACb2C,UAAU,EAAE;MACRhB,IAAI,EAAE,QAAQ;MACdiB,OAAO,EAAE,EAAE;MACXC,SAAS,EAAE;KACd;IACDP,OAAO,EAAE;MAAEQ,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAE,EAAE;MAAEC,KAAK,EAAE;KAAK;IAC1CC,OAAO,EAAE;MAAEH,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEC,KAAK,EAAE;KAAG;IACvCE,IAAI,EAAE;MAAEJ,OAAO,EAAE,CAAC;MAAEE,KAAK,EAAE,GAAG;MAAEL,UAAU,EAAE;QAAEQ,QAAQ,EAAE;;;kBACxDtD,cAACuD,KAAK,oBAAK7C,KAAK;IAAE8C,OAAO,EAAEA,MAAMjC,WAAW,CAACb,KAAK,CAACP,EAAE;KAAK,CACjD,CAChB,CAAC,CACY,CAChB,CACD,CACW;AAEhC;MAEasD,QAAQ,GAAGA,MAA+BzD,UAAgB,CAACD,YAAY;;;;"}
1
+ {"version":3,"file":"Toaster.js","sources":["../../../../../../../src/components/Toast/Toaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport ReactDOM from 'react-dom';\nimport { v4 as uuid } from 'uuid';\nimport { AnimatePresence, motion } from 'framer-motion';\n\nimport { ToastOptions, Toast, ToastProps, ToastContent } from './Toast';\nimport './Toast.css';\n\nconst DEFAULT_AUTO_CLOSE_TIMEOUT = 7500;\n\ntype ToastCreator<T> = (content: ToastContent | ((close: () => void) => ToastContent), options?: ToastOptions) => T;\n\nexport interface Toaster<T> extends ToastCreator<T> {\n success: ToastCreator<T>;\n error: ToastCreator<T>;\n warning: ToastCreator<T>;\n information: ToastCreator<T>;\n loading: ToastCreator<T>;\n}\n\nexport interface ToastReference {\n /** Show a success toast */\n success: ToastCreator<void>;\n /** Show an error toast */\n error: ToastCreator<void>;\n /** Show a warning toast */\n warning: ToastCreator<void>;\n /** Show an information toast */\n information: ToastCreator<void>;\n /** Show a loading toast */\n loading: ToastCreator<void>;\n /**\n * Close an existing toast.\n * The toast function returns a reference to the active toast,\n * allowing you to programmatically close it when needed\n */\n close: () => void;\n}\n\nconst ToastContext = React.createContext<Toaster<ToastReference>>({} as Toaster<ToastReference>);\n\nexport interface ToastProviderProps {\n children: React.ReactNode;\n}\n\ntype InternalToast = Omit<ToastProps, 'onClose'>;\n\nconst insertToastWithoutDuplicates = (\n currentToasts: InternalToast[],\n id: string,\n content: ToastContent,\n options: ToastOptions,\n close: () => void\n): InternalToast[] => {\n const nextToasts = [...currentToasts];\n const existingToastIndex = currentToasts.findIndex(toast => JSON.stringify(toast.content) === JSON.stringify(content));\n\n if (existingToastIndex > -1) {\n nextToasts[existingToastIndex].lastDuplicateId = id;\n nextToasts[existingToastIndex].lastUpdated = Date.now();\n } else {\n nextToasts.push({\n id,\n content: typeof content === 'function' ? content(close) : content,\n options,\n });\n }\n\n return nextToasts;\n};\n\ntype PortalProps = React.ComponentPropsWithRef<'div'> & {\n container?: Element | DocumentFragment | null;\n};\n\nconst Portal = (props: PortalProps) => {\n const { children, container: containerProp, ...portalProps } = props;\n\n const [mounted, setMounted] = React.useState(false);\n React.useLayoutEffect(() => setMounted(true), []);\n const container = containerProp || (mounted && globalThis?.document?.body);\n\n return container\n ? ReactDOM.createPortal(\n <div {...portalProps} data-taco=\"portal\">\n {children}\n </div>,\n container\n )\n : null;\n};\n\nexport const ToastProvider = ({ children, ...props }: ToastProviderProps): JSX.Element => {\n const [toasts, setToasts] = React.useState<InternalToast[]>([]);\n\n const handleClose = (id: string): void => {\n setToasts(currentToasts => currentToasts.filter(toast => toast.id !== id));\n };\n\n // memoize (useCallback) this function,\n // it is the value of the context provider and we don't want it to trigger state tree re-renders on provider children\n const toaster = React.useCallback((content: ToastContent, options: ToastOptions): ToastReference => {\n const id = uuid();\n const close = (): void => handleClose(id);\n\n setToasts(currentToasts => insertToastWithoutDuplicates(currentToasts, id, content, options, close));\n\n const update = (content: ToastContent, options: ToastOptions): void => {\n setToasts(currentToasts => {\n const nextToasts = currentToasts.filter(toast => {\n if (toast.lastDuplicateId) {\n return toast.lastDuplicateId !== id;\n }\n\n return toast.id !== id;\n });\n return insertToastWithoutDuplicates(nextToasts, uuid(), content, options, close);\n });\n };\n\n const success = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT, ...options, type: 'success' });\n };\n const error = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'error' });\n };\n const warning = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'warning' });\n };\n const information = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'information' });\n };\n const loading = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): void => {\n update(content, { ...options, type: 'loading' });\n };\n\n return {\n success,\n error,\n warning,\n information,\n loading,\n close,\n };\n }, []) as Toaster<ToastReference>;\n\n // no need to rebind these every render, do them once in an effect\n React.useEffect(() => {\n toaster.success = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT, ...options, type: 'success' });\n toaster.error = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'error' });\n toaster.warning = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'warning' });\n toaster.information = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'information' });\n toaster.loading = (content: ToastContent, options?: Omit<ToastOptions, 'type'>): ToastReference =>\n toaster(content, { ...options, type: 'loading' });\n }, []);\n\n return (\n <ToastContext.Provider {...props} value={toaster}>\n {children}\n <Portal>\n <div\n id=\"yt-toast__container\"\n className=\"pointer-events-all absolute !left-auto bottom-0 right-0 z-[1000] mb-4 mr-4 flex max-w-md flex-col items-end justify-end\"\n role=\"log\">\n <AnimatePresence initial={false}>\n {toasts.map((toast: InternalToast) => (\n <motion.div\n key={toast.id}\n transition={{\n type: 'spring',\n damping: 20,\n stiffness: 300,\n }}\n initial={{ opacity: 0, y: 10, scale: 0.5 }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={{ opacity: 0, scale: 0.5, transition: { duration: 0.2 } }}>\n <Toast {...toast} onClose={() => handleClose(toast.id)} />\n </motion.div>\n ))}\n </AnimatePresence>\n </div>\n </Portal>\n </ToastContext.Provider>\n );\n};\n\nexport const useToast = (): Toaster<ToastReference> => React.useContext(ToastContext);\n"],"names":["DEFAULT_AUTO_CLOSE_TIMEOUT","ToastContext","React","insertToastWithoutDuplicates","currentToasts","id","content","options","close","nextToasts","existingToastIndex","findIndex","toast","JSON","stringify","lastDuplicateId","lastUpdated","Date","now","push","Portal","props","children","container","containerProp","portalProps","mounted","setMounted","globalThis","_globalThis$document","document","body","ReactDOM","createPortal","ToastProvider","toasts","setToasts","handleClose","filter","toaster","uuid","update","success","autoClose","type","error","warning","information","loading","Provider","value","className","role","AnimatePresence","initial","map","motion","div","key","transition","damping","stiffness","opacity","y","scale","animate","exit","duration","Toast","onClose","useToast"],"mappings":";;;;;;AAQA,MAAMA,0BAA0B,GAAG,IAAI;AA+BvC,MAAMC,YAAY,gBAAGC,aAAmB,CAA0B,EAA6B,CAAC;AAQhG,MAAMC,4BAA4B,GAAGA,CACjCC,aAA8B,EAC9BC,EAAU,EACVC,OAAqB,EACrBC,OAAqB,EACrBC,KAAiB;EAEjB,MAAMC,UAAU,GAAG,CAAC,GAAGL,aAAa,CAAC;EACrC,MAAMM,kBAAkB,GAAGN,aAAa,CAACO,SAAS,CA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qC,IAAI,EAAE;KAAW,CAAC;GACxD,EAAE,EAAE,CAAC;EAEN,oBACI1C,cAACD,YAAY,CAACgD,QAAQ,oBAAK5B,KAAK;IAAE6B,KAAK,EAAEX;MACpCjB,QAAQ,eACTpB,cAACkB,MAAM,qBACHlB;IACIG,EAAE,EAAC,qBAAqB;IACxB8C,SAAS,EAAC,yHAAyH;IACnIC,IAAI,EAAC;kBACLlD,cAACmD,eAAe;IAACC,OAAO,EAAE;KACrBnB,MAAM,CAACoB,GAAG,CAAE3C,KAAoB,kBAC7BV,cAACsD,MAAM,CAACC,GAAG;IACPC,GAAG,EAAE9C,KAAK,CAACP,EAAE;IACbsD,UAAU,EAAE;MACRf,IAAI,EAAE,QAAQ;MACdgB,OAAO,EAAE,EAAE;MACXC,SAAS,EAAE;KACd;IACDP,OAAO,EAAE;MAAEQ,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAE,EAAE;MAAEC,KAAK,EAAE;KAAK;IAC1CC,OAAO,EAAE;MAAEH,OAAO,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEC,KAAK,EAAE;KAAG;IACvCE,IAAI,EAAE;MAAEJ,OAAO,EAAE,CAAC;MAAEE,KAAK,EAAE,GAAG;MAAEL,UAAU,EAAE;QAAEQ,QAAQ,EAAE;;;kBACxDjE,cAACkE,KAAK,oBAAKxD,KAAK;IAAEyD,OAAO,EAAEA,MAAMhC,WAAW,CAACzB,KAAK,CAACP,EAAE;KAAK,CACjD,CAChB,CAAC,CACY,CAChB,CACD,CACW;AAEhC;MAEaiE,QAAQ,GAAGA,MAA+BpE,UAAgB,CAACD,YAAY;;;;"}
@@ -1,31 +1,42 @@
1
1
  import React__default from 'react';
2
2
  import { flexRender } from '@tanstack/react-table';
3
+ import { isInternalColumn } from '../../../useTableManager/util/columns.js';
3
4
  import { Summary } from './Summary.js';
4
5
 
5
6
  function Foot(props) {
7
+ var _nonGroupedHeaders$fi;
6
8
  const {
7
9
  children,
8
10
  table,
9
11
  ...attributes
10
12
  } = props;
13
+ const tableMeta = table.options.meta;
11
14
  const nonGroupedHeaders = table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());
15
+ const firstVisibleExternalColumnIndex = (_nonGroupedHeaders$fi = nonGroupedHeaders.find(header => {
16
+ var _header$column$column;
17
+ return !isInternalColumn(header.id) && ((_header$column$column = header.column.columnDef.meta) === null || _header$column$column === void 0 ? void 0 : _header$column$column.enablePrinting) !== false;
18
+ })) === null || _nonGroupedHeaders$fi === void 0 ? void 0 : _nonGroupedHeaders$fi.index;
19
+ // During printing, the summary should be displayed in the first visible external column,
20
+ // as internal and hidden columns are excluded from the printed document.
21
+ // However, in the normal table view, the summary should appear in the first column.
22
+ const summaryColumnIndex = tableMeta.printing.isPrinting ? firstVisibleExternalColumnIndex : 0;
12
23
  return /*#__PURE__*/React__default.createElement("tfoot", Object.assign({}, attributes), children, /*#__PURE__*/React__default.createElement("tr", null, nonGroupedHeaders.map((header, index) => (/*#__PURE__*/React__default.createElement(Footer, {
13
24
  key: header.id,
14
25
  header: header,
15
- index: index
26
+ showSummary: index === summaryColumnIndex
16
27
  })))));
17
28
  }
18
29
  function Footer(props) {
19
30
  return /*#__PURE__*/React__default.createElement(MemoedFooter, {
20
31
  footer: props.header,
21
- index: props.index
32
+ showSummary: props.showSummary
22
33
  });
23
34
  }
24
35
  const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(props) {
25
36
  var _footer$subHeaders, _footer$subHeaders$fi;
26
37
  const {
27
38
  footer,
28
- index
39
+ showSummary
29
40
  } = props;
30
41
  const columnMeta = footer.column.columnDef.meta;
31
42
  // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers
@@ -38,7 +49,8 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
38
49
  }
39
50
  let content;
40
51
  let align;
41
- if (index === 0) {
52
+ // Summary should only be appended to the first visible external column, as internal columns like the select column will be hidden in the print view.
53
+ if (showSummary) {
42
54
  align = 'left';
43
55
  content = /*#__PURE__*/React__default.createElement(Summary, {
44
56
  table: footer.getContext().table
@@ -1 +1 @@
1
- {"version":3,"file":"Footer.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Header as ReactTableHeader,\n ColumnMeta as ReactTableColumnMeta,\n flexRender,\n Table as ReactTable,\n} from '@tanstack/react-table';\nimport { Summary } from './Summary';\n\nexport type FootProps<TType = unknown> = React.HTMLAttributes<HTMLTableSectionElement> & {\n table: ReactTable<TType>;\n};\nexport function Foot<TType = unknown>(props: FootProps<TType>) {\n const { children, table, ...attributes } = props;\n const nonGroupedHeaders = table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());\n return (\n <tfoot {...attributes}>\n {children}\n <tr>\n {nonGroupedHeaders.map((header, index) => (\n <Footer key={header.id} header={header} index={index} />\n ))}\n </tr>\n </tfoot>\n );\n}\n\nexport type FooterProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n index: number;\n};\nexport function Footer<TType = unknown>(props: FooterProps<TType>) {\n return <MemoedFooter footer={props.header} index={props.index} />;\n}\n\nexport type MemoedFooterProps<TType = unknown> = {\n footer: ReactTableHeader<TType, unknown>;\n index: number;\n};\nconst MemoedFooter = React.memo(function MemoedFooter<TType = unknown>(props: MemoedFooterProps<TType>) {\n const { footer, index } = props;\n const columnMeta = footer.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers\n const isHeaderGroup = !!footer.subHeaders?.length;\n const isPinned = isHeaderGroup\n ? footer.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : footer.column.getIsPinned();\n\n const style: React.CSSProperties = {};\n\n if (isPinned) {\n // pinned columns should be offset from either the left or right\n style[isPinned] = `${footer.column.getStart(isPinned)}px`;\n }\n\n let content;\n let align;\n\n if (index === 0) {\n align = 'left';\n content = <Summary table={footer.getContext().table} />;\n } else {\n align = columnMeta.align;\n content = footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext());\n }\n\n return (\n <td\n key={footer.id}\n data-cell-align={align}\n data-cell-id={footer.id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}>\n {content}\n </td>\n );\n}) as <TType = unknown>(props: MemoedFooterProps<TType>) => JSX.Element;\n"],"names":["Foot","props","children","table","attributes","nonGroupedHeaders","getFooterGroups","headers","filter","header","column","getIsGrouped","React","map","index","Footer","key","id","MemoedFooter","footer","memo","columnMeta","columnDef","meta","isHeaderGroup","_footer$subHeaders","subHeaders","length","isPinned","_footer$subHeaders$fi","find","x","getIsPinned","style","getStart","content","align","Summary","getContext","isPlaceholder","flexRender","undefined"],"mappings":";;;;SAYgBA,IAAIA,CAAkBC,KAAuB;EACzD,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGH,KAAK;EAChD,MAAMI,iBAAiB,GAAGF,KAAK,CAACG,eAAe,EAAE,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,MAAM,CAACC,MAAM,IAAI,CAACA,MAAM,CAACC,MAAM,CAACC,YAAY,EAAE,CAAC;EAC5G,oBACIC,wDAAWR,UAAU,GAChBF,QAAQ,eACTU,yCACKP,iBAAiB,CAACQ,GAAG,CAAC,CAACJ,MAAM,EAAEK,KAAK,mBACjCF,6BAACG,MAAM;IAACC,GAAG,EAAEP,MAAM,CAACQ,EAAE;IAAER,MAAM,EAAEA,MAAM;IAAEK,KAAK,EAAEA;IAAS,CAC3D,CAAC,CACD,CACD;AAEhB;SAMgBC,MAAMA,CAAkBd,KAAyB;EAC7D,oBAAOW,6BAACM,YAAY;IAACC,MAAM,EAAElB,KAAK,CAACQ,MAAM;IAAEK,KAAK,EAAEb,KAAK,CAACa;IAAS;AACrE;AAMA,MAAMI,YAAY,gBAAGN,cAAK,CAACQ,IAAI,CAAC,SAASF,YAAYA,CAAkBjB,KAA+B;;EAClG,MAAM;IAAEkB,MAAM;IA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E;;;;"}
1
+ {"version":3,"file":"Footer.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Header as ReactTableHeader,\n ColumnMeta as ReactTableColumnMeta,\n flexRender,\n Table as ReactTable,\n TableMeta as ReactTableMeta,\n} from '@tanstack/react-table';\n\nimport { Summary } from './Summary';\nimport { isInternalColumn } from '../../../useTableManager/util/columns';\n\nexport type FootProps<TType = unknown> = React.HTMLAttributes<HTMLTableSectionElement> & {\n table: ReactTable<TType>;\n};\nexport function Foot<TType = unknown>(props: FootProps<TType>) {\n const { children, table, ...attributes } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const nonGroupedHeaders = table.getFooterGroups()[0].headers.filter(header => !header.column.getIsGrouped());\n const firstVisibleExternalColumnIndex = nonGroupedHeaders.find(\n header => !isInternalColumn(header.id) && header.column.columnDef.meta?.enablePrinting !== false\n )?.index;\n\n // During printing, the summary should be displayed in the first visible external column,\n // as internal and hidden columns are excluded from the printed document.\n // However, in the normal table view, the summary should appear in the first column.\n const summaryColumnIndex = tableMeta.printing.isPrinting ? firstVisibleExternalColumnIndex : 0;\n\n return (\n <tfoot {...attributes}>\n {children}\n <tr>\n {nonGroupedHeaders.map((header, index) => (\n <Footer key={header.id} header={header} showSummary={index === summaryColumnIndex} />\n ))}\n </tr>\n </tfoot>\n );\n}\n\nexport type FooterProps<TType = unknown> = {\n header: ReactTableHeader<TType, unknown>;\n showSummary: boolean;\n};\nexport function Footer<TType = unknown>(props: FooterProps<TType>) {\n return <MemoedFooter footer={props.header} showSummary={props.showSummary} />;\n}\n\nexport type MemoedFooterProps<TType = unknown> = {\n footer: ReactTableHeader<TType, unknown>;\n showSummary: boolean;\n};\n\nconst MemoedFooter = React.memo(function MemoedFooter<TType = unknown>(props: MemoedFooterProps<TType>) {\n const { footer, showSummary } = props;\n const columnMeta = footer.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n\n // getIsPinned returns true for split header groups, even if the split group has no pinned sub headers\n const isHeaderGroup = !!footer.subHeaders?.length;\n const isPinned = isHeaderGroup\n ? footer.subHeaders.find(x => x.column.getIsPinned())?.column.getIsPinned()\n : footer.column.getIsPinned();\n\n const style: React.CSSProperties = {};\n\n if (isPinned) {\n // pinned columns should be offset from either the left or right\n style[isPinned] = `${footer.column.getStart(isPinned)}px`;\n }\n\n let content;\n let align;\n\n // Summary should only be appended to the first visible external column, as internal columns like the select column will be hidden in the print view.\n if (showSummary) {\n align = 'left';\n content = <Summary table={footer.getContext().table} />;\n } else {\n align = columnMeta.align;\n content = footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext());\n }\n\n return (\n <td\n key={footer.id}\n data-cell-align={align}\n data-cell-id={footer.id}\n data-cell-pinned={isPinned ? isPinned : undefined}\n style={style}>\n {content}\n </td>\n );\n}) as <TType = unknown>(props: MemoedFooterProps<TType>) => JSX.Element;\n"],"names":["Foot","props","children","table","attributes","tableMeta","options","meta","nonGroupedHeaders","getFooterGroups","headers","filter","header","column","getIsGrouped","firstVisibleExternalColumnIndex","_nonGroupedHeaders$fi","find","_header$column$column","isInternalColumn","id","columnDef","enablePrinting","index","summaryColumnIndex","printing","isPrinting","React","map","Footer","key","showSummary","MemoedFooter","footer","memo","columnMeta","isHeaderGroup","_footer$subHeaders","subHeaders","length","isPinned","_footer$subHeaders$fi","x","getIsPinned","style","getStart","content","align","Summary","getContext","isPlaceholder","flexRender","undefined"],"mappings":";;;;;SAegBA,IAAIA,CAAkBC,KAAuB;;EACzD,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGH,KAAK;EAChD,MAAMI,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,eAAe,EAAE,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,MAAM,CAACC,MAAM,IAAI,CAACA,MAAM,CAACC,MAAM,CAACC,YAA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