@teselagen/ui 0.10.5 → 0.10.6

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/index.es.js CHANGED
@@ -53,9 +53,9 @@ var __async = (__this, __arguments, generator) => {
53
53
  step((generator = generator.apply(__this, __arguments)).next());
54
54
  });
55
55
  };
56
- import * as React from "react";
56
+ import * as React$1 from "react";
57
57
  import React__default, { useState, useEffect, forwardRef as forwardRef$2, useImperativeHandle, Fragment, useMemo, useRef, useReducer, useCallback, createElement, Component, useLayoutEffect, createContext as createContext$1, memo, useContext, isValidElement, PureComponent } from "react";
58
- import { Classes, Icon, Button, Intent, MenuItem, Keys, Tag, Popover, Tooltip, Spinner, Checkbox, Switch, Position, FormGroup, InputGroup, TextArea, EditableText, NumericInput, RadioGroup, Menu, Toaster, MenuDivider, ContextMenu, KeyCombo, useHotkeys, Callout, Dialog, Card, Tabs, Tab, Colors, HTMLSelect, Overlay, ProgressBar } from "@blueprintjs/core";
58
+ import { Classes, Icon, Button, Intent, MenuItem, Keys, Tag, Popover, Tooltip, Spinner, Checkbox, Switch, Position, FormGroup, InputGroup, TextArea, EditableText, NumericInput, RadioGroup, Menu, Toaster, MenuDivider, KeyCombo, ContextMenu, useHotkeys, Callout, Dialog, Card, Tabs, Tab, Colors, HTMLSelect, Overlay, ProgressBar } from "@blueprintjs/core";
59
59
  import { formValueSelector, initialize, change, Field, reduxForm, SubmissionError, destroy, touch, FormName, Fields } from "redux-form";
60
60
  import require$$2$1, { unstable_batchedUpdates, createPortal, flushSync } from "react-dom";
61
61
  import { connect, useDispatch, useSelector, useStore } from "react-redux";
@@ -12523,6 +12523,64 @@ const rectSortingStrategy = /* @__PURE__ */ __name((_ref) => {
12523
12523
  scaleY: newRect.height / oldRect.height
12524
12524
  };
12525
12525
  }, "rectSortingStrategy");
12526
+ const defaultScale$1 = {
12527
+ scaleX: 1,
12528
+ scaleY: 1
12529
+ };
12530
+ const verticalListSortingStrategy = /* @__PURE__ */ __name((_ref) => {
12531
+ var _rects$activeIndex;
12532
+ let {
12533
+ activeIndex,
12534
+ activeNodeRect: fallbackActiveRect,
12535
+ index: index2,
12536
+ rects,
12537
+ overIndex
12538
+ } = _ref;
12539
+ const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect;
12540
+ if (!activeNodeRect) {
12541
+ return null;
12542
+ }
12543
+ if (index2 === activeIndex) {
12544
+ const overIndexRect = rects[overIndex];
12545
+ if (!overIndexRect) {
12546
+ return null;
12547
+ }
12548
+ return __spreadValues({
12549
+ x: 0,
12550
+ y: activeIndex < overIndex ? overIndexRect.top + overIndexRect.height - (activeNodeRect.top + activeNodeRect.height) : overIndexRect.top - activeNodeRect.top
12551
+ }, defaultScale$1);
12552
+ }
12553
+ const itemGap = getItemGap$1(rects, index2, activeIndex);
12554
+ if (index2 > activeIndex && index2 <= overIndex) {
12555
+ return __spreadValues({
12556
+ x: 0,
12557
+ y: -activeNodeRect.height - itemGap
12558
+ }, defaultScale$1);
12559
+ }
12560
+ if (index2 < activeIndex && index2 >= overIndex) {
12561
+ return __spreadValues({
12562
+ x: 0,
12563
+ y: activeNodeRect.height + itemGap
12564
+ }, defaultScale$1);
12565
+ }
12566
+ return __spreadValues({
12567
+ x: 0,
12568
+ y: 0
12569
+ }, defaultScale$1);
12570
+ }, "verticalListSortingStrategy");
12571
+ function getItemGap$1(clientRects, index2, activeIndex) {
12572
+ const currentRect = clientRects[index2];
12573
+ const previousRect = clientRects[index2 - 1];
12574
+ const nextRect = clientRects[index2 + 1];
12575
+ if (!currentRect) {
12576
+ return 0;
12577
+ }
12578
+ if (activeIndex < index2) {
12579
+ return previousRect ? currentRect.top - (previousRect.top + previousRect.height) : nextRect ? nextRect.top - (currentRect.top + currentRect.height) : 0;
12580
+ }
12581
+ return nextRect ? nextRect.top - (currentRect.top + currentRect.height) : previousRect ? currentRect.top - (previousRect.top + previousRect.height) : 0;
12582
+ }
12583
+ __name(getItemGap$1, "getItemGap$1");
12526
12584
  const ID_PREFIX = "Sortable";
