@feathery/react 2.15.2 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/Form/index.d.ts.map +1 -1
- package/cjs/elements/basic/TableElement/Actions.d.ts +3 -1
- package/cjs/elements/basic/TableElement/Actions.d.ts.map +1 -1
- package/cjs/elements/basic/TableElement/Search.d.ts.map +1 -1
- package/cjs/elements/basic/TableElement/Sort.d.ts +5 -0
- package/cjs/elements/basic/TableElement/Sort.d.ts.map +1 -1
- package/cjs/elements/basic/TableElement/index.d.ts.map +1 -1
- package/cjs/elements/basic/TableElement/styles.d.ts +1 -1
- package/cjs/elements/basic/TableElement/styles.d.ts.map +1 -1
- package/cjs/elements/basic/TableElement/useTableData.d.ts +7 -0
- package/cjs/elements/basic/TableElement/useTableData.d.ts.map +1 -1
- package/cjs/elements/components/QuikFormViewer.d.ts.map +1 -1
- package/cjs/{fthry_FormControl.CZhSI7ZP.js → fthry_FormControl.C2gii7wA.js} +1 -1
- package/cjs/{fthry_InlineTooltip.BLxhhDuP.js → fthry_InlineTooltip.CoC50zm9.js} +2 -2
- package/cjs/{fthry_Overlay.DX647lyL.js → fthry_Overlay.BIzRxPrM.js} +1 -1
- package/cjs/{fthry_PaymentMethodField.DwYI96Gn.js → fthry_PaymentMethodField.-hXPI_jX.js} +4 -4
- package/cjs/{fthry_Placeholder.eggaVDQj.js → fthry_Placeholder.Doq4SVW-.js} +1 -1
- package/cjs/{fthry_ShowEyeIcon.CUX7pJin.js → fthry_ShowEyeIcon.CalIm-u2.js} +1 -1
- package/cjs/{fthry_index.BN8zLfup.js → fthry_index.AqW7CDJ0.js} +4 -4
- package/cjs/{fthry_index.ujHj1dvo.js → fthry_index.B3JBsWHh.js} +331 -59
- package/cjs/{fthry_index.BjCAubFj.js → fthry_index.B6AqZxM7.js} +1 -1
- package/cjs/{fthry_index.BANnK-BV.js → fthry_index.BSapQjhy.js} +2 -2
- package/cjs/{fthry_index.bTWf3wVZ.js → fthry_index.BZ735KfT.js} +4 -4
- package/cjs/{fthry_index.DEqnH31I.js → fthry_index.Bft5fStu.js} +5 -5
- package/cjs/{fthry_index.DbcTkrx8.js → fthry_index.BhJ4szQr.js} +1 -1
- package/cjs/{fthry_index.EU1uftki.js → fthry_index.BnaDsqOU.js} +5 -5
- package/cjs/{fthry_index.BA7SCFjL.js → fthry_index.C0TCn2Ux.js} +1 -1
- package/cjs/{fthry_index.DanO29mY.js → fthry_index.C5823Ca4.js} +8 -8
- package/cjs/{fthry_index.DpwSZaXh.js → fthry_index.CBpFOv-6.js} +1 -1
- package/cjs/{fthry_index.DB4KHK9K.js → fthry_index.CWxw_jF1.js} +5 -5
- package/cjs/{fthry_index.BzhucXqv.js → fthry_index.CcYpNoXG.js} +2 -2
- package/cjs/{fthry_index.Cp5mHHk3.js → fthry_index.CqQ4nuhU.js} +5 -5
- package/cjs/{fthry_index.HFaIUSxu.js → fthry_index.D6fCY_7u.js} +1 -1
- package/cjs/{fthry_index.CoJCmnOp.js → fthry_index.DG7GarXh.js} +1 -1
- package/cjs/{fthry_index.B6zj96av.js → fthry_index.DM3kZqYZ.js} +639 -460
- package/cjs/{fthry_index.CZOSIfEV.js → fthry_index.DNfN7djS.js} +6 -6
- package/cjs/{fthry_index.DXh3tbd1.js → fthry_index.DhMRLgQI.js} +3 -3
- package/cjs/{fthry_index.BSCmisU5.js → fthry_index.Dy6kr12s.js} +6 -6
- package/cjs/{fthry_index.BDTST35w.js → fthry_index.IUi-6tcI.js} +1 -1
- package/cjs/{fthry_index.BfGtKml0.js → fthry_index.J5TQ2Ewn.js} +3 -3
- package/cjs/{fthry_index.CRDnACxw.js → fthry_index.WeceNCsH.js} +4 -4
- package/cjs/{fthry_index.B1CkkjWn.js → fthry_index.q64QgiwW.js} +6 -6
- package/cjs/{fthry_input.DDLPWCri.js → fthry_input.CohyS1zB.js} +1 -1
- package/cjs/{fthry_script.Cw49lCOF.js → fthry_script.DmEvTYNb.js} +1 -1
- package/cjs/{fthry_styles.DyY_xRrD.js → fthry_styles.3xCaaoLM.js} +1 -1
- package/cjs/{fthry_useElementSize.B6qHp4zN.js → fthry_useElementSize.CQjlfXpK.js} +1 -1
- package/cjs/{fthry_useSalesforceSync.DP3b2FKu.js → fthry_useSalesforceSync.32rS8YTl.js} +1 -1
- package/cjs/{fthry_webfontloader.CoyxhM39.js → fthry_webfontloader.CwNx0NKj.js} +1 -1
- package/cjs/index.d.ts +3 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +1 -1
- package/cjs/utils/error.d.ts +0 -5
- package/cjs/utils/error.d.ts.map +1 -1
- package/cjs/utils/featheryClient/index.d.ts +12 -20
- package/cjs/utils/featheryClient/index.d.ts.map +1 -1
- package/cjs/utils/featheryClient/integrationClient.d.ts +2 -8
- package/cjs/utils/featheryClient/integrationClient.d.ts.map +1 -1
- package/cjs/utils/featheryClient/utils.d.ts.map +1 -1
- package/cjs/utils/formContext.d.ts +3 -1
- package/cjs/utils/formContext.d.ts.map +1 -1
- package/cjs/utils/formHelperFunctions.d.ts.map +1 -1
- package/cjs/utils/internalState.d.ts +7 -32
- package/cjs/utils/internalState.d.ts.map +1 -1
- package/dist/Form/index.d.ts.map +1 -1
- package/dist/elements/basic/TableElement/Actions.d.ts +3 -1
- package/dist/elements/basic/TableElement/Actions.d.ts.map +1 -1
- package/dist/elements/basic/TableElement/Search.d.ts.map +1 -1
- package/dist/elements/basic/TableElement/Sort.d.ts +5 -0
- package/dist/elements/basic/TableElement/Sort.d.ts.map +1 -1
- package/dist/elements/basic/TableElement/index.d.ts.map +1 -1
- package/dist/elements/basic/TableElement/styles.d.ts +1 -1
- package/dist/elements/basic/TableElement/styles.d.ts.map +1 -1
- package/dist/elements/basic/TableElement/useTableData.d.ts +7 -0
- package/dist/elements/basic/TableElement/useTableData.d.ts.map +1 -1
- package/dist/elements/components/QuikFormViewer.d.ts.map +1 -1
- package/dist/{fthry_FormControl.pynS9Imy.js → fthry_FormControl.Dz4H3Nqt.js} +1 -1
- package/dist/{fthry_InlineTooltip.fbWGkrAv.js → fthry_InlineTooltip.BCLdRbuh.js} +2 -2
- package/dist/{fthry_Overlay.ByTdlq1g.js → fthry_Overlay.DTGRd-yx.js} +1 -1
- package/dist/{fthry_PaymentMethodField.CPOf1iA4.js → fthry_PaymentMethodField.BlQtJSh8.js} +4 -4
- package/dist/{fthry_Placeholder.DVLjngYh.js → fthry_Placeholder.BLhSzy3T.js} +1 -1
- package/dist/{fthry_ShowEyeIcon.Bp9QY90b.js → fthry_ShowEyeIcon.7tsfIkEi.js} +1 -1
- package/dist/{fthry_index.BTzaBsCg.js → fthry_index.B0ZoOvOp.js} +1 -1
- package/dist/{fthry_index.XqetSJci.js → fthry_index.BEVTHNge.js} +1 -1
- package/dist/{fthry_index.8lndGH_r.js → fthry_index.BKF8QYaJ.js} +6 -6
- package/dist/{fthry_index.DMrogAPL.js → fthry_index.BKx_ib3Z.js} +1 -1
- package/dist/{fthry_index.Ba9tRElL.js → fthry_index.BQTOSXrY.js} +1 -1
- package/dist/{fthry_index.BdCDxxfG.js → fthry_index.BUXSFiQm.js} +1 -1
- package/dist/{fthry_index.o4PxfOJO.js → fthry_index.BmVWgprP.js} +6 -6
- package/dist/{fthry_index.CFVO0drz.js → fthry_index.BnnhEYkW.js} +2 -2
- package/dist/{fthry_index.CxPrJCG7.js → fthry_index.C3M7dY30.js} +4 -4
- package/dist/{fthry_index.B0vwUF95.js → fthry_index.CCAfWfpV.js} +5 -5
- package/dist/{fthry_index.Tay5ya9r.js → fthry_index.CHiV56qK.js} +4 -4
- package/dist/{fthry_index.Hf19u6bh.js → fthry_index.DJuAPOgA.js} +3 -3
- package/dist/{fthry_index.CcXjEG71.js → fthry_index.DZ6LXvPd.js} +5 -5
- package/dist/{fthry_index.CI18NEpR.js → fthry_index.DaGwANAz.js} +6 -6
- package/dist/{fthry_index.C1kFKyCH.js → fthry_index.DdaMjlkR.js} +5 -5
- package/dist/{fthry_index.An6X1bIc.js → fthry_index.Dezy7kk3.js} +5 -5
- package/dist/{fthry_index.f_bJZ-Qj.js → fthry_index.DnL5sLL9.js} +2 -2
- package/dist/{fthry_index.BU4UE1sU.js → fthry_index.DwnYxPF-.js} +4 -4
- package/dist/{fthry_index.252mvAiR.js → fthry_index._0r_Q3rJ.js} +3 -3
- package/dist/{fthry_index.BPH2EnpZ.js → fthry_index.aP-M59PI.js} +639 -460
- package/dist/{fthry_index.C_g49tb4.js → fthry_index.cc7_DdfY.js} +8 -8
- package/dist/{fthry_index.DsaDQSjY.js → fthry_index.iZl84fEq.js} +1 -1
- package/dist/{fthry_index.BxQkJS7f.js → fthry_index.kMeXDR5E.js} +1 -1
- package/dist/{fthry_index.uyi04ekt.js → fthry_index.zrgRFrsp.js} +331 -59
- package/dist/{fthry_input.BozedSiT.js → fthry_input.BhPllXmF.js} +1 -1
- package/dist/{fthry_script.O8zBOlCA.js → fthry_script.BJjH5LOb.js} +1 -1
- package/dist/{fthry_styles.BT0jpQ03.js → fthry_styles.CtC5HgtM.js} +1 -1
- package/dist/{fthry_useElementSize.C9rdkcOU.js → fthry_useElementSize.CfVj4Mjx.js} +1 -1
- package/dist/{fthry_useSalesforceSync.1klZ-qUM.js → fthry_useSalesforceSync.D7CR1xsm.js} +1 -1
- package/dist/{fthry_webfontloader.CoDBzqSo.js → fthry_webfontloader.CnmGkKn7.js} +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/error.d.ts +0 -5
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/featheryClient/index.d.ts +12 -20
- package/dist/utils/featheryClient/index.d.ts.map +1 -1
- package/dist/utils/featheryClient/integrationClient.d.ts +2 -8
- package/dist/utils/featheryClient/integrationClient.d.ts.map +1 -1
- package/dist/utils/featheryClient/utils.d.ts.map +1 -1
- package/dist/utils/formContext.d.ts +3 -1
- package/dist/utils/formContext.d.ts.map +1 -1
- package/dist/utils/formHelperFunctions.d.ts.map +1 -1
- package/dist/utils/internalState.d.ts +7 -32
- package/dist/utils/internalState.d.ts.map +1 -1
- package/package.json +2 -1
- package/umd/{509.341a4196aad912adb28d.js → 509.a863f8749c28540476bb.js} +2 -2
- package/umd/TableElement.8941c979f39547669b6a.js +1 -0
- package/umd/index.js +1 -1
- package/umd/TableElement.ef63774f461682dd3ac9.js +0 -1
- /package/umd/{509.341a4196aad912adb28d.js.LICENSE.txt → 509.a863f8749c28540476bb.js.LICENSE.txt} +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { a as jsxs, _ as __assign, j as jsx, D as DROPDOWN_Z_INDEX, b as __read, u as useBorder, as as getFieldValue, s as stringifyWithNull, h as hoverStylesGuard, i as iosScrollOnFocus, q as FORM_Z_INDEX, r as resetStyles, at as emailPatternStr } from './fthry_index.
|
|
1
|
+
import { a as jsxs, _ as __assign, j as jsx, D as DROPDOWN_Z_INDEX, b as __read, u as useBorder, as as getFieldValue, s as stringifyWithNull, h as hoverStylesGuard, i as iosScrollOnFocus, q as FORM_Z_INDEX, r as resetStyles, at as emailPatternStr } from './fthry_index.aP-M59PI.js';
|
|
2
2
|
import { memo, useRef, useState } from 'react';
|
|
3
|
-
import { P as Placeholder } from './fthry_Placeholder.
|
|
4
|
-
import { I as InlineTooltip } from './fthry_InlineTooltip.
|
|
5
|
-
import { O as Overlay } from './fthry_Overlay.
|
|
6
|
-
import { u as useElementSize } from './fthry_useElementSize.
|
|
7
|
-
import { S as ShowEyeIcon, a as ShowEyeIcon$1 } from './fthry_ShowEyeIcon.
|
|
8
|
-
import { a as IMaskInput } from './fthry_input.
|
|
3
|
+
import { P as Placeholder } from './fthry_Placeholder.BLhSzy3T.js';
|
|
4
|
+
import { I as InlineTooltip } from './fthry_InlineTooltip.BCLdRbuh.js';
|
|
5
|
+
import { O as Overlay } from './fthry_Overlay.DTGRd-yx.js';
|
|
6
|
+
import { u as useElementSize } from './fthry_useElementSize.CfVj4Mjx.js';
|
|
7
|
+
import { S as ShowEyeIcon, a as ShowEyeIcon$1 } from './fthry_ShowEyeIcon.7tsfIkEi.js';
|
|
8
|
+
import { a as IMaskInput } from './fthry_input.BhPllXmF.js';
|
|
9
9
|
import 'react/jsx-runtime';
|
|
10
10
|
import 'react-dom/client';
|
|
11
11
|
import 'jszip';
|
|
12
12
|
import 'react-dom';
|
|
13
|
-
import './fthry_index.
|
|
13
|
+
import './fthry_index.BEVTHNge.js';
|
|
14
14
|
|
|
15
15
|
function TextAutocomplete(_a) {
|
|
16
16
|
var _b = _a.allOptions, allOptions = _b === void 0 ? [] : _b, showOptions = _a.showOptions, _c = _a.onSelect, onSelect = _c === void 0 ? function () { } : _c, _d = _a.onHide, onHide = _d === void 0 ? function () { } : _d, _e = _a.onInputFocus, onInputFocus = _e === void 0 ? function () { } : _e, _f = _a.value, value = _f === void 0 ? '' : _f, containerRef = _a.containerRef, responsiveStyles = _a.responsiveStyles, listItemRef = _a.listItemRef, children = _a.children;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as jsx, _ as __assign, a as jsxs, b as __read, k as __awaiter, l as __generator, t as featheryWindow, F as Fragment, E as ErrorInput } from './fthry_index.
|
|
1
|
+
import { j as jsx, _ as __assign, a as jsxs, b as __read, k as __awaiter, l as __generator, t as featheryWindow, F as Fragment, E as ErrorInput } from './fthry_index.aP-M59PI.js';
|
|
2
2
|
import { useRef, useState, useEffect, memo, useMemo } from 'react';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react-dom/client';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __assign, h as hoverStylesGuard, a as jsxs, j as jsx, i as iosScrollOnFocus } from './fthry_index.
|
|
1
|
+
import { _ as __assign, h as hoverStylesGuard, a as jsxs, j as jsx, i as iosScrollOnFocus } from './fthry_index.aP-M59PI.js';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react-dom/client';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __assign, j as jsx, a as jsxs, F as Fragment, b as __read, f as featheryDoc, c as fieldValues, s as stringifyWithNull, d as __values, e as __spreadArray } from './fthry_index.
|
|
1
|
+
import { _ as __assign, j as jsx, a as jsxs, F as Fragment, b as __read, f as featheryDoc, c as fieldValues, s as stringifyWithNull, d as __values, e as __spreadArray } from './fthry_index.aP-M59PI.js';
|
|
2
2
|
import { useState, useRef, useEffect, useMemo } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
@@ -105,7 +105,8 @@ var searchInputStyle = {
|
|
|
105
105
|
color: colors.gray900,
|
|
106
106
|
fontSize: '14px',
|
|
107
107
|
borderRadius: '8px',
|
|
108
|
-
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)'
|
|
108
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
109
|
+
boxSizing: 'border-box'
|
|
109
110
|
};
|
|
110
111
|
var tableStyle = {
|
|
111
112
|
width: '100%',
|
|
@@ -115,8 +116,7 @@ var tableStyle = {
|
|
|
115
116
|
color: colors.gray600,
|
|
116
117
|
textIndent: 0,
|
|
117
118
|
borderColor: 'inherit',
|
|
118
|
-
borderCollapse: 'collapse'
|
|
119
|
-
tableLayout: 'fixed'
|
|
119
|
+
borderCollapse: 'collapse'
|
|
120
120
|
};
|
|
121
121
|
var theadStyle = {
|
|
122
122
|
fontSize: '14px',
|
|
@@ -253,7 +253,12 @@ function SearchIcon() {
|
|
|
253
253
|
}
|
|
254
254
|
function Search(_a) {
|
|
255
255
|
var searchQuery = _a.searchQuery, onSearchChange = _a.onSearchChange;
|
|
256
|
-
|
|
256
|
+
var handleKeyDown = function (e) {
|
|
257
|
+
if (e.key === 'Enter') {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
return (jsx("div", __assign({ css: searchContainerStyle }, { children: jsxs("div", __assign({ css: searchWrapperStyle }, { children: [jsx("div", __assign({ css: searchIconWrapperStyle }, { children: jsx(SearchIcon, {}) })), jsx("input", { type: 'text', css: searchInputStyle, placeholder: 'Search', value: searchQuery, onChange: function (e) { return onSearchChange(e.target.value); }, onKeyDown: handleKeyDown })] })) })));
|
|
257
262
|
}
|
|
258
263
|
|
|
259
264
|
function SortIcon(_a) {
|
|
@@ -265,7 +270,8 @@ function SortHeader(_a) {
|
|
|
265
270
|
return (jsx(Fragment, { children: columns.map(function (column, index) {
|
|
266
271
|
var isSortable = enableSort;
|
|
267
272
|
var isSorted = sortColumn === column.name;
|
|
268
|
-
|
|
273
|
+
var isFirstColumn = index === 0;
|
|
274
|
+
return (jsx("th", __assign({ scope: 'col', onClick: function () { return isSortable && onSort(column.name); }, css: __assign(__assign(__assign(__assign({}, thStyle), (isFirstColumn ? {} : { paddingLeft: 0 })), styles.getTarget('th')), (isSortable ? { cursor: 'pointer' } : {})) }, { children: jsxs("div", __assign({ css: sortHeaderContentStyle }, { children: [jsx("span", { children: column.name }), isSortable && (jsx("span", __assign({ css: sortIconContainerStyle }, { children: jsx(SortIcon, { isSorted: isSorted, sortDirection: sortDirection }) })))] })) }), index));
|
|
269
275
|
}) }));
|
|
270
276
|
}
|
|
271
277
|
|
|
@@ -313,16 +319,15 @@ function MenuIcon() {
|
|
|
313
319
|
return (jsxs("svg", __assign({ css: menuIconStyle, fill: 'currentColor', viewBox: '0 0 24 24' }, { children: [jsx("circle", { cx: '12', cy: '5', r: '2' }), jsx("circle", { cx: '12', cy: '12', r: '2' }), jsx("circle", { cx: '12', cy: '19', r: '2' })] })));
|
|
314
320
|
}
|
|
315
321
|
function ActionButtons(_a) {
|
|
316
|
-
var actions = _a.actions, rowIndex = _a.rowIndex, columnData = _a.columnData, onClick = _a.onClick;
|
|
322
|
+
var actions = _a.actions, rowIndex = _a.rowIndex, columnData = _a.columnData, fieldValuesProp = _a.fieldValues, onClick = _a.onClick, _b = _a.forceInlineButtons, forceInlineButtons = _b === void 0 ? false : _b;
|
|
317
323
|
if (actions.length === 0)
|
|
318
324
|
return null;
|
|
319
|
-
var
|
|
320
|
-
var
|
|
325
|
+
var _c = __read(useState(false), 2), isMenuOpen = _c[0], setIsMenuOpen = _c[1];
|
|
326
|
+
var _d = __read(useState({ top: 0, left: 0 }), 2), menuPosition = _d[0], setMenuPosition = _d[1];
|
|
321
327
|
var containerRef = useRef(null);
|
|
322
328
|
var menuRef = useRef(null);
|
|
323
329
|
var menuButtonRef = useRef(null);
|
|
324
|
-
|
|
325
|
-
var useOverflow = actions.length > 1;
|
|
330
|
+
var useOverflow = !forceInlineButtons && actions.length > 1;
|
|
326
331
|
useEffect(function () {
|
|
327
332
|
var handleClickOutside = function (event) {
|
|
328
333
|
if (menuRef.current &&
|
|
@@ -341,9 +346,10 @@ function ActionButtons(_a) {
|
|
|
341
346
|
}, [isMenuOpen]);
|
|
342
347
|
var handleActionClick = function (action) {
|
|
343
348
|
setIsMenuOpen(false);
|
|
349
|
+
var activeFieldValues = fieldValuesProp || fieldValues;
|
|
344
350
|
var rowData = {};
|
|
345
351
|
columnData.forEach(function (col) {
|
|
346
|
-
var fValue =
|
|
352
|
+
var fValue = activeFieldValues[col.field_key];
|
|
347
353
|
var cValue = Array.isArray(fValue) ? fValue[rowIndex] : fValue;
|
|
348
354
|
rowData[col.name] = cValue;
|
|
349
355
|
});
|
|
@@ -481,21 +487,95 @@ function generateExampleData(columns, numRows) {
|
|
|
481
487
|
return exampleData;
|
|
482
488
|
}
|
|
483
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Transpose table data: columns become rows, rows become columns
|
|
492
|
+
* Returns new columns and transposed field values
|
|
493
|
+
*/
|
|
494
|
+
function transposeTableData(columns, activeFieldValues, numRows, rowIndicesToInclude) {
|
|
495
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
496
|
+
var includedRowIndices = rowIndicesToInclude || Array.from({ length: numRows }, function (_, i) { return i; });
|
|
497
|
+
var transposedColumns = [
|
|
498
|
+
{
|
|
499
|
+
name: '',
|
|
500
|
+
field_id: '_transpose_field_name',
|
|
501
|
+
field_type: 'text',
|
|
502
|
+
field_key: '_transpose_field_name'
|
|
503
|
+
}
|
|
504
|
+
];
|
|
505
|
+
try {
|
|
506
|
+
// Add a column for each original row
|
|
507
|
+
for (var includedRowIndices_1 = __values(includedRowIndices), includedRowIndices_1_1 = includedRowIndices_1.next(); !includedRowIndices_1_1.done; includedRowIndices_1_1 = includedRowIndices_1.next()) {
|
|
508
|
+
var rowIdx = includedRowIndices_1_1.value;
|
|
509
|
+
transposedColumns.push({
|
|
510
|
+
name: '',
|
|
511
|
+
field_id: "_transpose_row_".concat(rowIdx),
|
|
512
|
+
field_type: 'text',
|
|
513
|
+
field_key: "_transpose_row_".concat(rowIdx),
|
|
514
|
+
originalRowIndex: rowIdx
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
519
|
+
finally {
|
|
520
|
+
try {
|
|
521
|
+
if (includedRowIndices_1_1 && !includedRowIndices_1_1.done && (_a = includedRowIndices_1.return)) _a.call(includedRowIndices_1);
|
|
522
|
+
}
|
|
523
|
+
finally { if (e_1) throw e_1.error; }
|
|
524
|
+
}
|
|
525
|
+
var transposedFieldValues = {
|
|
526
|
+
_transpose_field_name: columns.map(function (col) { return col.name; })
|
|
527
|
+
};
|
|
528
|
+
try {
|
|
529
|
+
for (var includedRowIndices_2 = __values(includedRowIndices), includedRowIndices_2_1 = includedRowIndices_2.next(); !includedRowIndices_2_1.done; includedRowIndices_2_1 = includedRowIndices_2.next()) {
|
|
530
|
+
var rowIdx = includedRowIndices_2_1.value;
|
|
531
|
+
var transposedRowValues = [];
|
|
532
|
+
try {
|
|
533
|
+
for (var columns_1 = (e_3 = void 0, __values(columns)), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
|
|
534
|
+
var column = columns_1_1.value;
|
|
535
|
+
var fieldValue = activeFieldValues[column.field_key];
|
|
536
|
+
var cellValue = Array.isArray(fieldValue)
|
|
537
|
+
? fieldValue[rowIdx]
|
|
538
|
+
: fieldValue;
|
|
539
|
+
transposedRowValues.push(cellValue);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
543
|
+
finally {
|
|
544
|
+
try {
|
|
545
|
+
if (columns_1_1 && !columns_1_1.done && (_c = columns_1.return)) _c.call(columns_1);
|
|
546
|
+
}
|
|
547
|
+
finally { if (e_3) throw e_3.error; }
|
|
548
|
+
}
|
|
549
|
+
transposedFieldValues["_transpose_row_".concat(rowIdx)] = transposedRowValues;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
553
|
+
finally {
|
|
554
|
+
try {
|
|
555
|
+
if (includedRowIndices_2_1 && !includedRowIndices_2_1.done && (_b = includedRowIndices_2.return)) _b.call(includedRowIndices_2);
|
|
556
|
+
}
|
|
557
|
+
finally { if (e_2) throw e_2.error; }
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
transposedColumns: transposedColumns,
|
|
561
|
+
transposedFieldValues: transposedFieldValues,
|
|
562
|
+
includedRowIndices: includedRowIndices
|
|
563
|
+
};
|
|
564
|
+
}
|
|
484
565
|
function useTableData(_a) {
|
|
485
|
-
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
486
|
-
var element = _a.element,
|
|
566
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
567
|
+
var element = _a.element, _m = _a.editMode, editMode = _m === void 0 ? false : _m;
|
|
487
568
|
var userColumns = ((_b = element.properties) === null || _b === void 0 ? void 0 : _b.columns) || [];
|
|
488
569
|
var actions = (((_c = element.properties) === null || _c === void 0 ? void 0 : _c.actions) || []).filter(function (action) { return action.label && action.label.trim() !== ''; });
|
|
489
570
|
var enableSearch = (_e = (_d = element.properties) === null || _d === void 0 ? void 0 : _d.search) !== null && _e !== void 0 ? _e : false;
|
|
490
571
|
var enableSort = (_g = (_f = element.properties) === null || _f === void 0 ? void 0 : _f.sort) !== null && _g !== void 0 ? _g : false;
|
|
491
|
-
var
|
|
572
|
+
var enableTranspose = (_j = (_h = element.properties) === null || _h === void 0 ? void 0 : _h.transpose) !== null && _j !== void 0 ? _j : false;
|
|
573
|
+
var paginationSetting = (_l = (_k = element.properties) === null || _k === void 0 ? void 0 : _k.pagination) !== null && _l !== void 0 ? _l : 0;
|
|
492
574
|
var rowsPerPage = typeof paginationSetting === 'number' && paginationSetting > 0
|
|
493
575
|
? Math.floor(paginationSetting)
|
|
494
576
|
: 0;
|
|
495
577
|
var enablePagination = rowsPerPage > 0;
|
|
496
|
-
|
|
497
|
-
// Also ensure all columns have field_key in edit mode
|
|
498
|
-
var columns = useMemo(function () {
|
|
578
|
+
var baseColumns = useMemo(function () {
|
|
499
579
|
var cols = userColumns;
|
|
500
580
|
// In edit mode, replace field_key with a unique example key
|
|
501
581
|
if (editMode) {
|
|
@@ -504,16 +584,112 @@ function useTableData(_a) {
|
|
|
504
584
|
return cols;
|
|
505
585
|
}, [editMode, userColumns]);
|
|
506
586
|
// Use example data in edit mode
|
|
507
|
-
var
|
|
587
|
+
var baseFieldValues = useMemo(function () {
|
|
508
588
|
if (editMode) {
|
|
509
|
-
return generateExampleData(
|
|
589
|
+
return generateExampleData(baseColumns);
|
|
510
590
|
}
|
|
511
591
|
return fieldValues;
|
|
512
|
-
}, [editMode,
|
|
513
|
-
var
|
|
514
|
-
var
|
|
515
|
-
var
|
|
516
|
-
var
|
|
592
|
+
}, [editMode, baseColumns, userColumns.length]);
|
|
593
|
+
var _o = __read(useState(''), 2), searchQuery = _o[0], setSearchQuery = _o[1];
|
|
594
|
+
var _p = __read(useState(null), 2), sortColumn = _p[0], setSortColumn = _p[1];
|
|
595
|
+
var _q = __read(useState('asc'), 2), sortDirection = _q[0], setSortDirection = _q[1];
|
|
596
|
+
var _r = __read(useState(0), 2), currentPage = _r[0], setCurrentPage = _r[1];
|
|
597
|
+
var baseNumRows = useMemo(function () {
|
|
598
|
+
return baseColumns.reduce(function (maxRows, column) {
|
|
599
|
+
var fieldValue = baseFieldValues[column.field_key];
|
|
600
|
+
if (Array.isArray(fieldValue)) {
|
|
601
|
+
return Math.max(maxRows, fieldValue.length);
|
|
602
|
+
}
|
|
603
|
+
return maxRows;
|
|
604
|
+
}, 0);
|
|
605
|
+
}, [baseColumns, baseFieldValues]);
|
|
606
|
+
var allBaseRowIndices = useMemo(function () { return Array.from({ length: baseNumRows }, function (_, i) { return i; }); }, [baseNumRows]);
|
|
607
|
+
var filteredBaseRowIndices = useMemo(function () {
|
|
608
|
+
if (!enableTranspose || !enableSearch || !searchQuery.trim()) {
|
|
609
|
+
return allBaseRowIndices;
|
|
610
|
+
}
|
|
611
|
+
return allBaseRowIndices.filter(function (baseRowIdx) {
|
|
612
|
+
return baseColumns.some(function (column) {
|
|
613
|
+
var _a;
|
|
614
|
+
var fieldValue = baseFieldValues[column.field_key];
|
|
615
|
+
var cellValue = Array.isArray(fieldValue)
|
|
616
|
+
? fieldValue[baseRowIdx]
|
|
617
|
+
: fieldValue;
|
|
618
|
+
var stringValue = (_a = stringifyWithNull(cellValue)) !== null && _a !== void 0 ? _a : '';
|
|
619
|
+
return stringValue
|
|
620
|
+
.toLowerCase()
|
|
621
|
+
.includes(searchQuery.toLowerCase().trim());
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
}, [
|
|
625
|
+
enableTranspose,
|
|
626
|
+
allBaseRowIndices,
|
|
627
|
+
baseColumns,
|
|
628
|
+
searchQuery,
|
|
629
|
+
enableSearch,
|
|
630
|
+
baseFieldValues
|
|
631
|
+
]);
|
|
632
|
+
var _s = __read(useState(null), 2), sortedColumnIndex = _s[0], setSortedColumnIndex = _s[1];
|
|
633
|
+
var sortedBaseRowIndices = useMemo(function () {
|
|
634
|
+
if (!enableTranspose || !enableSort || sortedColumnIndex === null) {
|
|
635
|
+
return filteredBaseRowIndices;
|
|
636
|
+
}
|
|
637
|
+
var column = baseColumns[sortedColumnIndex];
|
|
638
|
+
if (!column)
|
|
639
|
+
return filteredBaseRowIndices;
|
|
640
|
+
return __spreadArray([], __read(filteredBaseRowIndices), false).sort(function (aIdx, bIdx) {
|
|
641
|
+
var fieldValue = baseFieldValues[column.field_key];
|
|
642
|
+
var aValue = Array.isArray(fieldValue) ? fieldValue[aIdx] : fieldValue;
|
|
643
|
+
var bValue = Array.isArray(fieldValue) ? fieldValue[bIdx] : fieldValue;
|
|
644
|
+
var aParsed = parseSortableValue(aValue);
|
|
645
|
+
var bParsed = parseSortableValue(bValue);
|
|
646
|
+
var comparison = compareSortableValues(aParsed, bParsed);
|
|
647
|
+
return sortDirection === 'asc' ? comparison : -comparison;
|
|
648
|
+
});
|
|
649
|
+
}, [
|
|
650
|
+
enableTranspose,
|
|
651
|
+
filteredBaseRowIndices,
|
|
652
|
+
sortedColumnIndex,
|
|
653
|
+
sortDirection,
|
|
654
|
+
baseColumns,
|
|
655
|
+
baseFieldValues,
|
|
656
|
+
enableSort
|
|
657
|
+
]);
|
|
658
|
+
var paginatedBaseRowIndices = useMemo(function () {
|
|
659
|
+
if (!enableTranspose || !enablePagination) {
|
|
660
|
+
return sortedBaseRowIndices;
|
|
661
|
+
}
|
|
662
|
+
var startIdx = currentPage * rowsPerPage;
|
|
663
|
+
var endIdx = startIdx + rowsPerPage;
|
|
664
|
+
return sortedBaseRowIndices.slice(startIdx, endIdx);
|
|
665
|
+
}, [
|
|
666
|
+
enableTranspose,
|
|
667
|
+
sortedBaseRowIndices,
|
|
668
|
+
currentPage,
|
|
669
|
+
rowsPerPage,
|
|
670
|
+
enablePagination
|
|
671
|
+
]);
|
|
672
|
+
var _t = useMemo(function () {
|
|
673
|
+
if (!enableTranspose || baseNumRows === 0) {
|
|
674
|
+
return {
|
|
675
|
+
columns: baseColumns,
|
|
676
|
+
activeFieldValues: baseFieldValues,
|
|
677
|
+
transposedRowIndices: []
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
var _a = transposeTableData(baseColumns, baseFieldValues, baseNumRows, paginatedBaseRowIndices), transposedColumns = _a.transposedColumns, transposedFieldValues = _a.transposedFieldValues, includedRowIndices = _a.includedRowIndices;
|
|
681
|
+
return {
|
|
682
|
+
columns: transposedColumns,
|
|
683
|
+
activeFieldValues: transposedFieldValues,
|
|
684
|
+
transposedRowIndices: includedRowIndices
|
|
685
|
+
};
|
|
686
|
+
}, [
|
|
687
|
+
enableTranspose,
|
|
688
|
+
baseColumns,
|
|
689
|
+
baseFieldValues,
|
|
690
|
+
baseNumRows,
|
|
691
|
+
paginatedBaseRowIndices
|
|
692
|
+
]), columns = _t.columns, activeFieldValues = _t.activeFieldValues, transposedRowIndices = _t.transposedRowIndices;
|
|
517
693
|
var numRows = useMemo(function () {
|
|
518
694
|
return columns.reduce(function (maxRows, column) {
|
|
519
695
|
var fieldValue = activeFieldValues[column.field_key];
|
|
@@ -525,6 +701,8 @@ function useTableData(_a) {
|
|
|
525
701
|
}, [columns, activeFieldValues]);
|
|
526
702
|
var allRowIndices = useMemo(function () { return Array.from({ length: numRows }, function (_, i) { return i; }); }, [numRows]);
|
|
527
703
|
var filteredRowIndices = useMemo(function () {
|
|
704
|
+
if (enableTranspose)
|
|
705
|
+
return allRowIndices; // Already filtered during transpose
|
|
528
706
|
if (!enableSearch || !searchQuery.trim())
|
|
529
707
|
return allRowIndices;
|
|
530
708
|
return allRowIndices.filter(function (rowIndex) {
|
|
@@ -540,8 +718,17 @@ function useTableData(_a) {
|
|
|
540
718
|
.includes(searchQuery.toLowerCase().trim());
|
|
541
719
|
});
|
|
542
720
|
});
|
|
543
|
-
}, [
|
|
721
|
+
}, [
|
|
722
|
+
enableTranspose,
|
|
723
|
+
allRowIndices,
|
|
724
|
+
columns,
|
|
725
|
+
searchQuery,
|
|
726
|
+
enableSearch,
|
|
727
|
+
activeFieldValues
|
|
728
|
+
]);
|
|
544
729
|
var sortedRowIndices = useMemo(function () {
|
|
730
|
+
if (enableTranspose)
|
|
731
|
+
return filteredRowIndices; // Already sorted during transpose
|
|
545
732
|
if (!enableSort || !sortColumn)
|
|
546
733
|
return filteredRowIndices;
|
|
547
734
|
var column = columns.find(function (col) { return col.name === sortColumn; });
|
|
@@ -557,6 +744,7 @@ function useTableData(_a) {
|
|
|
557
744
|
return sortDirection === 'asc' ? comparison : -comparison;
|
|
558
745
|
});
|
|
559
746
|
}, [
|
|
747
|
+
enableTranspose,
|
|
560
748
|
filteredRowIndices,
|
|
561
749
|
sortColumn,
|
|
562
750
|
sortDirection,
|
|
@@ -565,19 +753,30 @@ function useTableData(_a) {
|
|
|
565
753
|
activeFieldValues
|
|
566
754
|
]);
|
|
567
755
|
var paginatedRowIndices = useMemo(function () {
|
|
756
|
+
if (enableTranspose)
|
|
757
|
+
return allRowIndices; // Already paginated during transpose
|
|
568
758
|
if (!enablePagination)
|
|
569
759
|
return sortedRowIndices;
|
|
570
760
|
var startIdx = currentPage * rowsPerPage;
|
|
571
761
|
var endIdx = startIdx + rowsPerPage;
|
|
572
762
|
return sortedRowIndices.slice(startIdx, endIdx);
|
|
573
|
-
}, [
|
|
763
|
+
}, [
|
|
764
|
+
enableTranspose,
|
|
765
|
+
allRowIndices,
|
|
766
|
+
sortedRowIndices,
|
|
767
|
+
currentPage,
|
|
768
|
+
rowsPerPage,
|
|
769
|
+
enablePagination
|
|
770
|
+
]);
|
|
574
771
|
// Reset to first page when search or sort changes
|
|
575
772
|
useEffect(function () {
|
|
576
773
|
setCurrentPage(0);
|
|
577
774
|
}, [searchQuery, sortColumn, sortDirection]);
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
775
|
+
// For transposed tables, totalRows and totalPages are based on original rows (now columns)
|
|
776
|
+
var totalRows = enableTranspose
|
|
777
|
+
? sortedBaseRowIndices.length
|
|
778
|
+
: sortedRowIndices.length;
|
|
779
|
+
var totalPages = enablePagination ? Math.ceil(totalRows / rowsPerPage) : 1;
|
|
581
780
|
var handleSort = function (columnName) {
|
|
582
781
|
if (!enableSort)
|
|
583
782
|
return;
|
|
@@ -596,8 +795,29 @@ function useTableData(_a) {
|
|
|
596
795
|
setSortDirection('asc');
|
|
597
796
|
}
|
|
598
797
|
};
|
|
798
|
+
var handleTransposedSort = function (rowIndex) {
|
|
799
|
+
if (!enableSort || !enableTranspose)
|
|
800
|
+
return;
|
|
801
|
+
if (sortedColumnIndex === rowIndex) {
|
|
802
|
+
// Cycle through: asc → desc → none
|
|
803
|
+
if (sortDirection === 'asc') {
|
|
804
|
+
setSortDirection('desc');
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
setSortedColumnIndex(null);
|
|
808
|
+
setSortDirection('asc');
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
else {
|
|
812
|
+
setSortedColumnIndex(rowIndex);
|
|
813
|
+
setSortDirection('asc');
|
|
814
|
+
}
|
|
815
|
+
};
|
|
599
816
|
var hasData = numRows > 0;
|
|
600
|
-
var hasSearchResults =
|
|
817
|
+
var hasSearchResults = enableTranspose
|
|
818
|
+
? filteredBaseRowIndices.length > 0
|
|
819
|
+
: filteredRowIndices.length > 0;
|
|
820
|
+
var isTransposed = enableTranspose && baseNumRows > 0;
|
|
601
821
|
return {
|
|
602
822
|
enableSearch: enableSearch,
|
|
603
823
|
searchQuery: searchQuery,
|
|
@@ -606,7 +826,9 @@ function useTableData(_a) {
|
|
|
606
826
|
enableSort: enableSort,
|
|
607
827
|
sortColumn: sortColumn,
|
|
608
828
|
sortDirection: sortDirection,
|
|
829
|
+
sortedColumnIndex: sortedColumnIndex,
|
|
609
830
|
handleSort: handleSort,
|
|
831
|
+
handleTransposedSort: handleTransposedSort,
|
|
610
832
|
enablePagination: enablePagination,
|
|
611
833
|
currentPage: currentPage,
|
|
612
834
|
paginatedRowIndices: paginatedRowIndices,
|
|
@@ -614,10 +836,14 @@ function useTableData(_a) {
|
|
|
614
836
|
setCurrentPage: setCurrentPage,
|
|
615
837
|
columns: columns,
|
|
616
838
|
actions: actions,
|
|
617
|
-
|
|
839
|
+
isTransposed: isTransposed,
|
|
840
|
+
transposedRowIndices: transposedRowIndices,
|
|
841
|
+
totalRows: totalRows,
|
|
618
842
|
totalPages: totalPages,
|
|
619
843
|
hasData: hasData,
|
|
620
|
-
activeFieldValues: activeFieldValues
|
|
844
|
+
activeFieldValues: activeFieldValues,
|
|
845
|
+
baseColumns: baseColumns,
|
|
846
|
+
baseFieldValues: baseFieldValues
|
|
621
847
|
};
|
|
622
848
|
}
|
|
623
849
|
|
|
@@ -632,36 +858,82 @@ function TableElement(_a) {
|
|
|
632
858
|
// search
|
|
633
859
|
enableSearch = _d.enableSearch, searchQuery = _d.searchQuery, setSearchQuery = _d.setSearchQuery,
|
|
634
860
|
// sort
|
|
635
|
-
enableSort = _d.enableSort, sortColumn = _d.sortColumn, sortDirection = _d.sortDirection, handleSort = _d.handleSort,
|
|
861
|
+
enableSort = _d.enableSort, sortColumn = _d.sortColumn, sortDirection = _d.sortDirection, sortedColumnIndex = _d.sortedColumnIndex, handleSort = _d.handleSort, handleTransposedSort = _d.handleTransposedSort,
|
|
636
862
|
// pagination
|
|
637
863
|
enablePagination = _d.enablePagination, currentPage = _d.currentPage, setCurrentPage = _d.setCurrentPage, paginatedRowIndices = _d.paginatedRowIndices, rowsPerPage = _d.rowsPerPage,
|
|
638
864
|
// data
|
|
639
|
-
columns = _d.columns, actions = _d.actions, totalRows = _d.totalRows, totalPages = _d.totalPages, hasData = _d.hasData, hasSearchResults = _d.hasSearchResults, activeFieldValues = _d.activeFieldValues;
|
|
865
|
+
columns = _d.columns, actions = _d.actions, isTransposed = _d.isTransposed, transposedRowIndices = _d.transposedRowIndices, totalRows = _d.totalRows, totalPages = _d.totalPages, hasData = _d.hasData, hasSearchResults = _d.hasSearchResults, activeFieldValues = _d.activeFieldValues, baseColumns = _d.baseColumns, baseFieldValues = _d.baseFieldValues;
|
|
640
866
|
var showEmptyState = !hasData || (hasData && !hasSearchResults);
|
|
641
|
-
return (jsx("div", __assign({ css: __assign(__assign({}, containerStyle), styles.getTarget('container')) }, { children: jsxs("div", __assign({ css: { minWidth: 'fit-content' } }, { children: [enableSearch && (jsx(Search, { searchQuery: searchQuery, onSearchChange: setSearchQuery })), showEmptyState ? (jsx(EmptyState, { hasSearchQuery: searchQuery.trim().length > 0 })) : (jsxs("table", __assign({ css: __assign(__assign({}, tableStyle), styles.getTarget('table')) }, { children: [jsx("thead", __assign({ css: theadStyle }, { children: jsxs("tr", { children: [jsx(SortHeader, { columns: columns, enableSort: enableSort, sortColumn: sortColumn, sortDirection: sortDirection, onSort: handleSort, styles: styles }), actions.length > 0 && (jsx("th", { scope: 'col', css: __assign(__assign({}, thStyle), styles.getTarget('th')) }))] }) })),
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
867
|
+
return (jsx("div", __assign({ css: __assign(__assign({}, containerStyle), styles.getTarget('container')) }, { children: jsxs("div", __assign({ css: { minWidth: 'fit-content' } }, { children: [enableSearch && (jsx(Search, { searchQuery: searchQuery, onSearchChange: setSearchQuery })), showEmptyState ? (jsx(EmptyState, { hasSearchQuery: searchQuery.trim().length > 0 })) : (jsxs("table", __assign({ css: __assign(__assign({}, tableStyle), styles.getTarget('table')) }, { children: [!isTransposed && (jsx("thead", __assign({ css: theadStyle }, { children: jsxs("tr", { children: [jsx(SortHeader, { columns: columns, enableSort: enableSort, sortColumn: sortColumn, sortDirection: sortDirection, onSort: handleSort, styles: styles }), actions.length > 0 && (jsx("th", { scope: 'col', css: __assign(__assign(__assign({}, thStyle), { paddingLeft: 0 }), styles.getTarget('th')) }))] }) }))), jsxs("tbody", __assign({ css: styles.getTarget('tbody') }, { children: [paginatedRowIndices.map(function (rowIndex) {
|
|
868
|
+
var rowData = {};
|
|
869
|
+
if (!isTransposed) {
|
|
870
|
+
columns.forEach(function (col) {
|
|
871
|
+
var fValue = activeFieldValues[col.field_key];
|
|
872
|
+
var cValue = Array.isArray(fValue)
|
|
873
|
+
? fValue[rowIndex]
|
|
874
|
+
: fValue;
|
|
875
|
+
rowData[col.name] = cValue;
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
var handleRowClick = function () {
|
|
879
|
+
if (!isTransposed) {
|
|
880
|
+
onClick({
|
|
881
|
+
rowIndex: rowIndex,
|
|
882
|
+
rowData: rowData
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
return (jsxs("tr", __assign({ css: __assign(__assign({}, rowStyle), styles.getTarget('tr')), onClick: handleRowClick }, { children: [columns.map(function (column, colIndex) {
|
|
887
|
+
var _a, _b;
|
|
888
|
+
var fieldValue = activeFieldValues[column.field_key];
|
|
889
|
+
var cellValue = Array.isArray(fieldValue)
|
|
890
|
+
? fieldValue[rowIndex]
|
|
891
|
+
: fieldValue;
|
|
892
|
+
var isFirstColInTranspose = isTransposed && colIndex === 0;
|
|
893
|
+
var isSortable = isFirstColInTranspose && enableSort;
|
|
894
|
+
var isSorted = sortedColumnIndex === rowIndex;
|
|
895
|
+
var isFirstColumn = colIndex === 0;
|
|
896
|
+
var isSecondColumn = colIndex === 1;
|
|
897
|
+
// In transposed mode, get the original row index from the column
|
|
898
|
+
var originalRowIndex = isTransposed && !isFirstColInTranspose
|
|
899
|
+
? column.originalRowIndex
|
|
900
|
+
: undefined;
|
|
901
|
+
var cellCss = isFirstColInTranspose
|
|
902
|
+
? __assign(__assign(__assign(__assign({}, thStyle), { backgroundColor: '#f9fafb', borderRight: '1px solid #e5e7eb', width: '1px', whiteSpace: 'nowrap' }), styles.getTarget('th')), (isSortable ? { cursor: 'pointer' } : {})) : __assign(__assign(__assign(__assign({}, cellStyle), (isTransposed
|
|
903
|
+
? isSecondColumn
|
|
904
|
+
? {}
|
|
905
|
+
: { paddingLeft: 0 }
|
|
906
|
+
: isFirstColumn
|
|
907
|
+
? {}
|
|
908
|
+
: { paddingLeft: 0 })), (isTransposed && !isFirstColInTranspose
|
|
909
|
+
? { cursor: 'pointer' }
|
|
910
|
+
: {})), styles.getTarget('td'));
|
|
911
|
+
var CellElement = isFirstColInTranspose ? 'th' : 'td';
|
|
912
|
+
var handleCellClick = function (e) {
|
|
913
|
+
if (isSortable) {
|
|
914
|
+
handleTransposedSort(rowIndex);
|
|
915
|
+
}
|
|
916
|
+
else if (isTransposed &&
|
|
917
|
+
originalRowIndex !== undefined) {
|
|
918
|
+
// In transposed mode, clicking a cell triggers with original row data
|
|
919
|
+
e.stopPropagation();
|
|
920
|
+
var originalRowData_1 = {};
|
|
921
|
+
baseColumns.forEach(function (col) {
|
|
922
|
+
var fValue = baseFieldValues[col.field_key];
|
|
923
|
+
var cValue = Array.isArray(fValue)
|
|
924
|
+
? fValue[originalRowIndex]
|
|
925
|
+
: fValue;
|
|
926
|
+
originalRowData_1[col.name] = cValue;
|
|
927
|
+
});
|
|
928
|
+
onClick({
|
|
929
|
+
rowIndex: originalRowIndex,
|
|
930
|
+
rowData: originalRowData_1
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
return (jsx(CellElement, __assign({ css: cellCss, onClick: handleCellClick }, (isFirstColInTranspose ? { scope: 'row' } : {}), { children: isFirstColInTranspose && isSortable ? (jsxs("div", __assign({ css: __assign(__assign({}, sortHeaderContentStyle), { justifyContent: 'space-between' }) }, { children: [jsx("span", { children: (_a = stringifyWithNull(cellValue)) !== null && _a !== void 0 ? _a : '' }), jsx("span", __assign({ css: sortIconContainerStyle }, { children: jsx(SortIcon, { isSorted: isSorted, sortDirection: sortDirection }) }))] }))) : ((_b = stringifyWithNull(cellValue)) !== null && _b !== void 0 ? _b : '') }), colIndex));
|
|
935
|
+
}), !isTransposed && actions.length > 0 && (jsx("td", __assign({ css: __assign(__assign(__assign({}, cellStyle), { paddingLeft: 0 }), styles.getTarget('td')) }, { children: jsx(ActionButtons, { actions: actions, rowIndex: rowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick }) })))] }), rowIndex));
|
|
936
|
+
}), isTransposed && actions.length > 0 && (jsxs("tr", __assign({ css: __assign(__assign({}, rowStyle), styles.getTarget('tr')) }, { children: [jsx("th", { scope: 'row', css: __assign(__assign(__assign({}, thStyle), { backgroundColor: '#f9fafb', borderRight: '1px solid #e5e7eb', width: '1px', whiteSpace: 'nowrap' }), styles.getTarget('th')) }), transposedRowIndices.map(function (originalRowIndex, idx) { return (jsx("td", __assign({ css: __assign(__assign(__assign({}, cellStyle), (idx === 0 ? {} : { paddingLeft: 0 })), styles.getTarget('td')) }, { children: jsx("div", __assign({ css: { display: 'flex', justifyContent: 'flex-start' } }, { children: jsx(ActionButtons, { actions: actions, rowIndex: originalRowIndex, columnData: baseColumns, fieldValues: baseFieldValues, onClick: onClick, forceInlineButtons: true }) })) }), originalRowIndex)); })] })))] }))] }))), !showEmptyState && enablePagination && (jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, totalItems: totalRows, rowsPerPage: rowsPerPage, onPageChange: setCurrentPage }))] })) })));
|
|
665
937
|
}
|
|
666
938
|
|
|
667
939
|
export { TableElement as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState, useMemo } from 'react';
|
|
3
|
-
import { ar as cls, a as jsxs, F as Fragment, j as jsx, G as Global, v as css, w as __makeTemplateObject } from './fthry_index.
|
|
3
|
+
import { ar as cls, a as jsxs, F as Fragment, j as jsx, G as Global, v as css, w as __makeTemplateObject } from './fthry_index.aP-M59PI.js';
|
|
4
4
|
import { flushSync } from 'react-dom';
|
|
5
5
|
|
|
6
6
|
function canUseDom() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as __read, k as __awaiter, l as __generator, m as FeatheryClient } from './fthry_index.
|
|
1
|
+
import { b as __read, k as __awaiter, l as __generator, m as FeatheryClient } from './fthry_index.aP-M59PI.js';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
function useSalesforceSync(salesforceSync, editMode) {
|