@pisell/private-materials 6.12.371 → 6.12.373

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.
@@ -75,16 +75,6 @@ const getBodyScaleY = () => {
75
75
  const matrix = new DOMMatrixReadOnly(transform);
76
76
  return Math.sqrt(matrix.c * matrix.c + matrix.d * matrix.d) || 1;
77
77
  };
78
- const waitForModalEntranceFrame = () => {
79
- if (typeof window === "undefined") return Promise.resolve();
80
- return new Promise((resolve) => {
81
- requestAnimationFrame(() => {
82
- requestAnimationFrame(() => {
83
- window.setTimeout(() => resolve(), 10);
84
- });
85
- });
86
- });
87
- };
88
78
  const toValidDayjs = (value) => {
89
79
  if (!value) return null;
90
80
  const parsed = dayjs(value);
@@ -198,6 +188,8 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
198
188
  const inventory = useContext(SalesInventoryContext);
199
189
  const [baseProductData, setProductData] = useState(null);
200
190
  const [detailLoading, setDetailLoading] = useState(false);
191
+ const [modalEntered, setModalEntered] = useState(false);
192
+ const detailContentLoading = detailLoading || !modalEntered;
201
193
  const [appearanceConfirmPending, setAppearanceConfirmPending] = useState(false);
202
194
  const appearanceConfirmTaskRef = useRef(null);
203
195
  const [note, setNote] = useState("");
@@ -514,7 +506,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
514
506
  updateSelectionFlowCanScrollDown(canScrollDown);
515
507
  }, [resolveSelectionFlowScrollContainer, updateSelectionFlowCanScrollDown]);
516
508
  useLayoutEffect(() => {
517
- if (!open || !isMobile || detailLoading || !productData) {
509
+ if (!open || !isMobile || detailContentLoading || !productData) {
518
510
  updateSelectionFlowCanScrollDown(false);
519
511
  return;
520
512
  }
@@ -564,7 +556,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
564
556
  };
565
557
  }, [
566
558
  currentStep,
567
- detailLoading,
559
+ detailContentLoading,
568
560
  isCustomSelectionFlow,
569
561
  isKioskPlatform,
570
562
  isMobile,
@@ -980,8 +972,8 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
980
972
  });
981
973
  },
