@economic/taco 2.45.2 → 2.45.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -172,10 +172,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
172
172
  }
173
173
  return;
174
174
  }
175
- const shortcutWhitelist = ['f', 'p', 'e']; // f = search, p = print, and e = edit
176
- if (isPressingMetaKey(event) && !shortcutWhitelist.some(s => s === event.key)) {
177
- event.stopPropagation();
178
- }
179
175
  // toggle into detailed mode when actually inputting something
180
176
  if (!isPressingMetaKey(event) && (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace')) {
181
177
  toggleDetailedMode(true);
@@ -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 tableMeta = cell.getContext().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\n const handleFocus = useEditingCellAutofocus<TType>(props);\n\n const handleBlur = () => {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.validateCell(cell);\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 handleBlur();\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: (value: unknown) => tableMeta.editing.setCellValue(cell, value, rowIndex),\n row: cell.row.original,\n rowPendingChanges: tableMeta.editing.getRowPendingChange(cell.row.id),\n tabIndex: isActiveRow ? 0 : -1,\n toggleEditing: tableMeta.editing.toggleEditing,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type: columnMeta.control ?? 'input',\n value: cell.getValue(),\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: () => void;\n onChange: (value: TValue) => void;\n row: TType;\n rowPendingChanges: Partial<TType> | undefined;\n tabIndex?: number;\n toggleEditing: (editing: React.SetStateAction<boolean>) => void;\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 toggleEditing,\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 event.preventDefault();\n\n if (isDetailedMode) {\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 } else {\n toggleEditing(false);\n }\n\n return;\n }\n\n const shortcutWhitelist = ['f', 'p', 'e']; // f = search, p = print, and e = edit\n\n if (isPressingMetaKey(event) && !shortcutWhitelist.some(s => s === event.key)) {\n event.stopPropagation();\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 return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\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","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","handleFocus","useEditingCellAutofocus","handleBlur","editing","toggleDetailedMode","validateCell","useEffect","ref","current","document","activeElement","isElementInsideOrTriggeredFromContainer","error","getCellError","controlProps","dataType","fontSize","size","id","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","value","setCellValue","row","original","rowPendingChanges","getRowPendingChange","tabIndex","toggleEditing","type","_columnMeta$control","control","getValue","cellAttributes","getCellAttributes","undefined","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","controlFnProps","setValue","Switch","checked","Boolean","Checkbox","handleInputKeyDown","event","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","requestAnimationFrame","_target$select2","shortcutWhitelist","isPressingMetaKey","some","s","test","valueAsDate","date","handleChange","newDate","detail","isDate","Datepicker","onKeyDown","TextareaWithAutosizing","String","Number","parseInt","Input"],"mappings":";;;;;;;;;;;;;;;;SAmBgBA,kBAAkBA,CAAkBC,KAAoC;;EACpF,MAAM;I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,EAAEuC,UAA+C;MACpDrB,KAAK,EAAEsD;OACT;;EAIV,IAAI9C,IAAI,KAAK,UAAU,EAAE;IACrB,MAAMgD,YAAY,GAAIxB,KAA6C;MAC/DjC,QAAQ,CAACiC,KAAK,CAACC,MAAM,CAACjC,KAAK,CAAC;KAC/B;IAED,oBACIvC,6BAACqG,sBAAsB,oBACftC,WAAW;MACfjC,QAAQ,EAAEA,QAAQ;MAClBG,OAAO,EAAEA,OAAO;MAChBE,WAAW,EAAEA,WAAW;MACxBG,QAAQ,EAAEyD,YAAY;MACtBzC,OAAO,EAAExC,WAAW;MACpBsF,SAAS,EAAE9B,kBAAkB;MAC7BjD,GAAG,EAAEuC,UAAkD;MACvDrB,KAAK,EAAE+D,MAAM,CAAC/D,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;OAC3B;;EAIV,MAAMwD,YAAY,GAAIxB,KAA0C;IAC5DjC,QAAQ,CAACT,QAAQ,KAAK,QAAQ,IAAI0C,KAAK,CAACC,MAAM,CAACjC,KAAK,GAAGgE,MAAM,CAACC,QAAQ,CAACjC,KAAK,CAACC,MAAM,CAACjC,KAAK,CAAC,GAAGgC,KAAK,CAACC,MAAM,CAACjC,KAAK,CAAC;GACnH;EAED,oBACIvC,6BAACyG,KAAK,oBACE1C,WAAW;IACf9B,OAAO,EAAEA,OAAO;IAChBK,QAAQ,EAAEyD,YAAY;IACtBzC,OAAO,EAAExC,WAAW;IACpBsF,SAAS,EAAE9B,kBAAkB;IAC7BjD,GAAG,EAAEuC,UAA+C;IACpDb,IAAI,EAAElB,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAGwB,SAAS;IAClDd,KAAK,EAAEV,QAAQ,KAAK,QAAQ,GAAIU,KAAgB,GAAG+D,MAAM,CAAC/D,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 tableMeta = cell.getContext().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\n const handleFocus = useEditingCellAutofocus<TType>(props);\n\n const handleBlur = () => {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.validateCell(cell);\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 handleBlur();\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: (value: unknown) => tableMeta.editing.setCellValue(cell, value, rowIndex),\n row: cell.row.original,\n rowPendingChanges: tableMeta.editing.getRowPendingChange(cell.row.id),\n tabIndex: isActiveRow ? 0 : -1,\n toggleEditing: tableMeta.editing.toggleEditing,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type: columnMeta.control ?? 'input',\n value: cell.getValue(),\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: () => void;\n onChange: (value: TValue) => void;\n row: TType;\n rowPendingChanges: Partial<TType> | undefined;\n tabIndex?: number;\n toggleEditing: (editing: React.SetStateAction<boolean>) => void;\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 toggleEditing,\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 event.preventDefault();\n\n if (isDetailedMode) {\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 } else {\n toggleEditing(false);\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 return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\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","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","handleFocus","useEditingCellAutofocus","handleBlur","editing","toggleDetailedMode","validateCell","useEffect","ref","current","document","activeElement","isElementInsideOrTriggeredFromContainer","error","getCellError","controlProps","dataType","fontSize","size","id","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","value","setCellValue","row","original","rowPendingChanges","getRowPendingChange","tabIndex","toggleEditing","type","_columnMeta$control","control","getValue","cellAttributes","getCellAttributes","undefined","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","controlFnProps","setValue","Switch","checked","Boolean","Checkbox","handleInputKeyDown","event","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","requestAnimationFrame","_target$select2","isPressingMetaKey","test","valueAsDate","date","handleChange","newDate","detail","isDate","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,MAAMC,SAAS,GAAGR,IAAI,CAACS,UAAU,EAAE,CAACC,KAAK,CAACC,OAAO,CAACC,IAA6B;EAC/E,MAAMC,UAAU,GAAGb,IAAI,CAACc,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,WAAW,GAAGR,SAAS,CAACS,SAAS,CAACC,cAAc,KAAKd,QAAQ;EAEnE,MAAMe,WAAW,GAAGC,uBAAuB,CAAQrB,KAAK,CAAC;EAEzD,MAAMsB,UAAU,GAAGA;IACfb,SAAS,CAACc,OAAO,CAACC,kBAAkB,CAAC,KAAK,CAAC;IAC3Cf,SAAS,CAACc,OAAO,CAACE,YAAY,CAACxB,IAAI,CAAC;GACvC;;EAGDK,cAAK,CAACo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AAQ,EAAEsD,YAAY;IACtBtC,OAAO,EAAExC,WAAW;IACpBmF,SAAS,EAAE3B,kBAAkB;IAC7BjD,GAAG,EAAEuC,UAA+C;IACpDb,IAAI,EAAElB,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAGwB,SAAS;IAClDd,KAAK,EAAEV,QAAQ,KAAK,QAAQ,GAAIU,KAAgB,GAAG4D,MAAM,CAAC5D,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KACvE;AAEV,CAAC,CAA2E;;;;"}
@@ -3,6 +3,7 @@ import React__default from 'react';
3
3
  function useTableRowSelection(isEnabled = false) {
4
4
  const lastSelectedRowIndex = React__default.useRef();
5
5
  const onKeyDown = React__default.useCallback((event, table) => {
6
+ var _event$target;
6
7
  if (!isEnabled || !table.options.enableRowSelection || event.defaultPrevented) {
7
8
  return;
8
9
  }
@@ -17,7 +18,7 @@ function useTableRowSelection(isEnabled = false) {
17
18
  (_rows$rowActiveIndex2 = rows[rowActiveIndex]) === null || _rows$rowActiveIndex2 === void 0 ? void 0 : _rows$rowActiveIndex2.toggleSelected();
18
19
  }
19
20
  return;
20
- } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
21
+ } else if ((event.ctrlKey || event.metaKey) && event.key === 'a' && !['INPUT', 'TEXTAREA'].includes((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName)) {
21
22
  event.preventDefault();
22
23
  table.toggleAllRowsSelected();
23
24
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRowSelection.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowSelection.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\n\nexport function useTableRowSelection(isEnabled = false) {\n const lastSelectedRowIndex = React.useRef<number>();\n\n const onKeyDown = React.useCallback(\n <TType = unknown>(event: KeyboardEvent, table: ReactTable<TType>) => {\n if (!isEnabled || !table.options.enableRowSelection || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (event.key === ' ') {\n event.preventDefault();\n const rowActiveIndex = tableMeta.rowActive.rowActiveIndex;\n\n if (rowActiveIndex !== undefined && rows[rowActiveIndex]?.getCanSelect()) {\n rows[rowActiveIndex]?.toggleSelected();\n }\n\n return;\n } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {\n event.preventDefault();\n table.toggleAllRowsSelected();\n return;\n }\n },\n [isEnabled]\n ) as <TType = unknown>(event: KeyboardEvent, table: ReactTable<TType>) => void;\n\n return {\n isEnabled,\n handleKeyDown: isEnabled ? onKeyDown : () => undefined,\n lastSelectedRowIndex,\n };\n}\n"],"names":["useTableRowSelection","isEnabled","lastSelectedRowIndex","React","useRef","onKeyDown","useCallback","event","table","options","enableRowSelection","defaultPrevented","rows","getRowModel","tableMeta","meta","key","_rows$rowActiveIndex","preventDefault","rowActiveIndex","rowActive","undefined","getCanSelect","_rows$rowActiveIndex2","toggleSelected","ctrlKey","metaKey","toggleAllRowsSelected","handleKeyDown"],"mappings":";;SAGgBA,oBAAoBA,CAACC,SAAS,GAAG,KAAK;EAClD,MAAMC,oBAAoB,GAAGC,cAAK,CAACC,MAAM,EAAU;EAEnD,MAAMC,SAAS,GAAGF,cAAK,CAACG,WAAW,CAC/B,CAAkBC,KAAoB,EAAEC,KAAwB;IAC5D,IAAI,CAACP,SAAS,IAAI,CAACO,KAAK,CAACC,OAAO,CAACC,kBAAkB,IAAIH,KAAK,CAACI,gBAAgB,EAAE;MAC3E;;IAGJ,MAAMC,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGN,KAAK,CAACC,OAAO,CAACM,IAA6B;IAE7D,IAAIR,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAAA,IAAAC,oBAAA;MACnBV,KAAK,CAACW,cAAc,EAAE;MACtB,MAAMC,cAAc,GAAGL,SAAS,CAACM,SAAS,CAACD,cAAc;MAEzD,IAAIA,cAAc,KAAKE,SAAS,KAAAJ,oBAAA,GAAIL,IAAI,CAACO,cAAc,CAAC,cAAAF,oBAAA,eAApBA,oBAAA,CAAsBK,YAAY,EAAE,EAAE;QAAA,IAAAC,qBAAA;QACtE,CAAAA,qBAAA,GAAAX,IAAI,CAACO,cAAc,CAAC,cAAAI,qBAAA,uBAApBA,qBAAA,CAAsBC,cAAc,EAAE;;MAG1C;KACH,MAAM,IAAI,CAACjB,KAAK,CAACkB,OAAO,IAAIlB,KAAK,CAACmB,OAAO,KAAKnB,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAC9DT,KAAK,CAACW,cAAc,EAAE;MACtBV,KAAK,CAACmB,qBAAqB,EAAE;MAC7B;;GAEP,EACD,CAAC1B,SAAS,CAAC,CAC+D;EAE9E,OAAO;IACHA,SAAS;IACT2B,aAAa,EAAE3B,SAAS,GAAGI,SAAS,GAAG,MAAMgB,SAAS;IACtDnB;GACH;AACL;;;;"}
1
+ {"version":3,"file":"useTableRowSelection.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableRowSelection.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\n\nexport function useTableRowSelection(isEnabled = false) {\n const lastSelectedRowIndex = React.useRef<number>();\n\n const onKeyDown = React.useCallback(\n <TType = unknown>(event: KeyboardEvent, table: ReactTable<TType>) => {\n if (!isEnabled || !table.options.enableRowSelection || event.defaultPrevented) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (event.key === ' ') {\n event.preventDefault();\n const rowActiveIndex = tableMeta.rowActive.rowActiveIndex;\n\n if (rowActiveIndex !== undefined && rows[rowActiveIndex]?.getCanSelect()) {\n rows[rowActiveIndex]?.toggleSelected();\n }\n\n return;\n } else if (\n (event.ctrlKey || event.metaKey) &&\n event.key === 'a' &&\n !['INPUT', 'TEXTAREA'].includes((event.target as Element)?.tagName)\n ) {\n event.preventDefault();\n table.toggleAllRowsSelected();\n return;\n }\n },\n [isEnabled]\n ) as <TType = unknown>(event: KeyboardEvent, table: ReactTable<TType>) => void;\n\n return {\n isEnabled,\n handleKeyDown: isEnabled ? onKeyDown : () => undefined,\n lastSelectedRowIndex,\n };\n}\n"],"names":["useTableRowSelection","isEnabled","lastSelectedRowIndex","React","useRef","onKeyDown","useCallback","event","table","options","enableRowSelection","defaultPrevented","rows","getRowModel","tableMeta","meta","key","_rows$rowActiveIndex","preventDefault","rowActiveIndex","rowActive","undefined","getCanSelect","_rows$rowActiveIndex2","toggleSelected","ctrlKey","metaKey","includes","_event$target","target","tagName","toggleAllRowsSelected","handleKeyDown"],"mappings":";;SAGgBA,oBAAoBA,CAACC,SAAS,GAAG,KAAK;EAClD,MAAMC,oBAAoB,GAAGC,cAAK,CAACC,MAAM,EAAU;EAEnD,MAAMC,SAAS,GAAGF,cAAK,CAACG,WAAW,CAC/B,CAAkBC,KAAoB,EAAEC,KAAwB;;IAC5D,IAAI,CAACP,SAAS,IAAI,CAACO,KAAK,CAACC,OAAO,CAACC,kBAAkB,IAAIH,KAAK,CAACI,gBAAgB,EAAE;MAC3E;;IAGJ,MAAMC,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;IACrC,MAAME,SAAS,GAAGN,KAAK,CAACC,OAAO,CAACM,IAA6B;IAE7D,IAAIR,KAAK,CAACS,GAAG,KAAK,GAAG,EAAE;MAAA,IAAAC,oBAAA;MACnBV,KAAK,CAACW,cAAc,EAAE;MACtB,MAAMC,cAAc,GAAGL,SAAS,CAACM,SAAS,CAACD,cAAc;MAEzD,IAAIA,cAAc,KAAKE,SAAS,KAAAJ,oBAAA,GAAIL,IAAI,CAACO,cAAc,CAAC,cAAAF,oBAAA,eAApBA,oBAAA,CAAsBK,YAAY,EAAE,EAAE;QAAA,IAAAC,qBAAA;QACtE,CAAAA,qBAAA,GAAAX,IAAI,CAACO,cAAc,CAAC,cAAAI,qBAAA,uBAApBA,qBAAA,CAAsBC,cAAc,EAAE;;MAG1C;KACH,MAAM,IACH,CAACjB,KAAK,CAACkB,OAAO,IAAIlB,KAAK,CAACmB,OAAO,KAC/BnB,KAAK,CAACS,GAAG,KAAK,GAAG,IACjB,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAACW,QAAQ,EAAAC,aAAA,GAAErB,KAAK,CAACsB,MAAkB,cAAAD,aAAA,uBAAxBA,aAAA,CAA0BE,OAAO,CAAC,EACrE;MACEvB,KAAK,CAACW,cAAc,EAAE;MACtBV,KAAK,CAACuB,qBAAqB,EAAE;MAC7B;;GAEP,EACD,CAAC9B,SAAS,CAAC,CAC+D;EAE9E,OAAO;IACHA,SAAS;IACT+B,aAAa,EAAE/B,SAAS,GAAGI,SAAS,GAAG,MAAMgB,SAAS;IACtDnB;GACH;AACL;;;;"}
@@ -1,5 +1,5 @@
1
1
  // taken from react-aria
2
- const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled]):not([tabindex="-1"])', 'input:not([disabled]):not([type=hidden]):not([tabindex="-1"])', 'select:not([disabled]):not([tabindex="-1"])', 'textarea:not([disabled]):not([tabindex="-1"])', 'button:not([disabled]):not([tabindex="-1"])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]', 'details:not([disabled]):not([tabindex="-1"])', 'summary:not(:disabled):not([tabindex="-1"])'];
2
+ const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled])', 'input:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'button:not([disabled])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]', 'details:not([disabled])', 'summary:not(:disabled)'];
3
3
  const hasFocusableElement = element => {
4
4
  if (!element) {
5
5
  return null;
@@ -28,7 +28,7 @@ const getNextFocussableElement = currentElement => {
28
28
  let focussableElements = [...document.querySelectorAll(FOCUSABLE_ELEMENTS.join(','))];
29
29
  const currentElementIndex = focussableElements.indexOf(currentElement);
30
30
  if (currentElementIndex > -1) {
31
- focussableElements = focussableElements.slice(currentElementIndex + 1);
31
+ focussableElements = focussableElements.slice(currentElementIndex + 1).filter(element => element.getAttribute('tabindex') !== '-1');
32
32
  if (focussableElements.length) {
33
33
  var _focussableElements$;
34
34
  focussableElements = focussableElements.filter(element => {
@@ -1 +1 @@
1
- {"version":3,"file":"dom.js","sources":["../../../../../../src/utils/dom.ts"],"sourcesContent":["// taken from react-aria\nconst FOCUSABLE_ELEMENTS = [\n '[tabindex]:not([disabled]):not([tabindex=\"-1\"])',\n 'input:not([disabled]):not([type=hidden]):not([tabindex=\"-1\"])',\n 'select:not([disabled]):not([tabindex=\"-1\"])',\n 'textarea:not([disabled]):not([tabindex=\"-1\"])',\n 'button:not([disabled]):not([tabindex=\"-1\"])',\n 'a[href]',\n 'area[href]',\n 'summary',\n 'iframe',\n 'object',\n 'embed',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]',\n 'details:not([disabled]):not([tabindex=\"-1\"])',\n 'summary:not(:disabled):not([tabindex=\"-1\"])',\n];\n\nexport const hasFocusableElement = (element: HTMLElement | null) => {\n if (!element) {\n return null;\n }\n\n return !!element.querySelector(FOCUSABLE_ELEMENTS.join(','));\n};\n\nexport const isOverflowing = (element: HTMLElement | null) =>\n element !== null ? element.scrollWidth > element.offsetWidth : false;\n\nexport const getIndexOfFirstChildOverflowingParent = (element: HTMLElement, overscan = 0) => {\n let index = 0;\n let boundaryChildIndex: number | null = null;\n const clientRect = element.getBoundingClientRect();\n\n for (const child of Array.from(element.children)) {\n const right = child.getBoundingClientRect().right - clientRect.left;\n const width = clientRect.width - overscan;\n\n if (right > width) {\n boundaryChildIndex = index;\n break;\n }\n index++;\n }\n\n return boundaryChildIndex;\n};\n\nexport const getNextFocussableElement = (currentElement: HTMLElement | null) => {\n if (!currentElement) {\n return null;\n }\n\n let focussableElements = [...document.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENTS.join(','))];\n const currentElementIndex = focussableElements.indexOf(currentElement);\n\n if (currentElementIndex > -1) {\n focussableElements = focussableElements.slice(currentElementIndex + 1);\n\n if (focussableElements.length) {\n focussableElements = focussableElements.filter(element => (element as any).checkVisibility?.() ?? true);\n return focussableElements[0] ?? null;\n }\n }\n\n return null;\n};\n\nconst getOverlaySelector = (element: Element | null) => {\n switch (element?.getAttribute('role')) {\n case 'dialog':\n return `[aria-controls='${element.id}']`;\n\n case 'menu':\n return `#${element.getAttribute('aria-labelledby')}`;\n\n default:\n return undefined;\n }\n};\n\nexport function isElementInsideOrTriggeredFromContainer(element: Element | null, container: Element | null) {\n const selector = getOverlaySelector(element) ?? getOverlaySelector(element?.closest('[role=dialog],[role=menu]') ?? null);\n\n if (selector) {\n if (container?.querySelector(selector)) {\n return true;\n }\n\n const elementInDocument = document.querySelector(selector);\n\n // if the element does exist, see if it is itself connected to somethng that was triggered from the container\n if (elementInDocument) {\n return isElementInsideOrTriggeredFromContainer(elementInDocument, container);\n }\n\n return false;\n }\n\n return !!container?.contains(element);\n}\n\nexport function isElementInsideOverlay(element: Element | null) {\n return !!element?.closest('[role=dialog],[role=menu]');\n}\n\nexport function isSiblingElementInsideSameParentOverlay(element: Element | null, sibling: Element | null) {\n return !!element?.closest('[role=dialog],[role=menu]')?.contains(sibling);\n}\n\nexport function isElementInteractive(element: Element | null) {\n if (!element) {\n return false;\n }\n\n return (\n ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'LABEL', 'OPTION'].includes(element.tagName) &&\n !(element as HTMLElement).hidden &&\n !(element as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLButtonElement).disabled &&\n !(element as HTMLInputElement | HTMLTextAreaElement).readOnly\n );\n}\n\nexport function isElementInsideTable3OrReport(element: Element | null) {\n return !!element?.closest('[data-taco^=table]');\n}\n\nexport function setDataFocusAttribute(target: Element) {\n target.setAttribute('data-focus', 'programmatic');\n\n const cleanup = () => {\n target.removeAttribute('data-focus');\n target.removeEventListener('blur', cleanup);\n };\n\n target.addEventListener('blur', cleanup);\n}\n"],"names":["FOCUSABLE_ELEMENTS","hasFocusableElement","element","querySelector","join","getIndexOfFirstChildOverflowingParent","overscan","index","boundaryChildIndex","clientRect","getBoundingClientRect","child","Array","from","children","right","left","width","getNextFocussableElement","currentElement","focussableElements","document","querySelectorAll","currentElementIndex","indexOf","slice","length","_focussableElements$","filter","_element$checkVisibil","_element$checkVisibil2","checkVisibility","call","getOverlaySelector","getAttribute","id","undefined","isElementInsideOrTriggeredFromContainer","container","selector","_getOverlaySelector","_element$closest","closest","elementInDocument","contains","isElementInsideOverlay","isSiblingElementInsideSameParentOverlay","sibling","_element$closest2","isElementInteractive","includes","tagName","hidden","disabled","readOnly","isElementInsideTable3OrReport","setDataFocusAttribute","target","setAttribute","cleanup","removeAttribute","removeEventListener","addEventListener"],"mappings":"AAAA;AACA,MAAMA,kBAAkB,GAAG,CACvB,iDAAiD,EACjD,+DAA+D,EAC/D,6CAA6C,EAC7C,+CAA+C,EAC/C,6CAA6C,EAC7C,SAAS,EACT,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,8CAA8C,EAC9C,6CAA6C,CAChD;MAEYC,mBAAmB,GAAIC,OAA2B;EAC3D,IAAI,CAACA,OAAO,EAAE;IACV,OAAO,IAAI;;EAGf,OAAO,CAAC,CAACA,OAAO,CAACC,aAAa,CAACH,kBAAkB,CAACI,IAAI,CAAC,GAAG,CAAC,CAAC;AAChE;MAKaC,qCAAqC,GAAGA,CAACH,OAAoB,EAAEI,QAAQ,GAAG,CAAC;EACpF,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,kBAAkB,GAAkB,IAAI;EAC5C,MAAMC,UAAU,GAAGP,OAAO,CAACQ,qBAAqB,EAAE;EAElD,KAAK,MAAMC,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EwC,OAAO,CAAC,2BAA2B,CAAC,cAAAM,iBAAA,eAA7CA,iBAAA,CAA+CJ,QAAQ,CAACG,OAAO,CAAC;AAC7E;SAEgBE,oBAAoBA,CAAC/C,OAAuB;EACxD,IAAI,CAACA,OAAO,EAAE;IACV,OAAO,KAAK;;EAGhB,OACI,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAACgD,QAAQ,CAAChD,OAAO,CAACiD,OAAO,CAAC,IAC3F,CAAEjD,OAAuB,CAACkD,MAAM,IAChC,CAAElD,OAA0F,CAACmD,QAAQ,IACrG,CAAEnD,OAAkD,CAACoD,QAAQ;AAErE;SAEgBC,6BAA6BA,CAACrD,OAAuB;EACjE,OAAO,CAAC,EAACA,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEwC,OAAO,CAAC,oBAAoB,CAAC;AACnD;SAEgBc,qBAAqBA,CAACC,MAAe;EACjDA,MAAM,CAACC,YAAY,CAAC,YAAY,EAAE,cAAc,CAAC;EAEjD,MAAMC,OAAO,GAAGA;IACZF,MAAM,CAACG,eAAe,CAAC,YAAY,CAAC;IACpCH,MAAM,CAACI,mBAAmB,CAAC,MAAM,EAAEF,OAAO,CAAC;GAC9C;EAEDF,MAAM,CAACK,gBAAgB,CAAC,MAAM,EAAEH,OAAO,CAAC;AAC5C;;;;"}
1
+ {"version":3,"file":"dom.js","sources":["../../../../../../src/utils/dom.ts"],"sourcesContent":["// taken from react-aria\nconst FOCUSABLE_ELEMENTS = [\n '[tabindex]:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'button:not([disabled])',\n 'a[href]',\n 'area[href]',\n 'summary',\n 'iframe',\n 'object',\n 'embed',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]',\n 'details:not([disabled])',\n 'summary:not(:disabled)',\n];\n\nexport const hasFocusableElement = (element: HTMLElement | null) => {\n if (!element) {\n return null;\n }\n\n return !!element.querySelector(FOCUSABLE_ELEMENTS.join(','));\n};\n\nexport const isOverflowing = (element: HTMLElement | null) =>\n element !== null ? element.scrollWidth > element.offsetWidth : false;\n\nexport const getIndexOfFirstChildOverflowingParent = (element: HTMLElement, overscan = 0) => {\n let index = 0;\n let boundaryChildIndex: number | null = null;\n const clientRect = element.getBoundingClientRect();\n\n for (const child of Array.from(element.children)) {\n const right = child.getBoundingClientRect().right - clientRect.left;\n const width = clientRect.width - overscan;\n\n if (right > width) {\n boundaryChildIndex = index;\n break;\n }\n index++;\n }\n\n return boundaryChildIndex;\n};\n\nexport const getNextFocussableElement = (currentElement: HTMLElement | null) => {\n if (!currentElement) {\n return null;\n }\n\n let focussableElements = [...document.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENTS.join(','))];\n const currentElementIndex = focussableElements.indexOf(currentElement);\n\n if (currentElementIndex > -1) {\n focussableElements = focussableElements\n .slice(currentElementIndex + 1)\n .filter(element => element.getAttribute('tabindex') !== '-1');\n\n if (focussableElements.length) {\n focussableElements = focussableElements.filter(element => (element as any).checkVisibility?.() ?? true);\n return focussableElements[0] ?? null;\n }\n }\n\n return null;\n};\n\nconst getOverlaySelector = (element: Element | null) => {\n switch (element?.getAttribute('role')) {\n case 'dialog':\n return `[aria-controls='${element.id}']`;\n\n case 'menu':\n return `#${element.getAttribute('aria-labelledby')}`;\n\n default:\n return undefined;\n }\n};\n\nexport function isElementInsideOrTriggeredFromContainer(element: Element | null, container: Element | null) {\n const selector = getOverlaySelector(element) ?? getOverlaySelector(element?.closest('[role=dialog],[role=menu]') ?? null);\n\n if (selector) {\n if (container?.querySelector(selector)) {\n return true;\n }\n\n const elementInDocument = document.querySelector(selector);\n\n // if the element does exist, see if it is itself connected to somethng that was triggered from the container\n if (elementInDocument) {\n return isElementInsideOrTriggeredFromContainer(elementInDocument, container);\n }\n\n return false;\n }\n\n return !!container?.contains(element);\n}\n\nexport function isElementInsideOverlay(element: Element | null) {\n return !!element?.closest('[role=dialog],[role=menu]');\n}\n\nexport function isSiblingElementInsideSameParentOverlay(element: Element | null, sibling: Element | null) {\n return !!element?.closest('[role=dialog],[role=menu]')?.contains(sibling);\n}\n\nexport function isElementInteractive(element: Element | null) {\n if (!element) {\n return false;\n }\n\n return (\n ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'LABEL', 'OPTION'].includes(element.tagName) &&\n !(element as HTMLElement).hidden &&\n !(element as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLButtonElement).disabled &&\n !(element as HTMLInputElement | HTMLTextAreaElement).readOnly\n );\n}\n\nexport function isElementInsideTable3OrReport(element: Element | null) {\n return !!element?.closest('[data-taco^=table]');\n}\n\nexport function setDataFocusAttribute(target: Element) {\n target.setAttribute('data-focus', 'programmatic');\n\n const cleanup = () => {\n target.removeAttribute('data-focus');\n target.removeEventListener('blur', cleanup);\n };\n\n target.addEventListener('blur', cleanup);\n}\n"],"names":["FOCUSABLE_ELEMENTS","hasFocusableElement","element","querySelector","join","getIndexOfFirstChildOverflowingParent","overscan","index","boundaryChildIndex","clientRect","getBoundingClientRect","child","Array","from","children","right","left","width","getNextFocussableElement","currentElement","focussableElements","document","querySelectorAll","currentElementIndex","indexOf","slice","filter","getAttribute","length","_focussableElements$","_element$checkVisibil","_element$checkVisibil2","checkVisibility","call","getOverlaySelector","id","undefined","isElementInsideOrTriggeredFromContainer","container","selector","_getOverlaySelector","_element$closest","closest","elementInDocument","contains","isElementInsideOverlay","isSiblingElementInsideSameParentOverlay","sibling","_element$closest2","isElementInteractive","includes","tagName","hidden","disabled","readOnly","isElementInsideTable3OrReport","setDataFocusAttribute","target","setAttribute","cleanup","removeAttribute","removeEventListener","addEventListener"],"mappings":"AAAA;AACA,MAAMA,kBAAkB,GAAG,CACvB,4BAA4B,EAC5B,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,SAAS,EACT,YAAY,EACZ,SAAS,EACT,QAAQ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AAC;EAEjD,MAAMC,OAAO,GAAGA;IACZF,MAAM,CAACG,eAAe,CAAC,YAAY,CAAC;IACpCH,MAAM,CAACI,mBAAmB,CAAC,MAAM,EAAEF,OAAO,CAAC;GAC9C;EAEDF,MAAM,CAACK,gBAAgB,CAAC,MAAM,EAAEH,OAAO,CAAC;AAC5C;;;;"}
@@ -4161,7 +4161,7 @@ const useMergedRef = ref => {
4161
4161
  };
4162
4162
 
4163
4163
  // taken from react-aria
4164
- const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled]):not([tabindex="-1"])', 'input:not([disabled]):not([type=hidden]):not([tabindex="-1"])', 'select:not([disabled]):not([tabindex="-1"])', 'textarea:not([disabled]):not([tabindex="-1"])', 'button:not([disabled]):not([tabindex="-1"])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]', 'details:not([disabled]):not([tabindex="-1"])', 'summary:not(:disabled):not([tabindex="-1"])'];
4164
+ const FOCUSABLE_ELEMENTS = ['[tabindex]:not([disabled])', 'input:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'button:not([disabled])', 'a[href]', 'area[href]', 'summary', 'iframe', 'object', 'embed', 'audio[controls]', 'video[controls]', '[contenteditable]', 'details:not([disabled])', 'summary:not(:disabled)'];
4165
4165
  const hasFocusableElement = element => {
4166
4166
  if (!element) {
4167
4167
  return null;
@@ -4190,7 +4190,7 @@ const getNextFocussableElement = currentElement => {
4190
4190
  let focussableElements = [...document.querySelectorAll(FOCUSABLE_ELEMENTS.join(','))];
4191
4191
  const currentElementIndex = focussableElements.indexOf(currentElement);
4192
4192
  if (currentElementIndex > -1) {
4193
- focussableElements = focussableElements.slice(currentElementIndex + 1);
4193
+ focussableElements = focussableElements.slice(currentElementIndex + 1).filter(element => element.getAttribute('tabindex') !== '-1');
4194
4194
  if (focussableElements.length) {
4195
4195
  var _focussableElements$;
4196
4196
  focussableElements = focussableElements.filter(element => {
@@ -10909,6 +10909,7 @@ function useTableRowHeight(isEnabled = false, defaultRowHeight = 'medium') {
10909
10909
  function useTableRowSelection(isEnabled = false) {
10910
10910
  const lastSelectedRowIndex = React__default.useRef();
10911
10911
  const onKeyDown = React__default.useCallback((event, table) => {
10912
+ var _event$target;
10912
10913
  if (!isEnabled || !table.options.enableRowSelection || event.defaultPrevented) {
10913
10914
  return;
10914
10915
  }
@@ -10923,7 +10924,7 @@ function useTableRowSelection(isEnabled = false) {
10923
10924
  (_rows$rowActiveIndex2 = rows[rowActiveIndex]) === null || _rows$rowActiveIndex2 === void 0 ? void 0 : _rows$rowActiveIndex2.toggleSelected();
10924
10925
  }
10925
10926
  return;
10926
- } else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
10927
+ } else if ((event.ctrlKey || event.metaKey) && event.key === 'a' && !['INPUT', 'TEXTAREA'].includes((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName)) {
10927
10928
  event.preventDefault();
10928
10929
  table.toggleAllRowsSelected();
10929
10930
  return;
@@ -19284,10 +19285,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
19284
19285
  }
19285
19286
  return;
19286
19287
  }
19287
- const shortcutWhitelist = ['f', 'p', 'e']; // f = search, p = print, and e = edit
19288
- if (isPressingMetaKey(event) && !shortcutWhitelist.some(s => s === event.key)) {
19289
- event.stopPropagation();
19290
- }
19291
19288
  // toggle into detailed mode when actually inputting something
19292
19289
  if (!isPressingMetaKey(event) && (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace')) {
19293
19290
  toggleDetailedMode(true);