@tstdl/base 0.91.41 → 0.91.43
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/user.model.d.ts +1 -3
- package/examples/orm/user.model.js +0 -10
- package/orm/index.d.ts +1 -0
- package/orm/index.js +1 -0
- package/orm/types.d.ts +2 -2
- package/orm/types.js +2 -2
- package/package.json +1 -1
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Entity, Integer } from '../../orm/index.js';
|
|
2
2
|
export declare enum Foo {
|
|
3
3
|
Bar = 0,
|
|
4
4
|
Baz = 1
|
|
@@ -7,9 +7,7 @@ export declare class User extends Entity {
|
|
|
7
7
|
static entityName: string;
|
|
8
8
|
name: string;
|
|
9
9
|
nickNames: string[];
|
|
10
|
-
nickNames2: Array<Text>;
|
|
11
10
|
age: Integer | null;
|
|
12
|
-
age2: number | null;
|
|
13
11
|
hasAge: boolean;
|
|
14
12
|
mail: string;
|
|
15
13
|
foo: Foo;
|
|
@@ -18,9 +18,7 @@ export class User extends Entity {
|
|
|
18
18
|
static entityName = 'User';
|
|
19
19
|
name;
|
|
20
20
|
nickNames;
|
|
21
|
-
nickNames2;
|
|
22
21
|
age;
|
|
23
|
-
age2;
|
|
24
22
|
hasAge;
|
|
25
23
|
mail;
|
|
26
24
|
foo;
|
|
@@ -33,18 +31,10 @@ __decorate([
|
|
|
33
31
|
Array(String),
|
|
34
32
|
__metadata("design:type", Array)
|
|
35
33
|
], User.prototype, "nickNames", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
Array(String),
|
|
38
|
-
__metadata("design:type", Object)
|
|
39
|
-
], User.prototype, "nickNames2", void 0);
|
|
40
34
|
__decorate([
|
|
41
35
|
Integer({ nullable: true }),
|
|
42
36
|
__metadata("design:type", Object)
|
|
43
37
|
], User.prototype, "age", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
BooleanProperty(),
|
|
46
|
-
__metadata("design:type", Object)
|
|
47
|
-
], User.prototype, "age2", void 0);
|
|
48
38
|
__decorate([
|
|
49
39
|
BooleanProperty(),
|
|
50
40
|
__metadata("design:type", Boolean)
|
package/orm/index.d.ts
CHANGED
package/orm/index.js
CHANGED
package/orm/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HasDefault as DrizzleHasDefault, IsPrimaryKey as DrizzleIsPrimaryKey } from 'drizzle-orm';
|
|
2
2
|
import type { boolean, doublePrecision, integer, PgColumnBuilder, PgColumnBuilderBase, text, uuid } from 'drizzle-orm/pg-core';
|
|
3
3
|
import type { GetTagMetadata, Tagged, UnwrapTagged } from 'type-fest';
|
|
4
|
-
import {
|
|
4
|
+
import { Array, Integer } from '../schema/index.js';
|
|
5
5
|
import type { ObjectLiteral, Record } from '../types.js';
|
|
6
6
|
import { Uuid } from './schemas/index.js';
|
|
7
7
|
export type IsPrimaryKey<T> = T extends Tagged<unknown, 'column', PgColumnBuilderBase> ? Tagged<UnwrapTagged<T>, 'column', DrizzleIsPrimaryKey<GetTagMetadata<T, 'column'>>> : Tagged<T, 'column', ColumnBuilder<T>>;
|
|
@@ -19,4 +19,4 @@ export type Uuid = Tagged<string, 'column', ReturnType<typeof uuid>>;
|
|
|
19
19
|
export type Integer = Tagged<number, 'column', ReturnType<typeof integer>>;
|
|
20
20
|
export type DoublePrecision = Tagged<number, 'column', ReturnType<typeof doublePrecision>>;
|
|
21
21
|
export type Boolean = Tagged<number, 'column', ReturnType<typeof boolean>>;
|
|
22
|
-
export { Integer, Uuid
|
|
22
|
+
export { Array, Integer, Uuid };
|
package/orm/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-redeclare, @typescript-eslint/naming-convention */
|
|
2
|
-
import {
|
|
2
|
+
import { Array, Integer } from '../schema/index.js';
|
|
3
3
|
import { Uuid } from './schemas/index.js';
|
|
4
|
-
export { Integer, Uuid
|
|
4
|
+
export { Array, Integer, Uuid };
|
package/package.json
CHANGED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { JsonPath } from '../json-path/json-path.js';
|
|
2
|
-
import { type Signal } from '../signals/api.js';
|
|
3
|
-
import type { OneOrMany, ReactiveValue } from '../types.js';
|
|
4
|
-
import type { FormArray } from './form-array.js';
|
|
5
|
-
import { FormElement, type FormElementOptions } from './form-element.js';
|
|
6
|
-
import type { FormGroup } from './form-group.js';
|
|
7
|
-
import type { DynamicTextOption } from './types.js';
|
|
8
|
-
import type { FormValidator, FormValidatorError } from './validators/form.validator.js';
|
|
9
|
-
export type HideOption = boolean | 'when-disabled';
|
|
10
|
-
export type ShowOption = boolean | 'when-enabled';
|
|
11
|
-
export type AbstractControlParent = FormGroup | FormArray;
|
|
12
|
-
export type MarkOptions = {
|
|
13
|
-
/** In case of group and array, children are not set */
|
|
14
|
-
onlySelf?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export type AbstractControlOptions<T = any> = FormElementOptions & {
|
|
17
|
-
label?: ReactiveValue<DynamicTextOption>;
|
|
18
|
-
value?: ReactiveValue<T>;
|
|
19
|
-
readonly?: ReactiveValue<boolean | null>;
|
|
20
|
-
enabled?: ReactiveValue<boolean | null>;
|
|
21
|
-
disabled?: ReactiveValue<boolean | null>;
|
|
22
|
-
hide?: ReactiveValue<HideOption>;
|
|
23
|
-
show?: ReactiveValue<ShowOption>;
|
|
24
|
-
validators?: ReactiveValue<OneOrMany<FormValidator<T>>>;
|
|
25
|
-
};
|
|
26
|
-
export type AbstractControlValueType<T extends AbstractControl> = T[typeof abstractControlValueType];
|
|
27
|
-
export type AbstractControlRawValueType<T extends AbstractControl> = T[typeof abstractControlRawValueType];
|
|
28
|
-
declare const abstractControlValueType: unique symbol;
|
|
29
|
-
declare const abstractControlRawValueType: unique symbol;
|
|
30
|
-
/** Special value which gets ignored on set. Useful for setting groups/array containing controls which should not update because they are set by computed values. */
|
|
31
|
-
export declare const ignoreFormValue: any;
|
|
32
|
-
export declare abstract class AbstractControl<T = any, TRaw = any> extends FormElement {
|
|
33
|
-
#private;
|
|
34
|
-
readonly [abstractControlValueType]: T;
|
|
35
|
-
readonly [abstractControlRawValueType]: TRaw;
|
|
36
|
-
readonly parent: Signal<FormGroup<import("../types.js").Record, import("./form-group.js").FromGroupControls<import("../types.js").Record>> | FormArray<any, any, AbstractControl<any, any>> | null>;
|
|
37
|
-
readonly path: Signal<JsonPath<any>>;
|
|
38
|
-
readonly label: Signal<DynamicTextOption>;
|
|
39
|
-
readonly readonly: Signal<boolean>;
|
|
40
|
-
readonly disabled: Signal<boolean>;
|
|
41
|
-
readonly enabled: Signal<boolean>;
|
|
42
|
-
readonly hide: Signal<boolean>;
|
|
43
|
-
readonly show: Signal<boolean>;
|
|
44
|
-
readonly untouched: Signal<boolean>;
|
|
45
|
-
readonly pristine: Signal<boolean>;
|
|
46
|
-
readonly valid: Signal<boolean>;
|
|
47
|
-
readonly invalid: Signal<boolean>;
|
|
48
|
-
readonly focus$: import("rxjs").Observable<void>;
|
|
49
|
-
readonly validators: Signal<FormValidator<T>[]>;
|
|
50
|
-
protected abstract readonly internalValidators: Signal<readonly FormValidator<T>[]> | null;
|
|
51
|
-
abstract readonly rawValue: Signal<TRaw>;
|
|
52
|
-
abstract readonly value: Signal<T>;
|
|
53
|
-
abstract readonly errors: Signal<FormValidatorError[]>;
|
|
54
|
-
abstract readonly dirty: Signal<boolean>;
|
|
55
|
-
abstract readonly touched: Signal<boolean>;
|
|
56
|
-
abstract readonly errorDebug: Signal<any>;
|
|
57
|
-
constructor(options: AbstractControlOptions<T>);
|
|
58
|
-
setParent(parent: AbstractControlParent, force?: boolean): void;
|
|
59
|
-
setParent(parent: null): void;
|
|
60
|
-
setReadonly(readonly: boolean): void;
|
|
61
|
-
setDisabled(disabled: boolean): void;
|
|
62
|
-
setHide(hide: boolean): void;
|
|
63
|
-
focus(): void;
|
|
64
|
-
protected registerValidators(validators: Signal<readonly FormValidator<T>[]>): void;
|
|
65
|
-
abstract setValue(value: T): void;
|
|
66
|
-
abstract reset(): void;
|
|
67
|
-
abstract markAsTouched(options?: MarkOptions): void;
|
|
68
|
-
abstract markAsDirty(options?: MarkOptions): void;
|
|
69
|
-
}
|
|
70
|
-
export declare function computedInternalValidators(computeFn: () => (FormValidator<any> | null | undefined)[]): Signal<readonly FormValidator<any>[]>;
|
|
71
|
-
export declare function isAbstractControl(value: any): value is AbstractControl;
|
|
72
|
-
export {};
|
package/form/abstract-control.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
2
|
-
import { JsonPath } from '../json-path/json-path.js';
|
|
3
|
-
import { computed, signal, untracked } from '../signals/api.js';
|
|
4
|
-
import { switchAll } from '../signals/index.js';
|
|
5
|
-
import { toArray } from '../utils/array/array.js';
|
|
6
|
-
import { isDefined, isNotNull, isNotNullOrUndefined } from '../utils/type-guards.js';
|
|
7
|
-
import { FormElement } from './form-element.js';
|
|
8
|
-
import { bindReactiveOption } from './utils.js';
|
|
9
|
-
/** Special value which gets ignored on set. Useful for setting groups/array containing controls which should not update because they are set by computed values. */
|
|
10
|
-
export const ignoreFormValue = Symbol('ignoreFormValue');
|
|
11
|
-
export class AbstractControl extends FormElement {
|
|
12
|
-
#parent = signal(null);
|
|
13
|
-
#label = signal(null);
|
|
14
|
-
#readonly = signal(false);
|
|
15
|
-
#disabled = signal(false);
|
|
16
|
-
#hide = signal(false);
|
|
17
|
-
#internalValidators = signal([]);
|
|
18
|
-
#externalValidators = signal([]);
|
|
19
|
-
#focusSubject = new Subject();
|
|
20
|
-
parent = this.#parent.asReadonly();
|
|
21
|
-
path = switchAll(() => this.parent()?.getChildPath(this) ?? computed(() => JsonPath.ROOT));
|
|
22
|
-
label = this.#label.asReadonly();
|
|
23
|
-
readonly = computed(() => this.#readonly() || (this.parent()?.readonly() ?? false));
|
|
24
|
-
disabled = computed(() => this.#disabled() || (this.parent()?.disabled() ?? false));
|
|
25
|
-
enabled = computed(() => !this.disabled());
|
|
26
|
-
hide = this.#hide.asReadonly();
|
|
27
|
-
show = computed(() => !this.hide());
|
|
28
|
-
untouched = computed(() => !this.touched());
|
|
29
|
-
pristine = computed(() => !this.dirty());
|
|
30
|
-
valid = computed(() => this.disabled() || (this.errors().length == 0));
|
|
31
|
-
invalid = computed(() => !this.valid());
|
|
32
|
-
focus$ = this.#focusSubject.asObservable();
|
|
33
|
-
validators = computed(() => [
|
|
34
|
-
...(isNotNull(this.internalValidators) ? this.internalValidators() : []),
|
|
35
|
-
...this.#internalValidators().flatMap((provider) => provider()),
|
|
36
|
-
...this.#externalValidators()
|
|
37
|
-
]);
|
|
38
|
-
constructor(options) {
|
|
39
|
-
super(options);
|
|
40
|
-
if (isDefined(options.enabled) && isDefined(options.disabled)) {
|
|
41
|
-
throw new Error('Either enabled or disabled can be set but not both.');
|
|
42
|
-
}
|
|
43
|
-
if (isDefined(options.show) && isDefined(options.hide)) {
|
|
44
|
-
throw new Error('Either show or hide can be set but not both.');
|
|
45
|
-
}
|
|
46
|
-
bindReactiveOption(options.label, this.#label);
|
|
47
|
-
bindReactiveOption(options.value, (value) => this.setValue(value));
|
|
48
|
-
bindReactiveOption(options.readonly, this.#readonly, { defaultValue: false });
|
|
49
|
-
bindReactiveOption(options.disabled, this.#disabled, { defaultValue: false });
|
|
50
|
-
bindReactiveOption(options.enabled, (enabled) => this.setDisabled(enabled == false));
|
|
51
|
-
bindReactiveOption(options.hide, (hide) => this.setHide((hide == 'when-disabled') ? this.disabled() : hide));
|
|
52
|
-
bindReactiveOption(options.show, (show) => this.setHide(!((show == 'when-enabled') ? this.enabled() : show)));
|
|
53
|
-
bindReactiveOption(options.validators, (validators) => this.#externalValidators.set(toArray(validators)));
|
|
54
|
-
}
|
|
55
|
-
setParent(parent, force = false) {
|
|
56
|
-
if (!force && (isNotNull(parent) && isNotNull(untracked(this.parent)))) {
|
|
57
|
-
throw new Error(`Cannot have multiple parents. Remove parent before setting new. (Current: ${untracked(this.path).path}, New: ${untracked(parent.path).add('#').path})`);
|
|
58
|
-
}
|
|
59
|
-
this.#parent.set(parent);
|
|
60
|
-
}
|
|
61
|
-
setReadonly(readonly) {
|
|
62
|
-
this.#readonly.set(readonly);
|
|
63
|
-
}
|
|
64
|
-
setDisabled(disabled) {
|
|
65
|
-
this.#disabled.set(disabled);
|
|
66
|
-
}
|
|
67
|
-
setHide(hide) {
|
|
68
|
-
this.#hide.set(hide);
|
|
69
|
-
}
|
|
70
|
-
focus() {
|
|
71
|
-
this.#focusSubject.next();
|
|
72
|
-
}
|
|
73
|
-
registerValidators(validators) {
|
|
74
|
-
this.#internalValidators.update((current) => [...current, validators]);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
export function computedInternalValidators(computeFn) {
|
|
78
|
-
return computed(() => computeFn().filter(isNotNullOrUndefined));
|
|
79
|
-
}
|
|
80
|
-
export function isAbstractControl(value) {
|
|
81
|
-
return (value instanceof AbstractControl);
|
|
82
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FormControl, type FormControlOptions } from '../form-control.js';
|
|
2
|
-
export type CheckboxFormControlOptions = FormControlOptions<boolean>;
|
|
3
|
-
export declare class CheckboxFormControl extends FormControl<boolean, boolean> {
|
|
4
|
-
protected internalValidators: null;
|
|
5
|
-
constructor(initialValue: boolean, options?: CheckboxFormControlOptions);
|
|
6
|
-
parseInputValue(value: boolean | null): boolean | null;
|
|
7
|
-
formatRawValue(value: boolean): boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare function checkboxFormControl(options?: CheckboxFormControlOptions): CheckboxFormControl;
|
|
10
|
-
export declare function isCheckboxFormControl(value: any): value is CheckboxFormControl;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FormControl } from '../form-control.js';
|
|
2
|
-
export class CheckboxFormControl extends FormControl {
|
|
3
|
-
internalValidators = null;
|
|
4
|
-
constructor(initialValue, options = {}) {
|
|
5
|
-
super(initialValue, options);
|
|
6
|
-
}
|
|
7
|
-
parseInputValue(value) {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
formatRawValue(value) {
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export function checkboxFormControl(options) {
|
|
15
|
-
return new CheckboxFormControl(false, options);
|
|
16
|
-
}
|
|
17
|
-
export function isCheckboxFormControl(value) {
|
|
18
|
-
return (value instanceof CheckboxFormControl);
|
|
19
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Signal } from '../../signals/api.js';
|
|
2
|
-
import type { DynamicText } from '../../text/dynamic-text.model.js';
|
|
3
|
-
import type { EnumerationObject, FilledReadonlyArray, ReactiveValue, TypedOmit } from '../../types.js';
|
|
4
|
-
import { type FormControlOptions, FormControl } from '../form-control.js';
|
|
5
|
-
import type { DynamicTextOption } from '../types.js';
|
|
6
|
-
export type ChipSelectFormControlItem<T> = {
|
|
7
|
-
label: DynamicText;
|
|
8
|
-
value: T;
|
|
9
|
-
};
|
|
10
|
-
export type ChipSelectFormControlOptions<T> = FormControlOptions<T[]> & {
|
|
11
|
-
items?: ReactiveValue<ChipSelectFormControlItem<T>[]>;
|
|
12
|
-
identityProvider?: (value: T) => any;
|
|
13
|
-
allowArbitrary?: ReactiveValue<boolean>;
|
|
14
|
-
multi?: ReactiveValue<boolean>;
|
|
15
|
-
placeholder?: ReactiveValue<DynamicTextOption>;
|
|
16
|
-
};
|
|
17
|
-
export declare class ChipSelectFormControl<T> extends FormControl<T[], T[]> {
|
|
18
|
-
private readonly initialized;
|
|
19
|
-
protected internalValidators: null;
|
|
20
|
-
readonly items: Signal<readonly ChipSelectFormControlItem<T>[]>;
|
|
21
|
-
readonly allowArbitrary: Signal<boolean>;
|
|
22
|
-
readonly multi: Signal<boolean>;
|
|
23
|
-
readonly placeholder: Signal<DynamicTextOption>;
|
|
24
|
-
constructor(initialValue: T[], options: ChipSelectFormControlOptions<T>);
|
|
25
|
-
setInputValue(value: T[] | null): void;
|
|
26
|
-
setValue(value: T[] | null): void;
|
|
27
|
-
parseInputValue(value: T[] | null): T[];
|
|
28
|
-
formatRawValue(value: T[]): T[];
|
|
29
|
-
private filterArbitrary;
|
|
30
|
-
}
|
|
31
|
-
export declare function chipSelectFormControl<T>(options: ChipSelectFormControlOptions<T>): ChipSelectFormControl<T>;
|
|
32
|
-
export type EnumChipSelectFormControlOptions<T extends EnumerationObject> = TypedOmit<ChipSelectFormControlOptions<T[keyof T]>, 'items'> & {
|
|
33
|
-
allowedValues?: FilledReadonlyArray<T[keyof T]>;
|
|
34
|
-
};
|
|
35
|
-
export declare function enumChipSelectFormControl<T extends EnumerationObject>(enumeration: T, options?: EnumChipSelectFormControlOptions<T>): ChipSelectFormControl<T[keyof T]>;
|
|
36
|
-
export declare function isChipSelectFormControl(value: any): value is ChipSelectFormControl<any>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { tstdlCommonLocalizationKeys } from '../../text/common-localization.js';
|
|
2
|
-
import { ignoreFormValue } from '../abstract-control.js';
|
|
3
|
-
import { FormControl } from '../form-control.js';
|
|
4
|
-
import { enumAsItems, reactiveOptionToSignal } from '../utils.js';
|
|
5
|
-
export class ChipSelectFormControl extends FormControl {
|
|
6
|
-
initialized = false;
|
|
7
|
-
internalValidators = null;
|
|
8
|
-
items;
|
|
9
|
-
allowArbitrary;
|
|
10
|
-
multi;
|
|
11
|
-
placeholder;
|
|
12
|
-
constructor(initialValue, options) {
|
|
13
|
-
super(initialValue, options);
|
|
14
|
-
this.items = reactiveOptionToSignal(options.items ?? [], { initialValue: [] });
|
|
15
|
-
this.allowArbitrary = reactiveOptionToSignal(options.allowArbitrary ?? false, { initialValue: false });
|
|
16
|
-
this.multi = reactiveOptionToSignal(options.multi ?? true, { initialValue: true });
|
|
17
|
-
this.placeholder = reactiveOptionToSignal(options.placeholder ?? tstdlCommonLocalizationKeys.select, { initialValue: null });
|
|
18
|
-
this.initialized = true;
|
|
19
|
-
}
|
|
20
|
-
setInputValue(value) {
|
|
21
|
-
const filtered = this.filterArbitrary(value ?? []);
|
|
22
|
-
super.setInputValue(filtered);
|
|
23
|
-
}
|
|
24
|
-
setValue(value) {
|
|
25
|
-
if (value == ignoreFormValue) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const filtered = this.filterArbitrary(value ?? []);
|
|
29
|
-
super.setValue(filtered);
|
|
30
|
-
}
|
|
31
|
-
parseInputValue(value) {
|
|
32
|
-
return this.filterArbitrary(value ?? []);
|
|
33
|
-
}
|
|
34
|
-
formatRawValue(value) {
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
filterArbitrary(values) {
|
|
38
|
-
if (!this.initialized || this.allowArbitrary()) {
|
|
39
|
-
return values;
|
|
40
|
-
}
|
|
41
|
-
const items = this.items();
|
|
42
|
-
return values.filter((value) => items.some((item) => item.value == value));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export function chipSelectFormControl(options) {
|
|
46
|
-
return new ChipSelectFormControl([], options);
|
|
47
|
-
}
|
|
48
|
-
export function enumChipSelectFormControl(enumeration, options = {}) {
|
|
49
|
-
return chipSelectFormControl({
|
|
50
|
-
...options,
|
|
51
|
-
items: enumAsItems(enumeration, options.allowedValues)
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
export function isChipSelectFormControl(value) {
|
|
55
|
-
return (value instanceof ChipSelectFormControl);
|
|
56
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type Signal } from '../../signals/api.js';
|
|
2
|
-
import type { ReactiveValue } from '../../types.js';
|
|
3
|
-
import type { InputAutocomplete } from '../../web-types.js';
|
|
4
|
-
import { FormControl, type FormControlOptions, type InitialValue, type InitialValueOption } from '../form-control.js';
|
|
5
|
-
import type { DynamicTextOption } from '../types.js';
|
|
6
|
-
export type DateFormControlOptions<I extends InitialValue<number> = InitialValue<number>> = FormControlOptions<number | I> & {
|
|
7
|
-
autocomplete?: InputAutocomplete;
|
|
8
|
-
placeholder?: ReactiveValue<DynamicTextOption>;
|
|
9
|
-
minimum?: ReactiveValue<Date | number | null>;
|
|
10
|
-
maximum?: ReactiveValue<Date | number | null>;
|
|
11
|
-
};
|
|
12
|
-
export declare class DateFormControl<I extends InitialValue<number> = number | null> extends FormControl<number | I, string> {
|
|
13
|
-
protected readonly internalValidators: Signal<readonly import("../index.js").FormValidator<any>[]>;
|
|
14
|
-
readonly autocomplete: Signal<InputAutocomplete>;
|
|
15
|
-
readonly placeholder: Signal<DynamicTextOption>;
|
|
16
|
-
readonly minimum: Signal<Date | number | null>;
|
|
17
|
-
readonly maximum: Signal<Date | number | null>;
|
|
18
|
-
readonly minimumAsDate: Signal<Date | null>;
|
|
19
|
-
readonly maximumAsDate: Signal<Date | null>;
|
|
20
|
-
constructor(initialValue: I, options?: DateFormControlOptions<I>);
|
|
21
|
-
parseInputValue(value: string | null): number | null;
|
|
22
|
-
formatRawValue(value: number | null): string;
|
|
23
|
-
}
|
|
24
|
-
export declare function dateFormControl<I extends InitialValue<number>>(options: DateFormControlOptions<I> & InitialValueOption<I>): DateFormControl<I>;
|
|
25
|
-
export declare function dateFormControl<I extends InitialValue<number>>(options?: DateFormControlOptions<I>): DateFormControl;
|
|
26
|
-
export declare function isDateFormControl(value: any): value is DateFormControl<any>;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
|
-
import { computed } from '../../signals/api.js';
|
|
3
|
-
import { dateToNumericDate, numericDateToDate, numericDateToDateTime } from '../../utils/date-time.js';
|
|
4
|
-
import { isDefined, isNull, isNumber } from '../../utils/type-guards.js';
|
|
5
|
-
import { computedInternalValidators } from '../abstract-control.js';
|
|
6
|
-
import { FormControl } from '../form-control.js';
|
|
7
|
-
import { reactiveOptionToSignal } from '../utils.js';
|
|
8
|
-
import { dateValidator } from '../validators/date.validator.js';
|
|
9
|
-
export class DateFormControl extends FormControl {
|
|
10
|
-
internalValidators = computedInternalValidators(() => {
|
|
11
|
-
const minimum = this.minimum();
|
|
12
|
-
const maximum = this.maximum();
|
|
13
|
-
return [(isDefined(minimum) || isDefined(maximum)) ? dateValidator(minimum, maximum) : undefined];
|
|
14
|
-
});
|
|
15
|
-
autocomplete;
|
|
16
|
-
placeholder;
|
|
17
|
-
minimum;
|
|
18
|
-
maximum;
|
|
19
|
-
minimumAsDate = computed(() => {
|
|
20
|
-
const minimum = this.minimum();
|
|
21
|
-
if (isNumber(minimum)) {
|
|
22
|
-
return numericDateToDateTime(minimum).toJSDate();
|
|
23
|
-
}
|
|
24
|
-
return minimum;
|
|
25
|
-
});
|
|
26
|
-
maximumAsDate = computed(() => {
|
|
27
|
-
const maximum = this.maximum();
|
|
28
|
-
if (isNumber(maximum)) {
|
|
29
|
-
return numericDateToDateTime(maximum).toJSDate();
|
|
30
|
-
}
|
|
31
|
-
return maximum;
|
|
32
|
-
});
|
|
33
|
-
constructor(initialValue, options = {}) {
|
|
34
|
-
super(initialValue, options);
|
|
35
|
-
this.autocomplete = reactiveOptionToSignal(options.autocomplete ?? 'off', { initialValue: 'off' });
|
|
36
|
-
this.placeholder = reactiveOptionToSignal(options.placeholder ?? null, { initialValue: null });
|
|
37
|
-
this.minimum = reactiveOptionToSignal(options.minimum ?? DateTime.fromObject({ year: 1600 }).toJSDate(), { initialValue: null });
|
|
38
|
-
this.maximum = reactiveOptionToSignal(options.maximum ?? DateTime.fromObject({ year: 2200 }).toJSDate(), { initialValue: null });
|
|
39
|
-
}
|
|
40
|
-
parseInputValue(value) {
|
|
41
|
-
if (isNull(value)) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
const normalized = value.trim();
|
|
45
|
-
if (normalized.length == 0) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
const date = new Date(normalized);
|
|
49
|
-
return dateToNumericDate(date);
|
|
50
|
-
}
|
|
51
|
-
formatRawValue(value) {
|
|
52
|
-
if (isNull(value) || Number.isNaN(value)) {
|
|
53
|
-
return '';
|
|
54
|
-
}
|
|
55
|
-
const { year, month, day } = numericDateToDate(value);
|
|
56
|
-
return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export function dateFormControl(options) {
|
|
60
|
-
return new DateFormControl(null, options);
|
|
61
|
-
}
|
|
62
|
-
export function isDateFormControl(value) {
|
|
63
|
-
return (value instanceof DateFormControl);
|
|
64
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FormControl, type FormControlOptions } from '../form-control.js';
|
|
2
|
-
export type HiddenFormControlOptions<T = any> = FormControlOptions<T>;
|
|
3
|
-
export declare class HiddenFormControl<T = any> extends FormControl<T, T> {
|
|
4
|
-
protected internalValidators: null;
|
|
5
|
-
constructor(value: T, options?: HiddenFormControlOptions<T>);
|
|
6
|
-
parseInputValue(value: T | null): T | null;
|
|
7
|
-
formatRawValue(value: T): T;
|
|
8
|
-
}
|
|
9
|
-
export declare function hiddenFormControl<T>(value: T, options?: HiddenFormControlOptions<T>): HiddenFormControl<T>;
|
|
10
|
-
export declare function isHiddenFormControl<T>(value: any): value is HiddenFormControl<T>;
|
|
11
|
-
export declare function idFormControl(id?: string | null): HiddenFormControl<string>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { FormControl } from '../form-control.js';
|
|
2
|
-
export class HiddenFormControl extends FormControl {
|
|
3
|
-
internalValidators = null;
|
|
4
|
-
constructor(value, options = {}) {
|
|
5
|
-
super(value, options);
|
|
6
|
-
}
|
|
7
|
-
parseInputValue(value) {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
formatRawValue(value) {
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export function hiddenFormControl(value, options = {}) {
|
|
15
|
-
return new HiddenFormControl(value, options);
|
|
16
|
-
}
|
|
17
|
-
export function isHiddenFormControl(value) {
|
|
18
|
-
return (value instanceof HiddenFormControl);
|
|
19
|
-
}
|
|
20
|
-
export function idFormControl(id) {
|
|
21
|
-
return hiddenFormControl((id ?? null));
|
|
22
|
-
}
|
package/form/controls/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './checkbox.control.js';
|
|
2
|
-
export * from './chip-select.control.js';
|
|
3
|
-
export * from './date.control.js';
|
|
4
|
-
export * from './hidden.control.js';
|
|
5
|
-
export * from './items.control.js';
|
|
6
|
-
export * from './number.control.js';
|
|
7
|
-
export * from './radio-group.control.js';
|
|
8
|
-
export * from './select.control.js';
|
|
9
|
-
export * from './text.control.js';
|
|
10
|
-
export * from './time.control.js';
|
package/form/controls/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './checkbox.control.js';
|
|
2
|
-
export * from './chip-select.control.js';
|
|
3
|
-
export * from './date.control.js';
|
|
4
|
-
export * from './hidden.control.js';
|
|
5
|
-
export * from './items.control.js';
|
|
6
|
-
export * from './number.control.js';
|
|
7
|
-
export * from './radio-group.control.js';
|
|
8
|
-
export * from './select.control.js';
|
|
9
|
-
export * from './text.control.js';
|
|
10
|
-
export * from './time.control.js';
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type Signal } from '../../signals/index.js';
|
|
2
|
-
import { type DynamicText } from '../../text/dynamic-text.model.js';
|
|
3
|
-
import type { LocalizableText } from '../../text/localizable-text.model.js';
|
|
4
|
-
import type { ReactiveValue } from '../../types.js';
|
|
5
|
-
import { FormControl, type FormControlOptions, type InitialValue } from '../form-control.js';
|
|
6
|
-
export type ItemsFormControlItem<T> = {
|
|
7
|
-
label: DynamicText;
|
|
8
|
-
value: T;
|
|
9
|
-
};
|
|
10
|
-
export type SignalizedItemsFormControlItem<T> = {
|
|
11
|
-
label: Signal<LocalizableText> | LocalizableText;
|
|
12
|
-
value: T;
|
|
13
|
-
};
|
|
14
|
-
export type SignalizedTextResolvedItemsFormControlItem<T> = {
|
|
15
|
-
label: Signal<string>;
|
|
16
|
-
value: T;
|
|
17
|
-
};
|
|
18
|
-
export type ResolvedItemsFormControlItem<T> = {
|
|
19
|
-
label: string;
|
|
20
|
-
value: T;
|
|
21
|
-
};
|
|
22
|
-
export type ItemsFormControlOptions<T, I extends InitialValue<T>> = FormControlOptions<T | I> & {
|
|
23
|
-
items: ReactiveValue<readonly ItemsFormControlItem<T>[]>;
|
|
24
|
-
identityProvider?: (value: T) => any;
|
|
25
|
-
};
|
|
26
|
-
export declare abstract class ItemsFormControl<T, I extends InitialValue<T> = T | null> extends FormControl<T | I, T | I> {
|
|
27
|
-
#private;
|
|
28
|
-
protected readonly internalValidators: null;
|
|
29
|
-
readonly items: Signal<readonly ItemsFormControlItem<T>[]>;
|
|
30
|
-
readonly identityProvider: (value: T) => any;
|
|
31
|
-
readonly resolvedItems: Signal<ResolvedItemsFormControlItem<T>[]>;
|
|
32
|
-
readonly sortedResolvedItems: Signal<ResolvedItemsFormControlItem<T>[]>;
|
|
33
|
-
readonly selectedItem: Signal<I extends null ? ItemsFormControlItem<T> | null : ItemsFormControlItem<T>>;
|
|
34
|
-
constructor(initialValue: I, options: ItemsFormControlOptions<T, I>);
|
|
35
|
-
parseInputValue(value: T | I | null): T | I | null;
|
|
36
|
-
formatRawValue(value: T | I): T | I;
|
|
37
|
-
}
|
|
38
|
-
export declare function isItemsFormControl(value: any): value is ItemsFormControl<any, any>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { isObservable } from 'rxjs';
|
|
2
|
-
import { inject } from '../../injector/inject.js';
|
|
3
|
-
import { computed, isSignal, toSignal } from '../../signals/index.js';
|
|
4
|
-
import { resolveDynamicText } from '../../text/dynamic-text.model.js';
|
|
5
|
-
import { LocalizationService } from '../../text/localization.service.js';
|
|
6
|
-
import { compareByValueSelection } from '../../utils/comparison.js';
|
|
7
|
-
import { assertDefinedPass, isNull } from '../../utils/type-guards.js';
|
|
8
|
-
import { FormControl } from '../form-control.js';
|
|
9
|
-
import { reactiveOptionToSignal } from '../utils.js';
|
|
10
|
-
export class ItemsFormControl extends FormControl {
|
|
11
|
-
#localizationService = inject(LocalizationService);
|
|
12
|
-
#signalizedItems = computed(() => this.items().map(({ label, value }) => ({ label: isObservable(label) ? toSignal(label, { requireSync: true }) : label, value })));
|
|
13
|
-
#signalizedTextResolvedItems = computed(() => this.#signalizedItems().map(({ label, value }) => ({ label: resolveDynamicText(isSignal(label) ? label() : label, this.#localizationService), value })));
|
|
14
|
-
internalValidators = null;
|
|
15
|
-
items;
|
|
16
|
-
identityProvider;
|
|
17
|
-
resolvedItems = computed(() => this.#signalizedTextResolvedItems().map(({ label, value }) => ({ label: label(), value })));
|
|
18
|
-
sortedResolvedItems = computed(() => this.resolvedItems().sort(compareByValueSelection((item) => item.label)));
|
|
19
|
-
selectedItem = computed(() => {
|
|
20
|
-
const value = this.value();
|
|
21
|
-
if (isNull(value)) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
const selectedItem = this.items().find((item) => this.identityProvider(item.value) == this.identityProvider(value));
|
|
25
|
-
return assertDefinedPass(selectedItem, 'Value not in items');
|
|
26
|
-
});
|
|
27
|
-
constructor(initialValue, options) {
|
|
28
|
-
super(initialValue, options);
|
|
29
|
-
this.items = reactiveOptionToSignal(options.items, { initialValue: [] });
|
|
30
|
-
this.identityProvider = options.identityProvider ?? ((value) => value);
|
|
31
|
-
}
|
|
32
|
-
parseInputValue(value) {
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
formatRawValue(value) {
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export function isItemsFormControl(value) {
|
|
40
|
-
return (value instanceof ItemsFormControl);
|
|
41
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Signal } from '../../signals/api.js';
|
|
2
|
-
import type { ReactiveValue } from '../../types.js';
|
|
3
|
-
import type { InputAutocomplete } from '../../web-types.js';
|
|
4
|
-
import { FormControl, type FormControlOptions, type InitialValue, type InitialValueOption } from '../form-control.js';
|
|
5
|
-
import type { DynamicTextOption } from '../types.js';
|
|
6
|
-
export type NumberFormControlOptions<I extends InitialValue<number> = InitialValue<number>> = FormControlOptions<number | I> & {
|
|
7
|
-
autocomplete?: InputAutocomplete;
|
|
8
|
-
placeholder?: ReactiveValue<DynamicTextOption>;
|
|
9
|
-
integer?: ReactiveValue<boolean>;
|
|
10
|
-
format?: ReactiveValue<Intl.NumberFormatOptions>;
|
|
11
|
-
minimum?: ReactiveValue<number | null>;
|
|
12
|
-
maximum?: ReactiveValue<number | null>;
|
|
13
|
-
step?: ReactiveValue<number>;
|
|
14
|
-
};
|
|
15
|
-
export declare class NumberFormControl<I extends InitialValue<number> = number | null> extends FormControl<number | I, string> {
|
|
16
|
-
protected readonly internalValidators: Signal<readonly import("../index.js").FormValidator<any>[]>;
|
|
17
|
-
readonly autocomplete: Signal<InputAutocomplete>;
|
|
18
|
-
readonly placeholder: Signal<DynamicTextOption>;
|
|
19
|
-
readonly integer: Signal<boolean>;
|
|
20
|
-
readonly format: Signal<Intl.NumberFormatOptions>;
|
|
21
|
-
readonly minimum: Signal<number | null>;
|
|
22
|
-
readonly maximum: Signal<number | null>;
|
|
23
|
-
readonly step: Signal<number | null>;
|
|
24
|
-
constructor(initialValue: I, options?: NumberFormControlOptions<I>);
|
|
25
|
-
parseRawValue(value: number | I): number | I;
|
|
26
|
-
parseInputValue(value: string | null): number | I | null;
|
|
27
|
-
formatRawValue(value: number | I): string;
|
|
28
|
-
}
|
|
29
|
-
export declare function numberFormControl<I extends InitialValue<number>>(options: NumberFormControlOptions<I> & InitialValueOption<I>): NumberFormControl<I>;
|
|
30
|
-
export declare function numberFormControl<I extends InitialValue<number>>(options?: NumberFormControlOptions<I>): NumberFormControl;
|
|
31
|
-
export declare function integerNumberControl(options: NumberFormControlOptions): NumberFormControl;
|
|
32
|
-
export declare function yearNumberControl(options: NumberFormControlOptions): NumberFormControl;
|
|
33
|
-
export declare function isNumberFormControl(value: any): value is NumberFormControl<any>;
|