@feathery/react 2.32.1 → 2.34.0

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.
Files changed (146) hide show
  1. package/cjs/Form/grid/Element/index.d.ts.map +1 -1
  2. package/cjs/Form/index.d.ts.map +1 -1
  3. package/cjs/assistant/MarkdownText.d.ts.map +1 -1
  4. package/cjs/assistant/index.d.ts +7 -1
  5. package/cjs/assistant/index.d.ts.map +1 -1
  6. package/cjs/assistant/utils.d.ts +1 -0
  7. package/cjs/assistant/utils.d.ts.map +1 -1
  8. package/cjs/elements/basic/TableElement/Actions.d.ts +3 -1
  9. package/cjs/elements/basic/TableElement/Actions.d.ts.map +1 -1
  10. package/cjs/elements/basic/TableElement/DeleteConfirm.d.ts +11 -0
  11. package/cjs/elements/basic/TableElement/DeleteConfirm.d.ts.map +1 -0
  12. package/cjs/elements/basic/TableElement/EditableCell.d.ts +10 -0
  13. package/cjs/elements/basic/TableElement/EditableCell.d.ts.map +1 -0
  14. package/cjs/elements/basic/TableElement/Search.d.ts.map +1 -1
  15. package/cjs/elements/basic/TableElement/index.d.ts +1 -1
  16. package/cjs/elements/basic/TableElement/index.d.ts.map +1 -1
  17. package/cjs/elements/basic/TableElement/styles.d.ts +269 -4
  18. package/cjs/elements/basic/TableElement/styles.d.ts.map +1 -1
  19. package/cjs/elements/basic/TableElement/useTableData.d.ts +6 -1
  20. package/cjs/elements/basic/TableElement/useTableData.d.ts.map +1 -1
  21. package/cjs/elements/basic/TableElement/useTableMutations.d.ts +23 -0
  22. package/cjs/elements/basic/TableElement/useTableMutations.d.ts.map +1 -0
  23. package/cjs/elements/components/icons/TrashIcon.d.ts +3 -0
  24. package/cjs/elements/components/icons/TrashIcon.d.ts.map +1 -0
  25. package/cjs/elements/components/icons/index.d.ts +2 -1
  26. package/cjs/elements/components/icons/index.d.ts.map +1 -1
  27. package/cjs/{fthry_FormControl.DurQlaqU.js → fthry_FormControl.CML0lwzj.js} +1 -1
  28. package/cjs/{fthry_InlineTooltip.BXWfZzL2.js → fthry_InlineTooltip.BA5EZyVy.js} +2 -2
  29. package/cjs/{fthry_Overlay.CioCMhlq.js → fthry_Overlay.B_9rPs-m.js} +1 -1
  30. package/cjs/{fthry_PaymentMethodField.DhSkUuU-.js → fthry_PaymentMethodField.C00vPUNe.js} +4 -4
  31. package/cjs/{fthry_Placeholder.CX7qc-Cl.js → fthry_Placeholder.BFFDhXBs.js} +1 -1
  32. package/cjs/{fthry_ShowEyeIcon.80VHzelN.js → fthry_ShowEyeIcon.CuPS0oeE.js} +1 -1
  33. package/cjs/{fthry_index.Dofn1W06.js → fthry_index.03SRNIsU.js} +4 -4
  34. package/cjs/{fthry_index.RkgEXvkN.js → fthry_index.BJAVGAGZ.js} +5 -5
  35. package/cjs/{fthry_index.BrWW45H5.js → fthry_index.BQVESvqn.js} +5 -5
  36. package/cjs/{fthry_index.C05KVXV6.js → fthry_index.BXg6uKKM.js} +1 -1
  37. package/cjs/{fthry_index.Oufk9PK1.js → fthry_index.BYybPok4.js} +2 -2
  38. package/cjs/{fthry_index.DALbyltA.js → fthry_index.Bf0a9QEh.js} +8 -8
  39. package/cjs/{fthry_index.DPXTa2dj.js → fthry_index.BgedLiI0.js} +1 -1
  40. package/cjs/{fthry_index.CANZBm-k.js → fthry_index.BhR7_Tw1.js} +5 -5
  41. package/cjs/{fthry_index.CLPl9dPm.js → fthry_index.C0XeExCZ.js} +1 -1
  42. package/cjs/{fthry_index.CwZL5tZB.js → fthry_index.C0u7HxWh.js} +3 -3
  43. package/cjs/{fthry_index.NnMUv723.js → fthry_index.C5G-Orde.js} +507 -47
  44. package/cjs/{fthry_index.C5QUdS7L.js → fthry_index.C7Ucykze.js} +1 -1
  45. package/cjs/{fthry_index.DXol9L5L.js → fthry_index.CEcJUhQu.js} +6 -6
  46. package/cjs/{fthry_index.DQL_RNQ5.js → fthry_index.CLcw1cAr.js} +190 -57
  47. package/cjs/{fthry_index.D3P96Nnw.js → fthry_index.COZBuqOZ.js} +4 -4
  48. package/cjs/{fthry_index.CY58pJ5G.js → fthry_index.D5JB2gFa.js} +6 -6
  49. package/cjs/{fthry_index.Cm-Al4PR.js → fthry_index.DrY8SRA_.js} +4 -4
  50. package/cjs/{fthry_index.cjyiNFQz.js → fthry_index.Dx0lyifQ.js} +1 -1
  51. package/cjs/{fthry_index.Br877QRA.js → fthry_index.Ht6LeWDf.js} +3 -3
  52. package/cjs/{fthry_index.BnYce3sm.js → fthry_index.SDGVk6Nx.js} +5 -5
  53. package/cjs/{fthry_index.DpeEqUaO.js → fthry_index.T7PUxXEk.js} +1 -1
  54. package/cjs/{fthry_index.B8tZZXUF.js → fthry_index.WclRwtN5.js} +6 -6
  55. package/cjs/{fthry_index.Cgn2gw_g.js → fthry_index.cNEEOSYt.js} +1 -1
  56. package/cjs/{fthry_index.9yf8TiBa.js → fthry_index.feR_RWVW.js} +2 -2
  57. package/cjs/{fthry_input.Ek-TePLo.js → fthry_input.Cpq06SDM.js} +1 -1
  58. package/cjs/{fthry_script.D4I5wEAM.js → fthry_script.Pp5hc7_j.js} +1 -1
  59. package/cjs/{fthry_styles.BAOkmtNa.js → fthry_styles.C5aRtkKT.js} +1 -1
  60. package/cjs/{fthry_useElementSize.DxiZSHps.js → fthry_useElementSize.EwhSeBgA.js} +1 -1
  61. package/cjs/{fthry_useSalesforceSync.0Po-_R2K.js → fthry_useSalesforceSync.8708kCRl.js} +1 -1
  62. package/cjs/{fthry_webfontloader.Dpbr76nZ.js → fthry_webfontloader.pK_b8-qc.js} +1 -1
  63. package/cjs/index.js +1 -1
  64. package/cjs/utils/formHelperFunctions.d.ts +1 -1
  65. package/cjs/utils/formHelperFunctions.d.ts.map +1 -1
  66. package/dist/Form/grid/Element/index.d.ts.map +1 -1
  67. package/dist/Form/index.d.ts.map +1 -1
  68. package/dist/assistant/MarkdownText.d.ts.map +1 -1
  69. package/dist/assistant/index.d.ts +7 -1
  70. package/dist/assistant/index.d.ts.map +1 -1
  71. package/dist/assistant/utils.d.ts +1 -0
  72. package/dist/assistant/utils.d.ts.map +1 -1
  73. package/dist/elements/basic/TableElement/Actions.d.ts +3 -1
  74. package/dist/elements/basic/TableElement/Actions.d.ts.map +1 -1
  75. package/dist/elements/basic/TableElement/DeleteConfirm.d.ts +11 -0
  76. package/dist/elements/basic/TableElement/DeleteConfirm.d.ts.map +1 -0
  77. package/dist/elements/basic/TableElement/EditableCell.d.ts +10 -0
  78. package/dist/elements/basic/TableElement/EditableCell.d.ts.map +1 -0
  79. package/dist/elements/basic/TableElement/Search.d.ts.map +1 -1
  80. package/dist/elements/basic/TableElement/index.d.ts +1 -1
  81. package/dist/elements/basic/TableElement/index.d.ts.map +1 -1
  82. package/dist/elements/basic/TableElement/styles.d.ts +269 -4
  83. package/dist/elements/basic/TableElement/styles.d.ts.map +1 -1
  84. package/dist/elements/basic/TableElement/useTableData.d.ts +6 -1
  85. package/dist/elements/basic/TableElement/useTableData.d.ts.map +1 -1
  86. package/dist/elements/basic/TableElement/useTableMutations.d.ts +23 -0
  87. package/dist/elements/basic/TableElement/useTableMutations.d.ts.map +1 -0
  88. package/dist/elements/components/icons/TrashIcon.d.ts +3 -0
  89. package/dist/elements/components/icons/TrashIcon.d.ts.map +1 -0
  90. package/dist/elements/components/icons/index.d.ts +2 -1
  91. package/dist/elements/components/icons/index.d.ts.map +1 -1
  92. package/dist/{fthry_FormControl.CxJVENhU.js → fthry_FormControl.DKlbmUiV.js} +1 -1
  93. package/dist/{fthry_InlineTooltip.CqD5dxb4.js → fthry_InlineTooltip.BKSwt9jG.js} +2 -2
  94. package/dist/{fthry_Overlay.C-S2P_RR.js → fthry_Overlay.BTm6pCZJ.js} +1 -1
  95. package/dist/{fthry_PaymentMethodField.QXLEi8jw.js → fthry_PaymentMethodField.DpnAuKvB.js} +4 -4
  96. package/dist/{fthry_Placeholder.DdvJyqsu.js → fthry_Placeholder.CPAnnclY.js} +1 -1
  97. package/dist/{fthry_ShowEyeIcon.CZus1erN.js → fthry_ShowEyeIcon.BZ2aJo9D.js} +1 -1
  98. package/dist/{fthry_index.C6CFRFmj.js → fthry_index.-CcNnx9X.js} +3 -3
  99. package/dist/{fthry_index.BmrKBP2b.js → fthry_index.02uCZKhe.js} +4 -4
  100. package/dist/{fthry_index.BsCv8dPB.js → fthry_index.5DxASb1N.js} +1 -1
  101. package/dist/{fthry_index.Cv8JZvnf.js → fthry_index.B1QY7Fyq.js} +3 -3
  102. package/dist/{fthry_index.CNIO-M5G.js → fthry_index.BEF9nltO.js} +1 -1
  103. package/dist/{fthry_index.Bn5hHeFA.js → fthry_index.BKqYC-oZ.js} +6 -6
  104. package/dist/{fthry_index.DUhZfNzg.js → fthry_index.BNCwvjVk.js} +4 -4
  105. package/dist/{fthry_index.9VAfgoMl.js → fthry_index.CQVyGrDZ.js} +1 -1
  106. package/dist/{fthry_index.DVRFkK73.js → fthry_index.Cfd1x2qq.js} +5 -5
  107. package/dist/{fthry_index.B_7ywejL.js → fthry_index.CiAW_8IB.js} +5 -5
  108. package/dist/{fthry_index.B3B8bEEX.js → fthry_index.Ck_WYegw.js} +2 -2
  109. package/dist/{fthry_index.BT7cSNXV.js → fthry_index.D-UMzwNT.js} +1 -1
  110. package/dist/{fthry_index.BJVuZZ2J.js → fthry_index.D2a3hB7c.js} +1 -1
  111. package/dist/{fthry_index.4JG7sxtp.js → fthry_index.D36b2PTi.js} +2 -2
  112. package/dist/{fthry_index.p64tvQaa.js → fthry_index.D5e9d-bc.js} +6 -6
  113. package/dist/{fthry_index.CsSJubdr.js → fthry_index.DANjxt92.js} +6 -6
  114. package/dist/{fthry_index.BpZ7gZfF.js → fthry_index.DQtD1jTh.js} +5 -5
  115. package/dist/{fthry_index.Bk7-v1ou.js → fthry_index.DU4jPWLZ.js} +191 -58
  116. package/dist/{fthry_index.Cr2SZgDK.js → fthry_index.DpQBQuUs.js} +8 -8
  117. package/dist/{fthry_index.C5ZHl-kt.js → fthry_index.DwDyjSm7.js} +508 -48
  118. package/dist/{fthry_index.DmqZnhoE.js → fthry_index.DxPTSFlh.js} +1 -1
  119. package/dist/{fthry_index.BL5rEBAF.js → fthry_index.RHhTHWCk.js} +4 -4
  120. package/dist/{fthry_index.wqVaa2JI.js → fthry_index.anz0O6yX.js} +5 -5
  121. package/dist/{fthry_index.BV8FC0Yc.js → fthry_index.bTguBDFD.js} +1 -1
  122. package/dist/{fthry_input.aOsdUSPt.js → fthry_input.BCkUbKsr.js} +1 -1
  123. package/dist/{fthry_script.HcN-guNp.js → fthry_script.u21cC2ng.js} +1 -1
  124. package/dist/{fthry_styles.BLq5f5E_.js → fthry_styles.BCzx9hie.js} +1 -1
  125. package/dist/{fthry_useElementSize.ZyD83Wr1.js → fthry_useElementSize.DPJ5NPHR.js} +1 -1
  126. package/dist/{fthry_useSalesforceSync.Ddbp4SYp.js → fthry_useSalesforceSync.DQ8LIE8i.js} +1 -1
  127. package/dist/{fthry_webfontloader.C3IotuWt.js → fthry_webfontloader.BFz-Z-Vx.js} +1 -1
  128. package/dist/index.js +1 -1
  129. package/dist/utils/formHelperFunctions.d.ts +1 -1
  130. package/dist/utils/formHelperFunctions.d.ts.map +1 -1
  131. package/package.json +1 -1
  132. package/umd/{277.d9907ecd5dc2117c9171.js → 277.87e6ca5c1cf2a7477992.js} +1 -1
  133. package/umd/{509.a863f8749c28540476bb.js → 509.bca2ff43c66b1dba064f.js} +2 -2
  134. package/umd/{AddressField.ec97334fe233830bc05b.js → AddressField.2d777eda22a67a0ed3a3.js} +1 -1
  135. package/umd/{DateSelectorField.00f321e0b1972feb9d69.js → DateSelectorField.54afc978d2fd9d10b106.js} +1 -1
  136. package/umd/{FileUploadField.ea0067dd62b0454b7c2e.js → FileUploadField.7a5028fb6035d09b3e81.js} +1 -1
  137. package/umd/{PasswordField.1358356d6fbc6880f12a.js → PasswordField.7585ef588333cb4181f7.js} +1 -1
  138. package/umd/{PaymentMethodField.9a8e934f7450eb141217.js → PaymentMethodField.d08bcfa1efb56084572d.js} +1 -1
  139. package/umd/{PhoneField.c526085aaa5ccd25e982.js → PhoneField.19c987f04cfcb60ab07c.js} +1 -1
  140. package/umd/{SignatureField.d710930ca89642eb651c.js → SignatureField.0e7d60fa2fafcb6be554.js} +1 -1
  141. package/umd/TableElement.8e41e1015eb1543af90b.js +1 -0
  142. package/umd/{TextArea.f566845d458d4c00e0e7.js → TextArea.7cca0d69e618846660c5.js} +1 -1
  143. package/umd/{TextField.5a5296fe3ea60c4459f2.js → TextField.f5cc4a03e69d5872027b.js} +1 -1
  144. package/umd/index.js +1 -1
  145. package/umd/TableElement.ee77e0f53a9ccac846ab.js +0 -1
  146. /package/umd/{509.a863f8749c28540476bb.js.LICENSE.txt → 509.bca2ff43c66b1dba064f.js.LICENSE.txt} +0 -0
