@feathery/react 2.30.0 → 2.31.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 (136) 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/elements/basic/TableElement/Actions.d.ts +3 -1
  4. package/cjs/elements/basic/TableElement/Actions.d.ts.map +1 -1
  5. package/cjs/elements/basic/TableElement/DeleteConfirm.d.ts +11 -0
  6. package/cjs/elements/basic/TableElement/DeleteConfirm.d.ts.map +1 -0
  7. package/cjs/elements/basic/TableElement/EditableCell.d.ts +10 -0
  8. package/cjs/elements/basic/TableElement/EditableCell.d.ts.map +1 -0
  9. package/cjs/elements/basic/TableElement/Search.d.ts.map +1 -1
  10. package/cjs/elements/basic/TableElement/index.d.ts +1 -1
  11. package/cjs/elements/basic/TableElement/index.d.ts.map +1 -1
  12. package/cjs/elements/basic/TableElement/styles.d.ts +221 -4
  13. package/cjs/elements/basic/TableElement/styles.d.ts.map +1 -1
  14. package/cjs/elements/basic/TableElement/useColumnWidths.d.ts +7 -0
  15. package/cjs/elements/basic/TableElement/useColumnWidths.d.ts.map +1 -0
  16. package/cjs/elements/basic/TableElement/useTableData.d.ts +6 -1
  17. package/cjs/elements/basic/TableElement/useTableData.d.ts.map +1 -1
  18. package/cjs/elements/basic/TableElement/useTableMutations.d.ts +23 -0
  19. package/cjs/elements/basic/TableElement/useTableMutations.d.ts.map +1 -0
  20. package/cjs/elements/components/icons/TrashIcon.d.ts +3 -0
  21. package/cjs/elements/components/icons/TrashIcon.d.ts.map +1 -0
  22. package/cjs/elements/components/icons/index.d.ts +2 -1
  23. package/cjs/elements/components/icons/index.d.ts.map +1 -1
  24. package/cjs/{fthry_FormControl._mBWRKs7.js → fthry_FormControl.WIYoX7l6.js} +1 -1
  25. package/cjs/{fthry_InlineTooltip.Ci88wpmH.js → fthry_InlineTooltip.C6Kf0Ff-.js} +2 -2
  26. package/cjs/{fthry_Overlay.EZR3dxIp.js → fthry_Overlay.JRkHffzB.js} +1 -1
  27. package/cjs/{fthry_PaymentMethodField.D1qfT6ml.js → fthry_PaymentMethodField.DvPj_Lup.js} +4 -4
  28. package/cjs/{fthry_Placeholder.CxuLPsF-.js → fthry_Placeholder.luXrF_m_.js} +1 -1
  29. package/cjs/{fthry_ShowEyeIcon.B7ZyaGae.js → fthry_ShowEyeIcon.cWxfPj5A.js} +1 -1
  30. package/cjs/{fthry_index.DRlPrDHk.js → fthry_index.7lPT7adc.js} +4 -4
  31. package/cjs/{fthry_index.DmfLe1_p.js → fthry_index.Ax4XuQ-W.js} +1 -1
  32. package/cjs/{fthry_index.D1vI8h-g.js → fthry_index.B1gH_Pb_.js} +4 -4
  33. package/cjs/{fthry_index.YrpKr9cF.js → fthry_index.BAf-75T4.js} +1 -1
  34. package/cjs/{fthry_index.B29cmrSc.js → fthry_index.BS2jEY70.js} +5 -5
  35. package/cjs/{fthry_index.CatPMXS_.js → fthry_index.BT0N_ojJ.js} +5 -5
  36. package/cjs/{fthry_index.CZO8LB_A.js → fthry_index.B_WCqLEf.js} +2 -2
  37. package/cjs/{fthry_index.BTEjXAoq.js → fthry_index.Be2Fs97T.js} +5 -5
  38. package/cjs/{fthry_index.sxVKbE6v.js → fthry_index.Bxz6SYIg.js} +6 -6
  39. package/cjs/{fthry_index.Bm1hHYyX.js → fthry_index.C4a2Ic12.js} +1 -1
  40. package/cjs/{fthry_index.B87qkPTe.js → fthry_index.C51tqyoq.js} +1 -1
  41. package/cjs/{fthry_index.DlbhlY21.js → fthry_index.Caau3hdX.js} +5 -5
  42. package/cjs/{fthry_index.Dgwh7PEG.js → fthry_index.CcK_Svsf.js} +6 -6
  43. package/cjs/{fthry_index.Cx9wY-d4.js → fthry_index.CfElaaWV.js} +6 -6
  44. package/cjs/{fthry_index.CfL17UCN.js → fthry_index.CmAB9Ar7.js} +1 -1
  45. package/cjs/{fthry_index.BYHaM6D3.js → fthry_index.DWS39de6.js} +1 -1
  46. package/cjs/{fthry_index.CA9rB_hE.js → fthry_index.D_RuNzwI.js} +8 -8
  47. package/cjs/{fthry_index.CJ_xssDe.js → fthry_index.DdSDwu2Z.js} +1 -1
  48. package/cjs/{fthry_index.qIj6fG9T.js → fthry_index.DtcJ5ShY.js} +3 -3
  49. package/cjs/{fthry_index.CUmRx79G.js → fthry_index.DtiRdy95.js} +3 -3
  50. package/cjs/{fthry_index.esjf5uCx.js → fthry_index.IHqwZyC3.js} +29 -28
  51. package/cjs/{fthry_index.C2Hmw3MN.js → fthry_index.Io4u55nU.js} +527 -47
  52. package/cjs/{fthry_index.BS76NJIi.js → fthry_index.TgxeIOKY.js} +2 -2
  53. package/cjs/{fthry_index.DESk4H5E.js → fthry_index.W-9IfXEV.js} +4 -4
  54. package/cjs/{fthry_input.DL5PaVNA.js → fthry_input.QMSUSm2J.js} +1 -1
  55. package/cjs/{fthry_script.Dx-T4xgR.js → fthry_script.Bnnc8FZ3.js} +1 -1
  56. package/cjs/{fthry_styles.lXVAR-s8.js → fthry_styles.MX1EKxvQ.js} +1 -1
  57. package/cjs/{fthry_useElementSize.Di0_hIVc.js → fthry_useElementSize.Dup4Oq53.js} +1 -1
  58. package/cjs/{fthry_useSalesforceSync.BRclBQ5F.js → fthry_useSalesforceSync.D0kLb1UT.js} +1 -1
  59. package/cjs/{fthry_webfontloader.Cpo-BOVP.js → fthry_webfontloader.C-AsnAPa.js} +1 -1
  60. package/cjs/index.js +1 -1
  61. package/dist/Form/grid/Element/index.d.ts.map +1 -1
  62. package/dist/Form/index.d.ts.map +1 -1
  63. package/dist/elements/basic/TableElement/Actions.d.ts +3 -1
  64. package/dist/elements/basic/TableElement/Actions.d.ts.map +1 -1
  65. package/dist/elements/basic/TableElement/DeleteConfirm.d.ts +11 -0
  66. package/dist/elements/basic/TableElement/DeleteConfirm.d.ts.map +1 -0
  67. package/dist/elements/basic/TableElement/EditableCell.d.ts +10 -0
  68. package/dist/elements/basic/TableElement/EditableCell.d.ts.map +1 -0
  69. package/dist/elements/basic/TableElement/Search.d.ts.map +1 -1
  70. package/dist/elements/basic/TableElement/index.d.ts +1 -1
  71. package/dist/elements/basic/TableElement/index.d.ts.map +1 -1
  72. package/dist/elements/basic/TableElement/styles.d.ts +221 -4
  73. package/dist/elements/basic/TableElement/styles.d.ts.map +1 -1
  74. package/dist/elements/basic/TableElement/useColumnWidths.d.ts +7 -0
  75. package/dist/elements/basic/TableElement/useColumnWidths.d.ts.map +1 -0
  76. package/dist/elements/basic/TableElement/useTableData.d.ts +6 -1
  77. package/dist/elements/basic/TableElement/useTableData.d.ts.map +1 -1
  78. package/dist/elements/basic/TableElement/useTableMutations.d.ts +23 -0
  79. package/dist/elements/basic/TableElement/useTableMutations.d.ts.map +1 -0
  80. package/dist/elements/components/icons/TrashIcon.d.ts +3 -0
  81. package/dist/elements/components/icons/TrashIcon.d.ts.map +1 -0
  82. package/dist/elements/components/icons/index.d.ts +2 -1
  83. package/dist/elements/components/icons/index.d.ts.map +1 -1
  84. package/dist/{fthry_FormControl.CGMmdVSc.js → fthry_FormControl.DEleJ-Vj.js} +1 -1
  85. package/dist/{fthry_InlineTooltip.DIH2B37d.js → fthry_InlineTooltip.DeG1g5MU.js} +2 -2
  86. package/dist/{fthry_Overlay.Dms5dmjM.js → fthry_Overlay.CtQBdlg7.js} +1 -1
  87. package/dist/{fthry_PaymentMethodField.BnL3H5Wi.js → fthry_PaymentMethodField.CryiQIpT.js} +4 -4
  88. package/dist/{fthry_Placeholder.Iyh2B1Vg.js → fthry_Placeholder.Bel7e4T4.js} +1 -1
  89. package/dist/{fthry_ShowEyeIcon.fhgXiXP4.js → fthry_ShowEyeIcon.BeXoEyvh.js} +1 -1
  90. package/dist/{fthry_index.C40AmEzu.js → fthry_index.0A10yDWO.js} +1 -1
  91. package/dist/{fthry_index.B5mf0ZCq.js → fthry_index.BNi8VaMz.js} +2 -2
  92. package/dist/{fthry_index.DBZUNt6w.js → fthry_index.Bb9yC_Hb.js} +3 -3
  93. package/dist/{fthry_index.BOaXtIdq.js → fthry_index.Bi8oY0jk.js} +5 -5
  94. package/dist/{fthry_index.DX4rqE80.js → fthry_index.Bk-p0axS.js} +6 -6
  95. package/dist/{fthry_index.DOmt6TII.js → fthry_index.By9Va7yz.js} +6 -6
  96. package/dist/{fthry_index.CRvWHGpG.js → fthry_index.C9r-2T-9.js} +6 -6
  97. package/dist/{fthry_index.BkscK5im.js → fthry_index.CMh4cU_z.js} +30 -29
  98. package/dist/{fthry_index.BRU7YLIR.js → fthry_index.CUF2y3Aa.js} +1 -1
  99. package/dist/{fthry_index.BB67IaKw.js → fthry_index.CVQd320z.js} +8 -8
  100. package/dist/{fthry_index.DgW_Sk0D.js → fthry_index.ClSefCHf.js} +1 -1
  101. package/dist/{fthry_index.BLyrEbs8.js → fthry_index.D7lNVIgD.js} +1 -1
  102. package/dist/{fthry_index.C_xgfMIW.js → fthry_index.D9GA9x4P.js} +3 -3
  103. package/dist/{fthry_index.DNgUGj0v.js → fthry_index.DKiSNQ6p.js} +1 -1
  104. package/dist/{fthry_index.CxmqmKxy.js → fthry_index.DR8HsKVo.js} +4 -4
  105. package/dist/{fthry_index.BSFJ3j16.js → fthry_index.DSS7GFbG.js} +4 -4
  106. package/dist/{fthry_index.BYbi4yOb.js → fthry_index.D_JQEcg-.js} +4 -4
  107. package/dist/{fthry_index.B6oCJbWU.js → fthry_index.DclrMlf2.js} +5 -5
  108. package/dist/{fthry_index.B2Y9eDOP.js → fthry_index.Dkg3j5xH.js} +2 -2
  109. package/dist/{fthry_index.Cy3JGRX4.js → fthry_index.DtrV_j07.js} +1 -1
  110. package/dist/{fthry_index.fnKZHN9M.js → fthry_index.Dxpjw81y.js} +5 -5
  111. package/dist/{fthry_index.BkMppX8l.js → fthry_index.F3kjcuAK.js} +528 -48
  112. package/dist/{fthry_index.BtNQk9j_.js → fthry_index.sWxp-JjY.js} +5 -5
  113. package/dist/{fthry_index.C2gfdQbg.js → fthry_index.y9utv2Db.js} +1 -1
  114. package/dist/{fthry_input.BGGtX-3o.js → fthry_input.DlZicl10.js} +1 -1
  115. package/dist/{fthry_script.Dqr52s2y.js → fthry_script.BjtIkib6.js} +1 -1
  116. package/dist/{fthry_styles.BY3ne7eH.js → fthry_styles.Dxs0EByz.js} +1 -1
  117. package/dist/{fthry_useElementSize.OjCA2DBM.js → fthry_useElementSize.BeQYF72J.js} +1 -1
  118. package/dist/{fthry_useSalesforceSync.C09-2TZ5.js → fthry_useSalesforceSync.DcCcNLS2.js} +1 -1
  119. package/dist/{fthry_webfontloader.DIwhNN5h.js → fthry_webfontloader.B7FGEMJA.js} +1 -1
  120. package/dist/index.js +1 -1
  121. package/package.json +1 -1
  122. package/umd/{277.d9907ecd5dc2117c9171.js → 277.87e6ca5c1cf2a7477992.js} +1 -1
  123. package/umd/{509.a863f8749c28540476bb.js → 509.bca2ff43c66b1dba064f.js} +2 -2
  124. package/umd/{AddressField.ec97334fe233830bc05b.js → AddressField.2d777eda22a67a0ed3a3.js} +1 -1
  125. package/umd/{DateSelectorField.00f321e0b1972feb9d69.js → DateSelectorField.54afc978d2fd9d10b106.js} +1 -1
  126. package/umd/{FileUploadField.ea0067dd62b0454b7c2e.js → FileUploadField.7a5028fb6035d09b3e81.js} +1 -1
  127. package/umd/{PasswordField.1358356d6fbc6880f12a.js → PasswordField.7585ef588333cb4181f7.js} +1 -1
  128. package/umd/{PaymentMethodField.9a8e934f7450eb141217.js → PaymentMethodField.d08bcfa1efb56084572d.js} +1 -1
  129. package/umd/{PhoneField.c526085aaa5ccd25e982.js → PhoneField.19c987f04cfcb60ab07c.js} +1 -1
  130. package/umd/{SignatureField.d710930ca89642eb651c.js → SignatureField.0e7d60fa2fafcb6be554.js} +1 -1
  131. package/umd/TableElement.b9bb3cedf1a75fd2ea01.js +1 -0
  132. package/umd/{TextArea.f566845d458d4c00e0e7.js → TextArea.7cca0d69e618846660c5.js} +1 -1
  133. package/umd/{TextField.5a5296fe3ea60c4459f2.js → TextField.f5cc4a03e69d5872027b.js} +1 -1
  134. package/umd/index.js +1 -1
  135. package/umd/TableElement.ee77e0f53a9ccac846ab.js +0 -1
  136. /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.esjf5uCx.js');
