@pisell/materials 6.12.83 → 6.12.85
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/meta.js +2 -2
- package/build/lowcode/preview.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +2 -2
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +2 -2
- package/es/components/PisellSelectionFlow/PisellSelectionFlow.js +30 -2
- package/es/components/PisellSelectionFlow/hooks/useFlowModuleLifecycle.js +24 -7
- package/es/components/PisellSelectionFlow/hooks/useFlowNavigation.js +132 -14
- package/es/components/PisellSelectionFlow/types.d.ts +11 -0
- package/es/components/pisellLookup/PisellLookup.js +1 -2
- package/es/components/pisellLookup/components/LookupResultHost.js +3 -3
- package/es/components/pisellLookup/docs/pisellLookup.md +0 -1
- package/es/components/pisellLookup/types.d.ts +0 -3
- package/es/components/productCard/cartSkuCard/types.d.ts +0 -2
- package/es/components/productCard/cartSkuCard/variants/A12/index.js +2 -3
- package/es/pisell-materials.tw.css +1 -1
- package/lib/components/PisellSelectionFlow/PisellSelectionFlow.js +30 -2
- package/lib/components/PisellSelectionFlow/hooks/useFlowModuleLifecycle.js +24 -7
- package/lib/components/PisellSelectionFlow/hooks/useFlowNavigation.js +131 -13
- package/lib/components/PisellSelectionFlow/types.d.ts +11 -0
- package/lib/components/pisellLookup/PisellLookup.js +1 -2
- package/lib/components/pisellLookup/components/LookupResultHost.js +3 -3
- package/lib/components/pisellLookup/docs/pisellLookup.md +0 -1
- package/lib/components/pisellLookup/types.d.ts +0 -3
- package/lib/components/productCard/cartSkuCard/types.d.ts +0 -2
- package/lib/components/productCard/cartSkuCard/variants/A12/index.js +2 -3
- package/lib/pisell-materials.tw.css +1 -1
- package/package.json +3 -3
|
@@ -6,7 +6,23 @@ 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
|
+
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,
|
|
@@ -258,19 +274,109 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
258
274
|
onValidationFailed,
|
|
259
275
|
registry
|
|
260
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
|
+
]);
|
|
261
356
|
const validateFlowForCompletion = (0, react.useCallback)(require_asyncToGenerator._asyncToGenerator(function* () {
|
|
262
357
|
validatedCompletionRef.current = null;
|
|
263
358
|
if (configurationErrorRef.current) return false;
|
|
264
359
|
const currentIndex = currentStepIndexRef.current;
|
|
265
360
|
const allSteps = compiledStepsRef.current;
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
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;
|
|
269
366
|
for (const step of allSteps) {
|
|
270
367
|
if (step.index >= currentIndex) break;
|
|
271
368
|
for (const module of step.modules) {
|
|
272
|
-
|
|
369
|
+
let state = moduleStateRef.current[module.key];
|
|
273
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];
|
|
274
380
|
currentStepIndexRef.current = step.index;
|
|
275
381
|
currentStepKeyRef.current = step.key;
|
|
276
382
|
setCurrentStepIndex(step.index);
|
|
@@ -282,6 +388,9 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
282
388
|
}
|
|
283
389
|
}
|
|
284
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;
|
|
285
394
|
if (!(yield validateCurrentStep())) return false;
|
|
286
395
|
if (configurationErrorRef.current) return false;
|
|
287
396
|
const latestSteps = compiledStepsRef.current;
|
|
@@ -289,8 +398,8 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
289
398
|
const latestRevisionFingerprint = latestSteps.flatMap((step) => step.modules).map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|");
|
|
290
399
|
if (compiledFingerprint !== latestCompiledFingerprint || revisionFingerprint !== latestRevisionFingerprint || draftRevision !== draftRevisionRef.current) {
|
|
291
400
|
const targetStep = latestSteps.find((step) => step.modules.some((module) => {
|
|
292
|
-
var _moduleStateRef$
|
|
293
|
-
return ((_moduleStateRef$
|
|
401
|
+
var _moduleStateRef$curre4;
|
|
402
|
+
return ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) !== "ready";
|
|
294
403
|
})) || latestSteps[0];
|
|
295
404
|
const targetModule = targetStep === null || targetStep === void 0 ? void 0 : targetStep.modules[0];
|
|
296
405
|
if (targetStep && targetModule) {
|
|
@@ -320,8 +429,10 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
320
429
|
};
|
|
321
430
|
return true;
|
|
322
431
|
}), [
|
|
432
|
+
commitModuleState,
|
|
323
433
|
createRuntimeIssue,
|
|
324
434
|
onValidationFailed,
|
|
435
|
+
revalidateModuleBeforeComplete,
|
|
325
436
|
validateCurrentStep
|
|
326
437
|
]);
|
|
327
438
|
const complete = (0, react.useCallback)(() => {
|
|
@@ -329,6 +440,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
329
440
|
if (completedRef.current) return Promise.resolve(true);
|
|
330
441
|
if (completionPromiseRef.current) return completionPromiseRef.current;
|
|
331
442
|
if (transitionPendingRef.current) return Promise.resolve(false);
|
|
443
|
+
navigationDirectionRef.current = "forward";
|
|
332
444
|
transitionPendingRef.current = true;
|
|
333
445
|
const navigationRevision = navigationRevisionRef.current + 1;
|
|
334
446
|
navigationRevisionRef.current = navigationRevision;
|
|
@@ -383,6 +495,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
383
495
|
const currentIndex = currentStepIndexRef.current;
|
|
384
496
|
const allSteps = compiledStepsRef.current;
|
|
385
497
|
if (!allSteps[currentIndex]) return false;
|
|
498
|
+
navigationDirectionRef.current = "forward";
|
|
386
499
|
if (currentIndex >= allSteps.length - 1) return complete();
|
|
387
500
|
const currentStepKey = allSteps[currentIndex].key;
|
|
388
501
|
const navigationRevision = navigationRevisionRef.current + 1;
|
|
@@ -409,13 +522,18 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
|
|
|
409
522
|
back: (0, react.useCallback)(() => {
|
|
410
523
|
var _compiledStepsRef$cur3;
|
|
411
524
|
if (!mountedRef.current || transitionPendingRef.current || currentStepIndexRef.current <= 0) return false;
|
|
525
|
+
let nextIndex = currentStepIndexRef.current - 1;
|
|
526
|
+
while (nextIndex >= 0 && isStepSkippable(nextIndex)) nextIndex -= 1;
|
|
527
|
+
if (nextIndex < 0) return false;
|
|
528
|
+
navigationDirectionRef.current = "backward";
|
|
412
529
|
navigationRevisionRef.current += 1;
|
|
413
|
-
const nextIndex = currentStepIndexRef.current - 1;
|
|
414
530
|
currentStepIndexRef.current = nextIndex;
|
|
415
531
|
currentStepKeyRef.current = (_compiledStepsRef$cur3 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur3 === void 0 ? void 0 : _compiledStepsRef$cur3.key;
|
|
416
532
|
setCurrentStepIndex(nextIndex);
|
|
417
533
|
return true;
|
|
418
|
-
}, [])
|
|
534
|
+
}, [isStepSkippable]),
|
|
535
|
+
isStepSkippable,
|
|
536
|
+
navigationDirectionRef
|
|
419
537
|
};
|
|
420
538
|
};
|
|
421
539
|
//#endregion
|
|
@@ -100,10 +100,19 @@ 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[];
|
|
106
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;
|
|
107
116
|
isApplicable?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean;
|
|
108
117
|
canInitialize?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => boolean | Promise<boolean>;
|
|
109
118
|
refresh?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>, module: CompiledSelectionFlowModuleConfig<TModuleType>) => void | Promise<void>;
|
|
@@ -164,6 +173,8 @@ interface PisellSelectionFlowController<TDraft, TDraftUpdate, TField extends str
|
|
|
164
173
|
getState: () => SelectionFlowSnapshot<TDraft, TModuleType>;
|
|
165
174
|
registerModuleHandle: (moduleKey: string, handle: FlowModuleHandle | null) => void;
|
|
166
175
|
getModuleHandle: (moduleKey: string) => FlowModuleHandle | undefined;
|
|
176
|
+
/** True only when every module in the step is ready and explicitly permits skipping. */
|
|
177
|
+
isStepSkippable: (stepIndex: number) => boolean;
|
|
167
178
|
}
|
|
168
179
|
interface PisellSelectionFlowProps<TDraft, TDraftUpdate, TField extends string, TModuleType extends string, TServices = unknown, THostContext = unknown> {
|
|
169
180
|
registry: SelectionFlowModuleRegistry<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>;
|
|
@@ -29,7 +29,7 @@ require("./PisellLookup.less");
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
const PisellLookupComponent = (0, react.forwardRef)((props, ref) => {
|
|
32
|
-
const { showTrigger = true, triggerType = "input", trigger, triggerText, triggerIcon, buttonText = require_index.getText("pisell-lookup-button-text"), placeholder = require_index.getText("pisell-lookup-placeholder"), size = "middle", disabled = false, showPrefixIcon = false, prefixIcon, addonBefore, showClear = true, showConfirmButton = true, confirmButtonText = require_index.getText("pisell-lookup-confirm-button-text"), confirmButtonDisabled = false, closeButtonText = require_index.getText("pisell-lookup-close"), value, defaultValue, onChange, onSearch, searchMode = "realtime", debounceTime = 300, allowRepeatSearch = false, showScan = true, onScan, showHistory = false, historyKey = "pisell_lookup_history", maxHistoryCount = 10, onLoadHistory, onSaveHistory, historyRender, showSuggestions = false, onLoadSuggestions, suggestionsRender, showHotWords = false, onLoadHotWords, hotWordsRender, displayType: displayTypeProp, resultRender, loading = false, emptyRender,
|
|
32
|
+
const { showTrigger = true, triggerType = "input", trigger, triggerText, triggerIcon, buttonText = require_index.getText("pisell-lookup-button-text"), placeholder = require_index.getText("pisell-lookup-placeholder"), size = "middle", disabled = false, showPrefixIcon = false, prefixIcon, addonBefore, showClear = true, showConfirmButton = true, confirmButtonText = require_index.getText("pisell-lookup-confirm-button-text"), confirmButtonDisabled = false, closeButtonText = require_index.getText("pisell-lookup-close"), value, defaultValue, onChange, onSearch, searchMode = "realtime", debounceTime = 300, allowRepeatSearch = false, showScan = true, onScan, showHistory = false, historyKey = "pisell_lookup_history", maxHistoryCount = 10, onLoadHistory, onSaveHistory, historyRender, showSuggestions = false, onLoadSuggestions, suggestionsRender, showHotWords = false, onLoadHotWords, hotWordsRender, displayType: displayTypeProp, resultRender, loading = false, emptyRender, modalWidth, modalStyle, modalCentered = false, modalTransitionName, getContainer, drawerWidth, drawerHeight, drawerPlacement, drawerTitle, drawerClosable, popupWidth, containerStyle, containerClassName, visible: visibleProp, defaultVisible, onVisibleChange, onOpen, onClose, mask = false, maskClosable, clearOnClose = false, autoFocusOnOpen = true, inputRender, headerRender, className, style, zIndex } = props;
|
|
33
33
|
/**
|
|
34
34
|
* 智能判断展示类型
|
|
35
35
|
*/
|
|
@@ -419,7 +419,6 @@ const PisellLookupComponent = (0, react.forwardRef)((props, ref) => {
|
|
|
419
419
|
className: `pisell-lookup ${className || ""}`,
|
|
420
420
|
style
|
|
421
421
|
}, showTrigger ? renderTrigger() : null, /* @__PURE__ */ react.default.createElement(require_LookupResultHost.LookupResultHost, {
|
|
422
|
-
containerComponent,
|
|
423
422
|
displayType,
|
|
424
423
|
visible,
|
|
425
424
|
onClose: close,
|
|
@@ -13,7 +13,7 @@ let antd = require("antd");
|
|
|
13
13
|
*/
|
|
14
14
|
const LookupResultHost = (props) => {
|
|
15
15
|
const theme = require_index$2.usePisellTheme();
|
|
16
|
-
const {
|
|
16
|
+
const { displayType, visible, onClose, children, modalWidth = 834, modalStyle, modalCentered = false, modalTransitionName, getContainer, drawerWidth = 378, drawerHeight, drawerPlacement = "right", drawerTitle = require_index.getText("pisell-lookup-confirm-button-text"), drawerClosable = true, popupWidth, containerStyle, containerClassName, mask = false, maskClosable = true, zIndex, onAfterOpen } = props;
|
|
17
17
|
const portalContentStyle = theme ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, containerStyle), theme.cssVariables) : containerStyle;
|
|
18
18
|
/**
|
|
19
19
|
* 渲染 Inline 模式
|
|
@@ -61,7 +61,7 @@ const LookupResultHost = (props) => {
|
|
|
61
61
|
].filter(Boolean).join(" ");
|
|
62
62
|
const modalClassName = ["pisell-lookup-modal-container", containerClassName || ""].filter(Boolean).join(" ");
|
|
63
63
|
const wrapClassName = hasCustomContainer ? "pisell-lookup-modal-custom-container" : "";
|
|
64
|
-
return /* @__PURE__ */ react.default.createElement(
|
|
64
|
+
return /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
65
65
|
renderType: "modal",
|
|
66
66
|
props: {
|
|
67
67
|
open: visible,
|
|
@@ -97,7 +97,7 @@ const LookupResultHost = (props) => {
|
|
|
97
97
|
const renderDrawer = () => {
|
|
98
98
|
const effectiveMaskClosable = mask ? maskClosable : false;
|
|
99
99
|
const drawerClassName = `pisell-lookup-drawer-container ${!mask ? "pisell-lookup-drawer-no-mask" : ""} ${containerClassName || ""}`;
|
|
100
|
-
return /* @__PURE__ */ react.default.createElement(
|
|
100
|
+
return /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
101
101
|
renderType: "drawer",
|
|
102
102
|
props: {
|
|
103
103
|
open: visible,
|
|
@@ -1253,7 +1253,6 @@ export default () => {
|
|
|
1253
1253
|
| popupWidth | `number \| string` | - | Popup 宽度 |
|
|
1254
1254
|
| containerStyle | `CSSProperties` | - | 容器自定义样式 |
|
|
1255
1255
|
| containerClassName | `string` | - | 容器自定义类名 |
|
|
1256
|
-
| containerComponent | `React.ComponentType<PisellContainerProps<'modal' \| 'drawer'>>` | `PisellContainer` | 替换 Modal / Drawer 容器;接收 `renderType`、`props` 和 `children`,PisellFind 同样支持 |
|
|
1257
1256
|
|
|
1258
1257
|
#### 可见性控制
|
|
1259
1258
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PisellContainerProps } from "../pisellContainer/index.js";
|
|
2
1
|
import React from "react";
|
|
3
2
|
|
|
4
3
|
//#region src/components/pisellLookup/types.d.ts
|
|
@@ -318,8 +317,6 @@ interface PisellLookupProps {
|
|
|
318
317
|
* @returns 空状态内容
|
|
319
318
|
*/
|
|
320
319
|
emptyRender?: () => React.ReactNode;
|
|
321
|
-
/** 替换 Modal / Drawer 容器,默认使用 PisellContainer。 */
|
|
322
|
-
containerComponent?: React.ComponentType<PisellContainerProps<'modal' | 'drawer'>>;
|
|
323
320
|
/**
|
|
324
321
|
* Modal 宽度
|
|
325
322
|
* @default 834
|
|
@@ -12,8 +12,6 @@ interface CartSkuCardSlotContext {
|
|
|
12
12
|
}
|
|
13
13
|
interface CartSkuCardA12Slots {
|
|
14
14
|
contentFooter?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
15
|
-
/** 有内容时替代价格、编辑和数量区域,保留默认删除按钮;空值沿用原展示。 */
|
|
16
|
-
status?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
17
15
|
quantityControl?: (context: CartSkuCardSlotContext) => ReactNode;
|
|
18
16
|
actionRail?: (context: CartSkuCardSlotContext & {
|
|
19
17
|
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;
|
|
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,7 +85,6 @@ 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);
|
|
89
88
|
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);
|
|
90
89
|
const defaultEdit = Boolean(isShowEditProduct && onEditProduct) ? /* @__PURE__ */ react.default.createElement("button", {
|
|
91
90
|
type: "button",
|
|
@@ -108,7 +107,7 @@ const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOrigi
|
|
|
108
107
|
event.stopPropagation();
|
|
109
108
|
onDelete(dataSource);
|
|
110
109
|
}
|
|
111
|
-
}, /* @__PURE__ */ react.default.createElement(require_index.default, { type: "pisell2-trash-01" })) : null,
|
|
110
|
+
}, /* @__PURE__ */ react.default.createElement(require_index.default, { type: "pisell2-trash-01" })) : null, defaultPrice, defaultEdit, /* @__PURE__ */ react.default.createElement("div", { className: `${require_index$2.PREFIX}-a12__quantity-control` }, defaultQuantityControl));
|
|
112
111
|
const actionRail = (slots === null || slots === void 0 ? void 0 : slots.actionRail) ? slots.actionRail(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, slotContext), {}, {
|
|
113
112
|
defaultPrice,
|
|
114
113
|
defaultEdit,
|