@@ -1,10 +1,15 @@
1
- import { _ as __assign, j as jsx, a as jsxs, F as Fragment, b as __read, f as featheryDoc, c as fieldValues, s as stringifyWithNull, d as __values, e as __spreadArray } from './fthry_index.Bk7-v1ou.js';
2
- import { useState, useRef, useEffect, useMemo } from 'react';
1
+ import { _ as __rest, j as jsx, a as __assign, b as jsxs, F as Fragment, c as __read, f as featheryDoc, d as fieldValues, s as stringifyWithNull, e as __values, g as __spreadArray } from './fthry_index.DU4jPWLZ.js';
2
+ import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react-dom/client';
6
6
  import 'jszip';
7
7
 
8
+ function TrashIcon(_a) {
9
+ var _b = _a.width, width = _b === void 0 ? 16 : _b, _c = _a.height, height = _c === void 0 ? 16 : _c, props = __rest(_a, ["width", "height"]);
10
+ return (jsx("svg", __assign({ width: width, height: height, fill: 'none', viewBox: '0 0 24 24', stroke: 'currentColor', strokeWidth: 2, xmlns: 'http://www.w3.org/2000/svg' }, props, { children: jsx("path", { strokeLinecap: 'round', strokeLinejoin: 'round', d: 'M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16' }) })));
11
+ }
12
+
8
13
  var colors = {
9
14
  white: '#ffffff',
10
15
  gray50: '#f9fafb',
@@ -16,7 +21,9 @@ var colors = {
16
21
  gray700: '#374151',
17
22
  gray900: '#111827',
18
23
  blue50: '#eff6ff',
19
- blue700: '#1d4ed8'
24
+ blue700: '#1d4ed8',
25
+ red500: '#ef4444',
26
+ red600: '#dc2626'
20
27
  };
21
28
  var searchIconStyle = {
22
29
  width: '16px',
@@ -75,12 +82,9 @@ var emptyStateTextStyle = {
75
82
  fontWeight: '500',
76
83
  margin: 0
77
84
  };
78
- var searchContainerStyle = {
79
- padding: '16px',
80
- borderBottom: "1px solid ".concat(colors.gray200)
81
- };
82
85
  var searchWrapperStyle = {
83
- position: 'relative'
86
+ position: 'relative',
87
+ flex: 1
84
88
  };
85
89
  var searchIconWrapperStyle = {
86
90
  position: 'absolute',
@@ -127,7 +131,8 @@ var theadStyle = {
127
131
  var thStyle = {
128
132
  padding: '12px 24px',
129
133
  fontWeight: '500',
130
- userSelect: 'none'
134
+ userSelect: 'none',
135
+ whiteSpace: 'nowrap'
131
136
  };
132
137
  var rowStyle = {
133
138
  backgroundColor: colors.white,
@@ -235,6 +240,14 @@ var actionMenuItemStyle = {
235
240
  borderBottomRightRadius: '4px'
236
241
  }
237
242
  };
243
+ var actionMenuSeparatorStyle = {
244
+ borderTop: "1px solid ".concat(colors.gray200),
245
+ margin: '4px 0'
246
+ };
247
+ var actionMenuDeleteItemStyle = __assign(__assign({}, actionMenuItemStyle), { color: colors.red500, '&:hover': {
248
+ backgroundColor: colors.gray100,
249
+ color: colors.red600
250
+ } });
238
251
  var actionIconButtonStyle = __assign(__assign({}, actionButtonStyle), { aspectRatio: 1, paddingLeft: 0, paddingRight: 0 });
239
252
  var actionContainerStyle = {
240
253
  display: 'flex',
@@ -259,6 +272,138 @@ var overflowSelectStyle = __assign(__assign({}, pageButtonStyle), { appearance:
259
272
  color: colors.gray900
260
273
  }, '&:focus': {
261
274
  outline: 'none'
275
+ } });
276
+ // Editing styles
277
+ var toolbarStyle = {
278
+ display: 'flex',
279
+ alignItems: 'center',
280
+ justifyContent: 'space-between',
281
+ padding: '16px',
282
+ borderBottom: "1px solid ".concat(colors.gray200),
283
+ gap: '12px'
284
+ };
285
+ var addRowButtonStyle = __assign(__assign({}, buttonStyle), { borderRadius: '8px', paddingLeft: '12px', paddingRight: '12px', whiteSpace: 'nowrap' });
286
+ var clickToEditStyle = {
287
+ color: colors.gray400,
288
+ cursor: 'pointer',
289
+ userSelect: 'none',
290
+ fontSize: '14px'
291
+ };
292
+ var cellInputStyle = {
293
+ display: 'block',
294
+ width: '100%',
295
+ minWidth: 0,
296
+ maxWidth: '100%',
297
+ padding: '4px 8px',
298
+ border: "1px solid ".concat(colors.blue700),
299
+ borderRadius: '4px',
300
+ fontSize: '14px',
301
+ color: colors.gray900,
302
+ outline: 'none',
303
+ boxSizing: 'border-box',
304
+ resize: 'none',
305
+ overflowY: 'auto',
306
+ fontFamily: 'inherit',
307
+ lineHeight: 1.5
308
+ };
309
+ var editableCellContentStyle = {
310
+ display: 'flex',
311
+ alignItems: 'flex-start',
312
+ gap: '8px'
313
+ };
314
+ var editableCellTextStyle = {
315
+ flex: 1,
316
+ minWidth: 0,
317
+ whiteSpace: 'pre-wrap',
318
+ overflowWrap: 'anywhere',
319
+ wordBreak: 'break-word',
320
+ lineHeight: 1.5
321
+ };
322
+ var editingCellContentStyle = {
323
+ flex: 1,
324
+ minWidth: 0,
325
+ position: 'relative',
326
+ alignSelf: 'stretch'
327
+ };
328
+ var editingCellSizerStyle = __assign(__assign({}, cellInputStyle), { whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', wordBreak: 'break-word', visibility: 'hidden', pointerEvents: 'none' });
329
+ var editingCellInputStyle = {
330
+ position: 'absolute',
331
+ inset: 0,
332
+ height: '100%'
333
+ };
334
+ var overflowIconStyle = {
335
+ display: 'flex',
336
+ alignItems: 'center',
337
+ justifyContent: 'center',
338
+ width: '24px',
339
+ height: '24px',
340
+ borderRadius: '4px',
341
+ border: 'none',
342
+ backgroundColor: 'transparent',
343
+ color: colors.gray400,
344
+ cursor: 'pointer',
345
+ opacity: 0,
346
+ transition: 'opacity 0.15s',
347
+ flexShrink: 0,
348
+ padding: 0,
349
+ 'tr:hover &, &[aria-expanded="true"]': {
350
+ opacity: 1
351
+ },
352
+ '&:hover': {
353
+ backgroundColor: colors.gray100,
354
+ color: colors.gray600
355
+ }
356
+ };
357
+ var deleteColumnStyle = {
358
+ width: '40px',
359
+ padding: '0 8px'
360
+ };
361
+ var deleteIconStyle = {
362
+ display: 'flex',
363
+ alignItems: 'center',
364
+ justifyContent: 'center',
365
+ width: '28px',
366
+ height: '28px',
367
+ borderRadius: '4px',
368
+ border: 'none',
369
+ backgroundColor: 'transparent',
370
+ color: colors.gray400,
371
+ cursor: 'pointer',
372
+ opacity: 0,
373
+ transition: 'opacity 0.15s',
374
+ padding: 0,
375
+ 'tr:hover &': {
376
+ opacity: 1
377
+ },
378
+ '&:hover': {
379
+ backgroundColor: colors.gray100,
380
+ color: colors.red500
381
+ }
382
+ };
383
+ var confirmPopoverStyle = {
384
+ position: 'fixed',
385
+ backgroundColor: colors.white,
386
+ border: "1px solid ".concat(colors.gray300),
387
+ borderRadius: '8px',
388
+ boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
389
+ zIndex: 9999,
390
+ padding: '12px 16px'
391
+ };
392
+ var confirmTextStyle = {
393
+ margin: '0 0 12px 0',
394
+ fontSize: '14px',
395
+ fontWeight: '500',
396
+ color: colors.gray900
397
+ };
398
+ var confirmButtonRowStyle = {
399
+ display: 'flex',
400
+ gap: '8px',
401
+ justifyContent: 'flex-end'
402
+ };
403
+ var confirmCancelButtonStyle = __assign(__assign({}, buttonStyle), { borderRadius: '6px', paddingLeft: '12px', paddingRight: '12px', height: '32px' });
404
+ var confirmDeleteButtonStyle = __assign(__assign({}, buttonStyle), { borderRadius: '6px', paddingLeft: '12px', paddingRight: '12px', height: '32px', backgroundColor: colors.red500, color: colors.white, border: "1px solid ".concat(colors.red500), '&:hover': {
405
+ backgroundColor: colors.red600,
406
+ color: colors.white
262
407
  } });
263
408
 
264
409
  function SearchIcon() {
@@ -271,7 +416,7 @@ function Search(_a) {
271
416
  e.preventDefault();
272
417
  }
273
418
  };
274
- return (jsx("div", __assign({ css: searchContainerStyle }, { children: jsxs("div", __assign({ css: searchWrapperStyle }, { children: [jsx("div", __assign({ css: searchIconWrapperStyle }, { children: jsx(SearchIcon, {}) })), jsx("input", { type: 'text', css: searchInputStyle, placeholder: 'Search', value: searchQuery, onChange: function (e) { return onSearchChange(e.target.value); }, onKeyDown: handleKeyDown })] })) })));
419
+ return (jsxs("div", __assign({ css: searchWrapperStyle }, { children: [jsx("div", __assign({ css: searchIconWrapperStyle }, { children: jsx(SearchIcon, {}) })), jsx("input", { type: 'text', css: searchInputStyle, placeholder: 'Search', value: searchQuery, onChange: function (e) { return onSearchChange(e.target.value); }, onKeyDown: handleKeyDown })] })));
275
420
  }
276
421
 
277
422
  function SortIcon(_a) {
@@ -356,11 +501,11 @@ function MenuIcon() {
356
501
  }
357
502
  function ActionButtons(_a) {
358
503
  var _b, _c, _d;
359
- var actions = _a.actions, rowIndex = _a.rowIndex, columnData = _a.columnData, fieldValuesProp = _a.fieldValues, onClick = _a.onClick, _e = _a.forceInlineButtons, forceInlineButtons = _e === void 0 ? false : _e, _f = _a.tableId, tableId = _f === void 0 ? '' : _f, _g = _a.buttonLoaders, buttonLoaders = _g === void 0 ? {} : _g;
504
+ var actions = _a.actions, rowIndex = _a.rowIndex, columnData = _a.columnData, fieldValuesProp = _a.fieldValues, onClick = _a.onClick, _e = _a.forceInlineButtons, forceInlineButtons = _e === void 0 ? false : _e, _f = _a.tableId, tableId = _f === void 0 ? '' : _f, _g = _a.buttonLoaders, buttonLoaders = _g === void 0 ? {} : _g, _h = _a.canDeleteRows, canDeleteRows = _h === void 0 ? false : _h, onDeleteRow = _a.onDeleteRow;
360
505
  if (actions.length === 0)
361
506
  return null;
362
- var _h = __read(useState(false), 2), isMenuOpen = _h[0], setIsMenuOpen = _h[1];
363
- var _j = __read(useState({ top: 0, left: 0 }), 2), menuPosition = _j[0], setMenuPosition = _j[1];
507
+ var _j = __read(useState(false), 2), isMenuOpen = _j[0], setIsMenuOpen = _j[1];
508
+ var _k = __read(useState({ top: 0, left: 0 }), 2), menuPosition = _k[0], setMenuPosition = _k[1];
364
509
  var containerRef = useRef(null);
365
510
  var menuRef = useRef(null);
366
511
  var menuButtonRef = useRef(null);
@@ -427,13 +572,17 @@ function ActionButtons(_a) {
427
572
  alignItems: 'center',
428
573
  justifyContent: 'center'
429
574
  } }, { children: overflowLoader }))) : (jsx(MenuIcon, {})) })), isMenuOpen &&
