@zero-bits/taro-components 1.0.6 → 1.1.0
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/components/Permission/PermissionProvider.js +35 -1
- package/es/components/Permission/index.js +2 -1
- package/es/components/Permission/store.js +158 -1
- package/es/components/Text/index.js +136 -1
- package/es/components/View/index.d.ts +10 -0
- package/es/components/View/index.js +220 -1
- package/es/components/index.js +3 -1
- package/es/context/index.js +6 -1
- package/es/hooks/index.js +2 -1
- package/es/hooks/usePermission.js +18 -1
- package/es/hooks/useWeappUpdate.js +33 -1
- package/es/index.js +3 -1
- package/es/styles/index.css +1 -120
- package/es/types/index.js +1 -1
- package/lib/components/Permission/PermissionProvider.js +41 -1
- package/lib/components/Permission/index.js +20 -1
- package/lib/components/Permission/store.js +164 -1
- package/lib/components/Text/index.js +145 -1
- package/lib/components/View/index.d.ts +10 -0
- package/lib/components/View/index.js +227 -1
- package/lib/components/index.js +36 -1
- package/lib/context/index.js +12 -1
- package/lib/hooks/index.js +19 -1
- package/lib/hooks/usePermission.js +24 -1
- package/lib/hooks/useWeappUpdate.js +38 -1
- package/lib/index.js +63 -1
- package/lib/styles/index.css +1 -120
- package/lib/types/index.js +5 -1
- package/package.json +24 -1
|
@@ -1 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import { useSyncExternalStore, useEffect, useRef } from 'react';
|
|
2
|
+
import { PermissionContext } from "../../context";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 权限组件 Provider 的属性
|
|
6
|
+
*
|
|
7
|
+
* @template P - 权限对象类型
|
|
8
|
+
* @template U - 用户对象类型
|
|
9
|
+
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* 权限组件的入口 Provider,通常包裹在 App 根节点
|
|
13
|
+
*
|
|
14
|
+
* @template P - 权限对象类型
|
|
15
|
+
* @template U - 用户对象类型
|
|
16
|
+
* @param {PermissionProviderProps<P, U>} props - 组件属性
|
|
17
|
+
* @returns {JSX.Element}
|
|
18
|
+
*/
|
|
19
|
+
function PermissionProvider(_ref) {
|
|
20
|
+
var children = _ref.children,
|
|
21
|
+
store = _ref.store,
|
|
22
|
+
onDenied = _ref.onDenied;
|
|
23
|
+
var state = useSyncExternalStore(store.subscribe, store.getSnapshot);
|
|
24
|
+
var prevGrantedRef = useRef(state.isGranted);
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
if (prevGrantedRef.current && !state.isGranted) onDenied === null || onDenied === void 0 || onDenied();
|
|
27
|
+
prevGrantedRef.current = state.isGranted;
|
|
28
|
+
}, [state.isGranted, onDenied]);
|
|
29
|
+
return /*#__PURE__*/_jsx(PermissionContext.Provider, {
|
|
30
|
+
value: state,
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
PermissionProvider.displayName = 'PermissionProvider';
|
|
35
|
+
export default PermissionProvider;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { default as PermissionProvider } from "./PermissionProvider";
|
|
2
|
+
export { createPermissionStore } from "./store";
|
|
@@ -1 +1,158 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
/**
|
|
11
|
+
* Store 完整接口,包含 React useSyncExternalStore 所需的 getSnapshot / subscribe
|
|
12
|
+
* 业务侧若不希望在 IDE 补全中看到 React 内部方法,可将变量显式声明为 PermissionStorePublic
|
|
13
|
+
*
|
|
14
|
+
* @template P - 权限对象类型
|
|
15
|
+
* @template U - 用户对象类型
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* 业务侧(axios 拦截器等非 React 环境)使用的 Store 公共接口
|
|
19
|
+
* 只暴露权限操作方法和销毁能力,屏蔽 React 内部机制
|
|
20
|
+
*
|
|
21
|
+
* @template P - 权限对象类型
|
|
22
|
+
* @template U - 用户对象类型
|
|
23
|
+
*/
|
|
24
|
+
var PermissionStore = /*#__PURE__*/function () {
|
|
25
|
+
/**
|
|
26
|
+
* @param adapter - 权限数据持久化适配器
|
|
27
|
+
* 类字段初始化先于构造函数体,此处 this.granted 等已绑定完毕
|
|
28
|
+
*/
|
|
29
|
+
function PermissionStore(adapter) {
|
|
30
|
+
var _this = this;
|
|
31
|
+
_classCallCheck(this, PermissionStore);
|
|
32
|
+
_defineProperty(this, "state", void 0);
|
|
33
|
+
_defineProperty(this, "listeners", new Set());
|
|
34
|
+
/**
|
|
35
|
+
* 缓存 actions 对象以保证引用稳定
|
|
36
|
+
* 注意:类字段箭头函数(granted/denied 等)在构造函数体执行前已完成初始化
|
|
37
|
+
* 因此在构造函数体中赋值 cachedActions 时,this.granted 等引用已可用
|
|
38
|
+
*/
|
|
39
|
+
_defineProperty(this, "cachedActions", void 0);
|
|
40
|
+
/**
|
|
41
|
+
* 获取当前状态快照(供 React 及内部使用)
|
|
42
|
+
* @returns {PermissionContextValue<P, U>} 权限上下文值
|
|
43
|
+
*/
|
|
44
|
+
_defineProperty(this, "getSnapshot", function () {
|
|
45
|
+
return _this.state;
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* 同步获取当前状态(供业务侧非 React 环境使用)
|
|
49
|
+
* @returns {PermissionContextValue<P, U>} 权限上下文值
|
|
50
|
+
*/
|
|
51
|
+
_defineProperty(this, "getState", function () {
|
|
52
|
+
return _this.state;
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* 订阅状态变更,返回取消订阅函数(供 useSyncExternalStore 使用)
|
|
56
|
+
* @param {() => void} listener - 状态变更时的回调
|
|
57
|
+
* @returns {() => void} 取消订阅函数
|
|
58
|
+
*/
|
|
59
|
+
_defineProperty(this, "subscribe", function (listener) {
|
|
60
|
+
_this.listeners.add(listener);
|
|
61
|
+
return function () {
|
|
62
|
+
return _this.listeners.delete(listener);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* 通知所有订阅者状态已变更
|
|
67
|
+
*/
|
|
68
|
+
_defineProperty(this, "emitChange", function () {
|
|
69
|
+
_this.listeners.forEach(function (l) {
|
|
70
|
+
return l();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* 授权方法,登录成功后调用
|
|
75
|
+
* @param {P} permission - 权限数据
|
|
76
|
+
* @param {U} [user] - 用户信息(可选,后续可通过 updateUser 补充)
|
|
77
|
+
*/
|
|
78
|
+
_defineProperty(this, "granted", function (permission, user) {
|
|
79
|
+
_this.adapter.savePermission(permission);
|
|
80
|
+
if (user !== undefined) {
|
|
81
|
+
_this.adapter.saveUser(user);
|
|
82
|
+
}
|
|
83
|
+
_this.state = _this.buildState(permission, user);
|
|
84
|
+
_this.emitChange();
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* 取消授权,清空所有持久化数据并通知订阅者
|
|
88
|
+
*/
|
|
89
|
+
_defineProperty(this, "denied", function () {
|
|
90
|
+
_this.adapter.clear();
|
|
91
|
+
_this.state = _this.buildState();
|
|
92
|
+
_this.emitChange();
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* 更新用户信息(部分字段覆盖,不影响权限数据)
|
|
96
|
+
* @param {Partial<U>} userInfo - 需要更新的字段
|
|
97
|
+
*/
|
|
98
|
+
_defineProperty(this, "updateUser", function (userInfo) {
|
|
99
|
+
var nextUser = _objectSpread(_objectSpread({}, _this.state.user), userInfo);
|
|
100
|
+
_this.adapter.saveUser(nextUser);
|
|
101
|
+
_this.state = _this.buildState(_this.state.permission, nextUser);
|
|
102
|
+
_this.emitChange();
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* 更新权限数据(部分字段覆盖,例如无感刷新 token 后调用)
|
|
106
|
+
* @param {Partial<P>} permissionInfo - 需要更新的权限字段
|
|
107
|
+
*/
|
|
108
|
+
_defineProperty(this, "updatePermission", function (permissionInfo) {
|
|
109
|
+
var nextPermission = _objectSpread(_objectSpread({}, _this.state.permission), permissionInfo);
|
|
110
|
+
_this.adapter.savePermission(nextPermission);
|
|
111
|
+
_this.state = _this.buildState(nextPermission, _this.state.user);
|
|
112
|
+
_this.emitChange();
|
|
113
|
+
});
|
|
114
|
+
/** 销毁 Store,清除所有订阅者 */
|
|
115
|
+
_defineProperty(this, "destroy", function () {
|
|
116
|
+
_this.listeners.clear();
|
|
117
|
+
});
|
|
118
|
+
this.adapter = adapter;
|
|
119
|
+
this.cachedActions = {
|
|
120
|
+
granted: this.granted,
|
|
121
|
+
denied: this.denied,
|
|
122
|
+
updateUser: this.updateUser,
|
|
123
|
+
updatePermission: this.updatePermission
|
|
124
|
+
};
|
|
125
|
+
var _permission = adapter.loadPermission();
|
|
126
|
+
var _user = adapter.loadUser();
|
|
127
|
+
this.state = this.buildState(_permission instanceof Promise ? undefined : _permission, _user instanceof Promise ? undefined : _user);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 构建状态快照,复用 cachedActions 保证方法引用稳定性
|
|
132
|
+
* @param permission - 权限数据
|
|
133
|
+
* @param user - 用户信息
|
|
134
|
+
*/
|
|
135
|
+
_createClass(PermissionStore, [{
|
|
136
|
+
key: "buildState",
|
|
137
|
+
value: function buildState(permission, user) {
|
|
138
|
+
return _objectSpread(_objectSpread({}, this.cachedActions), {}, {
|
|
139
|
+
permission: permission,
|
|
140
|
+
user: user,
|
|
141
|
+
isGranted: !!permission
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}]);
|
|
145
|
+
return PermissionStore;
|
|
146
|
+
}();
|
|
147
|
+
/**
|
|
148
|
+
* 创建权限 Store 实例
|
|
149
|
+
* 返回 PermissionStoreInternal 类型(包含完整接口)
|
|
150
|
+
* 若业务侧不希望在 IDE 中看到 React 内部方法,可将变量显式声明为 PermissionStorePublic:
|
|
151
|
+
* const store: PermissionStorePublic<P, U> = createPermissionStore(adapter)
|
|
152
|
+
*
|
|
153
|
+
* @param {PermissionAdapter<P, U>} adapter - 权限数据持久化适配器
|
|
154
|
+
* @returns {PermissionStoreInternal<P, U>} 权限 Store 实例
|
|
155
|
+
*/
|
|
156
|
+
export function createPermissionStore(adapter) {
|
|
157
|
+
return new PermissionStore(adapter);
|
|
158
|
+
}
|
|
@@ -1 +1,136 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _excluded = ["children", "clamp", "width", "height", "lineHeight", "bold", "fontSize", "color", "margin", "padding", "style", "bgColor", "mHorizontal", "mVertical", "pHorizontal", "pVertical", "mTop", "mBottom", "mLeft", "mRight", "pTop", "pBottom", "pLeft", "pRight", "className", "textAlign", "decoration", "selectable", "skeleton"];
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
import React, { forwardRef } from 'react';
|
|
11
|
+
import { Text as OrigText } from '@tarojs/components';
|
|
12
|
+
import classNames from 'classnames';
|
|
13
|
+
import "../../styles/index.css";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* 处理 px 转换
|
|
17
|
+
* @param val px|string|undefined
|
|
18
|
+
* @returns px|string|undefined
|
|
19
|
+
*/
|
|
20
|
+
var px = function px(val) {
|
|
21
|
+
if (val === undefined || val === null || val === '') return undefined;
|
|
22
|
+
return typeof val === 'number' || !isNaN(Number(val)) ? "".concat(val, "px") : String(val);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* taro weapp Text Component (Tailwind 版)
|
|
27
|
+
* - clamp: number|undefined 溢出显示行数
|
|
28
|
+
* - width: px|string|undefined 宽度
|
|
29
|
+
* - height: px|string|undefined 高度
|
|
30
|
+
* - fontSize: px|string|undefined 字体大小
|
|
31
|
+
* - lineHeight: px|string|undefined 行高
|
|
32
|
+
* - bold: boolean|number|string 字体粗细
|
|
33
|
+
* - color: string 字体颜色
|
|
34
|
+
* - bgColor: string 背景颜色
|
|
35
|
+
* - textAlign: 'left' | 'center' | 'right' | 'justify' 文本对齐方式
|
|
36
|
+
* - decoration: 'underline' | 'line-through' | 'none' 文本装饰
|
|
37
|
+
* - selectable: boolean 是否可选择
|
|
38
|
+
* - skeleton: boolean 是否为骨架屏
|
|
39
|
+
* - style: CSSProperties 自定义样式
|
|
40
|
+
* - children: ReactNode 子元素
|
|
41
|
+
* - margin: px|string|undefined 外边距
|
|
42
|
+
* - mTop: px|string|undefined 上外边距
|
|
43
|
+
* - mBottom: px|string|undefined 下外边距
|
|
44
|
+
* - mLeft: px|string|undefined 左外边距
|
|
45
|
+
* - mRight: px|string|undefined 右外边距
|
|
46
|
+
* - mHorizontal: px|string|undefined 水平外边距
|
|
47
|
+
* - mVertical: px|string|undefined 垂直外边距
|
|
48
|
+
* - padding: px|string|undefined 内边距
|
|
49
|
+
* - pTop: px|string|undefined 上内边距
|
|
50
|
+
* - pBottom: px|string|undefined 下内边距
|
|
51
|
+
* - pLeft: px|string|undefined 左内边距
|
|
52
|
+
* - pRight: px|string|undefined 右内边距
|
|
53
|
+
* - pHorizontal: px|string|undefined 水平内边距
|
|
54
|
+
* - pVertical: px|string|undefined 垂直内边距
|
|
55
|
+
* - rest: Text组件的其他属性
|
|
56
|
+
*/
|
|
57
|
+
var Text = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
58
|
+
var children = props.children,
|
|
59
|
+
clamp = props.clamp,
|
|
60
|
+
width = props.width,
|
|
61
|
+
height = props.height,
|
|
62
|
+
lineHeight = props.lineHeight,
|
|
63
|
+
bold = props.bold,
|
|
64
|
+
fontSize = props.fontSize,
|
|
65
|
+
color = props.color,
|
|
66
|
+
margin = props.margin,
|
|
67
|
+
padding = props.padding,
|
|
68
|
+
_props$style = props.style,
|
|
69
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
70
|
+
bgColor = props.bgColor,
|
|
71
|
+
mHorizontal = props.mHorizontal,
|
|
72
|
+
mVertical = props.mVertical,
|
|
73
|
+
pHorizontal = props.pHorizontal,
|
|
74
|
+
pVertical = props.pVertical,
|
|
75
|
+
mTop = props.mTop,
|
|
76
|
+
mBottom = props.mBottom,
|
|
77
|
+
mLeft = props.mLeft,
|
|
78
|
+
mRight = props.mRight,
|
|
79
|
+
pTop = props.pTop,
|
|
80
|
+
pBottom = props.pBottom,
|
|
81
|
+
pLeft = props.pLeft,
|
|
82
|
+
pRight = props.pRight,
|
|
83
|
+
className = props.className,
|
|
84
|
+
textAlign = props.textAlign,
|
|
85
|
+
decoration = props.decoration,
|
|
86
|
+
selectable = props.selectable,
|
|
87
|
+
skeleton = props.skeleton,
|
|
88
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
89
|
+
var textClassNames = classNames(className, {
|
|
90
|
+
'zero-line-clamp-1': clamp === 1,
|
|
91
|
+
'zero-line-clamp-2': clamp === 2,
|
|
92
|
+
'zero-line-clamp-3': clamp === 3,
|
|
93
|
+
'zero-line-clamp-4': clamp === 4,
|
|
94
|
+
'zero-line-clamp-5': clamp === 5,
|
|
95
|
+
'zero-line-clamp-6': clamp === 6,
|
|
96
|
+
'zero-animate-pulse zero-bg-gray-200 zero-text-transparent': skeleton
|
|
97
|
+
});
|
|
98
|
+
var textStyle = _objectSpread({
|
|
99
|
+
width: px(width),
|
|
100
|
+
height: px(height),
|
|
101
|
+
margin: px(margin),
|
|
102
|
+
marginTop: px(mTop !== null && mTop !== void 0 ? mTop : mVertical),
|
|
103
|
+
marginBottom: px(mBottom !== null && mBottom !== void 0 ? mBottom : mVertical),
|
|
104
|
+
marginLeft: px(mLeft !== null && mLeft !== void 0 ? mLeft : mHorizontal),
|
|
105
|
+
marginRight: px(mRight !== null && mRight !== void 0 ? mRight : mHorizontal),
|
|
106
|
+
padding: px(padding),
|
|
107
|
+
paddingTop: px(pTop !== null && pTop !== void 0 ? pTop : pVertical),
|
|
108
|
+
paddingBottom: px(pBottom !== null && pBottom !== void 0 ? pBottom : pVertical),
|
|
109
|
+
paddingLeft: px(pLeft !== null && pLeft !== void 0 ? pLeft : pHorizontal),
|
|
110
|
+
paddingRight: px(pRight !== null && pRight !== void 0 ? pRight : pHorizontal),
|
|
111
|
+
fontSize: px(fontSize),
|
|
112
|
+
color: skeleton ? 'transparent' : color,
|
|
113
|
+
backgroundColor: bgColor,
|
|
114
|
+
lineHeight: px(lineHeight),
|
|
115
|
+
fontWeight: typeof bold === 'boolean' ? bold ? 'bold' : 'normal' : bold,
|
|
116
|
+
textAlign: textAlign,
|
|
117
|
+
textDecoration: decoration
|
|
118
|
+
}, _typeof(style) === 'object' ? style : {});
|
|
119
|
+
var cleanStyle = {};
|
|
120
|
+
for (var key in textStyle) {
|
|
121
|
+
if (textStyle[key] !== undefined && textStyle[key] !== null) {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
cleanStyle[key] = textStyle[key];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return /*#__PURE__*/_jsx(OrigText, _objectSpread(_objectSpread({
|
|
127
|
+
ref: ref,
|
|
128
|
+
style: cleanStyle,
|
|
129
|
+
className: textClassNames,
|
|
130
|
+
selectable: selectable
|
|
131
|
+
}, rest), {}, {
|
|
132
|
+
children: children
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
Text.displayName = 'Text';
|
|
136
|
+
export default Text;
|
|
@@ -31,7 +31,12 @@ export interface UIViewProps {
|
|
|
31
31
|
hidden?: boolean;
|
|
32
32
|
width?: string | number;
|
|
33
33
|
height?: string | number;
|
|
34
|
+
minWidth?: string | number;
|
|
35
|
+
minHeight?: string | number;
|
|
36
|
+
maxWidth?: string | number;
|
|
37
|
+
maxHeight?: string | number;
|
|
34
38
|
bgColor?: string;
|
|
39
|
+
background?: string;
|
|
35
40
|
safeArea?: 'top' | 'bottom' | 'both';
|
|
36
41
|
hover?: boolean;
|
|
37
42
|
skeleton?: boolean;
|
|
@@ -42,6 +47,8 @@ export interface UIViewProps {
|
|
|
42
47
|
top?: number | string;
|
|
43
48
|
bottom?: number | string;
|
|
44
49
|
overflow?: OverflowValue;
|
|
50
|
+
overflowX?: OverflowValue;
|
|
51
|
+
overflowY?: OverflowValue;
|
|
45
52
|
radius?: string | number;
|
|
46
53
|
border?: boolean;
|
|
47
54
|
borderColor?: string;
|
|
@@ -74,6 +81,7 @@ type Props = UIViewProps & Partial<PaddingType> & Partial<MarginType> & ViewProp
|
|
|
74
81
|
* - width: width 宽度
|
|
75
82
|
* - height: height 高度
|
|
76
83
|
* - bgColor: background-color 背景颜色
|
|
84
|
+
* - background: background 背景图片等复杂背景
|
|
77
85
|
* - safeArea: safe-area-inset 安全区域
|
|
78
86
|
* - hover: hover 悬停状态
|
|
79
87
|
* - skeleton: skeleton 骨架屏
|
|
@@ -84,6 +92,8 @@ type Props = UIViewProps & Partial<PaddingType> & Partial<MarginType> & ViewProp
|
|
|
84
92
|
* - top: top 定位上侧
|
|
85
93
|
* - bottom: bottom 定位下侧
|
|
86
94
|
* - overflow: overflow 显示
|
|
95
|
+
* - overflowX: overflow-x 显示
|
|
96
|
+
* - overflowY: overflow-y 显示
|
|
87
97
|
* - radius: border-radius 圆角
|
|
88
98
|
* - border: boolean 边框
|
|
89
99
|
* - borderColor: border-color 边框颜色
|