sccoreui 5.4.1 → 5.4.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.
- package/dist/App.scss +23 -0
- package/dist/components/form/form-fields/form-fields.js +7 -7
- package/dist/components/formula-template/FormulaCoponent.js +310 -0
- package/dist/components/froala-editor/FroalaEditor.js +2 -2
- package/dist/directives/svg-icons.js +17 -0
- package/dist/index.js +3 -1
- package/dist/types/components/formula-template/FormulaCoponent.d.ts +3 -0
- package/dist/types/components/froala-editor/FroalaEditor.d.ts +1 -1
- package/dist/types/components/types/type.d.ts +9 -3
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/components/formula-template/FormulaTemplate.js +0 -105
- package/dist/types/components/formula-template/FormulaTemplate.d.ts +0 -3
package/dist/App.scss
CHANGED
|
@@ -857,9 +857,32 @@ button[aria-expanded="true"] {
|
|
|
857
857
|
|
|
858
858
|
.condition_attribute_list_sect{
|
|
859
859
|
height: 215px;
|
|
860
|
+
.attr_chip {
|
|
861
|
+
transition: all 0.1s;
|
|
862
|
+
&:hover{
|
|
863
|
+
transform: scale(1.05);
|
|
864
|
+
// transition: all 0.2s;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
860
868
|
}
|
|
861
869
|
|
|
862
870
|
.condition_configure{
|
|
863
871
|
height: 224px;
|
|
864
872
|
outline: none;
|
|
873
|
+
line-height: 30px;
|
|
874
|
+
letter-spacing: 2px;
|
|
875
|
+
.formulaChipElm {
|
|
876
|
+
line-height: 24px;
|
|
877
|
+
letter-spacing: 0px;
|
|
878
|
+
margin: 2px;
|
|
879
|
+
float: left;
|
|
880
|
+
}
|
|
881
|
+
.formulaSpanElm {
|
|
882
|
+
font-size: 16px;
|
|
883
|
+
margin: 2px 0;
|
|
884
|
+
float: left;
|
|
885
|
+
min-width: 6px;
|
|
886
|
+
height: 32px;
|
|
887
|
+
}
|
|
865
888
|
}
|
|
@@ -14,7 +14,7 @@ const sccoreui_1 = require("sccoreui");
|
|
|
14
14
|
const InputTextField = (props) => {
|
|
15
15
|
const { errors, touched, name, length, label, placeholder, optional, maxLength, className, validate, disabled, isLoading } = props;
|
|
16
16
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex flex-column" }, { children: [!isLoading ?
|
|
17
|
-
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ type: "text", name: name, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsx)(inputtext_1.InputText, Object.assign({ maxLength: maxLength, autoComplete: "off", disabled: disabled, placeholder: placeholder }, field, { className:
|
|
17
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ type: "text", name: name, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsx)(inputtext_1.InputText, Object.assign({ maxLength: maxLength, autoComplete: "off", disabled: disabled, placeholder: placeholder }, field, { className: ` ${errors[name] && touched[name] ? 'p-invalid' : ''} ${length === 'full' ? 'full_form_field' : 'form_field'} ${className}`, id: name }))) }))] })
|
|
18
18
|
:
|
|
19
19
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "20px", className: "mb-1 w-5rem" }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${className ? className : 'form_field'} ` }, { children: (0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "40px" }) }))] }), errors[name] && touched[name] ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: errors[name] }) }))) : (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: "\u00A0" }) }))] })));
|
|
20
20
|
};
|
|
@@ -22,16 +22,16 @@ const InputNumberField = (props) => {
|
|
|
22
22
|
const { errors, touched, name, length, label, placeholder, optional, setFieldValue, min, max, maxLength, className, validate, disabled, isLoading, inputClassName, icon, iconPos, maxFractionDigits, minFractionDigits } = props;
|
|
23
23
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column" }, { children: !isLoading ?
|
|
24
24
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ name: name, errors: errors, touched: touched, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: icon ?
|
|
25
|
-
(0, jsx_runtime_1.jsxs)("span", Object.assign({ className: `p-input-icon-${iconPos}` }, { children: [(0, jsx_runtime_1.jsx)("i", { className: `pi pi-${icon} text-base` }), (0, jsx_runtime_1.jsx)(inputnumber_1.InputNumber, Object.assign({ maxFractionDigits: maxFractionDigits ? maxFractionDigits : 0, minFractionDigits: minFractionDigits ? minFractionDigits : 0, inputClassName: inputClassName ? inputClassName : '', min: min, max: max, disabled: disabled, pt: { input: { root: { autoComplete: 'off' } } }, maxLength: maxLength, placeholder: placeholder }, field, { onChange: (e) => setFieldValue(name, e.value !== null ? e.value : min), className: ` ${
|
|
25
|
+
(0, jsx_runtime_1.jsxs)("span", Object.assign({ className: `p-input-icon-${iconPos}` }, { children: [(0, jsx_runtime_1.jsx)("i", { className: `pi pi-${icon} text-base` }), (0, jsx_runtime_1.jsx)(inputnumber_1.InputNumber, Object.assign({ maxFractionDigits: maxFractionDigits ? maxFractionDigits : 0, minFractionDigits: minFractionDigits ? minFractionDigits : 0, inputClassName: inputClassName ? inputClassName : '', min: min, max: max, disabled: disabled, pt: { input: { root: { autoComplete: 'off' } } }, maxLength: maxLength, placeholder: placeholder }, field, { onChange: (e) => setFieldValue(name, e.value !== null ? e.value : min), className: ` ${errors[name] && touched[name] ? 'p-invalid' : ''} ${length === 'full' ? 'full_form_field' : 'form_field'} ${className}`, id: name }))] }))
|
|
26
26
|
:
|
|
27
|
-
(0, jsx_runtime_1.jsx)(inputnumber_1.InputNumber, Object.assign({ maxFractionDigits: maxFractionDigits ? maxFractionDigits : 0, minFractionDigits: minFractionDigits ? minFractionDigits : 0, inputClassName: inputClassName ? inputClassName : '', min: min, max: max, disabled: disabled, pt: { input: { root: { autoComplete: 'off' } } }, maxLength: maxLength, placeholder: placeholder }, field, { onChange: (e) => setFieldValue(name, e.value !== null ? e.value : min), className: ` ${
|
|
27
|
+
(0, jsx_runtime_1.jsx)(inputnumber_1.InputNumber, Object.assign({ maxFractionDigits: maxFractionDigits ? maxFractionDigits : 0, minFractionDigits: minFractionDigits ? minFractionDigits : 0, inputClassName: inputClassName ? inputClassName : '', min: min, max: max, disabled: disabled, pt: { input: { root: { autoComplete: 'off' } } }, maxLength: maxLength, placeholder: placeholder }, field, { onChange: (e) => setFieldValue(name, e.value !== null ? e.value : min), className: ` ${errors[name] && touched[name] ? 'p-invalid' : ''} ${length === 'full' ? 'full_form_field' : 'form_field'} ${className}`, id: name })) })) })), errors[name] && touched[name] ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: errors[name] }) }))) : (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: "\u00A0" }) }))] })
|
|
28
28
|
:
|
|
29
29
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "20px", className: "mb-1 w-5rem" }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${className ? className : 'form_field'} ` }, { children: (0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "40px" }) }))] }) })));
|
|
30
30
|
};
|
|
31
31
|
const InputCurrencyField = (props) => {
|
|
32
32
|
const { errors, spanClassName, touched, name, length, label, placeholder, optional, setFieldValue, min, max, maxLength, className, validate, disabled, isLoading } = props;
|
|
33
33
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column" }, { children: !isLoading ?
|
|
34
|
-
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ name: name, errors: errors, touched: touched, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsxs)("span", Object.assign({ className: `${spanClassName} p-input-icon-left form_field` }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "p-input-prefix text-lg text-gray-600 font-normal" }, { children: "$" })), (0, jsx_runtime_1.jsx)(inputnumber_1.InputNumber, Object.assign({ "aria-autocomplete": "none", minFractionDigits: 2, disabled: disabled, min: min, max: max, maxLength: maxLength }, field, { onChange: (e) => setFieldValue(name, e.value !== null ? e.value : min), maxFractionDigits: 2, placeholder: placeholder, className: `
|
|
34
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ name: name, errors: errors, touched: touched, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsxs)("span", Object.assign({ className: `${spanClassName} p-input-icon-left form_field` }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "p-input-prefix text-lg text-gray-600 font-normal" }, { children: "$" })), (0, jsx_runtime_1.jsx)(inputnumber_1.InputNumber, Object.assign({ "aria-autocomplete": "none", minFractionDigits: 2, disabled: disabled, min: min, max: max, maxLength: maxLength }, field, { onChange: (e) => setFieldValue(name, e.value !== null ? e.value : min), maxFractionDigits: 2, placeholder: placeholder, className: ` customNumberField ${errors[name] && touched[name] ? 'p-invalid' : ''} ${length === 'full' ? 'full_form_field' : 'form_field'} ${className}`, id: name }))] }))) })), errors[name] && touched[name] ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: errors[name] }) }))) : (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: "\u00A0" }) }))] })
|
|
35
35
|
:
|
|
36
36
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "20px", className: "mb-1 w-5rem" }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${className ? className : 'form_field'} ` }, { children: (0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "40px" }) }))] }) })));
|
|
37
37
|
};
|
|
@@ -43,21 +43,21 @@ const InputTextAreaField = (props) => {
|
|
|
43
43
|
}, [values[name]]);
|
|
44
44
|
(0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }));
|
|
45
45
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column relative" }, { children: !isLoading ?
|
|
46
|
-
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ name: name, type: "textarea", validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(inputtextarea_1.InputTextarea, Object.assign({ autoComplete: "off", placeholder: placeholder, style: { height: '154px', resize: 'none', overflowY: 'scroll' } }, field, { maxLength: maxLength, className: `pt-2
|
|
46
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ name: name, type: "textarea", validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(inputtextarea_1.InputTextarea, Object.assign({ autoComplete: "off", placeholder: placeholder, style: { height: '154px', resize: 'none', overflowY: 'scroll' } }, field, { maxLength: maxLength, className: `pt-2 ${errors[name] && touched[name] ? 'p-invalid' : ''} ${length === 'full' ? 'full_form_field' : 'form_field'} ${className}`, id: name })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "absolute text-base font-normal text-gray-600", style: { bottom: '20px', right: '12px' } }, { children: [charCount, "/", maxLength] }))] })) })), errors[name] && touched[name] ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: errors[name] }) }))) : (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: "\u00A0" }) }))] })
|
|
47
47
|
:
|
|
48
48
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "20px", className: "mb-1 w-5rem" }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${className ? className : 'form_field'} ` }, { children: (0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "40px" }) }))] }) })));
|
|
49
49
|
};
|
|
50
50
|
const DropDownField = (props) => {
|
|
51
51
|
const { errors, touched, name, length, label, placeholder, options, optional, customSelectedTemplate, customFieldsTemplate, optionLabel, optionDisabled, className, validate, disabled, filter, panelStyle, isLoading } = props;
|
|
52
52
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column" }, { children: !isLoading ?
|
|
53
|
-
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ type: "text", name: name, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, Object.assign({ panelStyle: panelStyle || '', filter: filter || false, disabled: disabled, placeholder: placeholder }, field, { options: options, itemTemplate: customFieldsTemplate, valueTemplate: customSelectedTemplate, optionDisabled: optionDisabled, optionLabel: optionLabel, className: ` ${
|
|
53
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ type: "text", name: name, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, Object.assign({ panelStyle: panelStyle || '', filter: filter || false, disabled: disabled, placeholder: placeholder }, field, { options: options, itemTemplate: customFieldsTemplate, valueTemplate: customSelectedTemplate, optionDisabled: optionDisabled, optionLabel: optionLabel, className: ` ${errors[name] && touched[name] ? 'p-invalid' : ''} ${length === 'full' ? 'full_form_field' : 'form_field'} ${className}`, id: name }))) })), errors[name] && touched[name] ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: errors[name] }) }))) : (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: "\u00A0" }) }))] })
|
|
54
54
|
:
|
|
55
55
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "20px", className: "mb-1 w-5rem" }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${className ? className : 'form_field'} ` }, { children: (0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "40px" }) }))] }) })));
|
|
56
56
|
};
|
|
57
57
|
const MultiSelectField = (props) => {
|
|
58
58
|
const { errors, touched, name, length, label, placeholder, options, optional, customFieldsTemplate, optionLabel, optionDisabled, className, validate, disabled, isLoading, filter } = props;
|
|
59
59
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "flex flex-column" }, { children: !isLoading ?
|
|
60
|
-
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ type: "text", name: name, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsx)(multiselect_1.MultiSelect, Object.assign({ filter: filter ? filter : false, disabled: disabled, placeholder: placeholder }, field, { options: options, itemTemplate: customFieldsTemplate, optionDisabled: optionDisabled, optionLabel: optionLabel, className: ` ${
|
|
60
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [optional && (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "font-medium text-base mb-1 w-full flex justify-content-between", htmlFor: name }, { children: [label, (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "text-base font-medium font-italic text-gray-600" }, { children: "Optional" }))] })), !optional && (0, jsx_runtime_1.jsx)("label", Object.assign({ className: "font-medium text-base mb-1", htmlFor: name }, { children: label })), (0, jsx_runtime_1.jsx)(formik_1.Field, Object.assign({ type: "text", name: name, validate: validate }, { children: ({ field }) => ((0, jsx_runtime_1.jsx)(multiselect_1.MultiSelect, Object.assign({ filter: filter ? filter : false, disabled: disabled, placeholder: placeholder }, field, { options: options, itemTemplate: customFieldsTemplate, optionDisabled: optionDisabled, optionLabel: optionLabel, className: ` ${errors[name] && touched[name] ? 'p-invalid' : ''} ${length === 'full' ? 'full_form_field' : 'form_field'} ${className}`, id: name }))) })), errors[name] && touched[name] ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: errors[name] }) }))) : (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'errorField flex align-items-center text-sm' }, { children: (0, jsx_runtime_1.jsx)("span", { children: "\u00A0" }) }))] })
|
|
61
61
|
:
|
|
62
62
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "20px", className: "mb-1 w-5rem" }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${className ? className : 'form_field'} ` }, { children: (0, jsx_runtime_1.jsx)(sccoreui_1.Skeleton, { height: "40px" }) }))] }) })));
|
|
63
63
|
};
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const dropdown_1 = require("primereact/dropdown");
|
|
7
|
+
const inputtext_1 = require("primereact/inputtext");
|
|
8
|
+
const svg_component_1 = tslib_1.__importDefault(require("../../directives/svg-component"));
|
|
9
|
+
const menu_1 = require("primereact/menu");
|
|
10
|
+
const FormulaCoponent = (props) => {
|
|
11
|
+
const priceConditioRef = (0, react_1.useRef)(null);
|
|
12
|
+
const [isValid, setIsValid] = (0, react_1.useState)(false);
|
|
13
|
+
const [selectedItem, setSelectedItem] = (0, react_1.useState)();
|
|
14
|
+
const [fieldOptions, setFieldOptions] = (0, react_1.useState)(props === null || props === void 0 ? void 0 : props.fieldOptions);
|
|
15
|
+
const contentEditableDivRef = (0, react_1.useRef)(null);
|
|
16
|
+
const [content, setContent] = (0, react_1.useState)(`<span class='formulaSpanElm'></span>`);
|
|
17
|
+
const [contentEditableCursorIndex, setContentEditableCursorIndex] = (0, react_1.useState)(null);
|
|
18
|
+
const operators = {
|
|
19
|
+
"addition": '+',
|
|
20
|
+
"subtraction": '-',
|
|
21
|
+
"multiplication": '*',
|
|
22
|
+
"division": '÷',
|
|
23
|
+
"percentile": '%',
|
|
24
|
+
"openBracket": "(",
|
|
25
|
+
"closeBracket": ")",
|
|
26
|
+
};
|
|
27
|
+
const onSelecteItem = (item) => {
|
|
28
|
+
if (selectedItem) {
|
|
29
|
+
if (selectedItem.find((id) => id === item.id))
|
|
30
|
+
setSelectedItem(selectedItem.filter((id) => id !== item.id));
|
|
31
|
+
else
|
|
32
|
+
setSelectedItem([item.id, ...selectedItem]);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setSelectedItem([item.id]);
|
|
36
|
+
}
|
|
37
|
+
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" 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> `;
|
|
38
|
+
let currentText = contentEditableDivRef.current.innerHTML === '<span class="formulaSpanElm"></span>' ? '<span class="formulaSpanElm"></span>' : contentEditableDivRef.current.innerHTML;
|
|
39
|
+
if (contentEditableCursorIndex === null) {
|
|
40
|
+
let str = currentText + chipElm + `<span class='formulaSpanElm'></span>`;
|
|
41
|
+
setContent(str);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (document.querySelector('.formulaSpanElm.activeSpanElm').innerHTML.length === contentEditableCursorIndex) {
|
|
45
|
+
let sliptText = currentText.split(document.querySelector('.formulaSpanElm.activeSpanElm').outerHTML);
|
|
46
|
+
let str = sliptText[0] + document.querySelector('.formulaSpanElm.activeSpanElm').outerHTML + chipElm + `<span class='formulaSpanElm'></span>` + sliptText[1];
|
|
47
|
+
setContent(str);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// let sliptText = document.querySelector('.formulaSpanElm.activeSpanElm').outerHTML.split(document.querySelector('.formulaSpanElm.activeSpanElm').innerHTML.substring(contentEditableCursorIndex))
|
|
51
|
+
const firstPart = `<span class="formulaSpanElm activeSpanElm">` + document.querySelector('.formulaSpanElm.activeSpanElm').innerHTML.substring(0, contentEditableCursorIndex);
|
|
52
|
+
// const secondPart = document.querySelector('.formulaSpanElm.activeSpanElm').innerHTML.substring(contentEditableCursorIndex) + `</span>`;
|
|
53
|
+
let contentSplit = contentEditableDivRef.current.innerHTML.split(firstPart);
|
|
54
|
+
let str = contentSplit[0] + firstPart + `</span>` + chipElm + `<span class="formulaSpanElm">` + contentSplit[1];
|
|
55
|
+
setContent(str);
|
|
56
|
+
// let sliptText = currentText.split(document.querySelector('.formulaSpanElm.activeSpanElm').outerHTML)
|
|
57
|
+
// let str = sliptText[0] + document.querySelector('.formulaSpanElm.activeSpanElm').outerHTML + chipElm + '<span class="formulaSpanElm"></span>' +sliptText[1]
|
|
58
|
+
// setContent(str);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
onChangeCondition();
|
|
63
|
+
addEventListenerForSpan();
|
|
64
|
+
}, 500);
|
|
65
|
+
};
|
|
66
|
+
const onChangeCondition = () => {
|
|
67
|
+
// Here we are validating a formula for its end result.
|
|
68
|
+
// The end result should be a number, whether negative or positive.
|
|
69
|
+
let elements = contentEditableDivRef.current.children;
|
|
70
|
+
let formula = '';
|
|
71
|
+
for (let i = 0; i < elements.length; i++) {
|
|
72
|
+
const element = elements[i];
|
|
73
|
+
if (element.classList.contains('formulaChipElm')) {
|
|
74
|
+
let id = element.getAttribute('itemid');
|
|
75
|
+
let findObj = fieldOptions.find((x) => x.id === id);
|
|
76
|
+
formula = formula + (findObj === null || findObj === void 0 ? void 0 : findObj.price);
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
formula = formula + (element.innerHTML ? element.innerHTML : ' ');
|
|
80
|
+
}
|
|
81
|
+
// If the formula ends with any operator without ending with numbers, then the formula is not correct
|
|
82
|
+
const regex = /^(?!0+$)(?=.*[+\-*/%])(?!.*(?:\s|\+\+|--|%%|\*\*|\+\-|\+\*|\+\%|\-\-|\-\*|\-\%|\*\-|\*\+|\*\%|\%\+|\%\-|\%\/|\%\*|\/\+|\/\-|\/\*|\/\%))(?:(?:\([+\-*/%]*\)|[-+*/%])*)$/;
|
|
83
|
+
if (!regex.test(formula) && formula !== '0' && formula !== '') {
|
|
84
|
+
try {
|
|
85
|
+
// For example, if textContent (formula) value is like "<chip> + <chip> - 456 + 778 * 464 / 645 % 4736"
|
|
86
|
+
// That will be converted here like "0 + 0 - 0 + 0 * 0 / 0 % 0". If the total equals 0 or -0, it means the formula is correct.
|
|
87
|
+
// The eval() JavaScript method will give us a result from the string.
|
|
88
|
+
// If the eval() result is NOT A NUMBER it will go to the error block.
|
|
89
|
+
// const str = formula.replaceAll(' ', '')
|
|
90
|
+
let total = eval(formula);
|
|
91
|
+
console.log(total);
|
|
92
|
+
setIsValid(true);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
setIsValid(false);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
setIsValid(false);
|
|
100
|
+
}
|
|
101
|
+
// setContent(contentEditableDivRef.current.innerHTML);
|
|
102
|
+
};
|
|
103
|
+
function getCursorPosition(contentEditableElm) {
|
|
104
|
+
const selection = window.getSelection();
|
|
105
|
+
const range = selection.getRangeAt(0);
|
|
106
|
+
const clonedRange = range.cloneRange();
|
|
107
|
+
clonedRange.selectNodeContents(contentEditableElm);
|
|
108
|
+
clonedRange.setEnd(range.endContainer, range.endOffset);
|
|
109
|
+
return clonedRange.toString().length;
|
|
110
|
+
}
|
|
111
|
+
const onConditionKeyDown = (event) => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
const content = event.target.textContent.trim();
|
|
114
|
+
const lastChar = content.charAt(content.length - 1);
|
|
115
|
+
const operators = ['%', '*', '-', '+', '/'];
|
|
116
|
+
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
117
|
+
let spanElms = document.querySelectorAll('.formulaSpanElm');
|
|
118
|
+
for (let i = 0; i < spanElms.length; i++) {
|
|
119
|
+
if (spanElms[i]) {
|
|
120
|
+
if (((_a = spanElms[i]) === null || _a === void 0 ? void 0 : _a.classList.value) === 'formulaSpanElm activeSpanElm') {
|
|
121
|
+
(_b = spanElms[i]) === null || _b === void 0 ? void 0 : _b.classList.remove('activeSpanElm');
|
|
122
|
+
let curentSpan = (event.key === 'ArrowLeft' || event.key === 'ArrowUp') ? i === 0 ? spanElms[i] : spanElms[i - 1] : (spanElms.length - 1) === i ? spanElms[i] : spanElms[i + 1];
|
|
123
|
+
curentSpan === null || curentSpan === void 0 ? void 0 : curentSpan.classList.add('activeSpanElm');
|
|
124
|
+
i = spanElms.length;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Allow backspace, delete, select all (Ctrl+A), and certain keys when text is selected
|
|
134
|
+
if (event.key === 'Backspace' || event.key === 'Delete' ||
|
|
135
|
+
(event.key === 'a' && event.ctrlKey) || (event.key === 'A' && event.ctrlKey) ||
|
|
136
|
+
event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowUp' ||
|
|
137
|
+
event.key === 'ArrowDown' || event.key === 'Home' || event.key === 'End' || event.key === 'Shift') {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Allow numbers, *, -, +, %, /, (, ), and single space
|
|
141
|
+
if (!((event.key >= '0' && event.key <= '9') ||
|
|
142
|
+
event.key === '*' || event.key === '-' || event.key === '+' ||
|
|
143
|
+
event.key === '%' || event.key === '/' || event.key === '(' ||
|
|
144
|
+
event.key === ')' || (event.key !== ' ' && event.target.textContent.trim().slice(-1) === ' '))) {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
}
|
|
147
|
+
// Prevent new lines (enter keypress)
|
|
148
|
+
if (event.key === 'Enter') {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
}
|
|
151
|
+
const cursorPosition = getCursorPosition(event.target);
|
|
152
|
+
// Prevent entering operators continuously after each other
|
|
153
|
+
if (operators.includes(event.key) && operators.includes(lastChar) && operators.includes(content[cursorPosition - 2])) {
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const onFilter = (e) => {
|
|
158
|
+
if (e.target.value) {
|
|
159
|
+
let opts = props === null || props === void 0 ? void 0 : props.fieldOptions.filter((x) => { var _a, _b; return (_b = (_a = x === null || x === void 0 ? void 0 : x[props === null || props === void 0 ? void 0 : props.fieldFilterOption]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes(e.target.value.toLowerCase()); });
|
|
160
|
+
setFieldOptions(opts);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
setFieldOptions(props === null || props === void 0 ? void 0 : props.fieldOptions);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const handleKeyPress = (event) => {
|
|
167
|
+
if ((event.key === 'Delete' || event.key === 'Backspace') && contentEditableDivRef.current) {
|
|
168
|
+
const selection = window.getSelection();
|
|
169
|
+
if (selection && selection.rangeCount > 0) {
|
|
170
|
+
const range = selection.getRangeAt(0);
|
|
171
|
+
const cursorElement = range.startContainer.parentElement;
|
|
172
|
+
if (cursorElement === null || cursorElement === void 0 ? void 0 : cursorElement.classList.contains('formulaChipElm')) {
|
|
173
|
+
cursorElement.remove();
|
|
174
|
+
setContent(contentEditableDivRef.current.innerHTML);
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const onClickContentEditable = (e) => {
|
|
182
|
+
var _a, _b, _c;
|
|
183
|
+
if (!e.target.classList.contains('formulaSpanElm')) {
|
|
184
|
+
let contentEditableElement = e.target;
|
|
185
|
+
// contentEditableElement.focus(); // Set focus to the content editable element
|
|
186
|
+
const range = document.createRange(); // Create a new range
|
|
187
|
+
range.selectNodeContents(contentEditableElement); // Select the entire content of the element
|
|
188
|
+
range.collapse(false); // Collapse the range to the end
|
|
189
|
+
const selection = window.getSelection(); // Get the selection object
|
|
190
|
+
selection.removeAllRanges(); // Remove any existing ranges from the selection
|
|
191
|
+
selection.addRange(range);
|
|
192
|
+
(_a = document.querySelector('.activeSpanElm')) === null || _a === void 0 ? void 0 : _a.classList.remove('activeSpanElm');
|
|
193
|
+
let elms = document.querySelectorAll('.formulaSpanElm');
|
|
194
|
+
(_c = (_b = elms[elms.length - 1]) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.add('activeSpanElm');
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const onAddOperator = (event, operator) => {
|
|
199
|
+
var _a, _b;
|
|
200
|
+
let elm = document.querySelector('.activeSpanElm');
|
|
201
|
+
const operators = ['%', '*', '-', '+', '/'];
|
|
202
|
+
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);
|
|
203
|
+
// const cursorPosition = getCursorPosition(elm);
|
|
204
|
+
// Prevent entering operators coonChangeCondition(str);ntinuously after each other
|
|
205
|
+
if (lastChar && operators.includes(lastChar)) {
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (contentEditableDivRef.current.innerHTML !== `<span class='formulaSpanElm'></span>`) {
|
|
210
|
+
elm.innerHTML = elm.innerHTML + operator;
|
|
211
|
+
}
|
|
212
|
+
onChangeCondition();
|
|
213
|
+
};
|
|
214
|
+
const onSave = (event) => {
|
|
215
|
+
let elements = contentEditableDivRef.current.children;
|
|
216
|
+
let formula = '';
|
|
217
|
+
for (let i = 0; i < elements.length; i++) {
|
|
218
|
+
const element = elements[i];
|
|
219
|
+
if (element.classList.contains('formulaChipElm'))
|
|
220
|
+
formula = formula + element.getAttribute('itemid');
|
|
221
|
+
else
|
|
222
|
+
formula = formula + element.innerHTML;
|
|
223
|
+
}
|
|
224
|
+
// setContent(contentEditableDivRef.current.innerHTML)
|
|
225
|
+
priceConditioRef.current.toggle(event);
|
|
226
|
+
props.onSaveFormula(formula);
|
|
227
|
+
};
|
|
228
|
+
const menuContent = [
|
|
229
|
+
{
|
|
230
|
+
template: () => {
|
|
231
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "condition_section flex border-top-1 border-bottom-1 border-gray-200" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "w-6 border-right-1 border-gray-200" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "bg-gray-50 w-full h-auto border-bottom-1 border-gray-200" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-4 h-2rem flex align-items-center" }, { children: (0, jsx_runtime_1.jsxs)("span", { children: [(props === null || props === void 0 ? void 0 : props.fieldOptionTemplateTitle) + ' (0)', " "] }) })), (props === null || props === void 0 ? void 0 : props.fieldFilter) &&
|
|
232
|
+
(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-4 py-2 border-top-1 border-gray-200" }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "relative flex aling-items-center w-full" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "h-full flex align-items-cente justify-content-center w-2rem absolute left-0" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "search-md" }) })), (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { onInput: (e) => onFilter(e), className: "pl-8 w-full", placeholder: props.fieldOptionFilterPlaceholder })] })) }))] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `condition_itemibute_list_sect overflow-auto flex flex-column row-gap-2 px-4 py-2` }, { children: fieldOptions.length > 0 ?
|
|
233
|
+
(0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'grid gap-2 p-2' }, { children: fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.map((item, index) => {
|
|
234
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'max-w-8rem overflow-hidden text-overflow-ellipsis white-space-nowrap bg-blue-100 text-gray-600 cursor-pointer item_chip border-round-sm p-1', onClick: () => onSelecteItem(item), title: item === null || item === void 0 ? void 0 : item.name }, { children: item === null || item === void 0 ? void 0 : item.name }), 'formula__option__' + index));
|
|
235
|
+
}) }))
|
|
236
|
+
:
|
|
237
|
+
(0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'text-gray-700 fobt-bold text-lg text-center' }, { children: (props === null || props === void 0 ? void 0 : props.fieldFilterEmptyMessage) ? props === null || props === void 0 ? void 0 : props.fieldFilterEmptyMessage : 'No Results Found!' })) }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "w-6" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "h-2rem px-4 border-bottom-1 flex column-gap-4 align-items-center border-gray-200" }, { children: props.formulaOperators.map((operator, index) => {
|
|
238
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "condition_operator text-center text-lg w-2 sc_icon_hover cursor-pointer hover:bg-primary-50 border-round-sm", onClick: (e) => onAddOperator(e, operators[operator]) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'text-lg font-bold' }, { children: operators[operator] })) }), 'formula__operator_' + index));
|
|
239
|
+
}) })), (0, jsx_runtime_1.jsx)("div", { onClick: (e) => onClickContentEditable(e), ref: contentEditableDivRef, onKeyDownCapture: handleKeyPress, dangerouslySetInnerHTML: { __html: content }, onKeyDown: (e) => onConditionKeyDown(e), onInput: () => onChangeCondition(), className: `condition_configure px-4 py-2 h-17rem overflow-auto w-full `, contentEditable: true })] }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "condition_footer_section flex align-items-center p-2" }, { 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" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", size: 20 }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ onClick: (e) => onSave(e), className: `w-6 px-4 py-2 hover:bg-primary-50 cursor-pointer sc_icon_hover ${!isValid && 'p-disabled'}` }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "check", size: 20 }) }))] }))] }), 'formula__dev'));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
];
|
|
243
|
+
const addEventListenerForSpan = () => {
|
|
244
|
+
// Select all div elements with the specified class name
|
|
245
|
+
const divElements = document.querySelectorAll('.formulaSpanElm');
|
|
246
|
+
// Loop through each div element
|
|
247
|
+
divElements.forEach(function (divElement) {
|
|
248
|
+
// Add an event listener for the 'click' event to each div element
|
|
249
|
+
divElement.addEventListener('click', function (e) {
|
|
250
|
+
var _a;
|
|
251
|
+
(_a = document.querySelector('.activeSpanElm')) === null || _a === void 0 ? void 0 : _a.classList.remove('activeSpanElm');
|
|
252
|
+
e.target.classList.add('activeSpanElm');
|
|
253
|
+
let index = getCursorPosition(e.target);
|
|
254
|
+
setContentEditableCursorIndex(index);
|
|
255
|
+
// Your event handler code here
|
|
256
|
+
});
|
|
257
|
+
divElement.addEventListener('keydown', function (e) {
|
|
258
|
+
var _a;
|
|
259
|
+
(_a = document.querySelector('.activeSpanElm')) === null || _a === void 0 ? void 0 : _a.classList.remove('activeSpanElm');
|
|
260
|
+
e.target.classList.add('activeSpanElm');
|
|
261
|
+
let index = getCursorPosition(e.target);
|
|
262
|
+
setContentEditableCursorIndex(index);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
const onShowMenu = () => {
|
|
267
|
+
if (props === null || props === void 0 ? void 0 : props.formulaValue) {
|
|
268
|
+
let formulatText;
|
|
269
|
+
const pattern = /[a-f0-9]{24}/g;
|
|
270
|
+
// const ids = props?.formulaValue.match(pattern);
|
|
271
|
+
// console.log(ids)
|
|
272
|
+
const splitPattern = /(?=[+\-*/%])/g;
|
|
273
|
+
// Split the text using the splitPattern
|
|
274
|
+
const splitText = props === null || props === void 0 ? void 0 : props.formulaValue.split(splitPattern);
|
|
275
|
+
for (let i = 0; i < splitText.length; i++) {
|
|
276
|
+
// let chipElm: string = '';
|
|
277
|
+
// let text = splitText[i];
|
|
278
|
+
const id = splitText[i].match(pattern);
|
|
279
|
+
let item = fieldOptions.find((x) => x.id === id[0]);
|
|
280
|
+
const 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" 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>`;
|
|
281
|
+
// chipElm = text.replace(text, t)
|
|
282
|
+
const placeholderText = splitText[i].replace(pattern, '|');
|
|
283
|
+
const textParts = placeholderText.split('|').filter(part => part !== '');
|
|
284
|
+
console.log('Text:', textParts);
|
|
285
|
+
if (textParts.length > 0) {
|
|
286
|
+
for (let z = 0; z < textParts.length; z++) {
|
|
287
|
+
if (z === 0 && (splitText.length - 1) === i)
|
|
288
|
+
formulatText = textParts[z] ? formulatText + `<span class='formulaSpanElm'>${textParts[z]}</span>` + chipElm + `<span class='formulaSpanElm'></span>` : `<span class='formulaSpanElm'></span>`;
|
|
289
|
+
else if (z === 0)
|
|
290
|
+
formulatText = textParts[z] ? formulatText + `<span class='formulaSpanElm'>${textParts[z]}</span>` + chipElm : `<span class='formulaSpanElm'></span>`;
|
|
291
|
+
else
|
|
292
|
+
formulatText = textParts[z] ? formulatText + `<span class='formulaSpanElm'>${textParts[z]}</span>` : `<span class='formulaSpanElm'></span>`;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
if ((splitText.length - 1) === i)
|
|
297
|
+
formulatText = `<span class='formulaSpanElm'></span>` + chipElm + `<span class='formulaSpanElm'></span>`;
|
|
298
|
+
else
|
|
299
|
+
formulatText = `<span class='formulaSpanElm'></span>` + chipElm;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
setContent(formulatText);
|
|
303
|
+
}
|
|
304
|
+
setTimeout(() => {
|
|
305
|
+
addEventListenerForSpan();
|
|
306
|
+
}, 1000);
|
|
307
|
+
};
|
|
308
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "condition_column border-1 flex border-gray-300 border-round-lg overflow-hidden", style: { width: "432px" } }, { children: [(0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { optionLabel: "name", placeholder: (props === null || props === void 0 ? void 0 : props.dropdownPlaceholder) ? props === null || props === void 0 ? void 0 : props.dropdownPlaceholder : 'Select', value: 0, className: "sc_animate w-10rem price_list_manage_price_rule_condition_dropdown border-right-1 border-gray-300 border-none border-noround\t", options: props === null || props === void 0 ? void 0 : props.options }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-auto cursor-pointer", onClick: (e) => { var _a; return (_a = priceConditioRef.current) === null || _a === void 0 ? void 0 : _a.toggle(e); } }), (0, jsx_runtime_1.jsx)(menu_1.Menu, { onShow: onShowMenu, popup: true, popupAlignment: "left", className: 'price_condition_menu p-0', model: menuContent, ref: priceConditioRef, id: "price_condition_menu" })] }), "asadssadsasdsdadasd"));
|
|
309
|
+
};
|
|
310
|
+
exports.default = FormulaCoponent;
|
|
@@ -10,7 +10,7 @@ require("froala-editor/js/plugins.pkgd.min.js");
|
|
|
10
10
|
// import { SvgComponent } from 'sccoreui';
|
|
11
11
|
// import SvgComponent from '../../directives/svg-component';
|
|
12
12
|
// import { Bold, Italic } from '../../assets/svg/svg';
|
|
13
|
-
const FroalaTextEditor = ({ onChange, value, placeholderText, id, className }) => {
|
|
13
|
+
const FroalaTextEditor = ({ onChange, value, placeholderText, id, className, maxlength = 255 }) => {
|
|
14
14
|
const editorRef = (0, react_1.useRef)(null);
|
|
15
15
|
// const html = ``;
|
|
16
16
|
const [editorContent, setEditorContent] = (0, react_1.useState)(value);
|
|
@@ -54,7 +54,7 @@ const FroalaTextEditor = ({ onChange, value, placeholderText, id, className }) =
|
|
|
54
54
|
fontFamilyDefaultSelection: 'sans-serif',
|
|
55
55
|
placeholderText: placeholderText,
|
|
56
56
|
key: "5OA4gB3A3B3E3B5D3E3F-11SLJCKHXOSLMc1YGSGb1ZXHSe1CgB5A4D4G4E3C2A12A19A6B4==",
|
|
57
|
-
|
|
57
|
+
charCounterMax: maxlength,
|
|
58
58
|
toolbarSticky: false,
|
|
59
59
|
quickInsertEnabled: false,
|
|
60
60
|
toolbarInline: false,
|
|
@@ -9170,5 +9170,22 @@ exports.iconList = [
|
|
|
9170
9170
|
</svg>
|
|
9171
9171
|
`,
|
|
9172
9172
|
},
|
|
9173
|
+
{
|
|
9174
|
+
name: "open-bracket",
|
|
9175
|
+
svg: `
|
|
9176
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 11 11" fill="none">
|
|
9177
|
+
<path d="M1.28496 4.66473C1.28496 5.36398 1.37154 6.04824 1.54468 6.71753C1.71783 7.38348 1.96923 8.01114 2.29887 8.60051C2.32884 8.66044 2.34716 8.71372 2.35382 8.76034C2.36048 8.80695 2.35715 8.84691 2.34383 8.88021C2.33051 8.91683 2.31053 8.9468 2.28389 8.97011C2.26058 8.99342 2.23394 9.01506 2.20398 9.03504L1.72948 9.32973C1.47975 8.9468 1.26831 8.56555 1.09516 8.18595C0.922017 7.80969 0.780502 7.4301 0.67062 7.04717C0.560738 6.66092 0.480823 6.27134 0.430877 5.87842C0.38093 5.48218 0.355957 5.07762 0.355957 4.66473C0.355957 4.25516 0.38093 3.85393 0.430877 3.46102C0.480823 3.06477 0.560738 2.67519 0.67062 2.29227C0.780502 1.90602 0.922017 1.52309 1.09516 1.1435C1.26831 0.763906 1.47975 0.382648 1.72948 -0.000274658L2.20398 0.29441C2.23394 0.314388 2.26058 0.336031 2.28389 0.35934C2.31053 0.382648 2.33051 0.412616 2.34383 0.449243C2.35715 0.482541 2.36048 0.522498 2.35382 0.569115C2.34716 0.615732 2.32884 0.669008 2.29887 0.728944C1.96923 1.32164 1.71783 1.95097 1.54468 2.61692C1.37154 3.28287 1.28496 3.96547 1.28496 4.66473Z" fill="#667085"/>
|
|
9178
|
+
</svg>
|
|
9179
|
+
|
|
9180
|
+
|
|
9181
|
+
`,
|
|
9182
|
+
},
|
|
9183
|
+
{
|
|
9184
|
+
name: "close-bracket",
|
|
9185
|
+
svg: `<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 11 11" fill="none">
|
|
9186
|
+
<path d="M1.6555 4.66473C1.6555 3.96547 1.56893 3.28287 1.39578 2.61692C1.22263 1.95097 0.9729 1.32164 0.646583 0.728944C0.616615 0.669008 0.598302 0.615732 0.591642 0.569115C0.584983 0.522498 0.586648 0.482541 0.596637 0.449243C0.609956 0.412616 0.62827 0.382648 0.651578 0.35934C0.678216 0.336031 0.706519 0.314388 0.736487 0.29441L1.21597 -0.000274658C1.46238 0.382648 1.67215 0.763906 1.8453 1.1435C2.01845 1.52309 2.15996 1.90602 2.26984 2.29227C2.37973 2.67519 2.45964 3.06477 2.50959 3.46102C2.55953 3.85393 2.58451 4.25516 2.58451 4.66473C2.58451 5.07762 2.55953 5.48218 2.50959 5.87842C2.45964 6.27134 2.37973 6.66092 2.26984 7.04717C2.15996 7.4301 2.01845 7.80969 1.8453 8.18595C1.67215 8.56555 1.46238 8.9468 1.21597 9.32973L0.736487 9.03504C0.706519 9.01506 0.678216 8.99342 0.651578 8.97011C0.62827 8.9468 0.609956 8.91683 0.596637 8.88021C0.586648 8.84691 0.584983 8.80695 0.591642 8.76034C0.598302 8.71372 0.616615 8.66044 0.646583 8.60051C0.9729 8.01114 1.22263 7.38348 1.39578 6.71753C1.56893 6.04824 1.6555 5.36398 1.6555 4.66473Z" fill="#667085"/>
|
|
9187
|
+
</svg>
|
|
9188
|
+
`,
|
|
9189
|
+
},
|
|
9173
9190
|
];
|
|
9174
9191
|
// console.log(iconList.length)
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProgressSpinner = exports.Skeleton = exports.Chip = exports.Chips = exports.Rating = exports.InputTextarea = exports.InputSwitch = exports.InputMask = exports.SpeedDial = exports.SplitButton = exports.DataViewLayoutOptions = exports.DataView = exports.Toast = exports.InputNumber = exports.OverlayPanel = exports.Tag = exports.Carousel = exports.ToggleButton = exports.CustomSlider = exports.Card = exports.Dialog = exports.Password = exports.confirmPopup = exports.ConfirmDialog = exports.RadioButton = exports.Badge = exports.Tooltip = exports.Calendar = exports.Image = exports.AvatarGroup = exports.Avatar = exports.classNames = exports.Paginator = exports.ScMultiSelect = exports.MultiSelect = exports.FileUpload = exports.TabMenu = exports.TabPanel = exports.TabView = exports.Sidebar = exports.Column = exports.DataTable = exports.Checkbox = exports.AutoComplete = exports.ColorPicker = exports.AccordionTab = exports.Accordion = exports.InputText = exports.Dropdown = exports.Button = void 0;
|
|
4
4
|
exports.ScrollTop = exports.InplaceContent = exports.InplaceDisplay = exports.Inplace = exports.BlockUI = exports.Messages = exports.Message = exports.TieredMenu = exports.Stesp = exports.SlideMenu = exports.PanelMenu = exports.Menubar = exports.Menu = exports.Dock = exports.ContextMenu = exports.Toolbar = exports.SplitterPanel = exports.Splitter = exports.ScrollPanel = exports.Panel = exports.Fieldset = exports.DeferredContent = exports.Timeline = exports.TreeTable = exports.Tree = exports.PickList = exports.OrganizationChart = exports.OrderList = exports.DataScroller = exports.TriStateCheckbox = exports.TreeSelect = exports.SelectButton = exports.MultiStateCheckbox = exports.Mention = exports.ListBox = exports.Knob = exports.Editor = exports.CascadeSelect = exports.FilterOperator = exports.FilterMatchMode = exports.Slider = exports.Galleria = exports.SvgComponent = exports.CircleProgressComponent = exports.ProgressSteps = exports.ProgressBar = exports.Divider = exports.MegaMenu = exports.BreadCrumb = exports.Chart = void 0;
|
|
5
|
-
exports.useOverlayScrollListener = exports.useOverlayListener = exports.useClickOutside = exports.CustomColorPicker = exports.ListBoxDropdown = exports.FroalaTextEditor = exports.FormFields = exports.FormComponent = exports.TreeDropdownSelect = exports.DatePicker = exports.MultiSelectDropDown = exports.Terminal = exports.StyleClass = void 0;
|
|
5
|
+
exports.useOverlayScrollListener = exports.useOverlayListener = exports.useClickOutside = exports.CustomColorPicker = exports.ListBoxDropdown = exports.FroalaTextEditor = exports.FormFields = exports.FormComponent = exports.TreeDropdownSelect = exports.DatePicker = exports.FormulaCoponent = exports.MultiSelectDropDown = exports.Terminal = exports.StyleClass = void 0;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const client_1 = tslib_1.__importDefault(require("react-dom/client"));
|
|
@@ -208,6 +208,8 @@ var terminal_1 = require("./components/terminal/terminal");
|
|
|
208
208
|
Object.defineProperty(exports, "Terminal", { enumerable: true, get: function () { return tslib_1.__importDefault(terminal_1).default; } });
|
|
209
209
|
var multi_select_dropdown_1 = require("./components/multi-select-dropdown/multi-select-dropdown");
|
|
210
210
|
Object.defineProperty(exports, "MultiSelectDropDown", { enumerable: true, get: function () { return tslib_1.__importDefault(multi_select_dropdown_1).default; } });
|
|
211
|
+
var FormulaCoponent_1 = require("./components/formula-template/FormulaCoponent");
|
|
212
|
+
Object.defineProperty(exports, "FormulaCoponent", { enumerable: true, get: function () { return tslib_1.__importDefault(FormulaCoponent_1).default; } });
|
|
211
213
|
var date_picker_1 = require("./components/date-picker/date-picker");
|
|
212
214
|
Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return tslib_1.__importDefault(date_picker_1).default; } });
|
|
213
215
|
var treeDropdownSelect_1 = require("./components/treeDropdownSelect/treeDropdownSelect");
|
|
@@ -2,5 +2,5 @@ import 'froala-editor/css/froala_editor.pkgd.min.css';
|
|
|
2
2
|
import 'froala-editor/css/froala_style.min.css';
|
|
3
3
|
import 'froala-editor/js/plugins.pkgd.min.js';
|
|
4
4
|
import { FroalaTextEditorTypes } from '../types/type';
|
|
5
|
-
declare const FroalaTextEditor: ({ onChange, value, placeholderText, id, className }: FroalaTextEditorTypes) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const FroalaTextEditor: ({ onChange, value, placeholderText, id, className, maxlength }: FroalaTextEditorTypes) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default FroalaTextEditor;
|
|
@@ -185,6 +185,7 @@ export interface FroalaTextEditorTypes {
|
|
|
185
185
|
id: string;
|
|
186
186
|
className?: string;
|
|
187
187
|
isLoading?: boolean;
|
|
188
|
+
maxlength?: number;
|
|
188
189
|
}
|
|
189
190
|
export interface ListBoxDropdownTypes {
|
|
190
191
|
values: any;
|
|
@@ -278,7 +279,7 @@ export interface ConfigurValueOptionsTypes {
|
|
|
278
279
|
value: number;
|
|
279
280
|
optionType: "INCREASE_BY_VALUE" | "DECREASE_BY_VALUE" | "INCREASE_BY_PERCENTAGE" | "DECREASE_BY_PERCENTAGE" | "MANUAL" | "CALCULATION";
|
|
280
281
|
}
|
|
281
|
-
type MathematicalOperator = "
|
|
282
|
+
type MathematicalOperator = "addition" | "subtraction" | "multiplication" | "division" | "percentile" | "openBracket" | "closeBracket";
|
|
282
283
|
export interface FormulaTemplateTypes {
|
|
283
284
|
className?: string;
|
|
284
285
|
inputClassName?: string;
|
|
@@ -287,11 +288,16 @@ export interface FormulaTemplateTypes {
|
|
|
287
288
|
inputPlaceholder?: string;
|
|
288
289
|
headerTemplate?: React.ReactNode;
|
|
289
290
|
headerTemplateClassName?: string;
|
|
290
|
-
formulaOperators
|
|
291
|
+
formulaOperators: MathematicalOperator[];
|
|
291
292
|
formulaElemectClassName?: string;
|
|
292
293
|
formulaElemectPlaceholder?: string;
|
|
294
|
+
formulaValue: string;
|
|
293
295
|
fieldOptionTemplateTitle?: string;
|
|
294
|
-
|
|
296
|
+
fieldOptions: any[];
|
|
297
|
+
fieldFilter?: boolean | undefined;
|
|
298
|
+
fieldFilterEmptyMessage?: string;
|
|
299
|
+
fieldFilterOption?: string;
|
|
300
|
+
fieldOptionFilterPlaceholder?: string;
|
|
295
301
|
fieldOptionTemplate?: React.ReactNode;
|
|
296
302
|
fieldOptionClassName?: string;
|
|
297
303
|
formulaChipTemplate?: React.ReactNode;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export { default as ScrollTop } from "./components/scroll-top/scrollTop";
|
|
|
94
94
|
export { default as StyleClass } from "./components/style-class/styleClass";
|
|
95
95
|
export { default as Terminal } from "./components/terminal/terminal";
|
|
96
96
|
export { default as MultiSelectDropDown } from './components/multi-select-dropdown/multi-select-dropdown';
|
|
97
|
+
export { default as FormulaCoponent } from './components/formula-template/FormulaCoponent';
|
|
97
98
|
export { default as DatePicker } from "./components/date-picker/date-picker";
|
|
98
99
|
export { default as TreeDropdownSelect } from './components/treeDropdownSelect/treeDropdownSelect';
|
|
99
100
|
export { default as FormComponent } from "./components/form/form";
|
package/package.json
CHANGED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const dropdown_1 = require("primereact/dropdown");
|
|
7
|
-
const inputtext_1 = require("primereact/inputtext");
|
|
8
|
-
const svg_component_1 = tslib_1.__importDefault(require("../../directives/svg-component"));
|
|
9
|
-
const menu_1 = require("primereact/menu");
|
|
10
|
-
const FormulaTemplate = (props) => {
|
|
11
|
-
console.log(props);
|
|
12
|
-
const priceConditioRef = (0, react_1.useRef)(null);
|
|
13
|
-
const [isValid, setIsValid] = (0, react_1.useState)(false);
|
|
14
|
-
const [selectedAttr, setSelectedAttr] = (0, react_1.useState)();
|
|
15
|
-
const attributes = [
|
|
16
|
-
{
|
|
17
|
-
id: '34t3246324687',
|
|
18
|
-
name: 'Test1',
|
|
19
|
-
code: '34sdf'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
id: '34t32463287',
|
|
23
|
-
name: 'Test2',
|
|
24
|
-
code: 't34sdf'
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: '34t32464687',
|
|
28
|
-
name: 'Test3',
|
|
29
|
-
code: 'dshbf'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: '34t32324687',
|
|
33
|
-
name: 'Test4',
|
|
34
|
-
code: '323sdf'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: '3446324687',
|
|
38
|
-
name: 'Test5',
|
|
39
|
-
code: '30edf'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: '34324687',
|
|
43
|
-
name: 'Test6',
|
|
44
|
-
code: '343sdf'
|
|
45
|
-
}
|
|
46
|
-
];
|
|
47
|
-
const onSelecteAttr = (attr) => {
|
|
48
|
-
if (selectedAttr) {
|
|
49
|
-
if (selectedAttr.find((id) => id === attr.id))
|
|
50
|
-
setSelectedAttr(selectedAttr.filter((id) => id !== attr.id));
|
|
51
|
-
else
|
|
52
|
-
setSelectedAttr([attr.id, ...selectedAttr]);
|
|
53
|
-
}
|
|
54
|
-
else
|
|
55
|
-
setSelectedAttr([attr.id]);
|
|
56
|
-
};
|
|
57
|
-
const onChangeCondition = (e) => {
|
|
58
|
-
let equation = e.target.textContent.replace(/[a-zA-Z0-9<>]+/g, '0');
|
|
59
|
-
const regex = /^(?!.*(?:\+\+|--|%%|\*\*|\+\-|\+\*|\+\%|\-\-|\-\*|\-\%|\*\-|\*\+|\*\%|\%\+|\%\-|\%\/|\%\*|\/\+|\/\-|\/\*|\/\%))(?:(?:\([+\-*/%]*\)|[-+*/%])*)$/;
|
|
60
|
-
if (!regex.test(equation)) {
|
|
61
|
-
try {
|
|
62
|
-
// let total = eval(equation)
|
|
63
|
-
setIsValid(true);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
setIsValid(false);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
setIsValid(false);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const onConditionKeyDown = (event) => {
|
|
74
|
-
// Allow backspace, delete, select all (Ctrl+A), and certain keys when text is selected
|
|
75
|
-
if (event.key === 'Backspace' || event.key === 'Delete' ||
|
|
76
|
-
(event.key === 'a' && event.ctrlKey) || (event.key === 'A' && event.ctrlKey) ||
|
|
77
|
-
event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowUp' ||
|
|
78
|
-
event.key === 'ArrowDown' || event.key === 'Home' || event.key === 'End') {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// Allow numbers, *, -, +, %, /, (, ), and single space
|
|
82
|
-
if (!((event.key >= '0' && event.key <= '9') ||
|
|
83
|
-
event.key === '*' || event.key === '-' || event.key === '+' ||
|
|
84
|
-
event.key === '%' || event.key === '/' || event.key === '(' ||
|
|
85
|
-
event.key === ')' || (event.key === ' ' && event.target.textContent.trim().slice(-1) !== ' '))) {
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
}
|
|
88
|
-
// Prevent new lines (enter keypress)
|
|
89
|
-
if (event.key === 'Enter') {
|
|
90
|
-
event.preventDefault();
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const menuContent = [
|
|
94
|
-
{
|
|
95
|
-
template: () => {
|
|
96
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "condition_section flex border-top-1 border-bottom-1 border-gray-200" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "w-6 border-right-1 border-gray-200" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "bg-gray-50 w-full h-auto border-bottom-1 border-gray-200" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-4 border-bottom-1 border-gray-200 h-2rem flex align-items-center" }, { children: (0, jsx_runtime_1.jsxs)("span", { children: [(props === null || props === void 0 ? void 0 : props.fieldOptionTemplateTitle) + ' (0)', " "] }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "px-4 py-2" }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "relative flex aling-items-center w-full" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "h-full flex align-items-cente justify-content-center w-3rem absolute left-0" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "search-md" }) })), (0, jsx_runtime_1.jsx)(inputtext_1.InputText, { className: "pl-12 w-full", placeholder: props.fieldOptionSearchPlaceholder })] })) }))] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `condition_attribute_list_sect overflow-auto flex flex-column row-gap-2 px-4 py-2` }, { children: attributes.map((attr) => {
|
|
97
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ onClick: () => onSelecteAttr(attr), className: `h-3rem hover:bg-primary-25 flex justify-content-between cursor-pointer align-items-center p-3 border-round-lg ${(selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.find((id) => id === attr.id)) && 'bg-primary-25'}` }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "attr_name max-w-14rem text-md text-gray-700 font-semibold overflow-hidden text-overflow-ellipsis white-space-nowrap", title: attr.name }, { children: attr.name })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex align-items-center" }, { children: [(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "scan", className: "mr-1", size: 14 }), (0, jsx_runtime_1.jsx)("span", Object.assign({ className: "attr_code text-sm max-w-13rem overflow-hidden text-overflow-ellipsis white-space-nowrap", title: attr.code }, { children: attr.code }))] }))] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "" }, { children: (selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.find((id) => id === attr.id)) &&
|
|
98
|
-
(0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "check", color: "#162578", size: 20 }) }))] })));
|
|
99
|
-
}) }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "w-6" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "h-2rem px-4 border-bottom-1 flex column-gap-4 align-items-center border-gray-200" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "condition_operator w-2 sc_icon_hover cursor-pointer hover:bg-primary-50 border-round-sm" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "plus", size: 20 }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "condition_operator w-2 sc_icon_hover cursor-pointer hover:bg-primary-50 border-round-sm" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "minus", size: 20 }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "condition_operator w-2 sc_icon_hover cursor-pointer hover:bg-primary-50 border-round-sm" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", size: 20 }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "condition_operator w-2 sc_icon_hover cursor-pointer hover:bg-primary-50 border-round-sm" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "percent-01", size: 20 }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "condition_operator w-2 sc_icon_hover cursor-pointer hover:bg-primary-50 border-round-sm" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "divide-01", size: 20 }) }))] })), (0, jsx_runtime_1.jsx)("div", { onKeyDown: (e) => onConditionKeyDown(e), onInput: (e) => onChangeCondition(e), className: `condition_configure px-4 py-2 h-17rem overflow-auto w-full`, contentEditable: true })] }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "condition_footer_section flex align-items-center p-2" }, { 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" }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "x-close", size: 20 }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `w-6 px-4 py-2 hover:bg-primary-50 cursor-pointer sc_icon_hover ${!isValid && 'p-disabled'}` }, { children: (0, jsx_runtime_1.jsx)(svg_component_1.default, { icon: "check", size: 20 }) }))] }))] })));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
];
|
|
103
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "condition_column border-1 flex border-gray-300 border-round-lg overflow-hidden", style: { width: "432px" } }, { children: [(0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { optionLabel: "name", placeholder: (props === null || props === void 0 ? void 0 : props.dropdownPlaceholder) ? props === null || props === void 0 ? void 0 : props.dropdownPlaceholder : 'Select', value: 0, className: "sc_animate w-10rem price_list_manage_price_rule_condition_dropdown border-right-1 border-gray-300 border-none border-noround\t", options: props === null || props === void 0 ? void 0 : props.options }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-auto cursor-pointer", onClick: (e) => { var _a; return (_a = priceConditioRef.current) === null || _a === void 0 ? void 0 : _a.toggle(e); } }), (0, jsx_runtime_1.jsx)(menu_1.Menu, { popup: true, popupAlignment: "left", className: 'price_condition_menu p-0', model: menuContent, ref: priceConditioRef, id: "price_condition_menu" })] })));
|
|
104
|
-
};
|
|
105
|
-
exports.default = FormulaTemplate;
|