@opentinyvue/vue-config-provider 2.22.0 → 2.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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { defineComponent, $prefix, props, hooks, provideDesignConfig, isVue2 } from '@opentinyvue/vue-common';
|
|
2
2
|
import '@opentinyvue/vue-theme/config-provider/index.css';
|
|
3
|
+
import TinyThemeTool from '@opentinyvue/vue-theme/theme-tool';
|
|
4
|
+
import { isObject } from '@opentinyvue/utils';
|
|
3
5
|
|
|
4
6
|
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
5
7
|
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
@@ -40,6 +42,45 @@ function _extends() {
|
|
|
40
42
|
return n;
|
|
41
43
|
}, _extends.apply(null, arguments);
|
|
42
44
|
}
|
|
45
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
46
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
47
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
48
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
49
|
+
t && (r = t);
|
|
50
|
+
var o = 0;
|
|
51
|
+
return function() {
|
|
52
|
+
return o >= r.length ? { done: true } : { done: false, value: r[o++] };
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
56
|
+
}
|
|
57
|
+
function _unsupportedIterableToArray(r, a) {
|
|
58
|
+
if (r) {
|
|
59
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
60
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
61
|
+
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;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function _arrayLikeToArray(r, a) {
|
|
65
|
+
(null == a || a > r.length) && (a = r.length);
|
|
66
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
67
|
+
return n;
|
|
68
|
+
}
|
|
69
|
+
var hasAnyKey = function hasAnyKey2(obj, keys) {
|
|
70
|
+
if (obj == null) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (keys.length === 0) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
for (var _iterator = _createForOfIteratorHelperLoose(keys), _step; !(_step = _iterator()).done; ) {
|
|
77
|
+
var key = _step.value;
|
|
78
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
};
|
|
43
84
|
var __vue2_script = defineComponent({
|
|
44
85
|
name: $prefix + "ConfigProvider",
|
|
45
86
|
props: _extends({
|
|
@@ -76,6 +117,12 @@ var __vue2_script = defineComponent({
|
|
|
76
117
|
name: "div"
|
|
77
118
|
};
|
|
78
119
|
}
|
|
120
|
+
},
|
|
121
|
+
theme: {
|
|
122
|
+
type: Object,
|
|
123
|
+
default: function _default4() {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
79
126
|
}
|
|
80
127
|
}, props.map(function(item) {
|
|
81
128
|
var _ref;
|
|
@@ -87,8 +134,24 @@ var __vue2_script = defineComponent({
|
|
|
87
134
|
})),
|
|
88
135
|
setup: function setup(props2, _ref2) {
|
|
89
136
|
var slots = _ref2.slots;
|
|
90
|
-
var _hooks$toRefs = hooks.toRefs(props2), direction = _hooks$toRefs.direction, design = _hooks$toRefs.design;
|
|
137
|
+
var _hooks$toRefs = hooks.toRefs(props2), direction = _hooks$toRefs.direction, design = _hooks$toRefs.design, theme = _hooks$toRefs.theme;
|
|
91
138
|
provideDesignConfig(design);
|
|
139
|
+
hooks.watch(function() {
|
|
140
|
+
return theme.value;
|
|
141
|
+
}, function() {
|
|
142
|
+
if (isObject(theme.value) && hasAnyKey(theme.value, ["data"])) {
|
|
143
|
+
var themeTool = new TinyThemeTool();
|
|
144
|
+
themeTool.changeTheme(theme.value);
|
|
145
|
+
}
|
|
146
|
+
if (isObject(theme.value) && !hasAnyKey(theme.value, ["data"])) {
|
|
147
|
+
console.warn("configProvider组件的theme属性对象请配置data属性。e.g { data: {'tv-base-color-brand': '#000'}}");
|
|
148
|
+
}
|
|
149
|
+
if (theme.value && !isObject(theme.value)) {
|
|
150
|
+
console.warn("configProvider组件的theme属性请配置对象格式数据");
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
immediate: true
|
|
154
|
+
});
|
|
92
155
|
var isRTL = hooks.computed(function() {
|
|
93
156
|
return direction.value === "rtl";
|
|
94
157
|
});
|
|
@@ -139,7 +202,7 @@ function __vue2_injectStyles(context) {
|
|
|
139
202
|
var ConfigProvider = /* @__PURE__ */ function() {
|
|
140
203
|
return __component__.exports;
|
|
141
204
|
}();
|
|
142
|
-
var version = "2.
|
|
205
|
+
var version = "2.23.0";
|
|
143
206
|
var configProviderContextKey = Symbol("CONFIG_PROVIDER_CONTEXT_KEY");
|
|
144
207
|
ConfigProvider.install = function(Vue) {
|
|
145
208
|
Vue.component(ConfigProvider.name, ConfigProvider);
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentinyvue/vue-config-provider",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.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": "~2.
|
|
10
|
-
"@opentinyvue/vue-theme": "~3.
|
|
9
|
+
"@opentinyvue/vue-common": "~2.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",
|