@economic/taco 2.17.0 → 2.17.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +2 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +7 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/taco.cjs.development.js +9 -3
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -67,7 +67,7 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Select2TriggerBut
|
|
67
67
|
disabled: disabled,
|
68
68
|
onClick: handleClick,
|
69
69
|
ref: ref,
|
70
|
-
role: "
|
70
|
+
role: "combobox",
|
71
71
|
tabIndex: disabled || readOnly ? -1 : tabIndex,
|
72
72
|
type: "button"
|
73
73
|
}), children, /*#__PURE__*/React__default.createElement(Icon, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer !px-1.5',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly }).replace('w-full', ''),\n { 'w-full': !props.className?.includes('w-') },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"button\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== undefined && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.prefix}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.prefix ? (\n typeof currentValue.props.prefix === 'string' ? (\n <Icon name={currentValue.props.prefix} className=\"mr-1 !h-5 !w-5\" />\n ) : (\n currentValue.props.prefix\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className={cn('relative inline-flex flex-grow', { 'h-8': open })}\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","_props$className","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","prefix","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;MAoBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS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AAK,EAAE/B,gBAAgB,CAClBgC,KAAK,CAACX,aAAa,GAAG,CAAC,CAAC,CACxBpB,GAAG,CAACM,KAAK,IAAKA,KAAK,GAAGE,MAAM,CAACF,KAAK,CAAC7D,KAAK,CAACa,QAAQ,CAAC,GAAG,EAAG,CAAC,CACzD0E,IAAI,CAAC,IAAI;kBACd1F,6BAAC2F,KAAK;IAAClE,SAAS,EAAC;UAAkBgC,gBAAgB,CAACM,MAAM,IAAIe,aAAa,GAAG,CAAC,CAAC,CAAS,CACnF,IACV,IAAI,CACN;AAEd,CAAC;AAED,MAAMhC,YAAY,GAAIxC,KAA8B,IAAM0D,KAA8B;EACpF,IAAIxD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACwB,QAAQ,CAACkC,KAAK,CAAC7D,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAO0D,KAAK,CAAC7D,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n emptyValue?: Select2OptionValue;\n placeholder?: string;\n children: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer !px-1.5',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly }).replace('w-full', ''),\n { 'w-full': !props.className?.includes('w-') },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"pointer-events-none -mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue; placeholder?: string };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, emptyValue, value, placeholder, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate items-center gap-1');\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (placeholder && currentValue === undefined) {\n output = <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>;\n } else if (currentValue) {\n if (tags && emptyValue !== undefined && emptyValue !== value) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.prefix}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.prefix ? (\n typeof currentValue.props.prefix === 'string' ? (\n <Icon name={currentValue.props.prefix} className=\"mr-1 !h-5 !w-5\" />\n ) : (\n currentValue.props.prefix\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <div className={contentClassName}>{output}</div>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, emptyValue: _, values = [], placeholder, ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values\n .map(value => children.find(c => c.props.value === value))\n .filter(c => !!c) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map(child => (\n <Tag\n key={String(child.props.value)}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))\n )}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} placeholder={placeholder} />;\n }\n\n return (\n <div\n className={cn('relative inline-flex flex-grow', { 'h-8': open })}\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\ntype MultipleValueProps = Omit<Select2TriggerProps, 'value' | 'children'> & {\n valuesAsChildren: React.ReactElement<Select2OptionProps>[];\n placeholder?: string;\n};\n\nconst MultipleValue = ({ valuesAsChildren, placeholder }: MultipleValueProps) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\n {valuesAsChildren.length === 0 ? (\n <div className={cn({ 'text-grey-700': disabled, 'text-grey-500': !disabled })}>{placeholder}</div>\n ) : (\n valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={String(child.props.value)}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.prefix}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={String(child.props.value)} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })\n )}\n </div>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </div>\n );\n};\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","_props$className","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","emptyValue","placeholder","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","prefix","Select2TriggerMultiple","_","setValue","buttonRef","useMergedRef","valuesAsChildren","map","c","filter","content","ScrollArea","length","child","key","String","onDelete","stopPropagation","MultipleValue","style","width","_buttonRef$current","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","slice","join","Badge"],"mappings":";;;;;;;;;;;;MAoBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAcA,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,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F,KAAK,CAAC7D,KAAK,CAACa,QAAQ,CAAC,GAAG,EAAG,CAAC,CACzD0E,IAAI,CAAC,IAAI;kBACd1F,6BAAC2F,KAAK;IAAClE,SAAS,EAAC;UAAkBgC,gBAAgB,CAACM,MAAM,IAAIe,aAAa,GAAG,CAAC,CAAC,CAAS,CACnF,IACV,IAAI,CACN;AAEd,CAAC;AAED,MAAMhC,YAAY,GAAIxC,KAA8B,IAAM0D,KAA8B;EACpF,IAAIxD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACwB,QAAQ,CAACkC,KAAK,CAAC7D,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAO0D,KAAK,CAAC7D,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
@@ -70,7 +70,8 @@ const Table = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
70
70
|
const handleKeyDown = event => {
|
71
71
|
const target = event.target;
|
72
72
|
const dialog = target.closest('[role="dialog"]');
|
73
|
-
|
73
|
+
// Select2 also have combobox role to align with W3C guidelines
|
74
|
+
const eventOriginatedFromCombobox = !!target.closest('[role="combobox"]:not([data-taco="Select2"])');
|
74
75
|
// Don't trigger global shortcuts on the table if event originated from a combobox or if table is
|
75
76
|
// outside the dialog
|
76
77
|
if (eventOriginatedFromCombobox || dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(internalRef.current)) || tableMeta.shortcutsState.isPaused) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3GroupProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\nimport { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle';\nimport { FONT_SIZE } from './components/toolbar/FontSize';\nimport { ErrorAlert } from './components/alert/ErrorAlert';\nimport { fixedForwardRef } from '../../types';\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 Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const {\n emptyState: EmptyState,\n customSettings,\n toolbarLeft,\n toolbarRight,\n defaultCurrentRowIndex: defaultRowActiveIndex,\n } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props, internalRef);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n // On a very first render, the tanstack table rendered without any rows,\n // so we delaying default row scrolling logic with using of requestAnimation frame\n const animationFrameId = requestAnimationFrame(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center' });\n }\n });\n\n return () => {\n cancelAnimationFrame(animationFrameId);\n };\n }, []);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (\n eventOriginatedFromCombobox ||\n (dialog && !dialog?.contains(internalRef.current)) ||\n tableMeta.shortcutsState.isPaused\n ) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n\n tableMeta.rowActive.handleKeyDown(\n event,\n rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing ? undefined : internalRef\n );\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n tableMeta.rowClick.handleKeyDown(event, rows[tableMeta.rowActive.rowActiveIndex]?.original);\n }\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current, tableMeta.rowActive.rowActiveIndex]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.rowActive.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n // mouse capture fires before focus, so we can prevent propagation and stop double setting of the active row\n const handleMouseCapture =\n tableMeta.rowActive.rowActiveIndex === undefined\n ? (event: React.MouseEvent) => {\n tableMeta.rowActive.handleMouseCapture(event, table.getRowModel().rows.length);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === FONT_SIZE.small,\n 'text-sm': tableMeta.fontSize.size === FONT_SIZE.medium,\n 'text-base': tableMeta.fontSize.size === FONT_SIZE.large,\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(\n table,\n tableMeta.printing.isPrinting,\n tableMeta.rowActions.actionsForRowLength,\n tableMeta.fontSize.size\n );\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n {headerOffsetStyle && !tableMeta.printing.isPrinting ? (\n <style data-taco=\"table3-column-header-offset-styles\">{headerOffsetStyle}</style>\n ) : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <ErrorAlert table={table} tableRef={internalRef} scrollToIndex={scrollToIndex} rowIdentifier={props.rowIdentifier} />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.rowActive.isHoverStatePaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map((header, index) => {\n // We need to render separator if column is not the last in array, if index is not equal to freeze column index,\n // if next element is not placeholder and if column itself is not placeholder.\n const hasSeparator =\n index !== tableMeta.columnFreezing.frozenColumnIndex &&\n index !== headerGroup.headers.length - 1 &&\n (!headerGroup.headers[index + 1]?.isPlaceholder || !header.isPlaceholder);\n return (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, {\n ...header.getContext(),\n scrollToIndex,\n hasSeparator,\n })}\n </React.Fragment>\n );\n })}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div\n onMouseDownCapture={handleMouseCapture}\n className=\"group/body contents\"\n data-taco=\"table2-body\"\n role=\"rowgroup\"\n ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div className=\"border-grey-300 col-span-full translate-y-px border-t\" />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {\n // Render the footer cell only for individual columns, excluding column groups.\n table\n .getFooterGroups()\n .slice(0, 1)\n .map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))\n }\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\nTable3.Group = Group;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3FontSize,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","displayName","Group","Table","fixedForwardRef","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","defaultCurrentRowIndex","defaultRowActiveIndex","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","React","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","animationFrameId","requestAnimationFrame","align","cancelAnimationFrame","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","shortcutsState","isPaused","rows","getRowModel","rowActive","editing","isEditing","undefined","rowActiveIndex","_rows$tableMeta$rowAc","rowClick","original","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","handleFocus","handleMouseCapture","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","FONT_SIZE","small","medium","large","style","cssGridStyle","useCssGrid","printing","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","headerOffsetStyle","useHeaderOffsetStyle","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","ErrorAlert","tableRef","rowIdentifier","horizontallyScrolled","isHoverStatePaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","index","hasSeparator","frozenColumnIndex","_headerGroup$headers","isPlaceholder","Fragment","flexRender","column","columnDef","getContext","FocusScope","onMouseDownCapture","enableFooter","getFooterGroups","slice","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,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,KAAK,gBAAGC,eAAe,CAAC,SAAS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S,EAAC;KAA0CjE,UAAU,gBAAGY,6BAACZ,UAAU,OAAG,GAAG,IAAI,CAAO,CACrG,CACC,CACP;AAEX,CAAC,CAAC;MAOWJ,MAAM,gBAAGD,eAAe,CAAC,SAASC,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EACvH,MAAMwI,mBAAmB,GAAGC,MAAM,CAAC1I,KAAK,CAAC2I,QAAQ,CAAC;;;EAGlD,MAAMxB,GAAG,GAAGpG,cAAK,CAAC6H,OAAO,CAAC,MAAMF,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAO1H,6BAAClB,KAAK,oBAAYG,KAAK;IAAEmH,GAAG,EAAEA,GAAG;IAAElH,GAAG,EAAEA;KAAO;AAC1D,CAAC;AACDF,MAAM,CAACN,MAAM,GAAGA,MAAM;AACtBM,MAAM,CAACH,KAAK,GAAGA,KAAK;;;;"}
|
1
|
+
{"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3GroupProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\nimport { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle';\nimport { FONT_SIZE } from './components/toolbar/FontSize';\nimport { ErrorAlert } from './components/alert/ErrorAlert';\nimport { fixedForwardRef } from '../../types';\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 Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const {\n emptyState: EmptyState,\n customSettings,\n toolbarLeft,\n toolbarRight,\n defaultCurrentRowIndex: defaultRowActiveIndex,\n } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props, internalRef);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n // On a very first render, the tanstack table rendered without any rows,\n // so we delaying default row scrolling logic with using of requestAnimation frame\n const animationFrameId = requestAnimationFrame(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center' });\n }\n });\n\n return () => {\n cancelAnimationFrame(animationFrameId);\n };\n }, []);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n // Select2 also have combobox role to align with W3C guidelines\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]:not([data-taco=\"Select2\"])');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (\n eventOriginatedFromCombobox ||\n (dialog && !dialog?.contains(internalRef.current)) ||\n tableMeta.shortcutsState.isPaused\n ) {\n return;\n }\n\n const rows = table.getRowModel().rows;\n\n tableMeta.rowActive.handleKeyDown(\n event,\n rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing ? undefined : internalRef\n );\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n tableMeta.rowClick.handleKeyDown(event, rows[tableMeta.rowActive.rowActiveIndex]?.original);\n }\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current, tableMeta.rowActive.rowActiveIndex]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.rowActive.rowActiveIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.rowActive.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n // mouse capture fires before focus, so we can prevent propagation and stop double setting of the active row\n const handleMouseCapture =\n tableMeta.rowActive.rowActiveIndex === undefined\n ? (event: React.MouseEvent) => {\n tableMeta.rowActive.handleMouseCapture(event, table.getRowModel().rows.length);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === FONT_SIZE.small,\n 'text-sm': tableMeta.fontSize.size === FONT_SIZE.medium,\n 'text-base': tableMeta.fontSize.size === FONT_SIZE.large,\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(\n table,\n tableMeta.printing.isPrinting,\n tableMeta.rowActions.actionsForRowLength,\n tableMeta.fontSize.size\n );\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n {headerOffsetStyle && !tableMeta.printing.isPrinting ? (\n <style data-taco=\"table3-column-header-offset-styles\">{headerOffsetStyle}</style>\n ) : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <ErrorAlert table={table} tableRef={internalRef} scrollToIndex={scrollToIndex} rowIdentifier={props.rowIdentifier} />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.rowActive.isHoverStatePaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map((header, index) => {\n // We need to render separator if column is not the last in array, if index is not equal to freeze column index,\n // if next element is not placeholder and if column itself is not placeholder.\n const hasSeparator =\n index !== tableMeta.columnFreezing.frozenColumnIndex &&\n index !== headerGroup.headers.length - 1 &&\n (!headerGroup.headers[index + 1]?.isPlaceholder || !header.isPlaceholder);\n return (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, {\n ...header.getContext(),\n scrollToIndex,\n hasSeparator,\n })}\n </React.Fragment>\n );\n })}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div\n onMouseDownCapture={handleMouseCapture}\n className=\"group/body contents\"\n data-taco=\"table2-body\"\n role=\"rowgroup\"\n ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div className=\"border-grey-300 col-span-full translate-y-px border-t\" />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {\n // Render the footer cell only for individual columns, excluding column groups.\n table\n .getFooterGroups()\n .slice(0, 1)\n .map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))\n }\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\nTable3.Group = Group;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3FontSize,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","displayName","Group","Table","fixedForwardRef","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","defaultCurrentRowIndex","defaultRowActiveIndex","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","React","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","animationFrameId","requestAnimationFrame","align","cancelAnimationFrame","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","shortcutsState","isPaused","rows","getRowModel","rowActive","editing","isEditing","undefined","rowActiveIndex","_rows$tableMeta$rowAc","rowClick","original","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","handleFocus","handleMouseCapture","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","FONT_SIZE","small","medium","large","style","cssGridStyle","useCssGrid","printing","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","headerOffsetStyle","useHeaderOffsetStyle","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","ErrorAlert","tableRef","rowIdentifier","horizontallyScrolled","isHoverStatePaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","index","hasSeparator","frozenColumnIndex","_headerGroup$headers","isPlaceholder","Fragment","flexRender","column","columnDef","getContext","FocusScope","onMouseDownCapture","enableFooter","getFooterGroups","slice","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,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,KAAK,gBAAGC,eAAe,CAAC,SAASC,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EAC/G,MAAM;IACFC,UAAU,EAAEC,UAAU;IACtBC,cAAc;IACdC,WAAW;IACXC,YAAY;IACZC,sBAAsB,EAAEC;GAC3B,GAAGR,KAAK;EACT,MAAMS,WAAW,GAAGC,YAAY,CAAYT,GAAG,CAAC;EAEhD,MAAM;IAAEU,KAAK;IAAEC;GAAQ,GAAGC,QAAQ,CAAQb,KAAK,EAAES,WAAW,CAAC;EAC7DK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H,OAAO,CAAC,MAAMF,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAO1H,6BAAClB,KAAK,oBAAYG,KAAK;IAAEmH,GAAG,EAAEA,GAAG;IAAElH,GAAG,EAAEA;KAAO;AAC1D,CAAC;AACDF,MAAM,CAACN,MAAM,GAAGA,MAAM;AACtBM,MAAM,CAACH,KAAK,GAAGA,KAAK;;;;"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import cn from 'classnames';
|
3
3
|
import { Field } from '../../../../Field/Field.js';
|
4
|
-
import { useRowContext } from '../../rows/RowContext.js';
|
4
|
+
import { useRowContext, RowContext } from '../../rows/RowContext.js';
|
5
5
|
import { Highlight } from './Highlight.js';
|
6
6
|
import { getCurrentRowCellElement } from '../../../util/columns.js';
|
7
7
|
import { globalFilterFn, columnFilterFn } from '../../../util/filtering.js';
|
@@ -42,6 +42,9 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
42
42
|
highlighted,
|
43
43
|
highlightedAsCurrent
|
44
44
|
} = props;
|
45
|
+
const {
|
46
|
+
rowIndex
|
47
|
+
} = React__default.useContext(RowContext);
|
45
48
|
const columnMeta = column.columnDef.meta;
|
46
49
|
const cellRef = React__default.useRef(null);
|
47
50
|
const controlRef = React__default.useRef(null);
|
@@ -107,7 +110,9 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
107
110
|
return;
|
108
111
|
}
|
109
112
|
if (hasChanged(getValue(), value)) {
|
110
|
-
const moveReason = getRowMoveReason(table,
|
113
|
+
const moveReason = getRowMoveReason(table, rowIndex,
|
114
|
+
// cannot use row.index, as this is not kept in sync once a column is sorted.
|
115
|
+
row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
|
111
116
|
tableMeta.editing.setRowMoveReason({
|
112
117
|
[cell.column.id]: moveReason
|
113
118
|
});
|
package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditingCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/EditingCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport _ from 'lodash';\nimport { TableMeta, CellContext, ColumnMeta, Cell as RTCell, Table as RTTable } from '@tanstack/react-table';\nimport { Indicator, IndicatorReason } from './Indicator';\nimport { columnFilterFn, globalFilterFn } from '../../../util/filtering';\nimport { Table3ColumnControlRenderer, Table3FilterValue } from '../../../types';\nimport { hasChanged, willRowMoveAfterSorting } from '../../../util/editing';\nimport { getCurrentRowCellElement } from '../../../util/columns';\nimport { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions';\nimport { EditingControl } from './EditingControl';\nimport { useRowContext } from '../../rows/RowContext';\nimport { Field } from '../../../../Field/Field';\nimport { Highlight } from './Highlight';\n\nexport type EditingCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n};\n\nexport function EditingCell<TType = unknown>(props: EditingCellProps<TType>) {\n const { cell, table } = props;\n const { isHovered } = useRowContext();\n // Need to explicitly pass tableMeta, because just passing the table object will not trigger editing change since table object is not mutatable.\n const tableMeta = table.options.meta as TableMeta<TType>;\n const error = tableMeta.validation.getCellError(cell);\n return <MemoedEditingCell<TType> {...props} error={error} isHovered={isHovered} tableMeta={tableMeta} />;\n}\n\n// Memoization\nexport type MemoedEditingCellProps<TType = unknown> = EditingCellProps<TType> & {\n isHovered: boolean;\n tableMeta: TableMeta<TType>;\n error?: string;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const { cell, column, index, getValue, table, tableRef, row, tableMeta, error, highlighted, highlightedAsCurrent } = props;\n\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n\n const cellRef = React.useRef<HTMLDivElement>(null);\n const controlRef = React.useRef<HTMLElement>(null);\n\n const handleChange = (value: unknown) => tableMeta.editing.setCellValue(cell, value);\n const value = tableMeta.editing.getCellValue(cell) ?? getValue();\n\n const handleFocus = event => {\n // Check if cell is hidden behind pinned columns or edititng actions, and scroll to it.\n const frozenColumnIndex = tableMeta.columnFreezing.frozenColumnIndex;\n const tableElement = tableRef.current;\n\n if (tableElement && frozenColumnIndex !== undefined && index > frozenColumnIndex) {\n const lastFrozenColumnElement = getCurrentRowCellElement(frozenColumnIndex, tableElement);\n const cellRect = cellRef.current?.getBoundingClientRect();\n const lastFrozenRect = lastFrozenColumnElement?.getBoundingClientRect();\n const tableRect = tableElement.getBoundingClientRect();\n\n // Check for pinned columns overlap\n if (cellRect && lastFrozenRect && cellRect.left < lastFrozenRect.left + lastFrozenRect.width) {\n const pinnedColumnsWidth = lastFrozenRect.left + lastFrozenRect.width;\n tableElement.scrollTo(cellRect.left - pinnedColumnsWidth, tableElement.scrollTop);\n // Check for editing actions overlap\n } else if (cellRect && tableRect && cellRect.right > tableRect.right - EDITING_ACTIONS_WIDTH) {\n const spaceBetweenCellAndEditingActions = 10;\n tableElement.scrollTo(\n // Need to take into account if table has been already scrolled.\n tableElement.scrollLeft + EDITING_ACTIONS_WIDTH + spaceBetweenCellAndEditingActions,\n tableElement.scrollTop\n );\n }\n }\n\n if (event.target?.select) {\n requestAnimationFrame(() => {\n event.target.select();\n });\n }\n };\n\n const handleBlur = () => {\n tableMeta.editing.setDetailModeEditing(false);\n if (tableMeta.editing.changes?.[cell.row.id]) {\n tableMeta.validation.validate(cell.row.id, tableMeta.editing.changes[cell.row.id] as TType, cell.column.id);\n }\n };\n\n // row move indicator\n const moveReason = tableMeta.editing.rowMoveReason?.[cell.column.id] || null;\n const rows = table.getRowModel().rows;\n const isActiveRow =\n tableMeta.rowActive.rowActiveIndex !== undefined && rows[tableMeta.rowActive.rowActiveIndex]?.id === row.id;\n const mountNode = React.useMemo(() => {\n if (moveReason !== null && isActiveRow && !error) {\n return cellRef.current?.parentElement?.firstChild as Element | null;\n }\n return null;\n }, [moveReason, isActiveRow, error, cellRef]);\n\n const removeMoveReason = () => {\n tableMeta.editing.removeRowMoveReason();\n };\n\n React.useEffect(() => {\n // To avoid reseting move reason on another row hover,\n // we need to check for changes only if value got changed in the current row.\n if (!isActiveRow || error) {\n if (tableMeta.editing.rowMoveReason) {\n removeMoveReason();\n }\n return;\n }\n\n if (hasChanged(getValue(), value)) {\n const moveReason = getRowMoveReason(\n table,\n row.index,\n row.original,\n cell,\n value,\n tableMeta.search.excludeUnmatchedResults\n );\n tableMeta.editing.setRowMoveReason({ [cell.column.id]: moveReason });\n } else {\n removeMoveReason();\n }\n return removeMoveReason;\n }, [value, tableMeta.rowActive.rowActiveIndex, tableMeta.search.excludeUnmatchedResults, error]);\n\n const controlRenderer = column.columnDef.meta?.control as Table3ColumnControlRenderer;\n\n const className = cn(\n 'py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]',\n {\n // Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative\n relative: controlRenderer === 'textarea' && columnMeta.enableTruncate,\n },\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n );\n\n const fieldClassName = cn('!min-h-0 w-full !pb-0', {\n '!pb-3': !!error,\n });\n\n const content = (\n <Field message={error} invalid={!!error} className={fieldClassName}>\n <EditingControl\n align={columnMeta.align}\n column={cell.column}\n data={cell.row.original}\n initialValue={getValue()}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onChange={handleChange}\n ref={controlRef}\n table={table}\n tableRef={tableRef}\n value={value}\n cell={cell}\n error={error}\n tabIndex={isActiveRow ? 0 : -1}\n isActiveRow={isActiveRow}\n />\n </Field>\n );\n\n return (\n <>\n {moveReason !== null && mountNode && !error ? (\n <Indicator\n reason={moveReason}\n columnName={String(cell.column.columnDef.header)}\n mountNode={mountNode}\n validationErrors={[]}\n />\n ) : null}\n <div\n className={!highlighted ? className : undefined}\n data-align={columnMeta.align}\n data-column-index={index}\n role=\"cell\"\n data-editable\n ref={cellRef}\n data-invalid={!!error}\n data-highlighted={highlighted}>\n {highlighted ? (\n <Highlight\n current={highlightedAsCurrent}\n className={className}\n frozenColumnIndex={tableMeta.columnFreezing.frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n </>\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n\nfunction getRowMoveReason<TType>(\n table: RTTable<any>,\n rowIndex: number,\n rowValues: TType,\n cell: RTCell<any, unknown>,\n newValue: any,\n excludeUnmatchedResults: boolean\n) {\n let rowMoveReason: IndicatorReason | null = null;\n const { globalFilter } = table.getState();\n\n const isFilteredByGlobalFilter = excludeUnmatchedResults\n ? Object.values<unknown>({ ...rowValues, [cell.id]: newValue }).some(() => {\n // Global filter can be undefined when there is no text being searched so we pass an empty string to\n // globalFilterFn as query in that case.\n return globalFilterFn(String(newValue), globalFilter ? String(globalFilter) : '');\n })\n : true;\n\n if (!isFilteredByGlobalFilter) {\n rowMoveReason = IndicatorReason.SEARCH;\n } else if (cell.column.getIsFiltered() && !columnFilterFn(newValue, cell.column.getFilterValue() as Table3FilterValue)) {\n rowMoveReason = IndicatorReason.FILTER;\n } else if (\n !rowMoveReason &&\n cell.column.getIsSorted() &&\n willRowMoveAfterSorting(\n newValue,\n cell,\n rowIndex,\n table.getRowModel().rows,\n !!table.getState().sorting.find(s => s.id === cell.column.id)?.desc\n )\n ) {\n rowMoveReason = IndicatorReason.SORTING;\n }\n\n return rowMoveReason;\n}\n"],"names":["EditingCell","props","cell","table","isHovered","useRowContext","tableMeta","options","meta","error","validation","getCellError","React","MemoedEditingCell","memo","column","index","getValue","tableRef","row","highlighted","highlightedAsCurrent","columnMeta","columnDef","cellRef","useRef","controlRef","handleChange","value","editing","setCellValue","_tableMeta$editing$ge","getCellValue","handleFocus","event","frozenColumnIndex","columnFreezing","tableElement","current","undefined","_cellRef$current","lastFrozenColumnElement","getCurrentRowCellElement","cellRect","getBoundingClientRect","lastFrozenRect","tableRect","left","width","pinnedColumnsWidth","scrollTo","scrollTop","right","EDITING_ACTIONS_WIDTH","spaceBetweenCellAndEditingActions","scrollLeft","_event$target","target","select","requestAnimationFrame","handleBlur","setDetailModeEditing","_tableMeta$editing$ch","changes","id","validate","moveReason","_tableMeta$editing$ro","rowMoveReason","rows","getRowModel","isActiveRow","rowActive","rowActiveIndex","_rows$tableMeta$rowAc","mountNode","useMemo","_cellRef$current2","_cellRef$current2$par","parentElement","firstChild","removeMoveReason","removeRowMoveReason","useEffect","hasChanged","getRowMoveReason","original","search","excludeUnmatchedResults","setRowMoveReason","controlRenderer","_column$columnDef$met","control","className","cn","relative","enableTruncate","fieldClassName","content","Field","message","invalid","EditingControl","align","data","initialValue","onBlur","onFocus","onChange","ref","tabIndex","Indicator","reason","columnName","String","header","validationErrors","role","Highlight","rowIndex","rowValues","newValue","globalFilter","getState","isFilteredByGlobalFilter","Object","values","some","globalFilterFn","IndicatorReason","SEARCH","getIsFiltered","columnFilterFn","getFilterValue","FILTER","getIsSorted","willRowMoveAfterSorting","_table$getState$sorti","sorting","find","s","desc","SORTING"],"mappings":";;;;;;;;;;;;SAqBgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC;GAAO,GAAGF,KAAK;EAC7B,MAAM;IAAEG;GAAW,GAAGC,aAAa,EAAE;;EAErC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAAwB;EACxD,MAAMC,KAAK,GAAGH,SAAS,CAACI,UAAU,CAACC,YAAY,CAACT,IAAI,CAAC;EACrD,oBAAOU,6BAACC,iBAAiB,oBAAYZ,KAAK;IAAEQ,KAAK,EAAEA,KAAK;IAAEL,SAAS,EAAEA,SAAS;IAAEE,SAAS,EAAEA;KAAa;AAC5G;AASA,MAAMO,iBAAiB,gBAAGD,cAAK,CAACE,IAAI,CAAC,SAASD,iBAAi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sD;GAAc,GAAGvH,KAAK,CAACwH,QAAQ,EAAE;EAEzC,MAAMC,wBAAwB,GAAGpC,uBAAuB,GAClDqC,MAAM,CAACC,MAAM,CAAU;IAAE,GAAGN,SAAS;IAAE,CAACtH,IAAI,CAAC8D,EAAE,GAAGyD;GAAU,CAAC,CAACM,IAAI,CAAC;;;IAG/D,OAAOC,cAAc,CAACd,MAAM,CAACO,QAAQ,CAAC,EAAEC,YAAY,GAAGR,MAAM,CAACQ,YAAY,CAAC,GAAG,EAAE,CAAC;GACpF,CAAC,GACF,IAAI;EAEV,IAAI,CAACE,wBAAwB,EAAE;IAC3BxD,aAAa,GAAG6D,eAAe,CAACC,MAAM;GACzC,MAAM,IAAIhI,IAAI,CAACa,MAAM,CAACoH,aAAa,EAAE,IAAI,CAACC,cAAc,CAACX,QAAQ,EAAEvH,IAAI,CAACa,MAAM,CAACsH,cAAc,EAAuB,CAAC,EAAE;IACpHjE,aAAa,GAAG6D,eAAe,CAACK,MAAM;GACzC,MAAM,IACH,CAAClE,aAAa,IACdlE,IAAI,CAACa,MAAM,CAACwH,WAAW,EAAE,IACzBC,uBAAuB,CACnBf,QAAQ,EACRvH,IAAI,EACJqH,QAAQ,EACRpH,KAAK,CAACmE,WAAW,EAAE,CAACD,IAAI,EACxB,CAAC,GAAAoE,qBAAA,GAACtI,KAAK,CAACwH,QAAQ,EAAE,CAACe,OAAO,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAAC5E,EAAE,KAAK9D,IAAI,CAACa,MAAM,CAACiD,EAAE,CAAC,cAAAyE,qBAAA,eAA3DA,qBAAA,CAA6DI,IAAI,EACtE,EACH;IACEzE,aAAa,GAAG6D,eAAe,CAACa,OAAO;;EAG3C,OAAO1E,aAAa;AACxB;;;;"}
|
1
|
+
{"version":3,"file":"EditingCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/EditingCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport _ from 'lodash';\nimport { TableMeta, CellContext, ColumnMeta, Cell as RTCell, Table as RTTable } from '@tanstack/react-table';\nimport { Indicator, IndicatorReason } from './Indicator';\nimport { columnFilterFn, globalFilterFn } from '../../../util/filtering';\nimport { Table3ColumnControlRenderer, Table3FilterValue } from '../../../types';\nimport { hasChanged, willRowMoveAfterSorting } from '../../../util/editing';\nimport { getCurrentRowCellElement } from '../../../util/columns';\nimport { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions';\nimport { EditingControl } from './EditingControl';\nimport { RowContext, useRowContext } from '../../rows/RowContext';\nimport { Field } from '../../../../Field/Field';\nimport { Highlight } from './Highlight';\n\nexport type EditingCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n};\n\nexport function EditingCell<TType = unknown>(props: EditingCellProps<TType>) {\n const { cell, table } = props;\n const { isHovered } = useRowContext();\n // Need to explicitly pass tableMeta, because just passing the table object will not trigger editing change since table object is not mutatable.\n const tableMeta = table.options.meta as TableMeta<TType>;\n const error = tableMeta.validation.getCellError(cell);\n return <MemoedEditingCell<TType> {...props} error={error} isHovered={isHovered} tableMeta={tableMeta} />;\n}\n\n// Memoization\nexport type MemoedEditingCellProps<TType = unknown> = EditingCellProps<TType> & {\n isHovered: boolean;\n tableMeta: TableMeta<TType>;\n error?: string;\n};\n\nconst MemoedEditingCell = React.memo(function MemoedEditingCell<TType = unknown>(props: MemoedEditingCellProps<TType>) {\n const { cell, column, index, getValue, table, tableRef, row, tableMeta, error, highlighted, highlightedAsCurrent } = props;\n const { rowIndex } = React.useContext(RowContext);\n\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n\n const cellRef = React.useRef<HTMLDivElement>(null);\n const controlRef = React.useRef<HTMLElement>(null);\n\n const handleChange = (value: unknown) => tableMeta.editing.setCellValue(cell, value);\n const value = tableMeta.editing.getCellValue(cell) ?? getValue();\n\n const handleFocus = event => {\n // Check if cell is hidden behind pinned columns or edititng actions, and scroll to it.\n const frozenColumnIndex = tableMeta.columnFreezing.frozenColumnIndex;\n const tableElement = tableRef.current;\n\n if (tableElement && frozenColumnIndex !== undefined && index > frozenColumnIndex) {\n const lastFrozenColumnElement = getCurrentRowCellElement(frozenColumnIndex, tableElement);\n const cellRect = cellRef.current?.getBoundingClientRect();\n const lastFrozenRect = lastFrozenColumnElement?.getBoundingClientRect();\n const tableRect = tableElement.getBoundingClientRect();\n\n // Check for pinned columns overlap\n if (cellRect && lastFrozenRect && cellRect.left < lastFrozenRect.left + lastFrozenRect.width) {\n const pinnedColumnsWidth = lastFrozenRect.left + lastFrozenRect.width;\n tableElement.scrollTo(cellRect.left - pinnedColumnsWidth, tableElement.scrollTop);\n // Check for editing actions overlap\n } else if (cellRect && tableRect && cellRect.right > tableRect.right - EDITING_ACTIONS_WIDTH) {\n const spaceBetweenCellAndEditingActions = 10;\n tableElement.scrollTo(\n // Need to take into account if table has been already scrolled.\n tableElement.scrollLeft + EDITING_ACTIONS_WIDTH + spaceBetweenCellAndEditingActions,\n tableElement.scrollTop\n );\n }\n }\n\n if (event.target?.select) {\n requestAnimationFrame(() => {\n event.target.select();\n });\n }\n };\n\n const handleBlur = () => {\n tableMeta.editing.setDetailModeEditing(false);\n if (tableMeta.editing.changes?.[cell.row.id]) {\n tableMeta.validation.validate(cell.row.id, tableMeta.editing.changes[cell.row.id] as TType, cell.column.id);\n }\n };\n\n // row move indicator\n const moveReason = tableMeta.editing.rowMoveReason?.[cell.column.id] || null;\n const rows = table.getRowModel().rows;\n const isActiveRow =\n tableMeta.rowActive.rowActiveIndex !== undefined && rows[tableMeta.rowActive.rowActiveIndex]?.id === row.id;\n const mountNode = React.useMemo(() => {\n if (moveReason !== null && isActiveRow && !error) {\n return cellRef.current?.parentElement?.firstChild as Element | null;\n }\n return null;\n }, [moveReason, isActiveRow, error, cellRef]);\n\n const removeMoveReason = () => {\n tableMeta.editing.removeRowMoveReason();\n };\n\n React.useEffect(() => {\n // To avoid reseting move reason on another row hover,\n // we need to check for changes only if value got changed in the current row.\n if (!isActiveRow || error) {\n if (tableMeta.editing.rowMoveReason) {\n removeMoveReason();\n }\n return;\n }\n\n if (hasChanged(getValue(), value)) {\n const moveReason = getRowMoveReason(\n table,\n rowIndex, // cannot use row.index, as this is not kept in sync once a column is sorted.\n row.original,\n cell,\n value,\n tableMeta.search.excludeUnmatchedResults\n );\n tableMeta.editing.setRowMoveReason({ [cell.column.id]: moveReason });\n } else {\n removeMoveReason();\n }\n return removeMoveReason;\n }, [value, tableMeta.rowActive.rowActiveIndex, tableMeta.search.excludeUnmatchedResults, error]);\n\n const controlRenderer = column.columnDef.meta?.control as Table3ColumnControlRenderer;\n\n const className = cn(\n 'py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]',\n {\n // Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative\n relative: controlRenderer === 'textarea' && columnMeta.enableTruncate,\n },\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n );\n\n const fieldClassName = cn('!min-h-0 w-full !pb-0', {\n '!pb-3': !!error,\n });\n\n const content = (\n <Field message={error} invalid={!!error} className={fieldClassName}>\n <EditingControl\n align={columnMeta.align}\n column={cell.column}\n data={cell.row.original}\n initialValue={getValue()}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onChange={handleChange}\n ref={controlRef}\n table={table}\n tableRef={tableRef}\n value={value}\n cell={cell}\n error={error}\n tabIndex={isActiveRow ? 0 : -1}\n isActiveRow={isActiveRow}\n />\n </Field>\n );\n\n return (\n <>\n {moveReason !== null && mountNode && !error ? (\n <Indicator\n reason={moveReason}\n columnName={String(cell.column.columnDef.header)}\n mountNode={mountNode}\n validationErrors={[]}\n />\n ) : null}\n <div\n className={!highlighted ? className : undefined}\n data-align={columnMeta.align}\n data-column-index={index}\n role=\"cell\"\n data-editable\n ref={cellRef}\n data-invalid={!!error}\n data-highlighted={highlighted}>\n {highlighted ? (\n <Highlight\n current={highlightedAsCurrent}\n className={className}\n frozenColumnIndex={tableMeta.columnFreezing.frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n </>\n );\n}) as <TType = unknown>(props: MemoedEditingCellProps<TType>) => JSX.Element;\n\nfunction getRowMoveReason<TType>(\n table: RTTable<any>,\n rowIndex: number,\n rowValues: TType,\n cell: RTCell<any, unknown>,\n newValue: any,\n excludeUnmatchedResults: boolean\n) {\n let rowMoveReason: IndicatorReason | null = null;\n const { globalFilter } = table.getState();\n\n const isFilteredByGlobalFilter = excludeUnmatchedResults\n ? Object.values<unknown>({ ...rowValues, [cell.id]: newValue }).some(() => {\n // Global filter can be undefined when there is no text being searched so we pass an empty string to\n // globalFilterFn as query in that case.\n return globalFilterFn(String(newValue), globalFilter ? String(globalFilter) : '');\n })\n : true;\n\n if (!isFilteredByGlobalFilter) {\n rowMoveReason = IndicatorReason.SEARCH;\n } else if (cell.column.getIsFiltered() && !columnFilterFn(newValue, cell.column.getFilterValue() as Table3FilterValue)) {\n rowMoveReason = IndicatorReason.FILTER;\n } else if (\n !rowMoveReason &&\n cell.column.getIsSorted() &&\n willRowMoveAfterSorting(\n newValue,\n cell,\n rowIndex,\n table.getRowModel().rows,\n !!table.getState().sorting.find(s => s.id === cell.column.id)?.desc\n )\n ) {\n rowMoveReason = IndicatorReason.SORTING;\n }\n\n return rowMoveReason;\n}\n"],"names":["EditingCell","props","cell","table","isHovered","useRowContext","tableMeta","options","meta","error","validation","getCellError","React","MemoedEditingCell","memo","column","index","getValue","tableRef","row","highlighted","highlightedAsCurrent","rowIndex","useContext","RowContext","columnMeta","columnDef","cellRef","useRef","controlRef","handleChange","value","editing","setCellValue","_tableMeta$editing$ge","getCellValue","handleFocus","event","frozenColumnIndex","columnFreezing","tableElement","current","undefined","_cellRef$current","lastFrozenColumnElement","getCurrentRowCellElement","cellRect","getBoundingClientRect","lastFrozenRect","tableRect","left","width","pinnedColumnsWidth","scrollTo","scrollTop","right","EDITING_ACTIONS_WIDTH","spaceBetweenCellAndEditingActions","scrollLeft","_event$target","target","select","requestAnimationFrame","handleBlur","setDetailModeEditing","_tableMeta$editing$ch","changes","id","validate","moveReason","_tableMeta$editing$ro","rowMoveReason","rows","getRowModel","isActiveRow","rowActive","rowActiveIndex","_rows$tableMeta$rowAc","mountNode","useMemo","_cellRef$current2","_cellRef$current2$par","parentElement","firstChild","removeMoveReason","removeRowMoveReason","useEffect","hasChanged","getRowMoveReason","original","search","excludeUnmatchedResults","setRowMoveReason","controlRenderer","_column$columnDef$met","control","className","cn","relative","enableTruncate","fieldClassName","content","Field","message","invalid","EditingControl","align","data","initialValue","onBlur","onFocus","onChange","ref","tabIndex","Indicator","reason","columnName","String","header","validationErrors","role","Highlight","rowValues","newValue","globalFilter","getState","isFilteredByGlobalFilter","Object","values","some","globalFilterFn","IndicatorReason","SEARCH","getIsFiltered","columnFilterFn","getFilterValue","FILTER","getIsSorted","willRowMoveAfterSorting","_table$getState$sorti","sorting","find","s","desc","SORTING"],"mappings":";;;;;;;;;;;;SAqBgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC;GAAO,GAAGF,KAAK;EAC7B,MAAM;IAAEG;GAAW,GAAGC,aAAa,EAAE;;EAErC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAAwB;EACxD,MAAMC,KAAK,GAAGH,SAAS,CAACI,UAAU,CAACC,YAAY,CAACT,IAAI,CAAC;EACrD,oBAAOU,6BAACC,iBAAiB,oBAAYZ,KAAK;IAAEQ,KAAK,EAAEA,KAAK;IAAEL,SAAS,EAAEA,SAAS;IAAEE,SAAS,EAAEA;KAAa;AAC5G;AASA,MAAMO,iBAAiB,gBAAGD,cAAK,CAACE,IAAI,CAAC,SAASD,iBAAiBA,CAAkBZ,KAAoC;;EACjH,MAAM;IAAEC,IAAI;IAAEa,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEd,KAAK;IAAEe,QAAQ;IAAEC,GA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C,MAAMC,wBAAwB,GAAGnC,uBAAuB,GAClDoC,MAAM,CAACC,MAAM,CAAU;IAAE,GAAGN,SAAS;IAAE,CAACxH,IAAI,CAACiE,EAAE,GAAGwD;GAAU,CAAC,CAACM,IAAI,CAAC;;;IAG/D,OAAOC,cAAc,CAACb,MAAM,CAACM,QAAQ,CAAC,EAAEC,YAAY,GAAGP,MAAM,CAACO,YAAY,CAAC,GAAG,EAAE,CAAC;GACpF,CAAC,GACF,IAAI;EAEV,IAAI,CAACE,wBAAwB,EAAE;IAC3BvD,aAAa,GAAG4D,eAAe,CAACC,MAAM;GACzC,MAAM,IAAIlI,IAAI,CAACa,MAAM,CAACsH,aAAa,EAAE,IAAI,CAACC,cAAc,CAACX,QAAQ,EAAEzH,IAAI,CAACa,MAAM,CAACwH,cAAc,EAAuB,CAAC,EAAE;IACpHhE,aAAa,GAAG4D,eAAe,CAACK,MAAM;GACzC,MAAM,IACH,CAACjE,aAAa,IACdrE,IAAI,CAACa,MAAM,CAAC0H,WAAW,EAAE,IACzBC,uBAAuB,CACnBf,QAAQ,EACRzH,IAAI,EACJoB,QAAQ,EACRnB,KAAK,CAACsE,WAAW,EAAE,CAACD,IAAI,EACxB,CAAC,GAAAmE,qBAAA,GAACxI,KAAK,CAAC0H,QAAQ,EAAE,CAACe,OAAO,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAAC3E,EAAE,KAAKjE,IAAI,CAACa,MAAM,CAACoD,EAAE,CAAC,cAAAwE,qBAAA,eAA3DA,qBAAA,CAA6DI,IAAI,EACtE,EACH;IACExE,aAAa,GAAG4D,eAAe,CAACa,OAAO;;EAG3C,OAAOzE,aAAa;AACxB;;;;"}
|
@@ -10090,7 +10090,7 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
10090
10090
|
disabled: disabled,
|
10091
10091
|
onClick: handleClick,
|
10092
10092
|
ref: ref,
|
10093
|
-
role: "
|
10093
|
+
role: "combobox",
|
10094
10094
|
tabIndex: disabled || readOnly ? -1 : tabIndex,
|
10095
10095
|
type: "button"
|
10096
10096
|
}), children, /*#__PURE__*/React__default.createElement(Icon, {
|
@@ -15136,6 +15136,9 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
15136
15136
|
highlighted,
|
15137
15137
|
highlightedAsCurrent
|
15138
15138
|
} = props;
|
15139
|
+
const {
|
15140
|
+
rowIndex
|
15141
|
+
} = React__default.useContext(RowContext);
|
15139
15142
|
const columnMeta = column.columnDef.meta;
|
15140
15143
|
const cellRef = React__default.useRef(null);
|
15141
15144
|
const controlRef = React__default.useRef(null);
|
@@ -15201,7 +15204,9 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
15201
15204
|
return;
|
15202
15205
|
}
|
15203
15206
|
if (hasChanged(getValue(), value)) {
|
15204
|
-
const moveReason = getRowMoveReason(table,
|
15207
|
+
const moveReason = getRowMoveReason(table, rowIndex,
|
15208
|
+
// cannot use row.index, as this is not kept in sync once a column is sorted.
|
15209
|
+
row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
|
15205
15210
|
tableMeta.editing.setRowMoveReason({
|
15206
15211
|
[cell.column.id]: moveReason
|
15207
15212
|
});
|
@@ -18670,7 +18675,8 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
18670
18675
|
const handleKeyDown = event => {
|
18671
18676
|
const target = event.target;
|
18672
18677
|
const dialog = target.closest('[role="dialog"]');
|
18673
|
-
|
18678
|
+
// Select2 also have combobox role to align with W3C guidelines
|
18679
|
+
const eventOriginatedFromCombobox = !!target.closest('[role="combobox"]:not([data-taco="Select2"])');
|
18674
18680
|
// Don't trigger global shortcuts on the table if event originated from a combobox or if table is
|
18675
18681
|
// outside the dialog
|
18676
18682
|
if (eventOriginatedFromCombobox || dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(internalRef.current)) || tableMeta.shortcutsState.isPaused) {
|