@economic/taco 2.46.4 → 2.46.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
  2. package/dist/components/Table3/features/useEditingState.d.ts +1 -1
  3. package/dist/components/Table3/features/useTableEditing.d.ts +4 -3
  4. package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
  5. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  6. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
  7. package/dist/esm/packages/taco/src/components/Table3/Table3.js +0 -1
  8. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +4 -33
  10. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +1 -1
  12. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +4 -4
  14. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +32 -1
  16. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +7 -5
  18. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +4 -1
  20. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  21. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +5 -4
  22. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  23. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +6 -0
  24. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
  25. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +2 -2
  26. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  27. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
  28. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
  29. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +7 -0
  30. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
  31. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -1
  32. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
  33. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +3 -1
  34. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
  35. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +3 -2
  36. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
  37. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +5 -1
  38. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  39. package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
  40. package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -1
  41. package/dist/primitives/Table/Core/types.d.ts +1 -0
  42. package/dist/taco.cjs.development.js +91 -58
  43. package/dist/taco.cjs.development.js.map +1 -1
  44. package/dist/taco.cjs.production.min.js +1 -1
  45. package/dist/taco.cjs.production.min.js.map +1 -1
  46. package/package.json +2 -2
@@ -10,9 +10,9 @@ export declare type RadioGroupItemProps<T = HTMLButtonElement> = Omit<React.Butt
10
10
  /** Value of the radio button */
11
11
  value: RadioGroupItemValue;
12
12
  };
