@dynamicforms/vue-forms 0.1.1 → 0.1.3

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
@@ -5,7 +5,8 @@ export declare class AbortEventHandlingException extends Error {
5
5
 
6
6
  export declare class Action extends FieldBase {
7
7
  private readonly _value;
8
- constructor(params?: Partial<IField>);
8
+ protected constructor(params?: Partial<IField<ActionValue>>);
9
+ static create(params?: Partial<IField<ActionValue>>): Action;
9
10
  get value(): ActionValue;
10
11
  set value(newValue: ActionValue);
11
12
  get icon(): string | undefined;
@@ -28,6 +29,8 @@ export declare interface ActionValue {
28
29
  icon?: string;
29
30
  }
30
31
 
32
+ export declare const defaultDisplayMode = DisplayMode.FULL;
33
+
31
34
  /**
32
35
  * DisplayMode enum provides an enumeration for supported ways of rendering a particular object in the DOM
33
36
  */
@@ -66,7 +69,8 @@ export declare class ExecuteAction extends FieldActionBase {
66
69
 
67
70
  export declare class Field<T = any> extends FieldBase {
68
71
  private _value;
69
- constructor(params?: Partial<IField<T>>);
72
+ protected constructor(params?: Partial<IField<T>>);
73
+ static create<T = any>(params?: Partial<IField<T>>): Field<T>;
70
74
  get value(): T;
71
75
  set value(newValue: T);
72
76
  clone(overrides?: Partial<IField<T>>): Field<T>;
@@ -84,6 +88,7 @@ export declare type FieldActionExecute<T = any> = (field: IField<T>, ...params:
84
88
  declare abstract class FieldBase<T = any> implements IField<T> {
85
89
  abstract get value(): T;
86
90
  abstract set value(newValue: T);
91
+ readonly reactiveValue: ComputedRef<T>;
87
92
  abstract clone(overrides?: Partial<IField<T>>): IField<T>;
88
93
  originalValue: T;
89
94
  valid: boolean;
@@ -102,20 +107,52 @@ declare abstract class FieldBase<T = any> implements IField<T> {
102
107
  validate(): void;
103
108
  get fullValue(): any;
104
109
  get isChanged(): boolean;
105
- get reactive(): IField;
106
110
  registerAction(action: IFieldAction<T>): this;
107
111
  triggerAction<T2 extends IFieldAction<T>>(actionClass: new (...args: any[]) => T2, ...params: any[]): any;
108
112
  }
109
113
 
114
+ declare namespace Form {
115
+ export {
116
+ defaultDisplayMode,
117
+ ValidationError,
118
+ ValidationErrorText,
119
+ FieldActionBase,
120
+ ActionsMap,
121
+ EnabledChangedAction,
122
+ EnabledChangingAction,
123
+ ExecuteAction,
124
+ VisibilityChangedAction,
125
+ VisibilityChangingAction,
126
+ ValidChangedAction,
127
+ ValueChangedAction,
128
+ ListItemAddedAction,
129
+ ListItemRemovedAction,
130
+ ActionValue,
131
+ Action,
132
+ NullableAction,
133
+ Field,
134
+ NullableField,
135
+ EmptyField,
136
+ IField,
137
+ AbortEventHandlingException,
138
+ FieldActionExecute,
139
+ IFieldAction,
140
+ GenericFieldsInterface,
141
+ Group,
142
+ NullableGroup,
143
+ List,
144
+ NullableList
145
+ }
146
+ }
147
+ export default Form;
148
+
110
149
  export declare type GenericFieldsInterface = Record<string, IField>;
111
150
 
112
151
  export declare class Group<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {
113
152
  private readonly _fields;
114
153
  private _value;
115
- readonly reactiveValue: ComputedRef<Record<string, any> | null>;
116
154
  private suppressNotifyValueChanged;
117
155
  constructor(fields: T, params?: Partial<IField>);
118
- get reactive(): this;
119
156
  private static isValidFields;
120
157
  static createFromFormData(data: Record<string, any> | null): Group;
121
158
  field(fieldName: string): IField | null;
@@ -129,6 +166,7 @@ export declare class Group<T extends GenericFieldsInterface = GenericFieldsInter
129
166
 
130
167
  export declare interface IField<T = any> {
131
168
  value: T;
169
+ reactiveValue: ComputedRef<T>;
132
170
  fullValue: T;
133
171
  originalValue: T;
134
172
  valid: boolean;
@@ -153,7 +191,6 @@ export declare class List<T extends GenericFieldsInterface = GenericFieldsInterf
153
191
  private _itemTemplate?;
154
192
  private _previousValue;
155
193
  constructor(itemTemplate?: Group<T>, params?: Partial<IField>);
156
- get reactive(): this;
157
194
  private processSetValueItem;
158
195
  private setValue;
159
196
  get value(): Record<string, any>[] | null;
@@ -188,11 +225,20 @@ export declare type NullableGroup = Group | null;
188
225
 
189
226
  export declare type NullableList = List | null;
190
227
 
191
- declare class ValidationError {
228
+ export declare class ValidationError {
192
229
  get componentName(): string;
193
230
  get componentBindings(): {};
194
231
  }
195
232
 
233
+ export declare class ValidationErrorText extends ValidationError {
234
+ text: string;
235
+ constructor(text: string);
236
+ get componentName(): string;
237
+ get componentBindings(): {
238
+ class: string;
239
+ };
240
+ }
241
+
196
242
  export declare class ValidChangedAction extends FieldActionBase {
197
243
  constructor(executorFn: (field: IField, supr: FieldActionExecute, newValue: boolean, oldValue: boolean) => Promise<void>);
198
244
  get classIdentifier(): symbol;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dynamicforms/vue-forms",
3
3
  "private": false,
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "description": "Data entry forms for vue - logic (no controls here)",
7
7
  "author": "Jure Erznožnik",
package/readme.md CHANGED
@@ -39,10 +39,10 @@ import { Field, Group, ValueChangedAction } from '@dynamicforms/vue-forms';
39
39
 
40
40
  // Create a form with fields
41
41
  const personForm = new Group({
42
- firstName: new Field({ value: 'John' }),
43
- lastName: new Field({ value: 'Doe' }),
44
- age: new Field({ value: 30 }),
45
- active: new Field({ value: true })
42
+ firstName: Field.create({ value: 'John' }),
43
+ lastName: Field.create({ value: 'Doe' }),
44
+ age: Field.create({ value: 30 }),
45
+ active: Field.create({ value: true })
46
46
  });
47
47
 
48
48
  // Access values
@@ -65,7 +65,7 @@ The library provides a powerful event system for field changes and other actions
65
65
  ```typescript
66
66
  import { Field, Group, ValueChangedAction, ValidationErrorText } from '@dynamicforms/vue-forms';
67
67
 
68
- const emailField = new Field({ value: '' })
68
+ const emailField = Field.create({ value: '' })
69
69
  .registerAction(new ValueChangedAction(async (field, supr, newValue, oldValue) => {
70
70
  // Custom validation on value change
71
71
  if (!newValue.includes('@')) {
@@ -81,7 +81,7 @@ const emailField = new Field({ value: '' })
81
81
  // Or register events on a form
82
82
  const form = new Group({
83
83
  email: emailField,
84
- username: new Field()
84
+ username: Field.create()
85
85
  }).registerAction(new ValueChangedAction(async (field, supr, newValue, oldValue) => {
86
86
  console.log('Form data changed:', newValue);
87
87
  return supr(field, newValue, oldValue);
@@ -107,11 +107,11 @@ interface UserFormData {
107
107
 
108
108
  // Create the form with type checking
109
109
  const userForm = new Group<UserFormData>({
110
- username: new Field({ value: '' }),
111
- email: new Field({ value: '' }),
110
+ username: Field.create({ value: '' }),
111
+ email: Field.create({ value: '' }),
112
112
  preferences: new Group({
113
- darkMode: new Field({ value: true }),
114
- notifications: new Field({ value: true })
113
+ darkMode: Field.create({ value: true }),
114
+ notifications: Field.create({ value: true })
115
115
  })
116
116
  });
117
117