@formality-ui/react 0.3.0 → 0.3.1
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.cjs +9 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -164,8 +164,15 @@ function Form({
|
|
|
164
164
|
return result;
|
|
165
165
|
}, [providerConfig.inputs, formConfig.inputs]);
|
|
166
166
|
const defaultValues = react.useMemo(() => {
|
|
167
|
-
const resolved = core.resolveAllInitialValues(
|
|
168
|
-
|
|
167
|
+
const resolved = core.resolveAllInitialValues(
|
|
168
|
+
config,
|
|
169
|
+
mergedInputs,
|
|
170
|
+
record ?? {}
|
|
171
|
+
);
|
|
172
|
+
const baseline = {
|
|
173
|
+
...record ?? {},
|
|
174
|
+
...resolved
|
|
175
|
+
};
|
|
169
176
|
for (const fieldName of Object.keys(config)) {
|
|
170
177
|
if (!(fieldName in baseline)) baseline[fieldName] = void 0;
|
|
171
178
|
}
|
|
@@ -203,11 +210,6 @@ function Form({
|
|
|
203
210
|
invertedSubscriptions.current.set(target, /* @__PURE__ */ new Set());
|
|
204
211
|
}
|
|
205
212
|
invertedSubscriptions.current.get(target).add(subscriber);
|
|
206
|
-
if (process.env.NODE_ENV !== "production") {
|
|
207
|
-
console.warn(
|
|
208
|
-
`[Formality Subscription] "${subscriber}" added to watch "${target}"`
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
213
|
const setter = watcherSetters.current.get(target);
|
|
212
214
|
if (setter) {
|
|
213
215
|
setter((prev) => ({ ...prev, [subscriber]: true }));
|
|
@@ -220,20 +222,7 @@ function Form({
|
|
|
220
222
|
}, []);
|
|
221
223
|
const removeSubscription = react.useCallback(
|
|
222
224
|
(target, subscriber) => {
|
|
223
|
-
const subscribers = invertedSubscriptions.current.get(target);
|
|
224
|
-
const subscriptionExists = subscribers?.has(subscriber) ?? false;
|
|
225
225
|
invertedSubscriptions.current.get(target)?.delete(subscriber);
|
|
226
|
-
if (process.env.NODE_ENV !== "production") {
|
|
227
|
-
if (subscriptionExists) {
|
|
228
|
-
console.warn(
|
|
229
|
-
`[Formality Subscription] "${subscriber}" removed from watching "${target}"`
|
|
230
|
-
);
|
|
231
|
-
} else {
|
|
232
|
-
console.warn(
|
|
233
|
-
`[Formality Subscription] WARNING: Double-cleanup attempt - "${subscriber}" was not watching "${target}"`
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
226
|
const setter = watcherSetters.current.get(target);
|
|
238
227
|
if (setter) {
|
|
239
228
|
setter((prev) => {
|
|
@@ -920,20 +909,10 @@ function useSubscriptions(fieldName, subscriptions) {
|
|
|
920
909
|
runSubscriptionsRef.current.set(currentRunId, [...subscriptions]);
|
|
921
910
|
subscriptions.forEach((target) => {
|
|
922
911
|
addSubscription(target, fieldName);
|
|
923
|
-
if (process.env.NODE_ENV !== "production") {
|
|
924
|
-
console.warn(
|
|
925
|
-
`[Formality Subscription] Run ${currentRunId}: "${fieldName}" subscribing to "${target}"`
|
|
926
|
-
);
|
|
927
|
-
}
|
|
928
912
|
});
|
|
929
913
|
return () => {
|
|
930
914
|
const thisRunSubscriptions = runSubscriptionsRef.current.get(currentRunId);
|
|
931
915
|
if (thisRunSubscriptions) {
|
|
932
|
-
if (process.env.NODE_ENV !== "production") {
|
|
933
|
-
console.warn(
|
|
934
|
-
`[Formality Subscription] Run ${currentRunId}: "${fieldName}" cleaning up [${thisRunSubscriptions.join(", ")}]`
|
|
935
|
-
);
|
|
936
|
-
}
|
|
937
916
|
[...thisRunSubscriptions].reverse().forEach((target) => {
|
|
938
917
|
removeSubscription(target, fieldName);
|
|
939
918
|
});
|