@teselagen/ui 0.6.1-beta.1 → 0.6.1

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 (44) hide show
  1. package/DataTable/ColumnFilterMenu.d.ts +1 -2
  2. package/DataTable/EditabelCell.d.ts +5 -2
  3. package/DataTable/utils/index.d.ts +2 -4
  4. package/DataTable/utils/removeCleanRows.d.ts +1 -1
  5. package/TgSelect/index.d.ts +1 -1
  6. package/index.cjs.js +2 -0
  7. package/index.es.js +2 -0
  8. package/package.json +1 -1
  9. package/src/DataTable/ColumnFilterMenu.js +21 -23
  10. package/src/DataTable/EditabelCell.js +18 -7
  11. package/src/DataTable/utils/index.js +3 -7
  12. package/src/DataTable/utils/removeCleanRows.js +3 -3
  13. package/src/TgSelect/index.js +1 -0
  14. package/DataTable/Columns.d.ts +0 -51
  15. package/DataTable/EditableCell.d.ts +0 -7
  16. package/DataTable/RenderCell.d.ts +0 -18
  17. package/DataTable/ThComponent.d.ts +0 -9
  18. package/DataTable/utils/handleCopyTable.d.ts +0 -1
  19. package/DataTable/utils/primarySelectedValue.d.ts +0 -1
  20. package/DataTable/utils/useDeepEqualMemo.d.ts +0 -1
  21. package/DataTable/utils/useTableEntities.d.ts +0 -5
  22. package/DataTable/utils/useTableParams.d.ts +0 -49
  23. package/FormComponents/AbstractField.d.ts +0 -1
  24. package/src/DataTable/Columns.js +0 -948
  25. package/src/DataTable/Columns.jsx +0 -945
  26. package/src/DataTable/EditabelCell.jsx +0 -44
  27. package/src/DataTable/EditableCell.js +0 -44
  28. package/src/DataTable/RenderCell.js +0 -191
  29. package/src/DataTable/RenderCell.jsx +0 -191
  30. package/src/DataTable/ThComponent.js +0 -44
  31. package/src/DataTable/utils/handleCopyTable.js +0 -16
  32. package/src/DataTable/utils/primarySelectedValue.js +0 -1
  33. package/src/DataTable/utils/useDeepEqualMemo.js +0 -10
  34. package/src/DataTable/utils/useTableEntities.js +0 -38
  35. package/src/DataTable/utils/useTableParams.js +0 -362
  36. package/src/FormComponents/AbstractField.js +0 -388
  37. package/src/utils/hooks/index.js +0 -1
  38. package/src/utils/hooks/useDeepEqualMemo.js +0 -10
  39. package/src/utils/hooks/useStableReference.js +0 -9
  40. package/src/utils/useTraceUpdate.js +0 -19
  41. package/utils/hooks/index.d.ts +0 -1
  42. package/utils/hooks/useDeepEqualMemo.d.ts +0 -1
  43. package/utils/hooks/useStableReference.d.ts +0 -1
  44. package/utils/useTraceUpdate.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- export function ColumnFilterMenu({ addFilters, compact, currentFilter, currentParams, dataType, extraCompact, filterActiveForColumn, FilterMenu, filterOn, removeSingleFilter, schemaForField, setNewParams, formName }: {
1
+ export function ColumnFilterMenu({ addFilters, compact, currentFilter, currentParams, dataType, extraCompact, filterActiveForColumn, FilterMenu, filterOn, removeSingleFilter, schemaForField, setNewParams }: {
2
2
  addFilters: any;
3
3
  compact: any;
4
4
  currentFilter: any;
@@ -11,5 +11,4 @@ export function ColumnFilterMenu({ addFilters, compact, currentFilter, currentPa
11
11
  removeSingleFilter: any;
12
12
  schemaForField: any;
13
13
  setNewParams: any;
14
- formName: any;
15
14
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,10 @@
1
- export function EditableCell({ cancelEdit, dataTest, finishEdit, isNumeric, initialValue }: {
1
+ export function EditableCell({ cancelEdit, dataTest, finishEdit, initialValue, isEditableCellInitialValue, isNumeric, shouldSelectAll, stopSelectAll }: {
2
2
  cancelEdit: any;
3
3
  dataTest: any;
4
4
  finishEdit: any;
5
- isNumeric: any;
6
5
  initialValue: any;
6
+ isEditableCellInitialValue: any;
7
+ isNumeric: any;
8
+ shouldSelectAll: any;
9
+ stopSelectAll: any;
7
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
+ import { default as computePresets } from './computePresets';
1
2
  import { defaultParsePaste, getEntityIdToEntity, getFieldPathToIndex, getNumberStrAtEnd, stripNumberAtEnd } from './utils';
2
3
  import { formatPasteData } from './formatPasteData';
3
4
  import { getAllRows } from './getAllRows';
@@ -13,11 +14,8 @@ import { getSelectedRowsFromEntities } from './selection';
13
14
  import { handleCopyColumn } from './handleCopyColumn';
14
15
  import { handleCopyHelper } from './handleCopyHelper';
15
16
  import { handleCopyRows } from './handleCopyRows';
16
- import { handleCopyTable } from './handleCopyTable';
17
17
  import { isBottomRightCornerOfRectangle } from './isBottomRightCornerOfRectangle';
18
18
  import { isEntityClean } from './isEntityClean';
19
- import { PRIMARY_SELECTED_VAL } from './primarySelectedValue';
20
19
  import { removeCleanRows } from './removeCleanRows';
21
- import { useTableEntities } from './useTableEntities';
22
20
 
23
- export { defaultParsePaste, formatPasteData, getAllRows, getCellCopyText, getCellInfo, getEntityIdToEntity, getFieldPathToIndex, getFieldPathToField, getIdOrCodeOrIndex, getLastSelectedEntity, getNewEntToSelect, getNumberStrAtEnd, getRecordsFromIdMap, getRowCopyText, getSelectedRowsFromEntities, handleCopyColumn, handleCopyHelper, handleCopyRows, handleCopyTable, isBottomRightCornerOfRectangle, isEntityClean, PRIMARY_SELECTED_VAL, removeCleanRows, stripNumberAtEnd, useTableEntities };
21
+ export { computePresets, defaultParsePaste, formatPasteData, getAllRows, getCellCopyText, getCellInfo, getEntityIdToEntity, getFieldPathToIndex, getFieldPathToField, getIdOrCodeOrIndex, getLastSelectedEntity, getNewEntToSelect, getNumberStrAtEnd, getRecordsFromIdMap, getRowCopyText, getSelectedRowsFromEntities, handleCopyColumn, handleCopyHelper, handleCopyRows, isBottomRightCornerOfRectangle, isEntityClean, removeCleanRows, stripNumberAtEnd };
@@ -1,4 +1,4 @@
1
- export function removeCleanRows(entities: any, cellValidation: any): {
1
+ export function removeCleanRows(reduxFormEntities: any, reduxFormCellValidation: any): {
2
2
  entsToUse: any;
3
3
  validationToUse: {};
4
4
  };
@@ -2,7 +2,7 @@ export function createNewOption(newValString: any): {
2
2
  userCreated: boolean;
3
3
  label: any;
4
4
  value: any;
5
- };
5
+ } | undefined;
6
6
  export function simplesearch(needle: any, haystack: any): boolean;
7
7
  declare function _default(props: any): import("react/jsx-runtime").JSX.Element;
8
8
  export default _default;
package/index.cjs.js CHANGED
@@ -37330,6 +37330,8 @@ const renderCreateNewOption$1 = /* @__PURE__ */ __name((query, active3, handleCl
37330
37330
  }
37331
37331
  ), "renderCreateNewOption$1");
37332
37332
  function createNewOption(newValString) {
37333
+ if (!newValString)
37334
+ return;
37333
37335
  return {
37334
37336
  userCreated: true,
37335
37337
  label: newValString,
package/index.es.js CHANGED
@@ -37312,6 +37312,8 @@ const renderCreateNewOption$1 = /* @__PURE__ */ __name((query, active3, handleCl
37312
37312
  }
37313
37313
  ), "renderCreateNewOption$1");
37314
37314
  function createNewOption(newValString) {
37315
+ if (!newValString)
37316
+ return;
37315
37317
  return {
37316
37318
  userCreated: true,
37317
37319
  label: newValString,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.6.1-beta.1",
3
+ "version": "0.6.1",
4
4
  "main": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -14,49 +14,47 @@ export const ColumnFilterMenu = ({
14
14
  filterOn,
15
15
  removeSingleFilter,
16
16
  schemaForField,
17
- setNewParams,
18
- formName
17
+ setNewParams
19
18
  }) => {
20
19
  const [columnFilterMenuOpen, setColumnFilterMenuOpen] = useState(false);
21
20
  return (
22
21
  <Popover
23
22
  position="bottom"
24
- onClose={() => setColumnFilterMenuOpen(false)}
23
+ onClose={() => {
24
+ setColumnFilterMenuOpen(false);
25
+ }}
25
26
  isOpen={columnFilterMenuOpen}
26
27
  modifiers={{
27
28
  preventOverflow: { enabled: true },
28
29
  hide: { enabled: false },
29
30
  flip: { enabled: false }
30
31
  }}
31
- content={
32
- <FilterMenu
33
- formName={formName}
34
- addFilters={addFilters}
35
- compact={compact}
36
- currentFilter={currentFilter}
37
- currentParams={currentParams}
38
- dataType={dataType}
39
- filterOn={filterOn}
40
- removeSingleFilter={removeSingleFilter}
41
- schemaForField={schemaForField}
42
- setNewParams={setNewParams}
43
- togglePopover={() => setColumnFilterMenuOpen(false)}
44
- />
45
- }
46
32
  >
47
33
  <Icon
48
34
  style={{ marginLeft: 5 }}
49
35
  icon="filter"
50
- size={extraCompact ? 14 : undefined}
51
- onClick={e => {
52
- e.preventDefault();
53
- e.stopPropagation();
54
- setColumnFilterMenuOpen(prev => !prev);
36
+ iconSize={extraCompact ? 14 : undefined}
37
+ onClick={() => {
38
+ setColumnFilterMenuOpen(!columnFilterMenuOpen);
55
39
  }}
56
40
  className={classNames("tg-filter-menu-button", {
57
41
  "tg-active-filter": !!filterActiveForColumn
58
42
  })}
59
43
  />
44
+ <FilterMenu
45
+ addFilters={addFilters}
46
+ compact={compact}
47
+ currentFilter={currentFilter}
48
+ currentParams={currentParams}
49
+ dataType={dataType}
50
+ filterOn={filterOn}
51
+ removeSingleFilter={removeSingleFilter}
52
+ schemaForField={schemaForField}
53
+ setNewParams={setNewParams}
54
+ togglePopover={() => {
55
+ setColumnFilterMenuOpen(false);
56
+ }}
57
+ />
60
58
  </Popover>
61
59
  );
62
60
  };
@@ -1,20 +1,30 @@
1
- import React, { useEffect, useRef } from "react";
1
+ import React, { useEffect, useRef, useState } from "react";
2
2
 
3
3
  export const EditableCell = ({
4
- value,
5
- setValue,
6
4
  cancelEdit,
7
5
  dataTest,
8
6
  finishEdit,
9
- isNumeric
7
+ initialValue,
8
+ isEditableCellInitialValue,
9
+ isNumeric,
10
+ shouldSelectAll,
11
+ stopSelectAll
10
12
  }) => {
13
+ const [value, setValue] = useState(initialValue);
11
14
  const inputRef = useRef(null);
12
15
 
13
16
  useEffect(() => {
14
17
  if (inputRef.current) {
15
18
  inputRef.current.focus();
19
+ if (isEditableCellInitialValue && !isNumeric) {
20
+ inputRef.current.selectionStart = inputRef.current.value.length;
21
+ inputRef.current.selectionEnd = inputRef.current.value.length;
22
+ } else if (shouldSelectAll) {
23
+ inputRef.current.select();
24
+ stopSelectAll();
25
+ }
16
26
  }
17
- }, [isNumeric]);
27
+ }, [isEditableCellInitialValue, isNumeric, shouldSelectAll, stopSelectAll]);
18
28
 
19
29
  return (
20
30
  <input
@@ -28,10 +38,11 @@ export const EditableCell = ({
28
38
  {...dataTest}
29
39
  autoFocus
30
40
  onKeyDown={e => {
31
- e.stopPropagation();
32
41
  if (e.key === "Enter") {
33
- e.target.blur();
42
+ finishEdit(value);
43
+ e.stopPropagation();
34
44
  } else if (e.key === "Escape") {
45
+ e.stopPropagation();
35
46
  cancelEdit();
36
47
  }
37
48
  }}
@@ -2,6 +2,7 @@ import { isEntityClean } from "./isEntityClean";
2
2
  import { getSelectedRowsFromEntities } from "./selection";
3
3
  import { removeCleanRows } from "./removeCleanRows";
4
4
  import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
5
+ import computePresets from "./computePresets";
5
6
  import { getRecordsFromIdMap } from "./withSelectedEntities";
6
7
  import { formatPasteData } from "./formatPasteData";
7
8
  import { getFieldPathToField } from "./getFieldPathToField";
@@ -22,11 +23,9 @@ import { handleCopyHelper } from "./handleCopyHelper";
22
23
  import { handleCopyRows } from "./handleCopyRows";
23
24
  import { handleCopyColumn } from "./handleCopyColumn";
24
25
  import { isBottomRightCornerOfRectangle } from "./isBottomRightCornerOfRectangle";
25
- import { handleCopyTable } from "./handleCopyTable";
26
- import { PRIMARY_SELECTED_VAL } from "./primarySelectedValue";
27
- import { useTableEntities } from "./useTableEntities";
28
26
 
29
27
  export {
28
+ computePresets,
30
29
  defaultParsePaste,
31
30
  formatPasteData,
32
31
  getAllRows,
@@ -45,11 +44,8 @@ export {
45
44
  handleCopyColumn,
46
45
  handleCopyHelper,
47
46
  handleCopyRows,
48
- handleCopyTable,
49
47
  isBottomRightCornerOfRectangle,
50
48
  isEntityClean,
51
- PRIMARY_SELECTED_VAL,
52
49
  removeCleanRows,
53
- stripNumberAtEnd,
54
- useTableEntities
50
+ stripNumberAtEnd
55
51
  };
@@ -1,9 +1,9 @@
1
1
  import { isEntityClean } from "./isEntityClean";
2
2
  import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
3
3
 
4
- export const removeCleanRows = (entities, cellValidation) => {
4
+ export const removeCleanRows = (reduxFormEntities, reduxFormCellValidation) => {
5
5
  const toFilterOut = {};
6
- const entsToUse = (entities || []).filter(e => {
6
+ const entsToUse = (reduxFormEntities || []).filter(e => {
7
7
  if (!(e._isClean || isEntityClean(e))) return true;
8
8
  else {
9
9
  toFilterOut[getIdOrCodeOrIndex(e)] = true;
@@ -12,7 +12,7 @@ export const removeCleanRows = (entities, cellValidation) => {
12
12
  });
13
13
 
14
14
  const validationToUse = {};
15
- Object.entries(cellValidation || {}).forEach(([k, v]) => {
15
+ Object.entries(reduxFormCellValidation || {}).forEach(([k, v]) => {
16
16
  const [rowId] = k.split(":");
17
17
  if (!toFilterOut[rowId]) {
18
18
  validationToUse[k] = v;
@@ -469,6 +469,7 @@ export const renderCreateNewOption = (query, active, handleClick) => (
469
469
  );
470
470
 
471
471
  export function createNewOption(newValString) {
472
+ if (!newValString) return;
472
473
  return {
473
474
  userCreated: true,
474
475
  label: newValString,
@@ -1,51 +0,0 @@
1
- export function useColumns({ addFilters, cellRenderer, columns, currentParams, compact, editingCell, editingCellSelectAll, entities, expandedEntityIdMap, extraCompact, filters, formName, getCellHoverText, isCellEditable, isEntityDisabled, isLocalCall, isSimple, isSingleSelect, isSelectionARectangle, noDeselectAll, noSelect, noUserSelect, onDeselect, onMultiRowSelect, onRowClick, onRowSelect, onSingleRowSelect, order, primarySelectedCellId, reduxFormCellValidation, reduxFormSelectedEntityIdMap, refocusTable, removeSingleFilter, schema, selectedCells, setExpandedEntityIdMap, setNewParams, setOrder, setSelectedCells, shouldShowSubComponent, startCellEdit, SubComponent, tableRef, updateEntitiesHelper, updateValidation, withCheckboxes, withExpandAndCollapseAllButton, withFilter: _withFilter, withSort }: {
2
- addFilters: any;
3
- cellRenderer: any;
4
- columns: any;
5
- currentParams: any;
6
- compact: any;
7
- editingCell: any;
8
- editingCellSelectAll: any;
9
- entities: any;
10
- expandedEntityIdMap: any;
11
- extraCompact: any;
12
- filters: any;
13
- formName: any;
14
- getCellHoverText: any;
15
- isCellEditable: any;
16
- isEntityDisabled: any;
17
- isLocalCall: any;
18
- isSimple: any;
19
- isSingleSelect: any;
20
- isSelectionARectangle: any;
21
- noDeselectAll: any;
22
- noSelect: any;
23
- noUserSelect: any;
24
- onDeselect: any;
25
- onMultiRowSelect: any;
26
- onRowClick: any;
27
- onRowSelect: any;
28
- onSingleRowSelect: any;
29
- order: any;
30
- primarySelectedCellId: any;
31
- reduxFormCellValidation: any;
32
- reduxFormSelectedEntityIdMap: any;
33
- refocusTable: any;
34
- removeSingleFilter?: ((...args: any[]) => void) | undefined;
35
- schema: any;
36
- selectedCells: any;
37
- setExpandedEntityIdMap: any;
38
- setNewParams: any;
39
- setOrder?: ((...args: any[]) => void) | undefined;
40
- setSelectedCells: any;
41
- shouldShowSubComponent: any;
42
- startCellEdit: any;
43
- SubComponent: any;
44
- tableRef: any;
45
- updateEntitiesHelper: any;
46
- updateValidation: any;
47
- withCheckboxes: any;
48
- withExpandAndCollapseAllButton: any;
49
- withFilter: any;
50
- withSort?: boolean | undefined;
51
- }): any;
@@ -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,18 +0,0 @@
1
- export function RenderCell({ oldFunc, getCopyTextForCell, column, isCellEditable, isEntityDisabled, finishCellEdit, formName, noEllipsis, cancelCellEdit, getCellHoverText, selectedCells, isSelectionARectangle, startCellEdit, tableRef, onDragEnd, args }: {
2
- oldFunc: any;
3
- getCopyTextForCell: any;
4
- column: any;
5
- isCellEditable: any;
6
- isEntityDisabled: any;
7
- finishCellEdit: any;
8
- formName: any;
9
- noEllipsis: any;
10
- cancelCellEdit: any;
11
- getCellHoverText: any;
12
- selectedCells: any;
13
- isSelectionARectangle: any;
14
- startCellEdit: any;
15
- tableRef: any;
16
- onDragEnd: any;
17
- args: any;
18
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +0,0 @@
1
- export function ThComponent({ toggleSort, immovable, className, children, style, columnindex, ...rest }: {
2
- [x: string]: any;
3
- toggleSort: any;
4
- immovable: any;
5
- className: any;
6
- children: any;
7
- style: any;
8
- columnindex: any;
9
- }): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export function handleCopyTable(e: any, opts: any): void;
@@ -1 +0,0 @@
1
- export const PRIMARY_SELECTED_VAL: "main_cell";
@@ -1 +0,0 @@
1
- export function useDeepEqualMemo(value: any): undefined;
@@ -1,5 +0,0 @@
1
- export function useTableEntities(tableFormName: any): {
2
- selectTableEntities: (entities?: any[]) => void;
3
- allOrderedEntities: any;
4
- selectedEntities: any;
5
- };
@@ -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
- };
@@ -1 +0,0 @@
1
- export function withAbstractWrapper(ComponentToWrap: any, opts?: {}): (props: any) => import("react/jsx-runtime").JSX.Element;