430
- createPortal(jsx("div", __assign({ ref: menuRef, css: __assign(__assign({}, actionMenuStyle), { top: "".concat(menuPosition.top, "px"), left: "".concat(menuPosition.left, "px"), transform: 'translateX(-100%)' }) }, { children: actions.map(function (action, index) {
431
- var disabled = Object.keys(buttonLoaders).length > 0;
432
- return (jsx("button", __assign({ type: 'button', onClick: function (e) {
433
- e.stopPropagation();
434
- handleActionClick(action);
435
- }, css: actionMenuItemStyle, disabled: disabled }, { children: action.label }), index));
436
- }) })), featheryDoc().body)] })) : (actions.map(function (action, index) {
575
+ createPortal(jsxs("div", __assign({ ref: menuRef, css: __assign(__assign({}, actionMenuStyle), { top: "".concat(menuPosition.top, "px"), left: "".concat(menuPosition.left, "px"), transform: 'translateX(-100%)' }) }, { children: [actions.map(function (action, index) {
576
+ var disabled = Object.keys(buttonLoaders).length > 0;
577
+ return (jsx("button", __assign({ type: 'button', onClick: function (e) {
578
+ e.stopPropagation();
579
+ handleActionClick(action);
580
+ }, css: actionMenuItemStyle, disabled: disabled }, { children: action.label }), index));
581
+ }), canDeleteRows && onDeleteRow && (jsxs(Fragment, { children: [jsx("div", { css: actionMenuSeparatorStyle }), jsx("button", __assign({ type: 'button', onClick: function (e) {
582
+ e.stopPropagation();
583
+ setIsMenuOpen(false);
584
+ onDeleteRow(rowIndex);
585
+ }, css: actionMenuDeleteItemStyle }, { children: "Delete" }))] }))] })), featheryDoc().body)] })) : (actions.map(function (action, index) {
437
586
  var _a;
438
587
  var buttonKey = "".concat(tableId, "_").concat(rowIndex, "_").concat(action.label);
439
588
  var loader = (_a = buttonLoaders[buttonKey]) === null || _a === void 0 ? void 0 : _a.loader;
@@ -462,6 +611,153 @@ function EmptyState(_a) {
462
611
  }, fill: 'none', viewBox: '0 0 24 24', stroke: 'currentColor', strokeWidth: 1.5 }, { children: jsx("path", { strokeLinecap: 'round', strokeLinejoin: 'round', d: 'M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z' }) }))), jsx("p", __assign({ css: emptyStateTextStyle }, { children: hasSearchQuery ? 'No results found' : 'No data available' })), hasSearchQuery && (jsx("p", __assign({ css: __assign(__assign({}, emptyStateTextStyle), { fontSize: '14px', marginTop: '8px' }) }, { children: "Try adjusting your search query" })))] })));