3
+ var index = require('./fthry_index.IHqwZyC3.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,111 @@ 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
+ width: '100%',
296
+ padding: '4px 8px',
297
+ border: "1px solid ".concat(colors.blue700),
298
+ borderRadius: '4px',
299
+ fontSize: '14px',
300
+ color: colors.gray900,
301
+ outline: 'none',
302
+ boxSizing: 'border-box'
303
+ };
304
+ var editableCellContentStyle = {
305
+ display: 'flex',
306
+ alignItems: 'center',
307
+ gap: '8px'
308
+ };
309
+ var overflowIconStyle = {
310
+ display: 'flex',
311
+ alignItems: 'center',
312
+ justifyContent: 'center',
313
+ width: '24px',
314
+ height: '24px',
315
+ borderRadius: '4px',
316
+ border: 'none',
317
+ backgroundColor: 'transparent',
318
+ color: colors.gray400,
319
+ cursor: 'pointer',
320
+ opacity: 0,
321
+ transition: 'opacity 0.15s',
322
+ flexShrink: 0,
323
+ padding: 0,
324
+ 'tr:hover &, &[aria-expanded="true"]': {
325
+ opacity: 1
326
+ },
327
+ '&:hover': {
328
+ backgroundColor: colors.gray100,
329
+ color: colors.gray600
330
+ }
331
+ };
332
+ var deleteColumnStyle = {
333
+ width: '40px',
334
+ padding: '0 8px'
335
+ };
336
+ var deleteIconStyle = {
337
+ display: 'flex',
338
+ alignItems: 'center',
339
+ justifyContent: 'center',
340
+ width: '28px',
341
+ height: '28px',
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
+ padding: 0,
350
+ 'tr:hover &': {
351
+ opacity: 1
352
+ },
353
+ '&:hover': {
354
+ backgroundColor: colors.gray100,
355
+ color: colors.red500
356
+ }
357
+ };
358
+ var confirmPopoverStyle = {
359
+ position: 'fixed',
360
+ backgroundColor: colors.white,
361
+ border: "1px solid ".concat(colors.gray300),
362
+ borderRadius: '8px',
363
+ boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
364
+ zIndex: 9999,
365
+ padding: '12px 16px'
366
+ };
367
+ var confirmTextStyle = {
368
+ margin: '0 0 12px 0',
369
+ fontSize: '14px',
370
+ fontWeight: '500',
371
+ color: colors.gray900
372
+ };
373
+ var confirmButtonRowStyle = {
374
+ display: 'flex',
375
+ gap: '8px',
376
+ justifyContent: 'flex-end'
377
+ };
378
+ var confirmCancelButtonStyle = index.__assign(index.__assign({}, buttonStyle), { borderRadius: '6px', paddingLeft: '12px', paddingRight: '12px', height: '32px' });
379
+ 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': {
380
+ backgroundColor: colors.red600,
381
+ color: colors.white
264
382
  } });
