@pisell/materials 6.12.89 → 6.12.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.js +1 -1
  6. package/build/lowcode/view.js +1 -1
  7. package/es/components/PisellFields/index.js +0 -11
  8. package/es/components/PisellSelectionFlow/PisellSelectionFlow.js +16 -5
  9. package/es/components/PisellSelectionFlow/hooks/useFlowNavigation.js +37 -8
  10. package/es/components/PisellSelectionFlow/types.d.ts +2 -0
  11. package/es/components/filter/components/FilterItem/AsyncOptionsSelectWrapper.js +0 -2
  12. package/es/components/filter/components/FilterItem/index.js +0 -11
  13. package/es/components/pisellRecordBoard/shellFrame/ResourceWall/ResourceWallControlPanelLayoutTab.js +0 -2
  14. package/es/components/pisellRecordBoard/utils/recordBoardColumns.js +0 -11
  15. package/es/index.js +0 -11
  16. package/lib/components/PisellSelectionFlow/PisellSelectionFlow.js +16 -5
  17. package/lib/components/PisellSelectionFlow/hooks/useFlowNavigation.js +37 -8
  18. package/lib/components/PisellSelectionFlow/types.d.ts +2 -0
  19. package/package.json +3 -3
  20. package/es/components/pisellCurrency/index.js +0 -13
  21. package/es/components/pisellEmail/index.js +0 -13
  22. package/es/components/pisellLongText/index.js +0 -13
  23. package/es/components/pisellMultipleSelect/index.js +0 -13
  24. package/es/components/pisellNumber/index.js +0 -13
  25. package/es/components/pisellPercent/index.js +0 -13
  26. package/es/components/pisellPhone/index.js +0 -14
  27. package/es/components/pisellRating/index.js +0 -13
  28. package/es/components/pisellSingleLineText/index.js +0 -13
  29. package/es/components/pisellSingleSelect/index.js +0 -13
  30. package/es/components/pisellUrl/index.js +0 -13
@@ -1,25 +1,14 @@
1
1
  import PisellSingleLineText_default from "../pisellSingleLineText/PisellSingleLineText.js";
2
- import "../pisellSingleLineText/index.js";
3
2
  import PisellLongText_default from "../pisellLongText/PisellLongText.js";
4
- import "../pisellLongText/index.js";
5
3
  import MemoizedPisellNumber from "../pisellNumber/PisellNumber.js";
6
- import "../pisellNumber/index.js";
7
4
  import MemoizedPisellCurrency from "../pisellCurrency/PisellCurrency.js";
8
- import "../pisellCurrency/index.js";
9
5
  import MemoizedPisellPercent from "../pisellPercent/PisellPercent.js";
10
- import "../pisellPercent/index.js";
11
6
  import PisellPhone_default from "../pisellPhone/PisellPhone.js";
12
- import "../pisellPhone/index.js";
13
7
  import PisellEmail_default from "../pisellEmail/PisellEmail.js";
14
- import "../pisellEmail/index.js";
15
8
  import PisellUrl_default from "../pisellUrl/PisellUrl.js";
16
- import "../pisellUrl/index.js";
17
9
  import PisellRating_default from "../pisellRating/PisellRating.js";
18
- import "../pisellRating/index.js";
19
10
  import PisellSingleSelect from "../pisellSingleSelect/PisellSingleSelect.js";
20
- import "../pisellSingleSelect/index.js";
21
11
  import PisellMultipleSelect from "../pisellMultipleSelect/PisellMultipleSelect.js";
22
- import "../pisellMultipleSelect/index.js";
23
12
  //#region src/components/PisellFields/index.tsx
