@zero-bits/taro-components 1.0.5 → 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 -63
- 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 -63
- package/lib/types/index.js +5 -1
- package/package.json +27 -4
package/lib/components/index.js
CHANGED
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
View: true,
|
|
8
|
+
Text: true
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "Text", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _Text.default;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "View", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _View.default;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _Permission = require("./Permission");
|
|
23
|
+
Object.keys(_Permission).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
+
if (key in exports && exports[key] === _Permission[key]) return;
|
|
27
|
+
Object.defineProperty(exports, key, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function get() {
|
|
30
|
+
return _Permission[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
var _View = _interopRequireDefault(require("./View"));
|
|
35
|
+
var _Text = _interopRequireDefault(require("./Text"));
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/context/index.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PermissionContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* PermissionContext 使用 object 作为基础泛型约束
|
|
10
|
+
* 消费侧通过 usePermission<P, U>() 收窄为具体的业务类型
|
|
11
|
+
*/
|
|
12
|
+
var PermissionContext = exports.PermissionContext = /*#__PURE__*/(0, _react.createContext)({});
|
package/lib/hooks/index.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "usePermission", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _usePermission.usePermission;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useWeappUpdate", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _useWeappUpdate.useWeappUpdate;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _usePermission = require("./usePermission");
|
|
19
|
+
var _useWeappUpdate = require("./useWeappUpdate");
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePermission = usePermission;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _context = require("../context");
|
|
9
|
+
/**
|
|
10
|
+
* 在任意子孙组件中获取权限状态与操作方法
|
|
11
|
+
* 必须在 PermissionProvider 内部使用
|
|
12
|
+
*
|
|
13
|
+
* @template P - 权限对象类型
|
|
14
|
+
* @template U - 用户对象类型
|
|
15
|
+
* @returns {PermissionContextValue<P, U>} 权限上下文值
|
|
16
|
+
* @throws {Error} 未包裹 PermissionProvider 时抛出异常
|
|
17
|
+
*/
|
|
18
|
+
function usePermission() {
|
|
19
|
+
var ctx = (0, _react.useContext)(_context.PermissionContext);
|
|
20
|
+
if (typeof ctx.granted !== 'function') {
|
|
21
|
+
throw new Error('[zero-bits/taro] usePermission must be used within a <PermissionProvider>.\n' + '请确保在 App 根节点包裹了 <PermissionProvider store={...}>');
|
|
22
|
+
}
|
|
23
|
+
return ctx;
|
|
24
|
+
}
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useWeappUpdate = void 0;
|
|
7
|
+
var _taro = require("@tarojs/taro");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* 微信小程序自动更新钩子
|
|
11
|
+
*/
|
|
12
|
+
var useWeappUpdate = exports.useWeappUpdate = function useWeappUpdate() {
|
|
13
|
+
(0, _react.useEffect)(function () {
|
|
14
|
+
if (process.env.TARO_ENV !== 'weapp') return;
|
|
15
|
+
var updateManager = (0, _taro.getUpdateManager)();
|
|
16
|
+
updateManager.onCheckForUpdate(function (res) {
|
|
17
|
+
if (res.hasUpdate) {
|
|
18
|
+
updateManager.onUpdateReady(function () {
|
|
19
|
+
(0, _taro.showModal)({
|
|
20
|
+
title: '更新提示',
|
|
21
|
+
content: '新版本已经准备好,是否重启应用?',
|
|
22
|
+
showCancel: false,
|
|
23
|
+
success: function success(result) {
|
|
24
|
+
if (result.confirm) updateManager.applyUpdate();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
updateManager.onUpdateFailed(function () {
|
|
31
|
+
(0, _taro.showModal)({
|
|
32
|
+
title: '更新提示',
|
|
33
|
+
content: '新版本下载失败,请删除当前小程序,重新搜索打开',
|
|
34
|
+
showCancel: false
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}, []);
|
|
38
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -1 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
View: true,
|
|
8
|
+
Text: true,
|
|
9
|
+
PermissionProvider: true,
|
|
10
|
+
createPermissionStore: true,
|
|
11
|
+
usePermission: true,
|
|
12
|
+
useWeappUpdate: true
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "PermissionProvider", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _components.PermissionProvider;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "Text", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _components.Text;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "View", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _components.View;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "createPermissionStore", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _components.createPermissionStore;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "usePermission", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _hooks.usePermission;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "useWeappUpdate", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return _hooks.useWeappUpdate;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
var _components = require("./components");
|
|
51
|
+
var _hooks = require("./hooks");
|
|
52
|
+
var _types = require("./types");
|
|
53
|
+
Object.keys(_types).forEach(function (key) {
|
|
54
|
+
if (key === "default" || key === "__esModule") return;
|
|
55
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
56
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
57
|
+
Object.defineProperty(exports, key, {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function get() {
|
|
60
|
+
return _types[key];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
package/lib/styles/index.css
CHANGED
|
@@ -1,63 +1 @@
|
|
|
1
|
-
|
|
2
|
-
@layer properties;
|
|
3
|
-
.visible {
|
|
4
|
-
visibility: visible;
|
|
5
|
-
}
|
|
6
|
-
.absolute {
|
|
7
|
-
position: absolute;
|
|
8
|
-
}
|
|
9
|
-
.fixed {
|
|
10
|
-
position: fixed;
|
|
11
|
-
}
|
|
12
|
-
.relative {
|
|
13
|
-
position: relative;
|
|
14
|
-
}
|
|
15
|
-
.static {
|
|
16
|
-
position: static;
|
|
17
|
-
}
|
|
18
|
-
.sticky {
|
|
19
|
-
position: sticky;
|
|
20
|
-
}
|
|
21
|
-
.flex {
|
|
22
|
-
display: flex;
|
|
23
|
-
}
|
|
24
|
-
.hidden {
|
|
25
|
-
display: none;
|
|
26
|
-
}
|
|
27
|
-
.flex-shrink {
|
|
28
|
-
flex-shrink: 1;
|
|
29
|
-
}
|
|
30
|
-
.flex-grow {
|
|
31
|
-
flex-grow: 1;
|
|
32
|
-
}
|
|
33
|
-
.flex-wrap {
|
|
34
|
-
flex-wrap: wrap;
|
|
35
|
-
}
|
|
36
|
-
.content-around {
|
|
37
|
-
align-content: space-around;
|
|
38
|
-
}
|
|
39
|
-
.justify-around {
|
|
40
|
-
justify-content: space-around;
|
|
41
|
-
}
|
|
42
|
-
.border {
|
|
43
|
-
border-style: var(--tw-border-style);
|
|
44
|
-
border-width: 1px;
|
|
45
|
-
}
|
|
46
|
-
.line-through {
|
|
47
|
-
text-decoration-line: line-through;
|
|
48
|
-
}
|
|
49
|
-
.underline {
|
|
50
|
-
text-decoration-line: underline;
|
|
51
|
-
}
|
|
52
|
-
@property --tw-border-style {
|
|
53
|
-
syntax: "*";
|
|
54
|
-
inherits: false;
|
|
55
|
-
initial-value: solid;
|
|
56
|
-
}
|
|
57
|
-
@layer properties {
|
|
58
|
-
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
59
|
-
*, ::before, ::after, ::backdrop {
|
|
60
|
-
--tw-border-style: solid;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
@tailwind utilities;
|
package/lib/types/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zero-bits/taro-components",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Taro components and utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -57,10 +57,33 @@
|
|
|
57
57
|
"author": "",
|
|
58
58
|
"license": "ISC",
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"react": ">=18.0.0",
|
|
61
|
-
"react-dom": ">=18.0.0",
|
|
62
60
|
"@tarojs/components": ">=4.2.1",
|
|
63
|
-
"@tarojs/taro": ">=4.2.1"
|
|
61
|
+
"@tarojs/taro": ">=4.2.1",
|
|
62
|
+
"react": ">=18.0.0",
|
|
63
|
+
"react-dom": ">=18.0.0"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "father build && npx tsc --emitDeclarationOnly --outDir lib && npx tsc --emitDeclarationOnly --outDir es",
|
|
67
|
+
"clean": "rm -rf lib && rm -rf es",
|
|
68
|
+
"prebuild": "npm run clean",
|
|
69
|
+
"build:cjs-css": "npx tailwindcss -i ./src/styles/index.css -o ./lib/styles/index.css",
|
|
70
|
+
"build:es-css": "npx tailwindcss -i ./src/styles/index.css -o ./es/styles/index.css",
|
|
71
|
+
"build:css": "npm run build:cjs-css && npm run build:es-css",
|
|
72
|
+
"build:all": "npm run build && npm run build:css",
|
|
73
|
+
"build:watch": "father dev",
|
|
74
|
+
"obfuscate": "node ../scripts/obfuscate.mjs",
|
|
75
|
+
"build:obf": "npm run build:all && npm run obfuscate",
|
|
76
|
+
"pub": "node ../scripts/publish.js"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@types/node": "^24.7.2",
|
|
80
|
+
"@types/react": "^18.2.0",
|
|
81
|
+
"@types/react-dom": "^18.2.0",
|
|
82
|
+
"father": "^4.6.15",
|
|
83
|
+
"react": "^18.2.0",
|
|
84
|
+
"react-dom": "^18.2.0",
|
|
85
|
+
"tailwindcss": "^3.4.19",
|
|
86
|
+
"typescript": "^5.9.3"
|
|
64
87
|
},
|
|
65
88
|
"dependencies": {
|
|
66
89
|
"classnames": "^2.3.0"
|