@pisell/materials 1.10.31 → 1.10.33
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 +2 -2
- package/build/lowcode/view.js +2 -2
- package/es/components/PisellSelectionFlow/PisellSelectionFlow.js +24 -2
- package/es/components/PisellSelectionFlow/hooks/useFlowNavigation.js +32 -9
- package/es/components/PisellSelectionFlow/types.d.ts +4 -0
- package/es/components/productCard/cartSkuCard/types.d.ts +2 -0
- package/es/components/productCard/cartSkuCard/variants/A12/index.js +3 -2
- package/lib/components/PisellSelectionFlow/PisellSelectionFlow.js +24 -2
- package/lib/components/PisellSelectionFlow/hooks/useFlowNavigation.js +31 -8
- package/lib/components/PisellSelectionFlow/types.d.ts +4 -0
- package/lib/components/productCard/cartSkuCard/types.d.ts +2 -0
- package/lib/components/productCard/cartSkuCard/variants/A12/index.js +3 -2
- package/package.json +1 -1
|
@@ -298,7 +298,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
298
298
|
draft,
|
|
299
299
|
moduleState
|
|
300
300
|
});
|
|
301
|
-
const { validateCurrentStep, prepareSteps, complete, next, back } = useFlowNavigation({
|
|
301
|
+
const { validateCurrentStep, prepareSteps, complete, next, back, isStepSkippable, navigationDirectionRef } = useFlowNavigation({
|
|
302
302
|
registry,
|
|
303
303
|
draftAdapter,
|
|
304
304
|
createRuntimeIssue,
|
|
@@ -330,6 +330,27 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
330
330
|
setCompletionReason,
|
|
331
331
|
setIsCompleting
|
|
332
332
|
});
|
|
333
|
+
const autoAdvanceAttemptRef = useRef();
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
if (configurationError || completedRef.current || transitionPendingRef.current || !currentStep || !isStepSkippable(resolvedCurrentStepIndex)) return;
|
|
336
|
+
const direction = navigationDirectionRef.current;
|
|
337
|
+
const key = `${direction}:${currentStep.key}:${draftRevisionRef.current}:${currentStep.modules.map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|")}`;
|
|
338
|
+
if (autoAdvanceAttemptRef.current === key) return;
|
|
339
|
+
autoAdvanceAttemptRef.current = key;
|
|
340
|
+
if (direction === "backward") back();
|
|
341
|
+
else next();
|
|
342
|
+
}, [
|
|
343
|
+
configurationError,
|
|
344
|
+
currentStep,
|
|
345
|
+
resolvedCurrentStepIndex,
|
|
346
|
+
moduleState,
|
|
347
|
+
moduleData,
|
|
348
|
+
draft,
|
|
349
|
+
isStepSkippable,
|
|
350
|
+
navigationDirectionRef,
|
|
351
|
+
back,
|
|
352
|
+
next
|
|
353
|
+
]);
|
|
333
354
|
const getState = useCallback(() => {
|
|
334
355
|
const stepIndex = currentStepIndexRef.current;
|
|
335
356
|
return {
|
|
@@ -387,7 +408,8 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
387
408
|
back,
|
|
388
409
|
getState,
|
|
389
410
|
registerModuleHandle,
|
|
390
|
-
getModuleHandle
|
|
411
|
+
getModuleHandle,
|
|
412
|
+
isStepSkippable
|
|
391
413
|
};
|
|
392
414
|
return /* @__PURE__ */ React.createElement(SelectionFlowProvider, { value: contextValue }, children(controller));
|
|
393
415
|
};
|
|
@@ -2,10 +2,26 @@ import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/
|
|
|
2
2
|
import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
3
|
import { resolveFlowModuleAdapter } from "../compiler.js";
|
|
4
4
|
import { getCompiledStepsFingerprint, getSelectionFlowErrorMessage, normalizeFlowBeforeLeaveResult, normalizeFlowValidationResult } from "../utils.js";
|
|
5
|
-
import { useCallback } from "react";
|
|
5
|
+
import { useCallback, useRef } from "react";
|
|
6
6
|
//#region src/components/PisellSelectionFlow/hooks/useFlowNavigation.ts
|
|
7
7
|
/** 导航、校验与提交门禁独立于模块加载生命周期。 */
|
|
8
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 }) => {
|
|
9
|
+
const navigationDirectionRef = useRef("forward");
|
|
10
|
+
const isStepSkippable = useCallback((stepIndex) => {
|
|
11
|
+
const step = compiledStepsRef.current[stepIndex];
|
|
12
|
+
const context = getFreshContext();
|
|
13
|
+
if (!(step === null || step === void 0 ? void 0 : step.modules.length) || !context) return false;
|
|
14
|
+
return step.modules.every((module) => {
|
|
15
|
+
var _moduleStateRef$curre;
|
|
16
|
+
if (((_moduleStateRef$curre = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre === void 0 ? void 0 : _moduleStateRef$curre.status) !== "ready") return false;
|
|
17
|
+
try {
|
|
18
|
+
var _resolveFlowModuleAda, _resolveFlowModuleAda2;
|
|
19
|
+
return ((_resolveFlowModuleAda = resolveFlowModuleAdapter(registry, module.type)) === null || _resolveFlowModuleAda === void 0 || (_resolveFlowModuleAda2 = _resolveFlowModuleAda.isSkippable) === null || _resolveFlowModuleAda2 === void 0 ? void 0 : _resolveFlowModuleAda2.call(_resolveFlowModuleAda, context, module)) === true;
|
|
20
|
+
} catch (_unused) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}, [getFreshContext, registry]);
|
|
9
25
|
const validateModule = useCallback(function() {
|
|
10
26
|
var _ref = _asyncToGenerator(function* (module) {
|
|
11
27
|
const adapter = resolveFlowModuleAdapter(registry, module.type);
|
|
@@ -180,16 +196,16 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
180
196
|
}
|
|
181
197
|
}
|
|
182
198
|
if (!targetModules.find(({ module }) => {
|
|
183
|
-
var _moduleStateRef$
|
|
184
|
-
return ((_moduleStateRef$
|
|
199
|
+
var _moduleStateRef$curre2;
|
|
200
|
+
return ((_moduleStateRef$curre2 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre2 === void 0 ? void 0 : _moduleStateRef$curre2.status) !== "ready";
|
|
185
201
|
})) return isCurrentPreparation() ? { prepared: true } : {
|
|
186
202
|
prepared: false,
|
|
187
203
|
cancelled: true
|
|
188
204
|
};
|
|
189
205
|
}
|
|
190
206
|
const unresolved = targetModules.find(({ module }) => {
|
|
191
|
-
var _moduleStateRef$
|
|
192
|
-
return ((_moduleStateRef$
|
|
207
|
+
var _moduleStateRef$curre3;
|
|
208
|
+
return ((_moduleStateRef$curre3 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre3 === void 0 ? void 0 : _moduleStateRef$curre3.status) !== "ready";
|
|
193
209
|
});
|
|
194
210
|
return unresolved ? {
|
|
195
211
|
prepared: false,
|
|
@@ -288,8 +304,8 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
288
304
|
const latestRevisionFingerprint = latestSteps.flatMap((step) => step.modules).map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|");
|
|
289
305
|
if (compiledFingerprint !== latestCompiledFingerprint || revisionFingerprint !== latestRevisionFingerprint || draftRevision !== draftRevisionRef.current) {
|
|
290
306
|
const targetStep = latestSteps.find((step) => step.modules.some((module) => {
|
|
291
|
-
var _moduleStateRef$
|
|
292
|
-
return ((_moduleStateRef$
|
|
307
|
+
var _moduleStateRef$curre4;
|
|
308
|
+
return ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) !== "ready";
|
|
293
309
|
})) || latestSteps[0];
|
|
294
310
|
const targetModule = targetStep === null || targetStep === void 0 ? void 0 : targetStep.modules[0];
|
|
295
311
|
if (targetStep && targetModule) {
|
|
@@ -328,6 +344,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
328
344
|
if (completedRef.current) return Promise.resolve(true);
|
|
329
345
|
if (completionPromiseRef.current) return completionPromiseRef.current;
|
|
330
346
|
if (transitionPendingRef.current) return Promise.resolve(false);
|
|
347
|
+
navigationDirectionRef.current = "forward";
|
|
331
348
|
transitionPendingRef.current = true;
|
|
332
349
|
const navigationRevision = navigationRevisionRef.current + 1;
|
|
333
350
|
navigationRevisionRef.current = navigationRevision;
|
|
@@ -382,6 +399,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
382
399
|
const currentIndex = currentStepIndexRef.current;
|
|
383
400
|
const allSteps = compiledStepsRef.current;
|
|
384
401
|
if (!allSteps[currentIndex]) return false;
|
|
402
|
+
navigationDirectionRef.current = "forward";
|
|
385
403
|
if (currentIndex >= allSteps.length - 1) return complete();
|
|
386
404
|
const currentStepKey = allSteps[currentIndex].key;
|
|
387
405
|
const navigationRevision = navigationRevisionRef.current + 1;
|
|
@@ -408,13 +426,18 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
408
426
|
back: useCallback(() => {
|
|
409
427
|
var _compiledStepsRef$cur3;
|
|
410
428
|
if (!mountedRef.current || transitionPendingRef.current || currentStepIndexRef.current <= 0) return false;
|
|
429
|
+
let nextIndex = currentStepIndexRef.current - 1;
|
|
430
|
+
while (nextIndex >= 0 && isStepSkippable(nextIndex)) nextIndex -= 1;
|
|
431
|
+
if (nextIndex < 0) return false;
|
|
432
|
+
navigationDirectionRef.current = "backward";
|
|
411
433
|
navigationRevisionRef.current += 1;
|
|
412
|
-
const nextIndex = currentStepIndexRef.current - 1;
|
|
413
434
|
currentStepIndexRef.current = nextIndex;
|
|
414
435
|
currentStepKeyRef.current = (_compiledStepsRef$cur3 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur3 === void 0 ? void 0 : _compiledStepsRef$cur3.key;
|
|
415
436
|
setCurrentStepIndex(nextIndex);
|
|
416
437
|
return true;
|
|
417
|
-
}, [])
|
|
438
|
+
}, [isStepSkippable]),
|
|
439
|
+
isStepSkippable,
|
|
440
|
+
navigationDirectionRef
|
|
418
441
|
};
|
|
419
442
|
};
|
|
420
443
|
//#endregion
|
|
@@ -100,6 +100,8 @@ interface SelectionFlowModuleAdapter<TDraft, TDraftUpdate, TField extends string
|
|
|
100
100
|
type: TModuleType;
|
|
101
101
|
/** 离开所在步骤后仍需随 Draft 变化保持就绪的无界面门禁模块。 */
|
|
102
102
|
initializeWhileInactive?: boolean;
|
|
103
|
+
/** Ready modules may omit their navigation stop; validation and beforeLeave still run. */
|
|
104
|
+
isSkippable?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
103
105
|
provides?: readonly TField[];
|
|
104
106
|
hardRequires?: readonly TField[];
|
|
105
107
|
refreshOn?: readonly TField[];
|
|
@@ -164,6 +166,8 @@ interface PisellSelectionFlowController<TDraft, TDraftUpdate, TField extends str
|
|
|
164
166
|
getState: () => SelectionFlowSnapshot<TDraft, TModuleType>;
|
|
165
167
|
registerModuleHandle: (moduleKey: string, handle: FlowModuleHandle | null) => void;
|
|
166
168
|
getModuleHandle: (moduleKey: string) => FlowModuleHandle | undefined;
|
|
169
|
+
/** True only when every module in the step is ready and explicitly permits skipping. */
|
|
170
|
+
isStepSkippable: (stepIndex: number) => boolean;
|
|
167
171
|
}
|
|
168
172
|
interface PisellSelectionFlowProps<TDraft, TDraftUpdate, TField extends string, TModuleType extends string, TServices = unknown, THostContext = unknown> {
|
|
169
173
|
registry: SelectionFlowModuleRegistry<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>;
|
|
@@ -12,6 +12,8 @@ interface CartSkuCardSlotContext {
|
|
|
12
12
|
}
|
|
13
13
|
interface CartSkuCardA12Slots {
|
|
14
14
|
contentFooter?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
15
|
+
/** 有内容时替代价格、编辑和数量区域,保留默认删除按钮;空值沿用原展示。 */
|
|
16
|
+
status?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
15
17
|
quantityControl?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
16
18
|
actionRail?: (context: CartSkuCardSlotContext & {
|
|
17
19
|
defaultPrice: ReactNode;
|
|
@@ -63,7 +63,7 @@ function getPresentationStyle(presentation) {
|
|
|
63
63
|
return style;
|
|
64
64
|
}
|
|
65
65
|
const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOriginalPrice = false, isShowEditProduct = false, disabled = false, disabledEditClick = false, slots, presentation, onDelete, onEditProduct }) => {
|
|
66
|
-
var _ref8, _dataSource$num, _dataSource$total, _dataSource$origin_to, _slots$contentFooter;
|
|
66
|
+
var _ref8, _dataSource$num, _dataSource$total, _dataSource$origin_to, _slots$contentFooter, _slots$status;
|
|
67
67
|
const display = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.a12) || {};
|
|
68
68
|
const specificationsData = useMemo(() => resolveSpecifications(dataSource), [dataSource]);
|
|
69
69
|
const weighingInfo = useMemo(() => resolveWeighingSnapshot(dataSource), [dataSource]);
|
|
@@ -82,6 +82,7 @@ const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOrigi
|
|
|
82
82
|
}, specification.label ? /* @__PURE__ */ React.createElement("span", { className: `${PREFIX}-a12__specification-label` }, specification.label) : null, /* @__PURE__ */ React.createElement("strong", { className: `${PREFIX}-a12__specification-value` }, specification.value)))) : (dataSource === null || dataSource === void 0 ? void 0 : dataSource.product_option_string) ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__specification-summary` }, dataSource.product_option_string) : null;
|
|
83
83
|
const specifications = (slots === null || slots === void 0 ? void 0 : slots.specifications) ? slots.specifications(_objectSpread2(_objectSpread2({}, slotContext), {}, { defaultSpecifications })) : defaultSpecifications;
|
|
84
84
|
const contentFooter = slots === null || slots === void 0 || (_slots$contentFooter = slots.contentFooter) === null || _slots$contentFooter === void 0 ? void 0 : _slots$contentFooter.call(slots, slotContext);
|
|
85
|
+
const status = slots === null || slots === void 0 || (_slots$status = slots.status) === null || _slots$status === void 0 ? void 0 : _slots$status.call(slots, slotContext);
|
|
85
86
|
const defaultPrice = /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}-a12__price` }, /* @__PURE__ */ React.createElement("strong", null, formatAmount(lineTotal, 2, symbol)), isShowOriginalPrice && originalTotal > 0 && originalTotal !== lineTotal ? /* @__PURE__ */ React.createElement("del", null, formatAmount(originalTotal, 2, symbol)) : null);
|
|
86
87
|
const defaultEdit = Boolean(isShowEditProduct && onEditProduct) ? /* @__PURE__ */ React.createElement("button", {
|
|
87
88
|
type: "button",
|
|
@@ -104,7 +105,7 @@ const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOrigi
|
|
|
104
105
|
event.stopPropagation();
|
|
105
106
|
onDelete(dataSource);
|
|
106
107
|
}
|
|
107
|
-
}, /* @__PURE__ */ React.createElement(IconFont, { type: "pisell2-trash-01" })) : null, defaultPrice, defaultEdit, /* @__PURE__ */ React.createElement("div", { className:
|
|
108
|
+
}, /* @__PURE__ */ React.createElement(IconFont, { type: "pisell2-trash-01" })) : null, status || /* @__PURE__ */ React.createElement(React.Fragment, null, defaultPrice, defaultEdit, /* @__PURE__ */ React.createElement("div", { className: `pisell-cart-sku-card-a12__quantity-control` }, defaultQuantityControl)));
|
|
108
109
|
const actionRail = (slots === null || slots === void 0 ? void 0 : slots.actionRail) ? slots.actionRail(_objectSpread2(_objectSpread2({}, slotContext), {}, {
|
|
109
110
|
defaultPrice,
|
|
110
111
|
defaultEdit,
|
|
@@ -300,7 +300,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
300
300
|
draft,
|
|
301
301
|
moduleState
|
|
302
302
|
});
|
|
303
|
-
const { validateCurrentStep, prepareSteps, complete, next, back } = require_useFlowNavigation.useFlowNavigation({
|
|
303
|
+
const { validateCurrentStep, prepareSteps, complete, next, back, isStepSkippable, navigationDirectionRef } = require_useFlowNavigation.useFlowNavigation({
|
|
304
304
|
registry,
|
|
305
305
|
draftAdapter,
|
|
306
306
|
createRuntimeIssue,
|
|
@@ -332,6 +332,27 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
332
332
|
setCompletionReason,
|
|
333
333
|
setIsCompleting
|
|
334
334
|
});
|
|
335
|
+
const autoAdvanceAttemptRef = (0, react.useRef)();
|
|
336
|
+
(0, react.useEffect)(() => {
|
|
337
|
+
if (configurationError || completedRef.current || transitionPendingRef.current || !currentStep || !isStepSkippable(resolvedCurrentStepIndex)) return;
|
|
338
|
+
const direction = navigationDirectionRef.current;
|
|
339
|
+
const key = `${direction}:${currentStep.key}:${draftRevisionRef.current}:${currentStep.modules.map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|")}`;
|
|
340
|
+
if (autoAdvanceAttemptRef.current === key) return;
|
|
341
|
+
autoAdvanceAttemptRef.current = key;
|
|
342
|
+
if (direction === "backward") back();
|
|
343
|
+
else next();
|
|
344
|
+
}, [
|
|
345
|
+
configurationError,
|
|
346
|
+
currentStep,
|
|
347
|
+
resolvedCurrentStepIndex,
|
|
348
|
+
moduleState,
|
|
349
|
+
moduleData,
|
|
350
|
+
draft,
|
|
351
|
+
isStepSkippable,
|
|
352
|
+
navigationDirectionRef,
|
|
353
|
+
back,
|
|
354
|
+
next
|
|
355
|
+
]);
|
|
335
356
|
const getState = (0, react.useCallback)(() => {
|
|
336
357
|
const stepIndex = currentStepIndexRef.current;
|
|
337
358
|
return {
|
|
@@ -389,7 +410,8 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
|
|
|
389
410
|
back,
|
|
390
411
|
getState,
|
|
391
412
|
registerModuleHandle,
|
|
392
|
-
getModuleHandle
|
|
413
|
+
getModuleHandle,
|
|
414
|
+
isStepSkippable
|
|
393
415
|
};
|
|
394
416
|
return /* @__PURE__ */ react.default.createElement(require_context.SelectionFlowProvider, { value: contextValue }, children(controller));
|
|
395
417
|
};
|
|
@@ -7,6 +7,22 @@ let react = require("react");
|
|
|
7
7
|
//#region src/components/PisellSelectionFlow/hooks/useFlowNavigation.ts
|
|
8
8
|
/** 导航、校验与提交门禁独立于模块加载生命周期。 */
|
|
9
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 }) => {
|
|
10
|
+
const navigationDirectionRef = (0, react.useRef)("forward");
|
|
11
|
+
const isStepSkippable = (0, react.useCallback)((stepIndex) => {
|
|
12
|
+
const step = compiledStepsRef.current[stepIndex];
|
|
13
|
+
const context = getFreshContext();
|
|
14
|
+
if (!(step === null || step === void 0 ? void 0 : step.modules.length) || !context) return false;
|
|
15
|
+
return step.modules.every((module) => {
|
|
16
|
+
var _moduleStateRef$curre;
|
|
17
|
+
if (((_moduleStateRef$curre = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre === void 0 ? void 0 : _moduleStateRef$curre.status) !== "ready") return false;
|
|
18
|
+
try {
|
|
19
|
+
var _resolveFlowModuleAda, _resolveFlowModuleAda2;
|
|
20
|
+
return ((_resolveFlowModuleAda = require_compiler.resolveFlowModuleAdapter(registry, module.type)) === null || _resolveFlowModuleAda === void 0 || (_resolveFlowModuleAda2 = _resolveFlowModuleAda.isSkippable) === null || _resolveFlowModuleAda2 === void 0 ? void 0 : _resolveFlowModuleAda2.call(_resolveFlowModuleAda, context, module)) === true;
|
|
21
|
+
} catch (_unused) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}, [getFreshContext, registry]);
|
|
10
26
|
const validateModule = (0, react.useCallback)(function() {
|
|
11
27
|
var _ref = require_asyncToGenerator._asyncToGenerator(function* (module) {
|
|
12
28
|
const adapter = require_compiler.resolveFlowModuleAdapter(registry, module.type);
|
|
@@ -181,16 +197,16 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
181
197
|
}
|
|
182
198
|
}
|
|
183
199
|
if (!targetModules.find(({ module }) => {
|
|
184
|
-
var _moduleStateRef$
|
|
185
|
-
return ((_moduleStateRef$
|
|
200
|
+
var _moduleStateRef$curre2;
|
|
201
|
+
return ((_moduleStateRef$curre2 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre2 === void 0 ? void 0 : _moduleStateRef$curre2.status) !== "ready";
|
|
186
202
|
})) return isCurrentPreparation() ? { prepared: true } : {
|
|
187
203
|
prepared: false,
|
|
188
204
|
cancelled: true
|
|
189
205
|
};
|
|
190
206
|
}
|
|
191
207
|
const unresolved = targetModules.find(({ module }) => {
|
|
192
|
-
var _moduleStateRef$
|
|
193
|
-
return ((_moduleStateRef$
|
|
208
|
+
var _moduleStateRef$curre3;
|
|
209
|
+
return ((_moduleStateRef$curre3 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre3 === void 0 ? void 0 : _moduleStateRef$curre3.status) !== "ready";
|
|
194
210
|
});
|
|
195
211
|
return unresolved ? {
|
|
196
212
|
prepared: false,
|
|
@@ -289,8 +305,8 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
289
305
|
const latestRevisionFingerprint = latestSteps.flatMap((step) => step.modules).map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|");
|
|
290
306
|
if (compiledFingerprint !== latestCompiledFingerprint || revisionFingerprint !== latestRevisionFingerprint || draftRevision !== draftRevisionRef.current) {
|
|
291
307
|
const targetStep = latestSteps.find((step) => step.modules.some((module) => {
|
|
292
|
-
var _moduleStateRef$
|
|
293
|
-
return ((_moduleStateRef$
|
|
308
|
+
var _moduleStateRef$curre4;
|
|
309
|
+
return ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) !== "ready";
|
|
294
310
|
})) || latestSteps[0];
|
|
295
311
|
const targetModule = targetStep === null || targetStep === void 0 ? void 0 : targetStep.modules[0];
|
|
296
312
|
if (targetStep && targetModule) {
|
|
@@ -329,6 +345,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
329
345
|
if (completedRef.current) return Promise.resolve(true);
|
|
330
346
|
if (completionPromiseRef.current) return completionPromiseRef.current;
|
|
331
347
|
if (transitionPendingRef.current) return Promise.resolve(false);
|
|
348
|
+
navigationDirectionRef.current = "forward";
|
|
332
349
|
transitionPendingRef.current = true;
|
|
333
350
|
const navigationRevision = navigationRevisionRef.current + 1;
|
|
334
351
|
navigationRevisionRef.current = navigationRevision;
|
|
@@ -383,6 +400,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
383
400
|
const currentIndex = currentStepIndexRef.current;
|
|
384
401
|
const allSteps = compiledStepsRef.current;
|
|
385
402
|
if (!allSteps[currentIndex]) return false;
|
|
403
|
+
navigationDirectionRef.current = "forward";
|
|
386
404
|
if (currentIndex >= allSteps.length - 1) return complete();
|
|
387
405
|
const currentStepKey = allSteps[currentIndex].key;
|
|
388
406
|
const navigationRevision = navigationRevisionRef.current + 1;
|
|
@@ -409,13 +427,18 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
409
427
|
back: (0, react.useCallback)(() => {
|
|
410
428
|
var _compiledStepsRef$cur3;
|
|
411
429
|
if (!mountedRef.current || transitionPendingRef.current || currentStepIndexRef.current <= 0) return false;
|
|
430
|
+
let nextIndex = currentStepIndexRef.current - 1;
|
|
431
|
+
while (nextIndex >= 0 && isStepSkippable(nextIndex)) nextIndex -= 1;
|
|
432
|
+
if (nextIndex < 0) return false;
|
|
433
|
+
navigationDirectionRef.current = "backward";
|
|
412
434
|
navigationRevisionRef.current += 1;
|
|
413
|
-
const nextIndex = currentStepIndexRef.current - 1;
|
|
414
435
|
currentStepIndexRef.current = nextIndex;
|
|
415
436
|
currentStepKeyRef.current = (_compiledStepsRef$cur3 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur3 === void 0 ? void 0 : _compiledStepsRef$cur3.key;
|
|
416
437
|
setCurrentStepIndex(nextIndex);
|
|
417
438
|
return true;
|
|
418
|
-
}, [])
|
|
439
|
+
}, [isStepSkippable]),
|
|
440
|
+
isStepSkippable,
|
|
441
|
+
navigationDirectionRef
|
|
419
442
|
};
|
|
420
443
|
};
|
|
421
444
|
//#endregion
|
|
@@ -100,6 +100,8 @@ interface SelectionFlowModuleAdapter<TDraft, TDraftUpdate, TField extends string
|
|
|
100
100
|
type: TModuleType;
|
|
101
101
|
/** 离开所在步骤后仍需随 Draft 变化保持就绪的无界面门禁模块。 */
|
|
102
102
|
initializeWhileInactive?: boolean;
|
|
103
|
+
/** Ready modules may omit their navigation stop; validation and beforeLeave still run. */
|
|
104
|
+
isSkippable?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
103
105
|
provides?: readonly TField[];
|
|
104
106
|
hardRequires?: readonly TField[];
|
|
105
107
|
refreshOn?: readonly TField[];
|
|
@@ -164,6 +166,8 @@ interface PisellSelectionFlowController<TDraft, TDraftUpdate, TField extends str
|
|
|
164
166
|
getState: () => SelectionFlowSnapshot<TDraft, TModuleType>;
|
|
165
167
|
registerModuleHandle: (moduleKey: string, handle: FlowModuleHandle | null) => void;
|
|
166
168
|
getModuleHandle: (moduleKey: string) => FlowModuleHandle | undefined;
|
|
169
|
+
/** True only when every module in the step is ready and explicitly permits skipping. */
|
|
170
|
+
isStepSkippable: (stepIndex: number) => boolean;
|
|
167
171
|
}
|
|
168
172
|
interface PisellSelectionFlowProps<TDraft, TDraftUpdate, TField extends string, TModuleType extends string, TServices = unknown, THostContext = unknown> {
|
|
169
173
|
registry: SelectionFlowModuleRegistry<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>;
|
|
@@ -12,6 +12,8 @@ interface CartSkuCardSlotContext {
|
|
|
12
12
|
}
|
|
13
13
|
interface CartSkuCardA12Slots {
|
|
14
14
|
contentFooter?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
15
|
+
/** 有内容时替代价格、编辑和数量区域,保留默认删除按钮;空值沿用原展示。 */
|
|
16
|
+
status?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
15
17
|
quantityControl?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
16
18
|
actionRail?: (context: CartSkuCardSlotContext & {
|
|
17
19
|
defaultPrice: ReactNode;
|
|
@@ -66,7 +66,7 @@ function getPresentationStyle(presentation) {
|
|
|
66
66
|
return style;
|
|
67
67
|
}
|
|
68
68
|
const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOriginalPrice = false, isShowEditProduct = false, disabled = false, disabledEditClick = false, slots, presentation, onDelete, onEditProduct }) => {
|
|
69
|
-
var _ref8, _dataSource$num, _dataSource$total, _dataSource$origin_to, _slots$contentFooter;
|
|
69
|
+
var _ref8, _dataSource$num, _dataSource$total, _dataSource$origin_to, _slots$contentFooter, _slots$status;
|
|
70
70
|
const display = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.a12) || {};
|
|
71
71
|
const specificationsData = (0, react.useMemo)(() => resolveSpecifications(dataSource), [dataSource]);
|
|
72
72
|
const weighingInfo = (0, react.useMemo)(() => (0, _pisell_utils.resolveWeighingSnapshot)(dataSource), [dataSource]);
|
|
@@ -85,6 +85,7 @@ const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOrigi
|
|
|
85
85
|
}, specification.label ? /* @__PURE__ */ react.default.createElement("span", { className: `${require_index$2.PREFIX}-a12__specification-label` }, specification.label) : null, /* @__PURE__ */ react.default.createElement("strong", { className: `${require_index$2.PREFIX}-a12__specification-value` }, specification.value)))) : (dataSource === null || dataSource === void 0 ? void 0 : dataSource.product_option_string) ? /* @__PURE__ */ react.default.createElement("div", { className: `${require_index$2.PREFIX}-a12__specification-summary` }, dataSource.product_option_string) : null;
|
|
86
86
|
const specifications = (slots === null || slots === void 0 ? void 0 : slots.specifications) ? slots.specifications(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, slotContext), {}, { defaultSpecifications })) : defaultSpecifications;
|
|
87
87
|
const contentFooter = slots === null || slots === void 0 || (_slots$contentFooter = slots.contentFooter) === null || _slots$contentFooter === void 0 ? void 0 : _slots$contentFooter.call(slots, slotContext);
|
|
88
|
+
const status = slots === null || slots === void 0 || (_slots$status = slots.status) === null || _slots$status === void 0 ? void 0 : _slots$status.call(slots, slotContext);
|
|
88
89
|
const defaultPrice = /* @__PURE__ */ react.default.createElement("div", { className: `${require_index$2.PREFIX}-a12__price` }, /* @__PURE__ */ react.default.createElement("strong", null, (0, _pisell_utils.formatAmount)(lineTotal, 2, symbol)), isShowOriginalPrice && originalTotal > 0 && originalTotal !== lineTotal ? /* @__PURE__ */ react.default.createElement("del", null, (0, _pisell_utils.formatAmount)(originalTotal, 2, symbol)) : null);
|
|
89
90
|
const defaultEdit = Boolean(isShowEditProduct && onEditProduct) ? /* @__PURE__ */ react.default.createElement("button", {
|
|
90
91
|
type: "button",
|
|
@@ -107,7 +108,7 @@ const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOrigi
|
|
|
107
108
|
event.stopPropagation();
|
|
108
109
|
onDelete(dataSource);
|
|
109
110
|
}
|
|
110
|
-
}, /* @__PURE__ */ react.default.createElement(require_index.default, { type: "pisell2-trash-01" })) : null, defaultPrice, defaultEdit, /* @__PURE__ */ react.default.createElement("div", { className:
|
|
111
|
+
}, /* @__PURE__ */ react.default.createElement(require_index.default, { type: "pisell2-trash-01" })) : null, status || /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, defaultPrice, defaultEdit, /* @__PURE__ */ react.default.createElement("div", { className: `pisell-cart-sku-card-a12__quantity-control` }, defaultQuantityControl)));
|
|
111
112
|
const actionRail = (slots === null || slots === void 0 ? void 0 : slots.actionRail) ? slots.actionRail(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, slotContext), {}, {
|
|
112
113
|
defaultPrice,
|
|
113
114
|
defaultEdit,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/materials",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.33",
|
|
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",
|