265
383
 
266
384
  function SearchIcon() {
@@ -273,7 +391,7 @@ function Search(_a) {
273
391
  e.preventDefault();
274
392
  }
275
393
  };
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 })] })) })));
394
+ 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
395
  }
278
396
 
279
397
  function SortIcon(_a) {
@@ -358,11 +476,11 @@ function MenuIcon() {
358
476
  }
359
477
  function ActionButtons(_a) {
360
478
  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;
479
+ 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
480
  if (actions.length === 0)
363
481
  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];
482
+ var _j = index.__read(React.useState(false), 2), isMenuOpen = _j[0], setIsMenuOpen = _j[1];
483
+ var _k = index.__read(React.useState({ top: 0, left: 0 }), 2), menuPosition = _k[0], setMenuPosition = _k[1];
366
484
  var containerRef = React.useRef(null);
367
485
  var menuRef = React.useRef(null);
368
486
  var menuButtonRef = React.useRef(null);
@@ -429,13 +547,17 @@ function ActionButtons(_a) {
429
547
  alignItems: 'center',
430
548
  justifyContent: 'center'
431
549
  } }, { 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) {
550
+ 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) {
551
+ var disabled = Object.keys(buttonLoaders).length > 0;
552
+ return (index.jsx("button", index.__assign({ type: 'button', onClick: function (e) {
553
+ e.stopPropagation();
554
+ handleActionClick(action);
555
+ }, css: actionMenuItemStyle, disabled: disabled }, { children: action.label }), index$1));
556
+ }), canDeleteRows && onDeleteRow && (index.jsxs(index.Fragment, { children: [index.jsx("div", { css: actionMenuSeparatorStyle }), index.jsx("button", index.__assign({ type: 'button', onClick: function (e) {
557
+ e.stopPropagation();
558
+ setIsMenuOpen(false);
559
+ onDeleteRow(rowIndex);
560
+ }, css: actionMenuDeleteItemStyle }, { children: "Delete" }))] }))] })), index.featheryDoc().body)] })) : (actions.map(function (action, index$1) {
439
561
  var _a;
440
562
  var buttonKey = "".concat(tableId, "_").concat(rowIndex, "_").concat(action.label);
441
563
  var loader = (_a = buttonLoaders[buttonKey]) === null || _a === void 0 ? void 0 : _a.loader;
@@ -464,6 +586,153 @@ function EmptyState(_a) {
464
586
  }, 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
587
  }
466
588
 
589
+ function DeleteConfirm(_a) {
590
+ 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;
591
+ var popoverRef = React.useRef(null);
592
+ if (!anchorEl)
593
+ return null;
594
+ var anchorRect = anchorEl.getBoundingClientRect();
595
+ var top = anchorRect.bottom + 4;
596
+ var left = anchorRect.right;
597
+ React.useEffect(function () {
598
+ var handleClickOutside = function (event) {
599
+ if (popoverRef.current &&
600
+ !popoverRef.current.contains(event.target) &&
601
+ anchorEl &&
602
+ !anchorEl.contains(event.target)) {
603
+ onCancel();
604
+ }
605
+ };
606
+ var handleScroll = function () { return onCancel(); };
607
+ var handleKeyDown = function (event) {
608
+ if (event.key === 'Escape')
609
+ onCancel();
610
+ };
611
+ var doc = index.featheryDoc();
612
+ doc.addEventListener('mousedown', handleClickOutside);
613
+ doc.addEventListener('scroll', handleScroll, true);
614
+ doc.addEventListener('keydown', handleKeyDown);
615
+ return function () {
616
+ doc.removeEventListener('mousedown', handleClickOutside);
617
+ doc.removeEventListener('scroll', handleScroll, true);
618
+ doc.removeEventListener('keydown', handleKeyDown);
619
+ };
620
+ }, [onCancel, anchorEl]);
621
+ 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) {
622
+ e.stopPropagation();
623
+ onCancel();
624
+ } }, { children: "Cancel" })), index.jsx("button", index.__assign({ type: 'button', css: confirmDeleteButtonStyle, onClick: function (e) {
625
+ e.stopPropagation();
626
+ onConfirm();
627
+ } }, { children: confirmLabel }))] }))] })), index.featheryDoc().body);
628
+ }
629
+
630
+ function OverflowIcon() {
631
+ 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' })] })));
632
+ }
633
+ function EditableCell(_a) {
634
+ var _b;
635
+ var value = _a.value, fieldKey = _a.fieldKey, rowIndex = _a.rowIndex, onEdit = _a.onEdit, onClear = _a.onClear;
636
+ var _c = index.__read(React.useState(false), 2), isEditing = _c[0], setIsEditing = _c[1];
637
+ var _d = index.__read(React.useState(''), 2), editValue = _d[0], setEditValue = _d[1];
638
+ var _e = index.__read(React.useState(false), 2), isMenuOpen = _e[0], setIsMenuOpen = _e[1];
639
+ var _f = index.__read(React.useState(false), 2), showClearConfirm = _f[0], setShowClearConfirm = _f[1];
640
+ var _g = index.__read(React.useState({ top: 0, left: 0 }), 2), menuPosition = _g[0], setMenuPosition = _g[1];
641
+ var inputRef = React.useRef(null);
642
+ var menuButtonRef = React.useRef(null);
643
+ var menuRef = React.useRef(null);
644
+ var shouldSaveRef = React.useRef(true);
645
+ var closeClearConfirm = React.useCallback(function () { return setShowClearConfirm(false); }, []);
646
+ var displayValue = (_b = index.stringifyWithNull(value)) !== null && _b !== void 0 ? _b : '';
647
+ var isEmpty = displayValue === '';
648
+ React.useEffect(function () {
649
+ if (isEditing && inputRef.current) {
650
+ inputRef.current.focus();
651
+ }
652
+ }, [isEditing]);
653
+ React.useEffect(function () {
654
+ if (!isMenuOpen)
655
+ return;
656
+ var handleClickOutside = function (event) {
657
+ if (menuRef.current &&
658
+ !menuRef.current.contains(event.target) &&
659
+ menuButtonRef.current &&
660
+ !menuButtonRef.current.contains(event.target)) {
661
+ setIsMenuOpen(false);
662
+ }
663
+ };
664
+ var handleScroll = function () { return setIsMenuOpen(false); };
665
+ var doc = index.featheryDoc();
666
+ doc.addEventListener('mousedown', handleClickOutside);
667
+ doc.addEventListener('scroll', handleScroll, true);
668
+ return function () {
669
+ doc.removeEventListener('mousedown', handleClickOutside);
670
+ doc.removeEventListener('scroll', handleScroll, true);
671
+ };
672
+ }, [isMenuOpen]);
673
+ var startEditing = function () {
674
+ setEditValue(displayValue);
675
+ setIsEditing(true);
676
+ setIsMenuOpen(false);
677
+ };
678
+ var saveEdit = function () {
679
+ if (editValue !== displayValue) {
680
+ onEdit(fieldKey, rowIndex, editValue);
681
+ }
682
+ setIsEditing(false);
683
+ };
684
+ var cancelEdit = function () {
685
+ shouldSaveRef.current = false;
686
+ setIsEditing(false);
687
+ };
688
+ var handleBlur = function () {
689
+ if (shouldSaveRef.current)
690
+ saveEdit();
691
+ shouldSaveRef.current = true;
692
+ };
693
+ var handleKeyDown = function (e) {
694
+ if (e.key === 'Enter') {
695
+ e.preventDefault();
696
+ shouldSaveRef.current = false;
697
+ saveEdit();
698
+ }
699
+ else if (e.key === 'Escape') {
700
+ e.preventDefault();
701
+ cancelEdit();
702
+ }
703
+ else if (e.key === 'Tab') {
704
+ shouldSaveRef.current = false;
705
+ saveEdit();
706
+ }
707
+ };
708
+ var handleMenuToggle = function (e) {
709
+ e.stopPropagation();
710
+ if (!isMenuOpen && menuButtonRef.current) {
711
+ var rect = menuButtonRef.current.getBoundingClientRect();
712
+ setMenuPosition({ top: rect.bottom + 4, left: rect.right });
713
+ }
714
+ setIsMenuOpen(!isMenuOpen);
715
+ };
716
+ if (isEditing) {
717
+ return (index.jsx("input", { ref: inputRef, type: 'text', value: editValue, onChange: function (e) { return setEditValue(e.target.value); }, onBlur: handleBlur, onKeyDown: handleKeyDown, css: cellInputStyle, onClick: function (e) { return e.stopPropagation(); } }));
718
+ }
719
+ if (isEmpty) {
720
+ return (index.jsx("span", index.__assign({ css: clickToEditStyle, onClick: startEditing }, { children: "Click to edit" })));
721
+ }
722
+ return (index.jsxs("div", index.__assign({ css: editableCellContentStyle }, { children: [index.jsx("span", index.__assign({ css: { flex: 1, minWidth: 0 } }, { 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 &&
723
+ 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) {
724
+ e.stopPropagation();
725
+ startEditing();
726
+ } }, { children: "Edit Value" })), index.jsx("button", index.__assign({ type: 'button', role: 'menuitem', css: actionMenuItemStyle, onClick: function (e) {
727
+ e.stopPropagation();
728
+ setIsMenuOpen(false);
729
+ setShowClearConfirm(true);
730
+ } }, { children: "Clear Field" }))] })), index.featheryDoc().body), showClearConfirm && (index.jsx(DeleteConfirm, { anchorEl: menuButtonRef.current, message: 'Clear this field?', confirmLabel: 'Clear', onConfirm: function () {
731
+ closeClearConfirm();
732
+ onClear(fieldKey, rowIndex);
733
+ }, onCancel: closeClearConfirm }))] })));
734
+ }
735
+
467
736
  // Utility functions for sorting strings as numbers and dates