24
13
  /**
25
14
  * PisellFields 命名空间
@@ -15,7 +15,7 @@ const createUnexpectedCompileError = (error) => {
15
15
  message: `Selection flow compilation failed: ${getSelectionFlowErrorMessage(error)}`
16
16
  }]);
17
17
  };
18
- const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialStepIndex = 0, preparePresentation = false, onPresentationReady, hostContext, services, children, onDraftChange, onStepChange, onCompiledStepsChange, onValidationFailed, onConfigurationError, onComplete }, ref) => {
18
+ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialStepIndex = 0, preparePresentation = false, resolveInitialStepIndex, onPresentationReady, hostContext, services, children, onDraftChange, onStepChange, onCompiledStepsChange, onValidationFailed, onConfigurationError, onComplete }, ref) => {
19
19
  const mountedRef = useRef(true);
20
20
  const flowGenerationRef = useRef(1);
21
21
  const draftRevisionRef = useRef(0);
@@ -29,6 +29,8 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
29
29
  const presentationTaskRef = useRef(null);
30
30
  const onPresentationReadyRef = useRef(onPresentationReady);
31
31
  onPresentationReadyRef.current = onPresentationReady;
32
+ const resolveInitialStepIndexRef = useRef(resolveInitialStepIndex);
33
+ resolveInitialStepIndexRef.current = resolveInitialStepIndex;
32
34
  const processDraftChangeRef = useRef(() => void 0);
33
35
  const onDraftChangeRef = useRef(onDraftChange);
34
36
  onDraftChangeRef.current = onDraftChange;
@@ -360,6 +362,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
360
362
  const autoAdvanceAttemptRef = useRef();
361
363
  useEffect(() => {
362
364
  if (configurationError || completedRef.current || transitionPendingRef.current || preparePresentation && !presentationReadyRef.current || !currentStep || !isStepSkippable(resolvedCurrentStepIndex)) return;
365
+ if (currentStep.modules.every((module) => automaticModuleKeysRef.current.includes(module.key))) return;
363
366
  const direction = navigationDirectionRef.current;
364
367
  const key = `${direction}:${currentStep.key}:${draftRevisionRef.current}:${currentStep.modules.map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|")}`;
365
368
  if (autoAdvanceAttemptRef.current === key) return;
@@ -378,14 +381,15 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
378
381
  back,
379
382
  next,
380
383
  preparePresentation,
381
- presentationReady
384
+ presentationReady,
385
+ automaticModuleKeys
382
386
  ]);
383
387
  useEffect(() => {
384
388
  if (!preparePresentation || presentationReadyRef.current || configurationError || presentationTaskRef.current) return;
385
389
  const generation = flowGenerationRef.current;
386
390
  const isCurrent = () => mountedRef.current && flowGenerationRef.current === generation;
387
391
  const task = _asyncToGenerator(function* () {
388
- var _firstVisible$index, _compiledStepsRef$cur, _onPresentationReadyR2;
392
+ var _visibleSteps$0$index, _visibleSteps$, _compiledStepsRef$cur, _onPresentationReadyR2;
389
393
  const modules = compiledStepsRef.current.reduce((allModules, step) => allModules.concat(step.modules), []);
390
394
  for (let pass = 0; pass <= modules.length; pass += 1) {
391
395
  for (const module of modules) {
@@ -417,8 +421,15 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
417
421
  }).map((module) => module.key);
418
422
  automaticModuleKeysRef.current = automatic;
419
423
  setAutomaticModuleKeys(automatic);
420
- const firstVisible = compiledStepsRef.current.find((step) => step.modules.some((module) => !automatic.includes(module.key)));
421
- const initialIndex = (_firstVisible$index = firstVisible === null || firstVisible === void 0 ? void 0 : firstVisible.index) !== null && _firstVisible$index !== void 0 ? _firstVisible$index : Math.max(0, compiledStepsRef.current.length - 1);
424
+ const visibleSteps = compiledStepsRef.current.filter((step) => step.modules.some((module) => !automatic.includes(module.key)));
425
+ let initialIndex = (_visibleSteps$0$index = (_visibleSteps$ = visibleSteps[0]) === null || _visibleSteps$ === void 0 ? void 0 : _visibleSteps$.index) !== null && _visibleSteps$0$index !== void 0 ? _visibleSteps$0$index : Math.max(0, compiledStepsRef.current.length - 1);
426
+ try {
427
+ var _resolveInitialStepIn;
428
+ const context = getFreshContext();
429
+ const requestedIndex = context && ((_resolveInitialStepIn = resolveInitialStepIndexRef.current) === null || _resolveInitialStepIn === void 0 ? void 0 : _resolveInitialStepIn.call(resolveInitialStepIndexRef, context));
430
+ const requestedStep = visibleSteps.find((step) => step.index === requestedIndex);
431
+ if (requestedStep) initialIndex = requestedStep.index;
432
+ } catch (_unused2) {}
422
433
  currentStepIndexRef.current = initialIndex;
423
434
  currentStepKeyRef.current = (_compiledStepsRef$cur = compiledStepsRef.current[initialIndex]) === null || _compiledStepsRef$cur === void 0 ? void 0 : _compiledStepsRef$cur.key;
424
435
  setCurrentStepIndex(initialIndex);
@@ -14,6 +14,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
14
14
  return step.modules.every((module) => {
15
15
  var _moduleStateRef$curre;
16
16
  if (((_moduleStateRef$curre = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre === void 0 ? void 0 : _moduleStateRef$curre.status) !== "ready") return false;
17
+ if (automaticModuleKeysRef.current.includes(module.key)) return true;
17
18
  try {
18
19
  var _resolveFlowModuleAda, _resolveFlowModuleAda2;
19
20
  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;
@@ -365,9 +366,32 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
365
366
  const preparationGeneration = flowGenerationRef.current;
366
367
  const preparationNavigation = navigationRevisionRef.current;
367
368
  const isCurrentPreparation = () => mountedRef.current && !configurationErrorRef.current && flowGenerationRef.current === preparationGeneration && navigationRevisionRef.current === preparationNavigation && currentStepIndexRef.current === currentIndex && getCompiledStepsFingerprint(compiledStepsRef.current) === preparationFingerprint;
368
- for (const step of allSteps) for (const module of step.modules) {
369
- if (automaticModuleKeysRef.current.includes(module.key) && !(yield validateModule(module))) return false;
370
- if (!isCurrentPreparation()) return false;
369
+ const automaticModules = [];
370
+ for (const step of allSteps) for (const module of step.modules) if (automaticModuleKeysRef.current.includes(module.key)) automaticModules.push(module);
371
+ for (let pass = 0; pass <= automaticModules.length; pass += 1) {
372
+ for (const module of automaticModules) {
373
+ var _moduleStateRef$curre4;
374
+ if (!isCurrentPreparation()) return false;
375
+ if (pass > 0 && ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) === "ready") continue;
376
+ if (!(yield validateModule(module)) || !isCurrentPreparation()) return false;
377
+ }
378
+ if (automaticModules.every((module) => {
379
+ var _moduleStateRef$curre5;
380
+ return ((_moduleStateRef$curre5 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre5 === void 0 ? void 0 : _moduleStateRef$curre5.status) === "ready";
381
+ })) break;
382
+ }
383
+ const unresolvedAutomatic = automaticModules.find((module) => {
384
+ var _moduleStateRef$curre6;
385
+ return ((_moduleStateRef$curre6 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre6 === void 0 ? void 0 : _moduleStateRef$curre6.status) !== "ready";
386
+ });
387
+ if (unresolvedAutomatic) {
388
+ onAutomaticModuleFailure === null || onAutomaticModuleFailure === void 0 || onAutomaticModuleFailure(unresolvedAutomatic);
389
+ const state = moduleStateRef.current[unresolvedAutomatic.key];
390
+ onValidationFailed === null || onValidationFailed === void 0 || onValidationFailed(unresolvedAutomatic, {
391
+ message: state === null || state === void 0 ? void 0 : state.message,
392
+ reason: (state === null || state === void 0 ? void 0 : state.reason) || createRuntimeIssue("previous-step-review")
393
+ });
394
+ return false;
371
395
  }
372
396
  const preparationDraftRevision = draftRevisionRef.current;
373
397
  for (const step of allSteps) {
@@ -405,8 +429,8 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
405
429
  const latestRevisionFingerprint = latestSteps.flatMap((step) => step.modules).map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|");
406
430
  if (compiledFingerprint !== latestCompiledFingerprint || revisionFingerprint !== latestRevisionFingerprint || draftRevision !== draftRevisionRef.current) {
407
431
  const targetStep = latestSteps.find((step) => step.modules.some((module) => {
408
- var _moduleStateRef$curre4;
409
- return ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) !== "ready";
432
+ var _moduleStateRef$curre7;
433
+ return ((_moduleStateRef$curre7 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre7 === void 0 ? void 0 : _moduleStateRef$curre7.status) !== "ready";
410
434
  })) || latestSteps[0];
411
435
  const targetModule = targetStep === null || targetStep === void 0 ? void 0 : targetStep.modules[0];
412
436
  if (targetStep && targetModule) {
@@ -438,6 +462,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
438
462
  }), [
439
463
  commitModuleState,
440
464
  createRuntimeIssue,
465
+ onAutomaticModuleFailure,
441
466
  onValidationFailed,
442
467
  revalidateModuleBeforeComplete,
443
468
  validateCurrentStep,
@@ -541,15 +566,19 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
541
566
  validateCurrentStep
542
567
  ]),
543
568
  back: useCallback(() => {
544
- var _compiledStepsRef$cur2, _compiledStepsRef$cur3;
569
+ var _compiledStepsRef$cur2;
545
570
  if (!mountedRef.current || transitionPendingRef.current || currentStepIndexRef.current <= 0) return false;
546
571
  let nextIndex = currentStepIndexRef.current - 1;
547
- while (nextIndex >= 0 && (isStepSkippable(nextIndex) || ((_compiledStepsRef$cur2 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur2 === void 0 ? void 0 : _compiledStepsRef$cur2.modules.every((module) => automaticModuleKeysRef.current.includes(module.key))))) nextIndex -= 1;
572
+ while (nextIndex >= 0) {
573
+ const step = compiledStepsRef.current[nextIndex];
574
+ if (!((step === null || step === void 0 ? void 0 : step.modules.length) > 0 && step.modules.every((module) => automaticModuleKeysRef.current.includes(module.key))) && !isStepSkippable(nextIndex)) break;
575
+ nextIndex -= 1;
576
+ }
548
577
  if (nextIndex < 0) return false;
549
578
  navigationDirectionRef.current = "backward";
550
579
  navigationRevisionRef.current += 1;
551
580
  currentStepIndexRef.current = nextIndex;
552
- currentStepKeyRef.current = (_compiledStepsRef$cur3 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur3 === void 0 ? void 0 : _compiledStepsRef$cur3.key;
581
+ currentStepKeyRef.current = (_compiledStepsRef$cur2 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur2 === void 0 ? void 0 : _compiledStepsRef$cur2.key;
553
582
  setCurrentStepIndex(nextIndex);
554
583
  return true;
555
584
  }, [isStepSkippable]),
@@ -188,6 +188,8 @@ interface PisellSelectionFlowProps<TDraft, TDraftUpdate, TField extends string,
188
188
  initialStepIndex?: number;
189
189
  /** Resolve a stable presentation before mounting interactive module components. */
