@teselagen/ui 0.9.7 → 0.10.2

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.
Files changed (68) hide show
  1. package/DataTable/index.d.ts +3 -3
  2. package/index.cjs.js +21025 -21144
  3. package/index.es.js +21028 -21147
  4. package/package.json +2 -1
  5. package/src/DataTable/PagingTool.js +2 -2
  6. package/src/DataTable/RenderCell.js +8 -4
  7. package/src/DataTable/index.js +1210 -224
  8. package/src/DataTable/utils/useTableEntities.js +3 -2
  9. package/src/DataTable/utils/withTableParams.js +8 -7
  10. package/src/UploadCsvWizard.js +7 -5
  11. package/src/utils/hooks/useDeepEqualMemo.js +2 -2
  12. package/src/utils/isEqualIgnoreFunctions.js +23 -0
  13. package/src/utils/pureNoFunc.js +4 -20
  14. package/utils/isEqualIgnoreFunctions.d.ts +1 -0
  15. package/DataTable/EditabelCell.d.ts +0 -7
  16. package/DataTable/ReactTable.d.ts +0 -78
  17. package/DataTable/defaultProps.d.ts +0 -43
  18. package/DataTable/utils/computePresets.d.ts +0 -1
  19. package/DataTable/utils/types/Entity.d.ts +0 -9
  20. package/DataTable/utils/types/Field.d.ts +0 -4
  21. package/DataTable/utils/types/OrderBy.d.ts +0 -11
  22. package/DataTable/utils/types/Schema.d.ts +0 -4
  23. package/DataTable/utils/useDeepEqualMemo.d.ts +0 -1
  24. package/DataTable/utils/useHotKeysWrapper.d.ts +0 -29
  25. package/DataTable/utils/useTableParams.d.ts +0 -49
  26. package/src/DataTable/Columns.jsx +0 -945
  27. package/src/DataTable/EditabelCell.js +0 -44
  28. package/src/DataTable/EditabelCell.jsx +0 -44
  29. package/src/DataTable/ReactTable.js +0 -738
  30. package/src/DataTable/RenderCell.jsx +0 -191
  31. package/src/DataTable/defaultProps.js +0 -45
  32. package/src/DataTable/utils/computePresets.js +0 -42
  33. package/src/DataTable/utils/convertSchema.ts +0 -79
  34. package/src/DataTable/utils/formatPasteData.ts +0 -34
  35. package/src/DataTable/utils/getAllRows.ts +0 -11
  36. package/src/DataTable/utils/getCellCopyText.ts +0 -7
  37. package/src/DataTable/utils/getCellInfo.ts +0 -46
  38. package/src/DataTable/utils/getFieldPathToField.ts +0 -10
  39. package/src/DataTable/utils/getIdOrCodeOrIndex.ts +0 -14
  40. package/src/DataTable/utils/getLastSelectedEntity.ts +0 -15
  41. package/src/DataTable/utils/getNewEntToSelect.ts +0 -32
  42. package/src/DataTable/utils/initializeHasuraWhereAndFilter.ts +0 -35
  43. package/src/DataTable/utils/isBottomRightCornerOfRectangle.ts +0 -27
  44. package/src/DataTable/utils/isEntityClean.ts +0 -15
  45. package/src/DataTable/utils/primarySelectedValue.ts +0 -1
  46. package/src/DataTable/utils/removeCleanRows.ts +0 -26
  47. package/src/DataTable/utils/selection.ts +0 -11
  48. package/src/DataTable/utils/types/Entity.ts +0 -13
  49. package/src/DataTable/utils/types/Field.ts +0 -4
  50. package/src/DataTable/utils/types/OrderBy.ts +0 -15
  51. package/src/DataTable/utils/types/Schema.ts +0 -5
  52. package/src/DataTable/utils/useDeepEqualMemo.js +0 -10
  53. package/src/DataTable/utils/useHotKeysWrapper.js +0 -395
  54. package/src/DataTable/utils/useTableEntities.ts +0 -60
  55. package/src/DataTable/utils/useTableParams.js +0 -361
  56. package/src/DataTable/utils/utils.ts +0 -39
  57. package/src/Timeline/TimelineEvent.tsx +0 -36
  58. package/src/Timeline/index.tsx +0 -21
  59. package/src/utils/browserUtils.ts +0 -3
  60. package/src/utils/determineBlackOrWhiteTextColor.ts +0 -11
  61. package/src/utils/getTextFromEl.ts +0 -45
  62. package/src/utils/handlerHelpers.ts +0 -32
  63. package/src/utils/hooks/index.ts +0 -1
  64. package/src/utils/hooks/useDeepEqualMemo.ts +0 -10
  65. package/src/utils/hooks/useStableReference.ts +0 -9
  66. package/src/utils/hotkeyUtils.tsx +0 -155
  67. package/src/utils/isBeingCalledExcessively.ts +0 -37
  68. package/style.css +0 -10537
