sccoreui 5.9.3 → 5.9.4

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.
@@ -45,8 +45,8 @@ const FormulaComponent = (props) => {
45
45
  else {
46
46
  setSelectedItem([item.id]);
47
47
  }
48
- let chipElm = ` <div class="formulaChipElm max-w-8rem w-max h-2rem overflow-hidden text-overflow-ellipsis white-space-nowrap bg-blue-100 text-gray-600 border-round-sm p-1 ${props.formulaChipClassName}" contentEditable=${false} itemId=${item === null || item === void 0 ? void 0 : item.id} title=${item === null || item === void 0 ? void 0 : item.name}>${item === null || item === void 0 ? void 0 : item.name}</div> `;
49
- let currentText = contentEditableDivRef.current.innerHTML === '<span class="formulaSpanElm"></span>' ? '<span class="formulaSpanElm"></span>' : contentEditableDivRef.current.innerHTML;
48
+ let chipElm = `<div class="formulaChipElm max-w-8rem w-max h-2rem overflow-hidden text-overflow-ellipsis white-space-nowrap bg-blue-100 text-gray-600 border-round-sm p-1 ${props.formulaChipClassName}" contentEditable=${false} itemId=${item === null || item === void 0 ? void 0 : item.id} title=${item === null || item === void 0 ? void 0 : item.name}>${item === null || item === void 0 ? void 0 : item.name}</div>`;
49
+ let currentText = contentEditableDivRef.current.innerHTML === '<span class="formulaSpanElm"></span>' ? '<span class="formulaSpanElm"></span>' : contentEditableDivRef.current.innerHTML.replaceAll('<br>', '');
50
50
  const index = contentEditableDivRef.current.innerHTML.indexOf((_a = document.querySelector('.formulaSpanElm.activeSpanElm')) === null || _a === void 0 ? void 0 : _a.outerHTML);
51
51
  if (index === -1 && (contentEditableCursorIndex === null || contentEditableCursorIndex === 0)) {
52
52
  let str = currentText + chipElm + `<span class='formulaSpanElm activeSpanElm'></span>`;
@@ -84,7 +84,6 @@ const FormulaComponent = (props) => {
84
84
  let spanElms = Array.from(document.querySelectorAll('.formulaSpanElm'));
85
85
  if (spanElms.length > 1) {
86
86
  let spanInnerText = spanElms === null || spanElms === void 0 ? void 0 : spanElms.map((x) => x === null || x === void 0 ? void 0 : x.innerHTML);
87
- // debugger
88
87
  // remove first and last span
89
88
  const specialCharacters = /[/*\-+%(]/;
90
89
  if (spanInnerText[0] !== "" && !specialCharacters.test(spanInnerText[0].charAt(spanInnerText[0].length - 1))) {
@@ -94,17 +93,15 @@ const FormulaComponent = (props) => {
94
93
  else if (specialCharacters.test(spanInnerText[0].charAt(spanInnerText[0].length - 1)) || spanInnerText[0] === "") {
95
94
  spanInnerText.shift();
96
95
  }
97
- if (spanInnerText[spanInnerText.length - 1] !== "" && !specialCharacters.test(spanInnerText[spanInnerText.length - 1].charAt(0))) {
98
- setIsValid(false);
99
- return;
100
- }
101
- else if (spanInnerText[spanInnerText.length - 1] === "" || specialCharacters.test(spanInnerText[spanInnerText.length - 1].charAt(0))) {
96
+ if (spanInnerText[spanInnerText.length - 1] === "" || specialCharacters.test(spanInnerText[spanInnerText.length - 1].charAt(0))) {
102
97
  spanInnerText.pop();
103
98
  }
104
99
  // spanInnerText = spanInnerText.slice(0, 1)
105
100
  // spanInnerText = spanInnerText.slice(0, spanElms.length - 1)
106
101
  // const specialCharacters = /[/*\-+%(]/;
107
102
  let findText = spanInnerText.find((x) => !specialCharacters.test(x.charAt(0)) || !specialCharacters.test(x.charAt(x.length - 1)));
103
+ if (findText)
104
+ findText = findText.replaceAll('<br>', '');
108
105
  if (findText) {
109
106
  setIsValid(false);
110
107
  return;
@@ -154,17 +151,22 @@ const FormulaComponent = (props) => {
154
151
  function getCursorPosition(contentEditableElm) {
155
152
  var _a;
156
153
  const selection = window.getSelection();
157
- const range = selection.getRangeAt(0);
158
- const clonedRange = range.cloneRange();
159
- clonedRange.selectNodeContents(contentEditableElm);
160
- clonedRange.setEnd(range.endContainer, range.endOffset);
161
- setContentEditableCursorIndex((_a = clonedRange === null || clonedRange === void 0 ? void 0 : clonedRange.toString()) === null || _a === void 0 ? void 0 : _a.length);
154
+ if (selection.anchorNode) {
155
+ const range = selection.getRangeAt(0);
156
+ const clonedRange = range.cloneRange();
157
+ clonedRange.selectNodeContents(contentEditableElm);
158
+ clonedRange.setEnd(range.endContainer, range.endOffset);
159
+ setContentEditableCursorIndex((_a = clonedRange === null || clonedRange === void 0 ? void 0 : clonedRange.toString()) === null || _a === void 0 ? void 0 : _a.length);
160
+ }
162
161
  }
163
162
  const onConditionKeyDown = (event) => {
164
163
  const content = event.target.textContent.trim();
165
164
  const lastChar = content.charAt(content.length - 1);
166
165
  const operators = ['%', '*', '-', '+', '/'];
167
166
  let selection = window.getSelection();
167
+ let actElm = document.querySelector('.formulaSpanElm.activeSpanElm');
168
+ if (actElm && actElm.innerHTML.indexOf('<br>') !== -1)
169
+ actElm.innerHTML = actElm.textContent;
168
170
  if (event.keyCode === 37 || event.keyCode === 39 || event.keyCode === 38 || event.keyCode === 40) {
169
171
  let actElm = document.querySelector('.formulaSpanElm.activeSpanElm');
170
172
  let spanElms = Array.from(document.querySelectorAll('.formulaSpanElm'));
@@ -177,25 +179,29 @@ const FormulaComponent = (props) => {
177
179
  }
178
180
  });
179
181
  if (actElm) {
180
- if ((event.keyCode === 37 /* ArrowLeft */ || event.keyCode === 38 /* ArrowUp */) && selection.focusOffset === 0) {
181
- activeIndex = activeIndex - 1;
182
- }
183
- else if ((event.keyCode === 39 /* ArrowRight */ || event.keyCode === 40 /* ArrowDown */) && selection.focusOffset === selection.focusNode.textContent.length) {
184
- activeIndex = activeIndex + 1;
182
+ if (event.keyCode === 37 /* ArrowLeft */ || event.keyCode === 38 /* ArrowUp */) {
183
+ if (selection.getRangeAt(0).endOffset !== 0 && actElm.innerText.length !== 0) {
184
+ getCursorPosition(actElm);
185
+ return;
186
+ }
187
+ if (activeIndex !== 0) {
188
+ // activeIndex = activeIndex + 1
189
+ activeIndex = activeIndex - 1;
190
+ }
185
191
  }
186
- else {
187
- event.preventDefault();
188
- return;
192
+ else if (event.keyCode === 39 /* ArrowRight */ || event.keyCode === 40 /* ArrowDown */) { //&& selection.focusOffset === selection.focusNode.textContent.length
193
+ if (actElm.innerText.length === selection.getRangeAt(0).endOffset && activeIndex < spanElms.length - 1) {
194
+ activeIndex = activeIndex + 1;
195
+ }
189
196
  }
190
- actElm.classList.remove('activeSpanElm');
197
+ if (activeIndex !== -1 && spanElms.indexOf(actElm) !== activeIndex)
198
+ actElm.classList.remove('activeSpanElm');
191
199
  }
192
- if (activeIndex !== null && activeIndex !== -1 && activeIndex && spanElms[activeIndex]) {
193
- range.selectNodeContents(spanElms[activeIndex]); // Select the entire content of the element
194
- range.collapse(false);
195
- const selection = window.getSelection();
196
- selection.removeAllRanges();
197
- selection.addRange(range);
198
- setContentEditableCursorIndex(range.startOffset);
200
+ if (activeIndex !== null && activeIndex !== -1 && spanElms.length > activeIndex && spanElms.indexOf(actElm) !== activeIndex) {
201
+ if (event.keyCode === 37 /* ArrowLeft */ || event.keyCode === 38 /* ArrowUp */)
202
+ range.selectNodeContents(spanElms[activeIndex]);
203
+ else if (event.keyCode === 39 /* ArrowRight */ || event.keyCode === 40)
204
+ range.setStart(spanElms[activeIndex], 0);
199
205
  if (!range.startContainer.parentElement.getAttribute('id')) {
200
206
  range.startContainer.parentElement.classList.add('activeSpanElm');
201
207
  }
@@ -204,6 +210,9 @@ const FormulaComponent = (props) => {
204
210
  eml === null || eml === void 0 ? void 0 : eml.classList.add('activeSpanElm');
205
211
  }
206
212
  }
213
+ let CurrentActElm = document.querySelector('.formulaSpanElm.activeSpanElm');
214
+ if (CurrentActElm)
215
+ getCursorPosition(CurrentActElm);
207
216
  }
208
217
  // Allow numbers, *, -, +, %, /, (, ), and single space
209
218
  if (!((event.keyCode >= '0' && event.keyCode <= '9') ||
@@ -253,15 +262,15 @@ const FormulaComponent = (props) => {
253
262
  }
254
263
  };
255
264
  const onAddOperator = (event, operator) => {
256
- var _a, _b;
257
265
  let elm = document.querySelector('.activeSpanElm');
258
- const operators = ['%', '*', '-', '+', '/'];
259
- const lastChar = (_a = elm.innerHTML) === null || _a === void 0 ? void 0 : _a.charAt(((_b = elm.innerHTML) === null || _b === void 0 ? void 0 : _b.length) - 1);
260
- // Prevent entering operators coonChangeCondition(str);ntinuously after each other
261
- if (lastChar && operators.includes(lastChar)) {
262
- event.preventDefault();
263
- return;
264
- }
266
+ console.log(event);
267
+ // const operators = ['%', '*', '-', '+', '/'];
268
+ // const lastChar = elm.innerHTML?.charAt(elm.innerHTML?.length - 1);
269
+ // // Prevent entering operators coonChangeCondition(str);ntinuously after each other
270
+ // if (lastChar && operators.includes(lastChar) && operators.includes(operator)) {
271
+ // event.preventDefault();
272
+ // return;
273
+ // }
265
274
  if (contentEditableDivRef.current.innerHTML !== `<span class='formulaSpanElm'></span>`) {
266
275
  elm.innerHTML = elm.innerHTML + operator;
267
276
  }
@@ -372,8 +381,8 @@ const FormulaComponent = (props) => {
372
381
  if (z === 0 && (splitText.length - 1) === i && chipElm)
373
382
  formulatText = textParts[z] ? formulatText + `<span class='formulaSpanElm'>${textParts[z]}</span>` + chipElm + `<span class='formulaSpanElm'></span>` : `<span class='formulaSpanElm'></span>`;
374
383
  else if (z === 0 && chipElm && id) {
375
- let lastSpanIndex = formulatText.lastIndexOf('</span>');
376
- formulatText = textParts[z] ? formulatText.slice(0, lastSpanIndex) + `${textParts[z]}</span>` + chipElm : `<span class='formulaSpanElm'></span>`;
384
+ // let lastSpanIndex = formulatText.lastIndexOf('</span>');
385
+ formulatText = textParts[z] ? formulatText + `<span class='formulaSpanElm'>${textParts[z]}</span>` + chipElm : `<span class='formulaSpanElm'></span>`;
377
386
  }
378
387
  else
379
388
  formulatText = textParts[z] ? formulatText + `<span class='formulaSpanElm'>${textParts[z]}</span>` : `<span class='formulaSpanElm'></span>`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sccoreui",
3
- "version": "5.9.3",
3
+ "version": "5.9.4",
4
4
  "description": "ui-sccore",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,4 +0,0 @@
1
- .condition_button {
2
- height: 40px !important;
3
- width: 64px !important;
4
- }
@@ -1,61 +0,0 @@
1
- .ag-grid-container {
2
- .ag-root-wrapper {
3
- &.ag-layout-normal {
4
- border: 0;
5
- }
6
- }
7
- }
8
-
9
- .ag-header {
10
- background: var(--gray-50);
11
-
12
- border-top: 1px solid var(--gray-300);
13
- border-bottom: 1px solid var(--gray-200) !important;
14
- }
15
-
16
- .ag-root-wrapper {
17
- border-radius: 6px !important;
18
- border-top-left-radius: 0px !important;
19
- }
20
-
21
- .ag-ltr .ag-cell-focus:not(.ag-cell-range-selected):focus-within {
22
- border: 0;
23
- border-color: initial;
24
- }
25
-
26
- .ag-ltr .ag-cell {
27
- display: flex;
28
- align-items: center;
29
- }
30
-
31
- .ag-grid-container {
32
- border: 1px solid var(--gray-200) !important;
33
- background: #fff !important;
34
- }
35
-
36
- // .ag-ltr .ag-header-cell-resize {
37
- // display: none;
38
- // }
39
-
40
- .ag-row {
41
- border-bottom: 1px solid var(--gray-200);
42
- }
43
-
44
- .ag-row-odd {
45
- background-color: var(--gray-25);
46
- }
47
-
48
- .ag-row {
49
- &:focus {
50
- background-color: var(--gray-100);
51
- }
52
- }
53
-
54
- .ag-theme-quartz {
55
- --ag-active-color: var(--gray-300);
56
- }
57
-
58
- .ag-ltr .ag-header-viewport .ag-header-cell-resize::after {
59
- background-color: var(--gray-200);
60
- width: 1px;
61
- }