468
737
  function tryParseNumber(value) {
469
738
  if (value === null || value === undefined || value === '')
@@ -654,14 +923,16 @@ function setCachedPage(elementId, page) {
654
923
  sessionStorage.setItem(key, page.toString());
655
924
  }
656
925
  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;
926
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
927
+ var element = _a.element, _r = _a.editMode, editMode = _r === void 0 ? false : _r, _s = _a.dataVersion, dataVersion = _s === void 0 ? 0 : _s;
659
928
  var userColumns = ((_b = element.properties) === null || _b === void 0 ? void 0 : _b.columns) || [];
660
929
  var actions = (((_c = element.properties) === null || _c === void 0 ? void 0 : _c.actions) || []).filter(function (action) { return action.label && action.label.trim() !== ''; });
661
930
  var enableSearch = (_e = (_d = element.properties) === null || _d === void 0 ? void 0 : _d.search) !== null && _e !== void 0 ? _e : false;
662
931
  var enableSort = (_g = (_f = element.properties) === null || _f === void 0 ? void 0 : _f.sort) !== null && _g !== void 0 ? _g : false;
663
932
  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;
933
+ var enableEditing = (_l = (_k = element.properties) === null || _k === void 0 ? void 0 : _k.enable_editing) !== null && _l !== void 0 ? _l : false;
934
+ var enableAddDeleteRows = (_o = (_m = element.properties) === null || _m === void 0 ? void 0 : _m.add_delete_rows) !== null && _o !== void 0 ? _o : false;
935
+ var paginationSetting = (_q = (_p = element.properties) === null || _p === void 0 ? void 0 : _p.pagination) !== null && _q !== void 0 ? _q : 0;
665
936
  var rowsPerPage = typeof paginationSetting === 'number' && paginationSetting > 0
666
937
  ? Math.floor(paginationSetting)
667
938
  : 0;
@@ -674,19 +945,20 @@ function useTableData(_a) {
674
945
  }
675
946
  return cols;
676
947
  }, [editMode, userColumns]);
