@teselagen/ui 0.8.1 → 0.8.3

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.
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,43 @@
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;
@@ -0,0 +1 @@
1
+ export default function computePresets(props?: {}): import('lodash').Dictionary<any>;
@@ -0,0 +1 @@
1
+ export function useDeepEqualMemo(value: any): undefined;
@@ -0,0 +1,49 @@
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
+ };
package/index.cjs.js CHANGED
@@ -51115,10 +51115,10 @@ const RenderCell = /* @__PURE__ */ __name(({
51115
51115
  return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormEditingCell;
51116
51116
  }
51117
51117
  );
51118
- const initialValue = reactRedux.useSelector(
51118
+ const shouldEditableCellInputBeCleared = reactRedux.useSelector(
51119
51119
  (state) => {
51120
51120
  var _a2, _b, _c;
51121
- return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormInitialValue;
51121
+ return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.shouldEditableCellInputBeCleared;
51122
51122
  }
51123
51123
  );
51124
51124
  const [row] = args;
@@ -51171,7 +51171,7 @@ const RenderCell = /* @__PURE__ */ __name(({
51171
51171
  dataTest,
51172
51172
  cancelEdit: cancelCellEdit,
51173
51173
  isNumeric: column.type === "number",
51174
- initialValue: initialValue || text2,
51174
+ initialValue: shouldEditableCellInputBeCleared ? void 0 : text2,
51175
51175
  finishEdit: /* @__PURE__ */ __name((newVal) => {
51176
51176
  finishCellEdit(cellId, newVal);
51177
51177
  }, "finishEdit")
@@ -57034,8 +57034,12 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
57034
57034
  }
57035
57035
  }, [selectedCells]);
57036
57036
  const startCellEdit = React.useCallback(
57037
- (cellId, initialValue) => {
57038
- change("reduxFormInitialValue", initialValue);
57037
+ (cellId, shouldClear) => {
57038
+ if (shouldClear) {
57039
+ change("shouldEditableCellInputBeCleared", true);
57040
+ } else {
57041
+ change("shouldEditableCellInputBeCleared", false);
57042
+ }
57039
57043
  change("reduxFormEditingCell", (prev) => {
57040
57044
  if (prev === cellId) return cellId;
57041
57045
  setSelectedCells((prev2) => {
@@ -58696,12 +58700,30 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58696
58700
  const rowDisabled = isEntityDisabled(entity);
58697
58701
  const isNum = (_g = e.code) == null ? void 0 : _g.startsWith("Digit");
58698
58702
  const isLetter = (_h = e.code) == null ? void 0 : _h.startsWith("Key");
58699
- if (!isNum && !isLetter) {
58703
+ const allowedSpecialChars = [
58704
+ "Minus",
58705
+ "Equal",
58706
+ "Backquote",
58707
+ "BracketLeft",
58708
+ "BracketRight",
58709
+ "Backslash",
58710
+ "IntlBackslash",
58711
+ "Semicolon",
58712
+ "Quote",
58713
+ "Comma",
58714
+ "Period",
58715
+ "Slash",
58716
+ "IntlRo",
58717
+ "IntlYen",
58718
+ "Space"
58719
+ ];
58720
+ const isSpecialChar = allowedSpecialChars.includes(e.code);
58721
+ if (!isNum && !isLetter && !isSpecialChar) {
58700
58722
  return;
58701
58723
  }
58702
58724
  if (rowDisabled) return;
58703
58725
  e.stopPropagation();
58704
- startCellEdit(primarySelectedCellId, e.key);
58726
+ startCellEdit(primarySelectedCellId, true);
58705
58727
  }, "onKeyDown")
58706
58728
  }),
58707
58729
  isCellEditable && entities.length > 50 && // test for this!!
package/index.es.js CHANGED
@@ -51097,10 +51097,10 @@ const RenderCell = /* @__PURE__ */ __name(({
51097
51097
  return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormEditingCell;
51098
51098
  }
51099
51099
  );
51100
- const initialValue = useSelector(
51100
+ const shouldEditableCellInputBeCleared = useSelector(
51101
51101
  (state) => {
51102
51102
  var _a2, _b, _c;
51103
- return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormInitialValue;
51103
+ return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.shouldEditableCellInputBeCleared;
51104
51104
  }
51105
51105
  );
51106
51106
  const [row] = args;
@@ -51153,7 +51153,7 @@ const RenderCell = /* @__PURE__ */ __name(({
51153
51153
  dataTest,
51154
51154
  cancelEdit: cancelCellEdit,
51155
51155
  isNumeric: column.type === "number",
51156
- initialValue: initialValue || text2,
51156
+ initialValue: shouldEditableCellInputBeCleared ? void 0 : text2,
51157
51157
  finishEdit: /* @__PURE__ */ __name((newVal) => {
51158
51158
  finishCellEdit(cellId, newVal);
51159
51159
  }, "finishEdit")
@@ -57016,8 +57016,12 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
57016
57016
  }
57017
57017
  }, [selectedCells]);
57018
57018
  const startCellEdit = useCallback(
57019
- (cellId, initialValue) => {
57020
- change$1("reduxFormInitialValue", initialValue);
57019
+ (cellId, shouldClear) => {
57020
+ if (shouldClear) {
57021
+ change$1("shouldEditableCellInputBeCleared", true);
57022
+ } else {
57023
+ change$1("shouldEditableCellInputBeCleared", false);
57024
+ }
57021
57025
  change$1("reduxFormEditingCell", (prev) => {
57022
57026
  if (prev === cellId) return cellId;
57023
57027
  setSelectedCells((prev2) => {
@@ -58678,12 +58682,30 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58678
58682
  const rowDisabled = isEntityDisabled(entity);
58679
58683
  const isNum = (_g = e.code) == null ? void 0 : _g.startsWith("Digit");
58680
58684
  const isLetter = (_h = e.code) == null ? void 0 : _h.startsWith("Key");
58681
- if (!isNum && !isLetter) {
58685
+ const allowedSpecialChars = [
58686
+ "Minus",
58687
+ "Equal",
58688
+ "Backquote",
58689
+ "BracketLeft",
58690
+ "BracketRight",
58691
+ "Backslash",
58692
+ "IntlBackslash",
58693
+ "Semicolon",
58694
+ "Quote",
58695
+ "Comma",
58696
+ "Period",
58697
+ "Slash",
58698
+ "IntlRo",
58699
+ "IntlYen",
58700
+ "Space"
58701
+ ];
58702
+ const isSpecialChar = allowedSpecialChars.includes(e.code);
58703
+ if (!isNum && !isLetter && !isSpecialChar) {
58682
58704
  return;
58683
58705
  }
58684
58706
  if (rowDisabled) return;
58685
58707
  e.stopPropagation();
58686
- startCellEdit(primarySelectedCellId, e.key);
58708
+ startCellEdit(primarySelectedCellId, true);
58687
58709
  }, "onKeyDown")
58688
58710
  }),
58689
58711
  isCellEditable && entities.length > 50 && // test for this!!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "main": "./src/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,6 +17,7 @@
17
17
  "@dnd-kit/core": "^6.1.0",
18
18
  "@dnd-kit/modifiers": "^7.0.0",
19
19
  "@dnd-kit/sortable": "^8.0.0",
20
+ "@teselagen/react-table": "6.10.16",
20
21
  "classnames": "^2.3.2",
21
22
  "color": "^3.2.1",
22
23
  "copy-to-clipboard": "^3.3.1",