190
190
  preparePresentation?: boolean;
191
+ /** Choose the entry step from prepared defaults without hiding earlier steps. */
192
+ resolveInitialStepIndex?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>) => number | undefined;
191
193
  onPresentationReady?: (automaticModuleKeys: readonly string[]) => void;
192
194
  hostContext?: THostContext;
193
195
  services: TServices;
@@ -1,9 +1,7 @@
1
1
  import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
2
  import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
3
3
  import PisellSingleSelect from "../../../pisellSingleSelect/PisellSingleSelect.js";
4
- import "../../../pisellSingleSelect/index.js";
5
4
  import PisellMultipleSelect from "../../../pisellMultipleSelect/PisellMultipleSelect.js";
6
- import "../../../pisellMultipleSelect/index.js";
7
5
  import React, { useEffect, useState } from "react";
8
6
  import { Spin } from "antd";
9
7
  //#region src/components/filter/components/FilterItem/AsyncOptionsSelectWrapper.tsx
@@ -1,28 +1,17 @@
1
1
  import { getText } from "../../../../locales/index.js";
2
2
  import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
3
3
  import PisellSingleLineText_default from "../../../pisellSingleLineText/PisellSingleLineText.js";
4
- import "../../../pisellSingleLineText/index.js";
5
4
  import PisellLongText_default from "../../../pisellLongText/PisellLongText.js";
