@atscript/vue-form 0.1.163 → 0.1.164
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/dist/as-action.d.cts +1 -1
- package/dist/as-action.d.mts +1 -1
- package/dist/{as-action.vue-wcB6Dkpu.d.cts → as-action.vue-CYGG4gUQ.d.mts} +1 -1
- package/dist/{as-action.vue-yDKx8hC0.d.mts → as-action.vue-Cp9Q8a-6.d.cts} +1 -1
- package/dist/{as-array-CD_Z7lZV.mjs → as-array-CqnBh3rv.mjs} +1 -1
- package/dist/{as-array-CX52_z_L.cjs → as-array-CxeMe9Dw.cjs} +1 -1
- package/dist/as-array.cjs +1 -1
- package/dist/as-array.d.cts +1 -1
- package/dist/as-array.d.mts +1 -1
- package/dist/as-array.mjs +1 -1
- package/dist/{as-array.vue-BoKbyO1a.d.cts → as-array.vue-Cgfjz2I-.d.cts} +1 -1
- package/dist/{as-array.vue-DKcxkmjP.d.mts → as-array.vue-Wj9giGdu.d.mts} +1 -1
- package/dist/as-checkbox.d.cts +1 -1
- package/dist/as-checkbox.d.mts +1 -1
- package/dist/{as-checkbox.vue-BXS5v6Ru.d.mts → as-checkbox.vue-CWe73b3Z.d.mts} +1 -1
- package/dist/{as-checkbox.vue-DdttMJAS.d.cts → as-checkbox.vue-CXiUHIZj.d.cts} +1 -1
- package/dist/as-collapsible.d.cts +1 -1
- package/dist/as-collapsible.d.mts +1 -1
- package/dist/{as-collapsible.vue-1JSWgRMg.d.cts → as-collapsible.vue-BXwe24OV.d.cts} +1 -1
- package/dist/{as-collapsible.vue-DowxhNde.d.mts → as-collapsible.vue-hfAqxx1w.d.mts} +1 -1
- package/dist/as-date.d.cts +1 -1
- package/dist/as-date.d.mts +1 -1
- package/dist/{as-date.vue-BVvALvZ_.d.mts → as-date.vue-BTm9X4fW.d.mts} +1 -1
- package/dist/{as-date.vue-BiUgcOwZ.d.cts → as-date.vue-axahL_Zv.d.cts} +1 -1
- package/dist/as-datetime.d.cts +1 -1
- package/dist/as-datetime.d.mts +1 -1
- package/dist/{as-datetime.vue-BVc6jcUI.d.cts → as-datetime.vue-C6ILTI-7.d.cts} +1 -1
- package/dist/{as-datetime.vue-CCQqZsKA.d.mts → as-datetime.vue-vysHc3Ug.d.mts} +1 -1
- package/dist/as-decimal.d.cts +1 -1
- package/dist/as-decimal.d.mts +1 -1
- package/dist/{as-decimal.vue-BDfM2ICc.d.mts → as-decimal.vue-CAq25zbX.d.mts} +1 -1
- package/dist/{as-decimal.vue-Cc9pNTqj.d.cts → as-decimal.vue-Dgfz9UDJ.d.cts} +1 -1
- package/dist/{as-field-C_DB6Lbi.cjs → as-field-8MDWK_jb.cjs} +16 -3
- package/dist/{as-field-DqK4Yiev.mjs → as-field-DQxlwJVM.mjs} +17 -4
- package/dist/as-field-shell.d.cts +1 -1
- package/dist/as-field-shell.d.mts +1 -1
- package/dist/{as-field-shell.vue-B1ep312_.d.cts → as-field-shell.vue-BU0_8-uI.d.mts} +1 -1
- package/dist/{as-field-shell.vue-DisEXQI1.d.mts → as-field-shell.vue-DAcRqi7G.d.cts} +1 -1
- package/dist/as-field.cjs +1 -1
- package/dist/as-field.mjs +1 -1
- package/dist/{as-form-DLYEF8Ez.mjs → as-form-C-CV5ezE.mjs} +5 -4
- package/dist/{as-form-DgbRGqD8.cjs → as-form-DLSFfuLR.cjs} +4 -3
- package/dist/as-form.cjs +1 -1
- package/dist/as-form.d.cts +1 -1
- package/dist/as-form.d.mts +1 -1
- package/dist/as-form.mjs +1 -1
- package/dist/{as-form.vue-BmKBCn6P.d.cts → as-form.vue-BA70Ib2m.d.cts} +50 -317
- package/dist/{as-form.vue-hHJm_Rxq.d.mts → as-form.vue-D2SQ5VeJ.d.mts} +50 -317
- package/dist/as-input.d.cts +1 -1
- package/dist/as-input.d.mts +1 -1
- package/dist/{as-input.vue-CL-Om6Ed.d.mts → as-input.vue-CyLveDWK.d.mts} +1 -1
- package/dist/{as-input.vue-D-RM35Rp.d.cts → as-input.vue-mZ0h1Q2J.d.cts} +1 -1
- package/dist/{as-iterator-DHNJwo-R.cjs → as-iterator-Bbyxog8g.cjs} +1 -1
- package/dist/{as-iterator-mOyaYJiN.mjs → as-iterator-CaQ1TkIR.mjs} +1 -1
- package/dist/as-iterator.cjs +1 -1
- package/dist/as-iterator.mjs +1 -1
- package/dist/{as-multi-select-AC05uVzY.mjs → as-multi-select-B7Nc2brD.mjs} +80 -12
- package/dist/{as-multi-select-BedSzod1.cjs → as-multi-select-BiUexFnY.cjs} +78 -10
- package/dist/as-multi-select.cjs +1 -1
- package/dist/as-multi-select.d.cts +1 -1
- package/dist/as-multi-select.d.mts +1 -1
- package/dist/as-multi-select.mjs +1 -1
- package/dist/{as-multi-select.vue-5GHWrbim.d.mts → as-multi-select.vue-BS9bNhCB.d.mts} +1 -1
- package/dist/{as-multi-select.vue-D1OnCH-x.d.cts → as-multi-select.vue-DAFz9hZR.d.cts} +1 -1
- package/dist/as-number.d.cts +1 -1
- package/dist/as-number.d.mts +1 -1
- package/dist/{as-number.vue-BiZ2B2iJ.d.mts → as-number.vue-BsJdJS36.d.cts} +1 -1
- package/dist/{as-number.vue-DE33Giq3.d.cts → as-number.vue-DSP2S_xP.d.mts} +1 -1
- package/dist/{as-object-B_x-yycI.mjs → as-object-0Qo0bPi5.mjs} +1 -1
- package/dist/{as-object-YYxV2y77.cjs → as-object-BjOUiVDG.cjs} +1 -1
- package/dist/as-object.cjs +1 -1
- package/dist/as-object.d.cts +1 -1
- package/dist/as-object.d.mts +1 -1
- package/dist/as-object.mjs +1 -1
- package/dist/{as-object.vue-Dg4IT2JT.d.mts → as-object.vue-CpDhlJ_D.d.mts} +1 -1
- package/dist/{as-object.vue-PUhmGqhY.d.cts → as-object.vue-DduGoHKD.d.cts} +1 -1
- package/dist/as-paragraph.d.cts +1 -1
- package/dist/as-paragraph.d.mts +1 -1
- package/dist/{as-paragraph.vue-BUfbXaiy.d.cts → as-paragraph.vue-BJSA27kd.d.cts} +1 -1
- package/dist/{as-paragraph.vue-Bp-MUDcH.d.mts → as-paragraph.vue-CMUaF6WV.d.mts} +1 -1
- package/dist/as-radio.d.cts +1 -1
- package/dist/as-radio.d.mts +1 -1
- package/dist/{as-radio.vue-NmjJm8Pj.d.mts → as-radio.vue-BR2ThEbi.d.mts} +1 -1
- package/dist/{as-radio.vue-h4XkpaW0.d.cts → as-radio.vue-Dw1QaJoY.d.cts} +1 -1
- package/dist/as-ref.d.cts +1 -1
- package/dist/as-ref.d.mts +1 -1
- package/dist/{as-ref.vue-ec447Bmx.d.cts → as-ref.vue-CZzOVBz1.d.mts} +1 -1
- package/dist/{as-ref.vue-vP2P1ePF.d.mts → as-ref.vue-CvY88H7p.d.cts} +1 -1
- package/dist/as-select.d.cts +1 -1
- package/dist/as-select.d.mts +1 -1
- package/dist/{as-select.vue-9mQ6cjW7.d.mts → as-select.vue-7xiuC9JG.d.cts} +1 -1
- package/dist/{as-select.vue-DV0C1MsH.d.cts → as-select.vue-BPPctxZT.d.mts} +1 -1
- package/dist/as-time.d.cts +1 -1
- package/dist/as-time.d.mts +1 -1
- package/dist/{as-time.vue-CmvsgHJd.d.cts → as-time.vue-CQhIKAs0.d.cts} +1 -1
- package/dist/{as-time.vue-DGfZPnWK.d.mts → as-time.vue-CjzRrsFg.d.mts} +1 -1
- package/dist/{as-tuple-CfgSnsT9.cjs → as-tuple-DKBOLriy.cjs} +1 -1
- package/dist/{as-tuple-Dny4Ov_j.mjs → as-tuple-fwxeV71M.mjs} +1 -1
- package/dist/as-tuple.cjs +1 -1
- package/dist/as-tuple.d.cts +1 -1
- package/dist/as-tuple.d.mts +1 -1
- package/dist/as-tuple.mjs +1 -1
- package/dist/{as-tuple.vue-CInEbMRo.d.mts → as-tuple.vue-BSh2-1uv.d.cts} +1 -1
- package/dist/{as-tuple.vue-zZkuYxet.d.cts → as-tuple.vue-DvHHrn-6.d.mts} +1 -1
- package/dist/as-union.d.cts +1 -1
- package/dist/as-union.d.mts +1 -1
- package/dist/{as-union.vue-Bz3EO0Gg.d.mts → as-union.vue-BJ8xFYYb.d.mts} +1 -1
- package/dist/{as-union.vue-K9ZSRg0G.d.cts → as-union.vue-CnF4bNex.d.cts} +1 -1
- package/dist/index.cjs +12 -9
- package/dist/index.d.cts +22 -22
- package/dist/index.d.mts +22 -22
- package/dist/index.mjs +12 -9
- package/dist/{types-BLoV3zIo.d.mts → types-BoguW89D.d.mts} +24 -19
- package/dist/{types-Crwu2D-w.d.cts → types-DoLxVJhd.d.cts} +24 -19
- package/package.json +11 -11
|
@@ -1,306 +1,12 @@
|
|
|
1
|
-
import { c as TAsUnionContext, n as TAsChangeType, o as TAsComponentProps, s as TAsTypeComponents } from "./types-
|
|
1
|
+
import { c as TAsUnionContext, n as TAsChangeType, o as TAsComponentProps, s as TAsTypeComponents } from "./types-BoguW89D.mjs";
|
|
2
2
|
import * as vue from "vue";
|
|
3
3
|
import { Component, ComputedRef, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef, WritableComputedRef } from "vue";
|
|
4
4
|
import * as _atscript_ui0 from "@atscript/ui";
|
|
5
|
-
import { ClientFactory, ClientFactory as ClientFactory$1, FormArrayFieldDef, FormDef, FormDiffOptions, FormDiffOptions as FormDiffOptions$1, FormFieldChange, FormFieldChange as FormFieldChange$1, FormFieldDef, FormRebaseOptions, FormRebaseOptions as FormRebaseOptions$1, FormTupleFieldDef, FormUnionFieldDef, FormUnionVariant, ResolvedValueHelp, TResolveOptions, ValueHelpInfo, getDefaultClientFactory, hasFieldMeta as hasFieldMeta$1, isFieldHidden as isFieldHidden$1, joinPath as joinPath$1, resetDefaultClientFactory, setDefaultClientFactory } from "@atscript/ui";
|
|
5
|
+
import { ClientFactory, ClientFactory as ClientFactory$1, CreateFormDefOptions, FormArrayFieldDef, FormDef, FormDiffOptions, FormDiffOptions as FormDiffOptions$1, FormFieldChange, FormFieldChange as FormFieldChange$1, FormFieldDef, FormRebaseOptions, FormRebaseOptions as FormRebaseOptions$1, FormTupleFieldDef, FormUnionFieldDef, FormUnionVariant, ResolvedValueHelp, TResolveOptions, TypedClientFactory, ValueHelpInfo, getDefaultClientFactory, hasFieldMeta as hasFieldMeta$1, isFieldHidden as isFieldHidden$1, joinPath as joinPath$1, resetDefaultClientFactory, setDefaultClientFactory } from "@atscript/ui";
|
|
6
6
|
import { TFnScope } from "@atscript/ui-fns";
|
|
7
|
+
import * as _atscript_typescript_utils0 from "@atscript/typescript/utils";
|
|
8
|
+
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
7
9
|
|
|
8
|
-
//#region ../../node_modules/.pnpm/@atscript+typescript@0.2.3_@atscript+core@0.2.3_@emnapi+core@1.10.0_@emnapi+runtime@1.1_827f363eb78bb82886801a5bf792b425/node_modules/@atscript/typescript/dist/utils.d.ts
|
|
9
|
-
interface TError {
|
|
10
|
-
path: string;
|
|
11
|
-
message: string;
|
|
12
|
-
details?: TError[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* A plugin function that can intercept validation.
|
|
16
|
-
*
|
|
17
|
-
* Return `true` to accept the value, `false` to reject it,
|
|
18
|
-
* or `undefined` to fall through to the default validation.
|
|
19
|
-
*/
|
|
20
|
-
type TValidatorPlugin = (ctx: TValidatorPluginContext, def: TAtscriptAnnotatedType, value: any) => boolean | undefined;
|
|
21
|
-
/** Options for configuring {@link Validator} behavior. */
|
|
22
|
-
interface TValidatorOptions {
|
|
23
|
-
partial: boolean | 'deep' | ((type: TAtscriptAnnotatedType<TAtscriptTypeObject>, path: string) => boolean);
|
|
24
|
-
replace?: (type: TAtscriptAnnotatedType, path: string) => TAtscriptAnnotatedType;
|
|
25
|
-
plugins: TValidatorPlugin[];
|
|
26
|
-
unknownProps: 'strip' | 'ignore' | 'error';
|
|
27
|
-
errorLimit: number;
|
|
28
|
-
skipList?: Set<string>;
|
|
29
|
-
}
|
|
30
|
-
/** Context exposed to {@link TValidatorPlugin} functions. */
|
|
31
|
-
interface TValidatorPluginContext {
|
|
32
|
-
opts: Validator<any>['opts'];
|
|
33
|
-
/**
|
|
34
|
-
* Validates `value` against `def` at the current path (errors go to the current level). With
|
|
35
|
-
* `unknownProps: 'strip'`, a call that returns `false` strips nothing: the keys it recorded are
|
|
36
|
-
* dropped, as for a rejected union branch, so trying alternatives (`a || b`) strips what the
|
|
37
|
-
* union `a | b` would.
|
|
38
|
-
*/
|
|
39
|
-
validateAnnotatedType: Validator<any>['validateAnnotatedType'];
|
|
40
|
-
error: Validator<any>['error'];
|
|
41
|
-
path: Validator<any>['path'];
|
|
42
|
-
/**
|
|
43
|
-
* The type the validator was created for — the root of the walk, as passed to the
|
|
44
|
-
* constructor (before `replace`). The plugin's `def` argument is the node visited now.
|
|
45
|
-
*/
|
|
46
|
-
readonly root: TAtscriptAnnotatedType;
|
|
47
|
-
context: unknown;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Validates values against an {@link TAtscriptAnnotatedType} definition.
|
|
51
|
-
*
|
|
52
|
-
* `DataType` is automatically inferred from the type definition's phantom generic,
|
|
53
|
-
* enabling the {@link validate} method to act as a type guard.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```ts
|
|
57
|
-
* // From a generated interface class:
|
|
58
|
-
* const validator = new Validator(MyInterface)
|
|
59
|
-
* if (validator.validate(data, true)) {
|
|
60
|
-
* data // narrowed to MyInterface
|
|
61
|
-
* }
|
|
62
|
-
*
|
|
63
|
-
* // Or use the built-in factory:
|
|
64
|
-
* MyInterface.validator().validate(data)
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @typeParam T - The annotated type definition.
|
|
68
|
-
* @typeParam DataType - The TypeScript type that `validate` narrows to (auto-inferred).
|
|
69
|
-
*/
|
|
70
|
-
declare class Validator<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> {
|
|
71
|
-
protected readonly def: T;
|
|
72
|
-
protected opts: TValidatorOptions;
|
|
73
|
-
protected hasPlugins: boolean;
|
|
74
|
-
protected hasReplace: boolean;
|
|
75
|
-
private replaceCache?;
|
|
76
|
-
constructor(def: T, opts?: Partial<TValidatorOptions>);
|
|
77
|
-
/** Validation errors collected during the last {@link validate} call. */
|
|
78
|
-
errors: TError[];
|
|
79
|
-
protected stackErrors: Array<TError[] | null>;
|
|
80
|
-
protected pathSegments: string[];
|
|
81
|
-
protected depth: number;
|
|
82
|
-
protected limitExceeded: boolean;
|
|
83
|
-
protected context: unknown;
|
|
84
|
-
/**
|
|
85
|
-
* The unions over objects this call decided inside union branches (value → outcomes). A union
|
|
86
|
-
* nested in its own branches, many branches each, is reached again with the same value and path
|
|
87
|
-
* from every branch of every union above it — (branches)^(depth) work. The memo is made once
|
|
88
|
-
* the call has wasted {@link WASTE_BEFORE_MEMO} union branches (failed after branches of nested
|
|
89
|
-
* unions over objects failed) since the outermost union, as in the pre-check — ordinary walks
|
|
90
|
-
* never make it. It decides each such union once, with the same result and the same error object
|
|
91
|
-
* (both depend only on these, the options and the input, which the walk never changes), and
|
|
92
|
-
* records the same strips again.
|
|
93
|
-
*/
|
|
94
|
-
private unionMemo?;
|
|
95
|
-
/** Union branches being checked (`> 0`: inside a union branch). */
|
|
96
|
-
private unionDepth;
|
|
97
|
-
/** Failed branches of unions over objects inside union branches (see `unionMemo`). */
|
|
98
|
-
private nestedFailures;
|
|
99
|
-
/** Wasted union branches since the outermost union was entered (see `unionMemo`). */
|
|
100
|
-
private wasted;
|
|
101
|
-
/**
|
|
102
|
-
* `unknownProps: 'strip'`: the unknown keys of the objects that passed (`object, key, …`), in the
|
|
103
|
-
* order the objects completed, then in key order. A rejected union branch, pattern property
|
|
104
|
-
* attempt or plugin sub-validation drops what it recorded; the keys are deleted once the whole
|
|
105
|
-
* call passes (`performStrips`).
|
|
106
|
-
*/
|
|
107
|
-
private strips;
|
|
108
|
-
protected buildPath(): string;
|
|
109
|
-
protected push(name: string): void;
|
|
110
|
-
protected pop(saveErrors: boolean): TError[] | null | undefined;
|
|
111
|
-
protected clear(): void;
|
|
112
|
-
protected error(message: string, path?: string, details?: TError[]): TError;
|
|
113
|
-
/** Adds `error`, already made, to the errors of the current level (as {@link error} does). */
|
|
114
|
-
private report;
|
|
115
|
-
protected throw(): void;
|
|
116
|
-
/**
|
|
117
|
-
* Validates a value against the type definition.
|
|
118
|
-
*
|
|
119
|
-
* Acts as a TypeScript type guard — when it returns `true`, the value
|
|
120
|
-
* is narrowed to `DataType`.
|
|
121
|
-
*
|
|
122
|
-
* @param value - The value to validate.
|
|
123
|
-
* @param safe - If `true`, returns `false` on failure instead of throwing.
|
|
124
|
-
* @returns `true` if the value matches the type definition.
|
|
125
|
-
* @throws {ValidatorError} When validation fails and `safe` is not `true`.
|
|
126
|
-
*/
|
|
127
|
-
validate<TT = DataType>(value: any, safe?: boolean, context?: unknown): value is TT;
|
|
128
|
-
/**
|
|
129
|
-
* Plain `Validator` without plugins / `replace`: eligible for the allocation-free
|
|
130
|
-
* shortcuts. Subclasses may override the protected `validate*` hooks, so they
|
|
131
|
-
* always take the full walk. (A getter, not a constructor-set field: validators are
|
|
132
|
-
* often built per call, so construction stays as cheap as before.)
|
|
133
|
-
*/
|
|
134
|
-
private get shortcuts();
|
|
135
|
-
/** Validates `value` against `def` (after `replace`, `optional` and the plugins). */
|
|
136
|
-
protected validateSafe(def: TAtscriptAnnotatedType, value: any): boolean;
|
|
137
|
-
/**
|
|
138
|
-
* What {@link validateSafe} decides of `def` (replaced) before its own validation: an
|
|
139
|
-
* optional `def` passes `undefined` / `null`, a plugin may decide — `undefined` to go on.
|
|
140
|
-
*/
|
|
141
|
-
private preCheck;
|
|
142
|
-
/** The context the plugins get (see {@link pluginContext}), made on the first plugin call. */
|
|
143
|
-
private pluginCtx?;
|
|
144
|
-
/**
|
|
145
|
-
* The plugins' view of this validator: its state read live; `validateAnnotatedType` drops the
|
|
146
|
-
* strips a failed call recorded (a failed validation at any level strips nothing).
|
|
147
|
-
*/
|
|
148
|
-
private pluginContext;
|
|
149
|
-
/** `def` as the `replace` option replaces it at the current path (memoized per node). */
|
|
150
|
-
private replaced;
|
|
151
|
-
protected get path(): string;
|
|
152
|
-
/** The type this validator was created for (see {@link TValidatorPluginContext.root}). */
|
|
153
|
-
protected get root(): T;
|
|
154
|
-
protected validateAnnotatedType(def: TAtscriptAnnotatedType, value: any): boolean;
|
|
155
|
-
protected validateUnion(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, value: any): boolean;
|
|
156
|
-
/** A union branch failed after branches of nested unions over objects did (see `unionMemo`). */
|
|
157
|
-
private wasteBranch;
|
|
158
|
-
/** The outcome this call recorded for union `def` over `value` at `path` (see `unionMemo`). */
|
|
159
|
-
private decided;
|
|
160
|
-
/**
|
|
161
|
-
* Records the outcome of union `def` over `value` at `path`, entered with `kept` strips (the
|
|
162
|
-
* ones after them are its own).
|
|
163
|
-
*/
|
|
164
|
-
private decide;
|
|
165
|
-
/**
|
|
166
|
-
* Constraints annotated on the union itself (`@expect.min 0` on `number | null`)
|
|
167
|
-
* apply to the non-null value that matched `branch`, on top of the branch's own.
|
|
168
|
-
* A literal branch (an enum value) is exempt: its value is fixed.
|
|
169
|
-
*/
|
|
170
|
-
protected validateUnionConstraints(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, branch: TAtscriptAnnotatedType, value: any): boolean;
|
|
171
|
-
/** Every member must pass, each on its own (JSON Schema `allOf`). */
|
|
172
|
-
protected validateIntersection(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, value: any): boolean;
|
|
173
|
-
/**
|
|
174
|
-
* An unknown key (`unknownProps`): 'error' reports it, 'strip' adds it to the keys to strip
|
|
175
|
-
* (returned; recorded in `strips` once the object passed).
|
|
176
|
-
*/
|
|
177
|
-
private unknownKey;
|
|
178
|
-
/** The `skipList` keys of the object at the current path. */
|
|
179
|
-
private skipListHere;
|
|
180
|
-
protected validateTuple(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, value: any): boolean;
|
|
181
|
-
protected validateArray(def: TAtscriptAnnotatedType<TAtscriptTypeArray>, value: any): boolean;
|
|
182
|
-
/** `@expect.minLength` / `maxLength` / `array.uniqueItems` checks for an array value. */
|
|
183
|
-
protected validateArrayConstraints(meta: TMetadataMap<AtscriptMetadata>, value: any[], of?: TAtscriptAnnotatedType): boolean;
|
|
184
|
-
protected validateObject(def: TAtscriptAnnotatedType<TAtscriptTypeObject>, value: any): boolean;
|
|
185
|
-
protected validatePrimitive(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: any): boolean;
|
|
186
|
-
protected validateString(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: string): boolean;
|
|
187
|
-
/** `@meta.required` / `@expect.minLength` / `maxLength` / `pattern` checks for a string value. */
|
|
188
|
-
protected validateStringConstraints(meta: TMetadataMap<AtscriptMetadata>, value: string): boolean;
|
|
189
|
-
protected validateNumber(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: number): boolean;
|
|
190
|
-
/** `@expect.int` / `min` / `max` / `exclusiveMin` / `exclusiveMax` checks for a number value. */
|
|
191
|
-
protected validateNumberConstraints(meta: TMetadataMap<AtscriptMetadata>, value: number): boolean;
|
|
192
|
-
/** Reports a failed number bound: its custom message, else `Expected <label> <bound>, got <value>`. */
|
|
193
|
-
private numberBoundFailed;
|
|
194
|
-
protected validateBoolean(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: boolean): boolean;
|
|
195
|
-
/** `@meta.required` check for a boolean value (must be `true`). */
|
|
196
|
-
protected validateBooleanConstraints(meta: TMetadataMap<AtscriptMetadata>, value: boolean): boolean;
|
|
197
|
-
}
|
|
198
|
-
/** Error thrown by {@link Validator.validate} when validation fails. Contains structured error details. */
|
|
199
|
-
/** Type definition for union, intersection, or tuple types. */
|
|
200
|
-
interface TAtscriptTypeComplex<DataType = unknown> {
|
|
201
|
-
kind: 'union' | 'intersection' | 'tuple';
|
|
202
|
-
items: TAtscriptAnnotatedType[];
|
|
203
|
-
tags: Set<AtscriptPrimitiveTags>;
|
|
204
|
-
/** @internal phantom — carries the DataType at the type level, never set at runtime */
|
|
205
|
-
__dataType?: DataType;
|
|
206
|
-
}
|
|
207
|
-
/** Type definition for array types. */
|
|
208
|
-
interface TAtscriptTypeArray<DataType = unknown[]> {
|
|
209
|
-
kind: 'array';
|
|
210
|
-
of: TAtscriptAnnotatedType;
|
|
211
|
-
tags: Set<AtscriptPrimitiveTags>;
|
|
212
|
-
/** @internal phantom — carries the DataType at the type level, never set at runtime */
|
|
213
|
-
__dataType?: DataType;
|
|
214
|
-
}
|
|
215
|
-
/** Type definition for object types with named and pattern-matched properties. */
|
|
216
|
-
interface TAtscriptTypeObject<K extends string = string, DataType = Record<K, unknown>> {
|
|
217
|
-
kind: 'object';
|
|
218
|
-
props: Map<K, TAtscriptAnnotatedType>;
|
|
219
|
-
propsPatterns: Array<{
|
|
220
|
-
pattern: RegExp;
|
|
221
|
-
def: TAtscriptAnnotatedType;
|
|
222
|
-
}>;
|
|
223
|
-
tags: Set<AtscriptPrimitiveTags>;
|
|
224
|
-
/** @internal phantom — carries the DataType at the type level, never set at runtime */
|
|
225
|
-
__dataType?: DataType;
|
|
226
|
-
}
|
|
227
|
-
/** Type definition for primitive/literal types (string, number, boolean, null, etc.). */
|
|
228
|
-
interface TAtscriptTypeFinal<DataType = unknown> {
|
|
229
|
-
kind: '';
|
|
230
|
-
/**
|
|
231
|
-
* design type
|
|
232
|
-
*/
|
|
233
|
-
designType: 'string' | 'number' | 'boolean' | 'undefined' | 'null' | 'object' | 'any' | 'never' | 'phantom' | 'decimal';
|
|
234
|
-
/**
|
|
235
|
-
* value for literals
|
|
236
|
-
*/
|
|
237
|
-
value?: string | number | boolean;
|
|
238
|
-
tags: Set<AtscriptPrimitiveTags>;
|
|
239
|
-
/** @internal phantom — carries the DataType at the type level, never set at runtime */
|
|
240
|
-
__dataType?: DataType;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Extract DataType from a type def's phantom generic
|
|
244
|
-
*/
|
|
245
|
-
type InferDataType<T> = T extends {
|
|
246
|
-
__dataType?: infer D;
|
|
247
|
-
} ? D : unknown;
|
|
248
|
-
/**
|
|
249
|
-
* Extract the DataType from a {@link TAtscriptAnnotatedType}.
|
|
250
|
-
*
|
|
251
|
-
* Resolves the phantom `__dataType` carried by the type definition.
|
|
252
|
-
* When `__dataType` is `unknown` (unset), falls back to the constructor
|
|
253
|
-
* instance type if `T` is also a class (i.e. a generated interface).
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```ts
|
|
257
|
-
* import type { TAtscriptDataType } from '@atscript/typescript/utils'
|
|
258
|
-
* import MyInterface from './my-interface.as'
|
|
259
|
-
*
|
|
260
|
-
* type Data = TAtscriptDataType<typeof MyInterface>
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
type TAtscriptDataType<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType> = T extends {
|
|
264
|
-
type: {
|
|
265
|
-
__dataType?: infer D;
|
|
266
|
-
};
|
|
267
|
-
} ? unknown extends D ? T extends (new (...args: any[]) => infer I) ? I : unknown : D : unknown;
|
|
268
|
-
/** Union of all possible type definition shapes. */
|
|
269
|
-
type TAtscriptTypeDef<DataType = unknown> = TAtscriptTypeComplex<DataType> | TAtscriptTypeFinal<DataType> | TAtscriptTypeArray<DataType> | TAtscriptTypeObject<string, DataType>;
|
|
270
|
-
/**
|
|
271
|
-
* Core annotated type — wraps a type definition with metadata and a validator factory.
|
|
272
|
-
*
|
|
273
|
-
* Generated `.as` files produce classes/namespaces that conform to this interface.
|
|
274
|
-
* The `DataType` phantom generic carries the TypeScript data shape for type-safe validation.
|
|
275
|
-
*
|
|
276
|
-
* @typeParam T - The underlying type definition (e.g. {@link TAtscriptTypeObject}).
|
|
277
|
-
* @typeParam DataType - The TypeScript type the validated data narrows to (auto-inferred from `T`).
|
|
278
|
-
*/
|
|
279
|
-
interface TAtscriptAnnotatedType<T extends TAtscriptTypeDef = TAtscriptTypeDef, DataType = InferDataType<T>> {
|
|
280
|
-
__is_atscript_annotated_type: true;
|
|
281
|
-
type: T;
|
|
282
|
-
validator(opts?: Partial<TValidatorOptions>): Validator<this, DataType>;
|
|
283
|
-
metadata: TMetadataMap<AtscriptMetadata>;
|
|
284
|
-
optional?: boolean;
|
|
285
|
-
id?: string;
|
|
286
|
-
ref?: {
|
|
287
|
-
type: () => TAtscriptAnnotatedType;
|
|
288
|
-
field: string;
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
/** An annotated type that is also a class constructor (i.e. a generated interface class). */
|
|
292
|
-
/**
|
|
293
|
-
* Atscript Metadata Map with typed setters/getters
|
|
294
|
-
*/
|
|
295
|
-
interface TMetadataMap<O extends object> extends Map<keyof O, O[keyof O]> {
|
|
296
|
-
get<K extends keyof O>(key: K): O[K] | undefined;
|
|
297
|
-
get(key: string): unknown;
|
|
298
|
-
set<K extends keyof O>(key: K, value: O[K]): this;
|
|
299
|
-
has<K extends keyof O>(key: K): boolean;
|
|
300
|
-
has(key: string): boolean;
|
|
301
|
-
}
|
|
302
|
-
/** Fluent builder handle returned by {@link defineAnnotatedType}. */
|
|
303
|
-
//#endregion
|
|
304
10
|
//#region src/composables/create-as-form-def.d.ts
|
|
305
11
|
/**
|
|
306
12
|
* Creates a reactive form definition and data object from an ATScript annotated type.
|
|
@@ -308,12 +14,14 @@ interface TMetadataMap<O extends object> extends Map<keyof O, O[keyof O]> {
|
|
|
308
14
|
* @param type - An ATScript annotated type (imported from a `.as` file).
|
|
309
15
|
* @param context - Optional context object forwarded to `ui.fn.value` resolvers during data creation.
|
|
310
16
|
* Only effective when `@atscript/ui-fns` is installed (dynamic resolver).
|
|
17
|
+
* @param opts - Options for `createFormDef`: `mode: "edit"` for a form that edits a stored row,
|
|
18
|
+
* `versionColumn`, `metaFields`.
|
|
311
19
|
* @returns `{ def, formData }` — the FormDef and a Vue reactive data object with defaults applied
|
|
312
20
|
*/
|
|
313
|
-
declare function createAsFormDef<T extends TAtscriptAnnotatedType>(type: T, context?: Record<string, unknown
|
|
21
|
+
declare function createAsFormDef<T extends TAtscriptAnnotatedType>(type: T, context?: Record<string, unknown>, opts?: CreateFormDefOptions): {
|
|
314
22
|
def: _atscript_ui0.FormDef;
|
|
315
23
|
formData: {
|
|
316
|
-
value: vue.UnwrapRef<TAtscriptDataType<T>>;
|
|
24
|
+
value: vue.UnwrapRef<_atscript_typescript_utils0.TAtscriptDataType<T>>;
|
|
317
25
|
};
|
|
318
26
|
};
|
|
319
27
|
//#endregion
|
|
@@ -598,16 +306,25 @@ interface UseAsFormOptions<TFormData = unknown, TFormContext = unknown> {
|
|
|
598
306
|
* `defineEmits`; advanced uses can pass plain functions.
|
|
599
307
|
*/
|
|
600
308
|
emits?: {
|
|
601
|
-
submit?: (data: TFormData) => void;
|
|
309
|
+
submit?: (data: TAsFormValue<TFormData>) => void;
|
|
602
310
|
error?: (errors: {
|
|
603
311
|
path: string;
|
|
604
312
|
message: string;
|
|
605
313
|
}[]) => void;
|
|
606
|
-
action?: (name: string, data: TFormData) => void;
|
|
607
|
-
unsupportedAction?: (name: string, data: TFormData) => void;
|
|
608
|
-
change?: (type: TAsChangeType, path: string, value: unknown, formData: TFormData) => void;
|
|
314
|
+
action?: (name: string, data: TAsFormValue<TFormData>) => void;
|
|
315
|
+
unsupportedAction?: (name: string, data: TAsFormValue<TFormData>) => void;
|
|
316
|
+
change?: (type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>) => void;
|
|
609
317
|
};
|
|
610
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* The value inside a `{ value }` form-data container (`value` may be
|
|
321
|
+
* optional): what the `submit`, `action`, `unsupportedAction` and `change`
|
|
322
|
+
* callbacks (and `<AsForm>`'s events) receive. `any` for an `any` container,
|
|
323
|
+
* `unknown` when the container has no `value`.
|
|
324
|
+
*/
|
|
325
|
+
type TAsFormValue<TFormData> = 0 extends 1 & TFormData ? any : TFormData extends {
|
|
326
|
+
value?: infer V;
|
|
327
|
+
} ? V : unknown;
|
|
611
328
|
interface UseAsFormReturn<TFormData = unknown, TFormContext = unknown> {
|
|
612
329
|
/** Reactive form-data container `{ value: domainData }`. */
|
|
613
330
|
data: ComputedRef<TFormData>;
|
|
@@ -1355,10 +1072,26 @@ interface UseAsDataReturn {
|
|
|
1355
1072
|
getValueAt: (path: string) => ComputedRef<unknown>;
|
|
1356
1073
|
/** Read a sibling field's value relative to the current `useAsPath()` prefix. */
|
|
1357
1074
|
siblingValue: <T = unknown>(name: string) => ComputedRef<T | undefined>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Write the value at an absolute dotted path inside the form (missing
|
|
1077
|
+
* containers are created: an array where the next segment is an index,
|
|
1078
|
+
* else an object; an empty form root too). The write is a committed edit:
|
|
1079
|
+
* change tracking sees it, the field at that path re-validates like one the
|
|
1080
|
+
* user changed, and `AsForm` emits `change` with type `"update"`. Outside a
|
|
1081
|
+
* form, a no-op.
|
|
1082
|
+
*/
|
|
1083
|
+
setValueAt: (path: string, value: unknown) => void;
|
|
1084
|
+
/**
|
|
1085
|
+
* Write a sibling field's value, relative to the current `useAsPath()`
|
|
1086
|
+
* prefix — e.g. a custom picker filling the fields next to it. Same rules
|
|
1087
|
+
* as `setValueAt`.
|
|
1088
|
+
*/
|
|
1089
|
+
setSibling: (name: string, value: unknown) => void;
|
|
1358
1090
|
}
|
|
1359
1091
|
/**
|
|
1360
|
-
* Reactive
|
|
1361
|
-
*
|
|
1092
|
+
* Reactive access to form data at any point in the `<AsForm>` tree: readers
|
|
1093
|
+
* plus `setValueAt` / `setSibling` writers. Outside a form, all readers
|
|
1094
|
+
* return `undefined` and the writers do nothing.
|
|
1362
1095
|
*
|
|
1363
1096
|
* Call sites get a `ComputedRef` so they can compose it directly with
|
|
1364
1097
|
* other reactive primitives without an extra `computed()` wrapper.
|
|
@@ -1390,8 +1123,8 @@ interface Props<TF, TC> {
|
|
|
1390
1123
|
components?: Record<string, Component<TAsComponentProps>>;
|
|
1391
1124
|
/**
|
|
1392
1125
|
* Type-to-component map for field rendering. Maps field types to Vue components.
|
|
1393
|
-
*
|
|
1394
|
-
*
|
|
1126
|
+
* Use `createDefaultTypes()` for a pre-filled map, or supply your own — it
|
|
1127
|
+
* needs entries only for the types its forms use.
|
|
1395
1128
|
*/
|
|
1396
1129
|
types: TAsTypeComponents;
|
|
1397
1130
|
errors?: Record<string, string | undefined>;
|
|
@@ -1441,10 +1174,10 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
|
|
|
1441
1174
|
path: string;
|
|
1442
1175
|
message: string;
|
|
1443
1176
|
}[]) => any) | undefined;
|
|
1444
|
-
onAction?: ((name: string, data: TFormData) => any) | undefined;
|
|
1445
|
-
onSubmit?: ((data: TFormData) => any) | undefined;
|
|
1446
|
-
"onUnsupported-action"?: ((name: string, data: TFormData) => any) | undefined;
|
|
1447
|
-
onChange?: ((type: TAsChangeType, path: string, value: unknown, formData: TFormData) => any) | undefined;
|
|
1177
|
+
onAction?: ((name: string, data: TAsFormValue<TFormData>) => any) | undefined;
|
|
1178
|
+
onSubmit?: ((data: TAsFormValue<TFormData>) => any) | undefined;
|
|
1179
|
+
"onUnsupported-action"?: ((name: string, data: TAsFormValue<TFormData>) => any) | undefined;
|
|
1180
|
+
onChange?: ((type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>) => any) | undefined;
|
|
1448
1181
|
}> & (typeof globalThis extends {
|
|
1449
1182
|
__VLS_PROPS_FALLBACK: infer P;
|
|
1450
1183
|
} ? P : {});
|
|
@@ -1637,14 +1370,14 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
|
|
|
1637
1370
|
}) => any;
|
|
1638
1371
|
};
|
|
1639
1372
|
emit: {
|
|
1640
|
-
(e: "submit", data: TFormData): void;
|
|
1373
|
+
(e: "submit", data: TAsFormValue<TFormData>): void;
|
|
1641
1374
|
(e: "error", errors: {
|
|
1642
1375
|
path: string;
|
|
1643
1376
|
message: string;
|
|
1644
1377
|
}[]): void;
|
|
1645
|
-
(e: "action", name: string, data: TFormData): void;
|
|
1646
|
-
(e: "unsupported-action", name: string, data: TFormData): void;
|
|
1647
|
-
(e: "change", type: TAsChangeType, path: string, value: unknown, formData: TFormData): void;
|
|
1378
|
+
(e: "action", name: string, data: TAsFormValue<TFormData>): void;
|
|
1379
|
+
(e: "unsupported-action", name: string, data: TAsFormValue<TFormData>): void;
|
|
1380
|
+
(e: "change", type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>): void;
|
|
1648
1381
|
};
|
|
1649
1382
|
}>) => vue.VNode & {
|
|
1650
1383
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
@@ -1652,4 +1385,4 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
|
|
|
1652
1385
|
declare const _default: typeof __VLS_export;
|
|
1653
1386
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
1654
1387
|
//#endregion
|
|
1655
|
-
export {
|
|
1388
|
+
export { useAsLevel as $, useAsNumber as A, UseAsFieldReturn as At, UseAsOptionalAddFlowOptions as B, UseAsDateReturn as C, AsFormPatchHandle as Ct, useAsDualInput as D, UseAsStateReturn as Dt, UseAsDualInputReturn as E, TFormSubmitValidator as Et, provideAsLocale as F, TFormState as Ft, useAsFocusFirstAfter as G, useAsOptionalAddFlow as H, useAsLocale as I, createDefaultTypes as It, useAsOptionalField as J, useAsVisibleFields as K, UseAsTriStateCheckboxOptions as L, createAsFormDef as Lt, UseAsDecimalReturn as M, TFormFieldCallbacks as Mt, useAsDecimal as N, TFormFieldRegistration as Nt, UseAsNumberOptions as O, useAsState as Ot, UseAsLocaleReturn as P, TFormRule as Pt, provideAsNestedLevel as Q, UseAsTriStateCheckboxReturn as R, UseAsDateOptions as S, useAsForm as St, UseAsDualInputOptions as T, useAsFormPatch as Tt, focusFirstAfter as U, UseAsOptionalAddFlowReturn as V, focusNewFocusableAfter as W, UseAsFieldScopeReturn as X, TResolveFieldPropOptions as Y, useAsFieldScope as Z, useAsData as _, UseAsExternalErrorsReturn as _t, FormFieldChange$1 as a, UseAsValueHelpOptions as at, UseAsPathReturn as b, UseAsFormOptions as bt, getDefaultClientFactory as c, formatIndexedLabelParts as ct, joinPath$1 as d, useAsUnion as dt, AsNestedSectionsStore as et, resetDefaultClientFactory as f, UseAsTupleReturn as ft, UseAsDataReturn as g, UseAsExternalErrorsOptions as gt, useAsErrorDismiss as h, useAsArray as ht, FormDiffOptions$1 as i, useAsDropdown as it, UseAsDecimalOptions as j, useAsField as jt, UseAsNumberReturn as k, UseAsFieldOptions as kt, hasFieldMeta$1 as l, useAsUnionVariant as lt, AsErrorDismiss as m, UseAsArrayReturn as mt, _default as n, useAsDescendantErrorCounts as nt, FormRebaseOptions$1 as o, UseAsValueHelpReturn as ot, setDefaultClientFactory as p, useAsTuple as pt, UseAsOptionalFieldReturn as q, ClientFactory$1 as r, useAsNestedSectionsStore as rt, TypedClientFactory as s, useAsValueHelp as st, Props as t, provideAsNestedSectionsStore as tt, isFieldHidden$1 as u, UseAsUnionReturn as ut, UseAsTypeMapReturn as v, useAsExternalErrors as vt, useAsDate as w, RebaseOntoResult as wt, useAsPath as x, UseAsFormReturn as xt, useAsTypeMap as y, TAsFormValue as yt, useAsTriStateCheckbox as z };
|
package/dist/as-input.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _default } from "./as-input.vue-
|
|
1
|
+
import { t as _default } from "./as-input.vue-mZ0h1Q2J.cjs";
|
|
2
2
|
export = _default;
|
package/dist/as-input.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _default } from "./as-input.vue-
|
|
1
|
+
import { t as _default } from "./as-input.vue-CyLveDWK.mjs";
|
|
2
2
|
export { _default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_use_form_context = require("./use-form-context-B6ZnzfxG.cjs");
|
|
2
|
-
const require_as_field = require("./as-field-
|
|
2
|
+
const require_as_field = require("./as-field-8MDWK_jb.cjs");
|
|
3
3
|
let vue = require("vue");
|
|
4
4
|
let _atscript_ui = require("@atscript/ui");
|
|
5
5
|
//#region src/composables/use-as-level.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h as PATH_PREFIX_KEY, m as LEVEL_KEY } from "./use-form-context-cDW2GW4-.mjs";
|
|
2
|
-
import { t as as_field_default } from "./as-field-
|
|
2
|
+
import { t as as_field_default } from "./as-field-DQxlwJVM.mjs";
|
|
3
3
|
import { Fragment, computed, createBlock, createElementBlock, defineComponent, inject, openBlock, provide, renderList } from "vue";
|
|
4
4
|
import { joinPath } from "@atscript/ui";
|
|
5
5
|
//#region src/composables/use-as-level.ts
|
package/dist/as-iterator.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_iterator = require("./as-iterator-
|
|
1
|
+
const require_as_iterator = require("./as-iterator-Bbyxog8g.cjs");
|
|
2
2
|
module.exports = require_as_iterator.as_iterator_default;
|
package/dist/as-iterator.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_iterator_default } from "./as-iterator-
|
|
1
|
+
import { t as as_iterator_default } from "./as-iterator-CaQ1TkIR.mjs";
|
|
2
2
|
export { as_iterator_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as as_field_shell_default } from "./as-field-shell-Bxqa_ZsU.mjs";
|
|
2
2
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, openBlock, ref, renderList, toDisplayString, unref, withCtx, withModifiers } from "vue";
|
|
3
|
-
import { optKey, optLabel } from "@atscript/ui";
|
|
4
|
-
import { ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxPortal, ComboboxRoot, ComboboxViewport } from "reka-ui";
|
|
3
|
+
import { hasFieldMeta, optKey, optLabel } from "@atscript/ui";
|
|
4
|
+
import { ComboboxAnchor, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxPortal, ComboboxRoot, ComboboxViewport, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText, TagsInputRoot } from "reka-ui";
|
|
5
5
|
//#region src/components/defaults/as-multi-select.vue?vue&type=script&setup=true&lang.ts
|
|
6
6
|
const _hoisted_1 = ["id"];
|
|
7
7
|
const _hoisted_2 = { class: "as-multi-select-chip-label" };
|
|
@@ -233,17 +233,85 @@ var as_multi_select_default = /* @__PURE__ */ defineComponent({
|
|
|
233
233
|
function selectAll() {
|
|
234
234
|
props.model.value = (props.options ?? []).map((o) => optKey(o));
|
|
235
235
|
}
|
|
236
|
+
const tags = computed(() => props.field?.customType === "tags");
|
|
237
|
+
const uniqueItems = computed(() => !!props.field && hasFieldMeta(props.field.prop, "expect.array.uniqueItems"));
|
|
238
|
+
const numericItems = computed(() => {
|
|
239
|
+
const item = props.field?.prop.type;
|
|
240
|
+
return item?.kind === "array" && item.of.type.kind === "" && item.of.type.designType === "number";
|
|
241
|
+
});
|
|
242
|
+
function toItem(text) {
|
|
243
|
+
const trimmed = text.trim();
|
|
244
|
+
return numericItems.value && trimmed !== "" ? Number(trimmed) : trimmed;
|
|
245
|
+
}
|
|
246
|
+
function onTags(values) {
|
|
247
|
+
props.model.value = values.filter((v) => v !== "" && !(typeof v === "number" && Number.isNaN(v)));
|
|
248
|
+
}
|
|
236
249
|
return (_ctx, _cache) => {
|
|
237
250
|
return openBlock(), createBlock(as_field_shell_default, mergeProps(_ctx.$props, { "field-class": "as-multi-select-field" }), {
|
|
238
251
|
header: withCtx(({ inputId }) => [createElementVNode("span", {
|
|
239
252
|
id: inputId,
|
|
240
253
|
class: "as-field-label"
|
|
241
254
|
}, toDisplayString(__props.label), 9, _hoisted_1)]),
|
|
242
|
-
default: withCtx(({ inputId }) => [
|
|
255
|
+
default: withCtx(({ inputId }) => [tags.value ? (openBlock(), createBlock(unref(TagsInputRoot), {
|
|
256
|
+
key: 0,
|
|
257
|
+
"model-value": __props.model.value ?? [],
|
|
258
|
+
disabled: __props.disabled || __props.readonly,
|
|
259
|
+
duplicate: !uniqueItems.value,
|
|
260
|
+
"convert-value": toItem,
|
|
261
|
+
"add-on-blur": "",
|
|
262
|
+
"add-on-paste": "",
|
|
263
|
+
class: "as-multi-select-anchor",
|
|
264
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => onTags($event))
|
|
265
|
+
}, {
|
|
266
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.model.value ?? [], (item, i) => {
|
|
267
|
+
return openBlock(), createBlock(unref(TagsInputItem), {
|
|
268
|
+
key: i,
|
|
269
|
+
value: item,
|
|
270
|
+
class: "as-multi-select-chip"
|
|
271
|
+
}, {
|
|
272
|
+
default: withCtx(() => [createVNode(unref(TagsInputItemText), { class: "as-multi-select-chip-label" }), createVNode(unref(TagsInputItemDelete), {
|
|
273
|
+
class: "as-multi-select-chip-remove",
|
|
274
|
+
"aria-label": `Remove ${item}`
|
|
275
|
+
}, {
|
|
276
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createElementVNode("span", {
|
|
277
|
+
class: "i-as-close",
|
|
278
|
+
"aria-hidden": "true"
|
|
279
|
+
}, null, -1)])]),
|
|
280
|
+
_: 1
|
|
281
|
+
}, 8, ["aria-label"])]),
|
|
282
|
+
_: 2
|
|
283
|
+
}, 1032, ["value"]);
|
|
284
|
+
}), 128)), createVNode(unref(TagsInputInput), {
|
|
285
|
+
id: inputId,
|
|
286
|
+
placeholder: __props.model.value?.length ? "" : __props.placeholder,
|
|
287
|
+
readonly: __props.readonly,
|
|
288
|
+
"aria-required": __props.required || void 0,
|
|
289
|
+
"aria-invalid": !!__props.error || void 0,
|
|
290
|
+
"aria-describedby": __props.ariaDescribedBy,
|
|
291
|
+
"aria-label": !__props.label ? __props.name : void 0,
|
|
292
|
+
class: "as-multi-select-input",
|
|
293
|
+
onBlur: __props.onBlur
|
|
294
|
+
}, null, 8, [
|
|
295
|
+
"id",
|
|
296
|
+
"placeholder",
|
|
297
|
+
"readonly",
|
|
298
|
+
"aria-required",
|
|
299
|
+
"aria-invalid",
|
|
300
|
+
"aria-describedby",
|
|
301
|
+
"aria-label",
|
|
302
|
+
"onBlur"
|
|
303
|
+
])]),
|
|
304
|
+
_: 2
|
|
305
|
+
}, 1032, [
|
|
306
|
+
"model-value",
|
|
307
|
+
"disabled",
|
|
308
|
+
"duplicate"
|
|
309
|
+
])) : (openBlock(), createBlock(unref(ComboboxRoot), {
|
|
310
|
+
key: 1,
|
|
243
311
|
modelValue: __props.model.value,
|
|
244
|
-
"onUpdate:modelValue": _cache[
|
|
312
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => __props.model.value = $event),
|
|
245
313
|
open: open.value,
|
|
246
|
-
"onUpdate:open": _cache[
|
|
314
|
+
"onUpdate:open": _cache[4] || (_cache[4] = ($event) => open.value = $event),
|
|
247
315
|
multiple: true,
|
|
248
316
|
disabled: __props.disabled || __props.readonly,
|
|
249
317
|
name: __props.name,
|
|
@@ -251,7 +319,7 @@ var as_multi_select_default = /* @__PURE__ */ defineComponent({
|
|
|
251
319
|
}, {
|
|
252
320
|
default: withCtx(() => [createVNode(unref(ComboboxAnchor), {
|
|
253
321
|
class: "as-multi-select-anchor",
|
|
254
|
-
onClick: _cache[
|
|
322
|
+
onClick: _cache[2] || (_cache[2] = ($event) => open.value = true)
|
|
255
323
|
}, {
|
|
256
324
|
default: withCtx(() => [
|
|
257
325
|
(openBlock(true), createElementBlock(Fragment, null, renderList(selectedOptions.value, (opt) => {
|
|
@@ -264,7 +332,7 @@ var as_multi_select_default = /* @__PURE__ */ defineComponent({
|
|
|
264
332
|
disabled: __props.disabled || __props.readonly,
|
|
265
333
|
"aria-label": `Remove ${unref(optLabel)(opt)}`,
|
|
266
334
|
onClick: withModifiers(($event) => deselect(unref(optKey)(opt)), ["stop"])
|
|
267
|
-
}, [..._cache[
|
|
335
|
+
}, [..._cache[6] || (_cache[6] = [createElementVNode("span", {
|
|
268
336
|
class: "i-as-close",
|
|
269
337
|
"aria-hidden": "true"
|
|
270
338
|
}, null, -1)])], 8, _hoisted_3)]);
|
|
@@ -279,7 +347,7 @@ var as_multi_select_default = /* @__PURE__ */ defineComponent({
|
|
|
279
347
|
"aria-describedby": __props.ariaDescribedBy,
|
|
280
348
|
"aria-label": !__props.label ? __props.name : void 0,
|
|
281
349
|
class: "as-multi-select-input",
|
|
282
|
-
onFocus: _cache[
|
|
350
|
+
onFocus: _cache[1] || (_cache[1] = ($event) => open.value = true),
|
|
283
351
|
onBlur: __props.onBlur
|
|
284
352
|
}, null, 8, [
|
|
285
353
|
"id",
|
|
@@ -298,11 +366,11 @@ var as_multi_select_default = /* @__PURE__ */ defineComponent({
|
|
|
298
366
|
class: "as-multi-select-clear",
|
|
299
367
|
"aria-label": "Clear selection",
|
|
300
368
|
onClick: withModifiers(clearAll, ["stop", "prevent"])
|
|
301
|
-
}, [..._cache[
|
|
369
|
+
}, [..._cache[7] || (_cache[7] = [createElementVNode("span", {
|
|
302
370
|
class: "i-as-close",
|
|
303
371
|
"aria-hidden": "true"
|
|
304
372
|
}, null, -1)])])) : createCommentVNode("v-if", true),
|
|
305
|
-
_cache[
|
|
373
|
+
_cache[8] || (_cache[8] = createElementVNode("span", {
|
|
306
374
|
class: "as-multi-select-caret i-as-chevron-down",
|
|
307
375
|
"aria-hidden": "true"
|
|
308
376
|
}, null, -1))
|
|
@@ -326,7 +394,7 @@ var as_multi_select_default = /* @__PURE__ */ defineComponent({
|
|
|
326
394
|
_: 2
|
|
327
395
|
}, 1032, ["value"]);
|
|
328
396
|
}), 128)), createVNode(unref(ComboboxEmpty), { class: "as-multi-select-empty" }, {
|
|
329
|
-
default: withCtx(() => [..._cache[
|
|
397
|
+
default: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode("No matches", -1)])]),
|
|
330
398
|
_: 1
|
|
331
399
|
})]),
|
|
332
400
|
_: 1
|
|
@@ -351,7 +419,7 @@ var as_multi_select_default = /* @__PURE__ */ defineComponent({
|
|
|
351
419
|
"open",
|
|
352
420
|
"disabled",
|
|
353
421
|
"name"
|
|
354
|
-
])]),
|
|
422
|
+
]))]),
|
|
355
423
|
_: 1
|
|
356
424
|
}, 16);
|
|
357
425
|
};
|