@teselagen/ui 0.5.23-beta.1 → 0.5.23-beta.11

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.cjs.js CHANGED
@@ -17180,6 +17180,43 @@ const useDeepEqualMemo = /* @__PURE__ */ __name((value) => {
17180
17180
  }
17181
17181
  return ref2.current;
17182
17182
  }, "useDeepEqualMemo");
17183
+ const useTableEntities = /* @__PURE__ */ __name((tableFormName) => {
17184
+ const dispatch = reactRedux.useDispatch();
17185
+ const selectTableEntities = React$1.useCallback(
17186
+ (entities = []) => {
17187
+ reduxForm.initialize(tableFormName, {}, true, {
17188
+ keepDirty: true,
17189
+ updateUnregisteredFields: true,
17190
+ keepValues: true
17191
+ });
17192
+ const selectedEntityIdMap = {};
17193
+ entities.forEach((entity) => {
17194
+ selectedEntityIdMap[entity.id] = {
17195
+ entity,
17196
+ time: Date.now()
17197
+ };
17198
+ });
17199
+ dispatch(
17200
+ reduxForm.change(
17201
+ tableFormName,
17202
+ "reduxFormSelectedEntityIdMap",
17203
+ selectedEntityIdMap
17204
+ )
17205
+ );
17206
+ },
17207
+ [dispatch, tableFormName]
17208
+ );
17209
+ const { allOrderedEntities = [], selectedEntities = {} } = reactRedux.useSelector(
17210
+ (state) => {
17211
+ var _a, _b, _c, _d, _e, _f;
17212
+ return {
17213
+ allOrderedEntities: (_c = (_b = (_a = state.form) == null ? void 0 : _a[tableFormName]) == null ? void 0 : _b.values) == null ? void 0 : _c.allOrderedEntities,
17214
+ selectedEntities: (_f = (_e = (_d = state.form) == null ? void 0 : _d[tableFormName]) == null ? void 0 : _e.values) == null ? void 0 : _f.reduxFormSelectedEntityIdMap
17215
+ };
17216
+ }
17217
+ );
17218
+ return { selectTableEntities, allOrderedEntities, selectedEntities };
17219
+ }, "useTableEntities");
17183
17220
  function rowClick(e2, rowInfo, entities, {
17184
17221
  reduxFormSelectedEntityIdMap,
17185
17222
  isSingleSelect,
@@ -33239,20 +33276,6 @@ const SortableColumns = /* @__PURE__ */ __name(({ className, style, children, mo
33239
33276
  children
33240
33277
  );
33241
33278
  }, "SortableColumns");
33242
- const isEq = /* @__PURE__ */ __name((o1, o2) => {
33243
- const isEq2 = isEqualWith(o1, o2, function(val1, val2) {
33244
- if (isFunction$4(val1) && isFunction$4(val2)) {
33245
- return val1 === val2 || val1.toString() === val2.toString();
33246
- }
33247
- if (val1 && val1.constructor && val1.constructor.name === "FiberNode")
33248
- return true;
33249
- });
33250
- return isEq2;
33251
- }, "isEq");
33252
- const pure = /* @__PURE__ */ __name((BaseComponent) => {
33253
- const hoc = shouldUpdate((props, nextProps) => !isEq(props, nextProps));
33254
- return hoc(BaseComponent);
33255
- }, "pure");
33256
33279
  var warning = /* @__PURE__ */ __name(function() {
33257
33280
  }, "warning");
33258
33281
  var warning_1 = warning;
@@ -34131,9 +34154,6 @@ var withRouter = /* @__PURE__ */ __name(function withRouter2(Component) {
34131
34154
  return hoistStatics(C, Component);
34132
34155
  }, "withRouter");
34133
34156
  const dataTableEnhancer = compose(
34134
- // Function to make sure we don't rerender unless there are changes
34135
- // in the params
34136
- branch((props) => !props.alwaysRerender, pure),
34137
34157
  // form prop is needed for redux-form, but we are giving this prop as
34138
34158
  // formName, so we need to rename it. Previously it was done in the withTableParams, but now
34139
34159
  // it doesn't have it by default.
@@ -34556,18 +34576,14 @@ const viewColumn = {
34556
34576
  return /* @__PURE__ */ React$1.createElement(core.Icon, { className: "dt-eyeIcon", icon: "eye-open" });
34557
34577
  }
34558
34578
  };
34559
- const openColumn = __spreadProps(__spreadValues({}, viewColumn), {
34560
- render: (val, record, rowInfo, props) => {
34579
+ const openColumn = /* @__PURE__ */ __name(({ onDoubleClick, history }) => __spreadProps(__spreadValues({}, viewColumn), {
34580
+ render: (val, record, rowInfo) => {
34561
34581
  return /* @__PURE__ */ React$1.createElement(core.Tooltip, { content: "Open" }, /* @__PURE__ */ React$1.createElement(
34562
34582
  core.Button,
34563
34583
  {
34564
34584
  onClick: (e2) => {
34565
34585
  e2.stopPropagation();
34566
- props.onDoubleClick && props.onDoubleClick(
34567
- rowInfo.original,
34568
- rowInfo.index,
34569
- props.history
34570
- );
34586
+ onDoubleClick && onDoubleClick(rowInfo.original, rowInfo.index, history);
34571
34587
  },
34572
34588
  minimal: true,
34573
34589
  small: true,
@@ -34576,7 +34592,7 @@ const openColumn = __spreadProps(__spreadValues({}, viewColumn), {
34576
34592
  }
34577
34593
  ));
34578
34594
  }
34579
- });
34595
+ }), "openColumn");
34580
34596
  function convertSchema(schema) {
34581
34597
  let schemaToUse = schema;
34582
34598
  if (!schemaToUse.fields && Array.isArray(schema)) {
@@ -47025,9 +47041,7 @@ const ColumnFilterMenu = /* @__PURE__ */ __name(({
47025
47041
  core.Popover,
47026
47042
  {
47027
47043
  position: "bottom",
47028
- onClose: () => {
47029
- setColumnFilterMenuOpen(false);
47030
- },
47044
+ onClose: () => setColumnFilterMenuOpen(false),
47031
47045
  isOpen: columnFilterMenuOpen,
47032
47046
  modifiers: {
47033
47047
  preventOverflow: { enabled: true },
@@ -47146,11 +47160,10 @@ const EditableCell = /* @__PURE__ */ __name(({
47146
47160
  }, dataTest), {
47147
47161
  autoFocus: true,
47148
47162
  onKeyDown: (e2) => {
47163
+ e2.stopPropagation();
47149
47164
  if (e2.key === "Enter") {
47150
47165
  e2.target.blur();
47151
- e2.stopPropagation();
47152
47166
  } else if (e2.key === "Escape") {
47153
- e2.stopPropagation();
47154
47167
  cancelEdit();
47155
47168
  }
47156
47169
  },
@@ -47695,61 +47708,60 @@ const RenderCell = /* @__PURE__ */ __name(({
47695
47708
  }
47696
47709
  ));
47697
47710
  }, "RenderCell");
47698
- const RenderColumns = /* @__PURE__ */ __name((props) => {
47699
- const {
47700
- addFilters,
47701
- cellRenderer,
47702
- change,
47703
- columns,
47704
- currentParams,
47705
- compact: compact3,
47706
- editableCellValue,
47707
- editingCell,
47708
- editingCellSelectAll,
47709
- entities,
47710
- expandedEntityIdMap,
47711
- extraCompact,
47712
- filters,
47713
- getCellHoverText,
47714
- isCellEditable,
47715
- isEntityDisabled,
47716
- isLocalCall,
47717
- isSimple,
47718
- isSingleSelect,
47719
- isSelectionARectangle,
47720
- noDeselectAll,
47721
- noSelect,
47722
- noUserSelect,
47723
- onDeselect,
47724
- onMultiRowSelect,
47725
- onRowClick,
47726
- onRowSelect,
47727
- onSingleRowSelect,
47728
- order: order2,
47729
- primarySelectedCellId,
47730
- reduxFormCellValidation,
47731
- reduxFormSelectedEntityIdMap,
47732
- refocusTable,
47733
- removeSingleFilter = noop$3,
47734
- schema,
47735
- selectedCells,
47736
- setEditableCellValue,
47737
- setEditingCell,
47738
- setExpandedEntityIdMap,
47739
- setNewParams,
47740
- setOrder = noop$3,
47741
- setSelectedCells,
47742
- shouldShowSubComponent,
47743
- startCellEdit,
47744
- SubComponent,
47745
- tableRef,
47746
- updateEntitiesHelper,
47747
- updateValidation,
47748
- withCheckboxes,
47749
- withExpandAndCollapseAllButton,
47750
- withFilter: _withFilter,
47751
- withSort = true
47752
- } = props;
47711
+ const RenderColumns = /* @__PURE__ */ __name(({
47712
+ addFilters,
47713
+ cellRenderer,
47714
+ change,
47715
+ columns,
47716
+ currentParams,
47717
+ compact: compact3,
47718
+ editableCellValue,
47719
+ editingCell,
47720
+ editingCellSelectAll,
47721
+ entities,
47722
+ expandedEntityIdMap,
47723
+ extraCompact,
47724
+ filters,
47725
+ getCellHoverText,
47726
+ isCellEditable,
47727
+ isEntityDisabled,
47728
+ isLocalCall,
47729
+ isSimple,
47730
+ isSingleSelect,
47731
+ isSelectionARectangle,
47732
+ noDeselectAll,
47733
+ noSelect,
47734
+ noUserSelect,
47735
+ onDeselect,
47736
+ onMultiRowSelect,
47737
+ onRowClick,
47738
+ onRowSelect,
47739
+ onSingleRowSelect,
47740
+ order: order2,
47741
+ primarySelectedCellId,
47742
+ reduxFormCellValidation,
47743
+ reduxFormSelectedEntityIdMap,
47744
+ refocusTable,
47745
+ removeSingleFilter = noop$3,
47746
+ schema,
47747
+ selectedCells,
47748
+ setEditableCellValue,
47749
+ setEditingCell,
47750
+ setExpandedEntityIdMap,
47751
+ setNewParams,
47752
+ setOrder = noop$3,
47753
+ setSelectedCells,
47754
+ shouldShowSubComponent,
47755
+ startCellEdit,
47756
+ SubComponent,
47757
+ tableRef,
47758
+ updateEntitiesHelper,
47759
+ updateValidation,
47760
+ withCheckboxes,
47761
+ withExpandAndCollapseAllButton,
47762
+ withFilter: _withFilter,
47763
+ withSort = true
47764
+ }) => {
47753
47765
  const withFilter = _withFilter === void 0 ? !isSimple : _withFilter;
47754
47766
  const onDragEnd = /* @__PURE__ */ __name((cellsToSelect) => {
47755
47767
  const [primaryRowId, primaryCellPath] = primarySelectedCellId.split(":");
@@ -47921,13 +47933,16 @@ const RenderColumns = /* @__PURE__ */ __name((props) => {
47921
47933
  let text2 = typeof val !== "string" ? row.value : val;
47922
47934
  const record = row.original;
47923
47935
  if (column.getClipboardData) {
47924
- text2 = column.getClipboardData(row.value, record, row, props);
47936
+ text2 = column.getClipboardData(row.value, record, row);
47925
47937
  } else if (column.getValueToFilterOn) {
47926
- text2 = column.getValueToFilterOn(record, props);
47938
+ text2 = column.getValueToFilterOn(record);
47927
47939
  } else if (column.render) {
47928
- text2 = column.render(row.value, record, row, props);
47940
+ text2 = column.render(row.value, record, row, {
47941
+ currentParams,
47942
+ setNewParams
47943
+ });
47929
47944
  } else if (cellRenderer && cellRenderer[column.path]) {
47930
- text2 = cellRenderer[column.path](row.value, row.original, row, props);
47945
+ text2 = cellRenderer[column.path](row.value, row.original, row);
47931
47946
  } else if (text2) {
47932
47947
  text2 = React$1.isValidElement(text2) ? text2 : String(text2);
47933
47948
  }
@@ -48145,17 +48160,15 @@ const RenderColumns = /* @__PURE__ */ __name((props) => {
48145
48160
  }
48146
48161
  if (cellRenderer && cellRenderer[column.path]) {
48147
48162
  tableColumn.Cell = (row) => {
48148
- const val = cellRenderer[column.path](
48149
- row.value,
48150
- row.original,
48151
- row,
48152
- props
48153
- );
48163
+ const val = cellRenderer[column.path](row.value, row.original, row);
48154
48164
  return val;
48155
48165
  };
48156
48166
  } else if (column.render) {
48157
48167
  tableColumn.Cell = (row) => {
48158
- const val = column.render(row.value, row.original, row, props);
48168
+ const val = column.render(row.value, row.original, row, {
48169
+ currentParams,
48170
+ setNewParams
48171
+ });
48159
48172
  return val;
48160
48173
  };
48161
48174
  } else if (column.type === "timestamp") {
@@ -48343,12 +48356,13 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48343
48356
  // }
48344
48357
  ]
48345
48358
  }, props.defaults || {}));
48346
- let _schema;
48347
- if (isFunction$4(__schema))
48348
- _schema = __schema(props);
48349
- else
48350
- _schema = __schema;
48351
- const convertedSchema = convertSchema(_schema);
48359
+ const _schema = React$1.useMemo(() => {
48360
+ if (isFunction$4(__schema))
48361
+ return __schema(props);
48362
+ else
48363
+ return __schema;
48364
+ }, [__schema, props]);
48365
+ const convertedSchema = React$1.useMemo(() => convertSchema(_schema), [_schema]);
48352
48366
  if (isLocalCall) {
48353
48367
  if (!noForm && (!formName || formName === "tgDataTable")) {
48354
48368
  throw new Error(
@@ -48389,12 +48403,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48389
48403
  const tmp = (urlConnected ? getCurrentParamsFromUrl(history.location) : reduxFormQueryParams) || {};
48390
48404
  tmp.searchTerm = reduxFormSearchInput;
48391
48405
  return tmp;
48392
- }, [
48393
- history.location,
48394
- reduxFormQueryParams,
48395
- reduxFormSearchInput,
48396
- urlConnected
48397
- ]);
48406
+ }, [history, reduxFormQueryParams, reduxFormSearchInput, urlConnected]);
48398
48407
  const tableParams = React$1.useMemo(() => {
48399
48408
  if (!isTableParamsConnected) {
48400
48409
  const updateSearch = /* @__PURE__ */ __name((val) => {
@@ -48431,7 +48440,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48431
48440
  _tableParams,
48432
48441
  change,
48433
48442
  currentParams,
48434
- history.replace,
48443
+ history,
48435
48444
  isTableParamsConnected,
48436
48445
  props,
48437
48446
  selectedEntities,
@@ -48461,6 +48470,9 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48461
48470
  }
48462
48471
  return {};
48463
48472
  }, [
48473
+ props.entities,
48474
+ props.noOrderError,
48475
+ props.isCodeModel,
48464
48476
  convertedSchema,
48465
48477
  currentParams,
48466
48478
  doNotCoercePageSize,
@@ -48495,8 +48507,8 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48495
48507
  doNotShowEmptyRows,
48496
48508
  doNotValidateUntouchedRows,
48497
48509
  editingCellSelectAll,
48498
- entities: __origEntities = [],
48499
- entitiesAcrossPages,
48510
+ entities: _origEntities = [],
48511
+ entitiesAcrossPages: _entitiesAcrossPages,
48500
48512
  entityCount,
48501
48513
  errorParsingUrlString,
48502
48514
  expandAllByDefault,
@@ -48576,10 +48588,24 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48576
48588
  withSort,
48577
48589
  withTitle = !isSimple
48578
48590
  } = props;
48579
- const _origEntities = useDeepEqualMemo(__origEntities);
48580
- const entities = useDeepEqualMemo(
48581
- ((reduxFormEntities == null ? void 0 : reduxFormEntities.length) ? reduxFormEntities : _origEntities) || []
48591
+ const _entities = React$1.useMemo(
48592
+ () => ((reduxFormEntities == null ? void 0 : reduxFormEntities.length) ? reduxFormEntities : _origEntities) || [],
48593
+ [_origEntities, reduxFormEntities]
48582
48594
  );
48595
+ const entities = useDeepEqualMemo(_entities);
48596
+ const entitiesAcrossPages = useDeepEqualMemo(_entitiesAcrossPages);
48597
+ React$1.useEffect(() => {
48598
+ if (change) {
48599
+ change("allOrderedEntities", entitiesAcrossPages);
48600
+ if (entities.length === 0 || isEmpty$1(reduxFormSelectedEntityIdMap))
48601
+ return;
48602
+ changeSelectedEntities({
48603
+ idMap: reduxFormSelectedEntityIdMap,
48604
+ entities,
48605
+ change
48606
+ });
48607
+ }
48608
+ }, [entitiesAcrossPages, reduxFormSelectedEntityIdMap]);
48583
48609
  const [tableConfig, setTableConfig] = React$1.useState({ fieldOptions: [] });
48584
48610
  React$1.useEffect(() => {
48585
48611
  let newTableConfig = {};
@@ -48603,12 +48629,15 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48603
48629
  withDisplayOptions
48604
48630
  ]);
48605
48631
  const schema = React$1.useMemo(() => {
48606
- const schema2 = convertSchema(_schema);
48632
+ const schema2 = convertedSchema;
48607
48633
  if (isViewable) {
48608
48634
  schema2.fields = [viewColumn, ...schema2.fields];
48609
48635
  }
48610
48636
  if (isOpenable) {
48611
- schema2.fields = [openColumn, ...schema2.fields];
48637
+ schema2.fields = [
48638
+ openColumn({ onDoubleClick, history }),
48639
+ ...schema2.fields
48640
+ ];
48612
48641
  }
48613
48642
  schema2.fields = schema2.fields.map((field) => {
48614
48643
  if (field.placementPath) {
@@ -48670,13 +48699,15 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
48670
48699
  }
48671
48700
  return schema2;
48672
48701
  }, [
48673
- _schema,
48674
48702
  cellRenderer,
48703
+ convertedSchema,
48675
48704
  entities,
48705
+ history,
48676
48706
  isInfinite,
48677
48707
  isOpenable,
48678
48708
  isSimple,
48679
48709
  isViewable,
48710
+ onDoubleClick,
48680
48711
  showForcedHiddenColumns,
48681
48712
  tableConfig.columnOrderings,
48682
48713
  tableConfig.fieldOptions,
@@ -49036,7 +49067,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
49036
49067
  if (editingCell === cellId)
49037
49068
  return;
49038
49069
  if (pressedKey) {
49039
- setEditableCellValue(pressedKey);
49070
+ setEditableCellValue("");
49040
49071
  } else {
49041
49072
  const [rowId, path2] = cellId.split(":");
49042
49073
  const entityIdToEntity = getEntityIdToEntity(entities);
@@ -50326,23 +50357,29 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50326
50357
  acc.push(field.filterKey);
50327
50358
  return acc;
50328
50359
  }, []);
50329
- const filtersOnNonDisplayedFields = [];
50330
- if (filters && filters.length) {
50331
- schema.fields.forEach((field) => {
50332
- const ccDisplayName = getCCDisplayName(field);
50333
- if (field.isHidden) {
50334
- filters.forEach((filter2) => {
50335
- if (filter2.filterOn === ccDisplayName) {
50336
- filtersOnNonDisplayedFields.push(__spreadProps(__spreadValues({}, filter2), {
50337
- displayName: field.displayName
50338
- }));
50339
- }
50340
- });
50341
- }
50342
- });
50343
- }
50360
+ const filtersOnNonDisplayedFields = React$1.useMemo(() => {
50361
+ const _filtersOnNonDisplayedFields = [];
50362
+ if (filters && filters.length) {
50363
+ schema.fields.forEach((field) => {
50364
+ const ccDisplayName = getCCDisplayName(field);
50365
+ if (field.isHidden) {
50366
+ filters.forEach((filter2) => {
50367
+ if (filter2.filterOn === ccDisplayName) {
50368
+ _filtersOnNonDisplayedFields.push(__spreadProps(__spreadValues({}, filter2), {
50369
+ displayName: field.displayName
50370
+ }));
50371
+ }
50372
+ });
50373
+ }
50374
+ });
50375
+ }
50376
+ return _filtersOnNonDisplayedFields;
50377
+ }, [filters, schema.fields]);
50344
50378
  const numRows = isInfinite ? entities.length : pageSize;
50345
- const idMap = reduxFormSelectedEntityIdMap || {};
50379
+ const idMap = React$1.useMemo(
50380
+ () => reduxFormSelectedEntityIdMap || {},
50381
+ [reduxFormSelectedEntityIdMap]
50382
+ );
50346
50383
  const selectedRowCount = Object.keys(idMap).filter((key) => idMap[key]).length;
50347
50384
  let rowsToShow = doNotShowEmptyRows ? Math.min(numRows, entities.length) : numRows;
50348
50385
  if (entities.length === 0 && rowsToShow < 3)
@@ -50352,10 +50389,12 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50352
50389
  acc[index2] = expandedEntityIdMap[rowId];
50353
50390
  return acc;
50354
50391
  }, {});
50355
- let children = maybeChildren;
50356
- if (children && typeof children === "function") {
50357
- children = children(props);
50358
- }
50392
+ const children = React$1.useMemo(() => {
50393
+ if (maybeChildren && typeof maybeChildren === "function") {
50394
+ return maybeChildren(props);
50395
+ }
50396
+ return maybeChildren;
50397
+ }, [maybeChildren, props]);
50359
50398
  const showHeader = (withTitle || withSearch || children) && !noHeader;
50360
50399
  const toggleFullscreenButton = /* @__PURE__ */ React$1.createElement(
50361
50400
  core.Button,
@@ -50366,111 +50405,134 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50366
50405
  onClick: () => setFullscreen((prev) => !prev)
50367
50406
  }
50368
50407
  );
50369
- let showSelectAll = false;
50370
- let showClearAll = false;
50371
- if (!isInfinite) {
50372
- const canShowSelectAll = withSelectAll || entitiesAcrossPages && numRows < entitiesAcrossPages.length;
50373
- if (canShowSelectAll) {
50374
- let atLeastOneRowOnCurrentPageSelected = false;
50375
- const allRowsOnCurrentPageSelected = entities.every((e2) => {
50376
- const rowId = getIdOrCodeOrIndex(e2);
50377
- const selected = idMap[rowId] || isEntityDisabled(e2);
50378
- if (selected)
50379
- atLeastOneRowOnCurrentPageSelected = true;
50380
- return selected;
50381
- });
50382
- if (atLeastOneRowOnCurrentPageSelected && allRowsOnCurrentPageSelected) {
50383
- let everyEntitySelected;
50384
- if (isLocalCall) {
50385
- everyEntitySelected = entitiesAcrossPages.every((e2) => {
50386
- const rowId = getIdOrCodeOrIndex(e2);
50387
- return idMap[rowId] || isEntityDisabled(e2);
50388
- });
50389
- } else {
50390
- everyEntitySelected = entityCount <= selectedRowCount;
50391
- }
50392
- if (everyEntitySelected) {
50393
- showClearAll = selectedRowCount;
50408
+ const { showSelectAll, showClearAll } = React$1.useMemo(() => {
50409
+ let _showSelectAll = false;
50410
+ let _showClearAll = false;
50411
+ if (!isInfinite) {
50412
+ const canShowSelectAll = withSelectAll || entitiesAcrossPages && numRows < entitiesAcrossPages.length;
50413
+ if (canShowSelectAll) {
50414
+ let atLeastOneRowOnCurrentPageSelected = false;
50415
+ const allRowsOnCurrentPageSelected = entities.every((e2) => {
50416
+ const rowId = getIdOrCodeOrIndex(e2);
50417
+ const selected = idMap[rowId] || isEntityDisabled(e2);
50418
+ if (selected)
50419
+ atLeastOneRowOnCurrentPageSelected = true;
50420
+ return selected;
50421
+ });
50422
+ if (atLeastOneRowOnCurrentPageSelected && allRowsOnCurrentPageSelected) {
50423
+ let everyEntitySelected;
50424
+ if (isLocalCall) {
50425
+ everyEntitySelected = entitiesAcrossPages.every((e2) => {
50426
+ const rowId = getIdOrCodeOrIndex(e2);
50427
+ return idMap[rowId] || isEntityDisabled(e2);
50428
+ });
50429
+ } else {
50430
+ everyEntitySelected = entityCount <= selectedRowCount;
50431
+ }
50432
+ if (everyEntitySelected) {
50433
+ _showClearAll = selectedRowCount;
50434
+ }
50435
+ _showSelectAll = !everyEntitySelected;
50394
50436
  }
50395
- showSelectAll = !everyEntitySelected;
50396
50437
  }
50397
50438
  }
50398
- }
50439
+ return { showSelectAll: _showSelectAll, showClearAll: _showClearAll };
50440
+ }, [
50441
+ entities,
50442
+ entitiesAcrossPages,
50443
+ entityCount,
50444
+ idMap,
50445
+ isEntityDisabled,
50446
+ isInfinite,
50447
+ isLocalCall,
50448
+ numRows,
50449
+ selectedRowCount,
50450
+ withSelectAll
50451
+ ]);
50399
50452
  const showNumSelected = !noSelect && !isSingleSelect && !hideSelectedCount;
50400
- let selectedAndTotalMessage = "";
50401
- if (showNumSelected) {
50402
- selectedAndTotalMessage += `${selectedRowCount} Selected `;
50403
- }
50404
- if (showCount && showNumSelected) {
50405
- selectedAndTotalMessage += `/ `;
50406
- }
50407
- if (showCount) {
50408
- selectedAndTotalMessage += `${entityCount || 0} Total`;
50409
- }
50410
- if (selectedAndTotalMessage) {
50411
- selectedAndTotalMessage = /* @__PURE__ */ React$1.createElement("div", null, selectedAndTotalMessage);
50412
- }
50453
+ const selectedAndTotalMessage = React$1.useMemo(() => {
50454
+ let _selectedAndTotalMessage = "";
50455
+ if (showNumSelected) {
50456
+ _selectedAndTotalMessage += `${selectedRowCount} Selected `;
50457
+ }
50458
+ if (showCount && showNumSelected) {
50459
+ _selectedAndTotalMessage += `/ `;
50460
+ }
50461
+ if (showCount) {
50462
+ _selectedAndTotalMessage += `${entityCount || 0} Total`;
50463
+ }
50464
+ if (_selectedAndTotalMessage) {
50465
+ _selectedAndTotalMessage = /* @__PURE__ */ React$1.createElement("div", null, _selectedAndTotalMessage);
50466
+ }
50467
+ return _selectedAndTotalMessage;
50468
+ }, [entityCount, selectedRowCount, showCount, showNumSelected]);
50413
50469
  const shouldShowPaging = !isInfinite && withPaging && (hidePageSizeWhenPossible ? entityCount > pageSize : true);
50414
- let SubComponentToUse;
50415
- if (SubComponent) {
50416
- SubComponentToUse = /* @__PURE__ */ __name((row) => {
50417
- let shouldShow = true;
50418
- if (shouldShowSubComponent) {
50419
- shouldShow = shouldShowSubComponent(row.original);
50420
- }
50421
- if (shouldShow) {
50422
- return SubComponent(row);
50423
- }
50424
- }, "SubComponentToUse");
50425
- }
50426
- let nonDisplayedFilterComp;
50427
- if (filtersOnNonDisplayedFields.length) {
50428
- const content2 = filtersOnNonDisplayedFields.map(
50429
- ({ displayName, path: path2, selectedFilter, filterValue }) => {
50430
- let filterValToDisplay = filterValue;
50431
- if (selectedFilter === "inList") {
50432
- filterValToDisplay = Array.isArray(filterValToDisplay) ? filterValToDisplay : filterValToDisplay && filterValToDisplay.split(";");
50470
+ const SubComponentToUse = React$1.useMemo(() => {
50471
+ if (SubComponent) {
50472
+ return (row) => {
50473
+ let shouldShow = true;
50474
+ if (shouldShowSubComponent) {
50475
+ shouldShow = shouldShowSubComponent(row.original);
50433
50476
  }
50434
- if (Array.isArray(filterValToDisplay)) {
50435
- filterValToDisplay = filterValToDisplay.join(", ");
50477
+ if (shouldShow) {
50478
+ return SubComponent(row);
50436
50479
  }
50437
- return /* @__PURE__ */ React$1.createElement(
50438
- "div",
50439
- {
50440
- key: displayName || startCase(camelCase(path2)),
50441
- className: "tg-filter-on-non-displayed-field"
50442
- },
50443
- displayName || startCase(camelCase(path2)),
50444
- " ",
50445
- lowerCase(selectedFilter),
50446
- " ",
50447
- filterValToDisplay
50448
- );
50449
- }
50450
- );
50451
- nonDisplayedFilterComp = /* @__PURE__ */ React$1.createElement("div", { style: { marginRight: 5, marginLeft: "auto" } }, /* @__PURE__ */ React$1.createElement(
50452
- core.Tooltip,
50453
- {
50454
- content: /* @__PURE__ */ React$1.createElement("div", null, "Active filters on hidden columns:", /* @__PURE__ */ React$1.createElement("br", null), /* @__PURE__ */ React$1.createElement("br", null), content2)
50455
- },
50456
- /* @__PURE__ */ React$1.createElement(core.Icon, { icon: "filter-list" })
50457
- ));
50458
- }
50459
- let filteredEnts = entities;
50460
- if (onlyShowRowsWErrors) {
50461
- const rowToErrorMap = {};
50462
- forEach(reduxFormCellValidation, (err, cellId) => {
50463
- if (err) {
50464
- const [rowId] = cellId.split(":");
50465
- rowToErrorMap[rowId] = true;
50466
- }
50467
- });
50468
- filteredEnts = entities.filter((e2) => {
50469
- return rowToErrorMap[e2.id];
50470
- });
50471
- }
50480
+ };
50481
+ }
50482
+ return;
50483
+ }, [SubComponent, shouldShowSubComponent]);
50484
+ const nonDisplayedFilterComp = React$1.useMemo(() => {
50485
+ if (filtersOnNonDisplayedFields.length) {
50486
+ const content2 = filtersOnNonDisplayedFields.map(
50487
+ ({ displayName, path: path2, selectedFilter, filterValue }) => {
50488
+ let filterValToDisplay = filterValue;
50489
+ if (selectedFilter === "inList") {
50490
+ filterValToDisplay = Array.isArray(filterValToDisplay) ? filterValToDisplay : filterValToDisplay && filterValToDisplay.split(";");
50491
+ }
50492
+ if (Array.isArray(filterValToDisplay)) {
50493
+ filterValToDisplay = filterValToDisplay.join(", ");
50494
+ }
50495
+ return /* @__PURE__ */ React$1.createElement(
50496
+ "div",
50497
+ {
50498
+ key: displayName || startCase(camelCase(path2)),
50499
+ className: "tg-filter-on-non-displayed-field"
50500
+ },
50501
+ displayName || startCase(camelCase(path2)),
50502
+ " ",
50503
+ lowerCase(selectedFilter),
50504
+ " ",
50505
+ filterValToDisplay
50506
+ );
50507
+ }
50508
+ );
50509
+ return /* @__PURE__ */ React$1.createElement("div", { style: { marginRight: 5, marginLeft: "auto" } }, /* @__PURE__ */ React$1.createElement(
50510
+ core.Tooltip,
50511
+ {
50512
+ content: /* @__PURE__ */ React$1.createElement("div", null, "Active filters on hidden columns:", /* @__PURE__ */ React$1.createElement("br", null), /* @__PURE__ */ React$1.createElement("br", null), content2)
50513
+ },
50514
+ /* @__PURE__ */ React$1.createElement(core.Icon, { icon: "filter-list" })
50515
+ ));
50516
+ }
50517
+ return null;
50518
+ }, [filtersOnNonDisplayedFields]);
50519
+ const filteredEnts = React$1.useMemo(() => {
50520
+ if (onlyShowRowsWErrors) {
50521
+ const rowToErrorMap = {};
50522
+ forEach(reduxFormCellValidation, (err, cellId) => {
50523
+ if (err) {
50524
+ const [rowId] = cellId.split(":");
50525
+ rowToErrorMap[rowId] = true;
50526
+ }
50527
+ });
50528
+ return entities.filter((e2) => {
50529
+ return rowToErrorMap[e2.id];
50530
+ });
50531
+ }
50532
+ return entities;
50533
+ }, [entities, onlyShowRowsWErrors, reduxFormCellValidation]);
50472
50534
  const renderColumns = React$1.useMemo(
50473
- () => RenderColumns(__spreadProps(__spreadValues({}, props), {
50535
+ () => RenderColumns({
50474
50536
  addFilters,
50475
50537
  cellRenderer,
50476
50538
  change,
@@ -50523,7 +50585,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
50523
50585
  withExpandAndCollapseAllButton,
50524
50586
  withFilter,
50525
50587
  withSort
50526
- })),
50588
+ }),
50527
50589
  // eslint-disable-next-line react-hooks/exhaustive-deps
50528
50590
  [
50529
50591
  SubComponent,
@@ -63281,86 +63343,89 @@ const Uploader = /* @__PURE__ */ __name(({
63281
63343
  threeDotMenuItems,
63282
63344
  validateAgainstSchema: _validateAgainstSchema
63283
63345
  }) => {
63346
+ var _a, _b;
63284
63347
  const dispatch = reactRedux.useDispatch();
63285
63348
  const [acceptLoading, setAcceptLoading] = React$1.useState();
63286
63349
  const [resolvedAccept, setResolvedAccept] = React$1.useState();
63287
63350
  const [loading, setLoading] = React$1.useState(false);
63288
63351
  const filesToClean = React$1.useRef([]);
63289
- const onChange = React$1.useCallback(
63290
- (val) => {
63291
- require$$2$1.flushSync(() => {
63292
- if (noRedux) {
63293
- return _onChange(val);
63294
- }
63295
- dispatch(reduxForm.touch(formName, name));
63296
- dispatch(reduxForm.change(formName, name, val));
63297
- });
63298
- },
63299
- [_onChange, dispatch, formName, name, noRedux]
63300
- );
63301
- const handleSecondHalfOfUpload = React$1.useCallback(
63302
- (_0) => __async(exports, [_0], function* ({ acceptedFiles, cleanedFileList }) {
63303
- onChange(cleanedFileList);
63304
- const keepGoing = beforeUpload ? yield beforeUpload(cleanedFileList, onChange) : true;
63305
- if (!keepGoing)
63306
- return;
63307
- if (action) {
63308
- const responses = [];
63309
- yield Promise.all(
63310
- acceptedFiles.map((fileToUpload) => __async(exports, null, function* () {
63311
- const data = new FormData();
63312
- data.append("file", fileToUpload);
63313
- try {
63314
- const res = yield window.api ? window.api.post(action, data) : fetch(action, {
63315
- method: "POST",
63316
- body: data
63317
- });
63318
- responses.push(res.data && res.data[0]);
63319
- onFileSuccess(res.data[0]).then(() => {
63320
- cleanedFileList = cleanedFileList.map((file) => {
63321
- const fileToReturn = __spreadValues(__spreadValues({}, file), res.data[0]);
63322
- if (fileToReturn.id === fileToUpload.id) {
63323
- fileToReturn.loading = false;
63324
- }
63325
- return fileToReturn;
63326
- });
63327
- onChange(cleanedFileList);
63328
- });
63329
- } catch (err) {
63330
- console.error("Error uploading file:", err);
63331
- responses.push(__spreadProps(__spreadValues({}, fileToUpload), {
63332
- error: err && err.msg ? err.msg : err
63333
- }));
63352
+ const onChange = /* @__PURE__ */ __name((val) => {
63353
+ require$$2$1.flushSync(() => {
63354
+ if (noRedux) {
63355
+ return _onChange(val);
63356
+ }
63357
+ dispatch(reduxForm.touch(formName, name));
63358
+ dispatch(reduxForm.change(formName, name, val));
63359
+ });
63360
+ }, "onChange");
63361
+ const handleSecondHalfOfUpload = /* @__PURE__ */ __name((_0) => __async(exports, [_0], function* ({
63362
+ acceptedFiles,
63363
+ cleanedFileList
63364
+ }) {
63365
+ onChange(cleanedFileList);
63366
+ const keepGoing = beforeUpload ? yield beforeUpload(cleanedFileList, onChange) : true;
63367
+ if (!keepGoing)
63368
+ return;
63369
+ if (action) {
63370
+ const responses = [];
63371
+ yield Promise.all(
63372
+ acceptedFiles.map((fileToUpload) => __async(exports, null, function* () {
63373
+ const data = new FormData();
63374
+ data.append("file", fileToUpload);
63375
+ try {
63376
+ const res = yield window.serverApi ? window.serverApi.post(action, data) : fetch(action, {
63377
+ method: "POST",
63378
+ body: data
63379
+ });
63380
+ responses.push(res.data && res.data[0]);
63381
+ onFileSuccess(res.data[0]).then(() => {
63334
63382
  cleanedFileList = cleanedFileList.map((file) => {
63335
- const fileToReturn = __spreadValues({}, file);
63383
+ const fileToReturn = __spreadValues(__spreadValues({}, file), res.data[0]);
63336
63384
  if (fileToReturn.id === fileToUpload.id) {
63337
63385
  fileToReturn.loading = false;
63338
- fileToReturn.error = true;
63339
63386
  }
63340
63387
  return fileToReturn;
63341
63388
  });
63342
63389
  onChange(cleanedFileList);
63343
- }
63344
- }))
63345
- );
63346
- onFieldSubmit(responses);
63347
- } else {
63348
- onChange(
63349
- cleanedFileList.map(function(file) {
63350
- return __spreadProps(__spreadValues({}, file), {
63351
- loading: false
63352
63390
  });
63353
- })
63354
- );
63355
- }
63356
- setLoading(false);
63357
- }),
63358
- [action, beforeUpload, onChange, onFieldSubmit, onFileSuccess]
63359
- );
63391
+ } catch (err) {
63392
+ console.error("Error uploading file:", err);
63393
+ responses.push(__spreadProps(__spreadValues({}, fileToUpload), {
63394
+ error: err && err.msg ? err.msg : err
63395
+ }));
63396
+ cleanedFileList = cleanedFileList.map((file) => {
63397
+ const fileToReturn = __spreadValues({}, file);
63398
+ if (fileToReturn.id === fileToUpload.id) {
63399
+ fileToReturn.loading = false;
63400
+ fileToReturn.error = true;
63401
+ }
63402
+ return fileToReturn;
63403
+ });
63404
+ onChange(cleanedFileList);
63405
+ }
63406
+ }))
63407
+ );
63408
+ onFieldSubmit(responses);
63409
+ } else {
63410
+ onChange(
63411
+ cleanedFileList.map(function(file) {
63412
+ return __spreadProps(__spreadValues({}, file), {
63413
+ loading: false
63414
+ });
63415
+ })
63416
+ );
63417
+ }
63418
+ setLoading(false);
63419
+ }), "handleSecondHalfOfUpload");
63360
63420
  const isAcceptPromise = React$1.useMemo(
63361
63421
  () => (__accept == null ? void 0 : __accept.then) || (Array.isArray(__accept) ? __accept.some((acc) => acc == null ? void 0 : acc.then) : false),
63362
63422
  [__accept]
63363
63423
  );
63424
+ let dropzoneDisabled = _disabled;
63425
+ let _accept = __accept;
63426
+ if (resolvedAccept) {
63427
+ _accept = resolvedAccept;
63428
+ }
63364
63429
  React$1.useEffect(() => {
63365
63430
  if (isAcceptPromise) {
63366
63431
  setAcceptLoading(true);
@@ -63373,234 +63438,208 @@ const Uploader = /* @__PURE__ */ __name(({
63373
63438
  );
63374
63439
  }
63375
63440
  }, [__accept, isAcceptPromise]);
63376
- const dropzoneDisabled = _disabled || acceptLoading;
63377
- const { accept, validateAgainstSchema } = React$1.useMemo(() => {
63378
- var _a, _b;
63379
- let _accept = __accept;
63380
- if (resolvedAccept) {
63381
- _accept = resolvedAccept;
63382
- }
63383
- if (isAcceptPromise && !resolvedAccept) {
63384
- _accept = [];
63385
- }
63386
- const newAccept = !_accept ? void 0 : isAcceptPromise && !resolvedAccept ? [] : isPlainObject$3(_accept) ? [_accept] : isArray$j(_accept) ? _accept : _accept.split(",").map((acc) => ({ type: acc }));
63387
- const validateAgainstSchema2 = setValidateAgainstSchema(
63388
- _validateAgainstSchema || ((_b = (_a = newAccept == null ? void 0 : newAccept.find) == null ? void 0 : _a.call(newAccept, (a2) => a2 == null ? void 0 : a2.validateAgainstSchema)) == null ? void 0 : _b.validateAgainstSchema)
63389
- );
63390
- if ((validateAgainstSchema2 || autoUnzip) && newAccept && !newAccept.some((a2) => a2.type === "zip")) {
63391
- newAccept == null ? void 0 : newAccept.unshift({
63392
- type: "zip",
63393
- description: "Any of the following types, just compressed"
63394
- });
63395
- }
63396
- return { accept: newAccept, validateAgainstSchema: validateAgainstSchema2 };
63397
- }, [
63398
- __accept,
63399
- _validateAgainstSchema,
63400
- autoUnzip,
63401
- isAcceptPromise,
63402
- resolvedAccept
63403
- ]);
63404
- const callout = React$1.useMemo(
63441
+ if (isAcceptPromise && !resolvedAccept) {
63442
+ _accept = [];
63443
+ }
63444
+ if (acceptLoading)
63445
+ dropzoneDisabled = true;
63446
+ const accept = React$1.useMemo(
63447
+ () => !_accept ? void 0 : isAcceptPromise && !resolvedAccept ? [] : isPlainObject$3(_accept) ? [_accept] : isArray$j(_accept) ? _accept : _accept.split(",").map((acc) => ({ type: acc })),
63448
+ [_accept, isAcceptPromise, resolvedAccept]
63449
+ );
63450
+ const callout = _callout || ((_b = (_a = accept == null ? void 0 : accept.find) == null ? void 0 : _a.call(accept, (a2) => a2 == null ? void 0 : a2.callout)) == null ? void 0 : _b.callout);
63451
+ const validateAgainstSchema = React$1.useMemo(
63405
63452
  () => {
63406
- var _a, _b;
63407
- return _callout || ((_b = (_a = accept == null ? void 0 : accept.find) == null ? void 0 : _a.call(accept, (a2) => a2 == null ? void 0 : a2.callout)) == null ? void 0 : _b.callout);
63453
+ var _a2, _b2;
63454
+ return setValidateAgainstSchema(
63455
+ _validateAgainstSchema || ((_b2 = (_a2 = accept == null ? void 0 : accept.find) == null ? void 0 : _a2.call(accept, (a2) => a2 == null ? void 0 : a2.validateAgainstSchema)) == null ? void 0 : _b2.validateAgainstSchema)
63456
+ );
63408
63457
  },
63409
- [_callout, accept]
63458
+ [_validateAgainstSchema, accept]
63410
63459
  );
63460
+ if ((validateAgainstSchema || autoUnzip) && accept && !accept.some((a2) => a2.type === "zip")) {
63461
+ accept == null ? void 0 : accept.unshift({
63462
+ type: "zip",
63463
+ description: "Any of the following types, just compressed"
63464
+ });
63465
+ }
63411
63466
  const { showDialogPromise: showUploadCsvWizardDialog, Comp } = useDialog({
63412
63467
  ModalComponent: UploadCsvWizardDialog
63413
63468
  });
63414
63469
  const { showDialogPromise: showSimpleInsertDataDialog, Comp: Comp2 } = useDialog({
63415
63470
  ModalComponent: SimpleInsertDataDialog
63416
63471
  });
63417
- const cleanupFiles = React$1.useCallback(() => {
63472
+ function cleanupFiles() {
63418
63473
  filesToClean.current.forEach((file) => URL.revokeObjectURL(file.preview));
63419
- }, []);
63474
+ }
63475
+ __name(cleanupFiles, "cleanupFiles");
63420
63476
  React$1.useEffect(() => {
63421
63477
  return () => {
63422
63478
  cleanupFiles();
63423
63479
  };
63424
- }, [cleanupFiles]);
63425
- const contentOverride = React$1.useMemo(() => {
63426
- let _contentOverride = maybeContentOverride;
63427
- if (_contentOverride && typeof _contentOverride === "function") {
63428
- _contentOverride = _contentOverride({ loading });
63429
- }
63430
- return _contentOverride;
63431
- }, [loading, maybeContentOverride]);
63432
- const fileListToUse = React$1.useMemo(() => fileList ? fileList : [], [fileList]);
63433
- const { simpleAccept, handleManuallyEnterData, advancedAccept } = React$1.useMemo(() => {
63434
- let simpleAccept2;
63435
- let handleManuallyEnterData2;
63436
- let advancedAccept2;
63437
- if (Array.isArray(accept)) {
63438
- if (accept.some((acc) => isPlainObject$3(acc))) {
63439
- advancedAccept2 = accept;
63440
- simpleAccept2 = flatMap(accept, (acc) => {
63441
- if (acc.validateAgainstSchema) {
63442
- if (!acc.type) {
63443
- acc.type = [".csv", ".xlsx"];
63444
- }
63445
- handleManuallyEnterData2 = /* @__PURE__ */ __name((e2) => __async(exports, null, function* () {
63446
- e2.stopPropagation();
63447
- const { newEntities, fileName } = yield showSimpleInsertDataDialog(
63448
- "onSimpleInsertDialogFinish",
63449
- {
63450
- validateAgainstSchema
63451
- }
63452
- );
63453
- if (!newEntities)
63454
- return;
63455
- const newFileName = getNewName(fileListToUse, fileName);
63456
- const { newFile, cleanedEntities } = getNewCsvFile(
63457
- newEntities,
63458
- newFileName
63459
- );
63460
- const file = __spreadProps(__spreadValues({}, newFile), {
63461
- parsedData: cleanedEntities,
63462
- meta: {
63463
- fields: validateAgainstSchema.fields.map(({ path: path2 }) => path2)
63464
- },
63465
- name: newFileName,
63466
- originFileObj: newFile,
63467
- originalFileObj: newFile,
63468
- id: nanoid(),
63469
- hasEditClick: true
63470
- });
63471
- const cleanedFileList = [file, ...fileListToUse].slice(
63472
- 0,
63473
- fileLimit ? fileLimit : void 0
63474
- );
63475
- handleSecondHalfOfUpload({
63476
- acceptedFiles: cleanedFileList,
63477
- cleanedFileList
63478
- });
63479
- window.toastr.success(`File Added`);
63480
- }), "handleManuallyEnterData2");
63481
- const nameToUse = startCase(
63482
- removeExt(
63483
- validateAgainstSchema.fileName || validateAgainstSchema.name
63484
- )
63485
- ) || "Example";
63486
- const handleDownloadXlsxFile = /* @__PURE__ */ __name(() => __async(exports, null, function* () {
63487
- var _a;
63488
- const dataDictionarySchema = [
63489
- {
63490
- value: (f2) => f2.displayName || f2.path,
63491
- column: `Column Name`
63492
- },
63493
- // {
63494
- // value: f => f.isUnique ? "Unique" : "",
63495
- // column: `Unique?`
63496
- // },
63497
- {
63498
- value: (f2) => f2.isRequired ? "Required" : "Optional",
63499
- column: `Required?`
63500
- },
63501
- {
63502
- value: (f2) => f2.type === "dropdown" ? "text" : f2.type || "text",
63503
- column: `Data Type`
63504
- },
63505
- {
63506
- value: (f2) => f2.description,
63507
- column: `Notes`
63508
- },
63509
- {
63510
- value: (f2) => f2.example || f2.defaultValue || "",
63511
- column: `Example Data`
63512
- }
63513
- ];
63514
- const mainExampleData = {};
63515
- const fieldsToUse = [
63516
- ...validateAgainstSchema.fields,
63517
- ...(_a = validateAgainstSchema.exampleDownloadFields) != null ? _a : []
63518
- ];
63519
- const mainSchema = fieldsToUse.map((f2) => {
63520
- mainExampleData[f2.displayName || f2.path] = f2.example || f2.defaultValue;
63521
- return {
63522
- column: f2.displayName || f2.path,
63523
- value: (v2) => {
63524
- return v2[f2.displayName || f2.path];
63525
- }
63526
- };
63527
- });
63528
- const blobFile = yield writeXlsxFile(
63529
- [[mainExampleData], fieldsToUse, helperText],
63530
- {
63531
- headerStyle: {
63532
- fontWeight: "bold"
63533
- },
63534
- schema: [mainSchema, dataDictionarySchema, helperSchema],
63535
- sheets: [nameToUse, "Column Info", "Upload Instructions"],
63536
- filePath: "file.xlsx"
63537
- }
63538
- );
63539
- downloadjs(blobFile, `${nameToUse}.xlsx`, "xlsx");
63540
- }), "handleDownloadXlsxFile");
63541
- acc.exampleFiles = [
63542
- // ...(a.exampleFile ? [a.exampleFile] : []),
63480
+ }, []);
63481
+ let contentOverride = maybeContentOverride;
63482
+ if (contentOverride && typeof contentOverride === "function") {
63483
+ contentOverride = contentOverride({ loading });
63484
+ }
63485
+ let simpleAccept;
63486
+ let handleManuallyEnterData;
63487
+ let advancedAccept;
63488
+ if (Array.isArray(accept)) {
63489
+ if (accept.some((acc) => isPlainObject$3(acc))) {
63490
+ advancedAccept = accept;
63491
+ simpleAccept = flatMap(accept, (acc) => {
63492
+ if (acc.validateAgainstSchema) {
63493
+ if (!acc.type) {
63494
+ acc.type = [".csv", ".xlsx"];
63495
+ }
63496
+ handleManuallyEnterData = /* @__PURE__ */ __name((e2) => __async(exports, null, function* () {
63497
+ e2.stopPropagation();
63498
+ const { newEntities, fileName } = yield showSimpleInsertDataDialog(
63499
+ "onSimpleInsertDialogFinish",
63543
63500
  {
63544
- description: "Download Example CSV File",
63545
- exampleFile: () => {
63546
- var _a, _b;
63547
- const rows = [];
63548
- const schemaToUse = [
63549
- ...acc.validateAgainstSchema.fields,
63550
- ...(_a = acc.validateAgainstSchema.exampleDownloadFields) != null ? _a : []
63551
- ];
63552
- rows.push(
63553
- schemaToUse.map((f2) => {
63554
- return `${f2.displayName || f2.path}`;
63555
- })
63556
- );
63557
- rows.push(
63558
- schemaToUse.map((f2) => {
63559
- return `${f2.example || f2.defaultValue || ""}`;
63560
- })
63561
- );
63562
- const csv = papaparse_minExports.unparse(rows);
63563
- const downloadFn = ((_b = window.Cypress) == null ? void 0 : _b.downloadTest) || downloadjs;
63564
- downloadFn(csv, `${nameToUse}.csv`, "csv");
63565
- }
63501
+ validateAgainstSchema
63502
+ }
63503
+ );
63504
+ if (!newEntities)
63505
+ return;
63506
+ const newFileName = getNewName(fileListToUse, fileName);
63507
+ const { newFile, cleanedEntities } = getNewCsvFile(
63508
+ newEntities,
63509
+ newFileName
63510
+ );
63511
+ const file = __spreadProps(__spreadValues({}, newFile), {
63512
+ parsedData: cleanedEntities,
63513
+ meta: {
63514
+ fields: validateAgainstSchema.fields.map(({ path: path2 }) => path2)
63566
63515
  },
63516
+ name: newFileName,
63517
+ originFileObj: newFile,
63518
+ originalFileObj: newFile,
63519
+ id: nanoid(),
63520
+ hasEditClick: true
63521
+ });
63522
+ const cleanedFileList = [file, ...fileListToUse].slice(
63523
+ 0,
63524
+ fileLimit ? fileLimit : void 0
63525
+ );
63526
+ handleSecondHalfOfUpload({
63527
+ acceptedFiles: cleanedFileList,
63528
+ cleanedFileList
63529
+ });
63530
+ window.toastr.success(`File Added`);
63531
+ }), "handleManuallyEnterData");
63532
+ const nameToUse = startCase(
63533
+ removeExt(
63534
+ validateAgainstSchema.fileName || validateAgainstSchema.name
63535
+ )
63536
+ ) || "Example";
63537
+ const handleDownloadXlsxFile = /* @__PURE__ */ __name(() => __async(exports, null, function* () {
63538
+ var _a2;
63539
+ const dataDictionarySchema = [
63540
+ { value: (f2) => f2.displayName || f2.path, column: `Column Name` },
63541
+ // {
63542
+ // value: f => f.isUnique ? "Unique" : "",
63543
+ // column: `Unique?`
63544
+ // },
63567
63545
  {
63568
- description: "Download Example XLSX File",
63569
- subtext: "Includes Upload Instructions and Column Info",
63570
- exampleFile: handleDownloadXlsxFile
63546
+ value: (f2) => f2.isRequired ? "Required" : "Optional",
63547
+ column: `Required?`
63571
63548
  },
63572
- ...noBuildCsvOption ? [] : [
63573
- {
63574
- description: manualEnterMessage,
63575
- subtext: manualEnterSubMessage,
63576
- icon: "manually-entered-data",
63577
- exampleFile: handleManuallyEnterData2
63578
- }
63579
- ]
63549
+ {
63550
+ value: (f2) => f2.type === "dropdown" ? "text" : f2.type || "text",
63551
+ column: `Data Type`
63552
+ },
63553
+ {
63554
+ value: (f2) => f2.description,
63555
+ column: `Notes`
63556
+ },
63557
+ {
63558
+ value: (f2) => f2.example || f2.defaultValue || "",
63559
+ column: `Example Data`
63560
+ }
63580
63561
  ];
63581
- delete acc.exampleFile;
63582
- }
63583
- if (acc.type)
63584
- return acc.type;
63585
- return acc;
63586
- });
63587
- simpleAccept2 = simpleAccept2.join(", ");
63588
- } else {
63589
- simpleAccept2 = accept.join(", ");
63590
- }
63562
+ const mainExampleData = {};
63563
+ const fieldsToUse = [
63564
+ ...validateAgainstSchema.fields,
63565
+ ...(_a2 = validateAgainstSchema.exampleDownloadFields) != null ? _a2 : []
63566
+ ];
63567
+ const mainSchema = fieldsToUse.map((f2) => {
63568
+ mainExampleData[f2.displayName || f2.path] = f2.example || f2.defaultValue;
63569
+ return {
63570
+ column: f2.displayName || f2.path,
63571
+ value: (v2) => {
63572
+ return v2[f2.displayName || f2.path];
63573
+ }
63574
+ };
63575
+ });
63576
+ const blobFile = yield writeXlsxFile(
63577
+ [[mainExampleData], fieldsToUse, helperText],
63578
+ {
63579
+ headerStyle: {
63580
+ fontWeight: "bold"
63581
+ },
63582
+ schema: [mainSchema, dataDictionarySchema, helperSchema],
63583
+ sheets: [nameToUse, "Column Info", "Upload Instructions"],
63584
+ filePath: "file.xlsx"
63585
+ }
63586
+ );
63587
+ downloadjs(blobFile, `${nameToUse}.xlsx`, "xlsx");
63588
+ }), "handleDownloadXlsxFile");
63589
+ acc.exampleFiles = [
63590
+ // ...(a.exampleFile ? [a.exampleFile] : []),
63591
+ {
63592
+ description: "Download Example CSV File",
63593
+ exampleFile: () => {
63594
+ var _a2, _b2;
63595
+ const rows = [];
63596
+ const schemaToUse = [
63597
+ ...acc.validateAgainstSchema.fields,
63598
+ ...(_a2 = acc.validateAgainstSchema.exampleDownloadFields) != null ? _a2 : []
63599
+ ];
63600
+ rows.push(
63601
+ schemaToUse.map((f2) => {
63602
+ return `${f2.displayName || f2.path}`;
63603
+ })
63604
+ );
63605
+ rows.push(
63606
+ schemaToUse.map((f2) => {
63607
+ return `${f2.example || f2.defaultValue || ""}`;
63608
+ })
63609
+ );
63610
+ const csv = papaparse_minExports.unparse(rows);
63611
+ const downloadFn = ((_b2 = window.Cypress) == null ? void 0 : _b2.downloadTest) || downloadjs;
63612
+ downloadFn(csv, `${nameToUse}.csv`, "csv");
63613
+ }
63614
+ },
63615
+ {
63616
+ description: "Download Example XLSX File",
63617
+ subtext: "Includes Upload Instructions and Column Info",
63618
+ exampleFile: handleDownloadXlsxFile
63619
+ },
63620
+ ...noBuildCsvOption ? [] : [
63621
+ {
63622
+ description: manualEnterMessage,
63623
+ subtext: manualEnterSubMessage,
63624
+ icon: "manually-entered-data",
63625
+ exampleFile: handleManuallyEnterData
63626
+ }
63627
+ ]
63628
+ ];
63629
+ delete acc.exampleFile;
63630
+ }
63631
+ if (acc.type)
63632
+ return acc.type;
63633
+ return acc;
63634
+ });
63635
+ simpleAccept = simpleAccept.join(", ");
63591
63636
  } else {
63592
- simpleAccept2 = accept;
63637
+ simpleAccept = accept.join(", ");
63593
63638
  }
63594
- return { simpleAccept: simpleAccept2, handleManuallyEnterData: handleManuallyEnterData2, advancedAccept: advancedAccept2 };
63595
- }, [
63596
- accept,
63597
- fileLimit,
63598
- fileListToUse,
63599
- handleSecondHalfOfUpload,
63600
- noBuildCsvOption,
63601
- showSimpleInsertDataDialog,
63602
- validateAgainstSchema
63603
- ]);
63639
+ } else {
63640
+ simpleAccept = accept;
63641
+ }
63642
+ const fileListToUse = fileList ? fileList : [];
63604
63643
  return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, callout && /* @__PURE__ */ React$1.createElement(core.Callout, { style: { marginBottom: 5 }, intent: "primary" }, callout), /* @__PURE__ */ React$1.createElement(
63605
63644
  "div",
63606
63645
  {
@@ -63724,13 +63763,13 @@ const Uploader = /* @__PURE__ */ __name(({
63724
63763
  multiple: fileLimit !== 1,
63725
63764
  accept: simpleAccept ? simpleAccept.split(", ").map((acc) => acc.startsWith(".") ? acc : "." + acc).join(", ") : void 0,
63726
63765
  onDrop: (_acceptedFiles, rejectedFiles) => __async(exports, null, function* () {
63727
- var _a, _b;
63766
+ var _a2, _b2;
63728
63767
  let acceptedFiles = [];
63729
63768
  for (const file of _acceptedFiles) {
63730
63769
  if ((validateAgainstSchema || autoUnzip) && isZipFile(file)) {
63731
63770
  const files = yield filterFilesInZip(
63732
63771
  file,
63733
- ((_a = simpleAccept == null ? void 0 : simpleAccept.split(", ")) == null ? void 0 : _a.map((acc) => acc.startsWith(".") ? acc : "." + acc)) || []
63772
+ ((_a2 = simpleAccept == null ? void 0 : simpleAccept.split(", ")) == null ? void 0 : _a2.map((acc) => acc.startsWith(".") ? acc : "." + acc)) || []
63734
63773
  );
63735
63774
  acceptedFiles.push(...files.map((f2) => f2.originFileObj));
63736
63775
  } else {
@@ -63825,7 +63864,7 @@ const Uploader = /* @__PURE__ */ __name(({
63825
63864
  incomingData: parsedF.data,
63826
63865
  validateAgainstSchema
63827
63866
  });
63828
- if (((_b = userSchema == null ? void 0 : userSchema.userData) == null ? void 0 : _b.length) === 0) {
63867
+ if (((_b2 = userSchema == null ? void 0 : userSchema.userData) == null ? void 0 : _b2.length) === 0) {
63829
63868
  console.error(
63830
63869
  `userSchema, parsedF.data:`,
63831
63870
  userSchema,
@@ -64358,6 +64397,20 @@ const withStore = /* @__PURE__ */ __name((Component) => {
64358
64397
  return /* @__PURE__ */ React$1.createElement(Component, __spreadProps(__spreadValues({}, props), { store }));
64359
64398
  };
64360
64399
  }, "withStore");
64400
+ const isEq = /* @__PURE__ */ __name((o1, o2) => {
64401
+ const isEq2 = isEqualWith(o1, o2, function(val1, val2) {
64402
+ if (isFunction$4(val1) && isFunction$4(val2)) {
64403
+ return val1 === val2 || val1.toString() === val2.toString();
64404
+ }
64405
+ if (val1 && val1.constructor && val1.constructor.name === "FiberNode")
64406
+ return true;
64407
+ });
64408
+ return isEq2;
64409
+ }, "isEq");
64410
+ const pure = /* @__PURE__ */ __name((BaseComponent) => {
64411
+ const hoc = shouldUpdate((props, nextProps) => !isEq(props, nextProps));
64412
+ return hoc(BaseComponent);
64413
+ }, "pure");
64361
64414
  function withTableParams(compOrOpts, pTopLevelOpts) {
64362
64415
  let topLevelOptions;
64363
64416
  let Component;
@@ -70686,6 +70739,7 @@ exports.tickMenuEnhancer = tickMenuEnhancer;
70686
70739
  exports.tubeIcon = tubeIcon;
70687
70740
  exports.useDeepEqualMemo = useDeepEqualMemo;
70688
70741
  exports.useDialog = useDialog;
70742
+ exports.useTableEntities = useTableEntities;
70689
70743
  exports.useTraceUpdate = useTraceUpdate;
70690
70744
  exports.withAbstractWrapper = withAbstractWrapper;
70691
70745
  exports.withCommand = withCommand;