@nickaux/form-configurator 1.1.219 → 1.1.221
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.
|
@@ -39043,7 +39043,15 @@ if (process.env.NODE_ENV === "production") {
|
|
|
39043
39043
|
m$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
39044
39044
|
}
|
|
39045
39045
|
const checkUserRole = (p_user, p_role) => {
|
|
39046
|
-
|
|
39046
|
+
var _a, _b;
|
|
39047
|
+
if (p_user === null) {
|
|
39048
|
+
return false;
|
|
39049
|
+
}
|
|
39050
|
+
const userRole = ((_b = (_a = p_user == null ? void 0 : p_user.appUser) == null ? void 0 : _a.roles) == null ? void 0 : _b.length) ? p_user.appUser.roles : ["user"];
|
|
39051
|
+
if (userRole) {
|
|
39052
|
+
return userRole.includes(p_role);
|
|
39053
|
+
}
|
|
39054
|
+
return false;
|
|
39047
39055
|
};
|
|
39048
39056
|
const autoFormatValue = (p_value) => {
|
|
39049
39057
|
let r_value = p_value;
|
|
@@ -39765,7 +39773,7 @@ const Field = forwardRef(({ field, children }, ref2) => {
|
|
|
39765
39773
|
var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
39766
39774
|
const [renderCounter, setRenderCounter] = useState(0);
|
|
39767
39775
|
let previousFocusedElement = null;
|
|
39768
|
-
const isUserAdmin = checkUserRole(field.formManager.options.user);
|
|
39776
|
+
const isUserAdmin = checkUserRole(field.formManager.options.user, "admin");
|
|
39769
39777
|
useImperativeHandle(ref2, () => ({
|
|
39770
39778
|
updateField: () => {
|
|
39771
39779
|
previousFocusedElement = document.activeElement;
|
|
@@ -136620,9 +136628,6 @@ class TypeFile extends TypeDefault {
|
|
|
136620
136628
|
}
|
|
136621
136629
|
}
|
|
136622
136630
|
class TypeColorPicker extends TypeDefault {
|
|
136623
|
-
// initValue(p_field) {
|
|
136624
|
-
// return "";
|
|
136625
|
-
// }
|
|
136626
136631
|
getComponent() {
|
|
136627
136632
|
return ({
|
|
136628
136633
|
getValue: getValue2 = () => "",
|
|
@@ -136630,15 +136635,12 @@ class TypeColorPicker extends TypeDefault {
|
|
|
136630
136635
|
onChange: onChange3 = false,
|
|
136631
136636
|
initComponent = false
|
|
136632
136637
|
}, ...props) => {
|
|
136633
|
-
const [fieldValue2, setFieldValue] = useState(
|
|
136634
|
-
getValue2() ? getValue2() : ""
|
|
136635
|
-
);
|
|
136638
|
+
const [fieldValue2, setFieldValue] = useState(getValue2() || "");
|
|
136636
136639
|
const [colorPickerColorValue, setColorPickerColorValue] = useState(
|
|
136637
|
-
getValue2()
|
|
136640
|
+
getValue2() || ""
|
|
136638
136641
|
);
|
|
136639
136642
|
const [displayColorPicker, setDisplayColorPicker] = useState(false);
|
|
136640
|
-
const popoverRef = useRef(
|
|
136641
|
-
const inputRef = useRef(false);
|
|
136643
|
+
const popoverRef = useRef(null);
|
|
136642
136644
|
const changeValue = () => {
|
|
136643
136645
|
setFieldValue(colorPickerColorValue);
|
|
136644
136646
|
if (onChange3) {
|
|
@@ -136657,31 +136659,98 @@ class TypeColorPicker extends TypeDefault {
|
|
|
136657
136659
|
setDisplayColorPicker(false);
|
|
136658
136660
|
};
|
|
136659
136661
|
const handleOutsideClick = (e2) => {
|
|
136660
|
-
if (!popoverRef.current.contains(e2.target)) {
|
|
136662
|
+
if (popoverRef.current && !popoverRef.current.contains(e2.target)) {
|
|
136661
136663
|
handleClose();
|
|
136662
136664
|
}
|
|
136663
136665
|
};
|
|
136664
|
-
const
|
|
136665
|
-
|
|
136666
|
-
|
|
136667
|
-
|
|
136668
|
-
"
|
|
136669
|
-
|
|
136670
|
-
|
|
136671
|
-
|
|
136672
|
-
|
|
136673
|
-
|
|
136674
|
-
|
|
136675
|
-
}
|
|
136666
|
+
const selectTransparent = () => {
|
|
136667
|
+
setColorPickerColorValue("transparent");
|
|
136668
|
+
setFieldValue("transparent");
|
|
136669
|
+
if (onChange3) {
|
|
136670
|
+
onChange3("transparent");
|
|
136671
|
+
}
|
|
136672
|
+
handleClose();
|
|
136673
|
+
};
|
|
136674
|
+
const copyToClipboard = (text2, format2) => {
|
|
136675
|
+
navigator.clipboard.writeText(text2).then(
|
|
136676
|
+
() => {
|
|
136677
|
+
alert(`Valeur ${format2} copiée : ${text2}`);
|
|
136678
|
+
},
|
|
136679
|
+
() => {
|
|
136680
|
+
alert("Échec de la copie dans le presse-papiers !");
|
|
136676
136681
|
}
|
|
136677
136682
|
);
|
|
136678
|
-
}
|
|
136679
|
-
|
|
136680
|
-
|
|
136681
|
-
|
|
136682
|
-
|
|
136683
|
-
|
|
136683
|
+
};
|
|
136684
|
+
useEffect(() => {
|
|
136685
|
+
if (displayColorPicker) {
|
|
136686
|
+
document.addEventListener("mousedown", handleOutsideClick);
|
|
136687
|
+
} else {
|
|
136688
|
+
document.removeEventListener("mousedown", handleOutsideClick);
|
|
136689
|
+
}
|
|
136690
|
+
return () => {
|
|
136691
|
+
document.removeEventListener("mousedown", handleOutsideClick);
|
|
136692
|
+
};
|
|
136693
|
+
}, [displayColorPicker]);
|
|
136694
|
+
const displayLabel = !param.displayLabel || param.displayLabel !== "notDisplay";
|
|
136695
|
+
const label = displayLabel && param.label ? /* @__PURE__ */ jsx$2("label", { children: param.label }) : "";
|
|
136696
|
+
const getColorLabel = () => {
|
|
136697
|
+
if (fieldValue2 === "transparent" || !fieldValue2) {
|
|
136698
|
+
return {
|
|
136699
|
+
rgba: "0, 0, 0, 0",
|
|
136700
|
+
hex: "transparent"
|
|
136701
|
+
};
|
|
136702
|
+
}
|
|
136703
|
+
const rgb = fieldValue2.startsWith("#") ? {
|
|
136704
|
+
r: parseInt(fieldValue2.substring(1, 3), 16),
|
|
136705
|
+
g: parseInt(fieldValue2.substring(3, 5), 16),
|
|
136706
|
+
b: parseInt(fieldValue2.substring(5, 7), 16)
|
|
136707
|
+
} : null;
|
|
136708
|
+
if (rgb) {
|
|
136709
|
+
return {
|
|
136710
|
+
rgba: `${rgb.r}, ${rgb.g}, ${rgb.b}, 1`,
|
|
136711
|
+
hex: fieldValue2
|
|
136712
|
+
};
|
|
136713
|
+
}
|
|
136714
|
+
return {
|
|
136715
|
+
rgba: "Invalid color",
|
|
136716
|
+
hex: ""
|
|
136684
136717
|
};
|
|
136718
|
+
};
|
|
136719
|
+
const colorInfo = getColorLabel();
|
|
136720
|
+
const cssWrapper = {
|
|
136721
|
+
display: "flex",
|
|
136722
|
+
alignItems: "center",
|
|
136723
|
+
gap: "10px"
|
|
136724
|
+
};
|
|
136725
|
+
const cssColor = {
|
|
136726
|
+
width: "36px",
|
|
136727
|
+
height: "14px",
|
|
136728
|
+
borderRadius: "2px",
|
|
136729
|
+
background: fieldValue2 === "transparent" ? "repeating-linear-gradient(45deg, #fff, #fff 10px, #ccc 10px, #ccc 20px)" : `${fieldValue2}`,
|
|
136730
|
+
border: "1px solid #ccc"
|
|
136731
|
+
};
|
|
136732
|
+
const cssColorInfo = {
|
|
136733
|
+
fontSize: "12px",
|
|
136734
|
+
fontStyle: "italic",
|
|
136735
|
+
lineHeight: "1.4",
|
|
136736
|
+
cursor: "pointer"
|
|
136737
|
+
// Curseur interactif
|
|
136738
|
+
};
|
|
136739
|
+
if (this.userAllow === "read-only") {
|
|
136740
|
+
return /* @__PURE__ */ jsxs("div", { style: cssWrapper, children: [
|
|
136741
|
+
/* @__PURE__ */ jsx$2("div", { style: cssColor }),
|
|
136742
|
+
/* @__PURE__ */ jsxs("div", { style: cssColorInfo, children: [
|
|
136743
|
+
/* @__PURE__ */ jsxs("div", { onClick: () => copyToClipboard(colorInfo.rgba, "RGBA"), children: [
|
|
136744
|
+
"RGBA: ",
|
|
136745
|
+
colorInfo.rgba
|
|
136746
|
+
] }),
|
|
136747
|
+
/* @__PURE__ */ jsxs("div", { onClick: () => copyToClipboard(colorInfo.hex, "HEX"), children: [
|
|
136748
|
+
"HEX: ",
|
|
136749
|
+
colorInfo.hex
|
|
136750
|
+
] })
|
|
136751
|
+
] })
|
|
136752
|
+
] });
|
|
136753
|
+
} else {
|
|
136685
136754
|
const cssSwatch = {
|
|
136686
136755
|
padding: "5px",
|
|
136687
136756
|
background: "#fff",
|
|
@@ -136695,34 +136764,82 @@ class TypeColorPicker extends TypeDefault {
|
|
|
136695
136764
|
zIndex: "30",
|
|
136696
136765
|
padding: "8px",
|
|
136697
136766
|
backgroundColor: "#FFFFFF",
|
|
136698
|
-
border: "solid 1px #
|
|
136767
|
+
border: "solid 1px #ccc",
|
|
136699
136768
|
borderRadius: "5px",
|
|
136700
136769
|
boxShadow: "0 0 5px rgba(0,0,0,0.2)"
|
|
136701
136770
|
};
|
|
136702
|
-
React__default.useEffect(() => {
|
|
136703
|
-
if (displayColorPicker) {
|
|
136704
|
-
document.addEventListener("mousedown", handleOutsideClick);
|
|
136705
|
-
} else {
|
|
136706
|
-
document.removeEventListener("mousedown", handleOutsideClick);
|
|
136707
|
-
}
|
|
136708
|
-
return () => {
|
|
136709
|
-
document.removeEventListener("mousedown", handleOutsideClick);
|
|
136710
|
-
};
|
|
136711
|
-
}, [displayColorPicker]);
|
|
136712
136771
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
136713
|
-
|
|
136772
|
+
label,
|
|
136773
|
+
/* @__PURE__ */ jsxs("div", { style: cssWrapper, children: [
|
|
136774
|
+
/* @__PURE__ */ jsx$2("div", { style: cssSwatch, onClick: handleClick, children: /* @__PURE__ */ jsx$2("div", { style: cssColor }) }),
|
|
136775
|
+
/* @__PURE__ */ jsxs("div", { style: cssColorInfo, children: [
|
|
136776
|
+
/* @__PURE__ */ jsxs("div", { onClick: () => copyToClipboard(colorInfo.rgba, "RGBA"), children: [
|
|
136777
|
+
"RGBA: ",
|
|
136778
|
+
colorInfo.rgba
|
|
136779
|
+
] }),
|
|
136780
|
+
/* @__PURE__ */ jsxs("div", { onClick: () => copyToClipboard(colorInfo.hex, "HEX"), children: [
|
|
136781
|
+
"HEX: ",
|
|
136782
|
+
colorInfo.hex
|
|
136783
|
+
] })
|
|
136784
|
+
] })
|
|
136785
|
+
] }),
|
|
136714
136786
|
displayColorPicker ? /* @__PURE__ */ jsxs("div", { ref: popoverRef, style: cssPopover, children: [
|
|
136715
136787
|
/* @__PURE__ */ jsx$2(
|
|
136716
136788
|
ChromePicker,
|
|
136717
136789
|
{
|
|
136718
|
-
ref: inputRef,
|
|
136719
136790
|
color: colorPickerColorValue,
|
|
136720
136791
|
onChange: pickValue
|
|
136721
136792
|
}
|
|
136722
136793
|
),
|
|
136723
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
136724
|
-
/* @__PURE__ */ jsx$2(
|
|
136725
|
-
|
|
136794
|
+
/* @__PURE__ */ jsxs("div", { style: { marginTop: "10px" }, children: [
|
|
136795
|
+
/* @__PURE__ */ jsx$2(
|
|
136796
|
+
"button",
|
|
136797
|
+
{
|
|
136798
|
+
type: "button",
|
|
136799
|
+
onClick: selectTransparent,
|
|
136800
|
+
style: {
|
|
136801
|
+
width: "100%",
|
|
136802
|
+
marginBottom: "5px",
|
|
136803
|
+
background: "#eee",
|
|
136804
|
+
border: "1px solid #ccc",
|
|
136805
|
+
padding: "5px",
|
|
136806
|
+
cursor: "pointer"
|
|
136807
|
+
},
|
|
136808
|
+
children: "Aucune couleur"
|
|
136809
|
+
}
|
|
136810
|
+
),
|
|
136811
|
+
/* @__PURE__ */ jsx$2(
|
|
136812
|
+
"button",
|
|
136813
|
+
{
|
|
136814
|
+
type: "button",
|
|
136815
|
+
onClick: handleClose,
|
|
136816
|
+
style: {
|
|
136817
|
+
width: "48%",
|
|
136818
|
+
marginRight: "4%",
|
|
136819
|
+
background: "#f5f5f5",
|
|
136820
|
+
border: "1px solid #ccc",
|
|
136821
|
+
padding: "5px",
|
|
136822
|
+
cursor: "pointer"
|
|
136823
|
+
},
|
|
136824
|
+
children: "Annuler"
|
|
136825
|
+
}
|
|
136826
|
+
),
|
|
136827
|
+
/* @__PURE__ */ jsx$2(
|
|
136828
|
+
"button",
|
|
136829
|
+
{
|
|
136830
|
+
type: "button",
|
|
136831
|
+
onClick: changeValue,
|
|
136832
|
+
style: {
|
|
136833
|
+
width: "48%",
|
|
136834
|
+
background: "#007BFF",
|
|
136835
|
+
border: "1px solid #007BFF",
|
|
136836
|
+
color: "white",
|
|
136837
|
+
padding: "5px",
|
|
136838
|
+
cursor: "pointer"
|
|
136839
|
+
},
|
|
136840
|
+
children: "Choisir"
|
|
136841
|
+
}
|
|
136842
|
+
)
|
|
136726
136843
|
] })
|
|
136727
136844
|
] }) : null
|
|
136728
136845
|
] });
|
|
@@ -148851,6 +148968,7 @@ class FormManager {
|
|
|
148851
148968
|
});
|
|
148852
148969
|
}
|
|
148853
148970
|
});
|
|
148971
|
+
// loop on all fields in fieldsByNode and get value if visible ( recursive )
|
|
148854
148972
|
__publicField(this, "getVisibleValue", (field = {
|
|
148855
148973
|
id: "__result__",
|
|
148856
148974
|
children: this.formElements.map((o2) => this.fieldsByPath[o2.id]),
|
|
@@ -148951,6 +149069,7 @@ class FormManager {
|
|
|
148951
149069
|
});
|
|
148952
149070
|
}
|
|
148953
149071
|
}
|
|
149072
|
+
// use for repeater
|
|
148954
149073
|
createDynamicField(field, p_position, p_data = null) {
|
|
148955
149074
|
const uniqueId = v4();
|
|
148956
149075
|
this.dynamicPathPart[uniqueId] = p_position;
|
|
@@ -149011,6 +149130,11 @@ class FormManager {
|
|
|
149011
149130
|
delete this.dynamicPathPart[p_itemId];
|
|
149012
149131
|
delete this.fields[p_itemId];
|
|
149013
149132
|
}
|
|
149133
|
+
//
|
|
149134
|
+
// removeDynamicField(p_uniqueId){
|
|
149135
|
+
// this.dynamicPathPart[p_uniqueId] =false;
|
|
149136
|
+
// }
|
|
149137
|
+
//
|
|
149014
149138
|
getField(p_item, v_item, custom_id, parentUid) {
|
|
149015
149139
|
if (typeField[v_item.format]) {
|
|
149016
149140
|
const currentTypeField = new typeField[v_item.format](
|
|
@@ -149035,6 +149159,7 @@ class FormManager {
|
|
|
149035
149159
|
return false;
|
|
149036
149160
|
}
|
|
149037
149161
|
}
|
|
149162
|
+
// get field path like path for data
|
|
149038
149163
|
getNormalizedFieldPath(path) {
|
|
149039
149164
|
const normalizedFieldPath = [];
|
|
149040
149165
|
var paths = ("" + path).split("__");
|
|
@@ -149151,6 +149276,8 @@ class FormManager {
|
|
|
149151
149276
|
return newField;
|
|
149152
149277
|
}) : [];
|
|
149153
149278
|
}
|
|
149279
|
+
initValueForm() {
|
|
149280
|
+
}
|
|
149154
149281
|
resolveFieldRefs(formJson, fieldsRefJson) {
|
|
149155
149282
|
const resolveRefsInForm = (formItem) => {
|
|
149156
149283
|
if (formItem.fieldRef && fieldsRefJson[formItem.fieldRef]) {
|
|
@@ -149186,6 +149313,45 @@ class FormManager {
|
|
|
149186
149313
|
}
|
|
149187
149314
|
return formData;
|
|
149188
149315
|
}
|
|
149316
|
+
// getMaxContentLevel(p_item) {
|
|
149317
|
+
// let maxContentLevel = 0;
|
|
149318
|
+
// let rootItem = p_item;
|
|
149319
|
+
// // Vérifier si l'élément est un tableau
|
|
149320
|
+
// if (p_item && Array.isArray(p_item)) {
|
|
149321
|
+
// p_item.forEach((item) => {
|
|
149322
|
+
// if (item?.content) {
|
|
149323
|
+
// // Appeler récursivement pour trouver le niveau maximum
|
|
149324
|
+
// const currentContent = this.getMaxContentLevel(item.content);
|
|
149325
|
+
// if (currentContent.lvl > maxContentLevel) {
|
|
149326
|
+
// maxContentLevel = currentContent.lvl;
|
|
149327
|
+
// rootItem = item;
|
|
149328
|
+
// }
|
|
149329
|
+
// }
|
|
149330
|
+
// });
|
|
149331
|
+
// }
|
|
149332
|
+
// // Retourner le niveau de contenu maximum et l'élément racine associé
|
|
149333
|
+
// return { lvl: maxContentLevel + 1, rootItem: rootItem };
|
|
149334
|
+
// }
|
|
149335
|
+
// getMaxDepthOfContent(content) {
|
|
149336
|
+
// let maxDepth = 0;
|
|
149337
|
+
// const traverse = (items, depth = 1) => {
|
|
149338
|
+
// if (Array.isArray(items)) {
|
|
149339
|
+
// items.forEach((item) => {
|
|
149340
|
+
// if (item?.content && Array.isArray(item.content)) {
|
|
149341
|
+
// traverse(item.content, depth + 1);
|
|
149342
|
+
// }
|
|
149343
|
+
// if (item?.forms?.content && Array.isArray(item.forms.content)) {
|
|
149344
|
+
// traverse(item.forms.content, depth + 1);
|
|
149345
|
+
// }
|
|
149346
|
+
// });
|
|
149347
|
+
// }
|
|
149348
|
+
// if (depth > maxDepth) {
|
|
149349
|
+
// maxDepth = depth;
|
|
149350
|
+
// }
|
|
149351
|
+
// };
|
|
149352
|
+
// traverse(content);
|
|
149353
|
+
// return maxDepth;
|
|
149354
|
+
// }
|
|
149189
149355
|
/**
|
|
149190
149356
|
* Charge et fusionne un nœud JSON représentant un formulaire ou une structure de données.
|
|
149191
149357
|
*
|
|
@@ -149200,7 +149366,7 @@ class FormManager {
|
|
|
149200
149366
|
if (p_item == null ? void 0 : p_item._fieldRefLinked) {
|
|
149201
149367
|
return p_item;
|
|
149202
149368
|
}
|
|
149203
|
-
if (p_item.fieldRef) {
|
|
149369
|
+
if (p_item.fieldRef && !(p_item == null ? void 0 : p_item._fieldRefLinked)) {
|
|
149204
149370
|
if ((_a = this.fieldsRef) == null ? void 0 : _a[p_item.fieldRef]) {
|
|
149205
149371
|
p_item.id = (p_item == null ? void 0 : p_item.id) ?? p_item.fieldRef;
|
|
149206
149372
|
p_item = _.merge(
|
|
@@ -149208,6 +149374,7 @@ class FormManager {
|
|
|
149208
149374
|
this.fieldsRef[p_item.fieldRef],
|
|
149209
149375
|
_.cloneDeep(p_item)
|
|
149210
149376
|
);
|
|
149377
|
+
p_item.content = this.fieldsRef[p_item.fieldRef].content;
|
|
149211
149378
|
const refContent = (_b = this.fieldsRef[p_item.fieldRef]) == null ? void 0 : _b.content;
|
|
149212
149379
|
if (refContent) {
|
|
149213
149380
|
if (((_c = p_item.content) == null ? void 0 : _c.length) && Array.isArray(p_item.content)) {
|
|
@@ -149247,6 +149414,8 @@ class FormManager {
|
|
|
149247
149414
|
}
|
|
149248
149415
|
return p_item;
|
|
149249
149416
|
}
|
|
149417
|
+
//initNodevValue: (p_node) => {},
|
|
149418
|
+
// check value of current field from validity param
|
|
149250
149419
|
checkValidity(item, p_TreeId = null, p_data = null) {
|
|
149251
149420
|
let resultCheckValidity = { type: "success", message: "" };
|
|
149252
149421
|
if (item["validity"] && Array.isArray(item["validity"]) && item["validity"].length) {
|
|
@@ -149296,7 +149465,8 @@ class FormManager {
|
|
|
149296
149465
|
resultCheckValidity = regex.test(testFieldValue) ? { type: "success", message: "" } : { type: "error", message: condition["message"] };
|
|
149297
149466
|
break;
|
|
149298
149467
|
case "mandatory":
|
|
149299
|
-
resultCheckValidity = testFieldValue !== "" && testFieldValue !== null && testFieldValue !== void 0 && testFieldValue !== false &&
|
|
149468
|
+
resultCheckValidity = testFieldValue !== "" && testFieldValue !== null && testFieldValue !== void 0 && testFieldValue !== false && // and test empty object or empty array
|
|
149469
|
+
(typeof testFieldValue !== "object" || typeof testFieldValue === "object" && Object.keys(testFieldValue).length !== 0) ? { type: "success", message: "" } : { type: "error", message: condition["message"] };
|
|
149300
149470
|
break;
|
|
149301
149471
|
case "compare":
|
|
149302
149472
|
resultCheckValidity = testValue(
|
|
@@ -149324,6 +149494,7 @@ class FormManager {
|
|
|
149324
149494
|
this.validityResult[item.id] = resultCheckValidity;
|
|
149325
149495
|
return resultCheckValidity;
|
|
149326
149496
|
}
|
|
149497
|
+
// check only first condition
|
|
149327
149498
|
checkCondition(item, p_TreeId = null, p_data = null) {
|
|
149328
149499
|
const evaluateCondition = (condition, treeId) => {
|
|
149329
149500
|
const operator = condition["operator"];
|