463
612
  }
464
613
 
614
+ function DeleteConfirm(_a) {
615
+ var anchorEl = _a.anchorEl, onConfirm = _a.onConfirm, onCancel = _a.onCancel, _b = _a.message, message = _b === void 0 ? 'Delete this row?' : _b, _c = _a.confirmLabel, confirmLabel = _c === void 0 ? 'Delete' : _c;
616
+ var popoverRef = useRef(null);
617
+ if (!anchorEl)
618
+ return null;
619
+ var anchorRect = anchorEl.getBoundingClientRect();
620
+ var top = anchorRect.bottom + 4;
621
+ var left = anchorRect.right;
622
+ useEffect(function () {
623
+ var handleClickOutside = function (event) {
624
+ if (popoverRef.current &&
625
+ !popoverRef.current.contains(event.target) &&
626
+ anchorEl &&
627
+ !anchorEl.contains(event.target)) {
628
+ onCancel();
629
+ }
630
+ };
631
+ var handleScroll = function () { return onCancel(); };
632
+ var handleKeyDown = function (event) {
633
+ if (event.key === 'Escape')
634
+ onCancel();
635
+ };
636
+ var doc = featheryDoc();
637
+ doc.addEventListener('mousedown', handleClickOutside);
638
+ doc.addEventListener('scroll', handleScroll, true);
639
+ doc.addEventListener('keydown', handleKeyDown);
640
+ return function () {
641
+ doc.removeEventListener('mousedown', handleClickOutside);
642
+ doc.removeEventListener('scroll', handleScroll, true);
643
+ doc.removeEventListener('keydown', handleKeyDown);
644
+ };
645
+ }, [onCancel, anchorEl]);
646
+ return createPortal(jsxs("div", __assign({ ref: popoverRef, role: 'alertdialog', "aria-label": message, css: __assign(__assign({}, confirmPopoverStyle), { top: "".concat(top, "px"), left: "".concat(left, "px"), transform: 'translateX(-100%)' }) }, { children: [jsx("p", __assign({ css: confirmTextStyle }, { children: message })), jsxs("div", __assign({ css: confirmButtonRowStyle }, { children: [jsx("button", __assign({ type: 'button', css: confirmCancelButtonStyle, onClick: function (e) {
647
+ e.stopPropagation();
648
+ onCancel();
649
+ } }, { children: "Cancel" })), jsx("button", __assign({ type: 'button', css: confirmDeleteButtonStyle, onClick: function (e) {
650
+ e.stopPropagation();
651
+ onConfirm();
652
+ } }, { children: confirmLabel }))] }))] })), featheryDoc().body);
653
+ }
654
+
655
+ function OverflowIcon() {
656
+ return (jsxs("svg", __assign({ width: '16', height: '16', fill: 'currentColor', viewBox: '0 0 24 24' }, { children: [jsx("circle", { cx: '12', cy: '5', r: '2' }), jsx("circle", { cx: '12', cy: '12', r: '2' }), jsx("circle", { cx: '12', cy: '19', r: '2' })] })));
657
+ }
658
+ function EditableCell(_a) {
659
+ var _b;
660
+ var value = _a.value, fieldKey = _a.fieldKey, rowIndex = _a.rowIndex, onEdit = _a.onEdit, onClear = _a.onClear;
661
+ var _c = __read(useState(false), 2), isEditing = _c[0], setIsEditing = _c[1];
662
+ var _d = __read(useState(''), 2), editValue = _d[0], setEditValue = _d[1];
663
+ var _e = __read(useState(false), 2), isMenuOpen = _e[0], setIsMenuOpen = _e[1];
664
+ var _f = __read(useState(false), 2), showClearConfirm = _f[0], setShowClearConfirm = _f[1];
665
+ var _g = __read(useState({ top: 0, left: 0 }), 2), menuPosition = _g[0], setMenuPosition = _g[1];
666
+ var inputRef = useRef(null);
667
+ var menuButtonRef = useRef(null);
668
+ var menuRef = useRef(null);
669
+ var shouldSaveRef = useRef(true);
670
+ var closeClearConfirm = useCallback(function () { return setShowClearConfirm(false); }, []);
671
+ var displayValue = (_b = stringifyWithNull(value)) !== null && _b !== void 0 ? _b : '';
672
+ var isEmpty = displayValue === '';
673
+ useEffect(function () {
674
+ if (isEditing && inputRef.current) {
675
+ inputRef.current.focus();
676
+ }
677
+ }, [isEditing]);
678
+ useEffect(function () {
679
+ if (!isMenuOpen)
680
+ return;
681
+ var handleClickOutside = function (event) {
682
+ if (menuRef.current &&
683
+ !menuRef.current.contains(event.target) &&
684
+ menuButtonRef.current &&
685
+ !menuButtonRef.current.contains(event.target)) {
686
+ setIsMenuOpen(false);
687
+ }
688
+ };
689
+ var handleScroll = function () { return setIsMenuOpen(false); };
690
+ var doc = featheryDoc();
691
+ doc.addEventListener('mousedown', handleClickOutside);
692
+ doc.addEventListener('scroll', handleScroll, true);
693
+ return function () {
694
+ doc.removeEventListener('mousedown', handleClickOutside);
695
+ doc.removeEventListener('scroll', handleScroll, true);
696
+ };
697
+ }, [isMenuOpen]);
698
+ var startEditing = function () {
699
+ setEditValue(displayValue);
700
+ setIsEditing(true);
701
+ setIsMenuOpen(false);
702
+ };
703
+ var saveEdit = function () {
704
+ if (editValue !== displayValue) {
705
+ onEdit(fieldKey, rowIndex, editValue);
706
+ }
707
+ setIsEditing(false);
708
+ };
709
+ var cancelEdit = function () {
710
+ shouldSaveRef.current = false;
711
+ setIsEditing(false);
712
+ };
713
+ var handleBlur = function () {
714
+ if (shouldSaveRef.current)
715
+ saveEdit();
716
+ shouldSaveRef.current = true;
717
+ };
718
+ var handleKeyDown = function (e) {
719
+ if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
720
+ e.preventDefault();
721
+ shouldSaveRef.current = false;
722
+ saveEdit();
723
+ }
724
+ else if (e.key === 'Escape') {
725
+ e.preventDefault();
726
+ cancelEdit();
727
+ }
728
+ else if (e.key === 'Tab') {
729
+ shouldSaveRef.current = false;
730
+ saveEdit();
731
+ }
732
+ };
733
+ var handleMenuToggle = function (e) {
734
+ e.stopPropagation();
735
+ if (!isMenuOpen && menuButtonRef.current) {
736
+ var rect = menuButtonRef.current.getBoundingClientRect();
737
+ setMenuPosition({ top: rect.bottom + 4, left: rect.right });
738
+ }
739
+ setIsMenuOpen(!isMenuOpen);
740
+ };
741
+ if (isEditing) {
742
+ return (jsxs("div", __assign({ css: editingCellContentStyle }, { children: [jsx("div", __assign({ css: editingCellSizerStyle }, { children: "".concat(editValue, "\u200B") })), jsx("textarea", { ref: inputRef, value: editValue, onChange: function (e) { return setEditValue(e.target.value); }, onBlur: handleBlur, onKeyDown: handleKeyDown, css: __assign(__assign({}, cellInputStyle), editingCellInputStyle), onClick: function (e) { return e.stopPropagation(); } })] })));
743
+ }
744
+ if (isEmpty) {
745
+ return (jsx("span", __assign({ css: clickToEditStyle, onClick: startEditing }, { children: "Click to edit" })));
746
+ }
747
+ return (jsxs("div", __assign({ css: editableCellContentStyle }, { children: [jsx("span", __assign({ css: editableCellTextStyle }, { children: displayValue })), jsx("button", __assign({ ref: menuButtonRef, type: 'button', "aria-expanded": isMenuOpen, "aria-haspopup": 'menu', css: overflowIconStyle, onClick: handleMenuToggle }, { children: jsx(OverflowIcon, {}) })), isMenuOpen &&
748
+ createPortal(jsxs("div", __assign({ ref: menuRef, role: 'menu', css: __assign(__assign({}, actionMenuStyle), { top: "".concat(menuPosition.top, "px"), left: "".concat(menuPosition.left, "px"), transform: 'translateX(-100%)' }) }, { children: [jsx("button", __assign({ type: 'button', role: 'menuitem', css: actionMenuItemStyle, onClick: function (e) {
749
+ e.stopPropagation();
750
+ startEditing();
751
+ } }, { children: "Edit Value" })), jsx("button", __assign({ type: 'button', role: 'menuitem', css: actionMenuItemStyle, onClick: function (e) {
752
+ e.stopPropagation();
753
+ setIsMenuOpen(false);
754
+ setShowClearConfirm(true);
755
+ } }, { children: "Clear Field" }))] })), featheryDoc().body), showClearConfirm && (jsx(DeleteConfirm, { anchorEl: menuButtonRef.current, message: 'Clear this field?', confirmLabel: 'Clear', onConfirm: function () {
756
+ closeClearConfirm();
757
+ onClear(fieldKey, rowIndex);
758
+ }, onCancel: closeClearConfirm }))] })));
759
+ }
760
+
465
761
  // Utility functions for sorting strings as numbers and dates
