@lax-wp/design-system 0.13.67 → 0.13.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-display/infinite-table/body/cell/CheckboxCell.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/body/cell/CheckboxCell.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/body/cell/CheckboxCell.es.js +49 -48
- package/dist/components/data-display/infinite-table/body/cell/CheckboxCell.es.js.map +1 -1
- package/dist/components/data-display/infinite-table/body/cell/PendingEditCell.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/body/cell/PendingEditCell.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/body/cell/PendingEditCell.es.js +28 -27
- package/dist/components/data-display/infinite-table/body/cell/PendingEditCell.es.js.map +1 -1
- package/dist/components/data-display/infinite-table/body/cell/RowActionCell.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/body/cell/RowActionCell.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/body/cell/RowActionCell.es.js +36 -35
- package/dist/components/data-display/infinite-table/body/cell/RowActionCell.es.js.map +1 -1
- package/dist/components/data-display/infinite-table/body/cell/RowOptionsCell.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/body/cell/RowOptionsCell.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/body/cell/RowOptionsCell.es.js +48 -47
- package/dist/components/data-display/infinite-table/body/cell/RowOptionsCell.es.js.map +1 -1
- package/dist/components/data-display/infinite-table/index.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/index.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/index.es.js +2 -2
- package/dist/components/data-display/infinite-table/index.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),_=require("antd"),B=require("../../../../../providers/design-system-provider/hooks.cjs.js"),R=require("../../../../../_virtual/index.cjs.js"),x=require("react"),$=require("../../constants.cjs.js");let b=null;const K=({checkboxConfig:t,id:e,rowHovering:r,isDisabled:S,is_read:M,is_modified:m,is_row_modified:y,is_deleted:u,is_added:n,isDraggingOver:T,showNewItem:q,currentData:a,bgColor:f,is_incomplete:d,isInlineEditing:c,hasPendingEditsColumn:w,rowHasPendingEdits:g})=>{const F=B.useTableConfig()?.t?.("Save or cancel pending changes first")??"Save or cancel pending changes first",l=x.useRef(null),N=s=>{if(s.key!=="Enter")return;s.preventDefault();const p=s.currentTarget.form;if(!p)return;const O=new Event("submit",{bubbles:!0,cancelable:!0});p.dispatchEvent(O);const C=p.querySelector('button[type="submit"]');C&&C.click()},j=typeof t?.checkboxMetadata=="object"&&t?.checkboxMetadata!==null&&t?.checkboxMetadata.checkedIds?.includes(e)||t?.checkedIds?.includes(e),h=S||g||t?.checkboxMetadata?.checkedIds?.includes(e);x.useLayoutEffect(()=>{b!==e||h||l.current&&document.activeElement!==l.current&&l.current.focus({preventScroll:!0})},[e,h,j]);const k=R({"bg-primary-50 dark:bg-primary-900":c,"bg-neutral-100 dark:bg-black-600":r===e&&!c&&!(u||a?.is_deleted)&&!(n||a?.is_added),"bg-error-200 dark:bg-error-900":r===e&&!c&&(u||a?.is_deleted),"bg-success-100 dark:bg-success-800":r===e&&!c&&(n||a?.is_added),"bg-warning-100 dark:bg-warning-950":r===e&&!c&&(d||m||y||a?.is_row_modified),"bg-primary-50 dark:bg-black-700":!d&&!M&&q&&r!==e&&!c,"bg-warning-50 dark:bg-orange-900":(d||m||y||a?.is_row_modified)&&r!==e&&!c,"bg-error-100 dark:bg-error-975":(u||a?.is_deleted)&&r!==e&&!c,"bg-success-50 dark:bg-success-900":(n||a?.is_added)&&r!==e&&!c,"bg-primary-50":T&&!c,...f&&!c&&{[f]:!0}});return o.jsx("td",{className:`min-w-[40px] sticky right-0 z-30 ${k||"bg-white dark:bg-black-800"} h-row`,style:{left:w?$.CHECKBOX_PENDING_EDITS_LEFT_OFFSET:"0"},children:o.jsxs("div",{className:"absolute w-full h-row inset-0 px-2.5 z-30 flex items-center justify-center",style:{boxShadow:"8px 0px 8px 0px rgba(0, 0, 0, 0.02)"},children:[o.jsx(_.Tooltip,{title:g?F:t?.checkboxMetadata?.tooltip&&t?.checkboxMetadata?.checkedIds?.includes(e)?t?.checkboxMetadata?.tooltip:"",children:o.jsx("input",{ref:l,id:`checkbox-table-search-${e}`,type:"checkbox",className:`w-4 h-4 text-primary-600 appearance-none border border-gray-400 dark:border-neutral-400 rounded-[4px] checked:appearance-auto focus:ring-primary-500 dark:focus:ring-primary-600 focus:ring-2 cursor-pointer ${k}`,onChange:s=>t?.onItemCheck(s,e),onKeyDown:N,onFocus:()=>{b=e},onBlur:()=>{b===e&&(b=null)},checked:j,disabled:h},`checkbox-table-search-${e}`)}),o.jsx("label",{htmlFor:"checkbox-table-search-1",className:"sr-only dark:text-neutral-200",children:"checkbox"})]})})},z=x.memo(K);exports.CheckboxCell=z;
|
|
2
2
|
//# sourceMappingURL=CheckboxCell.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxCell.cjs.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/CheckboxCell.tsx"],"sourcesContent":["import { Tooltip } from 'antd';\nimport { useTableConfig } from '../../../../../providers/design-system-provider/hooks';\nimport cn from 'classnames';\nimport React from 'react';\n\nimport { CHECKBOX_PENDING_EDITS_LEFT_OFFSET } from '../../constants';\n\ntype HighlightType = 'SUCCESS' | 'WARNING' | 'ERROR';\n\ntype CheckboxMetadata = {\n checkedIds: string[];\n tooltip: string;\n highlight: HighlightType;\n};\n\ntype TCheckboxCellProps = {\n checkboxConfig: {\n checkboxMetadata: CheckboxMetadata;\n checkedIds: string[];\n selectionDisabledRowIds: CheckboxMetadata;\n onItemCheck: (event: React.ChangeEvent<HTMLInputElement>, id: string) => void;\n };\n id: string;\n rowHovering?: string;\n isDisabled?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n isDraggingOver?: boolean;\n showNewItem?: boolean;\n currentData?: Record<string, unknown>;\n bgColor?: string;\n is_incomplete?: boolean;\n isInlineEditing?: boolean;\n hasPendingEditsColumn?: boolean;\n rowHasPendingEdits?: boolean;\n};\n\nlet lastFocusedCheckboxId: string | null = null;\n\nconst CheckboxCellBase = ({\n checkboxConfig,\n id,\n rowHovering,\n isDisabled,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n isDraggingOver,\n showNewItem,\n currentData,\n bgColor: bgColorProp,\n is_incomplete,\n isInlineEditing,\n hasPendingEditsColumn,\n rowHasPendingEdits,\n}: TCheckboxCellProps) => {\n const tableConfig = useTableConfig();\n const pendingEditsTooltip = tableConfig?.t?.('Save or cancel pending changes first') ?? 'Save or cancel pending changes first';\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== 'Enter') return;\n event.preventDefault();\n const formEl = event.currentTarget.form;\n if (!formEl) return;\n\n const submitEvent = new Event('submit', { bubbles: true, cancelable: true });\n formEl.dispatchEvent(submitEvent);\n\n const submitBtn = formEl.querySelector<HTMLButtonElement>('button[type=\"submit\"]');\n if (submitBtn) {\n submitBtn.click();\n }\n };\n\n const isCheckedObject = typeof checkboxConfig?.checkboxMetadata === 'object' && checkboxConfig?.checkboxMetadata !== null;\n const checkedValue = (isCheckedObject && checkboxConfig?.checkboxMetadata.checkedIds?.includes(id)) || checkboxConfig?.checkedIds?.includes(id);\n const isInputDisabled = isDisabled || rowHasPendingEdits || checkboxConfig?.checkboxMetadata?.checkedIds?.includes(id);\n\n React.useLayoutEffect(() => {\n if (lastFocusedCheckboxId !== id || isInputDisabled) return;\n if (inputRef.current && document.activeElement !== inputRef.current) {\n inputRef.current.focus({ preventScroll: true });\n }\n }, [id, isInputDisabled, checkedValue]);\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === id && !isInlineEditing && !(is_deleted || currentData?.is_deleted) && !(is_added || currentData?.is_added),\n 'bg-error-200 dark:bg-error-900': rowHovering === id && !isInlineEditing && (is_deleted || currentData?.is_deleted),\n 'bg-success-100 dark:bg-success-800': rowHovering === id && !isInlineEditing && (is_added || currentData?.is_added),\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== id && !isInlineEditing,\n 'bg-warning-50 dark:bg-
|
|
1
|
+
{"version":3,"file":"CheckboxCell.cjs.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/CheckboxCell.tsx"],"sourcesContent":["import { Tooltip } from 'antd';\nimport { useTableConfig } from '../../../../../providers/design-system-provider/hooks';\nimport cn from 'classnames';\nimport React from 'react';\n\nimport { CHECKBOX_PENDING_EDITS_LEFT_OFFSET } from '../../constants';\n\ntype HighlightType = 'SUCCESS' | 'WARNING' | 'ERROR';\n\ntype CheckboxMetadata = {\n checkedIds: string[];\n tooltip: string;\n highlight: HighlightType;\n};\n\ntype TCheckboxCellProps = {\n checkboxConfig: {\n checkboxMetadata: CheckboxMetadata;\n checkedIds: string[];\n selectionDisabledRowIds: CheckboxMetadata;\n onItemCheck: (event: React.ChangeEvent<HTMLInputElement>, id: string) => void;\n };\n id: string;\n rowHovering?: string;\n isDisabled?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n isDraggingOver?: boolean;\n showNewItem?: boolean;\n currentData?: Record<string, unknown>;\n bgColor?: string;\n is_incomplete?: boolean;\n isInlineEditing?: boolean;\n hasPendingEditsColumn?: boolean;\n rowHasPendingEdits?: boolean;\n};\n\nlet lastFocusedCheckboxId: string | null = null;\n\nconst CheckboxCellBase = ({\n checkboxConfig,\n id,\n rowHovering,\n isDisabled,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n isDraggingOver,\n showNewItem,\n currentData,\n bgColor: bgColorProp,\n is_incomplete,\n isInlineEditing,\n hasPendingEditsColumn,\n rowHasPendingEdits,\n}: TCheckboxCellProps) => {\n const tableConfig = useTableConfig();\n const pendingEditsTooltip = tableConfig?.t?.('Save or cancel pending changes first') ?? 'Save or cancel pending changes first';\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== 'Enter') return;\n event.preventDefault();\n const formEl = event.currentTarget.form;\n if (!formEl) return;\n\n const submitEvent = new Event('submit', { bubbles: true, cancelable: true });\n formEl.dispatchEvent(submitEvent);\n\n const submitBtn = formEl.querySelector<HTMLButtonElement>('button[type=\"submit\"]');\n if (submitBtn) {\n submitBtn.click();\n }\n };\n\n const isCheckedObject = typeof checkboxConfig?.checkboxMetadata === 'object' && checkboxConfig?.checkboxMetadata !== null;\n const checkedValue = (isCheckedObject && checkboxConfig?.checkboxMetadata.checkedIds?.includes(id)) || checkboxConfig?.checkedIds?.includes(id);\n const isInputDisabled = isDisabled || rowHasPendingEdits || checkboxConfig?.checkboxMetadata?.checkedIds?.includes(id);\n\n React.useLayoutEffect(() => {\n if (lastFocusedCheckboxId !== id || isInputDisabled) return;\n if (inputRef.current && document.activeElement !== inputRef.current) {\n inputRef.current.focus({ preventScroll: true });\n }\n }, [id, isInputDisabled, checkedValue]);\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === id && !isInlineEditing && !(is_deleted || currentData?.is_deleted) && !(is_added || currentData?.is_added),\n 'bg-error-200 dark:bg-error-900': rowHovering === id && !isInlineEditing && (is_deleted || currentData?.is_deleted),\n 'bg-success-100 dark:bg-success-800': rowHovering === id && !isInlineEditing && (is_added || currentData?.is_added),\n 'bg-warning-100 dark:bg-warning-950': rowHovering === id && !isInlineEditing && (is_incomplete || is_modified || is_row_modified || currentData?.is_row_modified),\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== id && !isInlineEditing,\n 'bg-warning-50 dark:bg-orange-900':\n (is_incomplete || is_modified || is_row_modified || currentData?.is_row_modified) && rowHovering !== id && !isInlineEditing,\n 'bg-error-100 dark:bg-error-975': (is_deleted || currentData?.is_deleted) && rowHovering !== id && !isInlineEditing,\n 'bg-success-50 dark:bg-success-900': (is_added || currentData?.is_added) && rowHovering !== id && !isInlineEditing,\n 'bg-primary-50': isDraggingOver && !isInlineEditing,\n ...(bgColorProp && !isInlineEditing && { [bgColorProp]: true }),\n });\n\n return (\n <td\n className={`min-w-[40px] sticky right-0 z-30 ${bgColor ? bgColor : 'bg-white dark:bg-black-800'} h-row`}\n style={{ left: hasPendingEditsColumn ? CHECKBOX_PENDING_EDITS_LEFT_OFFSET : '0' }}\n >\n <div\n className={`absolute w-full h-row inset-0 px-2.5 z-30 flex items-center justify-center`}\n style={{ boxShadow: '8px 0px 8px 0px rgba(0, 0, 0, 0.02)' }}\n >\n <Tooltip\n title={\n rowHasPendingEdits\n ? pendingEditsTooltip\n : checkboxConfig?.checkboxMetadata?.tooltip && checkboxConfig?.checkboxMetadata?.checkedIds?.includes(id)\n ? checkboxConfig?.checkboxMetadata?.tooltip\n : ''\n }\n >\n <input\n ref={inputRef}\n key={`checkbox-table-search-${id}`}\n id={`checkbox-table-search-${id}`}\n type='checkbox'\n className={`w-4 h-4 text-primary-600 appearance-none border border-gray-400 dark:border-neutral-400 rounded-[4px] checked:appearance-auto focus:ring-primary-500 dark:focus:ring-primary-600 focus:ring-2 cursor-pointer ${bgColor}`}\n onChange={(event) => checkboxConfig?.onItemCheck(event, id)}\n onKeyDown={handleKeyDown}\n onFocus={() => { lastFocusedCheckboxId = id; }}\n onBlur={() => { if (lastFocusedCheckboxId === id) lastFocusedCheckboxId = null; }}\n checked={checkedValue}\n disabled={isInputDisabled}\n />\n </Tooltip>\n <label htmlFor='checkbox-table-search-1' className='sr-only dark:text-neutral-200'>\n {'checkbox'}\n </label>\n </div>\n </td>\n );\n};\n\nexport const CheckboxCell = React.memo(CheckboxCellBase);\n"],"names":["lastFocusedCheckboxId","CheckboxCellBase","checkboxConfig","id","rowHovering","isDisabled","is_read","is_modified","is_row_modified","is_deleted","is_added","isDraggingOver","showNewItem","currentData","bgColorProp","is_incomplete","isInlineEditing","hasPendingEditsColumn","rowHasPendingEdits","pendingEditsTooltip","useTableConfig","inputRef","React","handleKeyDown","event","formEl","submitEvent","submitBtn","checkedValue","isInputDisabled","bgColor","cn","jsx","CHECKBOX_PENDING_EDITS_LEFT_OFFSET","jsxs","Tooltip","CheckboxCell"],"mappings":"0TAwCA,IAAIA,EAAuC,KAE3C,MAAMC,EAAmB,CAAC,CACxB,eAAAC,EACA,GAAAC,EACA,YAAAC,EACA,WAAAC,EACA,QAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,SAAAC,EACA,eAAAC,EACA,YAAAC,EACA,YAAAC,EACA,QAASC,EACT,cAAAC,EACA,gBAAAC,EACA,sBAAAC,EACA,mBAAAC,CACF,IAA0B,CAExB,MAAMC,EADcC,EAAAA,eAAA,GACqB,IAAI,sCAAsC,GAAK,uCAClFC,EAAWC,EAAM,OAAyB,IAAI,EAE9CC,EAAiBC,GAAiD,CACtE,GAAIA,EAAM,MAAQ,QAAS,OAC3BA,EAAM,eAAA,EACN,MAAMC,EAASD,EAAM,cAAc,KACnC,GAAI,CAACC,EAAQ,OAEb,MAAMC,EAAc,IAAI,MAAM,SAAU,CAAE,QAAS,GAAM,WAAY,GAAM,EAC3ED,EAAO,cAAcC,CAAW,EAEhC,MAAMC,EAAYF,EAAO,cAAiC,uBAAuB,EAC7EE,GACFA,EAAU,MAAA,CAEd,EAGMC,EADkB,OAAO1B,GAAgB,kBAAqB,UAAYA,GAAgB,mBAAqB,MAC5EA,GAA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AAA,IAACG,EAAAA,QAAA,CACC,MACEjB,EACIC,EACAjB,GAAgB,kBAAkB,SAAWA,GAAgB,kBAAkB,YAAY,SAASC,CAAE,EACtGD,GAAgB,kBAAkB,QAClC,GAGN,SAAA8B,EAAAA,IAAC,QAAA,CACC,IAAKX,EAEL,GAAI,yBAAyBlB,CAAE,GAC/B,KAAK,WACL,UAAW,gNAAgN2B,CAAO,GAClO,SAAWN,GAAUtB,GAAgB,YAAYsB,EAAOrB,CAAE,EAC1D,UAAWoB,EACX,QAAS,IAAM,CAAEvB,EAAwBG,CAAI,EAC7C,OAAQ,IAAM,CAAMH,IAA0BG,IAAIH,EAAwB,KAAM,EAChF,QAAS4B,EACT,SAAUC,CAAA,EATL,yBAAyB1B,CAAE,EAAA,CAUlC,CAAA,QAED,QAAA,CAAM,QAAQ,0BAA0B,UAAU,gCAChD,SAAA,UAAA,CACH,CAAA,CAAA,CAAA,CACF,CAAA,CAGN,EAEaiC,EAAed,EAAM,KAAKrB,CAAgB"}
|
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
import { jsx as l, jsxs as O } from "react/jsx-runtime";
|
|
2
2
|
import { Tooltip as $ } from "antd";
|
|
3
|
-
import { useTableConfig as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { CHECKBOX_PENDING_EDITS_LEFT_OFFSET as
|
|
3
|
+
import { useTableConfig as K } from "../../../../../providers/design-system-provider/hooks.es.js";
|
|
4
|
+
import R from "../../../../../_virtual/index.es.js";
|
|
5
|
+
import m from "react";
|
|
6
|
+
import { CHECKBOX_PENDING_EDITS_LEFT_OFFSET as z } from "../../constants.es.js";
|
|
7
7
|
let b = null;
|
|
8
|
-
const
|
|
9
|
-
checkboxConfig:
|
|
8
|
+
const E = ({
|
|
9
|
+
checkboxConfig: c,
|
|
10
10
|
id: e,
|
|
11
11
|
rowHovering: t,
|
|
12
|
-
isDisabled:
|
|
13
|
-
is_read:
|
|
14
|
-
is_modified:
|
|
15
|
-
is_row_modified:
|
|
12
|
+
isDisabled: S,
|
|
13
|
+
is_read: T,
|
|
14
|
+
is_modified: f,
|
|
15
|
+
is_row_modified: x,
|
|
16
16
|
is_deleted: u,
|
|
17
|
-
is_added:
|
|
18
|
-
isDraggingOver:
|
|
19
|
-
showNewItem:
|
|
17
|
+
is_added: p,
|
|
18
|
+
isDraggingOver: j,
|
|
19
|
+
showNewItem: w,
|
|
20
20
|
currentData: a,
|
|
21
|
-
bgColor:
|
|
22
|
-
is_incomplete:
|
|
23
|
-
isInlineEditing:
|
|
21
|
+
bgColor: y,
|
|
22
|
+
is_incomplete: d,
|
|
23
|
+
isInlineEditing: r,
|
|
24
24
|
hasPendingEditsColumn: F,
|
|
25
|
-
rowHasPendingEdits:
|
|
25
|
+
rowHasPendingEdits: g
|
|
26
26
|
}) => {
|
|
27
|
-
const N =
|
|
27
|
+
const N = K()?.t?.("Save or cancel pending changes first") ?? "Save or cancel pending changes first", o = m.useRef(null), _ = (s) => {
|
|
28
28
|
if (s.key !== "Enter") return;
|
|
29
29
|
s.preventDefault();
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
30
|
+
const k = s.currentTarget.form;
|
|
31
|
+
if (!k) return;
|
|
32
32
|
const B = new Event("submit", { bubbles: !0, cancelable: !0 });
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
b !== e ||
|
|
39
|
-
}, [e,
|
|
40
|
-
const
|
|
41
|
-
"bg-primary-50 dark:bg-primary-900":
|
|
42
|
-
"bg-neutral-100 dark:bg-black-600": t === e && !
|
|
43
|
-
"bg-error-200 dark:bg-error-900": t === e && !
|
|
44
|
-
"bg-success-100 dark:bg-success-800": t === e && !
|
|
45
|
-
"bg-
|
|
46
|
-
"bg-
|
|
47
|
-
"bg-
|
|
48
|
-
"bg-
|
|
49
|
-
"bg-
|
|
50
|
-
|
|
33
|
+
k.dispatchEvent(B);
|
|
34
|
+
const M = k.querySelector('button[type="submit"]');
|
|
35
|
+
M && M.click();
|
|
36
|
+
}, C = typeof c?.checkboxMetadata == "object" && c?.checkboxMetadata !== null && c?.checkboxMetadata.checkedIds?.includes(e) || c?.checkedIds?.includes(e), n = S || g || c?.checkboxMetadata?.checkedIds?.includes(e);
|
|
37
|
+
m.useLayoutEffect(() => {
|
|
38
|
+
b !== e || n || o.current && document.activeElement !== o.current && o.current.focus({ preventScroll: !0 });
|
|
39
|
+
}, [e, n, C]);
|
|
40
|
+
const h = R({
|
|
41
|
+
"bg-primary-50 dark:bg-primary-900": r,
|
|
42
|
+
"bg-neutral-100 dark:bg-black-600": t === e && !r && !(u || a?.is_deleted) && !(p || a?.is_added),
|
|
43
|
+
"bg-error-200 dark:bg-error-900": t === e && !r && (u || a?.is_deleted),
|
|
44
|
+
"bg-success-100 dark:bg-success-800": t === e && !r && (p || a?.is_added),
|
|
45
|
+
"bg-warning-100 dark:bg-warning-950": t === e && !r && (d || f || x || a?.is_row_modified),
|
|
46
|
+
"bg-primary-50 dark:bg-black-700": !d && !T && w && t !== e && !r,
|
|
47
|
+
"bg-warning-50 dark:bg-orange-900": (d || f || x || a?.is_row_modified) && t !== e && !r,
|
|
48
|
+
"bg-error-100 dark:bg-error-975": (u || a?.is_deleted) && t !== e && !r,
|
|
49
|
+
"bg-success-50 dark:bg-success-900": (p || a?.is_added) && t !== e && !r,
|
|
50
|
+
"bg-primary-50": j && !r,
|
|
51
|
+
...y && !r && { [y]: !0 }
|
|
51
52
|
});
|
|
52
53
|
return /* @__PURE__ */ l(
|
|
53
54
|
"td",
|
|
54
55
|
{
|
|
55
|
-
className: `min-w-[40px] sticky right-0 z-30 ${
|
|
56
|
-
style: { left: F ?
|
|
56
|
+
className: `min-w-[40px] sticky right-0 z-30 ${h || "bg-white dark:bg-black-800"} h-row`,
|
|
57
|
+
style: { left: F ? z : "0" },
|
|
57
58
|
children: /* @__PURE__ */ O(
|
|
58
59
|
"div",
|
|
59
60
|
{
|
|
@@ -63,24 +64,24 @@ const R = ({
|
|
|
63
64
|
/* @__PURE__ */ l(
|
|
64
65
|
$,
|
|
65
66
|
{
|
|
66
|
-
title:
|
|
67
|
+
title: g ? N : c?.checkboxMetadata?.tooltip && c?.checkboxMetadata?.checkedIds?.includes(e) ? c?.checkboxMetadata?.tooltip : "",
|
|
67
68
|
children: /* @__PURE__ */ l(
|
|
68
69
|
"input",
|
|
69
70
|
{
|
|
70
71
|
ref: o,
|
|
71
72
|
id: `checkbox-table-search-${e}`,
|
|
72
73
|
type: "checkbox",
|
|
73
|
-
className: `w-4 h-4 text-primary-600 appearance-none border border-gray-400 dark:border-neutral-400 rounded-[4px] checked:appearance-auto focus:ring-primary-500 dark:focus:ring-primary-600 focus:ring-2 cursor-pointer ${
|
|
74
|
-
onChange: (s) =>
|
|
75
|
-
onKeyDown:
|
|
74
|
+
className: `w-4 h-4 text-primary-600 appearance-none border border-gray-400 dark:border-neutral-400 rounded-[4px] checked:appearance-auto focus:ring-primary-500 dark:focus:ring-primary-600 focus:ring-2 cursor-pointer ${h}`,
|
|
75
|
+
onChange: (s) => c?.onItemCheck(s, e),
|
|
76
|
+
onKeyDown: _,
|
|
76
77
|
onFocus: () => {
|
|
77
78
|
b = e;
|
|
78
79
|
},
|
|
79
80
|
onBlur: () => {
|
|
80
81
|
b === e && (b = null);
|
|
81
82
|
},
|
|
82
|
-
checked:
|
|
83
|
-
disabled:
|
|
83
|
+
checked: C,
|
|
84
|
+
disabled: n
|
|
84
85
|
},
|
|
85
86
|
`checkbox-table-search-${e}`
|
|
86
87
|
)
|
|
@@ -92,8 +93,8 @@ const R = ({
|
|
|
92
93
|
)
|
|
93
94
|
}
|
|
94
95
|
);
|
|
95
|
-
},
|
|
96
|
+
}, Q = m.memo(E);
|
|
96
97
|
export {
|
|
97
|
-
|
|
98
|
+
Q as CheckboxCell
|
|
98
99
|
};
|
|
99
100
|
//# sourceMappingURL=CheckboxCell.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxCell.es.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/CheckboxCell.tsx"],"sourcesContent":["import { Tooltip } from 'antd';\nimport { useTableConfig } from '../../../../../providers/design-system-provider/hooks';\nimport cn from 'classnames';\nimport React from 'react';\n\nimport { CHECKBOX_PENDING_EDITS_LEFT_OFFSET } from '../../constants';\n\ntype HighlightType = 'SUCCESS' | 'WARNING' | 'ERROR';\n\ntype CheckboxMetadata = {\n checkedIds: string[];\n tooltip: string;\n highlight: HighlightType;\n};\n\ntype TCheckboxCellProps = {\n checkboxConfig: {\n checkboxMetadata: CheckboxMetadata;\n checkedIds: string[];\n selectionDisabledRowIds: CheckboxMetadata;\n onItemCheck: (event: React.ChangeEvent<HTMLInputElement>, id: string) => void;\n };\n id: string;\n rowHovering?: string;\n isDisabled?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n isDraggingOver?: boolean;\n showNewItem?: boolean;\n currentData?: Record<string, unknown>;\n bgColor?: string;\n is_incomplete?: boolean;\n isInlineEditing?: boolean;\n hasPendingEditsColumn?: boolean;\n rowHasPendingEdits?: boolean;\n};\n\nlet lastFocusedCheckboxId: string | null = null;\n\nconst CheckboxCellBase = ({\n checkboxConfig,\n id,\n rowHovering,\n isDisabled,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n isDraggingOver,\n showNewItem,\n currentData,\n bgColor: bgColorProp,\n is_incomplete,\n isInlineEditing,\n hasPendingEditsColumn,\n rowHasPendingEdits,\n}: TCheckboxCellProps) => {\n const tableConfig = useTableConfig();\n const pendingEditsTooltip = tableConfig?.t?.('Save or cancel pending changes first') ?? 'Save or cancel pending changes first';\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== 'Enter') return;\n event.preventDefault();\n const formEl = event.currentTarget.form;\n if (!formEl) return;\n\n const submitEvent = new Event('submit', { bubbles: true, cancelable: true });\n formEl.dispatchEvent(submitEvent);\n\n const submitBtn = formEl.querySelector<HTMLButtonElement>('button[type=\"submit\"]');\n if (submitBtn) {\n submitBtn.click();\n }\n };\n\n const isCheckedObject = typeof checkboxConfig?.checkboxMetadata === 'object' && checkboxConfig?.checkboxMetadata !== null;\n const checkedValue = (isCheckedObject && checkboxConfig?.checkboxMetadata.checkedIds?.includes(id)) || checkboxConfig?.checkedIds?.includes(id);\n const isInputDisabled = isDisabled || rowHasPendingEdits || checkboxConfig?.checkboxMetadata?.checkedIds?.includes(id);\n\n React.useLayoutEffect(() => {\n if (lastFocusedCheckboxId !== id || isInputDisabled) return;\n if (inputRef.current && document.activeElement !== inputRef.current) {\n inputRef.current.focus({ preventScroll: true });\n }\n }, [id, isInputDisabled, checkedValue]);\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === id && !isInlineEditing && !(is_deleted || currentData?.is_deleted) && !(is_added || currentData?.is_added),\n 'bg-error-200 dark:bg-error-900': rowHovering === id && !isInlineEditing && (is_deleted || currentData?.is_deleted),\n 'bg-success-100 dark:bg-success-800': rowHovering === id && !isInlineEditing && (is_added || currentData?.is_added),\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== id && !isInlineEditing,\n 'bg-warning-50 dark:bg-
|
|
1
|
+
{"version":3,"file":"CheckboxCell.es.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/CheckboxCell.tsx"],"sourcesContent":["import { Tooltip } from 'antd';\nimport { useTableConfig } from '../../../../../providers/design-system-provider/hooks';\nimport cn from 'classnames';\nimport React from 'react';\n\nimport { CHECKBOX_PENDING_EDITS_LEFT_OFFSET } from '../../constants';\n\ntype HighlightType = 'SUCCESS' | 'WARNING' | 'ERROR';\n\ntype CheckboxMetadata = {\n checkedIds: string[];\n tooltip: string;\n highlight: HighlightType;\n};\n\ntype TCheckboxCellProps = {\n checkboxConfig: {\n checkboxMetadata: CheckboxMetadata;\n checkedIds: string[];\n selectionDisabledRowIds: CheckboxMetadata;\n onItemCheck: (event: React.ChangeEvent<HTMLInputElement>, id: string) => void;\n };\n id: string;\n rowHovering?: string;\n isDisabled?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n isDraggingOver?: boolean;\n showNewItem?: boolean;\n currentData?: Record<string, unknown>;\n bgColor?: string;\n is_incomplete?: boolean;\n isInlineEditing?: boolean;\n hasPendingEditsColumn?: boolean;\n rowHasPendingEdits?: boolean;\n};\n\nlet lastFocusedCheckboxId: string | null = null;\n\nconst CheckboxCellBase = ({\n checkboxConfig,\n id,\n rowHovering,\n isDisabled,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n isDraggingOver,\n showNewItem,\n currentData,\n bgColor: bgColorProp,\n is_incomplete,\n isInlineEditing,\n hasPendingEditsColumn,\n rowHasPendingEdits,\n}: TCheckboxCellProps) => {\n const tableConfig = useTableConfig();\n const pendingEditsTooltip = tableConfig?.t?.('Save or cancel pending changes first') ?? 'Save or cancel pending changes first';\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== 'Enter') return;\n event.preventDefault();\n const formEl = event.currentTarget.form;\n if (!formEl) return;\n\n const submitEvent = new Event('submit', { bubbles: true, cancelable: true });\n formEl.dispatchEvent(submitEvent);\n\n const submitBtn = formEl.querySelector<HTMLButtonElement>('button[type=\"submit\"]');\n if (submitBtn) {\n submitBtn.click();\n }\n };\n\n const isCheckedObject = typeof checkboxConfig?.checkboxMetadata === 'object' && checkboxConfig?.checkboxMetadata !== null;\n const checkedValue = (isCheckedObject && checkboxConfig?.checkboxMetadata.checkedIds?.includes(id)) || checkboxConfig?.checkedIds?.includes(id);\n const isInputDisabled = isDisabled || rowHasPendingEdits || checkboxConfig?.checkboxMetadata?.checkedIds?.includes(id);\n\n React.useLayoutEffect(() => {\n if (lastFocusedCheckboxId !== id || isInputDisabled) return;\n if (inputRef.current && document.activeElement !== inputRef.current) {\n inputRef.current.focus({ preventScroll: true });\n }\n }, [id, isInputDisabled, checkedValue]);\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === id && !isInlineEditing && !(is_deleted || currentData?.is_deleted) && !(is_added || currentData?.is_added),\n 'bg-error-200 dark:bg-error-900': rowHovering === id && !isInlineEditing && (is_deleted || currentData?.is_deleted),\n 'bg-success-100 dark:bg-success-800': rowHovering === id && !isInlineEditing && (is_added || currentData?.is_added),\n 'bg-warning-100 dark:bg-warning-950': rowHovering === id && !isInlineEditing && (is_incomplete || is_modified || is_row_modified || currentData?.is_row_modified),\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== id && !isInlineEditing,\n 'bg-warning-50 dark:bg-orange-900':\n (is_incomplete || is_modified || is_row_modified || currentData?.is_row_modified) && rowHovering !== id && !isInlineEditing,\n 'bg-error-100 dark:bg-error-975': (is_deleted || currentData?.is_deleted) && rowHovering !== id && !isInlineEditing,\n 'bg-success-50 dark:bg-success-900': (is_added || currentData?.is_added) && rowHovering !== id && !isInlineEditing,\n 'bg-primary-50': isDraggingOver && !isInlineEditing,\n ...(bgColorProp && !isInlineEditing && { [bgColorProp]: true }),\n });\n\n return (\n <td\n className={`min-w-[40px] sticky right-0 z-30 ${bgColor ? bgColor : 'bg-white dark:bg-black-800'} h-row`}\n style={{ left: hasPendingEditsColumn ? CHECKBOX_PENDING_EDITS_LEFT_OFFSET : '0' }}\n >\n <div\n className={`absolute w-full h-row inset-0 px-2.5 z-30 flex items-center justify-center`}\n style={{ boxShadow: '8px 0px 8px 0px rgba(0, 0, 0, 0.02)' }}\n >\n <Tooltip\n title={\n rowHasPendingEdits\n ? pendingEditsTooltip\n : checkboxConfig?.checkboxMetadata?.tooltip && checkboxConfig?.checkboxMetadata?.checkedIds?.includes(id)\n ? checkboxConfig?.checkboxMetadata?.tooltip\n : ''\n }\n >\n <input\n ref={inputRef}\n key={`checkbox-table-search-${id}`}\n id={`checkbox-table-search-${id}`}\n type='checkbox'\n className={`w-4 h-4 text-primary-600 appearance-none border border-gray-400 dark:border-neutral-400 rounded-[4px] checked:appearance-auto focus:ring-primary-500 dark:focus:ring-primary-600 focus:ring-2 cursor-pointer ${bgColor}`}\n onChange={(event) => checkboxConfig?.onItemCheck(event, id)}\n onKeyDown={handleKeyDown}\n onFocus={() => { lastFocusedCheckboxId = id; }}\n onBlur={() => { if (lastFocusedCheckboxId === id) lastFocusedCheckboxId = null; }}\n checked={checkedValue}\n disabled={isInputDisabled}\n />\n </Tooltip>\n <label htmlFor='checkbox-table-search-1' className='sr-only dark:text-neutral-200'>\n {'checkbox'}\n </label>\n </div>\n </td>\n );\n};\n\nexport const CheckboxCell = React.memo(CheckboxCellBase);\n"],"names":["lastFocusedCheckboxId","CheckboxCellBase","checkboxConfig","id","rowHovering","isDisabled","is_read","is_modified","is_row_modified","is_deleted","is_added","isDraggingOver","showNewItem","currentData","bgColorProp","is_incomplete","isInlineEditing","hasPendingEditsColumn","rowHasPendingEdits","pendingEditsTooltip","useTableConfig","inputRef","React","handleKeyDown","event","formEl","submitEvent","submitBtn","checkedValue","isInputDisabled","bgColor","cn","jsx","CHECKBOX_PENDING_EDITS_LEFT_OFFSET","jsxs","Tooltip","CheckboxCell"],"mappings":";;;;;;AAwCA,IAAIA,IAAuC;AAE3C,MAAMC,IAAmB,CAAC;AAAA,EACxB,gBAAAC;AAAA,EACA,IAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,SAASC;AAAA,EACT,eAAA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;AAAA,oBAAM;AAAA,oBAChF,SAAS4B;AAAA,oBACT,UAAUC;AAAA,kBAAA;AAAA,kBATL,yBAAyB1B,CAAE;AAAA,gBAAA;AAAA,cAUlC;AAAA,YAAA;AAAA,8BAED,SAAA,EAAM,SAAQ,2BAA0B,WAAU,iCAChD,UAAA,WAAA,CACH;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN,GAEaiC,IAAed,EAAM,KAAKrB,CAAgB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),L=require("../../../../../utils/formatters.cjs.js"),$=require("@mui/icons-material"),B=require("../../../../../_virtual/index.cjs.js"),u=require("react"),D=require("react-dom"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),L=require("../../../../../utils/formatters.cjs.js"),$=require("@mui/icons-material"),B=require("../../../../../_virtual/index.cjs.js"),u=require("react"),D=require("react-dom"),R=(e,i)=>{if(typeof e=="boolean")return e?"Yes":"No";if(e==null||e==="")return"-";const s=String(e);if(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2})?)?/.test(s)){const n=s.includes("T"),r=L.formatDate(s,{withTime:n,skipTimezone:!0});if(r)return r.length>20?r.substring(0,20)+"...":r}const o=s.length>20?s.substring(0,20)+"...":s;return i?`${o} ${i}`:o},F=({rowId:e,rowIndex:i,pendingEdits:s,tableHeaders:d,rowHasPendingEdits:o,rowHovering:n,isInlineEditing:r,is_read:P,is_modified:k,is_row_modified:y,is_deleted:m,is_added:x,is_incomplete:b,showNewItem:S,onScrollToCell:q})=>{const[v,g]=u.useState(!1),[j,C]=u.useState({top:0,left:0}),l=u.useRef(null),f=u.useRef(null),h=s?.[e],p=u.useMemo(()=>h?Object.entries(h).map(([t,c])=>{const M=d?.find(O=>O.key===t),z=M?.Header||M?.display_name||t;return{columnKey:t,fieldName:z,value:c.value,originalValue:c.originalValue,meta:c.meta,originalMeta:c.originalMeta}}):[],[h,d]),V=t=>{g(!1),l.current&&(clearTimeout(l.current),l.current=null),q?.(e,t,i)},N=()=>{if(o){if(l.current&&(clearTimeout(l.current),l.current=null),f.current){const t=f.current.getBoundingClientRect();C({top:t.top+t.height/2,left:t.right+8})}g(!0)}},T=()=>{l.current=setTimeout(()=>{g(!1)},300)},w=B({"bg-primary-50 dark:bg-primary-900":r,"bg-neutral-100 dark:bg-black-600":n===e&&!r&&!m&&!x,"bg-error-200 dark:bg-error-900":n===e&&!r&&m,"bg-success-100 dark:bg-success-800":n===e&&!r&&x,"bg-warning-100 dark:bg-warning-950":n===e&&!r&&(b||k||y),"bg-primary-50 dark:bg-black-700":!b&&!P&&S&&n!==e&&!r,"bg-warning-50 dark:bg-orange-900":(b||k||y)&&n!==e&&!r,"bg-error-100 dark:bg-error-975":m&&n!==e&&!r,"bg-success-50 dark:bg-success-900":x&&n!==e&&!r});return a.jsxs("td",{className:`min-w-[28px] w-[28px] sticky left-0 z-30 ${w||"bg-white dark:bg-black-800"} h-row`,children:[a.jsx("div",{ref:f,className:"w-full h-row flex items-center justify-center cursor-pointer",onMouseEnter:N,onMouseLeave:T,children:o&&a.jsx("div",{className:"w-5 h-5 rounded-full bg-warning-100 dark:bg-warning-900 flex items-center justify-center shadow-sm border border-warning-200 dark:border-warning-700",children:a.jsx($.EditNoteOutlined,{sx:{fontSize:14},className:"text-warning-600 dark:text-warning-400"})})}),v&&p.length>0&&D.createPortal(a.jsxs("div",{className:"fixed bg-white dark:bg-black-700 rounded-lg shadow-xl border border-neutral-200 dark:border-black-600 py-2 min-w-[200px] max-w-[280px]",style:{top:j.top,left:j.left,transform:"translateY(-50%)",zIndex:99999},onMouseEnter:N,onMouseLeave:T,children:[a.jsxs("div",{className:"px-3 py-1.5 text-xs font-semibold text-neutral-500 dark:text-neutral-400 uppercase tracking-wider border-b border-neutral-100 dark:border-black-600",children:["Pending Changes (",p.length,")"]}),a.jsx("div",{className:"max-h-48 overflow-y-auto",children:p.map((t,c)=>a.jsxs("button",{onClick:()=>V(t.columnKey),className:"w-full px-3 py-2 text-left hover:bg-neutral-50 dark:hover:bg-black-600 transition-colors cursor-pointer",children:[a.jsx("div",{className:"text-xs font-medium text-neutral-700 dark:text-neutral-300 mb-1",children:t.fieldName}),a.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"text-neutral-400 dark:text-neutral-500 line-through truncate max-w-[80px]",children:R(t.originalValue,t.originalMeta?.currency_code)}),a.jsx("span",{className:"text-neutral-400 dark:text-neutral-500 flex-shrink-0",children:"→"}),a.jsx("span",{className:"text-primary-600 dark:text-primary-400 font-medium truncate max-w-[80px]",children:R(t.value,t.meta?.currency_code)})]})]},c))})]}),document.getElementById("full-screen-container")||document.body)]})};exports.PendingEditCell=F;
|
|
2
2
|
//# sourceMappingURL=PendingEditCell.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PendingEditCell.cjs.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/PendingEditCell.tsx"],"sourcesContent":["import { formatDate } from '../../../../../utils/formatters';\nimport { EditNoteOutlined } from '@mui/icons-material';\nimport cn from 'classnames';\nimport React, { useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\ntype TPendingEditCellProps = {\n rowId: string;\n rowIndex: number;\n pendingEdits:\n | Record<string, Record<string, { value: unknown; originalValue?: unknown; meta?: { currency_code?: string | null; [key: string]: unknown | null } | null; originalMeta?: { currency_code?: string | null; [key: string]: unknown | null } | null }>>\n | undefined;\n tableHeaders: Array<{ key?: string; Header?: string; display_name?: string }> | undefined;\n rowHasPendingEdits: boolean;\n rowHovering?: string;\n isInlineEditing?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n is_incomplete?: boolean;\n showNewItem?: boolean;\n onScrollToCell?: (targetRowId: string, columnKey: string, targetRowIndex: number) => void;\n};\n\nconst formatValue = (val: unknown, currencyCode?: string | null): string => {\n if (typeof val === 'boolean') return val ? 'Yes' : 'No';\n if (val === null || val === undefined || val === '') return '-';\n\n const strVal = String(val);\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?)?/;\n if (dateRegex.test(strVal)) {\n const hasTime = strVal.includes('T');\n const formatted = formatDate(strVal, { withTime: hasTime, skipTimezone: true });\n if (formatted) {\n return formatted.length > 20 ? formatted.substring(0, 20) + '...' : formatted;\n }\n }\n\n const display = strVal.length > 20 ? strVal.substring(0, 20) + '...' : strVal;\n if (currencyCode) return `${display} ${currencyCode}`;\n return display;\n};\n\nexport const PendingEditCell: React.FC<TPendingEditCellProps> = ({\n rowId,\n rowIndex,\n pendingEdits,\n tableHeaders,\n rowHasPendingEdits,\n rowHovering,\n isInlineEditing,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n is_incomplete,\n showNewItem,\n onScrollToCell,\n}) => {\n const [showTooltip, setShowTooltip] = useState(false);\n const [tooltipPosition, setTooltipPosition] = useState({ top: 0, left: 0 });\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const iconRef = useRef<HTMLDivElement>(null);\n\n const rowPendingEdits = pendingEdits?.[rowId];\n\n const editedFields = useMemo(\n () =>\n rowPendingEdits\n ? Object.entries(rowPendingEdits).map(([columnKey, edit]) => {\n const column = tableHeaders?.find((col) => col.key === columnKey);\n const fieldName = column?.Header || column?.display_name || columnKey;\n return { columnKey, fieldName, value: edit.value, originalValue: edit.originalValue, meta: edit.meta, originalMeta: edit.originalMeta };\n })\n : [],\n [rowPendingEdits, tableHeaders],\n );\n\n const handleFieldClick = (columnKey: string) => {\n setShowTooltip(false);\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n onScrollToCell?.(rowId, columnKey, rowIndex);\n };\n\n const handleMouseEnter = () => {\n if (!rowHasPendingEdits) return;\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n if (iconRef.current) {\n const rect = iconRef.current.getBoundingClientRect();\n setTooltipPosition({ top: rect.top + rect.height / 2, left: rect.right + 8 });\n }\n setShowTooltip(true);\n };\n\n const handleMouseLeave = () => {\n hideTimeoutRef.current = setTimeout(() => { setShowTooltip(false); }, 300);\n };\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === rowId && !isInlineEditing && !is_deleted && !is_added,\n 'bg-error-200 dark:bg-error-900': rowHovering === rowId && !isInlineEditing && is_deleted,\n 'bg-success-100 dark:bg-success-800': rowHovering === rowId && !isInlineEditing && is_added,\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== rowId && !isInlineEditing,\n 'bg-warning-50 dark:bg-black-500': (is_incomplete || is_modified || is_row_modified) && rowHovering !== rowId && !isInlineEditing,\n 'bg-error-100 dark:bg-error-975': is_deleted && rowHovering !== rowId && !isInlineEditing,\n 'bg-success-50 dark:bg-success-900': is_added && rowHovering !== rowId && !isInlineEditing,\n });\n\n return (\n <td className={`min-w-[28px] w-[28px] sticky left-0 z-30 ${bgColor ? bgColor : 'bg-white dark:bg-black-800'} h-row`}>\n <div ref={iconRef} className='w-full h-row flex items-center justify-center cursor-pointer' onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>\n {rowHasPendingEdits && (\n <div className='w-5 h-5 rounded-full bg-warning-100 dark:bg-warning-900 flex items-center justify-center shadow-sm border border-warning-200 dark:border-warning-700'>\n <EditNoteOutlined sx={{ fontSize: 14 }} className='text-warning-600 dark:text-warning-400' />\n </div>\n )}\n </div>\n {showTooltip && editedFields.length > 0 &&\n createPortal(\n <div\n className='fixed bg-white dark:bg-black-700 rounded-lg shadow-xl border border-neutral-200 dark:border-black-600 py-2 min-w-[200px] max-w-[280px]'\n style={{ top: tooltipPosition.top, left: tooltipPosition.left, transform: 'translateY(-50%)', zIndex: 99999 }}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <div className='px-3 py-1.5 text-xs font-semibold text-neutral-500 dark:text-neutral-400 uppercase tracking-wider border-b border-neutral-100 dark:border-black-600'>\n Pending Changes ({editedFields.length})\n </div>\n <div className='max-h-48 overflow-y-auto'>\n {editedFields.map((field, idx) => (\n <button key={idx} onClick={() => handleFieldClick(field.columnKey)} className='w-full px-3 py-2 text-left hover:bg-neutral-50 dark:hover:bg-black-600 transition-colors cursor-pointer'>\n <div className='text-xs font-medium text-neutral-700 dark:text-neutral-300 mb-1'>{field.fieldName}</div>\n <div className='flex items-center gap-1.5 text-xs'>\n <span className='text-neutral-400 dark:text-neutral-500 line-through truncate max-w-[80px]'>{formatValue(field.originalValue, field.originalMeta?.currency_code)}</span>\n <span className='text-neutral-400 dark:text-neutral-500 flex-shrink-0'>→</span>\n <span className='text-primary-600 dark:text-primary-400 font-medium truncate max-w-[80px]'>{formatValue(field.value, field.meta?.currency_code)}</span>\n </div>\n </button>\n ))}\n </div>\n </div>,\n document.getElementById('full-screen-container') || document.body,\n )}\n </td>\n );\n};\n"],"names":["formatValue","val","currencyCode","strVal","hasTime","formatted","formatDate","display","PendingEditCell","rowId","rowIndex","pendingEdits","tableHeaders","rowHasPendingEdits","rowHovering","isInlineEditing","is_read","is_modified","is_row_modified","is_deleted","is_added","is_incomplete","showNewItem","onScrollToCell","showTooltip","setShowTooltip","useState","tooltipPosition","setTooltipPosition","hideTimeoutRef","useRef","iconRef","rowPendingEdits","editedFields","useMemo","columnKey","edit","column","col","fieldName","handleFieldClick","handleMouseEnter","rect","handleMouseLeave","bgColor","cn","jsx","EditNoteOutlined","createPortal","jsxs","field","idx"],"mappings":"sSA0BMA,EAAc,CAACC,EAAcC,IAAyC,CAC1E,GAAI,OAAOD,GAAQ,UAAW,OAAOA,EAAM,MA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,UAAU,uJACb,SAAAA,EAAAA,IAACC,EAAAA,iBAAA,CAAiB,GAAI,CAAE,SAAU,IAAM,UAAU,wCAAA,CAAyC,CAAA,CAC7F,CAAA,CAEJ,EACCvB,GAAeS,EAAa,OAAS,GACpCe,EAAAA,aACEC,EAAAA,KAAC,MAAA,CACC,UAAU,yIACV,MAAO,CAAE,IAAKtB,EAAgB,IAAK,KAAMA,EAAgB,KAAM,UAAW,mBAAoB,OAAQ,KAAA,EACtG,aAAcc,EACd,aAAcE,EAEd,SAAA,CAAAM,EAAAA,KAAC,MAAA,CAAI,UAAU,sJAAsJ,SAAA,CAAA,oBACjJhB,EAAa,OAAO,GAAA,EACxC,QACC,MAAA,CAAI,UAAU,2BACZ,SAAAA,EAAa,IAAI,CAACiB,EAAOC,IACxBF,EAAAA,KAAC,SAAA,CAAiB,QAAS,IAAMT,EAAiBU,EAAM,SAAS,EAAG,UAAU,0GAC5E,SAAA,CAAAJ,EAAAA,IAAC,MAAA,CAAI,UAAU,kEAAmE,SAAAI,EAAM,UAAU,EAClGD,EAAAA,KAAC,MAAA,CAAI,UAAU,oCACb,SAAA,CAAAH,EAAAA,IAAC,OAAA,CAAK,UAAU,4EAA6E,SAAA9C,EAAYkD,EAAM,cAAeA,EAAM,cAAc,aAAa,CAAA,CAAE,EACjKJ,EAAAA,IAAC,OAAA,CAAK,UAAU,uDAAuD,SAAA,IAAC,EACxEA,EAAAA,IAAC,OAAA,CAAK,UAAU,2EAA4E,SAAA9C,EAAYkD,EAAM,MAAOA,EAAM,MAAM,aAAa,CAAA,CAAE,CAAA,CAAA,CAClJ,CAAA,CAAA,EANWC,CAOb,CACD,CAAA,CACH,CAAA,CAAA,CAAA,EAEF,SAAS,eAAe,uBAAuB,GAAK,SAAS,IAAA,CAC/D,EACJ,CAEJ"}
|
|
1
|
+
{"version":3,"file":"PendingEditCell.cjs.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/PendingEditCell.tsx"],"sourcesContent":["import { formatDate } from '../../../../../utils/formatters';\nimport { EditNoteOutlined } from '@mui/icons-material';\nimport cn from 'classnames';\nimport React, { useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\ntype TPendingEditCellProps = {\n rowId: string;\n rowIndex: number;\n pendingEdits:\n | Record<string, Record<string, { value: unknown; originalValue?: unknown; meta?: { currency_code?: string | null; [key: string]: unknown | null } | null; originalMeta?: { currency_code?: string | null; [key: string]: unknown | null } | null }>>\n | undefined;\n tableHeaders: Array<{ key?: string; Header?: string; display_name?: string }> | undefined;\n rowHasPendingEdits: boolean;\n rowHovering?: string;\n isInlineEditing?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n is_incomplete?: boolean;\n showNewItem?: boolean;\n onScrollToCell?: (targetRowId: string, columnKey: string, targetRowIndex: number) => void;\n};\n\nconst formatValue = (val: unknown, currencyCode?: string | null): string => {\n if (typeof val === 'boolean') return val ? 'Yes' : 'No';\n if (val === null || val === undefined || val === '') return '-';\n\n const strVal = String(val);\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?)?/;\n if (dateRegex.test(strVal)) {\n const hasTime = strVal.includes('T');\n const formatted = formatDate(strVal, { withTime: hasTime, skipTimezone: true });\n if (formatted) {\n return formatted.length > 20 ? formatted.substring(0, 20) + '...' : formatted;\n }\n }\n\n const display = strVal.length > 20 ? strVal.substring(0, 20) + '...' : strVal;\n if (currencyCode) return `${display} ${currencyCode}`;\n return display;\n};\n\nexport const PendingEditCell: React.FC<TPendingEditCellProps> = ({\n rowId,\n rowIndex,\n pendingEdits,\n tableHeaders,\n rowHasPendingEdits,\n rowHovering,\n isInlineEditing,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n is_incomplete,\n showNewItem,\n onScrollToCell,\n}) => {\n const [showTooltip, setShowTooltip] = useState(false);\n const [tooltipPosition, setTooltipPosition] = useState({ top: 0, left: 0 });\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const iconRef = useRef<HTMLDivElement>(null);\n\n const rowPendingEdits = pendingEdits?.[rowId];\n\n const editedFields = useMemo(\n () =>\n rowPendingEdits\n ? Object.entries(rowPendingEdits).map(([columnKey, edit]) => {\n const column = tableHeaders?.find((col) => col.key === columnKey);\n const fieldName = column?.Header || column?.display_name || columnKey;\n return { columnKey, fieldName, value: edit.value, originalValue: edit.originalValue, meta: edit.meta, originalMeta: edit.originalMeta };\n })\n : [],\n [rowPendingEdits, tableHeaders],\n );\n\n const handleFieldClick = (columnKey: string) => {\n setShowTooltip(false);\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n onScrollToCell?.(rowId, columnKey, rowIndex);\n };\n\n const handleMouseEnter = () => {\n if (!rowHasPendingEdits) return;\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n if (iconRef.current) {\n const rect = iconRef.current.getBoundingClientRect();\n setTooltipPosition({ top: rect.top + rect.height / 2, left: rect.right + 8 });\n }\n setShowTooltip(true);\n };\n\n const handleMouseLeave = () => {\n hideTimeoutRef.current = setTimeout(() => { setShowTooltip(false); }, 300);\n };\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === rowId && !isInlineEditing && !is_deleted && !is_added,\n 'bg-error-200 dark:bg-error-900': rowHovering === rowId && !isInlineEditing && is_deleted,\n 'bg-success-100 dark:bg-success-800': rowHovering === rowId && !isInlineEditing && is_added,\n 'bg-warning-100 dark:bg-warning-950': rowHovering === rowId && !isInlineEditing && (is_incomplete || is_modified || is_row_modified),\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== rowId && !isInlineEditing,\n 'bg-warning-50 dark:bg-orange-900': (is_incomplete || is_modified || is_row_modified) && rowHovering !== rowId && !isInlineEditing,\n 'bg-error-100 dark:bg-error-975': is_deleted && rowHovering !== rowId && !isInlineEditing,\n 'bg-success-50 dark:bg-success-900': is_added && rowHovering !== rowId && !isInlineEditing,\n });\n\n return (\n <td className={`min-w-[28px] w-[28px] sticky left-0 z-30 ${bgColor ? bgColor : 'bg-white dark:bg-black-800'} h-row`}>\n <div ref={iconRef} className='w-full h-row flex items-center justify-center cursor-pointer' onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>\n {rowHasPendingEdits && (\n <div className='w-5 h-5 rounded-full bg-warning-100 dark:bg-warning-900 flex items-center justify-center shadow-sm border border-warning-200 dark:border-warning-700'>\n <EditNoteOutlined sx={{ fontSize: 14 }} className='text-warning-600 dark:text-warning-400' />\n </div>\n )}\n </div>\n {showTooltip && editedFields.length > 0 &&\n createPortal(\n <div\n className='fixed bg-white dark:bg-black-700 rounded-lg shadow-xl border border-neutral-200 dark:border-black-600 py-2 min-w-[200px] max-w-[280px]'\n style={{ top: tooltipPosition.top, left: tooltipPosition.left, transform: 'translateY(-50%)', zIndex: 99999 }}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <div className='px-3 py-1.5 text-xs font-semibold text-neutral-500 dark:text-neutral-400 uppercase tracking-wider border-b border-neutral-100 dark:border-black-600'>\n Pending Changes ({editedFields.length})\n </div>\n <div className='max-h-48 overflow-y-auto'>\n {editedFields.map((field, idx) => (\n <button key={idx} onClick={() => handleFieldClick(field.columnKey)} className='w-full px-3 py-2 text-left hover:bg-neutral-50 dark:hover:bg-black-600 transition-colors cursor-pointer'>\n <div className='text-xs font-medium text-neutral-700 dark:text-neutral-300 mb-1'>{field.fieldName}</div>\n <div className='flex items-center gap-1.5 text-xs'>\n <span className='text-neutral-400 dark:text-neutral-500 line-through truncate max-w-[80px]'>{formatValue(field.originalValue, field.originalMeta?.currency_code)}</span>\n <span className='text-neutral-400 dark:text-neutral-500 flex-shrink-0'>→</span>\n <span className='text-primary-600 dark:text-primary-400 font-medium truncate max-w-[80px]'>{formatValue(field.value, field.meta?.currency_code)}</span>\n </div>\n </button>\n ))}\n </div>\n </div>,\n document.getElementById('full-screen-container') || document.body,\n )}\n </td>\n );\n};\n"],"names":["formatValue","val","currencyCode","strVal","hasTime","formatted","formatDate","display","PendingEditCell","rowId","rowIndex","pendingEdits","tableHeaders","rowHasPendingEdits","rowHovering","isInlineEditing","is_read","is_modified","is_row_modified","is_deleted","is_added","is_incomplete","showNewItem","onScrollToCell","showTooltip","setShowTooltip","useState","tooltipPosition","setTooltipPosition","hideTimeoutRef","useRef","iconRef","rowPendingEdits","editedFields","useMemo","columnKey","edit","column","col","fieldName","handleFieldClick","handleMouseEnter","rect","handleMouseLeave","bgColor","cn","jsx","EditNoteOutlined","createPortal","jsxs","field","idx"],"mappings":"sSA0BMA,EAAc,CAACC,EAAcC,IAAyC,CAC1E,GAAI,OAAOD,GAAQ,UAAW,OAAOA,EAAM,MAAQ,KACnD,GAAIA,GAAQ,MAA6BA,IAAQ,GAAI,MAAO,IAE5D,MAAME,EAAS,OAAOF,CAAG,EAEzB,GADkB,6CACJ,KAAKE,CAAM,EAAG,CAC1B,MAAMC,EAAUD,EAAO,SAAS,GAAG,EAC7BE,EAAYC,EAAAA,WAAWH,EAAQ,CAAE,SAAUC,EAAS,aAAc,GAAM,EAC9E,GAAIC,EACF,OAAOA,EAAU,OAAS,GAAKA,EAAU,UAAU,EAAG,EAAE,EAAI,MAAQA,CAExE,CAEA,MAAME,EAAUJ,EAAO,OAAS,GAAKA,EAAO,UAAU,EAAG,EAAE,EAAI,MAAQA,EACvE,OAAID,EAAqB,GAAGK,CAAO,IAAIL,CAAY,GAC5CK,CACT,EAEaC,EAAmD,CAAC,CAC/D,MAAAC,EACA,SAAAC,EACA,aAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,SAAAC,EACA,cAAAC,EACA,YAAAC,EACA,eAAA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MAAA,CAAI,UAAU,kEAAmE,SAAAI,EAAM,UAAU,EAClGD,EAAAA,KAAC,MAAA,CAAI,UAAU,oCACb,SAAA,CAAAH,EAAAA,IAAC,OAAA,CAAK,UAAU,4EAA6E,SAAA9C,EAAYkD,EAAM,cAAeA,EAAM,cAAc,aAAa,CAAA,CAAE,EACjKJ,EAAAA,IAAC,OAAA,CAAK,UAAU,uDAAuD,SAAA,IAAC,EACxEA,EAAAA,IAAC,OAAA,CAAK,UAAU,2EAA4E,SAAA9C,EAAYkD,EAAM,MAAOA,EAAM,MAAM,aAAa,CAAA,CAAE,CAAA,CAAA,CAClJ,CAAA,CAAA,EANWC,CAOb,CACD,CAAA,CACH,CAAA,CAAA,CAAA,EAEF,SAAS,eAAe,uBAAuB,GAAK,SAAS,IAAA,CAC/D,EACJ,CAEJ"}
|
|
@@ -2,9 +2,9 @@ import { jsxs as u, jsx as o } from "react/jsx-runtime";
|
|
|
2
2
|
import { formatDate as O } from "../../../../../utils/formatters.es.js";
|
|
3
3
|
import { EditNoteOutlined as Y } from "@mui/icons-material";
|
|
4
4
|
import D from "../../../../../_virtual/index.es.js";
|
|
5
|
-
import { useState as
|
|
5
|
+
import { useState as j, useRef as v, useMemo as q } from "react";
|
|
6
6
|
import { createPortal as A } from "react-dom";
|
|
7
|
-
const
|
|
7
|
+
const C = (e, i) => {
|
|
8
8
|
if (typeof e == "boolean") return e ? "Yes" : "No";
|
|
9
9
|
if (e == null || e === "") return "-";
|
|
10
10
|
const n = String(e);
|
|
@@ -23,67 +23,68 @@ const R = (e, i) => {
|
|
|
23
23
|
rowHasPendingEdits: c,
|
|
24
24
|
rowHovering: a,
|
|
25
25
|
isInlineEditing: r,
|
|
26
|
-
is_read:
|
|
27
|
-
is_modified:
|
|
28
|
-
is_row_modified:
|
|
26
|
+
is_read: P,
|
|
27
|
+
is_modified: k,
|
|
28
|
+
is_row_modified: y,
|
|
29
29
|
is_deleted: d,
|
|
30
30
|
is_added: b,
|
|
31
|
-
is_incomplete:
|
|
31
|
+
is_incomplete: g,
|
|
32
32
|
showNewItem: V,
|
|
33
33
|
onScrollToCell: z
|
|
34
34
|
}) => {
|
|
35
|
-
const [S, f] =
|
|
36
|
-
() =>
|
|
37
|
-
const
|
|
35
|
+
const [S, f] = j(!1), [N, L] = j({ top: 0, left: 0 }), l = v(null), p = v(null), x = n?.[e], h = q(
|
|
36
|
+
() => x ? Object.entries(x).map(([t, s]) => {
|
|
37
|
+
const R = m?.find((F) => F.key === t), B = R?.Header || R?.display_name || t;
|
|
38
38
|
return { columnKey: t, fieldName: B, value: s.value, originalValue: s.originalValue, meta: s.meta, originalMeta: s.originalMeta };
|
|
39
39
|
}) : [],
|
|
40
|
-
[
|
|
40
|
+
[x, m]
|
|
41
41
|
), $ = (t) => {
|
|
42
42
|
f(!1), l.current && (clearTimeout(l.current), l.current = null), z?.(e, t, i);
|
|
43
|
-
},
|
|
43
|
+
}, w = () => {
|
|
44
44
|
if (c) {
|
|
45
|
-
if (l.current && (clearTimeout(l.current), l.current = null),
|
|
46
|
-
const t =
|
|
45
|
+
if (l.current && (clearTimeout(l.current), l.current = null), p.current) {
|
|
46
|
+
const t = p.current.getBoundingClientRect();
|
|
47
47
|
L({ top: t.top + t.height / 2, left: t.right + 8 });
|
|
48
48
|
}
|
|
49
49
|
f(!0);
|
|
50
50
|
}
|
|
51
|
-
},
|
|
51
|
+
}, T = () => {
|
|
52
52
|
l.current = setTimeout(() => {
|
|
53
53
|
f(!1);
|
|
54
54
|
}, 300);
|
|
55
|
-
},
|
|
55
|
+
}, M = D({
|
|
56
56
|
"bg-primary-50 dark:bg-primary-900": r,
|
|
57
57
|
"bg-neutral-100 dark:bg-black-600": a === e && !r && !d && !b,
|
|
58
58
|
"bg-error-200 dark:bg-error-900": a === e && !r && d,
|
|
59
59
|
"bg-success-100 dark:bg-success-800": a === e && !r && b,
|
|
60
|
-
"bg-
|
|
61
|
-
"bg-
|
|
60
|
+
"bg-warning-100 dark:bg-warning-950": a === e && !r && (g || k || y),
|
|
61
|
+
"bg-primary-50 dark:bg-black-700": !g && !P && V && a !== e && !r,
|
|
62
|
+
"bg-warning-50 dark:bg-orange-900": (g || k || y) && a !== e && !r,
|
|
62
63
|
"bg-error-100 dark:bg-error-975": d && a !== e && !r,
|
|
63
64
|
"bg-success-50 dark:bg-success-900": b && a !== e && !r
|
|
64
65
|
});
|
|
65
|
-
return /* @__PURE__ */ u("td", { className: `min-w-[28px] w-[28px] sticky left-0 z-30 ${
|
|
66
|
-
/* @__PURE__ */ o("div", { ref:
|
|
67
|
-
S &&
|
|
66
|
+
return /* @__PURE__ */ u("td", { className: `min-w-[28px] w-[28px] sticky left-0 z-30 ${M || "bg-white dark:bg-black-800"} h-row`, children: [
|
|
67
|
+
/* @__PURE__ */ o("div", { ref: p, className: "w-full h-row flex items-center justify-center cursor-pointer", onMouseEnter: w, onMouseLeave: T, children: c && /* @__PURE__ */ o("div", { className: "w-5 h-5 rounded-full bg-warning-100 dark:bg-warning-900 flex items-center justify-center shadow-sm border border-warning-200 dark:border-warning-700", children: /* @__PURE__ */ o(Y, { sx: { fontSize: 14 }, className: "text-warning-600 dark:text-warning-400" }) }) }),
|
|
68
|
+
S && h.length > 0 && A(
|
|
68
69
|
/* @__PURE__ */ u(
|
|
69
70
|
"div",
|
|
70
71
|
{
|
|
71
72
|
className: "fixed bg-white dark:bg-black-700 rounded-lg shadow-xl border border-neutral-200 dark:border-black-600 py-2 min-w-[200px] max-w-[280px]",
|
|
72
|
-
style: { top:
|
|
73
|
-
onMouseEnter:
|
|
74
|
-
onMouseLeave:
|
|
73
|
+
style: { top: N.top, left: N.left, transform: "translateY(-50%)", zIndex: 99999 },
|
|
74
|
+
onMouseEnter: w,
|
|
75
|
+
onMouseLeave: T,
|
|
75
76
|
children: [
|
|
76
77
|
/* @__PURE__ */ u("div", { className: "px-3 py-1.5 text-xs font-semibold text-neutral-500 dark:text-neutral-400 uppercase tracking-wider border-b border-neutral-100 dark:border-black-600", children: [
|
|
77
78
|
"Pending Changes (",
|
|
78
|
-
|
|
79
|
+
h.length,
|
|
79
80
|
")"
|
|
80
81
|
] }),
|
|
81
|
-
/* @__PURE__ */ o("div", { className: "max-h-48 overflow-y-auto", children:
|
|
82
|
+
/* @__PURE__ */ o("div", { className: "max-h-48 overflow-y-auto", children: h.map((t, s) => /* @__PURE__ */ u("button", { onClick: () => $(t.columnKey), className: "w-full px-3 py-2 text-left hover:bg-neutral-50 dark:hover:bg-black-600 transition-colors cursor-pointer", children: [
|
|
82
83
|
/* @__PURE__ */ o("div", { className: "text-xs font-medium text-neutral-700 dark:text-neutral-300 mb-1", children: t.fieldName }),
|
|
83
84
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-1.5 text-xs", children: [
|
|
84
|
-
/* @__PURE__ */ o("span", { className: "text-neutral-400 dark:text-neutral-500 line-through truncate max-w-[80px]", children:
|
|
85
|
+
/* @__PURE__ */ o("span", { className: "text-neutral-400 dark:text-neutral-500 line-through truncate max-w-[80px]", children: C(t.originalValue, t.originalMeta?.currency_code) }),
|
|
85
86
|
/* @__PURE__ */ o("span", { className: "text-neutral-400 dark:text-neutral-500 flex-shrink-0", children: "→" }),
|
|
86
|
-
/* @__PURE__ */ o("span", { className: "text-primary-600 dark:text-primary-400 font-medium truncate max-w-[80px]", children:
|
|
87
|
+
/* @__PURE__ */ o("span", { className: "text-primary-600 dark:text-primary-400 font-medium truncate max-w-[80px]", children: C(t.value, t.meta?.currency_code) })
|
|
87
88
|
] })
|
|
88
89
|
] }, s)) })
|
|
89
90
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PendingEditCell.es.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/PendingEditCell.tsx"],"sourcesContent":["import { formatDate } from '../../../../../utils/formatters';\nimport { EditNoteOutlined } from '@mui/icons-material';\nimport cn from 'classnames';\nimport React, { useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\ntype TPendingEditCellProps = {\n rowId: string;\n rowIndex: number;\n pendingEdits:\n | Record<string, Record<string, { value: unknown; originalValue?: unknown; meta?: { currency_code?: string | null; [key: string]: unknown | null } | null; originalMeta?: { currency_code?: string | null; [key: string]: unknown | null } | null }>>\n | undefined;\n tableHeaders: Array<{ key?: string; Header?: string; display_name?: string }> | undefined;\n rowHasPendingEdits: boolean;\n rowHovering?: string;\n isInlineEditing?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n is_incomplete?: boolean;\n showNewItem?: boolean;\n onScrollToCell?: (targetRowId: string, columnKey: string, targetRowIndex: number) => void;\n};\n\nconst formatValue = (val: unknown, currencyCode?: string | null): string => {\n if (typeof val === 'boolean') return val ? 'Yes' : 'No';\n if (val === null || val === undefined || val === '') return '-';\n\n const strVal = String(val);\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?)?/;\n if (dateRegex.test(strVal)) {\n const hasTime = strVal.includes('T');\n const formatted = formatDate(strVal, { withTime: hasTime, skipTimezone: true });\n if (formatted) {\n return formatted.length > 20 ? formatted.substring(0, 20) + '...' : formatted;\n }\n }\n\n const display = strVal.length > 20 ? strVal.substring(0, 20) + '...' : strVal;\n if (currencyCode) return `${display} ${currencyCode}`;\n return display;\n};\n\nexport const PendingEditCell: React.FC<TPendingEditCellProps> = ({\n rowId,\n rowIndex,\n pendingEdits,\n tableHeaders,\n rowHasPendingEdits,\n rowHovering,\n isInlineEditing,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n is_incomplete,\n showNewItem,\n onScrollToCell,\n}) => {\n const [showTooltip, setShowTooltip] = useState(false);\n const [tooltipPosition, setTooltipPosition] = useState({ top: 0, left: 0 });\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const iconRef = useRef<HTMLDivElement>(null);\n\n const rowPendingEdits = pendingEdits?.[rowId];\n\n const editedFields = useMemo(\n () =>\n rowPendingEdits\n ? Object.entries(rowPendingEdits).map(([columnKey, edit]) => {\n const column = tableHeaders?.find((col) => col.key === columnKey);\n const fieldName = column?.Header || column?.display_name || columnKey;\n return { columnKey, fieldName, value: edit.value, originalValue: edit.originalValue, meta: edit.meta, originalMeta: edit.originalMeta };\n })\n : [],\n [rowPendingEdits, tableHeaders],\n );\n\n const handleFieldClick = (columnKey: string) => {\n setShowTooltip(false);\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n onScrollToCell?.(rowId, columnKey, rowIndex);\n };\n\n const handleMouseEnter = () => {\n if (!rowHasPendingEdits) return;\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n if (iconRef.current) {\n const rect = iconRef.current.getBoundingClientRect();\n setTooltipPosition({ top: rect.top + rect.height / 2, left: rect.right + 8 });\n }\n setShowTooltip(true);\n };\n\n const handleMouseLeave = () => {\n hideTimeoutRef.current = setTimeout(() => { setShowTooltip(false); }, 300);\n };\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === rowId && !isInlineEditing && !is_deleted && !is_added,\n 'bg-error-200 dark:bg-error-900': rowHovering === rowId && !isInlineEditing && is_deleted,\n 'bg-success-100 dark:bg-success-800': rowHovering === rowId && !isInlineEditing && is_added,\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== rowId && !isInlineEditing,\n 'bg-warning-50 dark:bg-black-500': (is_incomplete || is_modified || is_row_modified) && rowHovering !== rowId && !isInlineEditing,\n 'bg-error-100 dark:bg-error-975': is_deleted && rowHovering !== rowId && !isInlineEditing,\n 'bg-success-50 dark:bg-success-900': is_added && rowHovering !== rowId && !isInlineEditing,\n });\n\n return (\n <td className={`min-w-[28px] w-[28px] sticky left-0 z-30 ${bgColor ? bgColor : 'bg-white dark:bg-black-800'} h-row`}>\n <div ref={iconRef} className='w-full h-row flex items-center justify-center cursor-pointer' onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>\n {rowHasPendingEdits && (\n <div className='w-5 h-5 rounded-full bg-warning-100 dark:bg-warning-900 flex items-center justify-center shadow-sm border border-warning-200 dark:border-warning-700'>\n <EditNoteOutlined sx={{ fontSize: 14 }} className='text-warning-600 dark:text-warning-400' />\n </div>\n )}\n </div>\n {showTooltip && editedFields.length > 0 &&\n createPortal(\n <div\n className='fixed bg-white dark:bg-black-700 rounded-lg shadow-xl border border-neutral-200 dark:border-black-600 py-2 min-w-[200px] max-w-[280px]'\n style={{ top: tooltipPosition.top, left: tooltipPosition.left, transform: 'translateY(-50%)', zIndex: 99999 }}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <div className='px-3 py-1.5 text-xs font-semibold text-neutral-500 dark:text-neutral-400 uppercase tracking-wider border-b border-neutral-100 dark:border-black-600'>\n Pending Changes ({editedFields.length})\n </div>\n <div className='max-h-48 overflow-y-auto'>\n {editedFields.map((field, idx) => (\n <button key={idx} onClick={() => handleFieldClick(field.columnKey)} className='w-full px-3 py-2 text-left hover:bg-neutral-50 dark:hover:bg-black-600 transition-colors cursor-pointer'>\n <div className='text-xs font-medium text-neutral-700 dark:text-neutral-300 mb-1'>{field.fieldName}</div>\n <div className='flex items-center gap-1.5 text-xs'>\n <span className='text-neutral-400 dark:text-neutral-500 line-through truncate max-w-[80px]'>{formatValue(field.originalValue, field.originalMeta?.currency_code)}</span>\n <span className='text-neutral-400 dark:text-neutral-500 flex-shrink-0'>→</span>\n <span className='text-primary-600 dark:text-primary-400 font-medium truncate max-w-[80px]'>{formatValue(field.value, field.meta?.currency_code)}</span>\n </div>\n </button>\n ))}\n </div>\n </div>,\n document.getElementById('full-screen-container') || document.body,\n )}\n </td>\n );\n};\n"],"names":["formatValue","val","currencyCode","strVal","hasTime","formatted","formatDate","display","PendingEditCell","rowId","rowIndex","pendingEdits","tableHeaders","rowHasPendingEdits","rowHovering","isInlineEditing","is_read","is_modified","is_row_modified","is_deleted","is_added","is_incomplete","showNewItem","onScrollToCell","showTooltip","setShowTooltip","useState","tooltipPosition","setTooltipPosition","hideTimeoutRef","useRef","iconRef","rowPendingEdits","editedFields","useMemo","columnKey","edit","column","col","fieldName","handleFieldClick","handleMouseEnter","rect","handleMouseLeave","bgColor","cn","jsx","EditNoteOutlined","createPortal","jsxs","field","idx"],"mappings":";;;;;;AA0BA,MAAMA,IAAc,CAACC,GAAcC,MAAyC;AAC1E,MAAI,OAAOD,KAAQ,UAAW,QAAOA,IAAM,QAAQ;AACnD,MAAIA,KAAQ,QAA6BA,MAAQ,GAAI,QAAO;AAE5D,QAAME,IAAS,OAAOF,CAAG;AAEzB,MADkB,6CACJ,KAAKE,CAAM,GAAG;AAC1B,UAAMC,IAAUD,EAAO,SAAS,GAAG,GAC7BE,IAAYC,EAAWH,GAAQ,EAAE,UAAUC,GAAS,cAAc,IAAM;AAC9E,QAAIC;AACF,aAAOA,EAAU,SAAS,KAAKA,EAAU,UAAU,GAAG,EAAE,IAAI,QAAQA;AAAA,EAExE;AAEA,QAAME,IAAUJ,EAAO,SAAS,KAAKA,EAAO,UAAU,GAAG,EAAE,IAAI,QAAQA;AACvE,SAAID,IAAqB,GAAGK,CAAO,IAAIL,CAAY,KAC5CK;AACT,GAEaC,IAAmD,CAAC;AAAA,EAC/D,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,aAAAC;AAAA,EACA,gBAAAC;AACF,MAAM;AACJ,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAK,GAC9C,CAACC,GAAiBC,CAAkB,IAAIF,EAAS,EAAE,KAAK,GA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A;AAAA,cAAA,gBAAAJ,EAAC,OAAA,EAAI,WAAU,mEAAmE,UAAAI,EAAM,WAAU;AAAA,cAClG,gBAAAD,EAAC,OAAA,EAAI,WAAU,qCACb,UAAA;AAAA,gBAAA,gBAAAH,EAAC,QAAA,EAAK,WAAU,6EAA6E,UAAA9C,EAAYkD,EAAM,eAAeA,EAAM,cAAc,aAAa,EAAA,CAAE;AAAA,gBACjK,gBAAAJ,EAAC,QAAA,EAAK,WAAU,wDAAuD,UAAA,KAAC;AAAA,gBACxE,gBAAAA,EAAC,QAAA,EAAK,WAAU,4EAA4E,UAAA9C,EAAYkD,EAAM,OAAOA,EAAM,MAAM,aAAa,EAAA,CAAE;AAAA,cAAA,EAAA,CAClJ;AAAA,YAAA,EAAA,GANWC,CAOb,CACD,EAAA,CACH;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAEF,SAAS,eAAe,uBAAuB,KAAK,SAAS;AAAA,IAAA;AAAA,EAC/D,GACJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"PendingEditCell.es.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/PendingEditCell.tsx"],"sourcesContent":["import { formatDate } from '../../../../../utils/formatters';\nimport { EditNoteOutlined } from '@mui/icons-material';\nimport cn from 'classnames';\nimport React, { useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\ntype TPendingEditCellProps = {\n rowId: string;\n rowIndex: number;\n pendingEdits:\n | Record<string, Record<string, { value: unknown; originalValue?: unknown; meta?: { currency_code?: string | null; [key: string]: unknown | null } | null; originalMeta?: { currency_code?: string | null; [key: string]: unknown | null } | null }>>\n | undefined;\n tableHeaders: Array<{ key?: string; Header?: string; display_name?: string }> | undefined;\n rowHasPendingEdits: boolean;\n rowHovering?: string;\n isInlineEditing?: boolean;\n is_read?: boolean;\n is_modified?: boolean;\n is_row_modified?: boolean;\n is_deleted?: boolean;\n is_added?: boolean;\n is_incomplete?: boolean;\n showNewItem?: boolean;\n onScrollToCell?: (targetRowId: string, columnKey: string, targetRowIndex: number) => void;\n};\n\nconst formatValue = (val: unknown, currencyCode?: string | null): string => {\n if (typeof val === 'boolean') return val ? 'Yes' : 'No';\n if (val === null || val === undefined || val === '') return '-';\n\n const strVal = String(val);\n const dateRegex = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2})?)?/;\n if (dateRegex.test(strVal)) {\n const hasTime = strVal.includes('T');\n const formatted = formatDate(strVal, { withTime: hasTime, skipTimezone: true });\n if (formatted) {\n return formatted.length > 20 ? formatted.substring(0, 20) + '...' : formatted;\n }\n }\n\n const display = strVal.length > 20 ? strVal.substring(0, 20) + '...' : strVal;\n if (currencyCode) return `${display} ${currencyCode}`;\n return display;\n};\n\nexport const PendingEditCell: React.FC<TPendingEditCellProps> = ({\n rowId,\n rowIndex,\n pendingEdits,\n tableHeaders,\n rowHasPendingEdits,\n rowHovering,\n isInlineEditing,\n is_read,\n is_modified,\n is_row_modified,\n is_deleted,\n is_added,\n is_incomplete,\n showNewItem,\n onScrollToCell,\n}) => {\n const [showTooltip, setShowTooltip] = useState(false);\n const [tooltipPosition, setTooltipPosition] = useState({ top: 0, left: 0 });\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const iconRef = useRef<HTMLDivElement>(null);\n\n const rowPendingEdits = pendingEdits?.[rowId];\n\n const editedFields = useMemo(\n () =>\n rowPendingEdits\n ? Object.entries(rowPendingEdits).map(([columnKey, edit]) => {\n const column = tableHeaders?.find((col) => col.key === columnKey);\n const fieldName = column?.Header || column?.display_name || columnKey;\n return { columnKey, fieldName, value: edit.value, originalValue: edit.originalValue, meta: edit.meta, originalMeta: edit.originalMeta };\n })\n : [],\n [rowPendingEdits, tableHeaders],\n );\n\n const handleFieldClick = (columnKey: string) => {\n setShowTooltip(false);\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n onScrollToCell?.(rowId, columnKey, rowIndex);\n };\n\n const handleMouseEnter = () => {\n if (!rowHasPendingEdits) return;\n if (hideTimeoutRef.current) { clearTimeout(hideTimeoutRef.current); hideTimeoutRef.current = null; }\n if (iconRef.current) {\n const rect = iconRef.current.getBoundingClientRect();\n setTooltipPosition({ top: rect.top + rect.height / 2, left: rect.right + 8 });\n }\n setShowTooltip(true);\n };\n\n const handleMouseLeave = () => {\n hideTimeoutRef.current = setTimeout(() => { setShowTooltip(false); }, 300);\n };\n\n const bgColor = cn({\n 'bg-primary-50 dark:bg-primary-900': isInlineEditing,\n 'bg-neutral-100 dark:bg-black-600': rowHovering === rowId && !isInlineEditing && !is_deleted && !is_added,\n 'bg-error-200 dark:bg-error-900': rowHovering === rowId && !isInlineEditing && is_deleted,\n 'bg-success-100 dark:bg-success-800': rowHovering === rowId && !isInlineEditing && is_added,\n 'bg-warning-100 dark:bg-warning-950': rowHovering === rowId && !isInlineEditing && (is_incomplete || is_modified || is_row_modified),\n 'bg-primary-50 dark:bg-black-700': !is_incomplete && !is_read && showNewItem && rowHovering !== rowId && !isInlineEditing,\n 'bg-warning-50 dark:bg-orange-900': (is_incomplete || is_modified || is_row_modified) && rowHovering !== rowId && !isInlineEditing,\n 'bg-error-100 dark:bg-error-975': is_deleted && rowHovering !== rowId && !isInlineEditing,\n 'bg-success-50 dark:bg-success-900': is_added && rowHovering !== rowId && !isInlineEditing,\n });\n\n return (\n <td className={`min-w-[28px] w-[28px] sticky left-0 z-30 ${bgColor ? bgColor : 'bg-white dark:bg-black-800'} h-row`}>\n <div ref={iconRef} className='w-full h-row flex items-center justify-center cursor-pointer' onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>\n {rowHasPendingEdits && (\n <div className='w-5 h-5 rounded-full bg-warning-100 dark:bg-warning-900 flex items-center justify-center shadow-sm border border-warning-200 dark:border-warning-700'>\n <EditNoteOutlined sx={{ fontSize: 14 }} className='text-warning-600 dark:text-warning-400' />\n </div>\n )}\n </div>\n {showTooltip && editedFields.length > 0 &&\n createPortal(\n <div\n className='fixed bg-white dark:bg-black-700 rounded-lg shadow-xl border border-neutral-200 dark:border-black-600 py-2 min-w-[200px] max-w-[280px]'\n style={{ top: tooltipPosition.top, left: tooltipPosition.left, transform: 'translateY(-50%)', zIndex: 99999 }}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <div className='px-3 py-1.5 text-xs font-semibold text-neutral-500 dark:text-neutral-400 uppercase tracking-wider border-b border-neutral-100 dark:border-black-600'>\n Pending Changes ({editedFields.length})\n </div>\n <div className='max-h-48 overflow-y-auto'>\n {editedFields.map((field, idx) => (\n <button key={idx} onClick={() => handleFieldClick(field.columnKey)} className='w-full px-3 py-2 text-left hover:bg-neutral-50 dark:hover:bg-black-600 transition-colors cursor-pointer'>\n <div className='text-xs font-medium text-neutral-700 dark:text-neutral-300 mb-1'>{field.fieldName}</div>\n <div className='flex items-center gap-1.5 text-xs'>\n <span className='text-neutral-400 dark:text-neutral-500 line-through truncate max-w-[80px]'>{formatValue(field.originalValue, field.originalMeta?.currency_code)}</span>\n <span className='text-neutral-400 dark:text-neutral-500 flex-shrink-0'>→</span>\n <span className='text-primary-600 dark:text-primary-400 font-medium truncate max-w-[80px]'>{formatValue(field.value, field.meta?.currency_code)}</span>\n </div>\n </button>\n ))}\n </div>\n </div>,\n document.getElementById('full-screen-container') || document.body,\n )}\n </td>\n );\n};\n"],"names":["formatValue","val","currencyCode","strVal","hasTime","formatted","formatDate","display","PendingEditCell","rowId","rowIndex","pendingEdits","tableHeaders","rowHasPendingEdits","rowHovering","isInlineEditing","is_read","is_modified","is_row_modified","is_deleted","is_added","is_incomplete","showNewItem","onScrollToCell","showTooltip","setShowTooltip","useState","tooltipPosition","setTooltipPosition","hideTimeoutRef","useRef","iconRef","rowPendingEdits","editedFields","useMemo","columnKey","edit","column","col","fieldName","handleFieldClick","handleMouseEnter","rect","handleMouseLeave","bgColor","cn","jsx","EditNoteOutlined","createPortal","jsxs","field","idx"],"mappings":";;;;;;AA0BA,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,eAAeA,EAAM,cAAc,aAAa,EAAA,CAAE;AAAA,gBACjK,gBAAAJ,EAAC,QAAA,EAAK,WAAU,wDAAuD,UAAA,KAAC;AAAA,gBACxE,gBAAAA,EAAC,QAAA,EAAK,WAAU,4EAA4E,UAAA9C,EAAYkD,EAAM,OAAOA,EAAM,MAAM,aAAa,EAAA,CAAE;AAAA,cAAA,EAAA,CAClJ;AAAA,YAAA,EAAA,GANWC,CAOb,CACD,EAAA,CACH;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAEF,SAAS,eAAe,uBAAuB,KAAK,SAAS;AAAA,IAAA;AAAA,EAC/D,GACJ;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),S=require("../../../../tooltip/Tooltip.cjs.js"),T=require("../../../../../providers/design-system-provider/hooks.cjs.js"),C=require("../../../../../_virtual/index.cjs.js"),R=require("react"),v=({disableOptionsForRowIndex:d,tableActions:p,index:l,is_read:h,showNewItem:y,is_modified:t,is_row_modified:a,is_deleted:s,currentData:r,is_added:b,rowData:j,id:c,rowHovering:o,isDisabled:n,bgColor:u,is_incomplete:g,isInlineEditing:e,rowHasPendingEdits:f})=>{const q=T.useTableConfig()?.t?.("Save or cancel pending changes first")??"Save or cancel pending changes first",m=R.useMemo(()=>e?"bg-primary-50 dark:bg-primary-900":u||(s||r?.is_deleted?"bg-error-100 dark:bg-error-975":g||t||a||r?.is_row_modified?"bg-warning-50 dark:bg-orange-900":b||r?.is_added?"bg-success-50 dark:bg-success-900":!h&&y&&!n?"bg-primary-50 dark:bg-black-700":"bg-white dark:bg-black-800"),[g,h,y,t,a,s,r,b,u,e,n]),x=d===l||n||f;return k.jsxs("td",{"aria-disabled":x,className:C("px-2.5 relative h-row",m,x&&"cursor-not-allowed opacity-50"),children:[p(j,l),k.jsx(S,{title:f?q:"",children:k.jsx("div",{className:C("absolute top-0 left-0 flex items-center justify-center w-full h-full z-20",{[m]:o!==c||e},{"bg-neutral-100 dark:bg-black-600":o===c&&!e&&!(s||r?.is_deleted)&&!(b||r?.is_added)},{"bg-error-200 dark:bg-error-900":o===c&&!e&&(s||r?.is_deleted)},{"bg-success-100 dark:bg-success-800":o===c&&!e&&(b||r?.is_added)},{"bg-warning-100 dark:bg-warning-950":o===c&&!e&&(g||t||a||r?.is_row_modified)},f&&"pointer-events-none"),children:p(j,l)})})]})},w=R.memo(v);exports.RowActionCell=w;
|
|
2
2
|
//# sourceMappingURL=RowActionCell.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowActionCell.cjs.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/RowActionCell.tsx"],"sourcesContent":["import Tooltip from '../../../../tooltip/Tooltip';\nimport { useTableConfig } from '../../../../../providers/design-system-provider/hooks';\nimport cn from 'classnames';\nimport React, { useMemo } from 'react';\n\ntype TProps = {\n disableOptionsForRowIndex: number | null;\n tableActions: (rowData: Record<string, unknown>, index: number) => JSX.Element;\n index: number;\n is_read: boolean;\n showNewItem: boolean;\n is_modified: boolean;\n is_row_modified: boolean;\n is_deleted: boolean;\n currentData: Record<string, unknown>;\n is_added: boolean;\n rowData: Record<string, unknown>;\n id: string | number;\n rowHovering: string | number | null;\n isDisabled?: boolean;\n bgColor?: string;\n is_incomplete: boolean;\n isInlineEditing?: boolean;\n rowHasPendingEdits?: boolean;\n};\n\nconst RowActionCellInner: React.FC<TProps> = ({\n disableOptionsForRowIndex,\n tableActions,\n index,\n is_read,\n showNewItem,\n is_modified,\n is_row_modified,\n is_deleted,\n currentData,\n is_added,\n rowData,\n id,\n rowHovering,\n isDisabled,\n bgColor,\n is_incomplete,\n isInlineEditing,\n rowHasPendingEdits,\n}) => {\n const tableConfig = useTableConfig();\n const pendingEditsTooltip = tableConfig?.t?.('Save or cancel pending changes first') ?? 'Save or cancel pending changes first';\n\n const backgroundColorClass = useMemo(() => {\n if (isInlineEditing) return 'bg-primary-50 dark:bg-primary-900';\n if (bgColor) return bgColor;\n if (is_deleted || currentData?.is_deleted) return 'bg-error-100 dark:bg-error-975';\n if (is_incomplete || is_modified || is_row_modified || currentData?.is_row_modified) return 'bg-warning-50 dark:bg-
|
|
1
|
+
{"version":3,"file":"RowActionCell.cjs.js","sources":["../../../../../../src/components/data-display/infinite-table/body/cell/RowActionCell.tsx"],"sourcesContent":["import Tooltip from '../../../../tooltip/Tooltip';\nimport { useTableConfig } from '../../../../../providers/design-system-provider/hooks';\nimport cn from 'classnames';\nimport React, { useMemo } from 'react';\n\ntype TProps = {\n disableOptionsForRowIndex: number | null;\n tableActions: (rowData: Record<string, unknown>, index: number) => JSX.Element;\n index: number;\n is_read: boolean;\n showNewItem: boolean;\n is_modified: boolean;\n is_row_modified: boolean;\n is_deleted: boolean;\n currentData: Record<string, unknown>;\n is_added: boolean;\n rowData: Record<string, unknown>;\n id: string | number;\n rowHovering: string | number | null;\n isDisabled?: boolean;\n bgColor?: string;\n is_incomplete: boolean;\n isInlineEditing?: boolean;\n rowHasPendingEdits?: boolean;\n};\n\nconst RowActionCellInner: React.FC<TProps> = ({\n disableOptionsForRowIndex,\n tableActions,\n index,\n is_read,\n showNewItem,\n is_modified,\n is_row_modified,\n is_deleted,\n currentData,\n is_added,\n rowData,\n id,\n rowHovering,\n isDisabled,\n bgColor,\n is_incomplete,\n isInlineEditing,\n rowHasPendingEdits,\n}) => {\n const tableConfig = useTableConfig();\n const pendingEditsTooltip = tableConfig?.t?.('Save or cancel pending changes first') ?? 'Save or cancel pending changes first';\n\n const backgroundColorClass = useMemo(() => {\n if (isInlineEditing) return 'bg-primary-50 dark:bg-primary-900';\n if (bgColor) return bgColor;\n if (is_deleted || currentData?.is_deleted) return 'bg-error-100 dark:bg-error-975';\n if (is_incomplete || is_modified || is_row_modified || currentData?.is_row_modified) return 'bg-warning-50 dark:bg-orange-900';\n if (is_added || currentData?.is_added) return 'bg-success-50 dark:bg-success-900';\n if (!is_read && showNewItem && !isDisabled) return 'bg-primary-50 dark:bg-black-700';\n return 'bg-white dark:bg-black-800';\n }, [is_incomplete, is_read, showNewItem, is_modified, is_row_modified, is_deleted, currentData, is_added, bgColor, isInlineEditing, isDisabled]);\n\n const isRowDisabled = disableOptionsForRowIndex === index || isDisabled || rowHasPendingEdits;\n\n return (\n <td aria-disabled={isRowDisabled} className={cn('px-2.5 relative h-row', backgroundColorClass, isRowDisabled && 'cursor-not-allowed opacity-50')}>\n {tableActions(rowData, index)}\n <Tooltip title={rowHasPendingEdits ? pendingEditsTooltip : ''}>\n <div\n className={cn(\n 'absolute top-0 left-0 flex items-center justify-center w-full h-full z-20',\n { [backgroundColorClass]: rowHovering !== id || isInlineEditing },\n { 'bg-neutral-100 dark:bg-black-600': rowHovering === id && !isInlineEditing && !(is_deleted || currentData?.is_deleted) && !(is_added || currentData?.is_added) },\n { 'bg-error-200 dark:bg-error-900': rowHovering === id && !isInlineEditing && (is_deleted || currentData?.is_deleted) },\n { 'bg-success-100 dark:bg-success-800': rowHovering === id && !isInlineEditing && (is_added || currentData?.is_added) },\n { 'bg-warning-100 dark:bg-warning-950': rowHovering === id && !isInlineEditing && (is_incomplete || is_modified || is_row_modified || currentData?.is_row_modified) },\n rowHasPendingEdits && 'pointer-events-none',\n )}\n >\n {tableActions(rowData, index)}\n </div>\n </Tooltip>\n </td>\n );\n};\n\nexport const RowActionCell = React.memo(RowActionCellInner);\n"],"names":["RowActionCellInner","disableOptionsForRowIndex","tableActions","index","is_read","showNewItem","is_modified","is_row_modified","is_deleted","currentData","is_added","rowData","id","rowHovering","isDisabled","bgColor","is_incomplete","isInlineEditing","rowHasPendingEdits","pendingEditsTooltip","useTableConfig","backgroundColorClass","useMemo","isRowDisabled","jsxs","cn","jsx","Tooltip","RowActionCell","React"],"mappings":"oTA0BMA,EAAuC,CAAC,CAC5C,0BAAAC,EACA,aAAAC,E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