@economic/taco 2.41.4 → 2.42.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/AlertDialog/AlertDialog.d.ts +2 -0
- package/dist/components/AlertDialog/components/Content.d.ts +1 -1
- package/dist/components/Table3/util/editing.d.ts +2 -1
- package/dist/esm/packages/taco/src/components/AlertDialog/AlertDialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/AlertDialog/components/Content.js +31 -3
- package/dist/esm/packages/taco/src/components/AlertDialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js +7 -5
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Primitives.js +2 -1
- package/dist/esm/packages/taco/src/components/Popover/Primitives.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +7 -4
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js +6 -5
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/util.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.js +5 -7
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +4 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js +4 -17
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js +62 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/filtering.js +1 -15
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/filtering.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js +37 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +22 -8
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js +4 -6
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
- package/dist/primitives/Table/types.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/util/columns.d.ts +2 -2
- package/dist/primitives/Table/useTableManager/util/dataTypes.d.ts +12 -0
- package/dist/primitives/Table/useTableManager/util/filtering.d.ts +0 -2
- package/dist/primitives/Table/useTableManager/util/search.d.ts +6 -2
- package/dist/primitives/Table/useTableManager/util/setup.d.ts +3 -2
- package/dist/primitives/Table/useTableManager/util/sorting.d.ts +2 -1
- package/dist/taco.cjs.development.js +319 -219
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -12,6 +12,8 @@ export declare type AlertDialogProps = {
|
|
12
12
|
open?: boolean;
|
13
13
|
/** A trigger to be used for the alert dialog, should not be set if `children` already contains a trigger */
|
14
14
|
trigger?: JSX.Element;
|
15
|
+
/** A state to be used for the alert dialog, which will add appropriate badge icon next to the title */
|
16
|
+
variant?: 'warning' | 'error' | 'information';
|
15
17
|
};
|
16
18
|
export declare type ForwardedAlertDialogWithStatics = React.ForwardRefExoticComponent<AlertDialogProps & React.RefAttributes<HTMLElement>> & {
|
17
19
|
Trigger: React.ForwardRefExoticComponent<AlertDialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
@@ -6,7 +6,7 @@ export declare type AlertDialogContentProps = Omit<React.HTMLAttributes<HTMLDivE
|
|
6
6
|
'aria-label': string;
|
7
7
|
children: React.ReactNode;
|
8
8
|
};
|
9
|
-
export declare const Content: React.ForwardRefExoticComponent<Pick<React.HTMLAttributes<HTMLDivElement>, "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "
|
9
|
+
export declare const Content: React.ForwardRefExoticComponent<Pick<React.HTMLAttributes<HTMLDivElement>, "id" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "nonce" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "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" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "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"> & {
|
10
10
|
/** An accessible label to be announced when the dialog is opened */
|
11
11
|
'aria-label': string;
|
12
12
|
children: React.ReactNode;
|
@@ -1,3 +1,4 @@
|
|
1
1
|
import { Cell as ReactTableCell } from '@tanstack/react-table';
|
2
|
-
|
2
|
+
import { Localization } from '../../Provider/Localization';
|
3
|
+
export declare function willRowMove<TType = unknown>(cell: ReactTableCell<TType, unknown>, change: unknown, rowIndex: number, localization: Localization): "search" | "filter" | "sorting" | undefined;
|
3
4
|
export declare function animateCreateRow(id: any): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AlertDialog.js","sources":["../../../../../../../src/components/AlertDialog/AlertDialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport { AlertDialogContext } from './Context';\nimport { Trigger, AlertDialogTriggerProps } from './components/Trigger';\nimport {\n Cancel,\n Action,\n Footer,\n AlertDialogCancelProps,\n AlertDialogActionProps,\n AlertDialogFooterProps,\n} from './components/Footer';\nimport { Title, Content, AlertDialogContentProps, AlertDialogTitleProps } from './components/Content';\n\nexport type AlertDialogProps = {\n children: React.ReactNode | React.ReactNode[];\n /** Set whether the alert dialog is open by default or not, use when not providing a trigger */\n defaultOpen?: boolean;\n /** Called when the alert dialog opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean) => void;\n /** Control the open state of the dialog from outside the component */\n open?: boolean;\n /** A trigger to be used for the alert dialog, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n};\n\nexport type ForwardedAlertDialogWithStatics = React.ForwardRefExoticComponent<\n AlertDialogProps & React.RefAttributes<HTMLElement>\n> & {\n Trigger: React.ForwardRefExoticComponent<AlertDialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<AlertDialogContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<AlertDialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<AlertDialogFooterProps & React.RefAttributes<HTMLDivElement>>;\n Action: React.ForwardRefExoticComponent<AlertDialogActionProps & React.RefAttributes<HTMLButtonElement>>;\n Cancel: React.ForwardRefExoticComponent<AlertDialogCancelProps & React.RefAttributes<HTMLButtonElement>>;\n};\n\nexport const AlertDialog = React.forwardRef(function AlertDialog(props: AlertDialogProps, ref: React.Ref<HTMLElement>) {\n const { children: initialChildren, defaultOpen, onChange, open, trigger, ...otherProps } = props;\n\n const context = React.useMemo(\n () => ({\n props: otherProps,\n ref,\n }),\n [open, otherProps]\n );\n\n return (\n <AlertDialogContext.Provider value={context}>\n <AlertDialogPrimitive.Root {...props} defaultOpen={defaultOpen} open={open} onOpenChange={onChange}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {props.children}\n </AlertDialogPrimitive.Root>\n </AlertDialogContext.Provider>\n );\n}) as ForwardedAlertDialogWithStatics;\n\nAlertDialog.Trigger = Trigger;\nAlertDialog.Content = Content;\nAlertDialog.Title = Title;\nAlertDialog.Cancel = Cancel;\nAlertDialog.Action = Action;\nAlertDialog.Footer = Footer;\n"],"names":["AlertDialog","React","props","ref","children","initialChildren","defaultOpen","onChange","open","trigger","otherProps","context","AlertDialogContext","Provider","value","AlertDialogPrimitive","onOpenChange","Trigger","Content","Title","Cancel","Action","Footer"],"mappings":";;;;;;;
|
1
|
+
{"version":3,"file":"AlertDialog.js","sources":["../../../../../../../src/components/AlertDialog/AlertDialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport { AlertDialogContext } from './Context';\nimport { Trigger, AlertDialogTriggerProps } from './components/Trigger';\nimport {\n Cancel,\n Action,\n Footer,\n AlertDialogCancelProps,\n AlertDialogActionProps,\n AlertDialogFooterProps,\n} from './components/Footer';\nimport { Title, Content, AlertDialogContentProps, AlertDialogTitleProps } from './components/Content';\n\nexport type AlertDialogProps = {\n children: React.ReactNode | React.ReactNode[];\n /** Set whether the alert dialog is open by default or not, use when not providing a trigger */\n defaultOpen?: boolean;\n /** Called when the alert dialog opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean) => void;\n /** Control the open state of the dialog from outside the component */\n open?: boolean;\n /** A trigger to be used for the alert dialog, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n /** A state to be used for the alert dialog, which will add appropriate badge icon next to the title */\n variant?: 'warning' | 'error' | 'information';\n};\n\nexport type ForwardedAlertDialogWithStatics = React.ForwardRefExoticComponent<\n AlertDialogProps & React.RefAttributes<HTMLElement>\n> & {\n Trigger: React.ForwardRefExoticComponent<AlertDialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<AlertDialogContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<AlertDialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<AlertDialogFooterProps & React.RefAttributes<HTMLDivElement>>;\n Action: React.ForwardRefExoticComponent<AlertDialogActionProps & React.RefAttributes<HTMLButtonElement>>;\n Cancel: React.ForwardRefExoticComponent<AlertDialogCancelProps & React.RefAttributes<HTMLButtonElement>>;\n};\n\nexport const AlertDialog = React.forwardRef(function AlertDialog(props: AlertDialogProps, ref: React.Ref<HTMLElement>) {\n const { children: initialChildren, defaultOpen, onChange, open, trigger, ...otherProps } = props;\n\n const context = React.useMemo(\n () => ({\n props: otherProps,\n ref,\n }),\n [open, otherProps]\n );\n\n return (\n <AlertDialogContext.Provider value={context}>\n <AlertDialogPrimitive.Root {...props} defaultOpen={defaultOpen} open={open} onOpenChange={onChange}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {props.children}\n </AlertDialogPrimitive.Root>\n </AlertDialogContext.Provider>\n );\n}) as ForwardedAlertDialogWithStatics;\n\nAlertDialog.Trigger = Trigger;\nAlertDialog.Content = Content;\nAlertDialog.Title = Title;\nAlertDialog.Cancel = Cancel;\nAlertDialog.Action = Action;\nAlertDialog.Footer = Footer;\n"],"names":["AlertDialog","React","props","ref","children","initialChildren","defaultOpen","onChange","open","trigger","otherProps","context","AlertDialogContext","Provider","value","AlertDialogPrimitive","onOpenChange","Trigger","Content","Title","Cancel","Action","Footer"],"mappings":";;;;;;;MAuCaA,WAAW,gBAAGC,UAAgB,CAAC,SAASD,WAAWA,CAACE,KAAuB,EAAEC,GAA2B;EACjH,MAAM;IAAEC,QAAQ,EAAEC,eAAe;IAAEC,WAAW;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,OAAO;IAAE,GAAGC;GAAY,GAAGR,KAAK;EAEhG,MAAMS,OAAO,GAAGV,OAAa,CACzB,OAAO;IACHC,KAAK,EAAEQ,UAAU;IACjBP;GACH,CAAC,EACF,CAACK,IAAI,EAAEE,UAAU,CAAC,CACrB;EAED,oBACIT,cAACW,kBAAkB,CAACC,QAAQ;IAACC,KAAK,EAAEH;kBAChCV,cAACc,IAAyB,oBAAKb,KAAK;IAAEI,WAAW,EAAEA,WAAW;IAAEE,IAAI,EAAEA,IAAI;IAAEQ,YAAY,EAAET;MACrFE,OAAO,iBAAIR,cAACgB,OAAO,QAAER,OAAO,CAAW,EACvCP,KAAK,CAACE,QAAQ,CACS,CACF;AAEtC,CAAC;AAEDJ,WAAW,CAACiB,OAAO,GAAGA,OAAO;AAC7BjB,WAAW,CAACkB,OAAO,GAAGA,OAAO;AAC7BlB,WAAW,CAACmB,KAAK,GAAGA,KAAK;AACzBnB,WAAW,CAACoB,MAAM,GAAGA,MAAM;AAC3BpB,WAAW,CAACqB,MAAM,GAAGA,MAAM;AAC3BrB,WAAW,CAACsB,MAAM,GAAGA,MAAM;;;;"}
|
@@ -1,15 +1,43 @@
|
|
1
1
|
import { forwardRef, createElement } from 'react';
|
2
2
|
import cn from 'clsx';
|
3
|
+
import { BadgeIcon } from '../../BadgeIcon/BadgeIcon.js';
|
3
4
|
import { Title as Title$1, Portal, Overlay, Content as Content$1 } from '@radix-ui/react-alert-dialog';
|
5
|
+
import { useCurrentAlertDialog } from '../Context.js';
|
4
6
|
import { Backdrop } from '../../Backdrop/Backdrop.js';
|
5
7
|
import { getDialogPositionClassnames, getDialogStylingClassnames, getDialogSizeClassnames } from '../../Dialog/util.js';
|
6
8
|
|
9
|
+
const iconPropsByVariant = variant => {
|
10
|
+
switch (variant) {
|
11
|
+
case 'information':
|
12
|
+
return {
|
13
|
+
color: 'blue',
|
14
|
+
icon: 'info'
|
15
|
+
};
|
16
|
+
case 'error':
|
17
|
+
return {
|
18
|
+
color: 'red',
|
19
|
+
icon: 'close'
|
20
|
+
};
|
21
|
+
case 'warning':
|
22
|
+
return {
|
23
|
+
color: 'yellow',
|
24
|
+
icon: 'warning'
|
25
|
+
};
|
26
|
+
default:
|
27
|
+
return undefined;
|
28
|
+
}
|
29
|
+
};
|
7
30
|
const Title = /*#__PURE__*/forwardRef(function AlertDialogTitle(props, ref) {
|
8
|
-
const
|
31
|
+
const {
|
32
|
+
props: parentProps
|
33
|
+
} = useCurrentAlertDialog();
|
34
|
+
const iconProps = iconPropsByVariant(parentProps.variant);
|
9
35
|
return /*#__PURE__*/createElement(Title$1, Object.assign({}, props, {
|
10
|
-
className: className,
|
36
|
+
className: cn('flex items-center', props.className),
|
11
37
|
ref: ref
|
12
|
-
})
|
38
|
+
}), iconProps ? /*#__PURE__*/createElement(BadgeIcon, Object.assign({}, iconProps, {
|
39
|
+
className: "mr-2"
|
40
|
+
})) : undefined, props.children);
|
13
41
|
});
|
14
42
|
const Content = /*#__PURE__*/forwardRef(function AlertDialogContent(props, ref) {
|
15
43
|
const className = cn('p-6', getDialogPositionClassnames(), getDialogStylingClassnames(), getDialogSizeClassnames('dialog'));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Content.js","sources":["../../../../../../../../src/components/AlertDialog/components/Content.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport cn from 'clsx';\nimport { Backdrop } from '../../Backdrop/Backdrop';\nimport { getDialogPositionClassnames, getDialogSizeClassnames, getDialogStylingClassnames } from '../../Dialog/util';\n\nexport type AlertDialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function AlertDialogTitle(\n props: AlertDialogTitleProps,\n ref: React.Ref<HTMLHeadingElement>\n) {\n const
|
1
|
+
{"version":3,"file":"Content.js","sources":["../../../../../../../../src/components/AlertDialog/components/Content.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport cn from 'clsx';\nimport { Backdrop } from '../../Backdrop/Backdrop';\nimport { getDialogPositionClassnames, getDialogSizeClassnames, getDialogStylingClassnames } from '../../Dialog/util';\nimport { useCurrentAlertDialog } from '../Context';\nimport { BadgeIcon } from '../../BadgeIcon/BadgeIcon';\nimport { Color } from '../../../types';\nimport { IconName } from '../../Icon/components';\n\nconst iconPropsByVariant = (variant: 'information' | 'error' | 'warning'): { color: Color; icon: IconName } | undefined => {\n switch (variant) {\n case 'information':\n return {\n color: 'blue',\n icon: 'info',\n };\n case 'error':\n return {\n color: 'red',\n icon: 'close',\n };\n case 'warning':\n return {\n color: 'yellow',\n icon: 'warning',\n };\n default:\n return undefined;\n }\n};\n\nexport type AlertDialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function AlertDialogTitle(\n props: AlertDialogTitleProps,\n ref: React.Ref<HTMLHeadingElement>\n) {\n const { props: parentProps } = useCurrentAlertDialog();\n\n const iconProps = iconPropsByVariant(parentProps.variant);\n return (\n <AlertDialogPrimitive.Title {...props} className={cn('flex items-center', props.className)} ref={ref}>\n {iconProps ? <BadgeIcon {...iconProps} className=\"mr-2\" /> : undefined}\n {props.children}\n </AlertDialogPrimitive.Title>\n );\n});\n\nexport type AlertDialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the dialog is opened */\n 'aria-label': string;\n children: React.ReactNode;\n};\nexport const Content = React.forwardRef(function AlertDialogContent(\n props: AlertDialogContentProps,\n ref: React.Ref<HTMLDivElement>\n) {\n const className = cn('p-6', getDialogPositionClassnames(), getDialogStylingClassnames(), getDialogSizeClassnames('dialog'));\n\n return (\n <AlertDialogPrimitive.Portal>\n <AlertDialogPrimitive.Overlay asChild>\n <Backdrop>\n <AlertDialogPrimitive.Content\n {...props}\n ref={ref}\n className={className}\n onEscapeKeyDown={event => event.preventDefault()}>\n {props.children}\n </AlertDialogPrimitive.Content>\n </Backdrop>\n </AlertDialogPrimitive.Overlay>\n </AlertDialogPrimitive.Portal>\n );\n});\n"],"names":["iconPropsByVariant","variant","color","icon","undefined","Title","React","AlertDialogTitle","props","ref","parentProps","useCurrentAlertDialog","iconProps","AlertDialogPrimitive","className","cn","BadgeIcon","children","Content","AlertDialogContent","getDialogPositionClassnames","getDialogStylingClassnames","getDialogSizeClassnames","asChild","Backdrop","onEscapeKeyDown","event","preventDefault"],"mappings":";;;;;;;;AAUA,MAAMA,kBAAkB,GAAIC,OAA4C;EACpE,QAAQA,OAAO;IACX,KAAK,aAAa;MACd,OAAO;QACHC,KAAK,EAAE,MAAM;QACbC,IAAI,EAAE;OACT;IACL,KAAK,OAAO;MACR,OAAO;QACHD,KAAK,EAAE,KAAK;QACZC,IAAI,EAAE;OACT;IACL,KAAK,SAAS;MACV,OAAO;QACHD,KAAK,EAAE,QAAQ;QACfC,IAAI,EAAE;OACT;IACL;MACI,OAAOC,SAAS;;AAE5B,CAAC;MAGYC,KAAK,gBAAGC,UAAgB,CAAC,SAASC,gBAAgBA,CAC3DC,KAA4B,EAC5BC,GAAkC;EAElC,MAAM;IAAED,KAAK,EAAEE;GAAa,GAAGC,qBAAqB,EAAE;EAEtD,MAAMC,SAAS,GAAGZ,kBAAkB,CAACU,WAAW,CAACT,OAAO,CAAC;EACzD,oBACIK,cAACO,OAA0B,oBAAKL,KAAK;IAAEM,SAAS,EAAEC,EAAE,CAAC,mBAAmB,EAAEP,KAAK,CAACM,SAAS,CAAC;IAAEL,GAAG,EAAEA;MAC5FG,SAAS,gBAAGN,cAACU,SAAS,oBAAKJ,SAAS;IAAEE,SAAS,EAAC;KAAS,GAAGV,SAAS,EACrEI,KAAK,CAACS,QAAQ,CACU;AAErC,CAAC;MAOYC,OAAO,gBAAGZ,UAAgB,CAAC,SAASa,kBAAkBA,CAC/DX,KAA8B,EAC9BC,GAA8B;EAE9B,MAAMK,SAAS,GAAGC,EAAE,CAAC,KAAK,EAAEK,2BAA2B,EAAE,EAAEC,0BAA0B,EAAE,EAAEC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;EAE3H,oBACIhB,cAACO,MAA2B,qBACxBP,cAACO,OAA4B;IAACU,OAAO;kBACjCjB,cAACkB,QAAQ,qBACLlB,cAACO,SAA4B,oBACrBL,KAAK;IACTC,GAAG,EAAEA,GAAG;IACRK,SAAS,EAAEA,SAAS;IACpBW,eAAe,EAAEC,KAAK,IAAIA,KAAK,CAACC,cAAc;MAC7CnB,KAAK,CAACS,QAAQ,CACY,CACxB,CACgB,CACL;AAEtC,CAAC;;;;"}
|
@@ -21,14 +21,16 @@ const Card = /*#__PURE__*/forwardRef(function Card(props, ref) {
|
|
21
21
|
const {
|
22
22
|
title,
|
23
23
|
menu,
|
24
|
-
children
|
24
|
+
children,
|
25
|
+
className,
|
26
|
+
...otherProps
|
25
27
|
} = props;
|
26
|
-
const
|
27
|
-
return /*#__PURE__*/createElement("div", {
|
28
|
-
className:
|
28
|
+
const cardClassName = cn('bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500', className);
|
29
|
+
return /*#__PURE__*/createElement("div", Object.assign({}, otherProps, {
|
30
|
+
className: cardClassName,
|
29
31
|
"data-taco": "card",
|
30
32
|
ref: ref
|
31
|
-
}, /*#__PURE__*/createElement("div", {
|
33
|
+
}), /*#__PURE__*/createElement("div", {
|
32
34
|
className: "mx-4 mb-2 mt-4 flex justify-between"
|
33
35
|
}, title && (/*#__PURE__*/createElement(Truncate, {
|
34
36
|
tooltip: title
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Card.js","sources":["../../../../../../../src/components/Card/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { MenuProps } from '../Menu/Menu';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Truncate } from '../Truncate/Truncate';\nimport './style.css';\n\nexport type CardContentProps = React.HTMLAttributes<HTMLDivElement> & {\n noPadding?: boolean;\n};\n\nconst Content = React.forwardRef<HTMLDivElement, CardContentProps>(function CardContent(externalProps, ref) {\n const { noPadding, ...props } = externalProps;\n const className = cn(\n 'flex-grow overflow-auto',\n {\n 'mx-4 mb-4': !noPadding,\n },\n props.className\n );\n return <div {...props} className={className} data-taco=\"card-content\" ref={ref} />;\n});\n\nexport type CardProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Title of the Card */\n title: string | React.ReactElement;\n /** Menu component associated with the Card */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n};\n\nexport const Card = React.forwardRef<HTMLDivElement, CardProps>(function Card(props, ref) {\n const { title, menu, children } = props;\n const
|
1
|
+
{"version":3,"file":"Card.js","sources":["../../../../../../../src/components/Card/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { MenuProps } from '../Menu/Menu';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Truncate } from '../Truncate/Truncate';\nimport './style.css';\n\nexport type CardContentProps = React.HTMLAttributes<HTMLDivElement> & {\n noPadding?: boolean;\n};\n\nconst Content = React.forwardRef<HTMLDivElement, CardContentProps>(function CardContent(externalProps, ref) {\n const { noPadding, ...props } = externalProps;\n const className = cn(\n 'flex-grow overflow-auto',\n {\n 'mx-4 mb-4': !noPadding,\n },\n props.className\n );\n return <div {...props} className={className} data-taco=\"card-content\" ref={ref} />;\n});\n\nexport type CardProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Title of the Card */\n title: string | React.ReactElement;\n /** Menu component associated with the Card */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n};\n\nexport const Card = React.forwardRef<HTMLDivElement, CardProps>(function Card(props, ref) {\n const { title, menu, children, className, ...otherProps } = props;\n const cardClassName = cn(\n 'bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500',\n className\n );\n\n return (\n <div {...otherProps} className={cardClassName} data-taco=\"card\" ref={ref}>\n <div className=\"mx-4 mb-2 mt-4 flex justify-between\">\n {title && (\n <Truncate tooltip={title}>\n <h4 className=\"mb-0 flex-grow truncate text-left\">{title}</h4>\n </Truncate>\n )}\n {menu ? <IconButton icon=\"ellipsis-horizontal\" appearance=\"discrete\" menu={menu} className=\"-mt-[4px]\" /> : null}\n </div>\n {children}\n </div>\n );\n}) as React.ForwardRefExoticComponent<CardProps> & {\n Content: React.ForwardRefExoticComponent<CardContentProps>;\n};\nCard.Content = Content;\n"],"names":["Content","React","CardContent","externalProps","ref","noPadding","props","className","cn","Card","title","menu","children","otherProps","cardClassName","Truncate","tooltip","IconButton","icon","appearance"],"mappings":";;;;;AAWA,MAAMA,OAAO,gBAAGC,UAAgB,CAAmC,SAASC,WAAWA,CAACC,aAAa,EAAEC,GAAG;EACtG,MAAM;IAAEC,SAAS;IAAE,GAAGC;GAAO,GAAGH,aAAa;EAC7C,MAAMI,SAAS,GAAGC,EAAE,CAChB,yBAAyB,EACzB;IACI,WAAW,EAAE,CAACH;GACjB,EACDC,KAAK,CAACC,SAAS,CAClB;EACD,oBAAON,uCAASK,KAAK;IAAEC,SAAS,EAAEA,SAAS;iBAAY,cAAc;IAACH,GAAG,EAAEA;KAAO;AACtF,CAAC,CAAC;MASWK,IAAI,gBAAGR,UAAgB,CAA4B,SAASQ,IAAIA,CAACH,KAAK,EAAEF,GAAG;EACpF,MAAM;IAAEM,KAAK;IAAEC,IAAI;IAAEC,QAAQ;IAAEL,SAAS;IAAE,GAAGM;GAAY,GAAGP,KAAK;EACjE,MAAMQ,aAAa,GAAGN,EAAE,CACpB,kHAAkH,EAClHD,SAAS,CACZ;EAED,oBACIN,uCAASY,UAAU;IAAEN,SAAS,EAAEO,aAAa;iBAAY,MAAM;IAACV,GAAG,EAAEA;mBACjEH;IAAKM,SAAS,EAAC;KACVG,KAAK,kBACFT,cAACc,QAAQ;IAACC,OAAO,EAAEN;kBACfT;IAAIM,SAAS,EAAC;KAAqCG,KAAK,CAAM,CACvD,CACd,EACAC,IAAI,gBAAGV,cAACgB,UAAU;IAACC,IAAI,EAAC,qBAAqB;IAACC,UAAU,EAAC,UAAU;IAACR,IAAI,EAAEA,IAAI;IAAEJ,SAAS,EAAC;IAAc,GAAG,IAAI,CAC9G,EACLK,QAAQ,CACP;AAEd,CAAC;AAGDH,IAAI,CAACT,OAAO,GAAGA,OAAO;;;;"}
|
@@ -15,7 +15,8 @@ const UnstyledArrow = /*#__PURE__*/forwardRef(function PopoverArrow(props, ref)
|
|
15
15
|
transform: 'rotateZ(180deg)'
|
16
16
|
}
|
17
17
|
}), /*#__PURE__*/createElement("path", {
|
18
|
-
|
18
|
+
// rgba(89, 85, 98, 0.35) is the primary color of the yt-shadow, giving the arrow a shadow-like appearance
|
19
|
+
className: "text-[rgba(89, 85, 98, 0.35)] fill-current",
|
19
20
|
d: "M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z"
|
20
21
|
}), /*#__PURE__*/createElement("path", {
|
21
22
|
className: "fill-current",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Primitives.js","sources":["../../../../../../../src/components/Popover/Primitives.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nexport const UnstyledArrow = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGElement>>(function PopoverArrow(props, ref) {\n return (\n <PopoverPrimitive.Arrow className=\"pointer-events-none -mt-px\" asChild offset={2} width={30} height={11}>\n <svg {...props} ref={ref} viewBox=\"0 19 30 11\" style={{ transform: 'rotateZ(180deg)' }}>\n <path\n className=\"text-
|
1
|
+
{"version":3,"file":"Primitives.js","sources":["../../../../../../../src/components/Popover/Primitives.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nexport const UnstyledArrow = React.forwardRef<SVGSVGElement, React.SVGAttributes<SVGElement>>(function PopoverArrow(props, ref) {\n return (\n <PopoverPrimitive.Arrow className=\"pointer-events-none -mt-px\" asChild offset={2} width={30} height={11}>\n <svg {...props} ref={ref} viewBox=\"0 19 30 11\" style={{ transform: 'rotateZ(180deg)' }}>\n <path\n // rgba(89, 85, 98, 0.35) is the primary color of the yt-shadow, giving the arrow a shadow-like appearance\n className=\"text-[rgba(89, 85, 98, 0.35)] fill-current\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z\"></path>\n <path\n className=\"fill-current\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"></path>\n </svg>\n </PopoverPrimitive.Arrow>\n );\n});\n"],"names":["UnstyledArrow","React","PopoverArrow","props","ref","PopoverPrimitive","className","asChild","offset","width","height","viewBox","style","transform","d"],"mappings":";;;MAGaA,aAAa,gBAAGC,UAAgB,CAAiD,SAASC,YAAYA,CAACC,KAAK,EAAEC,GAAG;EAC1H,oBACIH,cAACI,KAAsB;IAACC,SAAS,EAAC,4BAA4B;IAACC,OAAO;IAACC,MAAM,EAAE,CAAC;IAAEC,KAAK,EAAE,EAAE;IAAEC,MAAM,EAAE;kBACjGT,uCAASE,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEO,OAAO,EAAC,YAAY;IAACC,KAAK,EAAE;MAAEC,SAAS,EAAE;;mBAC/DZ;;IAEIK,SAAS,EAAC,4CAA4C;IACtDQ,CAAC,EAAC;IAAoI,eAC1Ib;IACIK,SAAS,EAAC,cAAc;IACxBQ,CAAC,EAAC;IAA6G,CACjH,CACe;AAEjC,CAAC;;;;"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown.js';
|
3
|
+
import { useLocalization } from '../../Provider/Localization.js';
|
3
4
|
import { _forOf, _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
4
5
|
import { willRowMove } from '../util/editing.js';
|
5
6
|
import { debounce } from 'lodash-es';
|
@@ -160,7 +161,7 @@ function usePendingChanges(isEnabled, handleSave, handleChange, validator) {
|
|
160
161
|
[cell.column.id]: change
|
161
162
|
};
|
162
163
|
setPendingChanges(currentChanges => {
|
163
|
-
const nextChanges = createPendingChangesSetter(currentChanges, cell.row, rowIndex, changes);
|
164
|
+
const nextChanges = createPendingChangesSetter(currentChanges, cell.row, rowIndex, changes, localization);
|
164
165
|
pendingChangesUpdater.syncCellChanges(nextChanges);
|
165
166
|
return nextChanges;
|
166
167
|
});
|
@@ -204,6 +205,7 @@ function usePendingChanges(isEnabled, handleSave, handleChange, validator) {
|
|
204
205
|
return Promise.reject(e);
|
205
206
|
}
|
206
207
|
};
|
208
|
+
const localization = useLocalization();
|
207
209
|
const [pendingChanges, setPendingChanges] = React__default.useState({});
|
208
210
|
// we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted
|
209
211
|
const [saveStates, setSaveState] = React__default.useState({});
|
@@ -337,6 +339,7 @@ function useLastFocusedCellIndex() {
|
|
337
339
|
return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];
|
338
340
|
}
|
339
341
|
function usePendingChangesUpdater(handleChange, setPendingChanges) {
|
342
|
+
const localization = useLocalization();
|
340
343
|
const updatersRef = React__default.useRef({});
|
341
344
|
const runCellUpdates = React__default.useCallback(debounce(function (changes, cell, rowIndex) {
|
342
345
|
try {
|
@@ -352,7 +355,7 @@ function usePendingChangesUpdater(handleChange, setPendingChanges) {
|
|
352
355
|
};
|
353
356
|
return Promise.resolve(handleChange(cell.column.id, changes[cell.column.id], nextValues, previousValues)).then(function (updates) {
|
354
357
|
if (updates && Object.keys(updates).length) {
|
355
|
-
setPendingChanges(currentChanges => createPendingChangesSetter(currentChanges, cell.row, rowIndex, updates));
|
358
|
+
setPendingChanges(currentChanges => createPendingChangesSetter(currentChanges, cell.row, rowIndex, updates, localization));
|
356
359
|
}
|
357
360
|
});
|
358
361
|
}
|
@@ -370,7 +373,7 @@ function usePendingChangesUpdater(handleChange, setPendingChanges) {
|
|
370
373
|
runCellUpdates
|
371
374
|
};
|
372
375
|
}
|
373
|
-
function createPendingChangesSetter(currentChanges, row, rowIndex, changes) {
|
376
|
+
function createPendingChangesSetter(currentChanges, row, rowIndex, changes, localization) {
|
374
377
|
var _currentChanges$row$i, _currentChanges$row$i2, _currentChanges$row$i3;
|
375
378
|
// prepare
|
376
379
|
const nextChanges = {
|
@@ -397,7 +400,7 @@ function createPendingChangesSetter(currentChanges, row, rowIndex, changes) {
|
|
397
400
|
if (change !== row.original[accessor]) {
|
398
401
|
rowChanges[accessor] = change;
|
399
402
|
// determine if the row will move position based on this change, and save why it will move
|
400
|
-
const reason = willRowMove(cells[accessor], change, rowIndex);
|
403
|
+
const reason = willRowMove(cells[accessor], change, rowIndex, localization);
|
401
404
|
if (reason) {
|
402
405
|
rowChanges._meta.moveReason[accessor] = reason;
|
403
406
|
} else {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport {\n Cell as ReactTableCell,\n Row as ReactTableRow,\n Table as ReactTable,\n TableMeta as ReactTableMeta,\n} from '@tanstack/react-table';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown';\nimport { willRowMove } from '../util/editing';\nimport { TableRef } from '../../../primitives/Table/types';\nimport { debounce } from 'lodash';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, toggleEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = useLastFocusedCellIndex();\n\n // store pending changes for each row\n // changes are saved as soon as the active row changes, so in most cases this will only contain the active row's changes\n // but not always - if validation or server requests fail when saving, those rows remain until the failure is resolved\n const pendingChangesFns = usePendingChanges<TType>(isEnabled, handleSave, handleChange, validator);\n\n useGlobalKeyDown(isEnabled && isEditing ? { key: 's', meta: true, shift: false } : undefined, event => {\n event.preventDefault();\n pendingChangesFns.saveChanges();\n });\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n ...pendingChangesFns,\n };\n}\n\ntype SaveState = 'pending' | 'complete';\ntype PendingChange<TType = unknown> = Partial<TType> & {\n _meta: {\n original: TType;\n moveReason: Record<string, 'search' | 'sorting' | 'filter'>;\n errors: {\n row: string;\n cells: Record<string, string>;\n hasShownErrorAlert: boolean;\n };\n status?: SaveState;\n };\n};\n\ntype PendingChanges<TType = unknown> = Record<string, PendingChange<TType>>;\nfunction usePendingChanges<TType = unknown>(\n isEnabled: boolean,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const [pendingChanges, setPendingChanges] = React.useState<PendingChanges<TType>>({});\n // we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted\n const [saveStates, setSaveState] = React.useState<Record<string, SaveState>>({});\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return pendingChanges[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return pendingChanges[cell.row.id]?._meta.errors?.cells?.[cell.column.id];\n }\n\n async function addCreatedRowChangeset(row) {\n const cells = row.getAllCells();\n\n setPendingChanges(currentChanges => {\n return cells.reduce((changes, cell) => {\n if (cell.getValue()) {\n return {\n ...changes,\n [cell.row.id]: {\n ...changes[cell.row.id],\n [cell.column.id]: cell.getValue(),\n _meta: {\n ...currentChanges[cell.row.id]?._meta,\n original: cell.row.original,\n moveReason: {\n ...currentChanges[cell.row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[cell.row.id]?._meta.errors,\n },\n },\n },\n };\n } else {\n return changes;\n }\n }, currentChanges);\n });\n }\n const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);\n\n async function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, change: unknown, rowIndex: number) {\n const changes = {\n [cell.column.id]: change,\n } as Partial<T>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = createPendingChangesSetter<T>(currentChanges as PendingChanges<T>, cell.row, rowIndex, changes);\n pendingChangesUpdater.syncCellChanges(nextChanges);\n return nextChanges;\n });\n pendingChangesUpdater.runCellUpdates<T>(changes, cell, rowIndex);\n }\n\n async function validateCell<T extends TType>(cell: ReactTableCell<T, unknown>) {\n if (!validator || !isEnabled) {\n return;\n }\n\n const changeSet = getChangesetFromChanges(pendingChanges[cell.row.id]);\n\n // only validate if the cell being blurred actually has any changes\n if (cell.column.id in changeSet) {\n const errors = ((await validator(changeSet)) ?? {}) as Record<string, string>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[cell.row.id]._meta = {\n ...nextChanges[cell.row.id]._meta,\n errors: {\n ...nextChanges[cell.row.id]._meta.errors,\n cells: errors,\n hasShownErrorAlert:\n Object.keys(errors).length && !nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert\n ? false\n : nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert,\n },\n };\n return nextChanges;\n });\n }\n }\n\n function hasRowErrors(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return (\n !!pendingChanges[rowId]?._meta.errors?.row || !!Object.keys(pendingChanges[rowId]?._meta.errors?.cells ?? {}).length\n );\n }\n\n function hasRowErrorsSeen(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return hasRowErrors(rowId) && !!pendingChanges[rowId]._meta.errors?.hasShownErrorAlert;\n }\n\n function setRowErrorsSeen(rowId: string) {\n if (pendingChanges[rowId]._meta.errors?.hasShownErrorAlert === false) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n ...nextChanges[rowId]._meta.errors,\n hasShownErrorAlert: true,\n };\n return nextChanges;\n });\n }\n }\n\n function getRowSaveStatus(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return saveStates[rowId];\n }\n\n function setRowSaveStatus(rowId: string, status: 'pending' | 'complete' | undefined) {\n setSaveState(currentStates => {\n const nextStates = { ...currentStates };\n\n if (status) {\n nextStates[rowId] = status;\n } else {\n delete nextStates[rowId];\n }\n\n return nextStates;\n });\n }\n\n function getRowMoveReason(rowId: string) {\n return pendingChanges[rowId]?._meta.moveReason ? Object.values(pendingChanges[rowId]._meta.moveReason)[0] : undefined;\n }\n\n function hasChanges(rowId?: string) {\n if (!isEnabled) {\n return false;\n }\n\n return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;\n }\n\n function hasErrors<T extends TType>(table: ReactTable<T>, tableRef: React.RefObject<TableRef>) {\n if (!isEnabled) {\n return false;\n }\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const focusIsInsideTable = tableRef.current?.contains(document.activeElement);\n\n let activeRow;\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n activeRow = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex];\n }\n\n return Object.keys(\n getErrors().filter(error => {\n if (activeRow?.id && focusIsInsideTable) {\n return error.rowId === activeRow?.id ? error.pendingChange._meta.errors?.hasShownErrorAlert : true;\n }\n\n return true;\n })\n ).length;\n }\n\n function getErrors<T extends TType>() {\n return Object.keys(pendingChanges)\n .filter(hasRowErrors)\n .map(rowId => ({ rowId, pendingChange: pendingChanges[rowId] as PendingChange<T> }));\n }\n\n function resetChanges(rowId: string) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n delete nextChanges[rowId];\n return nextChanges;\n });\n }\n\n async function saveChanges(rowId: string | undefined = undefined) {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return;\n }\n\n // we save back to pendingChanges, so make a copy of it's state when save was triggered\n const changesToSave = rowId ? { [rowId]: pendingChanges[rowId] } : { ...pendingChanges };\n const changes = Object.keys(changesToSave);\n\n if (changes.length) {\n for (const rowId of changes) {\n const pendingChange = changesToSave[rowId];\n\n const changeSet = getChangesetFromChanges(pendingChange);\n try {\n if (getRowSaveStatus(rowId) === 'pending') return;\n\n // set saving = true\n setRowSaveStatus(rowId, 'pending');\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n resetChanges(rowId);\n setRowSaveStatus(rowId, 'complete');\n } catch (error) {\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n row: rowError,\n cells: cellErrors,\n hasShownErrorAlert: nextChanges[rowId]._meta.errors?.hasShownErrorAlert ?? false,\n };\n return nextChanges;\n });\n }\n\n setRowSaveStatus(rowId, undefined);\n }\n }\n }\n }\n\n return {\n getCellValue,\n getCellError,\n setCellValue,\n validateCell,\n addCreatedRowChangeset,\n hasChanges,\n hasErrors,\n getErrors,\n saveChanges,\n resetChanges,\n hasRowErrors,\n hasRowErrorsSeen,\n setRowErrorsSeen,\n getRowSaveStatus,\n setRowSaveStatus,\n getRowMoveReason,\n };\n}\n\nfunction useLastFocusedCellIndex(): [number | undefined, (index: number | undefined) => void] {\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const lastFocusedCellIndexRef = React.useRef<number | undefined>(undefined);\n const setLastFocusedCellIndex = React.useCallback((index: number | undefined) => {\n lastFocusedCellIndexRef.current = index;\n }, []);\n\n return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];\n}\n\nfunction usePendingChangesUpdater<TType = unknown>(\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n setPendingChanges: React.Dispatch<React.SetStateAction<PendingChanges<TType>>>\n) {\n const updatersRef = React.useRef<PendingChanges<TType>>({});\n\n const runCellUpdates = React.useCallback(\n debounce(async function <T extends TType>(changes: Partial<T>, cell: ReactTableCell<T, unknown>, rowIndex: number) {\n if (typeof handleChange === 'function') {\n const previousValues = {\n ...cell.row.original,\n ...getChangesetFromChanges(updatersRef.current[cell.row.id]),\n };\n const nextValues = {\n ...previousValues,\n ...changes,\n };\n const updates = await handleChange(cell.column.id, changes[cell.column.id], nextValues, previousValues);\n\n if (updates && Object.keys(updates).length) {\n setPendingChanges(currentChanges => createPendingChangesSetter(currentChanges, cell.row, rowIndex, updates));\n }\n }\n }, 250),\n []\n ) as unknown as <T extends TType>(changes: Partial<T>, cell: ReactTableCell<T, unknown>, rowIndex: number) => Promise<void>;\n\n function syncCellChanges<T extends TType>(changes: PendingChanges<T>) {\n updatersRef.current = changes;\n }\n\n return {\n syncCellChanges,\n runCellUpdates,\n };\n}\n\nfunction createPendingChangesSetter<TType = unknown>(\n currentChanges: PendingChanges<TType>,\n row: ReactTableRow<TType>,\n rowIndex: number,\n changes: Partial<TType>\n) {\n // prepare\n const nextChanges: PendingChanges<TType> = { ...currentChanges };\n const rowChanges = {\n ...currentChanges[row.id],\n _meta: {\n ...currentChanges[row.id]?._meta,\n original: row.original,\n moveReason: {\n ...currentChanges[row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[row.id]?._meta.errors,\n },\n },\n } as PendingChange<TType>;\n\n // run changes\n const cells = row._getAllCellsByColumnId();\n\n for (const [accessor, change] of Object.entries(changes)) {\n // update if the change is different to the original (saved) value,\n // otherwise remove any change - no point saving the same value\n if (change !== row.original[accessor]) {\n rowChanges[accessor] = change;\n\n // determine if the row will move position based on this change, and save why it will move\n const reason = willRowMove(cells[accessor], change, rowIndex);\n\n if (reason) {\n rowChanges._meta.moveReason[accessor] = reason;\n } else {\n delete rowChanges._meta.moveReason[accessor];\n }\n } else {\n delete rowChanges[accessor];\n delete rowChanges._meta.moveReason[accessor];\n }\n }\n\n // set changes\n // or delete if there are no changes left, so that we don't store changes with unchanged data\n if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {\n nextChanges[row.id] = rowChanges;\n } else {\n delete nextChanges[row.id];\n }\n\n return nextChanges;\n}\n\nfunction getChangesetFromChanges<TType = unknown>(changes: PendingChange<TType>): TType {\n // extract the original data from the row changes\n const { _meta, ...changeset } = changes ?? {};\n // and mix them in with the changes, ready to send to the server\n return { ..._meta?.original, ...changeset };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","handleChange","validator","isEditing","toggleEditing","React","useState","isDetailedMode","toggleDetailedMode","lastFocusedCellIndex","setLastFocusedCellIndex","useLastFocusedCellIndex","pendingChangesFns","usePendingChanges","useGlobalKeyDown","key","meta","shift","undefined","event","preventDefault","saveChanges","rowId","console","warn","Promise","resolve","changesToSave","pendingChanges","changes","Object","keys","length","_forOf","pendingChange","changeSet","getChangesetFromChanges","_catch","_temp3","_result","_exit","then","resetChanges","setRowSaveStatus","getRowSaveStatus","_temp2","errors","error","rowError","cellErrors","Error","_error$response","message","response","data","_error$response2","setPendingChanges","currentChanges","nextChanges","_meta","row","cells","hasShownErrorAlert","_nextChanges$rowId$_m","_nextChanges$rowId$_m2","e","reject","validateCell","cell","id","_temp","column","setCellValue","change","rowIndex","createPendingChangesSetter","pendingChangesUpdater","syncCellChanges","runCellUpdates","addCreatedRowChangeset","getAllCells","reduce","getValue","_currentChanges$cell$","_currentChanges$cell$2","_currentChanges$cell$3","original","moveReason","saveStates","setSaveState","getCellValue","_pendingChanges$cell$","getCellError","_pendingChanges$cell$2","_pendingChanges$cell$3","_pendingChanges$cell$4","usePendingChangesUpdater","hasRowErrors","_pendingChanges$rowId","_pendingChanges$rowId2","_pendingChanges$rowId3","_pendingChanges$rowId4","_pendingChanges$rowId5","hasRowErrorsSeen","_pendingChanges$rowId6","setRowErrorsSeen","_pendingChanges$rowId7","status","currentStates","nextStates","getRowMoveReason","_pendingChanges$rowId8","values","hasChanges","hasErrors","table","tableRef","tableMeta","options","focusIsInsideTable","_tableRef$current","current","contains","document","activeElement","activeRow","rowActive","rowActiveIndex","getRowModel","rows","getErrors","filter","_activeRow","_activeRow2","_error$pendingChange$","map","lastFocusedCellIndexRef","useRef","useCallback","index","updatersRef","debounce","previousValues","nextValues","updates","_temp4","rowChanges","_currentChanges$row$i","_currentChanges$row$i2","_currentChanges$row$i3","_getAllCellsByColumnId","accessor","entries","reason","willRowMove","k","changeset"],"mappings":";;;;;;SAagBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,YAA2D,EAC3DC,SAAsD;;EAGtD,MAAM,CAACC,SAAS,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGxD,MAAM,CAACC,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MAAM,EAAEC,QAAQ,CAAC;MAE7D,IAAI+E,MAAM,EAAE;QACRP,UAAU,CAACvF,KAAK,CAAC4B,UAAU,CAACgE,QAAQ,CAAC,GAAGE,MAAM;OACjD,MAAM;QACH,OAAOP,UAAU,CAACvF,KAAK,CAAC4B,UAAU,CAACgE,QAAQ,CAAC;;KAEnD,MAAM;MACH,OAAOL,UAAU,CAACK,QAAQ,CAAC;MAC3B,OAAOL,UAAU,CAACvF,KAAK,CAAC4B,UAAU,CAACgE,QAAQ,CAAC;;;;;EAMpD,IAAIzH,MAAM,CAACC,IAAI,CAACmH,UAAU,CAAC,CAACf,MAAM,CAACwB,CAAC,IAAIA,CAAC,KAAK,OAAO,CAAC,CAAC3H,MAAM,EAAE;IAC3D0B,WAAW,CAACE,GAAG,CAACS,EAAE,CAAC,GAAG6E,UAAU;GACnC,MAAM;IACH,OAAOxF,WAAW,CAACE,GAAG,CAACS,EAAE,CAAC;;EAG9B,OAAOX,WAAW;AACtB;AAEA,SAAStB,uBAAuBA,CAAkBP,OAA6B;;EAE3E,MAAM;IAAE8B,KAAK;IAAE,GAAGiG;GAAW,GAAG/H,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE;;EAE7C,OAAO;IAAE,IAAG8B,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE2B,QAAQ;IAAE,GAAGsE;GAAW;AAC/C;;;;"}
|
1
|
+
{"version":3,"file":"useTableEditing.js","sources":["../../../../../../../../src/components/Table3/features/useTableEditing.ts"],"sourcesContent":["import React from 'react';\nimport {\n Cell as ReactTableCell,\n Row as ReactTableRow,\n Table as ReactTable,\n TableMeta as ReactTableMeta,\n} from '@tanstack/react-table';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { useGlobalKeyDown } from '../../../hooks/useGlobalKeyDown';\nimport { willRowMove } from '../util/editing';\nimport { TableRef } from '../../../primitives/Table/types';\nimport { debounce } from 'lodash';\nimport { Localization, useLocalization } from '../../Provider/Localization';\n\nexport function useTableEditing<TType = unknown>(\n isEnabled = false,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n // used to switch the table into editing mode\n const [isEditing, toggleEditing] = React.useState(false);\n\n // used to switch the editing between \"detailed\" mode\n const [isDetailedMode, toggleDetailedMode] = React.useState(false);\n\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const [lastFocusedCellIndex, setLastFocusedCellIndex] = useLastFocusedCellIndex();\n\n // store pending changes for each row\n // changes are saved as soon as the active row changes, so in most cases this will only contain the active row's changes\n // but not always - if validation or server requests fail when saving, those rows remain until the failure is resolved\n const pendingChangesFns = usePendingChanges<TType>(isEnabled, handleSave, handleChange, validator);\n\n useGlobalKeyDown(isEnabled && isEditing ? { key: 's', meta: true, shift: false } : undefined, event => {\n event.preventDefault();\n pendingChangesFns.saveChanges();\n });\n\n return {\n isEnabled,\n isEditing,\n isDetailedMode,\n toggleDetailedMode: isEnabled ? toggleDetailedMode : () => undefined,\n toggleEditing: isEnabled ? toggleEditing : () => undefined,\n lastFocusedCellIndex,\n setLastFocusedCellIndex,\n ...pendingChangesFns,\n };\n}\n\ntype SaveState = 'pending' | 'complete';\ntype PendingChange<TType = unknown> = Partial<TType> & {\n _meta: {\n original: TType;\n moveReason: Record<string, 'search' | 'sorting' | 'filter'>;\n errors: {\n row: string;\n cells: Record<string, string>;\n hasShownErrorAlert: boolean;\n };\n status?: SaveState;\n };\n};\n\ntype PendingChanges<TType = unknown> = Record<string, PendingChange<TType>>;\nfunction usePendingChanges<TType = unknown>(\n isEnabled: boolean,\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [pendingChanges, setPendingChanges] = React.useState<PendingChanges<TType>>({});\n // we maintain save status as separate state because 'complete' needs to briefly show after pendingChanges are deleted\n const [saveStates, setSaveState] = React.useState<Record<string, SaveState>>({});\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return pendingChanges[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return pendingChanges[cell.row.id]?._meta.errors?.cells?.[cell.column.id];\n }\n\n async function addCreatedRowChangeset(row) {\n const cells = row.getAllCells();\n\n setPendingChanges(currentChanges => {\n return cells.reduce((changes, cell) => {\n if (cell.getValue()) {\n return {\n ...changes,\n [cell.row.id]: {\n ...changes[cell.row.id],\n [cell.column.id]: cell.getValue(),\n _meta: {\n ...currentChanges[cell.row.id]?._meta,\n original: cell.row.original,\n moveReason: {\n ...currentChanges[cell.row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[cell.row.id]?._meta.errors,\n },\n },\n },\n };\n } else {\n return changes;\n }\n }, currentChanges);\n });\n }\n const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);\n\n async function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, change: unknown, rowIndex: number) {\n const changes = {\n [cell.column.id]: change,\n } as Partial<T>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = createPendingChangesSetter<T>(\n currentChanges as PendingChanges<T>,\n cell.row,\n rowIndex,\n changes,\n localization\n );\n pendingChangesUpdater.syncCellChanges(nextChanges);\n return nextChanges;\n });\n pendingChangesUpdater.runCellUpdates<T>(changes, cell, rowIndex);\n }\n\n async function validateCell<T extends TType>(cell: ReactTableCell<T, unknown>) {\n if (!validator || !isEnabled) {\n return;\n }\n\n const changeSet = getChangesetFromChanges(pendingChanges[cell.row.id]);\n\n // only validate if the cell being blurred actually has any changes\n if (cell.column.id in changeSet) {\n const errors = ((await validator(changeSet)) ?? {}) as Record<string, string>;\n\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[cell.row.id]._meta = {\n ...nextChanges[cell.row.id]._meta,\n errors: {\n ...nextChanges[cell.row.id]._meta.errors,\n cells: errors,\n hasShownErrorAlert:\n Object.keys(errors).length && !nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert\n ? false\n : nextChanges[cell.row.id]._meta.errors.hasShownErrorAlert,\n },\n };\n return nextChanges;\n });\n }\n }\n\n function hasRowErrors(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return (\n !!pendingChanges[rowId]?._meta.errors?.row || !!Object.keys(pendingChanges[rowId]?._meta.errors?.cells ?? {}).length\n );\n }\n\n function hasRowErrorsSeen(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return hasRowErrors(rowId) && !!pendingChanges[rowId]._meta.errors?.hasShownErrorAlert;\n }\n\n function setRowErrorsSeen(rowId: string) {\n if (pendingChanges[rowId]._meta.errors?.hasShownErrorAlert === false) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n ...nextChanges[rowId]._meta.errors,\n hasShownErrorAlert: true,\n };\n return nextChanges;\n });\n }\n }\n\n function getRowSaveStatus(rowId: string) {\n if (!isEnabled) {\n return false;\n }\n\n return saveStates[rowId];\n }\n\n function setRowSaveStatus(rowId: string, status: 'pending' | 'complete' | undefined) {\n setSaveState(currentStates => {\n const nextStates = { ...currentStates };\n\n if (status) {\n nextStates[rowId] = status;\n } else {\n delete nextStates[rowId];\n }\n\n return nextStates;\n });\n }\n\n function getRowMoveReason(rowId: string) {\n return pendingChanges[rowId]?._meta.moveReason ? Object.values(pendingChanges[rowId]._meta.moveReason)[0] : undefined;\n }\n\n function hasChanges(rowId?: string) {\n if (!isEnabled) {\n return false;\n }\n\n return rowId ? !!pendingChanges[rowId] : !!Object.keys(pendingChanges).length;\n }\n\n function hasErrors<T extends TType>(table: ReactTable<T>, tableRef: React.RefObject<TableRef>) {\n if (!isEnabled) {\n return false;\n }\n\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const focusIsInsideTable = tableRef.current?.contains(document.activeElement);\n\n let activeRow;\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n activeRow = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex];\n }\n\n return Object.keys(\n getErrors().filter(error => {\n if (activeRow?.id && focusIsInsideTable) {\n return error.rowId === activeRow?.id ? error.pendingChange._meta.errors?.hasShownErrorAlert : true;\n }\n\n return true;\n })\n ).length;\n }\n\n function getErrors<T extends TType>() {\n return Object.keys(pendingChanges)\n .filter(hasRowErrors)\n .map(rowId => ({ rowId, pendingChange: pendingChanges[rowId] as PendingChange<T> }));\n }\n\n function resetChanges(rowId: string) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n delete nextChanges[rowId];\n return nextChanges;\n });\n }\n\n async function saveChanges(rowId: string | undefined = undefined) {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return;\n }\n\n // we save back to pendingChanges, so make a copy of it's state when save was triggered\n const changesToSave = rowId ? { [rowId]: pendingChanges[rowId] } : { ...pendingChanges };\n const changes = Object.keys(changesToSave);\n\n if (changes.length) {\n for (const rowId of changes) {\n const pendingChange = changesToSave[rowId];\n\n const changeSet = getChangesetFromChanges(pendingChange);\n try {\n if (getRowSaveStatus(rowId) === 'pending') return;\n\n // set saving = true\n setRowSaveStatus(rowId, 'pending');\n\n // re-run validation, maybe a cell is already invalid but has never been blurred\n if (validator) {\n const errors = await validator(changeSet);\n\n if (errors && Object.keys(errors).length) {\n throw errors;\n }\n }\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n resetChanges(rowId);\n setRowSaveStatus(rowId, 'complete');\n } catch (error) {\n // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc\n // this code handles those errors and maps them either to row errors or cell specific errors\n let rowError;\n let cellErrors;\n\n if (typeof error === 'string') {\n rowError = error;\n } else if (error instanceof Error) {\n rowError = error.message;\n\n // most of our apis return error objects within this shape\n if (typeof (error as any).response?.data === 'object') {\n cellErrors = (error as any).response?.data;\n }\n } else if (typeof error === 'object') {\n cellErrors = error;\n }\n\n if (rowError || cellErrors) {\n setPendingChanges(currentChanges => {\n const nextChanges = { ...currentChanges };\n nextChanges[rowId]._meta.errors = {\n row: rowError,\n cells: cellErrors,\n hasShownErrorAlert: nextChanges[rowId]._meta.errors?.hasShownErrorAlert ?? false,\n };\n return nextChanges;\n });\n }\n\n setRowSaveStatus(rowId, undefined);\n }\n }\n }\n }\n\n return {\n getCellValue,\n getCellError,\n setCellValue,\n validateCell,\n addCreatedRowChangeset,\n hasChanges,\n hasErrors,\n getErrors,\n saveChanges,\n resetChanges,\n hasRowErrors,\n hasRowErrorsSeen,\n setRowErrorsSeen,\n getRowSaveStatus,\n setRowSaveStatus,\n getRowMoveReason,\n };\n}\n\nfunction useLastFocusedCellIndex(): [number | undefined, (index: number | undefined) => void] {\n // store the last focused cell, so that up/down arrow key navigation remains in the same column\n const lastFocusedCellIndexRef = React.useRef<number | undefined>(undefined);\n const setLastFocusedCellIndex = React.useCallback((index: number | undefined) => {\n lastFocusedCellIndexRef.current = index;\n }, []);\n\n return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];\n}\n\nfunction usePendingChangesUpdater<TType = unknown>(\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n setPendingChanges: React.Dispatch<React.SetStateAction<PendingChanges<TType>>>\n) {\n const localization = useLocalization();\n const updatersRef = React.useRef<PendingChanges<TType>>({});\n\n const runCellUpdates = React.useCallback(\n debounce(async function <T extends TType>(changes: Partial<T>, cell: ReactTableCell<T, unknown>, rowIndex: number) {\n if (typeof handleChange === 'function') {\n const previousValues = {\n ...cell.row.original,\n ...getChangesetFromChanges(updatersRef.current[cell.row.id]),\n };\n const nextValues = {\n ...previousValues,\n ...changes,\n };\n const updates = await handleChange(cell.column.id, changes[cell.column.id], nextValues, previousValues);\n\n if (updates && Object.keys(updates).length) {\n setPendingChanges(currentChanges =>\n createPendingChangesSetter(currentChanges, cell.row, rowIndex, updates, localization)\n );\n }\n }\n }, 250),\n []\n ) as unknown as <T extends TType>(changes: Partial<T>, cell: ReactTableCell<T, unknown>, rowIndex: number) => Promise<void>;\n\n function syncCellChanges<T extends TType>(changes: PendingChanges<T>) {\n updatersRef.current = changes;\n }\n\n return {\n syncCellChanges,\n runCellUpdates,\n };\n}\n\nfunction createPendingChangesSetter<TType = unknown>(\n currentChanges: PendingChanges<TType>,\n row: ReactTableRow<TType>,\n rowIndex: number,\n changes: Partial<TType>,\n localization: Localization\n) {\n // prepare\n const nextChanges: PendingChanges<TType> = { ...currentChanges };\n const rowChanges = {\n ...currentChanges[row.id],\n _meta: {\n ...currentChanges[row.id]?._meta,\n original: row.original,\n moveReason: {\n ...currentChanges[row.id]?._meta.moveReason,\n },\n errors: {\n ...currentChanges[row.id]?._meta.errors,\n },\n },\n } as PendingChange<TType>;\n\n // run changes\n const cells = row._getAllCellsByColumnId();\n\n for (const [accessor, change] of Object.entries(changes)) {\n // update if the change is different to the original (saved) value,\n // otherwise remove any change - no point saving the same value\n if (change !== row.original[accessor]) {\n rowChanges[accessor] = change;\n\n // determine if the row will move position based on this change, and save why it will move\n const reason = willRowMove(cells[accessor], change, rowIndex, localization);\n\n if (reason) {\n rowChanges._meta.moveReason[accessor] = reason;\n } else {\n delete rowChanges._meta.moveReason[accessor];\n }\n } else {\n delete rowChanges[accessor];\n delete rowChanges._meta.moveReason[accessor];\n }\n }\n\n // set changes\n // or delete if there are no changes left, so that we don't store changes with unchanged data\n if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {\n nextChanges[row.id] = rowChanges;\n } else {\n delete nextChanges[row.id];\n }\n\n return nextChanges;\n}\n\nfunction getChangesetFromChanges<TType = unknown>(changes: PendingChange<TType>): TType {\n // extract the original data from the row changes\n const { _meta, ...changeset } = changes ?? {};\n // and mix them in with the changes, ready to send to the server\n return { ..._meta?.original, ...changeset };\n}\n"],"names":["useTableEditing","isEnabled","handleSave","handleChange","validator","isEditing","toggleEditing","React","useState","isDetailedMode","toggleDetailedMode","lastFocusedCellIndex","setLastFocusedCellIndex","useLastFocusedCellIndex","pendingChangesFns","usePendingChanges","useGlobalKeyDown","key","meta","shift","undefined","event","preventDefault","saveChanges","rowId","console","warn","Promise","resolve","changesToSave","pendingChanges","changes","Object","keys","length","_forOf","pendingChange","changeSet","getChangesetFromChanges","_catch","_temp3","_result","_exit","then","resetChanges","setRowSaveStatus","getRowSaveStatus","_temp2","errors","error","rowError","cellErrors","Error","_error$response","message","response","data","_error$response2","setPendingChanges","currentChanges","nextChanges","_meta","row","cells","hasShownErrorAlert","_nextChanges$rowId$_m","_nextChanges$rowId$_m2","e","reject","validateCell","cell","id","_temp","column","setCellValue","change","rowIndex","createPendingChangesSetter","localization","pendingChangesUpdater","syncCellChanges","runCellUpdates","addCreatedRowChangeset","getAllCells","reduce","getValue","_currentChanges$cell$","_currentChanges$cell$2","_currentChanges$cell$3","original","moveReason","useLocalization","saveStates","setSaveState","getCellValue","_pendingChanges$cell$","getCellError","_pendingChanges$cell$2","_pendingChanges$cell$3","_pendingChanges$cell$4","usePendingChangesUpdater","hasRowErrors","_pendingChanges$rowId","_pendingChanges$rowId2","_pendingChanges$rowId3","_pendingChanges$rowId4","_pendingChanges$rowId5","hasRowErrorsSeen","_pendingChanges$rowId6","setRowErrorsSeen","_pendingChanges$rowId7","status","currentStates","nextStates","getRowMoveReason","_pendingChanges$rowId8","values","hasChanges","hasErrors","table","tableRef","tableMeta","options","focusIsInsideTable","_tableRef$current","current","contains","document","activeElement","activeRow","rowActive","rowActiveIndex","getRowModel","rows","getErrors","filter","_activeRow","_activeRow2","_error$pendingChange$","map","lastFocusedCellIndexRef","useRef","useCallback","index","updatersRef","debounce","previousValues","nextValues","updates","_temp4","rowChanges","_currentChanges$row$i","_currentChanges$row$i2","_currentChanges$row$i3","_getAllCellsByColumnId","accessor","entries","reason","willRowMove","k","changeset"],"mappings":";;;;;;;SAcgBA,eAAeA,CAC3BC,SAAS,GAAG,KAAK,EACjBC,UAAuD,EACvDC,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from '../../../primitives/Table/useTableManager/util/filtering.js';
|
3
|
+
import { globalFilterFn } from '../../../primitives/Table/useTableManager/util/search.js';
|
3
4
|
|
4
|
-
function willRowMove(cell, change, rowIndex) {
|
5
|
+
function willRowMove(cell, change, rowIndex, localization) {
|
5
6
|
const {
|
6
7
|
table
|
7
8
|
} = cell.getContext();
|
8
|
-
if (willRowMoveAfterSearch(cell, change, table)) {
|
9
|
+
if (willRowMoveAfterSearch(cell, change, table, localization)) {
|
9
10
|
return 'search';
|
10
11
|
} else if (willRowMoveAfterFilter(cell, change)) {
|
11
12
|
return 'filter';
|
@@ -14,7 +15,7 @@ function willRowMove(cell, change, rowIndex) {
|
|
14
15
|
}
|
15
16
|
return undefined;
|
16
17
|
}
|
17
|
-
function willRowMoveAfterSearch(cell, change, table) {
|
18
|
+
function willRowMoveAfterSearch(cell, change, table, localization) {
|
18
19
|
const searchQuery = table.getState().globalFilter;
|
19
20
|
if (!table.options.enableGlobalFilter || !searchQuery) {
|
20
21
|
return false;
|
@@ -26,7 +27,7 @@ function willRowMoveAfterSearch(cell, change, table) {
|
|
26
27
|
[cell.column.id]: change
|
27
28
|
}
|
28
29
|
};
|
29
|
-
return !globalFilterFn(rowWithChange, cell.column.id, searchQuery);
|
30
|
+
return !globalFilterFn(rowWithChange, cell.column.id, searchQuery, localization);
|
30
31
|
}
|
31
32
|
function willRowMoveAfterFilter(cell, change) {
|
32
33
|
if (!cell.column.getIsFiltered()) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"editing.js","sources":["../../../../../../../../src/components/Table3/util/editing.ts"],"sourcesContent":["import { Cell as ReactTableCell, Row as ReactTableRow, Table as ReactTable } from '@tanstack/react-table';\nimport { TableFilterValue } from '../../../primitives/Table/types';\nimport { columnFilterFn
|
1
|
+
{"version":3,"file":"editing.js","sources":["../../../../../../../../src/components/Table3/util/editing.ts"],"sourcesContent":["import { Cell as ReactTableCell, Row as ReactTableRow, Table as ReactTable } from '@tanstack/react-table';\nimport { TableFilterValue } from '../../../primitives/Table/types';\nimport { setDataFocusAttribute } from '../../../utils/dom';\nimport { columnFilterFn } from '../../../primitives/Table/useTableManager/util/filtering';\nimport { globalFilterFn } from '../../../primitives/Table/useTableManager/util/search';\nimport { Localization } from '../../Provider/Localization';\n\nexport function willRowMove<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n change: unknown,\n rowIndex: number,\n localization: Localization\n) {\n const { table } = cell.getContext();\n\n if (willRowMoveAfterSearch<TType>(cell, change, table, localization)) {\n return 'search';\n } else if (willRowMoveAfterFilter<TType>(cell, change)) {\n return 'filter';\n } else if (willRowMoveAfterSorting<TType>(cell, change, rowIndex)) {\n return 'sorting';\n }\n\n return undefined;\n}\n\nfunction willRowMoveAfterSearch<TType = unknown>(\n cell: ReactTableCell<TType, unknown>,\n change: unknown,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const searchQuery = table.getState().globalFilter;\n\n if (!table.options.enableGlobalFilter || !searchQuery) {\n return false;\n }\n\n const rowWithChange = { ...cell.row, original: { ...cell.row.original, [cell.column.id]: change } };\n return !globalFilterFn(rowWithChange, cell.column.id, searchQuery, localization);\n}\n\nfunction willRowMoveAfterFilter<TType = unknown>(cell: ReactTableCell<TType, unknown>, change: unknown) {\n if (!cell.column.getIsFiltered()) {\n return false;\n }\n\n return !columnFilterFn(change, cell.column.getFilterValue() as TableFilterValue);\n}\n\nfunction willRowMoveAfterSorting<TType = unknown>(cell: ReactTableCell<TType, unknown>, change: unknown, rowIndex: number) {\n if (!cell.column.getIsSorted()) {\n return false;\n }\n\n const { table } = cell.getContext();\n const rows = table.getRowModel().rows;\n\n const miniSortRows: ReactTableRow<TType>[] = [\n {\n ...cell.row,\n original: {\n ...cell.row.original,\n [cell.column.id]: change,\n },\n getValue: () => change as any,\n },\n ];\n\n let index = 0;\n\n if (rowIndex > 0) {\n miniSortRows.unshift(rows[rowIndex - 1]);\n index = 1;\n }\n\n if (rowIndex < rows.length - 1) {\n miniSortRows.push(rows[rowIndex + 1]);\n }\n\n const resortedRows = [...miniSortRows].sort((rowA, rowB) => {\n const sortFn = cell.column.getSortingFn();\n const sortUndefined = cell.column.columnDef.sortUndefined;\n\n if (!table.options.manualSorting && sortUndefined) {\n const aValue = rowA.getValue(cell.column.id);\n const bValue = rowB.getValue(cell.column.id);\n\n const aUndefined = aValue === undefined;\n const bUndefined = bValue === undefined;\n\n if (aUndefined || bUndefined) {\n return aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;\n }\n }\n\n return sortFn(rowA, rowB, cell.column.id);\n });\n\n if (cell.column.getIsSorted() === 'desc') {\n resortedRows.reverse();\n }\n\n return resortedRows[index]?.id !== cell.row.id;\n}\n\nexport function animateCreateRow(id) {\n const templateRow = document.querySelector(`[data-row-id=\"${id}\"]`);\n\n if (templateRow) {\n const firstCell = templateRow.querySelector(':first-child') as HTMLElement;\n const checkbox = firstCell?.querySelector('[data-taco=\"checkbox\"]');\n firstCell?.focus();\n\n if (checkbox) {\n setDataFocusAttribute(checkbox);\n }\n\n templateRow.scrollIntoView();\n\n const keyframes = [{ background: '#b2c7ef' }, { background: '#ebebeb' }];\n\n for (const child of templateRow.children) {\n child.animate(keyframes, { duration: 1000, easing: 'ease-out' });\n }\n }\n}\n"],"names":["willRowMove","cell","change","rowIndex","localization","table","getContext","willRowMoveAfterSearch","willRowMoveAfterFilter","willRowMoveAfterSorting","undefined","searchQuery","getState","globalFilter","options","enableGlobalFilter","rowWithChange","row","original","column","id","globalFilterFn","getIsFiltered","columnFilterFn","getFilterValue","getIsSorted","rows","getRowModel","miniSortRows","getValue","index","unshift","length","push","resortedRows","sort","rowA","rowB","sortFn","getSortingFn","sortUndefined","columnDef","manualSorting","aValue","bValue","aUndefined","bUndefined","reverse","_resortedRows$index","animateCreateRow","templateRow","document","querySelector","firstCell","checkbox","focus","setDataFocusAttribute","scrollIntoView","keyframes","background","child","children","animate","duration","easing"],"mappings":";;;;SAOgBA,WAAWA,CACvBC,IAAoC,EACpCC,M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K,CAACE,OAAO,CAACJ,SAAS,EAAE;QAAEK,QAAQ,EAAE,IAAI;QAAEC,MAAM,EAAE;OAAY,CAAC;;;AAG5E;;;;"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
+
import { useLocalization } from '../../../../../../components/Provider/Localization.js';
|
2
3
|
import { isInternalColumn, isCellHighlighted } from '../../../../useTableManager/util/columns.js';
|
3
4
|
import { RowContext } from '../../Row/RowContext.js';
|
4
5
|
|
@@ -17,6 +18,7 @@ function getCellAttributes(cell, index, isHighlighted) {
|
|
17
18
|
};
|
18
19
|
}
|
19
20
|
function useSearchHighlighting(cell, cellIndex, ref) {
|
21
|
+
const localization = useLocalization();
|
20
22
|
const {
|
21
23
|
rowIndex
|
22
24
|
} = React__default.useContext(RowContext);
|
@@ -29,7 +31,7 @@ function useSearchHighlighting(cell, cellIndex, ref) {
|
|
29
31
|
}
|
30
32
|
let isHighlighted = false;
|
31
33
|
if (context.table.getState().globalFilter) {
|
32
|
-
isHighlighted = isCellHighlighted(context.table.getState().globalFilter, cell.getValue(), columnMeta.dataType);
|
34
|
+
isHighlighted = isCellHighlighted(context.table.getState().globalFilter, cell.getValue(), columnMeta.dataType, localization);
|
33
35
|
}
|
34
36
|
if (!isHighlighted || tableMeta.search.currentHighlightColumnIndex === undefined) {
|
35
37
|
return undefined;
|