13
- declare type ReactGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;
13
+ declare type RadioGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;
14
14
  declare type RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {
15
- children: ReactGroupBaseChild[];
15
+ children: RadioGroupBaseChild[];
16
16
  disabled?: boolean;
17
17
  invalid?: boolean;
18
18
  /** The name of the radio group, used when submitting an HTML form */
@@ -23,7 +23,7 @@ export declare function usePendingChangesState<TType = unknown>(handleSave: Tabl
23
23
  saveChanges: <T_7 extends TType>(table: ReactTable<T_7>, rowId?: string | undefined) => Promise<boolean>;
24
24
  discardChanges: <T_8 extends TType>(rowId: string, table: ReactTable<T_8>) => void;
25
25
  hasSaved: () => boolean;
26
- createRow: <T_9 extends TType>(data: Partial<T_9>) => string;
26
+ insertTemporaryRow: <T_9 extends TType>(data: Partial<T_9>) => string;
27
27
  temporaryRows: any;
28
28
  };
29
29
  export {};
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Table as ReactTable } from '@tanstack/react-table';
3
- import { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';
4
- export declare function useTableEditing<TType = unknown>(isEnabled: boolean | undefined, handleSave: Table3EditingSaveHandler<TType> | undefined, handleChange: Table3EditingChangeHandler<TType> | undefined, rowIdentityAccessor: keyof TType | undefined, validator: Table3EditingValidatorFn<TType> | undefined): {
3
+ import { Table3EditingChangeHandler, Table3EditingCreateHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';
4
+ export declare function useTableEditing<TType = unknown>(isEnabled: boolean | undefined, handleSave: Table3EditingSaveHandler<TType> | undefined, handleChange: Table3EditingChangeHandler<TType> | undefined, handleCreate: Table3EditingCreateHandler<TType> | undefined, rowIdentityAccessor: keyof TType | undefined, validator: Table3EditingValidatorFn<TType> | undefined): {
5
5
  setRowValue: <T extends TType>(rowId: string, original: T, value: Partial<T>) => Promise<void>;
6
6
  getRowValue: (rowId: string) => any;
7
7
  getRowMoveReason: (rowId: string) => unknown;
@@ -23,7 +23,7 @@ export declare function useTableEditing<TType = unknown>(isEnabled: boolean | un
23
23
  saveChanges: <T_7 extends TType>(table: ReactTable<T_7>, rowId?: string | undefined) => Promise<boolean>;
24
24
  discardChanges: <T_8 extends TType>(rowId: string, table: ReactTable<T_8>) => void;
25
25
  hasSaved: () => boolean;
26
- createRow: <T_9 extends TType>(data: Partial<T_9>) => string;
26
+ insertTemporaryRow: <T_9 extends TType>(data: Partial<T_9>) => string;
27
27
  temporaryRows: any;
28
28
  isEnabled: boolean;
29
29
  isEditing: boolean;
@@ -32,5 +32,6 @@ export declare function useTableEditing<TType = unknown>(isEnabled: boolean | un
32
32
  toggleEditing: <T_10 extends TType>(enabled: React.SetStateAction<boolean>, table: ReactTable<T_10>, scrollToIndex: (index: number) => void) => void;
33
33
  lastFocusedCellIndex: number | undefined;
34
34
  setLastFocusedCellIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
35
+ createRow: <T_11 extends TType>(table: ReactTable<T_11>, scrollToIndex: (index: number) => void, row?: Partial<T_11> | undefined) => Promise<void>;
35
36
  createRowButtonRef: React.RefObject<HTMLButtonElement>;
36
37
  };
@@ -4,7 +4,7 @@ const getInputClasses = props => {
4
4
  const disabled = props.disabled || !!props['aria-disabled'];
5
5
  const readOnly = props.readOnly || !!props['aria-readonly'];
6
6
  const invalid = props.invalid || !!props['aria-invalid'];
7
- return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus-visible:yt-focus',
7
+ return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus:yt-focus',
8
8
  // hide the arrow controls on input[type=number]
9
9
  '[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none', {
10
10
  'bg-white': !props.highlighted && !readOnly,
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sources":["../../../../../../../src/components/Input/util.ts"],"sourcesContent":["import cn from 'clsx';\n\nexport const getInputClasses = props => {\n const disabled = props.disabled || !!props['aria-disabled'];\n const readOnly = props.readOnly || !!props['aria-readonly'];\n const invalid = props.invalid || !!props['aria-invalid'];\n\n return cn(\n 'peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus-visible:yt-focus',\n // hide the arrow controls on input[type=number]\n '[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none',\n {\n 'bg-white': !props.highlighted && !readOnly,\n // default\n 'border-grey-300 enabled:hover:border-grey-500 disabled:border-grey-200': !invalid,\n // disabled\n 'text-opacity-25 cursor-not-allowed placeholder:text-grey-700': disabled,\n // highlighted\n 'bg-yellow-100/50': props.highlighted && disabled,\n 'bg-yellow-100': props.highlighted && !disabled,\n // invalid\n 'border-red-500 enabled:hover:border-red-700 disabled:border-red-500/50': invalid,\n // readOnly\n 'cursor-not-allowed text-black bg-grey-200': readOnly,\n }\n );\n};\n\nexport const getButtonStateClasses = (invalid: boolean | undefined, disabled = false): string => {\n if (invalid) {\n return cn('border border-red-500 group-peer-hover:enabled:border-red-700 transition-colors ease-in', {\n 'border-red-500/30': disabled,\n });\n }\n\n return 'border border-grey-300 group-peer-hover:enabled:border-grey-500 transition-colors transition-opacity ease-in';\n};\n"],"names":["getInputClasses","props","disabled","readOnly","invalid","cn","highlighted","getButtonStateClasses"],"mappings":";;MAEaA,eAAe,GAAGC,KAAK;EAChC,MAAMC,QAAQ,GAAGD,KAAK,CAACC,QAAQ,IAAI,CAAC,CAACD,KAAK,CAAC,eAAe,CAAC;EAC3D,MAAME,QAAQ,GAAGF,KAAK,CAACE,QAAQ,IAAI,CAAC,CAACF,KAAK,CAAC,eAAe,CAAC;EAC3D,MAAMG,OAAO,GAAGH,KAAK,CAACG,OAAO,IAAI,CAAC,CAACH,KAAK,CAAC,cAAc,CAAC;EAExD,OAAOI,EAAE,CACL,wOAAwO;;EAExO,sHAAsH,EACtH;IACI,UAAU,EAAE,CAACJ,KAAK,CAACK,WAAW,IAAI,CAACH,QAAQ;;IAE3C,wEAAwE,EAAE,CAACC,OAAO;;IAElF,8DAA8D,EAAEF,QAAQ;;IAExE,kBAAkB,EAAED,KAAK,CAACK,WAAW,IAAIJ,QAAQ;IACjD,eAAe,EAAED,KAAK,CAACK,WAAW,IAAI,CAACJ,QAAQ;;IAE/C,wEAAwE,EAAEE,OAAO;;IAEjF,2CAA2C,EAAED;GAChD,CACJ;AACL;MAEaI,qBAAqB,GAAGA,CAACH,OAA4B,EAAEF,QAAQ,GAAG,KAAK;EAChF,IAAIE,OAAO,EAAE;IACT,OAAOC,EAAE,CAAC,yFAAyF,EAAE;MACjG,mBAAmB,EAAEH;KACxB,CAAC;;EAGN,OAAO,8GAA8G;AACzH;;;;"}
1
+ {"version":3,"file":"util.js","sources":["../../../../../../../src/components/Input/util.ts"],"sourcesContent":["import cn from 'clsx';\n\nexport const getInputClasses = props => {\n const disabled = props.disabled || !!props['aria-disabled'];\n const readOnly = props.readOnly || !!props['aria-readonly'];\n const invalid = props.invalid || !!props['aria-invalid'];\n\n return cn(\n 'peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus:yt-focus',\n // hide the arrow controls on input[type=number]\n '[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none',\n {\n 'bg-white': !props.highlighted && !readOnly,\n // default\n 'border-grey-300 enabled:hover:border-grey-500 disabled:border-grey-200': !invalid,\n // disabled\n 'text-opacity-25 cursor-not-allowed placeholder:text-grey-700': disabled,\n // highlighted\n 'bg-yellow-100/50': props.highlighted && disabled,\n 'bg-yellow-100': props.highlighted && !disabled,\n // invalid\n 'border-red-500 enabled:hover:border-red-700 disabled:border-red-500/50': invalid,\n // readOnly\n 'cursor-not-allowed text-black bg-grey-200': readOnly,\n }\n );\n};\n\nexport const getButtonStateClasses = (invalid: boolean | undefined, disabled = false): string => {\n if (invalid) {\n return cn('border border-red-500 group-peer-hover:enabled:border-red-700 transition-colors ease-in', {\n 'border-red-500/30': disabled,\n });\n }\n\n return 'border border-grey-300 group-peer-hover:enabled:border-grey-500 transition-colors transition-opacity ease-in';\n};\n"],"names":["getInputClasses","props","disabled","readOnly","invalid","cn","highlighted","getButtonStateClasses"],"mappings":";;MAEaA,eAAe,GAAGC,KAAK;EAChC,MAAMC,QAAQ,GAAGD,KAAK,CAACC,QAAQ,IAAI,CAAC,CAACD,KAAK,CAAC,eAAe,CAAC;EAC3D,MAAME,QAAQ,GAAGF,KAAK,CAACE,QAAQ,IAAI,CAAC,CAACF,KAAK,CAAC,eAAe,CAAC;EAC3D,MAAMG,OAAO,GAAGH,KAAK,CAACG,OAAO,IAAI,CAAC,CAACH,KAAK,CAAC,cAAc,CAAC;EAExD,OAAOI,EAAE,CACL,gOAAgO;;EAEhO,sHAAsH,EACtH;IACI,UAAU,EAAE,CAACJ,KAAK,CAACK,WAAW,IAAI,CAACH,QAAQ;;IAE3C,wEAAwE,EAAE,CAACC,OAAO;;IAElF,8DAA8D,EAAEF,QAAQ;;IAExE,kBAAkB,EAAED,KAAK,CAACK,WAAW,IAAIJ,QAAQ;IACjD,eAAe,EAAED,KAAK,CAACK,WAAW,IAAI,CAACJ,QAAQ;;IAE/C,wEAAwE,EAAEE,OAAO;;IAEjF,2CAA2C,EAAED;GAChD,CACJ;AACL;MAEaI,qBAAqB,GAAGA,CAACH,OAA4B,EAAEF,QAAQ,GAAG,KAAK;EAChF,IAAIE,OAAO,EAAE;IACT,OAAOC,EAAE,CAAC,yFAAyF,EAAE;MACjG,mBAAmB,EAAEH;KACxB,CAAC;;EAGN,OAAO,8GAA8G;AACzH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\nimport { getRadioClassnames } from './util';\n\nexport type RadioGroupItemValue = string | number | boolean | null;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string => String(value ?? '');\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString) as RadioGroupItemValue;\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const isDisabled = context.disabled || props.disabled;\n\n const className = cn('self-start', getRadioClassnames(isDisabled, context.invalid));\n const labelClassName = cn(\n 'flex items-center gap-2',\n {\n 'cursor-pointer': !isDisabled,\n 'cursor-not-allowed text-grey-300': isDisabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={isDisabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}>\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype ReactGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: ReactGroupBaseChild[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value?: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(() => {\n const radioGroupItemValues: RadioGroupItemValue[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n radioGroupItemValues.push(child.props.value);\n }\n });\n\n return radioGroupItemValues;\n }, [children]);\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (onChange !== undefined) {\n const handleChange = (value: string): void => onChange(findByValue(values, value));\n\n valueProps = {\n onValueChange: handleChange,\n value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined,\n };\n } else {\n valueProps = {\n defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n disabled,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start gap-y-2',\n {\n 'flex-wrap gap-x-4 ': otherProps.orientation === 'horizontal',\n 'flex-col': otherProps.orientation === 'vertical',\n },\n otherProps.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","isDisabled","className","cn","getRadioClassnames","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","radioGroupItemValues","forEach","child","push","valueProps","undefined","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;;MAQaA,8BAA8B,GAAIC,KAA0B,IAAaC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;MAE3FE,WAAW,GAAGA,CAACC,MAA6B,EAAEC,aAAqB,KAC5ED,MAAM,CAACE,IAAI,CAACL,KAAK,IAAID,8BAA8B,CAACC,KAAK,CAAC,KAAKI,aAAa;AAEhF,MAAME,iBAAiB,gBAAGC,aAAmB,CAAC;EAAEC,QAAQ,EAAE,KAAK;EAAEC,OAAO,EAAE;CAAO,CAAC;AAclF,MAAMC,cAAc,gBAAGH,UAAgB,CAAC,SAASG,cAAcA,CAACC,KAA0B,EAAEC,GAAiC;EACzH,MAAMC,OAA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AEE,SAAS,EAAEA,SAAS;iBAAY,aAAa;IAACL,GAAG,EAAEA;KAAO,CAC3E;AAErC,CAAC;AACDsB,UAAU,CAACE,IAAI,GAAG1B,cAAc;;;;"}
1
+ {"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\nimport { getRadioClassnames } from './util';\n\nexport type RadioGroupItemValue = string | number | boolean | null;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string => String(value ?? '');\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString) as RadioGroupItemValue;\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const isDisabled = context.disabled || props.disabled;\n\n const className = cn('self-start', getRadioClassnames(isDisabled, context.invalid));\n const labelClassName = cn(\n 'flex items-center gap-2',\n {\n 'cursor-pointer': !isDisabled,\n 'cursor-not-allowed text-grey-300': isDisabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={isDisabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}>\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype RadioGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: RadioGroupBaseChild[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value?: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(() => {\n const radioGroupItemValues: RadioGroupItemValue[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n radioGroupItemValues.push(child.props.value);\n }\n });\n\n return radioGroupItemValues;\n }, [children]);\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (onChange !== undefined) {\n const handleChange = (value: string): void => onChange(findByValue(values, value));\n\n valueProps = {\n onValueChange: handleChange,\n value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined,\n };\n } else {\n valueProps = {\n defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n disabled,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start gap-y-2',\n {\n 'flex-wrap gap-x-4 ': otherProps.orientation === 'horizontal',\n 'flex-col': otherProps.orientation === 'vertical',\n },\n otherProps.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","isDisabled","className","cn","getRadioClassnames","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","radioGroupItemValues","forEach","child","push","valueProps","undefined","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;;MAQaA,8BAA8B,GAAIC,KAA0B,IAAaC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;MAE3FE,WAAW,GAAGA,CAACC,MAA6B,EAAEC,aAAqB,KAC5ED,MAAM,CAACE,IAAI,CAACL,KAAK,IAAID,8BAA8B,CAACC,KAAK,CAAC,KAAKI,aAAa;AAEhF,MAAME,iBAAiB,gBAAGC,aAAmB,CAAC;EAAEC,QAAQ,EAAE,KAAK;EAAEC,OAAO,EAAE;CAAO,CAAC;AAclF,MAAMC,cAAc,gBAAGH,UAAgB,CAAC,SAASG,cAAcA,CAACC,KAA0B,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,cAACc,IAAwB,oBAAKN,UAAU;IAAEE,SAAS,EAAEA,SAAS;iBAAY,aAAa;IAACL,GAAG,EAAEA;KAAO,CAC3E;AAErC,CAAC;AACDsB,UAAU,CAACE,IAAI,GAAG1B,cAAc;;;;"}
@@ -44,7 +44,6 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
44
44
  tableRef: table3.ref
45
45
  }), /*#__PURE__*/React__default.createElement(CreateNewRow, {
46
46
  buttonRef: table3.meta.editing.createRowButtonRef,
47
- onEditingCreate: props.onEditingCreate,
48
47
  scrollToIndex: table3.renderer.scrollToIndex,
49
48
  table: table3.instance,
50
49
  tableMeta: table3.meta,
@@ -1 +1 @@
1
- {"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport { fixedForwardRef } from '../../types';\nimport { useTable3 } from './useTable3';\nimport { Table } from '../../primitives/Table/Core/Table';\nimport { Alert } from './components/Editing/Alert';\nimport { Table3Props, Table3Ref, Table3ColumnProps, Table3GroupProps } from './types';\nimport { Editing } from './components/Toolbar/Editing/Editing';\nimport { CreateNewRow } from './components/Row/Editing/CreateNewRow';\nimport { TemporaryRow } from './components/Row/Editing/TemporaryRow';\nimport './style.css';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: Table3GroupProps) {\n return null;\n}\nGroup.displayName = 'Table3Group';\n\nconst BaseTable3 = fixedForwardRef(function BaseTable3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const table3 = useTable3<TType>(props, ref);\n\n const gridAttributes = {\n 'data-table-editing-mode': table3.meta.editing?.isEditing\n ? table3.meta.editing?.isDetailedMode\n ? 'detailed'\n : 'normal'\n : undefined,\n enableHorizontalArrowKeyNavigation: table3.meta.editing.isEditing,\n };\n\n const hasAlertErrors = table3.meta.editing.getErrorsShownInAlert().length;\n const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;\n\n return (\n <Table>\n <Table.Toolbar<TType> table={table3}>\n {table3.meta.editing.isEnabled ? (\n <Editing scrollToIndex={table3.renderer.scrollToIndex} table={table3.instance} />\n ) : null}\n </Table.Toolbar>\n {hasAlertErrors ? (\n <Alert\n className=\"mb-4\"\n scrollToIndex={table3.renderer.scrollToIndex}\n table={table3.instance}\n tableRef={table3.ref}\n />\n ) : null}\n <Table.Grid<TType> {...gridAttributes} data-taco=\"table3\" table={table3}>\n {hasCreateWorkflow ? (\n <>\n <TemporaryRow\n createRowButtonRef={table3.meta.editing.createRowButtonRef}\n table={table3.instance}\n tableMeta={table3.meta}\n tableRef={table3.ref}\n />\n <CreateNewRow\n buttonRef={table3.meta.editing.createRowButtonRef}\n onEditingCreate={props.onEditingCreate}\n scrollToIndex={table3.renderer.scrollToIndex}\n table={table3.instance}\n tableMeta={table3.meta}\n tableRef={table3.ref}\n />\n </>\n ) : null}\n </Table.Grid>\n </Table>\n );\n});\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <BaseTable3<TType> {...props} key={key} ref={ref} />;\n}) as (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\nTable3.Column = Column;\nTable3.Group = Group;\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3ColumnProps,\n Table3GroupProps,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n Table3Texts,\n Table3FeatureProps,\n Table3CommonProps,\n Table3WithoutEditingWithClientProps,\n Table3WithoutEditingWithServerProps,\n Table3WithEditingProps,\n Table3WithEditingWithClientProps,\n Table3WithEditingWithServerProps,\n Table3EditingChangeHandler,\n Table3EditingCreateHandler,\n} from './types';\n"],"names":["Column","_","displayName","Group","BaseTable3","fixedForwardRef","props","ref","table3","useTable3","gridAttributes","_table3$meta$editing","meta","editing","isEditing","_table3$meta$editing2","isDetailedMode","undefined","enableHorizontalArrowKeyNavigation","hasAlertErrors","getErrorsShownInAlert","length","hasCreateWorkflow","isEnabled","onEditingCreate","React","Table","Toolbar","table","Editing","scrollToIndex","renderer","instance","Alert","className","tableRef","Grid","TemporaryRow","createRowButtonRef","tableMeta","CreateNewRow","buttonRef","Table3","stringifiedChildren","String","children","key","useMemo"],"mappings":";;;;;;;;;AAWA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AACAD,MAAM,CAACE,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACF,CAAmB;EAC9B,OAAO,IAAI;AACf;AACAE,KAAK,CAACD,WAAW,GAAG,aAAa;AAEjC,MAAME,UAAU,gBAAGC,eAAe,CAAC,SAASD,UAAUA,CAAkBE,KAAyB,EAAEC,GAAyB;;EACxH,MAAMC,MAAM,GAAGC,SAAS,CAAQH,KAAK,EAAEC,GAAG,CAAC;EAE3C,MAAMG,cAAc,GAAG;IACnB,yBAAyB,EAAE,CAAAC,oBAAA,GAAAH,MAAM,CAACI,IAAI,CAACC,OAAO,cAAAF,oBAAA,eAAnBA,oBAAA,CAAqBG,SAAS,GACnD,CAAAC,qBAAA,GAAAP,MAAM,CAACI,IAAI,CAACC,OAAO,cAAAE,qBAAA,eAAnBA,qBAAA,CAAqBC,cAAc,GAC/B,UAAU,GACV,QAAQ,GACZC,SAAS;IACfC,kCAAkC,EAAEV,MAAM,CAACI,IAAI,CAACC,OAAO,CAACC;GAC3D;EAED,MAAMK,cAAc,GAAGX,MAAM,CAACI,IAAI,CAACC,OAAO,CAACO,qBAAqB,EAAE,CAACC,MAAM;EACzE,MAAMC,iBAAiB,GAAGd,MAAM,CAACI,IAAI,CAACC,OAA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MAAMA,CAAkBpC,KAAyB,EAAEC,GAAyB;EACvH,MAAMoC,mBAAmB,GAAGC,MAAM,CAACtC,KAAK,CAACuC,QAAQ,CAAC;;;EAGlD,MAAMC,GAAG,GAAGrB,cAAK,CAACsB,OAAO,CAAC,MAAMH,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAOlB,6BAACrB,UAAU,oBAAYE,KAAK;IAAEwC,GAAG,EAAEA,GAAG;IAAEvC,GAAG,EAAEA;KAAO;AAC/D,CAAC;AAIDmC,MAAM,CAAC1C,MAAM,GAAGA,MAAM;AACtB0C,MAAM,CAACvC,KAAK,GAAGA,KAAK;;;;"}
1
+ {"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport { fixedForwardRef } from '../../types';\nimport { useTable3 } from './useTable3';\nimport { Table } from '../../primitives/Table/Core/Table';\nimport { Alert } from './components/Editing/Alert';\nimport { Table3Props, Table3Ref, Table3ColumnProps, Table3GroupProps } from './types';\nimport { Editing } from './components/Toolbar/Editing/Editing';\nimport { CreateNewRow } from './components/Row/Editing/CreateNewRow';\nimport { TemporaryRow } from './components/Row/Editing/TemporaryRow';\nimport './style.css';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: Table3GroupProps) {\n return null;\n}\nGroup.displayName = 'Table3Group';\n\nconst BaseTable3 = fixedForwardRef(function BaseTable3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const table3 = useTable3<TType>(props, ref);\n\n const gridAttributes = {\n 'data-table-editing-mode': table3.meta.editing?.isEditing\n ? table3.meta.editing?.isDetailedMode\n ? 'detailed'\n : 'normal'\n : undefined,\n enableHorizontalArrowKeyNavigation: table3.meta.editing.isEditing,\n };\n\n const hasAlertErrors = table3.meta.editing.getErrorsShownInAlert().length;\n const hasCreateWorkflow = table3.meta.editing.isEnabled && props.onEditingCreate;\n\n return (\n <Table>\n <Table.Toolbar<TType> table={table3}>\n {table3.meta.editing.isEnabled ? (\n <Editing scrollToIndex={table3.renderer.scrollToIndex} table={table3.instance} />\n ) : null}\n </Table.Toolbar>\n {hasAlertErrors ? (\n <Alert\n className=\"mb-4\"\n scrollToIndex={table3.renderer.scrollToIndex}\n table={table3.instance}\n tableRef={table3.ref}\n />\n ) : null}\n <Table.Grid<TType> {...gridAttributes} data-taco=\"table3\" table={table3}>\n {hasCreateWorkflow ? (\n <>\n <TemporaryRow\n createRowButtonRef={table3.meta.editing.createRowButtonRef}\n table={table3.instance}\n tableMeta={table3.meta}\n tableRef={table3.ref}\n />\n <CreateNewRow\n buttonRef={table3.meta.editing.createRowButtonRef}\n scrollToIndex={table3.renderer.scrollToIndex}\n table={table3.instance}\n tableMeta={table3.meta}\n tableRef={table3.ref}\n />\n </>\n ) : null}\n </Table.Grid>\n </Table>\n );\n});\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <BaseTable3<TType> {...props} key={key} ref={ref} />;\n}) as (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\nTable3.Column = Column;\nTable3.Group = Group;\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3ColumnProps,\n Table3GroupProps,\n Table3EditingSaveHandler,\n Table3EditingValidatorFn,\n Table3Texts,\n Table3FeatureProps,\n Table3CommonProps,\n Table3WithoutEditingWithClientProps,\n Table3WithoutEditingWithServerProps,\n Table3WithEditingProps,\n Table3WithEditingWithClientProps,\n Table3WithEditingWithServerProps,\n Table3EditingChangeHandler,\n Table3EditingCreateHandler,\n} from './types';\n"],"names":["Column","_","displayName","Group","BaseTable3","fixedForwardRef","props","ref","table3","useTable3","gridAttributes","_table3$meta$editing","meta","editing","isEditing","_table3$meta$editing2","isDetailedMode","undefined","enableHorizontalArrowKeyNavigation","hasAlertErrors","getErrorsShownInAlert","length","hasCreateWorkflow","isEnabled","onEditingCreate","React","Table","Toolbar","table","Editing","scrollToIndex","renderer","instance","Alert","className","tableRef","Grid","TemporaryRow","createRowButtonRef","tableMeta","CreateNewRow","buttonRef","Table3","stringifiedChildren","String","children","key","useMemo"],"mappings":";;;;;;;;;AAWA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AACAD,MAAM,CAACE,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACF,CAAmB;EAC9B,OAAO,IAAI;AACf;AACAE,KAAK,CAACD,WAAW,GAAG,aAAa;AAEjC,MAAME,UAAU,gBAAGC,eAAe,CAAC,SAASD,UAAUA,CAAkBE,KAAyB,EAAEC,GAAyB;;EACxH,MAAMC,MAAM,GAAGC,SAAS,CAAQH,KAAK,EAAEC,GAAG,CAAC;EAE3C,MAAMG,cAAc,GAAG;IACnB,yBAAyB,EAAE,CAAAC,oBAAA,GAAAH,MAAM,CAACI,IAAI,CAACC,OAAO,cAAAF,oBAAA,eAAnBA,oBAAA,CAAqBG,SAAS,GACnD,CAAAC,qBAAA,GAAAP,MAAM,CAACI,IAAI,CAACC,OAAO,cAAAE,qBAAA,eAAnBA,qBAAA,CAAqBC,cAAc,GAC/B,UAAU,GACV,QAAQ,GACZC,SAAS;IACfC,kCAAkC,EAAEV,MAAM,CAACI,IAAI,CAACC,OAAO,CAACC;GAC3D;EAED,MAAMK,cAAc,GAAGX,MAAM,CAACI,IAAI,CAACC,OAAO,CAACO,qBAAqB,EAAE,CAACC,MAAM;EACzE,MAAMC,iBAAiB,GAAGd,MAAM,CAACI,IAAI,CAACC,OAAO,CAACU,SAAS,IA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AmB,GAAGC,MAAM,CAACtC,KAAK,CAACuC,QAAQ,CAAC;;;EAGlD,MAAMC,GAAG,GAAGrB,cAAK,CAACsB,OAAO,CAAC,MAAMH,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAOlB,6BAACrB,UAAU,oBAAYE,KAAK;IAAEwC,GAAG,EAAEA,GAAG;IAAEvC,GAAG,EAAEA;KAAO;AAC/D,CAAC;AAIDmC,MAAM,CAAC1C,MAAM,GAAGA,MAAM;AACtB0C,MAAM,CAACvC,KAAK,GAAGA,KAAK;;;;"}
@@ -6,10 +6,9 @@ import { Button } from '../../../../Button/Button.js';
6
6
  import { Shortcut } from '../../../../Shortcut/Shortcut.js';
7
7
 
8
8
  function CreateNewRow(props) {
9
- var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum, _tableRef$current2;
9
+ var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum;
10
10
  const {
11
11
  buttonRef,
12
- onEditingCreate: handleEditingCreate,
13
12
  scrollToIndex,
14
13
  table,
15
14
  tableMeta,
@@ -22,44 +21,16 @@ function CreateNewRow(props) {
22
21
  const temporaryRowId = (_temporaryRows$0$tabl = (_temporaryRows$ = temporaryRows[0]) === null || _temporaryRows$ === void 0 ? void 0 : _temporaryRows$[tableMeta.rowIdentityAccessor]) !== null && _temporaryRows$0$tabl !== void 0 ? _temporaryRows$0$tabl : '';
23
22
  const isDisabled = !!table.getState().globalFilter || !!((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length) || !!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId);
24
23
  const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';
25
- const createRow = function (row) {
24
+ const handleCreate = function () {
26
25
  try {
27
- if (!handleEditingCreate || isDisabled) {
26
+ if (isDisabled) {
28
27
  return Promise.resolve();
29
28
  }
30
- return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
31
- if (!saved) {
32
- return;
33
- }
34
- const changeset = row !== null && row !== void 0 ? row : handleEditingCreate();
35
- try {
36
- if (changeset) {
37
- const rowId = tableMeta.editing.createRow(changeset);
38
- table.getRow(rowId).pin('bottom');
39
- // set the active row to the new row before toggling editing on
40
- const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
41
- tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
42
- tableMeta.editing.toggleEditing(true, table, scrollToIndex);
43
- tableMeta.editing.setLastFocusedCellIndex(0);
44
- }
45
- } catch (error) {
46
- console.error(error);
47
- }
48
- });
29
+ return Promise.resolve(tableMeta.editing.createRow(table, scrollToIndex)).then(function () {});
49
30
  } catch (e) {
50
31
  return Promise.reject(e);
51
32
  }
52
33
  };
53
- // allow programmatic access to creating rows from outside the table
54
- React__default.useEffect(() => {
55
- var _tableRef$current;
56
- if (tableRef !== null && tableRef !== void 0 && (_tableRef$current = tableRef.current) !== null && _tableRef$current !== void 0 && _tableRef$current.instance) {
57
- tableRef.current.instance.createRow = createRow;
58
- }
59
- }, [tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.instance, createRow]);
60
- const handleCreate = function () {
61
- return createRow();
62
- };
63
34
  const shortcut = {
64
35
  key: 'Enter',
65
36
  meta: true
@@ -1 +1 @@
1
- {"version":3,"file":"CreateNewRow.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/CreateNewRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { Button } from '../../../../Button/Button';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Table3EditingCreateHandler, Table3Ref } from '../../../types';\nimport { TableRef } from '../../../../../primitives/Table/types';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport clsx from 'clsx';\n\ntype CreateNewRowProps<TType = unknown> = {\n buttonRef: React.Ref<HTMLButtonElement>;\n onEditingCreate?: Table3EditingCreateHandler<TType>;\n scrollToIndex: (index: number) => void;\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function CreateNewRow<TType = unknown>(props: CreateNewRowProps<TType>) {\n const { buttonRef, onEditingCreate: handleEditingCreate, scrollToIndex, table, tableMeta, tableRef } = props;\n const { texts } = useLocalization();\n\n const temporaryRows = tableMeta.editing.temporaryRows as TType[];\n const temporaryRowId: string = temporaryRows[0]?.[tableMeta.rowIdentityAccessor as string] ?? '';\n\n const isDisabled =\n !!table.getState().globalFilter ||\n !!table.getState().columnFilters?.length ||\n (!!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId));\n const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';\n\n const createRow = async (row?: Partial<TType>) => {\n if (!handleEditingCreate || isDisabled) {\n return;\n }\n\n const saved = await tableMeta.editing.saveChanges(table);\n\n if (!saved) {\n return;\n }\n\n const changeset = row ?? handleEditingCreate();\n\n try {\n if (changeset) {\n const rowId = tableMeta.editing.createRow(changeset);\n table.getRow(rowId).pin('bottom');\n\n // set the active row to the new row before toggling editing on\n const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;\n tableMeta.rowActive.setRowActiveIndex(nextRowIndex);\n\n tableMeta.editing.toggleEditing(true, table, scrollToIndex);\n tableMeta.editing.setLastFocusedCellIndex(0);\n }\n } catch (error) {\n console.error(error);\n }\n };\n\n // allow programmatic access to creating rows from outside the table\n React.useEffect(() => {\n if (tableRef?.current?.instance) {\n (tableRef.current as Table3Ref).instance.createRow = createRow as (row: unknown) => Promise<void>;\n }\n }, [tableRef?.current?.instance, createRow]);\n\n const handleCreate = async () => createRow();\n const shortcut = { key: 'Enter', meta: true };\n\n let tooltip;\n\n if (isSaving) {\n tooltip = texts.table3.editing.buttons.create.saving;\n } else if (isDisabled) {\n tooltip = texts.table3.editing.buttons.create.disabled;\n } else {\n tooltip = <Shortcut keys={shortcut} />;\n }\n\n const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;\n\n const className = clsx('group/row border-grey-300 !sticky z-[21]', {\n 'bottom-10': tableMeta.footer.isEnabled,\n 'bottom-0': !tableMeta.footer.isEnabled,\n 'border-t-2': isScrolled,\n 'border-b': !isScrolled,\n });\n\n return (\n <tr data-row-create className={className} tabIndex={-1}>\n <td className=\"!bg-grey-50 col-span-full !border-b-0 !px-1\">\n <Button\n appearance=\"transparent\"\n className=\"group-hover:bg-grey-200 sticky left-[4px]\"\n disabled={isDisabled}\n onClick={handleCreate}\n ref={buttonRef}\n shortcut={shortcut}\n tooltip={tooltip}>\n <Icon name=\"circle-plus\" />\n {texts.table3.editing.buttons.create.label}\n </Button>\n </td>\n </tr>\n );\n}\n"],"names":["CreateNewRow","props","buttonRef","onEditingCreate","handleEditingCreate","scrollToIndex","table","tableMeta","tableRef","texts","useLocalization","temporaryRows","editing","temporaryRowId","_temporaryRows$0$tabl","_temporaryRows$","rowIdentityAccessor","isDisabled","getState","globalFilter","_table$getState$colum","columnFilters","length","hasRowErrors","isSaving","getRowStatus","createRow","row","Promise","resolve","saveChanges","then","saved","changeset","rowId","getRow","pin","nextRowIndex","rowActive","setRowActiveIndex","toggleEditing","setLastFocusedCellIndex","error","console","e","reject","React","useEffect","_tableRef$current","current","instance","_tableRef$current2","handleCreate","shortcut","key","meta","tooltip","table3","buttons","create","saving","disabled","Shortcut","keys","isScrolled","scrollHeight","clientHeight","className","clsx","footer","isEnabled","tabIndex","Button","appearance","onClick","ref","Icon","name","label"],"mappings":";;;;;;;SAmBgBA,YAAYA,CAAkBC,KAA+B;;EACzE,MAAM;IAAEC,SAAS;IAAEC,eAAe,EAAEC,mBAAmB;IAAEC,aAAa;IAAEC,KAAK;IAAEC,SAAS;IAAEC;GAAU,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AAC7C,OAAO,CAAC8C,OAAO,CAACC,MAAM,CAACE,QAAQ;GACzD,MAAM;IACHL,OAAO,gBAAGV,6BAACgB,QAAQ;MAACC,IAAI,EAAEV;MAAY;;EAG1C,MAAMW,UAAU,GAAGxD,QAAQ,CAACyC,OAAO,GAAGzC,QAAQ,CAACyC,OAAO,CAACgB,YAAY,GAAGzD,QAAQ,CAACyC,OAAO,CAACiB,YAAY,GAAG,KAAK;EAE3G,MAAMC,SAAS,GAAGC,EAAI,CAAC,0CAA0C,EAAE;IAC/D,WAAW,EAAE7D,SAAS,CAAC8D,MAAM,CAACC,SAAS;IACvC,UAAU,EAAE,CAAC/D,SAAS,CAAC8D,MAAM,CAACC,SAAS;IACvC,YAAY,EAAEN,UAAU;IACxB,UAAU,EAAE,CAACA;GAChB,CAAC;EAEF,oBACIlB;;IAAoBqB,SAAS,EAAEA,SAAS;IAAEI,QAAQ,EAAE,CAAC;kBACjDzB;IAAIqB,SAAS,EAAC;kBACVrB,6BAAC0B,MAAM;IACHC,UAAU,EAAC,aAAa;IACxBN,SAAS,EAAC,2CAA2C;IACrDN,QAAQ,EAAE5C,UAAU;IACpByD,OAAO,EAAEtB,YAAY;IACrBuB,GAAG,EAAEzE,SAAS;IACdmD,QAAQ,EAAEA,QAAQ;IAClBG,OAAO,EAAEA;kBACTV,6BAAC8B,IAAI;IAACC,IAAI,EAAC;IAAgB,EAC1BpE,KAAK,CAACgD,MAAM,CAAC7C,OAAO,CAAC8C,OAAO,CAACC,MAAM,CAACmB,KAAK,CACrC,CACR,CACJ;AAEb;;;;"}
1
+ {"version":3,"file":"CreateNewRow.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/CreateNewRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Button } from '../../../../Button/Button';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Table3EditingCreateHandler } from '../../../types';\nimport { TableRef } from '../../../../../primitives/Table/types';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\n\ntype CreateNewRowProps<TType = unknown> = {\n buttonRef: React.Ref<HTMLButtonElement>;\n onEditingCreate?: Table3EditingCreateHandler<TType>;\n scrollToIndex: (index: number) => void;\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function CreateNewRow<TType = unknown>(props: CreateNewRowProps<TType>) {\n const { buttonRef, scrollToIndex, table, tableMeta, tableRef } = props;\n const { texts } = useLocalization();\n\n const temporaryRows = tableMeta.editing.temporaryRows as TType[];\n const temporaryRowId: string = temporaryRows[0]?.[tableMeta.rowIdentityAccessor as string] ?? '';\n\n const isDisabled =\n !!table.getState().globalFilter ||\n !!table.getState().columnFilters?.length ||\n (!!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId));\n const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';\n\n const handleCreate = async () => {\n if (isDisabled) {\n return;\n }\n\n await tableMeta.editing.createRow(table, scrollToIndex);\n };\n const shortcut = { key: 'Enter', meta: true };\n\n let tooltip;\n\n if (isSaving) {\n tooltip = texts.table3.editing.buttons.create.saving;\n } else if (isDisabled) {\n tooltip = texts.table3.editing.buttons.create.disabled;\n } else {\n tooltip = <Shortcut keys={shortcut} />;\n }\n\n const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;\n\n const className = clsx('group/row border-grey-300 !sticky z-[21]', {\n 'bottom-10': tableMeta.footer.isEnabled,\n 'bottom-0': !tableMeta.footer.isEnabled,\n 'border-t-2': isScrolled,\n 'border-b': !isScrolled,\n });\n\n return (\n <tr data-row-create className={className} tabIndex={-1}>\n <td className=\"!bg-grey-50 col-span-full !border-b-0 !px-1\">\n <Button\n appearance=\"transparent\"\n className=\"group-hover:bg-grey-200 sticky left-[4px]\"\n disabled={isDisabled}\n onClick={handleCreate}\n ref={buttonRef}\n shortcut={shortcut}\n tooltip={tooltip}>\n <Icon name=\"circle-plus\" />\n {texts.table3.editing.buttons.create.label}\n </Button>\n </td>\n </tr>\n );\n}\n"],"names":["CreateNewRow","props","buttonRef","scrollToIndex","table","tableMeta","tableRef","texts","useLocalization","temporaryRows","editing","temporaryRowId","_temporaryRows$0$tabl","_temporaryRows$","rowIdentityAccessor","isDisabled","getState","globalFilter","_table$getState$colum","columnFilters","length","hasRowErrors","isSaving","getRowStatus","handleCreate","Promise","resolve","createRow","then","e","reject","shortcut","key","meta","tooltip","table3","buttons","create","saving","disabled","React","Shortcut","keys","isScrolled","current","scrollHeight","clientHeight","className","clsx","footer","isEnabled","tabIndex","Button","appearance","onClick","ref","Icon","name","label"],"mappings":";;;;;;;SAmBgBA,YAAYA,CAAkBC,KAA+B;;EACzE,MAAM;IAAEC,SAAS;IAAEC,aAAa;IAAEC,KAAK;IAAEC,SAAS;IAAEC;GAAU,GAAGL,KAAK;EACtE,MAAM;IAAEM;GAAO,GAAGC,eAAe,EAAE;EAEnC,MAAMC,aAAa,GAAGJ,SAAS,CAACK,OAAO,CAACD,aAAwB;EAChE,MAAME,cAAc,IAAAC,qBAAA,IAAAC,eAAA,GAAWJ,aAAa,CAAC,CAAC,CAAC,cAAAI,eAAA,uBAAhBA,eAAA,CAAmBR,SAAS,CAACS,mBAA6B,CAAC,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,EAAE;EAEhG,MAAMG,UAAU,GACZ,CAAC,CAACX,KAAK,CAACY,QAAQ,EAAE,CAACC,YAAY,IAC/B,CAAC,GAAAC,qBAAA,GAACd,KAAK,CAACY,QAAQ,EAAE,CAACG,aAAa,cAAAD,qBAAA,eAA9BA,qBAAA,CAAgCE,MAAM,KACvC,CAAC,CAACT,cAAc,IAAI,CAAC,CAACN,SAAS,CAACK,OAAO,CAACW,YAAY,CAACV,cAAc,CAAE;EAC1E,MAAMW,QAAQ,GAAG,CAAC,CAACX,cAAc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P,6BAACY,MAAM;IACHC,UAAU,EAAC,aAAa;IACxBN,SAAS,EAAC,2CAA2C;IACrDR,QAAQ,EAAExB,UAAU;IACpBuC,OAAO,EAAE9B,YAAY;IACrB+B,GAAG,EAAErD,SAAS;IACd6B,QAAQ,EAAEA,QAAQ;IAClBG,OAAO,EAAEA;kBACTM,6BAACgB,IAAI;IAACC,IAAI,EAAC;IAAgB,EAC1BlD,KAAK,CAAC4B,MAAM,CAACzB,OAAO,CAAC0B,OAAO,CAACC,MAAM,CAACqB,KAAK,CACrC,CACR,CACJ;AAEb;;;;"}
@@ -87,7 +87,7 @@ function TemporaryRow(props) {
87
87
  className: className,
88
88
  onKeyDown: handleKeyDown,
89
89
  onKeyDownCapture: handleKeyDownCapture,
90
- // Row actions should only be hidden on temporary rows when editing is turned off
90
+ hideInternalColumns: true,
91
91
  hideRowActions: !tableMeta.editing.isEditing
92
92
  }))));
93
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TemporaryRow.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/TemporaryRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Row } from '../../../../../primitives/Table/Core/components/Row/Row';\nimport { RENDERERS } from '../../../useTable3';\nimport { isElementTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableRef } from '../../../../../primitives/Table/types';\nimport { TEMPORARY_ROW_ID_PREFIX } from '../../../util/editing';\n\ntype TemporaryRowProps<TType = unknown> = {\n createRowButtonRef: React.RefObject<HTMLButtonElement>;\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function TemporaryRow<TType = unknown>(props: TemporaryRowProps<TType>) {\n const { createRowButtonRef, table, tableMeta, tableRef } = props;\n\n const handleKeyDown = async (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (!isElementTriggeredFromContainer(event.target as Element, event.currentTarget)) {\n const saved = await tableMeta.editing.saveChanges(table);\n\n if (saved) {\n createRowButtonRef.current?.focus();\n }\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n\n if (tableRef.current) {\n const availableRows = Array.from(\n tableRef.current.querySelectorAll(`tbody tr:not([data-row-id^='${TEMPORARY_ROW_ID_PREFIX}'])`) ?? []\n );\n\n const footerHeight = tableRef.current.querySelector('tfoot')?.getBoundingClientRect().height ?? 0;\n const newRowHeight = event.currentTarget.getBoundingClientRect().height;\n const visibleHeight = tableRef.current.clientHeight - footerHeight - newRowHeight;\n const tableTopOffset = tableRef.current.getBoundingClientRect().top;\n\n let nextRowIndex;\n\n // iterate available rows in reverse order, since we're working at the bottom\n for (let index = availableRows.length - 1; index >= 0; index--) {\n const rowRect = availableRows[index].getBoundingClientRect();\n const topPlusHalfRow = rowRect.top + rowRect.height / 2;\n\n if (topPlusHalfRow - tableTopOffset <= visibleHeight) {\n nextRowIndex = index;\n break;\n }\n }\n\n if (nextRowIndex) {\n tableMeta.rowActive.setRowActiveIndex(\n Number(availableRows[nextRowIndex < 0 ? 0 : nextRowIndex].getAttribute('data-row-index'))\n );\n }\n }\n }\n };\n\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key === 'ArrowLeft' && tableMeta.editing.lastFocusedCellIndex === 0) {\n event.preventDefault();\n event.stopPropagation();\n } else if (event.key === 'ArrowRight' && tableMeta.editing.lastFocusedCellIndex) {\n if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n };\n\n const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;\n\n const className = clsx('group/row border-grey-300 !sticky z-[22]', {\n 'bottom-[calc(5rem_+_3px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,\n 'bottom-[calc(2.5rem_+_3px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,\n 'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled,\n });\n\n return (\n <>\n {table.getBottomRows().map(row => (\n <Row<TType>\n key={row.id}\n cellRenderer={RENDERERS.cell}\n index={tableMeta.length}\n measureRow={() => null}\n renderer={RENDERERS.row}\n row={row}\n table={table}\n className={className}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={handleKeyDownCapture}\n // Row actions should only be hidden on temporary rows when editing is turned off\n hideRowActions={!tableMeta.editing.isEditing}\n />\n ))}\n </>\n );\n}\n"],"names":["TemporaryRow","props","createRowButtonRef","table","tableMeta","tableRef","handleKeyDown","event","key","preventDefault","_temp","isElementTriggeredFromContainer","target","currentTarget","Promise","resolve","editing","saveChanges","then","saved","_createRowButtonRef$c","current","focus","stopPropagation","_tableRef$current$que","_tableRef$current$que2","_tableRef$current$que3","availableRows","Array","from","querySelectorAll","TEMPORARY_ROW_ID_PREFIX","footerHeight","querySelector","getBoundingClientRect","height","newRowHeight","visibleHeight","clientHeight","tableTopOffset","top","nextRowIndex","index","length","rowRect","topPlusHalfRow","rowActive","setRowActiveIndex","Number","getAttribute","_temp2","e","reject","handleKeyDownCapture","lastFocusedCellIndex","getVisibleFlatColumns","isScrolled","scrollHeight","className","clsx","footer","isEnabled","React","getBottomRows","map","row","Row","id","cellRenderer","RENDERERS","cell","measureRow","renderer","onKeyDown","onKeyDownCapture","hideRowActions","isEditing"],"mappings":";;;;;;;SAgBgBA,YAAYA,CAAkBC,KAA+B;EACzE,MAAM;IAAEC,kBAAkB;IAAEC,KAAK;IAAEC,SAAS;IAAEC;GAAU,GAAGJ,KAAK;EAEhE,MAAMK,aAAa,aAAUC,KAA+C;IAAA;;YACpEA,KAAK,CAACC,GAAG,KAAK,WAAW;UACzBD,KAAK,CAACE,cAAc,EAAE;UAAC,MAAAC,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E;QACrFpC,KAAK,CAACE,cAAc,EAAE;QACtBF,KAAK,CAACgB,eAAe,EAAE;;;GAGlC;EAED,MAAMiC,UAAU,GAAGnD,QAAQ,CAACgB,OAAO,GAAGhB,QAAQ,CAACgB,OAAO,CAACoC,YAAY,GAAGpD,QAAQ,CAACgB,OAAO,CAACiB,YAAY,GAAG,KAAK;EAE3G,MAAMoB,SAAS,GAAGC,EAAI,CAAC,0CAA0C,EAAE;IAC/D,6EAA6E,EAAEvD,SAAS,CAACwD,MAAM,CAACC,SAAS;IACzG,iFAAiF,EAAE,CAACzD,SAAS,CAACwD,MAAM,CAACC,SAAS;IAC9G,0EAA0E,EAAEL;GAC/E,CAAC;EAEF,oBACIM,4DACK3D,KAAK,CAAC4D,aAAa,EAAE,CAACC,GAAG,CAACC,GAAG,kBAC1BH,6BAACI,GAAG;IACA1D,GAAG,EAAEyD,GAAG,CAACE,EAAE;IACXC,YAAY,EAAEC,SAAS,CAACC,IAAI;IAC5B5B,KAAK,EAAEtC,SAAS,CAACuC,MAAM;IACvB4B,UAAU,EAAEA,MAAM,IAAI;IACtBC,QAAQ,EAAEH,SAAS,CAACJ,GAAG;IACvBA,GAAG,EAAEA,GAAG;IACR9D,KAAK,EAAEA,KAAK;IACZuD,SAAS,EAAEA,SAAS;IACpBe,SAAS,EAAEnE,aAAa;IACxBoE,gBAAgB,EAAErB,oBAAoB;;IAEtCsB,cAAc,EAAE,CAACvE,SAAS,CAACY,OAAO,CAAC4D;IACrC,CACL,CAAC,CACH;AAEX;;;;"}
1
+ {"version":3,"file":"TemporaryRow.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/TemporaryRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Row } from '../../../../../primitives/Table/Core/components/Row/Row';\nimport { RENDERERS } from '../../../useTable3';\nimport { isElementTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableRef } from '../../../../../primitives/Table/types';\nimport { TEMPORARY_ROW_ID_PREFIX } from '../../../util/editing';\n\ntype TemporaryRowProps<TType = unknown> = {\n createRowButtonRef: React.RefObject<HTMLButtonElement>;\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function TemporaryRow<TType = unknown>(props: TemporaryRowProps<TType>) {\n const { createRowButtonRef, table, tableMeta, tableRef } = props;\n\n const handleKeyDown = async (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (!isElementTriggeredFromContainer(event.target as Element, event.currentTarget)) {\n const saved = await tableMeta.editing.saveChanges(table);\n\n if (saved) {\n createRowButtonRef.current?.focus();\n }\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n\n if (tableRef.current) {\n const availableRows = Array.from(\n tableRef.current.querySelectorAll(`tbody tr:not([data-row-id^='${TEMPORARY_ROW_ID_PREFIX}'])`) ?? []\n );\n\n const footerHeight = tableRef.current.querySelector('tfoot')?.getBoundingClientRect().height ?? 0;\n const newRowHeight = event.currentTarget.getBoundingClientRect().height;\n const visibleHeight = tableRef.current.clientHeight - footerHeight - newRowHeight;\n const tableTopOffset = tableRef.current.getBoundingClientRect().top;\n\n let nextRowIndex;\n\n // iterate available rows in reverse order, since we're working at the bottom\n for (let index = availableRows.length - 1; index >= 0; index--) {\n const rowRect = availableRows[index].getBoundingClientRect();\n const topPlusHalfRow = rowRect.top + rowRect.height / 2;\n\n if (topPlusHalfRow - tableTopOffset <= visibleHeight) {\n nextRowIndex = index;\n break;\n }\n }\n\n if (nextRowIndex) {\n tableMeta.rowActive.setRowActiveIndex(\n Number(availableRows[nextRowIndex < 0 ? 0 : nextRowIndex].getAttribute('data-row-index'))\n );\n }\n }\n }\n };\n\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key === 'ArrowLeft' && tableMeta.editing.lastFocusedCellIndex === 0) {\n event.preventDefault();\n event.stopPropagation();\n } else if (event.key === 'ArrowRight' && tableMeta.editing.lastFocusedCellIndex) {\n if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n };\n\n const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;\n\n const className = clsx('group/row border-grey-300 !sticky z-[22]', {\n 'bottom-[calc(5rem_+_3px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,\n 'bottom-[calc(2.5rem_+_3px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,\n 'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled,\n });\n\n return (\n <>\n {table.getBottomRows().map(row => (\n <Row<TType>\n key={row.id}\n cellRenderer={RENDERERS.cell}\n index={tableMeta.length}\n measureRow={() => null}\n renderer={RENDERERS.row}\n row={row}\n table={table}\n className={className}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={handleKeyDownCapture}\n hideInternalColumns\n hideRowActions={!tableMeta.editing.isEditing}\n />\n ))}\n </>\n );\n}\n"],"names":["TemporaryRow","props","createRowButtonRef","table","tableMeta","tableRef","handleKeyDown","event","key","preventDefault","_temp","isElementTriggeredFromContainer","target","currentTarget","Promise","resolve","editing","saveChanges","then","saved","_createRowButtonRef$c","current","focus","stopPropagation","_tableRef$current$que","_tableRef$current$que2","_tableRef$current$que3","availableRows","Array","from","querySelectorAll","TEMPORARY_ROW_ID_PREFIX","footerHeight","querySelector","getBoundingClientRect","height","newRowHeight","visibleHeight","clientHeight","tableTopOffset","top","nextRowIndex","index","length","rowRect","topPlusHalfRow","rowActive","setRowActiveIndex","Number","getAttribute","_temp2","e","reject","handleKeyDownCapture","lastFocusedCellIndex","getVisibleFlatColumns","isScrolled","scrollHeight","className","clsx","footer","isEnabled","React","getBottomRows","map","row","Row","id","cellRenderer","RENDERERS","cell","measureRow","renderer","onKeyDown","onKeyDownCapture","hideInternalColumns","hideRowActions","isEditing"],"mappings":";;;;;;;SAgBgBA,YAAYA,CAAkBC,KAA+B;EACzE,MAAM;IAAEC,kBAAkB;IAAEC,KAAK;IAAEC,SAAS;IAAEC;GAAU,GAAGJ,KAAK;EAEhE,MAAMK,aAAa,aAAUC,KAA+C;IAAA;;YACpEA,KAAK,CAACC,GAAG,KAAK,WAAW;UACzBD,KAAK,CAACE,cAAc,EAAE;UAAC,MAAAC,KAAA;YAAA,IAEnB,CAACC,+BAA+B,CAACJ,KAAK,CAACK,MAAiB,EAAEL,KAAK,CAACM,aAAa,CAAC;cAAA,OAAAC,OAAA,CAAAC,OAAA,CAC1DX,SAAS,CAACY,OAAO,CAACC,WAAW,CAACd,KAAK,CAAC,EAAAe,IAAA,WAAlDC,KAAK;gBAAA,IAEPA,KAAK;kBAAA,IAAAC,qBAAA;kBACL,CAAAA,qBAAA,GAAAlB,kBAAkB,CAACmB,OAAO,cAAAD,qBAAA,uBAA1BA,qBAAA,CAA4BE,KAAK,EAAE;;;;;UAAC,IAAAZ,KAAA,IAAAA,KAAA,CAAAQ,IAAA,SAAAR,KAAA,CAAAQ,IAAA;eAGzC,IAAIX,KAAK,CAACC,GAAG,KAAK,SAAS,EAAE;UAChCD,KAAK,CAACE,cAAc,EAAE;UACtBF,KAAK,CAACgB,eAAe,EAAE;UAEvB,IAAIlB,QAAQ,CAACgB,OAAO,EAAE;YAAA,IAAAG,qBAAA,EAAAC,sBAAA,EAAAC,sBAAA;YAClB,MAAMC,aAAa,GAAGC,KAAK,CAACC,IAAI,EAAAL,qBAAA,GAC5BnB,QAAQ,CAACgB,OAAO,CAACS,gBAAgB,CAAC,+BAA+BC,uBAAuB,KAAK,CAAC,cAAAP,qBAAA,cAAAA,qBAAA,GAAI,EAAE,CACvG;YAED,MAAMQ,YAAY,IAAAP,sBAAA,IAAAC,sBAAA,GA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nBC,cAAc,EAAE,CAACxE,SAAS,CAACY,OAAO,CAAC6D;IACrC,CACL,CAAC,CACH;AAEX;;;;"}
@@ -122,7 +122,7 @@ function reducer(state, action) {
122
122
  }
123
123
  };
124
124
  }
125
- case 'createRow':
125
+ case 'insertTemporaryRow':
126
126
  {
127
127
  const {
128
128
  value
@@ -409,14 +409,14 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
409
409
  }
410
410
  });
411
411
  }
412
- function createRow(data) {
412
+ function insertTemporaryRow(data) {
413
413
  const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${v4()}`;
414
414
  const value = {
415
415
  ...data,
416
416
  [rowIdentityAccessor]: newRowId
417
417
  };
418
418
  dispatch({
419
- type: 'createRow',
419
+ type: 'insertTemporaryRow',
420
420
  rowId: newRowId,
421
421
  payload: {
422
422
  value
@@ -510,7 +510,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
510
510
  discardChanges,
511
511
  hasSaved,
512
512
  // new rows
513
- createRow,
513
+ insertTemporaryRow,
514
514
  temporaryRows: state.temporaryRows
515
515
  };
516
516
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useEditingState.js","sources":["../../../../../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, Cell as ReactTableCell } from '@tanstack/react-table';\nimport { v4 as uuid } from 'uuid';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { isTemporaryRow, TEMPORARY_ROW_ID_PREFIX, willRowMove } from '../util/editing';\nimport { useLocalization } from '../../Provider/Localization';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n status: Record<string, EditingSaveState>;\n };\n temporaryRows: TType[];\n};\ntype EditingStateAction = {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'createRow';\n rowId: string;\n payload?: any;\n};\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, rowId, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, rowId, row, Object),\n },\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${rowId}.${columnId}`);\n\n // if there are no changes left, remove the row\n if (!Object.keys(changes[rowId]).length) {\n return reducer(state, { type: 'removeRow', rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, moveReasons, original, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${rowId}.cells`,\n cellErrors ?? state.changes.errors.cells[rowId],\n Object\n ),\n originals: setWith(state.changes.originals, rowId, original ?? state.changes.originals[rowId], Object),\n moveReasons: setWith(\n state.changes.moveReasons,\n rowId,\n moveReasons ?? state.changes.moveReasons[rowId],\n Object\n ),\n // status can be undefined, so don't use ??\n status: setWith(state.changes.status, rowId, undefined, Object),\n },\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, rowId),\n errors: omit(state.changes.errors, rowId),\n moveReasons: omit(state.changes.moveReasons, rowId),\n originals: omit(state.changes.originals, rowId),\n status: omit(state.changes.status, rowId),\n },\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId),\n };\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n status: status ? setWith(state.changes.status, rowId, status, Object) : omit(state.changes.status, rowId),\n },\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, rowId, errors, Object),\n },\n };\n }\n\n case 'createRow': {\n const { value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n originals: setWith(state.changes.originals, rowId, value, Object),\n },\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },\n temporaryRows: [],\n });\n\n // rows\n async function setRowValue<T extends TType>(rowId: string, original: T, value: Partial<T>) {\n let cellErrors;\n\n if (validator) {\n const row = { ...original, ...value } as T;\n cellErrors = ((await validator(row)) ?? {}) as Record<string, string>;\n }\n\n dispatch({\n type: 'updateRow',\n rowId,\n payload: { cellErrors, original, value },\n });\n }\n\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function hasTemporaryRowErrors<T extends TType>() {\n const newRow = state.temporaryRows?.[0] as T | undefined;\n\n if (!newRow) {\n return false;\n }\n\n const rowId = newRow[rowIdentityAccessor as string];\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function getRowStatus(rowId: string) {\n return state.changes.status[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n function createRow<T extends TType>(data: Partial<T>) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'createRow',\n rowId: newRowId,\n payload: { value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number, shouldRunUpdaters = true) {\n const changes = state.changes.rows[cell.row.id];\n\n if (!changes) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function' && shouldRunUpdaters) {\n const previousRowValue = {\n ...state.changes.originals[cell.row.id],\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...state.changes.originals[cell.row.id],\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...state.changes.rows[cell.row.id], ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation\n let validationErrors: Record<string, string> = {};\n\n if (validator) {\n const nextRowValue = { ...state.changes.originals[cell.row.id], ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n },\n });\n }\n\n // general\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = Object.keys(state.changes.errors);\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({\n rowId,\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors: state.changes.errors[rowId],\n }));\n }\n\n function hasSaved() {\n return !!Object.values(state.changes.status).filter(value => value === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n const status = getRowStatus(rowId);\n\n try {\n // don't try to save if - already saving, or there are known errors\n if (status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...state.changes.originals[rowId], ...changes[rowId] };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (isTemporaryRow(changeSet[rowIdentityAccessor as string])) {\n delete changeSet[rowIdentityAccessor];\n }\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\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n discardChanges(rowId, table);\n\n // show the saved status, then remove it after a delay\n setRowStatus(rowId, 'saved');\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n console.error(error);\n }\n\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: string | undefined;\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 dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n table.resetRowPinning(true);\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n }\n\n return {\n // row\n setRowValue,\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n hasTemporaryRowErrors,\n getRowStatus,\n setRowStatus,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n createRow,\n temporaryRows: state.temporaryRows,\n };\n}\n"],"names":["DELAY_BEFORE_REMOVING_SAVE_STATUS","reducer","state","action","type","rowId","payload","columnId","row","value","changes","rows","setWith","Object","originals","rowIdentityAccessor","omit","keys","length","errors","moveReasons","cellErrors","original","cells","status","undefined","temporaryRows","filter","concat","usePendingChangesState","handleSave","handleChange","validator","saveChanges","table","console","warn","Promise","resolve","completed","_temp9","_forOf","getRowStatus","_catch","_temp8","_result","_exit","changeSet","then","discardChanges","setRowStatus","setTimeout","isTemporaryRow","_temp7","error","_error$response","ReferenceError","TypeError","response","rowError","Error","_error$response2","message","data","_error$response3","dispatch","shouldShowErrorAlert","_result3","e","reject","onCellChanged","cell","rowIndex","shouldRunUpdaters","cellsToActOn","column","id","updatesForOtherCells","allCells","_getAllCellsByColumnId","forEach","accessor","validationErrors","nextCellErrors","nextMoveReasons","_allCells$accessor","getIsSorted","reason","willRowMove","nextChanges","localization","_state$changes$errors11","_temp3","nextRowValue","_validator2","_temp4","_temp5","previousRowValue","_handleChange","_temp6","setRowValue","_temp","_validator","_temp2","useLocalization","React","useReducer","getRowValue","_state$changes$rows$r","_state$changes$rows","getRowMoveReason","_Object$values$","values","_state$changes$moveRe","_state$changes$moveRe2","hasRowErrors","_state$changes$errors","_state$changes$errors2","_state$changes$errors3","hasRowErrorsShownInAlert","_state$changes$errors4","hasTemporaryRowErrors","newRow","_state$temporaryRows","_state$changes$errors5","_state$changes$errors6","_state$changes$errors7","createRow","newRowId","TEMPORARY_ROW_ID_PREFIX","uuid","setCellValue","getCellValue","_state$changes$rows2","_state$changes$rows2$","getCellError","_state$changes$errors8","_state$changes$errors9","_state$changes$errors10","getErrorsShownInAlert","rowsWithErrors","map","hasSaved","hasChanges","resetRowPinning"],"mappings":";;;;;;;;AASA,MAAMA,iCAAiC,GAAG,IAAI;AAkC9C,SAASC,OAAOA,CAAkBC,KAA0B,EAAEC,MAA0B;EACpF,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC;GAAS,GAAGH,MAAM;EAEvC,QAAQC,IAAI;IACR,KAAK,cAAc;MAAE;QACjB,MAAM;UAAEG,QAAQ;UAAEC,GAAG;UAAEC;SAAO,GAAGH,OAAO;QACxC,OAAO;UACH,GAAGJ,KAAK;UACRQ,OAAO,EAAE;YACL,GAAGR,KAAK,CAACQ,OAAO;YAChBC,IAAI,EAAEC,OAAO,CAACV,K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B,cAAc;IACd6F,QAAQ;;IAERf,SAAS;IACTrG,aAAa,EAAExB,KAAK,CAACwB;GACxB;AACL;;;;"}
1
+ {"version":3,"file":"useEditingState.js","sources":["../../../../../../../../src/components/Table3/features/useEditingState.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, Cell as ReactTableCell } from '@tanstack/react-table';\nimport { v4 as uuid } from 'uuid';\nimport omit from 'lodash/omit';\nimport setWith from 'lodash/setWith';\nimport { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';\nimport { isTemporaryRow, TEMPORARY_ROW_ID_PREFIX, willRowMove } from '../util/editing';\nimport { useLocalization } from '../../Provider/Localization';\n\nconst DELAY_BEFORE_REMOVING_SAVE_STATUS = 3000;\n\ntype EditingError = {\n row: string;\n cells: Record<string, string>;\n shouldShowErrorAlert: boolean;\n};\ntype EditingRowMoveReason = Record<string, 'search' | 'sorting' | 'filter'>;\ntype EditingSaveState = 'saving' | 'saved' | 'errored';\ntype EditingChangeset<TType = unknown> = Partial<TType>;\ntype EditingState<TType = unknown> = {\n changes: {\n rows: Record<string, EditingChangeset<TType>>;\n errors: Record<string, EditingError>;\n moveReasons: Record<string, EditingRowMoveReason>;\n originals: Record<string, TType>;\n status: Record<string, EditingSaveState>;\n };\n temporaryRows: TType[];\n};\ntype EditingStateAction = {\n type:\n | 'setCellValue'\n | 'removeCellValue'\n | 'updateRow'\n | 'mergeRowValue'\n | 'removeRow'\n | 'setRowStatus'\n | 'setRowErrors'\n | 'insertTemporaryRow';\n rowId: string;\n payload?: any;\n};\n\nfunction reducer<TType = unknown>(state: EditingState<TType>, action: EditingStateAction) {\n const { type, rowId, payload } = action;\n\n switch (type) {\n case 'setCellValue': {\n const { columnId, row, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),\n originals: setWith(state.changes.originals, rowId, row, Object),\n },\n };\n }\n\n case 'removeCellValue': {\n const { columnId, rowIdentityAccessor } = payload;\n const changes = omit(state.changes.rows, `${rowId}.${columnId}`);\n\n // if there are no changes left, remove the row\n if (!Object.keys(changes[rowId]).length) {\n return reducer(state, { type: 'removeRow', rowId, payload: { rowIdentityAccessor } });\n }\n\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, `${rowId}.${columnId}`),\n errors: omit(state.changes.errors, `${rowId}.cells.${columnId}`),\n moveReasons: omit(state.changes.moveReasons, `${rowId}.${columnId}`),\n },\n };\n }\n\n case 'updateRow': {\n const { cellErrors, moveReasons, original, value } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n errors: setWith(\n state.changes.errors,\n `${rowId}.cells`,\n cellErrors ?? state.changes.errors.cells[rowId],\n Object\n ),\n originals: setWith(state.changes.originals, rowId, original ?? state.changes.originals[rowId], Object),\n moveReasons: setWith(\n state.changes.moveReasons,\n rowId,\n moveReasons ?? state.changes.moveReasons[rowId],\n Object\n ),\n // status can be undefined, so don't use ??\n status: setWith(state.changes.status, rowId, undefined, Object),\n },\n };\n }\n\n case 'removeRow': {\n const { rowIdentityAccessor } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n rows: omit(state.changes.rows, rowId),\n errors: omit(state.changes.errors, rowId),\n moveReasons: omit(state.changes.moveReasons, rowId),\n originals: omit(state.changes.originals, rowId),\n status: omit(state.changes.status, rowId),\n },\n temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId),\n };\n }\n\n case 'setRowStatus': {\n const { status } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n status: status ? setWith(state.changes.status, rowId, status, Object) : omit(state.changes.status, rowId),\n },\n };\n }\n\n case 'setRowErrors': {\n const { ...errors } = payload;\n return {\n ...state,\n changes: {\n ...state.changes,\n errors: setWith(state.changes.errors, rowId, errors, Object),\n },\n };\n }\n\n case 'insertTemporaryRow': {\n const { value } = payload;\n return {\n ...state,\n temporaryRows: state.temporaryRows.concat(value),\n changes: {\n ...state.changes,\n rows: setWith(state.changes.rows, rowId, value, Object),\n originals: setWith(state.changes.originals, rowId, value, Object),\n },\n };\n }\n\n default:\n return state;\n }\n}\n\nexport function usePendingChangesState<TType = unknown>(\n handleSave: Table3EditingSaveHandler<TType> | undefined,\n handleChange: Table3EditingChangeHandler<TType> | undefined,\n rowIdentityAccessor: keyof TType,\n validator: Table3EditingValidatorFn<TType> | undefined\n) {\n const localization = useLocalization();\n const [state, dispatch] = React.useReducer(reducer, {\n changes: { rows: {}, errors: {}, moveReasons: {}, originals: {}, status: {} },\n temporaryRows: [],\n });\n\n // rows\n async function setRowValue<T extends TType>(rowId: string, original: T, value: Partial<T>) {\n let cellErrors;\n\n if (validator) {\n const row = { ...original, ...value } as T;\n cellErrors = ((await validator(row)) ?? {}) as Record<string, string>;\n }\n\n dispatch({\n type: 'updateRow',\n rowId,\n payload: { cellErrors, original, value },\n });\n }\n\n function getRowValue(rowId: string) {\n return state.changes.rows?.[rowId] ?? undefined;\n }\n\n function getRowMoveReason(rowId: string) {\n return Object.values(state.changes.moveReasons?.[rowId] ?? {})[0] ?? undefined;\n }\n\n function hasRowErrors(rowId: string) {\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function hasRowErrorsShownInAlert(rowId: string) {\n return hasRowErrors(rowId) && !!state.changes.errors[rowId]?.shouldShowErrorAlert;\n }\n\n function hasTemporaryRowErrors<T extends TType>() {\n const newRow = state.temporaryRows?.[0] as T | undefined;\n\n if (!newRow) {\n return false;\n }\n\n const rowId = newRow[rowIdentityAccessor as string];\n return !!state.changes.errors[rowId]?.row || !!Object.keys(state.changes.errors[rowId]?.cells ?? {}).length;\n }\n\n function getRowStatus(rowId: string) {\n return state.changes.status[rowId];\n }\n\n function setRowStatus(rowId: string, status: EditingSaveState | undefined) {\n dispatch({\n type: 'setRowStatus',\n rowId,\n payload: {\n status,\n },\n });\n }\n\n function insertTemporaryRow<T extends TType>(data: Partial<T>) {\n const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid()}`;\n const value: Partial<TType> = {\n ...data,\n [rowIdentityAccessor]: newRowId,\n };\n\n dispatch({\n type: 'insertTemporaryRow',\n rowId: newRowId,\n payload: { value },\n });\n\n return newRowId;\n }\n\n // cells\n function setCellValue<T extends TType>(cell: ReactTableCell<T, unknown>, value: unknown) {\n const rowId = cell.row.id;\n const columnId = cell.column.id;\n\n // update if the change is different to the original value\n if (value !== cell.row.original[columnId]) {\n dispatch({\n type: 'setCellValue',\n rowId,\n payload: {\n columnId,\n row: cell.row.original,\n value,\n },\n });\n }\n // otherwise remove any previous change - no point saving the same value\n else if (cell.row.id in state.changes.rows) {\n dispatch({\n type: 'removeCellValue',\n rowId,\n payload: {\n columnId,\n rowIdentityAccessor,\n },\n });\n }\n }\n\n function getCellValue<T extends TType>(cell: ReactTableCell<T, unknown>): unknown | undefined {\n return state.changes.rows?.[cell.row.id]?.[cell.column.id];\n }\n\n function getCellError<T extends TType>(cell: ReactTableCell<T, unknown>): string | undefined {\n return state.changes.errors?.[cell.row.id]?.cells?.[cell.column.id];\n }\n\n async function onCellChanged<T extends TType>(cell: ReactTableCell<T, unknown>, rowIndex: number, shouldRunUpdaters = true) {\n const changes = state.changes.rows[cell.row.id];\n\n if (!changes) {\n return;\n }\n\n let updatesForOtherCells: Partial<T> = {};\n\n // run the updater handler if there is one, to see if there are any other cells to update\n if (typeof handleChange === 'function' && shouldRunUpdaters) {\n const previousRowValue = {\n ...state.changes.originals[cell.row.id],\n //...getRowChangeset(updatersRef.current[cell.row.id], rowIdentityAccessor),\n };\n const nextRowValue = {\n ...state.changes.originals[cell.row.id],\n ...changes,\n };\n updatesForOtherCells = ((await handleChange(\n cell.column.id,\n changes[cell.column.id],\n nextRowValue,\n previousRowValue\n )) ?? {}) as Partial<T>;\n }\n\n // create a projection of the next state, so we can act against it\n const nextChanges = { ...state.changes.rows[cell.row.id], ...updatesForOtherCells };\n const nextMoveReasons: EditingRowMoveReason = { ...state.changes.moveReasons[cell.row.id] };\n const nextCellErrors: Record<string, string> = { ...state.changes.errors[cell.row.id]?.cells };\n\n // run validation\n let validationErrors: Record<string, string> = {};\n\n if (validator) {\n const nextRowValue = { ...state.changes.originals[cell.row.id], ...changes, ...updatesForOtherCells };\n validationErrors = ((await validator(nextRowValue)) ?? {}) as Record<string, string>;\n }\n\n // only set errors and move reasons for the cells we're currently acting on\n // why? because the UX is not good if we set them for cells the user hasn't touched yet\n const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];\n const allCells = cell.row._getAllCellsByColumnId();\n\n cellsToActOn.forEach(accessor => {\n if (validationErrors[accessor]) {\n nextCellErrors[accessor] = validationErrors[accessor];\n // don't show move indicator for cells with errors, they aren't valid and can't be saved\n delete nextMoveReasons[accessor];\n } else {\n // there isn't any error in this run, remove any error set in state\n delete nextCellErrors[accessor];\n\n if (allCells[accessor]?.column.getIsSorted()) {\n // run row move determination\n const reason = willRowMove(cell, nextChanges[accessor], rowIndex, localization);\n\n // if the row will move based on this change save why, otherwise delete any existing state\n if (reason) {\n nextMoveReasons[accessor] = reason;\n } else {\n delete nextMoveReasons[accessor];\n }\n }\n }\n });\n\n dispatch({\n type: 'updateRow',\n rowId: cell.row.id,\n payload: {\n cellErrors: nextCellErrors,\n moveReasons: nextMoveReasons,\n value: nextChanges,\n },\n });\n }\n\n // general\n function getErrorsShownInAlert<T extends TType>() {\n const rowsWithErrors = Object.keys(state.changes.errors);\n\n if (!rowsWithErrors.length) {\n return [];\n }\n\n return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({\n rowId,\n changes: state.changes.rows[rowId] as EditingChangeset<T>,\n errors: state.changes.errors[rowId],\n }));\n }\n\n function hasSaved() {\n return !!Object.values(state.changes.status).filter(value => value === 'saved').length;\n }\n\n function hasChanges(rowId?: string) {\n return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;\n }\n\n async function saveChanges<T extends TType>(table: ReactTable<T>, rowId: string | undefined = undefined): Promise<boolean> {\n if (!handleSave) {\n console.warn('Tried to save, but Table has no onEditingSave handler');\n return false;\n }\n\n // sometimes we only want to save one row\n const changes = rowId ? { [rowId]: state.changes.rows[rowId] } : state.changes.rows;\n\n let completed = true;\n\n for (const rowId of Object.keys(changes)) {\n const status = getRowStatus(rowId);\n\n try {\n // don't try to save if - already saving, or there are known errors\n if (status === 'saving' || status === 'errored') {\n continue;\n }\n\n setRowStatus(rowId, 'saving');\n\n const changeSet = { ...state.changes.originals[rowId], ...changes[rowId] };\n\n // if we had to create a temporary id, delete it first - it's our data, not theirs\n if (isTemporaryRow(changeSet[rowIdentityAccessor as string])) {\n delete changeSet[rowIdentityAccessor];\n }\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\n // send new data to the server\n await handleSave(changeSet);\n\n // cleanup changes, we don't need them after saving\n discardChanges(rowId, table);\n\n // show the saved status, then remove it after a delay\n setRowStatus(rowId, 'saved');\n setTimeout(() => {\n setRowStatus(rowId, undefined);\n }, DELAY_BEFORE_REMOVING_SAVE_STATUS);\n } catch (error) {\n if (error instanceof ReferenceError || error instanceof TypeError || (error as any)?.response?.status >= 500) {\n console.error(error);\n }\n\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: string | undefined;\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 dispatch({\n type: 'setRowErrors',\n rowId,\n payload: {\n row: rowError,\n cells: cellErrors,\n shouldShowErrorAlert: true,\n },\n });\n }\n\n setRowStatus(rowId, 'errored');\n completed = false;\n }\n }\n\n return completed;\n }\n\n function discardChanges<T extends TType>(rowId: string, table: ReactTable<T>) {\n // remove any new rows from pinned state before discarding them\n table.resetRowPinning(true);\n\n dispatch({\n type: 'removeRow',\n rowId,\n payload: { rowIdentityAccessor },\n });\n }\n\n return {\n // row\n setRowValue,\n getRowValue,\n getRowMoveReason,\n hasRowErrors,\n hasRowErrorsShownInAlert,\n hasTemporaryRowErrors,\n getRowStatus,\n setRowStatus,\n // cells\n setCellValue,\n getCellValue,\n getCellError,\n onCellChanged,\n // general\n getErrorsShownInAlert,\n hasChanges,\n saveChanges,\n discardChanges,\n hasSaved,\n // new rows\n insertTemporaryRow,\n temporaryRows: state.temporaryRows,\n };\n}\n"],"names":["DELAY_BEFORE_REMOVING_SAVE_STATUS","reducer","state","action","type","rowId","payload","columnId","row","value","changes","rows","setWith","Object","originals","rowIdentityAccessor","omit","keys","length","errors","moveReasons","cellErrors","original","cells","status","undefined","temporaryRows","filter","concat","usePendingChangesState","handleSave","handleChange","validator","saveChanges","table","console","warn","Promise","resolve","completed","_temp9","_forOf","getRowStatus","_catch","_temp8","_result","_exit","changeSet","then","discardChanges","setRowStatus","setTimeout","isTemporaryRow","_temp7","error","_error$response","ReferenceError","TypeError","response","rowError","Error","_error$response2","message","data","_error$response3","dispatch","shouldShowErrorAlert","_result3","e","reject","onCellChanged","cell","rowIndex","shouldRunUpdaters","cellsToActOn","column","id","updatesForOtherCells","allCells","_getAllCellsByColumnId","forEach","accessor","validationErrors","nextCellErrors","nextMoveReasons","_allCells$accessor","getIsSorted","reason","willRowMove","nextChanges","localization","_state$changes$errors11","_temp3","nextRowValue","_validator2","_temp4","_temp5","previousRowValue","_handleChange","_temp6","setRowValue","_temp","_validator","_temp2","useLocalization","React","useReducer","getRowValue","_state$changes$rows$r","_state$changes$rows","getRowMoveReason","_Object$values$","values","_state$changes$moveRe","_state$changes$moveRe2","hasRowErrors","_state$changes$errors","_state$changes$errors2","_state$changes$errors3","hasRowErrorsShownInAlert","_state$changes$errors4","hasTemporaryRowErrors","newRow","_state$temporaryRows","_state$changes$errors5","_state$changes$errors6","_state$changes$errors7","insertTemporaryRow","newRowId","TEMPORARY_ROW_ID_PREFIX","uuid","setCellValue","getCellValue","_state$changes$rows2","_state$changes$rows2$","getCellError","_state$changes$errors8","_state$changes$errors9","_state$changes$errors10","getErrorsShownInAlert","rowsWithErrors","map","hasSaved","hasChanges","resetRowPinning"],"mappings":";;;;;;;;AASA,MAAMA,iCAAiC,GAAG,IAAI;AAkC9C,SAASC,OAAOA,CAAkBC,KAA0B,EAAEC,MAA0B;EACpF,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC;GAAS,GAAGH,MAAM;EAEvC,QAAQC,IAAI;IACR,KAAK,cAAc;MAAE;QACjB,MAAM;UAAEG,QAAQ;UAAEC,GAAG;UAAEC;SAAO,GAAGH,OAAO;QACxC,OAAO;UACH,GAAGJ,KAAK;UACRQ,OAAO,EAAE;YACL,GAAGR,KAAK,CAACQ,OAAO;YAChBC,IAAI,EAAEC,OAAO,CAACV,KAAK,CAACQ,OAAO,CAACC,IAAI,EAAE,GAAGN,KAAK,IAAIE,QAAQ,EAAE,EAAEE,KAAK,EAAEI,MAAM,CAAC;YACxEC,SAAS,EAAEF,OAAO,CAACV,KAAK,CAACQ,OAAO,CAACI,SAAS,EAAET,KAAK,EAAEG,GAAG,EAAEK,MAAM;;SAErE;;IAGL,KAAK,iBAAiB;MAAE;QACpB,MAAM;UAAEN,QAAQ;UAAEQ;SAAqB,GAAGT,OAAO;QACjD,MAAMI,OAAO,GAAGM,IAAI,CAACd,KAAK,CAACQ,OAAO,CAACC,IAAI,EAAE,GAAGN,KAAK,IAAIE,QAAQ,EAAE,CAAC;;QAGhE,IAAI,CAACM,MAAM,CAACI,IAAI,CAACP,OAAO,CAACL,KAAK,CAAC,CAAC,CAACa,MAAM,EAAE;UACrC,OAAOjB,OAAO,CAACC,KAAK,EAAE;YAAEE,IAAI,EAAE,WAAW;YAAEC,KAA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