sccoreui 6.3.87 → 6.3.89
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/dist/App.scss +23 -8
- package/dist/components/formula-template/ExpressionRender.js +37 -0
- package/dist/components/formula-template/FormulaCoponent.js +15 -11
- package/dist/components/formula-template/Tagify.js +185 -35
- package/dist/components/list-box-dropdown/list-box-dropdown.js +2 -2
- package/dist/types/components/formula-template/ExpressionRender.d.ts +4 -0
- package/package.json +1 -1
package/dist/App.scss
CHANGED
|
@@ -1161,14 +1161,7 @@ button[aria-expanded="true"] {
|
|
|
1161
1161
|
padding-inline: 6px 10px !important;
|
|
1162
1162
|
color: var(--primary-400);
|
|
1163
1163
|
background: transparent;
|
|
1164
|
-
|
|
1165
|
-
.p-button-label {
|
|
1166
|
-
max-width: 120px;
|
|
1167
|
-
white-space: nowrap;
|
|
1168
|
-
text-overflow: ellipsis;
|
|
1169
|
-
overflow: hidden;
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1164
|
+
|
|
1172
1165
|
&:not(.section_btn) {
|
|
1173
1166
|
height: 28px;
|
|
1174
1167
|
}
|
|
@@ -1196,6 +1189,28 @@ button[aria-expanded="true"] {
|
|
|
1196
1189
|
}
|
|
1197
1190
|
}
|
|
1198
1191
|
|
|
1192
|
+
.p-button.data_label {
|
|
1193
|
+
color: var(--gray-600);
|
|
1194
|
+
background-color: transparent;
|
|
1195
|
+
display: flex;
|
|
1196
|
+
gap: 4px;
|
|
1197
|
+
svg {
|
|
1198
|
+
path {
|
|
1199
|
+
stroke: var(--gray-700);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
&:hover {
|
|
1204
|
+
background-color: var(--gray-200);
|
|
1205
|
+
color: var(--gray-700);
|
|
1206
|
+
}
|
|
1207
|
+
.p-button-label {
|
|
1208
|
+
white-space: nowrap;
|
|
1209
|
+
text-overflow: ellipsis;
|
|
1210
|
+
overflow: hidden;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1199
1214
|
.list_box_chips {
|
|
1200
1215
|
display: flex;
|
|
1201
1216
|
flex-wrap: wrap;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const ExpressionRenderer = ({ inputValue }) => {
|
|
5
|
+
const parts = [];
|
|
6
|
+
const regex = /\[\[\{.*?\}\]\]/g;
|
|
7
|
+
let lastIndex = 0;
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = regex.exec(inputValue)) !== null) {
|
|
10
|
+
const before = inputValue.substring(lastIndex, match.index);
|
|
11
|
+
if (before.trim()) {
|
|
12
|
+
parts.push(...before.split(/(\s+)/).filter(Boolean));
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const json = JSON.parse(match[0].slice(2, -2));
|
|
16
|
+
parts.push(json); // Add parsed object
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
parts.push(match[0]); // Fallback to raw
|
|
20
|
+
}
|
|
21
|
+
lastIndex = regex.lastIndex;
|
|
22
|
+
}
|
|
23
|
+
const after = inputValue.substring(lastIndex);
|
|
24
|
+
if (after.trim()) {
|
|
25
|
+
parts.push(...after.split(/(\s+)/).filter(Boolean));
|
|
26
|
+
}
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex align-items-center gap-2" }, { children: parts.map((part, index) => {
|
|
28
|
+
if (typeof part === "object" && part.value) {
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "bg-gray-200 px-2 py-1 border-round-sm font-bold" }, { children: part.value }), index));
|
|
30
|
+
}
|
|
31
|
+
else if (typeof part === "string" && part.trim() !== "") {
|
|
32
|
+
return (0, jsx_runtime_1.jsx)("span", { children: part }, index);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}) })));
|
|
36
|
+
};
|
|
37
|
+
exports.default = ExpressionRenderer;
|
|
@@ -9,6 +9,7 @@ const svg_component_1 = tslib_1.__importDefault(require("../../directives/svg-co
|
|
|
9
9
|
const menu_1 = require("primereact/menu");
|
|
10
10
|
// import { InputText } from "primereact/inputtext";
|
|
11
11
|
const Tagify_1 = tslib_1.__importDefault(require("./Tagify"));
|
|
12
|
+
const ExpressionRender_1 = tslib_1.__importDefault(require("./ExpressionRender"));
|
|
12
13
|
const FormulaComponent = (props) => {
|
|
13
14
|
const priceConditioRef = (0, react_1.useRef)(null);
|
|
14
15
|
const [fieldOptions, setFieldOptions] = (0, react_1.useState)(props === null || props === void 0 ? void 0 : props.fieldOptions);
|
|
@@ -27,7 +28,7 @@ const FormulaComponent = (props) => {
|
|
|
27
28
|
? props === null || props === void 0 ? void 0 : props.headerLabel
|
|
28
29
|
: "Configure Value" })), (0, jsx_runtime_1.jsx)("span", { children: (props === null || props === void 0 ? void 0 : props.headerDescription)
|
|
29
30
|
? props === null || props === void 0 ? void 0 : props.headerDescription
|
|
30
|
-
: "Select price attribute and perform calculater." })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "help-circle", size: 16 }) }))] }))), (0, jsx_runtime_1.jsx)(Tagify_1.default, { formulaOperators: props.formulaOperators, fieldOptions: fieldOptions })] }), "formula__dev"));
|
|
31
|
+
: "Select price attribute and perform calculater." })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "help-circle", size: 16 }) }))] }))), (0, jsx_runtime_1.jsx)(Tagify_1.default, { formulaOperators: props.formulaOperators, fieldOptions: fieldOptions, formulaValue: props === null || props === void 0 ? void 0 : props.formulaValue })] }), "formula__dev"));
|
|
31
32
|
},
|
|
32
33
|
},
|
|
33
34
|
];
|
|
@@ -36,7 +37,7 @@ const FormulaComponent = (props) => {
|
|
|
36
37
|
props === null || props === void 0 ? void 0 : props.onConditionChange(e);
|
|
37
38
|
setConditionValue(e.value);
|
|
38
39
|
}, className: `sc_animate w-6 overflow-hidden text-overflow-ellipsis white-space-nowrap formula_condition_dropdown border-right-1 border-gray-300 border-none border-noround`, options: props === null || props === void 0 ? void 0 : props.options }), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (() => {
|
|
39
|
-
var _a
|
|
40
|
+
var _a;
|
|
40
41
|
let optiontype = (_a = props === null || props === void 0 ? void 0 : props.options.find((x) => x.value === conditionValue)) === null || _a === void 0 ? void 0 : _a.optionType;
|
|
41
42
|
switch (optiontype) {
|
|
42
43
|
case "INCREASE_BY_VALUE":
|
|
@@ -56,16 +57,19 @@ const FormulaComponent = (props) => {
|
|
|
56
57
|
return ((0, jsx_runtime_1.jsx)(inputnumber_1.InputNumber, Object.assign({ useGrouping: false, min: 0, minFractionDigits: 2, maxFractionDigits: 2, maxLength: (props === null || props === void 0 ? void 0 : props.maxLength) || Infinity }, props === null || props === void 0 ? void 0 : props.field, { onValueChange: (e) => (props === null || props === void 0 ? void 0 : props.onChange) && (props === null || props === void 0 ? void 0 : props.onChange(e)), placeholder: "Enter Number", value: props === null || props === void 0 ? void 0 : props.inputValue, className: "border-none w-6", inputClassName: "border-none focus:shadow-none" })));
|
|
57
58
|
}
|
|
58
59
|
case "CALCULATION": {
|
|
59
|
-
const pattern = /(?:[a-f0-9]{24}|msrp|map|costprice)/g;
|
|
60
|
+
// const pattern = /(?:[a-f0-9]{24}|msrp|map|costprice)/g;
|
|
60
61
|
// if(props?.formulaValue){
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
// const inputValue = `[[{"id": "660ab8748140c009b0af99a2","value": "Test1","code": "34sdf","price": 46}]] + 8 + [[{"id": "660abaee8140c009b0afa3ef","value": "Test2","code": "t34sdf","price": 4}]] + 86 + 7647`;
|
|
63
|
+
// const ids: any = props?.formulaValue.match(pattern);
|
|
64
|
+
// let text: string = props?.formulaValue;
|
|
65
|
+
// for (let i = 0; i < ids?.length; i++) {
|
|
66
|
+
// let id = ids[i];
|
|
67
|
+
// let name = fieldOptions.find(
|
|
68
|
+
// (item: any) => item.id === id
|
|
69
|
+
// )?.name;
|
|
70
|
+
// text = text.replaceAll(id, name);
|
|
71
|
+
// }
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "w-8 h-auto cursor-pointer flex align-items-center px-4", onClick: (e) => { var _a; return (_a = priceConditioRef.current) === null || _a === void 0 ? void 0 : _a.toggle(e); } }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-gray-700 overflow-hidden text-overflow-ellipsis white-space-nowrap w-full" }, { children: (props === null || props === void 0 ? void 0 : props.formulaValue) ? ((0, jsx_runtime_1.jsx)(ExpressionRender_1.default, { inputValue: props === null || props === void 0 ? void 0 : props.formulaValue })) : ("Select") })) })));
|
|
69
73
|
// }else{
|
|
70
74
|
// return 'Select'
|
|
71
75
|
// }
|
|
@@ -11,7 +11,8 @@ const TagifyComponent = (props) => {
|
|
|
11
11
|
var _a;
|
|
12
12
|
const tagifyRef = (0, react_1.useRef)(null);
|
|
13
13
|
const saveBtnRef = (0, react_1.useRef)(null);
|
|
14
|
-
const inputValue = `[[{"id": "660ab8748140c009b0af99a2","value": "Test1","code": "34sdf","price": 46}]] + 8 + [[{"id": "660abaee8140c009b0afa3ef","value": "Test2","code": "t34sdf","price": 4}]] + 86`;
|
|
14
|
+
// const inputValue = `[[{"id": "660ab8748140c009b0af99a2","value": "Test1","code": "34sdf","price": 46}]] + 8 + [[{"id": "660abaee8140c009b0afa3ef","value": "Test2","code": "t34sdf","price": 4}]] + 86`;
|
|
15
|
+
const inputValue = (props === null || props === void 0 ? void 0 : props.formulaValue) ? props === null || props === void 0 ? void 0 : props.formulaValue : "";
|
|
15
16
|
let tagifyInstance;
|
|
16
17
|
(0, react_1.useEffect)(() => {
|
|
17
18
|
// Initialize tagify with new keyword and options
|
|
@@ -21,6 +22,8 @@ const TagifyComponent = (props) => {
|
|
|
21
22
|
mode: "mix",
|
|
22
23
|
skipInvalid: true,
|
|
23
24
|
duplicates: true,
|
|
25
|
+
enforceWhitelist: true,
|
|
26
|
+
editTags: false,
|
|
24
27
|
whitelist: [...props === null || props === void 0 ? void 0 : props.fieldOptions, "+", "-", "*", "/", "%", "(", ")"],
|
|
25
28
|
dropdown: {
|
|
26
29
|
maxItems: 10,
|
|
@@ -28,27 +31,88 @@ const TagifyComponent = (props) => {
|
|
|
28
31
|
enabled: 1,
|
|
29
32
|
closeOnSelect: false,
|
|
30
33
|
searchKeys: ["value"],
|
|
34
|
+
highlightFirst: true,
|
|
35
|
+
position: "text",
|
|
36
|
+
mapValueTo: "value",
|
|
37
|
+
includeSelectedTags: true,
|
|
38
|
+
showTags: false,
|
|
39
|
+
hideSelected: false, // Don't hide selected items from the dropdown
|
|
40
|
+
},
|
|
41
|
+
templates: {
|
|
42
|
+
// Override the dropdownItem template to remove the selected checkmark
|
|
43
|
+
dropdownItem: function (tagData) {
|
|
44
|
+
// Create a custom template without checkmark
|
|
45
|
+
return `<div ${this.getAttributes(tagData)}
|
|
46
|
+
class='tagify__dropdown__item ${tagData.class ? tagData.class : ""}'
|
|
47
|
+
tabindex="0"
|
|
48
|
+
role="option">
|
|
49
|
+
<span>${tagData.value}</span>
|
|
50
|
+
</div>`;
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
// Prevent double-click from triggering edit mode
|
|
54
|
+
callbacks: {
|
|
55
|
+
click: function (e) {
|
|
56
|
+
// Prevent default double-click behavior
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return false;
|
|
59
|
+
},
|
|
31
60
|
},
|
|
32
|
-
enforceWhitelist: true,
|
|
33
61
|
});
|
|
62
|
+
// Apply custom CSS to hide checkmarks and prevent editing
|
|
63
|
+
const style = document.createElement("style");
|
|
64
|
+
style.innerHTML = `
|
|
65
|
+
.tagify__dropdown .tagify__dropdown__item--active::before {
|
|
66
|
+
display: none !important;
|
|
67
|
+
}
|
|
68
|
+
.tagify__dropdown .tagify__dropdown__item[aria-selected=true]::before {
|
|
69
|
+
display: none !important;
|
|
70
|
+
}
|
|
71
|
+
.tagify__tag:not(.tagify--noAnim) {
|
|
72
|
+
pointer-events: none !important;
|
|
73
|
+
}
|
|
74
|
+
.tagify__tag__removeBtn {
|
|
75
|
+
display: none !important;
|
|
76
|
+
}
|
|
77
|
+
.tagify__tag.tagify--editable {
|
|
78
|
+
pointer-events: none !important;
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
document.head.appendChild(style);
|
|
82
|
+
// Handle any click or dblclick on tags to prevent editing
|
|
83
|
+
tagifyRef.current.addEventListener("dblclick", function (e) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
return false;
|
|
87
|
+
}, true);
|
|
34
88
|
tagifyInstance.on("change input", onInput);
|
|
35
89
|
tagifyInstance.on("change", onChange);
|
|
36
90
|
function onChange() {
|
|
37
91
|
setTimeout(() => {
|
|
38
92
|
onCalculateSum();
|
|
39
|
-
},
|
|
93
|
+
}, 500);
|
|
40
94
|
}
|
|
41
95
|
function onInput() {
|
|
42
96
|
setTimeout(() => {
|
|
43
97
|
onCalculateSum();
|
|
44
|
-
},
|
|
98
|
+
}, 500);
|
|
45
99
|
}
|
|
46
100
|
onCalculateSum();
|
|
47
|
-
// Clean up the event listener on unmount
|
|
101
|
+
// Clean up the event listener and custom style on unmount
|
|
48
102
|
return () => {
|
|
49
103
|
tagifyInstance.destroy();
|
|
104
|
+
document.head.removeChild(style);
|
|
50
105
|
};
|
|
51
106
|
}, []);
|
|
107
|
+
// Override Tagify's editTag method to prevent editing
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
109
|
+
if (tagifyInstance) {
|
|
110
|
+
// Override the editTag method to do nothing
|
|
111
|
+
tagifyInstance.editTag = function () {
|
|
112
|
+
return false;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}, [tagifyInstance]);
|
|
52
116
|
const operators = {
|
|
53
117
|
addition: "+",
|
|
54
118
|
subtraction: "-",
|
|
@@ -60,62 +124,148 @@ const TagifyComponent = (props) => {
|
|
|
60
124
|
};
|
|
61
125
|
const onCalculateSum = () => {
|
|
62
126
|
if (tagifyRef === null || tagifyRef === void 0 ? void 0 : tagifyRef.current) {
|
|
63
|
-
const pattern = /^(?![\+\-\*/]).*(?:[\+\-\*/]\d+[\+\-\*/])*(?:(?:\[\[{.*}\]\])([\+\-\*/](?:\[\[{.*}\]\]))+)*(?:\[\[{.*}\]\])*(?![\+\-\*/])$/;
|
|
64
|
-
// /^(?![\+\-\*/]).*(?:[\+\-\*/]\d+[\+\-\*/])*(?:\[\[{.*}\]\])*(?![\+\-\*/])$/;
|
|
65
|
-
// /^(?![\+\-\*/]).*[\+\-\*/].*(?:\d+|(\[\[{.*}\]\]))(?![\+\-\*/])$/;
|
|
66
|
-
///^(?![\+\-\*/]).*(?:\[\[{.*}\]\])(?:[\+\-\*/]\d+[\+\-\*/])*(?:\[\[{.*}\]\])?(?![\+\-\*/])$/
|
|
67
127
|
try {
|
|
68
|
-
//
|
|
128
|
+
// Clean up the value (remove zero-width spaces but keep normal spaces for now)
|
|
69
129
|
let value = tagifyRef.current.value;
|
|
70
|
-
value = value.replaceAll("", "");
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
130
|
+
value = value.replaceAll("", ""); // Remove zero-width spaces
|
|
131
|
+
if (inputValue.replaceAll(" ", "") === value.replaceAll(" ", "")) {
|
|
132
|
+
saveBtnRef.current.disabled = true;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// First, extract all chip tokens to analyze the expression structure
|
|
136
|
+
const tagPattern = /\[\[{.*?}\]\]/g;
|
|
137
|
+
const chipTokens = [];
|
|
138
|
+
let match;
|
|
139
|
+
// Get all chip positions
|
|
140
|
+
while ((match = tagPattern.exec(value)) !== null) {
|
|
141
|
+
chipTokens.push({
|
|
142
|
+
start: match.index,
|
|
143
|
+
end: match.index + match[0].length,
|
|
144
|
+
value: match[0],
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// Check for adjacent chips (no operator between them)
|
|
148
|
+
for (let i = 0; i < chipTokens.length - 1; i++) {
|
|
149
|
+
const current = chipTokens[i];
|
|
150
|
+
const next = chipTokens[i + 1];
|
|
151
|
+
// Check the content between chips
|
|
152
|
+
const textBetween = value.substring(current.end, next.start);
|
|
153
|
+
const trimmedTextBetween = textBetween.trim();
|
|
154
|
+
// If there's nothing or just spaces between chips (no operator), it's invalid
|
|
155
|
+
if (!trimmedTextBetween ||
|
|
156
|
+
!/[\+\-\*\/\%\(\)]/.test(trimmedTextBetween)) {
|
|
157
|
+
if (saveBtnRef.current) {
|
|
158
|
+
saveBtnRef.current.disabled = true;
|
|
79
159
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Make a working copy of the value for validation
|
|
164
|
+
let validationValue = value;
|
|
165
|
+
// Replace tag tokens with placeholder numbers for validation
|
|
166
|
+
validationValue = validationValue.replace(tagPattern, "0");
|
|
167
|
+
// Normalize spaces around operators for consistent validation
|
|
168
|
+
validationValue = validationValue.replace(/\s*([+\-*/%()])\s*/g, "$1");
|
|
169
|
+
// Remove all spaces for further validation
|
|
170
|
+
validationValue = validationValue.replaceAll(" ", "");
|
|
171
|
+
// Check if expression starts with an invalid operator (not an open parenthesis)
|
|
172
|
+
if (/^[\+\*\/\%]/.test(validationValue)) {
|
|
173
|
+
if (saveBtnRef.current) {
|
|
174
|
+
saveBtnRef.current.disabled = true;
|
|
175
|
+
}
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// Check if expression ends with an invalid operator
|
|
179
|
+
if (/[\+\-\*\/\%\(]$/.test(validationValue)) {
|
|
180
|
+
if (saveBtnRef.current) {
|
|
181
|
+
saveBtnRef.current.disabled = true;
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// Check for balanced parentheses
|
|
186
|
+
let openParenCount = 0;
|
|
187
|
+
for (const char of validationValue) {
|
|
188
|
+
if (char === "(")
|
|
189
|
+
openParenCount++;
|
|
190
|
+
if (char === ")")
|
|
191
|
+
openParenCount--;
|
|
192
|
+
// If at any point we have more closing than opening parentheses, it's invalid
|
|
193
|
+
if (openParenCount < 0) {
|
|
194
|
+
if (saveBtnRef.current) {
|
|
195
|
+
saveBtnRef.current.disabled = true;
|
|
83
196
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// If we have unclosed parentheses at the end, it's invalid
|
|
201
|
+
if (openParenCount !== 0) {
|
|
202
|
+
if (saveBtnRef.current) {
|
|
203
|
+
saveBtnRef.current.disabled = true;
|
|
204
|
+
}
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
// Check for consecutive operators (except valid combinations like +-, -+, etc.)
|
|
208
|
+
if (/[\+\-\*\/\%][\*\/\%]/.test(validationValue)) {
|
|
88
209
|
if (saveBtnRef.current) {
|
|
89
|
-
saveBtnRef.current.disabled =
|
|
210
|
+
saveBtnRef.current.disabled = true;
|
|
90
211
|
}
|
|
212
|
+
return;
|
|
91
213
|
}
|
|
92
|
-
|
|
214
|
+
// If we passed all validations, extract prices and evaluate
|
|
215
|
+
let str = tagifyRef.current.value;
|
|
216
|
+
let res = str.replace(tagPattern, (match) => {
|
|
217
|
+
try {
|
|
218
|
+
const tagData = JSON.parse(match.slice(2, -2));
|
|
219
|
+
return tagData.price.toString();
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
console.error("Invalid tag format:", match);
|
|
223
|
+
return "0"; // Use 0 as fallback for invalid tags
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
// Clean the result string for evaluation
|
|
227
|
+
res = res.replaceAll("", "");
|
|
228
|
+
res = res.replaceAll(" ", "");
|
|
229
|
+
// Try to evaluate the expression
|
|
230
|
+
// eslint-disable-next-line no-eval
|
|
231
|
+
const result = eval(res);
|
|
232
|
+
// Check if result is a valid number
|
|
233
|
+
if (isNaN(result) || !isFinite(result)) {
|
|
93
234
|
if (saveBtnRef.current) {
|
|
94
235
|
saveBtnRef.current.disabled = true;
|
|
95
236
|
}
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
// Enable the save button if expression is valid and evaluates successfully
|
|
240
|
+
if (saveBtnRef.current) {
|
|
241
|
+
saveBtnRef.current.disabled = false;
|
|
96
242
|
}
|
|
97
243
|
}
|
|
98
244
|
catch (error) {
|
|
245
|
+
// Handle evaluation errors
|
|
246
|
+
console.error("Formula evaluation error:", error);
|
|
99
247
|
if (saveBtnRef.current) {
|
|
100
248
|
saveBtnRef.current.disabled = true;
|
|
101
249
|
}
|
|
102
250
|
}
|
|
103
251
|
}
|
|
104
252
|
};
|
|
105
|
-
// Function to get the cursor position and add
|
|
253
|
+
// Function to get the cursor position and add operator symbol
|
|
106
254
|
const addPlusAtCursor = (operator) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
255
|
+
var _b;
|
|
256
|
+
if (tagifyRef.current) {
|
|
257
|
+
tagifyRef.current.value = ((_b = tagifyRef === null || tagifyRef === void 0 ? void 0 : tagifyRef.current) === null || _b === void 0 ? void 0 : _b.value) + operators[operator];
|
|
258
|
+
}
|
|
259
|
+
yield tagifyInstance.on([{ value: operators[operator], type: "math" }]);
|
|
110
260
|
setTimeout(() => {
|
|
111
261
|
onCalculateSum();
|
|
112
262
|
}, 1000);
|
|
113
263
|
});
|
|
114
264
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "condition_section border-top-1 border-bottom-1 border-gray-200" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "h-2rem px-4 border-bottom-1 flex column-gap-2 align-items-center border-gray-200" }, { children: props.formulaOperators.map((operator, index) => {
|
|
115
265
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "condition_operator flex align-items-center justify-content-center text-lg w-2 sc_icon_hover cursor-pointer hover:bg-primary-50 border-round-sm", onClick: () => addPlusAtCursor(operator) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "text-lg font-bold" }, { children: operators[operator] })) }), "formula__operator_" + index), (0, jsx_runtime_1.jsx)("span", { className: "operator_divider" })] }));
|
|
116
|
-
}) })), (0, jsx_runtime_1.jsx)("input", { ref: tagifyRef, type: "text", placeholder: "Enter text or tags...", value: inputValue })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `condition_footer_section flex align-items-center p-2 ${props === null || props === void 0 ? void 0 : props.footerTemplateClassName}` }, { children: (props === null || props === void 0 ? void 0 : props.footerTemplate) ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props === null || props === void 0 ? void 0 : props.footerTemplate })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "w-6 px-4 py-2 hover:bg-primary-50 cursor-pointer sc_icon_hover", onClick: () => {
|
|
266
|
+
}) })), (0, jsx_runtime_1.jsx)("input", { ref: tagifyRef, type: "text", placeholder: "Enter text or tags...", value: inputValue })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `condition_footer_section flex align-items-center p-2 gap-2 ${props === null || props === void 0 ? void 0 : props.footerTemplateClassName}` }, { children: (props === null || props === void 0 ? void 0 : props.footerTemplate) ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props === null || props === void 0 ? void 0 : props.footerTemplate })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "w-6 px-4 py-2 hover:bg-primary-50 cursor-pointer sc_icon_hover border-round-md", onClick: () => {
|
|
117
267
|
// setContent(props?.formulaValue);
|
|
118
|
-
//
|
|
119
|
-
} }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", size: 20 }) })), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ ref: saveBtnRef, disabled: (_a = saveBtnRef === null || saveBtnRef === void 0 ? void 0 : saveBtnRef.current) === null || _a === void 0 ? void 0 : _a.disabled, className:
|
|
268
|
+
// priceConditioRef.current.toggle(e);
|
|
269
|
+
} }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", size: 20 }) })), (0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({ ref: saveBtnRef, disabled: (_a = saveBtnRef === null || saveBtnRef === void 0 ? void 0 : saveBtnRef.current) === null || _a === void 0 ? void 0 : _a.disabled, className: "w-6 px-4 py-2 bg-primary-50 cursor-pointer sc_icon_hover border-round-md flex justify-content-center align-items-center" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "check", size: 20 }) }))] })) }))] }));
|
|
120
270
|
};
|
|
121
271
|
exports.default = TagifyComponent;
|
|
@@ -136,10 +136,10 @@ const ListBoxDropdown = (props) => {
|
|
|
136
136
|
? emptyFilterMessage
|
|
137
137
|
: "No Results Found", emptyMessage: emptyMessage ? emptyMessage : "No Data Found" }), footeTemplate && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: footeTemplate() })] }))),
|
|
138
138
|
},
|
|
139
|
-
] }), !showChips ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !dataLabel ? ((0, jsx_runtime_1.jsx)(button_1.Button, { type: "button", className: `list_box_btn ${type === "sectionHeader" ? "section_btn" : ""}`, link: link ? true : false, icon: labelIcon ? labelIcon : "", size: labelIconSize ? labelIconSize : "", iconPos: labelIconPos ? labelIconPos : "", label: label, onClick: (event) => optionsMenuRef.current.toggle(event), title: label })) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ onClick: (event) => optionsMenuRef.current.toggle(event), title: label, className: "listbox_label" }, { children: dataLabel }))) })) : ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "
|
|
139
|
+
] }), !showChips ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !dataLabel ? ((0, jsx_runtime_1.jsx)(button_1.Button, { type: "button", className: `list_box_btn ${type === "sectionHeader" ? "section_btn" : ""}`, link: link ? true : false, icon: labelIcon ? labelIcon : "", size: labelIconSize ? labelIconSize : "", iconPos: labelIconPos ? labelIconPos : "", label: label, onClick: (event) => optionsMenuRef.current.toggle(event), title: label })) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ onClick: (event) => optionsMenuRef.current.toggle(event), title: label, className: "listbox_label" }, { children: dataLabel }))) })) : ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "data_label" }, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, { type: "button",
|
|
140
140
|
// className={`list_box_button focus:shadow-none p-0 h-max h-auto mx-2`}
|
|
141
141
|
// link={link ? true : false}
|
|
142
|
-
icon: labelIcon ? labelIcon : "", size: labelIconSize ? labelIconSize : "", iconPos: labelIconPos ? labelIconPos : "", label: label, onClick: (event) => optionsMenuRef.current.toggle(event), "aria-controls": "popup_menu_right", "aria-haspopup": true, ref: buttonRef, className:
|
|
142
|
+
icon: labelIcon ? labelIcon : "", size: labelIconSize ? labelIconSize : "", iconPos: labelIconPos ? labelIconPos : "", label: label, onClick: (event) => optionsMenuRef.current.toggle(event), "aria-controls": "popup_menu_right", "aria-haspopup": true, ref: buttonRef, className: "data_label", title: dataLabel }), (0, jsx_runtime_1.jsx)("ul", Object.assign({ className: `list_box_chips ${chipsParentClassName}` }, { children: selectedItems &&
|
|
143
143
|
(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.map((item, index) => {
|
|
144
144
|
var _a, _b, _c, _d;
|
|
145
145
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isDraggable !== undefined ? ((0, jsx_runtime_1.jsx)("li", Object.assign({ draggable: isDraggable, onDragStart: (e) => handleDragStart(e, index), onDragOver: (e) => handleDragOver(e), onDrop: (e) => handleDrop(e, index), className: `select-none ${chipClassName ? chipClassName : "list_box_chip"} ${showRemoveIcon ? "relative text-gray-700" : ""}` }, { children: chipTemplate ? (chipTemplate(item)) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-truncate max-w-10rem inline-block", title: typeof item === "object"
|