@teselagen/ui 0.7.33-beta.6 → 0.7.33-beta.7

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
@@ -2951,7 +2951,18 @@ let clearMe;
2951
2951
  document.querySelectorAll(`.${id}`).forEach((elem) => {
2952
2952
  elem.classList.remove(id);
2953
2953
  });
2954
- el2.classList.add(id);
2954
+ let targetEl = el2;
2955
+ if (targetEl.disabled || targetEl.getAttribute("disabled") !== null) {
2956
+ const parent2 = targetEl.parentElement;
2957
+ if (parent2) {
2958
+ parent2.classList.add(id);
2959
+ targetEl = parent2;
2960
+ } else {
2961
+ el2.classList.add(id);
2962
+ }
2963
+ } else {
2964
+ el2.classList.add(id);
2965
+ }
2955
2966
  const inst = tippy(`.${id}`, __spreadValues(__spreadProps(__spreadValues({
2956
2967
  theme: "teselagen",
2957
2968
  plugins: [followCursor],
@@ -19563,7 +19574,11 @@ function tableQueryParamsToHasuraClauses({
19563
19574
  ]
19564
19575
  };
19565
19576
  case "equalTo":
19566
- return { [filterOn]: { _eq: parseFloat(filterValue) } };
19577
+ return {
19578
+ [filterOn]: {
19579
+ _eq: type2 === "number" || type2 === "integer" ? parseFloat(filterValue) : filterValue
19580
+ }
19581
+ };
19567
19582
  case "regex":
19568
19583
  return { [filterOn]: { _regex: filterValue } };
19569
19584
  default:
@@ -50993,10 +51008,10 @@ const RenderCell = /* @__PURE__ */ __name(({
50993
51008
  return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormEditingCell;
50994
51009
  }
50995
51010
  );
50996
- const initialValue = reactRedux.useSelector(
51011
+ const shouldEditableCellInputBeCleared = reactRedux.useSelector(
50997
51012
  (state) => {
50998
51013
  var _a2, _b, _c;
50999
- return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormInitialValue;
51014
+ return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.shouldEditableCellInputBeCleared;
51000
51015
  }
51001
51016
  );
51002
51017
  const [row] = args;
@@ -51049,7 +51064,7 @@ const RenderCell = /* @__PURE__ */ __name(({
51049
51064
  dataTest,
51050
51065
  cancelEdit: cancelCellEdit,
51051
51066
  isNumeric: column.type === "number",
51052
- initialValue: initialValue || text2,
51067
+ initialValue: shouldEditableCellInputBeCleared ? void 0 : text2,
51053
51068
  finishEdit: /* @__PURE__ */ __name((newVal) => {
51054
51069
  finishCellEdit(cellId, newVal);
51055
51070
  }, "finishEdit")
@@ -56907,8 +56922,12 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
56907
56922
  }
56908
56923
  }, [selectedCells]);
56909
56924
  const startCellEdit = React.useCallback(
56910
- (cellId, initialValue) => {
56911
- change("reduxFormInitialValue", initialValue);
56925
+ (cellId, shouldClear) => {
56926
+ if (shouldClear) {
56927
+ change("shouldEditableCellInputBeCleared", true);
56928
+ } else {
56929
+ change("shouldEditableCellInputBeCleared", false);
56930
+ }
56912
56931
  change("reduxFormEditingCell", (prev) => {
56913
56932
  if (prev === cellId) return cellId;
56914
56933
  setSelectedCells((prev2) => {
@@ -58569,12 +58588,30 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58569
58588
  const rowDisabled = isEntityDisabled(entity);
58570
58589
  const isNum = (_g = e.code) == null ? void 0 : _g.startsWith("Digit");
58571
58590
  const isLetter = (_h = e.code) == null ? void 0 : _h.startsWith("Key");
58572
- if (!isNum && !isLetter) {
58591
+ const allowedSpecialChars = [
58592
+ "Minus",
58593
+ "Equal",
58594
+ "Backquote",
58595
+ "BracketLeft",
58596
+ "BracketRight",
58597
+ "Backslash",
58598
+ "IntlBackslash",
58599
+ "Semicolon",
58600
+ "Quote",
58601
+ "Comma",
58602
+ "Period",
58603
+ "Slash",
58604
+ "IntlRo",
58605
+ "IntlYen",
58606
+ "Space"
58607
+ ];
58608
+ const isSpecialChar = allowedSpecialChars.includes(e.code);
58609
+ if (!isNum && !isLetter && !isSpecialChar) {
58573
58610
  return;
58574
58611
  }
58575
58612
  if (rowDisabled) return;
58576
58613
  e.stopPropagation();
58577
- startCellEdit(primarySelectedCellId, e.key);
58614
+ startCellEdit(primarySelectedCellId, true);
58578
58615
  }, "onKeyDown")
58579
58616
  }),
58580
58617
  isCellEditable && entities.length > 50 && // test for this!!
package/index.es.js CHANGED
@@ -2933,7 +2933,18 @@ let clearMe;
2933
2933
  document.querySelectorAll(`.${id}`).forEach((elem) => {
2934
2934
  elem.classList.remove(id);
2935
2935
  });
2936
- el2.classList.add(id);
2936
+ let targetEl = el2;
2937
+ if (targetEl.disabled || targetEl.getAttribute("disabled") !== null) {
2938
+ const parent2 = targetEl.parentElement;
2939
+ if (parent2) {
2940
+ parent2.classList.add(id);
2941
+ targetEl = parent2;
2942
+ } else {
2943
+ el2.classList.add(id);
2944
+ }
2945
+ } else {
2946
+ el2.classList.add(id);
2947
+ }
2937
2948
  const inst = tippy(`.${id}`, __spreadValues(__spreadProps(__spreadValues({
2938
2949
  theme: "teselagen",
2939
2950
  plugins: [followCursor],
@@ -19545,7 +19556,11 @@ function tableQueryParamsToHasuraClauses({
19545
19556
  ]
19546
19557
  };
19547
19558
  case "equalTo":
19548
- return { [filterOn]: { _eq: parseFloat(filterValue) } };
19559
+ return {
19560
+ [filterOn]: {
19561
+ _eq: type2 === "number" || type2 === "integer" ? parseFloat(filterValue) : filterValue
19562
+ }
19563
+ };
19549
19564
  case "regex":
19550
19565
  return { [filterOn]: { _regex: filterValue } };
19551
19566
  default:
@@ -50975,10 +50990,10 @@ const RenderCell = /* @__PURE__ */ __name(({
50975
50990
  return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormEditingCell;
50976
50991
  }
50977
50992
  );
50978
- const initialValue = useSelector(
50993
+ const shouldEditableCellInputBeCleared = useSelector(
50979
50994
  (state) => {
50980
50995
  var _a2, _b, _c;
50981
- return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.reduxFormInitialValue;
50996
+ return (_c = (_b = (_a2 = state.form) == null ? void 0 : _a2[formName]) == null ? void 0 : _b.values) == null ? void 0 : _c.shouldEditableCellInputBeCleared;
50982
50997
  }
50983
50998
  );
50984
50999
  const [row] = args;
@@ -51031,7 +51046,7 @@ const RenderCell = /* @__PURE__ */ __name(({
51031
51046
  dataTest,
51032
51047
  cancelEdit: cancelCellEdit,
51033
51048
  isNumeric: column.type === "number",
51034
- initialValue: initialValue || text2,
51049
+ initialValue: shouldEditableCellInputBeCleared ? void 0 : text2,
51035
51050
  finishEdit: /* @__PURE__ */ __name((newVal) => {
51036
51051
  finishCellEdit(cellId, newVal);
51037
51052
  }, "finishEdit")
@@ -56889,8 +56904,12 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
56889
56904
  }
56890
56905
  }, [selectedCells]);
56891
56906
  const startCellEdit = useCallback(
56892
- (cellId, initialValue) => {
56893
- change$1("reduxFormInitialValue", initialValue);
56907
+ (cellId, shouldClear) => {
56908
+ if (shouldClear) {
56909
+ change$1("shouldEditableCellInputBeCleared", true);
56910
+ } else {
56911
+ change$1("shouldEditableCellInputBeCleared", false);
56912
+ }
56894
56913
  change$1("reduxFormEditingCell", (prev) => {
56895
56914
  if (prev === cellId) return cellId;
56896
56915
  setSelectedCells((prev2) => {
@@ -58551,12 +58570,30 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
58551
58570
  const rowDisabled = isEntityDisabled(entity);
58552
58571
  const isNum = (_g = e.code) == null ? void 0 : _g.startsWith("Digit");
58553
58572
  const isLetter = (_h = e.code) == null ? void 0 : _h.startsWith("Key");
58554
- if (!isNum && !isLetter) {
58573
+ const allowedSpecialChars = [
58574
+ "Minus",
58575
+ "Equal",
58576
+ "Backquote",
58577
+ "BracketLeft",
58578
+ "BracketRight",
58579
+ "Backslash",
58580
+ "IntlBackslash",
58581
+ "Semicolon",
58582
+ "Quote",
58583
+ "Comma",
58584
+ "Period",
58585
+ "Slash",
58586
+ "IntlRo",
58587
+ "IntlYen",
58588
+ "Space"
58589
+ ];
58590
+ const isSpecialChar = allowedSpecialChars.includes(e.code);
58591
+ if (!isNum && !isLetter && !isSpecialChar) {
58555
58592
  return;
58556
58593
  }
58557
58594
  if (rowDisabled) return;
58558
58595
  e.stopPropagation();
58559
- startCellEdit(primarySelectedCellId, e.key);
58596
+ startCellEdit(primarySelectedCellId, true);
58560
58597
  }, "onKeyDown")
58561
58598
  }),
58562
58599
  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.7.33-beta.6",
3
+ "version": "0.7.33-beta.7",
4
4
  "main": "./src/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -32,8 +32,8 @@ export const RenderCell = ({
32
32
  const editingCell = useSelector(
33
33
  state => state.form?.[formName]?.values?.reduxFormEditingCell
34
34
  );
35
- const initialValue = useSelector(
36
- state => state.form?.[formName]?.values?.reduxFormInitialValue
35
+ const shouldEditableCellInputBeCleared = useSelector(
36
+ state => state.form?.[formName]?.values?.shouldEditableCellInputBeCleared
37
37
  );
38
38
 
39
39
  const [row] = args;
@@ -85,7 +85,7 @@ export const RenderCell = ({
85
85
  dataTest={dataTest}
86
86
  cancelEdit={cancelCellEdit}
87
87
  isNumeric={column.type === "number"}
88
- initialValue={initialValue || text}
88
+ initialValue={shouldEditableCellInputBeCleared ? undefined : text}
89
89
  finishEdit={newVal => {
90
90
  finishCellEdit(cellId, newVal);
91
91
  }}
@@ -1075,11 +1075,17 @@ const DataTable = ({
1075
1075
  }, [selectedCells]);
1076
1076
 
1077
1077
  const startCellEdit = useCallback(
1078
- (cellId, initialValue) => {
1078
+ (cellId, shouldClear) => {
1079
+ // console.log(`startCellEdit initialValue:`, initialValue)
1079
1080
  // This initial value is not needed if the event is propagated accordingly.
1080
1081
  // This is directly connected to the RenderCell component, which does set
1081
1082
  // the initial value.
1082
- change("reduxFormInitialValue", initialValue);
1083
+ // change("shouldEditableCellInputBeCleared", undefined);
1084
+ if (shouldClear) {
1085
+ change("shouldEditableCellInputBeCleared", true);
1086
+ } else {
1087
+ change("shouldEditableCellInputBeCleared", false);
1088
+ }
1083
1089
  change("reduxFormEditingCell", prev => {
1084
1090
  //check if the cell is already selected and editing and if so, don't change it
1085
1091
  if (prev === cellId) return cellId;
@@ -2955,12 +2961,30 @@ const DataTable = ({
2955
2961
  const rowDisabled = isEntityDisabled(entity);
2956
2962
  const isNum = e.code?.startsWith("Digit");
2957
2963
  const isLetter = e.code?.startsWith("Key");
2958
- if (!isNum && !isLetter) {
2964
+ const allowedSpecialChars = [
2965
+ "Minus",
2966
+ "Equal",
2967
+ "Backquote",
2968
+ "BracketLeft",
2969
+ "BracketRight",
2970
+ "Backslash",
2971
+ "IntlBackslash",
2972
+ "Semicolon",
2973
+ "Quote",
2974
+ "Comma",
2975
+ "Period",
2976
+ "Slash",
2977
+ "IntlRo",
2978
+ "IntlYen",
2979
+ "Space"
2980
+ ];
2981
+ const isSpecialChar = allowedSpecialChars.includes(e.code);
2982
+ if (!isNum && !isLetter && !isSpecialChar) {
2959
2983
  return;
2960
2984
  }
2961
2985
  if (rowDisabled) return;
2962
2986
  e.stopPropagation();
2963
- startCellEdit(primarySelectedCellId, e.key);
2987
+ startCellEdit(primarySelectedCellId, true);
2964
2988
  }
2965
2989
  })}
2966
2990
  >
@@ -190,7 +190,14 @@ export function tableQueryParamsToHasuraClauses({
190
190
  ]
191
191
  };
192
192
  case "equalTo":
193
- return { [filterOn]: { _eq: parseFloat(filterValue) } };
193
+ return {
194
+ [filterOn]: {
195
+ _eq:
196
+ type === "number" || type === "integer"
197
+ ? parseFloat(filterValue)
198
+ : filterValue
199
+ }
200
+ };
194
201
  case "regex":
195
202
  return { [filterOn]: { _regex: filterValue } };
196
203
  default:
@@ -52,7 +52,23 @@ let clearMe;
52
52
  elem.classList.remove(id);
53
53
  });
54
54
 
55
- el.classList.add(id);
55
+ // Check if element is disabled, if so use parent instead
56
+ let targetEl = el;
57
+ if (targetEl.disabled || targetEl.getAttribute("disabled") !== null) {
58
+ const parent = targetEl.parentElement;
59
+ if (parent) {
60
+ // Use the parent as the tooltip target
61
+ parent.classList.add(id);
62
+ targetEl = parent; // Change the tooltip target to parent
63
+ } else {
64
+ // No parent, keep using the original element
65
+ el.classList.add(id);
66
+ }
67
+ } else {
68
+ // Element not disabled, use it directly
69
+ el.classList.add(id);
70
+ }
71
+
56
72
  const inst = tippy(`.${id}`, {
57
73
  theme: "teselagen",
58
74
  plugins: [followCursor],
@@ -84,19 +100,12 @@ let clearMe;
84
100
  requires: ["computeStyles"],
85
101
  requiresIfExists: ["offset"],
86
102
  fn({ state }) {
87
- // console.log(`state:`, state);
88
- // state.styles.popper.bottom = 20 + "px";
89
103
  const customBoundary =
90
104
  document.querySelector(dataAvoid) ||
91
105
  document.querySelector(dataAvoidBackup);
92
106
 
93
107
  if (!customBoundary) return;
94
108
  const a = customBoundary.getBoundingClientRect();
95
- // console.log(
96
- // `state.rects.reference.y:`,
97
- // state.rects.reference.y
98
- // );
99
- // console.log(`a.top:`, a.top);
100
109
 
101
110
  if (a.top < state.rects.reference.y) {
102
111
  const b = Math.abs(
@@ -104,16 +113,6 @@ let clearMe;
104
113
  );
105
114
  state.styles.popper.bottom = b + "px";
106
115
  }
107
-
108
- // const overflow = detectOverflow(state, {
109
- // boundary: customBoundary,
110
- // altBoundary: true
111
- // });
112
- // console.log(`overflow:`, overflow);
113
- // if (overflow.bottom > 0) {
114
- // const a = Math.abs(overflow.bottom);
115
- // state.styles.popper.bottom = a + "px";
116
- // }
117
116
  }
118
117
  }
119
118
  ]
@@ -199,3 +198,6 @@ function parentIncludesNoChildDataTip(el, count) {
199
198
  if (el.getAttribute("data-no-child-data-tip")) return true;
200
199
  return parentIncludesNoChildDataTip(el.parentElement, count + 1);
201
200
  }
201
+
202
+ // Export the function to clear parent tooltips so it can be used elsewhere
203
+ // export { clearParentTooltips };
@@ -1,4 +1,5 @@
1
1
  const keyCount = {};
2
+ // if this function is hit more than 20 times in a row in 2 seconds with the same uniqName then throw an error
2
3
  export const isBeingCalledExcessively = ({ uniqName }) => {
3
4
  if (process.env.NODE_ENV !== "development") {
4
5
  return;
@@ -6,19 +7,25 @@ export const isBeingCalledExcessively = ({ uniqName }) => {
6
7
  if (!uniqName) {
7
8
  throw new Error("uniqName is required");
8
9
  }
9
- // if this function is hit more than 10 times in a row in 2 seconds with the same uniqName then throw an error
10
- if (keyCount[uniqName + "_timeout"]) {
11
- clearTimeout(keyCount[uniqName + "_timeout"]);
12
- }
10
+ // Initialize the count if it doesn't exist
13
11
  keyCount[uniqName] = keyCount[uniqName] || 0;
14
12
  keyCount[uniqName]++;
15
13
 
16
- keyCount[uniqName + "_timeout"] = setTimeout(() => {
17
- keyCount[uniqName] = 0;
18
- }, 2000);
14
+ // Only set the timeout if it doesn't exist already to ensure it runs exactly once every 2 seconds
15
+ if (!keyCount[uniqName + "_timeout"]) {
16
+ keyCount[uniqName + "_timeout"] = setTimeout(() => {
17
+ keyCount[uniqName] = 0;
18
+ keyCount[uniqName + "_timeout"] = null;
19
+ }, 2000);
20
+ }
19
21
 
20
22
  if (keyCount[uniqName] > 20) {
21
23
  keyCount[uniqName] = 0;
24
+ // Also clear the timeout when throwing an error
25
+ if (keyCount[uniqName + "_timeout"]) {
26
+ clearTimeout(keyCount[uniqName + "_timeout"]);
27
+ keyCount[uniqName + "_timeout"] = null;
28
+ }
22
29
  throw new Error(`isBeingCalledExcessively: ${uniqName}`);
23
30
  }
24
31
  };