@blocklet/launcher-workflow 2.0.19 → 2.0.21

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 (2) hide show
  1. package/lib/purchase.js +23 -19
  2. package/package.json +5 -5
package/lib/purchase.js CHANGED
@@ -65,7 +65,7 @@ PrevIcon.defaultProps = {
65
65
  height: "40"
66
66
  };
67
67
  function PurchasePage(_ref) {
68
- var _planState$value3, _planState$value4;
68
+ var _planState$value4, _planState$value5;
69
69
  let {
70
70
  disableBack
71
71
  } = _ref;
@@ -83,9 +83,9 @@ function PurchasePage(_ref) {
83
83
  const [openMorePlanPrompt, setOpenMorePlanPrompt] = (0, _react.useState)(false);
84
84
  const [splideConfig, setSplideConfig] = (0, _useSetState.default)({
85
85
  arrows: false,
86
+ perPage: 100,
86
87
  width: '300px',
87
- gap: '16px',
88
- focus: 0
88
+ gap: '16px'
89
89
  });
90
90
  const {
91
91
  routerPrefix,
@@ -121,6 +121,11 @@ function PurchasePage(_ref) {
121
121
  };
122
122
  };
123
123
  const selectCurrent = (perPage, curIndex) => {
124
+ var _planState$value;
125
+ if (!((_planState$value = planState.value) !== null && _planState$value !== void 0 && _planState$value.length)) {
126
+ return;
127
+ }
128
+
124
129
  // 如果每页只有一个,则在翻页的时候默认选中当前项
125
130
  if (perPage === 1) {
126
131
  var _planState$value$curI;
@@ -132,8 +137,8 @@ function PurchasePage(_ref) {
132
137
  // eslint-disable-next-line react-hooks/exhaustive-deps
133
138
  }, [splideConfig]);
134
139
  (0, _react.useEffect)(() => {
135
- var _planState$value;
136
- if (!((_planState$value = planState.value) !== null && _planState$value !== void 0 && _planState$value.length) || typeof splideConfig.perPage === 'undefined') {
140
+ var _planState$value2;
141
+ if (!((_planState$value2 = planState.value) !== null && _planState$value2 !== void 0 && _planState$value2.length) || typeof splideConfig.perPage === 'undefined') {
137
142
  return;
138
143
  }
139
144
  const index = planState.value.findIndex(x => !!x.isRecommended);
@@ -149,8 +154,8 @@ function PurchasePage(_ref) {
149
154
  }
150
155
  }, [splideConfig.perPage, planState]);
151
156
  (0, _react.useEffect)(() => {
152
- var _planState$value2;
153
- if (!((_planState$value2 = planState.value) !== null && _planState$value2 !== void 0 && _planState$value2.length)) {
157
+ var _planState$value3;
158
+ if (!((_planState$value3 = planState.value) !== null && _planState$value3 !== void 0 && _planState$value3.length)) {
154
159
  return;
155
160
  }
156
161
  if (Number.isNaN(planListWidth)) {
@@ -176,7 +181,7 @@ function PurchasePage(_ref) {
176
181
  setSelectedPlanId(planId);
177
182
  };
178
183
  const productFeatures = [];
179
- if (!planState.loading && ((_planState$value3 = planState.value) === null || _planState$value3 === void 0 ? void 0 : _planState$value3.length) > 0) {
184
+ if (!planState.loading && ((_planState$value4 = planState.value) === null || _planState$value4 === void 0 ? void 0 : _planState$value4.length) > 0) {
180
185
  // TODO: Pricing Table: 临时做法
181
186
  try {
182
187
  const {
@@ -217,22 +222,22 @@ function PurchasePage(_ref) {
217
222
  toc: true,
218
223
  productFeatures: productFeatures,
219
224
  className: "toc"
220
- }), ((_planState$value4 = planState.value) === null || _planState$value4 === void 0 ? void 0 : _planState$value4.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactSplide.Splide, {
225
+ }), ((_planState$value5 = planState.value) === null || _planState$value5 === void 0 ? void 0 : _planState$value5.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactSplide.Splide, {
221
226
  extensions: {
222
227
  Grid: _splideExtensionGrid.Grid
223
228
  },
224
- onPaginationMounted: (_, _ref2) => {
225
- let {
226
- items
227
- } = _ref2;
228
- const showArrows = items.length > 1;
229
+ onPaginationMounted: splide => {
230
+ const pageCount = Math.ceil(planState.value.length / splide.options.perPage);
231
+ const showArrows = pageCount > 1;
229
232
  setSplideConfig({
230
233
  arrows: showArrows
231
234
  });
232
235
  if (showArrows) {
233
- setOpenMorePlanPrompt(true);
234
- // 3s 后隐藏
235
- setTimeout(() => setOpenMorePlanPrompt(false), 3000);
236
+ setTimeout(() => {
237
+ setOpenMorePlanPrompt(true);
238
+ // 3s 后隐藏
239
+ setTimeout(() => setOpenMorePlanPrompt(false), 3000);
240
+ }, 1000);
236
241
  }
237
242
  },
238
243
  hasTrack: false,
@@ -249,8 +254,7 @@ function PurchasePage(_ref) {
249
254
  trimSpace: true,
250
255
  width: splideConfig.width,
251
256
  perPage: splideConfig.perPage,
252
- gap: splideConfig.gap,
253
- focus: splideConfig.focus
257
+ gap: splideConfig.gap
254
258
  },
255
259
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
256
260
  className: "splide__arrows",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-workflow",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "description": "Purchase components for Launcher UI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -40,9 +40,9 @@
40
40
  "@arcblock/icons": "^2.5.19",
41
41
  "@arcblock/license": "^2.5.19",
42
42
  "@arcblock/ux": "^2.5.19",
43
- "@blocklet/launcher-layout": "2.0.19",
44
- "@blocklet/launcher-util": "2.0.19",
45
- "@blocklet/launcher-ux": "2.0.19",
43
+ "@blocklet/launcher-layout": "2.0.21",
44
+ "@blocklet/launcher-util": "2.0.21",
45
+ "@blocklet/launcher-ux": "2.0.21",
46
46
  "@did-pay/react": "^1.9.49",
47
47
  "@emotion/react": "^11.10.6",
48
48
  "@emotion/styled": "^11.10.6",
@@ -72,5 +72,5 @@
72
72
  "@babel/preset-react": "^7.18.6",
73
73
  "babel-plugin-inline-react-svg": "^2.0.2"
74
74
  },
75
- "gitHead": "175de8438e3343bd9a2b4e6df34fd78e0bfbd601"
75
+ "gitHead": "e427ccad66f6dc0b349d8ddff92f0f19e6d1753b"
76
76
  }