@economic/taco 2.12.1 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Field/Field.d.ts +4 -2
- package/dist/components/Icon/components/Location.d.ts +3 -0
- package/dist/components/Icon/components/index.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Menu/components/Item.d.ts +1 -1
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Navigation2/components/Link.d.ts +1 -1
- package/dist/components/Provider/Localization.d.ts +1 -113
- package/dist/components/Select2/components/Option.d.ts +7 -5
- package/dist/components/Select2/components/Search.d.ts +1 -1
- package/dist/components/Table3/Table3.d.ts +9 -1
- package/dist/components/Table3/components/columns/header/Group.d.ts +15 -0
- package/dist/components/Table3/components/columns/header/Header.d.ts +5 -0
- package/dist/components/Table3/components/columns/internal/EditingActions.d.ts +1 -1
- package/dist/components/Table3/components/columns/styles.d.ts +2 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +4 -4
- package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +3 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +3 -2
- package/dist/components/Table3/components/toolbar/FontSize.d.ts +4 -0
- package/dist/components/Table3/hooks/features/useHeaderOffsetStyle.d.ts +3 -0
- package/dist/components/Table3/hooks/useCssGrid.d.ts +2 -1
- package/dist/components/Table3/hooks/useTable.d.ts +1 -1
- package/dist/components/Table3/types.d.ts +8 -1
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/esm/index.css +24 -6
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +1 -1
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js +6 -4
- package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Icon/components/Location.js +17 -0
- package/dist/esm/packages/taco/src/components/Icon/components/Location.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +1 -110
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +13 -6
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +7 -6
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +29 -11
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -5
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +1 -4
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js +70 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +26 -8
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +6 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +13 -9
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +14 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +10 -7
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +15 -8
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +25 -4
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +0 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js +5 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js +9 -4
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +2 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useHeaderOffsetStyle.js +24 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useHeaderOffsetStyle.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +6 -7
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +48 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +34 -9
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +6 -5
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +11 -9
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -2
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +1 -2
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/index.css +24 -6
- package/dist/index.d.ts +0 -1
- package/dist/taco.cjs.development.js +697 -4100
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
- package/tailwind.config.js +3 -0
- package/types.json +14334 -32345
- package/dist/components/Table2/Table2.d.ts +0 -130
- package/dist/components/Table2/components/BatchActionsMenu.d.ts +0 -10
- package/dist/components/Table2/components/ColumnSettingsButton.d.ts +0 -6
- package/dist/components/Table2/components/EditModeButton.d.ts +0 -8
- package/dist/components/Table2/components/RowDensityButton.d.ts +0 -7
- package/dist/components/Table2/components/Search.d.ts +0 -3
- package/dist/components/Table2/components/ShortcutsGuideButton.d.ts +0 -7
- package/dist/components/Table2/components/column/Base.d.ts +0 -14
- package/dist/components/Table2/components/column/Cell.d.ts +0 -15
- package/dist/components/Table2/components/column/Footer.d.ts +0 -9
- package/dist/components/Table2/components/column/Header.d.ts +0 -11
- package/dist/components/Table2/components/column/Indicator.d.ts +0 -17
- package/dist/components/Table2/components/column/ValidationError.d.ts +0 -5
- package/dist/components/Table2/components/column/utils.d.ts +0 -3
- package/dist/components/Table2/components/filters/FiltersButton.d.ts +0 -7
- package/dist/components/Table2/components/filters/components/Column.d.ts +0 -11
- package/dist/components/Table2/components/filters/components/ColumnFilter.d.ts +0 -10
- package/dist/components/Table2/components/filters/components/Comparator.d.ts +0 -11
- package/dist/components/Table2/components/filters/components/EmptyFilter.d.ts +0 -13
- package/dist/components/Table2/components/filters/components/InferredControl.d.ts +0 -10
- package/dist/components/Table2/components/row/Context.d.ts +0 -24
- package/dist/components/Table2/components/row/ExpandedRow.d.ts +0 -6
- package/dist/components/Table2/components/row/Row.d.ts +0 -2
- package/dist/components/Table2/hooks/listeners/useActiveCellStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useActiveRowStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useFilterStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useRowSelectionListener.d.ts +0 -3
- package/dist/components/Table2/hooks/listeners/useSettingsStateListener.d.ts +0 -3
- package/dist/components/Table2/hooks/useActiveCell.d.ts +0 -26
- package/dist/components/Table2/hooks/useActiveRow.d.ts +0 -10
- package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +0 -37
- package/dist/components/Table2/hooks/useEditMode.d.ts +0 -28
- package/dist/components/Table2/hooks/useGridTemplate.d.ts +0 -2
- package/dist/components/Table2/hooks/useTable.d.ts +0 -46
- package/dist/components/Table2/hooks/useTableShortcuts.d.ts +0 -2
- package/dist/components/Table2/hooks/useVirtualiser.d.ts +0 -23
- package/dist/components/Table2/types.d.ts +0 -148
- package/dist/components/Table2/utilities/cell.d.ts +0 -14
- package/dist/components/Table2/utilities/columns.d.ts +0 -16
- package/dist/components/Table2/utilities/filterFn.d.ts +0 -3
- package/dist/esm/packages/taco/src/components/Table2/Table2.js +0 -422
- package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js +0 -83
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +0 -116
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +0 -81
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +0 -47
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js +0 -62
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js +0 -32
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +0 -605
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js +0 -32
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +0 -243
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +0 -73
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js +0 -30
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +0 -39
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +0 -155
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js +0 -31
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js +0 -129
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js +0 -68
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js +0 -63
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js +0 -99
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +0 -58
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js +0 -36
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +0 -44
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js +0 -19
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +0 -28
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js +0 -12
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js +0 -18
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js +0 -25
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js +0 -33
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +0 -122
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js +0 -112
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +0 -34
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +0 -222
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js +0 -46
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +0 -48
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/types.js +0 -18
- package/dist/esm/packages/taco/src/components/Table2/types.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +0 -41
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +0 -387
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js +0 -100
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +0 -32
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +0 -1
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +0 -20
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName
|
1
|
+
{"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Tag } from '../../Tag/Tag';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport * as ListboxPrimitive from '../../../primitives/Listbox2/Listbox2';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { EditPopover } from './Edit';\nimport { isMobileDevice } from '../../../utils/device';\nimport { Color } from '../../../types';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children' | 'prefix'> & {\n children: string;\n color?: Color;\n description?: string;\n prefix?: IconName | JSX.Element;\n postfix?: IconName | JSX.Element;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, prefix, postfix, className: cName, ...otherProps } = props;\n const {\n onDelete,\n onEdit,\n listboxRef,\n multiple,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n } = useSelect2Context();\n const className = cn(createOptionClassName(shouldPauseHoverState), cName);\n\n const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;\n const isTag = tags && !!color;\n\n const handleClick = () => {\n if (!multiple) {\n setOpen(false);\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isAriaSelectionKey(event)) {\n if (!multiple || event.key === 'Tab') {\n setOpen(false);\n }\n }\n };\n\n const isEmptyOption = children !== '';\n\n const popover =\n isEmptyOption && (onEdit || onDelete)\n ? popoverProps => (\n <EditPopover\n {...popoverProps}\n color={props.color}\n key={props.textValue ?? String(props.children)}\n text={props.textValue ?? String(props.children)}\n value={props.value}\n />\n )\n : undefined;\n\n return (\n <ListboxPrimitive.Option {...otherProps} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref}>\n {hasValue ? (\n <Icon name=\"tick\" className=\"pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible\" />\n ) : null}\n\n {isTag ? (\n <Tag className=\"pointer-events-none my-1\" color={color} icon={prefix}>\n {children}\n </Tag>\n ) : (\n <>\n {prefix ? typeof prefix === 'string' ? <Icon name={prefix} /> : prefix : null}\n <span className=\"flex w-full justify-between\">\n <span className=\"flex flex-col\">\n <span>{children}</span>\n {description ? <span className=\"text-grey-700 -mt-1.5 mb-1.5 text-xs\">{description}</span> : null}\n </span>\n <span className=\"flex flex-col self-center\">\n {postfix ? typeof postfix === 'string' ? <Icon name={postfix} /> : postfix : null}\n </span>\n </span>\n </>\n )}\n {popover ? (\n <IconButton\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn(\n 'group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible',\n {\n '!visible': isMobileDevice(window?.navigator),\n }\n )}\n onClick={event => {\n event.stopPropagation();\n listboxRef?.current?.setActiveIndex(event.currentTarget.parentElement as HTMLDivElement);\n }}\n popover={popover}\n tabIndex={-1}\n />\n ) : null}\n </ListboxPrimitive.Option>\n );\n});\n"],"names":["Option","React","forwardRef","Select2Option","props","ref","children","color","description","prefix","postfix","className","cName","otherProps","onDelete","onEdit","listboxRef","multiple","selectRef","setOpen","shouldPauseHoverState","tags","value","useSelect2Context","cn","createOptionClassName","hasValue","Array","isArray","length","undefined","isTag","handleClick","_selectRef$current","current","focus","handleKeyDown","event","isAriaSelectionKey","key","isEmptyOption","popover","popoverProps","_props$textValue","_props$textValue2","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","icon","IconButton","appearance","isMobileDevice","_window","window","navigator","stopPropagation","_listboxRef$current","setActiveIndex","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;MAsBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,WAAW;IAAEC,MAAM;IAAEC,OAAO;IAAEC,SAAS,EAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGT,KAAK;EAChG,MAAM;IACFU,QAAQ;IACRC,MAAM;IACNC,UAAU;IACVC,QAAQ;IACRZ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Eb,KAAK;;MACVA,KAAK,CAACyB,eAAe,EAAE;MACvB9C,UAAU,aAAVA,UAAU,wBAAA+C,mBAAA,GAAV/C,UAAU,CAAEkB,OAAO,cAAA6B,mBAAA,uBAAnBA,mBAAA,CAAqBC,cAAc,CAAC3B,KAAK,CAAC4B,aAAa,CAACC,aAA+B,CAAC;KAC3F;IACDzB,OAAO,EAAEA,OAAO;IAChB0B,QAAQ,EAAE,CAAC;IACb,GACF,IAAI,CACc;AAElC,CAAC;;;;"}
|
@@ -46,7 +46,7 @@ const Search = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(pro
|
|
46
46
|
className: cn('mx-1.5 mb-1.5 !min-h-fit ', {
|
47
47
|
'!pb-0': !validationError
|
48
48
|
}),
|
49
|
-
|
49
|
+
error: !!validationError,
|
50
50
|
message: validationError === null || validationError === void 0 ? void 0 : validationError.message
|
51
51
|
}, /*#__PURE__*/React__default.createElement(Input, Object.assign({}, otherProps, {
|
52
52
|
"aria-hidden": true,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["../../../../../../../../src/components/Select2/components/Search.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Input, InputProps } from '../../Input/Input';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { isAriaSelectionKey } from '../../../utils/aria';\n\nexport type Select2SearchProps = InputProps & {};\n\nexport const Search = React.forwardRef<HTMLInputElement, Select2SearchProps>(function ListboxSearch(props, ref) {\n const { ...otherProps } = props;\n const { listboxRef, searchQuery, setSearchQuery, setValidationError, validationError, setOpen } = useSelect2Context();\n\n const handleChange = event => {\n if (validationError) {\n setValidationError(undefined);\n }\n\n setSearchQuery(event.target.value);\n };\n\n const handleKeyDown = event => {\n // space is an aria selection key, so we have to remove it to allow spaces\n if (event.key === ' ') {\n return;\n }\n\n // Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)\n if (event.key === 'Tab') {\n setOpen(false);\n return;\n }\n\n if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n // forward navigation events onto the underlying collection - we want arrow keys to work from inside the filter input\n listboxRef?.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n return;\n }\n };\n\n return (\n <Field\n className={cn('mx-1.5 mb-1.5 !min-h-fit ', { '!pb-0': !validationError })}\n
|
1
|
+
{"version":3,"file":"Search.js","sources":["../../../../../../../../src/components/Select2/components/Search.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Input, InputProps } from '../../Input/Input';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { isAriaSelectionKey } from '../../../utils/aria';\n\nexport type Select2SearchProps = InputProps & {};\n\nexport const Search = React.forwardRef<HTMLInputElement, Select2SearchProps>(function ListboxSearch(props, ref) {\n const { ...otherProps } = props;\n const { listboxRef, searchQuery, setSearchQuery, setValidationError, validationError, setOpen } = useSelect2Context();\n\n const handleChange = event => {\n if (validationError) {\n setValidationError(undefined);\n }\n\n setSearchQuery(event.target.value);\n };\n\n const handleKeyDown = event => {\n // space is an aria selection key, so we have to remove it to allow spaces\n if (event.key === ' ') {\n return;\n }\n\n // Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)\n if (event.key === 'Tab') {\n setOpen(false);\n return;\n }\n\n if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n // forward navigation events onto the underlying collection - we want arrow keys to work from inside the filter input\n listboxRef?.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n return;\n }\n };\n\n return (\n <Field\n className={cn('mx-1.5 mb-1.5 !min-h-fit ', { '!pb-0': !validationError })}\n error={!!validationError}\n message={validationError?.message}>\n <Input\n {...otherProps}\n aria-hidden\n autoFocus\n invalid={!!validationError}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n ref={ref}\n value={searchQuery}\n />\n </Field>\n );\n});\n"],"names":["Search","React","forwardRef","ListboxSearch","props","ref","otherProps","listboxRef","searchQuery","setSearchQuery","setValidationError","validationError","setOpen","useSelect2Context","handleChange","event","undefined","target","value","handleKeyDown","key","isAriaSelectionKey","_listboxRef$current","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","Field","className","cn","error","message","Input","autoFocus","invalid","onChange","onKeyDown"],"mappings":";;;;;;;;MAUaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAuC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;EAC1G,MAAM;IAAE,GAAGC;GAAY,GAAGF,KAAK;EAC/B,MAAM;IAAEG,UAAU;IAAEC,WAAW;IAAEC,cAAc;IAAEC,kBAAkB;IAAEC,eAAe;IAAEC;GAAS,GAAGC,iBAAiB,EAAE;EAErH,MAAMC,YAAY,GAAGC,KAAK;IACtB,IAAIJ,eAAe,EAAE;MACjBD,kBAAkB,CAACM,SAAS,CAAC;;IAGjCP,cAAc,CAACM,KAAK,CAACE,MAAM,CAACC,KAAK,CAAC;GACrC;EAED,MAAMC,aAAa,GAAGJ,KAAK;;IAEvB,IAAIA,KAAK,CAACK,GAAG,KAAK,GAAG,EAAE;MACnB;;;IAIJ,IAAIL,KAAK,CAACK,GAAG,KAAK,KAAK,EAAE;MACrBR,OAAO,CAAC,KAAK,CAAC;MACd;;IAGJ,IAAIS,kBAAkB,CAACN,KAAK,CAAC,IAAIA,KAAK,CAACK,GAAG,KAAK,WAAW,IAAIL,KAAK,CAACK,GAAG,KAAK,SAAS,EAAE;MAAA,IAAAE,mBAAA;MACnFP,KAAK,CAACQ,cAAc,EAAE;;MAEtBhB,UAAU,aAAVA,UAAU,wBAAAe,mBAAA,GAAVf,UAAU,CAAEiB,OAAO,cAAAF,mBAAA,uBAAnBA,mBAAA,CAAqBG,aAAa,CAACC,yBAAyB,CAACX,KAA8C,CAAC,CAAC;MAC7G;;GAEP;EAED,oBACId,6BAAC0B,KAAK;IACFC,SAAS,EAAEC,EAAE,CAAC,2BAA2B,EAAE;MAAE,OAAO,EAAE,CAAClB;KAAiB,CAAC;IACzEmB,KAAK,EAAE,CAAC,CAACnB,eAAe;IACxBoB,OAAO,EAAEpB,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEoB;kBAC1B9B,6BAAC+B,KAAK,oBACE1B,UAAU;;IAEd2B,SAAS;IACTC,OAAO,EAAE,CAAC,CAACvB,eAAe;IAC1BwB,QAAQ,EAAErB,YAAY;IACtBsB,SAAS,EAAEjB,aAAa;IACxBd,GAAG,EAAEA,GAAG;IACRa,KAAK,EAAEV;KACT,CACE;AAEhB,CAAC;;;;"}
|
@@ -104,13 +104,14 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
104
104
|
className: "truncate",
|
105
105
|
color: currentValue.props.color,
|
106
106
|
disabled: disabled,
|
107
|
-
icon: currentValue.props.
|
107
|
+
icon: currentValue.props.prefix,
|
108
108
|
readOnly: readOnly
|
109
109
|
}, currentValue.props.children);
|
110
110
|
} else {
|
111
|
-
output = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, currentValue.props.
|
112
|
-
name: currentValue.props.
|
113
|
-
|
111
|
+
output = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, currentValue.props.prefix ? typeof currentValue.props.prefix === 'string' ? /*#__PURE__*/React__default.createElement(Icon, {
|
112
|
+
name: currentValue.props.prefix,
|
113
|
+
className: "mr-1 !h-5 !w-5"
|
114
|
+
}) : currentValue.props.prefix : null, currentValue.props.children);
|
114
115
|
}
|
115
116
|
}
|
116
117
|
return /*#__PURE__*/React__default.createElement(Button, Object.assign({}, buttonProps, {
|
@@ -157,7 +158,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
157
158
|
className: "truncate",
|
158
159
|
color: tags ? child.props.color : undefined,
|
159
160
|
disabled: disabled,
|
160
|
-
icon: child.props.
|
161
|
+
icon: child.props.prefix,
|
161
162
|
onDelete: event => {
|
162
163
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
163
164
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
@@ -225,7 +226,7 @@ const MultipleValue = ({
|
|
225
226
|
}),
|
226
227
|
color: tags ? child.props.color : undefined,
|
227
228
|
disabled: disabled,
|
228
|
-
icon: child.props.
|
229
|
+
icon: child.props.prefix,
|
229
230
|
onDelete: open ? createClickHandler(child.props.value) : undefined,
|
230
231
|
readOnly: readOnly
|
231
232
|
}, child.props.children);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer !px-1.5',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly }).replace('w-full', ''),\n { 'w-full': !props.className?.includes('w-') },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== undefined && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.icon}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.icon ? (\n typeof currentValue.props.icon === 'string' ? (\n <Icon name={currentValue.props.icon} />\n ) : (\n currentValue.props.icon\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.icon}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className={cn('relative inline-flex flex-grow', { 'h-8': open })}\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.icon}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","_props$className","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;MAoBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,EAAEA;OAAU;;EAG5D,oBAAOV,6BAACa,MAAM,oBAAKV,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEE,KAAK,EAAEA;KAAS;AACxD,CAAC;AAKD,MAAMQ,MAAM,gBAAGd,cAAK,CAACC,UAAU,CAAiC,SAASc,oBAAoBA,CAACZ,KAAK,EAAEC,GAAG;;EACpG,MAAM;IAAE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8B,IAAMyD,KAA8B;EACpF,IAAIvD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACwB,QAAQ,CAACiC,KAAK,CAAC5D,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAOyD,KAAK,CAAC5D,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer !px-1.5',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly }).replace('w-full', ''),\n { 'w-full': !props.className?.includes('w-') },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== undefined && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.prefix}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.prefix ? (\n typeof currentValue.props.prefix === 'string' ? (\n <Icon name={currentValue.props.prefix} className=\"mr-1 !h-5 !w-5\" />\n ) : (\n currentValue.props.prefix\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className={cn('relative inline-flex flex-grow', { 'h-8': open })}\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","_props$className","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","prefix","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;MAoBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,EAAEA;OAAU;;EAG5D,oBAAOV,6BAACa,MAAM,oBAAKV,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEE,KAAK,EAAEA;KAAS;AACxD,CAAC;AAKD,MAAMQ,MAAM,gBAAGd,cAAK,CAACC,UAAU,CAAiC,SAASc,oBAAoBA,CAACZ,KAAK,EAAEC,GAAG;;EACpG,MAAM;IAAEY,QAAQ;IAAEC,OAAO;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGhB,KAAK;EAChE,MAAM;IAAEiB,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEC,IAA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C7D,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAO0D,KAAK,CAAC7D,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
@@ -3,6 +3,7 @@ import cn from 'classnames';
|
|
3
3
|
import { useMergedRef } from '../../hooks/useMergedRef.js';
|
4
4
|
import { FocusScope } from '@react-aria/focus';
|
5
5
|
import { flexRender } from '@tanstack/react-table';
|
6
|
+
import { FONT_SIZE } from './components/toolbar/FontSize.js';
|
6
7
|
import { useCssGrid } from './hooks/useCssGrid.js';
|
7
8
|
import { useColumnFreezingStyle } from './hooks/features/useColumnFreezing.js';
|
8
9
|
import { useTable } from './hooks/useTable.js';
|
@@ -11,11 +12,17 @@ import { Toolbar } from './components/toolbar/Toolbar.js';
|
|
11
12
|
import { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup.js';
|
12
13
|
import { Summary } from './components/columns/footer/Summary.js';
|
13
14
|
import { useCssVars } from './hooks/useCssVars.js';
|
15
|
+
import { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle.js';
|
14
16
|
export { useTable3DataLoader } from './hooks/useTableDataLoader.js';
|
15
17
|
|
16
18
|
function Column(_) {
|
17
19
|
return null;
|
18
20
|
}
|
21
|
+
Column.displayName = 'Table3Column';
|
22
|
+
function Group(_) {
|
23
|
+
return null;
|
24
|
+
}
|
25
|
+
Group.displayName = 'Table3Group';
|
19
26
|
// Cast the old forwardRef to the new one
|
20
27
|
const fixedForwardRef = React__default.forwardRef;
|
21
28
|
const Table = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
@@ -88,15 +95,15 @@ const Table = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
88
95
|
}
|
89
96
|
};
|
90
97
|
const className = cn('border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none', '[&[data-resizing="true"]]:select-none', {
|
91
|
-
'text-xs': tableMeta.fontSize.size ===
|
92
|
-
'text-sm': tableMeta.fontSize.size ===
|
93
|
-
'text-base': tableMeta.fontSize.size ===
|
98
|
+
'text-xs': tableMeta.fontSize.size === FONT_SIZE.small,
|
99
|
+
'text-sm': tableMeta.fontSize.size === FONT_SIZE.medium,
|
100
|
+
'text-base': tableMeta.fontSize.size === FONT_SIZE.large
|
94
101
|
});
|
95
102
|
// Print tables have "_print" as the postfix for the table id, so we can use the it to determine
|
96
103
|
// if the table is a print table or not.
|
97
104
|
const {
|
98
105
|
style: cssGridStyle
|
99
|
-
} = useCssGrid(table, tableMeta.isPrinting, tableMeta.rowActions.actionsForRowLength);
|
106
|
+
} = useCssGrid(table, tableMeta.isPrinting, tableMeta.rowActions.actionsForRowLength, tableMeta.fontSize.size);
|
100
107
|
const {
|
101
108
|
style: cssVars
|
102
109
|
} = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);
|
@@ -108,10 +115,13 @@ const Table = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
108
115
|
opacity: 0.999
|
109
116
|
};
|
110
117
|
const columnFreezingStyle = useColumnFreezingStyle(props.id, table);
|
118
|
+
const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);
|
111
119
|
const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;
|
112
120
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, columnFreezingStyle ? /*#__PURE__*/React__default.createElement("style", {
|
113
121
|
"data-taco": "table3-column-freezing-styles"
|
114
|
-
}, columnFreezingStyle) : null, /*#__PURE__*/React__default.createElement(
|
122
|
+
}, columnFreezingStyle) : null, headerOffsetStyle ? /*#__PURE__*/React__default.createElement("style", {
|
123
|
+
"data-taco": "table3-column-header-offset-styles"
|
124
|
+
}, headerOffsetStyle) : null, /*#__PURE__*/React__default.createElement(Toolbar, {
|
115
125
|
table: table,
|
116
126
|
tableProps: props,
|
117
127
|
total: length,
|
@@ -143,12 +153,19 @@ const Table = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
143
153
|
className: "contents",
|
144
154
|
key: headerGroup.id,
|
145
155
|
role: "row"
|
146
|
-
}, headerGroup.headers.map(header =>
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
156
|
+
}, headerGroup.headers.map((header, index) => {
|
157
|
+
var _headerGroup$headers;
|
158
|
+
// We need to render separator if column is not the last in array, if index is not equal to freeze column index,
|
159
|
+
// if next element is not placeholder and if column itself is not placeholder.
|
160
|
+
const hasSeparator = index !== tableMeta.columnFreezing.frozenColumnIndex && index !== headerGroup.headers.length - 1 && (!((_headerGroup$headers = headerGroup.headers[index + 1]) !== null && _headerGroup$headers !== void 0 && _headerGroup$headers.isPlaceholder) || !header.isPlaceholder);
|
161
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
162
|
+
key: header.id
|
163
|
+
}, flexRender(header.column.columnDef.header, {
|
164
|
+
...header.getContext(),
|
165
|
+
scrollToIndex,
|
166
|
+
hasSeparator
|
167
|
+
}));
|
168
|
+
})))), table.getRowModel().rows.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(FocusScope, {
|
152
169
|
autoFocus: tableMeta.editing.isEditing
|
153
170
|
}, /*#__PURE__*/React__default.createElement("div", {
|
154
171
|
onMouseDownCapture: handleMouseCapture,
|
@@ -187,6 +204,7 @@ const Table3 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
187
204
|
}));
|
188
205
|
});
|
189
206
|
Table3.Column = Column;
|
207
|
+
Table3.Group = Group;
|
190
208
|
|
191
209
|
export { Table3, fixedForwardRef };
|
192
210
|
//# sourceMappingURL=Table3.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\n\ntype FixedForwardRef = <T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => JSX.Element\n) => (props: P & React.RefAttributes<T>) => JSX.Element;\n\n// Cast the old forwardRef to the new one\nexport const fixedForwardRef = React.forwardRef as FixedForwardRef;\n\nconst Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const { emptyState: EmptyState, customSettings, toolbarLeft, toolbarRight } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (eventOriginatedFromCombobox || (dialog && !dialog?.contains(internalRef.current))) {\n return;\n }\n\n tableMeta.hoverState.handleKeyDown(event);\n tableMeta.currentRow.handleKeyDown(\n event,\n table.getRowModel().rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing,\n internalRef\n );\n tableMeta.rowClick.handleKeyDown(event, table);\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.currentRow.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n // mouse capture fires before focus, so we can prevent propagation and stop double setting of the active row\n const handleMouseCapture =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.MouseEvent) => {\n tableMeta.currentRow.handleMouseCapture(event, table.getRowModel().rows.length);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === 'small',\n 'text-sm': tableMeta.fontSize.size === 'medium',\n 'text-base': tableMeta.fontSize.size === 'large',\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(table, tableMeta.isPrinting, tableMeta.rowActions.actionsForRowLength);\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.hoverState.isPaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map(header => (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, { ...header.getContext(), scrollToIndex })}\n </React.Fragment>\n ))}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div\n onMouseDownCapture={handleMouseCapture}\n className=\"group/body contents\"\n data-taco=\"table2-body\"\n role=\"rowgroup\"\n ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div className=\"border-grey-300 col-span-full translate-y-px border-t\" />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {table.getFooterGroups().map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))}\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3FontSize,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","fixedForwardRef","React","forwardRef","Table","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","hoverState","currentRow","getRowModel","rows","editing","isEditing","rowClick","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","undefined","handleFocus","currentRowIndex","handleMouseCapture","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","style","cssGridStyle","useCssGrid","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","horizontallyScrolled","isPaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","Fragment","flexRender","column","columnDef","getContext","FocusScope","onMouseDownCapture","enableFooter","getFooterGroups","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AAMA;MACaC,eAAe,GAAGC,cAAK,CAACC;AAErC,MAAMC,KAAK,gBAAGH,eAAe,CAAC,SAASI,M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,KAAK,CAACiH,QAAQ,CAAC;;;EAGlD,MAAMlB,GAAG,GAAGnG,cAAK,CAACsH,OAAO,CAAC,MAAMF,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAOnH,6BAACE,KAAK,oBAAYE,KAAK;IAAE+F,GAAG,EAAEA,GAAG;IAAE9F,GAAG,EAAEA;KAAO;AAC1D,CAAC;AACDF,MAAM,CAACN,MAAM,GAAGA,MAAM;;;;"}
|
1
|
+
{"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3GroupProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\nimport { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle';\nimport { FONT_SIZE } from './components/toolbar/FontSize';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: Table3GroupProps) {\n return null;\n}\nGroup.displayName = 'Table3Group';\n\ntype FixedForwardRef = <T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => JSX.Element\n) => (props: P & React.RefAttributes<T>) => JSX.Element;\n\n// Cast the old forwardRef to the new one\nexport const fixedForwardRef = React.forwardRef as FixedForwardRef;\n\nconst Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const { emptyState: EmptyState, customSettings, toolbarLeft, toolbarRight } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (eventOriginatedFromCombobox || (dialog && !dialog?.contains(internalRef.current))) {\n return;\n }\n\n tableMeta.hoverState.handleKeyDown(event);\n tableMeta.currentRow.handleKeyDown(\n event,\n table.getRowModel().rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing,\n internalRef\n );\n tableMeta.rowClick.handleKeyDown(event, table);\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.currentRow.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n // mouse capture fires before focus, so we can prevent propagation and stop double setting of the active row\n const handleMouseCapture =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.MouseEvent) => {\n tableMeta.currentRow.handleMouseCapture(event, table.getRowModel().rows.length);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === FONT_SIZE.small,\n 'text-sm': tableMeta.fontSize.size === FONT_SIZE.medium,\n 'text-base': tableMeta.fontSize.size === FONT_SIZE.large,\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(\n table,\n tableMeta.isPrinting,\n tableMeta.rowActions.actionsForRowLength,\n tableMeta.fontSize.size\n );\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n {headerOffsetStyle ? <style data-taco=\"table3-column-header-offset-styles\">{headerOffsetStyle}</style> : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.hoverState.isPaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map((header, index) => {\n // We need to render separator if column is not the last in array, if index is not equal to freeze column index,\n // if next element is not placeholder and if column itself is not placeholder.\n const hasSeparator =\n index !== tableMeta.columnFreezing.frozenColumnIndex &&\n index !== headerGroup.headers.length - 1 &&\n (!headerGroup.headers[index + 1]?.isPlaceholder || !header.isPlaceholder);\n return (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, {\n ...header.getContext(),\n scrollToIndex,\n hasSeparator,\n })}\n </React.Fragment>\n );\n })}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div\n onMouseDownCapture={handleMouseCapture}\n className=\"group/body contents\"\n data-taco=\"table2-body\"\n role=\"rowgroup\"\n ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div className=\"border-grey-300 col-span-full translate-y-px border-t\" />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {table.getFooterGroups().map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))}\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\nTable3.Group = Group;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3FontSize,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","displayName","Group","fixedForwardRef","React","forwardRef","Table","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","hoverState","currentRow","getRowModel","rows","editing","isEditing","rowClick","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","undefined","handleFocus","currentRowIndex","handleMouseCapture","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","FONT_SIZE","small","medium","large","style","cssGridStyle","useCssGrid","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","headerOffsetStyle","useHeaderOffsetStyle","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","horizontallyScrolled","isPaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","index","hasSeparator","frozenColumnIndex","_headerGroup$headers","isPlaceholder","Fragment","flexRender","column","columnDef","getContext","FocusScope","onMouseDownCapture","enableFooter","getFooterGroups","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AACAD,MAAM,CAACE,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACF,CAAmB;EAC9B,OAAO,IAAI;AACf;AACAE,KAAK,CAACD,WAAW,GAAG,aAAa;AAMj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AW,CAAChB,OAAO,CAACH,GAAG,CAACoB,MAAM,iBAC3B3H,6BAACA,cAAK,CAACiH,QAAQ;IAACR,GAAG,EAAEkB,MAAM,CAACxC;KACvB+B,UAAU,CAACS,MAAM,CAACR,MAAM,CAACC,SAAS,CAACO,MAAM,EAAEA,MAAM,CAACN,UAAU,EAAE,CAAC,CAEvE,CAAC,CAET,CAAC,EACDvG,MAAM,gBACHd,6BAAC4H,OAAO;IAACC,aAAa,EAAEhH,KAAK,CAAC4B,WAAW,EAAE,CAACC,IAAI,CAAC5B,MAAM;IAAEA,MAAM,EAAEA,MAAM;IAAED,KAAK,EAAEA;IAAS,GACzF,IAAI,CACN,GACN,IAAI,CACT,gBAEHb;IAAK8D,SAAS,EAAC;KAA0CvD,UAAU,gBAAGP,6BAACO,UAAU,OAAG,GAAG,IAAI,CAC9F,CACC,CACP;AAEX,CAAC,CAAC;MAOWJ,MAAM,gBAAGJ,eAAe,CAAC,SAASI,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EACvH,MAAMyH,mBAAmB,GAAGC,MAAM,CAAC3H,KAAK,CAAC4H,QAAQ,CAAC;;;EAGlD,MAAMvB,GAAG,GAAGzG,cAAK,CAACiI,OAAO,CAAC,MAAMF,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAO9H,6BAACE,KAAK,oBAAYE,KAAK;IAAEqG,GAAG,EAAEA,GAAG;IAAEpG,GAAG,EAAEA;KAAO;AAC1D,CAAC;AACDF,MAAM,CAACR,MAAM,GAAGA,MAAM;AACtBQ,MAAM,CAACL,KAAK,GAAGA,KAAK;;;;"}
|
@@ -27,10 +27,7 @@ function DisplayCell(props) {
|
|
27
27
|
return {
|
28
28
|
align: columnMeta.align,
|
29
29
|
children: (_ref = (_ref2 = (_props$children = props.children) !== null && _props$children !== void 0 ? _props$children : (_columnMeta$renderer = columnMeta.renderer) === null || _columnMeta$renderer === void 0 ? void 0 : _columnMeta$renderer.call(columnMeta, value, row.original)) !== null && _ref2 !== void 0 ? _ref2 : value) !== null && _ref !== void 0 ? _ref : null,
|
30
|
-
className: cn(className,
|
31
|
-
// we alias to any because className conflicts with the Table2 definition,
|
32
|
-
// when Table2 is gone, remove this as any
|
33
|
-
typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className),
|
30
|
+
className: cn(className, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className),
|
34
31
|
data: row.original,
|
35
32
|
debug: table.options.debugAll,
|
36
33
|
enableTruncate: columnMeta.enableTruncate,
|
@@ -79,7 +76,7 @@ const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDispla
|
|
79
76
|
index,
|
80
77
|
tableRef
|
81
78
|
} = props;
|
82
|
-
const layoutClassName = cn('py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none', customClassName);
|
79
|
+
const layoutClassName = cn('py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto', customClassName);
|
83
80
|
const className = highlighted ? undefined : layoutClassName;
|
84
81
|
const content = enableTruncate ? /*#__PURE__*/React__default.createElement("span", {
|
85
82
|
className: "truncate"
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { isCellHighlighted, scrollColumnIntoView } from '../../../util/columns';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n className?: string;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, getValue, index, row, table, tableRef } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { rowIndex } = React.useContext(RowContext);\n\n const value = getValue();\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n // we alias to any because className conflicts with the Table2 definition,\n // when Table2 is gone, remove this as any\n typeof columnMeta.className === 'function' ? (columnMeta.className as any)(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);\n\n const memoedHighlight = React.useMemo(() => {\n if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {\n return false;\n }\n\n if (tableMeta.search.query?.length) {\n return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);\n }\n\n return false;\n }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);\n\n const memoedHighlightCurrent = React.useMemo(() => {\n if (\n !tableMeta.search.isHighlightingEnabled ||\n !memoedHighlight ||\n tableMeta.search.currentHighlightColumnIndex === undefined\n ) {\n return false;\n }\n\n const [currentRowIndex, currentColumnIndex] =\n tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (currentRowIndex === rowIndex && currentColumnIndex === index) {\n return true;\n }\n\n return false;\n }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);\n\n return (\n <MemoedDisplayCell<TType> {...memoedProps} highlighted={memoedHighlight} highlightedAsCurrent={memoedHighlightCurrent} />\n );\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted: boolean;\n highlightedAsCurrent: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n\nconst Highlight = props => {\n const { current, frozenColumnIndex, index, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const className = cn('h-full flex [justify-content:inherit] [text-align:inherit]', props.className, {\n // normal row\n 'bg-blue-200/25': !current,\n // current row\n 'bg-blue-200/75': current,\n });\n\n React.useEffect(() => {\n if (ref.current && current) {\n scrollColumnIntoView(index, frozenColumnIndex, ref.current, tableRef.current);\n }\n }, [current]);\n\n return <div {...attributes} className={className} ref={ref} />;\n};\n"],"names":["DisplayCell","props","cell","className","column","getValue","index","row","table","tableRef","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","rowIndex","useContext","RowContext","value","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","memoedHighlight","search","isHighlightingEnabled","enableSearch","_tableMeta$search$que","query","length","isCellHighlighted","dataType","excludeUnmatchedResults","memoedHighlightCurrent","currentHighlightColumnIndex","undefined","currentRowIndex","currentColumnIndex","highlightedColumnIndexes","MemoedDisplayCell","highlighted","highlightedAsCurrent","memo","customClassName","layoutClassName","content","console","log","role","tabIndex","Highlight","current","attributes","ref","useRef","useEffect","scrollColumnIntoView"],"mappings":";;;;;SAYgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,GAAG;IAAEC,KAAK;IAAEC;GAAU,GAAGR,KAAK;EAChF,MAAMS,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMR,MAAM,CAACS,SAAS,CAACC,IAAkC,EAAE,EAAE,CAAC;EAC/F,MAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACF,IAAwB;EACxD,MAAM;IAAEG;GAAU,GAAGN,cAAK,CAACO,UAAU,CAACC,UAAU,CAAC;EAEjD,MAAMC,KAAK,GAAGf,QAAQ,EAAE;;;EAIxB,MAAMgB,WAAW,GAAGV,cAAK,CAACC,OAAO,CAAC;;IAC9B,OAAO;MACHU,KAAK,EAAEZ,UAAU,CAACY,KAAK;MACvBC,QAAQ,GAAAC,IAAA,IAAAC,KAAA,IAAAC,eAAA,GAAGzB,KAAK,CAACsB,QAAQ,cAAAG,eAAA,cAAAA,eAAA,IAAAC,oBAAA,GAAIjB,UAAU,CAACkB,QAAQ,cAAAD,oBAAA,uBAAnBA,oBAAA,CAAAE,IAAA,CAAAnB,UAA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../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { isCellHighlighted, scrollColumnIntoView } from '../../../util/columns';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n className?: string;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, getValue, index, row, table, tableRef } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { rowIndex } = React.useContext(RowContext);\n\n const value = getValue();\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);\n\n const memoedHighlight = React.useMemo(() => {\n if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {\n return false;\n }\n\n if (tableMeta.search.query?.length) {\n return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);\n }\n\n return false;\n }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);\n\n const memoedHighlightCurrent = React.useMemo(() => {\n if (\n !tableMeta.search.isHighlightingEnabled ||\n !memoedHighlight ||\n tableMeta.search.currentHighlightColumnIndex === undefined\n ) {\n return false;\n }\n\n const [currentRowIndex, currentColumnIndex] =\n tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (currentRowIndex === rowIndex && currentColumnIndex === index) {\n return true;\n }\n\n return false;\n }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);\n\n return (\n <MemoedDisplayCell<TType> {...memoedProps} highlighted={memoedHighlight} highlightedAsCurrent={memoedHighlightCurrent} />\n );\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted: boolean;\n highlightedAsCurrent: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n\nconst Highlight = props => {\n const { current, frozenColumnIndex, index, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const className = cn('h-full flex [justify-content:inherit] [text-align:inherit]', props.className, {\n // normal row\n 'bg-blue-200/25': !current,\n // current row\n 'bg-blue-200/75': current,\n });\n\n React.useEffect(() => {\n if (ref.current && current) {\n scrollColumnIntoView(index, frozenColumnIndex, ref.current, tableRef.current);\n }\n }, [current]);\n\n return <div {...attributes} className={className} ref={ref} />;\n};\n"],"names":["DisplayCell","props","cell","className","column","getValue","index","row","table","tableRef","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","rowIndex","useContext","RowContext","value","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","memoedHighlight","search","isHighlightingEnabled","enableSearch","_tableMeta$search$que","query","length","isCellHighlighted","dataType","excludeUnmatchedResults","memoedHighlightCurrent","currentHighlightColumnIndex","undefined","currentRowIndex","currentColumnIndex","highlightedColumnIndexes","MemoedDisplayCell","highlighted","highlightedAsCurrent","memo","customClassName","layoutClassName","content","console","log","role","tabIndex","Highlight","current","attributes","ref","useRef","useEffect","scrollColumnIntoView"],"mappings":";;;;;SAYgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,GAAG;IAAEC,KAAK;IAAEC;GAAU,GAAGR,KAAK;EAChF,MAAMS,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMR,MAAM,CAACS,SAAS,CAACC,IAAkC,EAAE,EAAE,CAAC;EAC/F,MAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACF,IAAwB;EACxD,MAAM;IAAEG;GAAU,GAAGN,cAAK,CAACO,UAAU,CAACC,UAAU,CAAC;EAEjD,MAAMC,KAAK,GAAGf,QAAQ,EAAE;;;EAIxB,M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O,EAAE;MACxBK,oBAAoB,CAAClE,KAAK,EAAE8B,iBAAiB,EAAEiC,GAAG,CAACF,OAAO,EAAE1D,QAAQ,CAAC0D,OAAO,CAAC;;GAEpF,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,oBAAOxD,sDAASyD,UAAU;IAAEjE,SAAS,EAAEA,SAAS;IAAEkE,GAAG,EAAEA;KAAO;AAClE,CAAC;;;;"}
|
@@ -108,10 +108,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
108
108
|
'z-[9]': isCurrentRow && controlRenderer === 'textarea'
|
109
109
|
},
|
110
110
|
// component overrides - grayscale for editing hover
|
111
|
-
'[[role="row"][data-current="false"]:hover_&>*]:!grayscale [[role="row"][data-current="false"]:hover_&_.bg-white]:!bg-grey-100',
|
112
|
-
// we alias to any because className conflicts with the Table2 definition,
|
113
|
-
// when Table2 is gone, remove this as any
|
114
|
-
typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
111
|
+
'[[role="row"][data-current="false"]:hover_&>*]:!grayscale [[role="row"][data-current="false"]:hover_&_.bg-white]:!bg-grey-100', typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
115
112
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && /*#__PURE__*/React__default.createElement(Indicator, {
|
116
113
|
reason: moveReason,
|
117
114
|
columnName: String(cell.column.columnDef.header),
|