@opentinyvue/vue-config-provider 2.21.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 - present TinyVue Authors.
4
+ Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ import type { ConfigProviderProps } from '../src/props';
2
+ export declare function useConfig(): ConfigProviderProps | {};
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import ConfigProvider from './src/index.vue';
2
+ export declare const configProviderContextKey: unique symbol;
3
+ export default ConfigProvider;
package/lib/index.js ADDED
@@ -0,0 +1,149 @@
1
+ import { defineComponent, $prefix, props, hooks, provideDesignConfig, isVue2 } from '@opentinyvue/vue-common';
2
+ import '@opentinyvue/vue-theme/config-provider/index.css';
3
+
4
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
5
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
6
+ if (render) {
7
+ options.render = render;
8
+ options.staticRenderFns = staticRenderFns;
9
+ options._compiled = true;
10
+ }
11
+ var hook;
12
+ if (injectStyles) {
13
+ hook = injectStyles;
14
+ }
15
+ if (hook) {
16
+ if (options.functional) {
17
+ options._injectStyles = hook;
18
+ var originalRender = options.render;
19
+ options.render = function renderWithStyleInjection(h, context) {
20
+ hook.call(context);
21
+ return originalRender(h, context);
22
+ };
23
+ } else {
24
+ var existing = options.beforeCreate;
25
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
26
+ }
27
+ }
28
+ return {
29
+ exports: scriptExports,
30
+ options
31
+ };
32
+ }
33
+
34
+ function _extends() {
35
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
36
+ for (var e = 1; e < arguments.length; e++) {
37
+ var t = arguments[e];
38
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
39
+ }
40
+ return n;
41
+ }, _extends.apply(null, arguments);
42
+ }
43
+ var __vue2_script = defineComponent({
44
+ name: $prefix + "ConfigProvider",
45
+ props: _extends({
46
+ design: {
47
+ type: Object,
48
+ default: function _default() {
49
+ return {};
50
+ }
51
+ },
52
+ breakPoints: {
53
+ type: Object,
54
+ default: function _default2() {
55
+ return {
56
+ breakPoints: {
57
+ "xs": 480,
58
+ "sm": 640,
59
+ "md": 768,
60
+ "lg": 1024,
61
+ "xl": 1280,
62
+ "2xl": 1536
63
+ }
64
+ };
65
+ }
66
+ },
67
+ direction: {
68
+ type: String,
69
+ default: "ltr"
70
+ },
71
+ tag: {
72
+ type: Object,
73
+ default: function _default3() {
74
+ return {
75
+ enable: true,
76
+ name: "div"
77
+ };
78
+ }
79
+ }
80
+ }, props.map(function(item) {
81
+ var _ref;
82
+ return _ref = {}, _ref[item] = {
83
+ type: String
84
+ }, _ref;
85
+ }).reduce(function(pre, cur) {
86
+ return _extends({}, pre, cur);
87
+ })),
88
+ setup: function setup(props2, _ref2) {
89
+ var slots = _ref2.slots;
90
+ var _hooks$toRefs = hooks.toRefs(props2), direction = _hooks$toRefs.direction, design = _hooks$toRefs.design;
91
+ provideDesignConfig(design);
92
+ var isRTL = hooks.computed(function() {
93
+ return direction.value === "rtl";
94
+ });
95
+ var cssVar = hooks.computed(function() {
96
+ return {
97
+ "--text-direction": direction.value
98
+ };
99
+ });
100
+ var classNames = hooks.reactive({
101
+ "tiny-config-provider": true,
102
+ "tiny-config-provider__rtl": isRTL
103
+ });
104
+ hooks.provide(configProviderContextKey, props2);
105
+ return {
106
+ slots,
107
+ classNames,
108
+ cssVar,
109
+ props: props2,
110
+ isVue2
111
+ };
112
+ },
113
+ render: function render() {
114
+ var _this$$slots, _this$slots, _this$props$tag$name;
115
+ var attr = {
116
+ class: this.classNames,
117
+ style: this.cssVar
118
+ };
119
+ var slots = isVue2 ? (_this$$slots = this.$slots) == null ? void 0 : _this$$slots.default : (_this$slots = this.slots) == null ? void 0 : _this$slots.default == null ? void 0 : _this$slots.default();
120
+ if (!this.props.tag.enable) {
121
+ var _slots$length;
122
+ if (isVue2 && ((_slots$length = slots == null ? void 0 : slots.length) != null ? _slots$length : 1) > 1) {
123
+ return hooks.h("div", {}, slots);
124
+ }
125
+ return slots;
126
+ }
127
+ var tagName = (_this$props$tag$name = this.props.tag.name) != null ? _this$props$tag$name : "div";
128
+ return hooks.h(tagName, attr, slots);
129
+ }
130
+ });
131
+ var __vue2_render, __vue2_staticRenderFns;
132
+ var __cssModules = {};
133
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
134
+ function __vue2_injectStyles(context) {
135
+ for (var o in __cssModules) {
136
+ this[o] = __cssModules[o];
137
+ }
138
+ }
139
+ var ConfigProvider = /* @__PURE__ */ function() {
140
+ return __component__.exports;
141
+ }();
142
+ var version = "2.21.0";
143
+ var configProviderContextKey = Symbol("CONFIG_PROVIDER_CONTEXT_KEY");
144
+ ConfigProvider.install = function(Vue) {
145
+ Vue.component(ConfigProvider.name, ConfigProvider);
146
+ };
147
+ ConfigProvider.version = version;
148
+
149
+ export { configProviderContextKey, ConfigProvider as default };
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@opentinyvue/vue-config-provider",
3
+ "version": "2.21.0",
4
+ "main": "./lib/index.js",
5
+ "module": "./lib/index.js",
6
+ "sideEffects": false,
7
+ "type": "module",
8
+ "dependencies": {
9
+ "@opentinyvue/vue-common": "~2.21.0",
10
+ "@opentinyvue/vue-theme": "~3.21.0"
11
+ },
12
+ "license": "MIT",
13
+ "types": "index.d.ts",
14
+ "scripts": {
15
+ "build": "pnpm -w build:ui $npm_package_name",
16
+ "//postversion": "pnpm build"
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
package/src/props.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ export interface breakPoint {
2
+ 'xs': number;
3
+ 'sm': number;
4
+ 'md': number;
5
+ 'lg': number;
6
+ 'xl': number;
7
+ '2xl': number;
8
+ }
9
+ export type TextDirection = 'rtl' | 'lrt';
10
+ export interface Tag {
11
+ enable: boolean;
12
+ name: string;
13
+ }
14
+ export interface ConfigProviderProps {
15
+ breakPoints: breakPoint;
16
+ direction: 'rtl' | 'ltr';
17
+ globalPrefix?: string;
18
+ tag: {
19
+ enable?: boolean;
20
+ name?: string;
21
+ };
22
+ }