@economic/taco 2.45.3 → 2.46.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Provider/Localization.d.ts +2 -0
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/components/Table3/Table3.d.ts +2 -14
- package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +1 -2
- package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +7 -0
- package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +14 -0
- package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +11 -0
- package/dist/components/Table3/features/useEditingState.d.ts +29 -0
- package/dist/components/Table3/features/useTableEditing.d.ts +26 -36
- package/dist/components/Table3/listeners/useTableEditingListener.d.ts +1 -1
- package/dist/components/Table3/types.d.ts +24 -8
- package/dist/components/Table3/useTable3.d.ts +6 -0
- package/dist/components/Table3/util/editing.d.ts +7 -1
- package/dist/esm/index.css +28 -4
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
- package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -3
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +14 -6
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js +1 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +25 -15
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +5 -37
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +17 -12
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +34 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +103 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -14
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +96 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +39 -6
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +4 -17
- package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +519 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +29 -406
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +44 -33
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +27 -9
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js +11 -23
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +1 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +9 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +9 -7
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +4 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +29 -7
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowSelection.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowSelection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +11 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +7 -4
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/index.css +28 -4
- package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +3 -1
- package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +1 -0
- package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
- package/dist/primitives/Table/Core/types.d.ts +4 -0
- package/dist/primitives/Table/Core/useTable.d.ts +2 -2
- package/dist/primitives/Table/types.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
- package/dist/taco.cjs.development.js +982 -661
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/dom.d.ts +1 -0
- package/package.json +2 -2
- package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +0 -90
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2CreateDialogRenderer,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName, filterOption, getFontSize } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { isGroup, useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement, isElementInsideTable3OrReport } from '../../utils/dom';\nimport { FontSize, FontSizes } from '../../types';\nimport { Button } from '../Button/Button';\nimport { Spinner } from '../Spinner/Spinner';\nimport { debounce } from '../../utils/debounce';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n selectAll: string;\n selectAllResults: string;\n deselectAll: string;\n deselectAllResults: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n /** Autofocus Select2 when loaded **/\n autoFocus?: boolean;\n /** Array of options in Select2 */\n children: Select2Children;\n /** Initial value of the input in Select2 */\n defaultValue?: Select2Value;\n /** Set what value should have an empty option in Select2 */\n emptyValue?: Select2OptionValue;\n /** Whether the Select2 is in a disabled state **/\n disabled?: boolean;\n /** Font size of text in Select2 **/\n fontSize?: FontSize;\n /** Draws attention to the Select2 by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Whether the Select2 is in an invalid state **/\n invalid?: boolean;\n /** Whether the Select2 is loading the data **/\n loading?: boolean;\n /** Whether the Select2 allows selecting multiple values **/\n multiple?: boolean;\n /** Whether the Select2 is in an invalid state **/\n name?: string;\n /** Handler called when user chooses an option from the provided options **/\n onChange?: (value: Select2Value) => void;\n /** Handler called when user creates a new option **/\n onCreate?: Select2CreateHandler;\n /** Handler called when user deletes an option **/\n onDelete?: Select2DeleteHandler;\n /** Handler called when user edits an option **/\n onEdit?: Select2EditHandler;\n /** Placeholder showed when nothing is selected **/\n placeholder?: string;\n /** Whether the Select2 is in a readonly state **/\n readOnly?: boolean;\n required?: boolean;\n /** Renders select options as tags **/\n tags?: boolean;\n /** Value of the input in select2 */\n value?: Select2Value;\n /** Create dialog component, if specified, then create button will become always visible in the bottom of options dropdown,\n * when clicked, it will open create dialog and wait for 'onCreate' handler to be triggered from the dialog */\n createDialog?: Select2CreateDialogRenderer;\n /** Create button text */\n createTriggerText?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n fontSize,\n highlighted = false,\n invalid = false,\n loading,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n placeholder,\n readOnly = false,\n tags = false,\n value: prop,\n createDialog,\n createTriggerText,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n createDialog,\n createTriggerText,\n };\n\n const hasInlineCreation = onCreate && !createDialog;\n const hasSearch = flattenedChildren.length > 5 || hasInlineCreation;\n const visibleChildren = searchQuery === '' ? initialChildren : filteredChildren;\n const selectOptions =\n searchQuery === ''\n ? flattenedChildren.map(child => child.props.value)\n : filteredChildren\n .map(child =>\n isGroup(child)\n ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value)\n : child.props.value\n )\n .flatMap(c => c) || [];\n\n // support typeahead functionality when search isn't available\n const queryTimeoutRef = React.useRef('');\n\n const typeahead = debounce(function () {\n if (!queryTimeoutRef.current) {\n return;\n }\n\n const matchedValueIndex = visibleChildren.findIndex(child =>\n filterOption(child as React.ReactElement<Select2OptionProps>, queryTimeoutRef.current)\n );\n\n if (matchedValueIndex > -1) {\n setValue(selectOptions[matchedValueIndex]);\n }\n\n queryTimeoutRef.current = '';\n }, 200);\n\n const setValueIfMatched = (query: string) => {\n queryTimeoutRef.current = queryTimeoutRef.current + query;\n typeahead();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (isElementInsideTable3OrReport(event.currentTarget)) {\n return;\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n\n if (!hasSearch) {\n setValueIfMatched(event.key);\n }\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n const shouldFocusNextRef = React.useRef<boolean>(false);\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n return;\n }\n\n if (event.key === 'Tab') {\n shouldFocusNextRef.current = true;\n setOpen(false);\n return;\n }\n\n // support typeahead to set the value by typing its text\n if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {\n setValueIfMatched(event.key);\n return;\n }\n };\n\n // popover closes and unmounts before any event can be used to focus next, so prevent focusing the trigger and focus next\n const handleCloseAutoFocus = event => {\n if (shouldFocusNextRef.current) {\n event.preventDefault();\n shouldFocusNextRef.current = false;\n otherProps.onBlur?.(event as any);\n getNextFocussableElement(internalRef.current)?.focus();\n return;\n }\n };\n\n const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option as string));\n\n const selectAllText = React.useMemo(() => {\n if (searchQuery === '') {\n if (areAllSelected) {\n return texts.select2.deselectAll;\n } else {\n return texts.select2.selectAll;\n }\n } else if (areAllSelected) {\n return texts.select2.deselectAllResults;\n } else {\n return texts.select2.selectAllResults;\n }\n }, [areAllSelected, searchQuery]);\n\n const selectAll = () => {\n if (!Array.isArray(value) || value.length === 0) {\n setValue(selectOptions);\n } else {\n // array of all available options which are not selected\n const preselectedValues = selectOptions.filter(option => !value.includes(option));\n setValue([...value, ...preselectedValues]);\n }\n };\n\n const deselectAll = () => {\n if (searchQuery === '') {\n setValue([]);\n } else {\n const nextValue = Array.isArray(value) && value.filter(subValue => !selectOptions.includes(subValue as string));\n setValue(nextValue);\n }\n };\n\n const className = cn(\n 'border-grey-300 rounded border bg-white py-1.5 shadow-md ',\n {\n 'focus-within:yt-focus': !hasSearch,\n 'outline-none': hasSearch,\n },\n createCollectionClassName()\n );\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={internalRef}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onCloseAutoFocus={handleCloseAutoFocus}\n onPointerDownOutside={otherProps.onBlur as any}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {hasSearch ? (\n <>\n <Search\n placeholder={hasInlineCreation ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n />\n {multiple && selectOptions.length > 1 && (\n <>\n <Button\n className=\"!justify-start\"\n appearance=\"discrete\"\n onClick={areAllSelected ? deselectAll : selectAll}>\n {selectAllText}\n </Button>\n <div className=\"border-grey-300 mx-3 rounded border-t\" />\n </>\n )}\n </>\n ) : null}\n {loading ? (\n <span className={cn('text-grey-700 flex items-center italic', fontSize && getFontSize(fontSize))}>\n <span>\n <Spinner\n delay={0}\n className={cn('ml-3 mr-2 mt-1.5 h-5 w-5', {\n '!mt-1 !h-3.5 !w-3.5': fontSize === FontSizes.small,\n '!h-4 !w-4': fontSize === FontSizes.medium,\n '!h-5 !w-5': fontSize === FontSizes.large,\n })}\n />\n </span>\n <span>{texts.listbox.loading}</span>\n </span>\n ) : flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n {texts.listbox.empty}\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5 focus-visible:outline-none\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n value={value}>\n <Collection>{visibleChildren}</Collection>\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\nconst ControlledHiddenField = props => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} tabIndex={-1} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","fontSize","highlighted","invalid","loading","multiple","name","onChange","onCreate","onDelete","onEdit","placeholder","readOnly","tags","value","prop","createDialog","createTriggerText","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","open","setOpen","useState","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","hasInlineCreation","hasSearch","length","visibleChildren","selectOptions","map","child","isGroup","Array","isArray","subChild","flatMap","c","queryTimeoutRef","typeahead","debounce","current","matchedValueIndex","findIndex","filterOption","setValueIfMatched","query","handleKeyDown","event","preventDefault","isElementInsideTable3OrReport","currentTarget","ctrlKey","metaKey","test","_listboxRef$current","dispatchEvent","createCustomKeyboardEvent","shouldFocusNextRef","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","_otherProps$onBlur","_getNextFocussableEle","onBlur","call","getNextFocussableElement","focus","areAllSelected","every","option","includes","selectAllText","select2","deselectAll","selectAll","deselectAllResults","selectAllResults","preselectedValues","filter","nextValue","subValue","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","asChild","Trigger","onKeyDown","align","onCloseAutoFocus","onPointerDownOutside","sideOffset","tabIndex","style","minWidth","width","Search","searchOrCreate","search","Button","appearance","onClick","getFontSize","Spinner","delay","FontSizes","small","medium","large","listbox","role","empty","customSelector","Collection","Create","options","ControlledHiddenField","parentRef","Group","Title","isFormControl","useIsFormControl","bubbleValue","String","BubbleSelect","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4GMA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASF,OAAOA,CAACG,KAAK,EAAEC,GAAG;EACzF,MAAM;IACFC,QAAQ,EAAEC,YAAY;IACtBC,YAAY,EAAEC,WAAW;IACzBC,QAAQ,GAAG,KAAK;IAChBC,UAAU,GAAGC,SAAS;IACtBC,QAAQ;IACRC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,OAAO;IACPC,QAAQ,GAAG,KAAK;IAChBC,IAAI;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNC,WAAW;IACXC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,KAAK,EAAEC,IAAI;IACXC,YAAY;IACZC,iBAAiB;IACjB,GAAGC;GACN,GAAG1B,KAAK;EAET,MAAM2B,WAAW,GAAuD7B,cAAK,CAAC8B,OAAO,CAAC;IAClF,IAAIrB,UAAU,KAAKC,SAAS,IAAI,CAACK,QAAQ,EAAE;;MAEvC,oBAAOf,6BAAC+B,MAAM;QAACC,GAAG,EAAC,SAAS;QAAC5B,QAAQ,EAAC,EAAE;QAACoB,KAAK,EAAEf,UAAU;QAAEwB,SAAS,EAAC;QAAQ;;IAElF;GACH,EAAE,CAACxB,UAAU,EAAEM,QAAQ,CAAC,CAAC;EAE1B,MAAMmB,eAAe,GAAGlC,cAAK,CAAC8B,OAAO,CAAC;IAClC,IAAID,WAAW,EAAE;MACb,OAAO,CAACA,WAAW,EAAE,GAAGxB,YAAY,CAAoB;;IAE5D,OAAOA,YAAY;GACtB,EAAE,CAACwB,WAAW,EAAExB,YAAY,CAAC,CAAC;;EAG/B,MAAM8B,WAAW,GAAGC,YAAY,CAAoBj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,QAAQ,EAAE;QACVmJ,WAAW,GAAG5F,KAAK,CAACC,OAAO,CAAC/C,KAAK,CAAC,GAAGA,KAAK,CAAC2C,GAAG,CAACgG,MAAM,CAAC,GAAG,CAAC3I,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG2I,MAAM,CAAC3I,KAAK,CAAC,CAAC;OACjG,MAAM;QACH0I,WAAW,GAAG1I,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG2I,MAAM,CAAC3I,KAAK,CAAC;;;IAIzD,oBACIxB,6BAACoK,YAAY;;MAAapI,GAAG,EAAEmI,MAAM,CAACD,WAAW,CAAC;MAAEnJ,QAAQ,EAAEA,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEoH,QAAQ,EAAE,CAAC,CAAC;MAAE5G,KAAK,EAAE0I;OACpGzJ,UAAU,KAAKC,SAAS,gBAAGV;MAAQwB,KAAK,EAAEf;MAAc,GAAG,IAAI,EAC/DkJ,OAAO,CAACxF,GAAG,CAACwC,MAAM,kBACf3G;MAAQgC,GAAG,EAAEmI,MAAM,CAACxD,MAAM,CAAC;MAAEnF,KAAK,EAAE2I,MAAM,CAACxD,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACD5G,OAAO,CAACsK,WAAW,GAAG,SAAS;;;;"}
|
1
|
+
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport * as ListboxPrimitive from '../../primitives/Listbox2/Listbox2';\nimport {\n Select2Children,\n Select2CreateHandler,\n Select2CreateDialogRenderer,\n Select2DeleteHandler,\n Select2EditHandler,\n Select2OptionValue,\n Select2Value,\n} from './types';\nimport { Option, Select2OptionProps } from './components/Option';\nimport { Group, Select2GroupProps } from './components/Group';\nimport { Select2TitleProps, Title } from './components/Title';\nimport { Select2Context } from './components/Context';\nimport { createCollectionClassName, filterOption, getFontSize } from './utilities';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { createCustomKeyboardEvent } from '../../utils/input';\nimport { Trigger } from './components/Trigger';\nimport { useIsFormControl } from '../../hooks/useIsFormControl';\nimport { BubbleSelect } from '../../primitives/BubbleSelect';\nimport { Search } from './components/Search';\nimport { isGroup, useChildren } from './hooks/useChildren';\n\nimport { Create } from './components/Create';\nimport { Collection } from './components/Collection';\nimport { CollectionRef } from '../../primitives/Collection/Collection';\nimport { useLocalization } from '../Provider/Localization';\nimport { useIsHoverStatePaused } from '../../hooks/useIsHoverStatePaused';\nimport { isAriaDirectionKey } from '../../utils/aria';\nimport { getNextFocussableElement, isElementInsideTable3OrReport } from '../../utils/dom';\nimport { FontSize, FontSizes } from '../../types';\nimport { Button } from '../Button/Button';\nimport { Spinner } from '../Spinner/Spinner';\nimport { debounce } from '../../utils/debounce';\n\ntype Select2Texts = {\n allSelect: string;\n allDeselect: string;\n cancel: string;\n chooseColor: string;\n create: string;\n delete: string;\n save: string;\n search: string;\n searchOrCreate: string;\n selectAll: string;\n selectAllResults: string;\n deselectAll: string;\n deselectAllResults: string;\n};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n /** Autofocus Select2 when loaded **/\n autoFocus?: boolean;\n /** Array of options in Select2 */\n children: Select2Children;\n /** Initial value of the input in Select2 */\n defaultValue?: Select2Value;\n /** Set what value should have an empty option in Select2 */\n emptyValue?: Select2OptionValue;\n /** Whether the Select2 is in a disabled state **/\n disabled?: boolean;\n /** Font size of text in Select2 **/\n fontSize?: FontSize;\n /** Draws attention to the Select2 by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Whether the Select2 is in an invalid state **/\n invalid?: boolean;\n /** Whether the Select2 is loading the data **/\n loading?: boolean;\n /** Whether the Select2 allows selecting multiple values **/\n multiple?: boolean;\n /** Whether the Select2 is in an invalid state **/\n name?: string;\n /** Handler called when user chooses an option from the provided options **/\n onChange?: (value: Select2Value) => void;\n /** Handler called when user creates a new option **/\n onCreate?: Select2CreateHandler;\n /** Handler called when user deletes an option **/\n onDelete?: Select2DeleteHandler;\n /** Handler called when user edits an option **/\n onEdit?: Select2EditHandler;\n /** Placeholder showed when nothing is selected **/\n placeholder?: string;\n /** Whether the Select2 is in a readonly state **/\n readOnly?: boolean;\n required?: boolean;\n /** Renders select options as tags **/\n tags?: boolean;\n /** Value of the input in select2 */\n value?: Select2Value;\n /** Create dialog component, if specified, then create button will become always visible in the bottom of options dropdown,\n * when clicked, it will open create dialog and wait for 'onCreate' handler to be triggered from the dialog */\n createDialog?: Select2CreateDialogRenderer;\n /** Create button text */\n createTriggerText?: string;\n};\ntype Select2PropsWithStatics = React.ForwardRefExoticComponent<Select2Props & React.RefAttributes<HTMLButtonElement>> & {\n Option: React.ForwardRefExoticComponent<Select2OptionProps>;\n Group: React.ForwardRefExoticComponent<Select2GroupProps>;\n Title: React.ForwardRefExoticComponent<Select2TitleProps>;\n};\n\nconst Select2 = React.forwardRef<HTMLButtonElement, Select2Props>(function Select2(props, ref) {\n const {\n children: initChildren,\n defaultValue: defaultProp,\n disabled = false,\n emptyValue = undefined,\n fontSize,\n highlighted = false,\n invalid = false,\n loading,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n placeholder,\n readOnly = false,\n tags = false,\n value: prop,\n createDialog,\n createTriggerText,\n ...otherProps\n } = props;\n\n const emptyOption: React.ReactElement<Select2OptionProps> | undefined = React.useMemo(() => {\n if (emptyValue !== undefined && !multiple) {\n // Empty option has 0px height, because it's empty, so need to apply height manually\n return <Option key=\"__empty\" children=\"\" value={emptyValue} className=\"h-8\" />;\n }\n return;\n }, [emptyValue, multiple]);\n\n const initialChildren = React.useMemo(() => {\n if (emptyOption) {\n return [emptyOption, ...initChildren] as Select2Children;\n }\n return initChildren;\n }, [emptyOption, initChildren]);\n\n // refs\n const internalRef = useMergedRef<HTMLButtonElement>(ref);\n const listboxRef = React.useRef<CollectionRef>(null);\n const searchRef = React.useRef<HTMLInputElement>(null);\n const { texts } = useLocalization();\n // align the listbox min width with the width of the input - it should never be smaller\n const dimensions = useBoundingClientRectListener(internalRef);\n\n // state\n const [open, setOpen] = React.useState(false);\n const [value, _setValue] = useControllableState<Select2Value>({\n // uncontrolled\n defaultProp,\n // controlled\n onChange,\n prop,\n });\n const setValue = ListboxPrimitive.createListboxValueSetter(multiple, _setValue);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n const [shouldPauseHoverState, setShouldPauseHoverState] = useIsHoverStatePaused();\n\n const { flattenedChildren, filteredChildren, searchQuery, setSearchQuery } = useChildren({\n children: initialChildren,\n emptyValue,\n multiple,\n open,\n setValue,\n value,\n });\n\n // context\n const context = {\n disabled,\n highlighted,\n invalid,\n listboxRef,\n multiple,\n onCreate,\n onDelete,\n onEdit,\n open,\n readOnly,\n ref: internalRef,\n searchQuery,\n searchRef,\n setOpen,\n setSearchQuery,\n setValidationError,\n setValue,\n shouldPauseHoverState,\n setShouldPauseHoverState,\n tags,\n fontSize,\n validationError,\n value,\n createDialog,\n createTriggerText,\n };\n\n const hasInlineCreation = onCreate && !createDialog;\n const hasSearch = flattenedChildren.length > 5 || hasInlineCreation;\n const visibleChildren = searchQuery === '' ? initialChildren : filteredChildren;\n const selectOptions =\n searchQuery === ''\n ? flattenedChildren.map(child => child.props.value)\n : filteredChildren\n .map(child =>\n isGroup(child)\n ? Array.isArray(child.props.children) && child.props.children.map(subChild => subChild.props.value)\n : child.props.value\n )\n .flatMap(c => c) || [];\n\n // support typeahead functionality when search isn't available\n const queryTimeoutRef = React.useRef('');\n\n const typeahead = debounce(function () {\n if (!queryTimeoutRef.current) {\n return;\n }\n\n const matchedValueIndex = visibleChildren.findIndex(child =>\n filterOption(child as React.ReactElement<Select2OptionProps>, queryTimeoutRef.current)\n );\n\n if (matchedValueIndex > -1) {\n setValue(selectOptions[matchedValueIndex]);\n }\n\n queryTimeoutRef.current = '';\n }, 200);\n\n const setValueIfMatched = (query: string) => {\n queryTimeoutRef.current = queryTimeoutRef.current + query;\n typeahead();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (isElementInsideTable3OrReport(event.currentTarget) && isAriaDirectionKey(event)) {\n return;\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\n\n if (!hasSearch) {\n setValueIfMatched(event.key);\n }\n }\n\n // the focus should always remain on the input, so we forward events on to the listbox\n listboxRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n };\n\n const shouldFocusNextRef = React.useRef<boolean>(false);\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n return;\n }\n\n if (event.key === 'Tab') {\n shouldFocusNextRef.current = true;\n setOpen(false);\n return;\n }\n\n // support typeahead to set the value by typing its text\n if (!hasSearch && /^[a-z0-9]$/i.test(event.key)) {\n setValueIfMatched(event.key);\n return;\n }\n };\n\n // popover closes and unmounts before any event can be used to focus next, so prevent focusing the trigger and focus next\n const handleCloseAutoFocus = event => {\n if (shouldFocusNextRef.current) {\n event.preventDefault();\n shouldFocusNextRef.current = false;\n otherProps.onBlur?.(event as any);\n getNextFocussableElement(internalRef.current)?.focus();\n return;\n }\n };\n\n const areAllSelected = Array.isArray(value) && selectOptions.every(option => value.includes(option as string));\n\n const selectAllText = React.useMemo(() => {\n if (searchQuery === '') {\n if (areAllSelected) {\n return texts.select2.deselectAll;\n } else {\n return texts.select2.selectAll;\n }\n } else if (areAllSelected) {\n return texts.select2.deselectAllResults;\n } else {\n return texts.select2.selectAllResults;\n }\n }, [areAllSelected, searchQuery]);\n\n const selectAll = () => {\n if (!Array.isArray(value) || value.length === 0) {\n setValue(selectOptions);\n } else {\n // array of all available options which are not selected\n const preselectedValues = selectOptions.filter(option => !value.includes(option));\n setValue([...value, ...preselectedValues]);\n }\n };\n\n const deselectAll = () => {\n if (searchQuery === '') {\n setValue([]);\n } else {\n const nextValue = Array.isArray(value) && value.filter(subValue => !selectOptions.includes(subValue as string));\n setValue(nextValue);\n }\n };\n\n const className = cn(\n 'border-grey-300 rounded border bg-white py-1.5 shadow-md ',\n {\n 'focus-within:yt-focus': !hasSearch,\n 'outline-none': hasSearch,\n },\n createCollectionClassName()\n );\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={internalRef}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onCloseAutoFocus={handleCloseAutoFocus}\n onPointerDownOutside={otherProps.onBlur as any}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {hasSearch ? (\n <>\n <Search\n placeholder={hasInlineCreation ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n />\n {multiple && selectOptions.length > 1 && (\n <>\n <Button\n className=\"!justify-start\"\n appearance=\"discrete\"\n onClick={areAllSelected ? deselectAll : selectAll}>\n {selectAllText}\n </Button>\n <div className=\"border-grey-300 mx-3 rounded border-t\" />\n </>\n )}\n </>\n ) : null}\n {loading ? (\n <span className={cn('text-grey-700 flex items-center italic', fontSize && getFontSize(fontSize))}>\n <span>\n <Spinner\n delay={0}\n className={cn('ml-3 mr-2 mt-1.5 h-5 w-5', {\n '!mt-1 !h-3.5 !w-3.5': fontSize === FontSizes.small,\n '!h-4 !w-4': fontSize === FontSizes.medium,\n '!h-5 !w-5': fontSize === FontSizes.large,\n })}\n />\n </span>\n <span>{texts.listbox.loading}</span>\n </span>\n ) : flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n {texts.listbox.empty}\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5 focus-visible:outline-none\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n value={value}>\n <Collection>{visibleChildren}</Collection>\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n <ControlledHiddenField\n emptyValue={emptyValue}\n multiple={multiple || tags}\n name={name}\n options={flattenedChildren.map(child => child.props.value)}\n parentRef={internalRef}\n setValue={setValue}\n value={value}\n />\n </PopoverPrimitive.Root>\n </Select2Context.Provider>\n );\n}) as Select2PropsWithStatics;\nSelect2.Option = Option;\nSelect2.Group = Group;\nSelect2.Title = Title;\n\nconst ControlledHiddenField = props => {\n const { emptyValue, multiple, name, options, parentRef, value, setValue } = props;\n const isFormControl = useIsFormControl(parentRef, () => setValue(multiple ? [] : undefined));\n\n let bubbleValue;\n\n if (isFormControl) {\n if (value !== undefined) {\n if (multiple) {\n bubbleValue = Array.isArray(value) ? value.map(String) : [value === null ? '' : String(value)];\n } else {\n bubbleValue = value === null ? '' : String(value);\n }\n }\n\n return (\n <BubbleSelect aria-hidden key={String(bubbleValue)} multiple={multiple} name={name} tabIndex={-1} value={bubbleValue}>\n {emptyValue !== undefined ? <option value={emptyValue} /> : null}\n {options.map(option => (\n <option key={String(option)} value={String(option)} />\n ))}\n </BubbleSelect>\n );\n }\n\n return null;\n};\nSelect2.displayName = 'Select2';\n\nexport { Select2 };\n\nexport type {\n Select2Texts,\n Select2GroupProps,\n Select2OptionProps,\n Select2OptionValue,\n Select2Value,\n Select2Props,\n Select2TitleProps,\n};\n"],"names":["Select2","React","forwardRef","props","ref","children","initChildren","defaultValue","defaultProp","disabled","emptyValue","undefined","fontSize","highlighted","invalid","loading","multiple","name","onChange","onCreate","onDelete","onEdit","placeholder","readOnly","tags","value","prop","createDialog","createTriggerText","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","open","setOpen","useState","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","hasInlineCreation","hasSearch","length","visibleChildren","selectOptions","map","child","isGroup","Array","isArray","subChild","flatMap","c","queryTimeoutRef","typeahead","debounce","current","matchedValueIndex","findIndex","filterOption","setValueIfMatched","query","handleKeyDown","event","preventDefault","isElementInsideTable3OrReport","currentTarget","isAriaDirectionKey","ctrlKey","metaKey","test","_listboxRef$current","dispatchEvent","createCustomKeyboardEvent","shouldFocusNextRef","handleListboxKeyDown","handleCloseAutoFocus","_otherProps$onBlur","_getNextFocussableEle","onBlur","call","getNextFocussableElement","focus","areAllSelected","every","option","includes","selectAllText","select2","deselectAll","selectAll","deselectAllResults","selectAllResults","preselectedValues","filter","nextValue","subValue","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","asChild","Trigger","onKeyDown","align","onCloseAutoFocus","onPointerDownOutside","sideOffset","tabIndex","style","minWidth","width","Search","searchOrCreate","search","Button","appearance","onClick","getFontSize","Spinner","delay","FontSizes","small","medium","large","listbox","role","empty","customSelector","Collection","Create","options","ControlledHiddenField","parentRef","Group","Title","isFormControl","useIsFormControl","bubbleValue","String","BubbleSelect","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4GMA,OA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,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG2I,MAAM,CAAC3I,KAAK,CAAC,CAAC;OACjG,MAAM;QACH0I,WAAW,GAAG1I,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG2I,MAAM,CAAC3I,KAAK,CAAC;;;IAIzD,oBACIxB,6BAACoK,YAAY;;MAAapI,GAAG,EAAEmI,MAAM,CAACD,WAAW,CAAC;MAAEnJ,QAAQ,EAAEA,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEoH,QAAQ,EAAE,CAAC,CAAC;MAAE5G,KAAK,EAAE0I;OACpGzJ,UAAU,KAAKC,SAAS,gBAAGV;MAAQwB,KAAK,EAAEf;MAAc,GAAG,IAAI,EAC/DkJ,OAAO,CAACxF,GAAG,CAACwC,MAAM,kBACf3G;MAAQgC,GAAG,EAAEmI,MAAM,CAACxD,MAAM,CAAC;MAAEnF,KAAK,EAAE2I,MAAM,CAACxD,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACD5G,OAAO,CAACsK,WAAW,GAAG,SAAS;;;;"}
|
@@ -28,7 +28,7 @@ const Switch = /*#__PURE__*/forwardRef(function Switch(props, ref) {
|
|
28
28
|
onCheckedChange: onChange,
|
29
29
|
ref: ref
|
30
30
|
}), /*#__PURE__*/createElement(Thumb, {
|
31
|
-
className: "
|
31
|
+
className: "pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]"
|
32
32
|
}));
|
33
33
|
if (label) {
|
34
34
|
const labelContainerClassName = cn('flex self-start cursor-pointer', {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\nimport { useId } from '../../hooks/useId';\n\ntype SwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /** Label for the switch */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\nexport interface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\nexport interface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { label, onChange, ...otherProps } = props;\n const id = useId(props.id);\n\n const className = cn(\n 'group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus',\n {\n 'mr-2': !!label,\n 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,\n 'bg-grey-500/50 aria-checked:bg-blue-500/50 cursor-not-allowed': props.disabled,\n },\n props.className\n );\n\n let labelledByProps: Record<string, string> | null = null;\n\n if (label) {\n labelledByProps = {\n 'aria-labelledby': `${id}-label`,\n id,\n };\n }\n\n const element = (\n <PrimitiveSwitch.Root\n {...otherProps}\n {...labelledByProps}\n className={className}\n data-taco=\"switch\"\n onCheckedChange={onChange}\n ref={ref}>\n <PrimitiveSwitch.Thumb className=\"
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\nimport { useId } from '../../hooks/useId';\n\ntype SwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /** Label for the switch */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\nexport interface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\nexport interface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { label, onChange, ...otherProps } = props;\n const id = useId(props.id);\n\n const className = cn(\n 'group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus',\n {\n 'mr-2': !!label,\n 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,\n 'bg-grey-500/50 aria-checked:bg-blue-500/50 cursor-not-allowed': props.disabled,\n },\n props.className\n );\n\n let labelledByProps: Record<string, string> | null = null;\n\n if (label) {\n labelledByProps = {\n 'aria-labelledby': `${id}-label`,\n id,\n };\n }\n\n const element = (\n <PrimitiveSwitch.Root\n {...otherProps}\n {...labelledByProps}\n className={className}\n data-taco=\"switch\"\n onCheckedChange={onChange}\n ref={ref}>\n <PrimitiveSwitch.Thumb className=\"pointer-events-none mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform will-change-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]\" />\n </PrimitiveSwitch.Root>\n );\n\n if (label) {\n const labelContainerClassName = cn('flex self-start cursor-pointer', {\n 'cursor-not-allowed text-grey-300': props.disabled,\n });\n\n return (\n <span className={labelContainerClassName} data-taco=\"switch-container\">\n {element}\n <label htmlFor={id} id={`${id}-label`}>\n {label}\n </label>\n </span>\n );\n }\n\n return element;\n});\nSwitch.displayName = 'Switch';\n"],"names":["Switch","React","props","ref","label","onChange","otherProps","id","useId","className","cn","disabled","labelledByProps","element","PrimitiveSwitch","onCheckedChange","labelContainerClassName","htmlFor","displayName"],"mappings":";;;;;MA6BaA,MAAM,gBAAGC,UAAgB,CAAC,SAASD,MAAMA,CAACE,KAAkB,EAAEC,GAAiC;EACxG,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAChD,MAAMK,EAAE,GAAGC,KAAK,CAACN,KAAK,CAACK,EAAE,CAAC;EAE1B,MAAME,SAAS,GAAGC,EAAE,CAChB,kFAAkF,EAClF;IACI,MAAM,EAAE,CAAC,CAACN,KAAK;IACf,uFAAuF,EAAE,CAACF,KAAK,CAACS,QAAQ;IACxG,+DAA+D,EAAET,KAAK,CAACS;GAC1E,EACDT,KAAK,CAACO,SAAS,CAClB;EAED,IAAIG,eAAe,GAAkC,IAAI;EAEzD,IAAIR,KAAK,EAAE;IACPQ,eAAe,GAAG;MACd,iBAAiB,EAAE,GAAGL,EAAE,QAAQ;MAChCA;KACH;;EAGL,MAAMM,OAAO,gBACTZ,cAACa,IAAoB,oBACbR,UAAU,EACVM,eAAe;IACnBH,SAAS,EAAEA,SAAS;iBACV,QAAQ;IAClBM,eAAe,EAAEV,QAAQ;IACzBF,GAAG,EAAEA;mBACLF,cAACa,KAAqB;IAACL,SAAS,EAAC;IAAgM,CAExO;EAED,IAAIL,KAAK,EAAE;IACP,MAAMY,uBAAuB,GAAGN,EAAE,CAAC,gCAAgC,EAAE;MACjE,kCAAkC,EAAER,KAAK,CAACS;KAC7C,CAAC;IAEF,oBACIV;MAAMQ,SAAS,EAAEO,uBAAuB;mBAAY;OAC/CH,OAAO,eACRZ;MAAOgB,OAAO,EAAEV,EAAE;MAAEA,EAAE,EAAE,GAAGA,EAAE;OACxBH,KAAK,CACF,CACL;;EAIf,OAAOS,OAAO;AAClB,CAAC;AACDb,MAAM,CAACkB,WAAW,GAAG,QAAQ;;;;"}
|
@@ -3,8 +3,9 @@ import { fixedForwardRef } from '../../types.js';
|
|
3
3
|
import { Table } from '../../primitives/Table/Core/Table.js';
|
4
4
|
import { useTable3 } from './useTable3.js';
|
5
5
|
import { Alert } from './components/Editing/Alert.js';
|
6
|
-
import CreateNewRowButton from './components/Row/Editing/CreateRowButton.js';
|
7
6
|
import { Editing } from './components/Toolbar/Editing/Editing.js';
|
7
|
+
import { CreateNewRow } from './components/Row/Editing/CreateNewRow.js';
|
8
|
+
import { TemporaryRow } from './components/Row/Editing/TemporaryRow.js';
|
8
9
|
|
9
10
|
function Column(_) {
|
10
11
|
return null;
|
@@ -21,8 +22,8 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
21
22
|
'data-table-editing-mode': (_table3$meta$editing = table3.meta.editing) !== null && _table3$meta$editing !== void 0 && _table3$meta$editing.isEditing ? (_table3$meta$editing2 = table3.meta.editing) !== null && _table3$meta$editing2 !== void 0 && _table3$meta$editing2.isDetailedMode ? 'detailed' : 'normal' : undefined,
|
22
23
|
enableHorizontalArrowKeyNavigation: table3.meta.editing.isEditing
|
23
24
|
};
|
24
|
-
const hasAlertErrors = table3.meta.editing.
|
25
|
-
const
|
25
|
+
const hasAlertErrors = table3.meta.editing.getErrorsShownInAlert().length;
|
26
|
+
const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;
|
26
27
|
return /*#__PURE__*/React__default.createElement(Table, null, /*#__PURE__*/React__default.createElement(Table.Toolbar, {
|
27
28
|
table: table3
|
28
29
|
}, table3.meta.editing.isEnabled ? (/*#__PURE__*/React__default.createElement(Editing, {
|
@@ -36,12 +37,19 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
36
37
|
})) : null, /*#__PURE__*/React__default.createElement(Table.Grid, Object.assign({}, gridAttributes, {
|
37
38
|
"data-taco": "table3",
|
38
39
|
table: table3
|
39
|
-
}),
|
40
|
+
}), hasCreateWorkflow ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TemporaryRow, {
|
41
|
+
createRowButtonRef: table3.meta.editing.createRowButtonRef,
|
40
42
|
table: table3.instance,
|
41
43
|
tableMeta: table3.meta,
|
44
|
+
tableRef: table3.ref
|
45
|
+
}), /*#__PURE__*/React__default.createElement(CreateNewRow, {
|
46
|
+
buttonRef: table3.meta.editing.createRowButtonRef,
|
42
47
|
onEditingCreate: props.onEditingCreate,
|
43
|
-
scrollToIndex: table3.renderer.scrollToIndex
|
44
|
-
|
48
|
+
scrollToIndex: table3.renderer.scrollToIndex,
|
49
|
+
table: table3.instance,
|
50
|
+
tableMeta: table3.meta,
|
51
|
+
tableRef: table3.ref
|
52
|
+
}))) : null));
|
45
53
|
});
|
46
54
|
const Table3 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
47
55
|
const stringifiedChildren = String(props.children);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport { fixedForwardRef } from '../../types';\nimport { useTable3 } from './useTable3';\nimport { Table } from '../../primitives/Table/Core/Table';\nimport { Alert } from './components/Editing/Alert';\nimport
|
1
|
+
{"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport { fixedForwardRef } from '../../types';\nimport { useTable3 } from './useTable3';\nimport { Table } from '../../primitives/Table/Core/Table';\nimport { Alert } from './components/Editing/Alert';\nimport { Table3Props, Table3Ref, Table3ColumnProps, Table3GroupProps } from './types';\nimport { Editing } from './components/Toolbar/Editing/Editing';\nimport { CreateNewRow } from './components/Row/Editing/CreateNewRow';\nimport { TemporaryRow } from './components/Row/Editing/TemporaryRow';\nimport './style.css';\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\nconst BaseTable3 = fixedForwardRef(function BaseTable3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const table3 = useTable3<TType>(props, ref);\n\n const gridAttributes = {\n 'data-table-editing-mode': table3.meta.editing?.isEditing\n ? table3.meta.editing?.isDetailedMode\n ? 'detailed'\n : 'normal'\n : undefined,\n enableHorizontalArrowKeyNavigation: table3.meta.editing.isEditing,\n };\n\n const hasAlertErrors = table3.meta.editing.getErrorsShownInAlert().length;\n const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;\n\n return (\n <Table>\n <Table.Toolbar<TType> table={table3}>\n {table3.meta.editing.isEnabled ? (\n <Editing scrollToIndex={table3.renderer.scrollToIndex} table={table3.instance} />\n ) : null}\n </Table.Toolbar>\n {hasAlertErrors ? (\n <Alert\n className=\"mb-4\"\n scrollToIndex={table3.renderer.scrollToIndex}\n table={table3.instance}\n tableRef={table3.ref}\n />\n ) : null}\n <Table.Grid<TType> {...gridAttributes} data-taco=\"table3\" table={table3}>\n {hasCreateWorkflow ? (\n <>\n <TemporaryRow\n createRowButtonRef={table3.meta.editing.createRowButtonRef}\n table={table3.instance}\n tableMeta={table3.meta}\n tableRef={table3.ref}\n />\n <CreateNewRow\n buttonRef={table3.meta.editing.createRowButtonRef}\n onEditingCreate={props.onEditingCreate}\n scrollToIndex={table3.renderer.scrollToIndex}\n table={table3.instance}\n tableMeta={table3.meta}\n tableRef={table3.ref}\n />\n </>\n ) : null}\n </Table.Grid>\n </Table>\n );\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 <BaseTable3<TType> {...props} key={key} ref={ref} />;\n}) as (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\nTable3.Column = Column;\nTable3.Group = Group;\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3ColumnProps,\n Table3GroupProps,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n Table3Texts,\n Table3FeatureProps,\n Table3CommonProps,\n Table3WithoutEditingWithClientProps,\n Table3WithoutEditingWithServerProps,\n Table3WithEditingProps,\n Table3WithEditingWithClientProps,\n Table3WithEditingWithServerProps,\n Table3EditingChangeHandler,\n Table3EditingCreateHandler,\n} from './types';\n"],"names":["Column","_","displayName","Group","BaseTable3","fixedForwardRef","props","ref","table3","useTable3","gridAttributes","_table3$meta$editing","meta","editing","isEditing","_table3$meta$editing2","isDetailedMode","undefined","enableHorizontalArrowKeyNavigation","hasAlertErrors","getErrorsShownInAlert","length","hasCreateWorkflow","isEnabled","onEditingCreate","React","Table","Toolbar","table","Editing","scrollToIndex","renderer","instance","Alert","className","tableRef","Grid","TemporaryRow","createRowButtonRef","tableMeta","CreateNewRow","buttonRef","Table3","stringifiedChildren","String","children","key","useMemo"],"mappings":";;;;;;;;;AAWA,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;AAEjC,MAAME,UAAU,gBAAGC,eAAe,CAAC,SAASD,UAAUA,CAAkBE,KAAyB,EAAEC,GAAyB;;EACxH,MAAMC,MAAM,GAAGC,SAAS,CAAQH,KAAK,EAAEC,GAAG,CAAC;EAE3C,MAAMG,cAAc,GAAG;IACnB,yBAAyB,EAAE,CAAAC,oBAAA,GAAAH,MAAM,CAACI,IAAI,CAACC,OAAO,cAAAF,oBAAA,eAAnBA,oBAAA,CAAqBG,SAAS,GACnD,CAAAC,qBAAA,GAAAP,MAAM,CAACI,IAAI,CAACC,OAAO,cAAAE,qBAAA,eAAnBA,qBAAA,CAAqBC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EAAEtB,MAAM,CAACuB,QAAQ,CAACD,aAAa;IAC5CF,KAAK,EAAEpB,MAAM,CAACwB,QAAQ;IACtBO,SAAS,EAAE/B,MAAM,CAACI,IAAI;IACtBuB,QAAQ,EAAE3B,MAAM,CAACD;IACnB,CACH,IACH,IAAI,CACC,CACT;AAEhB,CAAC,CAAC;MAEWmC,MAAM,gBAAGrC,eAAe,CAAC,SAASqC,MAAMA,CAAkBpC,KAAyB,EAAEC,GAAyB;EACvH,MAAMoC,mBAAmB,GAAGC,MAAM,CAACtC,KAAK,CAACuC,QAAQ,CAAC;;;EAGlD,MAAMC,GAAG,GAAGrB,cAAK,CAACsB,OAAO,CAAC,MAAMH,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAOlB,6BAACrB,UAAU,oBAAYE,KAAK;IAAEwC,GAAG,EAAEA,GAAG;IAAEvC,GAAG,EAAEA;KAAO;AAC/D,CAAC;AAIDmC,MAAM,CAAC1C,MAAM,GAAGA,MAAM;AACtB0C,MAAM,CAACvC,KAAK,GAAGA,KAAK;;;;"}
|
@@ -43,7 +43,6 @@ function RowMoveIndicator(props) {
|
|
43
43
|
if (!show) {
|
44
44
|
return null;
|
45
45
|
}
|
46
|
-
const className = 'wcag-blue-500 absolute left-0 top-full ml-1 whitespace-nowrap rounded-b-md px-1 py-1 text-xs font-bold z-10';
|
47
46
|
const {
|
48
47
|
title,
|
49
48
|
description
|
@@ -52,7 +51,7 @@ function RowMoveIndicator(props) {
|
|
52
51
|
placement: "bottom",
|
53
52
|
title: description.replace('[COLUMN]', columnMeta.header)
|
54
53
|
}, /*#__PURE__*/React__default.createElement("span", {
|
55
|
-
|
54
|
+
"data-row-move-indicator": true
|
56
55
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
57
56
|
name: "info",
|
58
57
|
className: "-mt-0.5 mr-1 !h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RowMoveIndicator.js","sources":["../../../../../../../../../../../src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.tsx"],"sourcesContent":["import React from 'react';\nimport { Cell as ReactTableCell, TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { Tooltip } from '../../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../../Provider/Localization';\nimport { Icon } from '../../../../../Icon/Icon';\n\ntype TableRowMoveIndicatorProps<TType = unknown> = {\n cell: ReactTableCell<TType, unknown>;\n cellRef: React.RefObject<HTMLTableCellElement>;\n isActiveRow: boolean;\n};\n\nexport function RowMoveIndicator<TType = unknown>(props: TableRowMoveIndicatorProps<TType>) {\n const { cell, cellRef, isActiveRow } = props;\n const { texts } = useLocalization();\n const [show, setShow] = React.useState(false);\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = (cell.column.columnDef.meta ?? {}) as ReactTableColumnMeta<TType, unknown>;\n const moveReason = tableMeta.editing.getRowMoveReason(cell.row.id);\n\n React.useEffect(() => {\n if (cellRef.current) {\n if (isActiveRow && !!moveReason) {\n const firstChild = cellRef.current.parentElement?.querySelector(`td[data-taco=\"cell-control\"]`);\n\n if (cellRef.current === firstChild) {\n setShow(true);\n cellRef.current.parentElement?.setAttribute('data-row-editing-move', 'true');\n }\n } else {\n setShow(false);\n cellRef.current.parentElement?.removeAttribute('data-row-editing-move');\n }\n }\n\n return () => {\n if (cellRef.current) {\n cellRef.current.parentElement?.removeAttribute('data-row-editing-move');\n }\n };\n }, [cellRef, isActiveRow, moveReason]);\n\n if (!show) {\n return null;\n }\n\n const
|
1
|
+
{"version":3,"file":"RowMoveIndicator.js","sources":["../../../../../../../../../../../src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.tsx"],"sourcesContent":["import React from 'react';\nimport { Cell as ReactTableCell, TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { Tooltip } from '../../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../../Provider/Localization';\nimport { Icon } from '../../../../../Icon/Icon';\n\ntype TableRowMoveIndicatorProps<TType = unknown> = {\n cell: ReactTableCell<TType, unknown>;\n cellRef: React.RefObject<HTMLTableCellElement>;\n isActiveRow: boolean;\n};\n\nexport function RowMoveIndicator<TType = unknown>(props: TableRowMoveIndicatorProps<TType>) {\n const { cell, cellRef, isActiveRow } = props;\n const { texts } = useLocalization();\n const [show, setShow] = React.useState(false);\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = (cell.column.columnDef.meta ?? {}) as ReactTableColumnMeta<TType, unknown>;\n const moveReason = tableMeta.editing.getRowMoveReason(cell.row.id);\n\n React.useEffect(() => {\n if (cellRef.current) {\n if (isActiveRow && !!moveReason) {\n const firstChild = cellRef.current.parentElement?.querySelector(`td[data-taco=\"cell-control\"]`);\n\n if (cellRef.current === firstChild) {\n setShow(true);\n cellRef.current.parentElement?.setAttribute('data-row-editing-move', 'true');\n }\n } else {\n setShow(false);\n cellRef.current.parentElement?.removeAttribute('data-row-editing-move');\n }\n }\n\n return () => {\n if (cellRef.current) {\n cellRef.current.parentElement?.removeAttribute('data-row-editing-move');\n }\n };\n }, [cellRef, isActiveRow, moveReason]);\n\n if (!show) {\n return null;\n }\n\n const { title, description } = getMessageFromReason(texts, moveReason);\n\n return (\n <Tooltip placement=\"bottom\" title={description.replace('[COLUMN]', columnMeta.header)}>\n <span data-row-move-indicator>\n <Icon name=\"info\" className=\"-mt-0.5 mr-1 !h-4 !w-4 rounded-full bg-white !p-0 text-blue-500\" />\n {title}\n </span>\n </Tooltip>\n );\n}\n\nfunction getMessageFromReason(texts, reason) {\n let title = '';\n let description = '';\n\n switch (reason) {\n case 'filter':\n title = texts.table3.editing.rowIndicator.rowWillBeHidden;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonFilter;\n break;\n\n case 'search':\n title = texts.table3.editing.rowIndicator.rowWillBeHidden;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonSearch;\n break;\n\n case 'sorting':\n title = texts.table3.editing.rowIndicator.rowWillMove;\n description = texts.table3.editing.rowIndicator.rowWillMoveReasonSorting;\n break;\n }\n\n return { title, description };\n}\n"],"names":["RowMoveIndicator","props","cell","cellRef","isActiveRow","texts","useLocalization","show","setShow","React","useState","tableMeta","getContext","table","options","meta","columnMeta","_cell$column$columnDe","column","columnDef","moveReason","editing","getRowMoveReason","row","id","useEffect","current","_cellRef$current$pare","firstChild","parentElement","querySelector","_cellRef$current$pare2","setAttribute","_cellRef$current$pare3","removeAttribute","_cellRef$current$pare4","title","description","getMessageFromReason","Tooltip","placement","replace","header","Icon","name","className","reason","table3","rowIndicator","rowWillBeHidden","rowWillMoveReasonFilter","rowWillMoveReasonSearch","rowWillMove","rowWillMoveReasonSorting"],"mappings":";;;;;SAYgBA,gBAAgBA,CAAkBC,KAAwC;;EACtF,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC;GAAa,GAAGH,KAAK;EAC5C,MAAM;IAAEI;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAMC,SAAS,GAAGT,IAAI,CAACU,UAAU,EAAE,CAACC,KAAK,CAACC,OAAO,CAACC,IAA6B;EAC/E,MAAMC,UAAU,IAAAC,qBAAA,GAAIf,IAAI,CAACgB,MAAM,CAACC,SAAS,CAACJ,IAAI,cAAAE,qBAAA,cAAAA,qBAAA,GAAI,EAA2C;EAC7F,MAAMG,UAAU,GAAGT,SAAS,CAACU,OAAO,CAACC,gBAAgB,CAACpB,IAAI,CAACqB,GAAG,CAACC,EAAE,CAAC;EAElEf,cAAK,CAACgB,SAAS,CAAC;IACZ,IAAItB,OAAO,CAACuB,OAAO,EAAE;MACjB,IAAItB,WAAW,IAAI,CAAC,CAACgB,UAAU,EAAE;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/FT,KAAK,CACH,CACD;AAElB;AAEA,SAASE,oBAAoBA,CAACjC,KAAK,EAAEyC,MAAM;EACvC,IAAIV,KAAK,GAAG,EAAE;EACd,IAAIC,WAAW,GAAG,EAAE;EAEpB,QAAQS,MAAM;IACV,KAAK,QAAQ;MACTV,KAAK,GAAG/B,KAAK,CAAC0C,MAAM,CAAC1B,OAAO,CAAC2B,YAAY,CAACC,eAAe;MACzDZ,WAAW,GAAGhC,KAAK,CAAC0C,MAAM,CAAC1B,OAAO,CAAC2B,YAAY,CAACE,uBAAuB;MACvE;IAEJ,KAAK,QAAQ;MACTd,KAAK,GAAG/B,KAAK,CAAC0C,MAAM,CAAC1B,OAAO,CAAC2B,YAAY,CAACC,eAAe;MACzDZ,WAAW,GAAGhC,KAAK,CAAC0C,MAAM,CAAC1B,OAAO,CAAC2B,YAAY,CAACG,uBAAuB;MACvE;IAEJ,KAAK,SAAS;MACVf,KAAK,GAAG/B,KAAK,CAAC0C,MAAM,CAAC1B,OAAO,CAAC2B,YAAY,CAACI,WAAW;MACrDf,WAAW,GAAGhC,KAAK,CAAC0C,MAAM,CAAC1B,OAAO,CAAC2B,YAAY,CAACK,wBAAwB;MACxE;;EAGR,OAAO;IAAEjB,KAAK;IAAEC;GAAa;AACjC;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js
CHANGED
@@ -25,13 +25,31 @@ function EditingControlCell(props) {
|
|
25
25
|
const {
|
26
26
|
rowIndex
|
27
27
|
} = React__default.useContext(RowContext);
|
28
|
-
const
|
28
|
+
const {
|
29
|
+
table
|
30
|
+
} = cell.getContext();
|
31
|
+
const tableMeta = table.options.meta;
|
29
32
|
const columnMeta = cell.column.columnDef.meta;
|
30
33
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
|
34
|
+
const type = (_columnMeta$control = columnMeta.control) !== null && _columnMeta$control !== void 0 ? _columnMeta$control : 'input';
|
31
35
|
const handleFocus = useEditingCellAutofocus(props);
|
36
|
+
const value = cell.getValue();
|
37
|
+
// some controls, like select2, should trigger cell changed (validation, updates) as the value changes
|
38
|
+
const hasNonTextControl = React__default.useMemo(() => {
|
39
|
+
var _cellRef$current;
|
40
|
+
return typeof type === 'function' && !!((_cellRef$current = cellRef.current) !== null && _cellRef$current !== void 0 && _cellRef$current.querySelector('[data-taco="Select2"],[data-taco="switch"],[data-taco="checkbox"]'));
|
41
|
+
}, [cellRef.current]);
|
42
|
+
const handleChange = nextValue => {
|
43
|
+
if (nextValue !== value) {
|
44
|
+
tableMeta.editing.setCellValue(cell, nextValue);
|
45
|
+
if (hasNonTextControl) {
|
46
|
+
tableMeta.editing.onCellChanged(cell, rowIndex);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
};
|
32
50
|
const handleBlur = () => {
|
33
51
|
tableMeta.editing.toggleDetailedMode(false);
|
34
|
-
tableMeta.editing.
|
52
|
+
tableMeta.editing.onCellChanged(cell, rowIndex, !hasNonTextControl);
|
35
53
|
};
|
36
54
|
// ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)
|
37
55
|
React__default.useEffect(() => {
|
@@ -51,14 +69,13 @@ function EditingControlCell(props) {
|
|
51
69
|
isDetailedMode: tableMeta.editing.isDetailedMode,
|
52
70
|
isTruncated: !!columnMeta.enableTruncate,
|
53
71
|
onBlur: handleBlur,
|
54
|
-
onChange:
|
72
|
+
onChange: handleChange,
|
55
73
|
row: cell.row.original,
|
56
|
-
rowPendingChanges: tableMeta.editing.
|
74
|
+
rowPendingChanges: tableMeta.editing.getRowValue(cell.row.id),
|
57
75
|
tabIndex: isActiveRow ? 0 : -1,
|
58
|
-
toggleEditing: tableMeta.editing.toggleEditing,
|
59
76
|
toggleDetailedMode: tableMeta.editing.toggleDetailedMode,
|
60
|
-
type
|
61
|
-
value
|
77
|
+
type,
|
78
|
+
value
|
62
79
|
};
|
63
80
|
const cellAttributes = {
|
64
81
|
...getCellAttributes(cell, index, isHighlighted),
|
@@ -90,7 +107,6 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
90
107
|
row,
|
91
108
|
rowPendingChanges,
|
92
109
|
tabIndex = -1,
|
93
|
-
toggleEditing,
|
94
110
|
toggleDetailedMode,
|
95
111
|
type = 'input',
|
96
112
|
value
|
@@ -156,8 +172,8 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
156
172
|
}
|
157
173
|
// reset the value, or exit edit mode when pressing escape
|
158
174
|
if (event.key === 'Escape') {
|
159
|
-
event.preventDefault();
|
160
175
|
if (isDetailedMode) {
|
176
|
+
event.preventDefault();
|
161
177
|
toggleDetailedMode(false);
|
162
178
|
if (value !== currentValue) {
|
163
179
|
props.onChange(currentValue);
|
@@ -167,15 +183,9 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
167
183
|
var _target$select2;
|
168
184
|
return (_target$select2 = target.select) === null || _target$select2 === void 0 ? void 0 : _target$select2.call(target);
|
169
185
|
});
|
170
|
-
} else {
|
171
|
-
toggleEditing(false);
|
172
186
|
}
|
173
187
|
return;
|
174
188
|
}
|
175
|
-
const shortcutWhitelist = ['f', 'p', 'e']; // f = search, p = print, and e = edit
|
176
|
-
if (isPressingMetaKey(event) && !shortcutWhitelist.some(s => s === event.key)) {
|
177
|
-
event.stopPropagation();
|
178
|
-
}
|
179
189
|
// toggle into detailed mode when actually inputting something
|
180
190
|
if (!isPressingMetaKey(event) && (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace')) {
|
181
191
|
toggleDetailedMode(true);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditingControlCell.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/EditingControlCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { TableColumnDataType, TableColumnRendererControl, TableFontSize } from '../../../../../primitives/Table/types';\nimport * as date from '../../../../../utils/date';\nimport { RowMoveIndicator } from './Editing/RowMoveIndicator';\nimport { TextareaWithAutosizing } from './Editing/TextareaWithAutosizing';\nimport { Field } from '../../../../Field/Field';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\nimport { getCellAttributes } from '../../../../../primitives/Table/Core/components/Columns/Cell/util';\nimport { useEditingCellAutofocus } from './util';\nimport { isPressingMetaKey } from '../../../../../utils/keyboard';\nimport { Checkbox } from '../../../../Checkbox/Checkbox';\n\nexport function EditingControlCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, isHighlighted, index } = props;\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = cell.getContext().table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n\n const handleFocus = useEditingCellAutofocus<TType>(props);\n\n const handleBlur = () => {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.validateCell(cell);\n };\n\n // ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)\n React.useEffect(() => {\n const ref = cellRef.current;\n\n return () => {\n if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {\n handleBlur();\n }\n };\n }, []);\n\n const error = tableMeta.editing.getCellError<TType>(cell);\n\n const controlProps = {\n dataType: columnMeta.dataType,\n fontSize: tableMeta.fontSize.size,\n id: cell.column.id,\n invalid: !!error,\n isDetailedMode: tableMeta.editing.isDetailedMode,\n isTruncated: !!columnMeta.enableTruncate,\n onBlur: handleBlur,\n onChange: (value: unknown) => tableMeta.editing.setCellValue(cell, value, rowIndex),\n row: cell.row.original,\n rowPendingChanges: tableMeta.editing.getRowPendingChange(cell.row.id),\n tabIndex: isActiveRow ? 0 : -1,\n toggleEditing: tableMeta.editing.toggleEditing,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type: columnMeta.control ?? 'input',\n value: cell.getValue(),\n };\n\n const cellAttributes = {\n ...getCellAttributes(cell, index, isHighlighted),\n 'data-cell-editing-invalid': error ? true : undefined,\n 'data-taco': 'cell-control',\n onFocus: handleFocus,\n ref: cellRef,\n tabIndex: -1,\n };\n\n return (\n <td {...cellAttributes}>\n <Field invalid={!!error} message={error}>\n <MemoedEditingCell<TType> {...controlProps} />\n </Field>\n {\n // we show row move indicator here within the cell rather than the row because it is\n // an editing only feature, and we don't want to leak editing into the shared row component\n }\n <RowMoveIndicator cell={cell} cellRef={cellRef} isActiveRow={isActiveRow} />\n </td>\n );\n}\n\ntype MemoedEditingCellProps<TType = unknown, TValue = unknown> = {\n dataType?: TableColumnDataType;\n fontSize: TableFontSize;\n id: string;\n invalid: boolean;\n isDetailedMode: boolean;\n isTruncated: boolean;\n onBlur: () => void;\n onChange: (value: TValue) => void;\n row: TType;\n rowPendingChanges: Partial<TType> | undefined;\n tabIndex?: number;\n toggleEditing: (editing: React.SetStateAction<boolean>) => void;\n toggleDetailedMode: (detailed: React.SetStateAction<boolean>) => void;\n type: TableColumnRendererControl<TType>;\n value: TValue;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const {\n dataType,\n fontSize,\n id,\n invalid,\n isDetailedMode,\n isTruncated,\n onBlur,\n onChange,\n row,\n rowPendingChanges,\n tabIndex = -1,\n toggleEditing,\n toggleDetailedMode,\n type = 'input',\n value,\n } = props;\n const controlRef = React.useRef<HTMLElement>(null);\n const currentValue = row[id];\n const commonProps = {\n onBlur,\n ref: controlRef,\n tabIndex,\n };\n\n if (typeof type === 'function') {\n const controlFnProps = {\n ...commonProps,\n invalid,\n setValue: onChange,\n value,\n };\n\n return type(controlFnProps, { ...row, ...rowPendingChanges });\n }\n\n if (type === 'switch') {\n return (\n <Switch\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n if (type === 'checkbox') {\n return (\n <Checkbox\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n\n if (target.readOnly) {\n return;\n }\n\n // prevent active row navigation while in detailed mode\n if (\n isDetailedMode &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight')\n ) {\n event.stopPropagation();\n }\n\n // enter or exit detail mode when pressing enter\n if (event.key === 'Enter') {\n // textareas support shift and enter, don't prevent default in that case\n if (event.shiftKey && isDetailedMode) {\n return;\n }\n\n event.preventDefault();\n\n if (isDetailedMode) {\n target.select?.();\n } else {\n target.setSelectionRange?.(target.value?.length, target.value?.length);\n }\n\n toggleDetailedMode(editing => !editing);\n return;\n }\n\n // reset the value, or exit edit mode when pressing escape\n if (event.key === 'Escape') {\n event.preventDefault();\n\n if (isDetailedMode) {\n toggleDetailedMode(false);\n\n if (value !== currentValue) {\n props.onChange(currentValue);\n }\n\n // have to let onChange run before selecting, otherwise the value changes\n requestAnimationFrame(() => target.select?.());\n } else {\n toggleEditing(false);\n }\n\n return;\n }\n\n const shortcutWhitelist = ['f', 'p', 'e']; // f = search, p = print, and e = edit\n\n if (isPressingMetaKey(event) && !shortcutWhitelist.some(s => s === event.key)) {\n event.stopPropagation();\n }\n\n // toggle into detailed mode when actually inputting something\n if (!isPressingMetaKey(event) && (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace')) {\n toggleDetailedMode(true);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (!isDetailedMode) {\n event.target.select();\n }\n };\n\n if (type === 'datepicker') {\n const valueAsDate = date.parse(value as Date | string | undefined);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDate = (event as any).detail as Date;\n\n if (!valueAsDate || !newDate || (isDate(valueAsDate) && isDate(newDate) && !date.isWeakEqual(valueAsDate, newDate))) {\n props.onChange(newDate);\n }\n };\n\n return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n value={valueAsDate}\n />\n );\n }\n\n if (type === 'textarea') {\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n onChange(event.target.value);\n };\n\n return (\n <TextareaWithAutosizing\n {...commonProps}\n fontSize={fontSize}\n invalid={invalid}\n isTruncated={isTruncated}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLTextAreaElement>}\n value={String(value ?? '')}\n />\n );\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(dataType === 'number' && event.target.value ? Number.parseInt(event.target.value) : event.target.value);\n };\n\n return (\n <Input\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n type={dataType === 'number' ? 'number' : undefined}\n value={dataType === 'number' ? (value as number) : String(value ?? '')}\n />\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n"],"names":["EditingControlCell","props","cell","cellRef","isHighlighted","index","rowIndex","React","useContext","RowContext","tableMeta","getContext","table","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","handleFocus","useEditingCellAutofocus","handleBlur","editing","toggleDetailedMode","validateCell","useEffect","ref","current","document","activeElement","isElementInsideOrTriggeredFromContainer","error","getCellError","controlProps","dataType","fontSize","size","id","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","value","setCellValue","row","original","rowPendingChanges","getRowPendingChange","tabIndex","toggleEditing","type","_columnMeta$control","control","getValue","cellAttributes","getCellAttributes","undefined","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","controlFnProps","setValue","Switch","checked","Boolean","Checkbox","handleInputKeyDown","event","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","requestAnimationFrame","_target$select2","shortcutWhitelist","isPressingMetaKey","some","s","test","valueAsDate","date","handleChange","newDate","detail","isDate","Datepicker","onKeyDown","TextareaWithAutosizing","String","Number","parseInt","Input"],"mappings":";;;;;;;;;;;;;;;;SAmBgBA,kBAAkBA,CAAkBC,KAAoC;;EACpF,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,aAAa;IAAEC;GAAO,GAAGJ,KAAK;EACrD,MAAM;IAAEK;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EACjD,MAAMC,SAAS,GAAGR,IAAI,CAACS,UAAU,EAAE,CAACC,KAAK,CAACC,OAAO,CAACC,IAA6B;EAC/E,MAAMC,UAAU,GAAGb,IAAI,CAACc,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,WAAW,GAAGR,SAAS,CAACS,SAAS,CAACC,cAAc,KAAKd,QAAQ;EAEnE,MAAMe,WAAW,GAAGC,uBAAuB,CAAQrB,KAAK,CAAC;EAEzD,MAAMsB,UAAU,GAAGA;IACfb,SAAS,CAACc,OAAO,CAACC,kBAAkB,CAAC,KAAK,CAAC;IAC3Cf,SAAS,CAACc,OAAO,CAACE,YAAY,CAACxB,IAAI,CAAC;GACvC;;EAGDK,cAAK,CAACoB,SAAS,CAAC;IACZ,MAAMC,GAAG,GAAGzB,OAAO,C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GAAGgE,MAAM,CAACC,QAAQ,CAACjC,KAAK,CAACC,MAAM,CAACjC,KAAK,CAAC,GAAGgC,KAAK,CAACC,MAAM,CAACjC,KAAK,CAAC;GACnH;EAED,oBACIvC,6BAACyG,KAAK,oBACE1C,WAAW;IACf9B,OAAO,EAAEA,OAAO;IAChBK,QAAQ,EAAEyD,YAAY;IACtBzC,OAAO,EAAExC,WAAW;IACpBsF,SAAS,EAAE9B,kBAAkB;IAC7BjD,GAAG,EAAEuC,UAA+C;IACpDb,IAAI,EAAElB,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAGwB,SAAS;IAClDd,KAAK,EAAEV,QAAQ,KAAK,QAAQ,GAAIU,KAAgB,GAAG+D,MAAM,CAAC/D,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KACvE;AAEV,CAAC,CAA2E;;;;"}
|
1
|
+
{"version":3,"file":"EditingControlCell.js","sources":["../../../../../../../../../../src/components/Table3/components/Columns/Cell/EditingControlCell.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta, ColumnMeta as ReactTableColumnMeta } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\nimport { Input } from '../../../../Input/Input';\nimport { TableColumnDataType, TableColumnRendererControl, TableFontSize } from '../../../../../primitives/Table/types';\nimport * as date from '../../../../../utils/date';\nimport { RowMoveIndicator } from './Editing/RowMoveIndicator';\nimport { TextareaWithAutosizing } from './Editing/TextareaWithAutosizing';\nimport { Field } from '../../../../Field/Field';\nimport { isElementInsideOrTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableCellRendererProps } from '../../../../../primitives/Table/Core/types';\nimport { RowContext } from '../../../../../primitives/Table/Core/components/Row/RowContext';\nimport { getCellAttributes } from '../../../../../primitives/Table/Core/components/Columns/Cell/util';\nimport { useEditingCellAutofocus } from './util';\nimport { isPressingMetaKey } from '../../../../../utils/keyboard';\nimport { Checkbox } from '../../../../Checkbox/Checkbox';\n\nexport function EditingControlCell<TType = unknown>(props: TableCellRendererProps<TType>) {\n const { cell, cellRef, isHighlighted, index } = props;\n const { rowIndex } = React.useContext(RowContext);\n const { table } = cell.getContext();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const columnMeta = cell.column.columnDef.meta as ReactTableColumnMeta<TType, unknown>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const type = columnMeta.control ?? 'input';\n const handleFocus = useEditingCellAutofocus<TType>(props);\n const value = cell.getValue();\n\n // some controls, like select2, should trigger cell changed (validation, updates) as the value changes\n const hasNonTextControl = React.useMemo(() => {\n return (\n typeof type === 'function' &&\n !!cellRef.current?.querySelector('[data-taco=\"Select2\"],[data-taco=\"switch\"],[data-taco=\"checkbox\"]')\n );\n }, [cellRef.current]);\n\n const handleChange = (nextValue: unknown) => {\n if (nextValue !== value) {\n tableMeta.editing.setCellValue(cell, nextValue);\n\n if (hasNonTextControl) {\n tableMeta.editing.onCellChanged(cell, rowIndex);\n }\n }\n };\n\n const handleBlur = () => {\n tableMeta.editing.toggleDetailedMode(false);\n tableMeta.editing.onCellChanged(cell, rowIndex, !hasNonTextControl);\n };\n\n // ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)\n React.useEffect(() => {\n const ref = cellRef.current;\n\n return () => {\n if (document.activeElement === ref || isElementInsideOrTriggeredFromContainer(document.activeElement, ref)) {\n handleBlur();\n }\n };\n }, []);\n\n const error = tableMeta.editing.getCellError<TType>(cell);\n\n const controlProps = {\n dataType: columnMeta.dataType,\n fontSize: tableMeta.fontSize.size,\n id: cell.column.id,\n invalid: !!error,\n isDetailedMode: tableMeta.editing.isDetailedMode,\n isTruncated: !!columnMeta.enableTruncate,\n onBlur: handleBlur,\n onChange: handleChange,\n row: cell.row.original,\n rowPendingChanges: tableMeta.editing.getRowValue(cell.row.id),\n tabIndex: isActiveRow ? 0 : -1,\n toggleDetailedMode: tableMeta.editing.toggleDetailedMode,\n type,\n value,\n };\n\n const cellAttributes = {\n ...getCellAttributes(cell, index, isHighlighted),\n 'data-cell-editing-invalid': error ? true : undefined,\n 'data-taco': 'cell-control',\n onFocus: handleFocus,\n ref: cellRef,\n tabIndex: -1,\n };\n\n return (\n <td {...cellAttributes}>\n <Field invalid={!!error} message={error}>\n <MemoedEditingCell<TType> {...controlProps} />\n </Field>\n {\n // we show row move indicator here within the cell rather than the row because it is\n // an editing only feature, and we don't want to leak editing into the shared row component\n }\n <RowMoveIndicator cell={cell} cellRef={cellRef} isActiveRow={isActiveRow} />\n </td>\n );\n}\n\ntype MemoedEditingCellProps<TType = unknown, TValue = unknown> = {\n dataType?: TableColumnDataType;\n fontSize: TableFontSize;\n id: string;\n invalid: boolean;\n isDetailedMode: boolean;\n isTruncated: boolean;\n onBlur: () => void;\n onChange: (value: TValue) => void;\n row: TType;\n rowPendingChanges: Partial<TType> | undefined;\n tabIndex?: number;\n toggleDetailedMode: (detailed: React.SetStateAction<boolean>) => void;\n type: TableColumnRendererControl<TType>;\n value: TValue;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const {\n dataType,\n fontSize,\n id,\n invalid,\n isDetailedMode,\n isTruncated,\n onBlur,\n onChange,\n row,\n rowPendingChanges,\n tabIndex = -1,\n toggleDetailedMode,\n type = 'input',\n value,\n } = props;\n const controlRef = React.useRef<HTMLElement>(null);\n const currentValue = row[id];\n const commonProps = {\n onBlur,\n ref: controlRef,\n tabIndex,\n };\n\n if (typeof type === 'function') {\n const controlFnProps = {\n ...commonProps,\n invalid,\n setValue: onChange,\n value,\n };\n\n return type(controlFnProps, { ...row, ...rowPendingChanges });\n }\n\n if (type === 'switch') {\n return (\n <Switch\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n if (type === 'checkbox') {\n return (\n <Checkbox\n {...commonProps}\n checked={Boolean(value)}\n onChange={onChange}\n ref={controlRef as React.RefObject<HTMLButtonElement>}\n />\n );\n }\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n\n if (target.readOnly) {\n return;\n }\n\n // prevent active row navigation while in detailed mode\n if (\n isDetailedMode &&\n (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight')\n ) {\n event.stopPropagation();\n }\n\n // enter or exit detail mode when pressing enter\n if (event.key === 'Enter') {\n // textareas support shift and enter, don't prevent default in that case\n if (event.shiftKey && isDetailedMode) {\n return;\n }\n\n event.preventDefault();\n\n if (isDetailedMode) {\n target.select?.();\n } else {\n target.setSelectionRange?.(target.value?.length, target.value?.length);\n }\n\n toggleDetailedMode(editing => !editing);\n return;\n }\n\n // reset the value, or exit edit mode when pressing escape\n if (event.key === 'Escape') {\n if (isDetailedMode) {\n event.preventDefault();\n toggleDetailedMode(false);\n\n if (value !== currentValue) {\n props.onChange(currentValue);\n }\n\n // have to let onChange run before selecting, otherwise the value changes\n requestAnimationFrame(() => target.select?.());\n }\n\n return;\n }\n\n // toggle into detailed mode when actually inputting something\n if (!isPressingMetaKey(event) && (/^[a-z0-9]$/i.test(event.key) || event.key === 'Backspace')) {\n toggleDetailedMode(true);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (!isDetailedMode) {\n event.target.select();\n }\n };\n\n if (type === 'datepicker') {\n const valueAsDate = date.parse(value as Date | string | undefined);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDate = (event as any).detail as Date;\n\n if (!valueAsDate || !newDate || (isDate(valueAsDate) && isDate(newDate) && !date.isWeakEqual(valueAsDate, newDate))) {\n props.onChange(newDate);\n }\n };\n\n return (\n <Datepicker\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n value={valueAsDate}\n />\n );\n }\n\n if (type === 'textarea') {\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n onChange(event.target.value);\n };\n\n return (\n <TextareaWithAutosizing\n {...commonProps}\n fontSize={fontSize}\n invalid={invalid}\n isTruncated={isTruncated}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLTextAreaElement>}\n value={String(value ?? '')}\n />\n );\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(dataType === 'number' && event.target.value ? Number.parseInt(event.target.value) : event.target.value);\n };\n\n return (\n <Input\n {...commonProps}\n invalid={invalid}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleInputKeyDown}\n ref={controlRef as React.RefObject<HTMLInputElement>}\n type={dataType === 'number' ? 'number' : undefined}\n value={dataType === 'number' ? (value as number) : String(value ?? '')}\n />\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n"],"names":["EditingControlCell","props","cell","cellRef","isHighlighted","index","rowIndex","React","useContext","RowContext","table","getContext","tableMeta","options","meta","columnMeta","column","columnDef","isActiveRow","rowActive","rowActiveIndex","type","_columnMeta$control","control","handleFocus","useEditingCellAutofocus","value","getValue","hasNonTextControl","useMemo","_cellRef$current","current","querySelector","handleChange","nextValue","editing","setCellValue","onCellChanged","handleBlur","toggleDetailedMode","useEffect","ref","document","activeElement","isElementInsideOrTriggeredFromContainer","error","getCellError","controlProps","dataType","fontSize","size","id","invalid","isDetailedMode","isTruncated","enableTruncate","onBlur","onChange","row","original","rowPendingChanges","getRowValue","tabIndex","cellAttributes","getCellAttributes","undefined","onFocus","Field","message","MemoedEditingCell","RowMoveIndicator","memo","controlRef","useRef","currentValue","commonProps","controlFnProps","setValue","Switch","checked","Boolean","Checkbox","handleInputKeyDown","event","target","readOnly","key","stopPropagation","shiftKey","preventDefault","_target$select","select","call","_target$setSelectionR","_target$value","_target$value2","setSelectionRange","length","requestAnimationFrame","_target$select2","isPressingMetaKey","test","valueAsDate","date","newDate","detail","isDate","Datepicker","onKeyDown","TextareaWithAutosizing","String","Number","parseInt","Input"],"mappings":";;;;;;;;;;;;;;;;SAmBgBA,kBAAkBA,CAAkBC,KAAoC;;EACpF,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,aAAa;IAAEC;GAAO,GAAGJ,KAAK;EACrD,MAAM;IAAEK;GAAU,GAAGC,cAAK,CAACC,UAAU,CAACC,UAAU,CAAC;EACjD,MAAM;IAAEC;GAAO,GAAGR,IAAI,CAACS,UAAU,EAAE;EACnC,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,UAAU,GAAGb,IAAI,CAACc,MAAM,CAACC,SAAS,CAACH,IAA4C;EACrF,MAAMI,WAAW,GAAGN,SAAS,CAACO,SAAS,CAACC,cAAc,KAAKd,QAAQ;EACnE,MAAMe,IAAI,IAAAC,mBAAA,GAAGP,UAAU,CAACQ,OAAO,cAAAD,mBAAA,cAAAA,mBAAA,GAAI,OAAO;EAC1C,MAAME,WAAW,GAAGC,uBAAuB,CAAQxB,KAAK,CAAC;EACzD,MAAMyB,KAAK,GAAGxB,IAAI,CAACyB,QAAQ,EAAE;;EAG7B,MAAMC,iBAAiB,GAAGrB,cAAK,CAACsB,OAAO,CAAC;;IACpC,OACI,OAAOR,IAAI,KAAK,UAAU,IAC1B,CAAC,GAAAS,gBAAA,GAAC3B,OAAO,CAAC4B,OAAO,cAAAD,gBAAA,eAAfA,gBAAA,CAAiBE,aAAa,CAAC,mEAAmE,CAAC;GAE5G,EAAE,CAAC7B,OAAO,CAAC4B,OAAO,CAAC,CAAC;EAErB,MAAME,YAAY,GAAIC,SAAkB;IACpC,IAAIA,SAAS,KAAKR,KAAK,EAAE;MACrBd,SAAS,CAACuB,OAAO,CAACC,YAAY,C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W;IACfvB,OAAO,EAAEA,OAAO;IAChBK,QAAQ,EAAExB,YAAY;IACtBiC,OAAO,EAAE1C,WAAW;IACpBoF,SAAS,EAAE1B,kBAAkB;IAC7BzC,GAAG,EAAE+B,UAA+C;IACpDnD,IAAI,EAAE2B,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAGiB,SAAS;IAClDvC,KAAK,EAAEsB,QAAQ,KAAK,QAAQ,GAAItB,KAAgB,GAAGoF,MAAM,CAACpF,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;KACvE;AAEV,CAAC,CAA2E;;;;"}
|
@@ -1,17 +1,14 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { IconButton } from '../../../../IconButton/IconButton.js';
|
3
3
|
import { useLocalization } from '../../../../Provider/Localization.js';
|
4
|
-
import { Button } from '../../../../Button/Button.js';
|
5
|
-
import { Dialog } from '../../../../Dialog/Dialog.js';
|
6
|
-
import { Group } from '../../../../Group/Group.js';
|
7
4
|
import { Menu } from '../../../../Menu/Menu.js';
|
5
|
+
import { DiscardChangesConfirmationDialog } from '../../Editing/DiscardChangesConfirmationDialog.js';
|
8
6
|
|
9
7
|
function EditingActionMenu(props) {
|
10
8
|
const {
|
11
9
|
hasChanges,
|
12
10
|
hasErrors,
|
13
|
-
|
14
|
-
onExit: handleExit,
|
11
|
+
onDiscard: handleDiscard,
|
15
12
|
onEditingSave: handleSave,
|
16
13
|
isLastRow
|
17
14
|
} = props;
|
@@ -33,7 +30,6 @@ function EditingActionMenu(props) {
|
|
33
30
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
34
31
|
appearance: "transparent",
|
35
32
|
"aria-label": texts.table3.editing.actions.tooltip,
|
36
|
-
className: "group-[[data-row-editing-status]]/row:hidden",
|
37
33
|
icon: "more",
|
38
34
|
onKeyDown: handleKeyDown,
|
39
35
|
menu: menuProps => (/*#__PURE__*/React__default.createElement(Menu, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu.Content, {
|
@@ -45,40 +41,12 @@ function EditingActionMenu(props) {
|
|
45
41
|
}, texts.table3.editing.actions.save), /*#__PURE__*/React__default.createElement(Menu.Item, {
|
46
42
|
icon: "close",
|
47
43
|
disabled: !hasChanges,
|
48
|
-
dialog: props => /*#__PURE__*/React__default.createElement(
|
49
|
-
|
44
|
+
dialog: props => /*#__PURE__*/React__default.createElement(DiscardChangesConfirmationDialog, Object.assign({}, props, {
|
45
|
+
onDiscard: handleDiscard
|
50
46
|
}))
|
51
|
-
}, texts.table3.editing.actions.clear)
|
52
|
-
icon: "undo",
|
53
|
-
onClick: handleExit
|
54
|
-
}, texts.table3.editing.actions.exit))))
|
47
|
+
}, texts.table3.editing.actions.clear))))
|
55
48
|
});
|
56
49
|
}
|
57
|
-
function ConfirmClearChangesDialog(props) {
|
58
|
-
const {
|
59
|
-
onClear: handleClear,
|
60
|
-
...dialogProps
|
61
|
-
} = props;
|
62
|
-
const {
|
63
|
-
texts
|
64
|
-
} = useLocalization();
|
65
|
-
const handleClickInsideDialogContent = event => {
|
66
|
-
// Prevents the click event from propagating to the table, ensuring the row isn't saved when a click occurs
|
67
|
-
// inside the dialog
|
68
|
-
event.stopPropagation();
|
69
|
-
};
|
70
|
-
return /*#__PURE__*/React__default.createElement(Dialog, Object.assign({}, dialogProps), /*#__PURE__*/React__default.createElement(Dialog.Content, {
|
71
|
-
"aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
|
72
|
-
onClick: handleClickInsideDialogContent
|
73
|
-
}, /*#__PURE__*/React__default.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title), /*#__PURE__*/React__default.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description), /*#__PURE__*/React__default.createElement(Dialog.Footer, null, /*#__PURE__*/React__default.createElement(Group, null, /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button, {
|
74
|
-
tabIndex: 0
|
75
|
-
}, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button, {
|
76
|
-
autoFocus: true,
|
77
|
-
tabIndex: 0,
|
78
|
-
appearance: "primary",
|
79
|
-
onClick: handleClear
|
80
|
-
}, texts.table3.editing.clearChangesConfirmationDialog.confirm))))));
|
81
|
-
}
|
82
50
|
|
83
51
|
export { EditingActionMenu };
|
84
52
|
//# sourceMappingURL=EditingActionsMenu.js.map
|