466
762
  function tryParseNumber(value) {
467
763
  if (value === null || value === undefined || value === '')
@@ -652,14 +948,16 @@ function setCachedPage(elementId, page) {
652
948
  sessionStorage.setItem(key, page.toString());
653
949
  }
654
950
  function useTableData(_a) {
655
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
656
- var element = _a.element, _m = _a.editMode, editMode = _m === void 0 ? false : _m;
951
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
952
+ var element = _a.element, _r = _a.editMode, editMode = _r === void 0 ? false : _r, _s = _a.dataVersion, dataVersion = _s === void 0 ? 0 : _s;
657
953
  var userColumns = ((_b = element.properties) === null || _b === void 0 ? void 0 : _b.columns) || [];
658
954
  var actions = (((_c = element.properties) === null || _c === void 0 ? void 0 : _c.actions) || []).filter(function (action) { return action.label && action.label.trim() !== ''; });
659
955
  var enableSearch = (_e = (_d = element.properties) === null || _d === void 0 ? void 0 : _d.search) !== null && _e !== void 0 ? _e : false;
660
956
  var enableSort = (_g = (_f = element.properties) === null || _f === void 0 ? void 0 : _f.sort) !== null && _g !== void 0 ? _g : false;
661
957
  var enableTranspose = (_j = (_h = element.properties) === null || _h === void 0 ? void 0 : _h.transpose) !== null && _j !== void 0 ? _j : false;
662
- var paginationSetting = (_l = (_k = element.properties) === null || _k === void 0 ? void 0 : _k.pagination) !== null && _l !== void 0 ? _l : 0;
958
+ var enableEditing = (_l = (_k = element.properties) === null || _k === void 0 ? void 0 : _k.enable_editing) !== null && _l !== void 0 ? _l : false;
959
+ var enableAddDeleteRows = (_o = (_m = element.properties) === null || _m === void 0 ? void 0 : _m.add_delete_rows) !== null && _o !== void 0 ? _o : false;
960
+ var paginationSetting = (_q = (_p = element.properties) === null || _p === void 0 ? void 0 : _p.pagination) !== null && _q !== void 0 ? _q : 0;
663
961
  var rowsPerPage = typeof paginationSetting === 'number' && paginationSetting > 0
664
962
  ? Math.floor(paginationSetting)
665
963
  : 0;
@@ -672,19 +970,20 @@ function useTableData(_a) {
672
970
  }
673
971
  return cols;
674
972
  }, [editMode, userColumns]);
