@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,12 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./fthry_index.DQL_RNQ5.js');
3
+ var index = require('./fthry_index.CLcw1cAr.js');
4
4
  var React = require('react');
5
5
  var ReactDOM = require('react-dom');
6
6
  require('react/jsx-runtime');
7
7
  require('react-dom/client');
8
8
  require('jszip');
9
9
 
10
+ function TrashIcon(_a) {
11
+ var _b = _a.width, width = _b === void 0 ? 16 : _b, _c = _a.height, height = _c === void 0 ? 16 : _c, props = index.__rest(_a, ["width", "height"]);
12
+ return (index.jsx("svg", index.__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: index.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' }) })));
13
+ }
14
+
10
15
  var colors = {
11
16
  white: '#ffffff',
12
17
  gray50: '#f9fafb',
@@ -18,7 +23,9 @@ var colors = {
18
23
  gray700: '#374151',
19
24
  gray900: '#111827',
20
25
  blue50: '#eff6ff',
21
- blue700: '#1d4ed8'
26
+ blue700: '#1d4ed8',
27
+ red500: '#ef4444',
28
+ red600: '#dc2626'
22
29
  };
23
30
  var searchIconStyle = {
24
31
  width: '16px',
@@ -77,12 +84,9 @@ var emptyStateTextStyle = {
77
84
  fontWeight: '500',
78
85
  margin: 0
79
86
  };
80
- var searchContainerStyle = {
81
- padding: '16px',
82
- borderBottom: "1px solid ".concat(colors.gray200)
83
- };
84
87
  var searchWrapperStyle = {
85
- position: 'relative'
88
+ position: 'relative',
89
+ flex: 1
86
90
  };
87
91
  var searchIconWrapperStyle = {
88
92
  position: 'absolute',
@@ -129,7 +133,8 @@ var theadStyle = {
129
133
  var thStyle = {
130
134
  padding: '12px 24px',
131
135
  fontWeight: '500',
132
- userSelect: 'none'
136
+ userSelect: 'none',
137
+ whiteSpace: 'nowrap'
133
138
  };
134
139
  var rowStyle = {
135
140
  backgroundColor: colors.white,
@@ -237,6 +242,14 @@ var actionMenuItemStyle = {
237
242
  borderBottomRightRadius: '4px'
238
243
  }
239
244
  };
245
+ var actionMenuSeparatorStyle = {
246
+ borderTop: "1px solid ".concat(colors.gray200),
247
+ margin: '4px 0'
248
+ };
249
+ var actionMenuDeleteItemStyle = index.__assign(index.__assign({}, actionMenuItemStyle), { color: colors.red500, '&:hover': {
250
+ backgroundColor: colors.gray100,
251
+ color: colors.red600
252
+ } });
240
253
  var actionIconButtonStyle = index.__assign(index.__assign({}, actionButtonStyle), { aspectRatio: 1, paddingLeft: 0, paddingRight: 0 });
241
254
  var actionContainerStyle = {
242
255
  display: 'flex',
@@ -261,6 +274,138 @@ var overflowSelectStyle = index.__assign(index.__assign({}, pageButtonStyle), {
261
274
  color: colors.gray900
262
275
  }, '&:focus': {
263
276
  outline: 'none'
277
+ } });
278
+ // Editing styles
279
+ var toolbarStyle = {
280
+ display: 'flex',
281
+ alignItems: 'center',
282
+ justifyContent: 'space-between',
283
+ padding: '16px',
284
+ borderBottom: "1px solid ".concat(colors.gray200),
285
+ gap: '12px'
286
+ };
287
+ var addRowButtonStyle = index.__assign(index.__assign({}, buttonStyle), { borderRadius: '8px', paddingLeft: '12px', paddingRight: '12px', whiteSpace: 'nowrap' });
288
+ var clickToEditStyle = {
289
+ color: colors.gray400,
290
+ cursor: 'pointer',
291
+ userSelect: 'none',
292
+ fontSize: '14px'
293
+ };
294
+ var cellInputStyle = {
295
+ display: 'block',
296
+ width: '100%',
297
+ minWidth: 0,
298
+ maxWidth: '100%',
299
+ padding: '4px 8px',
300
+ border: "1px solid ".concat(colors.blue700),
301
+ borderRadius: '4px',
302
+ fontSize: '14px',
303
+ color: colors.gray900,
304
+ outline: 'none',
305
+ boxSizing: 'border-box',
306
+ resize: 'none',
307
+ overflowY: 'auto',
308
+ fontFamily: 'inherit',
309
+ lineHeight: 1.5
310
+ };
311
+ var editableCellContentStyle = {
312
+ display: 'flex',
313
+ alignItems: 'flex-start',
314
+ gap: '8px'
315
+ };
316
+ var editableCellTextStyle = {
317
+ flex: 1,
318
+ minWidth: 0,
319
+ whiteSpace: 'pre-wrap',
320
+ overflowWrap: 'anywhere',
321
+ wordBreak: 'break-word',
322
+ lineHeight: 1.5
323
+ };
324
+ var editingCellContentStyle = {
325
+ flex: 1,
326
+ minWidth: 0,
327
+ position: 'relative',
328
+ alignSelf: 'stretch'
329
+ };
330
+ var editingCellSizerStyle = index.__assign(index.__assign({}, cellInputStyle), { whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', wordBreak: 'break-word', visibility: 'hidden', pointerEvents: 'none' });
331
+ var editingCellInputStyle = {
332
+ position: 'absolute',
333
+ inset: 0,
334
+ height: '100%'
335
+ };
336
+ var overflowIconStyle = {
337
+ display: 'flex',
338
+ alignItems: 'center',
339
+ justifyContent: 'center',
340
+ width: '24px',
341
+ height: '24px',
342
+ borderRadius: '4px',
343
+ border: 'none',
344
+ backgroundColor: 'transparent',
345
+ color: colors.gray400,
346
+ cursor: 'pointer',
347
+ opacity: 0,
348
+ transition: 'opacity 0.15s',
349
+ flexShrink: 0,
350
+ padding: 0,
351
+ 'tr:hover &, &[aria-expanded="true"]': {
352
+ opacity: 1
353
+ },
354
+ '&:hover': {
355
+ backgroundColor: colors.gray100,
356
+ color: colors.gray600
357
+ }
358
+ };
359
+ var deleteColumnStyle = {
360
+ width: '40px',
361
+ padding: '0 8px'
362
+ };
363
+ var deleteIconStyle = {
364
+ display: 'flex',
365
+ alignItems: 'center',
366
+ justifyContent: 'center',
367
+ width: '28px',
368
+ height: '28px',
369
+ borderRadius: '4px',
370
+ border: 'none',
371
+ backgroundColor: 'transparent',
372
+ color: colors.gray400,
373
+ cursor: 'pointer',
374
+ opacity: 0,
375
+ transition: 'opacity 0.15s',
376
+ padding: 0,
377
+ 'tr:hover &': {
378
+ opacity: 1
379
+ },
380
+ '&:hover': {
381
+ backgroundColor: colors.gray100,
382
+ color: colors.red500
383
+ }
384
+ };
385
+ var confirmPopoverStyle = {
386
+ position: 'fixed',
387
+ backgroundColor: colors.white,
388
+ border: "1px solid ".concat(colors.gray300),
389
+ borderRadius: '8px',
390
+ boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
391
+ zIndex: 9999,
392
+ padding: '12px 16px'
393
+ };
394
+ var confirmTextStyle = {
395
+ margin: '0 0 12px 0',
396
+ fontSize: '14px',
397
+ fontWeight: '500',
398
+ color: colors.gray900
399
+ };
400
+ var confirmButtonRowStyle = {
401
+ display: 'flex',
402
+ gap: '8px',
403
+ justifyContent: 'flex-end'
404
+ };
405
+ var confirmCancelButtonStyle = index.__assign(index.__assign({}, buttonStyle), { borderRadius: '6px', paddingLeft: '12px', paddingRight: '12px', height: '32px' });
406
+ var confirmDeleteButtonStyle = index.__assign(index.__assign({}, buttonStyle), { borderRadius: '6px', paddingLeft: '12px', paddingRight: '12px', height: '32px', backgroundColor: colors.red500, color: colors.white, border: "1px solid ".concat(colors.red500), '&:hover': {
407
+ backgroundColor: colors.red600,
408
+ color: colors.white
264
409
  } });
265
410
 
266
411
  function SearchIcon() {
@@ -273,7 +418,7 @@ function Search(_a) {
273
418
  e.preventDefault();
274
419
  }
275
420
  };
276
- return (index.jsx("div", index.__assign({ css: searchContainerStyle }, { children: index.jsxs("div", index.__assign({ css: searchWrapperStyle }, { children: [index.jsx("div", index.__assign({ css: searchIconWrapperStyle }, { children: index.jsx(SearchIcon, {}) })), index.jsx("input", { type: 'text', css: searchInputStyle, placeholder: 'Search', value: searchQuery, onChange: function (e) { return onSearchChange(e.target.value); }, onKeyDown: handleKeyDown })] })) })));
421
+ return (index.jsxs("div", index.__assign({ css: searchWrapperStyle }, { children: [index.jsx("div", index.__assign({ css: searchIconWrapperStyle }, { children: index.jsx(SearchIcon, {}) })), index.jsx("input", { type: 'text', css: searchInputStyle, placeholder: 'Search', value: searchQuery, onChange: function (e) { return onSearchChange(e.target.value); }, onKeyDown: handleKeyDown })] })));
277
422
  }
278
423
 
279
424
  function SortIcon(_a) {
@@ -358,11 +503,11 @@ function MenuIcon() {
358
503
  }
359
504
  function ActionButtons(_a) {
360
505
  var _b, _c, _d;
361
- 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;
506
+ 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;
362
507
  if (actions.length === 0)
363
508
  return null;
364
- var _h = index.__read(React.useState(false), 2), isMenuOpen = _h[0], setIsMenuOpen = _h[1];
365
- var _j = index.__read(React.useState({ top: 0, left: 0 }), 2), menuPosition = _j[0], setMenuPosition = _j[1];
509
+ var _j = index.__read(React.useState(false), 2), isMenuOpen = _j[0], setIsMenuOpen = _j[1];
510
+ var _k = index.__read(React.useState({ top: 0, left: 0 }), 2), menuPosition = _k[0], setMenuPosition = _k[1];
366
511
  var containerRef = React.useRef(null);
367
512
  var menuRef = React.useRef(null);
368
513
  var menuButtonRef = React.useRef(null);
@@ -429,13 +574,17 @@ function ActionButtons(_a) {
429
574
  alignItems: 'center',
430
575
  justifyContent: 'center'
431
576
  } }, { children: overflowLoader }))) : (index.jsx(MenuIcon, {})) })), isMenuOpen &&
432
- ReactDOM.createPortal(index.jsx("div", index.__assign({ ref: menuRef, css: index.__assign(index.__assign({}, actionMenuStyle), { top: "".concat(menuPosition.top, "px"), left: "".concat(menuPosition.left, "px"), transform: 'translateX(-100%)' }) }, { children: actions.map(function (action, index$1) {
433
- var disabled = Object.keys(buttonLoaders).length > 0;
434
- return (index.jsx("button", index.__assign({ type: 'button', onClick: function (e) {
435
- e.stopPropagation();
436
- handleActionClick(action);
437
- }, css: actionMenuItemStyle, disabled: disabled }, { children: action.label }), index$1));
438
- }) })), index.featheryDoc().body)] })) : (actions.map(function (action, index$1) {
577
+ ReactDOM.createPortal(index.jsxs("div", index.__assign({ ref: menuRef, css: index.__assign(index.__assign({}, actionMenuStyle), { top: "".concat(menuPosition.top, "px"), left: "".concat(menuPosition.left, "px"), transform: 'translateX(-100%)' }) }, { children: [actions.map(function (action, index$1) {
578
+ var disabled = Object.keys(buttonLoaders).length > 0;
579
+ return (index.jsx("button", index.__assign({ type: 'button', onClick: function (e) {
580
+ e.stopPropagation();
581
+ handleActionClick(action);
582
+ }, css: actionMenuItemStyle, disabled: disabled }, { children: action.label }), index$1));
583
+ }), canDeleteRows && onDeleteRow && (index.jsxs(index.Fragment, { children: [index.jsx("div", { css: actionMenuSeparatorStyle }), index.jsx("button", index.__assign({ type: 'button', onClick: function (e) {
584
+ e.stopPropagation();
585
+ setIsMenuOpen(false);
586
+ onDeleteRow(rowIndex);
587
+ }, css: actionMenuDeleteItemStyle }, { children: "Delete" }))] }))] })), index.featheryDoc().body)] })) : (actions.map(function (action, index$1) {
439
588
  var _a;
440
589
  var buttonKey = "".concat(tableId, "_").concat(rowIndex, "_").concat(action.label);
441
590
  var loader = (_a = buttonLoaders[buttonKey]) === null || _a === void 0 ? void 0 : _a.loader;
@@ -464,6 +613,153 @@ function EmptyState(_a) {
464
613
  }, fill: 'none', viewBox: '0 0 24 24', stroke: 'currentColor', strokeWidth: 1.5 }, { children: index.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' }) }))), index.jsx("p", index.__assign({ css: emptyStateTextStyle }, { children: hasSearchQuery ? 'No results found' : 'No data available' })), hasSearchQuery && (index.jsx("p", index.__assign({ css: index.__assign(index.__assign({}, emptyStateTextStyle), { fontSize: '14px', marginTop: '8px' }) }, { children: "Try adjusting your search query" })))] })));
465
614
  }
466
615
 
616
+ function DeleteConfirm(_a) {
617
+ 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;
618
+ var popoverRef = React.useRef(null);
619
+ if (!anchorEl)
620
+ return null;
621
+ var anchorRect = anchorEl.getBoundingClientRect();
622
+ var top = anchorRect.bottom + 4;
623
+ var left = anchorRect.right;
624
+ React.useEffect(function () {
625
+ var handleClickOutside = function (event) {
626
+ if (popoverRef.current &&
627
+ !popoverRef.current.contains(event.target) &&
628
+ anchorEl &&
629
+ !anchorEl.contains(event.target)) {
630
+ onCancel();
631
+ }
632
+ };
633
+ var handleScroll = function () { return onCancel(); };
634
+ var handleKeyDown = function (event) {
635
+ if (event.key === 'Escape')
636
+ onCancel();
637
+ };
638
+ var doc = index.featheryDoc();
639
+ doc.addEventListener('mousedown', handleClickOutside);
640
+ doc.addEventListener('scroll', handleScroll, true);
641
+ doc.addEventListener('keydown', handleKeyDown);
642
+ return function () {
643
+ doc.removeEventListener('mousedown', handleClickOutside);
644
+ doc.removeEventListener('scroll', handleScroll, true);
645
+ doc.removeEventListener('keydown', handleKeyDown);
646
+ };
647
+ }, [onCancel, anchorEl]);
648
+ return ReactDOM.createPortal(index.jsxs("div", index.__assign({ ref: popoverRef, role: 'alertdialog', "aria-label": message, css: index.__assign(index.__assign({}, confirmPopoverStyle), { top: "".concat(top, "px"), left: "".concat(left, "px"), transform: 'translateX(-100%)' }) }, { children: [index.jsx("p", index.__assign({ css: confirmTextStyle }, { children: message })), index.jsxs("div", index.__assign({ css: confirmButtonRowStyle }, { children: [index.jsx("button", index.__assign({ type: 'button', css: confirmCancelButtonStyle, onClick: function (e) {
649
+ e.stopPropagation();
650
+ onCancel();
651
+ } }, { children: "Cancel" })), index.jsx("button", index.__assign({ type: 'button', css: confirmDeleteButtonStyle, onClick: function (e) {
652
+ e.stopPropagation();
653
+ onConfirm();
654
+ } }, { children: confirmLabel }))] }))] })), index.featheryDoc().body);
655
+ }
656
+
657
+ function OverflowIcon() {
658
+ return (index.jsxs("svg", index.__assign({ width: '16', height: '16', fill: 'currentColor', viewBox: '0 0 24 24' }, { children: [index.jsx("circle", { cx: '12', cy: '5', r: '2' }), index.jsx("circle", { cx: '12', cy: '12', r: '2' }), index.jsx("circle", { cx: '12', cy: '19', r: '2' })] })));
659
+ }
660
+ function EditableCell(_a) {
661
+ var _b;
662
+ var value = _a.value, fieldKey = _a.fieldKey, rowIndex = _a.rowIndex, onEdit = _a.onEdit, onClear = _a.onClear;
663
+ var _c = index.__read(React.useState(false), 2), isEditing = _c[0], setIsEditing = _c[1];
664
+ var _d = index.__read(React.useState(''), 2), editValue = _d[0], setEditValue = _d[1];
665
+ var _e = index.__read(React.useState(false), 2), isMenuOpen = _e[0], setIsMenuOpen = _e[1];
666
+ var _f = index.__read(React.useState(false), 2), showClearConfirm = _f[0], setShowClearConfirm = _f[1];
667
+ var _g = index.__read(React.useState({ top: 0, left: 0 }), 2), menuPosition = _g[0], setMenuPosition = _g[1];
668
+ var inputRef = React.useRef(null);
669
+ var menuButtonRef = React.useRef(null);
670
+ var menuRef = React.useRef(null);
671
+ var shouldSaveRef = React.useRef(true);
672
+ var closeClearConfirm = React.useCallback(function () { return setShowClearConfirm(false); }, []);
673
+ var displayValue = (_b = index.stringifyWithNull(value)) !== null && _b !== void 0 ? _b : '';
674
+ var isEmpty = displayValue === '';
675
+ React.useEffect(function () {
676
+ if (isEditing && inputRef.current) {
677
+ inputRef.current.focus();
678
+ }
679
+ }, [isEditing]);
680
+ React.useEffect(function () {
681
+ if (!isMenuOpen)
682
+ return;
683
+ var handleClickOutside = function (event) {
684
+ if (menuRef.current &&
685
+ !menuRef.current.contains(event.target) &&
686
+ menuButtonRef.current &&
687
+ !menuButtonRef.current.contains(event.target)) {
688
+ setIsMenuOpen(false);
689
+ }
690
+ };
691
+ var handleScroll = function () { return setIsMenuOpen(false); };
692
+ var doc = index.featheryDoc();
693
+ doc.addEventListener('mousedown', handleClickOutside);
694
+ doc.addEventListener('scroll', handleScroll, true);
695
+ return function () {
696
+ doc.removeEventListener('mousedown', handleClickOutside);
697
+ doc.removeEventListener('scroll', handleScroll, true);
698
+ };
699
+ }, [isMenuOpen]);
700
+ var startEditing = function () {
701
+ setEditValue(displayValue);
702
+ setIsEditing(true);
703
+ setIsMenuOpen(false);
704
+ };
705
+ var saveEdit = function () {
706
+ if (editValue !== displayValue) {
707
+ onEdit(fieldKey, rowIndex, editValue);
708
+ }
709
+ setIsEditing(false);
710
+ };
711
+ var cancelEdit = function () {
712
+ shouldSaveRef.current = false;
713
+ setIsEditing(false);
714
+ };
715
+ var handleBlur = function () {
716
+ if (shouldSaveRef.current)
717
+ saveEdit();
718
+ shouldSaveRef.current = true;
719
+ };
720
+ var handleKeyDown = function (e) {
721
+ if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
722
+ e.preventDefault();
723
+ shouldSaveRef.current = false;
724
+ saveEdit();
725
+ }
726
+ else if (e.key === 'Escape') {
727
+ e.preventDefault();
728
+ cancelEdit();
729
+ }
730
+ else if (e.key === 'Tab') {
731
+ shouldSaveRef.current = false;
732
+ saveEdit();
733
+ }
734
+ };
735
+ var handleMenuToggle = function (e) {
736
+ e.stopPropagation();
737
+ if (!isMenuOpen && menuButtonRef.current) {
738
+ var rect = menuButtonRef.current.getBoundingClientRect();
739
+ setMenuPosition({ top: rect.bottom + 4, left: rect.right });
740
+ }
741
+ setIsMenuOpen(!isMenuOpen);
742
+ };
743
+ if (isEditing) {
744
+ return (index.jsxs("div", index.__assign({ css: editingCellContentStyle }, { children: [index.jsx("div", index.__assign({ css: editingCellSizerStyle }, { children: "".concat(editValue, "\u200B") })), index.jsx("textarea", { ref: inputRef, value: editValue, onChange: function (e) { return setEditValue(e.target.value); }, onBlur: handleBlur, onKeyDown: handleKeyDown, css: index.__assign(index.__assign({}, cellInputStyle), editingCellInputStyle), onClick: function (e) { return e.stopPropagation(); } })] })));
745
+ }
746
+ if (isEmpty) {
747
+ return (index.jsx("span", index.__assign({ css: clickToEditStyle, onClick: startEditing }, { children: "Click to edit" })));
748
+ }
749
+ return (index.jsxs("div", index.__assign({ css: editableCellContentStyle }, { children: [index.jsx("span", index.__assign({ css: editableCellTextStyle }, { children: displayValue })), index.jsx("button", index.__assign({ ref: menuButtonRef, type: 'button', "aria-expanded": isMenuOpen, "aria-haspopup": 'menu', css: overflowIconStyle, onClick: handleMenuToggle }, { children: index.jsx(OverflowIcon, {}) })), isMenuOpen &&
750
+ ReactDOM.createPortal(index.jsxs("div", index.__assign({ ref: menuRef, role: 'menu', css: index.__assign(index.__assign({}, actionMenuStyle), { top: "".concat(menuPosition.top, "px"), left: "".concat(menuPosition.left, "px"), transform: 'translateX(-100%)' }) }, { children: [index.jsx("button", index.__assign({ type: 'button', role: 'menuitem', css: actionMenuItemStyle, onClick: function (e) {
751
+ e.stopPropagation();
752
+ startEditing();
753
+ } }, { children: "Edit Value" })), index.jsx("button", index.__assign({ type: 'button', role: 'menuitem', css: actionMenuItemStyle, onClick: function (e) {
754
+ e.stopPropagation();
755
+ setIsMenuOpen(false);
756
+ setShowClearConfirm(true);
757
+ } }, { children: "Clear Field" }))] })), index.featheryDoc().body), showClearConfirm && (index.jsx(DeleteConfirm, { anchorEl: menuButtonRef.current, message: 'Clear this field?', confirmLabel: 'Clear', onConfirm: function () {
758
+ closeClearConfirm();
759
+ onClear(fieldKey, rowIndex);
760
+ }, onCancel: closeClearConfirm }))] })));
761
+ }
762
+
467
763
  // Utility functions for sorting strings as numbers and dates
468
764
  function tryParseNumber(value) {
469
765
  if (value === null || value === undefined || value === '')
@@ -654,14 +950,16 @@ function setCachedPage(elementId, page) {
654
950
  sessionStorage.setItem(key, page.toString());
655
951
  }
656
952
  function useTableData(_a) {
657
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
658
- var element = _a.element, _m = _a.editMode, editMode = _m === void 0 ? false : _m;
953
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
954
+ var element = _a.element, _r = _a.editMode, editMode = _r === void 0 ? false : _r, _s = _a.dataVersion, dataVersion = _s === void 0 ? 0 : _s;
659
955
  var userColumns = ((_b = element.properties) === null || _b === void 0 ? void 0 : _b.columns) || [];
660
956
  var actions = (((_c = element.properties) === null || _c === void 0 ? void 0 : _c.actions) || []).filter(function (action) { return action.label && action.label.trim() !== ''; });
661
957
  var enableSearch = (_e = (_d = element.properties) === null || _d === void 0 ? void 0 : _d.search) !== null && _e !== void 0 ? _e : false;
662
958
  var enableSort = (_g = (_f = element.properties) === null || _f === void 0 ? void 0 : _f.sort) !== null && _g !== void 0 ? _g : false;
663
959
  var enableTranspose = (_j = (_h = element.properties) === null || _h === void 0 ? void 0 : _h.transpose) !== null && _j !== void 0 ? _j : false;
664
- var paginationSetting = (_l = (_k = element.properties) === null || _k === void 0 ? void 0 : _k.pagination) !== null && _l !== void 0 ? _l : 0;
960
+ var enableEditing = (_l = (_k = element.properties) === null || _k === void 0 ? void 0 : _k.enable_editing) !== null && _l !== void 0 ? _l : false;
961
+ var enableAddDeleteRows = (_o = (_m = element.properties) === null || _m === void 0 ? void 0 : _m.add_delete_rows) !== null && _o !== void 0 ? _o : false;
962
+ var paginationSetting = (_q = (_p = element.properties) === null || _p === void 0 ? void 0 : _p.pagination) !== null && _q !== void 0 ? _q : 0;
665
963
  var rowsPerPage = typeof paginationSetting === 'number' && paginationSetting > 0
666
964
  ? Math.floor(paginationSetting)
667
965
  : 0;
@@ -674,19 +972,20 @@ function useTableData(_a) {
674
972
  }
675
973
  return cols;
676
974
  }, [editMode, userColumns]);
677
- // Use example data in edit mode
975
+ // fieldValues is mutated outside React state, so we need dataVersion
976
+ // as a manual dirty flag to trigger re-snapshots
678
977
  var baseFieldValues = React.useMemo(function () {
679
978
  if (editMode) {
680
979
  return generateExampleData(baseColumns);
681
980
  }
682
- return index.fieldValues;
683
- }, [editMode, baseColumns, userColumns.length]);
684
- var _o = index.__read(React.useState(''), 2), searchQuery = _o[0], setSearchQuery = _o[1];
685
- var _p = index.__read(React.useState(null), 2), sortColumn = _p[0], setSortColumn = _p[1];
686
- var _q = index.__read(React.useState('asc'), 2), sortDirection = _q[0], setSortDirection = _q[1];
687
- var _r = index.__read(React.useState(function () {
981
+ return index.__assign({}, index.fieldValues);
982
+ }, [editMode, baseColumns, dataVersion]);
983
+ var _t = index.__read(React.useState(''), 2), searchQuery = _t[0], setSearchQuery = _t[1];
984
+ var _u = index.__read(React.useState(null), 2), sortColumn = _u[0], setSortColumn = _u[1];
985
+ var _v = index.__read(React.useState('asc'), 2), sortDirection = _v[0], setSortDirection = _v[1];
986
+ var _w = index.__read(React.useState(function () {
688
987
  return getCachedPage(element.id);
689
- }), 2), currentPage = _r[0], setCurrentPage = _r[1];
988
+ }), 2), currentPage = _w[0], setCurrentPage = _w[1];
690
989
  var baseNumRows = React.useMemo(function () {
691
990
  return baseColumns.reduce(function (maxRows, column) {
692
991
  var fieldValue = baseFieldValues[column.field_key];
@@ -722,7 +1021,7 @@ function useTableData(_a) {
722
1021
  enableSearch,
723
1022
  baseFieldValues
724
1023
  ]);
725
- var _s = index.__read(React.useState(null), 2), sortedColumnIndex = _s[0], setSortedColumnIndex = _s[1];
1024
+ var _x = index.__read(React.useState(null), 2), sortedColumnIndex = _x[0], setSortedColumnIndex = _x[1];
726
1025
  var sortedBaseRowIndices = React.useMemo(function () {
727
1026
  if (!enableTranspose || !enableSort || sortedColumnIndex === null) {
728
1027
  return filteredBaseRowIndices;
@@ -762,7 +1061,7 @@ function useTableData(_a) {
762
1061
  rowsPerPage,
763
1062
  enablePagination
764
1063
  ]);
765
- var _t = React.useMemo(function () {
1064
+ var _y = React.useMemo(function () {
766
1065
  if (!enableTranspose || baseNumRows === 0) {
767
1066
  return {
768
1067
  columns: baseColumns,
@@ -782,7 +1081,7 @@ function useTableData(_a) {
782
1081
  baseFieldValues,
783
1082
  baseNumRows,
784
1083
  paginatedBaseRowIndices
785
- ]), columns = _t.columns, activeFieldValues = _t.activeFieldValues, transposedRowIndices = _t.transposedRowIndices;
1084
+ ]), columns = _y.columns, activeFieldValues = _y.activeFieldValues, transposedRowIndices = _y.transposedRowIndices;
786
1085
  var numRows = React.useMemo(function () {
787
1086
  return columns.reduce(function (maxRows, column) {
788
1087
  var fieldValue = activeFieldValues[column.field_key];
@@ -963,6 +1262,8 @@ function useTableData(_a) {
963
1262
  actions: actions,
964
1263
  isTransposed: isTransposed,
965
1264
  transposedRowIndices: transposedRowIndices,
1265
+ enableEditing: enableEditing,
1266
+ enableAddDeleteRows: enableAddDeleteRows,
966
1267
  totalRows: totalRows,
967
1268
  totalPages: totalPages,
968
1269
  hasData: hasData,
@@ -972,24 +1273,162 @@ function useTableData(_a) {
972
1273
  };
973
1274
  }
974
1275
 
1276
+ function useTableMutations(_a) {
1277
+ 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;
1278
+ var editModeFieldValuesRef = React.useRef(editModeFieldValues);
1279
+ editModeFieldValuesRef.current = editModeFieldValues;
1280
+ var getFieldArray = React.useCallback(function (fieldKey) {
1281
+ var source = editMode ? editModeFieldValuesRef.current : index.fieldValues;
1282
+ var val = source[fieldKey];
1283
+ return Array.isArray(val) ? val : [];
1284
+ }, [editMode]);
1285
+ var handleAddRow = React.useCallback(function () {
1286
+ var updates = {};
1287
+ columns.forEach(function (col) {
1288
+ var existing = getFieldArray(col.field_key);
1289
+ updates[col.field_key] = index.__spreadArray([''], index.__read(existing), false);
1290
+ });
1291
+ // Clear search so the new row is visible
1292
+ if (searchQuery)
1293
+ setSearchQuery('');
1294
+ // No submitCustom — new rows are provisional until the user edits a cell,
1295
+ // avoiding empty-row noise in the backend
1296
+ updateFieldValues(updates);
1297
+ onMutate();
1298
+ // Navigate to first page where the new row appears
1299
+ if (enablePagination)
1300
+ setCurrentPage(0);
1301
+ }, [
1302
+ columns,
1303
+ getFieldArray,
1304
+ updateFieldValues,
1305
+ onMutate,
1306
+ enablePagination,
1307
+ setCurrentPage,
1308
+ setSearchQuery,
1309
+ searchQuery
1310
+ ]);
1311
+ var buildRowRemovalUpdates = React.useCallback(function (rowIndex) {
1312
+ var updates = {};
1313
+ columns.forEach(function (col) {
1314
+ var existing = getFieldArray(col.field_key);
1315
+ updates[col.field_key] = existing.filter(function (_, i) { return i !== rowIndex; });
1316
+ });
1317
+ return updates;
1318
+ }, [columns, getFieldArray]);
1319
+ var handleDeleteRow = React.useCallback(function (rowIndex) {
1320
+ var updates = buildRowRemovalUpdates(rowIndex);
1321
+ updateFieldValues(updates);
1322
+ if (!editMode)
1323
+ submitCustom(updates);
1324
+ onMutate();
1325
+ }, [
1326
+ buildRowRemovalUpdates,
1327
+ updateFieldValues,
1328
+ submitCustom,
1329
+ editMode,
1330
+ onMutate
1331
+ ]);
1332
+ var handleRemoveRowLocal = React.useCallback(function (rowIndex) {
1333
+ var updates = buildRowRemovalUpdates(rowIndex);
1334
+ updateFieldValues(updates);
1335
+ onMutate();
1336
+ }, [buildRowRemovalUpdates, updateFieldValues, onMutate]);
1337
+ var handleCellEdit = React.useCallback(function (fieldKey, rowIndex, newValue) {
1338
+ var _a;
1339
+ var existing = getFieldArray(fieldKey);
1340
+ var updated = index.__spreadArray([], index.__read(existing), false);
1341
+ updated[rowIndex] = newValue;
1342
+ var values = (_a = {}, _a[fieldKey] = updated, _a);
1343
+ updateFieldValues(values);
1344
+ if (!editMode)
1345
+ submitCustom(values);
1346
+ onMutate();
1347
+ }, [getFieldArray, updateFieldValues, submitCustom, editMode, onMutate]);
1348
+ var handleCellClear = React.useCallback(function (fieldKey, rowIndex) {
1349
+ handleCellEdit(fieldKey, rowIndex, '');
1350
+ }, [handleCellEdit]);
1351
+ return {
1352
+ handleAddRow: handleAddRow,
1353
+ handleDeleteRow: handleDeleteRow,
1354
+ handleRemoveRowLocal: handleRemoveRowLocal,
1355
+ handleCellEdit: handleCellEdit,
1356
+ handleCellClear: handleCellClear
1357
+ };
1358
+ }
1359
+
975
1360
  function applyTableStyles(responsiveStyles) {
976
1361
  responsiveStyles.addTargets('table', 'thead', 'tbody', 'th', 'td', 'tr');
977
1362
  return responsiveStyles;
978
1363
  }
979
1364
  function TableElement(_a) {
980
- 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;
1365
+ 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;
981
1366
  var styles = React.useMemo(function () { return applyTableStyles(responsiveStyles); }, [responsiveStyles]);
982
- var _e = useTableData({ element: element, editMode: editMode }),
1367
+ var _g = index.__read(React.useState(0), 2), dataVersion = _g[0], setDataVersion = _g[1];
1368
+ var onMutate = React.useCallback(function () { return setDataVersion(function (v) { return v + 1; }); }, []);
1369
+ var _h = useTableData({ element: element, editMode: editMode, dataVersion: dataVersion }),
983
1370
  // search
984
- enableSearch = _e.enableSearch, searchQuery = _e.searchQuery, setSearchQuery = _e.setSearchQuery,
1371
+ enableSearch = _h.enableSearch, searchQuery = _h.searchQuery, setSearchQuery = _h.setSearchQuery,
985
1372
  // sort
986
- enableSort = _e.enableSort, sortColumn = _e.sortColumn, sortDirection = _e.sortDirection, sortedColumnIndex = _e.sortedColumnIndex, handleSort = _e.handleSort, handleTransposedSort = _e.handleTransposedSort,
1373
+ enableSort = _h.enableSort, sortColumn = _h.sortColumn, sortDirection = _h.sortDirection, sortedColumnIndex = _h.sortedColumnIndex, handleSort = _h.handleSort, handleTransposedSort = _h.handleTransposedSort,
987
1374
  // pagination
988
- enablePagination = _e.enablePagination, currentPage = _e.currentPage, setCurrentPage = _e.setCurrentPage, paginatedRowIndices = _e.paginatedRowIndices, rowsPerPage = _e.rowsPerPage,
1375
+ enablePagination = _h.enablePagination, currentPage = _h.currentPage, setCurrentPage = _h.setCurrentPage, paginatedRowIndices = _h.paginatedRowIndices, rowsPerPage = _h.rowsPerPage,
1376
+ // editing
1377
+ enableEditing = _h.enableEditing, enableAddDeleteRows = _h.enableAddDeleteRows,
989
1378
  // data
990
- 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;
991
- var showEmptyState = !hasData || (hasData && !hasSearchResults);
992
- return (index.jsx("div", index.__assign({ css: index.__assign(index.__assign({}, containerStyle), styles.getTarget('container')) }, { children: index.jsxs("div", index.__assign({ css: { minWidth: 'fit-content' } }, { children: [enableSearch && (index.jsx(Search, { searchQuery: searchQuery, onSearchChange: setSearchQuery })), showEmptyState ? (index.jsx(EmptyState, { hasSearchQuery: searchQuery.trim().length > 0 })) : (index.jsxs("table", index.__assign({ css: index.__assign(index.__assign({}, tableStyle), styles.getTarget('table')) }, { children: [!isTransposed && (index.jsx("thead", index.__assign({ css: theadStyle }, { children: index.jsxs("tr", { children: [index.jsx(SortHeader, { columns: columns, enableSort: enableSort, sortColumn: sortColumn, sortDirection: sortDirection, onSort: handleSort, styles: styles }), actions.length > 0 && (index.jsx("th", { scope: 'col', css: index.__assign(index.__assign(index.__assign({}, thStyle), { paddingLeft: 0 }), styles.getTarget('th')) }))] }) }))), index.jsxs("tbody", index.__assign({ css: styles.getTarget('tbody') }, { children: [paginatedRowIndices.map(function (rowIndex) {
1379
+ 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;
1380
+ var _j = useTableMutations({
1381
+ columns: baseColumns,
1382
+ updateFieldValues: updateFieldValues,
1383
+ submitCustom: submitCustom,
1384
+ editMode: editMode,
1385
+ editModeFieldValues: activeFieldValues,
1386
+ enablePagination: enablePagination,
1387
+ setCurrentPage: setCurrentPage,
1388
+ setSearchQuery: setSearchQuery,
1389
+ searchQuery: searchQuery,
1390
+ onMutate: onMutate
1391
+ }), handleAddRow = _j.handleAddRow, handleDeleteRow = _j.handleDeleteRow, handleCellEdit = _j.handleCellEdit, handleCellClear = _j.handleCellClear;
1392
+ var canEdit = enableEditing && !isTransposed;
1393
+ var showAddRow = canEdit && enableAddDeleteRows;
1394
+ var canDeleteRows = canEdit && enableAddDeleteRows;
1395
+ var hasOverflowMenu = actions.length > 1;
1396
+ var showStandaloneDeleteColumn = canDeleteRows && !hasOverflowMenu;
1397
+ var _k = index.__read(React.useState(new Set()), 2), pendingAddRows = _k[0], setPendingAddRows = _k[1];
1398
+ var pendingAddRowsRef = React.useRef(pendingAddRows);
1399
+ pendingAddRowsRef.current = pendingAddRows;
1400
+ var wrappedHandleCellEdit = React.useCallback(function (fieldKey, rowIndex, newValue) {
1401
+ if (pendingAddRowsRef.current.has(rowIndex)) {
1402
+ setPendingAddRows(function (prev) {
1403
+ var next = new Set(prev);
1404
+ next.delete(rowIndex);
1405
+ return next;
1406
+ });
1407
+ }
1408
+ handleCellEdit(fieldKey, rowIndex, newValue);
1409
+ }, [handleCellEdit]);
1410
+ var _l = index.__read(React.useState(null), 2), deleteRowIndex = _l[0], setDeleteRowIndex = _l[1];
1411
+ var prevPageRef = React.useRef(currentPage);
1412
+ if (prevPageRef.current !== currentPage) {
1413
+ prevPageRef.current = currentPage;
1414
+ setDeleteRowIndex(null);
1415
+ }
1416
+ var handleCancelDelete = React.useCallback(function () { return setDeleteRowIndex(null); }, []);
1417
+ var deleteIconRefs = React.useRef(new Map());
1418
+ var actionCellRefs = React.useRef(new Map());
1419
+ var showEmptyState = !hasData || !hasSearchResults;
1420
+ var showToolbar = enableSearch || showAddRow;
1421
+ return (index.jsxs("div", index.__assign({ css: index.__assign(index.__assign({}, containerStyle), styles.getTarget('container')) }, { children: [showToolbar && (index.jsxs("div", index.__assign({ css: toolbarStyle }, { children: [enableSearch ? (index.jsx(Search, { searchQuery: searchQuery, onSearchChange: setSearchQuery })) : (index.jsx("div", {})), showAddRow && (index.jsx("button", index.__assign({ type: 'button', css: addRowButtonStyle, onClick: function () {
1422
+ setDeleteRowIndex(null);
1423
+ handleAddRow();
1424
+ setPendingAddRows(function (prev) {
1425
+ var next = new Set();
1426
+ next.add(0);
1427
+ prev.forEach(function (idx) { return next.add(idx + 1); });
1428
+ return next;
1429
+ });
1430
+ } }, { children: "+ Add Row" })))] }))), showEmptyState ? (index.jsx(EmptyState, { hasSearchQuery: searchQuery.trim().length > 0 })) : (index.jsx("div", index.__assign({ css: { overflowX: 'auto' } }, { children: index.jsxs("table", index.__assign({ css: index.__assign(index.__assign({}, tableStyle), styles.getTarget('table')) }, { children: [!isTransposed && (index.jsx("thead", index.__assign({ css: theadStyle }, { children: index.jsxs("tr", { children: [index.jsx(SortHeader, { columns: columns, enableSort: enableSort, sortColumn: sortColumn, sortDirection: sortDirection, onSort: handleSort, styles: styles }), actions.length > 0 && (index.jsx("th", { scope: 'col', css: index.__assign(index.__assign(index.__assign({}, thStyle), { paddingLeft: 0 }), styles.getTarget('th')) })), showStandaloneDeleteColumn && (index.jsx("th", { scope: 'col', css: index.__assign(index.__assign(index.__assign({}, thStyle), deleteColumnStyle), styles.getTarget('th')) }))] }) }))), index.jsxs("tbody", index.__assign({ css: styles.getTarget('tbody') }, { children: [paginatedRowIndices.map(function (rowIndex) {
1431
+ var _a, _b;
993
1432
  var rowData = {};
994
1433
  if (!isTransposed) {
995
1434
  columns.forEach(function (col) {
@@ -1001,7 +1440,7 @@ function TableElement(_a) {
1001
1440
  });
1002
1441
  }
1003
1442
  var handleRowClick = function () {
1004
- if (!isTransposed) {
1443
+ if (!isTransposed && !canEdit) {
1005
1444
  onClick({
1006
1445
  rowIndex: rowIndex,
1007
1446
  rowData: rowData
@@ -1019,7 +1458,6 @@ function TableElement(_a) {
1019
1458
  var isSorted = sortedColumnIndex === rowIndex;
1020
1459
  var isFirstColumn = colIndex === 0;
1021
1460
  var isSecondColumn = colIndex === 1;
1022
- // In transposed mode, get the original row index from the column
1023
1461
  var originalRowIndex = isTransposed && !isFirstColInTranspose
1024
1462
  ? column.originalRowIndex
1025
1463
  : undefined;
@@ -1040,7 +1478,6 @@ function TableElement(_a) {
1040
1478
  }
1041
1479
  else if (isTransposed &&
1042
1480
  originalRowIndex !== undefined) {
1043
- // In transposed mode, clicking a cell triggers with original row data
1044
1481
  e.stopPropagation();
1045
1482
  var originalRowData_1 = {};
1046
1483
  baseColumns.forEach(function (col) {
@@ -1056,9 +1493,32 @@ function TableElement(_a) {
1056
1493
  });
1057
1494
  }
1058
1495
  };
1059
- return (index.jsx(CellElement, index.__assign({ css: cellCss, onClick: handleCellClick }, (isFirstColInTranspose ? { scope: 'row' } : {}), { children: isFirstColInTranspose && isSortable ? (index.jsxs("div", index.__assign({ css: index.__assign(index.__assign({}, sortHeaderContentStyle), { justifyContent: 'space-between' }) }, { children: [index.jsx("span", { children: (_a = index.stringifyWithNull(cellValue)) !== null && _a !== void 0 ? _a : '' }), index.jsx("span", index.__assign({ css: sortIconContainerStyle }, { children: index.jsx(SortIcon, { isSorted: isSorted, sortDirection: sortDirection }) }))] }))) : ((_b = index.stringifyWithNull(cellValue)) !== null && _b !== void 0 ? _b : '') }), colIndex));
1060
- }), !isTransposed && actions.length > 0 && (index.jsx("td", index.__assign({ css: index.__assign(index.__assign(index.__assign({}, cellStyle), { paddingLeft: 0 }), styles.getTarget('td')) }, { children: index.jsx(ActionButtons, { actions: actions, rowIndex: rowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, tableId: element.id, buttonLoaders: buttonLoaders }) })))] }), rowIndex));
1061
- }), isTransposed && actions.length > 0 && (index.jsxs("tr", index.__assign({ css: index.__assign(index.__assign({}, rowStyle), styles.getTarget('tr')) }, { children: [index.jsx("th", { scope: 'row', css: index.__assign(index.__assign(index.__assign({}, thStyle), { backgroundColor: '#f9fafb', borderRight: '1px solid #e5e7eb', width: '1px', whiteSpace: 'nowrap' }), styles.getTarget('th')) }), transposedRowIndices.map(function (originalRowIndex, idx) { return (index.jsx("td", index.__assign({ css: index.__assign(index.__assign(index.__assign({}, cellStyle), (idx === 0 ? {} : { paddingLeft: 0 })), styles.getTarget('td')) }, { children: index.jsx("div", index.__assign({ css: { display: 'flex', justifyContent: 'flex-start' } }, { children: index.jsx(ActionButtons, { actions: actions, rowIndex: originalRowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, forceInlineButtons: true, tableId: element.id, buttonLoaders: buttonLoaders }) })) }), originalRowIndex)); })] })))] }))] }))), !showEmptyState && enablePagination && (index.jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, totalItems: totalRows, rowsPerPage: rowsPerPage, onPageChange: setCurrentPage }))] })) })));
1496
+ return (index.jsx(CellElement, index.__assign({ css: cellCss, onClick: handleCellClick }, (isFirstColInTranspose ? { scope: 'row' } : {}), { children: isFirstColInTranspose && isSortable ? (index.jsxs("div", index.__assign({ css: index.__assign(index.__assign({}, sortHeaderContentStyle), { justifyContent: 'space-between' }) }, { children: [index.jsx("span", { children: (_a = index.stringifyWithNull(cellValue)) !== null && _a !== void 0 ? _a : '' }), index.jsx("span", index.__assign({ css: sortIconContainerStyle }, { children: index.jsx(SortIcon, { isSorted: isSorted, sortDirection: sortDirection }) }))] }))) : canEdit ? (index.jsx(EditableCell, { value: cellValue, fieldKey: column.field_key, rowIndex: rowIndex, onEdit: wrappedHandleCellEdit, onClear: handleCellClear })) : ((_b = index.stringifyWithNull(cellValue)) !== null && _b !== void 0 ? _b : '') }), colIndex));
1497
+ }), !isTransposed && actions.length > 0 && (index.jsxs("td", index.__assign({ ref: function (el) {
1498
+ if (el)
1499
+ actionCellRefs.current.set(rowIndex, el);
1500
+ else
1501
+ actionCellRefs.current.delete(rowIndex);
1502
+ }, css: index.__assign(index.__assign(index.__assign({}, cellStyle), { paddingLeft: 0 }), styles.getTarget('td')) }, { children: [index.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 &&
1503
+ canDeleteRows &&
1504
+ deleteRowIndex === rowIndex && (index.jsx(DeleteConfirm, { anchorEl: (_a = actionCellRefs.current.get(rowIndex)) !== null && _a !== void 0 ? _a : null, onConfirm: function () {
1505
+ handleDeleteRow(rowIndex);
1506
+ setDeleteRowIndex(null);
1507
+ }, onCancel: handleCancelDelete }))] }))), showStandaloneDeleteColumn && (index.jsxs("td", index.__assign({ css: index.__assign(index.__assign({}, deleteColumnStyle), styles.getTarget('td')) }, { children: [index.jsx("button", index.__assign({ type: 'button', ref: function (el) {
1508
+ if (el)
1509
+ deleteIconRefs.current.set(rowIndex, el);
1510
+ else
1511
+ deleteIconRefs.current.delete(rowIndex);
1512
+ }, css: index.__assign(index.__assign({}, deleteIconStyle), (deleteRowIndex === rowIndex && {
1513
+ opacity: 1
1514
+ })), onClick: function (e) {
1515
+ e.stopPropagation();
1516
+ setDeleteRowIndex(deleteRowIndex === rowIndex ? null : rowIndex);
1517
+ } }, { children: index.jsx(TrashIcon, {}) })), deleteRowIndex === rowIndex && (index.jsx(DeleteConfirm, { anchorEl: (_b = deleteIconRefs.current.get(rowIndex)) !== null && _b !== void 0 ? _b : null, onConfirm: function () {
1518
+ handleDeleteRow(rowIndex);
1519
+ setDeleteRowIndex(null);
1520
+ }, onCancel: handleCancelDelete }))] })))] }), rowIndex));
1521
+ }), isTransposed && actions.length > 0 && (index.jsxs("tr", index.__assign({ css: index.__assign(index.__assign({}, rowStyle), styles.getTarget('tr')) }, { children: [index.jsx("th", { scope: 'row', css: index.__assign(index.__assign(index.__assign({}, thStyle), { backgroundColor: '#f9fafb', borderRight: '1px solid #e5e7eb', width: '1px', whiteSpace: 'nowrap' }), styles.getTarget('th')) }), transposedRowIndices.map(function (originalRowIndex, idx) { return (index.jsx("td", index.__assign({ css: index.__assign(index.__assign(index.__assign({}, cellStyle), (idx === 0 ? {} : { paddingLeft: 0 })), styles.getTarget('td')) }, { children: index.jsx("div", index.__assign({ css: { display: 'flex', justifyContent: 'flex-start' } }, { children: index.jsx(ActionButtons, { actions: actions, rowIndex: originalRowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, forceInlineButtons: true, tableId: element.id, buttonLoaders: buttonLoaders }) })) }), originalRowIndex)); })] })))] }))] })) }))), !showEmptyState && enablePagination && (index.jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, totalItems: totalRows, rowsPerPage: rowsPerPage, onPageChange: setCurrentPage }))] })));
1062
1522
  }
1063
1523
 
1064
1524
  exports.default = TableElement;