iss-ctrl 0.0.18 → 0.0.19

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.
Files changed (24) hide show
  1. package/fesm2022/{iss-ctrl-iss-ctrl-C_ZiixeF.mjs → iss-ctrl-iss-ctrl-Cy9p_PEj.mjs} +60 -28
  2. package/fesm2022/iss-ctrl-iss-ctrl-Cy9p_PEj.mjs.map +1 -0
  3. package/fesm2022/{iss-ctrl-load-event-DIPikCdF.mjs → iss-ctrl-load-event-DbAc-Wqq.mjs} +3 -3
  4. package/fesm2022/{iss-ctrl-load-event-DIPikCdF.mjs.map → iss-ctrl-load-event-DbAc-Wqq.mjs.map} +1 -1
  5. package/fesm2022/{iss-ctrl-load-options-event-DOlkFXz5.mjs → iss-ctrl-load-options-event-CmXkuQ5O.mjs} +3 -3
  6. package/fesm2022/{iss-ctrl-load-options-event-DOlkFXz5.mjs.map → iss-ctrl-load-options-event-CmXkuQ5O.mjs.map} +1 -1
  7. package/fesm2022/{iss-ctrl-load-value-event-BjsuFpPf.mjs → iss-ctrl-load-value-event-DmX9Pkzf.mjs} +3 -3
  8. package/fesm2022/{iss-ctrl-load-value-event-BjsuFpPf.mjs.map → iss-ctrl-load-value-event-DmX9Pkzf.mjs.map} +1 -1
  9. package/fesm2022/{iss-ctrl-note.field-CakHrlcq.mjs → iss-ctrl-note.field-CbLlparb.mjs} +2 -2
  10. package/fesm2022/{iss-ctrl-note.field-CakHrlcq.mjs.map → iss-ctrl-note.field-CbLlparb.mjs.map} +1 -1
  11. package/fesm2022/{iss-ctrl-replace-api-keys-C-G34VNS.mjs → iss-ctrl-replace-api-keys-C_mYQdtP.mjs} +2 -2
  12. package/fesm2022/{iss-ctrl-replace-api-keys-C-G34VNS.mjs.map → iss-ctrl-replace-api-keys-C_mYQdtP.mjs.map} +1 -1
  13. package/fesm2022/{iss-ctrl-set-value-event-C-uD228s.mjs → iss-ctrl-set-value-event-vKIrSRgu.mjs} +2 -2
  14. package/fesm2022/{iss-ctrl-set-value-event-C-uD228s.mjs.map → iss-ctrl-set-value-event-vKIrSRgu.mjs.map} +1 -1
  15. package/fesm2022/{iss-ctrl-table.field-Ce1KnlZO.mjs → iss-ctrl-table.field-CvqXIE4q.mjs} +2 -2
  16. package/fesm2022/{iss-ctrl-table.field-Ce1KnlZO.mjs.map → iss-ctrl-table.field-CvqXIE4q.mjs.map} +1 -1
  17. package/fesm2022/{iss-ctrl-trigger-based-on-json-value-D5S3shyl.mjs → iss-ctrl-trigger-based-on-json-value-wyn6AXWA.mjs} +2 -2
  18. package/fesm2022/{iss-ctrl-trigger-based-on-json-value-D5S3shyl.mjs.map → iss-ctrl-trigger-based-on-json-value-wyn6AXWA.mjs.map} +1 -1
  19. package/fesm2022/{iss-ctrl-user-picker.field-C7DZ3ck2.mjs → iss-ctrl-user-picker.field-BhjVNeqN.mjs} +2 -2
  20. package/fesm2022/{iss-ctrl-user-picker.field-C7DZ3ck2.mjs.map → iss-ctrl-user-picker.field-BhjVNeqN.mjs.map} +1 -1
  21. package/fesm2022/iss-ctrl.mjs +1 -1
  22. package/package.json +1 -1
  23. package/types/iss-ctrl.d.ts +16 -4
  24. package/fesm2022/iss-ctrl-iss-ctrl-C_ZiixeF.mjs.map +0 -1
