@lehnihon/bit-form 2.2.6 → 2.2.7

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.
Files changed (121) hide show
  1. package/README.md +80 -24
  2. package/dist/angular/index.cjs +1 -1
  3. package/dist/angular/index.cjs.map +1 -1
  4. package/dist/angular/index.d.cts +18 -20
  5. package/dist/angular/index.d.ts +18 -20
  6. package/dist/angular/index.js +1 -1
  7. package/dist/angular/index.js.map +1 -1
  8. package/dist/array-controller-C1A5VKYd.d.cts +23 -0
  9. package/dist/array-controller-DtkmcnUr.d.ts +23 -0
  10. package/dist/{bus-B4zZmB9C.d.ts → bus-DgilLszS.d.ts} +83 -15
  11. package/dist/{bus-BeAeZwWu.d.cts → bus-rcUiufS7.d.cts} +83 -15
  12. package/dist/chunk-DIEE6LUO.js +2 -0
  13. package/dist/chunk-DIEE6LUO.js.map +1 -0
  14. package/dist/chunk-FUUQB4DV.cjs +2 -0
  15. package/dist/chunk-FUUQB4DV.cjs.map +1 -0
  16. package/dist/chunk-IV32WXCF.cjs +2 -0
  17. package/dist/chunk-IV32WXCF.cjs.map +1 -0
  18. package/dist/chunk-K5X37E3U.js +2 -0
  19. package/dist/chunk-K5X37E3U.js.map +1 -0
  20. package/dist/chunk-KWLLYQOL.cjs +2 -0
  21. package/dist/chunk-KWLLYQOL.cjs.map +1 -0
  22. package/dist/chunk-LIYZPSWM.js +2 -0
  23. package/dist/chunk-LIYZPSWM.js.map +1 -0
  24. package/dist/chunk-O5UPA33R.js +2 -0
  25. package/dist/chunk-O5UPA33R.js.map +1 -0
  26. package/dist/chunk-QAL6J5GQ.cjs +2 -0
  27. package/dist/chunk-QAL6J5GQ.cjs.map +1 -0
  28. package/dist/chunk-QKGTVKBU.cjs +2 -0
  29. package/dist/chunk-QKGTVKBU.cjs.map +1 -0
  30. package/dist/chunk-SA47B5OP.js +2 -0
  31. package/dist/chunk-SA47B5OP.js.map +1 -0
  32. package/dist/cli/index.cjs +22 -22
  33. package/dist/core.cjs +2 -0
  34. package/dist/core.cjs.map +1 -0
  35. package/dist/core.d.cts +122 -0
  36. package/dist/core.d.ts +122 -0
  37. package/dist/core.js +2 -0
  38. package/dist/core.js.map +1 -0
  39. package/dist/devtools/bridge.cjs +1 -1
  40. package/dist/devtools/bridge.cjs.map +1 -1
  41. package/dist/devtools/bridge.d.cts +4 -1
  42. package/dist/devtools/bridge.d.ts +4 -1
  43. package/dist/devtools/bridge.js +1 -1
  44. package/dist/devtools/bridge.js.map +1 -1
  45. package/dist/devtools/index.cjs +18 -18
  46. package/dist/devtools/index.cjs.map +1 -1
  47. package/dist/devtools/index.d.cts +26 -2
  48. package/dist/devtools/index.d.ts +26 -2
  49. package/dist/devtools/index.js +18 -18
  50. package/dist/devtools/index.js.map +1 -1
  51. package/dist/devtools/protocol.cjs +2 -0
  52. package/dist/devtools/protocol.cjs.map +1 -0
  53. package/dist/devtools/protocol.d.cts +54 -0
  54. package/dist/devtools/protocol.d.ts +54 -0
  55. package/dist/devtools/protocol.js +2 -0
  56. package/dist/devtools/protocol.js.map +1 -0
  57. package/dist/field-binding-Bi1g-D8X.d.ts +25 -0
  58. package/dist/field-binding-X5TkvfUt.d.cts +25 -0
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +64 -171
  62. package/dist/index.d.ts +64 -171
  63. package/dist/index.js +1 -1
  64. package/dist/mask.d.cts +2 -2
  65. package/dist/mask.d.ts +2 -2
  66. package/dist/react/index.cjs +1 -1
  67. package/dist/react/index.cjs.map +1 -1
  68. package/dist/react/index.d.cts +8 -7
  69. package/dist/react/index.d.ts +8 -7
  70. package/dist/react/index.js +1 -1
  71. package/dist/react/index.js.map +1 -1
  72. package/dist/react-native/index.cjs +1 -1
  73. package/dist/react-native/index.cjs.map +1 -1
  74. package/dist/react-native/index.d.cts +7 -6
  75. package/dist/react-native/index.d.ts +7 -6
  76. package/dist/react-native/index.js +1 -1
  77. package/dist/react-native/index.js.map +1 -1
  78. package/dist/resolvers/index.cjs +1 -1
  79. package/dist/resolvers/index.cjs.map +1 -1
  80. package/dist/resolvers/index.d.cts +2 -2
  81. package/dist/resolvers/index.d.ts +2 -2
  82. package/dist/resolvers/index.js +1 -1
  83. package/dist/resolvers/joi.d.cts +2 -2
  84. package/dist/resolvers/joi.d.ts +2 -2
  85. package/dist/resolvers/yup.d.cts +2 -2
  86. package/dist/resolvers/yup.d.ts +2 -2
  87. package/dist/resolvers/zod.d.cts +2 -2
  88. package/dist/resolvers/zod.d.ts +2 -2
  89. package/dist/store-api-types-9ipdute1.d.ts +187 -0
  90. package/dist/store-api-types-B6_bPoVI.d.cts +187 -0
  91. package/dist/{types-D8DgIUhJ.d.cts → types-CUXh7PqD.d.cts} +1 -1
  92. package/dist/{types-D8DgIUhJ.d.ts → types-CUXh7PqD.d.ts} +1 -1
  93. package/dist/{use-bit-persist-Dk3fUrds.d.ts → use-bit-persist-Bc06fmqZ.d.ts} +12 -14
  94. package/dist/{use-bit-persist-D_gimC9A.d.cts → use-bit-persist-CIKFwtdM.d.cts} +12 -14
  95. package/dist/vue/index.cjs +1 -1
  96. package/dist/vue/index.cjs.map +1 -1
  97. package/dist/vue/index.d.cts +15 -18
  98. package/dist/vue/index.d.ts +15 -18
  99. package/dist/vue/index.js +1 -1
  100. package/dist/vue/index.js.map +1 -1
  101. package/package.json +20 -11
  102. package/dist/chunk-2CVKNPWX.js +0 -2
  103. package/dist/chunk-2CVKNPWX.js.map +0 -1
  104. package/dist/chunk-3EDD3V43.cjs +0 -2
  105. package/dist/chunk-3EDD3V43.cjs.map +0 -1
  106. package/dist/chunk-PX6WKENM.js +0 -2
  107. package/dist/chunk-PX6WKENM.js.map +0 -1
  108. package/dist/chunk-QWH2NBVB.js +0 -2
  109. package/dist/chunk-QWH2NBVB.js.map +0 -1
  110. package/dist/chunk-T3FR7D5V.js +0 -2
  111. package/dist/chunk-T3FR7D5V.js.map +0 -1
  112. package/dist/chunk-VQ7MK5VB.cjs +0 -2
  113. package/dist/chunk-VQ7MK5VB.cjs.map +0 -1
  114. package/dist/chunk-Y2ONHDRE.cjs +0 -2
  115. package/dist/chunk-Y2ONHDRE.cjs.map +0 -1
  116. package/dist/chunk-YCSWULEN.cjs +0 -2
  117. package/dist/chunk-YCSWULEN.cjs.map +0 -1
  118. package/dist/field-binding-BXw0Ku2c.d.cts +0 -12
  119. package/dist/field-binding-BXw0Ku2c.d.ts +0 -12
  120. package/dist/public-types-Cd9ai20P.d.cts +0 -97
  121. package/dist/public-types-DdZxD6Op.d.ts +0 -97
