@economic/taco 2.17.1 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Select2/components/Search.d.ts +5 -1
- package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +1 -0
- package/dist/components/Table3/components/columns/cell/Indicator.d.ts +5 -0
- package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterValue.d.ts +1 -1
- package/dist/components/Table3/types.d.ts +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +21 -7
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js +2 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +12 -7
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +11 -6
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js +15 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +6 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +10 -4
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +11 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js +0 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +5 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js +4 -0
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowSelectionListener.js +7 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowSelectionListener.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +13 -1
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/taco.cjs.development.js +177 -100
- 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/types.json +5388 -5018
@@ -1,6 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { InputProps } from '../../Input/Input';
|
3
|
-
export declare type Select2SearchProps = InputProps & {
|
3
|
+
export declare type Select2SearchProps = InputProps & {
|
4
|
+
onTabKeyPress: () => void;
|
5
|
+
};
|
4
6
|
export declare const Search: React.ForwardRefExoticComponent<Pick<React.InputHTMLAttributes<HTMLInputElement>, "accept" | "alt" | "autoComplete" | "autoFocus" | "capture" | "checked" | "crossOrigin" | "disabled" | "enterKeyHint" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "height" | "list" | "max" | "maxLength" | "min" | "minLength" | "multiple" | "name" | "pattern" | "placeholder" | "readOnly" | "required" | "size" | "src" | "step" | "type" | "value" | "width" | "onChange" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & {
|
5
7
|
highlighted?: boolean | undefined;
|
6
8
|
invalid?: boolean | undefined;
|
@@ -9,4 +11,6 @@ export declare const Search: React.ForwardRefExoticComponent<Pick<React.InputHTM
|
|
9
11
|
} & {
|
10
12
|
button?: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | undefined;
|
11
13
|
icon?: "list" | JSX.Element | "document" | "log" | "menu" | "note" | "search" | "warning" | "time" | "filter" | "line" | "location" | "copy" | "move" | "account-preview" | "accounting-year-cancel" | "accounting-year" | "accounting" | "ai-chat-solid" | "ai-stars" | "arrow-bottom" | "arrow-down" | "arrow-end" | "arrow-left" | "arrow-right" | "arrow-start" | "arrow-top" | "arrow-up" | "attach-auto" | "attach-cancel" | "attach-warning" | "attach" | "autotext-insert" | "autotext" | "basic-tabs" | "basic" | "bell-solid" | "book" | "booking" | "budget" | "calendar" | "cash-account" | "cash-reports" | "chart-area" | "chart-bar" | "chart-line" | "chart-pie" | "chart-table" | "chat-solid" | "chat" | "chevron-down-double" | "chevron-down-solid" | "chevron-down" | "chevron-left-double" | "chevron-left-solid" | "chevron-left" | "chevron-right-double" | "chevron-right-solid" | "chevron-right" | "chevron-up-double" | "chevron-up-solid" | "chevron-up" | "circle-close" | "circle-information" | "circle-minus" | "circle-plus" | "circle-questionmark" | "circle-tick" | "circle-warning" | "clamp-open" | "clamp" | "close" | "column-freeze" | "column-unfreeze" | "columns" | "connection-enable" | "connection-revoke" | "contacts" | "courses" | "credit" | "delete-permanently" | "delete" | "depecriate" | "developer" | "distribution-template" | "document-approve" | "document-create-entry" | "document-cut" | "document-error" | "document-isolate-page" | "document-merge" | "document-move" | "document-preview" | "document-received" | "document-rejected-request" | "document-split" | "document-time" | "download" | "drag" | "e-copedia" | "e-signature" | "edit-simple" | "edit" | "ellipsis-horizontal" | "ellipsis-vertical" | "entries-on-account" | "entries-open" | "entries-warning" | "entry-type-customer-invoice" | "entry-type-customer-payment" | "entry-type-journal-entry" | "entry-type-manual-customer-invoice" | "entry-type-supplier-invoice" | "entry-type-supplier-payment" | "envelope-approved" | "envelope-solid" | "envelope" | "expand-view" | "expenses" | "export-to-excel" | "export-to-pdf" | "export" | "eye-off" | "eye-on" | "filter-solid" | "font-size" | "graph-solid" | "hash" | "height-extra-tall" | "height-medium" | "height-short" | "height-tall" | "home" | "images" | "import" | "inbox-einvoicing" | "inbox-scanning" | "inbox-smart" | "inbox" | "info" | "inventory-matrix" | "inventory" | "journal-pro" | "layout-both" | "layout-first" | "layout-last" | "layout-none" | "layout" | "ledger-card-customer-reminder" | "ledger-card-manual-customer-invoice" | "ledger-card-obsolete-stock" | "ledger-card-opening-entry" | "ledger-card-reserved-entry" | "ledger-card-shrinkage-pilferage" | "ledger-card-stock-adjustment" | "ledger-card-transferred-opening-entry" | "ledger-card" | "lightbulb" | "list-bulleted" | "list-search" | "lock-open" | "lock" | "log-out" | "market" | "match-amount" | "match-entries" | "mileage" | "modal-resize" | "modal-shrink" | "more-solid" | "more" | "navigation-list" | "note-follow-up" | "note-read" | "numbers" | "partner-api" | "payment-paid" | "payment-unpaid" | "period" | "person-change" | "person-minus" | "person-plus" | "person-tick" | "phone-solid" | "play" | "plus-minus" | "print" | "process-payment" | "product-ledger-card" | "profile" | "project-cards" | "projects" | "question-mark-bold" | "question-mark" | "quicklinks" | "rating-bankruptcy" | "rating-payment-problems" | "reconciled" | "refresh" | "report-solid" | "report" | "restore" | "rotate-left" | "rotate-right" | "sales" | "search-bold" | "secure-tick" | "secure" | "settings-solid" | "settings" | "shortcuts" | "show-all" | "show-less" | "show-more" | "show-template" | "sliders" | "smartpay" | "sort-by" | "star-solid" | "star" | "subscriptions" | "system-entries" | "tag" | "template-override" | "templates" | "thumb-both" | "thumb-down-solid" | "thumb-down" | "thumb-up-solid" | "thumb-up" | "tick-bold" | "tick" | "transfer-cancel" | "transfer-locked" | "transfer" | "undo" | "undock" | "unreconciled" | "webshop" | "website" | "workflow-template-basic" | "workflow" | "zoom" | undefined;
|
14
|
+
} & {
|
15
|
+
onTabKeyPress: () => void;
|
12
16
|
} & React.RefAttributes<HTMLInputElement>>;
|
@@ -4,6 +4,7 @@ export declare type EditingCellProps<TType = unknown> = CellContext<TType, unkno
|
|
4
4
|
highlighted?: boolean;
|
5
5
|
highlightedAsCurrent?: boolean;
|
6
6
|
children?: string | JSX.Element;
|
7
|
+
className?: string;
|
7
8
|
};
|
8
9
|
export declare function EditingCell<TType = unknown>(props: EditingCellProps<TType>): JSX.Element;
|
9
10
|
export declare type MemoedEditingCellProps<TType = unknown> = EditingCellProps<TType> & {
|
@@ -15,3 +15,8 @@ export declare type IndicatorProps = {
|
|
15
15
|
validationErrors: any;
|
16
16
|
};
|
17
17
|
export declare const Indicator: ({ reason, columnName, mountNode, validationErrors }: IndicatorProps) => React.ReactPortal;
|
18
|
+
/**
|
19
|
+
* Generates class names needed to highlight row cells, used when row has a move indicator
|
20
|
+
*/
|
21
|
+
export declare function getIndicatorCellClassName(columnIndex: number, lastColumnIndex: number): string;
|
22
|
+
export declare function isIndicatorVisible(rowIndex: any, rowActiveIndex: any, rowMoveReason: any): any;
|
package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterValue.d.ts
CHANGED
@@ -3,7 +3,7 @@ import { Column as RTColumn } from '@tanstack/react-table';
|
|
3
3
|
import { Table3FilterComparator } from '../../../../../types';
|
4
4
|
export declare type FilterValueProps<TType = unknown> = {
|
5
5
|
column?: RTColumn<TType, unknown>;
|
6
|
-
comparator: Table3FilterComparator;
|
6
|
+
comparator: Table3FilterComparator | null;
|
7
7
|
onChange: (value: any) => void;
|
8
8
|
value: any;
|
9
9
|
};
|
@@ -99,7 +99,7 @@ export declare enum Table3FilterComparator {
|
|
99
99
|
HasNoneOf = 13
|
100
100
|
}
|
101
101
|
export declare type Table3FilterValue = {
|
102
|
-
comparator: Table3FilterComparator;
|
102
|
+
comparator: Table3FilterComparator | null;
|
103
103
|
value: any;
|
104
104
|
};
|
105
105
|
export declare type Table3Filter = {
|
@@ -16,6 +16,7 @@ import { Select2Context } from './components/Context.js';
|
|
16
16
|
import { Option } from './components/Option.js';
|
17
17
|
import { Group } from './components/Group.js';
|
18
18
|
import { Title } from './components/Title.js';
|
19
|
+
import { getNextFocussableElement } from '../../utils/dom.js';
|
19
20
|
import { Trigger as Trigger$1 } from './components/Trigger.js';
|
20
21
|
import { useIsFormControl } from '../../hooks/useIsFormControl.js';
|
21
22
|
import { BubbleSelect } from '../../primitives/BubbleSelect.js';
|
@@ -73,6 +74,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
73
74
|
// align the listbox min width with the width of the input - it should never be smaller
|
74
75
|
const dimensions = useBoundingClientRectListener(internalRef);
|
75
76
|
// state
|
77
|
+
const [tabTriggeredClose, setTabTriggeredClose] = React__default.useState(false);
|
76
78
|
const [open, setOpen] = React__default.useState(false);
|
77
79
|
const [value, _setValue] = useControllableState({
|
78
80
|
// uncontrolled
|
@@ -155,6 +157,22 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
155
157
|
setShouldPauseHoverState(true);
|
156
158
|
}
|
157
159
|
};
|
160
|
+
const handleCloseAutoFocus = event => {
|
161
|
+
event.preventDefault();
|
162
|
+
event.stopPropagation();
|
163
|
+
if (tabTriggeredClose) {
|
164
|
+
const nextFocussableElement = getNextFocussableElement(internalRef.current);
|
165
|
+
if (nextFocussableElement) {
|
166
|
+
// UX requirement: move focus to the next focussable element when tab key is pressed to select the value
|
167
|
+
nextFocussableElement.focus();
|
168
|
+
// Reset the tabTriggeredClose state
|
169
|
+
setTabTriggeredClose(false);
|
170
|
+
}
|
171
|
+
} else {
|
172
|
+
var _internalRef$current;
|
173
|
+
(_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
|
174
|
+
}
|
175
|
+
};
|
158
176
|
const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none', createCollectionClassName());
|
159
177
|
return /*#__PURE__*/React__default.createElement(Select2Context.Provider, {
|
160
178
|
value: context
|
@@ -183,15 +201,10 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
183
201
|
asChild: true,
|
184
202
|
align: "start",
|
185
203
|
onOpenAutoFocus: () => {
|
186
|
-
var _internalRef$current;
|
187
|
-
(_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
|
188
|
-
},
|
189
|
-
onCloseAutoFocus: event => {
|
190
204
|
var _internalRef$current2;
|
191
|
-
event.preventDefault();
|
192
|
-
event.stopPropagation();
|
193
205
|
(_internalRef$current2 = internalRef.current) === null || _internalRef$current2 === void 0 ? void 0 : _internalRef$current2.focus();
|
194
206
|
},
|
207
|
+
onCloseAutoFocus: handleCloseAutoFocus,
|
195
208
|
sideOffset: 4,
|
196
209
|
tabIndex: -1
|
197
210
|
}, /*#__PURE__*/React__default.createElement("div", {
|
@@ -201,7 +214,8 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
|
|
201
214
|
}
|
202
215
|
}, flattenedChildren.length > 0 || onCreate ? ( /*#__PURE__*/React__default.createElement(Search, {
|
203
216
|
placeholder: onCreate ? texts.select2.searchOrCreate : texts.select2.search,
|
204
|
-
ref: searchRef
|
217
|
+
ref: searchRef,
|
218
|
+
onTabKeyPress: () => setTabTriggeredClose(true)
|
205
219
|
})) : null, flattenedChildren.length <= 0 ? ( /*#__PURE__*/React__default.createElement("div", {
|
206
220
|
className: "text-grey-700 -mt-0.5 flex h-8 items-center px-2",
|
207
221
|
role: "presentation"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\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 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 } 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 { 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';\n//import { All } from './components/All';\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};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n autoFocus?: boolean;\n children: Select2Children;\n defaultValue?: Select2Value;\n emptyValue?: Select2OptionValue;\n disabled?: boolean;\n highlighted?: boolean;\n invalid?: boolean;\n multiple?: boolean;\n name?: string;\n onChange?: (value: Select2Value) => void;\n onCreate?: Select2CreateHandler;\n onDelete?: Select2DeleteHandler;\n onEdit?: Select2EditHandler;\n readOnly?: boolean;\n required?: boolean;\n tags?: boolean;\n value?: Select2Value;\n placeholder?: 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 placeholder,\n highlighted = false,\n invalid = false,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n readOnly = false,\n tags = false,\n value: prop,\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 validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\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 let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n };\n\n const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none', createCollectionClassName());\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\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.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}\n placeholder={placeholder}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={event => {\n event.preventDefault();\n event.stopPropagation();\n internalRef.current?.focus();\n }}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n />\n ) : null}\n {flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n No results found...\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n tabIndex={-1}\n value={value}>\n {/*multiple && !searchQuery && Array.isArray(value) ? (\n <All\n children={flattenedChildren}\n onToggle={_setValue}\n selected={value.length === flattenedChildren.length}\n />\n ) : null*/}\n {searchQuery === '' ? (\n <Collection>{initialChildren}</Collection>\n ) : (\n <Collection>{filteredChildren}</Collection>\n )}\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\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} 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","placeholder","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","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","handleKeyDown","event","preventDefault","ctrlKey","metaKey","test","_listboxRef$current","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","currentTarget","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","map","child","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current","focus","onCloseAutoFocus","stopPropagation","_internalRef$current2","sideOffset","tabIndex","style","minWidth","width","length","Search","select2","searchOrCreate","search","role","customSelector","Collection","Create","Group","Title","isFormControl","useIsFormControl","bubbleValue","Array","isArray","String","BubbleSelect","option","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;MAyEMA,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,WAAW;IACXC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,QAAQ,GAAG,KAAK;IAChBC,IAAI;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,KAAK,EAAEC,IAAI;IACX,GAAGC;GACN,GAAGtB,KAAK;EAET,MAAMuB,WAAW,GAAuDzB,cAAK,CAAC0B,OAAO,CAAC;IAClF,IAAIjB,UAAU,KAAKC,SAAS,IAAI,CAACI,QAAQ,EAAE;;MAEvC,oBAAOd,6BAAC2B,MAAM;QAACC,GAAG,EAAC,SAAS;QAACxB,QAAQ,EAAC,EAAE;QAAC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/DgF,OAAO,CAACC,GAAG,CAACoC,MAAM,mBACf9H;MAAQ4B,GAAG,EAAEgG,MAAM,CAACE,MAAM,CAAC;MAAExG,KAAK,EAAEsG,MAAM,CAACE,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACD/H,OAAO,CAACgI,WAAW,GAAG,SAAS;;;;"}
|
1
|
+
{"version":3,"file":"Select2.js","sources":["../../../../../../../src/components/Select2/Select2.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\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 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 } 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 { 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 } from '../../utils/dom';\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};\n\ntype Select2Props = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n autoFocus?: boolean;\n children: Select2Children;\n defaultValue?: Select2Value;\n emptyValue?: Select2OptionValue;\n disabled?: boolean;\n highlighted?: boolean;\n invalid?: boolean;\n multiple?: boolean;\n name?: string;\n onChange?: (value: Select2Value) => void;\n onCreate?: Select2CreateHandler;\n onDelete?: Select2DeleteHandler;\n onEdit?: Select2EditHandler;\n readOnly?: boolean;\n required?: boolean;\n tags?: boolean;\n value?: Select2Value;\n placeholder?: 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 placeholder,\n highlighted = false,\n invalid = false,\n multiple = false,\n name,\n onChange,\n onCreate,\n onDelete,\n onEdit,\n readOnly = false,\n tags = false,\n value: prop,\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 [tabTriggeredClose, setTabTriggeredClose] = React.useState(false);\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 validationError,\n value,\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (open) {\n event.preventDefault();\n } else if (!event.ctrlKey && !event.metaKey && (event.key === 'ArrowDown' || /^[a-z0-9]$/i.test(event.key))) {\n setOpen(true);\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 let handleBlur;\n\n if (otherProps.onBlur) {\n // we might be focusing on an input or something inside the dropdown that was triggered by the select\n // so see if the element gaining focus is inside a portal and look up its controller\n // if we don't do this, things like validate on blur occur while simply opening the select\n handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {\n const elementGainingFocus = event.relatedTarget;\n\n if (elementGainingFocus === undefined) {\n return;\n }\n\n const portalId = elementGainingFocus?.closest('[data-radix-popper-content-wrapper] > :first-child')?.id;\n\n if (!portalId || event.currentTarget.getAttribute(`aria-controls`) !== portalId) {\n otherProps.onBlur?.(event);\n }\n };\n }\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (isAriaDirectionKey(event)) {\n setShouldPauseHoverState(true);\n }\n };\n\n const handleCloseAutoFocus = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n\n if (tabTriggeredClose) {\n const nextFocussableElement = getNextFocussableElement(internalRef.current);\n\n if (nextFocussableElement) {\n // UX requirement: move focus to the next focussable element when tab key is pressed to select the value\n nextFocussableElement.focus();\n // Reset the tabTriggeredClose state\n setTabTriggeredClose(false);\n }\n } else {\n internalRef.current?.focus();\n }\n };\n\n const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none', createCollectionClassName());\n\n return (\n <Select2Context.Provider value={context}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\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.Trigger asChild data-taco=\"Select2\">\n <Trigger\n {...otherProps}\n aria-haspopup=\"listbox\"\n emptyValue={emptyValue}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n ref={internalRef}\n placeholder={placeholder}>\n {flattenedChildren}\n </Trigger>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n align=\"start\"\n onOpenAutoFocus={() => {\n internalRef.current?.focus();\n }}\n onCloseAutoFocus={handleCloseAutoFocus}\n sideOffset={4}\n tabIndex={-1}>\n <div className={className} style={{ minWidth: dimensions?.width ? `${dimensions.width}px` : undefined }}>\n {flattenedChildren.length > 0 || onCreate ? (\n <Search\n placeholder={onCreate ? texts.select2.searchOrCreate : texts.select2.search}\n ref={searchRef}\n onTabKeyPress={() => setTabTriggeredClose(true)}\n />\n ) : null}\n {flattenedChildren.length <= 0 ? (\n <div className=\"text-grey-700 -mt-0.5 flex h-8 items-center px-2\" role=\"presentation\">\n No results found...\n </div>\n ) : (\n <ListboxPrimitive.Root\n className=\"flex flex-col gap-0.5\"\n customSelector=\":scope > button\"\n disabled={disabled}\n multiple={multiple}\n onKeyDown={handleListboxKeyDown}\n readOnly={readOnly}\n ref={listboxRef}\n setValue={setValue}\n tabIndex={-1}\n value={value}>\n {searchQuery === '' ? (\n <Collection>{initialChildren}</Collection>\n ) : (\n <Collection>{filteredChildren}</Collection>\n )}\n {onCreate ? <Create onCreate={onCreate} options={flattenedChildren} /> : null}\n </ListboxPrimitive.Root>\n )}\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\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} 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","placeholder","highlighted","invalid","multiple","name","onChange","onCreate","onDelete","onEdit","readOnly","tags","value","prop","otherProps","emptyOption","useMemo","Option","key","className","initialChildren","internalRef","useMergedRef","listboxRef","useRef","searchRef","texts","useLocalization","dimensions","useBoundingClientRectListener","tabTriggeredClose","setTabTriggeredClose","useState","open","setOpen","_setValue","useControllableState","setValue","ListboxPrimitive","validationError","setValidationError","shouldPauseHoverState","setShouldPauseHoverState","useIsHoverStatePaused","flattenedChildren","filteredChildren","searchQuery","setSearchQuery","useChildren","context","handleKeyDown","event","preventDefault","ctrlKey","metaKey","test","_listboxRef$current","current","dispatchEvent","createCustomKeyboardEvent","handleBlur","onBlur","elementGainingFocus","relatedTarget","portalId","_elementGainingFocus$","closest","id","currentTarget","getAttribute","_otherProps$onBlur","call","handleListboxKeyDown","isAriaDirectionKey","handleCloseAutoFocus","stopPropagation","nextFocussableElement","getNextFocussableElement","focus","_internalRef$current","cn","createCollectionClassName","Select2Context","Provider","PopoverPrimitive","onOpenChange","ControlledHiddenField","options","map","child","parentRef","asChild","Trigger","onKeyDown","align","onOpenAutoFocus","_internalRef$current2","onCloseAutoFocus","sideOffset","tabIndex","style","minWidth","width","length","Search","select2","searchOrCreate","search","onTabKeyPress","role","customSelector","Collection","Create","Group","Title","isFormControl","useIsFormControl","bubbleValue","Array","isArray","String","BubbleSelect","option","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;MAyEMA,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,WAAW;IACXC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAG,KAAK;IACfC,QAAQ,GAAG,KAAK;IAChBC,IAAI;IACJC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,MAAM;IACNC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,KAAK,EAAEC,IAAI;IACX,GAAGC;GACN,GAAGtB,KAAK;EAET,MAAMuB,WAAW,GAAuDzB,cAAK,CA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,IAAIF,aAAa,EAAE;IACf,IAAIvG,KAAK,KAAKZ,SAAS,EAAE;MACrB,IAAII,QAAQ,EAAE;QACViH,WAAW,GAAGC,KAAK,CAACC,OAAO,CAAC3G,KAAK,CAAC,GAAGA,KAAK,CAAC4E,GAAG,CAACgC,MAAM,CAAC,GAAG,CAAC5G,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG4G,MAAM,CAAC5G,KAAK,CAAC,CAAC;OACjG,MAAM;QACHyG,WAAW,GAAGzG,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG4G,MAAM,CAAC5G,KAAK,CAAC;;;IAIzD,oBACItB,6BAACmI,YAAY;;MAAavG,GAAG,EAAEsG,MAAM,CAACH,WAAW,CAAC;MAAEjH,QAAQ,EAAEA,QAAQ;MAAEC,IAAI,EAAEA,IAAI;MAAEO,KAAK,EAAEyG;OACtFtH,UAAU,KAAKC,SAAS,gBAAGV;MAAQsB,KAAK,EAAEb;MAAc,GAAG,IAAI,EAC/DwF,OAAO,CAACC,GAAG,CAACkC,MAAM,mBACfpI;MAAQ4B,GAAG,EAAEsG,MAAM,CAACE,MAAM,CAAC;MAAE9G,KAAK,EAAE4G,MAAM,CAACE,MAAM;MAAK,CACzD,CAAC,CACS;;EAIvB,OAAO,IAAI;AACf,CAAC;AACDrI,OAAO,CAACsI,WAAW,GAAG,SAAS;;;;"}
|
@@ -8,6 +8,7 @@ import { useSelect2Context } from './Context.js';
|
|
8
8
|
|
9
9
|
const Search = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(props, ref) {
|
10
10
|
const {
|
11
|
+
onTabKeyPress,
|
11
12
|
...otherProps
|
12
13
|
} = props;
|
13
14
|
const {
|
@@ -32,7 +33,7 @@ const Search = /*#__PURE__*/React__default.forwardRef(function ListboxSearch(pro
|
|
32
33
|
// Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)
|
33
34
|
if (event.key === 'Tab') {
|
34
35
|
setOpen(false);
|
35
|
-
|
36
|
+
onTabKeyPress();
|
36
37
|
}
|
37
38
|
if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
38
39
|
var _listboxRef$current;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["../../../../../../../../src/components/Select2/components/Search.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Input, InputProps } from '../../Input/Input';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { isAriaSelectionKey } from '../../../utils/aria';\n\nexport type Select2SearchProps = InputProps & {};\n\nexport const Search = React.forwardRef<HTMLInputElement, Select2SearchProps>(function ListboxSearch(props, ref) {\n const { ...otherProps } = props;\n const { listboxRef, searchQuery, setSearchQuery, setValidationError, validationError, setOpen } = useSelect2Context();\n\n const handleChange = event => {\n if (validationError) {\n setValidationError(undefined);\n }\n\n setSearchQuery(event.target.value);\n };\n\n const handleKeyDown = event => {\n // space is an aria selection key, so we have to remove it to allow spaces\n if (event.key === ' ') {\n return;\n }\n\n // Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)\n if (event.key === 'Tab') {\n setOpen(false);\n
|
1
|
+
{"version":3,"file":"Search.js","sources":["../../../../../../../../src/components/Select2/components/Search.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Input, InputProps } from '../../Input/Input';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { isAriaSelectionKey } from '../../../utils/aria';\n\nexport type Select2SearchProps = InputProps & {\n onTabKeyPress: () => void;\n};\n\nexport const Search = React.forwardRef<HTMLInputElement, Select2SearchProps>(function ListboxSearch(props, ref) {\n const { onTabKeyPress, ...otherProps } = props;\n const { listboxRef, searchQuery, setSearchQuery, setValidationError, validationError, setOpen } = useSelect2Context();\n\n const handleChange = event => {\n if (validationError) {\n setValidationError(undefined);\n }\n\n setSearchQuery(event.target.value);\n };\n\n const handleKeyDown = event => {\n // space is an aria selection key, so we have to remove it to allow spaces\n if (event.key === ' ') {\n return;\n }\n\n // Select2 should close dropdown and receive focus, when user press Tab while searching (UX requirement to support better keyboard navigation)\n if (event.key === 'Tab') {\n setOpen(false);\n onTabKeyPress();\n }\n\n if (isAriaSelectionKey(event) || event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n // forward navigation events onto the underlying collection - we want arrow keys to work from inside the filter input\n listboxRef?.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n return;\n }\n };\n\n return (\n <Field\n className={cn('mx-1.5 mb-1.5 !min-h-fit ', { '!pb-0': !validationError })}\n invalid={!!validationError}\n message={validationError?.message}>\n <Input\n {...otherProps}\n aria-hidden\n autoFocus\n invalid={!!validationError}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n ref={ref}\n value={searchQuery}\n />\n </Field>\n );\n});\n"],"names":["Search","React","forwardRef","ListboxSearch","props","ref","onTabKeyPress","otherProps","listboxRef","searchQuery","setSearchQuery","setValidationError","validationError","setOpen","useSelect2Context","handleChange","event","undefined","target","value","handleKeyDown","key","isAriaSelectionKey","_listboxRef$current","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","Field","className","cn","invalid","message","Input","autoFocus","onChange","onKeyDown"],"mappings":";;;;;;;;MAYaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAuC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;EAC1G,MAAM;IAAEC,aAAa;IAAE,GAAGC;GAAY,GAAGH,KAAK;EAC9C,MAAM;IAAEI,UAAU;IAAEC,WAAW;IAAEC,cAAc;IAAEC,kBAAkB;IAAEC,eAAe;IAAEC;GAAS,GAAGC,iBAAiB,EAAE;EAErH,MAAMC,YAAY,GAAGC,KAAK;IACtB,IAAIJ,eAAe,EAAE;MACjBD,kBAAkB,CAACM,SAAS,CAAC;;IAGjCP,cAAc,CAACM,KAAK,CAACE,MAAM,CAACC,KAAK,CAAC;GACrC;EAED,MAAMC,aAAa,GAAGJ,KAAK;;IAEvB,IAAIA,KAAK,CAACK,GAAG,KAAK,GAAG,EAAE;MACnB;;;IAIJ,IAAIL,KAAK,CAACK,GAAG,KAAK,KAAK,EAAE;MACrBR,OAAO,CAAC,KAAK,CAAC;MACdP,aAAa,EAAE;;IAGnB,IAAIgB,kBAAkB,CAACN,KAAK,CAAC,IAAIA,KAAK,CAACK,GAAG,KAAK,WAAW,IAAIL,KAAK,CAACK,GAAG,KAAK,SAAS,EAAE;MAAA,IAAAE,mBAAA;MACnFP,KAAK,CAACQ,cAAc,EAAE;;MAEtBhB,UAAU,aAAVA,UAAU,wBAAAe,mBAAA,GAAVf,UAAU,CAAEiB,OAAO,cAAAF,mBAAA,uBAAnBA,mBAAA,CAAqBG,aAAa,CAACC,yBAAyB,CAACX,KAA8C,CAAC,CAAC;MAC7G;;GAEP;EAED,oBACIf,6BAAC2B,KAAK;IACFC,SAAS,EAAEC,EAAE,CAAC,2BAA2B,EAAE;MAAE,OAAO,EAAE,CAAClB;KAAiB,CAAC;IACzEmB,OAAO,EAAE,CAAC,CAACnB,eAAe;IAC1BoB,OAAO,EAAEpB,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEoB;kBAC1B/B,6BAACgC,KAAK,oBACE1B,UAAU;;IAEd2B,SAAS;IACTH,OAAO,EAAE,CAAC,CAACnB,eAAe;IAC1BuB,QAAQ,EAAEpB,YAAY;IACtBqB,SAAS,EAAEhB,aAAa;IACxBf,GAAG,EAAEA,GAAG;IACRc,KAAK,EAAEV;KACT,CACE;AAEhB,CAAC;;;;"}
|
@@ -92,7 +92,7 @@ function ErrorAlert(props) {
|
|
92
92
|
// Getting the row from core rows (ignoring search and filtering)
|
93
93
|
const getCoreRow = React__default.useCallback(rowId => coreRows.find(coreRow => coreRow.id === rowId), [coreRows]);
|
94
94
|
return /*#__PURE__*/React__default.createElement("div", {
|
95
|
-
className: "mb-4"
|
95
|
+
className: "mb-4 empty:hidden"
|
96
96
|
}, errorsRowIds.length ? ( /*#__PURE__*/React__default.createElement(Alert, {
|
97
97
|
state: "error",
|
98
98
|
className: "mb-1"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ErrorAlert.js","sources":["../../../../../../../../../src/components/Table3/components/alert/ErrorAlert.tsx"],"sourcesContent":["import { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { TableStrategy } from '../../types';\nimport React from 'react';\nimport { Alert } from '../../../Alert/Alert';\nimport { Button } from '../../../Button/Button';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { focusableSelector } from '../../util/editing';\nimport { lastCellIndex } from '../rows/Row';\nimport { Dialog } from '../../../Dialog/Dialog';\nimport { Group } from '../../../Group/Group';\n\nexport type ErrorAlertProps<TType = unknown> = {\n table: RTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n scrollToIndex: TableStrategy['scrollToIndex'];\n rowIdentifier?: string;\n};\n\nexport function ErrorAlert<TType = unknown>(props: ErrorAlertProps<TType>) {\n const { table, tableRef, scrollToIndex, rowIdentifier } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const errors = tableMeta.validation.errors;\n const errorsRowIds = errors ? Object.keys(errors) : [];\n const rows = table.getRowModel().rows;\n const coreRows = table.getCoreRowModel().rows;\n const { texts } = useLocalization();\n const [resetFiltersConfirmationOpen, setResetFiltersConfirmationOpen] = React.useState(false);\n const [internalRowId, setInternalRowId] = React.useState<string | null>(null);\n const [internalRowIndex, setInternalRowIndex] = React.useState<number | null>(null);\n const [isFiltersReset, setIsFiltersReset] = React.useState(false);\n const columns = table.getAllFlatColumns();\n const column = columns.find(column => column.id === rowIdentifier);\n const rowIdentifierHeader = column?.columnDef.meta?.header;\n\n // Find and focus first invalid cell\n const navigateToFirstInvalidCell = () => {\n const firstInvalidCell = tableRef.current?.querySelector(\n '[role=\"row\"][data-current=\"true\"] [role=\"cell\"][data-invalid=\"true\"]'\n );\n const firstInvalidElement = firstInvalidCell?.querySelector(focusableSelector);\n\n if (firstInvalidElement) {\n (firstInvalidElement as HTMLElement)?.focus();\n lastCellIndex.value = firstInvalidCell?.getAttribute('data-column-index');\n }\n };\n\n // Navigate to row and focus first invalid cell\n const navigateToRow = rowIndex => {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n scrollToIndex(rowIndex, { align: 'center' });\n lastCellIndex.value = undefined;\n\n // Need to request animation frame here, because newly selected row is not rendered yet.\n requestAnimationFrame(() => {\n navigateToFirstInvalidCell();\n });\n };\n\n // When internal row index is changed after click on row link, we should navigate to the row.\n React.useEffect(() => {\n if (internalRowIndex !== null && internalRowIndex >= 0) {\n navigateToRow(internalRowIndex);\n }\n }, [internalRowIndex]);\n\n // When filters are reset, we're able to get the real row index by rowId\n React.useEffect(() => {\n if (isFiltersReset) {\n const rowIndex = rows.findIndex(row => row.id === internalRowId);\n if (rowIndex === -1) {\n return;\n }\n setInternalRowIndex(rowIndex);\n }\n }, [isFiltersReset]);\n\n const onRowNumberClick = React.useCallback(\n (rowId: string) => {\n // When row is hidden due filtering it will not be present in rows (but it still will be present in coreRows)\n const foundIndex = rows.findIndex(row => row.id === rowId);\n if (foundIndex === -1) {\n setIsFiltersReset(false);\n setResetFiltersConfirmationOpen(true);\n\n // Since row indexes changed due filtering, we need to save row id, so that we can find it when filters will be reset\n setInternalRowId(rowId);\n return;\n }\n\n // In cases when user clicked on a row link multiple times we still need to navigate to the row, and focus the cell,\n // because row/cell will loose focus on next click, but row index will not change.\n if (foundIndex === internalRowIndex) {\n navigateToRow(foundIndex);\n } else {\n setInternalRowIndex(foundIndex);\n }\n },\n [rows, internalRowIndex]\n );\n\n const onResetFiltersConfirm = () => {\n setIsFiltersReset(true);\n };\n\n // Getting the row from core rows (ignoring search and filtering)\n const getCoreRow = React.useCallback((rowId: string) => coreRows.find(coreRow => coreRow.id === rowId), [coreRows]);\n\n return (\n <div className=\"mb-4\">\n {errorsRowIds.length ? (\n <Alert state=\"error\" className=\"mb-1\">\n <>\n <b>\n {errorsRowIds.length} {texts.table3.validation.alert.unsavedEntries(errorsRowIds.length)}\n </b>{' '}\n </>\n {rowIdentifierHeader || texts.table3.validation.index}{' '}\n {errorsRowIds.map((rowId: string, index) => {\n const coreRow = getCoreRow(rowId);\n return (\n <>\n <Button\n key={rowId}\n className=\"!min-h-[theme(spacing.2)] !min-w-[theme(spacing.2)] !px-1\"\n appearance=\"discrete\"\n onClick={() => {\n onRowNumberClick(rowId);\n }}>\n {/* Getting row from core rows, because 'table.getRow' will fail if row is hidden due filtering */}\n {rowIdentifier ? coreRow?.original[rowIdentifier] : coreRow?.index}\n </Button>\n <span key={`${rowId}_comma`}>{index < errorsRowIds.length - 1 ? ',' : ''}</span>\n </>\n );\n })}\n {texts.table3.validation.alert.incompleteAndHavntBeenSaved(errorsRowIds.length)}\n </Alert>\n ) : null}\n <FilterResetDialog\n open={resetFiltersConfirmationOpen}\n onClose={() => {\n setResetFiltersConfirmationOpen(false);\n }}\n onConfirm={onResetFiltersConfirm}\n table={table}\n />\n </div>\n );\n}\n\ntype FilterResetDialogProps<TType = unknown> = {\n open: boolean;\n onClose: () => void;\n onConfirm: () => void;\n table: RTable<TType>;\n};\nfunction FilterResetDialog<TType = unknown>(props: FilterResetDialogProps<TType>) {\n const { open, onClose, onConfirm, table } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { texts } = useLocalization();\n\n const resetFilters = React.useCallback(() => {\n tableMeta.search.setQuery('');\n table.resetGlobalFilter();\n table.resetColumnFilters();\n }, [table, tableMeta.search]);\n\n const handleConfirmClick = () => {\n resetFilters();\n onConfirm();\n onClose();\n };\n\n return (\n <Dialog open={open} onClose={onClose} size=\"xs\">\n <Dialog.Content aria-label=\"Create a new account\">\n <Dialog.Title>{texts.table3.validation.resetFiltersDialog.title}</Dialog.Title>\n\n <p>{texts.table3.validation.resetFiltersDialog.description}</p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button>{texts.table3.validation.resetFiltersDialog.cancel}</Button>\n </Dialog.Close>\n <Button appearance=\"primary\" onClick={handleConfirmClick}>\n {texts.table3.validation.resetFiltersDialog.confirm}\n </Button>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n );\n}\n"],"names":["ErrorAlert","props","table","tableRef","scrollToIndex","rowIdentifier","tableMeta","options","meta","errors","validation","errorsRowIds","Object","keys","rows","getRowModel","coreRows","getCoreRowModel","texts","useLocalization","resetFiltersConfirmationOpen","setResetFiltersConfirmationOpen","React","useState","internalRowId","setInternalRowId","internalRowIndex","setInternalRowIndex","isFiltersReset","setIsFiltersReset","columns","getAllFlatColumns","column","find","id","rowIdentifierHeader","_column$columnDef$met","columnDef","header","navigateToFirstInvalidCell","firstInvalidCell","_tableRef$current","current","querySelector","firstInvalidElement","focusableSelector","focus","lastCellIndex","value","getAttribute","navigateToRow","rowIndex","rowActive","setRowActiveIndex","align","undefined","requestAnimationFrame","useEffect","findIndex","row","onRowNumberClick","useCallback","rowId","foundIndex","onResetFiltersConfirm","getCoreRow","coreRow","className","length","Alert","state","table3","alert","unsavedEntries","index","map","Button","key","appearance","onClick","original","incompleteAndHavntBeenSaved","FilterResetDialog","open","onClose","onConfirm","resetFilters","search","setQuery","resetGlobalFilter","resetColumnFilters","handleConfirmClick","Dialog","size","Content","Title","resetFiltersDialog","title","description","Footer","Group","Close","cancel","confirm"],"mappings":";;;;;;;;;SAkBgBA,UAAUA,CAAkBC,KAA6B;;EACrE,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,aAAa;IAAEC;GAAe,GAAGJ,KAAK;EAC/D,MAAMK,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;EACxD,MAAMC,MAAM,GAAGH,SAAS,CAACI,UAAU,CAACD,MAAM;EAC1C,MAAME,YAAY,GAAGF,MAAM,GAAGG,MAAM,CAACC,IAAI,CAACJ,MAAM,CAAC,GAAG,EAAE;EACtD,MAAMK,IAAI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CAAIJ,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACE,WAAW,CAAK,eAE/D5E,6BAACsE,MAAM,CAACO,MAAM,qBACV7E,6BAAC8E,KAAK,qBACF9E,6BAACsE,MAAM,CAACS,KAAK,qBACT/E,6BAACsD,MAAM,QAAE1D,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACM,MAAM,CAAU,CACzD,eACfhF,6BAACsD,MAAM;IAACE,UAAU,EAAC,SAAS;IAACC,OAAO,EAAEY;KACjCzE,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACO,OAAO,CAC9C,CACL,CACI,CACH,CACZ;AAEjB;;;;"}
|
1
|
+
{"version":3,"file":"ErrorAlert.js","sources":["../../../../../../../../../src/components/Table3/components/alert/ErrorAlert.tsx"],"sourcesContent":["import { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { TableStrategy } from '../../types';\nimport React from 'react';\nimport { Alert } from '../../../Alert/Alert';\nimport { Button } from '../../../Button/Button';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { focusableSelector } from '../../util/editing';\nimport { lastCellIndex } from '../rows/Row';\nimport { Dialog } from '../../../Dialog/Dialog';\nimport { Group } from '../../../Group/Group';\n\nexport type ErrorAlertProps<TType = unknown> = {\n table: RTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n scrollToIndex: TableStrategy['scrollToIndex'];\n rowIdentifier?: string;\n};\n\nexport function ErrorAlert<TType = unknown>(props: ErrorAlertProps<TType>) {\n const { table, tableRef, scrollToIndex, rowIdentifier } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const errors = tableMeta.validation.errors;\n const errorsRowIds = errors ? Object.keys(errors) : [];\n const rows = table.getRowModel().rows;\n const coreRows = table.getCoreRowModel().rows;\n const { texts } = useLocalization();\n const [resetFiltersConfirmationOpen, setResetFiltersConfirmationOpen] = React.useState(false);\n const [internalRowId, setInternalRowId] = React.useState<string | null>(null);\n const [internalRowIndex, setInternalRowIndex] = React.useState<number | null>(null);\n const [isFiltersReset, setIsFiltersReset] = React.useState(false);\n const columns = table.getAllFlatColumns();\n const column = columns.find(column => column.id === rowIdentifier);\n const rowIdentifierHeader = column?.columnDef.meta?.header;\n\n // Find and focus first invalid cell\n const navigateToFirstInvalidCell = () => {\n const firstInvalidCell = tableRef.current?.querySelector(\n '[role=\"row\"][data-current=\"true\"] [role=\"cell\"][data-invalid=\"true\"]'\n );\n const firstInvalidElement = firstInvalidCell?.querySelector(focusableSelector);\n\n if (firstInvalidElement) {\n (firstInvalidElement as HTMLElement)?.focus();\n lastCellIndex.value = firstInvalidCell?.getAttribute('data-column-index');\n }\n };\n\n // Navigate to row and focus first invalid cell\n const navigateToRow = rowIndex => {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n scrollToIndex(rowIndex, { align: 'center' });\n lastCellIndex.value = undefined;\n\n // Need to request animation frame here, because newly selected row is not rendered yet.\n requestAnimationFrame(() => {\n navigateToFirstInvalidCell();\n });\n };\n\n // When internal row index is changed after click on row link, we should navigate to the row.\n React.useEffect(() => {\n if (internalRowIndex !== null && internalRowIndex >= 0) {\n navigateToRow(internalRowIndex);\n }\n }, [internalRowIndex]);\n\n // When filters are reset, we're able to get the real row index by rowId\n React.useEffect(() => {\n if (isFiltersReset) {\n const rowIndex = rows.findIndex(row => row.id === internalRowId);\n if (rowIndex === -1) {\n return;\n }\n setInternalRowIndex(rowIndex);\n }\n }, [isFiltersReset]);\n\n const onRowNumberClick = React.useCallback(\n (rowId: string) => {\n // When row is hidden due filtering it will not be present in rows (but it still will be present in coreRows)\n const foundIndex = rows.findIndex(row => row.id === rowId);\n if (foundIndex === -1) {\n setIsFiltersReset(false);\n setResetFiltersConfirmationOpen(true);\n\n // Since row indexes changed due filtering, we need to save row id, so that we can find it when filters will be reset\n setInternalRowId(rowId);\n return;\n }\n\n // In cases when user clicked on a row link multiple times we still need to navigate to the row, and focus the cell,\n // because row/cell will loose focus on next click, but row index will not change.\n if (foundIndex === internalRowIndex) {\n navigateToRow(foundIndex);\n } else {\n setInternalRowIndex(foundIndex);\n }\n },\n [rows, internalRowIndex]\n );\n\n const onResetFiltersConfirm = () => {\n setIsFiltersReset(true);\n };\n\n // Getting the row from core rows (ignoring search and filtering)\n const getCoreRow = React.useCallback((rowId: string) => coreRows.find(coreRow => coreRow.id === rowId), [coreRows]);\n\n return (\n <div className=\"mb-4 empty:hidden\">\n {errorsRowIds.length ? (\n <Alert state=\"error\" className=\"mb-1\">\n <>\n <b>\n {errorsRowIds.length} {texts.table3.validation.alert.unsavedEntries(errorsRowIds.length)}\n </b>{' '}\n </>\n {rowIdentifierHeader || texts.table3.validation.index}{' '}\n {errorsRowIds.map((rowId: string, index) => {\n const coreRow = getCoreRow(rowId);\n return (\n <>\n <Button\n key={rowId}\n className=\"!min-h-[theme(spacing.2)] !min-w-[theme(spacing.2)] !px-1\"\n appearance=\"discrete\"\n onClick={() => {\n onRowNumberClick(rowId);\n }}>\n {/* Getting row from core rows, because 'table.getRow' will fail if row is hidden due filtering */}\n {rowIdentifier ? coreRow?.original[rowIdentifier] : coreRow?.index}\n </Button>\n <span key={`${rowId}_comma`}>{index < errorsRowIds.length - 1 ? ',' : ''}</span>\n </>\n );\n })}\n {texts.table3.validation.alert.incompleteAndHavntBeenSaved(errorsRowIds.length)}\n </Alert>\n ) : null}\n <FilterResetDialog\n open={resetFiltersConfirmationOpen}\n onClose={() => {\n setResetFiltersConfirmationOpen(false);\n }}\n onConfirm={onResetFiltersConfirm}\n table={table}\n />\n </div>\n );\n}\n\ntype FilterResetDialogProps<TType = unknown> = {\n open: boolean;\n onClose: () => void;\n onConfirm: () => void;\n table: RTable<TType>;\n};\nfunction FilterResetDialog<TType = unknown>(props: FilterResetDialogProps<TType>) {\n const { open, onClose, onConfirm, table } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { texts } = useLocalization();\n\n const resetFilters = React.useCallback(() => {\n tableMeta.search.setQuery('');\n table.resetGlobalFilter();\n table.resetColumnFilters();\n }, [table, tableMeta.search]);\n\n const handleConfirmClick = () => {\n resetFilters();\n onConfirm();\n onClose();\n };\n\n return (\n <Dialog open={open} onClose={onClose} size=\"xs\">\n <Dialog.Content aria-label=\"Create a new account\">\n <Dialog.Title>{texts.table3.validation.resetFiltersDialog.title}</Dialog.Title>\n\n <p>{texts.table3.validation.resetFiltersDialog.description}</p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button>{texts.table3.validation.resetFiltersDialog.cancel}</Button>\n </Dialog.Close>\n <Button appearance=\"primary\" onClick={handleConfirmClick}>\n {texts.table3.validation.resetFiltersDialog.confirm}\n </Button>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n );\n}\n"],"names":["ErrorAlert","props","table","tableRef","scrollToIndex","rowIdentifier","tableMeta","options","meta","errors","validation","errorsRowIds","Object","keys","rows","getRowModel","coreRows","getCoreRowModel","texts","useLocalization","resetFiltersConfirmationOpen","setResetFiltersConfirmationOpen","React","useState","internalRowId","setInternalRowId","internalRowIndex","setInternalRowIndex","isFiltersReset","setIsFiltersReset","columns","getAllFlatColumns","column","find","id","rowIdentifierHeader","_column$columnDef$met","columnDef","header","navigateToFirstInvalidCell","firstInvalidCell","_tableRef$current","current","querySelector","firstInvalidElement","focusableSelector","focus","lastCellIndex","value","getAttribute","navigateToRow","rowIndex","rowActive","setRowActiveIndex","align","undefined","requestAnimationFrame","useEffect","findIndex","row","onRowNumberClick","useCallback","rowId","foundIndex","onResetFiltersConfirm","getCoreRow","coreRow","className","length","Alert","state","table3","alert","unsavedEntries","index","map","Button","key","appearance","onClick","original","incompleteAndHavntBeenSaved","FilterResetDialog","open","onClose","onConfirm","resetFilters","search","setQuery","resetGlobalFilter","resetColumnFilters","handleConfirmClick","Dialog","size","Content","Title","resetFiltersDialog","title","description","Footer","Group","Close","cancel","confirm"],"mappings":";;;;;;;;;SAkBgBA,UAAUA,CAAkBC,KAA6B;;EACrE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AAS,EAAE;IACXD,OAAO,EAAE;GACZ;EAED,oBACI9D,6BAACsE,MAAM;IAACT,IAAI,EAAEA,IAAI;IAAEC,OAAO,EAAEA,OAAO;IAAES,IAAI,EAAC;kBACvCvE,6BAACsE,MAAM,CAACE,OAAO;kBAAY;kBACvBxE,6BAACsE,MAAM,CAACG,KAAK,QAAE7E,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACC,KAAK,CAAgB,eAE/E3E,wCAAIJ,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACE,WAAW,CAAK,eAE/D5E,6BAACsE,MAAM,CAACO,MAAM,qBACV7E,6BAAC8E,KAAK,qBACF9E,6BAACsE,MAAM,CAACS,KAAK,qBACT/E,6BAACsD,MAAM,QAAE1D,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACM,MAAM,CAAU,CACzD,eACfhF,6BAACsD,MAAM;IAACE,UAAU,EAAC,SAAS;IAACC,OAAO,EAAEY;KACjCzE,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACO,OAAO,CAC9C,CACL,CACI,CACH,CACZ;AAEjB;;;;"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
-
import { useRowContext
|
2
|
+
import { useRowContext } from '../../rows/RowContext.js';
|
3
3
|
import { DisplayCell } from './DisplayCell.js';
|
4
|
+
import { isIndicatorVisible, getIndicatorCellClassName } from './Indicator.js';
|
4
5
|
import { isCellHighlighted } from '../../../util/columns.js';
|
5
6
|
import { EditingCell } from './EditingCell.js';
|
6
7
|
|
@@ -16,7 +17,8 @@ function Cell(props) {
|
|
16
17
|
} = props;
|
17
18
|
const {
|
18
19
|
isHovered: isHoveredRow,
|
19
|
-
hasError
|
20
|
+
hasError,
|
21
|
+
rowIndex
|
20
22
|
} = useRowContext();
|
21
23
|
const rows = table.getRowModel().rows;
|
22
24
|
const tableMeta = table.options.meta;
|
@@ -26,15 +28,15 @@ function Cell(props) {
|
|
26
28
|
const rowActiveIndex = tableMeta.rowActive.rowActiveIndex;
|
27
29
|
const isActiveRow = rowActiveIndex !== undefined && ((_rows$rowActiveIndex = rows[rowActiveIndex]) === null || _rows$rowActiveIndex === void 0 ? void 0 : _rows$rowActiveIndex.id) === row.id;
|
28
30
|
let value = getValue();
|
31
|
+
const allVisibleColumns = table.getVisibleLeafColumns();
|
32
|
+
const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
|
33
|
+
const className = isIndicatorVisible(rowIndex, rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(index, lastColumnIndex) : undefined;
|
29
34
|
// When row has changes we always need to show the editing state value, end revert it to original value only when row got saved successfully.
|
30
35
|
// Otherwise it might confuse user because it will look like display value is getting reverted everytime user leaves the row.
|
31
36
|
if (tableMeta.editing.isEditing) {
|
32
37
|
const editingValue = tableMeta.editing.getCellValue(cell);
|
33
38
|
value = editingValue !== null && editingValue !== void 0 ? editingValue : value;
|
34
39
|
}
|
35
|
-
const {
|
36
|
-
rowIndex
|
37
|
-
} = React__default.useContext(RowContext);
|
38
40
|
const memoedHighlight = React__default.useMemo(() => {
|
39
41
|
var _tableMeta$search$que;
|
40
42
|
if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {
|
@@ -62,10 +64,13 @@ function Cell(props) {
|
|
62
64
|
if (tableMeta.editing.isEditing && columnMeta.control && (isActiveRow || isHoveredRow && !tableMeta.rowActive.isHoverStatePaused ||
|
63
65
|
// When cell has error, we renderimg it in edit mode (UX reqirement)
|
64
66
|
isColumnError)) {
|
65
|
-
return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props, highlightProps
|
67
|
+
return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props, highlightProps, {
|
68
|
+
className: className
|
69
|
+
}));
|
66
70
|
}
|
67
71
|
return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, highlightProps, {
|
68
|
-
value: value
|
72
|
+
value: value,
|
73
|
+
className: className
|
69
74
|
}));
|
70
75
|
}
|
71
76
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Cell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { DisplayCell } from './DisplayCell';\nimport { EditingCell } from './EditingCell';\nimport {
|
1
|
+
{"version":3,"file":"Cell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { DisplayCell } from './DisplayCell';\nimport { EditingCell } from './EditingCell';\nimport { useRowContext } from '../../rows/RowContext';\nimport { isCellHighlighted } from '../../../util/columns';\nimport { getIndicatorCellClassName, isIndicatorVisible } from './Indicator';\n\nexport type CellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n};\n\nexport function Cell<TType = unknown>(props: CellProps<TType>) {\n const { column, row, table, index, getValue, cell } = props;\n const { isHovered: isHoveredRow, hasError, rowIndex } = useRowContext();\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<unknown>;\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n const rowErrors = tableMeta.validation.errors ? tableMeta.validation.errors[row.id] : null;\n const isColumnError = hasError && rowErrors && !!rowErrors[column.id];\n\n const rowActiveIndex = tableMeta.rowActive.rowActiveIndex;\n const isActiveRow = rowActiveIndex !== undefined && rows[rowActiveIndex]?.id === row.id;\n let value = getValue();\n\n const allVisibleColumns = table.getVisibleLeafColumns();\n const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;\n const className = isIndicatorVisible(rowIndex, rowActiveIndex, tableMeta.editing.rowMoveReason)\n ? getIndicatorCellClassName(index, lastColumnIndex)\n : undefined;\n\n // When row has changes we always need to show the editing state value, end revert it to original value only when row got saved successfully.\n // Otherwise it might confuse user because it will look like display value is getting reverted everytime user leaves the row.\n if (tableMeta.editing.isEditing) {\n const editingValue = tableMeta.editing.getCellValue(cell);\n value = editingValue ?? value;\n }\n\n const memoedHighlight = React.useMemo(() => {\n if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {\n return false;\n }\n\n if (tableMeta.search.query?.length) {\n return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);\n }\n\n return false;\n }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);\n\n const memoedHighlightCurrent = React.useMemo(() => {\n if (\n !tableMeta.search.isHighlightingEnabled ||\n !memoedHighlight ||\n tableMeta.search.currentHighlightColumnIndex === undefined\n ) {\n return false;\n }\n\n const [rowActiveIndex, currentColumnIndex] =\n tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (rowActiveIndex === rowIndex && currentColumnIndex === index) {\n return true;\n }\n\n return false;\n }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);\n\n const highlightProps = {\n highlighted: memoedHighlight,\n highlightedAsCurrent: memoedHighlightCurrent,\n };\n\n if (\n tableMeta.editing.isEditing &&\n columnMeta.control &&\n (isActiveRow ||\n (isHoveredRow && !tableMeta.rowActive.isHoverStatePaused) ||\n // When cell has error, we renderimg it in edit mode (UX reqirement)\n isColumnError)\n ) {\n return <EditingCell {...props} {...highlightProps} className={className} />;\n }\n\n return <DisplayCell {...props} {...highlightProps} value={value} className={className} />;\n}\n"],"names":["Cell","props","column","row","table","index","getValue","cell","isHovered","isHoveredRow","hasError","rowIndex","useRowContext","rows","getRowModel","tableMeta","options","meta","columnMeta","columnDef","rowErrors","validation","errors","id","isColumnError","rowActiveIndex","rowActive","isActiveRow","undefined","_rows$rowActiveIndex","value","allVisibleColumns","getVisibleLeafColumns","lastColumnIndex","length","className","isIndicatorVisible","editing","rowMoveReason","getIndicatorCellClassName","isEditing","editingValue","getCellValue","memoedHighlight","React","useMemo","search","isHighlightingEnabled","enableSearch","_tableMeta$search$que","query","isCellHighlighted","dataType","excludeUnmatchedResults","memoedHighlightCurrent","currentHighlightColumnIndex","currentColumnIndex","highlightedColumnIndexes","highlightProps","highlighted","highlightedAsCurrent","control","isHoverStatePaused","EditingCell","DisplayCell"],"mappings":";;;;;;;SAYgBA,IAAIA,CAAkBC,KAAuB;;EACzD,MAAM;IAAEC,MAAM;IAAEC,GAAG;IAAEC,KAAK;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;GAAM,GAAGN,KAAK;EAC3D,MAAM;IAAEO,SAAS,EAAEC,YAAY;IAAEC,QAAQ;IAAEC;GAAU,GAAGC,aAAa,EAAE;EACvE,MAAMC,IAAI,GAAGT,KAAK,CAACU,WAAW,EAAE,CAACD,IAAI;EACrC,MAAME,SAAS,GAAGX,KAAK,CAACY,OAAO,CAACC,IAA0B;EAC1D,MAAMC,UAAU,GAAGhB,MAAM,CAACiB,SAAS,CAACF,IAAkC;EACtE,MAAMG,SAAS,GAAGL,SAAS,CAACM,UAAU,CAACC,MAAM,GAAGP,SAAS,CAACM,UAAU,CAACC,MAAM,CAACnB,GAAG,CAACoB,EAAE,CAAC,GAAG,IAAI;EAC1F,MAAMC,aAAa,GAAGd,QAAQ,IAAIU,SAAS,IAAI,CAAC,CAACA,SAAS,CAAClB,MAAM,CAACqB,EAAE,CAAC;EAErE,MAAME,cAAc,GAAGV,SAAS,CAACW,SAAS,CAACD,cAAc;EACzD,MAAME,WAAW,GAAGF,cAAc,KAAKG,SAAS,IAAI,EAAAC,oBAAA,GAAAhB,IAAI,CAACY,cAAc,CAAC,cAAAI,oBAAA,uBAApBA,oBAAA,CAAsBN,EAAE,MAAKpB,GAAG,CAACoB,EAAE;EACvF,IAAIO,KAAK,GAAGxB,QAAQ,EAAE;EAEtB,MAAMyB,iBAAiB,GAAG3B,KAA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MAAM,CAACS,2BAA2B,KAAK3B,SAAS,EAC5D;MACE,OAAO,KAAK;;IAGhB,MAAM,CAACH,cAAc,EAAE+B,kBAAkB,CAAC,GACtCzC,SAAS,CAAC+B,MAAM,CAACW,wBAAwB,CAAC1C,SAAS,CAAC+B,MAAM,CAACS,2BAA2B,CAAC;IAE3F,IAAI9B,cAAc,KAAKd,QAAQ,IAAI6C,kBAAkB,KAAKnD,KAAK,EAAE;MAC7D,OAAO,IAAI;;IAGf,OAAO,KAAK;GACf,EAAE,CAACsC,eAAe,EAAE5B,SAAS,CAAC+B,MAAM,CAACW,wBAAwB,CAACvB,MAAM,EAAEnB,SAAS,CAAC+B,MAAM,CAACS,2BAA2B,CAAC,CAAC;EAErH,MAAMG,cAAc,GAAG;IACnBC,WAAW,EAAEhB,eAAe;IAC5BiB,oBAAoB,EAAEN;GACzB;EAED,IACIvC,SAAS,CAACsB,OAAO,CAACG,SAAS,IAC3BtB,UAAU,CAAC2C,OAAO,KACjBlC,WAAW,IACPlB,YAAY,IAAI,CAACM,SAAS,CAACW,SAAS,CAACoC,kBAAmB;;EAEzDtC,aAAa,CAAC,EACpB;IACE,oBAAOoB,6BAACmB,WAAW,oBAAK9D,KAAK,EAAMyD,cAAc;MAAEvB,SAAS,EAAEA;OAAa;;EAG/E,oBAAOS,6BAACoB,WAAW,oBAAK/D,KAAK,EAAMyD,cAAc;IAAE5B,KAAK,EAAEA,KAAK;IAAEK,SAAS,EAAEA;KAAa;AAC7F;;;;"}
|
@@ -33,7 +33,7 @@ function DisplayCell(props) {
|
|
33
33
|
index,
|
34
34
|
tableRef
|
35
35
|
};
|
36
|
-
}, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);
|
36
|
+
}, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex, className]);
|
37
37
|
return /*#__PURE__*/React__default.createElement(MemoedDisplayCell, Object.assign({}, memoedProps, {
|
38
38
|
highlighted: highlighted,
|
39
39
|
highlightedAsCurrent: highlightedAsCurrent
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { Highlight } from './Highlight';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n className?: string;\n value?: any;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, value, index, row, table, tableRef, highlighted, highlightedAsCurrent } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);\n\n return <MemoedDisplayCell<TType> {...memoedProps} highlighted={highlighted} highlightedAsCurrent={highlightedAsCurrent} />;\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n"],"names":["DisplayCell","props","cell","className","column","value","index","row","table","tableRef","highlighted","highlightedAsCurrent","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","MemoedDisplayCell","memo","customClassName","layoutClassName","undefined","content","console","log","role","tabIndex","Highlight","current"],"mappings":";;;;SAcgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,GAAG;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;GAAsB,GAAGV,KAAK;EAChH,MAAMW,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMV,MAAM,CAACW,SAAS,CAACC,IAAkC,EAAE,EAAE,CAAC;EAC/F,MAAMC,SAAS,GAAGT,KAAK,CAACU,OAAO,CAACF,IAAwB;;;EAIxD,MAAMG,WAAW,GAAGN,cAAK,CAACC,OAAO,CAAC;;IAC9B,OAAO;MACHM,KAAK,EAAER,UAAU,CAACQ,KAAK;MACvBC,QAAQ,GAAAC,IAAA,IAAAC,KAAA,IAAAC,eAAA,GAAGvB,KAAK,CAACoB,QAAQ,cAAAG,eAAA,cAAAA,eAAA,IAAAC,oBAAA,GAAIb,UAAU,CAACc,QAAQ,cAAAD,oBAAA,uBAAnBA,oBAAA,CAAAE,IAAA,CAAAf,UAAU,EAAYP,KAAK,EAAEE,GAAG,CAACqB,QAAQ,CAAC,cAAAL,KAAA,cAAAA,KAAA,GAAIlB,KAAK,cAAAiB,IAAA,cAAAA,IAAA,GAAI,IAG1E;MACVnB,SAAS,EAAE0B,EAAE,CACT1B,SAAS,EACT,OAAOS,UAAU,CAACT,SAAS,KAAK,UAAU,GAAGS,UAAU,CAACT,SAAS,CAACI,GAAG,CAACqB,QAAQ,CAAC,GAAGhB,UAAU,CAACT,SAAS,CACzG;MACD2B,IAAI,EAAEvB,GAAG,CAACqB,QAAQ;MAClBG,KAAK,EAAEvB,KAAK,CAACU,OAAO,CAACc,QAAQ;MAC7BC,cAAc,EAAErB,UAAU,CAACqB,cAAc;MACzCC,iBAAiB,EAAEjB,SAAS,CAACkB,cAAc,CAACD,iBAAiB;MAC7DE,EAAE,EAAElC,IAAI,CAACkC,EAAE;MACX9B,KAAK;MACLG;KACH;GACJ,EAAE,CAACF,GAAG,CAACqB,QAAQ,EAAE3B,KAAK,CAACoB,QAAQ,EAAEhB,KAAK,EAAEY,SAAS,CAACkB,cAAc,CAACD,iBAAiB,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { Highlight } from './Highlight';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n className?: string;\n value?: any;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, value, index, row, table, tableRef, highlighted, highlightedAsCurrent } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex, className]);\n\n return <MemoedDisplayCell<TType> {...memoedProps} highlighted={highlighted} highlightedAsCurrent={highlightedAsCurrent} />;\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n"],"names":["DisplayCell","props","cell","className","column","value","index","row","table","tableRef","highlighted","highlightedAsCurrent","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","MemoedDisplayCell","memo","customClassName","layoutClassName","undefined","content","console","log","role","tabIndex","Highlight","current"],"mappings":";;;;SAcgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,GAAG;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;GAAsB,GAAGV,KAAK;EAChH,MAAMW,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMV,MAAM,CAACW,SAAS,CAACC,IAAkC,EAAE,EAAE,CAAC;EAC/F,MAAMC,SAAS,GAAGT,KAAK,CAACU,OAAO,CAACF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C;EACjH,MAAM;IACFmB,KAAK,GAAG,MAAM;IACdC,QAAQ;IACRlB,SAAS,EAAEoC,eAAe;IAC1BR,KAAK;IACLE,cAAc;IACdC,iBAAiB;IACjBxB,WAAW;IACXC,oBAAoB,GAAG,KAAK;IAC5ByB,EAAE;IACF9B,KAAK;IACLG;GACH,GAAGR,KAAK;EAET,MAAMuC,eAAe,GAAGX,EAAE,CACtB,gHAAgH,EAChHU,eAAe,CAClB;EAED,MAAMpC,SAAS,GAAGO,WAAW,GAAG+B,SAAS,GAAGD,eAAe;EAC3D,MAAME,OAAO,GAAGT,cAAc,gBAAGpB;IAAMV,SAAS,EAAC;KAAYkB,QAAQ,CAAQ,GAAGA,QAAQ;EAExF,IAAIU,KAAK,EAAE;IACPY,OAAO,CAACC,GAAG,CAAC,aAAa,EAAER,EAAE,CAAC;;EAGlC,oBACIvB;IACIV,SAAS,EAAEA,SAAS;kBACRiB,KAAK;yBACEd,KAAK;wBACNI,WAAW;IAC7BmC,IAAI,EAAC,MAAM;;IAEXC,QAAQ,EAAE,CAAC;KACVpC,WAAW,kBACRG,6BAACkC,SAAS;IACN5C,SAAS,EAAEqC,eAAe;IAC1BQ,OAAO,EAAErC,oBAAoB;IAC7BuB,iBAAiB,EAAEA,iBAAiB;IACpC5B,KAAK,EAAEA,KAAK;IACZG,QAAQ,EAAEA;KACTiC,OAAO,CACA,IAEZA,OACH,CACC;AAEd,CAAC,CAA2E;;;;"}
|
@@ -3,9 +3,9 @@ import cn from 'classnames';
|
|
3
3
|
import { Field } from '../../../../Field/Field.js';
|
4
4
|
import { useRowContext, RowContext } from '../../rows/RowContext.js';
|
5
5
|
import { Highlight } from './Highlight.js';
|
6
|
+
import { Indicator, IndicatorReason } from './Indicator.js';
|
6
7
|
import { getCurrentRowCellElement } from '../../../util/columns.js';
|
7
8
|
import { globalFilterFn, columnFilterFn } from '../../../util/filtering.js';
|
8
|
-
import { Indicator, IndicatorReason } from './Indicator.js';
|
9
9
|
import { hasChanged, willRowMoveAfterSorting } from '../../../util/editing.js';
|
10
10
|
import { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions.js';
|
11
11
|
import { EditingControl } from './EditingControl.js';
|
@@ -103,7 +103,10 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
103
103
|
React__default.useEffect(() => {
|
104
104
|
// To avoid reseting move reason on another row hover,
|
105
105
|
// we need to check for changes only if value got changed in the current row.
|
106
|
-
if (!isActiveRow
|
106
|
+
if (!isActiveRow) {
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
if (error) {
|
107
110
|
if (tableMeta.editing.rowMoveReason) {
|
108
111
|
removeMoveReason();
|
109
112
|
}
|
@@ -113,9 +116,11 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
113
116
|
const moveReason = getRowMoveReason(table, rowIndex,
|
114
117
|
// cannot use row.index, as this is not kept in sync once a column is sorted.
|
115
118
|
row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
+
if (moveReason) {
|
120
|
+
tableMeta.editing.setRowMoveReason({
|
121
|
+
[cell.column.id]: moveReason
|
122
|
+
});
|
123
|
+
}
|
119
124
|
} else {
|
120
125
|
removeMoveReason();
|
121
126
|
}
|
@@ -125,7 +130,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
125
130
|
const className = cn('py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]', {
|
126
131
|
// Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative
|
127
132
|
relative: controlRenderer === 'textarea' && columnMeta.enableTruncate
|
128
|
-
}, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
133
|
+
}, props.className, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
129
134
|
const fieldClassName = cn('!min-h-0 w-full !pb-0', {
|
130
135
|
'!pb-3': !!error
|
131
136
|
});
|