6
- import "../../../pisellLongText/index.js";
7
5
  import MemoizedPisellNumber from "../../../pisellNumber/PisellNumber.js";
8
- import "../../../pisellNumber/index.js";
9
6
  import MemoizedPisellCurrency from "../../../pisellCurrency/PisellCurrency.js";
10
- import "../../../pisellCurrency/index.js";
11
7
  import MemoizedPisellPercent from "../../../pisellPercent/PisellPercent.js";
12
- import "../../../pisellPercent/index.js";
13
8
  import PisellPhone_default from "../../../pisellPhone/PisellPhone.js";
14
- import "../../../pisellPhone/index.js";
15
9
  import PisellEmail_default from "../../../pisellEmail/PisellEmail.js";
16
- import "../../../pisellEmail/index.js";
17
10
  import PisellUrl_default from "../../../pisellUrl/PisellUrl.js";
18
- import "../../../pisellUrl/index.js";
19
11
  import PisellRating_default from "../../../pisellRating/PisellRating.js";
20
- import "../../../pisellRating/index.js";
21
12
  import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
22
13
  import PisellSingleSelect from "../../../pisellSingleSelect/PisellSingleSelect.js";
23
- import "../../../pisellSingleSelect/index.js";
24
14
  import PisellMultipleSelect from "../../../pisellMultipleSelect/PisellMultipleSelect.js";
25
- import "../../../pisellMultipleSelect/index.js";
26
15
  import { fieldMaps } from "../../../table/Table/fields/index.js";
27
16
  import { PisellMobileDateRangePicker } from "../../../pisellMobileDateRangePicker/PisellMobileDateRangePicker.js";
28
17
  import AsyncOptionsSelectWrapper from "./AsyncOptionsSelectWrapper.js";
@@ -1,8 +1,6 @@
1
1
  import { getText } from "../../../../locales/index.js";
2
2
  import MemoizedPisellNumber from "../../../pisellNumber/PisellNumber.js";
3
- import "../../../pisellNumber/index.js";
4
3
  import PisellSingleSelect from "../../../pisellSingleSelect/PisellSingleSelect.js";
5
- import "../../../pisellSingleSelect/index.js";
6
4
  import React from "react";
7
5
  //#region src/components/pisellRecordBoard/shellFrame/ResourceWall/ResourceWallControlPanelLayoutTab.tsx
8
6
  /** 控制台「资源 / 布局」分页:预设、自定义行列、翻页停留、主文案宽度 */
@@ -1,27 +1,16 @@
1
1
  import { getText } from "../../../locales/index.js";
2
2
  import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
3
3
  import PisellSingleLineText_default from "../../pisellSingleLineText/PisellSingleLineText.js";
4
- import "../../pisellSingleLineText/index.js";
5
4
  import PisellLongText_default from "../../pisellLongText/PisellLongText.js";
6
- import "../../pisellLongText/index.js";
7
5
  import MemoizedPisellNumber from "../../pisellNumber/PisellNumber.js";
8
- import "../../pisellNumber/index.js";
9
6
  import MemoizedPisellCurrency from "../../pisellCurrency/PisellCurrency.js";
