clxx 2.0.6 → 2.0.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.
package/README.md CHANGED
@@ -1,3 +1,2 @@
1
1
  # v2.0.0
2
2
 
3
- Completely reconstructed,Documentation coming soon...
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
  /**
3
3
  * 可触摸元素的属性,兼容PC
4
4
  */
@@ -10,8 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
13
- import { useCallback, useRef, useState, useEffect, } from "react";
14
- import { is } from "../utils/is";
13
+ import { useCallback, useRef, useState, useEffect, } from 'react';
14
+ import { is } from '../utils/is';
15
15
  export function Clickable(props) {
16
16
  let { children, bubble = true, className, activeClassName, style, activeStyle, disable = false } = props, attrs = __rest(props, ["children", "bubble", "className", "activeClassName", "style", "activeStyle", "disable"]);
17
17
  // 如果激活样式和激活类都不存在,则设置激活默认样式
@@ -20,9 +20,14 @@ export function Clickable(props) {
20
20
  opacity: 0.6,
21
21
  };
22
22
  }
23
- const touchable = is("touchable");
23
+ const touchable = is('touchable');
24
24
  const [boxClass, setBoxClass] = useState(className);
25
25
  const [boxStyle, setBoxStyle] = useState(style);
26
+ // 监控属性的更新
27
+ useEffect(() => {
28
+ setBoxClass(className);
29
+ setBoxStyle(style);
30
+ }, [className, style]);
26
31
  // 标记是否正处于触摸状态
27
32
  const touchRef = useRef(false);
