@opentinyvue/vue-config-provider 3.22.1 → 3.23.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/lib/index.js +65 -2
- package/package.json +4 -3
- package/src/props.d.ts +1 -0
package/lib/index.js
CHANGED
|
@@ -7,8 +7,49 @@ function _extends() {
|
|
|
7
7
|
return n;
|
|
8
8
|
}, _extends.apply(null, arguments);
|
|
9
9
|
}
|
|
10
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
11
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
12
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
13
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
14
|
+
t && (r = t);
|
|
15
|
+
var o = 0;
|
|
16
|
+
return function() {
|
|
17
|
+
return o >= r.length ? { done: true } : { done: false, value: r[o++] };
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
21
|
+
}
|
|
22
|
+
function _unsupportedIterableToArray(r, a) {
|
|
23
|
+
if (r) {
|
|
24
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
25
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
26
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function _arrayLikeToArray(r, a) {
|
|
30
|
+
(null == a || a > r.length) && (a = r.length);
|
|
31
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
32
|
+
return n;
|
|
33
|
+
}
|
|
10
34
|
import { defineComponent, props, isVue2, hooks, provideDesignConfig, $prefix } from "@opentinyvue/vue-common";
|
|
11
35
|
import "@opentinyvue/vue-theme/config-provider/index.css";
|
|
36
|
+
import TinyThemeTool from "@opentinyvue/vue-theme/theme-tool";
|
|
37
|
+
import { isObject } from "@opentinyvue/utils";
|
|
38
|
+
var hasAnyKey = function hasAnyKey2(obj, keys) {
|
|
39
|
+
if (obj == null) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (keys.length === 0) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
for (var _iterator = _createForOfIteratorHelperLoose(keys), _step; !(_step = _iterator()).done; ) {
|
|
46
|
+
var key = _step.value;
|
|
47
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
12
53
|
var _sfc_main = defineComponent({
|
|
13
54
|
name: $prefix + "ConfigProvider",
|
|
14
55
|
props: _extends({
|
|
@@ -45,6 +86,12 @@ var _sfc_main = defineComponent({
|
|
|
45
86
|
name: "div"
|
|
46
87
|
};
|
|
47
88
|
}
|
|
89
|
+
},
|
|
90
|
+
theme: {
|
|
91
|
+
type: Object,
|
|
92
|
+
default: function _default4() {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
48
95
|
}
|
|
49
96
|
}, props.map(function(item) {
|
|
50
97
|
var _ref;
|
|
@@ -56,8 +103,24 @@ var _sfc_main = defineComponent({
|
|
|
56
103
|
})),
|
|
57
104
|
setup: function setup(props2, _ref2) {
|
|
58
105
|
var slots = _ref2.slots;
|
|
59
|
-
var _hooks$toRefs = hooks.toRefs(props2), direction = _hooks$toRefs.direction, design = _hooks$toRefs.design;
|
|
106
|
+
var _hooks$toRefs = hooks.toRefs(props2), direction = _hooks$toRefs.direction, design = _hooks$toRefs.design, theme = _hooks$toRefs.theme;
|
|
60
107
|
provideDesignConfig(design);
|
|
108
|
+
hooks.watch(function() {
|
|
109
|
+
return theme.value;
|
|
110
|
+
}, function() {
|
|
111
|
+
if (isObject(theme.value) && hasAnyKey(theme.value, ["data"])) {
|
|
112
|
+
var themeTool = new TinyThemeTool();
|
|
113
|
+
themeTool.changeTheme(theme.value);
|
|
114
|
+
}
|
|
115
|
+
if (isObject(theme.value) && !hasAnyKey(theme.value, ["data"])) {
|
|
116
|
+
console.warn("configProvider组件的theme属性对象请配置data属性。e.g { data: {'tv-base-color-brand': '#000'}}");
|
|
117
|
+
}
|
|
118
|
+
if (theme.value && !isObject(theme.value)) {
|
|
119
|
+
console.warn("configProvider组件的theme属性请配置对象格式数据");
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
immediate: true
|
|
123
|
+
});
|
|
61
124
|
var isRTL = hooks.computed(function() {
|
|
62
125
|
return direction.value === "rtl";
|
|
63
126
|
});
|
|
@@ -97,7 +160,7 @@ var _sfc_main = defineComponent({
|
|
|
97
160
|
return hooks.h(tagName, attr, slots);
|
|
98
161
|
}
|
|
99
162
|
});
|
|
100
|
-
var version = "3.
|
|
163
|
+
var version = "3.23.0";
|
|
101
164
|
var configProviderContextKey = Symbol("CONFIG_PROVIDER_CONTEXT_KEY");
|
|
102
165
|
_sfc_main.install = function(Vue) {
|
|
103
166
|
Vue.component(_sfc_main.name, _sfc_main);
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentinyvue/vue-config-provider",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@opentinyvue/vue-common": "~3.
|
|
10
|
-
"@opentinyvue/vue-theme": "~3.
|
|
9
|
+
"@opentinyvue/vue-common": "~3.23.0",
|
|
10
|
+
"@opentinyvue/vue-theme": "~3.23.0",
|
|
11
|
+
"@opentinyvue/utils": "~3.23.0"
|
|
11
12
|
},
|
|
12
13
|
"license": "MIT",
|
|
13
14
|
"types": "index.d.ts",
|