@pisell/materials 1.10.33 → 1.10.34
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/PisellSelectionFlow/PisellSelectionFlow.js +6 -0
- package/es/components/PisellSelectionFlow/hooks/useFlowModuleLifecycle.js +24 -7
- package/es/components/PisellSelectionFlow/hooks/useFlowNavigation.js +100 -5
- package/es/components/PisellSelectionFlow/types.d.ts +7 -0
- package/lib/components/PisellSelectionFlow/PisellSelectionFlow.js +6 -0
- package/lib/components/PisellSelectionFlow/hooks/useFlowModuleLifecycle.js +24 -7
- package/lib/components/PisellSelectionFlow/hooks/useFlowNavigation.js +100 -5
- package/lib/components/PisellSelectionFlow/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -59,6 +59,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
59
59
|
const moduleInitializationRef = useRef(/* @__PURE__ */ new Map());
|
|
60
60
|
const moduleDependencyLifecycleRef = useRef(/* @__PURE__ */ new Map());
|
|
61
61
|
const pendingModuleChangeRef = useRef(/* @__PURE__ */ new Map());
|
|
62
|
+
const moduleInvalidationRef = useRef(/* @__PURE__ */ new Map());
|
|
62
63
|
const compiledStepsRef = useRef([]);
|
|
63
64
|
const configurationErrorRef = useRef(null);
|
|
64
65
|
const contextRef = useRef(null);
|
|
@@ -86,11 +87,13 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
86
87
|
moduleInitializationRef.current.clear();
|
|
87
88
|
moduleDependencyLifecycleRef.current.clear();
|
|
88
89
|
pendingModuleChangeRef.current.clear();
|
|
90
|
+
moduleInvalidationRef.current.clear();
|
|
89
91
|
moduleHandlesRef.current.clear();
|
|
90
92
|
};
|
|
91
93
|
}, []);
|
|
92
94
|
const commitModuleState = useCallback((moduleKey, nextState) => {
|
|
93
95
|
if (!mountedRef.current) return;
|
|
96
|
+
if (nextState.status === "ready") moduleInvalidationRef.current.delete(moduleKey);
|
|
94
97
|
const previous = moduleStateRef.current[moduleKey];
|
|
95
98
|
if ((previous === null || previous === void 0 ? void 0 : previous.status) === nextState.status && (previous === null || previous === void 0 ? void 0 : previous.message) === nextState.message && (previous === null || previous === void 0 ? void 0 : previous.reason) === nextState.reason && (previous === null || previous === void 0 ? void 0 : previous.error) === nextState.error) return;
|
|
96
99
|
const nextMap = _objectSpread2(_objectSpread2({}, moduleStateRef.current), {}, { [moduleKey]: nextState });
|
|
@@ -254,6 +257,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
254
257
|
moduleInitializationRef.current.delete(moduleKey);
|
|
255
258
|
moduleDependencyLifecycleRef.current.delete(moduleKey);
|
|
256
259
|
pendingModuleChangeRef.current.delete(moduleKey);
|
|
260
|
+
moduleInvalidationRef.current.delete(moduleKey);
|
|
257
261
|
moduleHandlesRef.current.delete(moduleKey);
|
|
258
262
|
if (moduleKey in nextMap) {
|
|
259
263
|
delete nextMap[moduleKey];
|
|
@@ -286,6 +290,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
286
290
|
moduleInitializationRef,
|
|
287
291
|
moduleDependencyLifecycleRef,
|
|
288
292
|
pendingModuleChangeRef,
|
|
293
|
+
moduleInvalidationRef,
|
|
289
294
|
compiledStepsRef,
|
|
290
295
|
moduleStateRef,
|
|
291
296
|
processDraftChangeRef,
|
|
@@ -305,6 +310,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
305
310
|
mountedRef,
|
|
306
311
|
moduleStateRef,
|
|
307
312
|
moduleRevisionRef,
|
|
313
|
+
moduleInvalidationRef,
|
|
308
314
|
draftRevisionRef,
|
|
309
315
|
flowGenerationRef,
|
|
310
316
|
moduleHandlesRef,
|
|
@@ -5,12 +5,13 @@ import { getSelectionFlowErrorMessage } from "../utils.js";
|
|
|
5
5
|
import { useCallback, useEffect } from "react";
|
|
6
6
|
//#region src/components/PisellSelectionFlow/hooks/useFlowModuleLifecycle.ts
|
|
7
7
|
/** 负责依赖失效、清理、校正、刷新和异步 latest-wins。 */
|
|
8
|
-
const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, flowGenerationRef, draftRevisionRef, draftRef, moduleRevisionRef, moduleInitializationRef, moduleDependencyLifecycleRef, pendingModuleChangeRef, compiledStepsRef, moduleStateRef, processDraftChangeRef, commitModuleState, getFreshContext, currentStep, configurationError, compiledSteps, resolvedCurrentStepIndex, draft, moduleState }) => {
|
|
8
|
+
const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, flowGenerationRef, draftRevisionRef, draftRef, moduleRevisionRef, moduleInitializationRef, moduleDependencyLifecycleRef, pendingModuleChangeRef, moduleInvalidationRef, compiledStepsRef, moduleStateRef, processDraftChangeRef, commitModuleState, getFreshContext, currentStep, configurationError, compiledSteps, resolvedCurrentStepIndex, draft, moduleState }) => {
|
|
9
9
|
processDraftChangeRef.current = useCallback((change) => {
|
|
10
10
|
const changedFields = new Set(change.changedFields);
|
|
11
11
|
const flowGeneration = flowGenerationRef.current;
|
|
12
12
|
if (!mountedRef.current) return;
|
|
13
13
|
for (const step of compiledStepsRef.current) for (const module of step.modules) {
|
|
14
|
+
var _previousInvalidation, _moduleStateRef$curre;
|
|
14
15
|
if (module.key === change.sourceModuleKey) continue;
|
|
15
16
|
const adapter = resolveFlowModuleAdapter(registry, module.type);
|
|
16
17
|
if (!adapter) continue;
|
|
@@ -24,6 +25,14 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
24
25
|
moduleRevisionRef.current.set(module.key, revision);
|
|
25
26
|
moduleInitializationRef.current.delete(module.key);
|
|
26
27
|
moduleDependencyLifecycleRef.current.delete(module.key);
|
|
28
|
+
const previousInvalidation = moduleInvalidationRef.current.get(module.key);
|
|
29
|
+
moduleInvalidationRef.current.set(module.key, {
|
|
30
|
+
wasReady: false,
|
|
31
|
+
change: previousInvalidation ? _objectSpread2(_objectSpread2({}, change), {}, {
|
|
32
|
+
previousDraft: previousInvalidation.change.previousDraft,
|
|
33
|
+
changedFields: Array.from(new Set([...previousInvalidation.change.changedFields, ...change.changedFields]))
|
|
34
|
+
}) : change
|
|
35
|
+
});
|
|
27
36
|
commitModuleState(module.key, {
|
|
28
37
|
status: "error",
|
|
29
38
|
message: getSelectionFlowErrorMessage(error),
|
|
@@ -32,6 +41,14 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
32
41
|
continue;
|
|
33
42
|
}
|
|
34
43
|
if (!shouldRefresh) continue;
|
|
44
|
+
const previousInvalidation = moduleInvalidationRef.current.get(module.key);
|
|
45
|
+
moduleInvalidationRef.current.set(module.key, {
|
|
46
|
+
wasReady: (_previousInvalidation = previousInvalidation === null || previousInvalidation === void 0 ? void 0 : previousInvalidation.wasReady) !== null && _previousInvalidation !== void 0 ? _previousInvalidation : ((_moduleStateRef$curre = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre === void 0 ? void 0 : _moduleStateRef$curre.status) === "ready",
|
|
47
|
+
change: previousInvalidation ? _objectSpread2(_objectSpread2({}, change), {}, {
|
|
48
|
+
previousDraft: previousInvalidation.change.previousDraft,
|
|
49
|
+
changedFields: Array.from(new Set([...previousInvalidation.change.changedFields, ...change.changedFields]))
|
|
50
|
+
}) : change
|
|
51
|
+
});
|
|
35
52
|
const previousPendingChange = pendingModuleChangeRef.current.get(module.key);
|
|
36
53
|
const lifecycleChange = previousPendingChange ? _objectSpread2(_objectSpread2({}, change), {}, {
|
|
37
54
|
previousDraft: previousPendingChange.previousDraft,
|
|
@@ -163,7 +180,7 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
163
180
|
return false;
|
|
164
181
|
}
|
|
165
182
|
try {
|
|
166
|
-
var _await$adapter$canIni, _adapter$canInitializ, _moduleStateRef$
|
|
183
|
+
var _await$adapter$canIni, _adapter$canInitializ, _moduleStateRef$curre3;
|
|
167
184
|
const canInitialize = (_await$adapter$canIni = yield (_adapter$canInitializ = adapter.canInitialize) === null || _adapter$canInitializ === void 0 ? void 0 : _adapter$canInitializ.call(adapter, context, module)) !== null && _await$adapter$canIni !== void 0 ? _await$adapter$canIni : true;
|
|
168
185
|
if (!isCurrentRun()) return false;
|
|
169
186
|
if (!canInitialize) {
|
|
@@ -174,14 +191,14 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
174
191
|
return false;
|
|
175
192
|
}
|
|
176
193
|
do {
|
|
177
|
-
var _adapter$refresh, _moduleStateRef$
|
|
194
|
+
var _adapter$refresh, _moduleStateRef$curre2;
|
|
178
195
|
commitModuleState(module.key, { status: "loading" });
|
|
179
196
|
context = getRunContext();
|
|
180
197
|
if (!context || !isCurrentRun()) return false;
|
|
181
198
|
yield (_adapter$refresh = adapter.refresh) === null || _adapter$refresh === void 0 ? void 0 : _adapter$refresh.call(adapter, context, module);
|
|
182
199
|
if (!isCurrentRun()) return false;
|
|
183
|
-
if (((_moduleStateRef$
|
|
184
|
-
} while (((_moduleStateRef$
|
|
200
|
+
if (((_moduleStateRef$curre2 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre2 === void 0 ? void 0 : _moduleStateRef$curre2.status) === "error") return false;
|
|
201
|
+
} while (((_moduleStateRef$curre3 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre3 === void 0 ? void 0 : _moduleStateRef$curre3.status) === "stale");
|
|
185
202
|
commitModuleState(module.key, { status: "ready" });
|
|
186
203
|
return true;
|
|
187
204
|
} catch (error) {
|
|
@@ -216,8 +233,8 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
216
233
|
return (adapter === null || adapter === void 0 ? void 0 : adapter.initializeWhileInactive) && module.stepIndex < resolvedCurrentStepIndex;
|
|
217
234
|
});
|
|
218
235
|
for (const module of [...currentStep.modules, ...backgroundModules]) {
|
|
219
|
-
var _moduleStateRef$
|
|
220
|
-
const status = ((_moduleStateRef$
|
|
236
|
+
var _moduleStateRef$curre4;
|
|
237
|
+
const status = ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) || "idle";
|
|
221
238
|
if (status === "idle" || status === "stale") ensureModuleReady(module);
|
|
222
239
|
}
|
|
223
240
|
}, [
|
|
@@ -5,7 +5,7 @@ import { getCompiledStepsFingerprint, getSelectionFlowErrorMessage, normalizeFlo
|
|
|
5
5
|
import { useCallback, useRef } from "react";
|
|
6
6
|
//#region src/components/PisellSelectionFlow/hooks/useFlowNavigation.ts
|
|
7
7
|
/** 导航、校验与提交门禁独立于模块加载生命周期。 */
|
|
8
|
-
const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, moduleStateRef, moduleRevisionRef, draftRevisionRef, flowGenerationRef, moduleHandlesRef, configurationErrorRef, compiledStepsRef, currentStepIndexRef, currentStepKeyRef, validatedCompletionRef, navigationRevisionRef, preparationRevisionRef, transitionPendingRef, completedRef, completionPromiseRef, isCompletingRef, draftRef, onCompleteRef, ensureModuleReady, commitModuleState, getFreshContext, onValidationFailed, setCurrentStepIndex, setCompletionError, setCompletionReason, setIsCompleting }) => {
|
|
8
|
+
const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, moduleStateRef, moduleRevisionRef, moduleInvalidationRef, draftRevisionRef, flowGenerationRef, moduleHandlesRef, configurationErrorRef, compiledStepsRef, currentStepIndexRef, currentStepKeyRef, validatedCompletionRef, navigationRevisionRef, preparationRevisionRef, transitionPendingRef, completedRef, completionPromiseRef, isCompletingRef, draftRef, onCompleteRef, ensureModuleReady, commitModuleState, getFreshContext, onValidationFailed, setCurrentStepIndex, setCompletionError, setCompletionReason, setIsCompleting }) => {
|
|
9
9
|
const navigationDirectionRef = useRef("forward");
|
|
10
10
|
const isStepSkippable = useCallback((stepIndex) => {
|
|
11
11
|
const step = compiledStepsRef.current[stepIndex];
|
|
@@ -273,19 +273,109 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
273
273
|
onValidationFailed,
|
|
274
274
|
registry
|
|
275
275
|
]);
|
|
276
|
+
const revalidateModuleBeforeComplete = useCallback(function() {
|
|
277
|
+
var _ref2 = _asyncToGenerator(function* (module, expectedDraftRevision) {
|
|
278
|
+
const invalidation = moduleInvalidationRef.current.get(module.key);
|
|
279
|
+
const adapter = resolveFlowModuleAdapter(registry, module.type);
|
|
280
|
+
if (!(invalidation === null || invalidation === void 0 ? void 0 : invalidation.wasReady) || !(adapter === null || adapter === void 0 ? void 0 : adapter.canRevalidateBeforeComplete) || !adapter.validateAutoResolution) return false;
|
|
281
|
+
const moduleRevision = moduleRevisionRef.current.get(module.key) || 0;
|
|
282
|
+
const flowGeneration = flowGenerationRef.current;
|
|
283
|
+
const navigationRevision = navigationRevisionRef.current;
|
|
284
|
+
const compiledFingerprint = getCompiledStepsFingerprint(compiledStepsRef.current);
|
|
285
|
+
const isCurrentRun = () => mountedRef.current && !configurationErrorRef.current && flowGenerationRef.current === flowGeneration && navigationRevisionRef.current === navigationRevision && (moduleRevisionRef.current.get(module.key) || 0) === moduleRevision && getCompiledStepsFingerprint(compiledStepsRef.current) === compiledFingerprint;
|
|
286
|
+
const isCurrentSelection = () => isCurrentRun() && draftRevisionRef.current === expectedDraftRevision;
|
|
287
|
+
const requireReviewIfCurrent = () => {
|
|
288
|
+
if (isCurrentRun()) commitModuleState(module.key, {
|
|
289
|
+
status: "stale",
|
|
290
|
+
reason: createRuntimeIssue("selection-changed-validation")
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
try {
|
|
294
|
+
const initialContext = getFreshContext();
|
|
295
|
+
if (!initialContext || !isCurrentSelection() || !adapter.canRevalidateBeforeComplete(initialContext, invalidation.change, module)) return false;
|
|
296
|
+
if (!(yield ensureModuleReady(module))) return false;
|
|
297
|
+
if (!isCurrentSelection()) {
|
|
298
|
+
requireReviewIfCurrent();
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
const context = getFreshContext();
|
|
302
|
+
if (!context) return false;
|
|
303
|
+
const validationContext = _objectSpread2(_objectSpread2({}, context), {}, {
|
|
304
|
+
updateDraft: (update, meta) => {
|
|
305
|
+
if (isCurrentSelection()) context.updateDraft(update, meta);
|
|
306
|
+
},
|
|
307
|
+
setModuleState: (moduleKey, state) => {
|
|
308
|
+
if (isCurrentSelection()) context.setModuleState(moduleKey, state);
|
|
309
|
+
},
|
|
310
|
+
setModuleStatus: (moduleKey, status, message, error) => {
|
|
311
|
+
if (isCurrentSelection()) context.setModuleStatus(moduleKey, status, message, error);
|
|
312
|
+
},
|
|
313
|
+
setModuleData: (moduleKey, value) => {
|
|
314
|
+
if (isCurrentSelection()) context.setModuleData(moduleKey, value);
|
|
315
|
+
},
|
|
316
|
+
clearModuleData: (moduleKey) => {
|
|
317
|
+
if (isCurrentSelection()) context.clearModuleData(moduleKey);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const result = normalizeFlowValidationResult(yield adapter.validateAutoResolution(validationContext, module));
|
|
321
|
+
if (!isCurrentSelection()) {
|
|
322
|
+
requireReviewIfCurrent();
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
if (!result.valid) {
|
|
326
|
+
commitModuleState(module.key, {
|
|
327
|
+
status: "error",
|
|
328
|
+
message: result.message,
|
|
329
|
+
reason: result.message ? void 0 : createRuntimeIssue("module-validation-failed")
|
|
330
|
+
});
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
commitModuleState(module.key, { status: "ready" });
|
|
334
|
+
return true;
|
|
335
|
+
} catch (error) {
|
|
336
|
+
if (isCurrentSelection()) commitModuleState(module.key, {
|
|
337
|
+
status: "error",
|
|
338
|
+
message: getSelectionFlowErrorMessage(error),
|
|
339
|
+
error
|
|
340
|
+
});
|
|
341
|
+
else requireReviewIfCurrent();
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
return function(_x2, _x3) {
|
|
346
|
+
return _ref2.apply(this, arguments);
|
|
347
|
+
};
|
|
348
|
+
}(), [
|
|
349
|
+
commitModuleState,
|
|
350
|
+
createRuntimeIssue,
|
|
351
|
+
ensureModuleReady,
|
|
352
|
+
getFreshContext,
|
|
353
|
+
registry
|
|
354
|
+
]);
|
|
276
355
|
const validateFlowForCompletion = useCallback(_asyncToGenerator(function* () {
|
|
277
356
|
validatedCompletionRef.current = null;
|
|
278
357
|
if (configurationErrorRef.current) return false;
|
|
279
358
|
const currentIndex = currentStepIndexRef.current;
|
|
280
359
|
const allSteps = compiledStepsRef.current;
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
360
|
+
const preparationFingerprint = getCompiledStepsFingerprint(allSteps);
|
|
361
|
+
const preparationGeneration = flowGenerationRef.current;
|
|
362
|
+
const preparationNavigation = navigationRevisionRef.current;
|
|
363
|
+
const preparationDraftRevision = draftRevisionRef.current;
|
|
364
|
+
const isCurrentPreparation = () => mountedRef.current && !configurationErrorRef.current && flowGenerationRef.current === preparationGeneration && navigationRevisionRef.current === preparationNavigation && currentStepIndexRef.current === currentIndex && getCompiledStepsFingerprint(compiledStepsRef.current) === preparationFingerprint;
|
|
284
365
|
for (const step of allSteps) {
|
|
285
366
|
if (step.index >= currentIndex) break;
|
|
286
367
|
for (const module of step.modules) {
|
|
287
|
-
|
|
368
|
+
let state = moduleStateRef.current[module.key];
|
|
288
369
|
if ((state === null || state === void 0 ? void 0 : state.status) !== "ready") {
|
|
370
|
+
const revalidationModuleRevision = moduleRevisionRef.current.get(module.key) || 0;
|
|
371
|
+
const revalidated = yield revalidateModuleBeforeComplete(module, preparationDraftRevision);
|
|
372
|
+
if (!isCurrentPreparation()) return false;
|
|
373
|
+
if (revalidated && draftRevisionRef.current === preparationDraftRevision) continue;
|
|
374
|
+
if (revalidated && (moduleRevisionRef.current.get(module.key) || 0) === revalidationModuleRevision) commitModuleState(module.key, {
|
|
375
|
+
status: "stale",
|
|
376
|
+
reason: createRuntimeIssue("selection-changed-validation")
|
|
377
|
+
});
|
|
378
|
+
state = moduleStateRef.current[module.key];
|
|
289
379
|
currentStepIndexRef.current = step.index;
|
|
290
380
|
currentStepKeyRef.current = step.key;
|
|
291
381
|
setCurrentStepIndex(step.index);
|
|
@@ -297,6 +387,9 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
297
387
|
}
|
|
298
388
|
}
|
|
299
389
|
}
|
|
390
|
+
const compiledFingerprint = getCompiledStepsFingerprint(allSteps);
|
|
391
|
+
const revisionFingerprint = allSteps.flatMap((step) => step.modules).map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|");
|
|
392
|
+
const draftRevision = draftRevisionRef.current;
|
|
300
393
|
if (!(yield validateCurrentStep())) return false;
|
|
301
394
|
if (configurationErrorRef.current) return false;
|
|
302
395
|
const latestSteps = compiledStepsRef.current;
|
|
@@ -335,8 +428,10 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
335
428
|
};
|
|
336
429
|
return true;
|
|
337
430
|
}), [
|
|
431
|
+
commitModuleState,
|
|
338
432
|
createRuntimeIssue,
|
|
339
433
|
onValidationFailed,
|
|
434
|
+
revalidateModuleBeforeComplete,
|
|
340
435
|
validateCurrentStep
|
|
341
436
|
]);
|
|
342
437
|
const complete = useCallback(() => {
|
|
@@ -106,6 +106,13 @@ interface SelectionFlowModuleAdapter<TDraft, TDraftUpdate, TField extends string
|
|
|
106
106
|
hardRequires?: readonly TField[];
|
|
107
107
|
refreshOn?: readonly TField[];
|
|
108
108
|
shouldRefresh?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, change: SelectionFlowDraftChange<TDraft, TField, TModuleType>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Explicitly permits completion to refresh a previously ready, invalidated
|
|
111
|
+
* module without revisiting its UI. The accumulated change starts at its last
|
|
112
|
+
* ready state. Completion still requires validateAutoResolution to succeed
|
|
113
|
+
* without any Draft revision changing; beforeLeave is not run here.
|
|
114
|
+
*/
|
|
115
|
+
canRevalidateBeforeComplete?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, change: SelectionFlowDraftChange<TDraft, TField, TModuleType>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
109
116
|
isApplicable?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
110
117
|
canInitialize?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean | Promise<boolean>;
|
|
111
118
|
refresh?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => void | Promise<void>;
|
|
@@ -61,6 +61,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
61
61
|
const moduleInitializationRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
62
62
|
const moduleDependencyLifecycleRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
63
63
|
const pendingModuleChangeRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
64
|
+
const moduleInvalidationRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
64
65
|
const compiledStepsRef = (0, react.useRef)([]);
|
|
65
66
|
const configurationErrorRef = (0, react.useRef)(null);
|
|
66
67
|
const contextRef = (0, react.useRef)(null);
|
|
@@ -88,11 +89,13 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
88
89
|
moduleInitializationRef.current.clear();
|
|
89
90
|
moduleDependencyLifecycleRef.current.clear();
|
|
90
91
|
pendingModuleChangeRef.current.clear();
|
|
92
|
+
moduleInvalidationRef.current.clear();
|
|
91
93
|
moduleHandlesRef.current.clear();
|
|
92
94
|
};
|
|
93
95
|
}, []);
|
|
94
96
|
const commitModuleState = (0, react.useCallback)((moduleKey, nextState) => {
|
|
95
97
|
if (!mountedRef.current) return;
|
|
98
|
+
if (nextState.status === "ready") moduleInvalidationRef.current.delete(moduleKey);
|
|
96
99
|
const previous = moduleStateRef.current[moduleKey];
|
|
97
100
|
if ((previous === null || previous === void 0 ? void 0 : previous.status) === nextState.status && (previous === null || previous === void 0 ? void 0 : previous.message) === nextState.message && (previous === null || previous === void 0 ? void 0 : previous.reason) === nextState.reason && (previous === null || previous === void 0 ? void 0 : previous.error) === nextState.error) return;
|
|
98
101
|
const nextMap = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, moduleStateRef.current), {}, { [moduleKey]: nextState });
|
|
@@ -256,6 +259,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
256
259
|
moduleInitializationRef.current.delete(moduleKey);
|
|
257
260
|
moduleDependencyLifecycleRef.current.delete(moduleKey);
|
|
258
261
|
pendingModuleChangeRef.current.delete(moduleKey);
|
|
262
|
+
moduleInvalidationRef.current.delete(moduleKey);
|
|
259
263
|
moduleHandlesRef.current.delete(moduleKey);
|
|
260
264
|
if (moduleKey in nextMap) {
|
|
261
265
|
delete nextMap[moduleKey];
|
|
@@ -288,6 +292,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
288
292
|
moduleInitializationRef,
|
|
289
293
|
moduleDependencyLifecycleRef,
|
|
290
294
|
pendingModuleChangeRef,
|
|
295
|
+
moduleInvalidationRef,
|
|
291
296
|
compiledStepsRef,
|
|
292
297
|
moduleStateRef,
|
|
293
298
|
processDraftChangeRef,
|
|
@@ -307,6 +312,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
307
312
|
mountedRef,
|
|
308
313
|
moduleStateRef,
|
|
309
314
|
moduleRevisionRef,
|
|
315
|
+
moduleInvalidationRef,
|
|
310
316
|
draftRevisionRef,
|
|
311
317
|
flowGenerationRef,
|
|
312
318
|
moduleHandlesRef,
|
|
@@ -6,12 +6,13 @@ const require_utils = require("../utils.js");
|
|
|
6
6
|
let react = require("react");
|
|
7
7
|
//#region src/components/PisellSelectionFlow/hooks/useFlowModuleLifecycle.ts
|
|
8
8
|
/** 负责依赖失效、清理、校正、刷新和异步 latest-wins。 */
|
|
9
|
-
const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, flowGenerationRef, draftRevisionRef, draftRef, moduleRevisionRef, moduleInitializationRef, moduleDependencyLifecycleRef, pendingModuleChangeRef, compiledStepsRef, moduleStateRef, processDraftChangeRef, commitModuleState, getFreshContext, currentStep, configurationError, compiledSteps, resolvedCurrentStepIndex, draft, moduleState }) => {
|
|
9
|
+
const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, flowGenerationRef, draftRevisionRef, draftRef, moduleRevisionRef, moduleInitializationRef, moduleDependencyLifecycleRef, pendingModuleChangeRef, moduleInvalidationRef, compiledStepsRef, moduleStateRef, processDraftChangeRef, commitModuleState, getFreshContext, currentStep, configurationError, compiledSteps, resolvedCurrentStepIndex, draft, moduleState }) => {
|
|
10
10
|
processDraftChangeRef.current = (0, react.useCallback)((change) => {
|
|
11
11
|
const changedFields = new Set(change.changedFields);
|
|
12
12
|
const flowGeneration = flowGenerationRef.current;
|
|
13
13
|
if (!mountedRef.current) return;
|
|
14
14
|
for (const step of compiledStepsRef.current) for (const module of step.modules) {
|
|
15
|
+
var _previousInvalidation, _moduleStateRef$curre;
|
|
15
16
|
if (module.key === change.sourceModuleKey) continue;
|
|
16
17
|
const adapter = require_compiler.resolveFlowModuleAdapter(registry, module.type);
|
|
17
18
|
if (!adapter) continue;
|
|
@@ -25,6 +26,14 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
25
26
|
moduleRevisionRef.current.set(module.key, revision);
|
|
26
27
|
moduleInitializationRef.current.delete(module.key);
|
|
27
28
|
moduleDependencyLifecycleRef.current.delete(module.key);
|
|
29
|
+
const previousInvalidation = moduleInvalidationRef.current.get(module.key);
|
|
30
|
+
moduleInvalidationRef.current.set(module.key, {
|
|
31
|
+
wasReady: false,
|
|
32
|
+
change: previousInvalidation ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, change), {}, {
|
|
33
|
+
previousDraft: previousInvalidation.change.previousDraft,
|
|
34
|
+
changedFields: Array.from(new Set([...previousInvalidation.change.changedFields, ...change.changedFields]))
|
|
35
|
+
}) : change
|
|
36
|
+
});
|
|
28
37
|
commitModuleState(module.key, {
|
|
29
38
|
status: "error",
|
|
30
39
|
message: require_utils.getSelectionFlowErrorMessage(error),
|
|
@@ -33,6 +42,14 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
33
42
|
continue;
|
|
34
43
|
}
|
|
35
44
|
if (!shouldRefresh) continue;
|
|
45
|
+
const previousInvalidation = moduleInvalidationRef.current.get(module.key);
|
|
46
|
+
moduleInvalidationRef.current.set(module.key, {
|
|
47
|
+
wasReady: (_previousInvalidation = previousInvalidation === null || previousInvalidation === void 0 ? void 0 : previousInvalidation.wasReady) !== null && _previousInvalidation !== void 0 ? _previousInvalidation : ((_moduleStateRef$curre = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre === void 0 ? void 0 : _moduleStateRef$curre.status) === "ready",
|
|
48
|
+
change: previousInvalidation ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, change), {}, {
|
|
49
|
+
previousDraft: previousInvalidation.change.previousDraft,
|
|
50
|
+
changedFields: Array.from(new Set([...previousInvalidation.change.changedFields, ...change.changedFields]))
|
|
51
|
+
}) : change
|
|
52
|
+
});
|
|
36
53
|
const previousPendingChange = pendingModuleChangeRef.current.get(module.key);
|
|
37
54
|
const lifecycleChange = previousPendingChange ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, change), {}, {
|
|
38
55
|
previousDraft: previousPendingChange.previousDraft,
|
|
@@ -164,7 +181,7 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
164
181
|
return false;
|
|
165
182
|
}
|
|
166
183
|
try {
|
|
167
|
-
var _await$adapter$canIni, _adapter$canInitializ, _moduleStateRef$
|
|
184
|
+
var _await$adapter$canIni, _adapter$canInitializ, _moduleStateRef$curre3;
|
|
168
185
|
const canInitialize = (_await$adapter$canIni = yield (_adapter$canInitializ = adapter.canInitialize) === null || _adapter$canInitializ === void 0 ? void 0 : _adapter$canInitializ.call(adapter, context, module)) !== null && _await$adapter$canIni !== void 0 ? _await$adapter$canIni : true;
|
|
169
186
|
if (!isCurrentRun()) return false;
|
|
170
187
|
if (!canInitialize) {
|
|
@@ -175,14 +192,14 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
175
192
|
return false;
|
|
176
193
|
}
|
|
177
194
|
do {
|
|
178
|
-
var _adapter$refresh, _moduleStateRef$
|
|
195
|
+
var _adapter$refresh, _moduleStateRef$curre2;
|
|
179
196
|
commitModuleState(module.key, { status: "loading" });
|
|
180
197
|
context = getRunContext();
|
|
181
198
|
if (!context || !isCurrentRun()) return false;
|
|
182
199
|
yield (_adapter$refresh = adapter.refresh) === null || _adapter$refresh === void 0 ? void 0 : _adapter$refresh.call(adapter, context, module);
|
|
183
200
|
if (!isCurrentRun()) return false;
|
|
184
|
-
if (((_moduleStateRef$
|
|
185
|
-
} while (((_moduleStateRef$
|
|
201
|
+
if (((_moduleStateRef$curre2 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre2 === void 0 ? void 0 : _moduleStateRef$curre2.status) === "error") return false;
|
|
202
|
+
} while (((_moduleStateRef$curre3 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre3 === void 0 ? void 0 : _moduleStateRef$curre3.status) === "stale");
|
|
186
203
|
commitModuleState(module.key, { status: "ready" });
|
|
187
204
|
return true;
|
|
188
205
|
} catch (error) {
|
|
@@ -217,8 +234,8 @@ const useFlowModuleLifecycle = ({ registry, draftAdapter, createRuntimeIssue, mo
|
|
|
217
234
|
return (adapter === null || adapter === void 0 ? void 0 : adapter.initializeWhileInactive) && module.stepIndex < resolvedCurrentStepIndex;
|
|
218
235
|
});
|
|
219
236
|
for (const module of [...currentStep.modules, ...backgroundModules]) {
|
|
220
|
-
var _moduleStateRef$
|
|
221
|
-
const status = ((_moduleStateRef$
|
|
237
|
+
var _moduleStateRef$curre4;
|
|
238
|
+
const status = ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) || "idle";
|
|
222
239
|
if (status === "idle" || status === "stale") ensureModuleReady(module);
|
|
223
240
|
}
|
|
224
241
|
}, [
|
|
@@ -6,7 +6,7 @@ const require_utils = require("../utils.js");
|
|
|
6
6
|
let react = require("react");
|
|
7
7
|
//#region src/components/PisellSelectionFlow/hooks/useFlowNavigation.ts
|
|
8
8
|
/** 导航、校验与提交门禁独立于模块加载生命周期。 */
|
|
9
|
-
const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, moduleStateRef, moduleRevisionRef, draftRevisionRef, flowGenerationRef, moduleHandlesRef, configurationErrorRef, compiledStepsRef, currentStepIndexRef, currentStepKeyRef, validatedCompletionRef, navigationRevisionRef, preparationRevisionRef, transitionPendingRef, completedRef, completionPromiseRef, isCompletingRef, draftRef, onCompleteRef, ensureModuleReady, commitModuleState, getFreshContext, onValidationFailed, setCurrentStepIndex, setCompletionError, setCompletionReason, setIsCompleting }) => {
|
|
9
|
+
const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mountedRef, moduleStateRef, moduleRevisionRef, moduleInvalidationRef, draftRevisionRef, flowGenerationRef, moduleHandlesRef, configurationErrorRef, compiledStepsRef, currentStepIndexRef, currentStepKeyRef, validatedCompletionRef, navigationRevisionRef, preparationRevisionRef, transitionPendingRef, completedRef, completionPromiseRef, isCompletingRef, draftRef, onCompleteRef, ensureModuleReady, commitModuleState, getFreshContext, onValidationFailed, setCurrentStepIndex, setCompletionError, setCompletionReason, setIsCompleting }) => {
|
|
10
10
|
const navigationDirectionRef = (0, react.useRef)("forward");
|
|
11
11
|
const isStepSkippable = (0, react.useCallback)((stepIndex) => {
|
|
12
12
|
const step = compiledStepsRef.current[stepIndex];
|
|
@@ -274,19 +274,109 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
274
274
|
onValidationFailed,
|
|
275
275
|
registry
|
|
276
276
|
]);
|
|
277
|
+
const revalidateModuleBeforeComplete = (0, react.useCallback)(function() {
|
|
278
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (module, expectedDraftRevision) {
|
|
279
|
+
const invalidation = moduleInvalidationRef.current.get(module.key);
|
|
280
|
+
const adapter = require_compiler.resolveFlowModuleAdapter(registry, module.type);
|
|
281
|
+
if (!(invalidation === null || invalidation === void 0 ? void 0 : invalidation.wasReady) || !(adapter === null || adapter === void 0 ? void 0 : adapter.canRevalidateBeforeComplete) || !adapter.validateAutoResolution) return false;
|
|
282
|
+
const moduleRevision = moduleRevisionRef.current.get(module.key) || 0;
|
|
283
|
+
const flowGeneration = flowGenerationRef.current;
|
|
284
|
+
const navigationRevision = navigationRevisionRef.current;
|
|
285
|
+
const compiledFingerprint = require_utils.getCompiledStepsFingerprint(compiledStepsRef.current);
|
|
286
|
+
const isCurrentRun = () => mountedRef.current && !configurationErrorRef.current && flowGenerationRef.current === flowGeneration && navigationRevisionRef.current === navigationRevision && (moduleRevisionRef.current.get(module.key) || 0) === moduleRevision && require_utils.getCompiledStepsFingerprint(compiledStepsRef.current) === compiledFingerprint;
|
|
287
|
+
const isCurrentSelection = () => isCurrentRun() && draftRevisionRef.current === expectedDraftRevision;
|
|
288
|
+
const requireReviewIfCurrent = () => {
|
|
289
|
+
if (isCurrentRun()) commitModuleState(module.key, {
|
|
290
|
+
status: "stale",
|
|
291
|
+
reason: createRuntimeIssue("selection-changed-validation")
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
try {
|
|
295
|
+
const initialContext = getFreshContext();
|
|
296
|
+
if (!initialContext || !isCurrentSelection() || !adapter.canRevalidateBeforeComplete(initialContext, invalidation.change, module)) return false;
|
|
297
|
+
if (!(yield ensureModuleReady(module))) return false;
|
|
298
|
+
if (!isCurrentSelection()) {
|
|
299
|
+
requireReviewIfCurrent();
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
const context = getFreshContext();
|
|
303
|
+
if (!context) return false;
|
|
304
|
+
const validationContext = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, context), {}, {
|
|
305
|
+
updateDraft: (update, meta) => {
|
|
306
|
+
if (isCurrentSelection()) context.updateDraft(update, meta);
|
|
307
|
+
},
|
|
308
|
+
setModuleState: (moduleKey, state) => {
|
|
309
|
+
if (isCurrentSelection()) context.setModuleState(moduleKey, state);
|
|
310
|
+
},
|
|
311
|
+
setModuleStatus: (moduleKey, status, message, error) => {
|
|
312
|
+
if (isCurrentSelection()) context.setModuleStatus(moduleKey, status, message, error);
|
|
313
|
+
},
|
|
314
|
+
setModuleData: (moduleKey, value) => {
|
|
315
|
+
if (isCurrentSelection()) context.setModuleData(moduleKey, value);
|
|
316
|
+
},
|
|
317
|
+
clearModuleData: (moduleKey) => {
|
|
318
|
+
if (isCurrentSelection()) context.clearModuleData(moduleKey);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
const result = require_utils.normalizeFlowValidationResult(yield adapter.validateAutoResolution(validationContext, module));
|
|
322
|
+
if (!isCurrentSelection()) {
|
|
323
|
+
requireReviewIfCurrent();
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
if (!result.valid) {
|
|
327
|
+
commitModuleState(module.key, {
|
|
328
|
+
status: "error",
|
|
329
|
+
message: result.message,
|
|
330
|
+
reason: result.message ? void 0 : createRuntimeIssue("module-validation-failed")
|
|
331
|
+
});
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
commitModuleState(module.key, { status: "ready" });
|
|
335
|
+
return true;
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (isCurrentSelection()) commitModuleState(module.key, {
|
|
338
|
+
status: "error",
|
|
339
|
+
message: require_utils.getSelectionFlowErrorMessage(error),
|
|
340
|
+
error
|
|
341
|
+
});
|
|
342
|
+
else requireReviewIfCurrent();
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
return function(_x2, _x3) {
|
|
347
|
+
return _ref2.apply(this, arguments);
|
|
348
|
+
};
|
|
349
|
+
}(), [
|
|
350
|
+
commitModuleState,
|
|
351
|
+
createRuntimeIssue,
|
|
352
|
+
ensureModuleReady,
|
|
353
|
+
getFreshContext,
|
|
354
|
+
registry
|
|
355
|
+
]);
|
|
277
356
|
const validateFlowForCompletion = (0, react.useCallback)(require_asyncToGenerator._asyncToGenerator(function* () {
|
|
278
357
|
validatedCompletionRef.current = null;
|
|
279
358
|
if (configurationErrorRef.current) return false;
|
|
280
359
|
const currentIndex = currentStepIndexRef.current;
|
|
281
360
|
const allSteps = compiledStepsRef.current;
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
const
|
|
361
|
+
const preparationFingerprint = require_utils.getCompiledStepsFingerprint(allSteps);
|
|
362
|
+
const preparationGeneration = flowGenerationRef.current;
|
|
363
|
+
const preparationNavigation = navigationRevisionRef.current;
|
|
364
|
+
const preparationDraftRevision = draftRevisionRef.current;
|
|
365
|
+
const isCurrentPreparation = () => mountedRef.current && !configurationErrorRef.current && flowGenerationRef.current === preparationGeneration && navigationRevisionRef.current === preparationNavigation && currentStepIndexRef.current === currentIndex && require_utils.getCompiledStepsFingerprint(compiledStepsRef.current) === preparationFingerprint;
|
|
285
366
|
for (const step of allSteps) {
|
|
286
367
|
if (step.index >= currentIndex) break;
|
|
287
368
|
for (const module of step.modules) {
|
|
288
|
-
|
|
369
|
+
let state = moduleStateRef.current[module.key];
|
|
289
370
|
if ((state === null || state === void 0 ? void 0 : state.status) !== "ready") {
|
|
371
|
+
const revalidationModuleRevision = moduleRevisionRef.current.get(module.key) || 0;
|
|
372
|
+
const revalidated = yield revalidateModuleBeforeComplete(module, preparationDraftRevision);
|
|
373
|
+
if (!isCurrentPreparation()) return false;
|
|
374
|
+
if (revalidated && draftRevisionRef.current === preparationDraftRevision) continue;
|
|
375
|
+
if (revalidated && (moduleRevisionRef.current.get(module.key) || 0) === revalidationModuleRevision) commitModuleState(module.key, {
|
|
376
|
+
status: "stale",
|
|
377
|
+
reason: createRuntimeIssue("selection-changed-validation")
|
|
378
|
+
});
|
|
379
|
+
state = moduleStateRef.current[module.key];
|
|
290
380
|
currentStepIndexRef.current = step.index;
|
|
291
381
|
currentStepKeyRef.current = step.key;
|
|
292
382
|
setCurrentStepIndex(step.index);
|
|
@@ -298,6 +388,9 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
298
388
|
}
|
|
299
389
|
}
|
|
300
390
|
}
|
|
391
|
+
const compiledFingerprint = require_utils.getCompiledStepsFingerprint(allSteps);
|
|
392
|
+
const revisionFingerprint = allSteps.flatMap((step) => step.modules).map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|");
|
|
393
|
+
const draftRevision = draftRevisionRef.current;
|
|
301
394
|
if (!(yield validateCurrentStep())) return false;
|
|
302
395
|
if (configurationErrorRef.current) return false;
|
|
303
396
|
const latestSteps = compiledStepsRef.current;
|
|
@@ -336,8 +429,10 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
336
429
|
};
|
|
337
430
|
return true;
|
|
338
431
|
}), [
|
|
432
|
+
commitModuleState,
|
|
339
433
|
createRuntimeIssue,
|
|
340
434
|
onValidationFailed,
|
|
435
|
+
revalidateModuleBeforeComplete,
|
|
341
436
|
validateCurrentStep
|
|
342
437
|
]);
|
|
343
438
|
const complete = (0, react.useCallback)(() => {
|
|
@@ -106,6 +106,13 @@ interface SelectionFlowModuleAdapter<TDraft, TDraftUpdate, TField extends string
|
|
|
106
106
|
hardRequires?: readonly TField[];
|
|
107
107
|
refreshOn?: readonly TField[];
|
|
108
108
|
shouldRefresh?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, change: SelectionFlowDraftChange<TDraft, TField, TModuleType>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Explicitly permits completion to refresh a previously ready, invalidated
|
|
111
|
+
* module without revisiting its UI. The accumulated change starts at its last
|
|
112
|
+
* ready state. Completion still requires validateAutoResolution to succeed
|
|
113
|
+
* without any Draft revision changing; beforeLeave is not run here.
|
|
114
|
+
*/
|
|
115
|
+
canRevalidateBeforeComplete?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, change: SelectionFlowDraftChange<TDraft, TField, TModuleType>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
109
116
|
isApplicable?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
110
117
|
canInitialize?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean | Promise<boolean>;
|
|
111
118
|
refresh?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => void | Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/materials",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.34",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev:tailwind-css": "tailwindcss -c ./tailwind.materials.config.cjs --postcss ./postcss.materials-tailwind.cjs -i ./src/tailwind-input.css -o ./src/pisell-materials.tw.css --watch",
|
|
6
6
|
"build:tailwind-css:once": "tailwindcss -c ./tailwind.materials.config.cjs --postcss ./postcss.materials-tailwind.cjs -i ./src/tailwind-input.css -o ./src/pisell-materials.tw.css",
|