@daracl/form 0.0.20 → 0.0.22

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.
@@ -1,59 +1,112 @@
1
1
  (function(factory) {
2
2
  typeof define === "function" && define.amd ? define(factory) : factory();
3
- })(function() {
3
+ })((function() {
4
4
  "use strict";
5
- function isArray$1(value) {
5
+ function isArray(value) {
6
6
  return Array.isArray(value);
7
7
  }
8
- function isNil(value) {
9
- return value === null || value === void 0;
8
+ function isFunction$1(value) {
9
+ return typeof value === "function";
10
10
  }
11
- function isString$1(value) {
12
- return typeof value === "string" || value instanceof String;
11
+ function isPlainObject(value) {
12
+ return value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
13
13
  }
14
- function isEmpty$1(value) {
15
- if (isNil(value)) {
16
- return true;
14
+ const isMergeObject = (value) => isPlainObject(value) || value !== null && typeof value === "object" && Object.getPrototypeOf(value) === null;
15
+ const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
16
+ function setOwn(target, key, value) {
17
+ Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });
18
+ }
19
+ function mergeSource(target, source, excludeKeys) {
20
+ const copies = /* @__PURE__ */ new WeakMap();
21
+ const tasks = [];
22
+ function copy2(value, current) {
23
+ if (value === null || typeof value !== "object") return value;
24
+ if (copies.has(value)) return copies.get(value);
25
+ let result;
26
+ if (isArray(value)) {
27
+ result = isArray(current) ? current : [];
28
+ tasks.push(() => mergeArray(result, value));
29
+ } else if (isMergeObject(value)) {
30
+ result = isMergeObject(current) ? current : Object.create(Object.getPrototypeOf(value));
31
+ tasks.push(() => mergeObject(result, value));
32
+ } else if (value instanceof Date) {
33
+ result = new Date(value.getTime());
34
+ } else if (value instanceof RegExp) {
35
+ result = new RegExp(value.source, value.flags);
36
+ result.lastIndex = value.lastIndex;
37
+ } else if (value instanceof Map) {
38
+ result = /* @__PURE__ */ new Map();
39
+ tasks.push(() => value.forEach((item, key) => result.set(copy2(key), copy2(item))));
40
+ } else if (value instanceof Set) {
41
+ result = /* @__PURE__ */ new Set();
42
+ tasks.push(() => value.forEach((item) => result.add(copy2(item))));
43
+ } else {
44
+ return value;
45
+ }
46
+ copies.set(value, result);
47
+ return result;
17
48
  }
18
- if (isString$1(value)) {
19
- return value.trim() === "";
49
+ function mergeObject(dst, src) {
50
+ for (const key of Object.keys(src)) {
51
+ if (excludeKeys.has(key) || key === "__proto__" || key === "constructor" || key === "prototype") continue;
52
+ const value = src[key];
53
+ if (value === void 0) continue;
54
+ setOwn(dst, key, copy2(value, hasOwn(dst, key) ? dst[key] : void 0));
55
+ }
56
+ }
57
+ function mergeArray(dst, src) {
58
+ const seen = new Set(dst);
59
+ for (const value of src) {
60
+ const item = copy2(value);
61
+ if (value !== null && typeof value === "object" || Number.isNaN(item) || !seen.has(item)) {
62
+ seen.add(item);
63
+ dst.push(item);
64
+ }
65
+ }
20
66
  }
21
- if (Array.isArray(value)) {
22
- return value.length === 0;
67
+ copies.set(source, target);
68
+ if (isArray(source) && isArray(target)) tasks.push(() => mergeArray(target, source));
69
+ else tasks.push(() => mergeObject(target, source));
70
+ while (tasks.length) tasks.pop()();
71
+ }
72
+ function objectDeepMerge(...values) {
73
+ if (values.length < 1) {
74
+ return values;
23
75
  }
24
- if (typeof value === "object") {
25
- return Object.keys(value).length === 0;
76
+ let excludeKeys = /* @__PURE__ */ new Set();
77
+ let sources = values;
78
+ const last = values[values.length - 1];
79
+ if (isMergeObject(last) && hasOwn(last, "_excludeKeys") && isArray(last._excludeKeys)) {
80
+ excludeKeys = new Set(last._excludeKeys.map(String));
81
+ sources = values.slice(0, -1);
26
82
  }
27
- return false;
83
+ let result = {};
84
+ for (let index = 0; index < sources.length; index++) {
85
+ const value = sources[index];
86
+ if (isArray(value) || isMergeObject(value)) {
87
+ mergeSource(result, value, index === 0 ? /* @__PURE__ */ new Set() : excludeKeys);
88
+ }
89
+ }
90
+ return result;
28
91
  }
29
- function isFunction$1(value) {
30
- return typeof value === "function" || value instanceof Function;
92
+ function hasProperty(obj, prop) {
93
+ return obj != null && obj != void 0 && Object.prototype.hasOwnProperty.call(obj, prop);
31
94
  }
32
- function isNumeric(value, typeIgnore = false) {
33
- if (typeIgnore === true) return !Number.isNaN(value);
34
- return (typeof value === "number" || isString$1(value) && value.trim() !== "" && !isNaN(parseFloat(value))) && isFinite(Number(value));
95
+ function isString$1(value) {
96
+ return typeof value === "string";
35
97
  }
36
- function leftPad(str, len, ch = "0") {
37
- return pad(str, len, ch, "l");
98
+ function isBlank(value) {
99
+ return value === null || value === void 0 || isString$1(value) && value.trim() === "";
38
100
  }
39
- function leftPadClamp(str, len, ch = "0") {
40
- return pad(str, len, ch, "l", true);
101
+ function isNil$1(value) {
102
+ return value === null || value === void 0;
41
103
  }
42
- function pad(orginStr, size, ch, type = "l", clamp = false) {
43
- let str = "";
44
- if (isEmpty$1(orginStr)) {
45
- str = "";
46
- } else {
47
- str = isString$1(orginStr) ? orginStr : `${orginStr}`;
48
- }
49
- const strLength = str.length;
50
- if (strLength > size) {
51
- return clamp ? str.slice(0, size) : str;
52
- }
53
- const len = size - strLength;
54
- if (len < 1) return str;
55
- const padStr = ch.repeat(len);
56
- return type === "l" ? padStr + str : str + padStr;
104
+ function isNumeric$1(value, typeIgnore = false) {
105
+ if (typeIgnore === true) return !Number.isNaN(value);
106
+ return (typeof value === "number" || isString$1(value) && value.trim() !== "" && !isNaN(parseFloat(value))) && isFinite(Number(value));
107
+ }
108
+ function isUndefined(value) {
109
+ return typeof value === "undefined";
57
110
  }
58
111
  const xssFilter = {
59
112
  "&": "&amp;",
@@ -62,7 +115,7 @@
62
115
  '"': "&quot;",
63
116
  "'": "&#39;"
64
117
  };
65
- const replaceXss = (inputText) => {
118
+ function xss(inputText) {
66
119
  let returnText = inputText;
67
120
  if (returnText) {
68
121
  Object.keys(xssFilter).forEach((key) => {
@@ -70,46 +123,37 @@
70
123
  });
71
124
  }
72
125
  return returnText;
126
+ }
127
+ function getHashCode(value) {
128
+ if (!value.length) return 0;
129
+ let hash = 0;
130
+ for (let index = 0; index < value.length; index++) hash = (hash << 5) - hash + value.charCodeAt(index) | 0;
131
+ return String(hash).replace(/-/g, "_");
132
+ }
133
+ const styleClassSplit = (styleClass) => {
134
+ return styleClass.trim().split(/\s+/).filter(Boolean);
73
135
  };
74
- const hasOwnProp = (obj, key) => {
75
- return obj.hasOwnProperty(key);
76
- };
77
- const isBlank = (value) => {
78
- if (value === null) return true;
79
- if (value === "") return true;
80
- if (typeof value === "undefined") return true;
81
- if (typeof value === "string" && (value === "" || value.replace(/\s/g, "") === "")) return true;
82
- return false;
83
- };
84
- const isUndefined = (value) => {
85
- return typeof value === "undefined";
86
- };
87
- const isFunction = (value) => {
88
- return typeof value === "function";
89
- };
90
- const isString = (value) => {
91
- return typeof value === "string";
92
- };
136
+ function templateToElement(html) {
137
+ const template = document.createElement("template");
138
+ template.innerHTML = html;
139
+ return template.content.firstElementChild;
140
+ }
141
+ function resolveClassName(value, params) {
142
+ if (!value) return [];
143
+ return styleClassSplit(isFunction$1(value) ? value(params) : value);
144
+ }
93
145
  const isNumber = (value) => {
94
- if (isBlank(value)) {
95
- return false;
96
- }
97
- value = +value;
98
- return !isNaN(value);
99
- };
100
- const isArray = (value) => {
101
- return isArray$1(value);
146
+ return !isBlank(value) && isNumeric$1(+value, true);
102
147
  };
103
- const isEmpty = (value) => isUndefined(value) || value == null;
104
148
  const isTabType = (field) => {
105
- return field && field.renderType === "tab";
149
+ return (field == null ? void 0 : field.renderType) === "tab";
106
150
  };
107
151
  const isGridType = (field) => {
108
- return field && field.renderType === "grid";
152
+ return (field == null ? void 0 : field.renderType) === "grid";
109
153
  };
110
154
  const replaceXssField = (field) => {
111
155
  field.$xssName = getXssFieldName(field);
112
- field.label = replaceXss(field.label);
156
+ field.label = xss(field.label);
113
157
  return field;
114
158
  };
115
159
  const ignoreValueField = (field) => {
@@ -119,120 +163,17 @@
119
163
  if (isUndefined(field.$xssName)) {
120
164
  let returnText = field.name;
121
165
  if (returnText) {
122
- Object.keys(xssFilter).forEach((key) => {
123
- returnText = returnText.replaceAll(key, "_");
124
- });
166
+ returnText = returnText.replace(/[&<>"']/g, "_");
125
167
  }
126
168
  return "df_" + returnText;
127
169
  }
128
170
  return field.$xssName;
129
171
  };
130
- const getHashCode = (str) => {
131
- let hash = 0;
132
- if (str.length == 0) return hash;
133
- for (let i = 0; i < str.length; i++) {
134
- let tmpChar = str.charCodeAt(i);
135
- hash = (hash << 5) - hash + tmpChar;
136
- hash = hash & hash;
137
- }
138
- return String(hash).replaceAll(/-/g, "_");
139
- };
140
- const isHiddenField = (field) => {
141
- if (field.renderType === "hidden") {
142
- return true;
143
- }
144
- return false;
145
- };
146
- const templateToElement = (htmlTemplate) => {
147
- const template = document.createElement("template");
148
- template.innerHTML = htmlTemplate;
149
- return template.content.firstElementChild;
150
- };
151
- function isPlainObject(obj) {
152
- if (typeof obj !== "object" || obj === null) {
153
- return false;
154
- }
155
- let proto = obj;
156
- while (Object.getPrototypeOf(proto) !== null) {
157
- proto = Object.getPrototypeOf(proto);
158
- }
159
- return Object.getPrototypeOf(obj) === proto;
160
- }
161
- function isObject(value) {
162
- return typeof value === "object" && value !== null && !isArray(value);
163
- }
164
- function isDate(value) {
165
- return value instanceof Date && !isNaN(value.valueOf());
166
- }
167
- const merge = (...value) => {
168
- let reval = value[0];
169
- if (!isPlainObject(reval) || isEmpty(reval)) {
170
- return reval;
171
- }
172
- let i = 1;
173
- if (Object.keys(reval).length > 0) {
174
- i = 0;
175
- reval = isArray(reval) ? [] : {};
176
- }
177
- const argLen = value.length;
178
- for (; i < argLen; i += 1) {
179
- cloneDeep(reval, value[i]);
180
- }
181
- return reval;
172
+ const isHiddenField = (field) => (field == null ? void 0 : field.renderType) === "hidden";
173
+ const merge = (...values) => {
174
+ if (!isPlainObject(values[0])) return values[0];
175
+ return objectDeepMerge(...values, {});
182
176
  };
183
- function cloneDeep(dst, src) {
184
- if (isObject(src)) {
185
- return cloneObjectDeep(dst, src);
186
- }
187
- if (isArray(src)) {
188
- return cloneArrayDeep(dst, src);
189
- }
190
- if (isDate(src)) {
191
- return new src.constructor(src);
192
- }
193
- return src;
194
- }
195
- function cloneObjectDeep(dst, src) {
196
- if (isFunction(src)) {
197
- return src;
198
- }
199
- for (const key of Object.keys(src)) {
200
- const val = src[key];
201
- if (isUndefined(val)) {
202
- continue;
203
- }
204
- if (val === null) {
205
- dst[key] = val;
206
- } else if (isFunction(val)) {
207
- dst[key] = val;
208
- } else if (isEmpty(dst[key])) {
209
- dst[key] = cloneDeep(isArray(val) ? [] : {}, val);
210
- } else if (!isObject(val)) {
211
- dst[key] = val;
212
- } else {
213
- cloneDeep(dst[key], val);
214
- }
215
- }
216
- return dst;
217
- }
218
- function cloneArrayDeep(dst, src) {
219
- const isObj = isPlainObject(dst);
220
- for (let i = 0; i < src.length; i += 1) {
221
- const val = src[i];
222
- let newVal;
223
- if (val == null) {
224
- newVal = val;
225
- } else {
226
- newVal = cloneDeep(isArray(val) ? [] : {}, val);
227
- }
228
- if (isObj) {
229
- dst[i] = newVal;
230
- } else {
231
- dst.push(newVal);
232
- }
233
- }
234
- return dst;
235
- }
236
177
  class Render {
237
178
  constructor(form, field, rowElement) {
238
179
  var _a;
@@ -275,8 +216,8 @@
275
216
  setValueItems(value) {
276
217
  }
277
218
  static getDescriptionTemplate(field) {
278
- const classNames = field.descriptionClass ? replaceXss(field.descriptionClass) : "";
279
- const style = field.descriptionStyle ? 'style="' + replaceXss(field.descriptionStyle) + '"' : "";
219
+ const classNames = field.descriptionClass ? xss(field.descriptionClass) : "";
220
+ const style = field.descriptionStyle ? 'style="' + xss(field.descriptionStyle) + '"' : "";
280
221
  return field.description ? `<div class="df-description ${classNames}" ${style}>${field.description}</div>` : "";
281
222
  }
282
223
  changeEventCall(field, e, rederInfo, fieldValue) {
@@ -293,7 +234,7 @@
293
234
  const valueKey = Render.valuesValueKey(field);
294
235
  for (let val of field.listItem.list) {
295
236
  let changeVal = val[valueKey];
296
- if (isString(fieldValue)) {
237
+ if (isString$1(fieldValue)) {
297
238
  if (changeVal == fieldValue) {
298
239
  valuesItem.push(val);
299
240
  break;
@@ -428,7 +369,7 @@
428
369
  if (field.different) {
429
370
  const diffFieldName = field.different.field;
430
371
  const diffField = field.$instance.getForm().getField(diffFieldName);
431
- if (!isEmpty(diffField) && field.$instance.getValue() == diffField.$instance.getValue()) {
372
+ if (!isNil$1(diffField) && field.$instance.getValue() == diffField.$instance.getValue()) {
432
373
  result.message = field.different.message;
433
374
  return result;
434
375
  }
@@ -436,7 +377,7 @@
436
377
  if (field.identical) {
437
378
  const diffFieldName = field.identical.field;
438
379
  const diffField = field.$instance.getForm().getField(diffFieldName);
439
- if (!isEmpty(diffField) && field.$instance.getValue() != diffField.$instance.getValue()) {
380
+ if (!isNil$1(diffField) && field.$instance.getValue() != diffField.$instance.getValue()) {
440
381
  result.message = field.identical.message;
441
382
  return result;
442
383
  }
@@ -919,17 +860,14 @@
919
860
  fieldStyle.valueClass = fieldStyle.labelStyle ? "df-col-full" : "";
920
861
  }
921
862
  }
922
- fieldStyle.fieldClass = spaceReplace(fieldStyle.fieldClass);
923
- fieldStyle.labelClass = spaceReplace(fieldStyle.labelClass);
924
- fieldStyle.valueClass = spaceReplace(fieldStyle.valueClass);
863
+ fieldStyle.fieldClass = resolveClassName(fieldStyle.fieldClass).join(" ");
864
+ fieldStyle.labelClass = resolveClassName(fieldStyle.labelClass).join(" ");
865
+ fieldStyle.valueClass = resolveClassName(fieldStyle.valueClass).join(" ");
925
866
  return fieldStyle;
926
867
  }
927
868
  function orientationClassName(orientation) {
928
869
  return orientation === "horizontal" ? "df-horizontal" : "df-vertical";
929
870
  }
930
- function spaceReplace(str) {
931
- return str.replace(/\s+/g, " ").trim();
932
- }
933
871
  class CheckboxRender extends Render {
934
872
  constructor(field, rowElement, daraForm) {
935
873
  var _a, _b;
@@ -988,11 +926,11 @@
988
926
  const valueKey = Render.valuesValueKey(field);
989
927
  templates.push(` <div class="df-field"><div class="df-field-group">`);
990
928
  (_b = (_a = field.listItem) == null ? void 0 : _a.list) == null ? void 0 : _b.forEach((val) => {
991
- const checkVal = val[valueKey];
929
+ const checkVal = String(val[valueKey] ?? "");
992
930
  templates.push(`
993
931
  <span class="df-field-item ${orientationClassName(field.listItem.orientation ?? OrientationMap.horizontal)}">
994
932
  <label>
995
- <input type="checkbox" name="${fieldName}" value="${checkVal ? replaceXss(checkVal) : ""}" class="df-form-field df-checkbox" ${val.selected ? "checked" : ""} ${val.disabled ? "disabled" : ""} />
933
+ <input type="checkbox" name="${fieldName}" value="${checkVal ? xss(checkVal) : ""}" class="df-form-field df-checkbox" ${val.selected ? "checked" : ""} ${val.disabled ? "disabled" : ""} />
996
934
  ${Render.valuesLabelValue(labelKey, val)}
997
935
  </label>
998
936
  </span>
@@ -1470,7 +1408,7 @@
1470
1408
  this.setFileList(this.fileList, true);
1471
1409
  }
1472
1410
  setValue(value) {
1473
- if (isArray$1(value)) {
1411
+ if (isArray(value)) {
1474
1412
  this.setValueItems(value);
1475
1413
  }
1476
1414
  this.element.value = "";
@@ -1511,7 +1449,7 @@
1511
1449
  }
1512
1450
  createField() {
1513
1451
  const field = this.field;
1514
- const fieldTemplate = isEmpty(field.template) ? "" : isString(field.template) ? field.template : field.template();
1452
+ const fieldTemplate = isNil$1(field.template) ? "" : isString$1(field.template) ? field.template : field.template();
1515
1453
  const fieldContainerElement = this.rowElement.querySelector(".df-field-container");
1516
1454
  fieldContainerElement.innerHTML = ` <div class="df-field">
1517
1455
  ${fieldTemplate}
@@ -1718,6 +1656,56 @@
1718
1656
  return validResult;
1719
1657
  }
1720
1658
  }
1659
+ function isFunction(value) {
1660
+ return typeof value === "function";
1661
+ }
1662
+ function isString(value) {
1663
+ return typeof value === "string";
1664
+ }
1665
+ function isNil(value) {
1666
+ return value === null || value === void 0;
1667
+ }
1668
+ function isEmpty(value) {
1669
+ if (isNil(value)) {
1670
+ return true;
1671
+ }
1672
+ if (isString(value)) {
1673
+ return value.trim() === "";
1674
+ }
1675
+ if (Array.isArray(value)) {
1676
+ return value.length === 0;
1677
+ }
1678
+ if (typeof value === "object") {
1679
+ return Object.keys(value).length === 0;
1680
+ }
1681
+ return false;
1682
+ }
1683
+ function isNumeric(value, typeIgnore = false) {
1684
+ if (typeIgnore === true) return !Number.isNaN(value);
1685
+ return (typeof value === "number" || isString(value) && value.trim() !== "" && !isNaN(parseFloat(value))) && isFinite(Number(value));
1686
+ }
1687
+ function leftPad(str, len, ch = "0") {
1688
+ return pad(str, len, ch, "l");
1689
+ }
1690
+ function leftPadClamp(str, len, ch = "0") {
1691
+ return pad(str, len, ch, "l", true);
1692
+ }
1693
+ function pad(orginStr, size, ch, type = "l", clamp2 = false) {
1694
+ let str = "";
1695
+ if (isEmpty(orginStr)) {
1696
+ str = "";
1697
+ } else {
1698
+ str = isString(orginStr) ? orginStr : `${orginStr}`;
1699
+ }
1700
+ const strLength = str.length;
1701
+ if (strLength > size) {
1702
+ return clamp2 ? str.slice(0, size) : str;
1703
+ }
1704
+ const len = size - strLength;
1705
+ if (len < 1) return str;
1706
+ const padStr = ch.repeat(len);
1707
+ return type === "l" ? padStr + str : str + padStr;
1708
+ }
1721
1709
  let localeMessage$1 = {
1722
1710
  year: "Year",
1723
1711
  month: "Month",
@@ -2656,7 +2644,7 @@
2656
2644
  */
2657
2645
  afterChangeDatepicker() {
2658
2646
  const formatValue = this.currentDate.format(this.dateFormat);
2659
- if (this.options.afterChangeDatepicker && isFunction$1(this.options.afterChangeDatepicker)) {
2647
+ if (this.options.afterChangeDatepicker && isFunction(this.options.afterChangeDatepicker)) {
2660
2648
  this.options.afterChangeDatepicker(formatValue, this.viewMode);
2661
2649
  }
2662
2650
  }
@@ -2666,7 +2654,7 @@
2666
2654
  */
2667
2655
  beforeChangeDatepicker() {
2668
2656
  const formatValue = this.currentDate.format(this.dateFormat);
2669
- if (this.options.beforeChangeDatepicker && isFunction$1(this.options.beforeChangeDatepicker)) {
2657
+ if (this.options.beforeChangeDatepicker && isFunction(this.options.beforeChangeDatepicker)) {
2670
2658
  const reval = this.options.beforeChangeDatepicker(formatValue, (result) => {
2671
2659
  if (result === false) {
2672
2660
  return;
@@ -2788,7 +2776,7 @@
2788
2776
  }
2789
2777
  const startYear = +currentYear - 8;
2790
2778
  this.datetimeElement.querySelector(".ddtp-header-year").textContent = `${startYear} ~ ${startYear + 15}`;
2791
- const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2779
+ const beforeDrawDateFlag = isFunction(this.options.beforeDrawDate);
2792
2780
  const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2793
2781
  const calHTML = [];
2794
2782
  for (let i = 0; i < 16; i++) {
@@ -2869,7 +2857,7 @@
2869
2857
  return;
2870
2858
  }
2871
2859
  this.datetimeElement.querySelector(".ddtp-header-month").textContent = this.currentDate.format("MMMM");
2872
- const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2860
+ const beforeDrawDateFlag = isFunction(this.options.beforeDrawDate);
2873
2861
  const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2874
2862
  const calHTML = [];
2875
2863
  for (let i = 0; i < 12; i++) {
@@ -2930,7 +2918,7 @@
2930
2918
  } else {
2931
2919
  monthFirstDate.addDate(-(7 + day));
2932
2920
  }
2933
- const beforeDrawDateFlag = isFunction$1(this.options.beforeDrawDate);
2921
+ const beforeDrawDateFlag = isFunction(this.options.beforeDrawDate);
2934
2922
  const beforeDrawDateFn = beforeDrawDateFlag ? this.options.beforeDrawDate : false;
2935
2923
  const calHTML = [];
2936
2924
  for (let i = 0; i < 42; i++) {
@@ -3021,7 +3009,7 @@
3021
3009
  let dateOnSelectEvent;
3022
3010
  this.field.rendererOptions = Object.assign({}, this.field.rendererOptions);
3023
3011
  if (typeof this.field.rendererOptions.onSelect !== "undefined") {
3024
- dateOnSelectEvent = typeof this.field.rendererOptions.onSelect;
3012
+ dateOnSelectEvent = this.field.rendererOptions.onSelect;
3025
3013
  }
3026
3014
  if (isUndefined(this.field.rendererOptions.mode)) {
3027
3015
  if (this.field.renderType == "datemonth" || this.field.renderType == "datehour") {
@@ -3031,7 +3019,7 @@
3031
3019
  }
3032
3020
  }
3033
3021
  this.field.rendererOptions.onSelect = (dt, e) => {
3034
- if (dateOnSelectEvent) {
3022
+ if (isFunction$1(dateOnSelectEvent)) {
3035
3023
  dateOnSelectEvent(dt, e);
3036
3024
  }
3037
3025
  this.setValue(dt);
@@ -3221,6 +3209,10 @@
3221
3209
  }
3222
3210
  }
3223
3211
  reset() {
3212
+ var _a;
3213
+ for (const childField of this.field.children ?? []) {
3214
+ (_a = childField.$tabForm) == null ? void 0 : _a.resetForm();
3215
+ }
3224
3216
  }
3225
3217
  getElement() {
3226
3218
  return this.rowElement;
@@ -3362,7 +3354,7 @@
3362
3354
  valueItem = valueItem ?? {};
3363
3355
  for (let columnField of addColumns) {
3364
3356
  columnField.$instance = new columnField.$renderType(columnField, addRowElement == null ? void 0 : addRowElement.querySelector(`#${columnField.$xssName}`), this.gridForm);
3365
- if (valueItem[columnField.$orgin.name]) {
3357
+ if (hasProperty(valueItem, columnField.$orgin.name)) {
3366
3358
  columnField.$instance.setValue(valueItem[columnField.$orgin.name]);
3367
3359
  }
3368
3360
  }
@@ -3388,8 +3380,7 @@
3388
3380
  */
3389
3381
  removeFieldInfo(rowIdx) {
3390
3382
  let removeFieldArrs = [];
3391
- console.log("rowIdx : ", rowIdx);
3392
- if (isEmpty(rowIdx)) {
3383
+ if (isNil$1(rowIdx)) {
3393
3384
  for (let key in this.allAddRowInfo) {
3394
3385
  removeFieldArrs = removeFieldArrs.concat(this.allAddRowInfo[key]);
3395
3386
  }
@@ -3899,7 +3890,7 @@
3899
3890
  formData[key] = value;
3900
3891
  }
3901
3892
  } else {
3902
- if (!isEmpty(fieldInfo.name)) {
3893
+ if (!isNil$1(fieldInfo.name)) {
3903
3894
  formData[fieldInfo.name] = fieldValue;
3904
3895
  }
3905
3896
  }
@@ -3928,7 +3919,7 @@
3928
3919
  formData.set(key, value);
3929
3920
  }
3930
3921
  } else {
3931
- if (!isEmpty(fieldInfo.name)) {
3922
+ if (!isNil$1(fieldInfo.name)) {
3932
3923
  formData.set(fieldInfo.$validName, fieldValue);
3933
3924
  }
3934
3925
  }
@@ -4004,7 +3995,7 @@
4004
3995
  rowElement.classList.add("df-row", parentFieldStyle.rowStyleClass ?? "");
4005
3996
  let idx = 0;
4006
3997
  for (const childField of field.children) {
4007
- if (isEmpty(childField)) {
3998
+ if (isNil$1(childField)) {
4008
3999
  throw new Error(`parent field :[${field.$validName}], children index ${idx}, empty [${childField}]`);
4009
4000
  }
4010
4001
  childField.$parent = field;
@@ -4088,10 +4079,18 @@
4088
4079
  }
4089
4080
  function initFormOptions(options) {
4090
4081
  const opts = merge({}, DEFAULT_OPTIONS, options);
4082
+ opts.fields = normalizeFields(opts.fields);
4091
4083
  return opts;
4092
4084
  }
4093
4085
  function setDefaultOptions(options) {
4094
4086
  DEFAULT_OPTIONS = merge({}, DEFAULT_OPTIONS, options);
4087
+ DEFAULT_OPTIONS.fields = normalizeFields(DEFAULT_OPTIONS.fields);
4088
+ }
4089
+ function normalizeFields(fields) {
4090
+ return (fields ?? []).filter((field) => field != null).map((field) => {
4091
+ if (Array.isArray(field.children)) field.children = normalizeFields(field.children);
4092
+ return field;
4093
+ });
4095
4094
  }
4096
4095
  let DEFAULT_OPTIONS = {
4097
4096
  style: {
@@ -4187,6 +4186,7 @@
4187
4186
  }
4188
4187
  };
4189
4188
  this.addField = (field) => {
4189
+ if (!normalizeFields([field]).length) return;
4190
4190
  this.options.fields.push(field);
4191
4191
  this.formTemplate.addRow(field);
4192
4192
  this.conditionCheck();
@@ -4255,10 +4255,10 @@
4255
4255
  this.destroy = () => {
4256
4256
  this.formElement.className = this.orginFormStyleClass;
4257
4257
  this.formElement.replaceChildren();
4258
+ delete allInstance[this.selector];
4258
4259
  for (const key in this) {
4259
- if (hasOwnProp(this, key)) {
4260
+ if (hasProperty(this, key)) {
4260
4261
  delete this[key];
4261
- delete allInstance[this.selector];
4262
4262
  }
4263
4263
  }
4264
4264
  };
@@ -4266,8 +4266,10 @@
4266
4266
  return this.options.fields;
4267
4267
  };
4268
4268
  this.setFields = (fields) => {
4269
- this.options.fields = fields;
4270
- this.createForm(fields);
4269
+ this.options.fields = normalizeFields(fields);
4270
+ this.formElement.replaceChildren();
4271
+ this.formValue = {};
4272
+ this.createForm(this.options.fields);
4271
4273
  };
4272
4274
  this.options = initFormOptions(options);
4273
4275
  Language$1.set(message2);
@@ -4454,28 +4456,21 @@
4454
4456
  fieldInfo.$instance.setDescription(desc);
4455
4457
  }
4456
4458
  static instance(ele) {
4457
- let element;
4458
- if (isString(ele)) {
4459
- element = document.querySelector(ele);
4460
- } else {
4461
- element = ele;
4462
- }
4463
- element = element;
4459
+ const element = isString$1(ele) ? document.querySelector(ele) : ele;
4460
+ if (!element) return void 0;
4464
4461
  let selector = element.getAttribute(SEQ_ATTR_KEY);
4465
- if (isUndefined(selector) || isBlank(selector)) {
4462
+ if (isBlank(selector)) {
4466
4463
  const keys = Object.keys(allInstance);
4467
- if (keys.length > 1) {
4468
- throw new Error(`selector empty : [${selector}]`);
4469
- }
4464
+ if (keys.length > 1) throw new Error(`selector empty : [${selector}]`);
4470
4465
  selector = keys[0];
4471
- return allInstance[selector];
4472
4466
  }
4467
+ return selector ? allInstance[selector] : void 0;
4473
4468
  }
4474
4469
  getFieldInfoMap() {
4475
4470
  return this.fieldInfoMap;
4476
4471
  }
4477
4472
  };
4478
- _DaraForm.VERSION = `${"0.0.20"}`;
4473
+ _DaraForm.VERSION = `${"0.0.22"}`;
4479
4474
  _DaraForm.validator = {
4480
4475
  string: (value, field) => {
4481
4476
  return stringValidator(value, field);
@@ -4493,5 +4488,5 @@
4493
4488
  window.Daracl = window.Daracl || {};
4494
4489
  window.Daracl.form = DaraForm;
4495
4490
  }
4496
- });
4491
+ }));
4497
4492
  //# sourceMappingURL=daracl.form.umd.js.map