677
- // Use example data in edit mode
948
+ // fieldValues is mutated outside React state, so we need dataVersion
949
+ // as a manual dirty flag to trigger re-snapshots
678
950
  var baseFieldValues = React.useMemo(function () {
679
951
  if (editMode) {
680
952
  return generateExampleData(baseColumns);
681
953
  }
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 () {
954
+ return index.__assign({}, index.fieldValues);
955
+ }, [editMode, baseColumns, dataVersion]);
956
+ var _t = index.__read(React.useState(''), 2), searchQuery = _t[0], setSearchQuery = _t[1];
957
+ var _u = index.__read(React.useState(null), 2), sortColumn = _u[0], setSortColumn = _u[1];
958
+ var _v = index.__read(React.useState('asc'), 2), sortDirection = _v[0], setSortDirection = _v[1];
959
+ var _w = index.__read(React.useState(function () {
688
960
  return getCachedPage(element.id);
689
- }), 2), currentPage = _r[0], setCurrentPage = _r[1];
961
+ }), 2), currentPage = _w[0], setCurrentPage = _w[1];
690
962
  var baseNumRows = React.useMemo(function () {
691
963
  return baseColumns.reduce(function (maxRows, column) {
692
964
  var fieldValue = baseFieldValues[column.field_key];
@@ -722,7 +994,7 @@ function useTableData(_a) {
722
994
  enableSearch,
723
995
  baseFieldValues
724
996
  ]);
725
- var _s = index.__read(React.useState(null), 2), sortedColumnIndex = _s[0], setSortedColumnIndex = _s[1];
997
+ var _x = index.__read(React.useState(null), 2), sortedColumnIndex = _x[0], setSortedColumnIndex = _x[1];
726
998
  var sortedBaseRowIndices = React.useMemo(function () {
727
999
  if (!enableTranspose || !enableSort || sortedColumnIndex === null) {
728
1000
  return filteredBaseRowIndices;
@@ -762,7 +1034,7 @@ function useTableData(_a) {
762
1034
  rowsPerPage,
763
1035
  enablePagination
764
1036
  ]);
765
- var _t = React.useMemo(function () {
1037
+ var _y = React.useMemo(function () {
766
1038
  if (!enableTranspose || baseNumRows === 0) {
767
1039
  return {
768
1040
  columns: baseColumns,
@@ -782,7 +1054,7 @@ function useTableData(_a) {
782
1054
  baseFieldValues,
783
1055
  baseNumRows,
784
1056
  paginatedBaseRowIndices
785
- ]), columns = _t.columns, activeFieldValues = _t.activeFieldValues, transposedRowIndices = _t.transposedRowIndices;
1057
+ ]), columns = _y.columns, activeFieldValues = _y.activeFieldValues, transposedRowIndices = _y.transposedRowIndices;
786
1058
  var numRows = React.useMemo(function () {
787
1059
  return columns.reduce(function (maxRows, column) {
788
1060
  var fieldValue = activeFieldValues[column.field_key];
@@ -963,6 +1235,8 @@ function useTableData(_a) {
963
1235
  actions: actions,
964
1236
  isTransposed: isTransposed,
965
1237
  transposedRowIndices: transposedRowIndices,
1238
+ enableEditing: enableEditing,
1239
+ enableAddDeleteRows: enableAddDeleteRows,
966
1240
  totalRows: totalRows,
967
1241
  totalPages: totalPages,
968
1242
  hasData: hasData,
@@ -972,24 +1246,209 @@ function useTableData(_a) {
972
1246
  };
973
1247
  }
974
1248
 
1249
+ function useTableMutations(_a) {
1250
+ 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;
1251
+ var editModeFieldValuesRef = React.useRef(editModeFieldValues);
1252
+ editModeFieldValuesRef.current = editModeFieldValues;
1253
+ var getFieldArray = React.useCallback(function (fieldKey) {
1254
+ var source = editMode ? editModeFieldValuesRef.current : index.fieldValues;
1255
+ var val = source[fieldKey];
1256
+ return Array.isArray(val) ? val : [];
1257
+ }, [editMode]);
1258
+ var handleAddRow = React.useCallback(function () {
1259
+ var updates = {};
1260
+ columns.forEach(function (col) {
1261
+ var existing = getFieldArray(col.field_key);
1262
+ updates[col.field_key] = index.__spreadArray([''], index.__read(existing), false);
1263
+ });
1264
+ // Clear search so the new row is visible
1265
+ if (searchQuery)
1266
+ setSearchQuery('');
1267
+ // No submitCustom — new rows are provisional until the user edits a cell,
1268
+ // avoiding empty-row noise in the backend
1269
+ updateFieldValues(updates);
1270
+ onMutate();
1271
+ // Navigate to first page where the new row appears
1272
+ if (enablePagination)
1273
+ setCurrentPage(0);
1274
+ }, [
1275
+ columns,
1276
+ getFieldArray,
1277
+ updateFieldValues,
1278
+ onMutate,
1279
+ enablePagination,
1280
+ setCurrentPage,
1281
+ setSearchQuery,
1282
+ searchQuery
1283
+ ]);
1284
+ var buildRowRemovalUpdates = React.useCallback(function (rowIndex) {
1285
+ var updates = {};
1286
+ columns.forEach(function (col) {
1287
+ var existing = getFieldArray(col.field_key);
1288
+ updates[col.field_key] = existing.filter(function (_, i) { return i !== rowIndex; });
1289
+ });
1290
+ return updates;
1291
+ }, [columns, getFieldArray]);
1292
+ var handleDeleteRow = React.useCallback(function (rowIndex) {
1293
+ var updates = buildRowRemovalUpdates(rowIndex);
1294
+ updateFieldValues(updates);
1295
+ if (!editMode)
1296
+ submitCustom(updates);
1297
+ onMutate();
1298
+ }, [
1299
+ buildRowRemovalUpdates,
1300
+ updateFieldValues,
1301
+ submitCustom,
1302
+ editMode,
1303
+ onMutate
1304
+ ]);
1305
+ var handleRemoveRowLocal = React.useCallback(function (rowIndex) {
1306
+ var updates = buildRowRemovalUpdates(rowIndex);
1307
+ updateFieldValues(updates);
1308
+ onMutate();
1309
+ }, [buildRowRemovalUpdates, updateFieldValues, onMutate]);
1310
+ var handleCellEdit = React.useCallback(function (fieldKey, rowIndex, newValue) {
1311
+ var _a;
1312
+ var existing = getFieldArray(fieldKey);
1313
+ var updated = index.__spreadArray([], index.__read(existing), false);
1314
+ updated[rowIndex] = newValue;
1315
+ var values = (_a = {}, _a[fieldKey] = updated, _a);
1316
+ updateFieldValues(values);
1317
+ if (!editMode)
1318
+ submitCustom(values);
1319
+ onMutate();
1320
+ }, [getFieldArray, updateFieldValues, submitCustom, editMode, onMutate]);
1321
+ var handleCellClear = React.useCallback(function (fieldKey, rowIndex) {
1322
+ handleCellEdit(fieldKey, rowIndex, '');
1323
+ }, [handleCellEdit]);
1324
+ return {
1325
+ handleAddRow: handleAddRow,
1326
+ handleDeleteRow: handleDeleteRow,
1327
+ handleRemoveRowLocal: handleRemoveRowLocal,
1328
+ handleCellEdit: handleCellEdit,
1329
+ handleCellClear: handleCellClear
1330
+ };
1331
+ }
1332
+
1333
+ /**
1334
+ * Measures column widths from the browser's auto layout, then locks them
1335
+ * for use with table-layout: fixed. Re-measures when columnCount changes.
1336
+ */
1337
+ function useColumnWidths(tableRef, columnCount) {
1338
+ var _a = index.__read(React.useState(null), 2), widths = _a[0], setWidths = _a[1];
1339
+ var prevColumnCount = React.useRef(columnCount);
1340
+ if (prevColumnCount.current !== columnCount) {
1341
+ prevColumnCount.current = columnCount;
1342
+ setWidths(null);
1343
+ }
1344
+ React.useLayoutEffect(function () {
1345
+ var _a;
1346
+ if (widths !== null)
1347
+ return;
1348
+ var win = index.featheryWindow();
1349
+ if (!win || typeof win.getComputedStyle !== 'function')
1350
+ return;
1351
+ var table = tableRef.current;
1352
+ if (!table)
1353
+ return;
1354
+ var headerRow = (_a = table.querySelector('thead tr')) !== null && _a !== void 0 ? _a : table.querySelector('tbody tr');
1355
+ if (!headerRow)
1356
+ return;
1357
+ var measured = [];
1358
+ for (var i = 0; i < headerRow.children.length; i++) {
1359
+ measured.push(headerRow.children[i].getBoundingClientRect().width);
1360
+ }
1361
+ if (measured.length > 0)
1362
+ setWidths(measured);
1363
+ }, [widths, columnCount]);
1364
+ return widths;
1365
+ }
1366
+
975
1367
  function applyTableStyles(responsiveStyles) {
976
1368
  responsiveStyles.addTargets('table', 'thead', 'tbody', 'th', 'td', 'tr');
977
1369
  return responsiveStyles;
978
1370
  }
979
1371
  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;
1372
+ 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
1373
  var styles = React.useMemo(function () { return applyTableStyles(responsiveStyles); }, [responsiveStyles]);
982
- var _e = useTableData({ element: element, editMode: editMode }),
1374
+ var _g = index.__read(React.useState(0), 2), dataVersion = _g[0], setDataVersion = _g[1];
1375
+ var onMutate = React.useCallback(function () { return setDataVersion(function (v) { return v + 1; }); }, []);
1376
+ var _h = useTableData({ element: element, editMode: editMode, dataVersion: dataVersion }),
983
1377
  // search
984
- enableSearch = _e.enableSearch, searchQuery = _e.searchQuery, setSearchQuery = _e.setSearchQuery,
1378
+ enableSearch = _h.enableSearch, searchQuery = _h.searchQuery, setSearchQuery = _h.setSearchQuery,
985
1379
  // sort
986
- enableSort = _e.enableSort, sortColumn = _e.sortColumn, sortDirection = _e.sortDirection, sortedColumnIndex = _e.sortedColumnIndex, handleSort = _e.handleSort, handleTransposedSort = _e.handleTransposedSort,
1380
+ enableSort = _h.enableSort, sortColumn = _h.sortColumn, sortDirection = _h.sortDirection, sortedColumnIndex = _h.sortedColumnIndex, handleSort = _h.handleSort, handleTransposedSort = _h.handleTransposedSort,
987
1381
  // pagination
988
- enablePagination = _e.enablePagination, currentPage = _e.currentPage, setCurrentPage = _e.setCurrentPage, paginatedRowIndices = _e.paginatedRowIndices, rowsPerPage = _e.rowsPerPage,
1382
+ enablePagination = _h.enablePagination, currentPage = _h.currentPage, setCurrentPage = _h.setCurrentPage, paginatedRowIndices = _h.paginatedRowIndices, rowsPerPage = _h.rowsPerPage,
1383
+ // editing
1384
+ enableEditing = _h.enableEditing, enableAddDeleteRows = _h.enableAddDeleteRows,
989
1385
  // 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) {
1386
+ 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;
1387
+ var _j = useTableMutations({
1388
+ columns: baseColumns,
1389
+ updateFieldValues: updateFieldValues,
1390
+ submitCustom: submitCustom,
1391
+ editMode: editMode,
1392
+ editModeFieldValues: activeFieldValues,
1393
+ enablePagination: enablePagination,
1394
+ setCurrentPage: setCurrentPage,
1395
+ setSearchQuery: setSearchQuery,
1396
+ searchQuery: searchQuery,
1397
+ onMutate: onMutate
1398
+ }), handleAddRow = _j.handleAddRow, handleDeleteRow = _j.handleDeleteRow, handleCellEdit = _j.handleCellEdit, handleCellClear = _j.handleCellClear;
1399
+ var canEdit = enableEditing && !isTransposed;
1400
+ var showAddRow = canEdit && enableAddDeleteRows;
1401
+ var canDeleteRows = canEdit && enableAddDeleteRows;
1402
+ var hasOverflowMenu = actions.length > 1;
1403
+ var showStandaloneDeleteColumn = canDeleteRows && !hasOverflowMenu;
1404
+ var _k = index.__read(React.useState(new Set()), 2), pendingAddRows = _k[0], setPendingAddRows = _k[1];
1405
+ var pendingAddRowsRef = React.useRef(pendingAddRows);
1406
+ pendingAddRowsRef.current = pendingAddRows;
1407
+ var wrappedHandleCellEdit = React.useCallback(function (fieldKey, rowIndex, newValue) {
1408
+ if (pendingAddRowsRef.current.has(rowIndex)) {
1409
+ setPendingAddRows(function (prev) {
1410
+ var next = new Set(prev);
1411
+ next.delete(rowIndex);
1412
+ return next;
1413
+ });
1414
+ }
1415
+ handleCellEdit(fieldKey, rowIndex, newValue);
1416
+ }, [handleCellEdit]);
1417
+ var _l = index.__read(React.useState(null), 2), deleteRowIndex = _l[0], setDeleteRowIndex = _l[1];
1418
+ var prevPageRef = React.useRef(currentPage);
1419
+ if (prevPageRef.current !== currentPage) {
1420
+ prevPageRef.current = currentPage;
1421
+ setDeleteRowIndex(null);
1422
+ }
1423
+ var handleCancelDelete = React.useCallback(function () { return setDeleteRowIndex(null); }, []);
1424
+ var deleteIconRefs = React.useRef(new Map());
1425
+ var actionCellRefs = React.useRef(new Map());
1426
+ var showEmptyState = !hasData || !hasSearchResults;
1427
+ var showToolbar = enableSearch || showAddRow;
1428
+ var tableRef = React.useRef(null);
1429
+ var visibleColumnCount = columns.length +
1430
+ (!isTransposed && actions.length > 0 ? 1 : 0) +
1431
+ (showStandaloneDeleteColumn ? 1 : 0);
1432
+ var columnWidths = useColumnWidths(tableRef, visibleColumnCount);
1433
+ 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 () {
1434
+ setDeleteRowIndex(null);
1435
+ handleAddRow();
1436
+ setPendingAddRows(function (prev) {
1437
+ var next = new Set();
1438
+ next.add(0);
1439
+ prev.forEach(function (idx) { return next.add(idx + 1); });
1440
+ return next;
1441
+ });
1442
+ } }, { 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({ ref: tableRef, css: index.__assign(index.__assign(index.__assign({}, tableStyle), (columnWidths
1443
+ ? {
1444
+ tableLayout: 'fixed',
1445
+ minWidth: "".concat(columnWidths.reduce(function (a, b) { return a + b; }, 0), "px")
1446
+ }
1447
+ : {
1448
+ tableLayout: 'auto',
1449
+ width: 'max-content'
1450
+ })), styles.getTarget('table')) }, { children: [columnWidths && (index.jsx("colgroup", { children: columnWidths.map(function (w, i) { return (index.jsx("col", { style: { width: "".concat(w, "px") } }, i)); }) })), !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) {
1451
+ var _a, _b;
993
1452
  var rowData = {};
994
1453
  if (!isTransposed) {
995
1454
  columns.forEach(function (col) {
@@ -1001,7 +1460,7 @@ function TableElement(_a) {
1001
1460
  });
1002
1461
  }
1003
1462
  var handleRowClick = function () {
1004
- if (!isTransposed) {
1463
+ if (!isTransposed && !canEdit) {
1005
1464
  onClick({
1006
1465
  rowIndex: rowIndex,
1007
1466
  rowData: rowData
@@ -1019,7 +1478,6 @@ function TableElement(_a) {
1019
1478
  var isSorted = sortedColumnIndex === rowIndex;
1020
1479
  var isFirstColumn = colIndex === 0;
1021
1480
  var isSecondColumn = colIndex === 1;
1022
- // In transposed mode, get the original row index from the column
1023
1481
  var originalRowIndex = isTransposed && !isFirstColInTranspose
1024
1482
  ? column.originalRowIndex
1025
1483
  : undefined;
@@ -1040,7 +1498,6 @@ function TableElement(_a) {
1040
1498
  }
1041
1499
  else if (isTransposed &&
1042
1500
  originalRowIndex !== undefined) {
1043
- // In transposed mode, clicking a cell triggers with original row data
1044
1501
  e.stopPropagation();
1045
1502
  var originalRowData_1 = {};
1046
1503
  baseColumns.forEach(function (col) {
@@ -1056,9 +1513,32 @@ function TableElement(_a) {
1056
1513
  });
1057
1514
  }
1058
1515
  };
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 }))] })) })));
1516
+ 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));
1517
+ }), !isTransposed && actions.length > 0 && (index.jsxs("td", index.__assign({ ref: function (el) {
1518
+ if (el)
1519
+ actionCellRefs.current.set(rowIndex, el);
1520
+ else
1521
+ actionCellRefs.current.delete(rowIndex);
1522
+ }, 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 &&
1523
+ canDeleteRows &&
1524
+ deleteRowIndex === rowIndex && (index.jsx(DeleteConfirm, { anchorEl: (_a = actionCellRefs.current.get(rowIndex)) !== null && _a !== void 0 ? _a : null, onConfirm: function () {
1525
+ handleDeleteRow(rowIndex);
1526
+ setDeleteRowIndex(null);
1527
+ }, 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) {
1528
+ if (el)
1529
+ deleteIconRefs.current.set(rowIndex, el);
1530
+ else
1531
+ deleteIconRefs.current.delete(rowIndex);
1532
+ }, css: index.__assign(index.__assign({}, deleteIconStyle), (deleteRowIndex === rowIndex && {
1533
+ opacity: 1
1534
+ })), onClick: function (e) {
1535
+ e.stopPropagation();
1536
+ setDeleteRowIndex(deleteRowIndex === rowIndex ? null : rowIndex);
1537
+ } }, { children: index.jsx(TrashIcon, {}) })), deleteRowIndex === rowIndex && (index.jsx(DeleteConfirm, { anchorEl: (_b = deleteIconRefs.current.get(rowIndex)) !== null && _b !== void 0 ? _b : null, onConfirm: function () {
1538
+ handleDeleteRow(rowIndex);
1539
+ setDeleteRowIndex(null);
1540
+ }, onCancel: handleCancelDelete }))] })))] }), rowIndex));
1541
+ }), 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
1542
  }
1063
1543
 
1064
1544
  exports.default = TableElement;