12527
12585
  const Context = /* @__PURE__ */ React__default.createContext({
12528
12586
  activeIndex: -1,
@@ -16493,6 +16551,7 @@ const ThComponent2 = /* @__PURE__ */ __name((_c) => {
16493
16551
  className,
16494
16552
  children,
16495
16553
  style,
16554
+ path: path2,
16496
16555
  columnindex
16497
16556
  } = _d, rest = __objRest(_d, [
16498
16557
  "toggleSort",
@@ -16500,16 +16559,30 @@ const ThComponent2 = /* @__PURE__ */ __name((_c) => {
16500
16559
  "className",
16501
16560
  "children",
16502
16561
  "style",
16562
+ "path",
16503
16563
  "columnindex"
16504
16564
  ]);
16505
- const index2 = columnindex != null ? columnindex : -1;
16506
- const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
16507
- id: `${index2}`,
16508
- disabled: immovable === "true"
16565
+ const index2 = columnindex ? path2 : -1;
16566
+ const disabled = !path2 || immovable === "true" || immovable === true;
16567
+ const {
16568
+ attributes,
16569
+ listeners,
16570
+ setNodeRef,
16571
+ transform,
16572
+ transition,
16573
+ isDragging: _isDragging
16574
+ } = useSortable({
16575
+ id: path2,
16576
+ disabled
16509
16577
  });
16578
+ const isDragging2 = _isDragging && !disabled;
16579
+ if (transform) {
16580
+ transform.scaleX = 1;
16581
+ }
16510
16582
  const sortStyles = {
16511
16583
  transform: CSS.Transform.toString(transform),
16512
- transition
16584
+ transition,
16585
+ zIndex: isDragging2 ? 999 : void 0
16513
16586
  };
16514
16587
  return /* @__PURE__ */ React__default.createElement(
16515
16588
  "div",
@@ -16517,11 +16590,12 @@ const ThComponent2 = /* @__PURE__ */ __name((_c) => {
16517
16590
  style: __spreadValues(__spreadValues({}, sortStyles), style),
16518
16591
  ref: setNodeRef
16519
16592
  }, attributes), listeners), {
16520
- className: classNames("rt-th", className),
16593
+ className: classNames("rt-th", className, { "th-dragging": isDragging2 }),
16521
16594
  onClick: /* @__PURE__ */ __name((e) => toggleSort && toggleSort(e), "onClick"),
16522
16595
  role: "columnheader",
16523
16596
  tabIndex: "-1",
16524
16597
  columnindex,
16598
+ path: path2,
16525
16599
  index: index2
16526
16600
  }), rest),
16527
16601
  children
@@ -19443,36 +19517,49 @@ function tableQueryParamsToHasuraClauses({
19443
19517
  const uniqueFieldsByPath = {};
19444
19518
  const searchTerms = searchTerm.split(",");
19445
19519
  schema.fields.forEach((field) => {
19446
- const { type: type2, path: path2, searchDisabled, isHidden } = field;
19447
- if (uniqueFieldsByPath[path2]) return;
19448
- uniqueFieldsByPath[path2] = true;
19449
- if (searchDisabled || field.filterDisabled || type2 === "color" || isHidden)
19450
- return;
19451
- searchTerms.forEach((term) => {
19452
- const filterValue = term.trim();
19453
- if (type2 === "string" || type2 === "lookup") {
19454
- const o2 = set$1({}, path2, { _ilike: `%${filterValue}%` });
19455
- searchTermFilters.push(o2);
19456
- } else if (type2 === "boolean") {
19457
- let regex;
19458
- try {
19459
- regex = new RegExp("^" + filterValue, "ig");
19460
- } catch (error) {
19461
- }
19462
- if (regex) {
19463
- if ("true".replace(regex, "") !== "true") {
19464
- const o2 = set$1({}, path2, { _eq: true });
19465
- searchTermFilters.push(o2);
19466
- } else if ("false".replace(regex, "") !== "false") {
19467
- const o2 = set$1({}, path2, { _eq: false });
19468
- searchTermFilters.push(o2);
19520
+ const {
19521
+ type: type2,
19522
+ path: path2,
19523
+ additionalSearchPaths = [],
19524
+ searchDisabled,
19525
+ isHidden
19526
+ } = field;
19527
+ const allPaths = [path2, ...additionalSearchPaths];
19528
+ allPaths.forEach((path22) => {
19529
+ addSearchTermFilters(path22);
19530
+ });
19531
+ function addSearchTermFilters(path22) {
19532
+ if (uniqueFieldsByPath[path22]) return;
19533
+ uniqueFieldsByPath[path22] = true;
19534
+ if (searchDisabled || field.filterDisabled || type2 === "color" || isHidden || !path22)
19535
+ return;
19536
+ searchTerms.forEach((term) => {
19537
+ const filterValue = term.trim();
19538
+ if (type2 === "string" || type2 === "lookup") {
19539
+ const o2 = set$1({}, path22, { _ilike: `%${filterValue}%` });
19540
+ searchTermFilters.push(o2);
19541
+ } else if (type2 === "boolean") {
19542
+ let regex;
19543
+ try {
19544
+ regex = new RegExp("^" + filterValue, "ig");
19545
+ } catch (error) {
19469
19546
  }
19547
+ if (regex) {
19548
+ if ("true".replace(regex, "") !== "true") {
19549
+ const o2 = set$1({}, path22, { _eq: true });
19550
+ searchTermFilters.push(o2);
19551
+ } else if ("false".replace(regex, "") !== "false") {
19552
+ const o2 = set$1({}, path22, { _eq: false });
19553
+ searchTermFilters.push(o2);
19554
+ }
19555
+ }
19556
+ } else if ((type2 === "number" || type2 === "integer") && !isNaN(filterValue)) {
19557
+ const o2 = set$1({}, path22, { _eq: parseFloat(filterValue) });
19558
+ searchTermFilters.push(o2);
19470
19559
  }
19471
- } else if ((type2 === "number" || type2 === "integer") && !isNaN(filterValue)) {
19472
- const o2 = set$1({}, path2, { _eq: parseFloat(filterValue) });
19473
- searchTermFilters.push(o2);
19474
- }
19475
- });
19560
+ });
19561
+ }
19562
+ __name(addSearchTermFilters, "addSearchTermFilters");
19476
19563
  });
19477
19564
  if (searchTermFilters.length > 0) {
19478
19565
  if (Object.keys(where).length > 0) {
@@ -19483,10 +19570,16 @@ function tableQueryParamsToHasuraClauses({
19483
19570
  }
19484
19571
  }
19485
19572
  if (filters && filters.length > 0) {
19486
- const filterClauses = filters.map((filter2) => {
19573
+ const filterClauses = flatMap(filters, (filter2) => {
19487
19574
  let { selectedFilter, filterOn, filterValue } = filter2;
19488
19575
  const fieldSchema = ccFields[filterOn] || {};
19489
- const { path: path2, reference: reference2, type: type2, customColumnFilter } = fieldSchema;
19576
+ const {
19577
+ path: path2,
19578
+ additionalSearchPaths = [],
19579
+ reference: reference2,
19580
+ type: type2,
19581
+ customColumnFilter
19582
+ } = fieldSchema;
19490
19583
  if (customColumnFilter) {
19491
19584
  return customColumnFilter(filterValue);
19492
19585
  }
@@ -19509,117 +19602,128 @@ function tableQueryParamsToHasuraClauses({
19509
19602
  }
19510
19603
  if (reference2) {
19511
19604
  filterOn = reference2.sourceField;
19605
+ return addColumnFilters(filterOn);
19512
19606
  } else {
19513
- filterOn = path2 || filterOn;
19514
- }
19515
- switch (selectedFilter) {
19516
- case "none":
19517
- return {};
19518
- case "startsWith":
19519
- return { [filterOn]: { _ilike: `${filterValue}%` } };
19520
- case "endsWith":
19521
- return { [filterOn]: { _ilike: `%${filterValue}` } };
19522
- case "contains":
19523
- return { [filterOn]: { _ilike: `%${filterValue}%` } };
19524
- case "notContains":
19525
- return { [filterOn]: { _nilike: `%${filterValue}%` } };
19526
- case "isExactly":
19527
- return { [filterOn]: { _eq: filterValue } };
19528
- case "isEmpty":
19529
- if (filterOn.includes(".")) {
19607
+ if (path2) {
19608
+ const allPaths = [path2, ...additionalSearchPaths];
19609
+ return allPaths.map((p2) => addColumnFilters(p2));
19610
+ } else {
19611
+ return addColumnFilters(filterOn);
19612
+ }
19613
+ }
19614
+ function addColumnFilters(filterOn2) {
19615
+ switch (selectedFilter) {
19616
+ case "none":
19617
+ return {};
19618
+ case "startsWith":
19619
+ return { [filterOn2]: { _ilike: `${filterValue}%` } };
19620
+ case "endsWith":
19621
+ return { [filterOn2]: { _ilike: `%${filterValue}` } };
19622
+ case "contains":
19623
+ return { [filterOn2]: { _ilike: `%${filterValue}%` } };
19624
+ case "notContains":
19625
+ return { [filterOn2]: { _nilike: `%${filterValue}%` } };
19626
+ case "isExactly":
19627
+ return { [filterOn2]: { _eq: filterValue } };
19628
+ case "isEmpty":
19629
+ if (filterOn2.includes(".")) {
19630
+ return {
19631
+ _not: {
19632
+ [filterOn2.split(".")[0]]: {}
19633
+ }
19634
+ };
19635
+ }
19530
19636
  return {
19531
- _not: {
19532
- [filterOn.split(".")[0]]: {}
19533
- }
19637
+ _or: [
19638
+ { [filterOn2]: { _eq: "" } },
19639
+ { [filterOn2]: { _is_null: true } }
19640
+ ]
19534
19641
  };
19535
- }
19536
- return {
19537
- _or: [
19538
- { [filterOn]: { _eq: "" } },
19539
- { [filterOn]: { _is_null: true } }
19540
- ]
19541
- };
19542
- case "notEmpty":
19543
- return {
19544
- _and: [
19545
- { [filterOn]: { _neq: "" } },
19546
- { [filterOn]: { _is_null: false } }
19547
- ]
19548
- };
19549
- case "inList":
19550
- return { [filterOn]: { _in: filterValue } };
19551
- case "notInList":
19552
- return { [filterOn]: { _nin: filterValue } };
19553
- case "true":
19554
- return { [filterOn]: { _eq: true } };
19555
- case "false":
19556
- return { [filterOn]: { _eq: false } };
19557
- case "dateIs":
19558
- return { [filterOn]: { _eq: filterValue } };
19559
- case "notBetween":
19560
- return {
19561
- _or: [
19562
- {
19563
- [filterOn]: {
19564
- _lt: new Date(arrayFilterValue[0])
19565
- }
19566
- },
19567
- {
19568
- [filterOn]: {
19569
- _gt: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
19642
+ case "notEmpty":
19643
+ return {
19644
+ _and: [
19645
+ { [filterOn2]: { _neq: "" } },
19646
+ { [filterOn2]: { _is_null: false } }
19647
+ ]
19648
+ };
19649
+ case "inList":
19650
+ return { [filterOn2]: { _in: filterValue } };
19651
+ case "notInList":
19652
+ return { [filterOn2]: { _nin: filterValue } };
19653
+ case "true":
19654
+ return { [filterOn2]: { _eq: true } };
19655
+ case "false":
19656
+ return { [filterOn2]: { _eq: false } };
19657
+ case "dateIs":
19658
+ return { [filterOn2]: { _eq: filterValue } };
19659
+ case "notBetween":
19660
+ return {
19661
+ _or: [
19662
+ {
19663
+ [filterOn2]: {
19664
+ _lt: new Date(arrayFilterValue[0])
19665
+ }
19666
+ },
19667
+ {
19668
+ [filterOn2]: {
19669
+ _gt: new Date(
19670
+ new Date(arrayFilterValue[1]).setHours(23, 59)
19671
+ )
19672
+ }
19570
19673
  }
19674
+ ]
19675
+ };
19676
+ case "isBetween":
19677
+ return {
19678
+ [filterOn2]: {
19679
+ _gte: new Date(arrayFilterValue[0]),
19680
+ _lte: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
19571
19681
  }
19572
- ]
19573
- };
19574
- case "isBetween":
19575
- return {
19576
- [filterOn]: {
19577
- _gte: new Date(arrayFilterValue[0]),
19578
- _lte: new Date(new Date(arrayFilterValue[1]).setHours(23, 59))
19579
- }
19580
- };
19581
- case "isBefore":
19582
- return { [filterOn]: { _lt: new Date(filterValue) } };
19583
- case "isAfter":
19584
- return { [filterOn]: { _gt: new Date(filterValue) } };
19585
- case "greaterThan":
19586
- return { [filterOn]: { _gt: parseFloat(filterValue) } };
19587
- case "lessThan":
19588
- return { [filterOn]: { _lt: parseFloat(filterValue) } };
19589
- case "inRange":
19590
- return {
19591
- [filterOn]: {
19592
- _gte: parseFloat(arrayFilterValue[0]),
19593
- _lte: parseFloat(arrayFilterValue[1])
19594
- }
19595
- };
19596
- case "outsideRange":
19597
- return {
19598
- _or: [
19599
- {
19600
- [filterOn]: {
19601
- _lt: parseFloat(arrayFilterValue[0])
19602
- }
19603
- },
19604
- {
19605
- [filterOn]: {
19606
- _gt: parseFloat(arrayFilterValue[1])
19682
+ };
19683
+ case "isBefore":
19684
+ return { [filterOn2]: { _lt: new Date(filterValue) } };
19685
+ case "isAfter":
19686
+ return { [filterOn2]: { _gt: new Date(filterValue) } };
19687
+ case "greaterThan":
19688
+ return { [filterOn2]: { _gt: parseFloat(filterValue) } };
19689
+ case "lessThan":
19690
+ return { [filterOn2]: { _lt: parseFloat(filterValue) } };
19691
+ case "inRange":
19692
+ return {
19693
+ [filterOn2]: {
19694
+ _gte: parseFloat(arrayFilterValue[0]),
19695
+ _lte: parseFloat(arrayFilterValue[1])
19696
+ }
19697
+ };
19698
+ case "outsideRange":
19699
+ return {
19700
+ _or: [
19701
+ {
19702
+ [filterOn2]: {
19703
+ _lt: parseFloat(arrayFilterValue[0])
19704
+ }
19705
+ },
19706
+ {
19707
+ [filterOn2]: {
19708
+ _gt: parseFloat(arrayFilterValue[1])
19709
+ }
19607
19710
  }
19711
+ ]
19712
+ };
19713
+ case "equalTo":
19714
+ return {
19715
+ [filterOn2]: {
19716
+ _eq: type2 === "number" || type2 === "integer" ? parseFloat(filterValue) : filterValue
19608
19717
  }
19609
- ]
19610
- };
19611
- case "equalTo":
19612
- return {
19613
- [filterOn]: {
19614
- _eq: type2 === "number" || type2 === "integer" ? parseFloat(filterValue) : filterValue
19615
- }
19616
- };
19617
- case "regex":
19618
- return { [filterOn]: { _regex: filterValue } };
19619
- default:
19620
- console.warn(`Unsupported filter type: ${selectedFilter}`);
19621
- return {};
19718
+ };
19719
+ case "regex":
19720
+ return { [filterOn2]: { _regex: filterValue } };
19721
+ default:
19722
+ console.warn(`Unsupported filter type: ${selectedFilter}`);
19723
+ return {};
19724
+ }
19622
19725
  }
19726
+ __name(addColumnFilters, "addColumnFilters");
19623
19727
  });
19624
19728
  if (filterClauses.length > 0) {
19625
19729
  if (Object.keys(where).length > 0) {
@@ -20150,10 +20254,15 @@ function getQueryParams({
20150
20254
  const ccDisplayName = orderVal.replace(/^-/gi, "");
20151
20255
  const schemaForField = ccFields[ccDisplayName];
20152
20256
  if (schemaForField) {
20153
- const { path: path2 } = schemaForField;
20257
+ const { path: path2, additionalSearchPaths } = schemaForField;
20154
20258
  const reversed = ccDisplayName !== orderVal;
20155
20259
  const prefix2 = reversed ? "-" : "";
20156
20260
  cleanedOrder.push(prefix2 + path2);
20261
+ if (additionalSearchPaths && additionalSearchPaths.length) {
20262
+ additionalSearchPaths.forEach((additionalPath) => {
20263
+ cleanedOrder.push(prefix2 + additionalPath);
20264
+ });
20265
+ }
20157
20266
  } else {
20158
20267
  !noOrderError && console.error(
20159
20268
  "No schema for field found!",
@@ -30206,19 +30315,19 @@ function dequal(foo, bar) {
30206
30315
  }
30207
30316
  __name(dequal, "dequal");
30208
30317
  function useDeepCompareMemoize(value) {
30209
- var ref2 = React.useRef(value);
30210
- var signalRef = React.useRef(0);
30318
+ var ref2 = React$1.useRef(value);
30319
+ var signalRef = React$1.useRef(0);
30211
30320
  if (!dequal(value, ref2.current)) {
30212
30321
  ref2.current = value;
30213
30322
  signalRef.current += 1;
30214
30323
  }
30215
- return React.useMemo(function() {
30324
+ return React$1.useMemo(function() {
30216
30325
  return ref2.current;
30217
30326
  }, [signalRef.current]);
30218
30327
  }
30219
30328
  __name(useDeepCompareMemoize, "useDeepCompareMemoize");
30220
30329
  function useDeepCompareEffect(callback, dependencies) {
30221
- return React.useEffect(callback, useDeepCompareMemoize(dependencies));
30330
+ return React$1.useEffect(callback, useDeepCompareMemoize(dependencies));
30222
30331
  }
30223
30332
  __name(useDeepCompareEffect, "useDeepCompareEffect");
30224
30333
  var fuzzysearch_1;
@@ -32487,6 +32596,7 @@ const _TgSelect = class _TgSelect extends React__default.Component {
32487
32596
  }
32488
32597
  }, "onKeyDown"),
32489
32598
  inputProps: __spreadValues({
32599
+ autoComplete: "off",
32490
32600
  name: "tg-multiselect-input",
32491
32601
  autoFocus: autoFocus || autoOpen,
32492
32602
  onBlur
@@ -34476,6 +34586,167 @@ const SearchBar = /* @__PURE__ */ __name(({
34476
34586
  })
34477
34587
  );
34478
34588
  }, "SearchBar");
34589
+ const restrictToHorizontalAxis = /* @__PURE__ */ __name((_ref) => {
34590
+ let {
34591
+ transform
34592
+ } = _ref;
34593
+ return __spreadProps(__spreadValues({}, transform), {
34594
+ y: 0
34595
+ });
34596
+ }, "restrictToHorizontalAxis");
34597
+ const restrictToVerticalAxis = /* @__PURE__ */ __name((_ref) => {
34598
+ let {
34599
+ transform
34600
+ } = _ref;
34601
+ return __spreadProps(__spreadValues({}, transform), {
34602
+ x: 0
34603
+ });
34604
+ }, "restrictToVerticalAxis");
34605
+ const DraggableColumnOption = /* @__PURE__ */ __name(({
34606
+ field,
34607
+ index: index2,
34608
+ onVisibilityChange,
34609
+ numVisible
34610
+ }) => {
34611
+ const { displayName, isHidden, path: path2, subFrag, immovable, type: type2 } = field;
34612
+ const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
34613
+ id: path2,
34614
+ disabled: immovable === "true"
34615
+ });
34616
+ if (type2 === "action") {
34617
+ return null;
34618
+ }
34619
+ const style = {
34620
+ transform: CSS.Transform.toString(transform),
34621
+ transition,
34622
+ cursor: "grab",
34623
+ marginBottom: 5
34624
+ };
34625
+ return /* @__PURE__ */ React__default.createElement(
34626
+ "div",
34627
+ __spreadValues(__spreadValues({
34628
+ ref: setNodeRef,
34629
+ style,
34630
+ className: "SortableItem",
34631
+ "data-path": path2
34632
+ }, attributes), listeners),
34633
+ /* @__PURE__ */ React__default.createElement(
34634
+ Checkbox,
34635
+ {
34636
+ name: `${path2}-${index2}`,
34637
+ key: index2,
34638
+ onChange: /* @__PURE__ */ __name(() => {
34639
+ if (numVisible <= 1 && !isHidden) {
34640
+ return window.toastr.warning(
34641
+ "We have to display at least one column :)"
34642
+ );
34643
+ }
34644
+ onVisibilityChange({ shouldShow: isHidden, path: path2 });
34645
+ }, "onChange"),
34646
+ checked: !isHidden,
34647
+ label: /* @__PURE__ */ React__default.createElement("span", { style: { display: "flex", marginTop: -17 } }, displayName, " ", field.fieldGroup && /* @__PURE__ */ React__default.createElement(
34648
+ "span",
34649
+ {
34650
+ style: { fontSize: 10, marginLeft: 5, marginTop: 2 },
34651
+ className: Classes.TEXT_MUTED
34652
+ },
34653
+ "(",
34654
+ field.fieldGroup,
34655
+ ")"
34656
+ ), subFrag && /* @__PURE__ */ React__default.createElement(
34657
+ InfoHelper,
34658
+ {
34659
+ icon: "warning-sign",
34660
+ intent: "warning",
34661
+ style: { marginLeft: 5 }
34662
+ },
34663
+ "Viewing this column may cause the table to load slower"
34664
+ ))
34665
+ }
34666
+ )
34667
+ );
34668
+ }, "DraggableColumnOption");
34669
+ const DraggableColumnOptions = /* @__PURE__ */ __name(({
34670
+ fields,
34671
+ onVisibilityChange,
34672
+ moveColumnPersist,
34673
+ numVisible
34674
+ }) => {
34675
+ const [sortedFields, setSortedFields] = useState(fields);
34676
+ useEffect(() => {
34677
+ setSortedFields(fields);
34678
+ }, [fields]);
34679
+ const mouseSensor = useSensor(MouseSensor, {
34680
+ activationConstraint: {
34681
+ distance: 5
34682
+ }
34683
+ });
34684
+ const sensors = useSensors(mouseSensor);
34685
+ const handleDragStart = /* @__PURE__ */ __name((event) => {
34686
+ document.body.classList.add("column-dragging");
34687
+ const { active: active2 } = event;
34688
+ if (active2) {
34689
+ const activeNode = document.querySelector(`[data-path="${active2.id}"]`);
34690
+ if (activeNode) {
34691
+ activeNode.classList.add("dragging");
34692
+ }
34693
+ }
34694
+ }, "handleDragStart");
34695
+ const handleDragEnd = /* @__PURE__ */ __name((event) => {
34696
+ document.body.classList.remove("column-dragging");
34697
+ const draggingItem = document.querySelector(".SortableItem.dragging");
34698
+ if (draggingItem) {
34699
+ draggingItem.classList.remove("dragging");
34700
+ }
34701
+ const { active: active2, over } = event;
34702
+ if (!over || !active2 || active2.id === over.id) {
34703
+ return;
34704
+ }
34705
+ const oldIndex = sortedFields.findIndex((f2) => f2.path === active2.id);
34706
+ const newIndex = sortedFields.findIndex((f2) => f2.path === over.id);
34707
+ const newSortedFields = arrayMove(sortedFields, oldIndex, newIndex);
34708
+ setSortedFields(newSortedFields);
34709
+ moveColumnPersist({ oldIndex, newIndex });
34710
+ }, "handleDragEnd");
34711
+ return /* @__PURE__ */ React__default.createElement(
34712
+ DndContext,
34713
+ {
34714
+ sensors,
34715
+ modifiers: [restrictToVerticalAxis],
34716
+ onDragStart: handleDragStart,
34717
+ onDragEnd: handleDragEnd
34718
+ },
34719
+ /* @__PURE__ */ React__default.createElement(
34720
+ SortableContext,
34721
+ {
34722
+ items: sortedFields.map((field) => field.path),
34723
+ strategy: verticalListSortingStrategy
34724
+ },
34725
+ /* @__PURE__ */ React__default.createElement("div", null, sortedFields.map((field, index2) => /* @__PURE__ */ React__default.createElement(
34726
+ DraggableColumnOption,
34727
+ {
34728
+ key: field.path || index2,
34729
+ field,
34730
+ index: index2,
34731
+ onVisibilityChange,
34732
+ numVisible
34733
+ }
34734
+ )))
34735
+ )
34736
+ );
34737
+ }, "DraggableColumnOptions");
34738
+ const dragNoticeEl = /* @__PURE__ */ React.createElement(
34739
+ "div",
34740
+ {
34741
+ className: Classes.TEXT_MUTED,
34742
+ style: {
34743
+ padding: 10,
34744
+ fontSize: "12px"
34745
+ }
34746
+ },
34747
+ /* @__PURE__ */ React.createElement(Icon, { icon: "info-sign", size: 12 }),
34748
+ " Drag columns to reorder them"
34749
+ );
34479
34750
  const DisplayOptions = /* @__PURE__ */ __name(({
34480
34751
  compact,
34481
34752
  extraCompact,
@@ -34485,13 +34756,13 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34485
34756
  resetDefaultVisibility = noop$4,
34486
34757
  updateColumnVisibility = noop$4,
34487
34758
  updateTableDisplayDensity,
34759
+ moveColumnPersist = noop$4,
34488
34760
  showForcedHiddenColumns,
34489
34761
  setShowForcedHidden,
34490
34762
  hasOptionForForcedHidden,
34491
34763
  schema
34492
34764
  }) => {
34493
34765
  const [isOpen, setIsOpen] = useState(false);
34494
- const [searchTerms, setSearchTerms] = useState({});
34495
34766
  const changeTableDensity = /* @__PURE__ */ __name((e) => {
34496
34767
  updateTableDisplayDensity(e.target.value);
34497
34768
  setIsOpen(false);
@@ -34501,85 +34772,10 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34501
34772
  return null;
34502
34773
  }
34503
34774
  const { fields } = schema;
34504
- const fieldGroups = {};
34505
- const mainFields = [];
34775
+ let numVisible = 0;
34506
34776
  fields.forEach((field) => {
34507
- if (field.hideInMenu) return;
34508
- if (!field.fieldGroup) return mainFields.push(field);
34509
- if (!fieldGroups[field.fieldGroup]) fieldGroups[field.fieldGroup] = [];
34510
- fieldGroups[field.fieldGroup].push(field);
34777
+ if (!field.isHidden && field.type !== "action") numVisible++;
34511
34778
  });
34512
- let numVisible = 0;
34513
- const getFieldCheckbox = /* @__PURE__ */ __name((field, i2) => {
34514
- const { displayName, isHidden, isForcedHidden, path: path2, subFrag } = field;
34515
- if (isForcedHidden) return;
34516
- if (!isHidden) numVisible++;
34517
- return /* @__PURE__ */ React__default.createElement(
34518
- Checkbox,
34519
- {
34520
- name: `${path2}-${i2}`,
34521
- key: path2 || i2,
34522
- onChange: /* @__PURE__ */ __name(() => {
34523
- if (numVisible <= 1 && !isHidden) {
34524
- return window.toastr.warning(
34525
- "We have to display at least one column :)"
34526
- );
34527
- }
34528
- updateColumnVisibility({ shouldShow: isHidden, path: path2 });
34529
- }, "onChange"),
34530
- checked: !isHidden,
34531
- label: /* @__PURE__ */ React__default.createElement("span", { style: { display: "flex", marginTop: -17 } }, displayName, subFrag && /* @__PURE__ */ React__default.createElement(
34532
- InfoHelper,
34533
- {
34534
- icon: "warning-sign",
34535
- intent: "warning",
34536
- style: { marginLeft: 5 }
34537
- },
34538
- "Viewing this column may cause the table to load slower"
34539
- ))
34540
- }
34541
- );
34542
- }, "getFieldCheckbox");
34543
- let fieldGroupMenu;
34544
- if (!isEmpty$1(fieldGroups)) {
34545
- fieldGroupMenu = map$3(fieldGroups, (groupFields, groupName) => {
34546
- const searchTerm = searchTerms[groupName] || "";
34547
- const anyVisible = groupFields.some(
34548
- (field) => !field.isHidden && !field.isForcedHidden
34549
- );
34550
- const anyNotForcedHidden = groupFields.some(
34551
- (field) => !field.isForcedHidden
34552
- );
34553
- if (!anyNotForcedHidden) return;
34554
- return /* @__PURE__ */ React__default.createElement(MenuItem, { key: groupName, text: groupName }, /* @__PURE__ */ React__default.createElement(
34555
- InputGroup,
34556
- {
34557
- leftIcon: "search",
34558
- value: searchTerm,
34559
- onChange: /* @__PURE__ */ __name((e) => {
34560
- setSearchTerms((prev) => __spreadProps(__spreadValues({}, prev), {
34561
- [groupName]: e.target.value
34562
- }));
34563
- }, "onChange")
34564
- }
34565
- ), /* @__PURE__ */ React__default.createElement(
34566
- Button,
34567
- {
34568
- className: Classes.MINIMAL,
34569
- text: (anyVisible ? "Hide" : "Show") + " All",
34570
- style: { margin: "10px 0" },
34571
- onClick: /* @__PURE__ */ __name(() => {
34572
- updateColumnVisibility({
34573
- shouldShow: !anyVisible,
34574
- paths: groupFields.map((field) => field.path)
34575
- });
34576
- }, "onClick")
34577
- }
34578
- ), groupFields.filter(
34579
- (field) => startCase(getCCDisplayName(field)).toLowerCase().indexOf(searchTerm.toLowerCase()) > -1
34580
- ).map(getFieldCheckbox));
34581
- });
34582
- }
34583
34779
  return /* @__PURE__ */ React__default.createElement(
34584
34780
  Popover,
34585
34781
  {
@@ -34606,14 +34802,22 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34606
34802
  {
34607
34803
  style: {
34608
34804
  fontWeight: "bold",
34609
- marginBottom: 10,
34805
+ marginBottom: 0,
34610
34806
  marginTop: 10,
34611
34807
  display: "flex"
34612
34808
  }
34613
34809
  },
34614
34810
  "Displayed Columns:  ",
34615
34811
  doNotSearchHiddenColumns && /* @__PURE__ */ React__default.createElement(InfoHelper, null, "Note: Hidden columns will NOT be used when searching the datatable")
34616
- ), /* @__PURE__ */ React__default.createElement("div", { style: { maxHeight: 260, overflowY: "auto", padding: 2 } }, mainFields.map(getFieldCheckbox)), /* @__PURE__ */ React__default.createElement("div", null, fieldGroupMenu), hasOptionForForcedHidden && /* @__PURE__ */ React__default.createElement("div", { style: { marginTop: 15 } }, /* @__PURE__ */ React__default.createElement(
34812
+ ), dragNoticeEl, /* @__PURE__ */ React__default.createElement("div", { style: { maxHeight: 360, overflowY: "auto", padding: 2 } }, /* @__PURE__ */ React__default.createElement(
34813
+ DraggableColumnOptions,
34814
+ {
34815
+ fields,
34816
+ onVisibilityChange: updateColumnVisibility,
34817
+ moveColumnPersist,
34818
+ numVisible
34819
+ }
34820
+ )), hasOptionForForcedHidden && /* @__PURE__ */ React__default.createElement("div", { style: { marginTop: 15 } }, /* @__PURE__ */ React__default.createElement(
34617
34821
  Switch,
34618
34822
  {
34619
34823
  label: "Show Empty Columns",
@@ -34621,24 +34825,15 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34621
34825
  onChange: toggleForcedHidden
34622
34826
  }
34623
34827
  )), /* @__PURE__ */ React__default.createElement(
34624
- "div",
34828
+ Button,
34625
34829
  {
34626
- style: {
34627
- width: "100%",
34628
- display: "flex",
34629
- justifyContent: "flex-end"
34630
- }
34830
+ style: { marginTop: 5 },
34831
+ onClick: resetDefaultVisibility,
34832
+ title: "Display Options",
34833
+ icon: "reset",
34834
+ minimal: true
34631
34835
  },
34632
- /* @__PURE__ */ React__default.createElement(
34633
- Button,
34634
- {
34635
- onClick: resetDefaultVisibility,
34636
- title: "Display Options",
34637
- icon: "reset",
34638
- minimal: true
34639
- },
34640
- "Reset Column Visibilites"
34641
- )
34836
+ "Reset Column Visibilites"
34642
34837
  )))
34643
34838
  },
34644
34839
  /* @__PURE__ */ React__default.createElement(
@@ -34665,22 +34860,22 @@ function DisabledLoadingComponent({ disabled, loading, loadingText }) {
34665
34860
  );
34666
34861
  }
34667
34862
  __name(DisabledLoadingComponent, "DisabledLoadingComponent");
34668
- const restrictToHorizontalAxis = /* @__PURE__ */ __name((_ref) => {
34669
- let {
34670
- transform
34671
- } = _ref;
34672
- return __spreadProps(__spreadValues({}, transform), {
34673
- y: 0
34674
- });
34675
- }, "restrictToHorizontalAxis");
34676
34863
  const CustomTheadComponent = /* @__PURE__ */ __name(({
34677
34864
  children: _children,
34678
34865
  className,
34679
- onSortEnd,
34680
- onSortStart,
34866
+ moveColumn,
34867
+ sortedItemsFull,
34681
34868
  style
34682
34869
  }) => {
34683
34870
  const children = _children.props.children;
34871
+ const [sortedItems, setSortedItems] = useState(
34872
+ () => children.map((c2) => {
34873
+ return c2.props.path || c2.key.split("-")[1];
34874
+ })
34875
+ );
34876
+ useEffect(() => {
34877
+ setSortedItems(children.map((c2) => c2.props.path || c2.key.split("-")[1]));
34878
+ }, [children]);
34684
34879
  const mouseSensor = useSensor(MouseSensor, {
34685
34880
  activationConstraint: {
34686
34881
  distance: 10
@@ -34695,15 +34890,17 @@ const CustomTheadComponent = /* @__PURE__ */ __name(({
34695
34890
  if (active2.id === over.id) {
34696
34891
  return;
34697
34892
  }
34698
- onSortEnd({
34699
- oldIndex: parseInt(active2.id),
34700
- newIndex: parseInt(over.id)
34701
- });
34893
+ const oldPath = active2.id;
34894
+ const newPath = over.id;
34895
+ const oldIndex = sortedItemsFull.indexOf(oldPath);
34896
+ const newIndex = sortedItemsFull.indexOf(newPath);
34897
+ const newSortedItems = arrayMove(sortedItemsFull, oldIndex, newIndex);
34898
+ setSortedItems(newSortedItems);
34899
+ moveColumn({ oldIndex, newIndex });
34702
34900
  }, "handleDragEnd");
34703
34901
  return /* @__PURE__ */ React__default.createElement(
34704
34902
  DndContext,
34705
34903
  {
34706
- onDragStart: onSortStart,
34707
34904
  onDragEnd: handleDragEnd,
34708
34905
  modifiers: [restrictToHorizontalAxis],
34709
34906
  sensors
@@ -34711,36 +34908,31 @@ const CustomTheadComponent = /* @__PURE__ */ __name(({
34711
34908
  /* @__PURE__ */ React__default.createElement("div", { className: "rt-thead " + className, style }, /* @__PURE__ */ React__default.createElement("div", { className: "rt-tr" }, /* @__PURE__ */ React__default.createElement(
34712
34909
  SortableContext,
34713
34910
  {
34714
- items: children.map((_2, index2) => `${index2}`),
34911
+ items: sortedItems,
34715
34912
  strategy: horizontalListSortingStrategy
34716
34913
  },
34717
34914
  children
34718
34915
  )))
34719
34916
  );
34720
34917
  }, "CustomTheadComponent");
34721
- const SortableColumns = /* @__PURE__ */ __name(({ className, style, children, moveColumn }) => {
34918
+ const SortableColumns = /* @__PURE__ */ __name(({
34919
+ className,
34920
+ style,
34921
+ children,
34922
+ moveColumn,
34923
+ sortedItemsFull
34924
+ }) => {
34722
34925
  const shouldCancelStart = /* @__PURE__ */ __name((e) => {
34723
34926
  const className2 = e.target.className;
34724
34927
  return e.target instanceof SVGElement || className2.indexOf("rt-resizer") > -1;
34725
34928
  }, "shouldCancelStart");
34726
- const onSortEnd = /* @__PURE__ */ __name((...args) => {
34727
- const { oldIndex, newIndex } = args[0];
34728
- document.body.classList.remove("drag-active");
34729
- moveColumn({
34730
- oldIndex,
34731
- newIndex
34732
- });
34733
- }, "onSortEnd");
34734
- const onSortStart = /* @__PURE__ */ __name(() => {
34735
- document.body.classList.add("drag-active");
34736
- }, "onSortStart");
34737
34929
  return /* @__PURE__ */ React__default.createElement(
34738
34930
  CustomTheadComponent,
34739
34931
  {
34740
34932
  className,
34741
34933
  style,
34742
- onSortStart,
34743
- onSortEnd,
34934
+ sortedItemsFull,
34935
+ moveColumn,
34744
34936
  helperClass: "above-dialog",
34745
34937
  shouldCancelStart
34746
34938
  },
@@ -37204,7 +37396,6 @@ __name(getTableConfigFromStorage, "getTableConfigFromStorage");
37204
37396
  const viewColumn = {
37205
37397
  width: 35,
37206
37398
  noEllipsis: true,
37207
- hideInMenu: true,
37208
37399
  immovable: true,
37209
37400
  type: "action",
37210
37401
  render: /* @__PURE__ */ __name(() => {
@@ -51769,6 +51960,7 @@ const RenderColumnHeader = /* @__PURE__ */ __name(({
51769
51960
  e.persist();
51770
51961
  showContextMenu(
51771
51962
  [
51963
+ dragNoticeEl,
51772
51964
  {
51773
51965
  text: "Hide Column",
51774
51966
  disabled: onlyOneVisibleColumn,
@@ -52446,7 +52638,10 @@ const useColumns = /* @__PURE__ */ __name(({
52446
52638
  }, "getProps")
52447
52639
  });
52448
52640
  }
52449
- const tableColumns = columns.map((column) => {
52641
+ const tableColumns = flatMap(columns, (column) => {
52642
+ if (column.isHidden) {
52643
+ return [];
52644
+ }
52450
52645
  const tableColumn = __spreadProps(__spreadValues({}, column), {
52451
52646
  Header: RenderColumnHeader({
52452
52647
  onlyOneVisibleColumn: columns.length === 1,
@@ -52478,8 +52673,9 @@ const useColumns = /* @__PURE__ */ __name(({
52478
52673
  getHeaderProps: /* @__PURE__ */ __name(() => ({
52479
52674
  // needs to be a string because it is getting passed
52480
52675
  // to the dom
52481
- immovable: column.immovable ? "true" : "false",
52482
- columnindex: column.columnIndex
52676
+ immovable: column.type === "action" || column.immovable ? "true" : "false",
52677
+ columnindex: column.columnIndex,
52678
+ path: column.path
52483
52679
  }), "getHeaderProps")
52484
52680
  });
52485
52681
  const noEllipsis = column.noEllipsis;
@@ -56687,7 +56883,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56687
56883
  "anyTouched",
56688
56884
  "blur"
56689
56885
  ]);
56690
- var _a;
56691
56886
  if (isTableParamsConnected && _tableParams && !_tableParams.entities) {
56692
56887
  throw new Error(
56693
56888
  `No entities array detected in tableParams object (<DataTable {...tableParams}/>). You need to call withQuery() after withTableParams() like: compose(withTableParams(), withQuery(something)).`
@@ -56767,12 +56962,11 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56767
56962
  const {
56768
56963
  doNotCoercePageSize,
56769
56964
  isInfinite = isSimple && !withPaging,
56770
- syncDisplayOptionsToDb,
56771
56965
  urlConnected,
56772
56966
  withSelectedEntities: withSelectedEntities2
56773
56967
  } = props;
56774
56968
  const defaults = useMemo(() => {
56775
- var _a2;
56969
+ var _a;
56776
56970
  const _defaults = __spreadValues({
56777
56971
  pageSize: controlled_pageSize || 25,
56778
56972
  order: [],
@@ -56788,11 +56982,11 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56788
56982
  // }
56789
56983
  ]
56790
56984
  }, props.defaults || {});
56791
- if (isLocalCall && orderByFirstColumn && !((_a2 = _defaults == null ? void 0 : _defaults.order) == null ? void 0 : _a2.length)) {
56985
+ if (isLocalCall && orderByFirstColumn && !((_a = _defaults == null ? void 0 : _defaults.order) == null ? void 0 : _a.length)) {
56792
56986
  const r2 = [getCCDisplayName(convertedSchema.fields[0])];
56793
56987
  _defaults.order = r2;
56794
56988
  }
56795
- if (!syncDisplayOptionsToDb && userSetPageSize) {
56989
+ if (userSetPageSize) {
56796
56990
  _defaults.pageSize = userSetPageSize;
56797
56991
  }
56798
56992
  return _defaults;
@@ -56802,7 +56996,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56802
56996
  isLocalCall,
56803
56997
  orderByFirstColumn,
56804
56998
  props.defaults,
56805
- syncDisplayOptionsToDb,
56806
56999
  userSetPageSize
56807
57000
  ]);
56808
57001
  const selectedEntities = withSelectedEntities2 ? getRecordsFromIdMap(reduxFormSelectedEntityIdMap) : void 0;
@@ -56900,8 +57093,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56900
57093
  controlled_setPage,
56901
57094
  controlled_setPageSize,
56902
57095
  controlled_total,
56903
- currentUser,
56904
- deleteTableConfiguration,
56905
57096
  disabled = false,
56906
57097
  disableSetPageSize,
56907
57098
  doNotShowEmptyRows,
@@ -56978,8 +57169,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56978
57169
  tableConfigurations,
56979
57170
  tableName,
56980
57171
  topLeftItems,
56981
- upsertFieldOption,
56982
- upsertTableConfiguration,
56983
57172
  variables,
56984
57173
  withCheckboxes = false,
56985
57174
  withDisplayOptions,
@@ -57036,11 +57225,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57036
57225
  useEffect(() => {
57037
57226
  if (withDisplayOptions) {
57038
57227
  let newTableConfig = {};
57039
- if (syncDisplayOptionsToDb) {
57040
- newTableConfig = tableConfigurations && tableConfigurations[0];
57041
- } else {
57042
- newTableConfig = getTableConfigFromStorage(formName);
57043
- }
57228
+ newTableConfig = getTableConfigFromStorage(formName);
57044
57229
  setTableConfig((prev) => {
57045
57230
  if (!newTableConfig) {
57046
57231
  newTableConfig = {
@@ -57061,7 +57246,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57061
57246
  // If the schema changes we want to take into account the synced tableConfig again
57062
57247
  formName,
57063
57248
  setTableConfig,
57064
- syncDisplayOptionsToDb,
57065
57249
  tableConfigurations,
57066
57250
  withDisplayOptions,
57067
57251
  noExcessiveCheck
@@ -57109,8 +57293,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57109
57293
  }
57110
57294
  if (noValsForField && entities.length) {
57111
57295
  return __spreadProps(__spreadValues({}, field), {
57112
- isHidden: true,
57113
- isForcedHidden: true
57296
+ isHidden: true
57114
57297
  });
57115
57298
  } else if (fieldOpt) {
57116
57299
  return __spreadProps(__spreadValues({}, field), {
@@ -57164,6 +57347,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57164
57347
  withDisplayOptions,
57165
57348
  recordIdToIsVisibleMap
57166
57349
  ]);
57350
+ const [columns, setColumns] = useState([]);
57167
57351
  const {
57168
57352
  moveColumnPersist,
57169
57353
  persistPageSize,
@@ -57180,69 +57364,37 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57180
57364
  let resizePersist2 = noop$4;
57181
57365
  if (withDisplayOptions) {
57182
57366
  const fieldOptsByPath = keyBy(tableConfig.fieldOptions, "path");
57183
- if (syncDisplayOptionsToDb) {
57184
- let tableConfigurationId;
57185
- resetDefaultVisibility2 = /* @__PURE__ */ __name(function() {
57186
- tableConfigurationId = tableConfig.id;
57187
- if (tableConfigurationId) {
57188
- deleteTableConfiguration(tableConfigurationId);
57189
- }
57190
- }, "resetDefaultVisibility2");
57191
- updateColumnVisibility2 = /* @__PURE__ */ __name(function({ shouldShow, path: path2 }) {
57192
- if (tableConfigurationId) {
57193
- const existingFieldOpt = fieldOptsByPath[path2] || {};
57194
- upsertFieldOption({
57195
- id: existingFieldOpt.id,
57196
- path: path2,
57197
- isHidden: !shouldShow,
57198
- tableConfigurationId
57199
- });
57200
- } else {
57201
- upsertTableConfiguration({
57202
- userId: currentUser.user.id,
57203
- formName,
57204
- fieldOptions: [
57205
- {
57206
- path: path2,
57207
- isHidden: !shouldShow
57208
- }
57209
- ]
57210
- });
57211
- }
57212
- }, "updateColumnVisibility2");
57213
- } else {
57214
- const syncStorage = /* @__PURE__ */ __name((newTableConfig) => {
57215
- setTableConfig(newTableConfig);
57216
- window.localStorage.setItem(formName, JSON.stringify(newTableConfig));
57217
- }, "syncStorage");
57218
- resetDefaultVisibility2 = /* @__PURE__ */ __name(function() {
57219
- setTableConfig({ fieldOptions: [] });
57220
- window.localStorage.removeItem(formName);
57221
- }, "resetDefaultVisibility2");
57222
- updateColumnVisibility2 = /* @__PURE__ */ __name(function({ path: path2, paths, shouldShow }) {
57223
- const newFieldOpts = __spreadValues({}, fieldOptsByPath);
57224
- const pathsToUse = paths ? paths : [path2];
57225
- pathsToUse.forEach((path22) => {
57226
- newFieldOpts[path22] = { path: path22, isHidden: !shouldShow };
57227
- });
57228
- syncStorage(__spreadProps(__spreadValues({}, tableConfig), { fieldOptions: toArray(newFieldOpts) }));
57229
- }, "updateColumnVisibility2");
57230
- updateTableDisplayDensity2 = /* @__PURE__ */ __name(function(density) {
57231
- syncStorage(__spreadProps(__spreadValues({}, tableConfig), { density }));
57232
- }, "updateTableDisplayDensity2");
57233
- persistPageSize2 = /* @__PURE__ */ __name(function(pageSize2) {
57234
- syncStorage(__spreadProps(__spreadValues({}, tableConfig), { userSetPageSize: pageSize2 }));
57235
- }, "persistPageSize2");
57236
- moveColumnPersist2 = /* @__PURE__ */ __name(function({ oldIndex, newIndex }) {
57237
- const columnOrderings = tableConfig.columnOrderings || schema.fields.map(({ path: path2 }) => path2);
57238
- syncStorage(__spreadProps(__spreadValues({}, tableConfig), {
57239
- columnOrderings: arrayMove(columnOrderings, oldIndex, newIndex)
57240
- }));
57241
- }, "moveColumnPersist2");
57242
- resizePersist2 = /* @__PURE__ */ __name(function(newResized) {
57243
- syncStorage(__spreadProps(__spreadValues({}, tableConfig), { resized: newResized }));
57244
- }, "resizePersist2");
57245
- }
57367
+ const syncStorage = /* @__PURE__ */ __name((newTableConfig) => {
57368
+ setTableConfig(newTableConfig);
57369
+ window.localStorage.setItem(formName, JSON.stringify(newTableConfig));
57370
+ }, "syncStorage");
57371
+ resetDefaultVisibility2 = /* @__PURE__ */ __name(function() {
57372
+ setTableConfig({ fieldOptions: [] });
57373
+ window.localStorage.removeItem(formName);
57374
+ }, "resetDefaultVisibility2");
57375
+ updateColumnVisibility2 = /* @__PURE__ */ __name(function({ path: path2, paths, shouldShow }) {
57376
+ const newFieldOpts = __spreadValues({}, fieldOptsByPath);
57377
+ const pathsToUse = paths ? paths : [path2];
57378
+ pathsToUse.forEach((path22) => {
57379
+ newFieldOpts[path22] = { path: path22, isHidden: !shouldShow };
57380
+ });
57381
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { fieldOptions: toArray(newFieldOpts) }));
57382
+ }, "updateColumnVisibility2");
57383
+ updateTableDisplayDensity2 = /* @__PURE__ */ __name(function(density) {
57384
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { density }));
57385
+ }, "updateTableDisplayDensity2");
57386
+ persistPageSize2 = /* @__PURE__ */ __name(function(pageSize2) {
57387
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { userSetPageSize: pageSize2 }));
57388
+ }, "persistPageSize2");
57389
+ moveColumnPersist2 = /* @__PURE__ */ __name(function({ oldIndex, newIndex }) {
57390
+ const columnOrderings = tableConfig.columnOrderings || columns.map(({ path: path2 }) => path2);
57391
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), {
57392
+ columnOrderings: arrayMove(columnOrderings, oldIndex, newIndex)
57393
+ }));
57394
+ }, "moveColumnPersist2");
57395
+ resizePersist2 = /* @__PURE__ */ __name(function(newResized) {
57396
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { resized: newResized }));
57397
+ }, "resizePersist2");
57246
57398
  }
57247
57399
  return {
57248
57400
  moveColumnPersist: moveColumnPersist2,
@@ -57252,18 +57404,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57252
57404
  updateColumnVisibility: updateColumnVisibility2,
57253
57405
  updateTableDisplayDensity: updateTableDisplayDensity2
57254
57406
  };
57255
- }, [
57256
- (_a = currentUser == null ? void 0 : currentUser.user) == null ? void 0 : _a.id,
57257
- deleteTableConfiguration,
57258
- formName,
57259
- setTableConfig,
57260
- schema.fields,
57261
- syncDisplayOptionsToDb,
57262
- tableConfig,
57263
- upsertFieldOption,
57264
- upsertTableConfiguration,
57265
- withDisplayOptions
57266
- ]);
57407
+ }, [formName, setTableConfig, columns, tableConfig, withDisplayOptions]);
57267
57408
  let compact = _compact;
57268
57409
  let extraCompact = _extraCompact;
57269
57410
  if (withDisplayOptions && tableConfig.density) {
@@ -57569,8 +57710,8 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57569
57710
  const waitUntilAllRowsAreRendered = useCallback(() => {
57570
57711
  return new Promise((resolve) => {
57571
57712
  const interval = setInterval(() => {
57572
- var _a2, _b;
57573
- const allRowEls = (_b = (_a2 = tableRef.current) == null ? void 0 : _a2.tableRef) == null ? void 0 : _b.querySelectorAll(".rt-tr-group");
57713
+ var _a, _b;
57714
+ const allRowEls = (_b = (_a = tableRef.current) == null ? void 0 : _a.tableRef) == null ? void 0 : _b.querySelectorAll(".rt-tr-group");
57574
57715
  if ((allRowEls == null ? void 0 : allRowEls.length) === entities.length) {
57575
57716
  clearInterval(interval);
57576
57717
  resolve();
@@ -57887,7 +58028,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57887
58028
  ]
57888
58029
  );
57889
58030
  const { handleKeyDown, handleKeyUp } = useHotkeys(hotKeys);
57890
- const [columns, setColumns] = useState([]);
57891
58031
  const [fullscreen, setFullscreen] = useState(false);
57892
58032
  const [selectingAll, setSelectingAll] = useState(false);
57893
58033
  useEffect(() => {
@@ -58068,16 +58208,15 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
58068
58208
  addFilters(additionalFilters);
58069
58209
  }, [additionalFilters]);
58070
58210
  useEffect(() => {
58071
- setColumns(
58072
- schema.fields ? schema.fields.reduce((col, field, i2) => {
58073
- if (field.isHidden) {
58074
- return col;
58075
- }
58076
- return col.concat(__spreadProps(__spreadValues({}, field), {
58077
- columnIndex: i2
58078
- }));
58079
- }, []) : []
58080
- );
58211
+ const newCols = schema.fields ? schema.fields.reduce((columns2, field, i2) => {
58212
+ if (field.isHidden) {
58213
+ return columns2.concat(field);
58214
+ }
58215
+ return columns2.concat(__spreadProps(__spreadValues({}, field), {
58216
+ columnIndex: i2
58217
+ }));
58218
+ }, []) : [];
58219
+ setColumns(newCols);
58081
58220
  }, [schema == null ? void 0 : schema.fields]);
58082
58221
  const setSelectedIds = useCallback(
58083
58222
  (selectedIds2, scrollToFirst) => {
@@ -58146,25 +58285,19 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
58146
58285
  const TheadComponent = useCallback(
58147
58286
  ({ className: className2, style: style2, children: children2 }) => {
58148
58287
  const moveColumn = /* @__PURE__ */ __name(({ oldIndex, newIndex }) => {
58149
- let oldStateColumnIndex, newStateColumnIndex;
58150
- columns.forEach((column, i2) => {
58151
- if (oldIndex === column.columnIndex) oldStateColumnIndex = i2;
58152
- if (newIndex === column.columnIndex) newStateColumnIndex = i2;
58153
- });
58154
- const newColumns = arrayMove(
58155
- columns,
58156
- oldStateColumnIndex,
58157
- newStateColumnIndex
58158
- ).map((column, i2) => {
58159
- return __spreadProps(__spreadValues({}, column), {
58160
- columnIndex: i2
58161
- });
58162
- });
58288
+ const newColumns = arrayMove(columns, oldIndex, newIndex).map(
58289
+ (column, i2) => {
58290
+ return __spreadProps(__spreadValues({}, column), {
58291
+ columnIndex: i2
58292
+ });
58293
+ }
58294
+ );
58163
58295
  setColumns(newColumns);
58164
58296
  }, "moveColumn");
58165
58297
  return /* @__PURE__ */ React__default.createElement(
58166
58298
  SortableColumns,
58167
58299
  {
58300
+ sortedItemsFull: columns.map((c2) => c2.path),
58168
58301
  className: className2,
58169
58302
  style: style2,
58170
58303
  moveColumn: moveColumnPersist || moveColumn
@@ -58197,8 +58330,8 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
58197
58330
  });
58198
58331
  }, "addEntitiesToSelection");
58199
58332
  const refocusTable = useCallback(() => {
58200
- var _a2, _b;
58201
- const table2 = (_b = (_a2 = tableRef.current) == null ? void 0 : _a2.tableRef) == null ? void 0 : _b.closest(
58333
+ var _a, _b;
58334
+ const table2 = (_b = (_a = tableRef.current) == null ? void 0 : _a.tableRef) == null ? void 0 : _b.closest(
58202
58335
  ".data-table-container>div"
58203
58336
  );
58204
58337
  table2 == null ? void 0 : table2.focus();
@@ -59032,8 +59165,8 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59032
59165
  });
59033
59166
  const scrollToTop = useCallback(
59034
59167
  () => {
59035
- var _a2, _b, _c, _d, _e, _f;
59036
- return (_f = (_e = (_d = (_c = (_b = (_a2 = tableRef.current) == null ? void 0 : _a2.tableRef) == null ? void 0 : _b.children) == null ? void 0 : _c[0]) == null ? void 0 : _d.children) == null ? void 0 : _e[0]) == null ? void 0 : _f.scrollIntoView();
59168
+ var _a, _b, _c, _d, _e, _f;
59169
+ return (_f = (_e = (_d = (_c = (_b = (_a = tableRef.current) == null ? void 0 : _a.tableRef) == null ? void 0 : _b.children) == null ? void 0 : _c[0]) == null ? void 0 : _d.children) == null ? void 0 : _e[0]) == null ? void 0 : _f.scrollIntoView();
59037
59170
  },
59038
59171
  []
59039
59172
  );
@@ -59046,7 +59179,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59046
59179
  noVirtual,
59047
59180
  className: classNames({
59048
59181
  isCellEditable,
59049
- "loading": isLoading,
59182
+ loading: isLoading,
59050
59183
  "tg-table-loading": isLoading,
59051
59184
  "tg-table-disabled": disabled
59052
59185
  }),
@@ -59150,10 +59283,10 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59150
59283
  }, isCellEditable && {
59151
59284
  tabIndex: -1,
59152
59285
  onKeyDown: /* @__PURE__ */ __name((e) => {
59153
- var _a2, _b, _c, _d, _e, _f, _g, _h;
59286
+ var _a, _b, _c, _d, _e, _f, _g, _h;
59154
59287
  const isTabKey = e.key === "Tab";
59155
59288
  const isArrowKey = e.key.startsWith("Arrow");
59156
- if (isArrowKey && ((_a2 = e.target) == null ? void 0 : _a2.tagName) !== "INPUT" || isTabKey) {
59289
+ if (isArrowKey && ((_a = e.target) == null ? void 0 : _a.tagName) !== "INPUT" || isTabKey) {
59157
59290
  const left2 = e.key === "ArrowLeft";
59158
59291
  const up = e.key === "ArrowUp";
59159
59292
  const down = e.key === "ArrowDown" || e.key === "Enter";
@@ -59432,6 +59565,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59432
59565
  resetDefaultVisibility,
59433
59566
  updateColumnVisibility,
59434
59567
  updateTableDisplayDensity,
59568
+ moveColumnPersist,
59435
59569
  showForcedHiddenColumns,
59436
59570
  setShowForcedHidden,
59437
59571
  hasOptionForForcedHidden: withDisplayOptions && (isSimple || isInfinite),
@@ -67330,7 +67464,6 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
67330
67464
  orderByFirstColumn,
67331
67465
  pageSize,
67332
67466
  schema,
67333
- syncDisplayOptionsToDb,
67334
67467
  tableParams: _tableParams,
67335
67468
  urlConnected,
67336
67469
  withDisplayOptions,
@@ -67418,12 +67551,12 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
67418
67551
  const _tableConfig = getTableConfigFromStorage(formName);
67419
67552
  const userSetPageSize = (_tableConfig == null ? void 0 : _tableConfig.userSetPageSize) && parseInt(_tableConfig.userSetPageSize, 10);
67420
67553
  let _defaultsToUse = defaults;
67421
- if (!syncDisplayOptionsToDb && userSetPageSize) {
67554
+ if (userSetPageSize) {
67422
67555
  _defaultsToUse = _defaultsToUse || {};
67423
67556
  _defaultsToUse.pageSize = userSetPageSize;
67424
67557
  }
67425
67558
  return _defaultsToUse;
67426
- }, [defaults, formName, syncDisplayOptionsToDb]);
67559
+ }, [defaults, formName]);
67427
67560
  const passingProps = useMemo(
67428
67561
  () => __spreadProps(__spreadValues({
67429
67562
  formName: "tgDataTable"
@@ -69430,10 +69563,10 @@ var Resizer = (
69430
69563
  }
69431
69564
  __name(Resizer2, "Resizer");
69432
69565
  Resizer2.prototype.render = function() {
69433
- return React.createElement("div", { className: this.props.className || "", style: __assign$2(__assign$2({ position: "absolute", userSelect: "none" }, styles[this.props.direction]), this.props.replaceStyles || {}), onMouseDown: this.onMouseDown, onTouchStart: this.onTouchStart }, this.props.children);
69566
+ return React$1.createElement("div", { className: this.props.className || "", style: __assign$2(__assign$2({ position: "absolute", userSelect: "none" }, styles[this.props.direction]), this.props.replaceStyles || {}), onMouseDown: this.onMouseDown, onTouchStart: this.onTouchStart }, this.props.children);
69434
69567
  };
69435
69568
  return Resizer2;
69436
- }(React.PureComponent)
69569
+ }(React$1.PureComponent)
69437
69570
  );
69438
69571
  var src = { exports: {} };
69439
69572
  var hasRequiredSrc;
@@ -70210,11 +70343,11 @@ var Resizable = (
70210
70343
  }
70211
70344
  var resizers = Object.keys(enable).map(function(dir) {
70212
70345
  if (enable[dir] !== false) {
70213
- return React.createElement(Resizer, { key: dir, direction: dir, onResizeStart: _this.onResizeStart, replaceStyles: handleStyles && handleStyles[dir], className: handleClasses && handleClasses[dir] }, handleComponent && handleComponent[dir] ? handleComponent[dir] : null);
70346
+ return React$1.createElement(Resizer, { key: dir, direction: dir, onResizeStart: _this.onResizeStart, replaceStyles: handleStyles && handleStyles[dir], className: handleClasses && handleClasses[dir] }, handleComponent && handleComponent[dir] ? handleComponent[dir] : null);
70214
70347
  }
70215
70348
  return null;
70216
70349
  });
70217
- return React.createElement("div", { className: handleWrapperClass, style: handleWrapperStyle }, resizers);
70350
+ return React$1.createElement("div", { className: handleWrapperClass, style: handleWrapperStyle }, resizers);
70218
70351
  };
70219
70352
  Resizable2.prototype.render = function() {
70220
70353
  var _this = this;
@@ -70230,10 +70363,10 @@ var Resizable = (
70230
70363
  style.flexBasis = this.state.flexBasis;
70231
70364
  }
70232
70365
  var Wrapper = this.props.as || "div";
70233
- return React.createElement(
70366
+ return React$1.createElement(
70234
70367
  Wrapper,
70235
70368
  __assign$1({ ref: this.ref, style, className: this.props.className }, extendsProps),
70236
- this.state.isResizing && React.createElement("div", { style: this.state.backgroundStyle }),
70369
+ this.state.isResizing && React$1.createElement("div", { style: this.state.backgroundStyle }),
70237
70370
  this.props.children,
70238
70371
  this.renderResizer()
70239
70372
  );
@@ -70266,7 +70399,7 @@ var Resizable = (
70266
70399
  snapGap: 0
70267
70400
  };
70268
70401
  return Resizable2;
70269
- }(React.PureComponent)
70402
+ }(React$1.PureComponent)
70270
70403
  );
70271
70404
  /*! *****************************************************************************
70272
70405
  Copyright (c) Microsoft Corporation. All rights reserved.