clxx 2.1.6 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +63 -0
  3. package/build/Ago/index.js +14 -8
  4. package/build/Alert/Wrapper.js +20 -20
  5. package/build/Alert/index.js +17 -11
  6. package/build/Alert/style.js +44 -26
  7. package/build/AutoGrid/index.js +50 -14
  8. package/build/AutoGrid/style.js +9 -6
  9. package/build/CarouselNotice/index.js +22 -19
  10. package/build/CarouselNotice/style.js +6 -3
  11. package/build/CitySelect/data.d.ts +3 -0
  12. package/build/CitySelect/data.js +2355 -0
  13. package/build/CitySelect/index.d.ts +17 -0
  14. package/build/CitySelect/index.js +335 -0
  15. package/build/CitySelect/search.d.ts +2 -0
  16. package/build/CitySelect/search.js +70 -0
  17. package/build/CitySelect/style.d.ts +4 -0
  18. package/build/CitySelect/style.js +237 -0
  19. package/build/CitySelect/type.d.ts +17 -0
  20. package/build/CitySelect/type.js +2 -0
  21. package/build/Clickable/index.js +56 -20
  22. package/build/Container/index.js +52 -16
  23. package/build/Countdowner/index.js +50 -14
  24. package/build/Dialog/Wrapper.js +13 -10
  25. package/build/Dialog/index.js +18 -12
  26. package/build/Dialog/style.js +29 -25
  27. package/build/Effect/useInterval.js +7 -4
  28. package/build/Effect/useTick.js +9 -6
  29. package/build/Effect/useUpdate.js +6 -3
  30. package/build/Effect/useViewport.js +15 -8
  31. package/build/Effect/useWindowResize.js +7 -4
  32. package/build/Fixed/index.js +6 -3
  33. package/build/Flex/Col.js +23 -15
  34. package/build/Flex/Row.js +23 -15
  35. package/build/Flex/index.js +9 -5
  36. package/build/Indicator/index.js +20 -14
  37. package/build/Indicator/style.js +6 -3
  38. package/build/Loading/Wrapper.js +14 -11
  39. package/build/Loading/index.js +17 -10
  40. package/build/Loading/style.js +9 -6
  41. package/build/Overlay/index.js +12 -9
  42. package/build/SafeArea/index.js +8 -5
  43. package/build/ScrollView/index.js +24 -21
  44. package/build/ScrollView/style.js +4 -1
  45. package/build/Toast/Toast.js +53 -17
  46. package/build/Toast/index.js +21 -14
  47. package/build/Toast/style.d.ts +0 -3
  48. package/build/Toast/style.js +49 -41
  49. package/build/index.d.ts +1 -1
  50. package/build/index.js +102 -36
  51. package/build/utils/Countdown.js +7 -3
  52. package/build/utils/ago.js +10 -4
  53. package/build/utils/calendarTable.js +9 -3
  54. package/build/utils/createApp.js +35 -27
  55. package/build/utils/cssUtil.js +10 -5
  56. package/build/utils/defaultScroll.js +4 -1
  57. package/build/utils/dom.js +6 -3
  58. package/build/utils/is.js +6 -2
  59. package/build/utils/jsonp.js +4 -1
  60. package/build/utils/request.js +40 -27
  61. package/build/utils/tick.js +4 -1
  62. package/build/utils/uniqKey.js +4 -1
  63. package/build/utils/wait.js +8 -4
  64. package/package.json +1 -1
  65. package/test/src/city-select/index.jsx +21 -0
  66. package/test/src/index/index.jsx +1 -0
  67. package/test/src/toast/index.jsx +1 -0
  68. package/test/vite.config.js +6 -2
  69. package/build/context.d.ts +0 -14
  70. package/build/context.js +0 -21
