@melodicdev/components 1.5.13 → 1.6.1
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/assets/melodic-components.js +831 -445
- package/assets/melodic-components.js.map +1 -1
- package/assets/melodic-components.min.js +2171 -1793
- package/lib/components/data-display/badge/badge.styles.d.ts.map +1 -1
- package/lib/components/data-display/badge/badge.styles.js +11 -0
- package/lib/components/data-display/table/table.styles.d.ts.map +1 -1
- package/lib/components/data-display/table/table.styles.js +18 -7
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.js +17 -0
- package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.component.js +8 -0
- package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.component.js +8 -0
- package/lib/components/forms/date-time-picker/date-time-picker.component.d.ts.map +1 -1
- package/lib/components/forms/date-time-picker/date-time-picker.component.js +8 -0
- package/lib/components/forms/input/input.component.d.ts.map +1 -1
- package/lib/components/forms/input/input.component.js +8 -0
- package/lib/components/forms/radio/radio-group.component.d.ts.map +1 -1
- package/lib/components/forms/radio/radio-group.component.js +8 -0
- package/lib/components/forms/select/select.component.d.ts.map +1 -1
- package/lib/components/forms/select/select.component.js +17 -0
- package/lib/components/forms/slider/slider.component.d.ts.map +1 -1
- package/lib/components/forms/slider/slider.component.js +8 -0
- package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.component.js +8 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
- package/lib/components/forms/time-picker/time-picker.component.js +8 -0
- package/lib/components/forms/toggle/toggle.component.d.ts.map +1 -1
- package/lib/components/forms/toggle/toggle.component.js +8 -0
- package/package.json +1 -1
- package/lib/bundle.d.ts +0 -59
- package/lib/bundle.d.ts.map +0 -1
- package/lib/bundle.js +0 -68
- package/lib/components/data-display/empty-state/index.d.ts +0 -2
- package/lib/components/data-display/empty-state/index.d.ts.map +0 -1
- package/lib/components/data-display/empty-state/index.js +0 -2
- package/lib/components/data-display/stat/index.d.ts +0 -2
- package/lib/components/data-display/stat/index.d.ts.map +0 -1
- package/lib/components/data-display/stat/index.js +0 -2
- package/lib/components/feedback/skeleton/index.d.ts +0 -2
- package/lib/components/feedback/skeleton/index.d.ts.map +0 -1
- package/lib/components/feedback/skeleton/index.js +0 -2
- package/lib/components/foundation/grid/index.d.ts +0 -2
- package/lib/components/foundation/grid/index.d.ts.map +0 -1
- package/lib/components/foundation/grid/index.js +0 -2
- package/lib/components/general/icon/fonts/phosphor/bold/Phosphor-Bold.svg +0 -3057
- package/lib/components/general/icon/fonts/phosphor/bold/Phosphor-Bold.ttf +0 -0
- package/lib/components/general/icon/fonts/phosphor/bold/Phosphor-Bold.woff +0 -0
- package/lib/components/general/icon/fonts/phosphor/bold/Phosphor-Bold.woff2 +0 -0
- package/lib/components/general/icon/fonts/phosphor/bold/style.css +0 -4627
- package/lib/components/general/icon/fonts/phosphor/duotone/Phosphor-Duotone.svg +0 -3054
- package/lib/components/general/icon/fonts/phosphor/duotone/Phosphor-Duotone.ttf +0 -0
- package/lib/components/general/icon/fonts/phosphor/duotone/Phosphor-Duotone.woff +0 -0
- package/lib/components/general/icon/fonts/phosphor/duotone/Phosphor-Duotone.woff2 +0 -0
- package/lib/components/general/icon/fonts/phosphor/duotone/style.css +0 -12115
- package/lib/components/general/icon/fonts/phosphor/fill/Phosphor-Fill.svg +0 -3057
- package/lib/components/general/icon/fonts/phosphor/fill/Phosphor-Fill.ttf +0 -0
- package/lib/components/general/icon/fonts/phosphor/fill/Phosphor-Fill.woff +0 -0
- package/lib/components/general/icon/fonts/phosphor/fill/Phosphor-Fill.woff2 +0 -0
- package/lib/components/general/icon/fonts/phosphor/fill/style.css +0 -4627
- package/lib/components/general/icon/fonts/phosphor/light/Phosphor-Light.svg +0 -3057
- package/lib/components/general/icon/fonts/phosphor/light/Phosphor-Light.ttf +0 -0
- package/lib/components/general/icon/fonts/phosphor/light/Phosphor-Light.woff +0 -0
- package/lib/components/general/icon/fonts/phosphor/light/Phosphor-Light.woff2 +0 -0
- package/lib/components/general/icon/fonts/phosphor/light/style.css +0 -4627
- package/lib/components/general/icon/fonts/phosphor/regular/Phosphor.svg +0 -3056
- package/lib/components/general/icon/fonts/phosphor/regular/Phosphor.ttf +0 -0
- package/lib/components/general/icon/fonts/phosphor/regular/Phosphor.woff +0 -0
- package/lib/components/general/icon/fonts/phosphor/regular/Phosphor.woff2 +0 -0
- package/lib/components/general/icon/fonts/phosphor/regular/style.css +0 -4627
- package/lib/components/general/icon/fonts/phosphor/thin/Phosphor-Thin.svg +0 -3057
- package/lib/components/general/icon/fonts/phosphor/thin/Phosphor-Thin.ttf +0 -0
- package/lib/components/general/icon/fonts/phosphor/thin/Phosphor-Thin.woff +0 -0
- package/lib/components/general/icon/fonts/phosphor/thin/Phosphor-Thin.woff2 +0 -0
- package/lib/components/general/icon/fonts/phosphor/thin/style.css +0 -4627
- package/lib/components/general/icon/icon.registry.d.ts +0 -32
- package/lib/components/general/icon/icon.registry.d.ts.map +0 -1
- package/lib/components/general/icon/icon.registry.js +0 -45
- package/lib/components/general/icon/icon.types.d.ts +0 -8
- package/lib/components/general/icon/icon.types.d.ts.map +0 -1
- package/lib/components/general/icon/icon.types.js +0 -1
- package/lib/components/general/icon/phosphor-fonts.d.ts +0 -12
- package/lib/components/general/icon/phosphor-fonts.d.ts.map +0 -1
- package/lib/components/general/icon/phosphor-fonts.js +0 -77
- package/lib/components/general/icon/phosphor.d.ts +0 -41
- package/lib/components/general/icon/phosphor.d.ts.map +0 -1
- package/lib/components/general/icon/phosphor.js +0 -42
- package/lib/components/overlays/modal/index.d.ts +0 -2
- package/lib/components/overlays/modal/index.d.ts.map +0 -1
- package/lib/components/overlays/modal/index.js +0 -2
|
@@ -315,6 +315,298 @@ var cacheCssSheet = (text) => {
|
|
|
315
315
|
var hasCachedSheets = () => {
|
|
316
316
|
return cachedCssSheets.length > 0;
|
|
317
317
|
};
|
|
318
|
+
var activeEffect = null;
|
|
319
|
+
const setActiveEffect = (effect) => {
|
|
320
|
+
activeEffect = effect;
|
|
321
|
+
};
|
|
322
|
+
const getActiveEffect = () => activeEffect;
|
|
323
|
+
var SignalEffect = class {
|
|
324
|
+
constructor(execute) {
|
|
325
|
+
this.execute = execute;
|
|
326
|
+
this._dependencies = /* @__PURE__ */ new Set();
|
|
327
|
+
this._isRunning = false;
|
|
328
|
+
this._needsRerun = false;
|
|
329
|
+
this.run = () => {
|
|
330
|
+
if (this._isRunning) {
|
|
331
|
+
this._needsRerun = true;
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
this._isRunning = true;
|
|
335
|
+
do {
|
|
336
|
+
this._needsRerun = false;
|
|
337
|
+
this._dependencies.forEach((signal$1) => {
|
|
338
|
+
signal$1.unsubscribe(this.run);
|
|
339
|
+
});
|
|
340
|
+
this._dependencies.clear();
|
|
341
|
+
const prevEffect = getActiveEffect();
|
|
342
|
+
setActiveEffect(this);
|
|
343
|
+
this.execute();
|
|
344
|
+
setActiveEffect(prevEffect);
|
|
345
|
+
} while (this._needsRerun);
|
|
346
|
+
this._isRunning = false;
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
addDependency(signal$1) {
|
|
350
|
+
this._dependencies.add(signal$1);
|
|
351
|
+
}
|
|
352
|
+
destroy() {
|
|
353
|
+
this._dependencies.forEach((signal$1) => {
|
|
354
|
+
signal$1.unsubscribe(this.run);
|
|
355
|
+
});
|
|
356
|
+
this._dependencies.clear();
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
function signal(initialValue) {
|
|
360
|
+
let value = initialValue;
|
|
361
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
362
|
+
const notify = () => {
|
|
363
|
+
[...subscribers].forEach((subscriber) => subscriber(value));
|
|
364
|
+
};
|
|
365
|
+
const read = (() => {
|
|
366
|
+
const activeEffect$1 = getActiveEffect();
|
|
367
|
+
if (activeEffect$1) {
|
|
368
|
+
activeEffect$1.addDependency(read);
|
|
369
|
+
subscribers.add(activeEffect$1.run);
|
|
370
|
+
}
|
|
371
|
+
return value;
|
|
372
|
+
});
|
|
373
|
+
read.set = (newValue) => {
|
|
374
|
+
if (value !== newValue) {
|
|
375
|
+
value = newValue;
|
|
376
|
+
notify();
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
read.update = (updater) => {
|
|
380
|
+
read.set(updater(value));
|
|
381
|
+
};
|
|
382
|
+
read.subscribe = (subscriber) => {
|
|
383
|
+
subscribers.add(subscriber);
|
|
384
|
+
return () => subscribers.delete(subscriber);
|
|
385
|
+
};
|
|
386
|
+
read.unsubscribe = (subscriber) => {
|
|
387
|
+
subscribers.delete(subscriber);
|
|
388
|
+
};
|
|
389
|
+
read.destroy = () => {
|
|
390
|
+
subscribers.clear();
|
|
391
|
+
};
|
|
392
|
+
Object.defineProperty(read, SIGNAL_MARKER, {
|
|
393
|
+
value: true,
|
|
394
|
+
enumerable: false,
|
|
395
|
+
configurable: false
|
|
396
|
+
});
|
|
397
|
+
return read;
|
|
398
|
+
}
|
|
399
|
+
function computed(computation) {
|
|
400
|
+
const computedSignal = signal(void 0);
|
|
401
|
+
const effect = new SignalEffect(() => {
|
|
402
|
+
computedSignal.set(computation());
|
|
403
|
+
});
|
|
404
|
+
effect.run();
|
|
405
|
+
const originalDestroy = computedSignal.destroy;
|
|
406
|
+
computedSignal.destroy = () => {
|
|
407
|
+
effect.destroy();
|
|
408
|
+
originalDestroy();
|
|
409
|
+
};
|
|
410
|
+
return computedSignal;
|
|
411
|
+
}
|
|
412
|
+
var globalMessages = {};
|
|
413
|
+
function registerDefaultMessages(messages) {
|
|
414
|
+
for (const code of Object.keys(messages)) globalMessages[code] = messages[code];
|
|
415
|
+
}
|
|
416
|
+
function setDefaultMessage(code, message) {
|
|
417
|
+
globalMessages[code] = message;
|
|
418
|
+
}
|
|
419
|
+
function getGlobalMessage(code) {
|
|
420
|
+
return globalMessages[code];
|
|
421
|
+
}
|
|
422
|
+
function resolveMessage(message, params) {
|
|
423
|
+
if (typeof message === "function") return message(params ?? {});
|
|
424
|
+
return message;
|
|
425
|
+
}
|
|
426
|
+
var AbstractControl = class {
|
|
427
|
+
constructor(initialValue, options = {}) {
|
|
428
|
+
this.parent = null;
|
|
429
|
+
this._validators = [];
|
|
430
|
+
this._asyncValidators = [];
|
|
431
|
+
this._touched = signal(false);
|
|
432
|
+
this._dirty = signal(false);
|
|
433
|
+
this._pending = signal(false);
|
|
434
|
+
this._ownDisabled = signal(false);
|
|
435
|
+
this._asyncValidationId = 0;
|
|
436
|
+
this.value = signal(initialValue);
|
|
437
|
+
this.errors = signal(null);
|
|
438
|
+
this._validators = options.validators ?? [];
|
|
439
|
+
this._asyncValidators = options.asyncValidators ?? [];
|
|
440
|
+
this._ownDisabled.set(options.disabled ?? false);
|
|
441
|
+
this.updateOn = options.updateOn ?? "change";
|
|
442
|
+
this.messages = options.messages ?? {};
|
|
443
|
+
}
|
|
444
|
+
initializeAggregates() {
|
|
445
|
+
this.dirty = computed(() => this.computeDirty());
|
|
446
|
+
this.touched = computed(() => this.computeTouched());
|
|
447
|
+
this.pending = computed(() => this.computePending());
|
|
448
|
+
this.disabled = computed(() => this.computeDisabled());
|
|
449
|
+
this.pristine = computed(() => !this.dirty());
|
|
450
|
+
this.untouched = computed(() => !this.touched());
|
|
451
|
+
this.enabled = computed(() => !this.disabled());
|
|
452
|
+
this.invalid = computed(() => this.errors() !== null || this.hasInvalidChild());
|
|
453
|
+
this.valid = computed(() => !this.invalid() && !this.pending());
|
|
454
|
+
this.state = computed(() => ({
|
|
455
|
+
dirty: this.dirty(),
|
|
456
|
+
touched: this.touched(),
|
|
457
|
+
pristine: !this.dirty(),
|
|
458
|
+
untouched: !this.touched(),
|
|
459
|
+
valid: !this.invalid() && !this.pending(),
|
|
460
|
+
invalid: this.invalid(),
|
|
461
|
+
pending: this.pending(),
|
|
462
|
+
disabled: this.disabled(),
|
|
463
|
+
enabled: !this.disabled()
|
|
464
|
+
}));
|
|
465
|
+
}
|
|
466
|
+
markAsTouched() {
|
|
467
|
+
this._touched.set(true);
|
|
468
|
+
if (this.updateOn === "blur") this.runValidation();
|
|
469
|
+
}
|
|
470
|
+
markAsUntouched() {
|
|
471
|
+
this._touched.set(false);
|
|
472
|
+
}
|
|
473
|
+
markAsDirty() {
|
|
474
|
+
this._dirty.set(true);
|
|
475
|
+
}
|
|
476
|
+
markAsPristine() {
|
|
477
|
+
this._dirty.set(false);
|
|
478
|
+
}
|
|
479
|
+
markAllAsTouched() {
|
|
480
|
+
this.markAsTouched();
|
|
481
|
+
}
|
|
482
|
+
markAllAsUntouched() {
|
|
483
|
+
this.markAsUntouched();
|
|
484
|
+
}
|
|
485
|
+
markAllAsDirty() {
|
|
486
|
+
this.markAsDirty();
|
|
487
|
+
}
|
|
488
|
+
markAllAsPristine() {
|
|
489
|
+
this.markAsPristine();
|
|
490
|
+
}
|
|
491
|
+
disable() {
|
|
492
|
+
this._ownDisabled.set(true);
|
|
493
|
+
}
|
|
494
|
+
enable() {
|
|
495
|
+
this._ownDisabled.set(false);
|
|
496
|
+
}
|
|
497
|
+
setValidators(validators) {
|
|
498
|
+
this._validators = validators;
|
|
499
|
+
this.runValidation();
|
|
500
|
+
}
|
|
501
|
+
addValidators(validators) {
|
|
502
|
+
this._validators = [...this._validators, ...validators];
|
|
503
|
+
this.runValidation();
|
|
504
|
+
}
|
|
505
|
+
removeValidators(validators) {
|
|
506
|
+
this._validators = this._validators.filter((v) => !validators.includes(v));
|
|
507
|
+
this.runValidation();
|
|
508
|
+
}
|
|
509
|
+
setAsyncValidators(validators) {
|
|
510
|
+
this._asyncValidators = validators;
|
|
511
|
+
this.runValidation();
|
|
512
|
+
}
|
|
513
|
+
async validate() {
|
|
514
|
+
await this.runValidation();
|
|
515
|
+
}
|
|
516
|
+
getError(code) {
|
|
517
|
+
return this.errors()?.[code] ?? null;
|
|
518
|
+
}
|
|
519
|
+
hasError(code) {
|
|
520
|
+
return this.errors()?.[code] !== void 0;
|
|
521
|
+
}
|
|
522
|
+
getErrorMessage(code) {
|
|
523
|
+
const error = this.getError(code);
|
|
524
|
+
if (!error) return "";
|
|
525
|
+
const params = error.params;
|
|
526
|
+
const localMessage = this.resolveFromChain(code);
|
|
527
|
+
if (localMessage !== void 0) return resolveMessage(localMessage, params);
|
|
528
|
+
const globalMessage = getGlobalMessage(code);
|
|
529
|
+
if (globalMessage !== void 0) return resolveMessage(globalMessage, params);
|
|
530
|
+
return code;
|
|
531
|
+
}
|
|
532
|
+
getFirstErrorMessage() {
|
|
533
|
+
const errors = this.errors();
|
|
534
|
+
if (!errors) return "";
|
|
535
|
+
const codes = Object.keys(errors);
|
|
536
|
+
if (codes.length === 0) return "";
|
|
537
|
+
return this.getErrorMessage(codes[0]);
|
|
538
|
+
}
|
|
539
|
+
resolveFromChain(code) {
|
|
540
|
+
let control = this;
|
|
541
|
+
while (control !== null) {
|
|
542
|
+
if (control.messages[code] !== void 0) return control.messages[code];
|
|
543
|
+
control = control.parent;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
async runValidation() {
|
|
547
|
+
const value = this.value();
|
|
548
|
+
let errors = null;
|
|
549
|
+
for (const validator of this._validators) {
|
|
550
|
+
const result = validator(value);
|
|
551
|
+
if (result !== null) errors = {
|
|
552
|
+
...errors ?? {},
|
|
553
|
+
...result
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
if (errors !== null) {
|
|
557
|
+
this.errors.set(errors);
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (this._asyncValidators.length > 0) {
|
|
561
|
+
const id = ++this._asyncValidationId;
|
|
562
|
+
this._pending.set(true);
|
|
563
|
+
try {
|
|
564
|
+
const results = await Promise.all(this._asyncValidators.map((v) => v(value)));
|
|
565
|
+
if (id !== this._asyncValidationId) return;
|
|
566
|
+
for (const result of results) if (result !== null) errors = {
|
|
567
|
+
...errors ?? {},
|
|
568
|
+
...result
|
|
569
|
+
};
|
|
570
|
+
} finally {
|
|
571
|
+
if (id === this._asyncValidationId) this._pending.set(false);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
this.errors.set(errors);
|
|
575
|
+
}
|
|
576
|
+
computeDirty() {
|
|
577
|
+
return this._dirty();
|
|
578
|
+
}
|
|
579
|
+
computeTouched() {
|
|
580
|
+
return this._touched();
|
|
581
|
+
}
|
|
582
|
+
computePending() {
|
|
583
|
+
return this._pending();
|
|
584
|
+
}
|
|
585
|
+
computeDisabled() {
|
|
586
|
+
return this._ownDisabled();
|
|
587
|
+
}
|
|
588
|
+
hasInvalidChild() {
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
destroySignals() {
|
|
592
|
+
this.value.destroy();
|
|
593
|
+
this.errors.destroy();
|
|
594
|
+
this._touched.destroy();
|
|
595
|
+
this._dirty.destroy();
|
|
596
|
+
this._pending.destroy();
|
|
597
|
+
this._ownDisabled.destroy();
|
|
598
|
+
this.dirty.destroy();
|
|
599
|
+
this.touched.destroy();
|
|
600
|
+
this.pristine.destroy();
|
|
601
|
+
this.untouched.destroy();
|
|
602
|
+
this.valid.destroy();
|
|
603
|
+
this.invalid.destroy();
|
|
604
|
+
this.pending.destroy();
|
|
605
|
+
this.disabled.destroy();
|
|
606
|
+
this.enabled.destroy();
|
|
607
|
+
this.state.destroy();
|
|
608
|
+
}
|
|
609
|
+
};
|
|
318
610
|
var ComponentBase = class extends HTMLElement {
|
|
319
611
|
constructor(meta, component) {
|
|
320
612
|
super();
|
|
@@ -400,6 +692,10 @@ var ComponentBase = class extends HTMLElement {
|
|
|
400
692
|
this.subscribeToSignal(value);
|
|
401
693
|
return false;
|
|
402
694
|
}
|
|
695
|
+
if (value instanceof AbstractControl) {
|
|
696
|
+
this.subscribeToSignal(value.state);
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
403
699
|
if (typeof value === "function") return false;
|
|
404
700
|
return prop !== "elementRef" && prop !== "constructor";
|
|
405
701
|
});
|
|
@@ -611,6 +907,7 @@ var RequestManager = class {
|
|
|
611
907
|
return hash;
|
|
612
908
|
}
|
|
613
909
|
};
|
|
910
|
+
var MAX_RETRIES = 3;
|
|
614
911
|
var HttpClient = class {
|
|
615
912
|
constructor(config) {
|
|
616
913
|
this._requestManager = new RequestManager();
|
|
@@ -671,6 +968,7 @@ var HttpClient = class {
|
|
|
671
968
|
});
|
|
672
969
|
}
|
|
673
970
|
async internalRequest(config) {
|
|
971
|
+
const originalConfig = config;
|
|
674
972
|
let requestConfig = this.mergeConfig(config);
|
|
675
973
|
requestConfig = await this.executeRequestInterceptors(requestConfig);
|
|
676
974
|
if (requestConfig.cancel?.cancelled) {
|
|
@@ -693,11 +991,56 @@ var HttpClient = class {
|
|
|
693
991
|
delete headers["Content-Type"];
|
|
694
992
|
delete headers["content-type"];
|
|
695
993
|
requestConfig.headers = headers;
|
|
994
|
+
} else if (this.shouldDefaultJsonContentType(requestConfig.body)) {
|
|
995
|
+
const headers = { ...requestConfig.headers };
|
|
996
|
+
if (!Object.keys(headers).some((k) => k.toLowerCase() === "content-type")) {
|
|
997
|
+
headers["Content-Type"] = "application/json";
|
|
998
|
+
requestConfig.headers = headers;
|
|
999
|
+
}
|
|
696
1000
|
}
|
|
697
1001
|
if (requestConfig.abortController === void 0) requestConfig.abortController = new AbortController();
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
1002
|
+
try {
|
|
1003
|
+
const response = await this.executeRequest(requestConfig);
|
|
1004
|
+
return await this.executeResponseInterceptors(response, 0);
|
|
1005
|
+
} catch (error) {
|
|
1006
|
+
return this.handleResponseError(error, originalConfig);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
async handleResponseError(error, originalConfig) {
|
|
1010
|
+
const retryCount = originalConfig._retryCount ?? 0;
|
|
1011
|
+
for (let i = 0; i < this._interceptors.response.length; i++) {
|
|
1012
|
+
const interceptor = this._interceptors.response[i];
|
|
1013
|
+
if (!interceptor.error) continue;
|
|
1014
|
+
let retryCalled = false;
|
|
1015
|
+
const retry = async () => {
|
|
1016
|
+
if (retryCalled) throw new Error("[HttpClient] retry() may only be called once per error handler invocation");
|
|
1017
|
+
retryCalled = true;
|
|
1018
|
+
if (retryCount >= MAX_RETRIES) throw new Error(`[HttpClient] Max retries (${MAX_RETRIES}) exceeded`);
|
|
1019
|
+
return this.internalRequest({
|
|
1020
|
+
...originalConfig,
|
|
1021
|
+
_retryCount: retryCount + 1,
|
|
1022
|
+
abortController: void 0
|
|
1023
|
+
});
|
|
1024
|
+
};
|
|
1025
|
+
const context = {
|
|
1026
|
+
retry,
|
|
1027
|
+
retryCount
|
|
1028
|
+
};
|
|
1029
|
+
try {
|
|
1030
|
+
const result = await interceptor.error(error, context);
|
|
1031
|
+
if (this.isHttpResponse(result)) return this.executeResponseInterceptors(result, i + 1);
|
|
1032
|
+
} catch {}
|
|
1033
|
+
}
|
|
1034
|
+
throw error;
|
|
1035
|
+
}
|
|
1036
|
+
isHttpResponse(value) {
|
|
1037
|
+
return !!value && typeof value === "object" && "data" in value && "status" in value && "headers" in value && "config" in value;
|
|
1038
|
+
}
|
|
1039
|
+
shouldDefaultJsonContentType(body) {
|
|
1040
|
+
if (body === null || body === void 0) return false;
|
|
1041
|
+
if (typeof body === "string") return false;
|
|
1042
|
+
if (body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof URLSearchParams || body instanceof ReadableStream) return false;
|
|
1043
|
+
return typeof body === "object";
|
|
701
1044
|
}
|
|
702
1045
|
async executeRequest(config) {
|
|
703
1046
|
if (config.deduplicate === true) {
|
|
@@ -739,13 +1082,8 @@ var HttpClient = class {
|
|
|
739
1082
|
}
|
|
740
1083
|
return config;
|
|
741
1084
|
}
|
|
742
|
-
async executeResponseInterceptors(response) {
|
|
743
|
-
for (
|
|
744
|
-
response = await interceptor.intercept(response);
|
|
745
|
-
} catch (error) {
|
|
746
|
-
if (interceptor.error) await interceptor.error(error);
|
|
747
|
-
throw error;
|
|
748
|
-
}
|
|
1085
|
+
async executeResponseInterceptors(response, startIndex) {
|
|
1086
|
+
for (let i = startIndex; i < this._interceptors.response.length; i++) response = await this._interceptors.response[i].intercept(response);
|
|
749
1087
|
return response;
|
|
750
1088
|
}
|
|
751
1089
|
mergeConfig(config) {
|
|
@@ -2421,118 +2759,24 @@ function routerLinkDirective(element, value, _) {
|
|
|
2421
2759
|
}
|
|
2422
2760
|
e.preventDefault();
|
|
2423
2761
|
const navOptions = {
|
|
2424
|
-
data,
|
|
2425
|
-
replace,
|
|
2426
|
-
queryParams
|
|
2427
|
-
};
|
|
2428
|
-
router.navigate(href, navOptions);
|
|
2429
|
-
};
|
|
2430
|
-
const handleNavigation = () => {
|
|
2431
|
-
updateActiveState();
|
|
2432
|
-
};
|
|
2433
|
-
element.addEventListener("click", handleClick);
|
|
2434
|
-
window.addEventListener("NavigationEvent", handleNavigation);
|
|
2435
|
-
updateActiveState();
|
|
2436
|
-
return (() => {
|
|
2437
|
-
element.removeEventListener("click", handleClick);
|
|
2438
|
-
window.removeEventListener("NavigationEvent", handleNavigation);
|
|
2439
|
-
});
|
|
2440
|
-
}
|
|
2441
|
-
registerAttributeDirective("routerLink", routerLinkDirective);
|
|
2442
|
-
var activeEffect = null;
|
|
2443
|
-
const setActiveEffect = (effect) => {
|
|
2444
|
-
activeEffect = effect;
|
|
2445
|
-
};
|
|
2446
|
-
const getActiveEffect = () => activeEffect;
|
|
2447
|
-
var SignalEffect = class {
|
|
2448
|
-
constructor(execute) {
|
|
2449
|
-
this.execute = execute;
|
|
2450
|
-
this._dependencies = /* @__PURE__ */ new Set();
|
|
2451
|
-
this._isRunning = false;
|
|
2452
|
-
this._needsRerun = false;
|
|
2453
|
-
this.run = () => {
|
|
2454
|
-
if (this._isRunning) {
|
|
2455
|
-
this._needsRerun = true;
|
|
2456
|
-
return;
|
|
2457
|
-
}
|
|
2458
|
-
this._isRunning = true;
|
|
2459
|
-
do {
|
|
2460
|
-
this._needsRerun = false;
|
|
2461
|
-
this._dependencies.forEach((signal$1) => {
|
|
2462
|
-
signal$1.unsubscribe(this.run);
|
|
2463
|
-
});
|
|
2464
|
-
this._dependencies.clear();
|
|
2465
|
-
const prevEffect = getActiveEffect();
|
|
2466
|
-
setActiveEffect(this);
|
|
2467
|
-
this.execute();
|
|
2468
|
-
setActiveEffect(prevEffect);
|
|
2469
|
-
} while (this._needsRerun);
|
|
2470
|
-
this._isRunning = false;
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
addDependency(signal$1) {
|
|
2474
|
-
this._dependencies.add(signal$1);
|
|
2475
|
-
}
|
|
2476
|
-
destroy() {
|
|
2477
|
-
this._dependencies.forEach((signal$1) => {
|
|
2478
|
-
signal$1.unsubscribe(this.run);
|
|
2479
|
-
});
|
|
2480
|
-
this._dependencies.clear();
|
|
2481
|
-
}
|
|
2482
|
-
};
|
|
2483
|
-
function signal(initialValue) {
|
|
2484
|
-
let value = initialValue;
|
|
2485
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
2486
|
-
const notify = () => {
|
|
2487
|
-
[...subscribers].forEach((subscriber) => subscriber(value));
|
|
2488
|
-
};
|
|
2489
|
-
const read = (() => {
|
|
2490
|
-
const activeEffect$1 = getActiveEffect();
|
|
2491
|
-
if (activeEffect$1) {
|
|
2492
|
-
activeEffect$1.addDependency(read);
|
|
2493
|
-
subscribers.add(activeEffect$1.run);
|
|
2494
|
-
}
|
|
2495
|
-
return value;
|
|
2496
|
-
});
|
|
2497
|
-
read.set = (newValue) => {
|
|
2498
|
-
if (value !== newValue) {
|
|
2499
|
-
value = newValue;
|
|
2500
|
-
notify();
|
|
2501
|
-
}
|
|
2502
|
-
};
|
|
2503
|
-
read.update = (updater) => {
|
|
2504
|
-
read.set(updater(value));
|
|
2505
|
-
};
|
|
2506
|
-
read.subscribe = (subscriber) => {
|
|
2507
|
-
subscribers.add(subscriber);
|
|
2508
|
-
return () => subscribers.delete(subscriber);
|
|
2509
|
-
};
|
|
2510
|
-
read.unsubscribe = (subscriber) => {
|
|
2511
|
-
subscribers.delete(subscriber);
|
|
2762
|
+
data,
|
|
2763
|
+
replace,
|
|
2764
|
+
queryParams
|
|
2765
|
+
};
|
|
2766
|
+
router.navigate(href, navOptions);
|
|
2512
2767
|
};
|
|
2513
|
-
|
|
2514
|
-
|
|
2768
|
+
const handleNavigation = () => {
|
|
2769
|
+
updateActiveState();
|
|
2515
2770
|
};
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
}
|
|
2523
|
-
function computed(computation) {
|
|
2524
|
-
const computedSignal = signal(void 0);
|
|
2525
|
-
const effect = new SignalEffect(() => {
|
|
2526
|
-
computedSignal.set(computation());
|
|
2771
|
+
element.addEventListener("click", handleClick);
|
|
2772
|
+
window.addEventListener("NavigationEvent", handleNavigation);
|
|
2773
|
+
updateActiveState();
|
|
2774
|
+
return (() => {
|
|
2775
|
+
element.removeEventListener("click", handleClick);
|
|
2776
|
+
window.removeEventListener("NavigationEvent", handleNavigation);
|
|
2527
2777
|
});
|
|
2528
|
-
effect.run();
|
|
2529
|
-
const originalDestroy = computedSignal.destroy;
|
|
2530
|
-
computedSignal.destroy = () => {
|
|
2531
|
-
effect.destroy();
|
|
2532
|
-
originalDestroy();
|
|
2533
|
-
};
|
|
2534
|
-
return computedSignal;
|
|
2535
2778
|
}
|
|
2779
|
+
registerAttributeDirective("routerLink", routerLinkDirective);
|
|
2536
2780
|
const props = () => {
|
|
2537
2781
|
return () => ({});
|
|
2538
2782
|
};
|
|
@@ -3145,15 +3389,20 @@ function when(condition, template, falseTemplate) {
|
|
|
3145
3389
|
parent.insertBefore(endMarker, startMarker.nextSibling);
|
|
3146
3390
|
const state = {
|
|
3147
3391
|
condition: false,
|
|
3148
|
-
template:
|
|
3149
|
-
falseTemplate:
|
|
3392
|
+
template: null,
|
|
3393
|
+
falseTemplate: null,
|
|
3150
3394
|
container: null,
|
|
3151
3395
|
startMarker,
|
|
3152
3396
|
endMarker,
|
|
3153
3397
|
nodes: []
|
|
3154
3398
|
};
|
|
3155
|
-
if (condition)
|
|
3156
|
-
|
|
3399
|
+
if (condition) {
|
|
3400
|
+
state.template = template();
|
|
3401
|
+
renderContent(state, true);
|
|
3402
|
+
} else if (falseTemplate) {
|
|
3403
|
+
state.falseTemplate = falseTemplate();
|
|
3404
|
+
renderContent(state, false);
|
|
3405
|
+
}
|
|
3157
3406
|
state.condition = condition;
|
|
3158
3407
|
return state;
|
|
3159
3408
|
}
|
|
@@ -3305,56 +3554,26 @@ var Directive = class {
|
|
|
3305
3554
|
this.__directive = true;
|
|
3306
3555
|
}
|
|
3307
3556
|
};
|
|
3308
|
-
|
|
3309
|
-
var FormControl = class {
|
|
3557
|
+
var FormControl = class extends AbstractControl {
|
|
3310
3558
|
constructor(initialValue, options = {}) {
|
|
3311
|
-
|
|
3312
|
-
this._validators = [];
|
|
3313
|
-
this._asyncValidators = [];
|
|
3314
|
-
this._touched = signal(false);
|
|
3315
|
-
this._dirty = signal(false);
|
|
3316
|
-
this._pending = signal(false);
|
|
3317
|
-
this._disabled = signal(false);
|
|
3318
|
-
this._asyncValidationId = 0;
|
|
3559
|
+
super(initialValue, options);
|
|
3319
3560
|
this.initialValue = initialValue;
|
|
3320
|
-
this.
|
|
3321
|
-
this.errors = signal(null);
|
|
3322
|
-
this._validators = options.validators ?? [];
|
|
3323
|
-
this._asyncValidators = options.asyncValidators ?? [];
|
|
3324
|
-
this._disabled.set(options.disabled ?? false);
|
|
3325
|
-
this.updateOn = options.updateOn ?? "input";
|
|
3326
|
-
this.dirty = computed(() => this._dirty());
|
|
3327
|
-
this.touched = computed(() => this._touched());
|
|
3328
|
-
this.pristine = computed(() => !this._dirty());
|
|
3329
|
-
this.pending = computed(() => this._pending());
|
|
3330
|
-
this.disabled = computed(() => this._disabled());
|
|
3331
|
-
this.valid = computed(() => this.errors() === null && !this._pending());
|
|
3332
|
-
this.invalid = computed(() => this.errors() !== null);
|
|
3333
|
-
this.state = computed(() => ({
|
|
3334
|
-
dirty: this._dirty(),
|
|
3335
|
-
touched: this._touched(),
|
|
3336
|
-
pristine: !this._dirty(),
|
|
3337
|
-
untouched: !this._touched(),
|
|
3338
|
-
valid: this.errors() === null && !this._pending(),
|
|
3339
|
-
invalid: this.errors() !== null,
|
|
3340
|
-
pending: this._pending(),
|
|
3341
|
-
disabled: this._disabled(),
|
|
3342
|
-
enabled: !this._disabled()
|
|
3343
|
-
}));
|
|
3561
|
+
this.initializeAggregates();
|
|
3344
3562
|
this.runValidation();
|
|
3345
3563
|
}
|
|
3346
|
-
setValue(value) {
|
|
3347
|
-
if (this.
|
|
3564
|
+
setValue(value, options) {
|
|
3565
|
+
if (this._ownDisabled()) return;
|
|
3348
3566
|
this.value.set(value);
|
|
3349
|
-
this._dirty.set(
|
|
3350
|
-
if (this.updateOn === "
|
|
3567
|
+
this._dirty.set(!options?.markAsPristine);
|
|
3568
|
+
if (this.updateOn === "change") this.runValidation();
|
|
3351
3569
|
}
|
|
3352
|
-
patchValue(value) {
|
|
3353
|
-
|
|
3354
|
-
|
|
3570
|
+
patchValue(value, options) {
|
|
3571
|
+
const current = this.value();
|
|
3572
|
+
if (typeof current === "object" && current !== null && !Array.isArray(current)) this.setValue({
|
|
3573
|
+
...current,
|
|
3355
3574
|
...value
|
|
3356
|
-
});
|
|
3357
|
-
else this.setValue(value);
|
|
3575
|
+
}, options);
|
|
3576
|
+
else this.setValue(value, options);
|
|
3358
3577
|
}
|
|
3359
3578
|
reset(value) {
|
|
3360
3579
|
this.value.set(value ?? this.initialValue);
|
|
@@ -3363,244 +3582,250 @@ var FormControl = class {
|
|
|
3363
3582
|
this.errors.set(null);
|
|
3364
3583
|
this.runValidation();
|
|
3365
3584
|
}
|
|
3366
|
-
|
|
3585
|
+
destroy() {
|
|
3586
|
+
this.destroySignals();
|
|
3587
|
+
}
|
|
3588
|
+
};
|
|
3589
|
+
var FormGroup = class FormGroup extends AbstractControl {
|
|
3590
|
+
constructor(initialControls, options = {}) {
|
|
3591
|
+
super(FormGroup.computeValue(initialControls), options);
|
|
3592
|
+
this.controls = signal({ ...initialControls });
|
|
3593
|
+
for (const key of Object.keys(initialControls)) initialControls[key].parent = this;
|
|
3594
|
+
this.initializeAggregates();
|
|
3595
|
+
this._childValueEffect = new SignalEffect(() => {
|
|
3596
|
+
const controls = this.controls();
|
|
3597
|
+
for (const key of Object.keys(controls)) controls[key].value();
|
|
3598
|
+
this.value.set(FormGroup.computeValue(controls));
|
|
3599
|
+
this.runValidation();
|
|
3600
|
+
});
|
|
3601
|
+
this._childValueEffect.run();
|
|
3602
|
+
}
|
|
3603
|
+
get(name) {
|
|
3604
|
+
return this.controls()[name];
|
|
3605
|
+
}
|
|
3606
|
+
contains(name) {
|
|
3607
|
+
return name in this.controls();
|
|
3608
|
+
}
|
|
3609
|
+
addControl(name, control) {
|
|
3610
|
+
control.parent = this;
|
|
3611
|
+
this.controls.update((current) => ({
|
|
3612
|
+
...current,
|
|
3613
|
+
[name]: control
|
|
3614
|
+
}));
|
|
3615
|
+
}
|
|
3616
|
+
removeControl(name) {
|
|
3617
|
+
const control = this.controls()[name];
|
|
3618
|
+
if (!control) return;
|
|
3619
|
+
control.parent = null;
|
|
3620
|
+
control.destroy();
|
|
3621
|
+
this.controls.update((current) => {
|
|
3622
|
+
const next = { ...current };
|
|
3623
|
+
delete next[name];
|
|
3624
|
+
return next;
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3627
|
+
setValue(value, options) {
|
|
3628
|
+
if (this._ownDisabled()) return;
|
|
3629
|
+
const controls = this.controls();
|
|
3630
|
+
for (const key of Object.keys(value)) controls[key]?.setValue(value[key], options);
|
|
3631
|
+
if (options?.markAsPristine) this._dirty.set(false);
|
|
3632
|
+
}
|
|
3633
|
+
patchValue(value, options) {
|
|
3634
|
+
if (this._ownDisabled()) return;
|
|
3635
|
+
const controls = this.controls();
|
|
3636
|
+
for (const key of Object.keys(value)) if (value[key] !== void 0) controls[key]?.setValue(value[key], options);
|
|
3637
|
+
if (options?.markAsPristine) this._dirty.set(false);
|
|
3638
|
+
}
|
|
3639
|
+
reset(value) {
|
|
3640
|
+
const controls = this.controls();
|
|
3641
|
+
for (const key of Object.keys(controls)) {
|
|
3642
|
+
const resetValue = value?.[key];
|
|
3643
|
+
controls[key].reset(resetValue);
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
markAllAsTouched() {
|
|
3367
3647
|
this._touched.set(true);
|
|
3368
|
-
|
|
3648
|
+
const controls = this.controls();
|
|
3649
|
+
for (const key of Object.keys(controls)) controls[key].markAllAsTouched();
|
|
3369
3650
|
}
|
|
3370
|
-
|
|
3651
|
+
markAllAsUntouched() {
|
|
3371
3652
|
this._touched.set(false);
|
|
3653
|
+
const controls = this.controls();
|
|
3654
|
+
for (const key of Object.keys(controls)) controls[key].markAllAsUntouched();
|
|
3372
3655
|
}
|
|
3373
|
-
|
|
3656
|
+
markAllAsDirty() {
|
|
3374
3657
|
this._dirty.set(true);
|
|
3658
|
+
const controls = this.controls();
|
|
3659
|
+
for (const key of Object.keys(controls)) controls[key].markAllAsDirty();
|
|
3375
3660
|
}
|
|
3376
|
-
|
|
3661
|
+
markAllAsPristine() {
|
|
3377
3662
|
this._dirty.set(false);
|
|
3663
|
+
const controls = this.controls();
|
|
3664
|
+
for (const key of Object.keys(controls)) controls[key].markAllAsPristine();
|
|
3378
3665
|
}
|
|
3379
3666
|
disable() {
|
|
3380
|
-
this.
|
|
3667
|
+
this._ownDisabled.set(true);
|
|
3668
|
+
const controls = this.controls();
|
|
3669
|
+
for (const key of Object.keys(controls)) controls[key].disable();
|
|
3381
3670
|
}
|
|
3382
3671
|
enable() {
|
|
3383
|
-
this.
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
this._validators = validators;
|
|
3387
|
-
this.runValidation();
|
|
3388
|
-
}
|
|
3389
|
-
setAsyncValidators(validators) {
|
|
3390
|
-
this._asyncValidators = validators;
|
|
3391
|
-
this.runValidation();
|
|
3392
|
-
}
|
|
3393
|
-
addValidators(validators) {
|
|
3394
|
-
this._validators = [...this._validators, ...validators];
|
|
3395
|
-
this.runValidation();
|
|
3396
|
-
}
|
|
3397
|
-
removeValidators(validators) {
|
|
3398
|
-
this._validators = this._validators.filter((v) => !validators.includes(v));
|
|
3399
|
-
this.runValidation();
|
|
3672
|
+
this._ownDisabled.set(false);
|
|
3673
|
+
const controls = this.controls();
|
|
3674
|
+
for (const key of Object.keys(controls)) controls[key].enable();
|
|
3400
3675
|
}
|
|
3401
3676
|
async validate() {
|
|
3677
|
+
const controls = this.controls();
|
|
3678
|
+
await Promise.all(Object.keys(controls).map((key) => controls[key].validate()));
|
|
3402
3679
|
await this.runValidation();
|
|
3403
3680
|
}
|
|
3404
|
-
getError(code) {
|
|
3405
|
-
return this.errors()?.[code] ?? null;
|
|
3406
|
-
}
|
|
3407
|
-
hasError(code) {
|
|
3408
|
-
return this.errors()?.[code] !== void 0;
|
|
3409
|
-
}
|
|
3410
3681
|
destroy() {
|
|
3411
|
-
this.
|
|
3412
|
-
this.
|
|
3413
|
-
|
|
3414
|
-
this.
|
|
3415
|
-
this.
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
const
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
if (
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
...result
|
|
3441
|
-
};
|
|
3442
|
-
} finally {
|
|
3443
|
-
if (validationId === this._asyncValidationId) this._pending.set(false);
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
this.errors.set(errors);
|
|
3682
|
+
this._childValueEffect.destroy();
|
|
3683
|
+
const controls = this.controls();
|
|
3684
|
+
for (const key of Object.keys(controls)) controls[key].destroy();
|
|
3685
|
+
this.destroySignals();
|
|
3686
|
+
this.controls.destroy();
|
|
3687
|
+
}
|
|
3688
|
+
computeDirty() {
|
|
3689
|
+
if (this._dirty()) return true;
|
|
3690
|
+
const controls = this.controls();
|
|
3691
|
+
return Object.keys(controls).some((key) => controls[key].dirty());
|
|
3692
|
+
}
|
|
3693
|
+
computeTouched() {
|
|
3694
|
+
if (this._touched()) return true;
|
|
3695
|
+
const controls = this.controls();
|
|
3696
|
+
return Object.keys(controls).some((key) => controls[key].touched());
|
|
3697
|
+
}
|
|
3698
|
+
computePending() {
|
|
3699
|
+
if (this._pending()) return true;
|
|
3700
|
+
const controls = this.controls();
|
|
3701
|
+
return Object.keys(controls).some((key) => controls[key].pending());
|
|
3702
|
+
}
|
|
3703
|
+
hasInvalidChild() {
|
|
3704
|
+
const controls = this.controls();
|
|
3705
|
+
return Object.keys(controls).some((key) => controls[key].invalid());
|
|
3706
|
+
}
|
|
3707
|
+
static computeValue(controls) {
|
|
3708
|
+
const result = {};
|
|
3709
|
+
for (const key of Object.keys(controls)) result[key] = controls[key].value();
|
|
3710
|
+
return result;
|
|
3447
3711
|
}
|
|
3448
3712
|
};
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
this
|
|
3453
|
-
|
|
3454
|
-
this.
|
|
3455
|
-
this.
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
this._disabled.set(options.disabled ?? false);
|
|
3461
|
-
this.value = computed(() => this.computeValue());
|
|
3462
|
-
this.errors = signal(null);
|
|
3463
|
-
this.setupControlWatchers();
|
|
3464
|
-
this.valid = computed(() => {
|
|
3465
|
-
if (this.errors() !== null) return false;
|
|
3466
|
-
return Object.values(this.controls).every((control) => control.valid());
|
|
3467
|
-
});
|
|
3468
|
-
this.invalid = computed(() => !this.valid());
|
|
3469
|
-
this.pending = computed(() => {
|
|
3470
|
-
return Object.values(this.controls).some((control) => control.pending());
|
|
3471
|
-
});
|
|
3472
|
-
this.dirty = computed(() => {
|
|
3473
|
-
return Object.values(this.controls).some((control) => control.dirty());
|
|
3713
|
+
var FormArray = class extends AbstractControl {
|
|
3714
|
+
constructor(initialControls, options = {}) {
|
|
3715
|
+
super(initialControls.map((c) => c.value()), options);
|
|
3716
|
+
this.controls = signal([...initialControls]);
|
|
3717
|
+
for (const control of initialControls) control.parent = this;
|
|
3718
|
+
this.initializeAggregates();
|
|
3719
|
+
this._childValueEffect = new SignalEffect(() => {
|
|
3720
|
+
const controls = this.controls();
|
|
3721
|
+
for (const control of controls) control.value();
|
|
3722
|
+
this.value.set(controls.map((c) => c.value()));
|
|
3723
|
+
this.runValidation();
|
|
3474
3724
|
});
|
|
3475
|
-
this.
|
|
3476
|
-
return Object.values(this.controls).some((control) => control.touched());
|
|
3477
|
-
});
|
|
3478
|
-
this.pristine = computed(() => !this.dirty());
|
|
3479
|
-
this.disabled = computed(() => this._disabled());
|
|
3480
|
-
this.runGroupValidation();
|
|
3725
|
+
this._childValueEffect.run();
|
|
3481
3726
|
}
|
|
3482
|
-
get(
|
|
3483
|
-
return this.controls
|
|
3727
|
+
get length() {
|
|
3728
|
+
return this.controls().length;
|
|
3484
3729
|
}
|
|
3485
|
-
|
|
3486
|
-
this.controls[
|
|
3487
|
-
this.setupControlWatcher(control);
|
|
3730
|
+
at(index) {
|
|
3731
|
+
return this.controls()[index];
|
|
3488
3732
|
}
|
|
3489
|
-
|
|
3490
|
-
|
|
3733
|
+
push(control) {
|
|
3734
|
+
control.parent = this;
|
|
3735
|
+
this.controls.update((current) => [...current, control]);
|
|
3491
3736
|
}
|
|
3492
|
-
|
|
3493
|
-
|
|
3737
|
+
insert(index, control) {
|
|
3738
|
+
control.parent = this;
|
|
3739
|
+
this.controls.update((current) => {
|
|
3740
|
+
const next = [...current];
|
|
3741
|
+
next.splice(index, 0, control);
|
|
3742
|
+
return next;
|
|
3743
|
+
});
|
|
3744
|
+
}
|
|
3745
|
+
removeAt(index) {
|
|
3746
|
+
const control = this.controls()[index];
|
|
3747
|
+
if (!control) return;
|
|
3748
|
+
control.parent = null;
|
|
3749
|
+
control.destroy();
|
|
3750
|
+
this.controls.update((current) => current.filter((_, i) => i !== index));
|
|
3751
|
+
}
|
|
3752
|
+
clear() {
|
|
3753
|
+
const controls = this.controls();
|
|
3754
|
+
for (const control of controls) {
|
|
3755
|
+
control.parent = null;
|
|
3756
|
+
control.destroy();
|
|
3757
|
+
}
|
|
3758
|
+
this.controls.set([]);
|
|
3494
3759
|
}
|
|
3495
|
-
setValue(value) {
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3760
|
+
setValue(value, options) {
|
|
3761
|
+
if (this._ownDisabled()) return;
|
|
3762
|
+
const controls = this.controls();
|
|
3763
|
+
value.forEach((v, i) => {
|
|
3764
|
+
controls[i]?.setValue(v, options);
|
|
3499
3765
|
});
|
|
3766
|
+
if (options?.markAsPristine) this._dirty.set(false);
|
|
3500
3767
|
}
|
|
3501
|
-
patchValue(value) {
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3768
|
+
patchValue(value, options) {
|
|
3769
|
+
if (this._ownDisabled()) return;
|
|
3770
|
+
const controls = this.controls();
|
|
3771
|
+
value.forEach((v, i) => {
|
|
3772
|
+
if (v !== void 0) controls[i]?.setValue(v, options);
|
|
3505
3773
|
});
|
|
3774
|
+
if (options?.markAsPristine) this._dirty.set(false);
|
|
3506
3775
|
}
|
|
3507
3776
|
reset(value) {
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
const resetValue = value?.[key];
|
|
3511
|
-
control.reset(resetValue);
|
|
3777
|
+
this.controls().forEach((control, i) => {
|
|
3778
|
+
control.reset(value?.[i]);
|
|
3512
3779
|
});
|
|
3513
3780
|
}
|
|
3514
3781
|
markAllAsTouched() {
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
});
|
|
3782
|
+
this._touched.set(true);
|
|
3783
|
+
for (const control of this.controls()) control.markAllAsTouched();
|
|
3518
3784
|
}
|
|
3519
3785
|
markAllAsUntouched() {
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
});
|
|
3786
|
+
this._touched.set(false);
|
|
3787
|
+
for (const control of this.controls()) control.markAllAsUntouched();
|
|
3523
3788
|
}
|
|
3524
3789
|
markAllAsDirty() {
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
});
|
|
3790
|
+
this._dirty.set(true);
|
|
3791
|
+
for (const control of this.controls()) control.markAllAsDirty();
|
|
3528
3792
|
}
|
|
3529
3793
|
markAllAsPristine() {
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
});
|
|
3794
|
+
this._dirty.set(false);
|
|
3795
|
+
for (const control of this.controls()) control.markAllAsPristine();
|
|
3533
3796
|
}
|
|
3534
3797
|
disable() {
|
|
3535
|
-
this.
|
|
3536
|
-
|
|
3537
|
-
control.disable();
|
|
3538
|
-
});
|
|
3798
|
+
this._ownDisabled.set(true);
|
|
3799
|
+
for (const control of this.controls()) control.disable();
|
|
3539
3800
|
}
|
|
3540
3801
|
enable() {
|
|
3541
|
-
this.
|
|
3542
|
-
|
|
3543
|
-
control.enable();
|
|
3544
|
-
});
|
|
3802
|
+
this._ownDisabled.set(false);
|
|
3803
|
+
for (const control of this.controls()) control.enable();
|
|
3545
3804
|
}
|
|
3546
3805
|
async validate() {
|
|
3547
|
-
await Promise.all(
|
|
3548
|
-
await this.
|
|
3549
|
-
}
|
|
3550
|
-
setValidators(validators) {
|
|
3551
|
-
this._validators = validators;
|
|
3552
|
-
this.runGroupValidation();
|
|
3553
|
-
}
|
|
3554
|
-
getError(code) {
|
|
3555
|
-
return this.errors()?.[code] ?? null;
|
|
3556
|
-
}
|
|
3557
|
-
hasError(code) {
|
|
3558
|
-
return this.errors()?.[code] !== void 0;
|
|
3806
|
+
await Promise.all(this.controls().map((c) => c.validate()));
|
|
3807
|
+
await this.runValidation();
|
|
3559
3808
|
}
|
|
3560
3809
|
destroy() {
|
|
3561
|
-
this.
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3810
|
+
this._childValueEffect.destroy();
|
|
3811
|
+
for (const control of this.controls()) control.destroy();
|
|
3812
|
+
this.destroySignals();
|
|
3813
|
+
this.controls.destroy();
|
|
3565
3814
|
}
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
result[key] = this.controls[key].value();
|
|
3570
|
-
});
|
|
3571
|
-
return result;
|
|
3815
|
+
computeDirty() {
|
|
3816
|
+
if (this._dirty()) return true;
|
|
3817
|
+
return this.controls().some((c) => c.dirty());
|
|
3572
3818
|
}
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
});
|
|
3819
|
+
computeTouched() {
|
|
3820
|
+
if (this._touched()) return true;
|
|
3821
|
+
return this.controls().some((c) => c.touched());
|
|
3577
3822
|
}
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
this.runGroupValidation();
|
|
3582
|
-
});
|
|
3583
|
-
effect.run();
|
|
3584
|
-
this._controlEffects.push(effect);
|
|
3823
|
+
computePending() {
|
|
3824
|
+
if (this._pending()) return true;
|
|
3825
|
+
return this.controls().some((c) => c.pending());
|
|
3585
3826
|
}
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
let errors = null;
|
|
3589
|
-
for (const validator of this._validators) {
|
|
3590
|
-
const result = validator(value);
|
|
3591
|
-
if (result !== null) errors = {
|
|
3592
|
-
...errors ?? {},
|
|
3593
|
-
...result
|
|
3594
|
-
};
|
|
3595
|
-
}
|
|
3596
|
-
if (this._asyncValidators.length > 0 && errors === null) {
|
|
3597
|
-
const asyncResults = await Promise.all(this._asyncValidators.map((v) => v(value)));
|
|
3598
|
-
for (const result of asyncResults) if (result !== null) errors = {
|
|
3599
|
-
...errors ?? {},
|
|
3600
|
-
...result
|
|
3601
|
-
};
|
|
3602
|
-
}
|
|
3603
|
-
this.errors.set(errors);
|
|
3827
|
+
hasInvalidChild() {
|
|
3828
|
+
return this.controls().some((c) => c.invalid());
|
|
3604
3829
|
}
|
|
3605
3830
|
};
|
|
3606
3831
|
function createFormControl(initialValue, options) {
|
|
@@ -3609,19 +3834,32 @@ function createFormControl(initialValue, options) {
|
|
|
3609
3834
|
function createFormGroup(controls, options) {
|
|
3610
3835
|
return new FormGroup(controls, options);
|
|
3611
3836
|
}
|
|
3837
|
+
function createFormArray(controls, options) {
|
|
3838
|
+
return new FormArray(controls, options);
|
|
3839
|
+
}
|
|
3840
|
+
registerDefaultMessages({
|
|
3841
|
+
required: "This field is required",
|
|
3842
|
+
minLength: (params) => `Minimum length is ${params.min} characters`,
|
|
3843
|
+
maxLength: (params) => `Maximum length is ${params.max} characters`,
|
|
3844
|
+
pattern: "Value does not match required pattern",
|
|
3845
|
+
email: "Please enter a valid email address",
|
|
3846
|
+
min: (params) => `Value must be at least ${params.min}`,
|
|
3847
|
+
max: (params) => `Value must be at most ${params.max}`,
|
|
3848
|
+
range: (params) => `Value must be between ${params.min} and ${params.max}`
|
|
3849
|
+
});
|
|
3850
|
+
var EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
3851
|
+
function isEmpty(value) {
|
|
3852
|
+
return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
|
|
3853
|
+
}
|
|
3612
3854
|
const Validators = {
|
|
3613
|
-
required
|
|
3614
|
-
return value
|
|
3615
|
-
code: "required",
|
|
3616
|
-
message: "This field is required"
|
|
3617
|
-
} } : null;
|
|
3855
|
+
required(value) {
|
|
3856
|
+
return isEmpty(value) ? { required: { code: "required" } } : null;
|
|
3618
3857
|
},
|
|
3619
|
-
minLength
|
|
3858
|
+
minLength(min) {
|
|
3620
3859
|
return (value) => {
|
|
3621
3860
|
if (!value || value.length === 0) return null;
|
|
3622
3861
|
return value.length < min ? { minLength: {
|
|
3623
3862
|
code: "minLength",
|
|
3624
|
-
message: `Minimum length is ${min} characters`,
|
|
3625
3863
|
params: {
|
|
3626
3864
|
min,
|
|
3627
3865
|
actual: value.length
|
|
@@ -3629,12 +3867,11 @@ const Validators = {
|
|
|
3629
3867
|
} } : null;
|
|
3630
3868
|
};
|
|
3631
3869
|
},
|
|
3632
|
-
maxLength
|
|
3870
|
+
maxLength(max) {
|
|
3633
3871
|
return (value) => {
|
|
3634
3872
|
if (!value) return null;
|
|
3635
3873
|
return value.length > max ? { maxLength: {
|
|
3636
3874
|
code: "maxLength",
|
|
3637
|
-
message: `Maximum length is ${max} characters`,
|
|
3638
3875
|
params: {
|
|
3639
3876
|
max,
|
|
3640
3877
|
actual: value.length
|
|
@@ -3642,29 +3879,24 @@ const Validators = {
|
|
|
3642
3879
|
} } : null;
|
|
3643
3880
|
};
|
|
3644
3881
|
},
|
|
3645
|
-
pattern
|
|
3882
|
+
pattern(regex) {
|
|
3646
3883
|
return (value) => {
|
|
3647
3884
|
if (!value) return null;
|
|
3648
3885
|
return !regex.test(value) ? { pattern: {
|
|
3649
3886
|
code: "pattern",
|
|
3650
|
-
message: "Value does not match required pattern",
|
|
3651
3887
|
params: { pattern: regex.toString() }
|
|
3652
3888
|
} } : null;
|
|
3653
3889
|
};
|
|
3654
3890
|
},
|
|
3655
|
-
email
|
|
3891
|
+
email(value) {
|
|
3656
3892
|
if (!value) return null;
|
|
3657
|
-
return
|
|
3658
|
-
code: "email",
|
|
3659
|
-
message: "Please enter a valid email address"
|
|
3660
|
-
} } : null;
|
|
3893
|
+
return !EMAIL_REGEX.test(value) ? { email: { code: "email" } } : null;
|
|
3661
3894
|
},
|
|
3662
|
-
min
|
|
3895
|
+
min(minValue) {
|
|
3663
3896
|
return (value) => {
|
|
3664
3897
|
if (value === null || value === void 0) return null;
|
|
3665
3898
|
return value < minValue ? { min: {
|
|
3666
3899
|
code: "min",
|
|
3667
|
-
message: `Value must be at least ${minValue}`,
|
|
3668
3900
|
params: {
|
|
3669
3901
|
min: minValue,
|
|
3670
3902
|
actual: value
|
|
@@ -3672,12 +3904,11 @@ const Validators = {
|
|
|
3672
3904
|
} } : null;
|
|
3673
3905
|
};
|
|
3674
3906
|
},
|
|
3675
|
-
max
|
|
3907
|
+
max(maxValue) {
|
|
3676
3908
|
return (value) => {
|
|
3677
3909
|
if (value === null || value === void 0) return null;
|
|
3678
3910
|
return value > maxValue ? { max: {
|
|
3679
3911
|
code: "max",
|
|
3680
|
-
message: `Value must be at most ${maxValue}`,
|
|
3681
3912
|
params: {
|
|
3682
3913
|
max: maxValue,
|
|
3683
3914
|
actual: value
|
|
@@ -3685,12 +3916,11 @@ const Validators = {
|
|
|
3685
3916
|
} } : null;
|
|
3686
3917
|
};
|
|
3687
3918
|
},
|
|
3688
|
-
range
|
|
3919
|
+
range(minValue, maxValue) {
|
|
3689
3920
|
return (value) => {
|
|
3690
3921
|
if (value === null || value === void 0) return null;
|
|
3691
3922
|
if (value < minValue || value > maxValue) return { range: {
|
|
3692
3923
|
code: "range",
|
|
3693
|
-
message: `Value must be between ${minValue} and ${maxValue}`,
|
|
3694
3924
|
params: {
|
|
3695
3925
|
min: minValue,
|
|
3696
3926
|
max: maxValue,
|
|
@@ -3700,7 +3930,7 @@ const Validators = {
|
|
|
3700
3930
|
return null;
|
|
3701
3931
|
};
|
|
3702
3932
|
},
|
|
3703
|
-
compose
|
|
3933
|
+
compose(...validators) {
|
|
3704
3934
|
return (value) => {
|
|
3705
3935
|
let errors = null;
|
|
3706
3936
|
for (const validator of validators) {
|
|
@@ -3713,7 +3943,7 @@ const Validators = {
|
|
|
3713
3943
|
return errors;
|
|
3714
3944
|
};
|
|
3715
3945
|
},
|
|
3716
|
-
composeAsync
|
|
3946
|
+
composeAsync(...validators) {
|
|
3717
3947
|
return async (value) => {
|
|
3718
3948
|
const results = await Promise.all(validators.map((v) => v(value)));
|
|
3719
3949
|
let errors = null;
|
|
@@ -3725,56 +3955,99 @@ const Validators = {
|
|
|
3725
3955
|
};
|
|
3726
3956
|
}
|
|
3727
3957
|
};
|
|
3728
|
-
function createValidator(code, validationFn,
|
|
3958
|
+
function createValidator(code, validationFn, defaultMessage) {
|
|
3959
|
+
if (defaultMessage !== void 0) setDefaultMessage(code, defaultMessage);
|
|
3729
3960
|
return (value) => {
|
|
3730
3961
|
if (validationFn(value)) return null;
|
|
3731
|
-
return { [code]: {
|
|
3732
|
-
code,
|
|
3733
|
-
message: typeof message === "function" ? message(value) : message
|
|
3734
|
-
} };
|
|
3962
|
+
return { [code]: { code } };
|
|
3735
3963
|
};
|
|
3736
3964
|
}
|
|
3737
|
-
function createAsyncValidator(code, validationFn,
|
|
3965
|
+
function createAsyncValidator(code, validationFn, defaultMessage) {
|
|
3966
|
+
if (defaultMessage !== void 0) setDefaultMessage(code, defaultMessage);
|
|
3738
3967
|
return async (value) => {
|
|
3739
3968
|
if (await validationFn(value)) return null;
|
|
3740
|
-
return { [code]: {
|
|
3741
|
-
code,
|
|
3742
|
-
message: typeof message === "function" ? message(value) : message
|
|
3743
|
-
} };
|
|
3969
|
+
return { [code]: { code } };
|
|
3744
3970
|
};
|
|
3745
3971
|
}
|
|
3746
|
-
|
|
3747
|
-
|
|
3972
|
+
var registry = [];
|
|
3973
|
+
function registerAdapter(predicate, adapter) {
|
|
3974
|
+
registry.unshift({
|
|
3975
|
+
predicate,
|
|
3976
|
+
adapter
|
|
3977
|
+
});
|
|
3978
|
+
}
|
|
3979
|
+
function getAdapter(element) {
|
|
3980
|
+
for (const entry of registry) if (entry.predicate(element)) return entry.adapter;
|
|
3748
3981
|
}
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
}
|
|
3758
|
-
|
|
3982
|
+
const textAdapter = {
|
|
3983
|
+
inputEvent: "input",
|
|
3984
|
+
blurEvent: "focusout",
|
|
3985
|
+
getValue(element) {
|
|
3986
|
+
return element.value ?? "";
|
|
3987
|
+
},
|
|
3988
|
+
setValue(element, value) {
|
|
3989
|
+
element.value = value !== null && value !== void 0 ? String(value) : "";
|
|
3990
|
+
},
|
|
3991
|
+
setDisabled(element, disabled) {
|
|
3992
|
+
if (disabled) element.setAttribute("disabled", "");
|
|
3993
|
+
else element.removeAttribute("disabled");
|
|
3994
|
+
}
|
|
3995
|
+
};
|
|
3996
|
+
const checkboxAdapter = {
|
|
3997
|
+
inputEvent: "change",
|
|
3998
|
+
blurEvent: "focusout",
|
|
3999
|
+
getValue(element) {
|
|
4000
|
+
return element.checked;
|
|
4001
|
+
},
|
|
4002
|
+
setValue(element, value) {
|
|
4003
|
+
element.checked = Boolean(value);
|
|
4004
|
+
},
|
|
4005
|
+
setDisabled(element, disabled) {
|
|
4006
|
+
if (disabled) element.setAttribute("disabled", "");
|
|
4007
|
+
else element.removeAttribute("disabled");
|
|
4008
|
+
}
|
|
4009
|
+
};
|
|
4010
|
+
const radioAdapter = {
|
|
4011
|
+
inputEvent: "change",
|
|
4012
|
+
blurEvent: "focusout",
|
|
4013
|
+
getValue(element) {
|
|
4014
|
+
const input = element;
|
|
4015
|
+
return input.checked ? input.value : "";
|
|
4016
|
+
},
|
|
4017
|
+
setValue(element, value) {
|
|
4018
|
+
const input = element;
|
|
4019
|
+
input.checked = input.value === value;
|
|
4020
|
+
},
|
|
4021
|
+
setDisabled(element, disabled) {
|
|
4022
|
+
if (disabled) element.setAttribute("disabled", "");
|
|
4023
|
+
else element.removeAttribute("disabled");
|
|
4024
|
+
}
|
|
4025
|
+
};
|
|
4026
|
+
function registerNativeAdapters() {
|
|
4027
|
+
registerAdapter((el) => el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT", textAdapter);
|
|
4028
|
+
registerAdapter((el) => el.tagName === "INPUT" && el.type === "radio", radioAdapter);
|
|
4029
|
+
registerAdapter((el) => el.tagName === "INPUT" && el.type === "checkbox", checkboxAdapter);
|
|
3759
4030
|
}
|
|
4031
|
+
registerNativeAdapters();
|
|
3760
4032
|
function formControlDirective(element, value, _) {
|
|
3761
|
-
if (!
|
|
3762
|
-
console.warn("formControl directive: value must be
|
|
4033
|
+
if (!(value instanceof AbstractControl)) {
|
|
4034
|
+
console.warn("formControl directive: value must be an AbstractControl");
|
|
3763
4035
|
return;
|
|
3764
4036
|
}
|
|
3765
4037
|
const control = value;
|
|
3766
|
-
const
|
|
4038
|
+
const adapter = getAdapter(element);
|
|
4039
|
+
if (!adapter) {
|
|
4040
|
+
console.warn(`formControl directive: no adapter registered for <${element.tagName.toLowerCase()}>`);
|
|
4041
|
+
return;
|
|
4042
|
+
}
|
|
3767
4043
|
const cleanupFns = [];
|
|
3768
|
-
const
|
|
3769
|
-
|
|
3770
|
-
else if (inputType === "radio") element.checked = element.value === val;
|
|
3771
|
-
else element.value = val !== null && val !== void 0 ? String(val) : "";
|
|
4044
|
+
const syncElementValue = (val) => {
|
|
4045
|
+
adapter.setValue(element, val);
|
|
3772
4046
|
};
|
|
3773
|
-
const
|
|
3774
|
-
|
|
3775
|
-
else element.removeAttribute("disabled");
|
|
4047
|
+
const syncDisabled = (disabled) => {
|
|
4048
|
+
adapter.setDisabled?.(element, disabled);
|
|
3776
4049
|
};
|
|
3777
|
-
const
|
|
4050
|
+
const syncClasses = () => {
|
|
3778
4051
|
element.classList.toggle("mf-valid", control.valid());
|
|
3779
4052
|
element.classList.toggle("mf-invalid", control.invalid());
|
|
3780
4053
|
element.classList.toggle("mf-dirty", control.dirty());
|
|
@@ -3783,40 +4056,38 @@ function formControlDirective(element, value, _) {
|
|
|
3783
4056
|
element.classList.toggle("mf-pending", control.pending());
|
|
3784
4057
|
element.classList.toggle("mf-disabled", control.disabled());
|
|
3785
4058
|
};
|
|
3786
|
-
const
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
4059
|
+
const syncError = () => {
|
|
4060
|
+
if (!control.touched() || !control.errors()) {
|
|
4061
|
+
element.removeAttribute("error");
|
|
4062
|
+
return;
|
|
4063
|
+
}
|
|
4064
|
+
const message = control.getFirstErrorMessage();
|
|
4065
|
+
if (message) element.setAttribute("error", message);
|
|
4066
|
+
else element.removeAttribute("error");
|
|
4067
|
+
};
|
|
4068
|
+
const handleInput = (event) => {
|
|
4069
|
+
const target = event.target;
|
|
4070
|
+
if (target === element || element.contains(target)) control.setValue(adapter.getValue(element));
|
|
3792
4071
|
};
|
|
3793
4072
|
const handleBlur = () => {
|
|
3794
4073
|
control.markAsTouched();
|
|
3795
4074
|
};
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
cleanupFns.push(
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
const unsubscribeState = control.state.subscribe(() => {
|
|
3807
|
-
updateValidationClasses();
|
|
3808
|
-
});
|
|
3809
|
-
cleanupFns.push(unsubscribeState);
|
|
3810
|
-
updateValidationClasses();
|
|
3811
|
-
const eventType = control.updateOn === "blur" ? "change" : "input";
|
|
3812
|
-
element.addEventListener(eventType, handleInput);
|
|
3813
|
-
element.addEventListener("blur", handleBlur);
|
|
4075
|
+
syncElementValue(control.value());
|
|
4076
|
+
syncDisabled(control.disabled());
|
|
4077
|
+
syncClasses();
|
|
4078
|
+
syncError();
|
|
4079
|
+
cleanupFns.push(control.value.subscribe((v) => syncElementValue(v)));
|
|
4080
|
+
cleanupFns.push(control.disabled.subscribe((d) => syncDisabled(d)));
|
|
4081
|
+
cleanupFns.push(control.state.subscribe(() => syncClasses()));
|
|
4082
|
+
cleanupFns.push(control.state.subscribe(() => syncError()));
|
|
4083
|
+
element.addEventListener(adapter.inputEvent, handleInput);
|
|
4084
|
+
element.addEventListener(adapter.blurEvent, handleBlur);
|
|
3814
4085
|
element.setAttribute("data-form-control", "");
|
|
3815
4086
|
return () => {
|
|
3816
|
-
element.removeEventListener(
|
|
3817
|
-
element.removeEventListener(
|
|
4087
|
+
element.removeEventListener(adapter.inputEvent, handleInput);
|
|
4088
|
+
element.removeEventListener(adapter.blurEvent, handleBlur);
|
|
3818
4089
|
element.removeAttribute("data-form-control");
|
|
3819
|
-
|
|
4090
|
+
for (const fn of cleanupFns) fn();
|
|
3820
4091
|
};
|
|
3821
4092
|
}
|
|
3822
4093
|
registerAttributeDirective("formControl", formControlDirective);
|
|
@@ -5984,6 +6255,17 @@ const inputStyles = () => css`
|
|
|
5984
6255
|
flex-shrink: 0;
|
|
5985
6256
|
}
|
|
5986
6257
|
`;
|
|
6258
|
+
registerAdapter((el) => el.tagName === "ML-INPUT", {
|
|
6259
|
+
inputEvent: "ml:input",
|
|
6260
|
+
blurEvent: "focusout",
|
|
6261
|
+
getValue: (el) => el.value ?? "",
|
|
6262
|
+
setValue: (el, value) => {
|
|
6263
|
+
el.value = value !== null && value !== void 0 ? String(value) : "";
|
|
6264
|
+
},
|
|
6265
|
+
setDisabled: (el, disabled) => {
|
|
6266
|
+
el.disabled = disabled;
|
|
6267
|
+
}
|
|
6268
|
+
});
|
|
5987
6269
|
var InputComponent = class InputComponent$1 {
|
|
5988
6270
|
constructor() {
|
|
5989
6271
|
this.type = "text";
|
|
@@ -6260,6 +6542,17 @@ const textareaStyles = () => css`
|
|
|
6260
6542
|
font-size: var(--ml-text-base);
|
|
6261
6543
|
}
|
|
6262
6544
|
`;
|
|
6545
|
+
registerAdapter((el) => el.tagName === "ML-TEXTAREA", {
|
|
6546
|
+
inputEvent: "ml:input",
|
|
6547
|
+
blurEvent: "focusout",
|
|
6548
|
+
getValue: (el) => el.value ?? "",
|
|
6549
|
+
setValue: (el, value) => {
|
|
6550
|
+
el.value = value !== null && value !== void 0 ? String(value) : "";
|
|
6551
|
+
},
|
|
6552
|
+
setDisabled: (el, disabled) => {
|
|
6553
|
+
el.disabled = disabled;
|
|
6554
|
+
}
|
|
6555
|
+
});
|
|
6263
6556
|
var TextareaComponent = class TextareaComponent$1 {
|
|
6264
6557
|
constructor() {
|
|
6265
6558
|
this.value = "";
|
|
@@ -6514,6 +6807,17 @@ const checkboxStyles = () => css`
|
|
|
6514
6807
|
--ml-checkbox-label-line-height: 1.5rem;
|
|
6515
6808
|
}
|
|
6516
6809
|
`;
|
|
6810
|
+
registerAdapter((el) => el.tagName === "ML-CHECKBOX", {
|
|
6811
|
+
inputEvent: "ml:change",
|
|
6812
|
+
blurEvent: "focusout",
|
|
6813
|
+
getValue: (el) => Boolean(el.checked),
|
|
6814
|
+
setValue: (el, value) => {
|
|
6815
|
+
el.checked = Boolean(value);
|
|
6816
|
+
},
|
|
6817
|
+
setDisabled: (el, disabled) => {
|
|
6818
|
+
el.disabled = disabled;
|
|
6819
|
+
}
|
|
6820
|
+
});
|
|
6517
6821
|
var CheckboxComponent = class CheckboxComponent$1 {
|
|
6518
6822
|
constructor() {
|
|
6519
6823
|
this.label = "";
|
|
@@ -6858,6 +7162,17 @@ const radioGroupStyles = () => css`
|
|
|
6858
7162
|
color: var(--ml-color-danger);
|
|
6859
7163
|
}
|
|
6860
7164
|
`;
|
|
7165
|
+
registerAdapter((el) => el.tagName === "ML-RADIO-GROUP", {
|
|
7166
|
+
inputEvent: "ml:change",
|
|
7167
|
+
blurEvent: "focusout",
|
|
7168
|
+
getValue: (el) => el.value ?? "",
|
|
7169
|
+
setValue: (el, value) => {
|
|
7170
|
+
el.value = value !== null && value !== void 0 ? String(value) : "";
|
|
7171
|
+
},
|
|
7172
|
+
setDisabled: (el, disabled) => {
|
|
7173
|
+
el.disabled = disabled;
|
|
7174
|
+
}
|
|
7175
|
+
});
|
|
6861
7176
|
var RadioGroupComponent = class RadioGroupComponent$1 {
|
|
6862
7177
|
constructor() {
|
|
6863
7178
|
this.label = "";
|
|
@@ -7549,6 +7864,17 @@ const toggleStyles = () => css`
|
|
|
7549
7864
|
line-height: var(--ml-leading-tight);
|
|
7550
7865
|
}
|
|
7551
7866
|
`;
|
|
7867
|
+
registerAdapter((el) => el.tagName === "ML-TOGGLE", {
|
|
7868
|
+
inputEvent: "ml:change",
|
|
7869
|
+
blurEvent: "focusout",
|
|
7870
|
+
getValue: (el) => Boolean(el.checked),
|
|
7871
|
+
setValue: (el, value) => {
|
|
7872
|
+
el.checked = Boolean(value);
|
|
7873
|
+
},
|
|
7874
|
+
setDisabled: (el, disabled) => {
|
|
7875
|
+
el.disabled = disabled;
|
|
7876
|
+
}
|
|
7877
|
+
});
|
|
7552
7878
|
var ToggleComponent = class ToggleComponent$1 {
|
|
7553
7879
|
constructor() {
|
|
7554
7880
|
this.label = "";
|
|
@@ -8115,6 +8441,22 @@ const selectStyles = () => css`
|
|
|
8115
8441
|
pointer-events: none;
|
|
8116
8442
|
}
|
|
8117
8443
|
`;
|
|
8444
|
+
registerAdapter((el) => el.tagName === "ML-SELECT", {
|
|
8445
|
+
inputEvent: "ml:change",
|
|
8446
|
+
blurEvent: "focusout",
|
|
8447
|
+
getValue: (el) => {
|
|
8448
|
+
const e = el;
|
|
8449
|
+
return e.multiple ? e.values ?? [] : e.value ?? "";
|
|
8450
|
+
},
|
|
8451
|
+
setValue: (el, value) => {
|
|
8452
|
+
const e = el;
|
|
8453
|
+
if (Array.isArray(value)) e.values = value;
|
|
8454
|
+
else e.value = value !== null && value !== void 0 ? String(value) : "";
|
|
8455
|
+
},
|
|
8456
|
+
setDisabled: (el, disabled) => {
|
|
8457
|
+
el.disabled = disabled;
|
|
8458
|
+
}
|
|
8459
|
+
});
|
|
8118
8460
|
var SelectComponent = class SelectComponent$1 {
|
|
8119
8461
|
constructor() {
|
|
8120
8462
|
this.label = "";
|
|
@@ -8687,6 +9029,17 @@ const sliderStyles = () => css`
|
|
|
8687
9029
|
color: var(--ml-slider-error-color);
|
|
8688
9030
|
}
|
|
8689
9031
|
`;
|
|
9032
|
+
registerAdapter((el) => el.tagName === "ML-SLIDER", {
|
|
9033
|
+
inputEvent: "ml:input",
|
|
9034
|
+
blurEvent: "focusout",
|
|
9035
|
+
getValue: (el) => Number(el.value) || 0,
|
|
9036
|
+
setValue: (el, value) => {
|
|
9037
|
+
el.value = Number(value) || 0;
|
|
9038
|
+
},
|
|
9039
|
+
setDisabled: (el, disabled) => {
|
|
9040
|
+
el.disabled = disabled;
|
|
9041
|
+
}
|
|
9042
|
+
});
|
|
8690
9043
|
var SliderComponent = class SliderComponent$1 {
|
|
8691
9044
|
constructor() {
|
|
8692
9045
|
this.label = "";
|
|
@@ -10229,6 +10582,17 @@ const datePickerStyles = () => css`
|
|
|
10229
10582
|
color: var(--ml-date-picker-error-color);
|
|
10230
10583
|
}
|
|
10231
10584
|
`;
|
|
10585
|
+
registerAdapter((el) => el.tagName === "ML-DATE-PICKER", {
|
|
10586
|
+
inputEvent: "ml:select",
|
|
10587
|
+
blurEvent: "focusout",
|
|
10588
|
+
getValue: (el) => el.value ?? "",
|
|
10589
|
+
setValue: (el, value) => {
|
|
10590
|
+
el.value = value !== null && value !== void 0 ? String(value) : "";
|
|
10591
|
+
},
|
|
10592
|
+
setDisabled: (el, disabled) => {
|
|
10593
|
+
el.disabled = disabled;
|
|
10594
|
+
}
|
|
10595
|
+
});
|
|
10232
10596
|
var DatePickerComponent = class DatePickerComponent$1 {
|
|
10233
10597
|
constructor() {
|
|
10234
10598
|
this.value = "";
|
|
@@ -12023,6 +12387,7 @@ const badgeStyles = () => css`
|
|
|
12023
12387
|
|
|
12024
12388
|
/* ── Badge: dot ── */
|
|
12025
12389
|
--ml-badge-dot-size: 0.375rem;
|
|
12390
|
+
--ml-badge-dot-size-xs: 0.3125rem;
|
|
12026
12391
|
--ml-badge-dot-size-lg: 0.5rem;
|
|
12027
12392
|
|
|
12028
12393
|
/* ── Badge: secondary variant ── */
|
|
@@ -12060,6 +12425,16 @@ const badgeStyles = () => css`
|
|
|
12060
12425
|
height: var(--ml-badge-dot-size-lg);
|
|
12061
12426
|
}
|
|
12062
12427
|
|
|
12428
|
+
.ml-badge--xs .ml-badge__dot {
|
|
12429
|
+
width: var(--ml-badge-dot-size-xs);
|
|
12430
|
+
height: var(--ml-badge-dot-size-xs);
|
|
12431
|
+
}
|
|
12432
|
+
|
|
12433
|
+
.ml-badge--xs {
|
|
12434
|
+
padding: 1px var(--ml-space-1-5);
|
|
12435
|
+
font-size: 0.6875rem;
|
|
12436
|
+
}
|
|
12437
|
+
|
|
12063
12438
|
.ml-badge--sm {
|
|
12064
12439
|
padding: 2px var(--ml-space-2);
|
|
12065
12440
|
font-size: var(--ml-text-xs);
|
|
@@ -13303,10 +13678,21 @@ const tableStyles = () => css`
|
|
|
13303
13678
|
|
|
13304
13679
|
/* ── Table: surface ── */
|
|
13305
13680
|
--ml-table-bg: var(--ml-color-surface);
|
|
13681
|
+
--ml-table-font: var(--ml-font-sans);
|
|
13682
|
+
|
|
13683
|
+
/* Deprecated aliases — prefer container-* and divider-* tokens below */
|
|
13306
13684
|
--ml-table-border-width: var(--ml-border);
|
|
13307
13685
|
--ml-table-border-color: var(--ml-color-border);
|
|
13308
13686
|
--ml-table-radius: var(--ml-radius-lg);
|
|
13309
|
-
|
|
13687
|
+
|
|
13688
|
+
/* ── Table: container chrome (outer border + radius) ── */
|
|
13689
|
+
--ml-table-container-border-width: var(--ml-table-border-width);
|
|
13690
|
+
--ml-table-container-border-color: var(--ml-table-border-color);
|
|
13691
|
+
--ml-table-container-radius: var(--ml-table-radius);
|
|
13692
|
+
|
|
13693
|
+
/* ── Table: internal dividers (header/row/footer separators) ── */
|
|
13694
|
+
--ml-table-divider-width: var(--ml-table-border-width);
|
|
13695
|
+
--ml-table-divider-color: var(--ml-table-border-color);
|
|
13310
13696
|
|
|
13311
13697
|
/* ── Table: header section ── */
|
|
13312
13698
|
--ml-table-title-color: var(--ml-color-text);
|
|
@@ -13340,8 +13726,8 @@ const tableStyles = () => css`
|
|
|
13340
13726
|
}
|
|
13341
13727
|
|
|
13342
13728
|
.ml-table {
|
|
13343
|
-
border: var(--ml-table-border-width) solid var(--ml-table-border-color);
|
|
13344
|
-
border-radius: var(--ml-table-radius);
|
|
13729
|
+
border: var(--ml-table-container-border-width) solid var(--ml-table-container-border-color);
|
|
13730
|
+
border-radius: var(--ml-table-container-radius);
|
|
13345
13731
|
background-color: var(--ml-table-bg);
|
|
13346
13732
|
overflow: hidden;
|
|
13347
13733
|
font-family: var(--ml-table-font);
|
|
@@ -13354,7 +13740,7 @@ const tableStyles = () => css`
|
|
|
13354
13740
|
justify-content: space-between;
|
|
13355
13741
|
gap: var(--ml-space-4);
|
|
13356
13742
|
padding: var(--ml-space-5) var(--ml-space-6);
|
|
13357
|
-
border-bottom: var(--ml-table-
|
|
13743
|
+
border-bottom: var(--ml-table-divider-width) solid var(--ml-table-divider-color);
|
|
13358
13744
|
}
|
|
13359
13745
|
|
|
13360
13746
|
.ml-table__header-text {
|
|
@@ -13401,7 +13787,7 @@ const tableStyles = () => css`
|
|
|
13401
13787
|
}
|
|
13402
13788
|
|
|
13403
13789
|
thead tr {
|
|
13404
|
-
border-bottom: var(--ml-table-
|
|
13790
|
+
border-bottom: var(--ml-table-divider-width) solid var(--ml-table-divider-color);
|
|
13405
13791
|
}
|
|
13406
13792
|
|
|
13407
13793
|
.ml-table__th {
|
|
@@ -13455,7 +13841,7 @@ const tableStyles = () => css`
|
|
|
13455
13841
|
|
|
13456
13842
|
/* ── Body rows ── */
|
|
13457
13843
|
.ml-table__row {
|
|
13458
|
-
border-bottom: var(--ml-table-
|
|
13844
|
+
border-bottom: var(--ml-table-divider-width) solid var(--ml-table-divider-color);
|
|
13459
13845
|
transition: background-color var(--ml-duration-150) var(--ml-ease-in-out);
|
|
13460
13846
|
}
|
|
13461
13847
|
|
|
@@ -13575,7 +13961,7 @@ const tableStyles = () => css`
|
|
|
13575
13961
|
align-items: center;
|
|
13576
13962
|
justify-content: space-between;
|
|
13577
13963
|
padding: var(--ml-space-3) var(--ml-space-6);
|
|
13578
|
-
border-top: var(--ml-table-
|
|
13964
|
+
border-top: var(--ml-table-divider-width) solid var(--ml-table-divider-color);
|
|
13579
13965
|
}
|
|
13580
13966
|
|
|
13581
13967
|
.ml-table--sm .ml-table__footer--visible {
|
|
@@ -25225,6 +25611,6 @@ DashboardPageComponent = __decorate([MelodicComponent({
|
|
|
25225
25611
|
"layout"
|
|
25226
25612
|
]
|
|
25227
25613
|
})], DashboardPageComponent);
|
|
25228
|
-
export { APP_CONFIG, AbortError, ActivityFeedComponent, ActivityFeedItemComponent, AlertComponent, AppShellComponent, AvatarComponent, BadgeComponent, BadgeGroupComponent, Binding, BreadcrumbComponent, BreadcrumbItemComponent, ButtonComponent, ButtonGroupComponent, ButtonGroupItemComponent, CalendarComponent, CalendarViewComponent, CardComponent, CheckboxComponent, ComponentBase, ComponentStateBaseService, ContainerComponent, DashboardPageComponent, DatePickerComponent, DialogComponent, DialogRef, DialogService, Directive, DividerComponent, DrawerComponent, DropdownComponent, DropdownGroupComponent, DropdownItemComponent, DropdownSeparatorComponent, EffectsBase,
|
|
25614
|
+
export { APP_CONFIG, AbortError, AbstractControl, ActivityFeedComponent, ActivityFeedItemComponent, AlertComponent, AppShellComponent, AvatarComponent, BadgeComponent, BadgeGroupComponent, Binding, BreadcrumbComponent, BreadcrumbItemComponent, ButtonComponent, ButtonGroupComponent, ButtonGroupItemComponent, CalendarComponent, CalendarViewComponent, CardComponent, CheckboxComponent, ComponentBase, ComponentStateBaseService, ContainerComponent, DashboardPageComponent, DatePickerComponent, DialogComponent, DialogRef, DialogService, Directive, DividerComponent, DrawerComponent, DropdownComponent, DropdownGroupComponent, DropdownItemComponent, DropdownSeparatorComponent, EffectsBase, FormArray, FormControl, FormFieldComponent, FormGroup, HeroSectionComponent, HttpBaseError, HttpClient, HttpError, IconComponent, Inject, Injectable, InjectionEngine, Injector, InputComponent, ListComponent, ListItemComponent, LoginPageComponent, MelodicComponent, NetworkError, PageHeaderComponent, PaginationComponent, PopoverComponent, ProgressComponent, ROUTE_CONTEXT_EVENT, RX_ACTION_PROVIDERS, RX_EFFECTS_PROVIDERS, RX_INIT_STATE, RX_STATE_DEBUG, RadioCardComponent, RadioCardGroupComponent, RadioComponent, RadioGroupComponent, RouteContextEvent, RouteContextService, RouteMatcher, RouterLinkComponent, RouterOutletComponent, RouterService, SIGNAL_MARKER, SelectComponent, Service, SidebarComponent, SidebarGroupComponent, SidebarItemComponent, SignalEffect, SignalStoreService, SignupPageComponent, SliderComponent, SpinnerComponent, StackComponent, StepComponent, StepPanelComponent, StepsComponent, TabComponent, TabPanelComponent, TableComponent, TabsComponent, TagComponent, TemplateResult, TextareaComponent, ToastComponent, ToastContainerComponent, ToastService, ToggleComponent, TooltipComponent, Validators, VirtualScroller, activityFeedItemStyles, activityFeedItemTemplate, activityFeedStyles, activityFeedTemplate, allTokens, announce, appShellStyles, appShellTemplate, applyGlobalStyles, applyTheme, arrow, autoUpdate, baseThemeCss, bootstrap, borderTokens, breadcrumbItemStyles, breadcrumbItemTemplate, breadcrumbStyles, breadcrumbTemplate, breakpointTokens, breakpoints, buildPathFromRoute, calendarViewStyles, calendarViewTemplate, checkboxAdapter, classMap, clickOutside, colorTokens, componentBaseStyles, computePosition, computed, containerStyles, containerTemplate, createAction, createAsyncValidator, createBrandTheme, createDeactivateGuard, createFocusTrap, createFormArray, createFormControl, createFormGroup, createGuard, createLiveRegion, createReducer, createResolver, createState, createTheme, createToken, createValidator, css, darkTheme, darkThemeCss, dashboardPageStyles, dashboardPageTemplate, defineConfig, directive, drawerStyles, drawerTemplate, dropdownGroupStyles, dropdownGroupTemplate, dropdownItemStyles, dropdownItemTemplate, dropdownSeparatorStyles, dropdownSeparatorTemplate, dropdownStyles, dropdownTemplate, environment, findRouteByName, flip, focusFirst, focusLast, focusTrap, focusVisible, formControlDirective, formFieldStyles, formFieldTemplate, getActiveEffect, getAdapter, getAttributeDirective, getEnvironment, getFirstFocusable, getFocusableElements, getGlobalMessage, getLastFocusable, getRegisteredDirectives, getResolvedTheme, getTheme, getTokenKey, hasAttributeDirective, heroSectionStyles, heroSectionTemplate, html, injectTheme, isDirective, isFocusVisible, isSignal, lightTheme, lightThemeCss, listItemStyles, listItemTemplate, listStyles, listTemplate, loginPageStyles, loginPageTemplate, matchRouteTree, newID, offset, onAction, onThemeChange, pageHeaderStyles, pageHeaderTemplate, paginationStyles, paginationTemplate, portalDirective, primitiveColors, progressStyles, progressTemplate, props, provideConfig, provideHttp, provideRX, radioAdapter, registerAdapter, registerAttributeDirective, registerDefaultMessages, render, repeat, repeatRaw, resetStyles, resolveMessage, routerLinkDirective, selectStyles, selectTemplate, setActiveEffect, setDefaultMessage, shadowTokens, shift, sidebarGroupStyles, sidebarGroupTemplate, sidebarItemStyles, sidebarItemTemplate, sidebarStyles, sidebarTemplate, signal, signupPageStyles, signupPageTemplate, sliderStyles, sliderTemplate, spacingTokens, stepPanelStyles, stepPanelTemplate, stepStyles, stepTemplate, stepsStyles, stepsTemplate, styleMap, tabPanelStyles, tabPanelTemplate, tabStyles, tabTemplate, tableStyles, tableTemplate, tabsStyles, tabsTemplate, textAdapter, toastContainerStyles, toastContainerTemplate, toastStyles, toastTemplate, toggleTheme, tokensToCss, tooltipDirective, transitionTokens, typographyTokens, unregisterAttributeDirective, unsafeHTML, visuallyHiddenStyles, when };
|
|
25229
25615
|
|
|
25230
25616
|
//# sourceMappingURL=melodic-components.js.map
|