@@ -29,10 +29,11 @@ export const useTableEntities = tableFormName => {
29
29
  [dispatch, tableFormName]
30
30
  );
31
31
 
32
- const { allOrderedEntities, selectedEntities } = useSelector(state => ({
32
+ const entitySelector = state => ({
33
33
  allOrderedEntities: state.form?.[tableFormName]?.values?.allOrderedEntities,
34
34
  selectedEntities:
35
35
  state.form?.[tableFormName]?.values?.reduxFormSelectedEntityIdMap
36
- }));
36
+ });
37
+ const { allOrderedEntities, selectedEntities } = useSelector(entitySelector);
37
38
  return { selectTableEntities, allOrderedEntities, selectedEntities };
38
39
  };
@@ -98,16 +98,17 @@ export const useTableParams = props => {
98
98
  }
99
99
  }
100
100
 
101
- const {
102
- reduxFormQueryParams: _reduxFormQueryParams = {},
103
- reduxFormSelectedEntityIdMap: _reduxFormSelectedEntityIdMap = {}
104
- } = useSelector(state =>
101
+ const formValueStateSelector = state =>
105
102
  formValueSelector(formName)(
106
103
  state,
107
104
  "reduxFormQueryParams",
108
105
  "reduxFormSelectedEntityIdMap"
109
- )
110
- );
106
+ );
107
+
108
+ const {
109
+ reduxFormQueryParams: _reduxFormQueryParams = {},
110
+ reduxFormSelectedEntityIdMap: _reduxFormSelectedEntityIdMap = {}
111
+ } = useSelector(formValueStateSelector);
111
112
 
112
113
  // We want to make sure we don't rerender everything unnecessary
113
114
  // with redux-forms we tend to do unnecessary renders