10
- import "../../pisellCurrency/index.js";
11
7
  import MemoizedPisellPercent from "../../pisellPercent/PisellPercent.js";
12
- import "../../pisellPercent/index.js";
13
8
  import PisellPhone_default from "../../pisellPhone/PisellPhone.js";
14
- import "../../pisellPhone/index.js";
15
9
  import PisellEmail_default from "../../pisellEmail/PisellEmail.js";
16
- import "../../pisellEmail/index.js";
17
10
  import PisellUrl_default from "../../pisellUrl/PisellUrl.js";
18
- import "../../pisellUrl/index.js";
19
11
  import PisellRating_default from "../../pisellRating/PisellRating.js";
20
- import "../../pisellRating/index.js";
21
12
  import PisellSingleSelect from "../../pisellSingleSelect/PisellSingleSelect.js";
22
- import "../../pisellSingleSelect/index.js";
23
13
  import PisellMultipleSelect from "../../pisellMultipleSelect/PisellMultipleSelect.js";
24
- import "../../pisellMultipleSelect/index.js";
25
14
  import PisellDateTimeDisplay_default from "../../pisellDateTimeDisplay/PisellDateTimeDisplay.js";
26
15
  import React, { useEffect, useState } from "react";
27
16
  //#region src/components/pisellRecordBoard/utils/recordBoardColumns.tsx
package/es/index.js CHANGED
@@ -1,26 +1,15 @@
1
1
  import PisellContext, { globalConfig } from "./components/pisell-config-provider/context.js";
2
2
  import PisellSingleLineText_default from "./components/pisellSingleLineText/PisellSingleLineText.js";
3
- import "./components/pisellSingleLineText/index.js";
4
3
  import PisellLongText_default from "./components/pisellLongText/PisellLongText.js";
5
- import "./components/pisellLongText/index.js";
6
4
  import MemoizedPisellNumber from "./components/pisellNumber/PisellNumber.js";
7
- import "./components/pisellNumber/index.js";
8
5
  import MemoizedPisellCurrency from "./components/pisellCurrency/PisellCurrency.js";
9
- import "./components/pisellCurrency/index.js";
10
6
  import MemoizedPisellPercent from "./components/pisellPercent/PisellPercent.js";
11
- import "./components/pisellPercent/index.js";
12
7
  import PisellPhone_default from "./components/pisellPhone/PisellPhone.js";
13
- import "./components/pisellPhone/index.js";
14
8
  import PisellEmail_default from "./components/pisellEmail/PisellEmail.js";
15
- import "./components/pisellEmail/index.js";
16
9
  import PisellUrl_default from "./components/pisellUrl/PisellUrl.js";
17
- import "./components/pisellUrl/index.js";
18
10
  import PisellRating_default from "./components/pisellRating/PisellRating.js";
19
- import "./components/pisellRating/index.js";
20
11
  import PisellSingleSelect from "./components/pisellSingleSelect/PisellSingleSelect.js";
21
- import "./components/pisellSingleSelect/index.js";
22
12
  import PisellMultipleSelect from "./components/pisellMultipleSelect/PisellMultipleSelect.js";
23
- import "./components/pisellMultipleSelect/index.js";
24
13
  import PisellFields from "./components/PisellFields/index.js";
25
14
  import PisellCard from "./components/pisellCard/index.js";
26
15
  import PisellMetricCard from "./components/pisellMetricCard/PisellMetricCard.js";
@@ -17,7 +17,7 @@ const createUnexpectedCompileError = (error) => {
17
17
  message: `Selection flow compilation failed: ${require_utils.getSelectionFlowErrorMessage(error)}`
18
18
  }]);
19
19
  };
