clxx 2.1.5 → 2.1.7

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 (74) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +827 -420
  3. package/build/Ago/index.js +14 -8
  4. package/build/Alert/Wrapper.js +13 -10
  5. package/build/Alert/index.js +17 -11
  6. package/build/Alert/style.js +44 -58
  7. package/build/AutoGrid/index.js +66 -48
  8. package/build/AutoGrid/style.d.ts +3 -4
  9. package/build/AutoGrid/style.js +13 -22
  10. package/build/CarouselNotice/index.js +22 -19
  11. package/build/CarouselNotice/style.js +12 -14
  12. package/build/CitySelect/data.d.ts +3 -0
  13. package/build/CitySelect/data.js +2355 -0
  14. package/build/CitySelect/index.d.ts +17 -0
  15. package/build/CitySelect/index.js +300 -0
  16. package/build/CitySelect/search.d.ts +2 -0
  17. package/build/CitySelect/search.js +70 -0
  18. package/build/CitySelect/style.d.ts +4 -0
  19. package/build/CitySelect/style.js +237 -0
  20. package/build/CitySelect/type.d.ts +17 -0
  21. package/build/CitySelect/type.js +2 -0
  22. package/build/Clickable/index.d.ts +1 -0
  23. package/build/Clickable/index.js +113 -31
  24. package/build/Container/index.js +62 -47
  25. package/build/Countdowner/index.js +50 -14
  26. package/build/Dialog/Wrapper.js +13 -10
  27. package/build/Dialog/index.js +18 -12
  28. package/build/Dialog/style.js +29 -25
  29. package/build/Effect/useInterval.js +7 -4
  30. package/build/Effect/useTick.js +9 -6
  31. package/build/Effect/useUpdate.js +6 -3
  32. package/build/Effect/useViewport.js +15 -8
  33. package/build/Effect/useWindowResize.js +7 -4
  34. package/build/Fixed/index.d.ts +5 -0
  35. package/build/Fixed/index.js +40 -0
  36. package/build/Flex/Col.js +23 -15
  37. package/build/Flex/Row.js +23 -15
  38. package/build/Flex/index.js +9 -5
  39. package/build/Indicator/index.js +24 -18
  40. package/build/Indicator/style.js +6 -3
  41. package/build/Loading/Wrapper.js +14 -11
  42. package/build/Loading/index.js +17 -10
  43. package/build/Loading/style.js +25 -23
  44. package/build/Overlay/index.js +15 -31
  45. package/build/SafeArea/index.js +8 -5
  46. package/build/ScrollView/index.js +24 -21
  47. package/build/ScrollView/style.js +16 -14
  48. package/build/Toast/Toast.js +53 -17
  49. package/build/Toast/index.js +21 -14
  50. package/build/Toast/style.js +31 -30
  51. package/build/index.d.ts +2 -2
  52. package/build/index.js +102 -36
  53. package/build/utils/Countdown.js +7 -3
  54. package/build/utils/ago.js +10 -4
  55. package/build/utils/calendarTable.js +9 -3
  56. package/build/utils/createApp.d.ts +1 -2
  57. package/build/utils/createApp.js +35 -31
  58. package/build/utils/cssUtil.d.ts +0 -9
  59. package/build/utils/cssUtil.js +10 -43
  60. package/build/utils/defaultScroll.js +4 -1
  61. package/build/utils/dom.js +6 -3
  62. package/build/utils/is.js +6 -2
  63. package/build/utils/jsonp.js +4 -1
  64. package/build/utils/request.js +40 -27
  65. package/build/utils/tick.js +4 -1
  66. package/build/utils/uniqKey.js +4 -1
  67. package/build/utils/wait.js +8 -4
  68. package/package.json +1 -1
  69. package/test/src/city-select/index.jsx +21 -0
  70. package/test/src/dialog/index.module.css +1 -1
  71. package/test/src/index/index.jsx +1 -0
  72. package/test/vite.config.js +6 -2
  73. package/build/context.d.ts +0 -15
  74. package/build/context.js +0 -24
@@ -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.5",
3
+ "version": "2.1.7",
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
+ }
@@ -1,5 +1,5 @@
1
1
  .contentBox {
2
- width: 7.5rem * 0.8;
2
+ width: calc(7.5rem * 0.8);
3
3
  height: 4rem;
4
4
  background: goldenrod;
5
5
  }
@@ -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() {
@@ -4,10 +4,14 @@ import path from "path";
4
4
 
5
5
  // https://vite.dev/config/
6
6
  export default defineConfig({
7
- plugins: [react()],
7
+ plugins: [
8
+ react({
9
+ jsxImportSource: "@emotion/react",
10
+ }),
11
+ ],
8
12
  resolve: {
9
13
  alias: {
10
- "@": path.resolve(__dirname, "../build/index"),
14
+ "@": path.resolve(__dirname, "../src/index.ts"),
11
15
  react: path.resolve(__dirname, "node_modules/react"),
12
16
  "react-dom": path.resolve(__dirname, "node_modules/react-dom"),
13
17
  },
@@ -1,15 +0,0 @@
1
- export interface ContextValue {
2
- maxDocWidth: number;
3
- minDocWidth: number;
4
- }
5
- /**
6
- * 设置环境变量的值
7
- * @param envValue
8
- */
9
- export declare function setContextValue(value: Partial<ContextValue>): void;
10
- /**
11
- * 获取环境变量值
12
- * @param key
13
- * @returns
14
- */
15
- export declare function getContextValue(key?: keyof ContextValue): number | ContextValue;
package/build/context.js DELETED
@@ -1,24 +0,0 @@
1
- let context = {
2
- maxDocWidth: 576,
3
- minDocWidth: 312,
4
- };
5
- /**
6
- * 设置环境变量的值
7
- * @param envValue
8
- */
9
- export function setContextValue(value) {
10
- if (typeof context === "object") {
11
- context = Object.assign(Object.assign({}, context), value);
12
- }
13
- }
14
- /**
15
- * 获取环境变量值
16
- * @param key
17
- * @returns
18
- */
19
- export function getContextValue(key) {
20
- if (key && typeof key === "string") {
21
- return context[key];
22
- }
23
- return context;
24
- }