@cniot/android-pda-components 0.1.0 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.es.js CHANGED
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __objRest = (source, exclude) => {
18
21
  var target = {};
19
22
  for (var prop in source)
@@ -30,11 +33,9 @@ var __publicField = (obj, key, value) => {
30
33
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
34
  return value;
32
35
  };
33
- import * as React from "react";
34
- import React__default, { useState, useEffect, useRef, cloneElement, useCallback, forwardRef, useContext, useMemo } from "react";
35
- import { unstable_batchedUpdates } from "react-dom";
36
- var global$1 = "";
37
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
36
+ import React, { useState, useEffect, useRef, cloneElement, useCallback } from "react";
37
+ import ReactDOM from "react-dom";
38
+ var global = "";
38
39
  var _classnames_2_3_1_classnames = { exports: {} };
39
40
  /*!
40
41
  Copyright (c) 2018 Jed Watson.
@@ -94,25 +95,25 @@ function getTypeClass$1(type) {
94
95
  function Overlay(props) {
95
96
  const { verticalPosition = "center", visible = true, closable = false, onClosed = () => {
96
97
  } } = props;
97
- const [hidden, setHidden2] = useState(!visible);
98
+ const [hidden, setHidden] = useState(!visible);
98
99
  const option = {};
99
100
  if (closable) {
100
101
  option.onClick = (e) => {
101
- setHidden2(true);
102
+ setHidden(true);
102
103
  onClosed();
103
104
  };
104
105
  }
105
106
  useEffect(() => {
106
- setHidden2(!visible);
107
+ setHidden(!visible);
107
108
  }, [visible]);
108
- return !hidden ? /* @__PURE__ */ React__default.createElement("div", __spreadValues({
109
+ return !hidden ? /* @__PURE__ */ React.createElement("div", __spreadValues({
109
110
  className: getTypeClass$1(verticalPosition)
110
111
  }, option), props.children) : null;
111
112
  }
112
113
  var index$l = "";
113
114
  const blankFunc$5 = () => {
114
115
  };
115
- class PdaTitle extends React__default.Component {
116
+ class PdaTitle extends React.Component {
116
117
  constructor(props) {
117
118
  super(props);
118
119
  __publicField(this, "state", {
@@ -122,28 +123,28 @@ class PdaTitle extends React__default.Component {
122
123
  render() {
123
124
  const { className, goBack = true, goBackHandle = blankFunc$5, icon = "scan", title = "\u4EFB\u52A1", menuList = null } = this.props;
124
125
  const { showMenu } = this.state;
125
- return /* @__PURE__ */ React__default.createElement("div", {
126
+ return /* @__PURE__ */ React.createElement("div", {
126
127
  className: classNames({ [className]: true, "pda-header": true })
127
- }, /* @__PURE__ */ React__default.createElement("div", {
128
+ }, /* @__PURE__ */ React.createElement("div", {
128
129
  className: "header-click-area",
129
130
  onClick: goBack ? goBackHandle : blankFunc$5
130
- }, goBack && /* @__PURE__ */ React__default.createElement("div", {
131
+ }, goBack && /* @__PURE__ */ React.createElement("div", {
131
132
  className: "pda-goback"
132
- }), icon && /* @__PURE__ */ React__default.createElement("div", {
133
+ }), icon && /* @__PURE__ */ React.createElement("div", {
133
134
  className: classNames({ "pda-header-icon": true, ["pda-header-icon-" + icon]: true })
134
- })), /* @__PURE__ */ React__default.createElement("p", {
135
+ })), /* @__PURE__ */ React.createElement("p", {
135
136
  className: classNames({ "pda-title-text": true })
136
- }, title), menuList ? /* @__PURE__ */ React__default.createElement("div", {
137
+ }, title), menuList ? /* @__PURE__ */ React.createElement("div", {
137
138
  className: "pda-header-more",
138
139
  onClick: (e) => {
139
140
  this.setState({ showMenu: true });
140
141
  }
141
- }) : null, /* @__PURE__ */ React__default.createElement(Overlay, {
142
+ }) : null, /* @__PURE__ */ React.createElement(Overlay, {
142
143
  visible: showMenu,
143
144
  verticalPosition: "bottom",
144
145
  closable: true,
145
146
  onClosed: (e) => this.setState({ showMenu: false })
146
- }, /* @__PURE__ */ React__default.createElement("div", {
147
+ }, /* @__PURE__ */ React.createElement("div", {
147
148
  className: "pda-menus"
148
149
  }, menuList)));
149
150
  }
@@ -151,13 +152,13 @@ class PdaTitle extends React__default.Component {
151
152
  var index$k = "";
152
153
  function Button(props) {
153
154
  const { type = "default", onClick, className = "" } = props;
154
- return /* @__PURE__ */ React__default.createElement("button", {
155
+ return /* @__PURE__ */ React.createElement("button", {
155
156
  className: `pda-button pda-button-${type} ${className}`,
156
157
  onClick
157
158
  }, props.children);
158
159
  }
159
160
  function ButtonGroup(props) {
160
- return /* @__PURE__ */ React__default.createElement("div", {
161
+ return /* @__PURE__ */ React.createElement("div", {
161
162
  className: "button-group"
162
163
  }, props.children);
163
164
  }
@@ -166,99 +167,103 @@ var index$j = "";
166
167
  const empty$2 = () => {
167
168
  };
168
169
  function index$i(props) {
169
- const { onBack, icon, title, menus = [], onClickMenuItem = empty$2 } = props;
170
- const [showMenus, setShowMenus] = React__default.useState(false);
171
- return /* @__PURE__ */ React__default.createElement("div", {
170
+ const { onBack, icon, title, menus = [], onClickMenuItem = empty$2, cancelMenuText } = props;
171
+ const [showMenus, setShowMenus] = React.useState(false);
172
+ return /* @__PURE__ */ React.createElement("div", {
172
173
  className: "pda-header"
173
- }, /* @__PURE__ */ React__default.createElement("div", {
174
+ }, /* @__PURE__ */ React.createElement("div", {
174
175
  className: "header-click-area"
175
- }, onBack ? /* @__PURE__ */ React__default.createElement("div", {
176
+ }, onBack ? /* @__PURE__ */ React.createElement("div", {
176
177
  className: "pda-goback",
177
178
  onClick: () => onBack("back")
178
- }) : null, icon && /* @__PURE__ */ React__default.createElement("div", {
179
+ }) : null, icon && /* @__PURE__ */ React.createElement("div", {
179
180
  className: `pda-header-icon pda-header-icon-${icon}`
180
- })), /* @__PURE__ */ React__default.createElement("div", {
181
+ })), /* @__PURE__ */ React.createElement("div", {
181
182
  className: "pda-title-text"
182
- }, title), menus && menus.length ? /* @__PURE__ */ React__default.createElement("div", {
183
+ }, title), menus && menus.length ? /* @__PURE__ */ React.createElement("div", {
183
184
  className: "pda-header-more",
184
185
  onClick: () => setShowMenus(true)
185
- }) : null, /* @__PURE__ */ React__default.createElement(Overlay, {
186
+ }) : null, /* @__PURE__ */ React.createElement(Overlay, {
186
187
  visible: showMenus,
187
188
  verticalPosition: "bottom",
188
189
  closable: false,
189
190
  onClosed: () => setShowMenus(false)
190
- }, /* @__PURE__ */ React__default.createElement("div", {
191
+ }, /* @__PURE__ */ React.createElement("div", {
191
192
  className: "pda-menus"
192
193
  }, menus.map((item, index2) => {
193
- return /* @__PURE__ */ React__default.createElement(Button, {
194
+ return /* @__PURE__ */ React.createElement(Button, {
194
195
  onClick: () => {
195
196
  setShowMenus(false);
196
197
  onClickMenuItem(item);
197
198
  },
198
199
  key: item.key || index2
199
200
  }, item.label);
200
- }))));
201
+ }), cancelMenuText ? /* @__PURE__ */ React.createElement("div", {
202
+ style: { marginTop: 20 }
203
+ }, /* @__PURE__ */ React.createElement(Button, {
204
+ onClick: () => setShowMenus(false)
205
+ }, cancelMenuText)) : null)));
201
206
  }
202
207
  var index$h = "";
203
- class PdaInfoCard$2 extends React__default.Component {
208
+ class PdaInfoCard$2 extends React.Component {
204
209
  constructor(props) {
205
210
  super(props);
206
211
  }
207
212
  render() {
208
213
  const { className = "", title, highlightInfo, subTitle, subHighlightInfo, subHighlightSubInfo, infoImage, tagText, highlightInfoCN, highlightSubInfo, percentage, highlightSubInfoCN, boldInfo, infoList = [], style = {}, theme = "light" } = this.props;
209
- return /* @__PURE__ */ React__default.createElement("div", {
214
+ return /* @__PURE__ */ React.createElement("div", {
210
215
  className: classNames({ [className]: true, "pda-info-card": true, "pda-info-card-dark": theme === "dark" }),
211
216
  style
212
- }, /* @__PURE__ */ React__default.createElement("div", {
217
+ }, /* @__PURE__ */ React.createElement("div", {
213
218
  className: "pda-info-card-title-section"
214
- }, /* @__PURE__ */ React__default.createElement("p", {
219
+ }, /* @__PURE__ */ React.createElement("div", {
215
220
  className: "pda-info-card-title"
216
- }, title), tagText ? /* @__PURE__ */ React__default.createElement("div", {
221
+ }, title), tagText ? /* @__PURE__ */ React.createElement("div", {
217
222
  className: "pda-info-card-tag"
218
- }, /* @__PURE__ */ React__default.createElement("p", {
223
+ }, /* @__PURE__ */ React.createElement("div", {
219
224
  className: "pda-info-card-tag-text"
220
- }, tagText)) : null), /* @__PURE__ */ React__default.createElement("div", {
225
+ }, tagText)) : null), /* @__PURE__ */ React.createElement("div", {
221
226
  className: "pda-info-card-highlight-section"
222
- }, /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("p", {
227
+ }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
223
228
  className: "pda-info-card-highlight"
224
- }, /* @__PURE__ */ React__default.createElement("span", {
229
+ }, /* @__PURE__ */ React.createElement("span", {
225
230
  className: "pda-info-card-highlight1"
226
- }, highlightInfo), /* @__PURE__ */ React__default.createElement("span", {
231
+ }, highlightInfo), /* @__PURE__ */ React.createElement("span", {
227
232
  className: "pda-info-card-highlight1CN"
228
- }, highlightInfoCN), /* @__PURE__ */ React__default.createElement("span", {
233
+ }, highlightInfoCN), /* @__PURE__ */ React.createElement("span", {
229
234
  className: "pda-info-card-highlight2"
230
- }, highlightSubInfo), /* @__PURE__ */ React__default.createElement("span", {
235
+ }, highlightSubInfo), /* @__PURE__ */ React.createElement("span", {
231
236
  className: "pda-info-card-highlight2CN"
232
- }, highlightSubInfoCN)), subTitle ? /* @__PURE__ */ React__default.createElement("p", {
237
+ }, highlightSubInfoCN)), subTitle ? /* @__PURE__ */ React.createElement("div", {
233
238
  className: "pda-info-card-title"
234
- }, subTitle) : null, subHighlightInfo ? /* @__PURE__ */ React__default.createElement("p", {
239
+ }, subTitle) : null, subHighlightInfo ? /* @__PURE__ */ React.createElement("div", {
235
240
  className: "pda-info-card-highlight"
236
- }, /* @__PURE__ */ React__default.createElement("span", {
241
+ }, /* @__PURE__ */ React.createElement("span", {
237
242
  className: "pda-info-card-highlight1"
238
- }, subHighlightInfo), /* @__PURE__ */ React__default.createElement("span", {
243
+ }, subHighlightInfo), /* @__PURE__ */ React.createElement("span", {
239
244
  className: "pda-info-card-highlight2"
240
- }, subHighlightSubInfo)) : null), infoImage ? /* @__PURE__ */ React__default.createElement("img", {
245
+ }, subHighlightSubInfo)) : null), infoImage ? /* @__PURE__ */ React.createElement("img", {
241
246
  src: infoImage,
242
247
  width: 150,
243
248
  height: 150
244
- }) : null), percentage !== void 0 ? /* @__PURE__ */ React__default.createElement("div", {
249
+ }) : null), percentage !== void 0 ? /* @__PURE__ */ React.createElement("div", {
245
250
  className: "pda-info-card-progress"
246
- }, /* @__PURE__ */ React__default.createElement("div", {
251
+ }, /* @__PURE__ */ React.createElement("div", {
247
252
  className: "pda-info-card-progress-inside",
248
253
  style: { width: `${percentage * 100}%` }
249
- })) : null, /* @__PURE__ */ React__default.createElement("p", {
254
+ })) : null, /* @__PURE__ */ React.createElement("div", {
250
255
  className: "pda-info-card-bold"
251
256
  }, boldInfo), infoList.map((item, index2) => {
252
- return /* @__PURE__ */ React__default.createElement("p", {
257
+ return /* @__PURE__ */ React.createElement("div", {
253
258
  key: index2,
254
259
  className: "pda-info-card-list"
255
- }, /* @__PURE__ */ React__default.createElement("span", null, item.label || ""), "\xA0\xA0", /* @__PURE__ */ React__default.createElement("span", null, item.content || ""));
260
+ }, /* @__PURE__ */ React.createElement("span", null, item.label || ""), "\xA0\xA0", /* @__PURE__ */ React.createElement("span", null, item.content || ""));
256
261
  }));
257
262
  }
258
263
  }
259
264
  PdaInfoCard$2.IMAGE_1 = "https://img.alicdn.com/imgextra/i2/O1CN01qYuxip1ME9zhdL9XG_!!6000000001402-2-tps-150-150.png";
260
265
  var index$g = "";
261
- class PdaListItem extends React__default.Component {
266
+ class PdaListItem extends React.Component {
262
267
  constructor(props) {
263
268
  super(props);
264
269
  }
@@ -267,38 +272,38 @@ class PdaListItem extends React__default.Component {
267
272
  }, onHeightLightClick = () => {
268
273
  }, onIconClick = () => {
269
274
  }, highlightText, highlightSubText, stateTextList = [], stateList = [], subInfoList = [], style = {}, icon } = this.props;
270
- return /* @__PURE__ */ React__default.createElement("div", {
275
+ return /* @__PURE__ */ React.createElement("div", {
271
276
  className: classNames({ [className]: true, "pda-list-item": true }),
272
277
  style,
273
278
  onClick
274
- }, /* @__PURE__ */ React__default.createElement("p", {
279
+ }, /* @__PURE__ */ React.createElement("div", {
275
280
  className: "pda-listitem-header"
276
- }, header), /* @__PURE__ */ React__default.createElement("div", {
281
+ }, header), /* @__PURE__ */ React.createElement("div", {
277
282
  onClick: onHeightLightClick,
278
283
  className: "pda-listitem-highlight"
279
- }, /* @__PURE__ */ React__default.createElement("p", null, highlightText), /* @__PURE__ */ React__default.createElement("p", null, highlightSubText)), /* @__PURE__ */ React__default.createElement("p", {
284
+ }, /* @__PURE__ */ React.createElement("div", null, highlightText), /* @__PURE__ */ React.createElement("div", null, highlightSubText)), /* @__PURE__ */ React.createElement("div", {
280
285
  className: "pda-listitem-state-text"
281
286
  }, stateTextList.map((item, index2) => {
282
- return /* @__PURE__ */ React__default.createElement("span", {
287
+ return /* @__PURE__ */ React.createElement("span", {
283
288
  key: index2
284
289
  }, item.label || "", "\uFF5C");
285
- })), /* @__PURE__ */ React__default.createElement("div", {
290
+ })), /* @__PURE__ */ React.createElement("div", {
286
291
  className: "pda-listitem-state-block"
287
292
  }, stateList.map((item, index2) => {
288
293
  const type = item && item.type ? item.type : "default";
289
- return /* @__PURE__ */ React__default.createElement("div", {
294
+ return /* @__PURE__ */ React.createElement("div", {
290
295
  key: index2,
291
296
  className: type
292
297
  }, item.label || "");
293
298
  })), subInfoList.map((item, index2) => {
294
- return /* @__PURE__ */ React__default.createElement("p", {
299
+ return /* @__PURE__ */ React.createElement("div", {
295
300
  key: index2,
296
301
  className: "pda-listitem-subinfo"
297
- }, /* @__PURE__ */ React__default.createElement("span", null, item.label || ""), "\xA0\xA0", /* @__PURE__ */ React__default.createElement("span", null, item.content || ""));
298
- }), icon ? /* @__PURE__ */ React__default.createElement("div", {
302
+ }, /* @__PURE__ */ React.createElement("span", null, item.label || ""), "\xA0\xA0", /* @__PURE__ */ React.createElement("span", null, item.content || ""));
303
+ }), icon ? /* @__PURE__ */ React.createElement("div", {
299
304
  onClick: onIconClick,
300
305
  className: "pda-listitem-icon"
301
- }, /* @__PURE__ */ React__default.createElement("div", {
306
+ }, /* @__PURE__ */ React.createElement("div", {
302
307
  className: classNames({ "listitem-icon-container": true, ["listitem-icon-" + icon]: true })
303
308
  })) : null);
304
309
  }
@@ -306,32 +311,49 @@ class PdaListItem extends React__default.Component {
306
311
  var index$f = "";
307
312
  function empty$1() {
308
313
  }
309
- function Confirm$1(props) {
314
+ function Confirm(props) {
310
315
  const { title = "title", message = null, subMessage = [], okText = "okText", cancelText = null, onClick = empty$1, type = "primary" } = props;
311
- return /* @__PURE__ */ React__default.createElement("div", {
316
+ return /* @__PURE__ */ React.createElement("div", {
312
317
  className: classNames({ "confirm-wrap": true, ["confirm-" + type]: true })
313
- }, /* @__PURE__ */ React__default.createElement("div", {
318
+ }, /* @__PURE__ */ React.createElement("div", {
314
319
  className: "confirm-title"
315
- }, title), message ? /* @__PURE__ */ React__default.createElement("div", {
320
+ }, title), message ? /* @__PURE__ */ React.createElement("div", {
316
321
  className: "confirm-message"
317
- }, message) : null, subMessage.length ? /* @__PURE__ */ React__default.createElement("div", {
322
+ }, message) : null, subMessage.length ? /* @__PURE__ */ React.createElement("div", {
318
323
  className: "confirm-sub-message"
319
324
  }, subMessage.map((item, index2) => {
320
- return /* @__PURE__ */ React__default.createElement("p", {
325
+ return /* @__PURE__ */ React.createElement("p", {
321
326
  key: index2,
322
327
  className: "pda-listitem-subinfo"
323
- }, /* @__PURE__ */ React__default.createElement("span", null, item.label || ""), ":\xA0", /* @__PURE__ */ React__default.createElement("span", null, item.content || ""));
324
- })) : null, /* @__PURE__ */ React__default.createElement("div", {
328
+ }, /* @__PURE__ */ React.createElement("span", null, item.label || ""), ":\xA0", /* @__PURE__ */ React.createElement("span", null, item.content || ""));
329
+ })) : null, /* @__PURE__ */ React.createElement("div", {
325
330
  className: "confirm-btns"
326
- }, cancelText ? /* @__PURE__ */ React__default.createElement(Button, {
331
+ }, cancelText ? /* @__PURE__ */ React.createElement(Button, {
327
332
  className: "confirm-cancel-button",
328
333
  onClick: () => onClick(false)
329
- }, cancelText) : null, /* @__PURE__ */ React__default.createElement(Button, {
334
+ }, cancelText) : null, /* @__PURE__ */ React.createElement(Button, {
330
335
  type: "primary",
331
336
  onClick: () => onClick(true)
332
337
  }, okText)));
333
338
  }
334
339
  var index$e = "";
340
+ function resolveContainer(getContainer) {
341
+ const container = typeof getContainer === "function" ? getContainer() : getContainer;
342
+ return container || document.body;
343
+ }
344
+ function isUndefined(v) {
345
+ return v === void 0;
346
+ }
347
+ function mergeProps(...items) {
348
+ function customizer(objValue, srcValue) {
349
+ return isUndefined(srcValue) ? objValue : srcValue;
350
+ }
351
+ let ret = Object.assign({}, items[0]);
352
+ for (let i = 1; i < items.length; i++) {
353
+ ret = Object.assign(ret, items[i], customizer);
354
+ }
355
+ return ret;
356
+ }
335
357
  function getTypeClass(type) {
336
358
  return {
337
359
  "success": "toast-wrap success",
@@ -339,31 +361,105 @@ function getTypeClass(type) {
339
361
  "error": "toast-wrap error"
340
362
  }[type] || "toast-wrap";
341
363
  }
342
- function Confirm(props) {
364
+ function Toast(props) {
343
365
  const { title = "title", message = "message", type = "success", duration = null } = props;
344
- const [hidden, setHidden2] = useState(false);
366
+ const [hidden, setHidden] = useState(false);
345
367
  if (duration) {
346
368
  setTimeout(() => {
347
- setHidden2(true);
369
+ setHidden(true);
348
370
  }, duration);
349
371
  }
350
- return !hidden ? /* @__PURE__ */ React__default.createElement("div", {
372
+ return !hidden ? /* @__PURE__ */ React.createElement("div", {
351
373
  className: getTypeClass(type)
352
- }, /* @__PURE__ */ React__default.createElement("div", {
374
+ }, /* @__PURE__ */ React.createElement("div", {
353
375
  className: "toast-title"
354
- }, title), /* @__PURE__ */ React__default.createElement("div", {
376
+ }, title), /* @__PURE__ */ React.createElement("div", {
355
377
  className: "toast-message"
356
378
  }, message)) : null;
357
379
  }
380
+ const defaultProps$1 = {
381
+ maskClickable: true,
382
+ stopPropagation: ["click"]
383
+ };
384
+ const InternalToast = (p) => {
385
+ mergeProps(defaultProps$1, p);
386
+ return /* @__PURE__ */ React.createElement(Overlay, {
387
+ verticalPosition: "bottom",
388
+ closable: true
389
+ }, /* @__PURE__ */ React.createElement(Toast, {
390
+ title: "111111",
391
+ message: "22222",
392
+ type: "success"
393
+ }));
394
+ };
395
+ const containers = [];
396
+ function unmount(container) {
397
+ const unmountResult = ReactDOM.unmountComponentAtNode(container);
398
+ if (unmountResult && container.parentNode) {
399
+ container.parentNode.removeChild(container);
400
+ }
401
+ }
402
+ const defaultProps = {
403
+ duration: 2e3
404
+ };
405
+ function show(p) {
406
+ const props = mergeProps(defaultProps, p);
407
+ let timer = 0;
408
+ const { getContainer = () => document.body } = props;
409
+ const container = document.createElement("div");
410
+ const bodyContainer = resolveContainer(getContainer);
411
+ bodyContainer.appendChild(container);
412
+ console.log("container: ", container);
413
+ clear();
414
+ containers.push(container);
415
+ function TempToast() {
416
+ const [visible, setVisible] = useState(true);
417
+ useEffect(() => {
418
+ return () => {
419
+ var _a;
420
+ (_a = props.afterClose) == null ? void 0 : _a.call(props);
421
+ };
422
+ }, []);
423
+ useEffect(() => {
424
+ if (props.duration === 0) {
425
+ return;
426
+ }
427
+ timer = window.setTimeout(() => {
428
+ setVisible(false);
429
+ }, props.duration);
430
+ return () => {
431
+ window.clearTimeout(timer);
432
+ };
433
+ }, []);
434
+ return /* @__PURE__ */ React.createElement(InternalToast, __spreadProps(__spreadValues({}, props), {
435
+ getContainer: () => container,
436
+ visible,
437
+ afterClose: () => {
438
+ unmount(container);
439
+ }
440
+ }));
441
+ }
442
+ ReactDOM.render(/* @__PURE__ */ React.createElement(TempToast, null), container);
443
+ }
444
+ function clear() {
445
+ while (true) {
446
+ const container = containers.pop();
447
+ if (!container)
448
+ break;
449
+ unmount(container);
450
+ }
451
+ }
452
+ Toast.show = show;
453
+ Toast.clear = clear;
358
454
  function Alert(props) {
359
455
  const { service, data = {} } = props;
360
456
  const { title = "title", message = "message", okText = "okText", cancelText = "" } = data;
361
- const onClickCallback = React__default.useCallback(function() {
457
+ const onClickCallback = React.useCallback(function() {
362
458
  service.onNext(true);
363
459
  }, [service]);
364
- return /* @__PURE__ */ React__default.createElement(Overlay, {
460
+ return /* @__PURE__ */ React.createElement(Overlay, {
365
461
  verticalPosition: "bottom"
366
- }, /* @__PURE__ */ React__default.createElement(Confirm$1, {
462
+ }, /* @__PURE__ */ React.createElement(Confirm, {
367
463
  title,
368
464
  message,
369
465
  okText,
@@ -373,10 +469,10 @@ function Alert(props) {
373
469
  }
374
470
  function Start(props) {
375
471
  const { action, appManager, service } = props;
376
- const onReStart = React__default.useCallback(function() {
472
+ const onReStart = React.useCallback(function() {
377
473
  service.onStart(appManager.config.appId);
378
474
  });
379
- return /* @__PURE__ */ React__default.createElement("div", {
475
+ return /* @__PURE__ */ React.createElement("div", {
380
476
  style: {
381
477
  display: "flex",
382
478
  flexDirection: "column",
@@ -385,20 +481,20 @@ function Start(props) {
385
481
  width: "100vw",
386
482
  height: "100vh"
387
483
  }
388
- }, /* @__PURE__ */ React__default.createElement(Button, {
484
+ }, /* @__PURE__ */ React.createElement(Button, {
389
485
  type: "primary",
390
486
  onClick: onReStart
391
- }, "\u5F00\u59CB\u4F5C\u4E1A"), /* @__PURE__ */ React__default.createElement("br", null), /* @__PURE__ */ React__default.createElement("div", null, appManager.config.appId), /* @__PURE__ */ React__default.createElement("div", null, appManager.config.groupId));
487
+ }, "\u5F00\u59CB\u4F5C\u4E1A"), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("div", null, appManager.config.appId), /* @__PURE__ */ React.createElement("div", null, appManager.config.groupId));
392
488
  }
393
489
  function confirm(props) {
394
490
  const { service, data = {} } = props;
395
491
  const { title = "title", message, subMessage = [], okText = "okText", cancelText = "" } = data;
396
- const onClickCallback = React__default.useCallback(function(isConfirm) {
492
+ const onClickCallback = React.useCallback(function(isConfirm) {
397
493
  service.onNext(isConfirm);
398
494
  }, [service]);
399
- return /* @__PURE__ */ React__default.createElement(Overlay, {
495
+ return /* @__PURE__ */ React.createElement(Overlay, {
400
496
  verticalPosition: "bottom"
401
- }, /* @__PURE__ */ React__default.createElement(Confirm$1, {
497
+ }, /* @__PURE__ */ React.createElement(Confirm, {
402
498
  title,
403
499
  message,
404
500
  subMessage,
@@ -408,17 +504,17 @@ function confirm(props) {
408
504
  }));
409
505
  }
410
506
  function Prompt(props) {
411
- return /* @__PURE__ */ React__default.createElement("div", null, "\u9875\u9762\u4E0D\u5B58\u5728");
507
+ return /* @__PURE__ */ React.createElement("div", null, "\u9875\u9762\u4E0D\u5B58\u5728");
412
508
  }
413
509
  function toast(props) {
414
510
  const { data = {}, service } = props;
415
511
  const { title, level, message, duration = null } = data;
416
- const [hidden, setHidden2] = useState(false);
417
- React__default.useEffect(() => {
512
+ const [hidden, setHidden] = useState(false);
513
+ React.useEffect(() => {
418
514
  let timeout = null;
419
515
  if (duration) {
420
516
  setTimeout(() => {
421
- setHidden2(true);
517
+ setHidden(true);
422
518
  service.onNext("");
423
519
  }, duration);
424
520
  }
@@ -426,13 +522,15 @@ function toast(props) {
426
522
  clearTimeout(timeout);
427
523
  };
428
524
  }, []);
429
- return !hidden ? /* @__PURE__ */ React__default.createElement(Overlay, {
525
+ return !hidden ? /* @__PURE__ */ React.createElement(Overlay, {
430
526
  verticalPosition: "bottom"
431
- }, /* @__PURE__ */ React__default.createElement(Confirm, {
527
+ }, /* @__PURE__ */ React.createElement("div", {
528
+ style: { width: "90%" }
529
+ }, /* @__PURE__ */ React.createElement(Toast, {
432
530
  type: level,
433
531
  title,
434
532
  message: splitMessage(message)
435
- })) : null;
533
+ }))) : null;
436
534
  }
437
535
  function splitMessage(message) {
438
536
  var msg = String(message).split("by Error:");
@@ -440,14 +538,14 @@ function splitMessage(message) {
440
538
  }
441
539
  var index$d = "";
442
540
  function NotFound(props) {
443
- return /* @__PURE__ */ React__default.createElement("div", {
541
+ return /* @__PURE__ */ React.createElement("div", {
444
542
  style: { padding: "20%" }
445
- }, /* @__PURE__ */ React__default.createElement("h1", null, "404 ", /* @__PURE__ */ React__default.createElement("small", {
543
+ }, /* @__PURE__ */ React.createElement("h1", null, "404 ", /* @__PURE__ */ React.createElement("small", {
446
544
  style: { fontSize: "60%" }
447
- }, "Not found")), /* @__PURE__ */ React__default.createElement("div", null, props.action.getPage()));
545
+ }, "Not found")), /* @__PURE__ */ React.createElement("div", null, props.action.getPage()));
448
546
  }
449
- function _extends$3() {
450
- _extends$3 = Object.assign || function(target) {
547
+ function _extends() {
548
+ _extends = Object.assign || function(target) {
451
549
  for (var i = 1; i < arguments.length; i++) {
452
550
  var source = arguments[i];
453
551
  for (var key in source) {
@@ -458,7 +556,7 @@ function _extends$3() {
458
556
  }
459
557
  return target;
460
558
  };
461
- return _extends$3.apply(this, arguments);
559
+ return _extends.apply(this, arguments);
462
560
  }
463
561
  var r, B = r || (r = {});
464
562
  B.Pop = "POP";
@@ -539,7 +637,7 @@ function createHashHistory(b) {
539
637
  }
540
638
  function z(a, e) {
541
639
  e === void 0 && (e = null);
542
- return C(_extends$3({ pathname: d.pathname, hash: "", search: "" }, typeof a === "string" ? J(a) : a, { state: e, key: H() }));
640
+ return C(_extends({}, d, typeof a === "string" ? J(a) : a, { state: e, key: H() }));
543
641
  }
544
642
  function A(a) {
545
643
  v = a;
@@ -570,7 +668,11 @@ function createHashHistory(b) {
570
668
  w(a, e);
571
669
  }
572
670
  var g = r.Replace, n = z(a, e);
573
- c.length && (c.call({ action: g, location: n, retry: l }), 1) || (n = [{ usr: n.state, key: n.key, idx: q }, x(n)], u.replaceState(n[0], "", n[1]), A(g));
671
+ c.length && (c.call({
672
+ action: g,
673
+ location: n,
674
+ retry: l
675
+ }), 1) || (n = [{ usr: n.state, key: n.key, idx: q }, x(n)], u.replaceState(n[0], "", n[1]), A(g));
574
676
  }
575
677
  function p(a) {
576
678
  u.go(a);
@@ -586,7 +688,7 @@ function createHashHistory(b) {
586
688
  var v = r.Pop;
587
689
  b = h();
588
690
  var q = b[0], d = b[1], f = F(), c = F();
589
- q == null && (q = 0, u.replaceState(_extends$3({}, u.state, { idx: q }), ""));
691
+ q == null && (q = 0, u.replaceState(_extends({}, u.state, { idx: q }), ""));
590
692
  return {
591
693
  get action() {
592
694
  return v;
@@ -621,7 +723,7 @@ var index$c = "";
621
723
  function Debug(props) {
622
724
  const { appManager } = props;
623
725
  const pages = Array.from(appManager.pageManager.keys()).reverse();
624
- React__default.useEffect(function() {
726
+ React.useEffect(function() {
625
727
  const history = createHashHistory();
626
728
  const unListen = history.listen(({ action, location }) => {
627
729
  const pathname = location.pathname;
@@ -629,18 +731,18 @@ function Debug(props) {
629
731
  });
630
732
  return unListen;
631
733
  }, []);
632
- return /* @__PURE__ */ React__default.createElement("div", {
734
+ return /* @__PURE__ */ React.createElement("div", {
633
735
  className: "local-debug-side"
634
- }, /* @__PURE__ */ React__default.createElement("ul", null, pages.map((pathname) => /* @__PURE__ */ React__default.createElement("li", {
736
+ }, /* @__PURE__ */ React.createElement("ul", null, pages.map((pathname) => /* @__PURE__ */ React.createElement("li", {
635
737
  key: pathname
636
- }, /* @__PURE__ */ React__default.createElement("a", {
738
+ }, /* @__PURE__ */ React.createElement("a", {
637
739
  href: `#${pathname}`
638
740
  }, pathname)))));
639
741
  }
640
742
  function Loading$1(props) {
641
- const [showLoading, setShowLoading] = React__default.useState(false);
743
+ const [showLoading, setShowLoading] = React.useState(false);
642
744
  const edgeService = props.edgeService;
643
- React__default.useEffect(function() {
745
+ React.useEffect(function() {
644
746
  let currentLoading = false;
645
747
  const throttleSetShowLoading = function(loading) {
646
748
  currentLoading = loading;
@@ -663,7 +765,7 @@ function Loading$1(props) {
663
765
  edgeService.off("IO_STATUS", throttleSetShowLoading);
664
766
  };
665
767
  }, [edgeService]);
666
- return showLoading ? /* @__PURE__ */ React__default.createElement("div", {
768
+ return showLoading ? /* @__PURE__ */ React.createElement("div", {
667
769
  style: { position: "absolute", left: 0, top: 0, zIndex: 100 }
668
770
  }, "LOADING...") : null;
669
771
  }
@@ -683,17 +785,15 @@ function Presentation(props) {
683
785
  image = Presentation.IMAGE_1,
684
786
  text = "",
685
787
  subText = "",
686
- transparent,
687
- imageStyle
788
+ transparent
688
789
  } = props;
689
- return /* @__PURE__ */ React__default.createElement("div", {
790
+ return /* @__PURE__ */ React.createElement("div", {
690
791
  className: transparent ? "presentation-card transparent" : "presentation-card"
691
- }, /* @__PURE__ */ React__default.createElement("img", {
692
- src: image,
693
- style: imageStyle
694
- }), text ? /* @__PURE__ */ React__default.createElement("div", {
792
+ }, /* @__PURE__ */ React.createElement("img", {
793
+ src: image
794
+ }), text ? /* @__PURE__ */ React.createElement("div", {
695
795
  className: "text"
696
- }, text) : null, subText ? /* @__PURE__ */ React__default.createElement("div", {
796
+ }, text) : null, subText ? /* @__PURE__ */ React.createElement("div", {
697
797
  className: "sub-text"
698
798
  }, subText) : null);
699
799
  }
@@ -706,10 +806,10 @@ function empty() {
706
806
  }
707
807
  function List(props) {
708
808
  const { dataSource = [], onClickItem, onItemClick = empty } = props;
709
- return /* @__PURE__ */ React__default.createElement("div", {
809
+ return /* @__PURE__ */ React.createElement("div", {
710
810
  className: "android-pda-list"
711
811
  }, dataSource.map((item, index2) => {
712
- return /* @__PURE__ */ React__default.createElement(DefaultItem, {
812
+ return /* @__PURE__ */ React.createElement(DefaultItem, {
713
813
  key: item.key || index2,
714
814
  dataSource: item,
715
815
  onClick: onClickItem || onItemClick
@@ -725,24 +825,24 @@ function DefaultItem(props) {
725
825
  };
726
826
  const { title, subTitle, extra, tags = [], tabIndex } = dataSource;
727
827
  const { onClick } = props;
728
- return /* @__PURE__ */ React__default.createElement("div", {
828
+ return /* @__PURE__ */ React.createElement("div", {
729
829
  className: "default-item",
730
830
  onClick: () => {
731
831
  onClick(props.dataSource);
732
832
  },
733
833
  tabIndex
734
- }, /* @__PURE__ */ React__default.createElement("div", {
834
+ }, /* @__PURE__ */ React.createElement("div", {
735
835
  className: "text"
736
- }, /* @__PURE__ */ React__default.createElement("div", null, title), /* @__PURE__ */ React__default.createElement("div", {
836
+ }, /* @__PURE__ */ React.createElement("div", null, title), /* @__PURE__ */ React.createElement("div", {
737
837
  className: "sub-text"
738
- }, subTitle), /* @__PURE__ */ React__default.createElement("div", {
838
+ }, subTitle), /* @__PURE__ */ React.createElement("div", {
739
839
  className: "sub-tags"
740
840
  }, tags.map((text) => {
741
- return /* @__PURE__ */ React__default.createElement("div", {
841
+ return /* @__PURE__ */ React.createElement("div", {
742
842
  className: "sub-tag-item",
743
843
  key: text
744
844
  }, text);
745
- }))), /* @__PURE__ */ React__default.createElement("div", {
845
+ }))), /* @__PURE__ */ React.createElement("div", {
746
846
  className: "extra"
747
847
  }, extra));
748
848
  }
@@ -750,7 +850,7 @@ List.Item = DefaultItem;
750
850
  var index$8 = "";
751
851
  const blankFunc$4 = () => {
752
852
  };
753
- class BaseLayoutContainer extends React__default.Component {
853
+ class BaseLayoutContainer extends React.Component {
754
854
  constructor(props) {
755
855
  super(props);
756
856
  this.state = {};
@@ -800,21 +900,21 @@ class BaseLayoutContainer extends React__default.Component {
800
900
  render() {
801
901
  const props = this.props;
802
902
  const { style = {}, header, footer } = this.props;
803
- return /* @__PURE__ */ React__default.createElement("div", {
903
+ return /* @__PURE__ */ React.createElement("div", {
804
904
  className: classNames({ "baselayout-wrapper": true }),
805
905
  style
806
- }, header && /* @__PURE__ */ React__default.createElement("div", {
906
+ }, header && /* @__PURE__ */ React.createElement("div", {
807
907
  className: classNames({ "baselayout-header": true })
808
- }, header), /* @__PURE__ */ React__default.createElement("div", {
908
+ }, header), /* @__PURE__ */ React.createElement("div", {
809
909
  className: classNames({ "baselayout-container": true })
810
- }, props.children), footer && /* @__PURE__ */ React__default.createElement("div", {
910
+ }, props.children), footer && /* @__PURE__ */ React.createElement("div", {
811
911
  className: classNames({ "baselayout-footer": true })
812
912
  }, footer));
813
913
  }
814
914
  }
815
915
  const blankFunc$3 = () => {
816
916
  };
817
- class RfidOnce$1 extends React__default.Component {
917
+ class RfidOnce$1 extends React.Component {
818
918
  constructor(props) {
819
919
  super(props);
820
920
  this._rfidBeginScan = false;
@@ -881,12 +981,12 @@ class RfidOnce$1 extends React__default.Component {
881
981
  render() {
882
982
  const props = this.props;
883
983
  const _a = props, { onRfidOnce = blankFunc$3 } = _a, opts = __objRest(_a, ["onRfidOnce"]);
884
- return /* @__PURE__ */ React__default.createElement(BaseLayoutContainer, __spreadValues({}, opts));
984
+ return /* @__PURE__ */ React.createElement(BaseLayoutContainer, __spreadValues({}, opts));
885
985
  }
886
986
  }
887
987
  const blankFunc$2 = () => {
888
988
  };
889
- class RfidOnce extends React__default.Component {
989
+ class RfidOnce extends React.Component {
890
990
  constructor(props) {
891
991
  super(props);
892
992
  this._rfidBeginScan = false;
@@ -962,7 +1062,7 @@ class RfidOnce extends React__default.Component {
962
1062
  render() {
963
1063
  const props = this.props;
964
1064
  const _a = props, { onRfidScan = blankFunc$2, autoRfidScan } = _a, opts = __objRest(_a, ["onRfidScan", "autoRfidScan"]);
965
- return /* @__PURE__ */ React__default.createElement(BaseLayoutContainer, __spreadValues({}, opts));
1065
+ return /* @__PURE__ */ React.createElement(BaseLayoutContainer, __spreadValues({}, opts));
966
1066
  }
967
1067
  }
968
1068
  __publicField(RfidOnce, "defaultProps", {
@@ -970,7 +1070,7 @@ __publicField(RfidOnce, "defaultProps", {
970
1070
  });
971
1071
  const blankFunc$1 = () => {
972
1072
  };
973
- class BarcodeScan extends React__default.Component {
1073
+ class BarcodeScan extends React.Component {
974
1074
  constructor(props) {
975
1075
  super(props);
976
1076
  this._barcodeBeginScan = false;
@@ -1016,10 +1116,10 @@ class BarcodeScan extends React__default.Component {
1016
1116
  render() {
1017
1117
  const props = this.props;
1018
1118
  const _a = props, { onBarcodeScan = blankFunc$1 } = _a, opts = __objRest(_a, ["onBarcodeScan"]);
1019
- return /* @__PURE__ */ React__default.createElement(BaseLayoutContainer, __spreadValues({}, opts));
1119
+ return /* @__PURE__ */ React.createElement(BaseLayoutContainer, __spreadValues({}, opts));
1020
1120
  }
1021
1121
  }
1022
- class BaseLayout extends React__default.Component {
1122
+ class BaseLayout extends React.Component {
1023
1123
  constructor(props) {
1024
1124
  super(props);
1025
1125
  }
@@ -1027,15 +1127,15 @@ class BaseLayout extends React__default.Component {
1027
1127
  const props = this.props;
1028
1128
  const { onBarcodeScan, onRfidOnce, onRfidBoxOnce, onRfidPalletOnce, onRfidScan, onRfidBoxScan, onRfidPalletScan } = props;
1029
1129
  if (onRfidOnce || onRfidBoxOnce || onRfidPalletOnce) {
1030
- return /* @__PURE__ */ React__default.createElement(RfidOnce$1, __spreadValues({}, props));
1130
+ return /* @__PURE__ */ React.createElement(RfidOnce$1, __spreadValues({}, props));
1031
1131
  }
1032
1132
  if (onRfidScan || onRfidBoxScan || onRfidPalletScan) {
1033
- return /* @__PURE__ */ React__default.createElement(RfidOnce, __spreadValues({}, props));
1133
+ return /* @__PURE__ */ React.createElement(RfidOnce, __spreadValues({}, props));
1034
1134
  }
1035
1135
  if (onBarcodeScan) {
1036
- return /* @__PURE__ */ React__default.createElement(BarcodeScan, __spreadValues({}, props));
1136
+ return /* @__PURE__ */ React.createElement(BarcodeScan, __spreadValues({}, props));
1037
1137
  }
1038
- return /* @__PURE__ */ React__default.createElement(BaseLayoutContainer, __spreadValues({}, props));
1138
+ return /* @__PURE__ */ React.createElement(BaseLayoutContainer, __spreadValues({}, props));
1039
1139
  }
1040
1140
  }
1041
1141
  var index$7 = "";
@@ -1060,22 +1160,22 @@ function WakeKeyborard(props) {
1060
1160
  document.removeEventListener("keyup", handleKeyUp);
1061
1161
  };
1062
1162
  }, []);
1063
- return /* @__PURE__ */ React__default.createElement("div", {
1163
+ return /* @__PURE__ */ React.createElement("div", {
1064
1164
  className: "wakekeyborard"
1065
- }, inputVisible ? /* @__PURE__ */ React__default.createElement("div", {
1165
+ }, inputVisible ? /* @__PURE__ */ React.createElement("div", {
1066
1166
  className: "wakekeyborard-overlay"
1067
- }, /* @__PURE__ */ React__default.createElement("div", {
1167
+ }, /* @__PURE__ */ React.createElement("div", {
1068
1168
  className: "wakekeyborard-inputbox"
1069
- }, /* @__PURE__ */ React__default.createElement("input", {
1169
+ }, /* @__PURE__ */ React.createElement("input", {
1070
1170
  ref: inputRef,
1071
1171
  type: "tel"
1072
- }), /* @__PURE__ */ React__default.createElement(Button, {
1172
+ }), /* @__PURE__ */ React.createElement(Button, {
1073
1173
  type: "primary",
1074
1174
  onClick: (e) => {
1075
1175
  onClick(inputRef.current.value);
1076
1176
  setInputVisible(!inputVisible);
1077
1177
  }
1078
- }, "\u67E5\u8BE2"))) : null, !inputVisible ? /* @__PURE__ */ React__default.createElement("div", {
1178
+ }, "\u67E5\u8BE2"))) : null, !inputVisible ? /* @__PURE__ */ React.createElement("div", {
1079
1179
  className: "wakekeyborard-icon",
1080
1180
  onClick: (e) => {
1081
1181
  setInputVisible(!inputVisible);
@@ -1088,42 +1188,42 @@ function WakeKeyborard(props) {
1088
1188
  }
1089
1189
  var index$6 = "";
1090
1190
  var index$5 = "";
1091
- class PdaInfoCard$1 extends React__default.Component {
1191
+ class PdaInfoCard$1 extends React.Component {
1092
1192
  constructor(props) {
1093
1193
  super(props);
1094
1194
  }
1095
1195
  render() {
1096
1196
  const { className, title, isActive, infoList = [], style = {}, index: index2, isLast } = this.props;
1097
- return /* @__PURE__ */ React__default.createElement("div", {
1197
+ return /* @__PURE__ */ React.createElement("div", {
1098
1198
  className: classNames({ [className]: true, "pda-step-card": true }),
1099
1199
  style
1100
- }, /* @__PURE__ */ React__default.createElement("div", {
1200
+ }, /* @__PURE__ */ React.createElement("div", {
1101
1201
  className: "pda-step-indictor"
1102
- }, /* @__PURE__ */ React__default.createElement("div", {
1202
+ }, /* @__PURE__ */ React.createElement("div", {
1103
1203
  className: classNames({ "pda-step-indictor-top": true, "pda-step-indictor-top-hidden": index2 === 0 })
1104
- }), /* @__PURE__ */ React__default.createElement("div", {
1204
+ }), /* @__PURE__ */ React.createElement("div", {
1105
1205
  className: classNames({ "pda-step-indictor-center": true, "pda-step-indictor-center-active": isActive })
1106
- }), /* @__PURE__ */ React__default.createElement("div", {
1206
+ }), /* @__PURE__ */ React.createElement("div", {
1107
1207
  className: classNames({ "pda-step-indictor-bottom": true, "pda-step-indictor-bottom-hidden": isLast })
1108
- })), /* @__PURE__ */ React__default.createElement("div", {
1208
+ })), /* @__PURE__ */ React.createElement("div", {
1109
1209
  className: classNames({ "pda-step": true, "pda-step-dark": !isActive })
1110
- }, /* @__PURE__ */ React__default.createElement("p", {
1210
+ }, /* @__PURE__ */ React.createElement("p", {
1111
1211
  className: "pda-step-title"
1112
1212
  }, title), infoList.map((item, index22) => {
1113
- return /* @__PURE__ */ React__default.createElement("p", {
1213
+ return /* @__PURE__ */ React.createElement("p", {
1114
1214
  key: index22,
1115
1215
  className: "pda-step-list"
1116
- }, /* @__PURE__ */ React__default.createElement("span", null, item.label || ""), "\xA0\xA0", /* @__PURE__ */ React__default.createElement("span", null, item.content || ""));
1216
+ }, /* @__PURE__ */ React.createElement("span", null, item.label || ""), "\xA0\xA0", /* @__PURE__ */ React.createElement("span", null, item.content || ""));
1117
1217
  })));
1118
1218
  }
1119
1219
  }
1120
- class PdaInfoCard extends React__default.Component {
1220
+ class PdaInfoCard extends React.Component {
1121
1221
  constructor(props) {
1122
1222
  super(props);
1123
1223
  }
1124
1224
  render() {
1125
1225
  const { className, style = {}, theme = "light", current = 0, children } = this.props;
1126
- return /* @__PURE__ */ React__default.createElement("div", {
1226
+ return /* @__PURE__ */ React.createElement("div", {
1127
1227
  className: classNames({ [className]: true }),
1128
1228
  style
1129
1229
  }, (children || []).map((child, index2) => {
@@ -1142,43 +1242,43 @@ class PdaInfoCard extends React__default.Component {
1142
1242
  }
1143
1243
  __publicField(PdaInfoCard, "Step", PdaInfoCard$1);
1144
1244
  var index$4 = "";
1145
- class PdaFinishCard extends React__default.Component {
1245
+ class PdaFinishCard extends React.Component {
1146
1246
  constructor(props) {
1147
1247
  super(props);
1148
1248
  }
1149
1249
  render() {
1150
1250
  const { className, title, infoList = [], isError = false, buttonMultiLines = false, style = {}, onClick = () => {
1151
1251
  }, okText = "\u8FD4\u56DE\u9996\u9875", cancelText = null } = this.props;
1152
- const footer = /* @__PURE__ */ React__default.createElement(Button.Group, null, cancelText ? /* @__PURE__ */ React__default.createElement(Button, {
1252
+ const footer = /* @__PURE__ */ React.createElement(Button.Group, null, cancelText ? /* @__PURE__ */ React.createElement(Button, {
1153
1253
  style: buttonMultiLines ? { height: "auto", lineHeight: "50px" } : {},
1154
1254
  type: "dark",
1155
1255
  onClick: () => onClick(false)
1156
- }, cancelText) : null, /* @__PURE__ */ React__default.createElement(Button, {
1256
+ }, cancelText) : null, /* @__PURE__ */ React.createElement(Button, {
1157
1257
  type: "primary",
1158
1258
  style: buttonMultiLines ? { height: "auto", lineHeight: "normal" } : {},
1159
1259
  onClick: () => onClick(true)
1160
1260
  }, okText));
1161
- return /* @__PURE__ */ React__default.createElement(BaseLayout, {
1261
+ return /* @__PURE__ */ React.createElement(BaseLayout, {
1162
1262
  footer
1163
- }, /* @__PURE__ */ React__default.createElement("div", {
1263
+ }, /* @__PURE__ */ React.createElement("div", {
1164
1264
  className: "pda-finish-card-top"
1165
- }, /* @__PURE__ */ React__default.createElement("img", {
1265
+ }, /* @__PURE__ */ React.createElement("img", {
1166
1266
  className: "pda-finish-card-img",
1167
1267
  src: isError ? PdaFinishCard.ERROR_SUCCESS : PdaFinishCard.SUCCESS
1168
- }), /* @__PURE__ */ React__default.createElement("p", {
1268
+ }), /* @__PURE__ */ React.createElement("p", {
1169
1269
  className: "pda-finish-card-title"
1170
1270
  }, title), infoList.map((item, index2) => {
1171
- return /* @__PURE__ */ React__default.createElement("p", {
1271
+ return /* @__PURE__ */ React.createElement("p", {
1172
1272
  key: index2,
1173
1273
  className: "pda-finish-card-list"
1174
- }, /* @__PURE__ */ React__default.createElement("span", null, item.label || ""), /* @__PURE__ */ React__default.createElement("span", null, item.content || ""));
1274
+ }, /* @__PURE__ */ React.createElement("span", null, item.label || ""), /* @__PURE__ */ React.createElement("span", null, item.content || ""));
1175
1275
  })));
1176
1276
  }
1177
1277
  }
1178
1278
  PdaFinishCard.SUCCESS = "https://img.alicdn.com/imgextra/i2/O1CN01yYwwSx1uNV0M1gHlQ_!!6000000006025-1-tps-630-436.gif";
1179
1279
  PdaFinishCard.ERROR_SUCCESS = "https://img.alicdn.com/imgextra/i3/O1CN01p5Oc5t1VMFWtBomQc_!!6000000002638-1-tps-600-456.gif";
1180
1280
  var index$3 = "";
1181
- class PdaDistanceCard extends React__default.Component {
1281
+ class PdaDistanceCard extends React.Component {
1182
1282
  constructor(props) {
1183
1283
  super(props);
1184
1284
  }
@@ -1186,380 +1286,59 @@ class PdaDistanceCard extends React__default.Component {
1186
1286
  const { className, title, infoText, percentage = 0, style = {} } = this.props;
1187
1287
  const distanceImg = "https://img.alicdn.com/imgextra/i3/O1CN01EFksWL1DBZCu0H1JH_!!6000000000178-2-tps-21-30.png";
1188
1288
  const indictorImg = "https://img.alicdn.com/imgextra/i1/O1CN01YEhCSg1aObe8UZq7K_!!6000000003320-2-tps-379-17.png";
1189
- return /* @__PURE__ */ React__default.createElement("div", {
1289
+ return /* @__PURE__ */ React.createElement("div", {
1190
1290
  className: classNames({ [className]: true, "pda-distance-card": true }),
1191
1291
  style
1192
- }, /* @__PURE__ */ React__default.createElement("p", {
1292
+ }, /* @__PURE__ */ React.createElement("p", {
1193
1293
  className: "pda-distance-card-highlight"
1194
- }, /* @__PURE__ */ React__default.createElement("span", {
1294
+ }, /* @__PURE__ */ React.createElement("span", {
1195
1295
  className: "pda-distance-card-highlight1"
1196
- }, title)), /* @__PURE__ */ React__default.createElement("div", {
1296
+ }, title)), /* @__PURE__ */ React.createElement("div", {
1197
1297
  className: "pda-distance-indictor"
1198
- }, /* @__PURE__ */ React__default.createElement("img", {
1298
+ }, /* @__PURE__ */ React.createElement("img", {
1199
1299
  src: distanceImg,
1200
1300
  width: 20,
1201
1301
  height: 29
1202
- }), /* @__PURE__ */ React__default.createElement("p", null, infoText)), /* @__PURE__ */ React__default.createElement("div", {
1302
+ }), /* @__PURE__ */ React.createElement("p", null, infoText)), /* @__PURE__ */ React.createElement("div", {
1203
1303
  className: "pda-distance-card-progress"
1204
- }, /* @__PURE__ */ React__default.createElement("div", {
1304
+ }, /* @__PURE__ */ React.createElement("div", {
1205
1305
  className: "pda-distance-card-progress-inside",
1206
1306
  style: { width: `${percentage * 100}%` }
1207
- }), /* @__PURE__ */ React__default.createElement("img", {
1307
+ }), /* @__PURE__ */ React.createElement("img", {
1208
1308
  className: "pda-distance-card-progress-indictor",
1209
1309
  src: indictorImg
1210
- })), /* @__PURE__ */ React__default.createElement("div", {
1310
+ })), /* @__PURE__ */ React.createElement("div", {
1211
1311
  className: "pda-distance-label"
1212
- }, /* @__PURE__ */ React__default.createElement("p", null, "\u8FDC"), /* @__PURE__ */ React__default.createElement("p", null, "\u8FD1")));
1312
+ }, /* @__PURE__ */ React.createElement("p", null, "\u8FDC"), /* @__PURE__ */ React.createElement("p", null, "\u8FD1")));
1213
1313
  }
1214
1314
  }
1215
1315
  var index$2 = "";
1216
1316
  function SubCard(props) {
1217
1317
  const { title, context, name, tag, attrs = [], style } = props;
1218
- return /* @__PURE__ */ React__default.createElement("div", {
1318
+ return /* @__PURE__ */ React.createElement("div", {
1219
1319
  className: "android-sub-card",
1220
1320
  style
1221
- }, /* @__PURE__ */ React__default.createElement("div", {
1321
+ }, /* @__PURE__ */ React.createElement("div", {
1222
1322
  className: "android-sub-card-title-section"
1223
- }, /* @__PURE__ */ React__default.createElement("div", {
1323
+ }, /* @__PURE__ */ React.createElement("div", {
1224
1324
  className: "android-sub-card-title"
1225
- }, title), tag ? /* @__PURE__ */ React__default.createElement("div", {
1325
+ }, title), tag ? /* @__PURE__ */ React.createElement("div", {
1226
1326
  className: "android-sub-card-tag"
1227
- }, /* @__PURE__ */ React__default.createElement("div", {
1327
+ }, /* @__PURE__ */ React.createElement("div", {
1228
1328
  className: tag.type
1229
- }, tag.label || "")) : null), /* @__PURE__ */ React__default.createElement("div", {
1329
+ }, tag.label || "")) : null), /* @__PURE__ */ React.createElement("div", {
1230
1330
  className: "android-sub-card-context"
1231
- }, context), name ? /* @__PURE__ */ React__default.createElement("div", {
1331
+ }, context), name ? /* @__PURE__ */ React.createElement("div", {
1232
1332
  className: "android-sub-card-name"
1233
- }, name) : null, /* @__PURE__ */ React__default.createElement("div", {
1333
+ }, name) : null, /* @__PURE__ */ React.createElement("div", {
1234
1334
  className: "android-sub-card-attrs"
1235
1335
  }, attrs.map((text) => {
1236
- return /* @__PURE__ */ React__default.createElement("div", {
1336
+ return /* @__PURE__ */ React.createElement("div", {
1237
1337
  key: text
1238
1338
  }, text);
1239
1339
  })));
1240
1340
  }
1241
1341
  var index$1 = "";
1242
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1243
- var freeSelf$1 = typeof self == "object" && self && self.Object === Object && self;
1244
- freeGlobal$1 || freeSelf$1 || Function("return this")();
1245
- var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1246
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
1247
- freeGlobal || freeSelf || Function("return this")();
1248
- function isDocumentVisible() {
1249
- if (typeof document !== "undefined" && typeof document.visibilityState !== "undefined") {
1250
- return document.visibilityState !== "hidden";
1251
- }
1252
- return true;
1253
- }
1254
- function isOnline() {
1255
- if (typeof navigator.onLine !== "undefined") {
1256
- return navigator.onLine;
1257
- }
1258
- return true;
1259
- }
1260
- var __read$7 = globalThis && globalThis.__read || function(o, n) {
1261
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1262
- if (!m)
1263
- return o;
1264
- var i = m.call(o), r2, ar = [], e;
1265
- try {
1266
- while ((n === void 0 || n-- > 0) && !(r2 = i.next()).done) {
1267
- ar.push(r2.value);
1268
- }
1269
- } catch (error) {
1270
- e = {
1271
- error
1272
- };
1273
- } finally {
1274
- try {
1275
- if (r2 && !r2.done && (m = i["return"]))
1276
- m.call(i);
1277
- } finally {
1278
- if (e)
1279
- throw e.error;
1280
- }
1281
- }
1282
- return ar;
1283
- };
1284
- globalThis && globalThis.__spread || function() {
1285
- for (var ar = [], i = 0; i < arguments.length; i++) {
1286
- ar = ar.concat(__read$7(arguments[i]));
1287
- }
1288
- return ar;
1289
- };
1290
- var __read$6 = globalThis && globalThis.__read || function(o, n) {
1291
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1292
- if (!m)
1293
- return o;
1294
- var i = m.call(o), r2, ar = [], e;
1295
- try {
1296
- while ((n === void 0 || n-- > 0) && !(r2 = i.next()).done) {
1297
- ar.push(r2.value);
1298
- }
1299
- } catch (error) {
1300
- e = {
1301
- error
1302
- };
1303
- } finally {
1304
- try {
1305
- if (r2 && !r2.done && (m = i["return"]))
1306
- m.call(i);
1307
- } finally {
1308
- if (e)
1309
- throw e.error;
1310
- }
1311
- }
1312
- return ar;
1313
- };
1314
- globalThis && globalThis.__spread || function() {
1315
- for (var ar = [], i = 0; i < arguments.length; i++) {
1316
- ar = ar.concat(__read$6(arguments[i]));
1317
- }
1318
- return ar;
1319
- };
1320
- var listeners$1 = [];
1321
- var eventsBinded$1 = false;
1322
- if (typeof window !== "undefined" && window.addEventListener && !eventsBinded$1) {
1323
- var revalidate$1 = function revalidate() {
1324
- if (!isDocumentVisible() || !isOnline())
1325
- return;
1326
- for (var i = 0; i < listeners$1.length; i++) {
1327
- var listener = listeners$1[i];
1328
- listener();
1329
- }
1330
- };
1331
- window.addEventListener("visibilitychange", revalidate$1, false);
1332
- window.addEventListener("focus", revalidate$1, false);
1333
- eventsBinded$1 = true;
1334
- }
1335
- var listeners = [];
1336
- var eventsBinded = false;
1337
- if (typeof window !== "undefined" && window.addEventListener && !eventsBinded) {
1338
- var revalidate = function revalidate2() {
1339
- if (!isDocumentVisible())
1340
- return;
1341
- for (var i = 0; i < listeners.length; i++) {
1342
- var listener = listeners[i];
1343
- listener();
1344
- }
1345
- };
1346
- window.addEventListener("visibilitychange", revalidate, false);
1347
- eventsBinded = true;
1348
- }
1349
- var __assign$3 = globalThis && globalThis.__assign || function() {
1350
- __assign$3 = Object.assign || function(t) {
1351
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1352
- s = arguments[i];
1353
- for (var p in s) {
1354
- if (Object.prototype.hasOwnProperty.call(s, p))
1355
- t[p] = s[p];
1356
- }
1357
- }
1358
- return t;
1359
- };
1360
- return __assign$3.apply(this, arguments);
1361
- };
1362
- var __read$5 = globalThis && globalThis.__read || function(o, n) {
1363
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1364
- if (!m)
1365
- return o;
1366
- var i = m.call(o), r2, ar = [], e;
1367
- try {
1368
- while ((n === void 0 || n-- > 0) && !(r2 = i.next()).done) {
1369
- ar.push(r2.value);
1370
- }
1371
- } catch (error) {
1372
- e = {
1373
- error
1374
- };
1375
- } finally {
1376
- try {
1377
- if (r2 && !r2.done && (m = i["return"]))
1378
- m.call(i);
1379
- } finally {
1380
- if (e)
1381
- throw e.error;
1382
- }
1383
- }
1384
- return ar;
1385
- };
1386
- globalThis && globalThis.__spread || function() {
1387
- for (var ar = [], i = 0; i < arguments.length; i++) {
1388
- ar = ar.concat(__read$5(arguments[i]));
1389
- }
1390
- return ar;
1391
- };
1392
- var __assign$2 = globalThis && globalThis.__assign || function() {
1393
- __assign$2 = Object.assign || function(t) {
1394
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1395
- s = arguments[i];
1396
- for (var p in s) {
1397
- if (Object.prototype.hasOwnProperty.call(s, p))
1398
- t[p] = s[p];
1399
- }
1400
- }
1401
- return t;
1402
- };
1403
- return __assign$2.apply(this, arguments);
1404
- };
1405
- globalThis && globalThis.__rest || function(s, e) {
1406
- var t = {};
1407
- for (var p in s) {
1408
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1409
- t[p] = s[p];
1410
- }
1411
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1412
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1413
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1414
- t[p[i]] = s[p[i]];
1415
- }
1416
- return t;
1417
- };
1418
- var __read$4 = globalThis && globalThis.__read || function(o, n) {
1419
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1420
- if (!m)
1421
- return o;
1422
- var i = m.call(o), r2, ar = [], e;
1423
- try {
1424
- while ((n === void 0 || n-- > 0) && !(r2 = i.next()).done) {
1425
- ar.push(r2.value);
1426
- }
1427
- } catch (error) {
1428
- e = {
1429
- error
1430
- };
1431
- } finally {
1432
- try {
1433
- if (r2 && !r2.done && (m = i["return"]))
1434
- m.call(i);
1435
- } finally {
1436
- if (e)
1437
- throw e.error;
1438
- }
1439
- }
1440
- return ar;
1441
- };
1442
- globalThis && globalThis.__spread || function() {
1443
- for (var ar = [], i = 0; i < arguments.length; i++) {
1444
- ar = ar.concat(__read$4(arguments[i]));
1445
- }
1446
- return ar;
1447
- };
1448
- var __assign$1 = globalThis && globalThis.__assign || function() {
1449
- __assign$1 = Object.assign || function(t) {
1450
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1451
- s = arguments[i];
1452
- for (var p in s) {
1453
- if (Object.prototype.hasOwnProperty.call(s, p))
1454
- t[p] = s[p];
1455
- }
1456
- }
1457
- return t;
1458
- };
1459
- return __assign$1.apply(this, arguments);
1460
- };
1461
- globalThis && globalThis.__rest || function(s, e) {
1462
- var t = {};
1463
- for (var p in s) {
1464
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1465
- t[p] = s[p];
1466
- }
1467
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1468
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1469
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1470
- t[p[i]] = s[p[i]];
1471
- }
1472
- return t;
1473
- };
1474
- var __read$3 = globalThis && globalThis.__read || function(o, n) {
1475
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1476
- if (!m)
1477
- return o;
1478
- var i = m.call(o), r2, ar = [], e;
1479
- try {
1480
- while ((n === void 0 || n-- > 0) && !(r2 = i.next()).done) {
1481
- ar.push(r2.value);
1482
- }
1483
- } catch (error) {
1484
- e = {
1485
- error
1486
- };
1487
- } finally {
1488
- try {
1489
- if (r2 && !r2.done && (m = i["return"]))
1490
- m.call(i);
1491
- } finally {
1492
- if (e)
1493
- throw e.error;
1494
- }
1495
- }
1496
- return ar;
1497
- };
1498
- globalThis && globalThis.__spread || function() {
1499
- for (var ar = [], i = 0; i < arguments.length; i++) {
1500
- ar = ar.concat(__read$3(arguments[i]));
1501
- }
1502
- return ar;
1503
- };
1504
- var ConfigContext = /* @__PURE__ */ React__default.createContext({});
1505
- ConfigContext.displayName = "UseRequestConfigContext";
1506
- var __assign = globalThis && globalThis.__assign || function() {
1507
- __assign = Object.assign || function(t) {
1508
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1509
- s = arguments[i];
1510
- for (var p in s) {
1511
- if (Object.prototype.hasOwnProperty.call(s, p))
1512
- t[p] = s[p];
1513
- }
1514
- }
1515
- return t;
1516
- };
1517
- return __assign.apply(this, arguments);
1518
- };
1519
- globalThis && globalThis.__rest || function(s, e) {
1520
- var t = {};
1521
- for (var p in s) {
1522
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1523
- t[p] = s[p];
1524
- }
1525
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1526
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1527
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1528
- t[p[i]] = s[p[i]];
1529
- }
1530
- return t;
1531
- };
1532
- var __read$2 = globalThis && globalThis.__read || function(o, n) {
1533
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1534
- if (!m)
1535
- return o;
1536
- var i = m.call(o), r2, ar = [], e;
1537
- try {
1538
- while ((n === void 0 || n-- > 0) && !(r2 = i.next()).done) {
1539
- ar.push(r2.value);
1540
- }
1541
- } catch (error) {
1542
- e = {
1543
- error
1544
- };
1545
- } finally {
1546
- try {
1547
- if (r2 && !r2.done && (m = i["return"]))
1548
- m.call(i);
1549
- } finally {
1550
- if (e)
1551
- throw e.error;
1552
- }
1553
- }
1554
- return ar;
1555
- };
1556
- globalThis && globalThis.__spread || function() {
1557
- for (var ar = [], i = 0; i < arguments.length; i++) {
1558
- ar = ar.concat(__read$2(arguments[i]));
1559
- }
1560
- return ar;
1561
- };
1562
- ConfigContext.Provider;
1563
1342
  function usePersistFn(fn) {
1564
1343
  var fnRef = useRef(fn);
1565
1344
  fnRef.current = fn;
@@ -1575,7 +1354,7 @@ function usePersistFn(fn) {
1575
1354
  }
1576
1355
  return persistFn.current;
1577
1356
  }
1578
- var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
1357
+ var __awaiter = function(thisArg, _arguments, P, generator) {
1579
1358
  function adopt(value) {
1580
1359
  return value instanceof P ? value : new P(function(resolve) {
1581
1360
  resolve(value);
@@ -1602,7 +1381,7 @@ var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _argumen
1602
1381
  step((generator = generator.apply(thisArg, _arguments || [])).next());
1603
1382
  });
1604
1383
  };
1605
- var __generator = globalThis && globalThis.__generator || function(thisArg, body) {
1384
+ var __generator = function(thisArg, body) {
1606
1385
  var _ = {
1607
1386
  label: 0,
1608
1387
  sent: function sent() {
@@ -1694,7 +1473,7 @@ var __generator = globalThis && globalThis.__generator || function(thisArg, body
1694
1473
  };
1695
1474
  }
1696
1475
  };
1697
- var __read$1 = globalThis && globalThis.__read || function(o, n) {
1476
+ var __read = function(o, n) {
1698
1477
  var m = typeof Symbol === "function" && o[Symbol.iterator];
1699
1478
  if (!m)
1700
1479
  return o;
@@ -1718,9 +1497,9 @@ var __read$1 = globalThis && globalThis.__read || function(o, n) {
1718
1497
  }
1719
1498
  return ar;
1720
1499
  };
1721
- var __spread = globalThis && globalThis.__spread || function() {
1500
+ var __spread = function() {
1722
1501
  for (var ar = [], i = 0; i < arguments.length; i++) {
1723
- ar = ar.concat(__read$1(arguments[i]));
1502
+ ar = ar.concat(__read(arguments[i]));
1724
1503
  }
1725
1504
  return ar;
1726
1505
  };
@@ -1769,36 +1548,6 @@ function useLockFn(fn) {
1769
1548
  });
1770
1549
  }, [fn]);
1771
1550
  }
1772
- var __read = globalThis && globalThis.__read || function(o, n) {
1773
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1774
- if (!m)
1775
- return o;
1776
- var i = m.call(o), r2, ar = [], e;
1777
- try {
1778
- while ((n === void 0 || n-- > 0) && !(r2 = i.next()).done) {
1779
- ar.push(r2.value);
1780
- }
1781
- } catch (error) {
1782
- e = {
1783
- error
1784
- };
1785
- } finally {
1786
- try {
1787
- if (r2 && !r2.done && (m = i["return"]))
1788
- m.call(i);
1789
- } finally {
1790
- if (e)
1791
- throw e.error;
1792
- }
1793
- }
1794
- return ar;
1795
- };
1796
- globalThis && globalThis.__spread || function() {
1797
- for (var ar = [], i = 0; i < arguments.length; i++) {
1798
- ar = ar.concat(__read(arguments[i]));
1799
- }
1800
- return ar;
1801
- };
1802
1551
  const overflowScrollReg = /scroll|auto/i;
1803
1552
  function isElement(node) {
1804
1553
  const ELEMENT_NODE_TYPE = 1;
@@ -1816,26 +1565,26 @@ function getScrollParent(el, root) {
1816
1565
  return root;
1817
1566
  }
1818
1567
  function Loading(props) {
1819
- return /* @__PURE__ */ React__default.createElement("div", {
1568
+ return /* @__PURE__ */ React.createElement("div", {
1820
1569
  style: {
1821
1570
  color: props.color || "#999"
1822
1571
  }
1823
- }, /* @__PURE__ */ React__default.createElement("svg", {
1572
+ }, /* @__PURE__ */ React.createElement("svg", {
1824
1573
  height: "1em",
1825
1574
  viewBox: "0 0 100 40",
1826
1575
  style: { verticalAlign: "-0.125em" }
1827
- }, /* @__PURE__ */ React__default.createElement("g", {
1576
+ }, /* @__PURE__ */ React.createElement("g", {
1828
1577
  stroke: "none",
1829
1578
  strokeWidth: "1",
1830
1579
  fill: "none",
1831
1580
  fillRule: "evenodd"
1832
- }, /* @__PURE__ */ React__default.createElement("g", {
1581
+ }, /* @__PURE__ */ React.createElement("g", {
1833
1582
  transform: "translate(-100.000000, -71.000000)"
1834
- }, /* @__PURE__ */ React__default.createElement("g", {
1583
+ }, /* @__PURE__ */ React.createElement("g", {
1835
1584
  transform: "translate(95.000000, 71.000000)"
1836
- }, /* @__PURE__ */ React__default.createElement("g", {
1585
+ }, /* @__PURE__ */ React.createElement("g", {
1837
1586
  transform: "translate(5.000000, 0.000000)"
1838
- }, [0, 1, 2].map((i) => /* @__PURE__ */ React__default.createElement("rect", {
1587
+ }, [0, 1, 2].map((i) => /* @__PURE__ */ React.createElement("rect", {
1839
1588
  key: i,
1840
1589
  fill: "currentColor",
1841
1590
  x: 20 + i * 26,
@@ -1843,7 +1592,7 @@ function Loading(props) {
1843
1592
  width: "8",
1844
1593
  height: "8",
1845
1594
  rx: "2"
1846
- }, /* @__PURE__ */ React__default.createElement("animate", {
1595
+ }, /* @__PURE__ */ React.createElement("animate", {
1847
1596
  attributeName: "y",
1848
1597
  from: "16",
1849
1598
  to: "16",
@@ -1897,3127 +1646,25 @@ function InfiniteScroll(props) {
1897
1646
  parent.removeEventListener("scroll", onScroll);
1898
1647
  };
1899
1648
  }, []);
1900
- return /* @__PURE__ */ React__default.createElement("div", {
1649
+ return /* @__PURE__ */ React.createElement("div", {
1901
1650
  className: classNames({ [className]: true, "pda-infinite-scroll": true }),
1902
1651
  style,
1903
1652
  ref: elementRef
1904
- }, hasMore ? /* @__PURE__ */ React__default.createElement("div", {
1653
+ }, hasMore ? /* @__PURE__ */ React.createElement("div", {
1905
1654
  className: "pda-infinite-scroll-view"
1906
- }, /* @__PURE__ */ React__default.createElement("span", null, "\u52A0\u8F7D\u4E2D"), /* @__PURE__ */ React__default.createElement(Loading, null)) : /* @__PURE__ */ React__default.createElement("div", {
1655
+ }, /* @__PURE__ */ React.createElement("span", null, "\u52A0\u8F7D\u4E2D"), /* @__PURE__ */ React.createElement(Loading, null)) : /* @__PURE__ */ React.createElement("div", {
1907
1656
  className: "pda-infinite-scroll-view"
1908
- }, /* @__PURE__ */ React__default.createElement("span", null, "\u6CA1\u6709\u66F4\u591A\u4E86~")));
1657
+ }, /* @__PURE__ */ React.createElement("span", null, "\u6CA1\u6709\u66F4\u591A\u4E86~")));
1909
1658
  }
1910
1659
  var index = "";
1911
- let updateQueue = makeQueue();
1912
- const raf = (fn) => schedule(fn, updateQueue);
1913
- let writeQueue = makeQueue();
1914
- raf.write = (fn) => schedule(fn, writeQueue);
1915
- let onStartQueue = makeQueue();
1916
- raf.onStart = (fn) => schedule(fn, onStartQueue);
1917
- let onFrameQueue = makeQueue();
1918
- raf.onFrame = (fn) => schedule(fn, onFrameQueue);
1919
- let onFinishQueue = makeQueue();
1920
- raf.onFinish = (fn) => schedule(fn, onFinishQueue);
1921
- let timeouts = [];
1922
- raf.setTimeout = (handler, ms) => {
1923
- let time = raf.now() + ms;
1924
- let cancel = () => {
1925
- let i = timeouts.findIndex((t) => t.cancel == cancel);
1926
- if (~i)
1927
- timeouts.splice(i, 1);
1928
- __raf.count -= ~i ? 1 : 0;
1929
- };
1930
- let timeout = {
1931
- time,
1932
- handler,
1933
- cancel
1934
- };
1935
- timeouts.splice(findTimeout(time), 0, timeout);
1936
- __raf.count += 1;
1937
- start();
1938
- return timeout;
1939
- };
1940
- let findTimeout = (time) => ~(~timeouts.findIndex((t) => t.time > time) || ~timeouts.length);
1941
- raf.cancel = (fn) => {
1942
- updateQueue.delete(fn);
1943
- writeQueue.delete(fn);
1944
- };
1945
- raf.sync = (fn) => {
1946
- sync = true;
1947
- raf.batchedUpdates(fn);
1948
- sync = false;
1949
- };
1950
- raf.throttle = (fn) => {
1951
- let lastArgs;
1952
- function queuedFn() {
1953
- try {
1954
- fn(...lastArgs);
1955
- } finally {
1956
- lastArgs = null;
1957
- }
1958
- }
1959
- function throttled(...args) {
1960
- lastArgs = args;
1961
- raf.onStart(queuedFn);
1962
- }
1963
- throttled.handler = fn;
1964
- throttled.cancel = () => {
1965
- onStartQueue.delete(queuedFn);
1966
- lastArgs = null;
1967
- };
1968
- return throttled;
1969
- };
1970
- let nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => {
1971
- };
1972
- raf.use = (impl) => nativeRaf = impl;
1973
- raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
1974
- raf.batchedUpdates = (fn) => fn();
1975
- raf.catch = console.error;
1976
- raf.frameLoop = "always";
1977
- raf.advance = () => {
1978
- if (raf.frameLoop !== "demand") {
1979
- console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand");
1980
- } else {
1981
- update();
1982
- }
1983
- };
1984
- let ts = -1;
1985
- let sync = false;
1986
- function schedule(fn, queue) {
1987
- if (sync) {
1988
- queue.delete(fn);
1989
- fn(0);
1990
- } else {
1991
- queue.add(fn);
1992
- start();
1993
- }
1994
- }
1995
- function start() {
1996
- if (ts < 0) {
1997
- ts = 0;
1998
- if (raf.frameLoop !== "demand") {
1999
- nativeRaf(loop);
2000
- }
2001
- }
2002
- }
2003
- function loop() {
2004
- if (~ts) {
2005
- nativeRaf(loop);
2006
- raf.batchedUpdates(update);
2007
- }
2008
- }
2009
- function update() {
2010
- let prevTs = ts;
2011
- ts = raf.now();
2012
- let count = findTimeout(ts);
2013
- if (count) {
2014
- eachSafely(timeouts.splice(0, count), (t) => t.handler());
2015
- __raf.count -= count;
2016
- }
2017
- onStartQueue.flush();
2018
- updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
2019
- onFrameQueue.flush();
2020
- writeQueue.flush();
2021
- onFinishQueue.flush();
2022
- }
2023
- function makeQueue() {
2024
- let next = new Set();
2025
- let current = next;
2026
- return {
2027
- add(fn) {
2028
- __raf.count += current == next && !next.has(fn) ? 1 : 0;
2029
- next.add(fn);
2030
- },
2031
- delete(fn) {
2032
- __raf.count -= current == next && next.has(fn) ? 1 : 0;
2033
- return next.delete(fn);
2034
- },
2035
- flush(arg) {
2036
- if (current.size) {
2037
- next = new Set();
2038
- __raf.count -= current.size;
2039
- eachSafely(current, (fn) => fn(arg) && next.add(fn));
2040
- __raf.count += next.size;
2041
- current = next;
2042
- }
2043
- }
2044
- };
2045
- }
2046
- function eachSafely(values, each2) {
2047
- values.forEach((value) => {
2048
- try {
2049
- each2(value);
2050
- } catch (e) {
2051
- raf.catch(e);
2052
- }
2053
- });
2054
- }
2055
- const __raf = {
2056
- count: 0,
2057
- clear() {
2058
- ts = -1;
2059
- timeouts = [];
2060
- onStartQueue = makeQueue();
2061
- updateQueue = makeQueue();
2062
- onFrameQueue = makeQueue();
2063
- writeQueue = makeQueue();
2064
- onFinishQueue = makeQueue();
2065
- __raf.count = 0;
2066
- }
2067
- };
2068
- function noop() {
2069
- }
2070
- const defineHidden = (obj, key, value) => Object.defineProperty(obj, key, {
2071
- value,
2072
- writable: true,
2073
- configurable: true
2074
- });
2075
- const is = {
2076
- arr: Array.isArray,
2077
- obj: (a) => !!a && a.constructor.name === "Object",
2078
- fun: (a) => typeof a === "function",
2079
- str: (a) => typeof a === "string",
2080
- num: (a) => typeof a === "number",
2081
- und: (a) => a === void 0
2082
- };
2083
- function isEqual(a, b) {
2084
- if (is.arr(a)) {
2085
- if (!is.arr(b) || a.length !== b.length)
2086
- return false;
2087
- for (let i = 0; i < a.length; i++) {
2088
- if (a[i] !== b[i])
2089
- return false;
2090
- }
2091
- return true;
2092
- }
2093
- return a === b;
2094
- }
2095
- const each = (obj, fn) => obj.forEach(fn);
2096
- function eachProp(obj, fn, ctx2) {
2097
- if (is.arr(obj)) {
2098
- for (let i = 0; i < obj.length; i++) {
2099
- fn.call(ctx2, obj[i], `${i}`);
2100
- }
2101
- return;
2102
- }
2103
- for (const key in obj) {
2104
- if (obj.hasOwnProperty(key)) {
2105
- fn.call(ctx2, obj[key], key);
2106
- }
2107
- }
2108
- }
2109
- const toArray = (a) => is.und(a) ? [] : is.arr(a) ? a : [a];
2110
- function flush(queue, iterator) {
2111
- if (queue.size) {
2112
- const items = Array.from(queue);
2113
- queue.clear();
2114
- each(items, iterator);
2115
- }
2116
- }
2117
- const flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
2118
- let createStringInterpolator$1;
2119
- let to;
2120
- let colors$1 = null;
2121
- let skipAnimation = false;
2122
- let willAdvance = noop;
2123
- const assign = (globals2) => {
2124
- if (globals2.to)
2125
- to = globals2.to;
2126
- if (globals2.now)
2127
- raf.now = globals2.now;
2128
- if (globals2.colors !== void 0)
2129
- colors$1 = globals2.colors;
2130
- if (globals2.skipAnimation != null)
2131
- skipAnimation = globals2.skipAnimation;
2132
- if (globals2.createStringInterpolator)
2133
- createStringInterpolator$1 = globals2.createStringInterpolator;
2134
- if (globals2.requestAnimationFrame)
2135
- raf.use(globals2.requestAnimationFrame);
2136
- if (globals2.batchedUpdates)
2137
- raf.batchedUpdates = globals2.batchedUpdates;
2138
- if (globals2.willAdvance)
2139
- willAdvance = globals2.willAdvance;
2140
- if (globals2.frameLoop)
2141
- raf.frameLoop = globals2.frameLoop;
2142
- };
2143
- var globals = /* @__PURE__ */ Object.freeze({
2144
- __proto__: null,
2145
- get createStringInterpolator() {
2146
- return createStringInterpolator$1;
2147
- },
2148
- get to() {
2149
- return to;
2150
- },
2151
- get colors() {
2152
- return colors$1;
2153
- },
2154
- get skipAnimation() {
2155
- return skipAnimation;
2156
- },
2157
- get willAdvance() {
2158
- return willAdvance;
2159
- },
2160
- assign
2161
- });
2162
- const startQueue = new Set();
2163
- let currentFrame = [];
2164
- let prevFrame = [];
2165
- let priority = 0;
2166
- const frameLoop = {
2167
- get idle() {
2168
- return !startQueue.size && !currentFrame.length;
2169
- },
2170
- start(animation) {
2171
- if (priority > animation.priority) {
2172
- startQueue.add(animation);
2173
- raf.onStart(flushStartQueue);
2174
- } else {
2175
- startSafely(animation);
2176
- raf(advance);
2177
- }
2178
- },
2179
- advance,
2180
- sort(animation) {
2181
- if (priority) {
2182
- raf.onFrame(() => frameLoop.sort(animation));
2183
- } else {
2184
- const prevIndex = currentFrame.indexOf(animation);
2185
- if (~prevIndex) {
2186
- currentFrame.splice(prevIndex, 1);
2187
- startUnsafely(animation);
2188
- }
2189
- }
2190
- },
2191
- clear() {
2192
- currentFrame = [];
2193
- startQueue.clear();
2194
- }
2195
- };
2196
- function flushStartQueue() {
2197
- startQueue.forEach(startSafely);
2198
- startQueue.clear();
2199
- raf(advance);
2200
- }
2201
- function startSafely(animation) {
2202
- if (!currentFrame.includes(animation))
2203
- startUnsafely(animation);
2204
- }
2205
- function startUnsafely(animation) {
2206
- currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation);
2207
- }
2208
- function advance(dt) {
2209
- const nextFrame = prevFrame;
2210
- for (let i = 0; i < currentFrame.length; i++) {
2211
- const animation = currentFrame[i];
2212
- priority = animation.priority;
2213
- if (!animation.idle) {
2214
- willAdvance(animation);
2215
- animation.advance(dt);
2216
- if (!animation.idle) {
2217
- nextFrame.push(animation);
2218
- }
2219
- }
2220
- }
2221
- priority = 0;
2222
- prevFrame = currentFrame;
2223
- prevFrame.length = 0;
2224
- currentFrame = nextFrame;
2225
- return currentFrame.length > 0;
2226
- }
2227
- function findIndex(arr, test) {
2228
- const index2 = arr.findIndex(test);
2229
- return index2 < 0 ? arr.length : index2;
2230
- }
2231
- const colors = {
2232
- transparent: 0,
2233
- aliceblue: 4042850303,
2234
- antiquewhite: 4209760255,
2235
- aqua: 16777215,
2236
- aquamarine: 2147472639,
2237
- azure: 4043309055,
2238
- beige: 4126530815,
2239
- bisque: 4293182719,
2240
- black: 255,
2241
- blanchedalmond: 4293643775,
2242
- blue: 65535,
2243
- blueviolet: 2318131967,
2244
- brown: 2771004159,
2245
- burlywood: 3736635391,
2246
- burntsienna: 3934150143,
2247
- cadetblue: 1604231423,
2248
- chartreuse: 2147418367,
2249
- chocolate: 3530104575,
2250
- coral: 4286533887,
2251
- cornflowerblue: 1687547391,
2252
- cornsilk: 4294499583,
2253
- crimson: 3692313855,
2254
- cyan: 16777215,
2255
- darkblue: 35839,
2256
- darkcyan: 9145343,
2257
- darkgoldenrod: 3095792639,
2258
- darkgray: 2846468607,
2259
- darkgreen: 6553855,
2260
- darkgrey: 2846468607,
2261
- darkkhaki: 3182914559,
2262
- darkmagenta: 2332068863,
2263
- darkolivegreen: 1433087999,
2264
- darkorange: 4287365375,
2265
- darkorchid: 2570243327,
2266
- darkred: 2332033279,
2267
- darksalmon: 3918953215,
2268
- darkseagreen: 2411499519,
2269
- darkslateblue: 1211993087,
2270
- darkslategray: 793726975,
2271
- darkslategrey: 793726975,
2272
- darkturquoise: 13554175,
2273
- darkviolet: 2483082239,
2274
- deeppink: 4279538687,
2275
- deepskyblue: 12582911,
2276
- dimgray: 1768516095,
2277
- dimgrey: 1768516095,
2278
- dodgerblue: 512819199,
2279
- firebrick: 2988581631,
2280
- floralwhite: 4294635775,
2281
- forestgreen: 579543807,
2282
- fuchsia: 4278255615,
2283
- gainsboro: 3705462015,
2284
- ghostwhite: 4177068031,
2285
- gold: 4292280575,
2286
- goldenrod: 3668254975,
2287
- gray: 2155905279,
2288
- green: 8388863,
2289
- greenyellow: 2919182335,
2290
- grey: 2155905279,
2291
- honeydew: 4043305215,
2292
- hotpink: 4285117695,
2293
- indianred: 3445382399,
2294
- indigo: 1258324735,
2295
- ivory: 4294963455,
2296
- khaki: 4041641215,
2297
- lavender: 3873897215,
2298
- lavenderblush: 4293981695,
2299
- lawngreen: 2096890111,
2300
- lemonchiffon: 4294626815,
2301
- lightblue: 2916673279,
2302
- lightcoral: 4034953471,
2303
- lightcyan: 3774873599,
2304
- lightgoldenrodyellow: 4210742015,
2305
- lightgray: 3553874943,
2306
- lightgreen: 2431553791,
2307
- lightgrey: 3553874943,
2308
- lightpink: 4290167295,
2309
- lightsalmon: 4288707327,
2310
- lightseagreen: 548580095,
2311
- lightskyblue: 2278488831,
2312
- lightslategray: 2005441023,
2313
- lightslategrey: 2005441023,
2314
- lightsteelblue: 2965692159,
2315
- lightyellow: 4294959359,
2316
- lime: 16711935,
2317
- limegreen: 852308735,
2318
- linen: 4210091775,
2319
- magenta: 4278255615,
2320
- maroon: 2147483903,
2321
- mediumaquamarine: 1724754687,
2322
- mediumblue: 52735,
2323
- mediumorchid: 3126187007,
2324
- mediumpurple: 2473647103,
2325
- mediumseagreen: 1018393087,
2326
- mediumslateblue: 2070474495,
2327
- mediumspringgreen: 16423679,
2328
- mediumturquoise: 1221709055,
2329
- mediumvioletred: 3340076543,
2330
- midnightblue: 421097727,
2331
- mintcream: 4127193855,
2332
- mistyrose: 4293190143,
2333
- moccasin: 4293178879,
2334
- navajowhite: 4292783615,
2335
- navy: 33023,
2336
- oldlace: 4260751103,
2337
- olive: 2155872511,
2338
- olivedrab: 1804477439,
2339
- orange: 4289003775,
2340
- orangered: 4282712319,
2341
- orchid: 3664828159,
2342
- palegoldenrod: 4008225535,
2343
- palegreen: 2566625535,
2344
- paleturquoise: 2951671551,
2345
- palevioletred: 3681588223,
2346
- papayawhip: 4293907967,
2347
- peachpuff: 4292524543,
2348
- peru: 3448061951,
2349
- pink: 4290825215,
2350
- plum: 3718307327,
2351
- powderblue: 2967529215,
2352
- purple: 2147516671,
2353
- rebeccapurple: 1714657791,
2354
- red: 4278190335,
2355
- rosybrown: 3163525119,
2356
- royalblue: 1097458175,
2357
- saddlebrown: 2336560127,
2358
- salmon: 4202722047,
2359
- sandybrown: 4104413439,
2360
- seagreen: 780883967,
2361
- seashell: 4294307583,
2362
- sienna: 2689740287,
2363
- silver: 3233857791,
2364
- skyblue: 2278484991,
2365
- slateblue: 1784335871,
2366
- slategray: 1887473919,
2367
- slategrey: 1887473919,
2368
- snow: 4294638335,
2369
- springgreen: 16744447,
2370
- steelblue: 1182971135,
2371
- tan: 3535047935,
2372
- teal: 8421631,
2373
- thistle: 3636451583,
2374
- tomato: 4284696575,
2375
- turquoise: 1088475391,
2376
- violet: 4001558271,
2377
- wheat: 4125012991,
2378
- white: 4294967295,
2379
- whitesmoke: 4126537215,
2380
- yellow: 4294902015,
2381
- yellowgreen: 2597139199
2382
- };
2383
- const NUMBER = "[-+]?\\d*\\.?\\d+";
2384
- const PERCENTAGE = NUMBER + "%";
2385
- function call(...parts) {
2386
- return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
2387
- }
2388
- const rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
2389
- const rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
2390
- const hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
2391
- const hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
2392
- const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
2393
- const hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
2394
- const hex6 = /^#([0-9a-fA-F]{6})$/;
2395
- const hex8 = /^#([0-9a-fA-F]{8})$/;
2396
- function normalizeColor(color) {
2397
- let match;
2398
- if (typeof color === "number") {
2399
- return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
2400
- }
2401
- if (match = hex6.exec(color))
2402
- return parseInt(match[1] + "ff", 16) >>> 0;
2403
- if (colors$1 && colors$1[color] !== void 0) {
2404
- return colors$1[color];
2405
- }
2406
- if (match = rgb.exec(color)) {
2407
- return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | 255) >>> 0;
2408
- }
2409
- if (match = rgba.exec(color)) {
2410
- return (parse255(match[1]) << 24 | parse255(match[2]) << 16 | parse255(match[3]) << 8 | parse1(match[4])) >>> 0;
2411
- }
2412
- if (match = hex3.exec(color)) {
2413
- return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + "ff", 16) >>> 0;
2414
- }
2415
- if (match = hex8.exec(color))
2416
- return parseInt(match[1], 16) >>> 0;
2417
- if (match = hex4.exec(color)) {
2418
- return parseInt(match[1] + match[1] + match[2] + match[2] + match[3] + match[3] + match[4] + match[4], 16) >>> 0;
2419
- }
2420
- if (match = hsl.exec(color)) {
2421
- return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | 255) >>> 0;
2422
- }
2423
- if (match = hsla.exec(color)) {
2424
- return (hslToRgb(parse360(match[1]), parsePercentage(match[2]), parsePercentage(match[3])) | parse1(match[4])) >>> 0;
2425
- }
2426
- return null;
2427
- }
2428
- function hue2rgb(p, q, t) {
2429
- if (t < 0)
2430
- t += 1;
2431
- if (t > 1)
2432
- t -= 1;
2433
- if (t < 1 / 6)
2434
- return p + (q - p) * 6 * t;
2435
- if (t < 1 / 2)
2436
- return q;
2437
- if (t < 2 / 3)
2438
- return p + (q - p) * (2 / 3 - t) * 6;
2439
- return p;
2440
- }
2441
- function hslToRgb(h, s, l) {
2442
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
2443
- const p = 2 * l - q;
2444
- const r2 = hue2rgb(p, q, h + 1 / 3);
2445
- const g = hue2rgb(p, q, h);
2446
- const b = hue2rgb(p, q, h - 1 / 3);
2447
- return Math.round(r2 * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
2448
- }
2449
- function parse255(str) {
2450
- const int = parseInt(str, 10);
2451
- if (int < 0)
2452
- return 0;
2453
- if (int > 255)
2454
- return 255;
2455
- return int;
2456
- }
2457
- function parse360(str) {
2458
- const int = parseFloat(str);
2459
- return (int % 360 + 360) % 360 / 360;
2460
- }
2461
- function parse1(str) {
2462
- const num = parseFloat(str);
2463
- if (num < 0)
2464
- return 0;
2465
- if (num > 1)
2466
- return 255;
2467
- return Math.round(num * 255);
2468
- }
2469
- function parsePercentage(str) {
2470
- const int = parseFloat(str);
2471
- if (int < 0)
2472
- return 0;
2473
- if (int > 100)
2474
- return 1;
2475
- return int / 100;
2476
- }
2477
- function colorToRgba(input) {
2478
- let int32Color = normalizeColor(input);
2479
- if (int32Color === null)
2480
- return input;
2481
- int32Color = int32Color || 0;
2482
- let r2 = (int32Color & 4278190080) >>> 24;
2483
- let g = (int32Color & 16711680) >>> 16;
2484
- let b = (int32Color & 65280) >>> 8;
2485
- let a = (int32Color & 255) / 255;
2486
- return `rgba(${r2}, ${g}, ${b}, ${a})`;
2487
- }
2488
- const createInterpolator = (range, output, extrapolate) => {
2489
- if (is.fun(range)) {
2490
- return range;
2491
- }
2492
- if (is.arr(range)) {
2493
- return createInterpolator({
2494
- range,
2495
- output,
2496
- extrapolate
2497
- });
2498
- }
2499
- if (is.str(range.output[0])) {
2500
- return createStringInterpolator$1(range);
2501
- }
2502
- const config2 = range;
2503
- const outputRange = config2.output;
2504
- const inputRange = config2.range || [0, 1];
2505
- const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend";
2506
- const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend";
2507
- const easing = config2.easing || ((t) => t);
2508
- return (input) => {
2509
- const range2 = findRange(input, inputRange);
2510
- return interpolate(input, inputRange[range2], inputRange[range2 + 1], outputRange[range2], outputRange[range2 + 1], easing, extrapolateLeft, extrapolateRight, config2.map);
2511
- };
2512
- };
2513
- function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
2514
- let result = map ? map(input) : input;
2515
- if (result < inputMin) {
2516
- if (extrapolateLeft === "identity")
2517
- return result;
2518
- else if (extrapolateLeft === "clamp")
2519
- result = inputMin;
2520
- }
2521
- if (result > inputMax) {
2522
- if (extrapolateRight === "identity")
2523
- return result;
2524
- else if (extrapolateRight === "clamp")
2525
- result = inputMax;
2526
- }
2527
- if (outputMin === outputMax)
2528
- return outputMin;
2529
- if (inputMin === inputMax)
2530
- return input <= inputMin ? outputMin : outputMax;
2531
- if (inputMin === -Infinity)
2532
- result = -result;
2533
- else if (inputMax === Infinity)
2534
- result = result - inputMin;
2535
- else
2536
- result = (result - inputMin) / (inputMax - inputMin);
2537
- result = easing(result);
2538
- if (outputMin === -Infinity)
2539
- result = -result;
2540
- else if (outputMax === Infinity)
2541
- result = result + outputMin;
2542
- else
2543
- result = result * (outputMax - outputMin) + outputMin;
2544
- return result;
2545
- }
2546
- function findRange(input, inputRange) {
2547
- for (var i = 1; i < inputRange.length - 1; ++i)
2548
- if (inputRange[i] >= input)
2549
- break;
2550
- return i - 1;
2551
- }
2552
- function _extends$2() {
2553
- _extends$2 = Object.assign || function(target) {
2554
- for (var i = 1; i < arguments.length; i++) {
2555
- var source = arguments[i];
2556
- for (var key in source) {
2557
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2558
- target[key] = source[key];
2559
- }
2560
- }
2561
- }
2562
- return target;
2563
- };
2564
- return _extends$2.apply(this, arguments);
2565
- }
2566
- const $get = Symbol.for("FluidValue.get");
2567
- const $observers = Symbol.for("FluidValue.observers");
2568
- const hasFluidValue = (arg) => Boolean(arg && arg[$get]);
2569
- const getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
2570
- const getFluidObservers = (target) => target[$observers] || null;
2571
- function callFluidObserver(observer, event) {
2572
- if (observer.eventObserved) {
2573
- observer.eventObserved(event);
2574
- } else {
2575
- observer(event);
2576
- }
2577
- }
2578
- function callFluidObservers(target, event) {
2579
- let observers = target[$observers];
2580
- if (observers) {
2581
- observers.forEach((observer) => {
2582
- callFluidObserver(observer, event);
2583
- });
2584
- }
2585
- }
2586
- class FluidValue {
2587
- constructor(get) {
2588
- this[$get] = void 0;
2589
- this[$observers] = void 0;
2590
- if (!get && !(get = this.get)) {
2591
- throw Error("Unknown getter");
2592
- }
2593
- setFluidGetter(this, get);
2594
- }
2595
- }
2596
- const setFluidGetter = (target, get) => setHidden(target, $get, get);
2597
- function addFluidObserver(target, observer) {
2598
- if (target[$get]) {
2599
- let observers = target[$observers];
2600
- if (!observers) {
2601
- setHidden(target, $observers, observers = new Set());
2602
- }
2603
- if (!observers.has(observer)) {
2604
- observers.add(observer);
2605
- if (target.observerAdded) {
2606
- target.observerAdded(observers.size, observer);
2607
- }
2608
- }
2609
- }
2610
- return observer;
2611
- }
2612
- function removeFluidObserver(target, observer) {
2613
- let observers = target[$observers];
2614
- if (observers && observers.has(observer)) {
2615
- const count = observers.size - 1;
2616
- if (count) {
2617
- observers.delete(observer);
2618
- } else {
2619
- target[$observers] = null;
2620
- }
2621
- if (target.observerRemoved) {
2622
- target.observerRemoved(count, observer);
2623
- }
2624
- }
2625
- }
2626
- const setHidden = (target, key, value) => Object.defineProperty(target, key, {
2627
- value,
2628
- writable: true,
2629
- configurable: true
2630
- });
2631
- const numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
2632
- const colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
2633
- const unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
2634
- let namedColorRegex;
2635
- const rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
2636
- const rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
2637
- const createStringInterpolator = (config2) => {
2638
- if (!namedColorRegex)
2639
- namedColorRegex = colors$1 ? new RegExp(`(${Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/;
2640
- const output = config2.output.map((value) => getFluidValue(value).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba));
2641
- const keyframes = output.map((value) => value.match(numberRegex).map(Number));
2642
- const outputRanges = keyframes[0].map((_, i) => keyframes.map((values) => {
2643
- if (!(i in values)) {
2644
- throw Error('The arity of each "output" value must be equal');
2645
- }
2646
- return values[i];
2647
- }));
2648
- const interpolators = outputRanges.map((output2) => createInterpolator(_extends$2({}, config2, {
2649
- output: output2
2650
- })));
2651
- return (input) => {
2652
- var _output$find;
2653
- const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, ""));
2654
- let i = 0;
2655
- return output[0].replace(numberRegex, () => `${interpolators[i++](input)}${missingUnit || ""}`).replace(rgbaRegex, rgbaRound);
2656
- };
2657
- };
2658
- const prefix = "react-spring: ";
2659
- const once = (fn) => {
2660
- const func = fn;
2661
- let called = false;
2662
- if (typeof func != "function") {
2663
- throw new TypeError(`${prefix}once requires a function parameter`);
2664
- }
2665
- return (...args) => {
2666
- if (!called) {
2667
- func(...args);
2668
- called = true;
2669
- }
2670
- };
2671
- };
2672
- const warnInterpolate = once(console.warn);
2673
- function deprecateInterpolate() {
2674
- warnInterpolate(`${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`);
2675
- }
2676
- const warnDirectCall = once(console.warn);
2677
- function deprecateDirectCall() {
2678
- warnDirectCall(`${prefix}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`);
2679
- }
2680
- function isAnimatedString(value) {
2681
- return is.str(value) && (value[0] == "#" || /\d/.test(value) || value in (colors$1 || {}));
2682
- }
2683
- const useOnce = (effect) => useEffect(effect, emptyDeps);
2684
- const emptyDeps = [];
2685
- function useForceUpdate() {
2686
- const update2 = useState()[1];
2687
- const mounted = useState(makeMountedRef)[0];
2688
- useOnce(mounted.unmount);
2689
- return () => {
2690
- if (mounted.current) {
2691
- update2({});
2692
- }
2693
- };
2694
- }
2695
- function makeMountedRef() {
2696
- const mounted = {
2697
- current: true,
2698
- unmount: () => () => {
2699
- mounted.current = false;
2700
- }
2701
- };
2702
- return mounted;
2703
- }
2704
- function useMemoOne(getResult, inputs) {
2705
- const [initial] = useState(() => ({
2706
- inputs,
2707
- result: getResult()
2708
- }));
2709
- const committed = useRef();
2710
- const prevCache = committed.current;
2711
- let cache = prevCache;
2712
- if (cache) {
2713
- const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs));
2714
- if (!useCache) {
2715
- cache = {
2716
- inputs,
2717
- result: getResult()
2718
- };
2719
- }
2720
- } else {
2721
- cache = initial;
2722
- }
2723
- useEffect(() => {
2724
- committed.current = cache;
2725
- if (prevCache == initial) {
2726
- initial.inputs = initial.result = void 0;
2727
- }
2728
- }, [cache]);
2729
- return cache.result;
2730
- }
2731
- function areInputsEqual(next, prev) {
2732
- if (next.length !== prev.length) {
2733
- return false;
2734
- }
2735
- for (let i = 0; i < next.length; i++) {
2736
- if (next[i] !== prev[i]) {
2737
- return false;
2738
- }
2739
- }
2740
- return true;
2741
- }
2742
- function usePrev(value) {
2743
- const prevRef = useRef();
2744
- useEffect(() => {
2745
- prevRef.current = value;
2746
- });
2747
- return prevRef.current;
2748
- }
2749
- const useLayoutEffect = typeof window !== "undefined" && window.document && window.document.createElement ? React.useLayoutEffect : React.useEffect;
2750
- const $node = Symbol.for("Animated:node");
2751
- const isAnimated = (value) => !!value && value[$node] === value;
2752
- const getAnimated = (owner) => owner && owner[$node];
2753
- const setAnimated = (owner, node) => defineHidden(owner, $node, node);
2754
- const getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
2755
- class Animated {
2756
- constructor() {
2757
- this.payload = void 0;
2758
- setAnimated(this, this);
2759
- }
2760
- getPayload() {
2761
- return this.payload || [];
2762
- }
2763
- }
2764
- class AnimatedValue extends Animated {
2765
- constructor(_value) {
2766
- super();
2767
- this.done = true;
2768
- this.elapsedTime = void 0;
2769
- this.lastPosition = void 0;
2770
- this.lastVelocity = void 0;
2771
- this.v0 = void 0;
2772
- this.durationProgress = 0;
2773
- this._value = _value;
2774
- if (is.num(this._value)) {
2775
- this.lastPosition = this._value;
2776
- }
2777
- }
2778
- static create(value) {
2779
- return new AnimatedValue(value);
2780
- }
2781
- getPayload() {
2782
- return [this];
2783
- }
2784
- getValue() {
2785
- return this._value;
2786
- }
2787
- setValue(value, step) {
2788
- if (is.num(value)) {
2789
- this.lastPosition = value;
2790
- if (step) {
2791
- value = Math.round(value / step) * step;
2792
- if (this.done) {
2793
- this.lastPosition = value;
2794
- }
2795
- }
2796
- }
2797
- if (this._value === value) {
2798
- return false;
2799
- }
2800
- this._value = value;
2801
- return true;
2802
- }
2803
- reset() {
2804
- const {
2805
- done
2806
- } = this;
2807
- this.done = false;
2808
- if (is.num(this._value)) {
2809
- this.elapsedTime = 0;
2810
- this.durationProgress = 0;
2811
- this.lastPosition = this._value;
2812
- if (done)
2813
- this.lastVelocity = null;
2814
- this.v0 = null;
2815
- }
2816
- }
2817
- }
2818
- class AnimatedString extends AnimatedValue {
2819
- constructor(value) {
2820
- super(0);
2821
- this._string = null;
2822
- this._toString = void 0;
2823
- this._toString = createInterpolator({
2824
- output: [value, value]
2825
- });
2826
- }
2827
- static create(value) {
2828
- return new AnimatedString(value);
2829
- }
2830
- getValue() {
2831
- let value = this._string;
2832
- return value == null ? this._string = this._toString(this._value) : value;
2833
- }
2834
- setValue(value) {
2835
- if (is.str(value)) {
2836
- if (value == this._string) {
2837
- return false;
2838
- }
2839
- this._string = value;
2840
- this._value = 1;
2841
- } else if (super.setValue(value)) {
2842
- this._string = null;
2843
- } else {
2844
- return false;
2845
- }
2846
- return true;
2847
- }
2848
- reset(goal) {
2849
- if (goal) {
2850
- this._toString = createInterpolator({
2851
- output: [this.getValue(), goal]
2852
- });
2853
- }
2854
- this._value = 0;
2855
- super.reset();
2856
- }
2857
- }
2858
- const TreeContext = {
2859
- dependencies: null
2860
- };
2861
- class AnimatedObject extends Animated {
2862
- constructor(source) {
2863
- super();
2864
- this.source = source;
2865
- this.setValue(source);
2866
- }
2867
- getValue(animated2) {
2868
- const values = {};
2869
- eachProp(this.source, (source, key) => {
2870
- if (isAnimated(source)) {
2871
- values[key] = source.getValue(animated2);
2872
- } else if (hasFluidValue(source)) {
2873
- values[key] = getFluidValue(source);
2874
- } else if (!animated2) {
2875
- values[key] = source;
2876
- }
2877
- });
2878
- return values;
2879
- }
2880
- setValue(source) {
2881
- this.source = source;
2882
- this.payload = this._makePayload(source);
2883
- }
2884
- reset() {
2885
- if (this.payload) {
2886
- each(this.payload, (node) => node.reset());
2887
- }
2888
- }
2889
- _makePayload(source) {
2890
- if (source) {
2891
- const payload = new Set();
2892
- eachProp(source, this._addToPayload, payload);
2893
- return Array.from(payload);
2894
- }
2895
- }
2896
- _addToPayload(source) {
2897
- if (TreeContext.dependencies && hasFluidValue(source)) {
2898
- TreeContext.dependencies.add(source);
2899
- }
2900
- const payload = getPayload(source);
2901
- if (payload) {
2902
- each(payload, (node) => this.add(node));
2903
- }
2904
- }
2905
- }
2906
- class AnimatedArray extends AnimatedObject {
2907
- constructor(source) {
2908
- super(source);
2909
- }
2910
- static create(source) {
2911
- return new AnimatedArray(source);
2912
- }
2913
- getValue() {
2914
- return this.source.map((node) => node.getValue());
2915
- }
2916
- setValue(source) {
2917
- const payload = this.getPayload();
2918
- if (source.length == payload.length) {
2919
- return payload.map((node, i) => node.setValue(source[i])).some(Boolean);
2920
- }
2921
- super.setValue(source.map(makeAnimated));
2922
- return true;
2923
- }
2924
- }
2925
- function makeAnimated(value) {
2926
- const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
2927
- return nodeType.create(value);
2928
- }
2929
- function getAnimatedType(value) {
2930
- const parentNode = getAnimated(value);
2931
- return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
2932
- }
2933
- function _extends$1() {
2934
- _extends$1 = Object.assign || function(target) {
2935
- for (var i = 1; i < arguments.length; i++) {
2936
- var source = arguments[i];
2937
- for (var key in source) {
2938
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2939
- target[key] = source[key];
2940
- }
2941
- }
2942
- }
2943
- return target;
2944
- };
2945
- return _extends$1.apply(this, arguments);
2946
- }
2947
- const withAnimated = (Component, host2) => {
2948
- const hasInstance = !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent;
2949
- return forwardRef((givenProps, givenRef) => {
2950
- const instanceRef = useRef(null);
2951
- const ref = hasInstance && useCallback((value) => {
2952
- instanceRef.current = updateRef(givenRef, value);
2953
- }, [givenRef]);
2954
- const [props, deps] = getAnimatedState(givenProps, host2);
2955
- const forceUpdate = useForceUpdate();
2956
- const callback = () => {
2957
- const instance = instanceRef.current;
2958
- if (hasInstance && !instance) {
2959
- return;
2960
- }
2961
- const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false;
2962
- if (didUpdate === false) {
2963
- forceUpdate();
2964
- }
2965
- };
2966
- const observer = new PropsObserver(callback, deps);
2967
- const observerRef = useRef();
2968
- useLayoutEffect(() => {
2969
- const lastObserver = observerRef.current;
2970
- observerRef.current = observer;
2971
- each(deps, (dep) => addFluidObserver(dep, observer));
2972
- if (lastObserver) {
2973
- each(lastObserver.deps, (dep) => removeFluidObserver(dep, lastObserver));
2974
- raf.cancel(lastObserver.update);
2975
- }
2976
- });
2977
- useEffect(callback, []);
2978
- useOnce(() => () => {
2979
- const observer2 = observerRef.current;
2980
- each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
2981
- });
2982
- const usedProps = host2.getComponentProps(props.getValue());
2983
- return React.createElement(Component, _extends$1({}, usedProps, {
2984
- ref
2985
- }));
2986
- });
2987
- };
2988
- class PropsObserver {
2989
- constructor(update2, deps) {
2990
- this.update = update2;
2991
- this.deps = deps;
2992
- }
2993
- eventObserved(event) {
2994
- if (event.type == "change") {
2995
- raf.write(this.update);
2996
- }
2997
- }
2998
- }
2999
- function getAnimatedState(props, host2) {
3000
- const dependencies = new Set();
3001
- TreeContext.dependencies = dependencies;
3002
- if (props.style)
3003
- props = _extends$1({}, props, {
3004
- style: host2.createAnimatedStyle(props.style)
3005
- });
3006
- props = new AnimatedObject(props);
3007
- TreeContext.dependencies = null;
3008
- return [props, dependencies];
3009
- }
3010
- function updateRef(ref, value) {
3011
- if (ref) {
3012
- if (is.fun(ref))
3013
- ref(value);
3014
- else
3015
- ref.current = value;
3016
- }
3017
- return value;
3018
- }
3019
- const cacheKey = Symbol.for("AnimatedComponent");
3020
- const createHost = (components, {
3021
- applyAnimatedValues: _applyAnimatedValues = () => false,
3022
- createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style),
3023
- getComponentProps: _getComponentProps = (props) => props
3024
- } = {}) => {
3025
- const hostConfig = {
3026
- applyAnimatedValues: _applyAnimatedValues,
3027
- createAnimatedStyle: _createAnimatedStyle,
3028
- getComponentProps: _getComponentProps
3029
- };
3030
- const animated2 = (Component) => {
3031
- const displayName = getDisplayName(Component) || "Anonymous";
3032
- if (is.str(Component)) {
3033
- Component = animated2[Component] || (animated2[Component] = withAnimated(Component, hostConfig));
3034
- } else {
3035
- Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
3036
- }
3037
- Component.displayName = `Animated(${displayName})`;
3038
- return Component;
3039
- };
3040
- eachProp(components, (Component, key) => {
3041
- if (is.arr(components)) {
3042
- key = getDisplayName(Component);
3043
- }
3044
- animated2[key] = animated2(Component);
3045
- });
3046
- return {
3047
- animated: animated2
3048
- };
3049
- };
3050
- const getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
3051
- function _extends() {
3052
- _extends = Object.assign || function(target) {
3053
- for (var i = 1; i < arguments.length; i++) {
3054
- var source = arguments[i];
3055
- for (var key in source) {
3056
- if (Object.prototype.hasOwnProperty.call(source, key)) {
3057
- target[key] = source[key];
3058
- }
3059
- }
3060
- }
3061
- return target;
3062
- };
3063
- return _extends.apply(this, arguments);
3064
- }
3065
- function callProp(value, ...args) {
3066
- return is.fun(value) ? value(...args) : value;
3067
- }
3068
- const matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
3069
- const resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
3070
- const getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
3071
- const noopTransform = (value) => value;
3072
- const getDefaultProps = (props, transform = noopTransform) => {
3073
- let keys = DEFAULT_PROPS;
3074
- if (props.default && props.default !== true) {
3075
- props = props.default;
3076
- keys = Object.keys(props);
3077
- }
3078
- const defaults2 = {};
3079
- for (const key of keys) {
3080
- const value = transform(props[key], key);
3081
- if (!is.und(value)) {
3082
- defaults2[key] = value;
3083
- }
3084
- }
3085
- return defaults2;
3086
- };
3087
- const DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"];
3088
- const RESERVED_PROPS = {
3089
- config: 1,
3090
- from: 1,
3091
- to: 1,
3092
- ref: 1,
3093
- loop: 1,
3094
- reset: 1,
3095
- pause: 1,
3096
- cancel: 1,
3097
- reverse: 1,
3098
- immediate: 1,
3099
- default: 1,
3100
- delay: 1,
3101
- onProps: 1,
3102
- onStart: 1,
3103
- onChange: 1,
3104
- onPause: 1,
3105
- onResume: 1,
3106
- onRest: 1,
3107
- onResolve: 1,
3108
- items: 1,
3109
- trail: 1,
3110
- sort: 1,
3111
- expires: 1,
3112
- initial: 1,
3113
- enter: 1,
3114
- update: 1,
3115
- leave: 1,
3116
- children: 1,
3117
- onDestroyed: 1,
3118
- keys: 1,
3119
- callId: 1,
3120
- parentId: 1
3121
- };
3122
- function getForwardProps(props) {
3123
- const forward = {};
3124
- let count = 0;
3125
- eachProp(props, (value, prop) => {
3126
- if (!RESERVED_PROPS[prop]) {
3127
- forward[prop] = value;
3128
- count++;
3129
- }
3130
- });
3131
- if (count) {
3132
- return forward;
3133
- }
3134
- }
3135
- function inferTo(props) {
3136
- const to2 = getForwardProps(props);
3137
- if (to2) {
3138
- const out = {
3139
- to: to2
3140
- };
3141
- eachProp(props, (val, key) => key in to2 || (out[key] = val));
3142
- return out;
3143
- }
3144
- return _extends({}, props);
3145
- }
3146
- function computeGoal(value) {
3147
- value = getFluidValue(value);
3148
- return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({
3149
- range: [0, 1],
3150
- output: [value, value]
3151
- })(1) : value;
3152
- }
3153
- function hasProps(props) {
3154
- for (const _ in props)
3155
- return true;
3156
- return false;
3157
- }
3158
- function isAsyncTo(to2) {
3159
- return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
3160
- }
3161
- function detachRefs(ctrl, ref) {
3162
- var _ctrl$ref;
3163
- (_ctrl$ref = ctrl.ref) == null ? void 0 : _ctrl$ref.delete(ctrl);
3164
- ref == null ? void 0 : ref.delete(ctrl);
3165
- }
3166
- function replaceRef(ctrl, ref) {
3167
- if (ref && ctrl.ref !== ref) {
3168
- var _ctrl$ref2;
3169
- (_ctrl$ref2 = ctrl.ref) == null ? void 0 : _ctrl$ref2.delete(ctrl);
3170
- ref.add(ctrl);
3171
- ctrl.ref = ref;
3172
- }
3173
- }
3174
- const config = {
3175
- default: {
3176
- tension: 170,
3177
- friction: 26
3178
- },
3179
- gentle: {
3180
- tension: 120,
3181
- friction: 14
3182
- },
3183
- wobbly: {
3184
- tension: 180,
3185
- friction: 12
3186
- },
3187
- stiff: {
3188
- tension: 210,
3189
- friction: 20
3190
- },
3191
- slow: {
3192
- tension: 280,
3193
- friction: 60
3194
- },
3195
- molasses: {
3196
- tension: 280,
3197
- friction: 120
3198
- }
3199
- };
3200
- const linear = (t) => t;
3201
- const defaults = _extends({}, config.default, {
3202
- mass: 1,
3203
- damping: 1,
3204
- easing: linear,
3205
- clamp: false
3206
- });
3207
- class AnimationConfig {
3208
- constructor() {
3209
- this.tension = void 0;
3210
- this.friction = void 0;
3211
- this.frequency = void 0;
3212
- this.damping = void 0;
3213
- this.mass = void 0;
3214
- this.velocity = 0;
3215
- this.restVelocity = void 0;
3216
- this.precision = void 0;
3217
- this.progress = void 0;
3218
- this.duration = void 0;
3219
- this.easing = void 0;
3220
- this.clamp = void 0;
3221
- this.bounce = void 0;
3222
- this.decay = void 0;
3223
- this.round = void 0;
3224
- Object.assign(this, defaults);
3225
- }
3226
- }
3227
- function mergeConfig(config2, newConfig, defaultConfig) {
3228
- if (defaultConfig) {
3229
- defaultConfig = _extends({}, defaultConfig);
3230
- sanitizeConfig(defaultConfig, newConfig);
3231
- newConfig = _extends({}, defaultConfig, newConfig);
3232
- }
3233
- sanitizeConfig(config2, newConfig);
3234
- Object.assign(config2, newConfig);
3235
- for (const key in defaults) {
3236
- if (config2[key] == null) {
3237
- config2[key] = defaults[key];
3238
- }
3239
- }
3240
- let {
3241
- mass,
3242
- frequency,
3243
- damping
3244
- } = config2;
3245
- if (!is.und(frequency)) {
3246
- if (frequency < 0.01)
3247
- frequency = 0.01;
3248
- if (damping < 0)
3249
- damping = 0;
3250
- config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
3251
- config2.friction = 4 * Math.PI * damping * mass / frequency;
3252
- }
3253
- return config2;
3254
- }
3255
- function sanitizeConfig(config2, props) {
3256
- if (!is.und(props.decay)) {
3257
- config2.duration = void 0;
3258
- } else {
3259
- const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
3260
- if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
3261
- config2.duration = void 0;
3262
- config2.decay = void 0;
3263
- }
3264
- if (isTensionConfig) {
3265
- config2.frequency = void 0;
3266
- }
3267
- }
3268
- }
3269
- const emptyArray = [];
3270
- class Animation {
3271
- constructor() {
3272
- this.changed = false;
3273
- this.values = emptyArray;
3274
- this.toValues = null;
3275
- this.fromValues = emptyArray;
3276
- this.to = void 0;
3277
- this.from = void 0;
3278
- this.config = new AnimationConfig();
3279
- this.immediate = false;
3280
- }
3281
- }
3282
- function scheduleProps(callId, {
3283
- key,
3284
- props,
3285
- defaultProps,
3286
- state,
3287
- actions
3288
- }) {
3289
- return new Promise((resolve, reject) => {
3290
- var _props$cancel;
3291
- let delay;
3292
- let timeout;
3293
- let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key);
3294
- if (cancel) {
3295
- onStart();
3296
- } else {
3297
- if (!is.und(props.pause)) {
3298
- state.paused = matchProp(props.pause, key);
3299
- }
3300
- let pause = defaultProps == null ? void 0 : defaultProps.pause;
3301
- if (pause !== true) {
3302
- pause = state.paused || matchProp(pause, key);
3303
- }
3304
- delay = callProp(props.delay || 0, key);
3305
- if (pause) {
3306
- state.resumeQueue.add(onResume);
3307
- actions.pause();
3308
- } else {
3309
- actions.resume();
3310
- onResume();
3311
- }
3312
- }
3313
- function onPause() {
3314
- state.resumeQueue.add(onResume);
3315
- state.timeouts.delete(timeout);
3316
- timeout.cancel();
3317
- delay = timeout.time - raf.now();
3318
- }
3319
- function onResume() {
3320
- if (delay > 0) {
3321
- timeout = raf.setTimeout(onStart, delay);
3322
- state.pauseQueue.add(onPause);
3323
- state.timeouts.add(timeout);
3324
- } else {
3325
- onStart();
3326
- }
3327
- }
3328
- function onStart() {
3329
- state.pauseQueue.delete(onPause);
3330
- state.timeouts.delete(timeout);
3331
- if (callId <= (state.cancelId || 0)) {
3332
- cancel = true;
3333
- }
3334
- try {
3335
- actions.start(_extends({}, props, {
3336
- callId,
3337
- cancel
3338
- }), resolve);
3339
- } catch (err) {
3340
- reject(err);
3341
- }
3342
- }
3343
- });
3344
- }
3345
- const getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every((result) => result.finished));
3346
- const getNoopResult = (value) => ({
3347
- value,
3348
- noop: true,
3349
- finished: true,
3350
- cancelled: false
3351
- });
3352
- const getFinishedResult = (value, finished, cancelled = false) => ({
3353
- value,
3354
- finished,
3355
- cancelled
3356
- });
3357
- const getCancelledResult = (value) => ({
3358
- value,
3359
- cancelled: true,
3360
- finished: false
3361
- });
3362
- function runAsync(to2, props, state, target) {
3363
- const {
3364
- callId,
3365
- parentId,
3366
- onRest
3367
- } = props;
3368
- const {
3369
- asyncTo: prevTo,
3370
- promise: prevPromise
3371
- } = state;
3372
- if (!parentId && to2 === prevTo && !props.reset) {
3373
- return prevPromise;
3374
- }
3375
- return state.promise = (async () => {
3376
- state.asyncId = callId;
3377
- state.asyncTo = to2;
3378
- const defaultProps = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value);
3379
- let preventBail;
3380
- let bail;
3381
- const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject));
3382
- const bailIfEnded = (bailSignal) => {
3383
- const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false);
3384
- if (bailResult) {
3385
- bailSignal.result = bailResult;
3386
- bail(bailSignal);
3387
- throw bailSignal;
3388
- }
3389
- };
3390
- const animate = (arg1, arg2) => {
3391
- const bailSignal = new BailSignal();
3392
- const skipAnimationSignal = new SkipAniamtionSignal();
3393
- return (async () => {
3394
- if (globals.skipAnimation) {
3395
- stopAsync(state);
3396
- skipAnimationSignal.result = getFinishedResult(target, false);
3397
- bail(skipAnimationSignal);
3398
- throw skipAnimationSignal;
3399
- }
3400
- bailIfEnded(bailSignal);
3401
- const props2 = is.obj(arg1) ? _extends({}, arg1) : _extends({}, arg2, {
3402
- to: arg1
3403
- });
3404
- props2.parentId = callId;
3405
- eachProp(defaultProps, (value, key) => {
3406
- if (is.und(props2[key])) {
3407
- props2[key] = value;
3408
- }
3409
- });
3410
- const result2 = await target.start(props2);
3411
- bailIfEnded(bailSignal);
3412
- if (state.paused) {
3413
- await new Promise((resume) => {
3414
- state.resumeQueue.add(resume);
3415
- });
3416
- }
3417
- return result2;
3418
- })();
3419
- };
3420
- let result;
3421
- if (globals.skipAnimation) {
3422
- stopAsync(state);
3423
- return getFinishedResult(target, false);
3424
- }
3425
- try {
3426
- let animating;
3427
- if (is.arr(to2)) {
3428
- animating = (async (queue) => {
3429
- for (const props2 of queue) {
3430
- await animate(props2);
3431
- }
3432
- })(to2);
3433
- } else {
3434
- animating = Promise.resolve(to2(animate, target.stop.bind(target)));
3435
- }
3436
- await Promise.all([animating.then(preventBail), bailPromise]);
3437
- result = getFinishedResult(target.get(), true, false);
3438
- } catch (err) {
3439
- if (err instanceof BailSignal) {
3440
- result = err.result;
3441
- } else if (err instanceof SkipAniamtionSignal) {
3442
- result = err.result;
3443
- } else {
3444
- throw err;
3445
- }
3446
- } finally {
3447
- if (callId == state.asyncId) {
3448
- state.asyncId = parentId;
3449
- state.asyncTo = parentId ? prevTo : void 0;
3450
- state.promise = parentId ? prevPromise : void 0;
3451
- }
3452
- }
3453
- if (is.fun(onRest)) {
3454
- raf.batchedUpdates(() => {
3455
- onRest(result, target, target.item);
3456
- });
3457
- }
3458
- return result;
3459
- })();
3460
- }
3461
- function stopAsync(state, cancelId) {
3462
- flush(state.timeouts, (t) => t.cancel());
3463
- state.pauseQueue.clear();
3464
- state.resumeQueue.clear();
3465
- state.asyncId = state.asyncTo = state.promise = void 0;
3466
- if (cancelId)
3467
- state.cancelId = cancelId;
3468
- }
3469
- class BailSignal extends Error {
3470
- constructor() {
3471
- super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");
3472
- this.result = void 0;
3473
- }
3474
- }
3475
- class SkipAniamtionSignal extends Error {
3476
- constructor() {
3477
- super("SkipAnimationSignal");
3478
- this.result = void 0;
3479
- }
3480
- }
3481
- const isFrameValue = (value) => value instanceof FrameValue;
3482
- let nextId$1 = 1;
3483
- class FrameValue extends FluidValue {
3484
- constructor(...args) {
3485
- super(...args);
3486
- this.id = nextId$1++;
3487
- this.key = void 0;
3488
- this._priority = 0;
3489
- }
3490
- get priority() {
3491
- return this._priority;
3492
- }
3493
- set priority(priority2) {
3494
- if (this._priority != priority2) {
3495
- this._priority = priority2;
3496
- this._onPriorityChange(priority2);
3497
- }
3498
- }
3499
- get() {
3500
- const node = getAnimated(this);
3501
- return node && node.getValue();
3502
- }
3503
- to(...args) {
3504
- return globals.to(this, args);
3505
- }
3506
- interpolate(...args) {
3507
- deprecateInterpolate();
3508
- return globals.to(this, args);
3509
- }
3510
- toJSON() {
3511
- return this.get();
3512
- }
3513
- observerAdded(count) {
3514
- if (count == 1)
3515
- this._attach();
3516
- }
3517
- observerRemoved(count) {
3518
- if (count == 0)
3519
- this._detach();
3520
- }
3521
- _attach() {
3522
- }
3523
- _detach() {
3524
- }
3525
- _onChange(value, idle = false) {
3526
- callFluidObservers(this, {
3527
- type: "change",
3528
- parent: this,
3529
- value,
3530
- idle
3531
- });
3532
- }
3533
- _onPriorityChange(priority2) {
3534
- if (!this.idle) {
3535
- frameLoop.sort(this);
3536
- }
3537
- callFluidObservers(this, {
3538
- type: "priority",
3539
- parent: this,
3540
- priority: priority2
3541
- });
3542
- }
3543
- }
3544
- const $P = Symbol.for("SpringPhase");
3545
- const HAS_ANIMATED = 1;
3546
- const IS_ANIMATING = 2;
3547
- const IS_PAUSED = 4;
3548
- const hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
3549
- const isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
3550
- const isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
3551
- const setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
3552
- const setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
3553
- class SpringValue extends FrameValue {
3554
- constructor(arg1, arg2) {
3555
- super();
3556
- this.key = void 0;
3557
- this.animation = new Animation();
3558
- this.queue = void 0;
3559
- this.defaultProps = {};
3560
- this._state = {
3561
- paused: false,
3562
- pauseQueue: new Set(),
3563
- resumeQueue: new Set(),
3564
- timeouts: new Set()
3565
- };
3566
- this._pendingCalls = new Set();
3567
- this._lastCallId = 0;
3568
- this._lastToId = 0;
3569
- this._memoizedDuration = 0;
3570
- if (!is.und(arg1) || !is.und(arg2)) {
3571
- const props = is.obj(arg1) ? _extends({}, arg1) : _extends({}, arg2, {
3572
- from: arg1
3573
- });
3574
- if (is.und(props.default)) {
3575
- props.default = true;
3576
- }
3577
- this.start(props);
3578
- }
3579
- }
3580
- get idle() {
3581
- return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
3582
- }
3583
- get goal() {
3584
- return getFluidValue(this.animation.to);
3585
- }
3586
- get velocity() {
3587
- const node = getAnimated(this);
3588
- return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
3589
- }
3590
- get hasAnimated() {
3591
- return hasAnimated(this);
3592
- }
3593
- get isAnimating() {
3594
- return isAnimating(this);
3595
- }
3596
- get isPaused() {
3597
- return isPaused(this);
3598
- }
3599
- advance(dt) {
3600
- let idle = true;
3601
- let changed = false;
3602
- const anim = this.animation;
3603
- let {
3604
- config: config2,
3605
- toValues
3606
- } = anim;
3607
- const payload = getPayload(anim.to);
3608
- if (!payload && hasFluidValue(anim.to)) {
3609
- toValues = toArray(getFluidValue(anim.to));
3610
- }
3611
- anim.values.forEach((node2, i) => {
3612
- if (node2.done)
3613
- return;
3614
- const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i];
3615
- let finished = anim.immediate;
3616
- let position = to2;
3617
- if (!finished) {
3618
- position = node2.lastPosition;
3619
- if (config2.tension <= 0) {
3620
- node2.done = true;
3621
- return;
3622
- }
3623
- let elapsed = node2.elapsedTime += dt;
3624
- const from = anim.fromValues[i];
3625
- const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i] : config2.velocity;
3626
- let velocity;
3627
- if (!is.und(config2.duration)) {
3628
- let p = 1;
3629
- if (config2.duration > 0) {
3630
- if (this._memoizedDuration !== config2.duration) {
3631
- this._memoizedDuration = config2.duration;
3632
- if (node2.durationProgress > 0) {
3633
- node2.elapsedTime = config2.duration * node2.durationProgress;
3634
- elapsed = node2.elapsedTime += dt;
3635
- }
3636
- }
3637
- p = (config2.progress || 0) + elapsed / this._memoizedDuration;
3638
- p = p > 1 ? 1 : p < 0 ? 0 : p;
3639
- node2.durationProgress = p;
3640
- }
3641
- position = from + config2.easing(p) * (to2 - from);
3642
- velocity = (position - node2.lastPosition) / dt;
3643
- finished = p == 1;
3644
- } else if (config2.decay) {
3645
- const decay = config2.decay === true ? 0.998 : config2.decay;
3646
- const e = Math.exp(-(1 - decay) * elapsed);
3647
- position = from + v0 / (1 - decay) * (1 - e);
3648
- finished = Math.abs(node2.lastPosition - position) < 0.1;
3649
- velocity = v0 * e;
3650
- } else {
3651
- velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
3652
- const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
3653
- const restVelocity = config2.restVelocity || precision / 10;
3654
- const bounceFactor = config2.clamp ? 0 : config2.bounce;
3655
- const canBounce = !is.und(bounceFactor);
3656
- const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
3657
- let isMoving;
3658
- let isBouncing = false;
3659
- const step = 1;
3660
- const numSteps = Math.ceil(dt / step);
3661
- for (let n = 0; n < numSteps; ++n) {
3662
- isMoving = Math.abs(velocity) > restVelocity;
3663
- if (!isMoving) {
3664
- finished = Math.abs(to2 - position) <= precision;
3665
- if (finished) {
3666
- break;
3667
- }
3668
- }
3669
- if (canBounce) {
3670
- isBouncing = position == to2 || position > to2 == isGrowing;
3671
- if (isBouncing) {
3672
- velocity = -velocity * bounceFactor;
3673
- position = to2;
3674
- }
3675
- }
3676
- const springForce = -config2.tension * 1e-6 * (position - to2);
3677
- const dampingForce = -config2.friction * 1e-3 * velocity;
3678
- const acceleration = (springForce + dampingForce) / config2.mass;
3679
- velocity = velocity + acceleration * step;
3680
- position = position + velocity * step;
3681
- }
3682
- }
3683
- node2.lastVelocity = velocity;
3684
- if (Number.isNaN(position)) {
3685
- console.warn(`Got NaN while animating:`, this);
3686
- finished = true;
3687
- }
3688
- }
3689
- if (payload && !payload[i].done) {
3690
- finished = false;
3691
- }
3692
- if (finished) {
3693
- node2.done = true;
3694
- } else {
3695
- idle = false;
3696
- }
3697
- if (node2.setValue(position, config2.round)) {
3698
- changed = true;
3699
- }
3700
- });
3701
- const node = getAnimated(this);
3702
- const currVal = node.getValue();
3703
- if (idle) {
3704
- const finalVal = getFluidValue(anim.to);
3705
- if ((currVal !== finalVal || changed) && !config2.decay) {
3706
- node.setValue(finalVal);
3707
- this._onChange(finalVal);
3708
- } else if (changed && config2.decay) {
3709
- this._onChange(currVal);
3710
- }
3711
- this._stop();
3712
- } else if (changed) {
3713
- this._onChange(currVal);
3714
- }
3715
- }
3716
- set(value) {
3717
- raf.batchedUpdates(() => {
3718
- this._stop();
3719
- this._focus(value);
3720
- this._set(value);
3721
- });
3722
- return this;
3723
- }
3724
- pause() {
3725
- this._update({
3726
- pause: true
3727
- });
3728
- }
3729
- resume() {
3730
- this._update({
3731
- pause: false
3732
- });
3733
- }
3734
- finish() {
3735
- if (isAnimating(this)) {
3736
- const {
3737
- to: to2,
3738
- config: config2
3739
- } = this.animation;
3740
- raf.batchedUpdates(() => {
3741
- this._onStart();
3742
- if (!config2.decay) {
3743
- this._set(to2, false);
3744
- }
3745
- this._stop();
3746
- });
3747
- }
3748
- return this;
3749
- }
3750
- update(props) {
3751
- const queue = this.queue || (this.queue = []);
3752
- queue.push(props);
3753
- return this;
3754
- }
3755
- start(to2, arg2) {
3756
- let queue;
3757
- if (!is.und(to2)) {
3758
- queue = [is.obj(to2) ? to2 : _extends({}, arg2, {
3759
- to: to2
3760
- })];
3761
- } else {
3762
- queue = this.queue || [];
3763
- this.queue = [];
3764
- }
3765
- return Promise.all(queue.map((props) => this._update(props))).then((results) => getCombinedResult(this, results));
3766
- }
3767
- stop(cancel) {
3768
- const {
3769
- to: to2
3770
- } = this.animation;
3771
- this._focus(this.get());
3772
- stopAsync(this._state, cancel && this._lastCallId);
3773
- raf.batchedUpdates(() => this._stop(to2, cancel));
3774
- return this;
3775
- }
3776
- reset() {
3777
- this._update({
3778
- reset: true
3779
- });
3780
- }
3781
- eventObserved(event) {
3782
- if (event.type == "change") {
3783
- this._start();
3784
- } else if (event.type == "priority") {
3785
- this.priority = event.priority + 1;
3786
- }
3787
- }
3788
- _prepareNode(props) {
3789
- const key = this.key || "";
3790
- let {
3791
- to: to2,
3792
- from
3793
- } = props;
3794
- to2 = is.obj(to2) ? to2[key] : to2;
3795
- if (to2 == null || isAsyncTo(to2)) {
3796
- to2 = void 0;
3797
- }
3798
- from = is.obj(from) ? from[key] : from;
3799
- if (from == null) {
3800
- from = void 0;
3801
- }
3802
- const range = {
3803
- to: to2,
3804
- from
3805
- };
3806
- if (!hasAnimated(this)) {
3807
- if (props.reverse)
3808
- [to2, from] = [from, to2];
3809
- from = getFluidValue(from);
3810
- if (!is.und(from)) {
3811
- this._set(from);
3812
- } else if (!getAnimated(this)) {
3813
- this._set(to2);
3814
- }
3815
- }
3816
- return range;
3817
- }
3818
- _update(_ref, isLoop) {
3819
- let props = _extends({}, _ref);
3820
- const {
3821
- key,
3822
- defaultProps
3823
- } = this;
3824
- if (props.default)
3825
- Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value));
3826
- mergeActiveFn(this, props, "onProps");
3827
- sendEvent(this, "onProps", props, this);
3828
- const range = this._prepareNode(props);
3829
- if (Object.isFrozen(this)) {
3830
- throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");
3831
- }
3832
- const state = this._state;
3833
- return scheduleProps(++this._lastCallId, {
3834
- key,
3835
- props,
3836
- defaultProps,
3837
- state,
3838
- actions: {
3839
- pause: () => {
3840
- if (!isPaused(this)) {
3841
- setPausedBit(this, true);
3842
- flushCalls(state.pauseQueue);
3843
- sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
3844
- }
3845
- },
3846
- resume: () => {
3847
- if (isPaused(this)) {
3848
- setPausedBit(this, false);
3849
- if (isAnimating(this)) {
3850
- this._resume();
3851
- }
3852
- flushCalls(state.resumeQueue);
3853
- sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this);
3854
- }
3855
- },
3856
- start: this._merge.bind(this, range)
3857
- }
3858
- }).then((result) => {
3859
- if (props.loop && result.finished && !(isLoop && result.noop)) {
3860
- const nextProps = createLoopUpdate(props);
3861
- if (nextProps) {
3862
- return this._update(nextProps, true);
3863
- }
3864
- }
3865
- return result;
3866
- });
3867
- }
3868
- _merge(range, props, resolve) {
3869
- if (props.cancel) {
3870
- this.stop(true);
3871
- return resolve(getCancelledResult(this));
3872
- }
3873
- const hasToProp = !is.und(range.to);
3874
- const hasFromProp = !is.und(range.from);
3875
- if (hasToProp || hasFromProp) {
3876
- if (props.callId > this._lastToId) {
3877
- this._lastToId = props.callId;
3878
- } else {
3879
- return resolve(getCancelledResult(this));
3880
- }
3881
- }
3882
- const {
3883
- key,
3884
- defaultProps,
3885
- animation: anim
3886
- } = this;
3887
- const {
3888
- to: prevTo,
3889
- from: prevFrom
3890
- } = anim;
3891
- let {
3892
- to: to2 = prevTo,
3893
- from = prevFrom
3894
- } = range;
3895
- if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
3896
- to2 = from;
3897
- }
3898
- if (props.reverse)
3899
- [to2, from] = [from, to2];
3900
- const hasFromChanged = !isEqual(from, prevFrom);
3901
- if (hasFromChanged) {
3902
- anim.from = from;
3903
- }
3904
- from = getFluidValue(from);
3905
- const hasToChanged = !isEqual(to2, prevTo);
3906
- if (hasToChanged) {
3907
- this._focus(to2);
3908
- }
3909
- const hasAsyncTo = isAsyncTo(props.to);
3910
- const {
3911
- config: config2
3912
- } = anim;
3913
- const {
3914
- decay,
3915
- velocity
3916
- } = config2;
3917
- if (hasToProp || hasFromProp) {
3918
- config2.velocity = 0;
3919
- }
3920
- if (props.config && !hasAsyncTo) {
3921
- mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0);
3922
- }
3923
- let node = getAnimated(this);
3924
- if (!node || is.und(to2)) {
3925
- return resolve(getFinishedResult(this, true));
3926
- }
3927
- const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key);
3928
- const value = reset ? from : this.get();
3929
- const goal = computeGoal(to2);
3930
- const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
3931
- const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
3932
- if (hasToChanged) {
3933
- const nodeType = getAnimatedType(to2);
3934
- if (nodeType !== node.constructor) {
3935
- if (immediate) {
3936
- node = this._set(goal);
3937
- } else
3938
- throw Error(`Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`);
3939
- }
3940
- }
3941
- const goalType = node.constructor;
3942
- let started = hasFluidValue(to2);
3943
- let finished = false;
3944
- if (!started) {
3945
- const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
3946
- if (hasToChanged || hasValueChanged) {
3947
- finished = isEqual(computeGoal(value), goal);
3948
- started = !finished;
3949
- }
3950
- if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
3951
- started = true;
3952
- }
3953
- }
3954
- if (finished && isAnimating(this)) {
3955
- if (anim.changed && !reset) {
3956
- started = true;
3957
- } else if (!started) {
3958
- this._stop(prevTo);
3959
- }
3960
- }
3961
- if (!hasAsyncTo) {
3962
- if (started || hasFluidValue(prevTo)) {
3963
- anim.values = node.getPayload();
3964
- anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
3965
- }
3966
- if (anim.immediate != immediate) {
3967
- anim.immediate = immediate;
3968
- if (!immediate && !reset) {
3969
- this._set(prevTo);
3970
- }
3971
- }
3972
- if (started) {
3973
- const {
3974
- onRest
3975
- } = anim;
3976
- each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
3977
- const result = getFinishedResult(this, checkFinished(this, prevTo));
3978
- flushCalls(this._pendingCalls, result);
3979
- this._pendingCalls.add(resolve);
3980
- if (anim.changed)
3981
- raf.batchedUpdates(() => {
3982
- anim.changed = !reset;
3983
- onRest == null ? void 0 : onRest(result, this);
3984
- if (reset) {
3985
- callProp(defaultProps.onRest, result);
3986
- } else {
3987
- anim.onStart == null ? void 0 : anim.onStart(result, this);
3988
- }
3989
- });
3990
- }
3991
- }
3992
- if (reset) {
3993
- this._set(value);
3994
- }
3995
- if (hasAsyncTo) {
3996
- resolve(runAsync(props.to, props, this._state, this));
3997
- } else if (started) {
3998
- this._start();
3999
- } else if (isAnimating(this) && !hasToChanged) {
4000
- this._pendingCalls.add(resolve);
4001
- } else {
4002
- resolve(getNoopResult(value));
4003
- }
4004
- }
4005
- _focus(value) {
4006
- const anim = this.animation;
4007
- if (value !== anim.to) {
4008
- if (getFluidObservers(this)) {
4009
- this._detach();
4010
- }
4011
- anim.to = value;
4012
- if (getFluidObservers(this)) {
4013
- this._attach();
4014
- }
4015
- }
4016
- }
4017
- _attach() {
4018
- let priority2 = 0;
4019
- const {
4020
- to: to2
4021
- } = this.animation;
4022
- if (hasFluidValue(to2)) {
4023
- addFluidObserver(to2, this);
4024
- if (isFrameValue(to2)) {
4025
- priority2 = to2.priority + 1;
4026
- }
4027
- }
4028
- this.priority = priority2;
4029
- }
4030
- _detach() {
4031
- const {
4032
- to: to2
4033
- } = this.animation;
4034
- if (hasFluidValue(to2)) {
4035
- removeFluidObserver(to2, this);
4036
- }
4037
- }
4038
- _set(arg, idle = true) {
4039
- const value = getFluidValue(arg);
4040
- if (!is.und(value)) {
4041
- const oldNode = getAnimated(this);
4042
- if (!oldNode || !isEqual(value, oldNode.getValue())) {
4043
- const nodeType = getAnimatedType(value);
4044
- if (!oldNode || oldNode.constructor != nodeType) {
4045
- setAnimated(this, nodeType.create(value));
4046
- } else {
4047
- oldNode.setValue(value);
4048
- }
4049
- if (oldNode) {
4050
- raf.batchedUpdates(() => {
4051
- this._onChange(value, idle);
4052
- });
4053
- }
4054
- }
4055
- }
4056
- return getAnimated(this);
4057
- }
4058
- _onStart() {
4059
- const anim = this.animation;
4060
- if (!anim.changed) {
4061
- anim.changed = true;
4062
- sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this);
4063
- }
4064
- }
4065
- _onChange(value, idle) {
4066
- if (!idle) {
4067
- this._onStart();
4068
- callProp(this.animation.onChange, value, this);
4069
- }
4070
- callProp(this.defaultProps.onChange, value, this);
4071
- super._onChange(value, idle);
4072
- }
4073
- _start() {
4074
- const anim = this.animation;
4075
- getAnimated(this).reset(getFluidValue(anim.to));
4076
- if (!anim.immediate) {
4077
- anim.fromValues = anim.values.map((node) => node.lastPosition);
4078
- }
4079
- if (!isAnimating(this)) {
4080
- setActiveBit(this, true);
4081
- if (!isPaused(this)) {
4082
- this._resume();
4083
- }
4084
- }
4085
- }
4086
- _resume() {
4087
- if (globals.skipAnimation) {
4088
- this.finish();
4089
- } else {
4090
- frameLoop.start(this);
4091
- }
4092
- }
4093
- _stop(goal, cancel) {
4094
- if (isAnimating(this)) {
4095
- setActiveBit(this, false);
4096
- const anim = this.animation;
4097
- each(anim.values, (node) => {
4098
- node.done = true;
4099
- });
4100
- if (anim.toValues) {
4101
- anim.onChange = anim.onPause = anim.onResume = void 0;
4102
- }
4103
- callFluidObservers(this, {
4104
- type: "idle",
4105
- parent: this
4106
- });
4107
- const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to));
4108
- flushCalls(this._pendingCalls, result);
4109
- if (anim.changed) {
4110
- anim.changed = false;
4111
- sendEvent(this, "onRest", result, this);
4112
- }
4113
- }
4114
- }
4115
- }
4116
- function checkFinished(target, to2) {
4117
- const goal = computeGoal(to2);
4118
- const value = computeGoal(target.get());
4119
- return isEqual(value, goal);
4120
- }
4121
- function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) {
4122
- let loopRet = callProp(loop2);
4123
- if (loopRet) {
4124
- const overrides = loopRet !== true && inferTo(loopRet);
4125
- const reverse = (overrides || props).reverse;
4126
- const reset = !overrides || overrides.reset;
4127
- return createUpdate(_extends({}, props, {
4128
- loop: loop2,
4129
- default: false,
4130
- pause: void 0,
4131
- to: !reverse || isAsyncTo(to2) ? to2 : void 0,
4132
- from: reset ? props.from : void 0,
4133
- reset
4134
- }, overrides));
4135
- }
4136
- }
4137
- function createUpdate(props) {
4138
- const {
4139
- to: to2,
4140
- from
4141
- } = props = inferTo(props);
4142
- const keys = new Set();
4143
- if (is.obj(to2))
4144
- findDefined(to2, keys);
4145
- if (is.obj(from))
4146
- findDefined(from, keys);
4147
- props.keys = keys.size ? Array.from(keys) : null;
4148
- return props;
4149
- }
4150
- function declareUpdate(props) {
4151
- const update2 = createUpdate(props);
4152
- if (is.und(update2.default)) {
4153
- update2.default = getDefaultProps(update2);
4154
- }
4155
- return update2;
4156
- }
4157
- function findDefined(values, keys) {
4158
- eachProp(values, (value, key) => value != null && keys.add(key));
4159
- }
4160
- const ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"];
4161
- function mergeActiveFn(target, props, type) {
4162
- target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
4163
- }
4164
- function sendEvent(target, type, ...args) {
4165
- var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps;
4166
- (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args);
4167
- (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args);
4168
- }
4169
- const BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
4170
- let nextId = 1;
4171
- class Controller {
4172
- constructor(props, flush2) {
4173
- this.id = nextId++;
4174
- this.springs = {};
4175
- this.queue = [];
4176
- this.ref = void 0;
4177
- this._flush = void 0;
4178
- this._initialProps = void 0;
4179
- this._lastAsyncId = 0;
4180
- this._active = new Set();
4181
- this._changed = new Set();
4182
- this._started = false;
4183
- this._item = void 0;
4184
- this._state = {
4185
- paused: false,
4186
- pauseQueue: new Set(),
4187
- resumeQueue: new Set(),
4188
- timeouts: new Set()
4189
- };
4190
- this._events = {
4191
- onStart: new Map(),
4192
- onChange: new Map(),
4193
- onRest: new Map()
4194
- };
4195
- this._onFrame = this._onFrame.bind(this);
4196
- if (flush2) {
4197
- this._flush = flush2;
4198
- }
4199
- if (props) {
4200
- this.start(_extends({
4201
- default: true
4202
- }, props));
4203
- }
4204
- }
4205
- get idle() {
4206
- return !this._state.asyncTo && Object.values(this.springs).every((spring) => spring.idle);
4207
- }
4208
- get item() {
4209
- return this._item;
4210
- }
4211
- set item(item) {
4212
- this._item = item;
4213
- }
4214
- get() {
4215
- const values = {};
4216
- this.each((spring, key) => values[key] = spring.get());
4217
- return values;
4218
- }
4219
- set(values) {
4220
- for (const key in values) {
4221
- const value = values[key];
4222
- if (!is.und(value)) {
4223
- this.springs[key].set(value);
4224
- }
4225
- }
4226
- }
4227
- update(props) {
4228
- if (props) {
4229
- this.queue.push(createUpdate(props));
4230
- }
4231
- return this;
4232
- }
4233
- start(props) {
4234
- let {
4235
- queue
4236
- } = this;
4237
- if (props) {
4238
- queue = toArray(props).map(createUpdate);
4239
- } else {
4240
- this.queue = [];
4241
- }
4242
- if (this._flush) {
4243
- return this._flush(this, queue);
4244
- }
4245
- prepareKeys(this, queue);
4246
- return flushUpdateQueue(this, queue);
4247
- }
4248
- stop(arg, keys) {
4249
- if (arg !== !!arg) {
4250
- keys = arg;
4251
- }
4252
- if (keys) {
4253
- const springs = this.springs;
4254
- each(toArray(keys), (key) => springs[key].stop(!!arg));
4255
- } else {
4256
- stopAsync(this._state, this._lastAsyncId);
4257
- this.each((spring) => spring.stop(!!arg));
4258
- }
4259
- return this;
4260
- }
4261
- pause(keys) {
4262
- if (is.und(keys)) {
4263
- this.start({
4264
- pause: true
4265
- });
4266
- } else {
4267
- const springs = this.springs;
4268
- each(toArray(keys), (key) => springs[key].pause());
4269
- }
4270
- return this;
4271
- }
4272
- resume(keys) {
4273
- if (is.und(keys)) {
4274
- this.start({
4275
- pause: false
4276
- });
4277
- } else {
4278
- const springs = this.springs;
4279
- each(toArray(keys), (key) => springs[key].resume());
4280
- }
4281
- return this;
4282
- }
4283
- each(iterator) {
4284
- eachProp(this.springs, iterator);
4285
- }
4286
- _onFrame() {
4287
- const {
4288
- onStart,
4289
- onChange,
4290
- onRest
4291
- } = this._events;
4292
- const active = this._active.size > 0;
4293
- const changed = this._changed.size > 0;
4294
- if (active && !this._started || changed && !this._started) {
4295
- this._started = true;
4296
- flush(onStart, ([onStart2, result]) => {
4297
- result.value = this.get();
4298
- onStart2(result, this, this._item);
4299
- });
4300
- }
4301
- const idle = !active && this._started;
4302
- const values = changed || idle && onRest.size ? this.get() : null;
4303
- if (changed && onChange.size) {
4304
- flush(onChange, ([onChange2, result]) => {
4305
- result.value = values;
4306
- onChange2(result, this, this._item);
4307
- });
4308
- }
4309
- if (idle) {
4310
- this._started = false;
4311
- flush(onRest, ([onRest2, result]) => {
4312
- result.value = values;
4313
- onRest2(result, this, this._item);
4314
- });
4315
- }
4316
- }
4317
- eventObserved(event) {
4318
- if (event.type == "change") {
4319
- this._changed.add(event.parent);
4320
- if (!event.idle) {
4321
- this._active.add(event.parent);
4322
- }
4323
- } else if (event.type == "idle") {
4324
- this._active.delete(event.parent);
4325
- } else
4326
- return;
4327
- raf.onFrame(this._onFrame);
4328
- }
4329
- }
4330
- function flushUpdateQueue(ctrl, queue) {
4331
- return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results));
4332
- }
4333
- async function flushUpdate(ctrl, props, isLoop) {
4334
- const {
4335
- keys,
4336
- to: to2,
4337
- from,
4338
- loop: loop2,
4339
- onRest,
4340
- onResolve
4341
- } = props;
4342
- const defaults2 = is.obj(props.default) && props.default;
4343
- if (loop2) {
4344
- props.loop = false;
4345
- }
4346
- if (to2 === false)
4347
- props.to = null;
4348
- if (from === false)
4349
- props.from = null;
4350
- const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
4351
- if (asyncTo) {
4352
- props.to = void 0;
4353
- props.onRest = void 0;
4354
- if (defaults2) {
4355
- defaults2.onRest = void 0;
4356
- }
4357
- } else {
4358
- each(BATCHED_EVENTS, (key) => {
4359
- const handler = props[key];
4360
- if (is.fun(handler)) {
4361
- const queue = ctrl["_events"][key];
4362
- props[key] = ({
4363
- finished,
4364
- cancelled
4365
- }) => {
4366
- const result2 = queue.get(handler);
4367
- if (result2) {
4368
- if (!finished)
4369
- result2.finished = false;
4370
- if (cancelled)
4371
- result2.cancelled = true;
4372
- } else {
4373
- queue.set(handler, {
4374
- value: null,
4375
- finished: finished || false,
4376
- cancelled: cancelled || false
4377
- });
4378
- }
4379
- };
4380
- if (defaults2) {
4381
- defaults2[key] = props[key];
4382
- }
4383
- }
4384
- });
4385
- }
4386
- const state = ctrl["_state"];
4387
- if (props.pause === !state.paused) {
4388
- state.paused = props.pause;
4389
- flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
4390
- } else if (state.paused) {
4391
- props.pause = true;
4392
- }
4393
- const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props));
4394
- const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
4395
- if (asyncTo || cancel && state.asyncId) {
4396
- promises.push(scheduleProps(++ctrl["_lastAsyncId"], {
4397
- props,
4398
- state,
4399
- actions: {
4400
- pause: noop,
4401
- resume: noop,
4402
- start(props2, resolve) {
4403
- if (cancel) {
4404
- stopAsync(state, ctrl["_lastAsyncId"]);
4405
- resolve(getCancelledResult(ctrl));
4406
- } else {
4407
- props2.onRest = onRest;
4408
- resolve(runAsync(asyncTo, props2, state, ctrl));
4409
- }
4410
- }
4411
- }
4412
- }));
4413
- }
4414
- if (state.paused) {
4415
- await new Promise((resume) => {
4416
- state.resumeQueue.add(resume);
4417
- });
4418
- }
4419
- const result = getCombinedResult(ctrl, await Promise.all(promises));
4420
- if (loop2 && result.finished && !(isLoop && result.noop)) {
4421
- const nextProps = createLoopUpdate(props, loop2, to2);
4422
- if (nextProps) {
4423
- prepareKeys(ctrl, [nextProps]);
4424
- return flushUpdate(ctrl, nextProps, true);
4425
- }
4426
- }
4427
- if (onResolve) {
4428
- raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
4429
- }
4430
- return result;
4431
- }
4432
- function getSprings(ctrl, props) {
4433
- const springs = _extends({}, ctrl.springs);
4434
- if (props) {
4435
- each(toArray(props), (props2) => {
4436
- if (is.und(props2.keys)) {
4437
- props2 = createUpdate(props2);
4438
- }
4439
- if (!is.obj(props2.to)) {
4440
- props2 = _extends({}, props2, {
4441
- to: void 0
4442
- });
4443
- }
4444
- prepareSprings(springs, props2, (key) => {
4445
- return createSpring(key);
4446
- });
4447
- });
4448
- }
4449
- setSprings(ctrl, springs);
4450
- return springs;
4451
- }
4452
- function setSprings(ctrl, springs) {
4453
- eachProp(springs, (spring, key) => {
4454
- if (!ctrl.springs[key]) {
4455
- ctrl.springs[key] = spring;
4456
- addFluidObserver(spring, ctrl);
4457
- }
4458
- });
4459
- }
4460
- function createSpring(key, observer) {
4461
- const spring = new SpringValue();
4462
- spring.key = key;
4463
- if (observer) {
4464
- addFluidObserver(spring, observer);
4465
- }
4466
- return spring;
4467
- }
4468
- function prepareSprings(springs, props, create) {
4469
- if (props.keys) {
4470
- each(props.keys, (key) => {
4471
- const spring = springs[key] || (springs[key] = create(key));
4472
- spring["_prepareNode"](props);
4473
- });
4474
- }
4475
- }
4476
- function prepareKeys(ctrl, queue) {
4477
- each(queue, (props) => {
4478
- prepareSprings(ctrl.springs, props, (key) => {
4479
- return createSpring(key, ctrl);
4480
- });
4481
- });
4482
- }
4483
- function _objectWithoutPropertiesLoose$1(source, excluded) {
4484
- if (source == null)
4485
- return {};
4486
- var target = {};
4487
- var sourceKeys = Object.keys(source);
4488
- var key, i;
4489
- for (i = 0; i < sourceKeys.length; i++) {
4490
- key = sourceKeys[i];
4491
- if (excluded.indexOf(key) >= 0)
4492
- continue;
4493
- target[key] = source[key];
4494
- }
4495
- return target;
4496
- }
4497
- const _excluded$3 = ["children"];
4498
- const SpringContext = (_ref) => {
4499
- let {
4500
- children
4501
- } = _ref, props = _objectWithoutPropertiesLoose$1(_ref, _excluded$3);
4502
- const inherited = useContext(ctx);
4503
- const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
4504
- props = useMemoOne(() => ({
4505
- pause,
4506
- immediate
4507
- }), [pause, immediate]);
4508
- const {
4509
- Provider
4510
- } = ctx;
4511
- return React.createElement(Provider, {
4512
- value: props
4513
- }, children);
4514
- };
4515
- const ctx = makeContext(SpringContext, {});
4516
- SpringContext.Provider = ctx.Provider;
4517
- SpringContext.Consumer = ctx.Consumer;
4518
- function makeContext(target, init) {
4519
- Object.assign(target, React.createContext(init));
4520
- target.Provider._context = target;
4521
- target.Consumer._context = target;
4522
- return target;
4523
- }
4524
- const SpringRef = () => {
4525
- const current = [];
4526
- const SpringRef2 = function SpringRef3(props) {
4527
- deprecateDirectCall();
4528
- const results = [];
4529
- each(current, (ctrl, i) => {
4530
- if (is.und(props)) {
4531
- results.push(ctrl.start());
4532
- } else {
4533
- const update2 = _getProps(props, ctrl, i);
4534
- if (update2) {
4535
- results.push(ctrl.start(update2));
4536
- }
4537
- }
4538
- });
4539
- return results;
4540
- };
4541
- SpringRef2.current = current;
4542
- SpringRef2.add = function(ctrl) {
4543
- if (!current.includes(ctrl)) {
4544
- current.push(ctrl);
4545
- }
4546
- };
4547
- SpringRef2.delete = function(ctrl) {
4548
- const i = current.indexOf(ctrl);
4549
- if (~i)
4550
- current.splice(i, 1);
4551
- };
4552
- SpringRef2.pause = function() {
4553
- each(current, (ctrl) => ctrl.pause(...arguments));
4554
- return this;
4555
- };
4556
- SpringRef2.resume = function() {
4557
- each(current, (ctrl) => ctrl.resume(...arguments));
4558
- return this;
4559
- };
4560
- SpringRef2.set = function(values) {
4561
- each(current, (ctrl) => ctrl.set(values));
4562
- };
4563
- SpringRef2.start = function(props) {
4564
- const results = [];
4565
- each(current, (ctrl, i) => {
4566
- if (is.und(props)) {
4567
- results.push(ctrl.start());
4568
- } else {
4569
- const update2 = this._getProps(props, ctrl, i);
4570
- if (update2) {
4571
- results.push(ctrl.start(update2));
4572
- }
4573
- }
4574
- });
4575
- return results;
4576
- };
4577
- SpringRef2.stop = function() {
4578
- each(current, (ctrl) => ctrl.stop(...arguments));
4579
- return this;
4580
- };
4581
- SpringRef2.update = function(props) {
4582
- each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i)));
4583
- return this;
4584
- };
4585
- const _getProps = function _getProps2(arg, ctrl, index2) {
4586
- return is.fun(arg) ? arg(index2, ctrl) : arg;
4587
- };
4588
- SpringRef2._getProps = _getProps;
4589
- return SpringRef2;
4590
- };
4591
- function useSprings(length, props, deps) {
4592
- const propsFn = is.fun(props) && props;
4593
- if (propsFn && !deps)
4594
- deps = [];
4595
- const ref = useMemo(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
4596
- const layoutId = useRef(0);
4597
- const forceUpdate = useForceUpdate();
4598
- const state = useMemo(() => ({
4599
- ctrls: [],
4600
- queue: [],
4601
- flush(ctrl, updates2) {
4602
- const springs2 = getSprings(ctrl, updates2);
4603
- const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs2).some((key) => !ctrl.springs[key]);
4604
- return canFlushSync ? flushUpdateQueue(ctrl, updates2) : new Promise((resolve) => {
4605
- setSprings(ctrl, springs2);
4606
- state.queue.push(() => {
4607
- resolve(flushUpdateQueue(ctrl, updates2));
4608
- });
4609
- forceUpdate();
4610
- });
4611
- }
4612
- }), []);
4613
- const ctrls = useRef([...state.ctrls]);
4614
- const updates = [];
4615
- const prevLength = usePrev(length) || 0;
4616
- useMemo(() => {
4617
- each(ctrls.current.slice(length, prevLength), (ctrl) => {
4618
- detachRefs(ctrl, ref);
4619
- ctrl.stop(true);
4620
- });
4621
- ctrls.current.length = length;
4622
- declareUpdates(prevLength, length);
4623
- }, [length]);
4624
- useMemo(() => {
4625
- declareUpdates(0, Math.min(prevLength, length));
4626
- }, deps);
4627
- function declareUpdates(startIndex, endIndex) {
4628
- for (let i = startIndex; i < endIndex; i++) {
4629
- const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush));
4630
- const update2 = propsFn ? propsFn(i, ctrl) : props[i];
4631
- if (update2) {
4632
- updates[i] = declareUpdate(update2);
4633
- }
4634
- }
4635
- }
4636
- const springs = ctrls.current.map((ctrl, i) => getSprings(ctrl, updates[i]));
4637
- const context = useContext(SpringContext);
4638
- const prevContext = usePrev(context);
4639
- const hasContext = context !== prevContext && hasProps(context);
4640
- useLayoutEffect(() => {
4641
- layoutId.current++;
4642
- state.ctrls = ctrls.current;
4643
- const {
4644
- queue
4645
- } = state;
4646
- if (queue.length) {
4647
- state.queue = [];
4648
- each(queue, (cb) => cb());
4649
- }
4650
- each(ctrls.current, (ctrl, i) => {
4651
- ref == null ? void 0 : ref.add(ctrl);
4652
- if (hasContext) {
4653
- ctrl.start({
4654
- default: context
4655
- });
4656
- }
4657
- const update2 = updates[i];
4658
- if (update2) {
4659
- replaceRef(ctrl, update2.ref);
4660
- if (ctrl.ref) {
4661
- ctrl.queue.push(update2);
4662
- } else {
4663
- ctrl.start(update2);
4664
- }
4665
- }
4666
- });
4667
- });
4668
- useOnce(() => () => {
4669
- each(state.ctrls, (ctrl) => ctrl.stop(true));
4670
- });
4671
- const values = springs.map((x) => _extends({}, x));
4672
- return ref ? [values, ref] : values;
4673
- }
4674
- function useSpring(props, deps) {
4675
- const isFn = is.fun(props);
4676
- const [[values], ref] = useSprings(1, isFn ? props : [props], isFn ? deps || [] : deps);
4677
- return isFn || arguments.length == 2 ? [values, ref] : values;
4678
- }
4679
- let TransitionPhase;
4680
- (function(TransitionPhase2) {
4681
- TransitionPhase2["MOUNT"] = "mount";
4682
- TransitionPhase2["ENTER"] = "enter";
4683
- TransitionPhase2["UPDATE"] = "update";
4684
- TransitionPhase2["LEAVE"] = "leave";
4685
- })(TransitionPhase || (TransitionPhase = {}));
4686
- class Interpolation extends FrameValue {
4687
- constructor(source, args) {
4688
- super();
4689
- this.key = void 0;
4690
- this.idle = true;
4691
- this.calc = void 0;
4692
- this._active = new Set();
4693
- this.source = source;
4694
- this.calc = createInterpolator(...args);
4695
- const value = this._get();
4696
- const nodeType = getAnimatedType(value);
4697
- setAnimated(this, nodeType.create(value));
4698
- }
4699
- advance(_dt) {
4700
- const value = this._get();
4701
- const oldValue = this.get();
4702
- if (!isEqual(value, oldValue)) {
4703
- getAnimated(this).setValue(value);
4704
- this._onChange(value, this.idle);
4705
- }
4706
- if (!this.idle && checkIdle(this._active)) {
4707
- becomeIdle(this);
4708
- }
4709
- }
4710
- _get() {
4711
- const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
4712
- return this.calc(...inputs);
4713
- }
4714
- _start() {
4715
- if (this.idle && !checkIdle(this._active)) {
4716
- this.idle = false;
4717
- each(getPayload(this), (node) => {
4718
- node.done = false;
4719
- });
4720
- if (globals.skipAnimation) {
4721
- raf.batchedUpdates(() => this.advance());
4722
- becomeIdle(this);
4723
- } else {
4724
- frameLoop.start(this);
4725
- }
4726
- }
4727
- }
4728
- _attach() {
4729
- let priority2 = 1;
4730
- each(toArray(this.source), (source) => {
4731
- if (hasFluidValue(source)) {
4732
- addFluidObserver(source, this);
4733
- }
4734
- if (isFrameValue(source)) {
4735
- if (!source.idle) {
4736
- this._active.add(source);
4737
- }
4738
- priority2 = Math.max(priority2, source.priority + 1);
4739
- }
4740
- });
4741
- this.priority = priority2;
4742
- this._start();
4743
- }
4744
- _detach() {
4745
- each(toArray(this.source), (source) => {
4746
- if (hasFluidValue(source)) {
4747
- removeFluidObserver(source, this);
4748
- }
4749
- });
4750
- this._active.clear();
4751
- becomeIdle(this);
4752
- }
4753
- eventObserved(event) {
4754
- if (event.type == "change") {
4755
- if (event.idle) {
4756
- this.advance();
4757
- } else {
4758
- this._active.add(event.parent);
4759
- this._start();
4760
- }
4761
- } else if (event.type == "idle") {
4762
- this._active.delete(event.parent);
4763
- } else if (event.type == "priority") {
4764
- this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0);
4765
- }
4766
- }
4767
- }
4768
- function isIdle(source) {
4769
- return source.idle !== false;
4770
- }
4771
- function checkIdle(active) {
4772
- return !active.size || Array.from(active).every(isIdle);
4773
- }
4774
- function becomeIdle(self2) {
4775
- if (!self2.idle) {
4776
- self2.idle = true;
4777
- each(getPayload(self2), (node) => {
4778
- node.done = true;
4779
- });
4780
- callFluidObservers(self2, {
4781
- type: "idle",
4782
- parent: self2
4783
- });
4784
- }
4785
- }
4786
- globals.assign({
4787
- createStringInterpolator,
4788
- to: (source, args) => new Interpolation(source, args)
4789
- });
4790
- function _objectWithoutPropertiesLoose(source, excluded) {
4791
- if (source == null)
4792
- return {};
4793
- var target = {};
4794
- var sourceKeys = Object.keys(source);
4795
- var key, i;
4796
- for (i = 0; i < sourceKeys.length; i++) {
4797
- key = sourceKeys[i];
4798
- if (excluded.indexOf(key) >= 0)
4799
- continue;
4800
- target[key] = source[key];
4801
- }
4802
- return target;
4803
- }
4804
- const _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
4805
- const isCustomPropRE = /^--/;
4806
- function dangerousStyleValue(name, value) {
4807
- if (value == null || typeof value === "boolean" || value === "")
4808
- return "";
4809
- if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]))
4810
- return value + "px";
4811
- return ("" + value).trim();
4812
- }
4813
- const attributeCache = {};
4814
- function applyAnimatedValues(instance, props) {
4815
- if (!instance.nodeType || !instance.setAttribute) {
4816
- return false;
4817
- }
4818
- const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
4819
- const _ref = props, {
4820
- style,
4821
- children,
4822
- scrollTop,
4823
- scrollLeft
4824
- } = _ref, attributes = _objectWithoutPropertiesLoose(_ref, _excluded$2);
4825
- const values = Object.values(attributes);
4826
- const names = Object.keys(attributes).map((name) => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, (n) => "-" + n.toLowerCase())));
4827
- if (children !== void 0) {
4828
- instance.textContent = children;
4829
- }
4830
- for (let name in style) {
4831
- if (style.hasOwnProperty(name)) {
4832
- const value = dangerousStyleValue(name, style[name]);
4833
- if (isCustomPropRE.test(name)) {
4834
- instance.style.setProperty(name, value);
4835
- } else {
4836
- instance.style[name] = value;
4837
- }
4838
- }
4839
- }
4840
- names.forEach((name, i) => {
4841
- instance.setAttribute(name, values[i]);
4842
- });
4843
- if (scrollTop !== void 0) {
4844
- instance.scrollTop = scrollTop;
4845
- }
4846
- if (scrollLeft !== void 0) {
4847
- instance.scrollLeft = scrollLeft;
4848
- }
4849
- }
4850
- let isUnitlessNumber = {
4851
- animationIterationCount: true,
4852
- borderImageOutset: true,
4853
- borderImageSlice: true,
4854
- borderImageWidth: true,
4855
- boxFlex: true,
4856
- boxFlexGroup: true,
4857
- boxOrdinalGroup: true,
4858
- columnCount: true,
4859
- columns: true,
4860
- flex: true,
4861
- flexGrow: true,
4862
- flexPositive: true,
4863
- flexShrink: true,
4864
- flexNegative: true,
4865
- flexOrder: true,
4866
- gridRow: true,
4867
- gridRowEnd: true,
4868
- gridRowSpan: true,
4869
- gridRowStart: true,
4870
- gridColumn: true,
4871
- gridColumnEnd: true,
4872
- gridColumnSpan: true,
4873
- gridColumnStart: true,
4874
- fontWeight: true,
4875
- lineClamp: true,
4876
- lineHeight: true,
4877
- opacity: true,
4878
- order: true,
4879
- orphans: true,
4880
- tabSize: true,
4881
- widows: true,
4882
- zIndex: true,
4883
- zoom: true,
4884
- fillOpacity: true,
4885
- floodOpacity: true,
4886
- stopOpacity: true,
4887
- strokeDasharray: true,
4888
- strokeDashoffset: true,
4889
- strokeMiterlimit: true,
4890
- strokeOpacity: true,
4891
- strokeWidth: true
4892
- };
4893
- const prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1);
4894
- const prefixes = ["Webkit", "Ms", "Moz", "O"];
4895
- isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
4896
- prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]);
4897
- return acc;
4898
- }, isUnitlessNumber);
4899
- const _excluded$1 = ["x", "y", "z"];
4900
- const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
4901
- const pxTransforms = /^(translate)/;
4902
- const degTransforms = /^(rotate|skew)/;
4903
- const addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
4904
- const isValueIdentity = (value, id) => is.arr(value) ? value.every((v) => isValueIdentity(v, id)) : is.num(value) ? value === id : parseFloat(value) === id;
4905
- class AnimatedStyle extends AnimatedObject {
4906
- constructor(_ref) {
4907
- let {
4908
- x,
4909
- y,
4910
- z
4911
- } = _ref, style = _objectWithoutPropertiesLoose(_ref, _excluded$1);
4912
- const inputs = [];
4913
- const transforms = [];
4914
- if (x || y || z) {
4915
- inputs.push([x || 0, y || 0, z || 0]);
4916
- transforms.push((xyz) => [`translate3d(${xyz.map((v) => addUnit(v, "px")).join(",")})`, isValueIdentity(xyz, 0)]);
4917
- }
4918
- eachProp(style, (value, key) => {
4919
- if (key === "transform") {
4920
- inputs.push([value || ""]);
4921
- transforms.push((transform) => [transform, transform === ""]);
4922
- } else if (domTransforms.test(key)) {
4923
- delete style[key];
4924
- if (is.und(value))
4925
- return;
4926
- const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
4927
- inputs.push(toArray(value));
4928
- transforms.push(key === "rotate3d" ? ([x2, y2, z2, deg]) => [`rotate3d(${x2},${y2},${z2},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`${key}(${input.map((v) => addUnit(v, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]);
4929
- }
4930
- });
4931
- if (inputs.length) {
4932
- style.transform = new FluidTransform(inputs, transforms);
4933
- }
4934
- super(style);
4935
- }
4936
- }
4937
- class FluidTransform extends FluidValue {
4938
- constructor(inputs, transforms) {
4939
- super();
4940
- this._value = null;
4941
- this.inputs = inputs;
4942
- this.transforms = transforms;
4943
- }
4944
- get() {
4945
- return this._value || (this._value = this._get());
4946
- }
4947
- _get() {
4948
- let transform = "";
4949
- let identity = true;
4950
- each(this.inputs, (input, i) => {
4951
- const arg1 = getFluidValue(input[0]);
4952
- const [t, id] = this.transforms[i](is.arr(arg1) ? arg1 : input.map(getFluidValue));
4953
- transform += " " + t;
4954
- identity = identity && id;
4955
- });
4956
- return identity ? "none" : transform;
4957
- }
4958
- observerAdded(count) {
4959
- if (count == 1)
4960
- each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this)));
4961
- }
4962
- observerRemoved(count) {
4963
- if (count == 0)
4964
- each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this)));
4965
- }
4966
- eventObserved(event) {
4967
- if (event.type == "change") {
4968
- this._value = null;
4969
- }
4970
- callFluidObservers(this, event);
4971
- }
4972
- }
4973
- const primitives = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"];
4974
- const _excluded = ["scrollTop", "scrollLeft"];
4975
- globals.assign({
4976
- batchedUpdates: unstable_batchedUpdates,
4977
- createStringInterpolator,
4978
- colors
4979
- });
4980
- const host = createHost(primitives, {
4981
- applyAnimatedValues,
4982
- createAnimatedStyle: (style) => new AnimatedStyle(style),
4983
- getComponentProps: (_ref) => {
4984
- let props = _objectWithoutPropertiesLoose(_ref, _excluded);
4985
- return props;
4986
- }
4987
- });
4988
- const animated = host.animated;
4989
1660
  function PdaActionSheet(props) {
4990
- const { className, visible, actions } = props;
4991
- const [active, setActive] = useState(visible);
4992
- const ref = useRef(null);
4993
- const { percent } = useSpring({
4994
- percent: visible ? 0 : 100,
4995
- config: {
4996
- precision: 0.1,
4997
- mass: 0.4,
4998
- tension: 300,
4999
- friction: 30
5000
- },
5001
- onStart: () => {
5002
- setActive(true);
5003
- },
5004
- onRest: () => {
5005
- setActive(props.visible);
5006
- }
5007
- });
5008
- return /* @__PURE__ */ React__default.createElement("div", {
5009
- className: classNames({ [className]: true, "pda-action-sheet": true }),
5010
- style: { display: active ? "unset" : "none" }
5011
- }, /* @__PURE__ */ React__default.createElement(animated.div, {
5012
- className: "pda-action-sheet-body",
5013
- style: {
5014
- transform: percent.to((v) => {
5015
- return `translate(0, ${v}%)`;
5016
- })
5017
- },
5018
- ref
1661
+ const { className = "", visible, actions } = props;
1662
+ return /* @__PURE__ */ React.createElement("div", {
1663
+ className: classNames({ [className]: true, "pda-action-sheet": true, "show": visible })
1664
+ }, /* @__PURE__ */ React.createElement("div", {
1665
+ className: "pda-action-sheet-body"
5019
1666
  }, actions.map((item, index2) => {
5020
- return /* @__PURE__ */ React__default.createElement("div", {
1667
+ return /* @__PURE__ */ React.createElement("div", {
5021
1668
  onClick: () => {
5022
1669
  item.onClick(item.key);
5023
1670
  },
@@ -5026,4 +1673,5 @@ function PdaActionSheet(props) {
5026
1673
  }, item.title);
5027
1674
  })));
5028
1675
  }
5029
- export { PdaActionSheet as ActionSheet, BaseLayout, Button, Confirm$1 as Confirm, PdaDistanceCard as DistanceCard, PdaFinishCard as FinishCard, index$i as Header, InfiniteScroll, PdaInfoCard$2 as InfoCard, List, PdaListItem as ListItem, Overlay, index$b as PageFlowSystemPages, Presentation, PdaInfoCard as Steps, SubCard, PdaTitle as Title, Confirm as Toast, WakeKeyborard };
1676
+ const ListItem = PdaListItem;
1677
+ export { PdaActionSheet as ActionSheet, BaseLayout, Button, Confirm, PdaDistanceCard as DistanceCard, PdaFinishCard as FinishCard, index$i as Header, InfiniteScroll, PdaInfoCard$2 as InfoCard, List, ListItem, Overlay, index$b as PageFlowSystemPages, Presentation, PdaInfoCard as Steps, SubCard, PdaListItem as TaskCard, PdaTitle as Title, Toast, WakeKeyborard };