20
- const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialStepIndex = 0, preparePresentation = false, onPresentationReady, hostContext, services, children, onDraftChange, onStepChange, onCompiledStepsChange, onValidationFailed, onConfigurationError, onComplete }, ref) => {
20
+ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialStepIndex = 0, preparePresentation = false, resolveInitialStepIndex, onPresentationReady, hostContext, services, children, onDraftChange, onStepChange, onCompiledStepsChange, onValidationFailed, onConfigurationError, onComplete }, ref) => {
21
21
  const mountedRef = (0, react.useRef)(true);
22
22
  const flowGenerationRef = (0, react.useRef)(1);
23
23
  const draftRevisionRef = (0, react.useRef)(0);
@@ -31,6 +31,8 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
31
31
  const presentationTaskRef = (0, react.useRef)(null);
32
32
  const onPresentationReadyRef = (0, react.useRef)(onPresentationReady);
33
33
  onPresentationReadyRef.current = onPresentationReady;
34
+ const resolveInitialStepIndexRef = (0, react.useRef)(resolveInitialStepIndex);
35
+ resolveInitialStepIndexRef.current = resolveInitialStepIndex;
34
36
  const processDraftChangeRef = (0, react.useRef)(() => void 0);
35
37
  const onDraftChangeRef = (0, react.useRef)(onDraftChange);
36
38
  onDraftChangeRef.current = onDraftChange;
@@ -362,6 +364,7 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
362
364
  const autoAdvanceAttemptRef = (0, react.useRef)();
363
365
  (0, react.useEffect)(() => {
364
366
  if (configurationError || completedRef.current || transitionPendingRef.current || preparePresentation && !presentationReadyRef.current || !currentStep || !isStepSkippable(resolvedCurrentStepIndex)) return;
367
+ if (currentStep.modules.every((module) => automaticModuleKeysRef.current.includes(module.key))) return;
365
368
  const direction = navigationDirectionRef.current;
366
369
  const key = `${direction}:${currentStep.key}:${draftRevisionRef.current}:${currentStep.modules.map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|")}`;
367
370
  if (autoAdvanceAttemptRef.current === key) return;
@@ -380,14 +383,15 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
380
383
  back,
381
384
  next,
382
385
  preparePresentation,
383
- presentationReady
386
+ presentationReady,
387
+ automaticModuleKeys
384
388
  ]);
385
389
  (0, react.useEffect)(() => {
386
390
  if (!preparePresentation || presentationReadyRef.current || configurationError || presentationTaskRef.current) return;
387
391
  const generation = flowGenerationRef.current;
388
392
  const isCurrent = () => mountedRef.current && flowGenerationRef.current === generation;
389
393
  const task = require_asyncToGenerator._asyncToGenerator(function* () {
390
- var _firstVisible$index, _compiledStepsRef$cur, _onPresentationReadyR2;
394
+ var _visibleSteps$0$index, _visibleSteps$, _compiledStepsRef$cur, _onPresentationReadyR2;
391
395
  const modules = compiledStepsRef.current.reduce((allModules, step) => allModules.concat(step.modules), []);
392
396
  for (let pass = 0; pass <= modules.length; pass += 1) {
393
397
  for (const module of modules) {
@@ -419,8 +423,15 @@ const SelectionFlow = ({ registry, draftAdapter, steps, initialDraft, initialSte
419
423
  }).map((module) => module.key);
420
424
  automaticModuleKeysRef.current = automatic;
421
425
  setAutomaticModuleKeys(automatic);
422
- const firstVisible = compiledStepsRef.current.find((step) => step.modules.some((module) => !automatic.includes(module.key)));
423
- const initialIndex = (_firstVisible$index = firstVisible === null || firstVisible === void 0 ? void 0 : firstVisible.index) !== null && _firstVisible$index !== void 0 ? _firstVisible$index : Math.max(0, compiledStepsRef.current.length - 1);
426
+ const visibleSteps = compiledStepsRef.current.filter((step) => step.modules.some((module) => !automatic.includes(module.key)));
427
+ let initialIndex = (_visibleSteps$0$index = (_visibleSteps$ = visibleSteps[0]) === null || _visibleSteps$ === void 0 ? void 0 : _visibleSteps$.index) !== null && _visibleSteps$0$index !== void 0 ? _visibleSteps$0$index : Math.max(0, compiledStepsRef.current.length - 1);
428
+ try {
429
+ var _resolveInitialStepIn;
430
+ const context = getFreshContext();
431
+ const requestedIndex = context && ((_resolveInitialStepIn = resolveInitialStepIndexRef.current) === null || _resolveInitialStepIn === void 0 ? void 0 : _resolveInitialStepIn.call(resolveInitialStepIndexRef, context));
432
+ const requestedStep = visibleSteps.find((step) => step.index === requestedIndex);
433
+ if (requestedStep) initialIndex = requestedStep.index;
434
+ } catch (_unused2) {}
424
435
  currentStepIndexRef.current = initialIndex;
425
436
  currentStepKeyRef.current = (_compiledStepsRef$cur = compiledStepsRef.current[initialIndex]) === null || _compiledStepsRef$cur === void 0 ? void 0 : _compiledStepsRef$cur.key;
426
437
  setCurrentStepIndex(initialIndex);
@@ -15,6 +15,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
15
15
  return step.modules.every((module) => {
16
16
  var _moduleStateRef$curre;
17
17
  if (((_moduleStateRef$curre = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre === void 0 ? void 0 : _moduleStateRef$curre.status) !== "ready") return false;
18
+ if (automaticModuleKeysRef.current.includes(module.key)) return true;
18
19
  try {
19
20
  var _resolveFlowModuleAda, _resolveFlowModuleAda2;
20
21
  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;
@@ -366,9 +367,32 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
366
367
  const preparationGeneration = flowGenerationRef.current;
367
368
  const preparationNavigation = navigationRevisionRef.current;
368
369
  const isCurrentPreparation = () => mountedRef.current && !configurationErrorRef.current && flowGenerationRef.current === preparationGeneration && navigationRevisionRef.current === preparationNavigation && currentStepIndexRef.current === currentIndex && require_utils.getCompiledStepsFingerprint(compiledStepsRef.current) === preparationFingerprint;
369
- for (const step of allSteps) for (const module of step.modules) {
370
- if (automaticModuleKeysRef.current.includes(module.key) && !(yield validateModule(module))) return false;
371
- if (!isCurrentPreparation()) return false;
370
+ const automaticModules = [];
371
+ for (const step of allSteps) for (const module of step.modules) if (automaticModuleKeysRef.current.includes(module.key)) automaticModules.push(module);
372
+ for (let pass = 0; pass <= automaticModules.length; pass += 1) {
373
+ for (const module of automaticModules) {
374
+ var _moduleStateRef$curre4;
375
+ if (!isCurrentPreparation()) return false;
376
+ if (pass > 0 && ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) === "ready") continue;
377
+ if (!(yield validateModule(module)) || !isCurrentPreparation()) return false;
378
+ }
379
+ if (automaticModules.every((module) => {
380
+ var _moduleStateRef$curre5;
381
+ return ((_moduleStateRef$curre5 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre5 === void 0 ? void 0 : _moduleStateRef$curre5.status) === "ready";
382
+ })) break;
383
+ }
384
+ const unresolvedAutomatic = automaticModules.find((module) => {
385
+ var _moduleStateRef$curre6;
386
+ return ((_moduleStateRef$curre6 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre6 === void 0 ? void 0 : _moduleStateRef$curre6.status) !== "ready";
387
+ });
388
+ if (unresolvedAutomatic) {
389
+ onAutomaticModuleFailure === null || onAutomaticModuleFailure === void 0 || onAutomaticModuleFailure(unresolvedAutomatic);
390
+ const state = moduleStateRef.current[unresolvedAutomatic.key];
391
+ onValidationFailed === null || onValidationFailed === void 0 || onValidationFailed(unresolvedAutomatic, {
392
+ message: state === null || state === void 0 ? void 0 : state.message,
393
+ reason: (state === null || state === void 0 ? void 0 : state.reason) || createRuntimeIssue("previous-step-review")
394
+ });
395
+ return false;
372
396
  }
373
397
  const preparationDraftRevision = draftRevisionRef.current;
374
398
  for (const step of allSteps) {
@@ -406,8 +430,8 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
406
430
  const latestRevisionFingerprint = latestSteps.flatMap((step) => step.modules).map((module) => `${module.key}:${moduleRevisionRef.current.get(module.key) || 0}`).join("|");
407
431
  if (compiledFingerprint !== latestCompiledFingerprint || revisionFingerprint !== latestRevisionFingerprint || draftRevision !== draftRevisionRef.current) {
408
432
  const targetStep = latestSteps.find((step) => step.modules.some((module) => {
409
- var _moduleStateRef$curre4;
410
- return ((_moduleStateRef$curre4 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre4 === void 0 ? void 0 : _moduleStateRef$curre4.status) !== "ready";
433
+ var _moduleStateRef$curre7;
434
+ return ((_moduleStateRef$curre7 = moduleStateRef.current[module.key]) === null || _moduleStateRef$curre7 === void 0 ? void 0 : _moduleStateRef$curre7.status) !== "ready";
411
435
  })) || latestSteps[0];
412
436
  const targetModule = targetStep === null || targetStep === void 0 ? void 0 : targetStep.modules[0];
413
437
  if (targetStep && targetModule) {
@@ -439,6 +463,7 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
439
463
  }), [
440
464
  commitModuleState,
441
465
  createRuntimeIssue,
466
+ onAutomaticModuleFailure,
442
467
  onValidationFailed,
443
468
  revalidateModuleBeforeComplete,
444
469
  validateCurrentStep,
@@ -542,15 +567,19 @@ const useFlowNavigation = ({ registry, draftAdapter, createRuntimeIssue, mounted
542
567
  validateCurrentStep
543
568
  ]),
544
569
  back: (0, react.useCallback)(() => {
545
- var _compiledStepsRef$cur2, _compiledStepsRef$cur3;
570
+ var _compiledStepsRef$cur2;
546
571
  if (!mountedRef.current || transitionPendingRef.current || currentStepIndexRef.current <= 0) return false;
547
572
  let nextIndex = currentStepIndexRef.current - 1;
548
- while (nextIndex >= 0 && (isStepSkippable(nextIndex) || ((_compiledStepsRef$cur2 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur2 === void 0 ? void 0 : _compiledStepsRef$cur2.modules.every((module) => automaticModuleKeysRef.current.includes(module.key))))) nextIndex -= 1;
573
+ while (nextIndex >= 0) {
574
+ const step = compiledStepsRef.current[nextIndex];
575
+ if (!((step === null || step === void 0 ? void 0 : step.modules.length) > 0 && step.modules.every((module) => automaticModuleKeysRef.current.includes(module.key))) && !isStepSkippable(nextIndex)) break;
576
+ nextIndex -= 1;
577
+ }
549
578
  if (nextIndex < 0) return false;
550
579
  navigationDirectionRef.current = "backward";
551
580
  navigationRevisionRef.current += 1;
552
581
  currentStepIndexRef.current = nextIndex;
553
- currentStepKeyRef.current = (_compiledStepsRef$cur3 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur3 === void 0 ? void 0 : _compiledStepsRef$cur3.key;
582
+ currentStepKeyRef.current = (_compiledStepsRef$cur2 = compiledStepsRef.current[nextIndex]) === null || _compiledStepsRef$cur2 === void 0 ? void 0 : _compiledStepsRef$cur2.key;
554
583
  setCurrentStepIndex(nextIndex);
555
584
  return true;
556
585
  }, [isStepSkippable]),
@@ -188,6 +188,8 @@ interface PisellSelectionFlowProps<TDraft, TDraftUpdate, TField extends string,
188
188
  initialStepIndex?: number;
189
189
  /** Resolve a stable presentation before mounting interactive module components. */
190
190
  preparePresentation?: boolean;
191
+ /** Choose the entry step from prepared defaults without hiding earlier steps. */
192
+ resolveInitialStepIndex?: (context: SelectionFlowContextValue<TDraft, TDraftUpdate, TField, TModuleType, TServices, THostContext>) => number | undefined;
191
193
  onPresentationReady?: (automaticModuleKeys: readonly string[]) => void;
192
194
  hostContext?: THostContext;
193
195
  services: TServices;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "6.12.89",
3
+ "version": "6.12.90",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -95,9 +95,9 @@
95
95
  "swiper": "^8.4.7",
96
96
  "antd-mobile": "^5.38.1",
97
97
  "vod-js-sdk-v6": "^1.4.11",
98
- "@pisell/utils": "3.0.7",
98
+ "@pisell/date-picker": "3.0.12",
99
99
  "@pisell/icon": "0.0.11",
100
- "@pisell/date-picker": "3.0.12"
100
+ "@pisell/utils": "3.0.7"
101
101
  },
102
102
  "peerDependencies": {
103
103
  "react": "^18.0.0",
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import MemoizedPisellCurrency from "./PisellCurrency.js";
3
- //#region src/components/pisellCurrency/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 0 → 9 / 9 → 0 */
5
- MemoizedPisellCurrency.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-0-9")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-9-0")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import PisellEmail_default from "./PisellEmail.js";
3
- //#region src/components/pisellEmail/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 A → Z / Z → A */
5
- PisellEmail_default.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-a-z")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-z-a")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import PisellLongText_default from "./PisellLongText.js";
3
- //#region src/components/pisellLongText/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 A → Z / Z → A */
5
- PisellLongText_default.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-a-z")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-z-a")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import PisellMultipleSelect from "./PisellMultipleSelect.js";
3
- //#region src/components/pisellMultipleSelect/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 First → Last / Last → First */
5
- PisellMultipleSelect.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-first-last")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-last-first")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import MemoizedPisellNumber from "./PisellNumber.js";
3
- //#region src/components/pisellNumber/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 0 → 9 / 9 → 0 */
5
- MemoizedPisellNumber.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-0-9")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-9-0")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import MemoizedPisellPercent from "./PisellPercent.js";
3
- //#region src/components/pisellPercent/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 0 → 9 / 9 → 0 */
5
- MemoizedPisellPercent.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-0-9")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-9-0")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,14 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import "./constants/countryCodes.js";
3
- import PisellPhone_default from "./PisellPhone.js";
4
- //#region src/components/pisellPhone/index.tsx
5
- /** RecordBoard 列 type 联动排序:内置 A → Z / Z → A */
6
- PisellPhone_default.SortOptions = { getSortItems: (fieldKey) => [{
7
- key: `${fieldKey}:asc`,
8
- label: getText("sort-a-z")
9
- }, {
10
- key: `${fieldKey}:desc`,
11
- label: getText("sort-z-a")
12
- }] };
13
- //#endregion
14
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import PisellRating_default from "./PisellRating.js";
3
- //#region src/components/pisellRating/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 0 → 9 / 9 → 0 */
5
- PisellRating_default.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-0-9")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-9-0")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import PisellSingleLineText_default from "./PisellSingleLineText.js";
3
- //#region src/components/pisellSingleLineText/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 A → Z / Z → A */
5
- PisellSingleLineText_default.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-a-z")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-z-a")
11
- }] };
12
- //#endregion
13
- export {};
@@ -1,13 +0,0 @@
1
- import { getText } from "../../locales/index.js";
2
- import PisellSingleSelect from "./PisellSingleSelect.js";
3
- //#region src/components/pisellSingleSelect/index.tsx
4
- /** RecordBoard 列 type 联动排序:内置 First → Last / Last → First */
5
- PisellSingleSelect.SortOptions = { getSortItems: (fieldKey) => [{
6
- key: `${fieldKey}:asc`,
7
- label: getText("sort-first-last")
8
- }, {
9
- key: `${fieldKey}:desc`,
10
- label: getText("sort-last-first")
11
- }] };
12
- //#endregion
13
- export {};