@@ -0,0 +1,187 @@
1
+ import { f as BitState, e as BitPath, g as BitFieldState, b as BitPathValue, h as BitFieldDefinition, c as BitErrors, D as DeepPartial, B as BitArrayPath, a as BitArrayItem, i as BitPersistMetadata, S as ScopeStatus, j as BitConfig, k as ValidatorFn, l as DevToolsOptions, m as BitPersistResolvedConfig, n as BitIdFactory, o as BitPlugin, p as BitScheduler, q as BitFormGlobal } from './bus-rcUiufS7.cjs';
2
+ import { B as BitMask } from './types-CUXh7PqD.cjs';
3
+
4
+ type BitSelector<T extends object, TSlice> = (state: Readonly<BitState<T>>) => TSlice;
5
+ type BitEqualityFn<TValue> = (previous: TValue, next: TValue) => boolean;
6
+ interface BitSelectorSubscriptionOptions<TValue> {
7
+ equalityFn?: BitEqualityFn<TValue>;
8
+ emitImmediately?: boolean;
9
+ paths?: string[];
10
+ }
11
+
12
+ interface BitValidationOptions {
13
+ scope?: string;
14
+ scopeFields?: string[];
15
+ }
16
+ interface BitHistoryMetadata {
17
+ enabled: boolean;
18
+ canUndo: boolean;
19
+ canRedo: boolean;
20
+ historyIndex: number;
21
+ historySize: number;
22
+ }
23
+ interface BitFormMeta {
24
+ isValid: boolean;
25
+ isDirty: boolean;
26
+ isSubmitting: boolean;
27
+ }
28
+
29
+ interface BitFrameworkConfig<T extends object = any> extends BitConfig<T> {
30
+ initialValues: T;
31
+ resolver?: ValidatorFn<T>;
32
+ validationDelay: number;
33
+ history: {
34
+ enabled: boolean;
35
+ limit: number;
36
+ };
37
+ masks?: Record<string, BitMask>;
38
+ fields?: Record<string, BitFieldDefinition<T>>;
39
+ devTools?: boolean | DevToolsOptions;
40
+ persist: BitPersistResolvedConfig<T>;
41
+ idFactory: BitIdFactory;
42
+ plugins: BitPlugin<T>[];
43
+ scheduler?: BitScheduler;
44
+ subscriptionCacheSize?: number;
45
+ bus?: BitFormGlobal;
46
+ }
47
+ interface BitStoreQueryApi<T extends object = any> {
48
+ getConfig(): Readonly<BitFrameworkConfig<T>>;
49
+ getState(): Readonly<BitState<T>>;
50
+ isHidden<P extends BitPath<T>>(path: P): boolean;
51
+ isRequired<P extends BitPath<T>>(path: P): boolean;
52
+ isFieldDirty(path: string): boolean;
53
+ isFieldValidating(path: string): boolean;
54
+ getDirtyValues(): Partial<T>;
55
+ getPersistMetadata(): BitPersistMetadata;
56
+ getHistoryMetadata(): BitHistoryMetadata;
57
+ getStepStatus(scopeName: string): ScopeStatus;
58
+ getStepErrors(scopeName: string): Record<string, string>;
59
+ }
60
+ interface BitStoreObserveApi<T extends object = any> {
61
+ subscribe(listener: () => void): () => void;
62
+ subscribePersistMeta(listener: (meta: BitPersistMetadata) => void): () => void;
63
+ subscribeHistoryMeta(listener: (meta: BitHistoryMetadata) => void): () => void;
64
+ subscribeScopeStatus(scopeName: string, listener: (status: ScopeStatus) => void): () => void;
65
+ }
66
+ interface BitStoreWriteApi<T extends object = any> {
67
+ setField<P extends BitPath<T>>(path: P, value: BitPathValue<T, P>): void;
68
+ blurField<P extends BitPath<T>>(path: P): void;
69
+ setValues(values: T | DeepPartial<T>, options?: {
70
+ partial?: boolean;
71
+ rebase?: boolean;
72
+ }): void;
73
+ setError(path: string, message: string | undefined): void;
74
+ setErrors(errors: BitErrors<T>): void;
75
+ setServerErrors(serverErrors: Record<string, string[] | string>): void;
76
+ validate(options?: BitValidationOptions): Promise<boolean>;
77
+ reset(): void;
78
+ transaction<TResult>(callback: () => TResult): TResult;
79
+ submit(onSuccess: (values: T, dirtyValues?: Partial<T>) => void | Promise<void>): Promise<void>;
80
+ }
81
+ interface BitStorePersistFeatureApi {
82
+ getPersistMetadata(): BitPersistMetadata;
83
+ restorePersisted(): Promise<boolean>;
84
+ forceSave(): Promise<void>;
85
+ clearPersisted(): Promise<void>;
86
+ }
87
+ interface BitStoreRegistrationFeatureApi<T extends object = any> {
88
+ cleanup(): void;
89
+ registerField(path: string, config: BitFieldDefinition<T>): void;
90
+ unregisterField(path: string): void;
91
+ }
92
+ interface BitStoreArrayFeatureApi<T extends object = any> {
93
+ pushItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
94
+ prependItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
95
+ insertItem<P extends BitArrayPath<T>>(path: P, index: number, value: BitArrayItem<BitPathValue<T, P>>): void;
96
+ removeItem<P extends BitArrayPath<T>>(path: P, index: number): void;
97
+ moveItem<P extends BitArrayPath<T>>(path: P, from: number, to: number): void;
98
+ swapItems<P extends BitArrayPath<T>>(path: P, indexA: number, indexB: number): void;
99
+ }
100
+ interface BitStoreHistoryFeatureApi {
101
+ undo(): void;
102
+ redo(): void;
103
+ }
104
+ interface BitFormMetaBindingApi<T extends object = any> {
105
+ getState(): Readonly<BitState<T>>;
106
+ subscribeFormMeta(listener: (meta: BitFormMeta) => void): () => void;
107
+ }
108
+ interface BitFieldBindingApi<T extends object = any> {
109
+ getFieldState<P extends BitPath<T>>(path: P): Readonly<BitFieldState<T, BitPathValue<T, P>>>;
110
+ subscribeFieldState<P extends BitPath<T>>(path: P, listener: (state: Readonly<BitFieldState<T, BitPathValue<T, P>>>) => void): () => void;
111
+ setField<P extends BitPath<T>>(path: P, value: BitPathValue<T, P>): void;
112
+ blurField<P extends BitPath<T>>(path: P): void;
113
+ resolveMask(path: string): BitMask | undefined;
114
+ unregisterField?(path: string): void;
115
+ }
116
+ interface BitArrayBindingApi<T extends object = any> extends Pick<BitFormBindingApi<T>, "getState" | "setField" | "subscribePath" | "pushItem" | "prependItem" | "insertItem" | "removeItem" | "moveItem" | "swapItems" | "createArrayItemId"> {
117
+ }
118
+ interface BitStoreFeatureApi<T extends object = any> extends BitStorePersistFeatureApi, BitStoreRegistrationFeatureApi<T>, BitStoreArrayFeatureApi<T>, BitStoreHistoryFeatureApi {
119
+ }
120
+ interface BitStoreApi<T extends object = any> extends BitStoreQueryApi<T>, BitStoreObserveApi<T>, BitStoreWriteApi<T>, BitStoreFeatureApi<T> {
121
+ }
122
+ interface BitStoreHooksApi<T extends object = any> extends BitStoreApi<T> {
123
+ getFieldState<P extends BitPath<T>>(path: P): Readonly<BitFieldState<T, BitPathValue<T, P>>>;
124
+ subscribeFieldState<P extends BitPath<T>>(path: P, listener: (state: Readonly<BitFieldState<T, BitPathValue<T, P>>>) => void): () => void;
125
+ subscribeFormMeta(listener: (meta: BitFormMeta) => void): () => void;
126
+ subscribePath<P extends BitPath<T>>(path: P, listener: (value: BitPathValue<T, P>) => void, options?: BitSelectorSubscriptionOptions<BitPathValue<T, P>>): () => void;
127
+ subscribeSelector<TSlice>(selector: BitSelector<T, TSlice>, listener: (slice: TSlice) => void, options?: BitSelectorSubscriptionOptions<TSlice>): () => void;
128
+ subscribeTracked<TSlice>(selector: BitSelector<T, TSlice>, listener: (slice: TSlice) => void, options?: Omit<BitSelectorSubscriptionOptions<TSlice>, "paths">): () => void;
129
+ unregisterPrefix?(prefix: string): void;
130
+ markFieldsTouched(paths: string[]): void;
131
+ hasValidationsInProgress(scopeFields?: string[]): boolean;
132
+ resolveMask(path: string): BitMask | undefined;
133
+ getScopeFields(scopeName: string): string[];
134
+ createArrayItemId(path: string, index?: number): string;
135
+ }
136
+ interface BitFormBindingApi<T extends object = any> {
137
+ getFieldState<P extends BitPath<T>>(path: P): Readonly<BitFieldState<T, BitPathValue<T, P>>>;
138
+ subscribeFieldState<P extends BitPath<T>>(path: P, listener: (state: Readonly<BitFieldState<T, BitPathValue<T, P>>>) => void): () => void;
139
+ getState(): Readonly<BitState<T>>;
140
+ subscribeFormMeta(listener: (meta: BitFormMeta) => void): () => void;
141
+ subscribe(listener: () => void): () => void;
142
+ subscribePath<P extends BitPath<T>>(path: P, listener: (value: BitPathValue<T, P>) => void, options?: BitSelectorSubscriptionOptions<BitPathValue<T, P>>): () => void;
143
+ subscribeSelector<TSlice>(selector: BitSelector<T, TSlice>, listener: (slice: TSlice) => void, options?: BitSelectorSubscriptionOptions<TSlice>): () => void;
144
+ subscribeTracked<TSlice>(selector: BitSelector<T, TSlice>, listener: (slice: TSlice) => void, options?: Omit<BitSelectorSubscriptionOptions<TSlice>, "paths">): () => void;
145
+ setField<P extends BitPath<T>>(path: P, value: BitPathValue<T, P>): void;
146
+ blurField<P extends BitPath<T>>(path: P): void;
147
+ registerField?(path: string, config: BitFieldDefinition<T>): void;
148
+ unregisterField?(path: string): void;
149
+ unregisterPrefix?(prefix: string): void;
150
+ markFieldsTouched(paths: string[]): void;
151
+ resolveMask(path: string): BitMask | undefined;
152
+ submit(onSuccess: (values: T, dirtyValues?: Partial<T>) => void | Promise<void>): Promise<void>;
153
+ reset(): void;
154
+ validate(options?: BitValidationOptions): Promise<boolean>;
155
+ setError(path: string, message: string | undefined): void;
156
+ setErrors(errors: BitErrors<T>): void;
157
+ setServerErrors(serverErrors: Record<string, string[] | string>): void;
158
+ setValues(values: T | DeepPartial<T>, options?: {
159
+ partial?: boolean;
160
+ rebase?: boolean;
161
+ }): void;
162
+ transaction<TResult>(callback: () => TResult): TResult;
163
+ pushItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
164
+ prependItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
165
+ insertItem<P extends BitArrayPath<T>>(path: P, index: number, value: BitArrayItem<BitPathValue<T, P>>): void;
166
+ removeItem<P extends BitArrayPath<T>>(path: P, index: number): void;
167
+ moveItem<P extends BitArrayPath<T>>(path: P, from: number, to: number): void;
168
+ swapItems<P extends BitArrayPath<T>>(path: P, indexA: number, indexB: number): void;
169
+ undo(): void;
170
+ redo(): void;
171
+ getHistoryMetadata(): BitHistoryMetadata;
172
+ getPersistMetadata(): BitPersistMetadata;
173
+ restorePersisted(): Promise<boolean>;
174
+ forceSave(): Promise<void>;
175
+ clearPersisted(): Promise<void>;
176
+ getDirtyValues(): Partial<T>;
177
+ hasValidationsInProgress(scopeFields?: string[]): boolean;
178
+ getScopeFields(scopeName: string): string[];
179
+ getStepStatus(scopeName: string): ScopeStatus;
180
+ getStepErrors(scopeName: string): Record<string, string>;
181
+ subscribePersistMeta(listener: (meta: BitPersistMetadata) => void): () => void;
182
+ subscribeHistoryMeta(listener: (meta: BitHistoryMetadata) => void): () => void;
183
+ subscribeScopeStatus(scopeName: string, listener: (status: ScopeStatus) => void): () => void;
184
+ createArrayItemId(path: string, index?: number): string;
185
+ }
186
+
187
+ export type { BitArrayBindingApi as B, BitStoreHooksApi as a, BitFormBindingApi as b, BitHistoryMetadata as c, BitValidationOptions as d, BitFormMetaBindingApi as e, BitFormMeta as f, BitFieldBindingApi as g, BitEqualityFn as h, BitFrameworkConfig as i, BitSelector as j, BitSelectorSubscriptionOptions as k, BitStoreApi as l, BitStoreArrayFeatureApi as m, BitStoreFeatureApi as n, BitStoreHistoryFeatureApi as o, BitStoreObserveApi as p, BitStorePersistFeatureApi as q, BitStoreQueryApi as r, BitStoreRegistrationFeatureApi as s, BitStoreWriteApi as t };
@@ -24,4 +24,4 @@ interface DateMaskConfig extends PatternMaskOptions {
24
24
  format?: "DD/MM/YYYY" | "YYYY-MM-DD";
25
25
  }
