clxx 2.0.3 → 2.0.6

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 (76) hide show
  1. package/build/Ago/index.d.ts +3 -5
  2. package/build/Ago/index.js +6 -7
  3. package/build/Alert/Wrapper.d.ts +3 -4
  4. package/build/Alert/Wrapper.js +10 -17
  5. package/build/Alert/index.d.ts +2 -2
  6. package/build/Alert/index.js +9 -10
  7. package/build/Alert/style.js +1 -0
  8. package/build/AutoGrid/index.d.ts +4 -5
  9. package/build/AutoGrid/index.js +19 -21
  10. package/build/CarouselNotice/index.d.ts +4 -5
  11. package/build/CarouselNotice/index.js +20 -21
  12. package/build/Clickable/index.d.ts +1 -1
  13. package/build/Clickable/index.js +3 -2
  14. package/build/Container/index.d.ts +3 -4
  15. package/build/Container/index.js +37 -39
  16. package/build/Countdowner/index.d.ts +4 -5
  17. package/build/Countdowner/index.js +13 -14
  18. package/build/Dialog/Wrapper.d.ts +2 -2
  19. package/build/Dialog/Wrapper.js +6 -9
  20. package/build/Dialog/index.d.ts +3 -3
  21. package/build/Dialog/index.js +21 -12
  22. package/build/{effect → Effect}/useInterval.d.ts +0 -0
  23. package/build/{effect → Effect}/useInterval.js +0 -0
  24. package/build/{effect → Effect}/useTick.d.ts +0 -0
  25. package/build/{effect → Effect}/useTick.js +4 -2
  26. package/build/Effect/useUpdate.d.ts +5 -0
  27. package/build/Effect/useUpdate.js +10 -0
  28. package/build/{effect → Effect}/useViewport.d.ts +0 -0
  29. package/build/{effect → Effect}/useViewport.js +0 -0
  30. package/build/{effect → Effect}/useWindowResize.d.ts +0 -0
  31. package/build/{effect → Effect}/useWindowResize.js +0 -0
  32. package/build/Flex/Col.d.ts +7 -9
  33. package/build/Flex/Col.js +14 -15
  34. package/build/Flex/Row.d.ts +7 -9
  35. package/build/Flex/Row.js +14 -15
  36. package/build/Flex/index.d.ts +2 -4
  37. package/build/Flex/index.js +5 -6
  38. package/build/Indicator/index.d.ts +4 -5
  39. package/build/Indicator/index.js +14 -15
  40. package/build/Loading/Wrapper.d.ts +7 -8
  41. package/build/Loading/Wrapper.js +14 -18
  42. package/build/Loading/index.d.ts +1 -1
  43. package/build/Loading/index.js +10 -11
  44. package/build/Overlay/index.d.ts +2 -4
  45. package/build/Overlay/index.js +15 -17
  46. package/build/SafeArea/index.d.ts +2 -4
  47. package/build/SafeArea/index.js +7 -8
  48. package/build/ScrollView/index.d.ts +2 -2
  49. package/build/ScrollView/index.js +12 -11
  50. package/build/Toast/Toast.d.ts +2 -2
  51. package/build/Toast/Toast.js +4 -5
  52. package/build/Toast/index.d.ts +2 -2
  53. package/build/Toast/index.js +13 -11
  54. package/build/Toast/style.d.ts +1 -1
  55. package/build/Toast/style.js +1 -1
  56. package/build/index.d.ts +4 -5
  57. package/build/index.js +4 -5
  58. package/build/utils/Countdown.d.ts +1 -2
  59. package/build/utils/Countdown.js +4 -2
  60. package/build/utils/createApp.d.ts +8 -8
  61. package/build/utils/createApp.js +29 -23
  62. package/build/utils/dom.d.ts +5 -5
  63. package/build/utils/dom.js +14 -27
  64. package/build/utils/request.js +4 -3
  65. package/build/utils/tick.d.ts +11 -5
  66. package/build/utils/tick.js +28 -24
  67. package/build/utils/wait.js +5 -4
  68. package/package.json +15 -15
  69. package/build/Picker/Wrapper.d.ts +0 -20
  70. package/build/Picker/Wrapper.js +0 -92
  71. package/build/Picker/index.d.ts +0 -21
  72. package/build/Picker/index.js +0 -64
  73. package/build/Picker/style.d.ts +0 -3
  74. package/build/Picker/style.js +0 -122
  75. package/build/Picker/swiperStyle.d.ts +0 -1
  76. package/build/Picker/swiperStyle.js +0 -66
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { tick } from "./tick";
10
+ import { Tick } from "./tick";
11
11
  /**
12
12
  * 直接条件为真或者超时才返回结果
13
13
  *
@@ -29,19 +29,19 @@ export function waitUntil(condition, maxTime) {
29
29
  maxTime = Infinity;
30
30
  }
31
31
  return new Promise((resolve) => {
32
- const stop = tick(() => {
32
+ const tick = new Tick(() => {
33
33
  const now = Date.now();
34
34
  const result = condition();
35
35
  // 超时返回false
36
36
  if (now - start >= maxTime) {
37
- stop();
37
+ tick.destroy();
38
38
  resolve(false);
39
39
  return;
40
40
  }
41
41
  // 处理结果
42
42
  const handle = (res) => {
43
43
  if (res) {
44
- stop();
44
+ tick.destroy();
45
45
  resolve(true);
46
46
  }
47
47
  };
@@ -53,6 +53,7 @@ export function waitUntil(condition, maxTime) {
53
53
  // 普通一般的结果
54
54
  handle(result);
55
55
  });
56
+ tick.start();
56
57
  });
57
58
  });
58
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clxx",
3
- "version": "2.0.3",
3
+ "version": "2.0.6",
4
4
  "description": "Basic JS library for mobile devices",
5
5
  "main": "./build/index.js",
6
6
  "module": "./build/index.js",
@@ -32,21 +32,21 @@
32
32
  "registry": "https://registry.npmjs.org",
33
33
  "access": "public"
34
34
  },
35
- "devDependencies": {
36
- "@types/lodash": "^4.14.175",
37
- "@types/react": "^17.0.27",
38
- "@types/react-dom": "^17.0.9",
39
- "@types/swiper": "^5.4.3",
40
- "csstype": "^3.0.9",
41
- "typescript": "^4.4.3"
42
- },
43
35
  "dependencies": {
44
- "@emotion/react": "^11.4.1",
45
- "dayjs": "^1.10.7",
46
- "history": "^5.0.1",
36
+ "@emotion/react": "^11.10.0",
37
+ "dayjs": "^1.11.5",
38
+ "history": "^5.3.0",
47
39
  "lodash": "^4.17.21",
48
- "react": "^17.0.2",
49
- "react-dom": "^17.0.2",
50
- "swiper": "^6.8.4"
40
+ "react": "^18.2.0",
41
+ "react-dom": "^18.2.0",
42
+ "swiper": "^8.3.2"
43
+ },
44
+ "devDependencies": {
45
+ "@types/lodash": "^4.14.182",
46
+ "@types/react": "^18.0.17",
47
+ "@types/react-dom": "^18.0.6",
48
+ "@types/swiper": "^6.0.0",
49
+ "csstype": "^3.1.0",
50
+ "typescript": "^4.7.4"
51
51
  }
52
52
  }
@@ -1,20 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from "@emotion/react";
3
- import React from "react";
4
- export declare type OptionType = {
5
- value: string | number;
6
- label?: React.ReactNode;
7
- [key: string]: any;
8
- };
9
- export interface PickerWrapperProps {
10
- options: OptionType[];
11
- defaultValue?: number;
12
- renderOption?: (option: OptionType, index: number) => React.ReactNode;
13
- onConfirm?: (option: OptionType, index: number) => void;
14
- onCancel?: () => void;
15
- renderCancel?: () => React.ReactNode;
16
- renderConfirm?: () => React.ReactNode;
17
- showTitle?: boolean;
18
- renderTitle?: (option: OptionType, index: number) => React.ReactNode;
19
- }
20
- export declare function Wrapper(props: PickerWrapperProps): jsx.JSX.Element;
@@ -1,92 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from "@emotion/react";
3
- import { RowBetween } from "../Flex/Row";
4
- import { Col } from "../Flex/Col";
5
- import { style } from "./style";
6
- import { swiperStyle } from "./swiperStyle";
7
- import { Clickable } from "../Clickable";
8
- import Swiper from "swiper";
9
- import { useCallback, useEffect, useRef, useState } from "react";
10
- export function Wrapper(props) {
11
- const { onConfirm, onCancel, renderCancel, renderConfirm, options, renderOption, showTitle = true, renderTitle, defaultValue, } = props;
12
- // 获取初始索引
13
- const getInitialSlide = useCallback(() => {
14
- let initialSlide = 0;
15
- if (Array.isArray(options)) {
16
- let findIndex = options.findIndex((option) => option.value === defaultValue);
17
- if (findIndex >= 0) {
18
- initialSlide = findIndex;
19
- }
20
- }
21
- return initialSlide;
22
- }, [options, defaultValue]);
23
- const swiperRef = useRef(null);
24
- const [index, setIndex] = useState(getInitialSlide());
25
- useEffect(() => {
26
- const swiper = new Swiper(swiperRef.current, {
27
- initialSlide: getInitialSlide(),
28
- direction: "vertical",
29
- slidesPerView: 5,
30
- centeredSlides: true,
31
- freeMode: true,
32
- freeModeSticky: true,
33
- });
34
- swiper.on("init", () => {
35
- setIndex(swiper.realIndex);
36
- });
37
- swiper.on("slideChange", () => {
38
- setIndex(swiper.realIndex);
39
- });
40
- return () => {
41
- swiper.destroy();
42
- };
43
- }, [getInitialSlide]);
44
- // 显示标题逻辑
45
- const showTitleContent = () => {
46
- if (showTitle) {
47
- const option = options[index];
48
- if (typeof renderTitle === "function") {
49
- return jsx("div", { css: style.title }, renderTitle(option, index));
50
- }
51
- else {
52
- return (jsx(Col, { css: style.title },
53
- jsx("span", { css: style.titleLabel }, "\u5F53\u524D\u9009\u62E9"),
54
- jsx("span", { css: style.titleContent }, option.label)));
55
- }
56
- }
57
- };
58
- // 按钮逻辑
59
- const showCancel = () => {
60
- var _a;
61
- return (_a = renderCancel === null || renderCancel === void 0 ? void 0 : renderCancel()) !== null && _a !== void 0 ? _a : jsx("div", { css: [style.btn, style.btnCancel] }, "\u53D6\u6D88");
62
- };
63
- const showConfirm = () => {
64
- var _a;
65
- return (_a = renderConfirm === null || renderConfirm === void 0 ? void 0 : renderConfirm()) !== null && _a !== void 0 ? _a : jsx("div", { css: [style.btn, style.btnConfirm] }, "\u786E\u5B9A");
66
- };
67
- /**
68
- * 显示选项列表
69
- * @returns
70
- */
71
- const showOptions = () => {
72
- if (Array.isArray(options)) {
73
- return options.map((option, index) => {
74
- let content = option.label;
75
- if (typeof renderOption === "function") {
76
- content = renderOption(option, index);
77
- }
78
- return (jsx("div", { className: "swiper-slide", key: option.value }, content));
79
- });
80
- }
81
- };
82
- return (jsx("div", { css: [style.container] },
83
- jsx(RowBetween, { css: style.header },
84
- showTitleContent(),
85
- jsx(Clickable, { css: style.btnBox, onClick: onCancel }, showCancel()),
86
- jsx(Clickable, { css: style.btnBox, onClick: () => onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(options[index], index) }, showConfirm())),
87
- jsx("div", { css: [swiperStyle, style.body] },
88
- jsx("div", { className: "swiper", css: style.swiper, ref: swiperRef },
89
- jsx("div", { className: "swiper-wrapper" }, showOptions()),
90
- jsx("div", { css: [style.mask, style.maskTop] }),
91
- jsx("div", { css: [style.mask, style.maskBottom] })))));
92
- }
@@ -1,21 +0,0 @@
1
- import { PickerWrapperProps } from "./Wrapper";
2
- import React from "react";
3
- export interface ShowPickerOption extends PickerWrapperProps {
4
- blankClosable?: boolean;
5
- showMask?: boolean;
6
- maskColor?: string;
7
- }
8
- export interface PickerOption extends ShowPickerOption, Omit<React.HTMLProps<HTMLDivElement>, "defaultValue"> {
9
- children?: React.ReactNode;
10
- }
11
- /**
12
- * 显示picker
13
- * @param option
14
- */
15
- export declare function showPicker(option: ShowPickerOption): void;
16
- /**
17
- * picker组件
18
- * @param props
19
- * @returns
20
- */
21
- export declare function Picker(props: PickerOption): JSX.Element;
@@ -1,64 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { showDialog } from "../Dialog";
13
- import { Wrapper } from "./Wrapper";
14
- import React from "react";
15
- import pick from "lodash/pick";
16
- import omit from "lodash/omit";
17
- /**
18
- * 显示picker
19
- * @param option
20
- */
21
- export function showPicker(option) {
22
- const { blankClosable, showMask, maskColor, onCancel, onConfirm } = option, extra = __rest(option, ["blankClosable", "showMask", "maskColor", "onCancel", "onConfirm"]);
23
- const stop = showDialog({
24
- content: (React.createElement(Wrapper, Object.assign({}, extra, { onCancel: () => {
25
- stop();
26
- onCancel === null || onCancel === void 0 ? void 0 : onCancel();
27
- }, onConfirm: (option, index) => {
28
- stop();
29
- onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(option, index);
30
- } }))),
31
- type: "pullUp",
32
- blankClosable,
33
- showMask,
34
- maskColor,
35
- });
36
- }
37
- /**
38
- * picker组件
39
- * @param props
40
- * @returns
41
- */
42
- export function Picker(props) {
43
- const { children, onClick } = props, option = __rest(props, ["children", "onClick"]);
44
- const pickerProps = [
45
- "blankClosable",
46
- "showMask",
47
- "maskColor",
48
- "options",
49
- "defaultValue",
50
- "renderOption",
51
- "onConfirm",
52
- "onCancel",
53
- "renderCancel",
54
- "renderConfirm",
55
- "showTitle",
56
- "renderTitle",
57
- ];
58
- const showPickerOption = pick(option, pickerProps);
59
- const boxProps = omit(option, pickerProps);
60
- return (React.createElement("div", Object.assign({ onClick: (event) => {
61
- onClick === null || onClick === void 0 ? void 0 : onClick(event);
62
- showPicker(showPickerOption);
63
- } }, boxProps), children));
64
- }
@@ -1,3 +0,0 @@
1
- import { Interpolation, Theme } from "@emotion/react";
2
- export declare const tinyLine: Interpolation<Theme>;
3
- export declare const style: Record<string, Interpolation<Theme>>;
@@ -1,122 +0,0 @@
1
- import { adaptive } from "../utils/cssUtil";
2
- export const tinyLine = {
3
- "&:after,&::after": {
4
- content: "''",
5
- position: "absolute",
6
- left: 0,
7
- right: 0,
8
- height: "1px",
9
- backgroundColor: "#c0c0c0",
10
- transform: `scale(1, ${1 / window.devicePixelRatio})`,
11
- },
12
- };
13
- // 标题栏和每个选项通用的高度
14
- const itemHeight = 90;
15
- export const style = {
16
- container: [
17
- {
18
- backgroundColor: "#fff",
19
- overflow: "hidden",
20
- position: "relative",
21
- },
22
- adaptive({
23
- borderTopLeftRadius: 16,
24
- borderTopRightRadius: 16,
25
- }),
26
- ],
27
- header: [
28
- {
29
- position: "relative",
30
- backgroundColor: "#fafafa",
31
- "&:after,&::after": {
32
- bottom: 0,
33
- },
34
- },
35
- tinyLine,
36
- adaptive({
37
- height: itemHeight,
38
- }),
39
- ],
40
- title: {
41
- position: "absolute",
42
- left: "50%",
43
- top: "50%",
44
- transform: "translate(-50%, -50%)",
45
- zIndex: 1,
46
- },
47
- titleLabel: [
48
- {
49
- color: "#666",
50
- lineHeight: 1,
51
- },
52
- adaptive({
53
- fontSize: 20,
54
- marginBottom: 5,
55
- }),
56
- ],
57
- titleContent: [
58
- {
59
- color: "#333",
60
- lineHeight: 1,
61
- },
62
- adaptive({
63
- fontSize: 28,
64
- }),
65
- ],
66
- btnBox: {
67
- zIndex: 2,
68
- },
69
- btn: [
70
- { textAlign: "center", lineHeight: 2 },
71
- adaptive({
72
- width: 120,
73
- fontSize: 32,
74
- }),
75
- ],
76
- btnCancel: {
77
- color: "#666",
78
- },
79
- btnConfirm: {
80
- color: "#007afe",
81
- },
82
- body: {
83
- overflow: "hidden",
84
- position: "relative",
85
- },
86
- swiper: [
87
- adaptive({ height: itemHeight * 5, fontSize: 32 }),
88
- {
89
- ".swiper-slide": {
90
- display: "flex",
91
- justifyContent: "center",
92
- alignItems: "center",
93
- },
94
- },
95
- ],
96
- mask: [
97
- {
98
- position: "absolute",
99
- left: 0,
100
- width: "100%",
101
- zIndex: 2,
102
- },
103
- tinyLine,
104
- adaptive({
105
- height: itemHeight * 2,
106
- }),
107
- ],
108
- maskTop: {
109
- top: 0,
110
- backgroundImage: "linear-gradient(180deg, #fefefe, transparent)",
111
- "&:after,&::after": {
112
- bottom: 0,
113
- },
114
- },
115
- maskBottom: {
116
- backgroundImage: "linear-gradient(0deg, #fefefe, transparent)",
117
- bottom: 0,
118
- "&:after,&::after": {
119
- top: 0,
120
- },
121
- },
122
- };
@@ -1 +0,0 @@
1
- export declare const swiperStyle: import("@emotion/utils").SerializedStyles;
@@ -1,66 +0,0 @@
1
- import { css } from "@emotion/react";
2
- export const swiperStyle = css `
3
- .swiper-container {
4
- margin-left: auto;
5
- margin-right: auto;
6
- position: relative;
7
- overflow: hidden;
8
- list-style: none;
9
- padding: 0;
10
- z-index: 1;
11
- }
12
- .swiper-container-vertical > .swiper-wrapper {
13
- flex-direction: column;
14
- }
15
- .swiper-wrapper {
16
- position: relative;
17
- width: 100%;
18
- height: 100%;
19
- z-index: 1;
20
- display: flex;
21
- transition-property: transform;
22
- box-sizing: content-box;
23
- }
24
- .swiper-container-android .swiper-slide,
25
- .swiper-wrapper {
26
- transform: translate3d(0px, 0, 0);
27
- }
28
- .swiper-container-multirow > .swiper-wrapper {
29
- flex-wrap: wrap;
30
- }
31
- .swiper-container-multirow-column > .swiper-wrapper {
32
- flex-wrap: wrap;
33
- flex-direction: column;
34
- }
35
- .swiper-container-free-mode > .swiper-wrapper {
36
- transition-timing-function: ease-out;
37
- margin: 0 auto;
38
- }
39
- .swiper-container-pointer-events {
40
- touch-action: pan-y;
41
- &.swiper-container-vertical {
42
- touch-action: pan-x;
43
- }
44
- }
45
- .swiper-slide {
46
- flex-shrink: 0;
47
- width: 100%;
48
- height: 100%;
49
- position: relative;
50
- transition-property: transform;
51
- }
52
- .swiper-slide-invisible-blank {
53
- visibility: hidden;
54
- }
55
- .swiper-container-autoheight {
56
- &,
57
- .swiper-slide {
58
- height: auto;
59
- }
60
-
61
- .swiper-wrapper {
62
- align-items: flex-start;
63
- transition-property: transform, height;
64
- }
65
- }
66
- `;