@opentiny/vue-drawer 2.16.0 → 2.17.1

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 CHANGED
@@ -1,18 +1,14 @@
1
1
  function _extends() {
2
- _extends = Object.assign ? Object.assign.bind() : function(target) {
3
- for (var i = 1; i < arguments.length; i++) {
4
- var source = arguments[i];
5
- for (var key in source) {
6
- if (Object.prototype.hasOwnProperty.call(source, key)) {
7
- target[key] = source[key];
8
- }
9
- }
2
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
3
+ for (var e = 1; e < arguments.length; e++) {
4
+ var t = arguments[e];
5
+ for (var r in t)
6
+ ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
10
7
  }
11
- return target;
12
- };
13
- return _extends.apply(this, arguments);
8
+ return n;
9
+ }, _extends.apply(null, arguments);
14
10
  }
15
- import { defineComponent, $prefix, $setup, $props } from "@opentiny/vue-common";
11
+ import { defineComponent, $prefix, $setup, $props, createComponent, appProperties, hooks, setupComponent } from "@opentiny/vue-common";
16
12
  import PcTemplate from "./pc.js";
17
13
  import MobileFirstTemplate from "./mobile-first.js";
18
14
  var template = function template2(mode) {
@@ -30,7 +26,7 @@ var $constants = {
30
26
  SCROLL_LOCK_CLASS: function SCROLL_LOCK_CLASS(mode) {
31
27
  var scrollLockClasses = {
32
28
  "mobile-first": "overflow-hidden",
33
- "pc": "tiny-popup-parent--hidden tiny-dialog-box__scroll-lock"
29
+ "pc": "popup-parent--hidden dialog-box__scroll-lock"
34
30
  };
35
31
  return scrollLockClasses[mode] || "";
36
32
  },
@@ -90,7 +86,9 @@ var drawerProps = _extends({}, $props, {
90
86
  default: 2e3
91
87
  },
92
88
  beforeClose: Function,
93
- tipsProps: Object
89
+ tipsProps: Object,
90
+ // tiny 新增:用于方法调用组件
91
+ customSlots: Object
94
92
  });
95
93
  var Drawer = defineComponent({
96
94
  name: $prefix + "Drawer",
@@ -103,15 +101,80 @@ var Drawer = defineComponent({
103
101
  });
104
102
  }
105
103
  });
106
- var version = "2.16.0";
104
+ var defaultConfigs = {
105
+ customClass: null,
106
+ placement: "right",
107
+ width: null,
108
+ title: "",
109
+ showClose: true,
110
+ showHeader: true,
111
+ showFooter: false,
112
+ mask: true,
113
+ maskClosable: true,
114
+ dragable: false,
115
+ lockScroll: true,
116
+ flex: false,
117
+ zIndex: 2e3,
118
+ beforeClose: null,
119
+ tipsProps: null
120
+ };
121
+ var service = function service2(configs) {
122
+ var _appProperties$tiny_m;
123
+ if (configs === void 0) {
124
+ configs = {};
125
+ }
126
+ var events = {
127
+ onOpen: function onOpen(params) {
128
+ var _configs$events;
129
+ if (typeof ((_configs$events = configs.events) == null ? void 0 : _configs$events.open) === "function") {
130
+ configs.events.open(params);
131
+ }
132
+ },
133
+ onClose: function onClose(params) {
134
+ var _configs$events2;
135
+ if (typeof ((_configs$events2 = configs.events) == null ? void 0 : _configs$events2.close) === "function") {
136
+ configs.events.close(params);
137
+ }
138
+ },
139
+ onConfirm: function onConfirm(params) {
140
+ var _configs$events3;
141
+ if (typeof ((_configs$events3 = configs.events) == null ? void 0 : _configs$events3.confirm) === "function") {
142
+ configs.events.confirm(params);
143
+ }
144
+ }
145
+ };
146
+ var options = _extends({}, defaultConfigs, configs, events);
147
+ var instance = createComponent({
148
+ component: Drawer,
149
+ propsData: _extends({}, options, {
150
+ _constants: $constants,
151
+ tiny_mode: configs.tiny_mode || ((_appProperties$tiny_m = appProperties().tiny_mode) == null ? void 0 : _appProperties$tiny_m.value)
152
+ }),
153
+ el: document.createElement("div")
154
+ });
155
+ var parent = document.body;
156
+ parent.appendChild(instance.$el);
157
+ hooks.nextTick(function() {
158
+ instance.open();
159
+ });
160
+ return instance;
161
+ };
162
+ var version = "2.undefined";
107
163
  Drawer.model = {
108
- prop: "modelValue",
109
- event: "update:modelValue"
164
+ prop: "visible",
165
+ event: "update:visible"
110
166
  };