@@ -228,7 +229,7 @@ export const useTableParams = props => {
228
229
 
229
230
  const tableParams = useMemo(
230
231
  () => ({
231
- changeFormValue: change,
232
+ changeFormValue: (...args) => change(...args),
232
233
  selectedEntities,
233
234
  ..._tableParams,
234
235
  formName,
@@ -185,7 +185,9 @@ export const SimpleInsertDataDialog = compose(
185
185
  }, [dataTableForm, dispatch]);
186
186
 
187
187
  const _reduxFormCellValidation = useSelector(
188
- state => state.form?.[dataTableForm]?.values.reduxFormCellValidation
188
+ function _reduxFormCellValidationSelector(state) {
189
+ return state.form?.[dataTableForm]?.values.reduxFormCellValidation;
190
+ }
189
191
  );
190
192
  const reduxFormCellValidation = useDeepEqualMemo(_reduxFormCellValidation);
191
193
 
@@ -272,13 +274,13 @@ const UploadCsvWizardDialogInner = reduxForm()(({
272
274
  const {
273
275
  reduxFormEntities: _reduxFormEntities,
274
276
  reduxFormCellValidation: _reduxFormCellValidation
275
- } = useSelector(state =>
276
- formValueSelector(datatableFormName)(
277
+ } = useSelector(function dtFormNameSelector(state) {
278
+ return formValueSelector(datatableFormName)(
277
279
  state,
278
280
  "reduxFormEntities",
279
281
  "reduxFormCellValidation"
280
- )
281
- );
282
+ );
283
+ });
282
284
 
283
285
  const reduxFormEntities = useDeepEqualMemo(_reduxFormEntities);
284
286
  const reduxFormCellValidation = useDeepEqualMemo(_reduxFormCellValidation);
@@ -1,9 +1,9 @@
1
- import { isEqual } from "lodash-es";
2
1
  import { useEffect, useRef } from "react";
2
+ import { isEqualIgnoreFunctions } from "../isEqualIgnoreFunctions";
3
3
 
4
4
  export const useDeepEqualMemo = value => {
5
5
  const ref = useRef();
6
- if (!isEqual(value, ref.current)) {
6
+ if (!isEqualIgnoreFunctions(value, ref.current)) {
7
7
  ref.current = value;
8
8
  }
9
9
  return ref.current;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This HOC compares props to create a pure component that will only update
3
+ * when props are not deep equal. It will compare the string values of functions
4
+ */
5
+ import { isEqualWith, isFunction } from "lodash-es";
6
+
7
+ /**
8
+ * tgreen: This is an awful function which we should come up with a better solution for
9
+ * @param {*} o1
10
+ * @param {*} o2
11
+ */
12
+ export const isEqualIgnoreFunctions = (o1, o2) => {
13
+ const isEq = isEqualWith(o1, o2, function (val1, val2) {
14
+ if (isFunction(val1) && isFunction(val2)) {
15
+ return val1 === val2 || val1.toString() === val2.toString();
16
+ }
17
+ // tgreen: we were seeing an issue where the isEq would infinite loop on react children
18
+ // components. We decided to just ignore them (assume they are equal)
19
+ if (val1 && val1.constructor && val1.constructor.name === "FiberNode")
20
+ return true;
21
+ });
22
+ return isEq;
23
+ };
@@ -3,28 +3,12 @@
3
3
  * when props are not deep equal. It will compare the string values of functions
4
4
  */
5
5
  import { shouldUpdate } from "recompose";
6
- import { isEqualWith, isFunction } from "lodash-es";
7
-
8
- /**
9
- * tgreen: This is an awful function which we should come up with a better solution for
10
- * @param {*} o1
11
- * @param {*} o2
12
- */
13
- const isEq = (o1, o2) => {
14
- const isEq = isEqualWith(o1, o2, function (val1, val2) {
15
- if (isFunction(val1) && isFunction(val2)) {
16
- return val1 === val2 || val1.toString() === val2.toString();
17
- }
18
- // tgreen: we were seeing an issue where the isEq would infinite loop on react children
19
- // components. We decided to just ignore them (assume they are equal)
20
- if (val1 && val1.constructor && val1.constructor.name === "FiberNode")
21
- return true;
22
- });
23
- return isEq;
24
- };
6
+ import { isEqualIgnoreFunctions } from "./isEqualIgnoreFunctions";
25
7
 
26
8
  const pure = BaseComponent => {
27
- const hoc = shouldUpdate((props, nextProps) => !isEq(props, nextProps));
9
+ const hoc = shouldUpdate(
10
+ (props, nextProps) => !isEqualIgnoreFunctions(props, nextProps)
11
+ );
28
12
  return hoc(BaseComponent);
29
13
  };
30
14
 
@@ -0,0 +1 @@
1
+ export function isEqualIgnoreFunctions(o1: any, o2: any): boolean;
@@ -1,7 +0,0 @@
1
- export function EditableCell({ cancelEdit, dataTest, finishEdit, isNumeric, initialValue }: {
2
- cancelEdit: any;
3
- dataTest: any;
4
- finishEdit: any;
5
- isNumeric: any;
6
- initialValue: any;
7
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,78 +0,0 @@
1
- export function ReactTable({ addFilters, cellRenderer, change, columns, compact, contextMenu, currentParams, disabled, doNotShowEmptyRows, doNotValidateUntouchedRows, editingCellSelectAll, entities, expandedEntityIdMap, extraCompact, filters, formName, getCellHoverText, getRowClassName, handleCellClick, handleCopySelectedRows, history, insertRows, isCellEditable, isCopyable, isEntityDisabled, isLoading, isLocalCall, isSelectionARectangle, isSimple, isSingleSelect, maxHeight, moveColumnPersist, mustClickCheckboxToSelect, noDeselectAll, noRowsFoundMessage, noSelect, noUserSelect, noVirtual, numRows, onDeselect, onDoubleClick, onlyShowRowsWErrors, onMultiRowSelect, onRowClick, onRowSelect, onSingleRowSelect, order, primarySelectedCellId, ReactTableProps, recordIdToIsVisibleMap, reduxFormCellValidation, reduxFormEditingCell, reduxFormSelectedEntityIdMap, refocusTable, removeSingleFilter, resizePersist, schema, selectedCells, setColumns, setExpandedEntityIdMap, setNewParams, setOrder, setRecordIdToIsVisibleMap, setSelectedCells, shouldShowSubComponent, startCellEdit, style, SubComponent, tableConfig, tableRef, updateEntitiesHelper, updateValidation, withCheckboxes, withExpandAndCollapseAllButton, withFilter, withSort }: {
2
- addFilters: any;
3
- cellRenderer: any;
4
- change: any;
5
- columns: any;
6
- compact: any;
7
- contextMenu: any;
8
- currentParams: any;
9
- disabled: any;
10
- doNotShowEmptyRows: any;
11
- doNotValidateUntouchedRows: any;
12
- editingCellSelectAll: any;
13
- entities: any;
14
- expandedEntityIdMap: any;
15
- extraCompact: any;
16
- filters: any;
17
- formName: any;
18
- getCellHoverText: any;
19
- getRowClassName: any;
20
- handleCellClick: any;
21
- handleCopySelectedRows: any;
22
- history: any;
23
- insertRows: any;
24
- isCellEditable: any;
25
- isCopyable: any;
26
- isEntityDisabled: any;
27
- isLoading: any;
28
- isLocalCall: any;
29
- isSelectionARectangle: any;
30
- isSimple: any;
31
- isSingleSelect: any;
32
- maxHeight: any;
33
- moveColumnPersist: any;
34
- mustClickCheckboxToSelect: any;
35
- noDeselectAll: any;
36
- noRowsFoundMessage: any;
37
- noSelect: any;
38
- noUserSelect: any;
39
- noVirtual: any;
40
- numRows: any;
41
- onDeselect: any;
42
- onDoubleClick: any;
43
- onlyShowRowsWErrors: any;
44
- onMultiRowSelect: any;
45
- onRowClick: any;
46
- onRowSelect: any;
47
- onSingleRowSelect: any;
48
- order: any;
49
- primarySelectedCellId: any;
50
- ReactTableProps: any;
51
- recordIdToIsVisibleMap: any;
52
- reduxFormCellValidation: any;
53
- reduxFormEditingCell: any;
54
- reduxFormSelectedEntityIdMap: any;
55
- refocusTable: any;
56
- removeSingleFilter: any;
57
- resizePersist: any;
58
- schema: any;
59
- selectedCells: any;
60
- setColumns: any;
61
- setExpandedEntityIdMap: any;
62
- setNewParams: any;
63
- setOrder: any;
64
- setRecordIdToIsVisibleMap: any;
65
- setSelectedCells: any;
66
- shouldShowSubComponent: any;
67
- startCellEdit: any;
68
- style: any;
69
- SubComponent: any;
70
- tableConfig: any;
71
- tableRef: any;
72
- updateEntitiesHelper: any;
73
- updateValidation: any;
74
- withCheckboxes: any;
75
- withExpandAndCollapseAllButton: any;
76
- withFilter: any;
77
- withSort: any;
78
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,43 +0,0 @@
1
- import { noop } from 'lodash-es';
2
- declare namespace _default {
3
- export { noop as addFilters };
4
- export let className: string;
5
- export { noop as clearFilters };
6
- export { noop as contextMenu };
7
- export let disabled: boolean;
8
- export let entities: never[];
9
- export let extraClasses: string;
10
- export let filters: never[];
11
- export let isCopyable: boolean;
12
- export { noop as isEntityDisabled };
13
- export let isLoading: boolean;
14
- export let isSimple: boolean;
15
- export let isSingleSelect: boolean;
16
- export let maxHeight: number;
17
- export let noHeader: boolean;
18
- export let noSelect: boolean;
19
- export let noUserSelect: boolean;
20
- export { noop as onDeselect };
21
- export { noop as onMultiRowSelect };
22
- export { noop as onRowClick };
23
- export { noop as onRowSelect };
24
- export { noop as onSingleRowSelect };
25
- export let page: number;
26
- export let pageSize: number;
27
- export let reduxFormExpandedEntityIdMap: {};
28
- export let reduxFormSearchInput: string;
29
- export let reduxFormSelectedEntityIdMap: {};
30
- export { noop as removeSingleFilter };
31
- export let resized: never[];
32
- export { noop as resizePersist };
33
- export { noop as setFilter };
34
- export { noop as setOrder };
35
- export { noop as setPage };
36
- export { noop as setPageSize };
37
- export { noop as setSearchTerm };
38
- export let showCount: boolean;
39
- export let style: {};
40
- export let withCheckboxes: boolean;
41
- export let withSort: boolean;
42
- }
43
- export default _default;
@@ -1 +0,0 @@
1
- export default function computePresets(props?: {}): import('lodash').Dictionary<any>;
@@ -1,9 +0,0 @@
1
- type SharedFields = {
2
- _isClean?: boolean;
3
- };
4
- export type Entity = ({
5
- id?: string | number;
6
- } | {
7
- code?: string;
8
- }) & SharedFields;
9
- export {};
@@ -1,4 +0,0 @@
1
- export type Field = {
2
- path: string;
3
- type: "genericSelect" | string;
4
- };
@@ -1,11 +0,0 @@
1
- type OrderByClause<T = {
2
- id: string;
3
- }> = {
4
- path?: string;
5
- direction?: "asc" | "desc";
6
- type?: string;
7
- sortFn?: ((record: T) => unknown) | string | Array<((record: T) => unknown) | string>;
8
- getValueToFilterOn?: (record: T) => unknown;
9
- };
10
- export type OrderBy = OrderByClause | OrderByClause[] | Record<string, "asc" | "desc">;
11
- export {};
@@ -1,4 +0,0 @@
1
- import { Field } from './Field';
2
- export type Schema = {
3
- fields: Field[];
4
- };
@@ -1 +0,0 @@
1
- export function useDeepEqualMemo(value: any): undefined;
@@ -1,29 +0,0 @@
1
- export function useHotKeysWrapper({ change, entities, entitiesUndoRedoStack, formatAndValidateEntities, handleCopySelectedRows, isCellEditable, isEntityDisabled, isSingleSelect, noDeselectAll, noSelect, onDeselect, onMultiRowSelect, onRowSelect, onSingleRowSelect, primarySelectedCellId, reduxFormCellValidation, reduxFormSelectedEntityIdMap, schema, selectedCells, setEntitiesUndoRedoStack, setNoVirtual, setSelectedCells, startCellEdit, tableRef, updateEntitiesHelper, updateValidation, waitUntilAllRowsAreRendered }: {
2
- change: any;
3
- entities: any;
4
- entitiesUndoRedoStack: any;
5
- formatAndValidateEntities: any;
6
- handleCopySelectedRows: any;
7
- isCellEditable: any;
8
- isEntityDisabled: any;
9
- isSingleSelect: any;
10
- noDeselectAll: any;
11
- noSelect: any;
12
- onDeselect: any;
13
- onMultiRowSelect: any;
14
- onRowSelect: any;
15
- onSingleRowSelect: any;
16
- primarySelectedCellId: any;
17
- reduxFormCellValidation: any;
18
- reduxFormSelectedEntityIdMap: any;
19
- schema: any;
20
- selectedCells: any;
21
- setEntitiesUndoRedoStack: any;
22
- setNoVirtual: any;
23
- setSelectedCells: any;
24
- startCellEdit: any;
25
- tableRef: any;
26
- updateEntitiesHelper: any;
27
- updateValidation: any;
28
- waitUntilAllRowsAreRendered: any;
29
- }): import('../../../../../node_modules/@blueprintjs/core').UseHotkeysReturnValue;
@@ -1,49 +0,0 @@
1
- /**
2
- * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
3
- *
4
- * @export
5
- *
6
- * @param {compOrOpts} compOrOpts
7
- * @typedef {object} compOrOpts
8
- * @property {*string} formName - required unique identifier for the table
9
- * @property {Object | Function} schema - The data table schema or a function returning it. The function wll be called with props as the argument.
10
- * @property {boolean} urlConnected - whether the table should connect to/update the URL
11
- * @property {boolean} withSelectedEntities - whether or not to pass the selected entities
12
- * @property {boolean} isCodeModel - whether the model is keyed by code instead of id in the db
13
- * @property {object} defaults - tableParam defaults such as pageSize, filter, etc
14
- * @property {boolean} noOrderError - won't console an error if an order is not found on schema
15
- */
16
- export default function useTableParams(props: any): any;
17
- /**
18
- * Note all these options can be passed at Design Time or at Runtime (like reduxForm())
19
- */
20
- export type compOrOpts = {
21
- /**
22
- * } formName - required unique identifier for the table
23
- */
24
- string: any;
25
- /**
26
- * - The data table schema or a function returning it. The function wll be called with props as the argument.
27
- */
28
- schema: Object | Function;
29
- /**
30
- * - whether the table should connect to/update the URL
31
- */
32
- urlConnected: boolean;
33
- /**
34
- * - whether or not to pass the selected entities
35
- */
36
- withSelectedEntities: boolean;
37
- /**
38
- * - whether the model is keyed by code instead of id in the db
39
- */
40
- isCodeModel: boolean;
41
- /**
42
- * - tableParam defaults such as pageSize, filter, etc
43
- */
44
- defaults: object;
45
- /**
46
- * - won't console an error if an order is not found on schema
47
- */
48
- noOrderError: boolean;
49
- };