@teselagen/ui 0.10.5 → 0.10.7

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,165 @@ 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
+ style: { marginLeft: 5 }
34660
+ },
34661
+ "Note: Viewing this complex column may cause the table to load slower. Try hiding it for better performance."
34662
+ ))
34663
+ }
34664
+ )
34665
+ );
34666
+ }, "DraggableColumnOption");
34667
+ const DraggableColumnOptions = /* @__PURE__ */ __name(({
34668
+ fields,
34669
+ onVisibilityChange,
34670
+ moveColumnPersist,
34671
+ numVisible
34672
+ }) => {
34673
+ const [sortedFields, setSortedFields] = useState(fields);
34674
+ useEffect(() => {
34675
+ setSortedFields(fields);
34676
+ }, [fields]);
34677
+ const mouseSensor = useSensor(MouseSensor, {
34678
+ activationConstraint: {
34679
+ distance: 5
34680
+ }
34681
+ });
34682
+ const sensors = useSensors(mouseSensor);
34683
+ const handleDragStart = /* @__PURE__ */ __name((event) => {
34684
+ document.body.classList.add("column-dragging");
34685
+ const { active: active2 } = event;
34686
+ if (active2) {
34687
+ const activeNode = document.querySelector(`[data-path="${active2.id}"]`);
34688
+ if (activeNode) {
34689
+ activeNode.classList.add("dragging");
34690
+ }
34691
+ }
34692
+ }, "handleDragStart");
34693
+ const handleDragEnd = /* @__PURE__ */ __name((event) => {
34694
+ document.body.classList.remove("column-dragging");
34695
+ const draggingItem = document.querySelector(".SortableItem.dragging");
34696
+ if (draggingItem) {
34697
+ draggingItem.classList.remove("dragging");
34698
+ }
34699
+ const { active: active2, over } = event;
34700
+ if (!over || !active2 || active2.id === over.id) {
34701
+ return;
34702
+ }
34703
+ const oldIndex = sortedFields.findIndex((f2) => f2.path === active2.id);
34704
+ const newIndex = sortedFields.findIndex((f2) => f2.path === over.id);
34705
+ const newSortedFields = arrayMove(sortedFields, oldIndex, newIndex);
34706
+ setSortedFields(newSortedFields);
34707
+ moveColumnPersist({ oldIndex, newIndex });
34708
+ }, "handleDragEnd");
34709
+ return /* @__PURE__ */ React__default.createElement(
34710
+ DndContext,
34711
+ {
34712
+ sensors,
34713
+ modifiers: [restrictToVerticalAxis],
34714
+ onDragStart: handleDragStart,
34715
+ onDragEnd: handleDragEnd
34716
+ },
34717
+ /* @__PURE__ */ React__default.createElement(
34718
+ SortableContext,
34719
+ {
34720
+ items: sortedFields.map((field) => field.path),
34721
+ strategy: verticalListSortingStrategy
34722
+ },
34723
+ /* @__PURE__ */ React__default.createElement("div", null, sortedFields.map((field, index2) => /* @__PURE__ */ React__default.createElement(
34724
+ DraggableColumnOption,
34725
+ {
34726
+ key: field.path || index2,
34727
+ field,
34728
+ index: index2,
34729
+ onVisibilityChange,
34730
+ numVisible
34731
+ }
34732
+ )))
34733
+ )
34734
+ );
34735
+ }, "DraggableColumnOptions");
34736
+ const dragNoticeEl = /* @__PURE__ */ React.createElement(
34737
+ "div",
34738
+ {
34739
+ className: Classes.TEXT_MUTED,
34740
+ style: {
34741
+ padding: 10,
34742
+ fontSize: "12px"
34743
+ }
34744
+ },
34745
+ /* @__PURE__ */ React.createElement(Icon, { icon: "info-sign", size: 12 }),
34746
+ " Drag columns to reorder them"
34747
+ );
34479
34748
  const DisplayOptions = /* @__PURE__ */ __name(({
34480
34749
  compact,
34481
34750
  extraCompact,
@@ -34485,13 +34754,13 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34485
34754
  resetDefaultVisibility = noop$4,
34486
34755
  updateColumnVisibility = noop$4,
34487
34756
  updateTableDisplayDensity,
34757
+ moveColumnPersist = noop$4,
34488
34758
  showForcedHiddenColumns,
34489
34759
  setShowForcedHidden,
34490
34760
  hasOptionForForcedHidden,
34491
34761
  schema
34492
34762
  }) => {
34493
34763
  const [isOpen, setIsOpen] = useState(false);
34494
- const [searchTerms, setSearchTerms] = useState({});
34495
34764
  const changeTableDensity = /* @__PURE__ */ __name((e) => {
34496
34765
  updateTableDisplayDensity(e.target.value);
34497
34766
  setIsOpen(false);
@@ -34501,85 +34770,10 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34501
34770
  return null;
34502
34771
  }
34503
34772
  const { fields } = schema;
34504
- const fieldGroups = {};
34505
- const mainFields = [];
34773
+ let numVisible = 0;
34506
34774
  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);
34775
+ if (!field.isHidden && field.type !== "action") numVisible++;
34511
34776
  });
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
34777
  return /* @__PURE__ */ React__default.createElement(
34584
34778
  Popover,
34585
34779
  {
@@ -34606,14 +34800,22 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34606
34800
  {
34607
34801
  style: {
34608
34802
  fontWeight: "bold",
34609
- marginBottom: 10,
34803
+ marginBottom: 0,
34610
34804
  marginTop: 10,
34611
34805
  display: "flex"
34612
34806
  }
34613
34807
  },
34614
34808
  "Displayed Columns:  ",
34615
34809
  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(
34810
+ ), dragNoticeEl, /* @__PURE__ */ React__default.createElement("div", { style: { maxHeight: 360, overflowY: "auto", padding: 2 } }, /* @__PURE__ */ React__default.createElement(
34811
+ DraggableColumnOptions,
34812
+ {
34813
+ fields,
34814
+ onVisibilityChange: updateColumnVisibility,
34815
+ moveColumnPersist,
34816
+ numVisible
34817
+ }
34818
+ )), hasOptionForForcedHidden && /* @__PURE__ */ React__default.createElement("div", { style: { marginTop: 15 } }, /* @__PURE__ */ React__default.createElement(
34617
34819
  Switch,
34618
34820
  {
34619
34821
  label: "Show Empty Columns",
@@ -34621,24 +34823,15 @@ const DisplayOptions = /* @__PURE__ */ __name(({
34621
34823
  onChange: toggleForcedHidden
34622
34824
  }
34623
34825
  )), /* @__PURE__ */ React__default.createElement(
34624
- "div",
34826
+ Button,
34625
34827
  {
34626
- style: {
34627
- width: "100%",
34628
- display: "flex",
34629
- justifyContent: "flex-end"
34630
- }
34828
+ style: { marginTop: 5 },
34829
+ onClick: resetDefaultVisibility,
34830
+ title: "Display Options",
34831
+ icon: "reset",
34832
+ minimal: true
34631
34833
  },
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
- )
34834
+ "Reset Column Visibilites"
34642
34835
  )))
34643
34836
  },
34644
34837
  /* @__PURE__ */ React__default.createElement(
@@ -34665,22 +34858,22 @@ function DisabledLoadingComponent({ disabled, loading, loadingText }) {
34665
34858
  );
34666
34859
  }
34667
34860
  __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
34861
  const CustomTheadComponent = /* @__PURE__ */ __name(({
34677
34862
  children: _children,
34678
34863
  className,
34679
- onSortEnd,
34680
- onSortStart,
34864
+ moveColumn,
34865
+ sortedItemsFull,
34681
34866
  style
34682
34867
  }) => {
34683
34868
  const children = _children.props.children;
34869
+ const [sortedItems, setSortedItems] = useState(
34870
+ () => children.map((c2) => {
34871
+ return c2.props.path || c2.key.split("-")[1];
34872
+ })
34873
+ );
34874
+ useEffect(() => {
34875
+ setSortedItems(children.map((c2) => c2.props.path || c2.key.split("-")[1]));
34876
+ }, [children]);
34684
34877
  const mouseSensor = useSensor(MouseSensor, {
34685
34878
  activationConstraint: {
34686
34879
  distance: 10
@@ -34695,15 +34888,17 @@ const CustomTheadComponent = /* @__PURE__ */ __name(({
34695
34888
  if (active2.id === over.id) {
34696
34889
  return;
34697
34890
  }
34698
- onSortEnd({
34699
- oldIndex: parseInt(active2.id),
34700
- newIndex: parseInt(over.id)
34701
- });
34891
+ const oldPath = active2.id;
34892
+ const newPath = over.id;
34893
+ const oldIndex = sortedItemsFull.indexOf(oldPath);
34894
+ const newIndex = sortedItemsFull.indexOf(newPath);
34895
+ const newSortedItems = arrayMove(sortedItemsFull, oldIndex, newIndex);
34896
+ setSortedItems(newSortedItems);
34897
+ moveColumn({ oldIndex, newIndex });
34702
34898
  }, "handleDragEnd");
34703
34899
  return /* @__PURE__ */ React__default.createElement(
34704
34900
  DndContext,
34705
34901
  {
34706
- onDragStart: onSortStart,
34707
34902
  onDragEnd: handleDragEnd,
34708
34903
  modifiers: [restrictToHorizontalAxis],
34709
34904
  sensors
@@ -34711,36 +34906,31 @@ const CustomTheadComponent = /* @__PURE__ */ __name(({
34711
34906
  /* @__PURE__ */ React__default.createElement("div", { className: "rt-thead " + className, style }, /* @__PURE__ */ React__default.createElement("div", { className: "rt-tr" }, /* @__PURE__ */ React__default.createElement(
34712
34907
  SortableContext,
34713
34908
  {
34714
- items: children.map((_2, index2) => `${index2}`),
34909
+ items: sortedItems,
34715
34910
  strategy: horizontalListSortingStrategy
34716
34911
  },
34717
34912
  children
34718
34913
  )))
34719
34914
  );
34720
34915
  }, "CustomTheadComponent");
34721
- const SortableColumns = /* @__PURE__ */ __name(({ className, style, children, moveColumn }) => {
34916
+ const SortableColumns = /* @__PURE__ */ __name(({
34917
+ className,
34918
+ style,
34919
+ children,
34920
+ moveColumn,
34921
+ sortedItemsFull
34922
+ }) => {
34722
34923
  const shouldCancelStart = /* @__PURE__ */ __name((e) => {
34723
34924
  const className2 = e.target.className;
34724
34925
  return e.target instanceof SVGElement || className2.indexOf("rt-resizer") > -1;
34725
34926
  }, "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
34927
  return /* @__PURE__ */ React__default.createElement(
34738
34928
  CustomTheadComponent,
34739
34929
  {
34740
34930
  className,
34741
34931
  style,
34742
- onSortStart,
34743
- onSortEnd,
34932
+ sortedItemsFull,
34933
+ moveColumn,
34744
34934
  helperClass: "above-dialog",
34745
34935
  shouldCancelStart
34746
34936
  },
@@ -37204,7 +37394,6 @@ __name(getTableConfigFromStorage, "getTableConfigFromStorage");
37204
37394
  const viewColumn = {
37205
37395
  width: 35,
37206
37396
  noEllipsis: true,
37207
- hideInMenu: true,
37208
37397
  immovable: true,
37209
37398
  type: "action",
37210
37399
  render: /* @__PURE__ */ __name(() => {
@@ -51769,6 +51958,7 @@ const RenderColumnHeader = /* @__PURE__ */ __name(({
51769
51958
  e.persist();
51770
51959
  showContextMenu(
51771
51960
  [
51961
+ dragNoticeEl,
51772
51962
  {
51773
51963
  text: "Hide Column",
51774
51964
  disabled: onlyOneVisibleColumn,
@@ -52446,7 +52636,10 @@ const useColumns = /* @__PURE__ */ __name(({
52446
52636
  }, "getProps")
52447
52637
  });
52448
52638
  }
52449
- const tableColumns = columns.map((column) => {
52639
+ const tableColumns = flatMap(columns, (column) => {
52640
+ if (column.isHidden) {
52641
+ return [];
52642
+ }
52450
52643
  const tableColumn = __spreadProps(__spreadValues({}, column), {
52451
52644
  Header: RenderColumnHeader({
52452
52645
  onlyOneVisibleColumn: columns.length === 1,
@@ -52478,8 +52671,9 @@ const useColumns = /* @__PURE__ */ __name(({
52478
52671
  getHeaderProps: /* @__PURE__ */ __name(() => ({
52479
52672
  // needs to be a string because it is getting passed
52480
52673
  // to the dom
52481
- immovable: column.immovable ? "true" : "false",
52482
- columnindex: column.columnIndex
52674
+ immovable: column.type === "action" || column.immovable ? "true" : "false",
52675
+ columnindex: column.columnIndex,
52676
+ path: column.path
52483
52677
  }), "getHeaderProps")
52484
52678
  });
52485
52679
  const noEllipsis = column.noEllipsis;
@@ -56687,7 +56881,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56687
56881
  "anyTouched",
56688
56882
  "blur"
56689
56883
  ]);
56690
- var _a;
56691
56884
  if (isTableParamsConnected && _tableParams && !_tableParams.entities) {
56692
56885
  throw new Error(
56693
56886
  `No entities array detected in tableParams object (<DataTable {...tableParams}/>). You need to call withQuery() after withTableParams() like: compose(withTableParams(), withQuery(something)).`
@@ -56767,12 +56960,11 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56767
56960
  const {
56768
56961
  doNotCoercePageSize,
56769
56962
  isInfinite = isSimple && !withPaging,
56770
- syncDisplayOptionsToDb,
56771
56963
  urlConnected,
56772
56964
  withSelectedEntities: withSelectedEntities2
56773
56965
  } = props;
56774
56966
  const defaults = useMemo(() => {
56775
- var _a2;
56967
+ var _a;
56776
56968
  const _defaults = __spreadValues({
56777
56969
  pageSize: controlled_pageSize || 25,
56778
56970
  order: [],
@@ -56788,11 +56980,11 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56788
56980
  // }
56789
56981
  ]
56790
56982
  }, props.defaults || {});
56791
- if (isLocalCall && orderByFirstColumn && !((_a2 = _defaults == null ? void 0 : _defaults.order) == null ? void 0 : _a2.length)) {
56983
+ if (isLocalCall && orderByFirstColumn && !((_a = _defaults == null ? void 0 : _defaults.order) == null ? void 0 : _a.length)) {
56792
56984
  const r2 = [getCCDisplayName(convertedSchema.fields[0])];
56793
56985
  _defaults.order = r2;
56794
56986
  }
56795
- if (!syncDisplayOptionsToDb && userSetPageSize) {
56987
+ if (userSetPageSize) {
56796
56988
  _defaults.pageSize = userSetPageSize;
56797
56989
  }
56798
56990
  return _defaults;
@@ -56802,7 +56994,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56802
56994
  isLocalCall,
56803
56995
  orderByFirstColumn,
56804
56996
  props.defaults,
56805
- syncDisplayOptionsToDb,
56806
56997
  userSetPageSize
56807
56998
  ]);
56808
56999
  const selectedEntities = withSelectedEntities2 ? getRecordsFromIdMap(reduxFormSelectedEntityIdMap) : void 0;
@@ -56900,8 +57091,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56900
57091
  controlled_setPage,
56901
57092
  controlled_setPageSize,
56902
57093
  controlled_total,
56903
- currentUser,
56904
- deleteTableConfiguration,
56905
57094
  disabled = false,
56906
57095
  disableSetPageSize,
56907
57096
  doNotShowEmptyRows,
@@ -56978,8 +57167,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
56978
57167
  tableConfigurations,
56979
57168
  tableName,
56980
57169
  topLeftItems,
56981
- upsertFieldOption,
56982
- upsertTableConfiguration,
56983
57170
  variables,
56984
57171
  withCheckboxes = false,
56985
57172
  withDisplayOptions,
@@ -57036,11 +57223,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57036
57223
  useEffect(() => {
57037
57224
  if (withDisplayOptions) {
57038
57225
  let newTableConfig = {};
57039
- if (syncDisplayOptionsToDb) {
57040
- newTableConfig = tableConfigurations && tableConfigurations[0];
57041
- } else {
57042
- newTableConfig = getTableConfigFromStorage(formName);
57043
- }
57226
+ newTableConfig = getTableConfigFromStorage(formName);
57044
57227
  setTableConfig((prev) => {
57045
57228
  if (!newTableConfig) {
57046
57229
  newTableConfig = {
@@ -57061,7 +57244,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57061
57244
  // If the schema changes we want to take into account the synced tableConfig again
57062
57245
  formName,
57063
57246
  setTableConfig,
57064
- syncDisplayOptionsToDb,
57065
57247
  tableConfigurations,
57066
57248
  withDisplayOptions,
57067
57249
  noExcessiveCheck
@@ -57109,8 +57291,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57109
57291
  }
57110
57292
  if (noValsForField && entities.length) {
57111
57293
  return __spreadProps(__spreadValues({}, field), {
57112
- isHidden: true,
57113
- isForcedHidden: true
57294
+ isHidden: true
57114
57295
  });
57115
57296
  } else if (fieldOpt) {
57116
57297
  return __spreadProps(__spreadValues({}, field), {
@@ -57164,6 +57345,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57164
57345
  withDisplayOptions,
57165
57346
  recordIdToIsVisibleMap
57166
57347
  ]);
57348
+ const [columns, setColumns] = useState([]);
57167
57349
  const {
57168
57350
  moveColumnPersist,
57169
57351
  persistPageSize,
@@ -57180,69 +57362,37 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57180
57362
  let resizePersist2 = noop$4;
57181
57363
  if (withDisplayOptions) {
57182
57364
  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
- }
57365
+ const syncStorage = /* @__PURE__ */ __name((newTableConfig) => {
57366
+ setTableConfig(newTableConfig);
57367
+ window.localStorage.setItem(formName, JSON.stringify(newTableConfig));
57368
+ }, "syncStorage");
57369
+ resetDefaultVisibility2 = /* @__PURE__ */ __name(function() {
57370
+ setTableConfig({ fieldOptions: [] });
57371
+ window.localStorage.removeItem(formName);
57372
+ }, "resetDefaultVisibility2");
57373
+ updateColumnVisibility2 = /* @__PURE__ */ __name(function({ path: path2, paths, shouldShow }) {
57374
+ const newFieldOpts = __spreadValues({}, fieldOptsByPath);
57375
+ const pathsToUse = paths ? paths : [path2];
57376
+ pathsToUse.forEach((path22) => {
57377
+ newFieldOpts[path22] = { path: path22, isHidden: !shouldShow };
57378
+ });
57379
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { fieldOptions: toArray(newFieldOpts) }));
57380
+ }, "updateColumnVisibility2");
57381
+ updateTableDisplayDensity2 = /* @__PURE__ */ __name(function(density) {
57382
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { density }));
57383
+ }, "updateTableDisplayDensity2");
57384
+ persistPageSize2 = /* @__PURE__ */ __name(function(pageSize2) {
57385
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { userSetPageSize: pageSize2 }));
57386
+ }, "persistPageSize2");
57387
+ moveColumnPersist2 = /* @__PURE__ */ __name(function({ oldIndex, newIndex }) {
57388
+ const columnOrderings = tableConfig.columnOrderings || columns.map(({ path: path2 }) => path2);
57389
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), {
57390
+ columnOrderings: arrayMove(columnOrderings, oldIndex, newIndex)
57391
+ }));
57392
+ }, "moveColumnPersist2");
57393
+ resizePersist2 = /* @__PURE__ */ __name(function(newResized) {
57394
+ syncStorage(__spreadProps(__spreadValues({}, tableConfig), { resized: newResized }));
57395
+ }, "resizePersist2");
57246
57396
  }
57247
57397
  return {
57248
57398
  moveColumnPersist: moveColumnPersist2,
@@ -57252,18 +57402,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57252
57402
  updateColumnVisibility: updateColumnVisibility2,
57253
57403
  updateTableDisplayDensity: updateTableDisplayDensity2
57254
57404
  };
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
- ]);
57405
+ }, [formName, setTableConfig, columns, tableConfig, withDisplayOptions]);
57267
57406
  let compact = _compact;
57268
57407
  let extraCompact = _extraCompact;
57269
57408
  if (withDisplayOptions && tableConfig.density) {
@@ -57569,8 +57708,8 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57569
57708
  const waitUntilAllRowsAreRendered = useCallback(() => {
57570
57709
  return new Promise((resolve) => {
57571
57710
  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");
57711
+ var _a, _b;
57712
+ const allRowEls = (_b = (_a = tableRef.current) == null ? void 0 : _a.tableRef) == null ? void 0 : _b.querySelectorAll(".rt-tr-group");
57574
57713
  if ((allRowEls == null ? void 0 : allRowEls.length) === entities.length) {
57575
57714
  clearInterval(interval);
57576
57715
  resolve();
@@ -57887,7 +58026,6 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
57887
58026
  ]
57888
58027
  );
57889
58028
  const { handleKeyDown, handleKeyUp } = useHotkeys(hotKeys);
57890
- const [columns, setColumns] = useState([]);
57891
58029
  const [fullscreen, setFullscreen] = useState(false);
57892
58030
  const [selectingAll, setSelectingAll] = useState(false);
57893
58031
  useEffect(() => {
@@ -58068,16 +58206,15 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
58068
58206
  addFilters(additionalFilters);
58069
58207
  }, [additionalFilters]);
58070
58208
  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
- );
58209
+ const newCols = schema.fields ? schema.fields.reduce((columns2, field, i2) => {
58210
+ if (field.isHidden) {
58211
+ return columns2.concat(field);
58212
+ }
58213
+ return columns2.concat(__spreadProps(__spreadValues({}, field), {
58214
+ columnIndex: i2
58215
+ }));
58216
+ }, []) : [];
58217
+ setColumns(newCols);
58081
58218
  }, [schema == null ? void 0 : schema.fields]);
58082
58219
  const setSelectedIds = useCallback(
58083
58220
  (selectedIds2, scrollToFirst) => {
@@ -58146,25 +58283,19 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
58146
58283
  const TheadComponent = useCallback(
58147
58284
  ({ className: className2, style: style2, children: children2 }) => {
58148
58285
  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
- });
58286
+ const newColumns = arrayMove(columns, oldIndex, newIndex).map(
58287
+ (column, i2) => {
58288
+ return __spreadProps(__spreadValues({}, column), {
58289
+ columnIndex: i2
58290
+ });
58291
+ }
58292
+ );
58163
58293
  setColumns(newColumns);
58164
58294
  }, "moveColumn");
58165
58295
  return /* @__PURE__ */ React__default.createElement(
58166
58296
  SortableColumns,
58167
58297
  {
58298
+ sortedItemsFull: columns.map((c2) => c2.path),
58168
58299
  className: className2,
58169
58300
  style: style2,
58170
58301
  moveColumn: moveColumnPersist || moveColumn
@@ -58197,8 +58328,8 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
58197
58328
  });
58198
58329
  }, "addEntitiesToSelection");
58199
58330
  const refocusTable = useCallback(() => {
58200
- var _a2, _b;
58201
- const table2 = (_b = (_a2 = tableRef.current) == null ? void 0 : _a2.tableRef) == null ? void 0 : _b.closest(
58331
+ var _a, _b;
58332
+ const table2 = (_b = (_a = tableRef.current) == null ? void 0 : _a.tableRef) == null ? void 0 : _b.closest(
58202
58333
  ".data-table-container>div"
58203
58334
  );
58204
58335
  table2 == null ? void 0 : table2.focus();
@@ -59032,8 +59163,8 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59032
59163
  });
59033
59164
  const scrollToTop = useCallback(
59034
59165
  () => {
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();
59166
+ var _a, _b, _c, _d, _e, _f;
59167
+ 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
59168
  },
59038
59169
  []
59039
59170
  );
@@ -59046,7 +59177,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59046
59177
  noVirtual,
59047
59178
  className: classNames({
59048
59179
  isCellEditable,
59049
- "loading": isLoading,
59180
+ loading: isLoading,
59050
59181
  "tg-table-loading": isLoading,
59051
59182
  "tg-table-disabled": disabled
59052
59183
  }),
@@ -59150,10 +59281,10 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59150
59281
  }, isCellEditable && {
59151
59282
  tabIndex: -1,
59152
59283
  onKeyDown: /* @__PURE__ */ __name((e) => {
59153
- var _a2, _b, _c, _d, _e, _f, _g, _h;
59284
+ var _a, _b, _c, _d, _e, _f, _g, _h;
59154
59285
  const isTabKey = e.key === "Tab";
59155
59286
  const isArrowKey = e.key.startsWith("Arrow");
59156
- if (isArrowKey && ((_a2 = e.target) == null ? void 0 : _a2.tagName) !== "INPUT" || isTabKey) {
59287
+ if (isArrowKey && ((_a = e.target) == null ? void 0 : _a.tagName) !== "INPUT" || isTabKey) {
59157
59288
  const left2 = e.key === "ArrowLeft";
59158
59289
  const up = e.key === "ArrowUp";
59159
59290
  const down = e.key === "ArrowDown" || e.key === "Enter";
@@ -59432,6 +59563,7 @@ const DataTable = /* @__PURE__ */ __name((_M) => {
59432
59563
  resetDefaultVisibility,
59433
59564
  updateColumnVisibility,
59434
59565
  updateTableDisplayDensity,
59566
+ moveColumnPersist,
59435
59567
  showForcedHiddenColumns,
59436
59568
  setShowForcedHidden,
59437
59569
  hasOptionForForcedHidden: withDisplayOptions && (isSimple || isInfinite),
@@ -67330,7 +67462,6 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
67330
67462
  orderByFirstColumn,
67331
67463
  pageSize,
67332
67464
  schema,
67333
- syncDisplayOptionsToDb,
67334
67465
  tableParams: _tableParams,
67335
67466
  urlConnected,
67336
67467
  withDisplayOptions,
@@ -67418,12 +67549,12 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
67418
67549
  const _tableConfig = getTableConfigFromStorage(formName);
67419
67550
  const userSetPageSize = (_tableConfig == null ? void 0 : _tableConfig.userSetPageSize) && parseInt(_tableConfig.userSetPageSize, 10);
67420
67551
  let _defaultsToUse = defaults;
67421
- if (!syncDisplayOptionsToDb && userSetPageSize) {
67552
+ if (userSetPageSize) {
67422
67553
  _defaultsToUse = _defaultsToUse || {};
67423
67554
  _defaultsToUse.pageSize = userSetPageSize;
67424
67555
  }
67425
67556
  return _defaultsToUse;
67426
- }, [defaults, formName, syncDisplayOptionsToDb]);
67557
+ }, [defaults, formName]);
67427
67558
  const passingProps = useMemo(
67428
67559
  () => __spreadProps(__spreadValues({
67429
67560
  formName: "tgDataTable"
@@ -69430,10 +69561,10 @@ var Resizer = (
69430
69561
  }
69431
69562
  __name(Resizer2, "Resizer");
69432
69563
  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);
69564
+ 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
69565
  };
69435
69566
  return Resizer2;
69436
- }(React.PureComponent)
69567
+ }(React$1.PureComponent)
69437
69568
  );
69438
69569
  var src = { exports: {} };
69439
69570
  var hasRequiredSrc;
@@ -70210,11 +70341,11 @@ var Resizable = (
70210
70341
  }
70211
70342
  var resizers = Object.keys(enable).map(function(dir) {
70212
70343
  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);
70344
+ 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
70345
  }
70215
70346
  return null;
70216
70347
  });
70217
- return React.createElement("div", { className: handleWrapperClass, style: handleWrapperStyle }, resizers);
70348
+ return React$1.createElement("div", { className: handleWrapperClass, style: handleWrapperStyle }, resizers);
70218
70349
  };
70219
70350
  Resizable2.prototype.render = function() {
70220
70351
  var _this = this;
@@ -70230,10 +70361,10 @@ var Resizable = (
70230
70361
  style.flexBasis = this.state.flexBasis;
70231
70362
  }
70232
70363
  var Wrapper = this.props.as || "div";
70233
- return React.createElement(
70364
+ return React$1.createElement(
70234
70365
  Wrapper,
70235
70366
  __assign$1({ ref: this.ref, style, className: this.props.className }, extendsProps),
70236
- this.state.isResizing && React.createElement("div", { style: this.state.backgroundStyle }),
70367
+ this.state.isResizing && React$1.createElement("div", { style: this.state.backgroundStyle }),
70237
70368
  this.props.children,
70238
70369
  this.renderResizer()
70239
70370
  );
@@ -70266,7 +70397,7 @@ var Resizable = (
70266
70397
  snapGap: 0
70267
70398
  };
70268
70399
  return Resizable2;
70269
- }(React.PureComponent)
70400
+ }(React$1.PureComponent)
70270
70401
  );
70271
70402
  /*! *****************************************************************************
70272
70403
  Copyright (c) Microsoft Corporation. All rights reserved.