26
26
 
27
- export type { BitMask as B, CurrencyMaskConfig as C, DateMaskConfig as D, PatternMaskOptions as P, BitMaskName as a, BitBuiltInMaskName as b };
27
+ export type { BitMask as B, CurrencyMaskConfig as C, DateMaskConfig as D, PatternMaskOptions as P, BitBuiltInMaskName as a, BitMaskName as b };
@@ -24,4 +24,4 @@ interface DateMaskConfig extends PatternMaskOptions {
24
24
  format?: "DD/MM/YYYY" | "YYYY-MM-DD";
25
25
  }
26
26
 
27
- export type { BitMask as B, CurrencyMaskConfig as C, DateMaskConfig as D, PatternMaskOptions as P, BitMaskName as a, BitBuiltInMaskName as b };
27
+ export type { BitMask as B, CurrencyMaskConfig as C, DateMaskConfig as D, PatternMaskOptions as P, BitBuiltInMaskName as a, BitMaskName as b };
@@ -1,14 +1,15 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { e as BitStoreApi, f as BitStoreHooksApi, c as BitHistoryMetadata, d as BitValidationOptions } from './public-types-DdZxD6Op.js';
4
- import { f as BitPath, g as BitPathValue, j as BitPersistMetadata, S as ScopeStatus, n as ValidateScopeResult, i as BitErrors, H as BitTouched, h as DeepPartial, k as BitArrayPath, l as BitArrayItem } from './bus-B4zZmB9C.js';
5
- import { B as BitFieldInputEvent } from './field-binding-BXw0Ku2c.js';
3
+ import { a as BitStoreHooksApi, b as BitFormBindingApi, c as BitHistoryMetadata, d as BitValidationOptions } from './store-api-types-9ipdute1.js';
4
+ import { e as BitPath, b as BitPathValue, i as BitPersistMetadata, S as ScopeStatus, V as ValidateScopeResult, c as BitErrors, r as BitTouched, D as DeepPartial, B as BitArrayPath, a as BitArrayItem } from './bus-DgilLszS.js';
5
+ import { B as BitArrayBindingField } from './array-controller-DtkmcnUr.js';
6
+ import { B as BitFieldInputEvent } from './field-binding-Bi1g-D8X.js';
6
7
 
7
8
  declare const BitFormProvider: ({ store, children, }: {
8
- store: BitStoreApi<any>;
9
+ store: BitStoreHooksApi<any>;
9
10
  children: React.ReactNode;
10
11
  }) => react_jsx_runtime.JSX.Element;
11
- declare const useBitStore: <T extends object>() => BitStoreHooksApi<T>;
12
+ declare const useBitStore: <T extends object>() => BitFormBindingApi<T>;
12
13
 
