@tstdl/base 0.91.40 → 0.91.42
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/examples/orm/test.js +1 -0
- package/examples/orm/user.model.d.ts +5 -0
- package/examples/orm/user.model.js +8 -2
- package/orm/types.d.ts +6 -5
- package/orm/types.js +2 -2
- package/package.json +3 -2
- package/form/abstract-control.d.ts +0 -72
- package/form/abstract-control.js +0 -82
- package/form/controls/checkbox.control.d.ts +0 -10
- package/form/controls/checkbox.control.js +0 -19
- package/form/controls/chip-select.control.d.ts +0 -36
- package/form/controls/chip-select.control.js +0 -56
- package/form/controls/date.control.d.ts +0 -26
- package/form/controls/date.control.js +0 -64
- package/form/controls/hidden.control.d.ts +0 -11
- package/form/controls/hidden.control.js +0 -22
- package/form/controls/index.d.ts +0 -10
- package/form/controls/index.js +0 -10
- package/form/controls/items.control.d.ts +0 -38
- package/form/controls/items.control.js +0 -41
- package/form/controls/number.control.d.ts +0 -33
- package/form/controls/number.control.js +0 -73
- package/form/controls/radio-group.control.d.ts +0 -22
- package/form/controls/radio-group.control.js +0 -28
- package/form/controls/select.control.d.ts +0 -17
- package/form/controls/select.control.js +0 -26
- package/form/controls/text.control.d.ts +0 -47
- package/form/controls/text.control.js +0 -94
- package/form/controls/time.control.d.ts +0 -24
- package/form/controls/time.control.js +0 -44
- package/form/form-array.d.ts +0 -71
- package/form/form-array.js +0 -188
- package/form/form-button.d.ts +0 -41
- package/form/form-button.js +0 -49
- package/form/form-container.d.ts +0 -24
- package/form/form-container.js +0 -33
- package/form/form-control.d.ts +0 -45
- package/form/form-control.js +0 -92
- package/form/form-dialog.d.ts +0 -22
- package/form/form-dialog.js +0 -24
- package/form/form-element.d.ts +0 -7
- package/form/form-element.js +0 -6
- package/form/form-group.d.ts +0 -70
- package/form/form-group.js +0 -134
- package/form/form-header-footer-element.d.ts +0 -14
- package/form/form-header-footer-element.js +0 -20
- package/form/form-portal.d.ts +0 -10
- package/form/form-portal.js +0 -13
- package/form/form-text.d.ts +0 -13
- package/form/form-text.js +0 -15
- package/form/form-wrapper.d.ts +0 -40
- package/form/form-wrapper.js +0 -64
- package/form/index.d.ts +0 -15
- package/form/index.js +0 -15
- package/form/localization.d.ts +0 -49
- package/form/localization.js +0 -56
- package/form/types.d.ts +0 -11
- package/form/types.js +0 -1
- package/form/utils.d.ts +0 -38
- package/form/utils.js +0 -47
- package/form/validators/boolean.validator.d.ts +0 -3
- package/form/validators/boolean.validator.js +0 -15
- package/form/validators/date.validator.d.ts +0 -4
- package/form/validators/date.validator.js +0 -26
- package/form/validators/form.validator.d.ts +0 -10
- package/form/validators/form.validator.js +0 -3
- package/form/validators/index.d.ts +0 -9
- package/form/validators/index.js +0 -9
- package/form/validators/max-length.validator.d.ts +0 -3
- package/form/validators/max-length.validator.js +0 -17
- package/form/validators/number.validator.d.ts +0 -4
- package/form/validators/number.validator.js +0 -22
- package/form/validators/pattern.validator.d.ts +0 -3
- package/form/validators/pattern.validator.js +0 -16
- package/form/validators/required.validator.d.ts +0 -3
- package/form/validators/required.validator.js +0 -16
- package/form/validators/time.validator.d.ts +0 -4
- package/form/validators/time.validator.js +0 -22
- package/form/validators/unique.validator.d.ts +0 -5
- package/form/validators/unique.validator.js +0 -22
package/form/form-group.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { computed, signal, switchAll } from '../signals/index.js';
|
|
2
|
-
import { fromEntries, hasOwnProperty, objectEntries } from '../utils/object/object.js';
|
|
3
|
-
import { isDefined, isNotNull } from '../utils/type-guards.js';
|
|
4
|
-
import { ignoreFormValue } from './abstract-control.js';
|
|
5
|
-
import { FormContainer } from './form-container.js';
|
|
6
|
-
import { reactiveOptionToSignal } from './utils.js';
|
|
7
|
-
export class FormGroup extends FormContainer {
|
|
8
|
-
#children = signal({});
|
|
9
|
-
#selfTouched = signal(false);
|
|
10
|
-
#selfDirty = signal(false);
|
|
11
|
-
internalValidators = null;
|
|
12
|
-
displayType;
|
|
13
|
-
stepperOrientation;
|
|
14
|
-
children = this.#children.asReadonly();
|
|
15
|
-
childrenEntries = computed(() => objectEntries(this.children()));
|
|
16
|
-
childrenValues = computed(() => this.childrenEntries().map(([_, child]) => child));
|
|
17
|
-
enabledChildrenEntries = computed(() => this.childrenEntries().filter(([_, child]) => child.enabled()));
|
|
18
|
-
enabledChildrenValues = computed(() => this.enabledChildrenEntries().map(([_, child]) => child));
|
|
19
|
-
/**
|
|
20
|
-
* Raw values of all children whether disabled or not
|
|
21
|
-
*/
|
|
22
|
-
rawValue = computed(() => fromEntries(this.childrenEntries().map(([key, child]) => [key, child.rawValue()]))); // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
23
|
-
/**
|
|
24
|
-
* If enabled: values of all enabled children
|
|
25
|
-
* if disabled: values of all children whether disabled or not (same as {@link rawValue})
|
|
26
|
-
*/
|
|
27
|
-
value = computed(() => (this.disabled()
|
|
28
|
-
? this.rawValue()
|
|
29
|
-
: fromEntries(this.childrenEntries()
|
|
30
|
-
.filter(([_, child]) => child.enabled())
|
|
31
|
-
.map(([key, child]) => [key, child.value()]))));
|
|
32
|
-
dirty = computed(() => this.#selfDirty() || this.enabledChildrenValues().some((child) => child.dirty()));
|
|
33
|
-
touched = computed(() => this.#selfTouched() || this.enabledChildrenValues().some((child) => child.touched()));
|
|
34
|
-
localErrors = switchAll(() => {
|
|
35
|
-
const validations = this.validators().map((validator) => validator(this));
|
|
36
|
-
return computed(() => validations.map((validation) => validation()).filter(isNotNull));
|
|
37
|
-
});
|
|
38
|
-
childrenErrors = computed(() => this.enabledChildrenValues().flatMap((child) => child.errors()));
|
|
39
|
-
errors = computed(() => [
|
|
40
|
-
...this.localErrors(),
|
|
41
|
-
...this.childrenErrors()
|
|
42
|
-
]);
|
|
43
|
-
errorDebug = computed(() => this.valid()
|
|
44
|
-
? null
|
|
45
|
-
: ({
|
|
46
|
-
_self: this.localErrors(),
|
|
47
|
-
...fromEntries(this.childrenEntries().map(([key, child]) => [key, child.errorDebug()]).filter(([, errorDebug]) => isNotNull(errorDebug)))
|
|
48
|
-
}));
|
|
49
|
-
constructor(options) {
|
|
50
|
-
super(options);
|
|
51
|
-
this.displayType = reactiveOptionToSignal(options.displayType ?? 'simple', { initialValue: 'simple' });
|
|
52
|
-
this.stepperOrientation = reactiveOptionToSignal(options.stepperOrientation ?? 'vertical', { initialValue: 'vertical' });
|
|
53
|
-
this.#children.set(options.children);
|
|
54
|
-
this.updateParents();
|
|
55
|
-
}
|
|
56
|
-
setParent(parent, force) {
|
|
57
|
-
super.setParent(parent, force);
|
|
58
|
-
this.updateParents(true);
|
|
59
|
-
}
|
|
60
|
-
getChildPath(child) {
|
|
61
|
-
return computed(() => {
|
|
62
|
-
const key = this.childrenEntries().find(([_, _child]) => child == _child)?.[0] ?? '_CHILD_NOT_FOUND_';
|
|
63
|
-
return this.path().add(key);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
reset() {
|
|
67
|
-
for (const child of this.childrenValues()) {
|
|
68
|
-
child.reset();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
get(key) {
|
|
72
|
-
return this.children()[key];
|
|
73
|
-
}
|
|
74
|
-
getValue(key) {
|
|
75
|
-
return this.get(key).value(); // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
76
|
-
}
|
|
77
|
-
getRawValue(key) {
|
|
78
|
-
return this.get(key).rawValue(); // eslint-disable-line @typescript-eslint/no-unsafe-return
|
|
79
|
-
}
|
|
80
|
-
patchValue(values) {
|
|
81
|
-
const children = this.children();
|
|
82
|
-
for (const [key, value] of objectEntries(values)) {
|
|
83
|
-
if (isDefined(value) && hasOwnProperty(children, key)) {
|
|
84
|
-
children[key].setValue(value);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
setValue(values) {
|
|
89
|
-
if (values == ignoreFormValue) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
for (const [key, child] of this.childrenEntries()) {
|
|
93
|
-
const value = values[key];
|
|
94
|
-
if (isDefined(value)) {
|
|
95
|
-
child.setValue(value);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
child.reset();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
markAsDirty({ onlySelf = false } = {}) {
|
|
103
|
-
this.#selfDirty.set(true);
|
|
104
|
-
if (onlySelf) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
for (const child of this.childrenValues()) {
|
|
108
|
-
child.markAsDirty();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
markAsTouched({ onlySelf = false } = {}) {
|
|
112
|
-
this.#selfTouched.set(true);
|
|
113
|
-
if (onlySelf) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
for (const child of this.childrenValues()) {
|
|
117
|
-
child.markAsTouched();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
*[Symbol.iterator]() {
|
|
121
|
-
yield* this.childrenEntries();
|
|
122
|
-
}
|
|
123
|
-
updateParents(force) {
|
|
124
|
-
for (const child of this.childrenValues()) {
|
|
125
|
-
child.setParent(this, force);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
export function formGroup(options) {
|
|
130
|
-
return new FormGroup(options);
|
|
131
|
-
}
|
|
132
|
-
export function isFormGroup(value) {
|
|
133
|
-
return (value instanceof FormGroup);
|
|
134
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ReactiveValue } from '../types.js';
|
|
2
|
-
import { FormElement, type FormElementOptions } from './form-element.js';
|
|
3
|
-
import type { ClassesOptions } from './types.js';
|
|
4
|
-
export type FormHeaderFooterElementOptions = FormElementOptions & ClassesOptions & {
|
|
5
|
-
hide?: ReactiveValue<boolean | null>;
|
|
6
|
-
show?: ReactiveValue<boolean | null>;
|
|
7
|
-
};
|
|
8
|
-
export declare abstract class FormHeaderFooterElement extends FormElement {
|
|
9
|
-
#private;
|
|
10
|
-
readonly hide: import("../signals/api.js").Signal<boolean>;
|
|
11
|
-
readonly show: import("../signals/api.js").Signal<boolean>;
|
|
12
|
-
readonly classes: import("../signals/api.js").Signal<string[]>;
|
|
13
|
-
constructor(options: FormHeaderFooterElementOptions);
|
|
14
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { computed, signal } from '../signals/api.js';
|
|
2
|
-
import { isDefined } from '../utils/type-guards.js';
|
|
3
|
-
import { FormElement } from './form-element.js';
|
|
4
|
-
import { bindReactiveOption, normalizeClassesOption } from './utils.js';
|
|
5
|
-
export class FormHeaderFooterElement extends FormElement {
|
|
6
|
-
#hide = signal(false);
|
|
7
|
-
#classes = signal([]);
|
|
8
|
-
hide = this.#hide.asReadonly();
|
|
9
|
-
show = computed(() => !this.hide());
|
|
10
|
-
classes = this.#classes.asReadonly();
|
|
11
|
-
constructor(options) {
|
|
12
|
-
super(options);
|
|
13
|
-
if (isDefined(options.show) && isDefined(options.hide)) {
|
|
14
|
-
throw new Error('Either enabled or disabled can be set but not both.');
|
|
15
|
-
}
|
|
16
|
-
bindReactiveOption(options.hide, (hide) => this.#hide.set(hide ?? false));
|
|
17
|
-
bindReactiveOption(options.show, (show) => this.#hide.set(!(show ?? true)));
|
|
18
|
-
bindReactiveOption(options.classes, (value) => this.#classes.set(normalizeClassesOption(value)));
|
|
19
|
-
}
|
|
20
|
-
}
|
package/form/form-portal.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TypedOmit } from '../types.js';
|
|
2
|
-
import { type AbstractControl, type AbstractControlRawValueType, type AbstractControlValueType } from './abstract-control.js';
|
|
3
|
-
import { FormWrapper, type FormWrapperOptions } from './form-wrapper.js';
|
|
4
|
-
export type FormPortalOptions<T, C extends AbstractControl<T>> = FormWrapperOptions<T, C>;
|
|
5
|
-
export type FormPortalByControl<C extends AbstractControl> = FormPortal<AbstractControlValueType<C>, AbstractControlRawValueType<C>, C>;
|
|
6
|
-
export declare class FormPortal<T = any, TRaw = any, C extends AbstractControl<T, TRaw> = AbstractControl<T, TRaw>> extends FormWrapper<T, TRaw, C> {
|
|
7
|
-
}
|
|
8
|
-
export declare function formPortal<C extends AbstractControl>(control: C, options?: TypedOmit<FormPortalOptions<AbstractControlRawValueType<C>, C>, 'element'>): FormPortal<AbstractControlValueType<C>, AbstractControlRawValueType<C>, C>;
|
|
9
|
-
export declare function formPortal<C extends AbstractControl>(options: FormPortalOptions<AbstractControlRawValueType<C>, C>): FormPortal<AbstractControlValueType<C>, AbstractControlRawValueType<C>, C>;
|
|
10
|
-
export declare function isFormPortal(value: any): value is FormPortal;
|
package/form/form-portal.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isAbstractControl } from './abstract-control.js';
|
|
2
|
-
import { FormWrapper } from './form-wrapper.js';
|
|
3
|
-
export class FormPortal extends FormWrapper {
|
|
4
|
-
}
|
|
5
|
-
export function formPortal(controlOrOptions, optionsOrNothing) {
|
|
6
|
-
if (isAbstractControl(controlOrOptions)) {
|
|
7
|
-
return new FormPortal({ ...optionsOrNothing, element: controlOrOptions });
|
|
8
|
-
}
|
|
9
|
-
return new FormPortal({ ...controlOrOptions });
|
|
10
|
-
}
|
|
11
|
-
export function isFormPortal(value) {
|
|
12
|
-
return (value instanceof FormPortal);
|
|
13
|
-
}
|
package/form/form-text.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Signal } from '../signals/api.js';
|
|
2
|
-
import type { ReactiveValue } from '../types.js';
|
|
3
|
-
import { FormHeaderFooterElement, type FormHeaderFooterElementOptions } from './form-header-footer-element.js';
|
|
4
|
-
import type { DynamicTextOption } from './types.js';
|
|
5
|
-
export type FormTextOptions = FormHeaderFooterElementOptions & {
|
|
6
|
-
text: ReactiveValue<DynamicTextOption>;
|
|
7
|
-
};
|
|
8
|
-
export declare class FormText extends FormHeaderFooterElement {
|
|
9
|
-
readonly text: Signal<DynamicTextOption>;
|
|
10
|
-
constructor(options: FormTextOptions);
|
|
11
|
-
}
|
|
12
|
-
export declare function formText(options: FormTextOptions): FormText;
|
|
13
|
-
export declare function isFormText(value: any): value is FormText;
|
package/form/form-text.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FormHeaderFooterElement } from './form-header-footer-element.js';
|
|
2
|
-
import { reactiveOptionToSignal } from './utils.js';
|
|
3
|
-
export class FormText extends FormHeaderFooterElement {
|
|
4
|
-
text;
|
|
5
|
-
constructor(options) {
|
|
6
|
-
super(options);
|
|
7
|
-
this.text = reactiveOptionToSignal(options.text, { initialValue: '[MISSING TEXT]' });
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function formText(options) {
|
|
11
|
-
return new FormText(options);
|
|
12
|
-
}
|
|
13
|
-
export function isFormText(value) {
|
|
14
|
-
return (value instanceof FormText);
|
|
15
|
-
}
|
package/form/form-wrapper.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type Signal } from '../signals/api.js';
|
|
2
|
-
import type { ReactiveValue } from '../types.js';
|
|
3
|
-
import type { AbstractControl, AbstractControlRawValueType, AbstractControlValueType } from './abstract-control.js';
|
|
4
|
-
import { type FormContainerOptions, FormContainer } from './form-container.js';
|
|
5
|
-
export type FormWrapperOptions<T, C extends AbstractControl<T>> = FormContainerOptions<T> & {
|
|
6
|
-
element: C;
|
|
7
|
-
forwardWrites?: ReactiveValue<boolean>;
|
|
8
|
-
forwardErrors?: ReactiveValue<boolean>;
|
|
9
|
-
};
|
|
10
|
-
export type FormWrapperByControl<C extends AbstractControl> = FormWrapper<AbstractControlValueType<C>, AbstractControlRawValueType<C>, C>;
|
|
11
|
-
export declare abstract class FormWrapper<T = any, TRaw = any, C extends AbstractControl<T, TRaw> = AbstractControl<T, TRaw>> extends FormContainer<T, TRaw> {
|
|
12
|
-
#private;
|
|
13
|
-
protected readonly internalValidators: null;
|
|
14
|
-
readonly element: Signal<C>;
|
|
15
|
-
readonly forwardWrites: Signal<boolean>;
|
|
16
|
-
readonly forwardErrors: Signal<boolean>;
|
|
17
|
-
errors: Signal<import("./index.js").FormValidatorError[]>;
|
|
18
|
-
valid: Signal<boolean>;
|
|
19
|
-
invalid: Signal<boolean>;
|
|
20
|
-
disabled: Signal<boolean>;
|
|
21
|
-
enabled: Signal<boolean>;
|
|
22
|
-
untouched: Signal<boolean>;
|
|
23
|
-
pristine: Signal<boolean>;
|
|
24
|
-
rawValue: Signal<TRaw>;
|
|
25
|
-
value: Signal<T>;
|
|
26
|
-
dirty: Signal<boolean>;
|
|
27
|
-
touched: Signal<boolean>;
|
|
28
|
-
errorDebug: Signal<{
|
|
29
|
-
wrapped: any;
|
|
30
|
-
}>;
|
|
31
|
-
constructor(options: FormWrapperOptions<T, C>);
|
|
32
|
-
setElement(element: C): void;
|
|
33
|
-
setReadonly(readonly: boolean): void;
|
|
34
|
-
setDisabled(disabled: boolean): void;
|
|
35
|
-
setValue(value: T): void;
|
|
36
|
-
reset(): void;
|
|
37
|
-
markAsTouched(): void;
|
|
38
|
-
markAsDirty(): void;
|
|
39
|
-
}
|
|
40
|
-
export declare function isFormWrapper(value: any): value is FormWrapper<any, any, any>;
|
package/form/form-wrapper.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { computed, signal, untracked } from '../signals/api.js';
|
|
2
|
-
import { FormContainer } from './form-container.js';
|
|
3
|
-
import { reactiveOptionToSignal } from './utils.js';
|
|
4
|
-
export class FormWrapper extends FormContainer {
|
|
5
|
-
#element = signal(null);
|
|
6
|
-
internalValidators = null;
|
|
7
|
-
element = this.#element.asReadonly();
|
|
8
|
-
forwardWrites;
|
|
9
|
-
forwardErrors;
|
|
10
|
-
errors = computed(() => this.forwardErrors() ? this.element().errors() : []);
|
|
11
|
-
valid = computed(() => this.forwardErrors() ? this.element().valid() : true);
|
|
12
|
-
invalid = computed(() => this.forwardErrors() ? this.element().invalid() : false);
|
|
13
|
-
disabled = computed(() => this.element().disabled());
|
|
14
|
-
enabled = computed(() => this.element().enabled());
|
|
15
|
-
untouched = computed(() => this.element().untouched());
|
|
16
|
-
pristine = computed(() => this.element().pristine());
|
|
17
|
-
rawValue = computed(() => this.element().rawValue());
|
|
18
|
-
value = computed(() => this.element().value());
|
|
19
|
-
dirty = computed(() => this.element().dirty());
|
|
20
|
-
touched = computed(() => this.element().touched());
|
|
21
|
-
errorDebug = computed(() => ({ wrapped: this.element().errorDebug() }));
|
|
22
|
-
constructor(options) {
|
|
23
|
-
super(options);
|
|
24
|
-
this.forwardWrites = reactiveOptionToSignal(options.forwardWrites ?? true, { requireSync: true });
|
|
25
|
-
this.forwardErrors = reactiveOptionToSignal(options.forwardErrors ?? true, { requireSync: true });
|
|
26
|
-
this.setElement(options.element);
|
|
27
|
-
}
|
|
28
|
-
setElement(element) {
|
|
29
|
-
this.#element.set(element);
|
|
30
|
-
}
|
|
31
|
-
setReadonly(readonly) {
|
|
32
|
-
if (untracked(this.forwardWrites)) {
|
|
33
|
-
untracked(this.element).setReadonly(readonly);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
setDisabled(disabled) {
|
|
37
|
-
if (untracked(this.forwardWrites)) {
|
|
38
|
-
untracked(this.element).setDisabled(disabled);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
setValue(value) {
|
|
42
|
-
if (untracked(this.forwardWrites)) {
|
|
43
|
-
untracked(this.element).setValue(value);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
reset() {
|
|
47
|
-
if (untracked(this.forwardWrites)) {
|
|
48
|
-
untracked(this.element).reset();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
markAsTouched() {
|
|
52
|
-
if (untracked(this.forwardWrites)) {
|
|
53
|
-
untracked(this.element).markAsTouched();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
markAsDirty() {
|
|
57
|
-
if (untracked(this.forwardWrites)) {
|
|
58
|
-
untracked(this.element).markAsDirty();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export function isFormWrapper(value) {
|
|
63
|
-
return (value instanceof FormWrapper);
|
|
64
|
-
}
|
package/form/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './abstract-control.js';
|
|
2
|
-
export * from './controls/index.js';
|
|
3
|
-
export * from './form-array.js';
|
|
4
|
-
export * from './form-button.js';
|
|
5
|
-
export * from './form-control.js';
|
|
6
|
-
export * from './form-dialog.js';
|
|
7
|
-
export * from './form-element.js';
|
|
8
|
-
export * from './form-group.js';
|
|
9
|
-
export * from './form-header-footer-element.js';
|
|
10
|
-
export * from './form-portal.js';
|
|
11
|
-
export * from './form-text.js';
|
|
12
|
-
export * from './form-wrapper.js';
|
|
13
|
-
export * from './types.js';
|
|
14
|
-
export * from './utils.js';
|
|
15
|
-
export * from './validators/index.js';
|
package/form/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './abstract-control.js';
|
|
2
|
-
export * from './controls/index.js';
|
|
3
|
-
export * from './form-array.js';
|
|
4
|
-
export * from './form-button.js';
|
|
5
|
-
export * from './form-control.js';
|
|
6
|
-
export * from './form-dialog.js';
|
|
7
|
-
export * from './form-element.js';
|
|
8
|
-
export * from './form-group.js';
|
|
9
|
-
export * from './form-header-footer-element.js';
|
|
10
|
-
export * from './form-portal.js';
|
|
11
|
-
export * from './form-text.js';
|
|
12
|
-
export * from './form-wrapper.js';
|
|
13
|
-
export * from './types.js';
|
|
14
|
-
export * from './utils.js';
|
|
15
|
-
export * from './validators/index.js';
|
package/form/localization.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type Localization, type LocalizeItem } from '../text/localization.service.js';
|
|
2
|
-
export type TstdlFormLocalization = Localization<{
|
|
3
|
-
tstdl: {
|
|
4
|
-
validation: {
|
|
5
|
-
required: LocalizeItem;
|
|
6
|
-
unique: LocalizeItem;
|
|
7
|
-
pattern: LocalizeItem;
|
|
8
|
-
maxLength: LocalizeItem<{
|
|
9
|
-
maxLength: number;
|
|
10
|
-
}>;
|
|
11
|
-
time: LocalizeItem<{
|
|
12
|
-
minimum?: number;
|
|
13
|
-
maximum?: number;
|
|
14
|
-
}>;
|
|
15
|
-
date: LocalizeItem<{
|
|
16
|
-
minimum?: Date | number;
|
|
17
|
-
maximum?: Date | number;
|
|
18
|
-
}>;
|
|
19
|
-
number: LocalizeItem<{
|
|
20
|
-
minimum?: number;
|
|
21
|
-
maximum?: number;
|
|
22
|
-
}>;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
}>;
|
|
26
|
-
export declare const tstdlFormLocalizationKeys: import("../text/localization.service.js").ProxyLocalizationKeys<{
|
|
27
|
-
validation: {
|
|
28
|
-
required: LocalizeItem;
|
|
29
|
-
unique: LocalizeItem;
|
|
30
|
-
pattern: LocalizeItem;
|
|
31
|
-
maxLength: LocalizeItem<{
|
|
32
|
-
maxLength: number;
|
|
33
|
-
}>;
|
|
34
|
-
time: LocalizeItem<{
|
|
35
|
-
minimum?: number;
|
|
36
|
-
maximum?: number;
|
|
37
|
-
}>;
|
|
38
|
-
date: LocalizeItem<{
|
|
39
|
-
minimum?: Date | number;
|
|
40
|
-
maximum?: Date | number;
|
|
41
|
-
}>;
|
|
42
|
-
number: LocalizeItem<{
|
|
43
|
-
minimum?: number;
|
|
44
|
-
maximum?: number;
|
|
45
|
-
}>;
|
|
46
|
-
};
|
|
47
|
-
}>;
|
|
48
|
-
export declare const germanTstdlFormLocalization: TstdlFormLocalization;
|
|
49
|
-
export declare const englishTstdlFormLocalization: TstdlFormLocalization;
|
package/form/localization.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { formatDateShort, formatTimeShort } from '../formats.js';
|
|
2
|
-
import { getLocalizationKeys } from '../text/localization.service.js';
|
|
3
|
-
import { isDefined } from '../utils/type-guards.js';
|
|
4
|
-
export const tstdlFormLocalizationKeys = getLocalizationKeys().tstdl;
|
|
5
|
-
export const germanTstdlFormLocalization = {
|
|
6
|
-
language: { code: 'de', name: 'Deutsch' },
|
|
7
|
-
keys: {
|
|
8
|
-
tstdl: {
|
|
9
|
-
validation: {
|
|
10
|
-
required: 'Angabe erforderlich',
|
|
11
|
-
unique: 'Wert darf nur einmal vorkommen',
|
|
12
|
-
pattern: 'Ungültiges Format',
|
|
13
|
-
maxLength: ({ maxLength }) => `Maximallänge von ${maxLength} überschritten`,
|
|
14
|
-
time: ({ minimum, maximum }) => ((isDefined(minimum) && isDefined(maximum)) ? `Uhrzeit muss zwischen ${formatTimeShort(minimum)} und ${formatTimeShort(maximum)} liegen`
|
|
15
|
-
: isDefined(minimum) ? `Uhrzeit muss nach ${formatTimeShort(minimum)} liegen`
|
|
16
|
-
: isDefined(maximum) ? `Uhrzeit muss vor ${formatTimeShort(maximum)} liegen`
|
|
17
|
-
: 'Ungültige Uhrzeit'),
|
|
18
|
-
date: ({ minimum, maximum }) => ((isDefined(minimum) && isDefined(maximum)) ? `Datum muss zwischen ${formatDateShort(minimum)} und ${formatDateShort(maximum)} liegen`
|
|
19
|
-
: isDefined(minimum) ? `Datum muss nach ${formatDateShort(minimum)} liegen`
|
|
20
|
-
: isDefined(maximum) ? `Datum muss vor ${formatDateShort(maximum)} liegen`
|
|
21
|
-
: 'Ungültiges Datum'),
|
|
22
|
-
number: ({ minimum, maximum }) => ((isDefined(minimum) && isDefined(maximum)) ? `Wert muss zwischen ${minimum} und ${maximum} liegen`
|
|
23
|
-
: isDefined(minimum) ? `Wert muss größer/gleich ${minimum} sein`
|
|
24
|
-
: isDefined(maximum) ? `Wert muss kleiner/gleich ${maximum} sein`
|
|
25
|
-
: 'Ungültiger Wert')
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
enums: []
|
|
30
|
-
};
|
|
31
|
-
export const englishTstdlFormLocalization = {
|
|
32
|
-
language: { code: 'en', name: 'English' },
|
|
33
|
-
keys: {
|
|
34
|
-
tstdl: {
|
|
35
|
-
validation: {
|
|
36
|
-
required: 'Input required',
|
|
37
|
-
unique: 'Value must be unique',
|
|
38
|
-
pattern: 'Invalid format',
|
|
39
|
-
maxLength: ({ maxLength }) => `Maxmimum length of ${maxLength} exceeded`,
|
|
40
|
-
time: ({ minimum, maximum }) => ((isDefined(minimum) && isDefined(maximum)) ? `Time must be between ${formatTimeShort(minimum)} and ${formatTimeShort(maximum)}`
|
|
41
|
-
: isDefined(minimum) ? `Time must be after ${formatTimeShort(minimum)}`
|
|
42
|
-
: isDefined(maximum) ? `Time must be before ${formatTimeShort(maximum)}`
|
|
43
|
-
: 'Invalid time'),
|
|
44
|
-
date: ({ minimum, maximum }) => ((isDefined(minimum) && isDefined(maximum)) ? `Date must be between ${formatDateShort(minimum)} and ${formatDateShort(maximum)}`
|
|
45
|
-
: isDefined(minimum) ? `Date must be after ${formatDateShort(minimum)}`
|
|
46
|
-
: isDefined(maximum) ? `Date must be before ${formatDateShort(maximum)}`
|
|
47
|
-
: 'Invalid date'),
|
|
48
|
-
number: ({ minimum, maximum }) => ((isDefined(minimum) && isDefined(maximum)) ? `Value must be between ${minimum} and ${maximum}`
|
|
49
|
-
: isDefined(minimum) ? `Value must be at least ${minimum}`
|
|
50
|
-
: isDefined(maximum) ? `Value must be at most ${maximum}`
|
|
51
|
-
: 'Invalid value')
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
enums: []
|
|
56
|
-
};
|
package/form/types.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { LocalizableText } from '../text/localizable-text.model.js';
|
|
2
|
-
import type { ReactiveValue } from '../types.js';
|
|
3
|
-
import type { AbstractControl, AbstractControlRawValueType, AbstractControlValueType } from './abstract-control.js';
|
|
4
|
-
export type FormControlRemoveHandler<C extends AbstractControl = AbstractControl> = (control: C) => boolean | Promise<boolean>;
|
|
5
|
-
export type FormValue<T extends AbstractControl> = AbstractControlValueType<T>;
|
|
6
|
-
export type RawFormValue<T extends AbstractControl> = AbstractControlRawValueType<T>;
|
|
7
|
-
export type DynamicTextOption = LocalizableText | null;
|
|
8
|
-
export type ClassesOption = string | string[] | null;
|
|
9
|
-
export type ClassesOptions = {
|
|
10
|
-
classes?: ReactiveValue<ClassesOption>;
|
|
11
|
-
};
|
package/form/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/form/utils.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type Signal } from '../signals/index.js';
|
|
2
|
-
import { LocalizationService } from '../text/localization.service.js';
|
|
3
|
-
import type { EnumerationObject, FilledReadonlyArray, ReactiveValue } from '../types.js';
|
|
4
|
-
import { type ReactiveValueToSignalOptions } from '../utils/reactive-value-to-signal.js';
|
|
5
|
-
export type EnumFormItem<T> = {
|
|
6
|
-
label: Signal<string>;
|
|
7
|
-
value: T;
|
|
8
|
-
};
|
|
9
|
-
export type BindReactiveOptionOptions<D> = {
|
|
10
|
-
defaultValue?: D;
|
|
11
|
-
};
|
|
12
|
-
export type BindReactiveOptionTarget<T> = (Signal<T> & {
|
|
13
|
-
set: (value: T) => void;
|
|
14
|
-
}) | ((value: T) => void);
|
|
15
|
-
export declare function enumAsItems<T extends EnumerationObject>(enumeration: T, allowedValues?: FilledReadonlyArray<T[keyof T]>, localizationService?: LocalizationService): EnumFormItem<T[keyof T]>[];
|
|
16
|
-
export declare function nullToUndefinedSignal<T>(source: Signal<T | null>): Signal<T | undefined>;
|
|
17
|
-
export declare function reactiveOptionToSignal<T>(source: ReactiveValue<T>): Signal<T | undefined>;
|
|
18
|
-
export declare function reactiveOptionToSignal<T>(source: ReactiveValue<T>, options: ReactiveValueToSignalOptions<T | undefined> & {
|
|
19
|
-
initialValue?: undefined;
|
|
20
|
-
requireSync?: false;
|
|
21
|
-
}): Signal<T | undefined>;
|
|
22
|
-
export declare function reactiveOptionToSignal<T>(source: ReactiveValue<T>, options: ReactiveValueToSignalOptions<T | null> & {
|
|
23
|
-
initialValue?: null;
|
|
24
|
-
requireSync?: false;
|
|
25
|
-
}): Signal<T | null>;
|
|
26
|
-
export declare function reactiveOptionToSignal<T>(source: ReactiveValue<T>, options: ReactiveValueToSignalOptions<T> & {
|
|
27
|
-
initialValue?: undefined;
|
|
28
|
-
requireSync: true;
|
|
29
|
-
}): Signal<T>;
|
|
30
|
-
export declare function reactiveOptionToSignal<T, const I>(source: ReactiveValue<T>, options: ReactiveValueToSignalOptions<T | I> & {
|
|
31
|
-
initialValue: I;
|
|
32
|
-
requireSync?: false;
|
|
33
|
-
}): Signal<T | I>;
|
|
34
|
-
export declare function bindReactiveOption<T>(option: ReactiveValue<T> | undefined, target: BindReactiveOptionTarget<T>): void;
|
|
35
|
-
export declare function bindReactiveOption<T>(option: ReactiveValue<T | null | undefined>, target: BindReactiveOptionTarget<T>, options: BindReactiveOptionOptions<T> & {
|
|
36
|
-
defaultValue: T;
|
|
37
|
-
}): void;
|
|
38
|
-
export declare function normalizeClassesOption(classes: string | string[] | null): string[];
|
package/form/utils.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { inject } from '../injector/inject.js';
|
|
2
|
-
import { computed, effect, isSignal, untracked } from '../signals/index.js';
|
|
3
|
-
import { LocalizationService } from '../text/localization.service.js';
|
|
4
|
-
import { enumValues } from '../utils/enum.js';
|
|
5
|
-
import { hasOwnProperty } from '../utils/object/object.js';
|
|
6
|
-
import { reactiveValueToSignal } from '../utils/reactive-value-to-signal.js';
|
|
7
|
-
import { isNull, isNullOrUndefined, isString, isUndefined } from '../utils/type-guards.js';
|
|
8
|
-
export function enumAsItems(enumeration, allowedValues, localizationService = inject(LocalizationService)) {
|
|
9
|
-
return enumValues(enumeration)
|
|
10
|
-
.filter((value) => allowedValues?.includes(value) ?? true)
|
|
11
|
-
.map((type) => ({ label: localizationService.localizeEnum(enumeration, type), value: type }));
|
|
12
|
-
}
|
|
13
|
-
export function nullToUndefinedSignal(source) {
|
|
14
|
-
return computed(() => source() ?? undefined);
|
|
15
|
-
}
|
|
16
|
-
export function reactiveOptionToSignal(source, options) {
|
|
17
|
-
return untracked(() => reactiveValueToSignal(source, options));
|
|
18
|
-
}
|
|
19
|
-
export function bindReactiveOption(option, target, options = {}) {
|
|
20
|
-
const targetSetValue = isSignal(target)
|
|
21
|
-
? (value) => target.set(value)
|
|
22
|
-
: target;
|
|
23
|
-
if (isUndefined(option)) {
|
|
24
|
-
if (hasOwnProperty(options, 'defaultValue')) {
|
|
25
|
-
targetSetValue(options.defaultValue);
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const setValue = (value) => {
|
|
30
|
-
const defaultedValue = (isNullOrUndefined(value) && hasOwnProperty(options, 'defaultValue')) ? options.defaultValue : value;
|
|
31
|
-
targetSetValue(defaultedValue);
|
|
32
|
-
};
|
|
33
|
-
const optionSignal = reactiveValueToSignal(option);
|
|
34
|
-
untracked(() => effect(() => setValue(optionSignal()), { allowSignalWrites: true }));
|
|
35
|
-
}
|
|
36
|
-
export function normalizeClassesOption(classes) {
|
|
37
|
-
if (isNull(classes)) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
if (isString(classes)) {
|
|
41
|
-
return classes
|
|
42
|
-
.split(' ')
|
|
43
|
-
.map((klass) => klass.trim())
|
|
44
|
-
.filter((klass) => klass.length > 0);
|
|
45
|
-
}
|
|
46
|
-
return classes;
|
|
47
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { computed } from '../../signals/api.js';
|
|
2
|
-
import { isNullOrUndefined } from '../../utils/type-guards.js';
|
|
3
|
-
import { formValidatorError } from './form.validator.js';
|
|
4
|
-
export function booleanValidator(value, errorMessage) {
|
|
5
|
-
function booleanValidator(control) {
|
|
6
|
-
return computed(() => {
|
|
7
|
-
const controlValue = control.value();
|
|
8
|
-
if (isNullOrUndefined(controlValue) || (controlValue == value)) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return formValidatorError(control, errorMessage);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return booleanValidator;
|
|
15
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DynamicText } from '../../text/dynamic-text.model.js';
|
|
2
|
-
import type { ReactiveValue } from '../../types.js';
|
|
3
|
-
import { type FormValidator } from './form.validator.js';
|
|
4
|
-
export declare function dateValidator(minimum: ReactiveValue<Date | number | null | undefined>, maximum: ReactiveValue<Date | number | null | undefined>, errorMessage?: DynamicText): FormValidator<Date | number | null>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { computed } from '../../signals/api.js';
|
|
2
|
-
import { localizationData } from '../../text/localization.service.js';
|
|
3
|
-
import { dateToNumericDate } from '../../utils/date-time.js';
|
|
4
|
-
import { isNullOrUndefined, isNumber } from '../../utils/type-guards.js';
|
|
5
|
-
import { tstdlFormLocalizationKeys } from '../localization.js';
|
|
6
|
-
import { reactiveOptionToSignal } from '../utils.js';
|
|
7
|
-
import { formValidatorError } from './form.validator.js';
|
|
8
|
-
export function dateValidator(minimum, maximum, errorMessage) {
|
|
9
|
-
const minimumSignal = reactiveOptionToSignal(minimum);
|
|
10
|
-
const maximumSignal = reactiveOptionToSignal(maximum);
|
|
11
|
-
function dateValidator(control) {
|
|
12
|
-
return computed(() => {
|
|
13
|
-
const value = control.value();
|
|
14
|
-
const min = minimumSignal();
|
|
15
|
-
const max = maximumSignal();
|
|
16
|
-
const valueNumericDate = isNullOrUndefined(value) ? null : isNumber(value) ? value : dateToNumericDate(value);
|
|
17
|
-
const minNumericDate = isNullOrUndefined(min) ? null : isNumber(min) ? min : dateToNumericDate(min); // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
18
|
-
const maxNumericDate = isNullOrUndefined(max) ? null : isNumber(max) ? max : dateToNumericDate(max);
|
|
19
|
-
if (isNullOrUndefined(valueNumericDate) || ((isNullOrUndefined(minNumericDate) || (valueNumericDate >= minNumericDate)) && (isNullOrUndefined(maxNumericDate) || (valueNumericDate <= maxNumericDate)))) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return formValidatorError(control, errorMessage ?? localizationData(tstdlFormLocalizationKeys.validation.date, { minimum: min ?? undefined, maximum: max ?? undefined }));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return dateValidator;
|
|
26
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Signal } from '../../signals/api.js';
|
|
2
|
-
import type { DynamicText } from '../../text/dynamic-text.model.js';
|
|
3
|
-
import type { AbstractControl } from '../abstract-control.js';
|
|
4
|
-
export type FormValidator<T> = (control: AbstractControl<T>) => Signal<FormValidatorError | null>;
|
|
5
|
-
export type FormValidatorProvider<T> = () => FormValidator<T>;
|
|
6
|
-
export type FormValidatorError = {
|
|
7
|
-
readonly control: AbstractControl;
|
|
8
|
-
readonly errorMessage: DynamicText;
|
|
9
|
-
};
|
|
10
|
-
export declare function formValidatorError(control: AbstractControl, errorMessage: DynamicText): FormValidatorError;
|