@dynamicforms/vue-forms 0.16.1 → 0.17.0

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/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import { Ref } from 'vue';
12
12
  export declare class AbortEventHandlingException extends Error {
13
13
  }
14
14
 
15
- export declare class Action<T extends ActionValue = ActionValue, X extends object = {}> extends Field<T, X> {
15
+ export declare class Action<T extends ActionValue = ActionValue, X extends object = Omit<Extras, keyof ActionValue>> extends Field<T, X> {
16
16
  get [Symbol.toStringTag](): string;
17
17
  protected init(params?: IFieldParams<T, X>): void;
18
18
  /**
@@ -22,9 +22,9 @@ export declare class Action<T extends ActionValue = ActionValue, X extends objec
22
22
  * against a baseline that never carried the key.
23
23
  */
24
24
  private valueWith;
25
- get icon(): string | undefined;
26
- set icon(newValue: string | undefined);
27
- get label(): string | undefined;
25
+ get icon(): T['icon'];
26
+ set icon(newValue: T['icon']);
27
+ get label(): T['label'];
28
28
  /**
29
29
  * The two setters hand the value setter a new object rather than writing into the one the action holds, so each
30
30
  * is an ordinary value change: the handlers fire, isChanged answers over it, and a disabled action refuses it.
@@ -32,7 +32,7 @@ export declare class Action<T extends ActionValue = ActionValue, X extends objec
32
32
  * identity and every copy is a new object, so without the comparison here a write of the value already held
33
33
  * would announce a change and invalidate the value cache of every container above.
34
34
  */
35
- set label(newValue: string | undefined);
35
+ set label(newValue: T['label']);
36
36
  /** the counter behind `busy`, allocated for this action the first time it is asked for */
37
37
  private get busyRuns();
38
38
  /** true from the moment execute() is called until the handler it ran has settled, however it settles */
@@ -117,9 +117,19 @@ export declare class ActionsMap {
117
117
  private walk;
118
118
  }
119
119
 
120
+ /**
121
+ * The value an `Action` holds. Both members are `unknown` because `Action` states the concept and a UI library
122
+ * states what it renders: a subclass declares its value type with `label` and `icon` in whatever shape it renders
123
+ * them - `string | MdString`, a per-breakpoint object - and the accessors below answer at that type, because they
124
+ * read it off `T` rather than fixing one of their own.
125
+ *
126
+ * The consequence for an `Action` built without a type argument is that reading either member answers `unknown`
127
+ * and the reader states what it expects. That is the shape the class is for; an application that renders actions
128
+ * uses the subclass its UI library ships.
129
+ */
120
130
  export declare interface ActionValue {
121
- label?: string;
122
- icon?: string;
131
+ label?: unknown;
132
+ icon?: unknown;
123
133
  }
124
134
 
125
135
  /**
@@ -363,7 +373,31 @@ export declare class ExecuteAction extends FieldActionBase {
363
373
  execute(field: FieldBase, supr: FieldActionExecute, params: any): any;
364
374
  }
365
375
 
366
- export declare class Field<T = any, X extends object = {}> extends FieldBase<T, X> {
376
+ /**
377
+ * The extended properties an element carries when nothing states otherwise. It is empty as declared and exists
378
+ * to be augmented: the layer that renders the elements declares what it renders them with, and every element in
379
+ * the application then carries those properties without a type argument at any construction site.
380
+ *
381
+ * ```ts
382
+ * declare module '@dynamicforms/vue-forms' {
383
+ * interface Extras {
384
+ * label?: string;
385
+ * hint?: string;
386
+ * cssClass?: string;
387
+ * }
388
+ * }
389
+ * ```
390
+ *
391
+ * The interface is one per application, so two packages that both declare a property of the same name must give
392
+ * it the same type; declaration merging refuses a second declaration that differs.
393
+ *
394
+ * An element that states an X of its own replaces this rather than adding to it, so an element that carries both
395
+ * is `Field<string, Extras & Local>`.
396
+ */
397
+ export declare interface Extras {
398
+ }
399
+
400
+ export declare class Field<T = any, X extends object = Extras> extends FieldBase<T, X> {
367
401
  get [Symbol.toStringTag](): string;
368
402
  protected get state(): FieldSlots<T>;
369
403
  protected get raw(): FieldSlots<T>;
@@ -431,7 +465,7 @@ export declare abstract class FieldActionBase {
431
465
 
432
466
  export declare type FieldActionExecute<T = any> = (field: FieldBase<T>, ...params: any[]) => any;
433
467
 
434
- export declare abstract class FieldBase<T = any, X extends object = {}> {
468
+ export declare abstract class FieldBase<T = any, X extends object = Extras> {
435
469
  #private;
436
470
  /**
437
471
  * Vue's getTargetType answers INVALID for an object that carries __v_skip, so reactive() hands an element back
@@ -785,6 +819,22 @@ export declare abstract class FieldBase<T = any, X extends object = {}> {
785
819
  set visibility(newValue: DisplayMode);
786
820
  get enabled(): boolean;
787
821
  set enabled(newValue: boolean);
822
+ /**
823
+ * Whether this element and every container above it are enabled. A rendering layer binds one read instead of
824
+ * walking the parent chain: a disabled `Group` states that its section cannot be edited, and the inputs
825
+ * rendered from the members inside it read that here.
826
+ *
827
+ * It is a read and nothing else. `enabled` on each element stays exactly what was written to it, a write to a
828
+ * member of a disabled container is accepted the way it always was, and what a container serializes is decided
829
+ * by the members' own `enabled`. Where a whole subtree is to stop serializing, the members are disabled.
830
+ *
831
+ * `enabled` is the only member with a reading of this kind, and it is not a scheme the other members follow.
832
+ * `visibility` has none because `SUPPRESS` states that an element is absent from the value as well, so folding
833
+ * it down the tree would decide serialization rather than report it; `value` has none because a container
834
+ * composes its own from its members rather than passing one down. A rendering layer that needs a third thing
835
+ * folded down the tree has `provide`/`inject`, which is where the render tree's own context belongs.
836
+ */
837
+ get effectiveEnabled(): boolean;
788
838
  /**
789
839
  * True for an element whose value is composed of its members'. The commit builds such a value only where
790
840
  * something receives it, compares it by content rather than by identity, and runs the element's own validators
@@ -916,6 +966,7 @@ declare namespace Form {
916
966
  NullableField,
917
967
  IFieldConstructorActionsList,
918
968
  IFieldConstructorParams,
969
+ Extras,
919
970
  IFieldParams,
920
971
  IBindParams,
921
972
  AbortEventHandlingException,
@@ -971,7 +1022,7 @@ export declare type GenericFieldsInterface = Record<string, FieldBase>;
971
1022
  /** The current configuration. The object is the module's own record, and reading it again reports later writes. */
972
1023
  export declare function getConfig(): FormsConfig;
973
1024
 
974
- export declare class Group<T extends GenericFieldsInterface = GenericFieldsInterface, X extends object = {}> extends FieldBase<GroupValue<T>, X> {
1025
+ export declare class Group<T extends GenericFieldsInterface = GenericFieldsInterface, X extends object = Extras> extends FieldBase<GroupValue<T>, X> {
975
1026
  get [Symbol.toStringTag](): string;
976
1027
  protected get state(): GroupSlots<GroupValue<T>>;
977
1028
  protected get raw(): GroupSlots<GroupValue<T>>;
@@ -1105,7 +1156,7 @@ export declare type GroupValueInput<T extends GenericFieldsInterface> = Partial<
1105
1156
  * `validators` and `actions` are carried from the declaration rather than supplied, and `touched` and `errors`
1106
1157
  * are what the binding establishes for itself as it validates.
1107
1158
  */
1108
- export declare type IBindParams<T = any, X extends object = {}> = Partial<Pick<IFieldConstructorParams<T>, 'originalValue' | 'enabled' | 'visibility'>> & Partial<NoInfer<X>>;
1159
+ export declare type IBindParams<T = any, X extends object = Extras> = Partial<Pick<IFieldConstructorParams<T>, 'originalValue' | 'enabled' | 'visibility'>> & Partial<NoInfer<X>>;
1109
1160
 
1110
1161
  export declare interface IFieldConstructorActionsList {
1111
1162
  actions?: FieldActionBase[];
@@ -1132,15 +1183,14 @@ export declare type IFieldConstructorParams<T = any> = {
1132
1183
  * What an element's constructor accepts: the parameters the element answers for itself, together with the
1133
1184
  * extended properties its X parameter declares.
1134
1185
  *
1135
- * X is left out of inference, so an element built without a type argument carries no extended properties and a
1136
- * parameter object naming one is rejected as an excess property. A caller that wants them states them:
1137
- * `new Field<string, { label: string }>({ value: 'a', label: 'Name' })`.
1186
+ * X is left out of inference, so an element carries what its X states - `Extras` where no type argument replaces
1187
+ * it - and a parameter object naming anything else is rejected as an excess property.
1138
1188
  *
1139
1189
  * The two halves are made partial separately. `Partial<A & X>` is a mapped type over an intersection, which is
1140
1190
  * what T is inferred through, and inference through it answers with one constituent of a union rather than the
1141
1191
  * union: `new Field({ value: someStringOrNumber })` would be a Field<string>.
1142
1192
  */
1143
- export declare type IFieldParams<T = any, X extends object = {}> = Partial<IFieldConstructorParams<T>> & Partial<NoInfer<X>>;
1193
+ export declare type IFieldParams<T = any, X extends object = Extras> = Partial<IFieldConstructorParams<T>> & Partial<NoInfer<X>>;
1144
1194
 
1145
1195
  declare class InAllowedValues<T = any> extends Validator {
1146
1196
  constructor(allowedValues: AllowedValues<T>, message?: RenderContentRef);
@@ -1159,7 +1209,7 @@ declare class LengthInRange extends Validator {
1159
1209
  constructor(minLength: number, maxLength: number, message?: RenderContentRef);
1160
1210
  }
1161
1211
 
1162
- export declare class List<T extends GenericFieldsInterface = GenericFieldsInterface, X extends object = {}> extends FieldBase<ListValue, X> {
1212
+ export declare class List<T extends GenericFieldsInterface = GenericFieldsInterface, X extends object = Extras> extends FieldBase<ListValue, X> {
1163
1213
  get [Symbol.toStringTag](): string;
1164
1214
  protected get state(): ListSlots<T>;
1165
1215
  protected get raw(): ListSlots<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dynamicforms/vue-forms",
3
3
  "private": false,
4
- "version": "0.16.1",
4
+ "version": "0.17.0",
5
5
  "type": "module",
6
6
  "description": "A lightweight Vue.js library for form state management with built-in validation, conditional logic, nested structures, and a rich event system. UI-agnostic and TypeScript-first.",
7
7
  "author": "Jure Erzno\u017enik",