13
14
  /**
14
15
  * Metadata describing the current state of a form field.
@@ -118,9 +119,10 @@ interface UseBitFormResult<T extends object = any> {
118
119
  transaction: <TResult>(callback: () => TResult) => TResult;
119
120
  setField: <P extends BitPath<T>>(path: P, value: BitPathValue<T, P>) => void;
120
121
  blurField: <P extends BitPath<T>>(path: P) => void;
121
- replaceValues: (values: T) => void;
122
- hydrate: (values: DeepPartial<T>) => void;
123
- rebase: (values: T) => void;
122
+ setValues: (values: T | DeepPartial<T>, options?: {
123
+ partial?: boolean;
124
+ rebase?: boolean;
125
+ }) => void;
124
126
  setError: (path: string, message: string | undefined) => void;
125
127
  setErrors: (errors: BitErrors<T>) => void;
126
128
  setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
@@ -130,6 +132,8 @@ interface UseBitFormResult<T extends object = any> {
130
132
  declare function useBitForm<T extends object>(): UseBitFormResult<T>;
131
133
 
132
134
  declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
135
+ fields: BitArrayBindingField<BitArrayItem<BitPathValue<TForm, P>>>[];
136
+ length: number;
133
137
  append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
134
138
  prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
135
139
  insert: (index: number, value: BitArrayItem<BitPathValue<TForm, P>>) => void;
@@ -138,12 +142,6 @@ declare function useBitArray<TForm extends object = any, P extends BitArrayPath<
138
142
  swap: (indexA: number, indexB: number) => void;
139
143
  replace: (items: BitArrayItem<BitPathValue<TForm, P>>[]) => void;
140
144
  clear: () => void;
141
- fields: {
142
- key: string;
143
- value: BitArrayItem<BitPathValue<TForm, P>>;
144
- index: number;
145
- }[];
146
- length: number;
147
145
  };
148
146
 
149
147
  declare function useBitScope(scopeName: string): {
@@ -1,14 +1,15 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { e as BitStoreApi, f as BitStoreHooksApi, c as BitHistoryMetadata, d as BitValidationOptions } from './public-types-Cd9ai20P.cjs';
4
- import { f as BitPath, g as BitPathValue, j as BitPersistMetadata, S as ScopeStatus, n as ValidateScopeResult, i as BitErrors, H as BitTouched, h as DeepPartial, k as BitArrayPath, l as BitArrayItem } from './bus-BeAeZwWu.cjs';
5
- import { B as BitFieldInputEvent } from './field-binding-BXw0Ku2c.cjs';
3
+ import { a as BitStoreHooksApi, b as BitFormBindingApi, c as BitHistoryMetadata, d as BitValidationOptions } from './store-api-types-B6_bPoVI.cjs';
4
+ import { e as BitPath, b as BitPathValue, i as BitPersistMetadata, S as ScopeStatus, V as ValidateScopeResult, c as BitErrors, r as BitTouched, D as DeepPartial, B as BitArrayPath, a as BitArrayItem } from './bus-rcUiufS7.cjs';
5
+ import { B as BitArrayBindingField } from './array-controller-C1A5VKYd.cjs';
6
+ import { B as BitFieldInputEvent } from './field-binding-X5TkvfUt.cjs';
6
7
 
7
8
  declare const BitFormProvider: ({ store, children, }: {
8
- store: BitStoreApi<any>;
9
+ store: BitStoreHooksApi<any>;
9
10
  children: React.ReactNode;
10
11
  }) => react_jsx_runtime.JSX.Element;
11
- declare const useBitStore: <T extends object>() => BitStoreHooksApi<T>;
12
+ declare const useBitStore: <T extends object>() => BitFormBindingApi<T>;
12
13
 
13
14
  /**
14
15
  * Metadata describing the current state of a form field.
@@ -118,9 +119,10 @@ interface UseBitFormResult<T extends object = any> {
118
119
  transaction: <TResult>(callback: () => TResult) => TResult;
119
120
  setField: <P extends BitPath<T>>(path: P, value: BitPathValue<T, P>) => void;
120
121
  blurField: <P extends BitPath<T>>(path: P) => void;
121
- replaceValues: (values: T) => void;
122
- hydrate: (values: DeepPartial<T>) => void;
123
- rebase: (values: T) => void;
122
+ setValues: (values: T | DeepPartial<T>, options?: {
123
+ partial?: boolean;
124
+ rebase?: boolean;
125
+ }) => void;
124
126
  setError: (path: string, message: string | undefined) => void;
125
127
  setErrors: (errors: BitErrors<T>) => void;
126
128
  setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
@@ -130,6 +132,8 @@ interface UseBitFormResult<T extends object = any> {
130
132
  declare function useBitForm<T extends object>(): UseBitFormResult<T>;
131
133
 
132
134
  declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
135
+ fields: BitArrayBindingField<BitArrayItem<BitPathValue<TForm, P>>>[];
136
+ length: number;
133
137
  append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
134
138
  prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
135
139
  insert: (index: number, value: BitArrayItem<BitPathValue<TForm, P>>) => void;
@@ -138,12 +142,6 @@ declare function useBitArray<TForm extends object = any, P extends BitArrayPath<
138
142
  swap: (indexA: number, indexB: number) => void;
139
143
  replace: (items: BitArrayItem<BitPathValue<TForm, P>>[]) => void;
140
144
  clear: () => void;
141
- fields: {
142
- key: string;
143
- value: BitArrayItem<BitPathValue<TForm, P>>;
144
- index: number;
145
- }[];
146
- length: number;
147
145
  };
148
146
 
149
147
  declare function useBitScope(scopeName: string): {
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkVQ7MK5VBcjs = require('../chunk-VQ7MK5VB.cjs');var _chunkY2ONHDREcjs = require('../chunk-Y2ONHDRE.cjs');var _chunkYCSWULENcjs = require('../chunk-YCSWULEN.cjs');require('../chunk-PFPGASVZ.cjs');var _vue = require('vue');var W=Symbol("BIT_STORE");function X(t){_vue.provide.call(void 0, W,_chunkYCSWULENcjs.k.call(void 0, t))}function c(){let t=_vue.inject.call(void 0, W);if(!t)throw new Error("BitForm Vue hooks devem ser usados sob um provideBitStore");return t}function ee(){let t=c(),e=_vue.shallowRef.call(void 0, {isValid:t.getState().isValid,isSubmitting:t.getState().isSubmitting,isDirty:t.getState().isDirty}),i=_vue.ref.call(void 0, null),s=_vue.ref.call(void 0, null),o=t.subscribeSelector(p=>({isValid:p.isValid,isSubmitting:p.isSubmitting,isDirty:p.isDirty}),p=>{e.value=p},{paths:["isValid","isSubmitting","isDirty"]});_vue.onUnmounted.call(void 0, o);let u=_chunkY2ONHDREcjs.b.call(void 0, t,{clearSubmissionState:()=>{i.value=null,s.value=null},setSubmissionResult:p=>{s.value=p},setSubmissionError:p=>{i.value=p}}),n=_chunkY2ONHDREcjs.a.call(void 0, t),d=_vue.computed.call(void 0, ()=>e.value.isValid),S=_vue.computed.call(void 0, ()=>e.value.isSubmitting),f=_vue.computed.call(void 0, ()=>e.value.isDirty),r=u.onSubmit,a=u.reset;return{meta:{isValid:d,isDirty:f,isSubmitting:S,submitError:i,lastResponse:s},getValues:u.getValues,getErrors:u.getErrors,getTouched:u.getTouched,getDirtyValues:u.getDirtyValues,submit:u.submit,onSubmit:r,reset:a,...n}}function E(t){let e=c(),i=e.resolveMask(t),s=_chunkY2ONHDREcjs.d.call(void 0, e,t,i),o=_vue.shallowRef.call(void 0, e.getFieldState(t)),u=_chunkY2ONHDREcjs.c.call(void 0, e,t,B=>{o.value=B});_vue.onUnmounted.call(void 0, ()=>{u(),e.unregisterField&&e.unregisterField(t)});let n=_vue.computed.call(void 0, ()=>o.value.value),d=_vue.computed.call(void 0, ()=>s.displayValue(n.value)),S=_vue.computed.call(void 0, {get:()=>d.value,set:B=>{s.setValue(B)}}),f=_vue.computed.call(void 0, ()=>o.value.error),r=_vue.computed.call(void 0, ()=>o.value.touched?o.value.error:void 0),a=_vue.computed.call(void 0, ()=>o.value.touched),l=_vue.computed.call(void 0, ()=>!!(a.value&&r.value)),p=_vue.computed.call(void 0, ()=>o.value.isValidating),b=_vue.computed.call(void 0, ()=>o.value.isDirty),P=_vue.computed.call(void 0, ()=>o.value.isHidden),h=_vue.computed.call(void 0, ()=>o.value.isRequired),R=_vue.computed.call(void 0, ()=>!!f.value),m=B=>{s.setValue(B)},g=()=>s.setBlur();return{value:n,displayValue:d,modelValue:S,setValue:m,setBlur:g,onInput:B=>{m(B)},onBlur:()=>{g()},meta:{error:r,touched:a,invalid:l,isValidating:p,isDirty:b,isHidden:P,isRequired:h,hasError:R}}}function se(t){let e=c(),i=r=>e.config.idFactory({scope:"array",path:t,index:r}),o=(()=>{let r=_chunkYCSWULENcjs.e.call(void 0, e.getState().values,t);return Array.isArray(r)?r:[]})(),u=_vue.ref.call(void 0, o),n=_vue.ref.call(void 0, o.map((r,a)=>i(a))),d=e.subscribePath(t,r=>{let a=Array.isArray(r)?r:[];if(u.value=[...a],a.length!==n.value.length){let l=[...n.value];if(a.length>l.length){let p=a.length-l.length,b=Array.from({length:p},(P,h)=>i(l.length+h));n.value=[...l,...b]}else n.value=l.slice(0,a.length)}});_vue.onUnmounted.call(void 0, ()=>{d(),e.unregisterPrefix&&e.unregisterPrefix(`${t}.`)});let S=_vue.computed.call(void 0, ()=>u.value.map((r,a)=>({key:n.value[a]||`temp-${a}`,value:r,index:a}))),f=_vue.computed.call(void 0, ()=>u.value.length);return{fields:S,length:f,append:r=>{n.value.push(i(n.value.length)),e.pushItem(t,r)},prepend:r=>{n.value.unshift(i(0)),e.prependItem(t,r)},insert:(r,a)=>{n.value.splice(r,0,i(r)),e.insertItem(t,r,a)},remove:r=>{n.value.splice(r,1),e.removeItem(t,r)},move:(r,a)=>{let l=[...n.value],[p]=l.splice(r,1);l.splice(a,0,p),n.value=l,e.moveItem(t,r,a)},swap:(r,a)=>{let l=[...n.value];[l[r],l[a]]=[l[a],l[r]],n.value=l,e.swapItems(t,r,a)},replace:r=>{n.value=r.map((a,l)=>i(l)),e.setField(t,r)},clear:()=>{n.value=[],e.setField(t,[])}}}function ae(){let t=c(),e=_vue.shallowRef.call(void 0, t.getHistoryMetadata()),i=t.subscribe(()=>{let u=t.getHistoryMetadata();_chunkVQ7MK5VBcjs.a.call(void 0, e.value,u)||(e.value=u)});_vue.onUnmounted.call(void 0, i);let s=()=>t.undo(),o=()=>t.redo();return{canUndo:_vue.computed.call(void 0, ()=>e.value.canUndo),canRedo:_vue.computed.call(void 0, ()=>e.value.canRedo),historyIndex:_vue.computed.call(void 0, ()=>e.value.historyIndex),historySize:_vue.computed.call(void 0, ()=>e.value.historySize),undo:s,redo:o}}function me(t){let e=c(),i=e.getScopeFields(t),s=_vue.ref.call(void 0, e.getStepStatus(t)),o;_vue.onMounted.call(void 0, ()=>{o=e.subscribeSelector(r=>({errors:r.errors,isDirty:r.isDirty}),()=>{let r=e.getStepStatus(t);_chunkY2ONHDREcjs.e.call(void 0, s.value,r)||(s.value=r)},{paths:_chunkY2ONHDREcjs.f.call(void 0, i)})}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([o, 'optionalCall', _2 => _2()])});let u=async()=>{let r=await e.validate({scope:t}),a=e.getStepErrors(t);return{valid:r,errors:a}},n=()=>e.getStepErrors(t),d=_vue.computed.call(void 0, ()=>!s.value.hasErrors),S=_vue.computed.call(void 0, ()=>s.value.isDirty),f=_vue.computed.call(void 0, ()=>s.value.errors);return{scopeName:t,status:s,errors:f,validate:u,getErrors:n,isValid:d,isDirty:S}}function Se(t){let e=c(),i=_vue.ref.call(void 0, 0),s=_vue.computed.call(void 0, ()=>_nullishCoalesce(t[i.value], () => (""))),o=_vue.ref.call(void 0, e.getStepStatus(s.value)),u;_vue.watch.call(void 0, s,m=>{o.value=e.getStepStatus(m)});let n=()=>{let m=s.value,g=e.getStepStatus(m);_chunkY2ONHDREcjs.e.call(void 0, o.value,g)||(o.value=g)};_vue.onMounted.call(void 0, ()=>{u=e.subscribeSelector(m=>({errors:m.errors,isDirty:m.isDirty}),n,{paths:_chunkY2ONHDREcjs.f.call(void 0, e.getScopeFields(s.value))})}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([u, 'optionalCall', _3 => _3()])});let d=async()=>{let m=s.value,g=await e.validate({scope:m}),F=e.getStepErrors(m);return{valid:g,errors:F}},S=()=>e.getStepErrors(s.value),f=async()=>{let m=s.value,g=e.getScopeFields(m);if(e.hasValidationsInProgress(g))return!1;let F=await e.validate({scope:m});if(F)i.value=Math.min(i.value+1,t.length-1);else{let k=e.getStepErrors(m),B=Object.keys(k);B.length>0&&e.markFieldsTouched(B)}return F},r=()=>{i.value=Math.max(i.value-1,0)},a=m=>{i.value=Math.max(0,Math.min(m-1,t.length-1))},l=_vue.computed.call(void 0, ()=>i.value+1),p=_vue.computed.call(void 0, ()=>i.value===0),b=_vue.computed.call(void 0, ()=>i.value>=t.length-1),P=_vue.computed.call(void 0, ()=>!o.value.hasErrors),h=_vue.computed.call(void 0, ()=>o.value.isDirty),R=_vue.computed.call(void 0, ()=>o.value.errors);return{step:l,stepIndex:i,scope:s,next:f,prev:r,goTo:a,isFirst:p,isLast:b,status:o,errors:R,isValid:P,isDirty:h,validate:d,getErrors:S}}function ye(t){let e=c(),i=_chunkYCSWULENcjs.e.call(void 0, e.getState().values,t),s=_vue.ref.call(void 0, i),o=e.watch(t,u=>{_chunkYCSWULENcjs.d.call(void 0, s.value,u)||(s.value=u)});return _vue.onUnmounted.call(void 0, o),_vue.readonly.call(void 0, s)}function he(t,e,i){let s=c(),o=E(t),u=null,n=_vue.ref.call(void 0, !1),d={setLoading:r=>{n.value=r},setError:(r,a)=>s.setError(r,a),setValue:r=>o.setValue(r),getUploadKey:()=>u,setUploadKey:r=>{u=r}},S=_chunkVQ7MK5VBcjs.b.call(void 0, t,e,d),f=_chunkVQ7MK5VBcjs.c.call(void 0, t,i,d);return{value:o.value,setValue:o.setValue,error:_vue.computed.call(void 0, ()=>o.meta.error.value),isValidating:_vue.computed.call(void 0, ()=>!!o.meta.isValidating.value||n.value),upload:S,remove:f}}function Ve(){let t=c(),e=_vue.ref.call(void 0, t.getPersistMetadata()),i=t.subscribeSelector(n=>n.persist,n=>{e.value=n},{paths:["persist"]});return _vue.onUnmounted.call(void 0, ()=>i()),{restore:async()=>t.restorePersisted(),save:async()=>{await t.forceSave()},clear:async()=>{await t.clearPersisted()},meta:{isSaving:_vue.computed.call(void 0, ()=>e.value.isSaving),isRestoring:_vue.computed.call(void 0, ()=>e.value.isRestoring),error:_vue.computed.call(void 0, ()=>e.value.error)}}}exports.provideBitStore = X; exports.useBitArray = se; exports.useBitField = E; exports.useBitForm = ee; exports.useBitHistory = ae; exports.useBitPersist = Ve; exports.useBitScope = me; exports.useBitSteps = Se; exports.useBitStore = c; exports.useBitUpload = he; exports.useBitWatch = ye;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkIV32WXCFcjs = require('../chunk-IV32WXCF.cjs');var _chunkFUUQB4DVcjs = require('../chunk-FUUQB4DV.cjs');require('../chunk-PFPGASVZ.cjs');var _vue = require('vue');var J=Symbol("BIT_STORE");function oe(t){_vue.provide.call(void 0, J,_chunkFUUQB4DVcjs.s.call(void 0, t))}function n(){let t=_vue.inject.call(void 0, J);if(!t)throw new Error("BitForm Vue hooks devem ser usados sob um provideBitStore");return t}function ie(){let t=n(),e=_vue.shallowRef.call(void 0, {isValid:!0,isDirty:!1,isSubmitting:!1}),o=_vue.ref.call(void 0, null),r=_vue.ref.call(void 0, null),i=_chunkFUUQB4DVcjs.y.call(void 0, t,v=>{e.value=v});_vue.onUnmounted.call(void 0, i);let{controller:s,actions:a}=_chunkFUUQB4DVcjs.C.call(void 0, t,{clearSubmissionState:()=>{o.value=null,r.value=null},setSubmissionResult:v=>{r.value=v},setSubmissionError:v=>{o.value=v}}),d=_vue.computed.call(void 0, ()=>e.value.isValid),u=_vue.computed.call(void 0, ()=>e.value.isSubmitting),p=_vue.computed.call(void 0, ()=>e.value.isDirty),c=s.onSubmit,B=s.reset;return{meta:{isValid:d,isDirty:p,isSubmitting:u,submitError:o,lastResponse:r},getValues:s.getValues,getErrors:s.getErrors,getTouched:s.getTouched,getDirtyValues:s.getDirtyValues,submit:s.submit,onSubmit:c,reset:B,...a}}function U(t){let e=n(),{fieldController:o}=_chunkFUUQB4DVcjs.E.call(void 0, e,t),r=_vue.shallowRef.call(void 0, e.getFieldState(t)),i=_chunkFUUQB4DVcjs.D.call(void 0, e,t,f=>{r.value=f});_vue.onUnmounted.call(void 0, ()=>{i(),_chunkFUUQB4DVcjs.G.call(void 0, e,t)});let s=_vue.computed.call(void 0, ()=>r.value.value),a=_vue.computed.call(void 0, ()=>o.displayValue(s.value)),d=_vue.computed.call(void 0, {get:()=>a.value,set:f=>{o.setValue(f)}}),u=_vue.computed.call(void 0, ()=>_chunkFUUQB4DVcjs.I.call(void 0, r.value)),p=_vue.computed.call(void 0, ()=>u.value.error),c=_vue.computed.call(void 0, ()=>u.value.touched),B=_vue.computed.call(void 0, ()=>u.value.invalid),b=_vue.computed.call(void 0, ()=>u.value.isValidating),v=_vue.computed.call(void 0, ()=>u.value.isDirty),P=_vue.computed.call(void 0, ()=>u.value.isHidden),V=_vue.computed.call(void 0, ()=>u.value.isRequired),x=_vue.computed.call(void 0, ()=>u.value.hasError),F=f=>{o.setValue(f)},l=()=>o.setBlur();return{value:s,displayValue:a,modelValue:d,setValue:F,setBlur:l,onInput:f=>{F(f)},onBlur:()=>{l()},meta:{error:p,touched:c,invalid:B,isValidating:b,isDirty:v,isHidden:P,isRequired:V,hasError:x}}}function ce(t){let e=n(),o=_chunkFUUQB4DVcjs.F.call(void 0, e,t),r=_vue.shallowRef.call(void 0, o.readItems()),i=e.subscribePath(t,()=>{r.value=o.readItems()});_vue.onUnmounted.call(void 0, ()=>{i(),_chunkFUUQB4DVcjs.H.call(void 0, e,`${t}.`)});let s=_vue.computed.call(void 0, ()=>o.getFields(r.value)),a=_vue.computed.call(void 0, ()=>r.value.length);return{fields:s,length:a,append:o.append,prepend:o.prepend,insert:o.insert,remove:o.remove,move:o.move,swap:o.swap,replace:o.replace,clear:o.clear}}function de(){let t=n(),e=_vue.shallowRef.call(void 0, _chunkFUUQB4DVcjs.m.call(void 0, t)),o=_chunkFUUQB4DVcjs.n.call(void 0, t,s=>{e.value=s});_vue.onUnmounted.call(void 0, o);let r=()=>t.undo(),i=()=>t.redo();return{canUndo:_vue.computed.call(void 0, ()=>e.value.canUndo),canRedo:_vue.computed.call(void 0, ()=>e.value.canRedo),historyIndex:_vue.computed.call(void 0, ()=>e.value.historyIndex),historySize:_vue.computed.call(void 0, ()=>e.value.historySize),undo:r,redo:i}}function Se(t){let e=n(),o=_vue.ref.call(void 0, e.getStepStatus(t)),r;_vue.onMounted.call(void 0, ()=>{r=_chunkFUUQB4DVcjs.r.call(void 0, e,t,p=>{o.value=p})}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([r, 'optionalCall', _2 => _2()])});let i=async()=>{let p=await e.validate({scope:t}),c=e.getStepErrors(t);return{valid:p,errors:c}},s=()=>e.getStepErrors(t),a=_vue.computed.call(void 0, ()=>!o.value.hasErrors),d=_vue.computed.call(void 0, ()=>o.value.isDirty),u=_vue.computed.call(void 0, ()=>o.value.errors);return{scopeName:t,status:o,errors:u,validate:i,getErrors:s,isValid:a,isDirty:d}}function Fe(t){let e=n(),o=_vue.ref.call(void 0, 0),r=_vue.computed.call(void 0, ()=>_nullishCoalesce(t[o.value], () => (""))),i=_vue.ref.call(void 0, e.getStepStatus(r.value)),s;_vue.watch.call(void 0, r,l=>{i.value=e.getStepStatus(l),_optionalChain([s, 'optionalCall', _3 => _3()]),s=e.subscribeScopeStatus(l,a)});let a=()=>{let l=r.value,S=e.getStepStatus(l);_chunkFUUQB4DVcjs.p.call(void 0, i.value,S)||(i.value=S)};_vue.onMounted.call(void 0, ()=>{s=e.subscribeScopeStatus(r.value,a)}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([s, 'optionalCall', _4 => _4()])});let d=async()=>{let l=r.value,S=await e.validate({scope:l}),y=e.getStepErrors(l);return{valid:S,errors:y}},u=()=>e.getStepErrors(r.value),p=async()=>{let l=r.value,S=e.getScopeFields(l);if(e.hasValidationsInProgress(S))return!1;let y=await e.validate({scope:l});if(y)o.value=Math.min(o.value+1,t.length-1);else{let f=e.getStepErrors(l),w=Object.keys(f);w.length>0&&e.markFieldsTouched(w)}return y},c=()=>{o.value=Math.max(o.value-1,0)},B=l=>{o.value=Math.max(0,Math.min(l-1,t.length-1))},b=_vue.computed.call(void 0, ()=>o.value+1),v=_vue.computed.call(void 0, ()=>o.value===0),P=_vue.computed.call(void 0, ()=>o.value>=t.length-1),V=_vue.computed.call(void 0, ()=>!i.value.hasErrors),x=_vue.computed.call(void 0, ()=>i.value.isDirty),F=_vue.computed.call(void 0, ()=>i.value.errors);return{step:b,stepIndex:o,scope:r,next:p,prev:c,goTo:B,isFirst:v,isLast:P,status:i,errors:F,isValid:V,isDirty:x,validate:d,getErrors:u}}function xe(t){let e=n(),o=_chunkFUUQB4DVcjs.e.call(void 0, e.getState().values,t),r=_vue.ref.call(void 0, o),i=e.subscribePath(t,s=>{_chunkFUUQB4DVcjs.c.call(void 0, r.value,s)||(r.value=s)});return _vue.onUnmounted.call(void 0, i),_vue.readonly.call(void 0, r)}function Ue(t,e,o){let r=n(),i=U(t),s=null,a=_vue.ref.call(void 0, !1),d={setLoading:c=>{a.value=c},setError:(c,B)=>r.setError(c,B),setValue:c=>i.setValue(c),getUploadKey:()=>s,setUploadKey:c=>{s=c}},u=_chunkIV32WXCFcjs.a.call(void 0, t,e,d),p=_chunkIV32WXCFcjs.b.call(void 0, t,o,d);return{value:i.value,setValue:i.setValue,error:_vue.computed.call(void 0, ()=>i.meta.error.value),isValidating:_vue.computed.call(void 0, ()=>!!i.meta.isValidating.value||a.value),upload:u,remove:p}}function we(){let t=n(),e=_vue.ref.call(void 0, t.getPersistMetadata()),o=_chunkFUUQB4DVcjs.B.call(void 0, t,a=>{e.value=a});return _vue.onUnmounted.call(void 0, ()=>o()),{restore:async()=>t.restorePersisted(),save:async()=>{await t.forceSave()},clear:async()=>{await t.clearPersisted()},meta:{isSaving:_vue.computed.call(void 0, ()=>e.value.isSaving),isRestoring:_vue.computed.call(void 0, ()=>e.value.isRestoring),error:_vue.computed.call(void 0, ()=>e.value.error)}}}exports.provideBitStore = oe; exports.useBitArray = ce; exports.useBitField = U; exports.useBitForm = ie; exports.useBitHistory = de; exports.useBitPersist = we; exports.useBitScope = Se; exports.useBitSteps = Fe; exports.useBitStore = n; exports.useBitUpload = Ue; exports.useBitWatch = xe;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/vue/index.cjs","../../src/vue/context.ts","../../src/vue/use-bit-form.ts","../../src/vue/use-bit-field.ts","../../src/vue/use-bit-array.ts"],"names":["BIT_STORE_KEY","provideBitStore","store","provide","resolveBitStoreForHooks","useBitStore","inject","useBitForm","state","shallowRef","submitError","ref","lastResponse","unsubscribe","snapshot","nextState","onUnmounted","controller","createFormController","result","error","actions","createStoreFormActions","isValid","computed","isSubmitting","isDirty","onSubmit","reset","useBitField","path","resolvedMask","fieldController","createMaskedFieldController","subscribeFieldState","rawValue","displayValue","modelValue","val","rawError","touched","invalid","isValidating","isHidden","isRequired","hasError","setValue","setBlur","useBitArray","createId","index","initialValues","getDeepValue","values","ids","_","newValues","nextValues","currentIds","diff","newIds","i"],"mappings":"AAAA,0uBAAuD,yDAA6E,yDAAwD,iCAA8B,0BCA5K,IAKjCA,CAAAA,CACX,MAAA,CAAO,WAAW,CAAA,CAEb,SAASC,CAAAA,CAAkCC,C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AA,CAAI,KAAA,CAAQ,CAAC,GAAGI,CAAAA,CAAY,GAAGE,CAAM,CACvC,CAAA,KACEN,CAAAA,CAAI,KAAA,CAAQI,CAAAA,CAAW,KAAA,CAAM,CAAA,CAAGD,CAAAA,CAAW,MAAM,CAErD,CACF,CAAC,CAAA,CAEDzC,8BAAAA,CAAY,CAAA,EAAM,CAChBH,CAAAA,CAAY,CAAA,CACRX,CAAAA,CAAM,gBAAA,EACRA,CAAAA,CAAM,gBAAA,CAAiB,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/vue/index.cjs","sourcesContent":[null,"import { inject, provide, InjectionKey } from \"vue\";\nimport type { BitStoreApi, BitStoreHooksApi } from \"../core\";\nimport { resolveBitStoreForHooks } from \"../core\";\n\n// Chave única para evitar colisões\nexport const BIT_STORE_KEY: InjectionKey<BitStoreHooksApi<any>> =\n Symbol(\"BIT_STORE\");\n\nexport function provideBitStore<T extends object>(store: BitStoreApi<T>) {\n provide(BIT_STORE_KEY, resolveBitStoreForHooks(store));\n}\n\nexport function useBitStore<T extends object>() {\n const store = inject(BIT_STORE_KEY);\n if (!store)\n throw new Error(\n \"BitForm Vue hooks devem ser usados sob um provideBitStore\",\n );\n return store as BitStoreHooksApi<T>;\n}\n","import { computed, onUnmounted, shallowRef, ref } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport {\n createFormController,\n createStoreFormActions,\n} from \"../core/form-controller\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n const state = shallowRef({\n isValid: store.getState().isValid,\n isSubmitting: store.getState().isSubmitting,\n isDirty: store.getState().isDirty,\n });\n const submitError = ref<Error | null>(null);\n const lastResponse = ref<unknown>(null);\n\n const unsubscribe = store.subscribeSelector(\n (snapshot) => ({\n isValid: snapshot.isValid,\n isSubmitting: snapshot.isSubmitting,\n isDirty: snapshot.isDirty,\n }),\n (nextState) => {\n state.value = nextState;\n },\n { paths: [\"isValid\", \"isSubmitting\", \"isDirty\"] },\n );\n\n onUnmounted(unsubscribe);\n\n const controller = createFormController(store, {\n clearSubmissionState: () => {\n submitError.value = null;\n lastResponse.value = null;\n },\n setSubmissionResult: (result) => {\n lastResponse.value = result;\n },\n setSubmissionError: (error) => {\n submitError.value = error;\n },\n });\n const actions = createStoreFormActions(store);\n\n const isValid = computed(() => state.value.isValid);\n const isSubmitting = computed(() => state.value.isSubmitting);\n const isDirty = computed(() => state.value.isDirty);\n\n const onSubmit = controller.onSubmit;\n const reset = controller.reset;\n\n const meta = {\n isValid,\n isDirty,\n isSubmitting,\n submitError,\n lastResponse,\n };\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues: controller.getValues,\n getErrors: controller.getErrors,\n getTouched: controller.getTouched,\n getDirtyValues: controller.getDirtyValues,\n // Main actions (frequent use - flat)\n submit: controller.submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitFieldVueResult } from \"./types\";\nimport type { BitPath, BitPathValue } from \"../core\";\nimport {\n createMaskedFieldController,\n subscribeFieldState,\n} from \"../core/field-controller\";\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): UseBitFieldVueResult<BitPathValue<TForm, P>> {\n const store = useBitStore<TForm>();\n\n const resolvedMask = store.resolveMask(path);\n const fieldController = createMaskedFieldController(\n store,\n path,\n resolvedMask,\n );\n\n const state = shallowRef(store.getFieldState(path));\n\n const unsubscribe = subscribeFieldState(store, path, (nextState) => {\n state.value = nextState;\n });\n\n onUnmounted(() => {\n unsubscribe();\n if (store.unregisterField) {\n store.unregisterField(path);\n }\n });\n\n const rawValue = computed(() => state.value.value as BitPathValue<TForm, P>);\n\n const displayValue = computed(() =>\n fieldController.displayValue(rawValue.value),\n );\n\n const modelValue = computed({\n get: () => displayValue.value,\n set: (val: string) => {\n fieldController.setValue(val);\n },\n });\n\n const rawError = computed(() => state.value.error);\n const error = computed(() =>\n state.value.touched ? state.value.error : undefined,\n );\n const touched = computed(() => state.value.touched);\n const invalid = computed(() => !!(touched.value && error.value));\n\n const isValidating = computed(() => state.value.isValidating);\n\n const isDirty = computed(() => state.value.isDirty);\n\n const isHidden = computed(() => state.value.isHidden);\n\n const isRequired = computed(() => state.value.isRequired);\n\n const hasError = computed(() => !!rawError.value);\n\n const setValue = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n fieldController.setValue(val);\n };\n\n const setBlur = () => fieldController.setBlur();\n\n const onInput = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n setValue(val);\n };\n\n const onBlur = () => {\n setBlur();\n };\n\n return {\n // Main handlers and values (flat)\n value: rawValue,\n displayValue,\n modelValue,\n setValue,\n setBlur,\n onInput,\n onBlur,\n // Metadata (grouped)\n meta: {\n error,\n touched,\n invalid,\n isValidating,\n isDirty,\n isHidden,\n isRequired,\n hasError,\n },\n };\n}\n","import { ref, computed, onUnmounted } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport {\n getDeepValue,\n BitArrayPath,\n BitPathValue,\n BitArrayItem,\n BitPath,\n} from \"../core\";\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n\n const createId = (index?: number) =>\n store.config.idFactory({\n scope: \"array\",\n path: path as string,\n index,\n });\n\n type Item = BitArrayItem<BitPathValue<TForm, P>>;\n\n const getSnapshot = (): Item[] => {\n const val = getDeepValue(store.getState().values, path as string) as\n | BitPathValue<TForm, P>\n | undefined;\n return Array.isArray(val) ? (val as Item[]) : [];\n };\n\n const initialValues = getSnapshot();\n const values = ref<Item[]>(initialValues);\n const ids = ref<string[]>(initialValues.map((_, index) => createId(index)));\n\n const unsubscribe = store.subscribePath(path, (newValues) => {\n const nextValues = (Array.isArray(newValues) ? newValues : []) as Item[];\n\n values.value = [...nextValues];\n\n if (nextValues.length !== ids.value.length) {\n const currentIds = [...ids.value];\n if (nextValues.length > currentIds.length) {\n const diff = nextValues.length - currentIds.length;\n const newIds = Array.from({ length: diff }, (_, i) =>\n createId(currentIds.length + i),\n );\n ids.value = [...currentIds, ...newIds];\n } else {\n ids.value = currentIds.slice(0, nextValues.length);\n }\n }\n });\n\n onUnmounted(() => {\n unsubscribe();\n if (store.unregisterPrefix) {\n store.unregisterPrefix(`${path as string}.`);\n }\n });\n\n const fields = computed(() =>\n values.value.map((v, i) => ({\n key: ids.value[i] || `temp-${i}`,\n value: v,\n index: i,\n })),\n );\n\n const length = computed(() => values.value.length);\n\n return {\n fields,\n length,\n append: (val: Item) => {\n ids.value.push(createId(ids.value.length));\n store.pushItem(path, val);\n },\n prepend: (val: Item) => {\n ids.value.unshift(createId(0));\n store.prependItem(path, val);\n },\n insert: (index: number, val: Item) => {\n ids.value.splice(index, 0, createId(index));\n store.insertItem(path, index, val);\n },\n remove: (index: number) => {\n ids.value.splice(index, 1);\n store.removeItem(path, index);\n },\n move: (from: number, to: number) => {\n const currentIds = [...ids.value];\n const [id] = currentIds.splice(from, 1);\n currentIds.splice(to, 0, id);\n ids.value = currentIds;\n store.moveItem(path, from, to);\n },\n swap: (a: number, b: number) => {\n const currentIds = [...ids.value];\n [currentIds[a], currentIds[b]] = [currentIds[b], currentIds[a]];\n ids.value = currentIds;\n store.swapItems(path, a, b);\n },\n replace: (items: Item[]) => {\n ids.value = items.map((_, index) => createId(index));\n store.setField(\n path as unknown as BitPath<TForm>,\n items as unknown as BitPathValue<TForm, BitPath<TForm>>,\n );\n },\n clear: () => {\n ids.value = [];\n store.setField(\n path as unknown as BitPath<TForm>,\n [] as unknown as BitPathValue<TForm, BitPath<TForm>>,\n );\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/vue/index.cjs","../../src/vue/context.ts","../../src/vue/use-bit-form.ts","../../src/vue/use-bit-field.ts","../../src/vue/use-bit-array.ts"],"names":["BIT_STORE_KEY","provideBitStore","store","provide","resolveBitStoreForHooks","useBitStore","inject","useBitForm","state","shallowRef","submitError","ref","lastResponse","unsubscribe","observeFormMetaSnapshot","nextMeta","onUnmounted","controller","actions","createFrameworkFormBinding","result","error","isValid","computed","isSubmitting","isDirty","onSubmit","reset","useBitField","path","fieldController","createFrameworkMaskedFieldBinding","subscribeFieldState","nextState","cleanupRegisteredField","rawValue","displayValue","modelValue","val","metaState","deriveFieldMeta","touched","invalid","isValidating","isHidden","isRequired","hasError","setValue","setBlur","useBitArray","createArrayBindingController","values","cleanupRegisteredPrefix"],"mappings":"AAAA,0uBAAgD,yDAAmJ,iCAA8B,0BCAnL,IAKjCA,CAAAA,CACX,MAAA,CAAO,WAAW,CAAA,CAEb,SAASC,EAAAA,CAAkCC,CAAAA,CAA4B,CAC5EC,0BAAAA,CAAQH,CAAeI,iCAAAA,CAA6B,CAAC,CACvD,CAEO,SAASC,CAAAA,CAAAA,CAAgC,CAC9C,IAAMH,CAAAA,CAAQI,yBAAAA,CAAoB,CAAA,CAClC,EAAA,CAAI,CAACJ,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,2DACF,CAAA,CACF,OAAOA,CACT,CCnBA,SAKgBK,EAAAA,CAAAA,CAAoD,CAClE,IAAML,CAAAA,CAAQG,CAAAA,CAAe,CAAA,CACvBG,CAAAA,CAAQC,6BAAAA,CACZ,OAAA,CAAS,CAAA,CAAA,CACT,OAAA,CAAS,CAAA,CAAA,CACT,YAAA,CAAc,CAAA,CAChB,CAAC,CAAA,CACKC,CAAAA,CAAcC,sBAAAA,IAAsB,CAAA,CACpCC,CAAAA,CAAeD,sBAAAA,IAAiB,CAAA,CAEhCE,CAAAA,CAAcC,iCAAAA,CAAwBZ,CAAQa,CAAAA,EAAa,CAC/DP,CAAAA,CAAM,KAAA,CAAQO,CAChB,CAAC,CAAA,CAEDC,8BAAAA,CAAuB,CAAA,CAEvB,GAAM,CAAE,UAAA,CAAAC,CAAAA,CAA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AAAA,CAAWQ,CAAW,SAAA,CAAU,CAAC,CAAA,CAE1CJ,CAAAA,CAAcX,CAAAA,CAAM,aAAA,CAAc2B,CAAAA,CAAM,CAAA,CAAA,EAAM,CAClDsB,CAAAA,CAAO,KAAA,CAAQlC,CAAAA,CAAW,SAAA,CAAU,CACtC,CAAC,CAAA,CAEDD,8BAAAA,CAAY,CAAA,EAAM,CAChBH,CAAAA,CAAY,CAAA,CACZuC,iCAAAA,CAAwBlD,CAAO,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/vue/index.cjs","sourcesContent":[null,"import { inject, provide, InjectionKey } from \"vue\";\nimport type { BitFormBindingApi, BitStoreHooksApi } from \"../core\";\nimport { resolveBitStoreForHooks } from \"../core\";\n\n// Chave única para evitar colisões\nexport const BIT_STORE_KEY: InjectionKey<BitFormBindingApi<any>> =\n Symbol(\"BIT_STORE\");\n\nexport function provideBitStore<T extends object>(store: BitStoreHooksApi<T>) {\n provide(BIT_STORE_KEY, resolveBitStoreForHooks(store));\n}\n\nexport function useBitStore<T extends object>() {\n const store = inject(BIT_STORE_KEY);\n if (!store)\n throw new Error(\n \"BitForm Vue hooks devem ser usados sob um provideBitStore\",\n );\n return store as BitFormBindingApi<T>;\n}\n","import { computed, onUnmounted, shallowRef, ref } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { createFrameworkFormBinding, observeFormMetaSnapshot } from \"../core\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n const state = shallowRef({\n isValid: true,\n isDirty: false,\n isSubmitting: false,\n });\n const submitError = ref<Error | null>(null);\n const lastResponse = ref<unknown>(null);\n\n const unsubscribe = observeFormMetaSnapshot(store, (nextMeta) => {\n state.value = nextMeta;\n });\n\n onUnmounted(unsubscribe);\n\n const { controller, actions } = createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n submitError.value = null;\n lastResponse.value = null;\n },\n setSubmissionResult: (result) => {\n lastResponse.value = result;\n },\n setSubmissionError: (error) => {\n submitError.value = error;\n },\n });\n\n const isValid = computed(() => state.value.isValid);\n const isSubmitting = computed(() => state.value.isSubmitting);\n const isDirty = computed(() => state.value.isDirty);\n\n const onSubmit = controller.onSubmit;\n const reset = controller.reset;\n\n const meta = {\n isValid,\n isDirty,\n isSubmitting,\n submitError,\n lastResponse,\n };\n\n return {\n // Metadata (grouped)\n meta,\n // Getters\n getValues: controller.getValues,\n getErrors: controller.getErrors,\n getTouched: controller.getTouched,\n getDirtyValues: controller.getDirtyValues,\n // Main actions (frequent use - flat)\n submit: controller.submit,\n onSubmit,\n reset,\n ...actions,\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitFieldVueResult } from \"./types\";\nimport type { BitPath, BitPathValue } from \"../core\";\nimport {\n cleanupRegisteredField,\n createFrameworkMaskedFieldBinding,\n deriveFieldMeta,\n subscribeFieldState,\n} from \"../core\";\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): UseBitFieldVueResult<BitPathValue<TForm, P>> {\n const store = useBitStore<TForm>();\n\n const { fieldController } = createFrameworkMaskedFieldBinding(store, path);\n\n const state = shallowRef(store.getFieldState(path));\n\n const unsubscribe = subscribeFieldState(store, path, (nextState) => {\n state.value = nextState;\n });\n\n onUnmounted(() => {\n unsubscribe();\n cleanupRegisteredField(store, path as string);\n });\n\n const rawValue = computed(() => state.value.value as BitPathValue<TForm, P>);\n\n const displayValue = computed(() =>\n fieldController.displayValue(rawValue.value),\n );\n\n const modelValue = computed({\n get: () => displayValue.value,\n set: (val: string) => {\n fieldController.setValue(val);\n },\n });\n\n const metaState = computed(() => deriveFieldMeta(state.value));\n const error = computed(() => metaState.value.error);\n const touched = computed(() => metaState.value.touched);\n const invalid = computed(() => metaState.value.invalid);\n const isValidating = computed(() => metaState.value.isValidating);\n const isDirty = computed(() => metaState.value.isDirty);\n const isHidden = computed(() => metaState.value.isHidden);\n const isRequired = computed(() => metaState.value.isRequired);\n const hasError = computed(() => metaState.value.hasError);\n\n const setValue = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n fieldController.setValue(val);\n };\n\n const setBlur = () => fieldController.setBlur();\n\n const onInput = (\n val: BitPathValue<TForm, P> | string | number | null | undefined,\n ) => {\n setValue(val);\n };\n\n const onBlur = () => {\n setBlur();\n };\n\n return {\n // Main handlers and values (flat)\n value: rawValue,\n displayValue,\n modelValue,\n setValue,\n setBlur,\n onInput,\n onBlur,\n // Metadata (grouped)\n meta: {\n error,\n touched,\n invalid,\n isValidating,\n isDirty,\n isHidden,\n isRequired,\n hasError,\n },\n };\n}\n","import { shallowRef, computed, onUnmounted } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { createArrayBindingController, BitArrayPath } from \"../core\";\nimport { cleanupRegisteredPrefix } from \"../core\";\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const controller = createArrayBindingController<TForm, P>(store, path);\n const values = shallowRef(controller.readItems());\n\n const unsubscribe = store.subscribePath(path, () => {\n values.value = controller.readItems();\n });\n\n onUnmounted(() => {\n unsubscribe();\n cleanupRegisteredPrefix(store, `${path as string}.`);\n });\n\n const fields = computed(() => controller.getFields(values.value));\n\n const length = computed(() => values.value.length);\n\n return {\n fields,\n length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n };\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { e as BitStoreApi, f as BitStoreHooksApi, c as BitHistoryMetadata, d as BitValidationOptions } from '../public-types-Cd9ai20P.cjs';
2
- import { j as BitPersistMetadata, S as ScopeStatus, n as ValidateScopeResult, i as BitErrors, H as BitTouched, h as DeepPartial, f as BitPath, g as BitPathValue, k as BitArrayPath, l as BitArrayItem } from '../bus-BeAeZwWu.cjs';
1
+ import { a as BitStoreHooksApi, b as BitFormBindingApi, c as BitHistoryMetadata, d as BitValidationOptions } from '../store-api-types-B6_bPoVI.cjs';
2
+ import { i as BitPersistMetadata, S as ScopeStatus, V as ValidateScopeResult, c as BitErrors, r as BitTouched, D as DeepPartial, e as BitPath, b as BitPathValue, B as BitArrayPath, a as BitArrayItem } from '../bus-rcUiufS7.cjs';
3
3
  import * as vue from 'vue';
4
4
  import { ComputedRef, Ref } from 'vue';
5
- import * as _vue_reactivity from '@vue/reactivity';
5
+ import { B as BitArrayBindingField } from '../array-controller-C1A5VKYd.cjs';
6
6
  import * as _vue_shared from '@vue/shared';
7
7
  import { B as BitUploadFn, a as BitDeleteUploadFn } from '../upload-EXnJLq8k.cjs';
8
- import '../types-D8DgIUhJ.cjs';
8
+ import '../types-CUXh7PqD.cjs';
9
9
 
10
- declare function provideBitStore<T extends object>(store: BitStoreApi<T>): void;
11
- declare function useBitStore<T extends object>(): BitStoreHooksApi<T>;
10
+ declare function provideBitStore<T extends object>(store: BitStoreHooksApi<T>): void;
11
+ declare function useBitStore<T extends object>(): BitFormBindingApi<T>;
12
12
 
13
13
  /**
14
14
  * Metadata describing the current state of a form field (Vue reactive).
@@ -107,9 +107,10 @@ interface UseBitFormResult<T extends object = any> {
107
107
  onSubmit: (handler: (values: T, dirtyValues?: Partial<T>) => Promise<unknown>) => (e?: Event) => Promise<void>;
108
108
  reset: () => void;
109
109
  transaction: <TResult>(callback: () => TResult) => TResult;
110
- replaceValues: (values: T) => void;
111
- hydrate: (values: DeepPartial<T>) => void;
112
- rebase: (values: T) => void;
110
+ setValues: (values: T | DeepPartial<T>, options?: {
111
+ partial?: boolean;
112
+ rebase?: boolean;
113
+ }) => void;
113
114
  setError: (path: string, message: string | undefined) => void;
114
115
  setErrors: (errors: BitErrors<T>) => void;
115
116
  setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
@@ -123,18 +124,14 @@ declare function useBitForm<T extends object>(): UseBitFormResult<T>;
123
124
  declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): UseBitFieldVueResult<BitPathValue<TForm, P>>;
124
125
 
125
126
  declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
126
- fields: vue.ComputedRef<{
127
- key: string;
128
- value: _vue_reactivity.UnwrapRefSimple<BitArrayItem<BitPathValue<TForm, P>>>;
129
- index: number;
130
- }[]>;
127
+ fields: vue.ComputedRef<BitArrayBindingField<BitArrayItem<BitPathValue<TForm, P>>>[]>;
131
128
  length: vue.ComputedRef<number>;
132
- append: (val: BitArrayItem<BitPathValue<TForm, P>>) => void;
133
- prepend: (val: BitArrayItem<BitPathValue<TForm, P>>) => void;
134
- insert: (index: number, val: BitArrayItem<BitPathValue<TForm, P>>) => void;
129
+ append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
130
+ prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
131
+ insert: (index: number, value: BitArrayItem<BitPathValue<TForm, P>>) => void;
135
132
  remove: (index: number) => void;
136
133
  move: (from: number, to: number) => void;
137
- swap: (a: number, b: number) => void;
134
+ swap: (indexA: number, indexB: number) => void;
138
135
  replace: (items: BitArrayItem<BitPathValue<TForm, P>>[]) => void;
139
136
  clear: () => void;
140
137
  };
@@ -1,14 +1,14 @@
1
- import { e as BitStoreApi, f as BitStoreHooksApi, c as BitHistoryMetadata, d as BitValidationOptions } from '../public-types-DdZxD6Op.js';
2
- import { j as BitPersistMetadata, S as ScopeStatus, n as ValidateScopeResult, i as BitErrors, H as BitTouched, h as DeepPartial, f as BitPath, g as BitPathValue, k as BitArrayPath, l as BitArrayItem } from '../bus-B4zZmB9C.js';
1
+ import { a as BitStoreHooksApi, b as BitFormBindingApi, c as BitHistoryMetadata, d as BitValidationOptions } from '../store-api-types-9ipdute1.js';
2
+ import { i as BitPersistMetadata, S as ScopeStatus, V as ValidateScopeResult, c as BitErrors, r as BitTouched, D as DeepPartial, e as BitPath, b as BitPathValue, B as BitArrayPath, a as BitArrayItem } from '../bus-DgilLszS.js';
3
3
  import * as vue from 'vue';
4
4
  import { ComputedRef, Ref } from 'vue';
5
- import * as _vue_reactivity from '@vue/reactivity';
5
+ import { B as BitArrayBindingField } from '../array-controller-DtkmcnUr.js';
6
6
  import * as _vue_shared from '@vue/shared';
7
7
  import { B as BitUploadFn, a as BitDeleteUploadFn } from '../upload-EXnJLq8k.js';
8
- import '../types-D8DgIUhJ.js';
8
+ import '../types-CUXh7PqD.js';
9
9
 
10
- declare function provideBitStore<T extends object>(store: BitStoreApi<T>): void;
11
- declare function useBitStore<T extends object>(): BitStoreHooksApi<T>;
10
+ declare function provideBitStore<T extends object>(store: BitStoreHooksApi<T>): void;
11
+ declare function useBitStore<T extends object>(): BitFormBindingApi<T>;
12
12
 
13
13
  /**
14
14
  * Metadata describing the current state of a form field (Vue reactive).
@@ -107,9 +107,10 @@ interface UseBitFormResult<T extends object = any> {
107
107
  onSubmit: (handler: (values: T, dirtyValues?: Partial<T>) => Promise<unknown>) => (e?: Event) => Promise<void>;
108
108
  reset: () => void;
109
109
  transaction: <TResult>(callback: () => TResult) => TResult;
110
- replaceValues: (values: T) => void;
111
- hydrate: (values: DeepPartial<T>) => void;
112
- rebase: (values: T) => void;
110
+ setValues: (values: T | DeepPartial<T>, options?: {
111
+ partial?: boolean;
112
+ rebase?: boolean;
113
+ }) => void;
113
114
  setError: (path: string, message: string | undefined) => void;
114
115
  setErrors: (errors: BitErrors<T>) => void;
115
116
  setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
@@ -123,18 +124,14 @@ declare function useBitForm<T extends object>(): UseBitFormResult<T>;
123
124
  declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): UseBitFieldVueResult<BitPathValue<TForm, P>>;
124
125
 
125
126
  declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
126
- fields: vue.ComputedRef<{
127
- key: string;
128
- value: _vue_reactivity.UnwrapRefSimple<BitArrayItem<BitPathValue<TForm, P>>>;
129
- index: number;
130
- }[]>;
127
+ fields: vue.ComputedRef<BitArrayBindingField<BitArrayItem<BitPathValue<TForm, P>>>[]>;
131
128
  length: vue.ComputedRef<number>;
132
- append: (val: BitArrayItem<BitPathValue<TForm, P>>) => void;
133
- prepend: (val: BitArrayItem<BitPathValue<TForm, P>>) => void;
134
- insert: (index: number, val: BitArrayItem<BitPathValue<TForm, P>>) => void;
129
+ append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
130
+ prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
131
+ insert: (index: number, value: BitArrayItem<BitPathValue<TForm, P>>) => void;
135
132
  remove: (index: number) => void;
136
133
  move: (from: number, to: number) => void;
137
- swap: (a: number, b: number) => void;
134
+ swap: (indexA: number, indexB: number) => void;
138
135
  replace: (items: BitArrayItem<BitPathValue<TForm, P>>[]) => void;
139
136
  clear: () => void;
140
137
  };