@@ -6049,7 +6049,8 @@ class FieldEvent {
6049
6049
  * | `visible()` | `boolean` | Whether the field is rendered at all. |
6050
6050
  * | `loading()` | `boolean` | Shows the field's own loading state. |
6051
6051
  * | `config` | `FieldConfig` | Per-type configuration — see {@link FieldConfig}. |
6052
- * | `validation` | `any` | Synchronous validation rules. |
6052
+ * | `validation` | `any` | Synchronous validation rules, exactly as the JSON declared them. |
6053
+ * | `validationFns` | `Record<string, Function>` | Validator factory behind each active rule, resolved by the outlet. |
6053
6054
  * | `asyncValidation` | `FieldAsyncValidation` | Remote validation rules. |
6054
6055
  * | `events` | `FieldEvent[]` | Cross-field reactions (show, hide, set value, …). |
6055
6056
  * | `children` | `IssField[]` | Nested fields, used by table and group fields. |
@@ -6073,6 +6074,10 @@ class IssField {
6073
6074
  wasVisible = signal(true, ...(ngDevMode ? [{ debugName: "wasVisible" }] : /* istanbul ignore next */ []));
6074
6075
  events;
6075
6076
  validation;
6077
+ // The lazily imported factory behind each active rule in `validation`, keyed by rule name.
6078
+ // The factories are kept beside the rules instead of inside them so `validation` stays the
6079
+ // object the JSON declared: what a rule says is the API's, how it is applied is ours.
6080
+ validationFns = {};
6076
6081
  asyncValidation;
6077
6082
  children;
6078
6083
  apiResponse = new BehaviorSubject(null);
@@ -6163,6 +6168,18 @@ const VALIDATORS = {
6163
6168
  fileSize: () => Promise.resolve().then(function () { return file_validator; }).then((c) => c.FileValidators.size),
6164
6169
  fileType: () => Promise.resolve().then(function () { return file_validator; }).then((c) => c.FileValidators.type),
6165
6170
  };
6171
+ /**
6172
+ * Whether a rule in a field's `validation` is switched on.
6173
+ *
6174
+ * The rule's value is the argument its validator is built with, so it is also what says
6175
+ * whether the rule applies at all: `{ "required": false }` is an optional field, not a
6176
+ * required one, and a rule the API left out or sent as null is off the same way. Values
6177
+ * that are falsy but meaningful — `0`, `""` — are rules, so only the three off states are
6178
+ * rejected here.
6179
+ */
6180
+ function isActiveValidationRule(value) {
6181
+ return value !== undefined && value !== null && value !== false;
6182
+ }
6166
6183
 
6167
6184
  class FormEngine {
6168
6185
  // Fields are stored per host FormGroup, never on the service itself: a single root
@@ -6247,9 +6264,11 @@ class FormEngine {
6247
6264
  trackChangesValidations(field, form) {
6248
6265
  const changes$ = [];
6249
6266
  const masterNames = new Set();
6250
- const iterateOn = Object.entries(field.validation);
6267
+ // A rule that names another field — `beforeDate`, say — carries that name as its value, and
6268
+ // `processTrackChanges` ignores every value that is not a string.
6269
+ const iterateOn = Object.entries(field.validation ?? {});
6251
6270
  iterateOn.forEach((validationObj) => {
6252
- this.processTrackChanges(validationObj[1].value, masterNames, changes$, field, form);
6271
+ this.processTrackChanges(validationObj[1], masterNames, changes$, field, form);
6253
6272
  });
6254
6273
  return merge(...changes$);
6255
6274
  }
@@ -6281,8 +6300,10 @@ class FormEngine {
6281
6300
  changes$.push(this.#mapMasterFieldValueChangesToFieldChanges(masterField, masterCtrl));
6282
6301
  }
6283
6302
  }
6303
+ // A field carries validation only where a rule is actually switched on: one sent as `false`
6304
+ // or `null` says the field is free of it, so it counts for nothing here.
6284
6305
  fieldHasValidation(field) {
6285
- return !!(field.validation && Object.values(field.validation).filter((v) => v).length);
6306
+ return !!field.validation && Object.values(field.validation).some(isActiveValidationRule);
6286
6307
  }
6287
6308
  fieldHasAsyncValidation(field) {
6288
6309
  return !!(field.asyncValidation && Object.values(field.asyncValidation).filter((v) => v).length);
@@ -6290,7 +6311,7 @@ class FormEngine {
6290
6311
  isFormValid(form, fields) {
6291
6312
  return fields.map((childField) => {
6292
6313
  const currentCtrl = form.get(childField.name);
6293
- if (childField.validation?.required() && childField.visible() && childField.mode() === "edit" && currentCtrl?.status !== "DISABLED") {
6314
+ if (isActiveValidationRule(childField.validation?.required) && childField.visible() && childField.mode() === "edit" && currentCtrl?.status !== "DISABLED") {
6294
6315
  return currentCtrl?.valid;
6295
6316
  }
6296
6317
  return true;
@@ -6316,8 +6337,15 @@ class FormEngine {
6316
6337
  }
6317
6338
  return registration;
6318
6339
  }
6340
+ // Builds each switched-on rule into its validator, out of the value the rule was given:
6341
+ // `{ "minLength": 3 }` is what makes the validator refuse two characters, and `{ "required":
6342
+ // false }` builds nothing at all. The field rides along as the second argument for the rules
6343
+ // that need their neighbours — `beforeDate` and friends — and is ignored by the rest.
6344
+ // A rule whose factory never resolved is skipped rather than called.
6319
6345
  #validatorsToNgValidators(field) {
6320
- return this.#mapNgValidators(field.validation).map((validatorValue) => validatorValue?.fn(field));
6346
+ return Object.entries(field.validation ?? {})
6347
+ .filter(([key, value]) => isActiveValidationRule(value) && typeof field.validationFns?.[key] === "function")
6348
+ .map(([key, value]) => field.validationFns[key](value, field));
6321
6349
  }
6322
6350
  #mapNgValidators(validationObj) {
6323
6351
  return Object.entries((validationObj ? validationObj : {}))
@@ -6383,22 +6411,22 @@ const COMPONENTS = {
6383
6411
  datetime: () => Promise.resolve().then(function () { return datetimePicker_field; }).then((c) => c.DatetimePickerField),
6384
6412
  date_range: () => Promise.resolve().then(function () { return dateRangePicker_field; }).then((c) => c.DateRangePickerField),
6385
6413
  attachment: () => Promise.resolve().then(function () { return filePicker_field; }).then((c) => c.FilePickerField),
6386
- userPicker: () => import('./iss-ctrl-user-picker.field-C7DZ3ck2.mjs').then((c) => c.UserPickerField),
6414
+ userPicker: () => import('./iss-ctrl-user-picker.field-BhjVNeqN.mjs').then((c) => c.UserPickerField),
6387
6415
  vehicle_plate: () => Promise.resolve().then(function () { return plate_field; }).then((c) => c.PlateField),
6388
- enrichment: () => import('./iss-ctrl-note.field-CakHrlcq.mjs').then((c) => c.NoteField),
6416
+ enrichment: () => import('./iss-ctrl-note.field-CbLlparb.mjs').then((c) => c.NoteField),
6389
6417
  mobile: () => Promise.resolve().then(function () { return mobile_field; }).then((c) => c.MobileField),
6390
- table: () => import('./iss-ctrl-table.field-Ce1KnlZO.mjs').then((c) => c.TableField),
6418
+ table: () => import('./iss-ctrl-table.field-CvqXIE4q.mjs').then((c) => c.TableField),
6391
6419
  chips: () => Promise.resolve().then(function () { return chips_field; }).then((c) => c.ChipsField),
6392
6420
  switch: () => Promise.resolve().then(function () { return slideToggle_field; }).then((c) => c.SlideToggleField),
6393
6421
  };
6394
6422
 
6395
6423
  const SERVICES = {
6396
- setValue: () => import('./iss-ctrl-set-value-event-C-uD228s.mjs').then((s) => s.SetValueEvent),
6424
+ setValue: () => import('./iss-ctrl-set-value-event-vKIrSRgu.mjs').then((s) => s.SetValueEvent),
6397
6425
  show: () => import('./iss-ctrl-show-event-BcRCwAfo.mjs').then((s) => s.ShowEvent),
6398
- load: () => import('./iss-ctrl-load-value-event-BjsuFpPf.mjs').then((s) => s.LoadValueEvent),
6399
- loadOptions: () => import('./iss-ctrl-load-options-event-DOlkFXz5.mjs').then((s) => s.LoadOptionsEvent),
6400
- triggerBasedOnJsonValue: () => import('./iss-ctrl-trigger-based-on-json-value-D5S3shyl.mjs').then((s) => s.TriggerBasedOnJsonValue),
6401
- replaceApiKeyDefaultImpl: () => import('./iss-ctrl-replace-api-keys-C-G34VNS.mjs').then((s) => s.ReplaceApiKeys),
6426
+ load: () => import('./iss-ctrl-load-value-event-DmX9Pkzf.mjs').then((s) => s.LoadValueEvent),
6427
+ loadOptions: () => import('./iss-ctrl-load-options-event-CmXkuQ5O.mjs').then((s) => s.LoadOptionsEvent),
6428
+ triggerBasedOnJsonValue: () => import('./iss-ctrl-trigger-based-on-json-value-wyn6AXWA.mjs').then((s) => s.TriggerBasedOnJsonValue),
6429
+ replaceApiKeyDefaultImpl: () => import('./iss-ctrl-replace-api-keys-C_mYQdtP.mjs').then((s) => s.ReplaceApiKeys),
6402
6430
  };
6403
6431
 
6404
6432
  // Read-only counterpart of COMPONENTS: the component used to render a field's value
@@ -6585,6 +6613,11 @@ class Outlet {
6585
6613
  action.config.fn = configFn;
6586
6614
  }));
6587
6615
  }
6616
+ // Resolves the validator behind every rule the field switched on. `validation` itself is left
6617
+ // exactly as it arrived — the caller's own object, which it may still read and re-render — so
6618
+ // the factories land in `validationFns` and the rules keep the values they were given.
6619
+ // A rule that is off carries no validator: nothing is imported for it and nothing is built
6620
+ // from it, which is what makes `{ "required": false }` an optional field.
6588
6621
  async #loadFieldValidation(f) {
6589
6622
  if (!f.validation)
6590
6623
  return;
@@ -6593,13 +6626,10 @@ class Outlet {
6593
6626
  console.error(`${key} not found`);
6594
6627
  return false;
6595
6628
  }
6596
- return validation !== undefined && !validation?.hasOwnProperty("fn");
6629
+ return isActiveValidationRule(validation);
6597
6630
  });
6598
- await Promise.all(validationEntries.map(async ([key, validation]) => {
6599
- f.validation[key] = {
6600
- fn: await VALIDATORS[key](),
6601
- value: validation
6602
- };
6631
+ await Promise.all(validationEntries.map(async ([key]) => {
6632
+ f.validationFns[key] = await VALIDATORS[key]();
6603
6633
  }));
6604
6634
  }
6605
6635
  #listenToHostFormGroupChanges() {
@@ -8562,10 +8592,10 @@ class FilePickerField extends FieldBase {
8562
8592
  super.ngOnDestroy();
8563
8593
  this.#valueEffect.destroy();
8564
8594
  }
8565
- // the outlet rewrites every validation entry into {fn, value}, so the extensions live under value
8595
+ // The accepted extensions are the `fileType` rule's own value, the same one its validator is
8596
+ // built from — a list, or the comma-separated string an older definition wrote it as.
8566
8597
  #acceptFactory() {
8567
- const fileType = this.field.validation?.["fileType"];
8568
- const extensions = fileType && fileType.hasOwnProperty("fn") ? fileType.value : fileType;
8598
+ const extensions = this.field.validation?.["fileType"];
8569
8599
  if (!extensions) {
8570
8600
  return "";
8571
8601
  }
@@ -9402,11 +9432,13 @@ var file_validator = /*#__PURE__*/Object.freeze({
9402
9432
  });
9403
9433
 
9404
9434
  class TimeValidator {
9405
- static beforeDate(field) {
9435
+ // The rule's value is the name of the field this one must not run past, so it arrives here
9436
+ // rather than being read back off the field.
9437
+ static beforeDate(otherFieldName) {
9406
9438
  const controlContainer = inject(ControlContainer);
9407
9439
  const parentForm = controlContainer.control;
9408
9440
  return (control) => {
9409
- const anotherControl = parentForm.get(field?.validation?.beforeDate?.value);
9441
+ const anotherControl = parentForm.get(otherFieldName);
9410
9442
  if (anotherControl) {
9411
9443
  const anotherControlValue = anotherControl.getRawValue();
9412
9444
  const controlValue = control.getRawValue();
@@ -9419,7 +9451,7 @@ class TimeValidator {
9419
9451
  return null;
9420
9452
  };
9421
9453
  }
9422
- static afterDate(field) {
9454
+ static afterDate(otherFieldName) {
9423
9455
  return (control) => {
9424
9456
  return null;
9425
9457
  };
@@ -9437,5 +9469,5 @@ var time_validator = /*#__PURE__*/Object.freeze({
9437
9469
  * Generated bundle index. Do not edit.
9438
9470
  */
9439
9471
 
9440
- export { PlateViewer as $, TimePickerField as A, DatePickerField as B, ControlBase as C, DatePickerControl as D, Employee as E, FieldBase as F, DatetimePickerField as G, HOST as H, IssField as I, DateRangePickerField as J, InputViewer as K, Loader as L, MobileControl as M, TextareaViewer as N, Outlet as O, PLACEHOLDER_REGEX as P, ChipsViewer as Q, RadioControl as R, SelectControl as S, TextareaControl as T, RadioViewer as U, VIEW_PROVIDER as V, SelectViewer as W, MobileViewer as X, CheckboxViewer as Y, ToggleButtonViewer as Z, SlideToggleViewer as _, ValidationMessageComponent as a, AttachmentViewer as a0, TimePickerViewer as a1, DatePickerViewer as a2, DatePickerTimeViewer as a3, DateRangePickerViewer as a4, DEFAULT_COUNTRY as a5, COUNTRIES as a6, DATE_FORMAT_ADAPTER as a7, DATETIME_FORMAT as a8, PLATE_LETTERS as a9, startOfHijriMonth as aA, getHijriDaysInMonth as aB, createHijriDate as aC, formatHijriDate as aD, parseHijriDate as aE, toHijriDisplay as aF, IssValidators as aG, FileValidators as aH, TimeValidator as aI, VALIDATION_MESSAGES as aa, COMPONENTS as ab, SERVICES as ac, VALIDATORS as ad, FIELD_DATA as ae, UI_LANGUAGE as af, ATTACHMENT_UPLOAD_URL as ag, ATTACHMENT_UPLOAD_RESPONSE_MAPPER as ah, ATTACHMENT_DOWNLOAD_URL as ai, USER_SEARCH_API as aj, HintsComponent as ak, Droppable as al, ArabicNumberPipe as am, FieldDataInjector as an, PlateLetterPipe as ao, SelectStatusPipe as ap, TranslatePipe as aq, FileHandler as ar, IssDateAdapter as as, provideIssDateAdapter as at, Phone as au, arrayFrom as av, formatFileSize as aw, HIJRI_LOCALE as ax, HIJRI_MONTH_NAMES as ay, getHijriParts as az, ViewerBase as b, FormEngine as c, CheckboxControl as d, ChipsControl as e, DateRangePickerControl as f, getPropertyByPath as g, DatetimePickerControl as h, FilePickerControl as i, InputControl as j, PlateControl as k, SlideToggleControl as l, TimePickerControl as m, ToggleButtonControl as n, InputField as o, TextareaField as p, ChipsField as q, replacePlaceholders as r, RadioField as s, SelectField as t, MobileField as u, CheckboxField as v, ToggleButtonField as w, SlideToggleField as x, PlateField as y, FilePickerField as z };
9441
- //# sourceMappingURL=iss-ctrl-iss-ctrl-C_ZiixeF.mjs.map
9472
+ export { PlateViewer as $, TimePickerField as A, DatePickerField as B, ControlBase as C, DatePickerControl as D, Employee as E, FieldBase as F, DatetimePickerField as G, HOST as H, IssField as I, DateRangePickerField as J, InputViewer as K, Loader as L, MobileControl as M, TextareaViewer as N, Outlet as O, PLACEHOLDER_REGEX as P, ChipsViewer as Q, RadioControl as R, SelectControl as S, TextareaControl as T, RadioViewer as U, VIEW_PROVIDER as V, SelectViewer as W, MobileViewer as X, CheckboxViewer as Y, ToggleButtonViewer as Z, SlideToggleViewer as _, ValidationMessageComponent as a, AttachmentViewer as a0, TimePickerViewer as a1, DatePickerViewer as a2, DatePickerTimeViewer as a3, DateRangePickerViewer as a4, DEFAULT_COUNTRY as a5, COUNTRIES as a6, DATE_FORMAT_ADAPTER as a7, DATETIME_FORMAT as a8, PLATE_LETTERS as a9, getHijriParts as aA, startOfHijriMonth as aB, getHijriDaysInMonth as aC, createHijriDate as aD, formatHijriDate as aE, parseHijriDate as aF, toHijriDisplay as aG, IssValidators as aH, FileValidators as aI, TimeValidator as aJ, VALIDATION_MESSAGES as aa, COMPONENTS as ab, SERVICES as ac, VALIDATORS as ad, isActiveValidationRule as ae, FIELD_DATA as af, UI_LANGUAGE as ag, ATTACHMENT_UPLOAD_URL as ah, ATTACHMENT_UPLOAD_RESPONSE_MAPPER as ai, ATTACHMENT_DOWNLOAD_URL as aj, USER_SEARCH_API as ak, HintsComponent as al, Droppable as am, ArabicNumberPipe as an, FieldDataInjector as ao, PlateLetterPipe as ap, SelectStatusPipe as aq, TranslatePipe as ar, FileHandler as as, IssDateAdapter as at, provideIssDateAdapter as au, Phone as av, arrayFrom as aw, formatFileSize as ax, HIJRI_LOCALE as ay, HIJRI_MONTH_NAMES as az, ViewerBase as b, FormEngine as c, CheckboxControl as d, ChipsControl as e, DateRangePickerControl as f, getPropertyByPath as g, DatetimePickerControl as h, FilePickerControl as i, InputControl as j, PlateControl as k, SlideToggleControl as l, TimePickerControl as m, ToggleButtonControl as n, InputField as o, TextareaField as p, ChipsField as q, replacePlaceholders as r, RadioField as s, SelectField as t, MobileField as u, CheckboxField as v, ToggleButtonField as w, SlideToggleField as x, PlateField as y, FilePickerField as z };
9473
+ //# sourceMappingURL=iss-ctrl-iss-ctrl-Cy9p_PEj.mjs.map