675
- // Use example data in edit mode
973
+ // fieldValues is mutated outside React state, so we need dataVersion
974
+ // as a manual dirty flag to trigger re-snapshots
676
975
  var baseFieldValues = useMemo(function () {
677
976
  if (editMode) {
678
977
  return generateExampleData(baseColumns);
679
978
  }
680
- return fieldValues;
681
- }, [editMode, baseColumns, userColumns.length]);
682
- var _o = __read(useState(''), 2), searchQuery = _o[0], setSearchQuery = _o[1];
683
- var _p = __read(useState(null), 2), sortColumn = _p[0], setSortColumn = _p[1];
684
- var _q = __read(useState('asc'), 2), sortDirection = _q[0], setSortDirection = _q[1];
685
- var _r = __read(useState(function () {
979
+ return __assign({}, fieldValues);
980
+ }, [editMode, baseColumns, dataVersion]);
981
+ var _t = __read(useState(''), 2), searchQuery = _t[0], setSearchQuery = _t[1];
982
+ var _u = __read(useState(null), 2), sortColumn = _u[0], setSortColumn = _u[1];
983
+ var _v = __read(useState('asc'), 2), sortDirection = _v[0], setSortDirection = _v[1];
984
+ var _w = __read(useState(function () {
686
985
  return getCachedPage(element.id);
687
- }), 2), currentPage = _r[0], setCurrentPage = _r[1];
986
+ }), 2), currentPage = _w[0], setCurrentPage = _w[1];
688
987
  var baseNumRows = useMemo(function () {
689
988
  return baseColumns.reduce(function (maxRows, column) {
690
989
  var fieldValue = baseFieldValues[column.field_key];
@@ -720,7 +1019,7 @@ function useTableData(_a) {
720
1019
  enableSearch,
721
1020
  baseFieldValues
722
1021
  ]);
723
- var _s = __read(useState(null), 2), sortedColumnIndex = _s[0], setSortedColumnIndex = _s[1];
1022
+ var _x = __read(useState(null), 2), sortedColumnIndex = _x[0], setSortedColumnIndex = _x[1];
724
1023
  var sortedBaseRowIndices = useMemo(function () {
725
1024
  if (!enableTranspose || !enableSort || sortedColumnIndex === null) {
726
1025
  return filteredBaseRowIndices;
@@ -760,7 +1059,7 @@ function useTableData(_a) {
760
1059
  rowsPerPage,
761
1060
  enablePagination
762
1061
  ]);
763
- var _t = useMemo(function () {
1062
+ var _y = useMemo(function () {
764
1063
  if (!enableTranspose || baseNumRows === 0) {
765
1064
  return {
766
1065
  columns: baseColumns,
@@ -780,7 +1079,7 @@ function useTableData(_a) {
780
1079
  baseFieldValues,
781
1080
  baseNumRows,
782
1081
  paginatedBaseRowIndices
783
- ]), columns = _t.columns, activeFieldValues = _t.activeFieldValues, transposedRowIndices = _t.transposedRowIndices;
1082
+ ]), columns = _y.columns, activeFieldValues = _y.activeFieldValues, transposedRowIndices = _y.transposedRowIndices;
784
1083
  var numRows = useMemo(function () {
785
1084
  return columns.reduce(function (maxRows, column) {
786
1085
  var fieldValue = activeFieldValues[column.field_key];
@@ -961,6 +1260,8 @@ function useTableData(_a) {
961
1260
  actions: actions,
962
1261
  isTransposed: isTransposed,
963
1262
  transposedRowIndices: transposedRowIndices,
1263
+ enableEditing: enableEditing,
1264
+ enableAddDeleteRows: enableAddDeleteRows,
964
1265
  totalRows: totalRows,
965
1266
  totalPages: totalPages,
966
1267
  hasData: hasData,
@@ -970,24 +1271,162 @@ function useTableData(_a) {
970
1271
  };
971
1272
  }
972
1273
 
1274
+ function useTableMutations(_a) {
1275
+ var columns = _a.columns, updateFieldValues = _a.updateFieldValues, submitCustom = _a.submitCustom, editMode = _a.editMode, editModeFieldValues = _a.editModeFieldValues, enablePagination = _a.enablePagination, setCurrentPage = _a.setCurrentPage, setSearchQuery = _a.setSearchQuery, searchQuery = _a.searchQuery, onMutate = _a.onMutate;
1276
+ var editModeFieldValuesRef = useRef(editModeFieldValues);
1277
+ editModeFieldValuesRef.current = editModeFieldValues;
1278
+ var getFieldArray = useCallback(function (fieldKey) {
1279
+ var source = editMode ? editModeFieldValuesRef.current : fieldValues;
1280
+ var val = source[fieldKey];
1281
+ return Array.isArray(val) ? val : [];
1282
+ }, [editMode]);
1283
+ var handleAddRow = useCallback(function () {
1284
+ var updates = {};
1285
+ columns.forEach(function (col) {
1286
+ var existing = getFieldArray(col.field_key);
1287
+ updates[col.field_key] = __spreadArray([''], __read(existing), false);
1288
+ });
1289
+ // Clear search so the new row is visible
1290
+ if (searchQuery)
1291
+ setSearchQuery('');
1292
+ // No submitCustom — new rows are provisional until the user edits a cell,
1293
+ // avoiding empty-row noise in the backend
1294
+ updateFieldValues(updates);
1295
+ onMutate();
1296
+ // Navigate to first page where the new row appears
1297
+ if (enablePagination)
1298
+ setCurrentPage(0);
1299
+ }, [
1300
+ columns,
1301
+ getFieldArray,
1302
+ updateFieldValues,
1303
+ onMutate,
1304
+ enablePagination,
1305
+ setCurrentPage,
1306
+ setSearchQuery,
1307
+ searchQuery
1308
+ ]);
1309
+ var buildRowRemovalUpdates = useCallback(function (rowIndex) {
1310
+ var updates = {};
1311
+ columns.forEach(function (col) {
1312
+ var existing = getFieldArray(col.field_key);
1313
+ updates[col.field_key] = existing.filter(function (_, i) { return i !== rowIndex; });
1314
+ });
1315
+ return updates;
1316
+ }, [columns, getFieldArray]);
1317
+ var handleDeleteRow = useCallback(function (rowIndex) {
1318
+ var updates = buildRowRemovalUpdates(rowIndex);
1319
+ updateFieldValues(updates);
1320
+ if (!editMode)
1321
+ submitCustom(updates);
1322
+ onMutate();
1323
+ }, [
1324
+ buildRowRemovalUpdates,
1325
+ updateFieldValues,
1326
+ submitCustom,
1327
+ editMode,
1328
+ onMutate
1329
+ ]);
1330
+ var handleRemoveRowLocal = useCallback(function (rowIndex) {
1331
+ var updates = buildRowRemovalUpdates(rowIndex);
1332
+ updateFieldValues(updates);
1333
+ onMutate();
1334
+ }, [buildRowRemovalUpdates, updateFieldValues, onMutate]);
1335
+ var handleCellEdit = useCallback(function (fieldKey, rowIndex, newValue) {
1336
+ var _a;
1337
+ var existing = getFieldArray(fieldKey);
1338
+ var updated = __spreadArray([], __read(existing), false);
1339
+ updated[rowIndex] = newValue;
1340
+ var values = (_a = {}, _a[fieldKey] = updated, _a);
1341
+ updateFieldValues(values);
1342
+ if (!editMode)
1343
+ submitCustom(values);
1344
+ onMutate();
1345
+ }, [getFieldArray, updateFieldValues, submitCustom, editMode, onMutate]);
1346
+ var handleCellClear = useCallback(function (fieldKey, rowIndex) {
1347
+ handleCellEdit(fieldKey, rowIndex, '');
1348
+ }, [handleCellEdit]);
1349
+ return {
1350
+ handleAddRow: handleAddRow,
1351
+ handleDeleteRow: handleDeleteRow,
1352
+ handleRemoveRowLocal: handleRemoveRowLocal,
1353
+ handleCellEdit: handleCellEdit,
1354
+ handleCellClear: handleCellClear
1355
+ };
1356
+ }
1357
+
973
1358
  function applyTableStyles(responsiveStyles) {
974
1359
  responsiveStyles.addTargets('table', 'thead', 'tbody', 'th', 'td', 'tr');
975
1360
  return responsiveStyles;
976
1361
  }
977
1362
  function TableElement(_a) {
978
- var element = _a.element, responsiveStyles = _a.responsiveStyles, _b = _a.onClick, onClick = _b === void 0 ? function () { } : _b, _c = _a.editMode, editMode = _c === void 0 ? false : _c, _d = _a.buttonLoaders, buttonLoaders = _d === void 0 ? {} : _d;
1363
+ var element = _a.element, responsiveStyles = _a.responsiveStyles, _b = _a.onClick, onClick = _b === void 0 ? function () { } : _b, _c = _a.updateFieldValues, updateFieldValues = _c === void 0 ? function () { } : _c, _d = _a.submitCustom, submitCustom = _d === void 0 ? function () { } : _d, _e = _a.editMode, editMode = _e === void 0 ? false : _e, _f = _a.buttonLoaders, buttonLoaders = _f === void 0 ? {} : _f;
979
1364
  var styles = useMemo(function () { return applyTableStyles(responsiveStyles); }, [responsiveStyles]);
980
- var _e = useTableData({ element: element, editMode: editMode }),
1365
+ var _g = __read(useState(0), 2), dataVersion = _g[0], setDataVersion = _g[1];
1366
+ var onMutate = useCallback(function () { return setDataVersion(function (v) { return v + 1; }); }, []);
1367
+ var _h = useTableData({ element: element, editMode: editMode, dataVersion: dataVersion }),
981
1368
  // search
982
- enableSearch = _e.enableSearch, searchQuery = _e.searchQuery, setSearchQuery = _e.setSearchQuery,
1369
+ enableSearch = _h.enableSearch, searchQuery = _h.searchQuery, setSearchQuery = _h.setSearchQuery,
983
1370
  // sort
984
- enableSort = _e.enableSort, sortColumn = _e.sortColumn, sortDirection = _e.sortDirection, sortedColumnIndex = _e.sortedColumnIndex, handleSort = _e.handleSort, handleTransposedSort = _e.handleTransposedSort,
1371
+ enableSort = _h.enableSort, sortColumn = _h.sortColumn, sortDirection = _h.sortDirection, sortedColumnIndex = _h.sortedColumnIndex, handleSort = _h.handleSort, handleTransposedSort = _h.handleTransposedSort,
985
1372
  // pagination
986
- enablePagination = _e.enablePagination, currentPage = _e.currentPage, setCurrentPage = _e.setCurrentPage, paginatedRowIndices = _e.paginatedRowIndices, rowsPerPage = _e.rowsPerPage,
1373
+ enablePagination = _h.enablePagination, currentPage = _h.currentPage, setCurrentPage = _h.setCurrentPage, paginatedRowIndices = _h.paginatedRowIndices, rowsPerPage = _h.rowsPerPage,
1374
+ // editing
1375
+ enableEditing = _h.enableEditing, enableAddDeleteRows = _h.enableAddDeleteRows,
987
1376
  // data
988
- columns = _e.columns, actions = _e.actions, isTransposed = _e.isTransposed, transposedRowIndices = _e.transposedRowIndices, totalRows = _e.totalRows, totalPages = _e.totalPages, hasData = _e.hasData, hasSearchResults = _e.hasSearchResults, activeFieldValues = _e.activeFieldValues, baseColumns = _e.baseColumns, baseFieldValues = _e.baseFieldValues;
989
- var showEmptyState = !hasData || (hasData && !hasSearchResults);
990
- return (jsx("div", __assign({ css: __assign(__assign({}, containerStyle), styles.getTarget('container')) }, { children: jsxs("div", __assign({ css: { minWidth: 'fit-content' } }, { children: [enableSearch && (jsx(Search, { searchQuery: searchQuery, onSearchChange: setSearchQuery })), showEmptyState ? (jsx(EmptyState, { hasSearchQuery: searchQuery.trim().length > 0 })) : (jsxs("table", __assign({ css: __assign(__assign({}, tableStyle), styles.getTarget('table')) }, { children: [!isTransposed && (jsx("thead", __assign({ css: theadStyle }, { children: jsxs("tr", { children: [jsx(SortHeader, { columns: columns, enableSort: enableSort, sortColumn: sortColumn, sortDirection: sortDirection, onSort: handleSort, styles: styles }), actions.length > 0 && (jsx("th", { scope: 'col', css: __assign(__assign(__assign({}, thStyle), { paddingLeft: 0 }), styles.getTarget('th')) }))] }) }))), jsxs("tbody", __assign({ css: styles.getTarget('tbody') }, { children: [paginatedRowIndices.map(function (rowIndex) {
1377
+ columns = _h.columns, actions = _h.actions, isTransposed = _h.isTransposed, transposedRowIndices = _h.transposedRowIndices, totalRows = _h.totalRows, totalPages = _h.totalPages, hasData = _h.hasData, hasSearchResults = _h.hasSearchResults, activeFieldValues = _h.activeFieldValues, baseColumns = _h.baseColumns, baseFieldValues = _h.baseFieldValues;
1378
+ var _j = useTableMutations({
1379
+ columns: baseColumns,
1380
+ updateFieldValues: updateFieldValues,
1381
+ submitCustom: submitCustom,
1382
+ editMode: editMode,
1383
+ editModeFieldValues: activeFieldValues,
1384
+ enablePagination: enablePagination,
1385
+ setCurrentPage: setCurrentPage,
1386
+ setSearchQuery: setSearchQuery,
1387
+ searchQuery: searchQuery,
1388
+ onMutate: onMutate
1389
+ }), handleAddRow = _j.handleAddRow, handleDeleteRow = _j.handleDeleteRow, handleCellEdit = _j.handleCellEdit, handleCellClear = _j.handleCellClear;
1390
+ var canEdit = enableEditing && !isTransposed;
1391
+ var showAddRow = canEdit && enableAddDeleteRows;
1392
+ var canDeleteRows = canEdit && enableAddDeleteRows;
1393
+ var hasOverflowMenu = actions.length > 1;
1394
+ var showStandaloneDeleteColumn = canDeleteRows && !hasOverflowMenu;
1395
+ var _k = __read(useState(new Set()), 2), pendingAddRows = _k[0], setPendingAddRows = _k[1];
1396
+ var pendingAddRowsRef = useRef(pendingAddRows);
1397
+ pendingAddRowsRef.current = pendingAddRows;
1398
+ var wrappedHandleCellEdit = useCallback(function (fieldKey, rowIndex, newValue) {
1399
+ if (pendingAddRowsRef.current.has(rowIndex)) {
1400
+ setPendingAddRows(function (prev) {
1401
+ var next = new Set(prev);
1402
+ next.delete(rowIndex);
1403
+ return next;
1404
+ });
1405
+ }
1406
+ handleCellEdit(fieldKey, rowIndex, newValue);
1407
+ }, [handleCellEdit]);
1408
+ var _l = __read(useState(null), 2), deleteRowIndex = _l[0], setDeleteRowIndex = _l[1];
1409
+ var prevPageRef = useRef(currentPage);
1410
+ if (prevPageRef.current !== currentPage) {
1411
+ prevPageRef.current = currentPage;
1412
+ setDeleteRowIndex(null);
1413
+ }
1414
+ var handleCancelDelete = useCallback(function () { return setDeleteRowIndex(null); }, []);
1415
+ var deleteIconRefs = useRef(new Map());
1416
+ var actionCellRefs = useRef(new Map());
1417
+ var showEmptyState = !hasData || !hasSearchResults;
1418
+ var showToolbar = enableSearch || showAddRow;
1419
+ return (jsxs("div", __assign({ css: __assign(__assign({}, containerStyle), styles.getTarget('container')) }, { children: [showToolbar && (jsxs("div", __assign({ css: toolbarStyle }, { children: [enableSearch ? (jsx(Search, { searchQuery: searchQuery, onSearchChange: setSearchQuery })) : (jsx("div", {})), showAddRow && (jsx("button", __assign({ type: 'button', css: addRowButtonStyle, onClick: function () {
1420
+ setDeleteRowIndex(null);
1421
+ handleAddRow();
1422
+ setPendingAddRows(function (prev) {
1423
+ var next = new Set();
1424
+ next.add(0);
1425
+ prev.forEach(function (idx) { return next.add(idx + 1); });
1426
+ return next;
1427
+ });
1428
+ } }, { children: "+ Add Row" })))] }))), showEmptyState ? (jsx(EmptyState, { hasSearchQuery: searchQuery.trim().length > 0 })) : (jsx("div", __assign({ css: { overflowX: 'auto' } }, { children: jsxs("table", __assign({ css: __assign(__assign({}, tableStyle), styles.getTarget('table')) }, { children: [!isTransposed && (jsx("thead", __assign({ css: theadStyle }, { children: jsxs("tr", { children: [jsx(SortHeader, { columns: columns, enableSort: enableSort, sortColumn: sortColumn, sortDirection: sortDirection, onSort: handleSort, styles: styles }), actions.length > 0 && (jsx("th", { scope: 'col', css: __assign(__assign(__assign({}, thStyle), { paddingLeft: 0 }), styles.getTarget('th')) })), showStandaloneDeleteColumn && (jsx("th", { scope: 'col', css: __assign(__assign(__assign({}, thStyle), deleteColumnStyle), styles.getTarget('th')) }))] }) }))), jsxs("tbody", __assign({ css: styles.getTarget('tbody') }, { children: [paginatedRowIndices.map(function (rowIndex) {
1429
+ var _a, _b;
991
1430
  var rowData = {};
992
1431
  if (!isTransposed) {
993
1432
  columns.forEach(function (col) {
@@ -999,7 +1438,7 @@ function TableElement(_a) {
999
1438
  });
1000
1439
  }
1001
1440
  var handleRowClick = function () {
1002
- if (!isTransposed) {
1441
+ if (!isTransposed && !canEdit) {
1003
1442
  onClick({
1004
1443
  rowIndex: rowIndex,
1005
1444
  rowData: rowData
@@ -1017,7 +1456,6 @@ function TableElement(_a) {
1017
1456
  var isSorted = sortedColumnIndex === rowIndex;
1018
1457
  var isFirstColumn = colIndex === 0;
1019
1458
  var isSecondColumn = colIndex === 1;
1020
- // In transposed mode, get the original row index from the column
1021
1459
  var originalRowIndex = isTransposed && !isFirstColInTranspose
1022
1460
  ? column.originalRowIndex
1023
1461
  : undefined;
@@ -1038,7 +1476,6 @@ function TableElement(_a) {
1038
1476
  }
1039
1477
  else if (isTransposed &&
1040
1478
  originalRowIndex !== undefined) {
1041
- // In transposed mode, clicking a cell triggers with original row data
1042
1479
  e.stopPropagation();
1043
1480
  var originalRowData_1 = {};
1044
1481
  baseColumns.forEach(function (col) {
@@ -1054,9 +1491,32 @@ function TableElement(_a) {
1054
1491
  });
1055
1492
  }
1056
1493
  };
1057
- return (jsx(CellElement, __assign({ css: cellCss, onClick: handleCellClick }, (isFirstColInTranspose ? { scope: 'row' } : {}), { children: isFirstColInTranspose && isSortable ? (jsxs("div", __assign({ css: __assign(__assign({}, sortHeaderContentStyle), { justifyContent: 'space-between' }) }, { children: [jsx("span", { children: (_a = stringifyWithNull(cellValue)) !== null && _a !== void 0 ? _a : '' }), jsx("span", __assign({ css: sortIconContainerStyle }, { children: jsx(SortIcon, { isSorted: isSorted, sortDirection: sortDirection }) }))] }))) : ((_b = stringifyWithNull(cellValue)) !== null && _b !== void 0 ? _b : '') }), colIndex));
1058
- }), !isTransposed && actions.length > 0 && (jsx("td", __assign({ css: __assign(__assign(__assign({}, cellStyle), { paddingLeft: 0 }), styles.getTarget('td')) }, { children: jsx(ActionButtons, { actions: actions, rowIndex: rowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, tableId: element.id, buttonLoaders: buttonLoaders }) })))] }), rowIndex));
1059
- }), isTransposed && actions.length > 0 && (jsxs("tr", __assign({ css: __assign(__assign({}, rowStyle), styles.getTarget('tr')) }, { children: [jsx("th", { scope: 'row', css: __assign(__assign(__assign({}, thStyle), { backgroundColor: '#f9fafb', borderRight: '1px solid #e5e7eb', width: '1px', whiteSpace: 'nowrap' }), styles.getTarget('th')) }), transposedRowIndices.map(function (originalRowIndex, idx) { return (jsx("td", __assign({ css: __assign(__assign(__assign({}, cellStyle), (idx === 0 ? {} : { paddingLeft: 0 })), styles.getTarget('td')) }, { children: jsx("div", __assign({ css: { display: 'flex', justifyContent: 'flex-start' } }, { children: jsx(ActionButtons, { actions: actions, rowIndex: originalRowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, forceInlineButtons: true, tableId: element.id, buttonLoaders: buttonLoaders }) })) }), originalRowIndex)); })] })))] }))] }))), !showEmptyState && enablePagination && (jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, totalItems: totalRows, rowsPerPage: rowsPerPage, onPageChange: setCurrentPage }))] })) })));
1494
+ return (jsx(CellElement, __assign({ css: cellCss, onClick: handleCellClick }, (isFirstColInTranspose ? { scope: 'row' } : {}), { children: isFirstColInTranspose && isSortable ? (jsxs("div", __assign({ css: __assign(__assign({}, sortHeaderContentStyle), { justifyContent: 'space-between' }) }, { children: [jsx("span", { children: (_a = stringifyWithNull(cellValue)) !== null && _a !== void 0 ? _a : '' }), jsx("span", __assign({ css: sortIconContainerStyle }, { children: jsx(SortIcon, { isSorted: isSorted, sortDirection: sortDirection }) }))] }))) : canEdit ? (jsx(EditableCell, { value: cellValue, fieldKey: column.field_key, rowIndex: rowIndex, onEdit: wrappedHandleCellEdit, onClear: handleCellClear })) : ((_b = stringifyWithNull(cellValue)) !== null && _b !== void 0 ? _b : '') }), colIndex));
1495
+ }), !isTransposed && actions.length > 0 && (jsxs("td", __assign({ ref: function (el) {
1496
+ if (el)
1497
+ actionCellRefs.current.set(rowIndex, el);
1498
+ else
1499
+ actionCellRefs.current.delete(rowIndex);
1500
+ }, css: __assign(__assign(__assign({}, cellStyle), { paddingLeft: 0 }), styles.getTarget('td')) }, { children: [jsx(ActionButtons, { actions: actions, rowIndex: rowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, tableId: element.id, buttonLoaders: buttonLoaders, canDeleteRows: canDeleteRows && hasOverflowMenu, onDeleteRow: function (ri) { return setDeleteRowIndex(ri); } }), hasOverflowMenu &&
1501
+ canDeleteRows &&
1502
+ deleteRowIndex === rowIndex && (jsx(DeleteConfirm, { anchorEl: (_a = actionCellRefs.current.get(rowIndex)) !== null && _a !== void 0 ? _a : null, onConfirm: function () {
1503
+ handleDeleteRow(rowIndex);
1504
+ setDeleteRowIndex(null);
1505
+ }, onCancel: handleCancelDelete }))] }))), showStandaloneDeleteColumn && (jsxs("td", __assign({ css: __assign(__assign({}, deleteColumnStyle), styles.getTarget('td')) }, { children: [jsx("button", __assign({ type: 'button', ref: function (el) {
1506
+ if (el)
1507
+ deleteIconRefs.current.set(rowIndex, el);
1508
+ else
1509
+ deleteIconRefs.current.delete(rowIndex);
1510
+ }, css: __assign(__assign({}, deleteIconStyle), (deleteRowIndex === rowIndex && {
1511
+ opacity: 1
1512
+ })), onClick: function (e) {
1513
+ e.stopPropagation();
1514
+ setDeleteRowIndex(deleteRowIndex === rowIndex ? null : rowIndex);
1515
+ } }, { children: jsx(TrashIcon, {}) })), deleteRowIndex === rowIndex && (jsx(DeleteConfirm, { anchorEl: (_b = deleteIconRefs.current.get(rowIndex)) !== null && _b !== void 0 ? _b : null, onConfirm: function () {
1516
+ handleDeleteRow(rowIndex);
1517
+ setDeleteRowIndex(null);
1518
+ }, onCancel: handleCancelDelete }))] })))] }), rowIndex));
1519
+ }), isTransposed && actions.length > 0 && (jsxs("tr", __assign({ css: __assign(__assign({}, rowStyle), styles.getTarget('tr')) }, { children: [jsx("th", { scope: 'row', css: __assign(__assign(__assign({}, thStyle), { backgroundColor: '#f9fafb', borderRight: '1px solid #e5e7eb', width: '1px', whiteSpace: 'nowrap' }), styles.getTarget('th')) }), transposedRowIndices.map(function (originalRowIndex, idx) { return (jsx("td", __assign({ css: __assign(__assign(__assign({}, cellStyle), (idx === 0 ? {} : { paddingLeft: 0 })), styles.getTarget('td')) }, { children: jsx("div", __assign({ css: { display: 'flex', justifyContent: 'flex-start' } }, { children: jsx(ActionButtons, { actions: actions, rowIndex: originalRowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, forceInlineButtons: true, tableId: element.id, buttonLoaders: buttonLoaders }) })) }), originalRowIndex)); })] })))] }))] })) }))), !showEmptyState && enablePagination && (jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, totalItems: totalRows, rowsPerPage: rowsPerPage, onPageChange: setCurrentPage }))] })));
1060
1520
  }
1061
1521
 
1062
1522
  export { TableElement as default };