@onehat/ui 0.4.68 → 0.4.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.4.68",
3
+ "version": "0.4.69",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -84,7 +84,7 @@ export default function Accordion(props) {
84
84
  if (isActive) {
85
85
  newActiveSections = _.without(activeSections, ix);
86
86
  } else {
87
- newActiveSections = _.clone(activeSections);
87
+ newActiveSections = [...activeSections]; // clone
88
88
  newActiveSections.push(ix);
89
89
  }
90
90
  }
@@ -144,7 +144,7 @@ function TagComponent(props) {
144
144
 
145
145
 
146
146
  // add new value
147
- const newValue = _.clone(value); // so we trigger a re-render
147
+ const newValue = [...value]; // clone, so we trigger a re-render
148
148
  newValue.push({
149
149
  id,
150
150
  text: displayValue,
@@ -165,7 +165,7 @@ function TagComponent(props) {
165
165
  const
166
166
  entity = selection[0],
167
167
  id = entity.id,
168
- newValue = _.clone(valueRef.current);
168
+ newValue = [...valueRef.current]; // clone
169
169
  newValue.push({
170
170
  id,
171
171
  text: entity.displayValue,
@@ -190,7 +190,7 @@ function TagComponent(props) {
190
190
  return;
191
191
  }
192
192
 
193
- const newValue = _.clone(valueRef.current);
193
+ const newValue = [...valueRef.current]; // clone
194
194
  newValue[ix] = {
195
195
  id,
196
196
  text: entity.displayValue,
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useRef, useMemo, useCallback, } from 'react';
1
+ import { useState, useEffect, useRef, useMemo, useCallback, } from 'react';
2
2
  import {
3
3
  Box,
4
4
  FlatList,
@@ -266,7 +266,7 @@ function GridComponent(props) {
266
266
  },
267
267
  setLocalColumnsConfig = (config) => {
268
268
  if (localColumnsConfigKey) {
269
- const localConfig = _.clone(config); // clone it so we don't alter the original
269
+ const localConfig = [...config]; // clone it so we don't alter the original
270
270
  if (hasUnserializableColumns) {
271
271
  // just save the data needed to later reconstruct the columns
272
272
  const usedIds = [];
@@ -1166,7 +1166,7 @@ function GridComponent(props) {
1166
1166
 
1167
1167
  // Actual data to show in the grid
1168
1168
  const entities = Repository ? (Repository.isRemote ? Repository.entities : Repository.getEntitiesOnPage()) : data;
1169
- let rowData = _.clone(entities); // don't use the original array, make a new one so alterations to it are temporary
1169
+ let rowData = [...entities]; // don't use the original array, make a new one so alterations to it are temporary
1170
1170
  if (showHeaders) {
1171
1171
  rowData.unshift({ id: 'headerRow' });
1172
1172
  }
@@ -86,7 +86,7 @@ export default function GridHeaderRow(props) {
86
86
  if (isDragging) {
87
87
  return;
88
88
  }
89
- const columnsConfig = _.clone(localColumnsConfig); // work with a copy, so that setter forces rerender
89
+ const columnsConfig = [...localColumnsConfig]; // work with a copy, so that setter forces rerender
90
90
  columnsConfig[ix].isOver = true;
91
91
  setLocalColumnsConfig(columnsConfig);
92
92
  },
@@ -94,7 +94,7 @@ export default function GridHeaderRow(props) {
94
94
  if (isDragging) {
95
95
  return;
96
96
  }
97
- const columnsConfig = _.clone(localColumnsConfig); // work with a copy, so that setter forces rerender
97
+ const columnsConfig = [...localColumnsConfig]; // work with a copy, so that setter forces rerender
98
98
  columnsConfig[ix].isOver = false;
99
99
  setLocalColumnsConfig(columnsConfig);
100
100
  },
@@ -240,7 +240,7 @@ export default function GridHeaderRow(props) {
240
240
  setDragColumnSlot({ ix: newIx, marker, });
241
241
  },
242
242
  onColumnReorderDragStop = (delta, e, config) => {
243
- const columnsConfig = _.clone(localColumnsConfig); // work with a copy, so that setter forces rerender
243
+ const columnsConfig = [...localColumnsConfig]; // work with a copy, so that setter forces rerender
244
244
 
245
245
  _.pull(columnsConfig, config);
246
246
 
@@ -256,7 +256,7 @@ export default function GridHeaderRow(props) {
256
256
  setDragColumnSlot(null);
257
257
  },
258
258
  onColumnResize = (delta, e, node, config) => {
259
- const columnsConfig = _.clone(localColumnsConfig); // work with a copy, so that setter forces rerender
259
+ const columnsConfig = [...localColumnsConfig]; // work with a copy, so that setter forces rerender
260
260
  if (config.w) {
261
261
  config.w = Math.round(config.w + delta);
262
262
  } else if (config.flex) {
@@ -11,7 +11,6 @@ import {
11
11
  UI_MODE_NATIVE,
12
12
  CURRENT_MODE,
13
13
  } from '../../Constants/UiModes.js';
14
- import { getEmptyImage } from 'react-dnd-html5-backend';
15
14
  import * as colourMixer from '@k-renwick/colour-mixer';
16
15
  import getComponentFromType from '../../Functions/getComponentFromType.js';
17
16
  import UiGlobals from '../../UiGlobals.js';
@@ -22,6 +21,16 @@ import RowDragHandle from './RowDragHandle.js';
22
21
  import RowSelectHandle from './RowSelectHandle.js';
23
22
  import _ from 'lodash';
24
23
 
24
+ // Conditional import for web only
25
+ let getEmptyImage;
26
+ if (CURRENT_MODE === UI_MODE_WEB) {
27
+ import('react-dnd-html5-backend').then((module) => {
28
+ getEmptyImage = module.getEmptyImage;
29
+ }).catch(() => {
30
+ getEmptyImage = null;
31
+ });
32
+ }
33
+
25
34
  // This was broken out from Grid simply so we can memoize it
26
35
 
27
36
  function GridRow(props) {
@@ -169,7 +169,7 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
169
169
  if (secondaryDefaultValues) {
170
170
  _.merge(defaultValuesToUse, secondaryDefaultValues);
171
171
  }
172
- addValues = _.clone(defaultValuesToUse);
172
+ addValues = [...defaultValuesToUse];
173
173
  }
174
174
 
175
175
  if (secondarySelectorId && !_.isEmpty(secondarySelectorSelected)) {
@@ -111,7 +111,7 @@ export default function withSelection(WrappedComponent) {
111
111
  }
112
112
  },
113
113
  secondaryAddToSelection = (item) => {
114
- const newSelection = _.clone(secondaryGetSelection()); // so we get a new object, so descendants rerender
114
+ const newSelection = [...secondaryGetSelection()]; // so we get a new object, so descendants rerender
115
115
  newSelection.push(item);
116
116
  secondarySetSelection(newSelection);
117
117
  },
@@ -175,7 +175,7 @@ export default function withSelection(WrappedComponent) {
175
175
  const
176
176
  currentSelectionLength = secondaryGetSelection().length,
177
177
  index = getIndexOfSelectedItem(item);
178
- let newSelection = _.clone(secondaryGetSelection()); // so we get a new object, so descendants rerender
178
+ let newSelection = [...secondaryGetSelection()]; // so we get a new object, so descendants rerender
179
179
 
180
180
  if (currentSelectionLength) {
181
181
  const { items, max, min, } = getMaxMinSelectionIndices();
@@ -179,7 +179,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
179
179
  if (defaultValues) {
180
180
  _.merge(defaultValuesToUse, defaultValues);
181
181
  }
182
- addValues = _.clone(defaultValuesToUse);
182
+ addValues = [...defaultValuesToUse];
183
183
  }
184
184
 
185
185
  if (selectorId && !_.isEmpty(selectorSelected)) {
@@ -228,7 +228,7 @@ export default function withFilters(WrappedComponent) {
228
228
  filterById = (id, cb) => {
229
229
  onClearFilters();
230
230
  filterCallbackRef.current = cb; // store the callback, so we can call it the next time this HOC renders with new filters
231
- const newFilters = _.clone(filters);
231
+ const newFilters = [...filters];
232
232
  _.remove(newFilters, (filter) => {
233
233
  return filter.field === 'q';
234
234
  });
@@ -410,8 +410,8 @@ export default function withFilters(WrappedComponent) {
410
410
  data,
411
411
  onChange: (value) => {
412
412
  const
413
- newFilters = _.clone(modalFilters),
414
- newSlots = _.clone(modalSlots),
413
+ newFilters = [...modalFilters],
414
+ newSlots = [...modalSlots],
415
415
  i = ix;//searchAllText ? ixPlusOne : ix; // compensate for 'q' filter's possible presence
416
416
 
417
417
  newFilters[i] = getFormattedFilter(value);
@@ -447,7 +447,7 @@ export default function withFilters(WrappedComponent) {
447
447
  if (!canAddSlot) {
448
448
  return;
449
449
  }
450
- const newSlots = _.clone(modalSlots);
450
+ const newSlots = [...modalSlots];
451
451
  newSlots.push(null);
452
452
  rebuildModalBody(modalFilters, newSlots);
453
453
  },
@@ -456,8 +456,8 @@ export default function withFilters(WrappedComponent) {
456
456
  return;
457
457
  }
458
458
  const
459
- newFilters = _.clone(modalFilters),
460
- newSlots = _.clone(modalSlots);
459
+ newFilters = [...modalFilters],
460
+ newSlots = [...modalSlots];
461
461
  newFilters.pop();
462
462
  newSlots.pop();
463
463
  rebuildModalBody(newFilters, newSlots);
@@ -109,7 +109,7 @@ export default function withSelection(WrappedComponent) {
109
109
  }
110
110
  },
111
111
  addToSelection = (item) => {
112
- const newSelection = _.clone(getSelection()); // so we get a new object, so descendants rerender
112
+ const newSelection = [...getSelection()]; // so we get a new object, so descendants rerender
113
113
  newSelection.push(item);
114
114
  setSelection(newSelection);
115
115
  },
@@ -175,7 +175,7 @@ export default function withSelection(WrappedComponent) {
175
175
  const
176
176
  currentSelectionLength = getSelection().length,
177
177
  index = getIndexOfSelectedItem(item);
178
- let newSelection = _.clone(getSelection()); // so we get a new object, so descendants rerender
178
+ let newSelection = [...getSelection()]; // so we get a new object, so descendants rerender
179
179
 
180
180
  if (currentSelectionLength) {
181
181
  const { items, max, min, } = getMaxMinSelectionIndices();
@@ -244,7 +244,7 @@ function TabBar(props) {
244
244
  const
245
245
  isCurrentTab = ix === getCurrentTab(),
246
246
  useIconTab = (isCollapsed || !tab.title),
247
- tabIcon = tab._icon ? _.clone(tab._icon) : {};
247
+ tabIcon = tab._icon ? [...tab._icon] : {};
248
248
  if (tabIcon.as && _.isString(tabIcon.as)) {
249
249
  const Type = getComponentFromType(tabIcon.as);
250
250
  if (Type) {
@@ -307,7 +307,7 @@ function TabBar(props) {
307
307
 
308
308
  const
309
309
  useIconTab = (isCollapsed || !additionalButton.text),
310
- additionalButtonIcon = _.clone(additionalButton._icon);
310
+ additionalButtonIcon = [...additionalButton._icon];
311
311
 
312
312
  if (additionalButtonIcon.as && _.isString(additionalButtonIcon.as)) {
313
313
  const Type = getComponentFromType(additionalButtonIcon.as);
@@ -384,13 +384,13 @@ function TreeComponent(props) {
384
384
  forceUpdate();
385
385
  },
386
386
  onCollapseAll = () => {
387
- const newTreeNodeData = _.clone(getTreeNodeData());
387
+ const newTreeNodeData = [...getTreeNodeData()];
388
388
  collapseNodes(newTreeNodeData);
389
389
  setTreeNodeData(newTreeNodeData);
390
390
  },
391
391
  onExpandAll = () => {
392
392
  confirm('Are you sure you want to expand the whole tree? This may take a while.', async () => {
393
- const newTreeNodeData = _.clone(getTreeNodeData());
393
+ const newTreeNodeData = [...getTreeNodeData()];
394
394
  await expandNodes(newTreeNodeData);
395
395
  setTreeNodeData(newTreeNodeData);
396
396
  });
@@ -678,7 +678,7 @@ function TreeComponent(props) {
678
678
  // NOTE: This is only for 'data', not for Repositories!
679
679
  // 'data' is essentially an Adjacency List, not a ClosureTable.
680
680
 
681
- const clonedData = _.clone(data);
681
+ const clonedData = [...data];
682
682
 
683
683
  // Reset all parent/child relationships
684
684
  _.each(clonedData, (treeNode) => {
@@ -831,7 +831,7 @@ function TreeComponent(props) {
831
831
  },
832
832
  expandPath = async (cPath, highlight = true) => {
833
833
  // First, close the whole tree.
834
- let newTreeNodeData = _.clone(getTreeNodeData());
834
+ let newTreeNodeData = [...getTreeNodeData()];
835
835
  collapseNodes(newTreeNodeData);
836
836
 
837
837
  // As it navigates down, it will expand the appropriate branches,
@@ -11,7 +11,6 @@ import {
11
11
  UI_MODE_WEB,
12
12
  CURRENT_MODE,
13
13
  } from '../../Constants/UiModes.js';
14
- import { getEmptyImage } from 'react-dnd-html5-backend';
15
14
  import UiGlobals from '../../UiGlobals.js';
16
15
  import withDraggable from '../Hoc/withDraggable.js';
17
16
  import IconButton from '../Buttons/IconButton.js';
@@ -22,6 +21,16 @@ import ChevronRight from '../Icons/ChevronRight.js';
22
21
  import ChevronDown from '../Icons/ChevronDown.js';
23
22
  import _ from 'lodash';
24
23
 
24
+ // Conditional import for web only
25
+ let getEmptyImage;
26
+ if (CURRENT_MODE === UI_MODE_WEB) {
27
+ import('react-dnd-html5-backend').then((module) => {
28
+ getEmptyImage = module.getEmptyImage;
29
+ }).catch(() => {
30
+ getEmptyImage = null;
31
+ });
32
+ }
33
+
25
34
  // This was broken out from Tree simply so we can memoize it
26
35
 
27
36
  export default function TreeNode(props) {