@stemy/ngx-dynamic-form 19.9.6 → 19.9.7

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.
@@ -175,33 +175,37 @@ function convertToNumber(value, defaultVal) {
175
175
  const num = Number(value);
176
176
  return isNaN(num) ? defaultVal ?? value : num;
177
177
  }
178
- function getFieldByPath(field, path) {
179
- if (field.path === path) {
178
+ function getFieldByPath(lookup, path) {
179
+ const field = ObjectUtils.isArray(lookup) ? null : lookup;
180
+ if (field?.path === path) {
180
181
  return field;
181
182
  }
182
- if (!field.fieldGroup)
183
+ const fields = ObjectUtils.isArray(lookup) ? lookup : field.fieldGroup;
184
+ if (!fields)
183
185
  return null;
184
- for (const sf of field.fieldGroup) {
186
+ for (const sf of fields) {
185
187
  const found = getFieldByPath(sf, path);
186
188
  if (found)
187
189
  return found;
188
190
  }
189
191
  return null;
190
192
  }
191
- function getFieldsByPredicate(field, cb) {
192
- if (cb(field)) {
193
+ function getFieldsByPredicate(lookup, cb) {
194
+ const field = ObjectUtils.isArray(lookup) ? null : lookup;
195
+ if (field && cb(field)) {
193
196
  return [field];
194
197
  }
195
- if (!field.fieldGroup)
196
- return [];
197
198
  const results = [];
198
- for (const sf of field.fieldGroup) {
199
+ const fields = ObjectUtils.isArray(lookup) ? lookup : field.fieldGroup;
200
+ if (!fields)
201
+ return results;
202
+ for (const sf of fields) {
199
203
  results.push(...getFieldsByPredicate(sf, cb));
200
204
  }
201
205
  return results;
202
206
  }
203
- function getFieldsByKey(field, key) {
204
- return getFieldsByPredicate(field, f => f.key === key);
207
+ function getFieldsByKey(lookup, key) {
208
+ return getFieldsByPredicate(lookup, f => f.key === key);
205
209
  }
206
210
  async function getSelectOptions(fieldOrOpts) {
207
211
  const options = fieldOrOpts.props?.options || fieldOrOpts;