167
+ Drawer.service = service;
111
168
  Drawer.install = function(Vue) {
112
169
  Vue.component(Drawer.name, Drawer);
113
170
  };
114
171
  Drawer.version = version;
172
+ setupComponent.TINYDrawer = {
173
+ init: function init(root) {
174
+ var prefix = root.$apiPrefix || "$";
175
+ root[prefix + "drawer"] = service;
176
+ }
177
+ };
115
178
  export {
116
179
  Drawer as default
117
180
  };
@@ -63,6 +63,7 @@ var __vue2_script = defineComponent({
63
63
  IconClose: IconClose()
64
64
  },
65
65
  props: [].concat(props, ["visible", "title", "showHeader", "showFooter", "customClass", "placement", "width", "mask", "dragable", "maskClosable", "lockScroll", "flex", "beforeClose"]),
66
+ emits: ["update:visible", "open", "close", "confirm"],
66
67
  setup: function setup$1(props2, context) {
67
68
  return setup({
68
69
  props: props2,
@@ -89,8 +90,8 @@ var render = function render2() {
89
90
  }
90
91
  }, [_vm.mask ? _c("div", {
91
92
  ref: "mask",
92
- class: _vm.m("fixed z-50 left-0 right-0 top-0 bottom-0 w-full h-full transition-opacity ease-linear duration-200", {
93
- "bg-color-bg-7": _vm.state.toggle
93
+ class: _vm.m("fixed z-50 left-0 right-0 top-0 bottom-0 w-full h-full transition ease-linear duration-200", {
94
+ "bg-color-bg-7": _vm.state.visible
94
95
  }),
95
96
  on: {
96
97
  "click": function click($event) {
@@ -110,13 +111,13 @@ var render = function render2() {
110
111
  }, {
111
112
  "left-0 top-0 -translate-y-full border-b-0.5 rounded-b-lg": _vm.placement === "top"
112
113
  }, {
113
- "translate-y-0": ["top", "bottom"].includes(_vm.placement) && _vm.state.toggle
114
+ "translate-y-0": ["top", "bottom"].includes(_vm.placement) && _vm.state.visible
114
115
  }, {
115
116
  "left-0 top-0 -translate-x-full border-r-0.5 rounded-r-lg": _vm.placement === "left"
116
117
  }, {
117
118
  "right-0 top-0 translate-x-full border-l-0.5 rounded-l-lg": _vm.placement === "right"
118
119
  }, {
119
- "translate-x-0": ["left", "right"].includes(_vm.placement) && _vm.state.toggle
120
+ "translate-x-0": ["left", "right"].includes(_vm.placement) && _vm.state.visible
120
121
  }, _vm.customClass),
121
122
  style: {
122
123
  width: ["left", "right"].includes(_vm.placement) ? _vm.state.computedWidth : null,
package/lib/pc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { renderless, api } from '@opentiny/vue-renderless/drawer/vue';
2
- import { defineComponent, props, setup } from '@opentiny/vue-common';
2
+ import { defineComponent, h, props, setup } from '@opentiny/vue-common';
3
3
  import '@opentiny/vue-theme/drawer/index.css';
4
4
  import { iconClose, iconHelpCircle } from '@opentiny/vue-icon';
5
5
  import Button from '@opentiny/vue-button';
@@ -64,9 +64,22 @@ var __vue2_script = defineComponent({
64
64
  TinyButton: Button,
65
65
  TinyTooltip: Tooltip,
66
66
  IconClose: iconClose(),
67
- IconHelpCircle: iconHelpCircle()
67
+ IconHelpCircle: iconHelpCircle(),
68
+ // tiny新增: 适配Vue2下, 在模板中渲染VNode
69
+ SlotWrapper: {
70
+ props: ["node"],
71
+ render: function render() {
72
+ var node = this.node;
73
+ if (typeof node === "function") {
74
+ return node(h);
75
+ } else {
76
+ return node;
77
+ }
78
+ }
79
+ }
68
80
  },
69
- props: [].concat(props, ["visible", "title", "showHeader", "showFooter", "customClass", "placement", "width", "mask", "dragable", "maskClosable", "lockScroll", "flex", "showClose", "zIndex", "beforeClose", "tipsProps"]),
81
+ props: [].concat(props, ["visible", "title", "showHeader", "showFooter", "customClass", "placement", "width", "mask", "dragable", "maskClosable", "lockScroll", "flex", "showClose", "zIndex", "beforeClose", "tipsProps", "customSlots"]),
82
+ emits: ["update:visible", "open", "close", "confirm", "drag"],
70
83
  setup: function setup$1(props2, context) {
71
84
  return setup({
72
85
  props: props2,
@@ -76,7 +89,7 @@ var __vue2_script = defineComponent({
76
89
  });
77
90
  }
78
91
  });
79
- var render = function render2() {
92
+ var render2 = function render3() {
80
93
  var _vm = this;
81
94
  var _h = _vm.$createElement;
82
95
  var _c = _vm._self._c || _h;
@@ -89,11 +102,9 @@ var render = function render2() {
89
102
  attrs: {
90
103
  "name": "drawer-fade"
91
104
  }
92
- }, [_vm.mask && _vm.visible ? _c("div", {
105
+ }, [_vm.mask && _vm.state.visible ? _c("div", {
93
106
  ref: "mask",
94
- class: ["tiny-drawer__mask", {
95
- "show-bg-color": _vm.state.toggle
96
- }],
107
+ staticClass: "tiny-drawer__mask show-bg-color",
97
108
  style: {
98
109
  zIndex: _vm.zIndex
99
110
  },
@@ -110,8 +121,8 @@ var render = function render2() {
110
121
  directives: [{
111
122
  name: "show",
112
123
  rawName: "v-show",
113
- value: _vm.visible,
114
- expression: "visible"
124
+ value: _vm.state.visible,
125
+ expression: "state.visible"
115
126
  }],
116
127
  ref: "drawerBox",
117
128
  class: ["tiny-drawer__main", {
@@ -120,7 +131,7 @@ var render = function render2() {
120
131
  "is-top": _vm.placement === "top",
121
132
  "is-bottom": _vm.placement === "bottom",
122
133
  "drag-effects": !_vm.state.dragEvent.isDrag,
123
- "toggle": _vm.state.toggle
134
+ "toggle": _vm.state.visible
124
135
  }, "tiny-drawer-main", _vm.customClass],
125
136
  style: {
126
137
  width: ["left", "right"].includes(_vm.placement) ? _vm.state.computedWidth : null,
@@ -145,7 +156,12 @@ var render = function render2() {
145
156
  "data-tag": "drawer-header"
146
157
  }
147
158
  }, [_vm._t("header", function() {
148
- return [_c("div", {
159
+ var _vm$customSlots;
160
+ return [(_vm$customSlots = _vm.customSlots) !== null && _vm$customSlots !== void 0 && _vm$customSlots.header ? _c("slot-wrapper", {
161
+ attrs: {
162
+ "node": _vm.customSlots.header
163
+ }
164
+ }) : _c("div", {
149
165
  staticClass: "tiny-drawer__header"
150
166
  }, [_c("div", {
151
167
  staticClass: "tiny-drawer__header-left"
@@ -155,7 +171,14 @@ var render = function render2() {
155
171
  staticClass: "tiny-drawer__help-icon"
156
172
  })], 1) : _vm._e()], 1), _c("div", {
157
173
  staticClass: "tiny-drawer__header-right"
158
- }, [_vm._t("header-right")], 2)])];
174
+ }, [_vm._t("header-right", function() {
175
+ var _vm$customSlots2;
176
+ return [(_vm$customSlots2 = _vm.customSlots) !== null && _vm$customSlots2 !== void 0 && _vm$customSlots2.headerRight ? _c("slot-wrapper", {
177
+ attrs: {
178
+ "node": _vm.customSlots.headerRight
179
+ }
180
+ }) : _vm._e()];
181
+ })], 2)])];
159
182
  }), _vm.showClose ? _c("button", {
160
183
  staticClass: "tiny-drawer__headerbtn",
161
184
  attrs: {
@@ -177,14 +200,25 @@ var render = function render2() {
177
200
  attrs: {
178
201
  "data-tag": "drawer-body"
179
202
  }
180
- }, [_vm._t("default")], 2), _vm.showFooter ? _c("div", {
203
+ }, [_vm._t("default", function() {
204
+ return [_c("slot-wrapper", {
205
+ attrs: {
206
+ "node": _vm.customSlots.default
207
+ }
208
+ })];
209
+ })], 2), _vm.showFooter ? _c("div", {
181
210
  ref: "footer",
182
211
  staticClass: "tiny-drawer__footer",
183
212
  attrs: {
184
213
  "data-tag": "drawer-footer"
185
214
  }
186
215
  }, [_vm._t("footer", function() {
187
- return [_c("tiny-button", {
216
+ var _vm$customSlots3;
217
+ return [(_vm$customSlots3 = _vm.customSlots) !== null && _vm$customSlots3 !== void 0 && _vm$customSlots3.footer ? _c("slot-wrapper", {
218
+ attrs: {
219
+ "node": _vm.customSlots.footer
220
+ }
221
+ }) : [_c("tiny-button", {
188
222
  class: ["tiny-drawer__confirm-btn", {
189
223
  reverse: _vm.state.btnOrderReversed
190
224
  }],
@@ -208,12 +242,12 @@ var render = function render2() {
208
242
  return _vm.handleClose("cancel");
209
243
  }
210
244
  }
211
- }, [_vm._v(_vm._s(_vm.t("ui.button.cancel")))])];
245
+ }, [_vm._v(_vm._s(_vm.t("ui.button.cancel")))])]];
212
246
  })], 2) : _vm._e()])])])], 1);
213
247
  };
214
248
  var staticRenderFns = [];
215
249
  var __cssModules = {};
216
- var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
250
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render2, staticRenderFns, false, __vue2_injectStyles, null, null, null);
217
251
  function __vue2_injectStyles(context) {
218
252
  for (var o in __cssModules) {
219
253
  this[o] = __cssModules[o];
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@opentiny/vue-drawer",
3
- "version": "2.16.0",
3
+ "version": "2.17.1",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
7
7
  "sideEffects": false,
8
8
  "type": "module",
9
9
  "dependencies": {
10
- "@opentiny/vue-button": "~2.16.0",
11
- "@opentiny/vue-tooltip": "~2.16.0",
12
- "@opentiny/vue-common": "~2.16.0",
13
- "@opentiny/vue-renderless": "~3.16.0",
14
- "@opentiny/vue-icon": "~2.16.0",
15
- "@opentiny/vue-theme": "~3.16.0"
10
+ "@opentiny/vue-button": "~2.17.0",
11
+ "@opentiny/vue-tooltip": "~2.17.0",
12
+ "@opentiny/vue-common": "~2.17.0",
13
+ "@opentiny/vue-renderless": "~3.17.0",
14
+ "@opentiny/vue-icon": "~2.17.0",
15
+ "@opentiny/vue-theme": "~3.17.0"
16
16
  },
17
17
  "license": "MIT",
18
18
  "types": "index.d.ts"
package/src/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export declare const $constants: {
2
+ SCROLL_LOCK_CLASS(mode: string): string;
3
+ DEFAULT_WIDTH: string;
4
+ };
1
5
  export declare const drawerProps: {
2
6
  _constants: {
3
7
  type: ObjectConstructor;
@@ -10,7 +14,7 @@ export declare const drawerProps: {
10
14
  type: BooleanConstructor;
11
15
  default: boolean;
12
16
  };
13
- customClass: (StringConstructor | ArrayConstructor | ObjectConstructor)[];
17
+ customClass: (ObjectConstructor | StringConstructor | ArrayConstructor)[];
14
18
  placement: {
15
19
  type: StringConstructor;
16
20
  default: string;
@@ -54,6 +58,7 @@ export declare const drawerProps: {
54
58
  };
55
59
  beforeClose: FunctionConstructor;
56
60
  tipsProps: ObjectConstructor;
61
+ customSlots: ObjectConstructor;
57
62
  tiny_mode: StringConstructor;
58
63
  tiny_mode_root: BooleanConstructor;
59
64
  tiny_template: (ObjectConstructor | FunctionConstructor)[];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) 2022 - present TinyVue Authors.
3
+ * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license.
6
+ *
7
+ * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8
+ * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9
+ * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10
+ *
11
+ */
12
+ export declare const defaultConfigs: {
13
+ customClass: null;
14
+ placement: string;
15
+ width: null;
16
+ title: string;
17
+ showClose: boolean;
18
+ showHeader: boolean;
19
+ showFooter: boolean;
20
+ mask: boolean;
21
+ maskClosable: boolean;
22
+ dragable: boolean;
23
+ lockScroll: boolean;
24
+ flex: boolean;
25
+ zIndex: number;
26
+ beforeClose: null;
27
+ tipsProps: null;
28
+ };
29
+ declare const _default: (configs?: {}) => import("vue/types/vue").CombinedVueInstance<Record<never, any> & import("vue").default, object, object, object, Record<never, any>>;
30
+ export default _default;