@@ -1,5 +1,8 @@
1
- import { tick } from './tick';
2
- export class Countdown {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Countdown = void 0;
4
+ const tick_1 = require("./tick");
5
+ class Countdown {
3
6
  constructor(option) {
4
7
  /**
5
8
  * 倒计时的剩余时间,单位为秒
@@ -61,7 +64,7 @@ export class Countdown {
61
64
  // 记录倒计时开启时的时间
62
65
  const start = Date.now();
63
66
  // 使用 1000ms 间隔,避免每帧都执行(性能优化)
64
- this._stopTick = tick(() => {
67
+ this._stopTick = (0, tick_1.tick)(() => {
65
68
  var _a, _b, _c, _d;
66
69
  // 获取倒计时已经持续的时间
67
70
  const duration = Math.floor((Date.now() - start) / 1000);
@@ -121,3 +124,4 @@ export class Countdown {
121
124
  return result;
122
125
  }
123
126
  }
127
+ exports.Countdown = Countdown;
@@ -1,11 +1,17 @@
1
- import dayjs from 'dayjs';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ago = ago;
7
+ const dayjs_1 = __importDefault(require("dayjs"));
2
8
  /**
3
9
  * 用于格式化显示:多久以前
4
10
  * @param date
5
11
  */
6
- export function ago(date) {
7
- const now = dayjs();
8
- const input = dayjs(date);
12
+ function ago(date) {
13
+ const now = (0, dayjs_1.default)();
14
+ const input = (0, dayjs_1.default)(date);
9
15
  if (!input.isValid()) {
10
16
  return {
11
17
  num: 0,
@@ -1,12 +1,18 @@
1
- import dayjs from "dayjs";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calendarTable = calendarTable;
7
+ const dayjs_1 = __importDefault(require("dayjs"));
2
8
  /**
3
9
  * 创建一个月历视图的原始数据表
4
10
  * @param usefulFormat dayjs构造函数可以识别的任意值
5
11
  * @param startFromSunday 是否以星期天作为一周的第一天
6
12
  * @param sizeGuarantee 是否保证生成表格始终有6行
7
13
  */
8
- export function calendarTable(usefulFormat = dayjs(), startFromSunday = false, sizeGuarantee = true) {
9
- const value = dayjs(usefulFormat);
14
+ function calendarTable(usefulFormat = (0, dayjs_1.default)(), startFromSunday = false, sizeGuarantee = true) {
15
+ const value = (0, dayjs_1.default)(usefulFormat);
10
16
  const startOfMonth = value.startOf("month");
11
17
  const endOfMonth = value.endOf("month");
12
18
  const monthStartDay = startOfMonth.date();
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,31 +8,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
11
- import { useCallback, useEffect, useState } from "react";
12
- import { createRoot } from "react-dom/client";
13
- import { createBrowserHistory, createHashHistory, createMemoryHistory, } from "history";
14
- import { Container } from "../Container";
15
- import pick from "lodash/pick";
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.history = void 0;
16
+ exports.getHistory = getHistory;
17
+ exports.createApp = createApp;
18
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
19
+ const react_1 = require("react");
20
+ const client_1 = require("react-dom/client");
21
+ const history_1 = require("history");
22
+ const Container_1 = require("../Container");
23
+ const pick_1 = __importDefault(require("lodash/pick"));
16
24
  // 存储历史记录对象
17
- export let history = null;
25
+ exports.history = null;
18
26
  // 获取历史记录对象
19
- export function getHistory(mode = "browser") {
20
- if (history === null) {
27
+ function getHistory(mode = "browser") {
28
+ if (exports.history === null) {
21
29
  const createMap = {
22
- browser: createBrowserHistory,
23
- hash: createHashHistory,
24
- memory: createMemoryHistory,
30
+ browser: history_1.createBrowserHistory,
31
+ hash: history_1.createHashHistory,
32
+ memory: history_1.createMemoryHistory,
25
33
  };
26
- history = createMap[mode]();
34
+ exports.history = createMap[mode]();
27
35
  }
28
- return history;
36
+ return exports.history;
29
37
  }
30
38
  /**
31
39
  * 创建带路由的APP对象,全局对象,绝大部分情况下只需要调用一次
32
40
  * @param option CreateAppOption
33
41
  */
34
- export function createApp(option) {
42
+ function createApp(option) {
35
43
  return __awaiter(this, void 0, void 0, function* () {
36
44
  // 设置默认的路由方式
37
45
  if (!option.mode ||
@@ -43,9 +51,9 @@ export function createApp(option) {
43
51
  option.default = "/index";
44
52
  }
45
53
  // 这里是为了确保历史记录对象在组件渲染之前一定存在
46
- history = getHistory(option.mode);
54
+ exports.history = getHistory(option.mode);
47
55
  // 提取关键数据
48
- const containerProps = pick(option, [
56
+ const containerProps = (0, pick_1.default)(option, [
49
57
  "designWidth",
50
58
  "globalStyle",
51
59
  ]);
@@ -61,11 +69,11 @@ export function createApp(option) {
61
69
  * @returns
62
70
  */
63
71
  const App = () => {
64
- const [page, setPage] = useState(null);
72
+ const [page, setPage] = (0, react_1.useState)(null);
65
73
  /**
66
74
  * 加载并渲染页面
67
75
  */
68
- const loadAndRenderPage = useCallback((pathname) => __awaiter(this, void 0, void 0, function* () {
76
+ const loadAndRenderPage = (0, react_1.useCallback)((pathname) => __awaiter(this, void 0, void 0, function* () {
69
77
  const normalizedPath = normalizePath(pathname);
70
78
  // 如果有 loading 占位符,先显示
71
79
  if (typeof loading === "function") {
@@ -84,7 +92,7 @@ export function createApp(option) {
84
92
  }
85
93
  else {
86
94
  // 默认 404 页面
87
- setPage(_jsxs("div", { children: ["Not Found: ", normalizedPath] }));
95
+ setPage((0, jsx_runtime_1.jsxs)("div", { children: ["Not Found: ", normalizedPath] }));
88
96
  }
89
97
  return;
90
98
  }
@@ -96,7 +104,7 @@ export function createApp(option) {
96
104
  setPage(yield notFound(normalizedPath));
97
105
  }
98
106
  else {
99
- setPage(_jsxs("div", { children: ["Not Found: ", normalizedPath] }));
107
+ setPage((0, jsx_runtime_1.jsxs)("div", { children: ["Not Found: ", normalizedPath] }));
100
108
  }
101
109
  return;
102
110
  }
@@ -110,17 +118,17 @@ export function createApp(option) {
110
118
  /**
111
119
  * 监听路由变化
112
120
  */
113
- useEffect(() => {
121
+ (0, react_1.useEffect)(() => {
114
122
  // 监听页面变化,一旦变化渲染新页面
115
- const unlisten = history.listen(({ location }) => {
123
+ const unlisten = exports.history.listen(({ location }) => {
116
124
  loadAndRenderPage(location.pathname);
117
125
  });
118
126
  // 初始化时渲染当前路径对应的页面
119
- loadAndRenderPage(history.location.pathname);
127
+ loadAndRenderPage(exports.history.location.pathname);
120
128
  // 卸载时,取消监听
121
129
  return unlisten;
122
130
  }, [loadAndRenderPage]);
123
- return _jsx(Container, Object.assign({}, containerProps, { children: page }));
131
+ return (0, jsx_runtime_1.jsx)(Container_1.Container, Object.assign({}, containerProps, { children: page }));
124
132
  };
125
133
  // 获取挂载对象
126
134
  let mount = null;
@@ -133,7 +141,7 @@ export function createApp(option) {
133
141
  if (!mount) {
134
142
  throw new Error(`Mount target not found: ${typeof option.target === "string" ? option.target : "invalid element"}`);
135
143
  }
136
- const root = createRoot(mount);
137
- root.render(_jsx(App, {}));
144
+ const root = (0, client_1.createRoot)(mount);
145
+ root.render((0, jsx_runtime_1.jsx)(App, {}));
138
146
  });
139
147
  }
@@ -1,19 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CSSValueReg = void 0;
4
+ exports.normalizeUnit = normalizeUnit;
5
+ exports.splitValue = splitValue;
1
6
  /**
2
7
  * 匹配所有的CSS数值类型的值
3
8
  */
4
9
  // eslint-disable-next-line no-useless-escape
5
- export const CSSValueReg = /^((?:\-)?(?:\d+\.?|\.\d+|\d+\.\d+))([a-zA-Z%]*)$/;
10
+ exports.CSSValueReg = /^((?:\-)?(?:\d+\.?|\.\d+|\d+\.\d+))([a-zA-Z%]*)$/;
6
11
  /**
7
12
  * 标准化长度值单位
8
13
  * @param value 长度值
9
14
  * @param defaultUnit 默认长度值单位
10
15
  */
11
- export function normalizeUnit(value, defaultUnit = 'px') {
16
+ function normalizeUnit(value, defaultUnit = 'px') {
12
17
  if (typeof value === 'number') {
13
18
  return value + defaultUnit;
14
19
  }
15
20
  if (typeof value === 'string') {
16
- const result = value.match(CSSValueReg);
21
+ const result = value.match(exports.CSSValueReg);
17
22
  if (Array.isArray(result)) {
18
23
  return result[2]
19
24
  ? parseFloat(value) + result[2]
@@ -37,12 +42,12 @@ export function normalizeUnit(value, defaultUnit = 'px') {
37
42
  * @param value
38
43
  * @param defaultUnit
39
44
  */
40
- export function splitValue(value, defaultUnit = 'px') {
45
+ function splitValue(value, defaultUnit = 'px') {
41
46
  if (typeof value === 'number') {
42
47
  return { num: value, unit: defaultUnit };
43
48
  }
44
49
  if (typeof value === 'string') {
45
- const result = value.match(CSSValueReg);
50
+ const result = value.match(exports.CSSValueReg);
46
51
  if (Array.isArray(result)) {
47
52
  return { num: parseFloat(result[1]), unit: result[2] || defaultUnit };
48
53
  }
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultScroll = void 0;
1
4
  /**
2
5
  * 触摸移动事件处理器
3
6
  */
@@ -11,7 +14,7 @@ const touchMoveHandler = (event) => {
11
14
  * 默认视为 passive: true,此时 preventDefault() 会静默失效。
12
15
  * 因此必须显式声明 passive: false 才能真正阻止默认滚动行为。
13
16
  */
14
- export const defaultScroll = {
17
+ exports.defaultScroll = {
15
18
  disable() {
16
19
  document.documentElement.addEventListener('touchmove', touchMoveHandler, { capture: false, passive: false });
17
20
  },
@@ -1,4 +1,7 @@
1
- import { createRoot } from 'react-dom/client';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPortalDOM = createPortalDOM;
4
+ const client_1 = require("react-dom/client");
2
5
  /**
3
6
  *
4
7
  * 组件可以通过函数的第一个参数传递进去
@@ -6,14 +9,14 @@ import { createRoot } from 'react-dom/client';
6
9
  * @param point HTMLElement 挂载点,如果未指定,则挂载点为body
7
10
  * @returns CreatePortalDOMResult
8
11
  */
9
- export function createPortalDOM(point) {
12
+ function createPortalDOM(point) {
10
13
  const container = document.createElement('div');
11
14
  let mountPoint = document.body;
12
15
  if (point instanceof HTMLElement) {
13
16
  mountPoint = point;
14
17
  }
15
18
  mountPoint.appendChild(container);
16
- const root = createRoot(container);
19
+ const root = (0, client_1.createRoot)(container);
17
20
  return {
18
21
  element: container,
19
22
  mount(component) {
package/build/utils/is.js CHANGED
@@ -1,3 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.is = is;
4
+ exports.clearIsCache = clearIsCache;
1
5
  // 缓存 UserAgent,避免重复获取
2
6
  const UA = window.navigator.userAgent;
3
7
  // 预编译正则表达式,提升性能
@@ -56,7 +60,7 @@ function isIPad() {
56
60
  * }
57
61
  * ```
58
62
  */
59
- export function is(env) {
63
+ function is(env) {
60
64
  // 从缓存中获取结果
61
65
  if (cache.has(env)) {
62
66
  return cache.get(env);
@@ -106,6 +110,6 @@ export function is(env) {
106
110
  /**
107
111
  * 清除缓存(用于测试或特殊场景)
108
112
  */
109
- export function clearIsCache() {
113
+ function clearIsCache() {
110
114
  cache.clear();
111
115
  }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,13 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.jsonp = jsonp;
10
13
  let JSONP_INDEX = 1;
11
14
  /**
12
15
  * 发送jsonp请求
13
16
  * @param url
14
17
  * @param callbackName
15
18
  */
16
- export function jsonp(url_1) {
19
+ function jsonp(url_1) {
17
20
  return __awaiter(this, arguments, void 0, function* (url, callbackName = 'callback') {
18
21
  return new Promise((resolve, reject) => {
19
22
  // 生成全局唯一的
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,11 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import isPlainObject from "lodash/isPlainObject";
11
- import omit from "lodash/omit";
12
- import isArrayBuffer from "lodash/isArrayBuffer";
13
- import isTypedArray from "lodash/isTypedArray";
14
- import { uniqKey } from "./uniqKey";
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.registerHostAlias = registerHostAlias;
16
+ exports.buildUrlByOption = buildUrlByOption;
17
+ exports.parseRequestOption = parseRequestOption;
18
+ exports.sendRequest = sendRequest;
19
+ exports.sugarSend = sugarSend;
20
+ exports.GET = GET;
21
+ exports.POST = POST;
22
+ exports.sendJSON = sendJSON;
23
+ const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
24
+ const omit_1 = __importDefault(require("lodash/omit"));
25
+ const isArrayBuffer_1 = __importDefault(require("lodash/isArrayBuffer"));
26
+ const isTypedArray_1 = __importDefault(require("lodash/isTypedArray"));
27
+ const uniqKey_1 = require("./uniqKey");
15
28
  // 用来全局存储host别名映射
16
29
  let hostAliasMap = {};
17
30
  /**
@@ -19,9 +32,9 @@ let hostAliasMap = {};
19
32
  * @param aliasMap
20
33
  * @returns
21
34
  */
22
- export function registerHostAlias(aliasMap) {
35
+ function registerHostAlias(aliasMap) {
23
36
  return __awaiter(this, void 0, void 0, function* () {
24
- if (!isPlainObject(aliasMap))
37
+ if (!(0, isPlainObject_1.default)(aliasMap))
25
38
  return;
26
39
  hostAliasMap = Object.assign(Object.assign({}, hostAliasMap), aliasMap);
27
40
  });
@@ -30,7 +43,7 @@ export function registerHostAlias(aliasMap) {
30
43
  * 通过ajax选项构建Url
31
44
  * @param option
32
45
  */
33
- export function buildUrlByOption(option) {
46
+ function buildUrlByOption(option) {
34
47
  var _a;
35
48
  let config = {
36
49
  url: "",
@@ -39,10 +52,10 @@ export function buildUrlByOption(option) {
39
52
  disableUrlCache: false,
40
53
  transmitPageParam: false,
41
54
  };
42
- if (isPlainObject(option)) {
55
+ if ((0, isPlainObject_1.default)(option)) {
43
56
  config = Object.assign(Object.assign({}, config), option);
44
57
  }
45
- if (!isPlainObject(config.data)) {
58
+ if (!(0, isPlainObject_1.default)(config.data)) {
46
59
  config.data = {};
47
60
  }
48
61
  let url = config.url || "";
@@ -80,7 +93,7 @@ export function buildUrlByOption(option) {
80
93
  }
81
94
  // 如果是normal请求,将data中的数据作为url的查询字符串
82
95
  if (((_a = config.sendType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "normal") {
83
- if (isPlainObject(config.data)) {
96
+ if ((0, isPlainObject_1.default)(config.data)) {
84
97
  const data = config.data;
85
98
  for (let key in data) {
86
99
  urlObject.searchParams.append(key, data[key]);
@@ -95,7 +108,7 @@ export function buildUrlByOption(option) {
95
108
  }
96
109
  // 如果禁用了URL缓存,添加去缓存参数
97
110
  if (config.disableUrlCache) {
98
- urlObject.searchParams.append("__c", uniqKey());
111
+ urlObject.searchParams.append("__c", (0, uniqKey_1.uniqKey)());
99
112
  }
100
113
  // 返回URL地址
101
114
  return urlObject.toString();
@@ -105,7 +118,7 @@ export function buildUrlByOption(option) {
105
118
  * @param option
106
119
  * @returns
107
120
  */
108
- export function parseRequestOption(option) {
121
+ function parseRequestOption(option) {
109
122
  var _a, _b;
110
123
  let config = {
111
124
  url: "",
@@ -118,7 +131,7 @@ export function parseRequestOption(option) {
118
131
  config.sendType = config.sendType.toLowerCase();
119
132
  config.method = (_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase();
120
133
  // 传递过来的参数覆盖默认值
121
- if (isPlainObject(option)) {
134
+ if ((0, isPlainObject_1.default)(option)) {
122
135
  config = Object.assign(Object.assign({}, config), option);
123
136
  }
124
137
  /**
@@ -145,7 +158,7 @@ export function parseRequestOption(option) {
145
158
  }
146
159
  break;
147
160
  case "form":
148
- if (isPlainObject(config.data)) {
161
+ if ((0, isPlainObject_1.default)(config.data)) {
149
162
  const body = new FormData();
150
163
  const data = config.data;
151
164
  for (let key in data) {
@@ -158,7 +171,7 @@ export function parseRequestOption(option) {
158
171
  }
159
172
  break;
160
173
  case "json":
161
- if (isPlainObject(config.data)) {
174
+ if ((0, isPlainObject_1.default)(config.data)) {
162
175
  config.headers["Content-Type"] = "application/json";
163
176
  config.body = JSON.stringify(config.data);
164
177
  }
@@ -169,7 +182,7 @@ export function parseRequestOption(option) {
169
182
  }
170
183
  break;
171
184
  case "params":
172
- if (isPlainObject(config.data)) {
185
+ if ((0, isPlainObject_1.default)(config.data)) {
173
186
  const body = new URLSearchParams();
174
187
  const data = config.data;
175
188
  for (let key in data) {
@@ -182,8 +195,8 @@ export function parseRequestOption(option) {
182
195
  }
183
196
  break;
184
197
  case "buffer":
185
- if (isArrayBuffer(config.data) ||
186
- isTypedArray(config.data) ||
198
+ if ((0, isArrayBuffer_1.default)(config.data) ||
199
+ (0, isTypedArray_1.default)(config.data) ||
187
200
  config.data instanceof DataView) {
188
201
  config.body = config.data;
189
202
  }
@@ -191,7 +204,7 @@ export function parseRequestOption(option) {
191
204
  default:
192
205
  break;
193
206
  }
194
- const fetchOption = omit(config, [
207
+ const fetchOption = (0, omit_1.default)(config, [
195
208
  "url",
196
209
  "sendType",
197
210
  "data",
@@ -206,7 +219,7 @@ export function parseRequestOption(option) {
206
219
  * @param url
207
220
  * @param option
208
221
  */
209
- export function sendRequest(option) {
222
+ function sendRequest(option) {
210
223
  return __awaiter(this, void 0, void 0, function* () {
211
224
  const { url, fetchOption, timeout } = parseRequestOption(option);
212
225
  const controller = new AbortController();
@@ -246,15 +259,15 @@ export function sendRequest(option) {
246
259
  * @param option
247
260
  * @returns
248
261
  */
249
- export function sugarSend(sendType, url, data, option) {
262
+ function sugarSend(sendType, url, data, option) {
250
263
  return __awaiter(this, void 0, void 0, function* () {
251
264
  let config = {
252
265
  url,
253
266
  data,
254
267
  sendType,
255
268
  };
256
- if (isPlainObject(option)) {
257
- config = Object.assign(Object.assign({}, config), omit(option, ["url", "data", "sendType"]));
269
+ if ((0, isPlainObject_1.default)(option)) {
270
+ config = Object.assign(Object.assign({}, config), (0, omit_1.default)(option, ["url", "data", "sendType"]));
258
271
  }
259
272
  return sendRequest(config);
260
273
  });
@@ -266,7 +279,7 @@ export function sugarSend(sendType, url, data, option) {
266
279
  * @param option
267
280
  * @returns
268
281
  */
269
- export function GET(url, data, option) {
282
+ function GET(url, data, option) {
270
283
  return __awaiter(this, void 0, void 0, function* () {
271
284
  return sugarSend("normal", url, data, option);
272
285
  });
@@ -278,7 +291,7 @@ export function GET(url, data, option) {
278
291
  * @param option
279
292
  * @returns
280
293
  */
281
- export function POST(url, data, option) {
294
+ function POST(url, data, option) {
282
295
  return __awaiter(this, void 0, void 0, function* () {
283
296
  return sugarSend("form", url, data, option);
284
297
  });
@@ -290,7 +303,7 @@ export function POST(url, data, option) {
290
303
  * @param option
291
304
  * @returns
292
305
  */
293
- export function sendJSON(url, data, option) {
306
+ function sendJSON(url, data, option) {
294
307
  return __awaiter(this, void 0, void 0, function* () {
295
308
  return sugarSend("json", url, data, option);
296
309
  });
@@ -1,9 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tick = tick;
1
4
  /**
2
5
  * 逐帧执行的工具函数,返回一个方法,调用该方法,停止执行
3
6
  * @param callback
4
7
  * @param interval
5
8
  */
6
- export function tick(callback, interval) {
9
+ function tick(callback, interval) {
7
10
  let isRunning;
8
11
  let frame;
9
12
  let frameId;
@@ -1,10 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uniqKey = uniqKey;
1
4
  let keyIndex = 0;
2
5
  let lastTimestamp = 0;
3
6
  /**
4
7
  * 生成一个全局唯一的key
5
8
  * @returns
6
9
  */
7
- export function uniqKey() {
10
+ function uniqKey() {
8
11
  const now = Date.now();
9
12
  // 时间戳变化时重置计数器
10
13
  if (now !== lastTimestamp) {
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,7 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import { tick } from './tick';
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.waitUntil = waitUntil;
13
+ exports.waitFor = waitFor;
14
+ const tick_1 = require("./tick");
11
15
  /**
12
16
  * 直接条件为真或者超时才返回结果
13
17
  *
@@ -16,7 +20,7 @@ import { tick } from './tick';
16
20
  *
17
21
  * @returns 返回检测的结果,超时返回false
18
22
  */
19
- export function waitUntil(condition, maxTime) {
23
+ function waitUntil(condition, maxTime) {
20
24
  return __awaiter(this, void 0, void 0, function* () {
21
25
  // 记录检测开始时间
22
26
  const start = Date.now();
@@ -29,7 +33,7 @@ export function waitUntil(condition, maxTime) {
29
33
  maxTime = Infinity;
30
34
  }
31
35
  return new Promise((resolve) => {
32
- const stop = tick(() => {
36
+ const stop = (0, tick_1.tick)(() => {
33
37
  const now = Date.now();
34
38
  // 超时返回false
35
39
  if (now - start >= maxTime) {
@@ -60,7 +64,7 @@ export function waitUntil(condition, maxTime) {
60
64
  * 等待固定时间,期间一直阻塞
61
65
  * @param duration 等待时长(毫秒)
62
66
  */
63
- export function waitFor(duration) {
67
+ function waitFor(duration) {
64
68
  return __awaiter(this, void 0, void 0, function* () {
65
69
  return new Promise((resolve) => {
66
70
  window.setTimeout(resolve, duration);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clxx",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "Basic JS library for mobile devices",
5
5
  "main": "./build/index.js",
6
6
  "module": "./build/index.js",
@@ -0,0 +1,21 @@
1
+ import { showCitySelect } from "@";
2
+ import { useEffect } from "react";
3
+
4
+ export default function Index() {
5
+ return (
6
+ <button
7
+ onClick={() => {
8
+ showCitySelect({
9
+ onSelect: (city) => {
10
+ console.log("选择了城市:", city);
11
+ },
12
+ getLocation() {
13
+ return "北京";
14
+ },
15
+ });
16
+ }}
17
+ >
18
+ 选择城市
19
+ </button>
20
+ );
21
+ }
@@ -16,6 +16,7 @@ const pageConfig = [
16
16
  { path: "clickable", title: "Clickable可触摸组件", enable: true },
17
17
  // { path: 'privacy', title: 'Privacy去标识化', enable: true },
18
18
  { path: "autogrid", title: "AutoGrid生成自动对齐的表格", enable: true },
19
+ { path: "city-select", title: "CitySelect城市选择器", enable: true },
19
20
  ];
20
21
 
21
22
  export default function Index() {
@@ -44,6 +44,7 @@ export default function Index () {
44
44
  showToast({
45
45
  content: "一个简单的Toast轻提示Toast轻提示Toast轻提示Toast轻提示",
46
46
  position: "bottom",
47
+ // duration: 500000,
47
48
  });
48
49
  }}
49
50
  >