28
33
  const onStart = (event) => {
@@ -33,13 +38,13 @@ export function Clickable(props) {
33
38
  event.stopPropagation();
34
39
  }
35
40
  // 激活目标样式
36
- if (typeof activeClassName === "string") {
37
- setBoxClass(typeof boxClass === "string"
41
+ if (typeof activeClassName === 'string') {
42
+ setBoxClass(typeof boxClass === 'string'
38
43
  ? `${boxClass} ${activeClassName}`
39
44
  : activeClassName);
40
45
  }
41
- if (typeof activeStyle === "object") {
42
- setBoxStyle(typeof boxStyle === "object"
46
+ if (typeof activeStyle === 'object') {
47
+ setBoxStyle(typeof boxStyle === 'object'
43
48
  ? Object.assign(Object.assign({}, boxStyle), activeStyle) : activeStyle);
44
49
  }
45
50
  }
@@ -56,9 +61,9 @@ export function Clickable(props) {
56
61
  useEffect(() => {
57
62
  if (!disable && !touchable) {
58
63
  const doc = document.documentElement;
59
- doc.addEventListener("mouseup", onEnd);
64
+ doc.addEventListener('mouseup', onEnd);
60
65
  return () => {
61
- doc.removeEventListener("mouseup", onEnd);
66
+ doc.removeEventListener('mouseup', onEnd);
62
67
  };
63
68
  }
64
69
  }, [disable, touchable, onEnd]);
@@ -1,7 +1,7 @@
1
1
  import { Keyframes } from "@emotion/serialize";
2
2
  export declare const maskHide: Keyframes;
3
- export declare type DialogType = "center" | "pullUp" | "pullDown" | "pullLeft" | "pullRight";
4
- export declare type AnimationStatus = "show" | "hide";
3
+ export type DialogType = "center" | "pullUp" | "pullDown" | "pullLeft" | "pullRight";
4
+ export type AnimationStatus = "show" | "hide";
5
5
  export declare function getAnimation(type: DialogType, status: AnimationStatus): {
6
6
  keyframes: Keyframes;
7
7
  animation: import("@emotion/utils").SerializedStyles;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import * as CSS from "csstype";
2
+ import * as CSS from 'csstype';
3
3
  export interface FlexProps extends React.HTMLProps<HTMLDivElement> {
4
4
  children?: React.ReactNode;
5
5
  alignItems?: CSS.Property.AlignItems;
@@ -11,9 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
13
13
  export function Flex(props) {
14
- const { children, alignItems = "center", alignContent, justifyContent, flexFlow, flexWrap, flexDirection } = props, extra = __rest(props, ["children", "alignItems", "alignContent", "justifyContent", "flexFlow", "flexWrap", "flexDirection"]);
14
+ const { children, alignItems = 'center', alignContent, justifyContent, flexFlow, flexWrap, flexDirection } = props, extra = __rest(props, ["children", "alignItems", "alignContent", "justifyContent", "flexFlow", "flexWrap", "flexDirection"]);
15
15
  return (_jsx("div", Object.assign({ css: {
16
- display: "flex",
16
+ display: 'flex',
17
17
  alignItems,
18
18
  alignContent,
19
19
  justifyContent,
package/build/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { setContextValue, getContextValue } from "./context";
3
3
  export { jsonp } from "./utils/jsonp";
4
4
  export { uniqKey } from "./utils/uniqKey";
5
5
  export { ago } from "./utils/ago";
6
- export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption } from "./utils/request";
6
+ export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption, registerHostAlias } from "./utils/request";
7
7
  export { calendarTable } from "./utils/calendarTable";
8
8
  export { Countdown } from "./utils/Countdown";
9
9
  export { defaultScroll } from "./utils/defaultScroll";
package/build/index.js CHANGED
@@ -3,7 +3,7 @@ export { setContextValue, getContextValue } from "./context";
3
3
  export { jsonp } from "./utils/jsonp";
4
4
  export { uniqKey } from "./utils/uniqKey";
5
5
  export { ago } from "./utils/ago";
6
- export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption } from "./utils/request";
6
+ export { GET, POST, sendJSON, sugarSend, sendRequest, buildUrlByOption, registerHostAlias } from "./utils/request";
7
7
  export { calendarTable } from "./utils/calendarTable";
8
8
  export { Countdown } from "./utils/Countdown";
9
9
  export { defaultScroll } from "./utils/defaultScroll";
@@ -1,8 +1,8 @@
1
- export declare type CountdownValueIndex = "d" | "h" | "i" | "s";
2
- export declare type CountdownValue = {
1
+ export type CountdownValueIndex = "d" | "h" | "i" | "s";
2
+ export type CountdownValue = {
3
3
  [key in CountdownValueIndex]?: number;
4
4
  };
5
- export declare type UpdateCallback = (value: CountdownValue) => void;
5
+ export type UpdateCallback = (value: CountdownValue) => void;
6
6
  export interface CountdownOption {
7
7
  remain?: number | string;
8
8
  onUpdate?: UpdateCallback;
@@ -1,5 +1,5 @@
1
1
  import dayjs from 'dayjs';
2
- export declare type AgoValue = {
2
+ export type AgoValue = {
3
3
  num: number;
4
4
  unit: 'y' | 'm' | 'd' | 'h' | 'i' | 's';
5
5
  format: string;
@@ -2,12 +2,12 @@ import React from 'react';
2
2
  import { History } from 'history';
3
3
  import { ContainerProps } from '../Container';
4
4
  import { ContextValue } from '../context';
5
- export declare type RouteMethod = 'browser' | 'hash' | 'memory';
6
- export declare type AwaitValue<T> = T | Promise<T>;
5
+ export type RouteMethod = 'browser' | 'hash' | 'memory';
6
+ export type AwaitValue<T> = T | Promise<T>;
7
7
  export interface CreateAppOption extends Omit<ContainerProps, 'children'>, ContextValue {
8
8
  onBeforeRenderPage?: (pathname?: string) => AwaitValue<void>;
9
9
  onAfterRenderPage?: (pathname?: string) => AwaitValue<void>;
10
- renderLoading?: (pathname?: string) => AwaitValue<React.ReactNode>;
10
+ onLoadingPage?: (pathname?: string) => AwaitValue<React.ReactNode>;
11
11
  renderPage?: (pathname?: string) => AwaitValue<React.ReactNode>;
12
12
  routeMethod?: RouteMethod;
13
13
  defaultRoute?: string;
@@ -51,7 +51,7 @@ export function createApp(option) {
51
51
  'designWidth',
52
52
  'globalStyle',
53
53
  ]);
54
- const { onBeforeRenderPage, onAfterRenderPage, renderLoading, renderPage } = option;
54
+ const { onBeforeRenderPage, onAfterRenderPage, onLoadingPage, renderPage } = option;
55
55
  // 设置上下文属性
56
56
  setContextValue(context);
57
57
  /**
@@ -70,8 +70,8 @@ export function createApp(option) {
70
70
  pathname = option.defaultRoute.replace(pathReg, '');
71
71
  }
72
72
  // 如果有loading,要先显示loading
73
- if (typeof renderLoading === 'function') {
74
- setPage(yield (renderLoading === null || renderLoading === void 0 ? void 0 : renderLoading(pathname)));
73
+ if (typeof onLoadingPage === 'function') {
74
+ setPage(yield (onLoadingPage === null || onLoadingPage === void 0 ? void 0 : onLoadingPage(pathname)));
75
75
  }
76
76
  // 加载页面之前可能会存在的逻辑
77
77
  yield (onBeforeRenderPage === null || onBeforeRenderPage === void 0 ? void 0 : onBeforeRenderPage(pathname));
@@ -7,8 +7,8 @@
7
7
  * params: 请求体为URLSearchParams,data为JSON对象或URLSearchParams
8
8
  * buffer: 请求体data只能为ArrayBuffer、TypeArray、DataView
9
9
  */
10
- export declare type SendType = "normal" | "text" | "form" | "json" | "blob" | "params" | "buffer";
11
- export declare type SendDataType = BodyInit | Record<string, any>;
10
+ export type SendType = "normal" | "text" | "form" | "json" | "blob" | "params" | "buffer";
11
+ export type SendDataType = BodyInit | Record<string, any>;
12
12
  /**
13
13
  * 请求对象参数
14
14
  */
@@ -20,8 +20,8 @@ export interface RequestOption extends RequestInit {
20
20
  transmitPageParam?: boolean;
21
21
  timeout?: number;
22
22
  }
23
- export declare type BuildUrlOption = Pick<RequestOption, "url" | "data" | "disableUrlCache" | "transmitPageParam" | "sendType">;
24
- export declare type StandardAjaxResult = {
23
+ export type BuildUrlOption = Pick<RequestOption, "url" | "data" | "disableUrlCache" | "transmitPageParam" | "sendType">;
24
+ export type StandardAjaxResult = {
25
25
  code: number;
26
26
  message?: string;
27
27
  data?: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clxx",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Basic JS library for mobile devices",
5
5
  "main": "./build/index.js",
6
6
  "module": "./build/index.js",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "start": "tsc -w --pretty",
12
- "build": "node ./scripts/clear.js && tsc"
12
+ "build": "rm -rfv ./build && tsc"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -33,20 +33,18 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@emotion/react": "^11.10.0",
36
+ "@emotion/react": "^11.10.6",
37
37
  "dayjs": "^1.11.5",
38
38
  "history": "^5.3.0",
39
39
  "lodash": "^4.17.21",
40
40
  "react": "^18.2.0",
41
- "react-dom": "^18.2.0",
42
- "swiper": "^8.3.2"
41
+ "react-dom": "^18.2.0"
43
42
  },
44
43
  "devDependencies": {
45
44
  "@types/lodash": "^4.14.182",
46
- "@types/react": "^18.0.17",
47
- "@types/react-dom": "^18.0.6",
48
- "@types/swiper": "^6.0.0",
45
+ "@types/react": "^18.0.37",
46
+ "@types/react-dom": "^18.0.11",
49
47
  "csstype": "^3.1.0",
50
- "typescript": "^4.7.4"
48
+ "typescript": "^4.9.5"
51
49
  }
52
50
  }