982
974
  open: function() {
983
- var _ref19 = _asyncToGenerator(function* (data) {
984
- var _product_id, _selectionFlowService2, _noteDiagnosticsRef$c2, _product_id2, _enrichmentAbortRef$c2, _skuDetailConfig$enab, _skuDetailConfig$isSh, _skuDetailConfig$isSh2, _skuDetailConfig$isSh3, _skuDetailConfig$isSh4, _skuDetailConfig$isSh5, _skuDetailConfig$hide, _skuDetailConfig$isSh6, _skuDetailConfig$isSh7, _skuDetailConfig$isSh8, _skuDetailConfig$exte, _skuDetailConfig$useC, _skuDetailConfig$cust, _skuDetailConfig$isCa, _skuDetailConfig, _skuDetailConfig2, _data$bundle_group, _data$_extend, _data$_extend2, _data$discount_list, _ref17, _data$_extend3, _data$_extend4, _data$_extend5, _data$discount_list$f, _data$discount_list2, _ref18, _data$_extend$priceOv, _data$_extend7;
975
+ var _ref18 = _asyncToGenerator(function* (data) {
976
+ var _product_id, _selectionFlowService2, _noteDiagnosticsRef$c2, _product_id2, _enrichmentAbortRef$c2, _skuDetailConfig$enab, _skuDetailConfig$isSh, _skuDetailConfig$isSh2, _skuDetailConfig$isSh3, _skuDetailConfig$isSh4, _skuDetailConfig$isSh5, _skuDetailConfig$hide, _skuDetailConfig$isSh6, _skuDetailConfig$isSh7, _skuDetailConfig$isSh8, _skuDetailConfig$exte, _skuDetailConfig$useC, _skuDetailConfig$cust, _skuDetailConfig$isCa, _skuDetailConfig, _skuDetailConfig2, _data$bundle_group, _data$_extend, _data$_extend2, _data$discount_list, _ref16, _data$_extend3, _data$_extend4, _data$_extend5, _data$discount_list$f, _data$discount_list2, _ref17, _data$_extend$priceOv, _data$_extend7;
985
977
  const shownLog = {
986
978
  product_id: String((_product_id = data.product_id) !== null && _product_id !== void 0 ? _product_id : data.id),
987
979
  mode: ((_selectionFlowService2 = data.selectionFlowServices) === null || _selectionFlowService2 === void 0 ? void 0 : _selectionFlowService2.selectionFlowMode) || ("date" in data && !("_extend" in data) ? "create" : "edit"),
@@ -1005,18 +997,12 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1005
997
  setInventorySelectorSnapshot(null);
1006
998
  flowDateHydrationVersionRef.current += 1;
1007
999
  const isCurrentOpenTask = () => openTaskIdRef.current === currentTaskId;
1008
- const showModalShellBeforeHydration = function() {
1009
- var _ref8 = _asyncToGenerator(function* () {
1010
- setProductData(null);
1011
- setDetailLoading(true);
1012
- setOpen(true);
1013
- yield waitForModalEntranceFrame();
1014
- return isCurrentOpenTask();
1015
- });
1016
- return function showModalShellBeforeHydration() {
1017
- return _ref8.apply(this, arguments);
1018
- };
1019
- }();
1000
+ if (!open) setModalEntered(false);
1001
+ const showModalShellBeforeHydration = () => {
1002
+ setProductData(null);
1003
+ setDetailLoading(true);
1004
+ setOpen(true);
1005
+ };
1020
1006
  setCurrentStep(0);
1021
1007
  lateQuantityReviewStepIndexRef.current = null;
1022
1008
  lateQuantityRevalidationTaskRef.current = null;
@@ -1077,7 +1063,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1077
1063
  };
1078
1064
  setSkuDetailConfig(config);
1079
1065
  if ("date" in data && !("_extend" in data)) {
1080
- var _data$is_eject2, _ref9, _ref10, _initialExtend$price, _data$productData2, _apiData$duration, _apiData$schedules, _apiData$scheduleIds, _apiData$extension_ty, _ref11, _variantData$variant_, _ref12, _variantData$variant, _apiData$option_group, _apiData$bundle_group, _apiData$product_reso, _apiData$holder_confi, _ref13, _data$initialQuantity, _initialExtend$price2, _initialExtend$total, _initialExtend$origin, _ref14, _initialExtend$note, _ref15, _is_eject, _ref16, _hydratedExtend$quant, _hydratedExtend$price;
1066
+ var _data$is_eject2, _ref8, _ref9, _initialExtend$price, _data$productData2, _apiData$duration, _apiData$schedules, _apiData$scheduleIds, _apiData$extension_ty, _ref10, _variantData$variant_, _ref11, _variantData$variant, _apiData$option_group, _apiData$bundle_group, _apiData$product_reso, _apiData$holder_confi, _ref12, _data$initialQuantity, _initialExtend$price2, _initialExtend$total, _initialExtend$origin, _ref13, _initialExtend$note, _ref14, _is_eject, _ref15, _hydratedExtend$quant, _hydratedExtend$price;
1081
1067
  logger === null || logger === void 0 || logger.addLog({
1082
1068
  type: "info",
1083
1069
  title: "sku_detail_modal_open_create",
@@ -1085,9 +1071,8 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1085
1071
  });
1086
1072
  openParamsRef.current = data;
1087
1073
  const shouldOpenBeforeHydration = hasConfiguredSelectionFlow || Number((_data$is_eject2 = data.is_eject) !== null && _data$is_eject2 !== void 0 ? _data$is_eject2 : 0) === 1 || isWeighingProduct(data.productData);
1088
- if (shouldOpenBeforeHydration) {
1089
- if (!(yield showModalShellBeforeHydration())) return;
1090
- } else {
1074
+ if (shouldOpenBeforeHydration) showModalShellBeforeHydration();
1075
+ else {
1091
1076
  setOpen(false);
1092
1077
  setProductData(null);
1093
1078
  setDetailLoading(false);
@@ -1108,7 +1093,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1108
1093
  if ((config === null || config === void 0 ? void 0 : config.useCustomData) && (config === null || config === void 0 ? void 0 : config.customData)) apiData = _objectSpread2(_objectSpread2({}, apiData), (config === null || config === void 0 ? void 0 : config.customData) || {});
1109
1094
  const initialCacheItem = data.initialCacheItem;
1110
1095
  const initialExtend = (initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem._extend) || {};
1111
- const basePrice = Number((_ref9 = (_ref10 = (_initialExtend$price = initialExtend.price) !== null && _initialExtend$price !== void 0 ? _initialExtend$price : apiData === null || apiData === void 0 ? void 0 : apiData.price) !== null && _ref10 !== void 0 ? _ref10 : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.price) !== null && _ref9 !== void 0 ? _ref9 : 0);
1096
+ const basePrice = Number((_ref8 = (_ref9 = (_initialExtend$price = initialExtend.price) !== null && _initialExtend$price !== void 0 ? _initialExtend$price : apiData === null || apiData === void 0 ? void 0 : apiData.price) !== null && _ref9 !== void 0 ? _ref9 : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.price) !== null && _ref8 !== void 0 ? _ref8 : 0);
1112
1097
  let variantData = formatVariant(config, data === null || data === void 0 || (_data$productData2 = data.productData) === null || _data$productData2 === void 0 ? void 0 : _data$productData2.variant, apiData);
1113
1098
  const initialSkuValue = resolveSkuValueCandidates([
1114
1099
  initialExtend.skuValue,
@@ -1128,8 +1113,8 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1128
1113
  schedules: (_apiData$schedules = apiData === null || apiData === void 0 ? void 0 : apiData.schedules) !== null && _apiData$schedules !== void 0 ? _apiData$schedules : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.schedules,
1129
1114
  "schedule.ids": (_apiData$scheduleIds = apiData === null || apiData === void 0 ? void 0 : apiData["schedule.ids"]) !== null && _apiData$scheduleIds !== void 0 ? _apiData$scheduleIds : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem["schedule.ids"],
1130
1115
  extension_type: (_apiData$extension_ty = apiData === null || apiData === void 0 ? void 0 : apiData.extension_type) !== null && _apiData$extension_ty !== void 0 ? _apiData$extension_ty : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.extension_type,
1131
- variant_group: (_ref11 = (_variantData$variant_ = variantData === null || variantData === void 0 ? void 0 : variantData.variant_group) !== null && _variantData$variant_ !== void 0 ? _variantData$variant_ : apiData === null || apiData === void 0 ? void 0 : apiData.variant_group) !== null && _ref11 !== void 0 ? _ref11 : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.variant_group,
1132
- variant: (_ref12 = (_variantData$variant = variantData === null || variantData === void 0 ? void 0 : variantData.variant) !== null && _variantData$variant !== void 0 ? _variantData$variant : apiData === null || apiData === void 0 ? void 0 : apiData.variant) !== null && _ref12 !== void 0 ? _ref12 : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.variant,
1116
+ variant_group: (_ref10 = (_variantData$variant_ = variantData === null || variantData === void 0 ? void 0 : variantData.variant_group) !== null && _variantData$variant_ !== void 0 ? _variantData$variant_ : apiData === null || apiData === void 0 ? void 0 : apiData.variant_group) !== null && _ref10 !== void 0 ? _ref10 : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.variant_group,
1117
+ variant: (_ref11 = (_variantData$variant = variantData === null || variantData === void 0 ? void 0 : variantData.variant) !== null && _variantData$variant !== void 0 ? _variantData$variant : apiData === null || apiData === void 0 ? void 0 : apiData.variant) !== null && _ref11 !== void 0 ? _ref11 : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.variant,
1133
1118
  option_group: (_apiData$option_group = apiData === null || apiData === void 0 ? void 0 : apiData.option_group) !== null && _apiData$option_group !== void 0 ? _apiData$option_group : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.option_group,
1134
1119
  bundle_group: (_apiData$bundle_group = apiData === null || apiData === void 0 ? void 0 : apiData.bundle_group) !== null && _apiData$bundle_group !== void 0 ? _apiData$bundle_group : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.bundle_group,
1135
1120
  product_resource: (_apiData$product_reso = apiData === null || apiData === void 0 ? void 0 : apiData.product_resource) !== null && _apiData$product_reso !== void 0 ? _apiData$product_reso : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.product_resource
@@ -1137,11 +1122,11 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1137
1122
  _data: _objectSpread2(_objectSpread2({}, (apiData === null || apiData === void 0 ? void 0 : apiData._data) || {}), (initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem._data) || {}),
1138
1123
  _extend: _objectSpread2(_objectSpread2(_objectSpread2({}, (apiData === null || apiData === void 0 ? void 0 : apiData._extend) || {}), initialExtend), {}, {
1139
1124
  product_name: resolveDisplayText(initialExtend.product_name || (apiData === null || apiData === void 0 ? void 0 : apiData.title) || (apiData === null || apiData === void 0 ? void 0 : apiData.product_name)),
1140
- quantity: (_ref13 = (_data$initialQuantity = data.initialQuantity) !== null && _data$initialQuantity !== void 0 ? _data$initialQuantity : initialExtend.quantity) !== null && _ref13 !== void 0 ? _ref13 : 1,
1125
+ quantity: (_ref12 = (_data$initialQuantity = data.initialQuantity) !== null && _data$initialQuantity !== void 0 ? _data$initialQuantity : initialExtend.quantity) !== null && _ref12 !== void 0 ? _ref12 : 1,
1141
1126
  price: (_initialExtend$price2 = initialExtend.price) !== null && _initialExtend$price2 !== void 0 ? _initialExtend$price2 : basePrice,
1142
1127
  total: (_initialExtend$total = initialExtend.total) !== null && _initialExtend$total !== void 0 ? _initialExtend$total : basePrice,
1143
1128
  origin_total: (_initialExtend$origin = initialExtend.origin_total) !== null && _initialExtend$origin !== void 0 ? _initialExtend$origin : basePrice,
1144
- note: (_ref14 = (_initialExtend$note = initialExtend.note) !== null && _initialExtend$note !== void 0 ? _initialExtend$note : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.note) !== null && _ref14 !== void 0 ? _ref14 : "",
1129
+ note: (_ref13 = (_initialExtend$note = initialExtend.note) !== null && _initialExtend$note !== void 0 ? _initialExtend$note : initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem.note) !== null && _ref13 !== void 0 ? _ref13 : "",
1145
1130
  skuValue: initialSkuValue
1146
1131
  })
1147
1132
  });
@@ -1191,7 +1176,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1191
1176
  return;
1192
1177
  }
1193
1178
  }
1194
- if (!(Number((_ref15 = (_is_eject = apiData === null || apiData === void 0 ? void 0 : apiData.is_eject) !== null && _is_eject !== void 0 ? _is_eject : data.is_eject) !== null && _ref15 !== void 0 ? _ref15 : 0) === 1 || Number(data.is_eject) === 1 && Boolean(resolveDetailAppearance(config, hydratedData)) || isWeighingProduct(apiData)) && !hasEffectiveSelectionFlow && !confirmDisabledRef.current) {
1179
+ if (!(Number((_ref14 = (_is_eject = apiData === null || apiData === void 0 ? void 0 : apiData.is_eject) !== null && _is_eject !== void 0 ? _is_eject : data.is_eject) !== null && _ref14 !== void 0 ? _ref14 : 0) === 1 || Number(data.is_eject) === 1 && Boolean(resolveDetailAppearance(config, hydratedData)) || isWeighingProduct(apiData)) && !hasEffectiveSelectionFlow && !confirmDisabledRef.current) {
1195
1180
  var _extend, _bookingState$booking2;
1196
1181
  const stockResult = getStockValidationResult({
1197
1182
  value: hydratedData === null || hydratedData === void 0 || (_extend = hydratedData._extend) === null || _extend === void 0 ? void 0 : _extend.skuValue,
@@ -1227,7 +1212,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1227
1212
  setProductData(hydratedData);
1228
1213
  const hydratedExtend = hydratedData._extend || {};
1229
1214
  setNote(hydratedExtend.note || "");
1230
- setQuantity(isWeighingProduct(apiData) ? 1 : (_ref16 = (_hydratedExtend$quant = hydratedExtend.quantity) !== null && _hydratedExtend$quant !== void 0 ? _hydratedExtend$quant : apiData === null || apiData === void 0 ? void 0 : apiData.min_num_unit) !== null && _ref16 !== void 0 ? _ref16 : 1);
1215
+ setQuantity(isWeighingProduct(apiData) ? 1 : (_ref15 = (_hydratedExtend$quant = hydratedExtend.quantity) !== null && _hydratedExtend$quant !== void 0 ? _hydratedExtend$quant : apiData === null || apiData === void 0 ? void 0 : apiData.min_num_unit) !== null && _ref15 !== void 0 ? _ref15 : 1);
1231
1216
  setDiscounts(initialCacheItem ? (hydratedData.discount_list || []).filter((item) => item.type !== "product") : []);
1232
1217
  setWeighingData(getWeighingValueFromProductSku(initialCacheItem) || initialExtend.weighing || null);
1233
1218
  setSkuValue(initialSkuValue);
@@ -1254,7 +1239,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1254
1239
  });
1255
1240
  openParamsRef.current = null;
1256
1241
  if ((Array.isArray(data === null || data === void 0 || (_skuDetailConfig = data.skuDetailConfig) === null || _skuDetailConfig === void 0 ? void 0 : _skuDetailConfig.steps) || typeof (data === null || data === void 0 || (_skuDetailConfig2 = data.skuDetailConfig) === null || _skuDetailConfig2 === void 0 ? void 0 : _skuDetailConfig2.resolveSteps) === "function") && process.env.NODE_ENV !== "production") console.warn("[SkuDetailModal] 自定义 steps 一期仅在 create 模式生效,edit 继续使用旧流程。");
1257
- if (!(yield showModalShellBeforeHydration())) return;
1242
+ showModalShellBeforeHydration();
1258
1243
  shownLog.dataSource = "local";
1259
1244
  const _data = cloneDeep(data);
1260
1245
  if ((_data === null || _data === void 0 ? void 0 : _data.is_bundle) && !(_data === null || _data === void 0 || (_data$bundle_group = _data.bundle_group) === null || _data$bundle_group === void 0 || (_data$bundle_group = _data$bundle_group[0]) === null || _data$bundle_group === void 0 || (_data$bundle_group = _data$bundle_group.bundle_item) === null || _data$bundle_group === void 0 ? void 0 : _data$bundle_group[0].title)) {
@@ -1302,7 +1287,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1302
1287
  setNote((_data === null || _data === void 0 || (_data$_extend = _data._extend) === null || _data$_extend === void 0 ? void 0 : _data$_extend.note) || "");
1303
1288
  setQuantity(isWeighingProduct(_data) ? 1 : (_data === null || _data === void 0 || (_data$_extend2 = _data._extend) === null || _data$_extend2 === void 0 ? void 0 : _data$_extend2.quantity) || 1);
1304
1289
  setDiscounts((_data === null || _data === void 0 || (_data$discount_list = _data.discount_list) === null || _data$discount_list === void 0 ? void 0 : _data$discount_list.filter((item) => item.type !== "product")) || []);
1305
- setWeighingData(getWeighingValueFromProductSku(_data) || (_data === null || _data === void 0 || (_ref17 = _data._extend) === null || _ref17 === void 0 ? void 0 : _ref17.weighing) || null);
1290
+ setWeighingData(getWeighingValueFromProductSku(_data) || (_data === null || _data === void 0 || (_ref16 = _data._extend) === null || _ref16 === void 0 ? void 0 : _ref16.weighing) || null);
1306
1291
  const recordSkuValue = resolveSkuValueCandidates([
1307
1292
  _data === null || _data === void 0 || (_data$_extend3 = _data._extend) === null || _data$_extend3 === void 0 ? void 0 : _data$_extend3._skuValue,
1308
1293
  _data === null || _data === void 0 || (_data$_extend4 = _data._extend) === null || _data$_extend4 === void 0 ? void 0 : _data$_extend4.other,
@@ -1321,7 +1306,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1321
1306
  var _data$_extend6;
1322
1307
  discountListPriceOverride = new Decimal(_data === null || _data === void 0 || (_data$_extend6 = _data._extend) === null || _data$_extend6 === void 0 ? void 0 : _data$_extend6.origin_total).minus(new Decimal(discountListPriceOverride)).toNumber();
1323
1308
  }
1324
- setPriceOverride((_ref18 = (_data$_extend$priceOv = _data === null || _data === void 0 || (_data$_extend7 = _data._extend) === null || _data$_extend7 === void 0 ? void 0 : _data$_extend7.priceOverride) !== null && _data$_extend$priceOv !== void 0 ? _data$_extend$priceOv : discountListPriceOverride) !== null && _ref18 !== void 0 ? _ref18 : null);
1309
+ setPriceOverride((_ref17 = (_data$_extend$priceOv = _data === null || _data === void 0 || (_data$_extend7 = _data._extend) === null || _data$_extend7 === void 0 ? void 0 : _data$_extend7.priceOverride) !== null && _data$_extend$priceOv !== void 0 ? _data$_extend$priceOv : discountListPriceOverride) !== null && _ref17 !== void 0 ? _ref17 : null);
1325
1310
  setShowPriceAdjustModal(false);
1326
1311
  setDetailLoading(false);
1327
1312
  const dataAny = _data;
@@ -1334,7 +1319,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1334
1319
  });
1335
1320
  });
1336
1321
  return function open(_x7) {
1337
- return _ref19.apply(this, arguments);
1322
+ return _ref18.apply(this, arguments);
1338
1323
  };
1339
1324
  }(),
1340
1325
  close: () => {
@@ -1585,6 +1570,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1585
1570
  const resetModalStateAfterClose = useCallback(() => {
1586
1571
  var _noteDiagnosticsRef$c4;
1587
1572
  (_noteDiagnosticsRef$c4 = noteDiagnosticsRef.current) === null || _noteDiagnosticsRef$c4 === void 0 || _noteDiagnosticsRef$c4.stop();
1573
+ setModalEntered(false);
1588
1574
  setProductData(null);
1589
1575
  setDetailLoading(false);
1590
1576
  setNote("");
@@ -1624,6 +1610,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1624
1610
  setShowPriceAdjustModal(false);
1625
1611
  };
1626
1612
  const handleModalOpenChange = useCallback((nextOpen) => {
1613
+ if (nextOpen) setModalEntered(true);
1627
1614
  if (nextOpen && shownLogRef.current) {
1628
1615
  const _shownLogRef$current = shownLogRef.current, { startedAt } = _shownLogRef$current, metadata = _objectWithoutProperties(_shownLogRef$current, _excluded);
1629
1616
  shownLogRef.current = null;
@@ -1648,7 +1635,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1648
1635
  onClose === null || onClose === void 0 || onClose();
1649
1636
  };
1650
1637
  const handleConfirm = function() {
1651
- var _ref20 = _asyncToGenerator(function* (flowDraft) {
1638
+ var _ref19 = _asyncToGenerator(function* (flowDraft) {
1652
1639
  var _noteDiagnosticsRef$c6, _bookingState$booking3, _selectionFlowRef$cur8, _selectionFlowService4;
1653
1640
  (_noteDiagnosticsRef$c6 = noteDiagnosticsRef.current) === null || _noteDiagnosticsRef$c6 === void 0 || _noteDiagnosticsRef$c6.skuConfirm(note.length);
1654
1641
  if (confirmDisabledRef.current) return false;
@@ -1892,7 +1879,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1892
1879
  return false;
1893
1880
  });
1894
1881
  return function handleConfirm(_x8) {
1895
- return _ref20.apply(this, arguments);
1882
+ return _ref19.apply(this, arguments);
1896
1883
  };
1897
1884
  }();
1898
1885
  const handleStockAlertCancel = () => {
@@ -1901,7 +1888,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1901
1888
  setStockAlertDontShowAgainChecked(false);
1902
1889
  };
1903
1890
  const handleStockAlertContinue = function() {
1904
- var _ref21 = _asyncToGenerator(function* () {
1891
+ var _ref20 = _asyncToGenerator(function* () {
1905
1892
  if (confirmDisabledRef.current) return;
1906
1893
  const pendingData = pendingConfirmDataRef.current;
1907
1894
  if (!pendingData) {
@@ -1921,7 +1908,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1921
1908
  modalCloseAction();
1922
1909
  });
1923
1910
  return function handleStockAlertContinue() {
1924
- return _ref21.apply(this, arguments);
1911
+ return _ref20.apply(this, arguments);
1925
1912
  };
1926
1913
  }();
1927
1914
  const handleRemove = () => {
@@ -1975,7 +1962,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1975
1962
  * - 使用双 RAF 等待 Weighing 子组件渲染完成后再滚动
1976
1963
  */
1977
1964
  useEffect(() => {
1978
- if (!open) return;
1965
+ if (!open || detailContentLoading) return;
1979
1966
  if (isMobile) return;
1980
1967
  if (!isWeighingProduct$1) return;
1981
1968
  if (!productData) return;
@@ -1994,6 +1981,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
1994
1981
  };
1995
1982
  }, [
1996
1983
  open,
1984
+ detailContentLoading,
1997
1985
  isMobile,
1998
1986
  isWeighingProduct$1,
1999
1987
  productData === null || productData === void 0 ? void 0 : productData._id,
@@ -2128,7 +2116,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
2128
2116
  })) : null);
2129
2117
  };
2130
2118
  const handleEnrichmentRetry = function() {
2131
- var _ref22 = _asyncToGenerator(function* () {
2119
+ var _ref21 = _asyncToGenerator(function* () {
2132
2120
  if (!productData || enrichmentRetryingRef.current) return;
2133
2121
  const taskId = openTaskIdRef.current;
2134
2122
  enrichmentRetryingRef.current = true;
@@ -2146,7 +2134,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
2146
2134
  }
2147
2135
  });
2148
2136
  return function handleEnrichmentRetry() {
2149
- return _ref22.apply(this, arguments);
2137
+ return _ref21.apply(this, arguments);
2150
2138
  };
2151
2139
  }();
2152
2140
  const enrichmentRetryAction = /* @__PURE__ */ React.createElement(Button$1, {
@@ -2160,13 +2148,13 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
2160
2148
  value: quantity,
2161
2149
  min: 1,
2162
2150
  max: inventorySelection ? Math.max(1, inventorySelection.maxQuantity) : 99999,
2163
- disabled: appearanceConfirmPending || detailLoading || (inventorySelection === null || inventorySelection === void 0 ? void 0 : inventorySelection.maxQuantity) === 0,
2151
+ disabled: appearanceConfirmPending || detailContentLoading || (inventorySelection === null || inventorySelection === void 0 ? void 0 : inventorySelection.maxQuantity) === 0,
2164
2152
  enableInput: (inventorySelection === null || inventorySelection === void 0 ? void 0 : inventorySelection.maxQuantity) !== 0,
2165
2153
  onChange: handleQuantityChange
2166
2154
  }) : null;
2167
2155
  const leftContent = (options = {}) => {
2168
2156
  const { showTop = true, showBottom = true } = options;
2169
- if (detailLoading || !productData) {
2157
+ if (detailContentLoading || !productData) {
2170
2158
  if (!showTop) return null;
2171
2159
  return /* @__PURE__ */ React.createElement("div", { className: "sku-detail-left" }, renderLoadingPanel());
2172
2160
  }
@@ -2227,7 +2215,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
2227
2215
  })) : null);
2228
2216
  };
2229
2217
  const rightContent = () => {
2230
- if (detailLoading || !productData) return /* @__PURE__ */ React.createElement("div", { className: "sku-detail-right-content" }, renderLoadingPanel());
2218
+ if (detailContentLoading || !productData) return /* @__PURE__ */ React.createElement("div", { className: "sku-detail-right-content" }, renderLoadingPanel());
2231
2219
  if (isCustomSelectionFlow && selectionFlowInitialDraft) {
2232
2220
  var _compiledSelectionFlo;
2233
2221
  const showProductDetailsCollapsible = !detailAppearance && !!(skuDetailConfig === null || skuDetailConfig === void 0 ? void 0 : skuDetailConfig.isShowCollapsibleSections);
@@ -2464,7 +2452,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
2464
2452
  subtitle: productSubtitle,
2465
2453
  cover: productData === null || productData === void 0 ? void 0 : productData.cover,
2466
2454
  coverText,
2467
- loading: detailLoading || !productData,
2455
+ loading: detailContentLoading || !productData,
2468
2456
  pending: appearanceConfirmPending,
2469
2457
  confirmDisabled: confirmDisabled || salesSettingsPending || inventoryQuantityBlocked || posAutoResolutionConfirmPending || Boolean(hasReachedBookingPriceStep && (selectionFlowBookingPricePending || selectionFlowBookingPriceError)),
2470
2458
  unitPrice: isVirtualOnlySettlement ? renderVirtualSettlementUnitPrices() : productDetailPriceText,
@@ -2490,7 +2478,7 @@ const SkuDetailModal = ({ onConfirm, onRemove, onClose, resolveProductData, reso
2490
2478
  removeControl: !isCreateMode && skuDetailConfig.isShowRemove !== false && onRemove && /* @__PURE__ */ React.createElement("button", {
2491
2479
  type: "button",
2492
2480
  className: "sku-detail-appearance__remove",
2493
- disabled: appearanceConfirmPending || detailLoading || isRemoveDisabled,
2481
+ disabled: appearanceConfirmPending || detailContentLoading || isRemoveDisabled,
2494
2482
  onClick: handleRemove
2495
2483
  }, locales.getText("pisell2.text.sku.detail.modal.btn.remove")),
2496
2484
  confirmLabel: isCreateMode && currentStep >= maxStepIndex ? locales.getText("pisell2.text.sku.detail.modal.btn.add.to.cart") : pcConfirmButtonText,
@@ -2613,16 +2601,16 @@ var skuDetailModal_default = withResponsive(ForwardedSkuDetailModal);
2613
2601
  * v2 主商品 source 单价(不含套餐子商品、不含单规格加价),供 _extend.price / transform 使用。
2614
2602
  */
2615
2603
  function getSourceUnitPrice(params) {
2616
- var _ref23, _ref24, _productData$base_pri, _productData$_extend3;
2604
+ var _ref22, _ref23, _productData$base_pri, _productData$_extend3;
2617
2605
  const { productData, skuValue } = params;
2618
2606
  if (!productData) return 0;
2619
- let price = new Decimal((_ref23 = (_ref24 = (_productData$base_pri = productData === null || productData === void 0 ? void 0 : productData.base_price) !== null && _productData$base_pri !== void 0 ? _productData$base_pri : productData === null || productData === void 0 ? void 0 : productData.price) !== null && _ref24 !== void 0 ? _ref24 : productData === null || productData === void 0 || (_productData$_extend3 = productData._extend) === null || _productData$_extend3 === void 0 ? void 0 : _productData$_extend3.price) !== null && _ref23 !== void 0 ? _ref23 : 0);
2607
+ let price = new Decimal((_ref22 = (_ref23 = (_productData$base_pri = productData === null || productData === void 0 ? void 0 : productData.base_price) !== null && _productData$base_pri !== void 0 ? _productData$base_pri : productData === null || productData === void 0 ? void 0 : productData.price) !== null && _ref23 !== void 0 ? _ref23 : productData === null || productData === void 0 || (_productData$_extend3 = productData._extend) === null || _productData$_extend3 === void 0 ? void 0 : _productData$_extend3.price) !== null && _ref22 !== void 0 ? _ref22 : 0);
2620
2608
  if (skuValue === null || skuValue === void 0 ? void 0 : skuValue.product_variant_id) {
2621
2609
  var _variant2;
2622
2610
  const variantItem = productData === null || productData === void 0 || (_variant2 = productData.variant) === null || _variant2 === void 0 ? void 0 : _variant2.find((item) => Number(item === null || item === void 0 ? void 0 : item.id) === Number(skuValue.product_variant_id));
2623
2611
  if (variantItem) {
2624
- var _ref25, _ref26, _variantItem$price;
2625
- price = new Decimal((_ref25 = (_ref26 = (_variantItem$price = variantItem === null || variantItem === void 0 ? void 0 : variantItem.price) !== null && _variantItem$price !== void 0 ? _variantItem$price : variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _ref26 !== void 0 ? _ref26 : variantItem === null || variantItem === void 0 ? void 0 : variantItem.original_price) !== null && _ref25 !== void 0 ? _ref25 : 0);
2612
+ var _ref24, _ref25, _variantItem$price;
2613
+ price = new Decimal((_ref24 = (_ref25 = (_variantItem$price = variantItem === null || variantItem === void 0 ? void 0 : variantItem.price) !== null && _variantItem$price !== void 0 ? _variantItem$price : variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _ref25 !== void 0 ? _ref25 : variantItem === null || variantItem === void 0 ? void 0 : variantItem.original_price) !== null && _ref24 !== void 0 ? _ref24 : 0);
2626
2614
  }
2627
2615
  }
2628
2616
  return price.toNumber();
@@ -2633,16 +2621,16 @@ function getSourceUnitPrice(params) {
2633
2621
  * 计算规则与 booking/utils.ts 的 getProductTotalPrice 保持一致。
2634
2622
  */
2635
2623
  function getSelectedUnitPrice(params) {
2636
- var _ref27, _productData$base_pri2, _productData$_extend4;
2624
+ var _ref26, _productData$base_pri2, _productData$_extend4;
2637
2625
  const { productData, skuValue } = params;
2638
2626
  if (!productData) return 0;
2639
- let price = new Decimal((_ref27 = (_productData$base_pri2 = productData === null || productData === void 0 ? void 0 : productData.base_price) !== null && _productData$base_pri2 !== void 0 ? _productData$base_pri2 : productData === null || productData === void 0 || (_productData$_extend4 = productData._extend) === null || _productData$_extend4 === void 0 ? void 0 : _productData$_extend4.price) !== null && _ref27 !== void 0 ? _ref27 : 0);
2627
+ let price = new Decimal((_ref26 = (_productData$base_pri2 = productData === null || productData === void 0 ? void 0 : productData.base_price) !== null && _productData$base_pri2 !== void 0 ? _productData$base_pri2 : productData === null || productData === void 0 || (_productData$_extend4 = productData._extend) === null || _productData$_extend4 === void 0 ? void 0 : _productData$_extend4.price) !== null && _ref26 !== void 0 ? _ref26 : 0);
2640
2628
  if (skuValue === null || skuValue === void 0 ? void 0 : skuValue.product_variant_id) {
2641
2629
  var _variant3;
2642
2630
  const variantItem = productData === null || productData === void 0 || (_variant3 = productData.variant) === null || _variant3 === void 0 ? void 0 : _variant3.find((item) => Number(item === null || item === void 0 ? void 0 : item.id) === Number(skuValue.product_variant_id));
2643
2631
  if (variantItem) {
2644
- var _ref28, _variantItem$base_pri;
2645
- price = new Decimal((_ref28 = (_variantItem$base_pri = variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _variantItem$base_pri !== void 0 ? _variantItem$base_pri : variantItem === null || variantItem === void 0 ? void 0 : variantItem.original_price) !== null && _ref28 !== void 0 ? _ref28 : 0);
2632
+ var _ref27, _variantItem$base_pri;
2633
+ price = new Decimal((_ref27 = (_variantItem$base_pri = variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _variantItem$base_pri !== void 0 ? _variantItem$base_pri : variantItem === null || variantItem === void 0 ? void 0 : variantItem.original_price) !== null && _ref27 !== void 0 ? _ref27 : 0);
2646
2634
  }
2647
2635
  }
2648
2636
  if (Array.isArray(skuValue === null || skuValue === void 0 ? void 0 : skuValue.bundle) && skuValue.bundle.length > 0) price = skuValue.bundle.reduce((accumulator, currentValue) => {
@@ -2651,8 +2639,8 @@ function getSelectedUnitPrice(params) {
2651
2639
  return accumulator.add(currentPrice.mul(currentNum));
2652
2640
  }, price);
2653
2641
  if (Array.isArray(skuValue === null || skuValue === void 0 ? void 0 : skuValue.option) && skuValue.option.length > 0) price = skuValue.option.reduce((accumulator, currentValue) => {
2654
- var _ref29, _currentValue$origina;
2655
- const currentPrice = new Decimal((_ref29 = (_currentValue$origina = currentValue === null || currentValue === void 0 ? void 0 : currentValue.original_price) !== null && _currentValue$origina !== void 0 ? _currentValue$origina : currentValue === null || currentValue === void 0 ? void 0 : currentValue.price) !== null && _ref29 !== void 0 ? _ref29 : 0);
2642
+ var _ref28, _currentValue$origina;
2643
+ const currentPrice = new Decimal((_ref28 = (_currentValue$origina = currentValue === null || currentValue === void 0 ? void 0 : currentValue.original_price) !== null && _currentValue$origina !== void 0 ? _currentValue$origina : currentValue === null || currentValue === void 0 ? void 0 : currentValue.price) !== null && _ref28 !== void 0 ? _ref28 : 0);
2656
2644
  const currentNum = new Decimal((currentValue === null || currentValue === void 0 ? void 0 : currentValue.num) || 0);
2657
2645
  return accumulator.add(currentPrice.mul(currentNum));
2658
2646
  }, price);
@@ -2673,8 +2661,8 @@ function getOtherFromSkuValue(params) {
2673
2661
  var _variant4;
2674
2662
  const variantItem = productData === null || productData === void 0 || (_variant4 = productData.variant) === null || _variant4 === void 0 ? void 0 : _variant4.find((item) => Number(item === null || item === void 0 ? void 0 : item.id) === Number(other.product_variant_id));
2675
2663
  if (variantItem) {
2676
- var _ref30, _variantItem$price2;
2677
- other.price = Number((_ref30 = (_variantItem$price2 = variantItem === null || variantItem === void 0 ? void 0 : variantItem.price) !== null && _variantItem$price2 !== void 0 ? _variantItem$price2 : variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _ref30 !== void 0 ? _ref30 : 0);
2664
+ var _ref29, _variantItem$price2;
2665
+ other.price = Number((_ref29 = (_variantItem$price2 = variantItem === null || variantItem === void 0 ? void 0 : variantItem.price) !== null && _variantItem$price2 !== void 0 ? _variantItem$price2 : variantItem === null || variantItem === void 0 ? void 0 : variantItem.base_price) !== null && _ref29 !== void 0 ? _ref29 : 0);
2678
2666
  }
2679
2667
  }
2680
2668
  return other;
@@ -23,7 +23,7 @@ function resolveLocalizedText(value, translationOriginal, localeOverride) {
23
23
  const locale = localeOverride || ((_locales$getLocale = _pisell_utils.locales.getLocale) === null || _locales$getLocale === void 0 ? void 0 : _locales$getLocale.call(_pisell_utils.locales)) || _pisell_utils.locales.locale || "en";
24
24
  const normalized = ((_locales$formatLocale = _pisell_utils.locales.formatLocale) === null || _locales$formatLocale === void 0 ? void 0 : _locales$formatLocale.call(_pisell_utils.locales, locale)) || locale;
25
25
  const record = value;
26
- return record[normalized] || record[locale] || record.auto || record.default || record.original || record.en || record["zh-CN"] || record["zh-HK"] || record.ja || record.pt || record.kitchen || Object.keys(record).sort().map((key) => record[key]).find((text) => typeof text === "string" && text) || "";
26
+ return record[normalized] || record[locale] || record.original || record.default || record.auto || record.en || record["zh-CN"] || record["zh-HK"] || record.ja || record.pt || record.kitchen || Object.keys(record).sort().map((key) => record[key]).find((text) => typeof text === "string" && text) || "";
27
27
  }
28
28
  return String(value);
29
29
  }
@@ -1,6 +1,7 @@
1
1
  const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
2
2
  const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
3
3
  const require_useScrollActivity = require("../../../hooks/useScrollActivity.js");
4
+ const require_observeTransitions = require("./observeTransitions.js");
4
5
  let react = require("react");
5
6
  react = require_runtime.__toESM(react);
6
7
  let antd = require("antd");
@@ -11,7 +12,6 @@ require("./index.less");
11
12
  //#region src/pro/compensatedPisellContainer/floatingLayer/index.tsx
12
13
  const prefixCls = "pisell-lowcode-floating-layer";
13
14
  const legacyDrawerPrefixCls = "pisell-lowcode-drawer";
14
- const motionDuration = 300;
15
15
  const ModalButton = antd.Button;
16
16
  const overlayBaseZIndex = 600;
17
17
  const overlayZIndexStep = 10;
@@ -75,35 +75,28 @@ const getFloatingLayoutState = (isLayoutChanging = false) => {
75
75
  viewportSize: getViewportSize()
76
76
  };
77
77
  };
78
- const isSameFloatingLayout = (prevLayout, nextLayout) => {
79
- return Math.abs(prevLayout.bodyScale.x - nextLayout.bodyScale.x) < .001 && Math.abs(prevLayout.bodyScale.y - nextLayout.bodyScale.y) < .001 && prevLayout.viewportSize.width === nextLayout.viewportSize.width && prevLayout.viewportSize.height === nextLayout.viewportSize.height && prevLayout.isLayoutChanging === nextLayout.isLayoutChanging;
78
+ const isSameFloatingGeometry = (prevLayout, nextLayout) => {
79
+ return Math.abs(prevLayout.bodyScale.x - nextLayout.bodyScale.x) < .001 && Math.abs(prevLayout.bodyScale.y - nextLayout.bodyScale.y) < .001 && prevLayout.viewportSize.width === nextLayout.viewportSize.width && prevLayout.viewportSize.height === nextLayout.viewportSize.height;
80
80
  };
81
81
  const useBodyScaleViewport = () => {
82
82
  const [layoutState, setLayoutState] = (0, react.useState)(() => getFloatingLayoutState(false));
83
83
  const updateFrameRef = (0, react.useRef)();
84
- const settleTimerRef = (0, react.useRef)();
84
+ const settleFrameRef = (0, react.useRef)();
85
85
  (0, react.useEffect)(() => {
86
86
  var _window$visualViewpor;
87
87
  if (typeof window === "undefined" || typeof document === "undefined") return;
88
- const setNextLayout = (isLayoutChanging) => {
89
- const nextLayout = getFloatingLayoutState(isLayoutChanging);
90
- setLayoutState((prevLayout) => isSameFloatingLayout(prevLayout, nextLayout) ? prevLayout : nextLayout);
91
- };
92
- const markLayoutSettled = () => {
93
- if (settleTimerRef.current) window.clearTimeout(settleTimerRef.current);
94
- settleTimerRef.current = window.setTimeout(() => {
95
- setNextLayout(false);
96
- }, motionDuration);
88
+ const updateGeometry = () => {
89
+ const nextLayout = getFloatingLayoutState(true);
90
+ setLayoutState((prevLayout) => isSameFloatingGeometry(prevLayout, nextLayout) ? prevLayout : nextLayout);
97
91
  };
98
92
  const scheduleScaleViewportUpdate = () => {
99
93
  if (updateFrameRef.current) window.cancelAnimationFrame(updateFrameRef.current);
100
94
  updateFrameRef.current = window.requestAnimationFrame(() => {
101
95
  updateFrameRef.current = void 0;
102
- setNextLayout(true);
103
- markLayoutSettled();
96
+ updateGeometry();
104
97
  });
105
98
  };
106
- setNextLayout(false);
99
+ updateGeometry();
107
100
  window.addEventListener("resize", scheduleScaleViewportUpdate);
108
101
  (_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.addEventListener("resize", scheduleScaleViewportUpdate);
109
102
  const bodyObserver = new MutationObserver(scheduleScaleViewportUpdate);
@@ -114,12 +107,21 @@ const useBodyScaleViewport = () => {
114
107
  return () => {
115
108
  var _window$visualViewpor2;
116
109
  if (updateFrameRef.current) window.cancelAnimationFrame(updateFrameRef.current);
117
- if (settleTimerRef.current) window.clearTimeout(settleTimerRef.current);
118
110
  window.removeEventListener("resize", scheduleScaleViewportUpdate);
119
111
  (_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 || _window$visualViewpor2.removeEventListener("resize", scheduleScaleViewportUpdate);
120
112
  bodyObserver.disconnect();
121
113
  };
122
114
  }, []);
115
+ (0, react.useLayoutEffect)(() => {
116
+ if (!layoutState.isLayoutChanging) return;
117
+ document.body.getBoundingClientRect();
118
+ settleFrameRef.current = requestAnimationFrame(() => {
119
+ setLayoutState((current) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, current), {}, { isLayoutChanging: false }));
120
+ });
121
+ return () => {
122
+ if (settleFrameRef.current !== void 0) cancelAnimationFrame(settleFrameRef.current);
123
+ };
124
+ }, [layoutState]);
123
125
  return layoutState;
124
126
  };
125
127
  const getDefaultDrawerSize = (size) => {
@@ -236,7 +238,13 @@ const TransformFloatingLayer = (props) => {
236
238
  shouldAutoHideHeaderFooter
237
239
  ]);
238
240
  const [rendered, setRendered] = (0, react.useState)(mergedOpen);
239
- const [motionOpen, setMotionOpen] = (0, react.useState)(mergedOpen);
241
+ const [motion, setMotion] = (0, react.useState)({
242
+ open: false,
243
+ id: 0
244
+ });
245
+ const motionOpen = motion.open;
246
+ const wrapperRef = (0, react.useRef)(null);
247
+ const maskRef = (0, react.useRef)(null);
240
248
  const shouldRenderLayer = rendered || mergedOpen;
241
249
  const skipCurrentEnterMotion = skipEnterMotion && mergedOpen;
242
250
  const effectiveMotionOpen = skipCurrentEnterMotion ? true : motionOpen;
@@ -244,10 +252,16 @@ const TransformFloatingLayer = (props) => {
244
252
  const overlayIdRef = (0, react.useRef)();
245
253
  const autoZIndexRef = (0, react.useRef)();
246
254
  const autoZIndexActiveRef = (0, react.useRef)(false);
247
- const mountedRef = (0, react.useRef)(false);
248
- const renderedRef = (0, react.useRef)(mergedOpen);
249
- const motionFrameRef = (0, react.useRef)();
250
- const motionTimerRef = (0, react.useRef)();
255
+ const hasOpenedRef = (0, react.useRef)(false);
256
+ const motionRunRef = (0, react.useRef)(0);
257
+ const motionOptionsRef = (0, react.useRef)({
258
+ afterOpenChange,
259
+ shouldDestroyOnClose
260
+ });
261
+ motionOptionsRef.current = {
262
+ afterOpenChange,
263
+ shouldDestroyOnClose
264
+ };
251
265
  if (overlayIdRef.current === void 0) overlayIdRef.current = getNextOverlayId();
252
266
  const overlayId = overlayIdRef.current;
253
267
  const releaseAutoZIndex = () => {
@@ -263,50 +277,49 @@ const TransformFloatingLayer = (props) => {
263
277
  autoZIndexActiveRef.current = true;
264
278
  }
265
279
  const mergedZIndex = (_ref = zIndex !== null && zIndex !== void 0 ? zIndex : autoZIndexRef.current) !== null && _ref !== void 0 ? _ref : overlayBaseZIndex;
266
- const updateRendered = (nextRendered) => {
267
- renderedRef.current = nextRendered;
268
- setRendered(nextRendered);
269
- };
270
280
  const handleClose = (event) => {
271
281
  const closeHandler = mode === "modal" ? onCancel || onClose : onClose || onCancel;
272
282
  closeHandler === null || closeHandler === void 0 || closeHandler(event);
273
283
  };
274
- (0, react.useEffect)(() => {
284
+ (0, react.useEffect)(() => () => releaseAutoZIndex(), []);
285
+ (0, react.useLayoutEffect)(() => {
286
+ const id = ++motionRunRef.current;
287
+ let frame;
288
+ if (mergedOpen) {
289
+ hasOpenedRef.current = true;
290
+ setRendered(true);
291
+ }
292
+ if (mergedOpen && !skipEnterMotion && !motionOpen) {
293
+ var _wrapperRef$current, _maskRef$current;
294
+ (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 || _wrapperRef$current.getBoundingClientRect();
295
+ (_maskRef$current = maskRef.current) === null || _maskRef$current === void 0 || _maskRef$current.getBoundingClientRect();
296
+ frame = requestAnimationFrame(() => {
297
+ frame = requestAnimationFrame(() => setMotion({
298
+ open: true,
299
+ id
300
+ }));
301
+ });
302
+ } else setMotion({
303
+ open: mergedOpen,
304
+ id
305
+ });
275
306
  return () => {
276
- if (motionFrameRef.current) window.cancelAnimationFrame(motionFrameRef.current);
277
- if (motionTimerRef.current) window.clearTimeout(motionTimerRef.current);
278
- releaseAutoZIndex();
307
+ ++motionRunRef.current;
308
+ if (frame !== void 0) cancelAnimationFrame(frame);
279
309
  };
280
- }, []);
281
- (0, react.useEffect)(() => {
282
- if (typeof window === "undefined") return;
283
- if (motionFrameRef.current) window.cancelAnimationFrame(motionFrameRef.current);
284
- if (motionTimerRef.current) window.clearTimeout(motionTimerRef.current);
285
- if (mergedOpen) if (renderedRef.current) setMotionOpen(true);
286
- else {
287
- updateRendered(true);
288
- setMotionOpen(false);
289
- motionFrameRef.current = window.requestAnimationFrame(() => {
290
- setMotionOpen(true);
291
- });
292
- }
293
- else setMotionOpen(false);
294
- if (!mountedRef.current) {
295
- mountedRef.current = true;
296
- return;
297
- }
298
- motionTimerRef.current = window.setTimeout(() => {
299
- afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(mergedOpen);
300
- if (!mergedOpen) {
310
+ }, [mergedOpen, skipEnterMotion]);
311
+ (0, react.useLayoutEffect)(() => {
312
+ if (!hasOpenedRef.current || motion.id !== motionRunRef.current || motion.open !== mergedOpen) return;
313
+ return require_observeTransitions.observeTransitions([wrapperRef.current, maskRef.current].filter((element) => element !== null), () => {
314
+ var _motionOptionsRef$cur, _motionOptionsRef$cur2;
315
+ if (motion.id !== motionRunRef.current) return;
316
+ if (!motion.open) {
301
317
  releaseAutoZIndex();
302
- if (shouldDestroyOnClose) updateRendered(false);
318
+ if (motionOptionsRef.current.shouldDestroyOnClose) setRendered(false);
303
319
  }
304
- }, motionDuration);
305
- }, [
306
- afterOpenChange,
307
- mergedOpen,
308
- shouldDestroyOnClose
309
- ]);
320
+ (_motionOptionsRef$cur = (_motionOptionsRef$cur2 = motionOptionsRef.current).afterOpenChange) === null || _motionOptionsRef$cur === void 0 || _motionOptionsRef$cur.call(_motionOptionsRef$cur2, motion.open);
321
+ });
322
+ }, [motion, mergedOpen]);
310
323
  (0, react.useEffect)(() => {
311
324
  if (!mergedOpen || keyboard === false || typeof window === "undefined") return;
312
325
  const handleKeyDown = (event) => {
@@ -413,12 +426,14 @@ const TransformFloatingLayer = (props) => {
413
426
  className: (0, classnames.default)(`${prefixCls}-root`, `${prefixCls}-mode-${mode}`, `${prefixCls}-${centered && mode === "modal" ? "center" : placement}`, getLegacyDrawerRootClasses(mode, placement), rootClassName, wrapClassName, layerClassNames === null || layerClassNames === void 0 ? void 0 : layerClassNames.root),
414
427
  style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ zIndex: mergedZIndex }, rootScaleStyle), rootStyle), styles === null || styles === void 0 ? void 0 : styles.root)
415
428
  }, mask ? /* @__PURE__ */ react.default.createElement("div", {
429
+ ref: maskRef,
416
430
  className: (0, classnames.default)(`${prefixCls}-mask`, getLegacyDrawerClass(mode, "mask"), layerClassNames === null || layerClassNames === void 0 ? void 0 : layerClassNames.mask),
417
431
  style: maskStyle,
418
432
  onClick: (event) => {
419
433
  if (event.target === event.currentTarget && maskClosable) handleClose(event);
420
434
  }
421
435
  }) : null, /* @__PURE__ */ react.default.createElement("div", {
436
+ ref: wrapperRef,
422
437
  className: (0, classnames.default)(`${prefixCls}-content-wrapper`, getLegacyDrawerWrapperClasses(mode), className, layerClassNames === null || layerClassNames === void 0 ? void 0 : layerClassNames.wrapper),
423
438
  style: wrapperStyle
424
439
  }, modalRender ? modalRender(contentNode) : contentNode)) : null;