vue-devui 1.0.0-beta.4 → 1.0.0-beta.8

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.
Files changed (203) hide show
  1. package/accordion/index.d.ts +7 -0
  2. package/accordion/index.es.js +186 -139
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.d.ts +7 -0
  6. package/alert/index.es.js +1 -1
  7. package/alert/index.umd.js +1 -1
  8. package/anchor/index.d.ts +7 -0
  9. package/avatar/index.d.ts +7 -0
  10. package/avatar/index.es.js +1 -1
  11. package/avatar/index.umd.js +1 -1
  12. package/back-top/index.d.ts +7 -0
  13. package/back-top/index.es.js +128 -0
  14. package/back-top/index.umd.js +1 -0
  15. package/back-top/package.json +7 -0
  16. package/back-top/style.css +1 -0
  17. package/badge/index.d.ts +7 -0
  18. package/badge/index.es.js +1 -1
  19. package/badge/index.umd.js +1 -1
  20. package/breadcrumb/index.d.ts +7 -0
  21. package/button/index.d.ts +7 -0
  22. package/button/index.es.js +4 -4
  23. package/button/index.umd.js +1 -1
  24. package/card/index.d.ts +7 -0
  25. package/card/index.es.js +1 -1
  26. package/card/index.umd.js +1 -1
  27. package/carousel/index.d.ts +7 -0
  28. package/carousel/index.es.js +3 -3
  29. package/carousel/index.umd.js +1 -1
  30. package/cascader/index.d.ts +7 -0
  31. package/cascader/index.es.js +1239 -83
  32. package/cascader/index.umd.js +1 -1
  33. package/cascader/style.css +1 -1
  34. package/checkbox/index.d.ts +7 -0
  35. package/checkbox/index.es.js +1 -1
  36. package/checkbox/index.umd.js +1 -1
  37. package/comment/index.d.ts +7 -0
  38. package/comment/index.es.js +57 -0
  39. package/comment/index.umd.js +1 -0
  40. package/comment/package.json +7 -0
  41. package/comment/style.css +1 -0
  42. package/countdown/index.d.ts +7 -0
  43. package/countdown/index.es.js +167 -0
  44. package/countdown/index.umd.js +1 -0
  45. package/countdown/package.json +7 -0
  46. package/countdown/style.css +1 -0
  47. package/date-picker/index.d.ts +7 -0
  48. package/date-picker/index.es.js +15 -15
  49. package/date-picker/index.umd.js +1 -1
  50. package/dragdrop/index.d.ts +7 -0
  51. package/drawer/index.d.ts +7 -0
  52. package/drawer/index.es.js +33 -9
  53. package/drawer/index.umd.js +1 -1
  54. package/dropdown/index.d.ts +7 -0
  55. package/dropdown/index.es.js +61 -61
  56. package/dropdown/index.umd.js +1 -1
  57. package/editable-select/index.d.ts +7 -0
  58. package/editable-select/index.es.js +53 -26
  59. package/editable-select/index.umd.js +9 -9
  60. package/form/index.d.ts +7 -0
  61. package/form/index.es.js +175 -80
  62. package/form/index.umd.js +1 -1
  63. package/form/style.css +1 -1
  64. package/fullscreen/index.d.ts +7 -0
  65. package/fullscreen/index.es.js +1 -1
  66. package/fullscreen/index.umd.js +1 -1
  67. package/gantt/index.d.ts +7 -0
  68. package/grid/index.d.ts +7 -0
  69. package/grid/index.es.js +2 -2
  70. package/grid/index.umd.js +1 -1
  71. package/icon/index.d.ts +7 -0
  72. package/icon/index.es.js +4 -4
  73. package/icon/index.umd.js +1 -1
  74. package/image-preview/index.d.ts +7 -0
  75. package/image-preview/index.es.js +23 -2
  76. package/image-preview/index.umd.js +1 -1
  77. package/index.d.ts +7 -0
  78. package/input/index.d.ts +7 -0
  79. package/input/index.es.js +12 -12
  80. package/input/index.umd.js +1 -1
  81. package/input-icon/index.d.ts +7 -0
  82. package/input-icon/index.es.js +331 -0
  83. package/input-icon/index.umd.js +1 -0
  84. package/input-icon/package.json +7 -0
  85. package/input-icon/style.css +1 -0
  86. package/input-number/index.d.ts +7 -0
  87. package/input-number/index.es.js +3 -3
  88. package/input-number/index.umd.js +1 -1
  89. package/layout/index.d.ts +7 -0
  90. package/layout/index.es.js +1 -1
  91. package/layout/index.umd.js +1 -1
  92. package/loading/index.d.ts +7 -0
  93. package/loading/index.es.js +1 -1
  94. package/loading/index.umd.js +1 -1
  95. package/modal/index.d.ts +7 -0
  96. package/modal/index.es.js +58 -57
  97. package/modal/index.umd.js +1 -1
  98. package/nav-sprite/index.d.ts +7 -0
  99. package/overlay/index.d.ts +7 -0
  100. package/overlay/index.es.js +56 -55
  101. package/overlay/index.umd.js +1 -1
  102. package/package.json +2 -31
  103. package/pagination/index.d.ts +7 -0
  104. package/pagination/index.es.js +3 -3
  105. package/pagination/index.umd.js +1 -1
  106. package/panel/index.d.ts +7 -0
  107. package/popover/index.d.ts +7 -0
  108. package/popover/index.es.js +1 -1
  109. package/popover/index.umd.js +1 -1
  110. package/progress/index.d.ts +7 -0
  111. package/progress/index.es.js +1 -1
  112. package/progress/index.umd.js +2 -2
  113. package/quadrant-diagram/index.d.ts +7 -0
  114. package/radio/index.d.ts +7 -0
  115. package/radio/index.es.js +1 -1
  116. package/radio/index.umd.js +1 -1
  117. package/rate/index.d.ts +7 -0
  118. package/rate/index.es.js +1 -1
  119. package/rate/index.umd.js +1 -1
  120. package/read-tip/index.d.ts +7 -0
  121. package/read-tip/index.es.js +61 -24
  122. package/read-tip/index.umd.js +1 -1
  123. package/read-tip/style.css +1 -1
  124. package/result/index.d.ts +7 -0
  125. package/result/index.es.js +118 -0
  126. package/result/index.umd.js +1 -0
  127. package/result/package.json +7 -0
  128. package/result/style.css +1 -0
  129. package/ripple/index.d.ts +7 -0
  130. package/ripple/index.es.js +5 -2
  131. package/ripple/index.umd.js +1 -1
  132. package/search/index.d.ts +7 -0
  133. package/search/index.es.js +14 -14
  134. package/search/index.umd.js +1 -1
  135. package/select/index.d.ts +7 -0
  136. package/select/index.es.js +3 -3
  137. package/select/index.umd.js +1 -1
  138. package/skeleton/index.d.ts +7 -0
  139. package/skeleton/index.es.js +148 -26
  140. package/skeleton/index.umd.js +1 -1
  141. package/skeleton/style.css +1 -1
  142. package/slider/index.d.ts +7 -0
  143. package/slider/index.es.js +1 -1
  144. package/slider/index.umd.js +1 -1
  145. package/splitter/index.d.ts +7 -0
  146. package/splitter/index.es.js +24 -25
  147. package/splitter/index.umd.js +1 -1
  148. package/status/index.d.ts +7 -0
  149. package/status/index.es.js +1 -1
  150. package/status/index.umd.js +1 -1
  151. package/steps-guide/index.d.ts +7 -0
  152. package/steps-guide/index.es.js +97 -74
  153. package/steps-guide/index.umd.js +1 -1
  154. package/sticky/index.d.ts +7 -0
  155. package/style.css +1 -1
  156. package/switch/index.d.ts +7 -0
  157. package/switch/index.es.js +1 -1
  158. package/switch/index.umd.js +1 -1
  159. package/table/index.d.ts +7 -0
  160. package/table/index.es.js +1492 -157
  161. package/table/index.umd.js +1 -1
  162. package/table/style.css +1 -1
  163. package/tabs/index.d.ts +7 -0
  164. package/tabs/index.es.js +1 -0
  165. package/tabs/index.umd.js +1 -1
  166. package/tag/index.d.ts +7 -0
  167. package/tag/index.es.js +94 -12
  168. package/tag/index.umd.js +1 -1
  169. package/tag/style.css +1 -1
  170. package/tag-input/index.d.ts +7 -0
  171. package/tag-input/index.es.js +1 -1
  172. package/tag-input/index.umd.js +1 -1
  173. package/textarea/index.d.ts +7 -0
  174. package/textarea/index.es.js +1 -1
  175. package/textarea/index.umd.js +1 -1
  176. package/time-axis/index.d.ts +7 -0
  177. package/time-axis/index.es.js +240 -21
  178. package/time-axis/index.umd.js +1 -1
  179. package/time-axis/style.css +1 -1
  180. package/time-picker/index.d.ts +7 -0
  181. package/time-picker/index.es.js +12 -7
  182. package/time-picker/index.umd.js +1 -1
  183. package/time-picker/style.css +1 -1
  184. package/toast/index.d.ts +7 -0
  185. package/toast/index.es.js +4 -4
  186. package/toast/index.umd.js +1 -1
  187. package/tooltip/index.d.ts +7 -0
  188. package/transfer/index.d.ts +7 -0
  189. package/transfer/index.es.js +301 -62
  190. package/transfer/index.umd.js +1 -1
  191. package/transfer/style.css +1 -1
  192. package/tree/index.d.ts +7 -0
  193. package/tree/index.es.js +160 -31
  194. package/tree/index.umd.js +1 -1
  195. package/tree-select/index.d.ts +7 -0
  196. package/tree-select/index.es.js +435 -110
  197. package/tree-select/index.umd.js +1 -1
  198. package/tree-select/style.css +1 -1
  199. package/upload/index.d.ts +7 -0
  200. package/upload/index.es.js +4 -4
  201. package/upload/index.umd.js +1 -1
  202. package/vue-devui.es.js +14014 -11820
  203. package/vue-devui.umd.js +19 -19
@@ -0,0 +1,7 @@
1
+ import { App } from 'vue';
2
+ declare function install(app: App): void
3
+ declare const _default: {
4
+ install: typeof install;
5
+ version: string;
6
+ };
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { App } from 'vue';
2
+ declare function install(app: App): void
3
+ declare const _default: {
4
+ install: typeof install;
5
+ version: string;
6
+ };
7
+ export default _default;
@@ -39,6 +39,13 @@ const drawerProps = {
39
39
  position: {
40
40
  type: String,
41
41
  default: "left"
42
+ },
43
+ backdropCloseable: {
44
+ type: Boolean,
45
+ default: true
46
+ },
47
+ beforeHidden: {
48
+ type: [Promise, Function]
42
49
  }
43
50
  };
44
51
  var drawerHeader = "";
@@ -122,35 +129,41 @@ var DrawerBody = defineComponent({
122
129
  const position = inject("position");
123
130
  const width = inject("width");
124
131
  const visible = inject("visible");
132
+ const backdropCloseable = inject("backdropCloseable");
125
133
  const navRight = computed(() => position.value === "right" ? {
126
134
  "right": 0
127
135
  } : {
128
136
  "left": 0
129
137
  });
130
138
  const navWidth = computed(() => isFullScreen.value ? "100vw" : width.value);
131
- let clickContent = (e) => {
139
+ const clickContent = (e) => {
132
140
  e.stopPropagation();
133
141
  };
142
+ const handleDrawerClose = () => {
143
+ if (!backdropCloseable.value)
144
+ return;
145
+ closeDrawer();
146
+ };
134
147
  return {
135
- closeDrawer,
136
148
  zindex,
137
149
  slots,
138
150
  isCover,
139
151
  navRight,
140
152
  navWidth,
141
153
  visible,
142
- clickContent
154
+ clickContent,
155
+ handleDrawerClose
143
156
  };
144
157
  },
145
158
  render() {
146
159
  const {
147
160
  zindex,
148
- closeDrawer,
149
161
  slots,
150
162
  isCover,
151
163
  navRight,
152
164
  navWidth,
153
- visible
165
+ visible,
166
+ handleDrawerClose
154
167
  } = this;
155
168
  if (!visible)
156
169
  return null;
@@ -159,7 +172,7 @@ var DrawerBody = defineComponent({
159
172
  "style": {
160
173
  zIndex: zindex
161
174
  },
162
- "onClick": closeDrawer
175
+ "onClick": handleDrawerClose
163
176
  }, [isCover ? createVNode("div", {
164
177
  "class": "devui-overlay-backdrop"
165
178
  }, null) : null, createVNode("div", {
@@ -189,13 +202,23 @@ var Drawer = defineComponent({
189
202
  zIndex,
190
203
  isCover,
191
204
  escKeyCloseable,
192
- position
205
+ position,
206
+ backdropCloseable
193
207
  } = toRefs(props);
194
- let isFullScreen = ref(false);
208
+ const isFullScreen = ref(false);
195
209
  const fullScreenEvent = () => {
196
210
  isFullScreen.value = !isFullScreen.value;
197
211
  };
198
- const closeDrawer = () => {
212
+ const closeDrawer = async () => {
213
+ var _a;
214
+ const beforeHidden = props.beforeHidden;
215
+ let result = (_a = typeof beforeHidden === "function" ? beforeHidden() : beforeHidden) != null ? _a : true;
216
+ if (result instanceof Promise) {
217
+ console.log(result);
218
+ result = await result;
219
+ }
220
+ if (result)
221
+ return;
199
222
  emit("update:visible", false);
200
223
  emit("close");
201
224
  };
@@ -222,6 +245,7 @@ var Drawer = defineComponent({
222
245
  provide("width", width);
223
246
  provide("visible", visible);
224
247
  provide("isFullScreen", isFullScreen);
248
+ provide("backdropCloseable", backdropCloseable);
225
249
  onUnmounted(() => {
226
250
  document.removeEventListener("keyup", escCloseDrawer);
227
251
  });
@@ -1 +1 @@
1
- var g=Object.defineProperty;var C=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var D=(t,e,l)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[e]=l,y=(t,e)=>{for(var l in e||(e={}))F.call(e,l)&&D(t,l,e[l]);if(C)for(var l of C(e))j.call(e,l)&&D(t,l,e[l]);return t};(function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.index={},t.Vue))})(this,function(t,e){"use strict";const l={width:{type:String,default:"300px"},visible:{type:Boolean,default:!1},zIndex:{type:Number,default:1e3},isCover:{type:Boolean,default:!0},escKeyCloseable:{type:Boolean,default:!0},position:{type:String,default:"left"}};var k="",b=e.defineComponent({name:"DrawerHeader",emits:["toggleFullScreen","close"],setup(n,r){const i=e.ref(!1),o=e.inject("visible");return{fullScreenClassName:e.computed(()=>i.value?"icon icon-minimize":"icon icon-maxmize"),visible:o,handleFullScreen:p=>{p.stopPropagation(),i.value=!i.value,r.emit("toggleFullScreen")},handleDrawerClose:()=>{r.emit("close")}}},render(){const{handleFullScreen:n,handleDrawerClose:r,visible:i,fullScreenClassName:o}=this;return i?e.createVNode("div",{class:"devui-drawer-header"},[e.createVNode("div",{class:"devui-drawer-header-item"},[e.createVNode("span",{class:"devui-drawer-header-item icon icon-more-operate"},null)]),e.createVNode("div",{class:"devui-drawer-header-item",onClick:n},[e.createVNode("span",{class:o},null)]),e.createVNode("div",{class:"devui-drawer-header-item",onClick:r},[e.createVNode("span",{class:"icon icon-close"},null)])]):null}}),N=e.defineComponent({name:"DrawerContainer",setup(){return{visible:e.inject("visible")}},render(){const{visible:n}=this;return n?e.createVNode("div",null,[e.createTextVNode("\u5185\u5BB9\u533A\u57DF")]):null}}),x="",S=e.defineComponent({name:"DrawerBody",setup(n,{slots:r}){const i=e.inject("isFullScreen"),o=e.inject("closeDrawer"),s=e.inject("zindex"),d=e.inject("isCover"),c=e.inject("position"),p=e.inject("width"),v=e.inject("visible"),a=e.computed(()=>c.value==="right"?{right:0}:{left:0}),h=e.computed(()=>i.value?"100vw":p.value);return{closeDrawer:o,zindex:s,slots:r,isCover:d,navRight:a,navWidth:h,visible:v,clickContent:f=>{f.stopPropagation()}}},render(){const{zindex:n,closeDrawer:r,slots:i,isCover:o,navRight:s,navWidth:d,visible:c}=this;return c?e.createVNode("div",{class:"devui-drawer",style:{zIndex:n},onClick:r},[o?e.createVNode("div",{class:"devui-overlay-backdrop"},null):null,e.createVNode("div",{class:"devui-overlay-wrapper"},[e.createVNode("div",{class:"devui-drawer-nav",style:y({width:d},s)},[e.createVNode("div",{class:"devui-drawer-content",onClick:this.clickContent},[i.default?i.default():null])])])]):null}}),u=e.defineComponent({name:"DDrawer",props:l,emits:["close","update:visible","afterOpened"],setup(n,{emit:r,slots:i}){const{width:o,visible:s,zIndex:d,isCover:c,escKeyCloseable:p,position:v}=e.toRefs(n);let a=e.ref(!1);const h=()=>{a.value=!a.value},w=()=>{r("update:visible",!1),r("close")},f=m=>{m.code==="Escape"&&w()};return e.watch(s,m=>{m&&(r("afterOpened"),a.value=!1),p&&m?document.addEventListener("keyup",f):document.removeEventListener("keyup",f)}),e.provide("closeDrawer",w),e.provide("zindex",d),e.provide("isCover",c),e.provide("position",v),e.provide("width",o),e.provide("visible",s),e.provide("isFullScreen",a),e.onUnmounted(()=>{document.removeEventListener("keyup",f)}),{isFullScreen:a,visible:s,slots:i,fullScreenEvent:h,closeDrawer:w}},render(){const n=this.fullScreenEvent,r=this.closeDrawer;return this.visible?e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(S,null,{default:()=>[e.createVNode(b,{onToggleFullScreen:n,onClose:r},null),this.slots.default?this.slots.default():e.createVNode(N,null,null)]})]}):null}});u.install=function(n){n.component(u.name,u)};var V={title:"Drawer \u62BD\u5C49\u677F",category:"\u53CD\u9988",status:"30%",install(n){n.use(u)}};t.Drawer=u,t.default=V,Object.defineProperty(t,"__esModule",{value:!0}),t[Symbol.toStringTag]="Module"});
1
+ var j=Object.defineProperty;var D=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var N=(n,e,o)=>e in n?j(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,S=(n,e)=>{for(var o in e||(e={}))x.call(e,o)&&N(n,o,e[o]);if(D)for(var o of D(e))B.call(e,o)&&N(n,o,e[o]);return n};(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.index={},n.Vue))})(this,function(n,e){"use strict";const o={width:{type:String,default:"300px"},visible:{type:Boolean,default:!1},zIndex:{type:Number,default:1e3},isCover:{type:Boolean,default:!0},escKeyCloseable:{type:Boolean,default:!0},position:{type:String,default:"left"},backdropCloseable:{type:Boolean,default:!0},beforeHidden:{type:[Promise,Function]}};var z="",V=e.defineComponent({name:"DrawerHeader",emits:["toggleFullScreen","close"],setup(r,t){const l=e.ref(!1),s=e.inject("visible");return{fullScreenClassName:e.computed(()=>l.value?"icon icon-minimize":"icon icon-maxmize"),visible:s,handleFullScreen:f=>{f.stopPropagation(),l.value=!l.value,t.emit("toggleFullScreen")},handleDrawerClose:()=>{t.emit("close")}}},render(){const{handleFullScreen:r,handleDrawerClose:t,visible:l,fullScreenClassName:s}=this;return l?e.createVNode("div",{class:"devui-drawer-header"},[e.createVNode("div",{class:"devui-drawer-header-item"},[e.createVNode("span",{class:"devui-drawer-header-item icon icon-more-operate"},null)]),e.createVNode("div",{class:"devui-drawer-header-item",onClick:r},[e.createVNode("span",{class:s},null)]),e.createVNode("div",{class:"devui-drawer-header-item",onClick:t},[e.createVNode("span",{class:"icon icon-close"},null)])]):null}}),g=e.defineComponent({name:"DrawerContainer",setup(){return{visible:e.inject("visible")}},render(){const{visible:r}=this;return r?e.createVNode("div",null,[e.createTextVNode("\u5185\u5BB9\u533A\u57DF")]):null}}),E="",k=e.defineComponent({name:"DrawerBody",setup(r,{slots:t}){const l=e.inject("isFullScreen"),s=e.inject("closeDrawer"),a=e.inject("zindex"),c=e.inject("isCover"),u=e.inject("position"),f=e.inject("width"),C=e.inject("visible"),v=e.inject("backdropCloseable"),d=e.computed(()=>u.value==="right"?{right:0}:{left:0}),b=e.computed(()=>l.value?"100vw":f.value);return{zindex:a,slots:t,isCover:c,navRight:d,navWidth:b,visible:C,clickContent:i=>{i.stopPropagation()},handleDrawerClose:()=>{!v.value||s()}}},render(){const{zindex:r,slots:t,isCover:l,navRight:s,navWidth:a,visible:c,handleDrawerClose:u}=this;return c?e.createVNode("div",{class:"devui-drawer",style:{zIndex:r},onClick:u},[l?e.createVNode("div",{class:"devui-overlay-backdrop"},null):null,e.createVNode("div",{class:"devui-overlay-wrapper"},[e.createVNode("div",{class:"devui-drawer-nav",style:S({width:a},s)},[e.createVNode("div",{class:"devui-drawer-content",onClick:this.clickContent},[t.default?t.default():null])])])]):null}}),p=e.defineComponent({name:"DDrawer",props:o,emits:["close","update:visible","afterOpened"],setup(r,{emit:t,slots:l}){const{width:s,visible:a,zIndex:c,isCover:u,escKeyCloseable:f,position:C,backdropCloseable:v}=e.toRefs(r),d=e.ref(!1),b=()=>{d.value=!d.value},h=async()=>{var y;const i=r.beforeHidden;let w=(y=typeof i=="function"?i():i)!=null?y:!0;w instanceof Promise&&(console.log(w),w=await w),!w&&(t("update:visible",!1),t("close"))},m=i=>{i.code==="Escape"&&h()};return e.watch(a,i=>{i&&(t("afterOpened"),d.value=!1),f&&i?document.addEventListener("keyup",m):document.removeEventListener("keyup",m)}),e.provide("closeDrawer",h),e.provide("zindex",c),e.provide("isCover",u),e.provide("position",C),e.provide("width",s),e.provide("visible",a),e.provide("isFullScreen",d),e.provide("backdropCloseable",v),e.onUnmounted(()=>{document.removeEventListener("keyup",m)}),{isFullScreen:d,visible:a,slots:l,fullScreenEvent:b,closeDrawer:h}},render(){const r=this.fullScreenEvent,t=this.closeDrawer;return this.visible?e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(k,null,{default:()=>[e.createVNode(V,{onToggleFullScreen:r,onClose:t},null),this.slots.default?this.slots.default():e.createVNode(g,null,null)]})]}):null}});p.install=function(r){r.component(p.name,p)};var F={title:"Drawer \u62BD\u5C49\u677F",category:"\u53CD\u9988",status:"30%",install(r){r.use(p)}};n.Drawer=p,n.default=F,Object.defineProperty(n,"__esModule",{value:!0}),n[Symbol.toStringTag]="Module"});
@@ -0,0 +1,7 @@
1
+ import { App } from 'vue';
2
+ declare function install(app: App): void
3
+ declare const _default: {
4
+ install: typeof install;
5
+ version: string;
6
+ };
7
+ export default _default;
@@ -17,11 +17,10 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { ref, watch, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, onUnmounted, withDirectives, vShow, reactive, getCurrentInstance, nextTick, toRef, onBeforeUnmount, isRef, toRefs, Fragment } from "vue";
20
+ import { ref, watch, defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, onUnmounted, withDirectives, vShow, reactive, toRef, isRef, toRefs, Fragment } from "vue";
21
21
  const dropdownProps = {
22
22
  origin: {
23
- type: Object,
24
- required: true
23
+ type: Object
25
24
  },
26
25
  isOpen: {
27
26
  type: Boolean,
@@ -41,7 +40,7 @@ const dropdownProps = {
41
40
  },
42
41
  closeOnMouseLeaveMenu: {
43
42
  type: Boolean,
44
- default: true
43
+ default: false
45
44
  },
46
45
  showAnimation: {
47
46
  type: Boolean,
@@ -176,7 +175,7 @@ const overlayProps = {
176
175
  backgroundStyle: {
177
176
  type: [String, Object]
178
177
  },
179
- backdropClick: {
178
+ onBackdropClick: {
180
179
  type: Function
181
180
  },
182
181
  backdropClose: {
@@ -188,6 +187,7 @@ const overlayProps = {
188
187
  default: true
189
188
  }
190
189
  };
190
+ const overlayEmits = ["onUpdate:visible", "backdropClick"];
191
191
  const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
192
192
  overlayStyle: {
193
193
  type: [String, Object],
@@ -223,7 +223,7 @@ function useOverlayLogic(props) {
223
223
  const handleBackdropClick = (event) => {
224
224
  var _a, _b;
225
225
  event.preventDefault();
226
- (_a = props.backdropClick) == null ? void 0 : _a.call(props);
226
+ (_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
227
227
  if (props.backdropClose) {
228
228
  (_b = props["onUpdate:visible"]) == null ? void 0 : _b.call(props, false);
229
229
  }
@@ -262,6 +262,7 @@ function useOverlayLogic(props) {
262
262
  const FixedOverlay = defineComponent({
263
263
  name: "DFixedOverlay",
264
264
  props: fixedOverlayProps,
265
+ emits: overlayEmits,
265
266
  setup(props, ctx) {
266
267
  const {
267
268
  backgroundClass,
@@ -285,61 +286,46 @@ const FixedOverlay = defineComponent({
285
286
  const FlexibleOverlay = defineComponent({
286
287
  name: "DFlexibleOverlay",
287
288
  props: flexibleOverlayProps,
288
- emits: ["onUpdate:visible"],
289
+ emits: overlayEmits,
289
290
  setup(props, ctx) {
290
291
  const overlayRef = ref(null);
291
292
  const positionedStyle = reactive({
292
293
  position: "absolute"
293
294
  });
294
- const instance = getCurrentInstance();
295
295
  onMounted(async () => {
296
- await nextTick();
297
- const overlay2 = overlayRef.value;
298
- if (!overlay2) {
299
- return;
300
- }
301
- const origin = getOrigin(props.origin);
302
- if (!origin) {
303
- return;
304
- }
305
- const handleRectChange = (rect) => {
306
- const point = calculatePosition(props.position, rect, origin);
296
+ const handleRectChange = (position, rect, origin) => {
297
+ const point = calculatePosition(position, rect, origin);
307
298
  positionedStyle.left = `${point.x}px`;
308
299
  positionedStyle.top = `${point.y}px`;
309
300
  };
310
- const handleChange = () => handleRectChange(overlay2.getBoundingClientRect());
301
+ const locationElements = computed(() => {
302
+ const overlay2 = overlayRef.value;
303
+ const origin = getOrigin(props.origin);
304
+ if (!overlay2 || !origin) {
305
+ return;
306
+ }
307
+ return {
308
+ origin,
309
+ overlay: overlay2
310
+ };
311
+ });
311
312
  const visibleRef = toRef(props, "visible");
312
313
  const positionRef = toRef(props, "position");
313
- watch(visibleRef, (visible, ov, onInvalidate) => {
314
- if (visible) {
315
- subscribeLayoutEvent(handleChange);
316
- } else {
317
- unsbscribeLayoutEvent(handleChange);
314
+ watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
315
+ if (!visible || !locationElements2) {
316
+ return;
318
317
  }
318
+ const {
319
+ origin,
320
+ overlay: overlay2
321
+ } = locationElements2;
322
+ handleRectChange(position, overlay2.getBoundingClientRect(), origin);
323
+ const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
319
324
  onInvalidate(() => {
320
- unsbscribeLayoutEvent(handleChange);
325
+ unsubscriptions.forEach((fn) => fn());
321
326
  });
322
327
  });
323
- watch([visibleRef, positionRef], () => {
324
- handleChange();
325
- });
326
- const resizeObserver = new ResizeObserver((entries) => {
327
- handleRectChange(entries[0].contentRect);
328
- });
329
- resizeObserver.observe(overlay2);
330
- onBeforeUnmount(() => {
331
- resizeObserver.disconnect();
332
- }, instance);
333
- if (origin instanceof Element) {
334
- const observer = new MutationObserver(handleChange);
335
- observer.observe(origin, {
336
- attributeFilter: ["style"]
337
- });
338
- onBeforeUnmount(() => {
339
- observer.disconnect();
340
- }, instance);
341
- }
342
- }, instance);
328
+ });
343
329
  const {
344
330
  backgroundClass,
345
331
  overlayClass,
@@ -372,15 +358,9 @@ function getOrigin(origin) {
372
358
  }
373
359
  return origin;
374
360
  }
375
- function calculatePosition(position, panelOrRect, origin) {
361
+ function calculatePosition(position, rect, origin) {
376
362
  const originRect = getOriginRect(origin);
377
363
  const originPoint = getOriginRelativePoint(originRect, position);
378
- let rect;
379
- if (panelOrRect instanceof HTMLElement) {
380
- rect = panelOrRect.getBoundingClientRect();
381
- } else {
382
- rect = panelOrRect;
383
- }
384
364
  return getOverlayPoint(originPoint, rect, position);
385
365
  }
386
366
  function getOriginRect(origin) {
@@ -444,11 +424,31 @@ function subscribeLayoutEvent(event) {
444
424
  window.addEventListener("scroll", event, true);
445
425
  window.addEventListener("resize", event);
446
426
  window.addEventListener("orientationchange", event);
427
+ return () => {
428
+ window.removeEventListener("scroll", event, true);
429
+ window.removeEventListener("resize", event);
430
+ window.removeEventListener("orientationchange", event);
431
+ };
447
432
  }
448
- function unsbscribeLayoutEvent(event) {
449
- window.removeEventListener("scroll", event, true);
450
- window.removeEventListener("resize", event);
451
- window.removeEventListener("orientationchange", event);
433
+ function subscribeOverlayResize(overlay2, callback) {
434
+ if (overlay2 instanceof Element) {
435
+ const resizeObserver = new ResizeObserver(callback);
436
+ resizeObserver.observe(overlay2);
437
+ return () => resizeObserver.disconnect();
438
+ }
439
+ return () => {
440
+ };
441
+ }
442
+ function subscribeOriginResize(origin, callback) {
443
+ if (origin instanceof Element) {
444
+ const observer = new MutationObserver(callback);
445
+ observer.observe(origin, {
446
+ attributeFilter: ["style"]
447
+ });
448
+ return () => observer.disconnect();
449
+ }
450
+ return () => {
451
+ };
452
452
  }
453
453
  FlexibleOverlay.install = function(app) {
454
454
  app.component(FlexibleOverlay.name, FlexibleOverlay);
@@ -476,9 +476,9 @@ var Dropdown = defineComponent({
476
476
  immediate: true
477
477
  });
478
478
  const position = {
479
- originX: "left",
479
+ originX: "center",
480
480
  originY: "bottom",
481
- overlayX: "left",
481
+ overlayX: "center",
482
482
  overlayY: "top"
483
483
  };
484
484
  const {
@@ -508,7 +508,7 @@ var Dropdown = defineComponent({
508
508
  var _a, _b;
509
509
  return [withDirectives(createVNode("div", {
510
510
  "ref": dropdownEl,
511
- "style": "width:100vw"
511
+ "style": "min-width:102px"
512
512
  }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), [[vShow, animatedVisible.value]])];
513
513
  }
514
514
  })]
@@ -522,7 +522,7 @@ Dropdown.install = function(app) {
522
522
  var index = {
523
523
  title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
524
524
  category: "\u5BFC\u822A",
525
- status: void 0,
525
+ status: "10%",
526
526
  install(app) {
527
527
  app.use(Dropdown);
528
528
  }
@@ -1 +1 @@
1
- var I=Object.defineProperty,G=Object.defineProperties;var J=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var X=(r,t,f)=>t in r?I(r,t,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[t]=f,E=(r,t)=>{for(var f in t||(t={}))K.call(t,f)&&X(r,f,t[f]);if(j)for(var f of j(t))Q.call(t,f)&&X(r,f,t[f]);return r},Y=(r,t)=>G(r,J(t));(function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r.index={},r.Vue))})(this,function(r,t){"use strict";const f={origin:{type:Object,required:!0},isOpen:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},trigger:{type:String,default:"click"},closeScope:{type:String,default:"all"},closeOnMouseLeaveMenu:{type:Boolean,default:!0},showAnimation:{type:Boolean,default:!0}};function F(e){return!!(e==null?void 0:e.$el)}function O(e){return e instanceof Element?e:e&&typeof e=="object"&&e.$el instanceof Element?e.$el:null}function w(e,l,n){return e==null||e.addEventListener(l,n),()=>{e==null||e.removeEventListener(l,n)}}const R=({visible:e,trigger:l,origin:n,closeScope:a,closeOnMouseLeaveMenu:i})=>{const o=t.ref(),s=()=>{a.value!=="none"&&(e.value=!1)};return t.watch([l,n,o],([c,g,d],b,v)=>{const u=O(g);if(!u||!d)return;const m=[w(d,"click",()=>{a.value==="all"&&(e.value=!1)})];if(c==="click")m.push(w(u,"click",()=>e.value=!e.value),w(document,"click",h=>{if(!e.value)return;const p=h.target;u.contains(p)||d.contains(p)||s()}),w(d,"mouseleave",()=>{i.value&&(e.value=!1)}));else if(c==="hover"){let h=!1,p=!1;const y=async C=>{await new Promise(x=>setTimeout(x,50)),!(C==="origin"&&h||C==="dropdown"&&p)&&s()};m.push(w(u,"mouseenter",()=>{p=!0,e.value=!0}),w(u,"mouseleave",()=>{p=!1,i.value||y("origin")}),w(d,"mouseenter",()=>{h=!0,e.value=!0}),w(d,"mouseleave",()=>{h=!1,y("dropdown")}))}v(()=>m.forEach(h=>h()))}),{dropdownEl:o}};var W="";function T(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const V=t.defineComponent({setup(e,l){return()=>{let n;return t.createVNode(t.Teleport,{to:"#d-overlay-anchor"},{default:()=>[t.createVNode(t.Transition,{name:"devui-overlay-fade"},T(n=t.renderSlot(l.slots,"default"))?n:{default:()=>[n]})]})}}}),L={visible:{type:Boolean},"onUpdate:visible":{type:Function},backgroundBlock:{type:Boolean,default:!1},backgroundClass:{type:String,default:""},backgroundStyle:{type:[String,Object]},backdropClick:{type:Function},backdropClose:{type:Boolean,default:!0},hasBackdrop:{type:Boolean,default:!0}},M=Y(E({},L),{overlayStyle:{type:[String,Object],default:void 0}}),_=E({origin:{type:Object,require:!0},position:{type:Object,default:()=>({originX:"left",originY:"top",overlayX:"left",overlayY:"top"})}},L);function D(e){const l=t.computed(()=>["devui-overlay-background",e.backgroundClass,e.hasBackdrop?"devui-overlay-background__color":"devui-overlay-background__disabled"]),n=t.computed(()=>"devui-overlay"),a=o=>{var s,c;o.preventDefault(),(s=e.backdropClick)==null||s.call(e),e.backdropClose&&((c=e["onUpdate:visible"])==null||c.call(e,!1))},i=o=>o.cancelBubble=!0;return t.onMounted(()=>{const o=document.body,s=o.style.overflow,c=o.style.position;t.watch([()=>e.visible,()=>e.backgroundBlock],([g,d])=>{if(d){const b=o.getBoundingClientRect().y;g?(o.style.overflowY="scroll",o.style.position=g?"fixed":"",o.style.top=`${b}px`):(o.style.overflowY=s,o.style.position=c,o.style.top="",window.scrollTo(0,-b))}}),t.onUnmounted(()=>{document.body.style.overflow=s})}),{backgroundClass:l,overlayClass:n,handleBackdropClick:a,handleOverlayBubbleCancel:i}}const S=t.defineComponent({name:"DFixedOverlay",props:M,setup(e,l){const{backgroundClass:n,overlayClass:a,handleBackdropClick:i,handleOverlayBubbleCancel:o}=D(e);return()=>t.createVNode(V,null,{default:()=>[t.withDirectives(t.createVNode("div",{class:n.value,style:e.backgroundStyle,onClick:i},[t.createVNode("div",{class:a.value,style:e.overlayStyle,onClick:o},[t.renderSlot(l.slots,"default")])]),[[t.vShow,e.visible]])]})}}),B=t.defineComponent({name:"DFlexibleOverlay",props:_,emits:["onUpdate:visible"],setup(e,l){const n=t.ref(null),a=t.reactive({position:"absolute"}),i=t.getCurrentInstance();t.onMounted(async()=>{await t.nextTick();const d=n.value;if(!d)return;const b=U(e.origin);if(!b)return;const v=y=>{const C=P(e.position,y,b);a.left=`${C.x}px`,a.top=`${C.y}px`},u=()=>v(d.getBoundingClientRect()),m=t.toRef(e,"visible"),h=t.toRef(e,"position");t.watch(m,(y,C,x)=>{y?A(u):N(u),x(()=>{N(u)})}),t.watch([m,h],()=>{u()});const p=new ResizeObserver(y=>{v(y[0].contentRect)});if(p.observe(d),t.onBeforeUnmount(()=>{p.disconnect()},i),b instanceof Element){const y=new MutationObserver(u);y.observe(b,{attributeFilter:["style"]}),t.onBeforeUnmount(()=>{y.disconnect()},i)}},i);const{backgroundClass:o,overlayClass:s,handleBackdropClick:c,handleOverlayBubbleCancel:g}=D(e);return()=>t.createVNode(V,null,{default:()=>[t.withDirectives(t.createVNode("div",{style:e.backgroundStyle,class:o.value,onClick:c},[t.createVNode("div",{ref:n,class:s.value,style:a,onClick:g},[t.renderSlot(l.slots,"default")])]),[[t.vShow,e.visible]])]})}});function U(e){return e instanceof Element?e:t.isRef(e)?O(e.value):F(e)?O(e):e}function P(e,l,n){const a=$(n),i=q(a,e);let o;return l instanceof HTMLElement?o=l.getBoundingClientRect():o=l,z(i,o,e)}function $(e){if(e instanceof Element)return e.getBoundingClientRect();const l=e.width||0,n=e.height||0;return{top:e.y,bottom:e.y+n,left:e.x,right:e.x+l,height:n,width:l}}function z(e,l,n){let a;const{width:i,height:o}=l;n.overlayX=="center"?a=e.x-i/2:a=n.overlayX=="left"?e.x:e.x-i;let s;return n.overlayY=="center"?s=e.y-o/2:s=n.overlayY=="top"?e.y:e.y-o,{x:a,y:s}}function q(e,l){let n;if(l.originX=="center")n=e.left+e.width/2;else{const i=e.left,o=e.right;n=l.originX=="left"?i:o}let a;return l.originY=="center"?a=e.top+e.height/2:a=l.originY=="top"?e.top:e.bottom,{x:n,y:a}}function A(e){window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),window.addEventListener("orientationchange",e)}function N(e){window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}B.install=function(e){e.component(B.name,B)},S.install=function(e){e.component(S.name,S)};var Z="",k=t.defineComponent({name:"DDropdown",props:f,emits:[],setup(e,l){const{isOpen:n,origin:a,trigger:i,closeScope:o,closeOnMouseLeaveMenu:s}=t.toRefs(e),c=t.ref(!1);t.watch(n,v=>{c.value=v},{immediate:!0});const g={originX:"left",originY:"bottom",overlayX:"left",overlayY:"top"},{dropdownEl:d}=R({visible:c,origin:a,trigger:i,closeScope:o,closeOnMouseLeaveMenu:s}),b=t.computed(()=>e.showAnimation?c.value:!0);return()=>t.createVNode(t.Fragment,null,[t.createVNode(B,{origin:e.origin,visible:c.value,"onUpdate:visible":v=>c.value=v,position:g,hasBackdrop:!1},{default:()=>[t.createVNode(t.Transition,{name:"devui-dropdown-fade"},{default:()=>{var v,u;return[t.withDirectives(t.createVNode("div",{ref:d,style:"width:100vw"},[(u=(v=l.slots).default)==null?void 0:u.call(v)]),[[t.vShow,b.value]])]}})]})])}});k.install=function(e){e.component(k.name,k)};var H={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:void 0,install(e){e.use(k)}};r.Dropdown=k,r.default=H,Object.defineProperty(r,"__esModule",{value:!0}),r[Symbol.toStringTag]="Module"});
1
+ var Q=Object.defineProperty,W=Object.defineProperties;var Z=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var X=(a,t,f)=>t in a?Q(a,t,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[t]=f,V=(a,t)=>{for(var f in t||(t={}))ee.call(t,f)&&X(a,f,t[f]);if(j)for(var f of j(t))te.call(t,f)&&X(a,f,t[f]);return a},Y=(a,t)=>W(a,Z(t));(function(a,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(a=typeof globalThis!="undefined"?globalThis:a||self,t(a.index={},a.Vue))})(this,function(a,t){"use strict";const f={origin:{type:Object},isOpen:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},trigger:{type:String,default:"click"},closeScope:{type:String,default:"all"},closeOnMouseLeaveMenu:{type:Boolean,default:!1},showAnimation:{type:Boolean,default:!0}};function F(e){return!!(e==null?void 0:e.$el)}function S(e){return e instanceof Element?e:e&&typeof e=="object"&&e.$el instanceof Element?e.$el:null}function g(e,o,n){return e==null||e.addEventListener(o,n),()=>{e==null||e.removeEventListener(o,n)}}const _=({visible:e,trigger:o,origin:n,closeScope:r,closeOnMouseLeaveMenu:i})=>{const l=t.ref(),s=()=>{r.value!=="none"&&(e.value=!1)};return t.watch([o,n,l],([u,v,y],m,b)=>{const c=S(v);if(!c||!y)return;const p=[g(y,"click",()=>{r.value==="all"&&(e.value=!1)})];if(u==="click")p.push(g(c,"click",()=>e.value=!e.value),g(document,"click",d=>{if(!e.value)return;const h=d.target;c.contains(h)||y.contains(h)||s()}),g(y,"mouseleave",()=>{i.value&&(e.value=!1)}));else if(u==="hover"){let d=!1,h=!1;const O=async w=>{await new Promise(k=>setTimeout(k,50)),!(w==="origin"&&d||w==="dropdown"&&h)&&s()};p.push(g(c,"mouseenter",()=>{h=!0,e.value=!0}),g(c,"mouseleave",()=>{h=!1,i.value||O("origin")}),g(y,"mouseenter",()=>{d=!0,e.value=!0}),g(y,"mouseleave",()=>{d=!1,O("dropdown")}))}b(()=>p.forEach(d=>d()))}),{dropdownEl:l}};var ne="";function M(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const R=t.defineComponent({setup(e,o){return()=>{let n;return t.createVNode(t.Teleport,{to:"#d-overlay-anchor"},{default:()=>[t.createVNode(t.Transition,{name:"devui-overlay-fade"},M(n=t.renderSlot(o.slots,"default"))?n:{default:()=>[n]})]})}}}),D={visible:{type:Boolean},"onUpdate:visible":{type:Function},backgroundBlock:{type:Boolean,default:!1},backgroundClass:{type:String,default:""},backgroundStyle:{type:[String,Object]},onBackdropClick:{type:Function},backdropClose:{type:Boolean,default:!0},hasBackdrop:{type:Boolean,default:!0}},N=["onUpdate:visible","backdropClick"],T=Y(V({},D),{overlayStyle:{type:[String,Object],default:void 0}}),z=V({origin:{type:Object,require:!0},position:{type:Object,default:()=>({originX:"left",originY:"top",overlayX:"left",overlayY:"top"})}},D);function L(e){const o=t.computed(()=>["devui-overlay-background",e.backgroundClass,e.hasBackdrop?"devui-overlay-background__color":"devui-overlay-background__disabled"]),n=t.computed(()=>"devui-overlay"),r=l=>{var s,u;l.preventDefault(),(s=e.onBackdropClick)==null||s.call(e),e.backdropClose&&((u=e["onUpdate:visible"])==null||u.call(e,!1))},i=l=>l.cancelBubble=!0;return t.onMounted(()=>{const l=document.body,s=l.style.overflow,u=l.style.position;t.watch([()=>e.visible,()=>e.backgroundBlock],([v,y])=>{if(y){const m=l.getBoundingClientRect().y;v?(l.style.overflowY="scroll",l.style.position=v?"fixed":"",l.style.top=`${m}px`):(l.style.overflowY=s,l.style.position=u,l.style.top="",window.scrollTo(0,-m))}}),t.onUnmounted(()=>{document.body.style.overflow=s})}),{backgroundClass:o,overlayClass:n,handleBackdropClick:r,handleOverlayBubbleCancel:i}}const E=t.defineComponent({name:"DFixedOverlay",props:T,emits:N,setup(e,o){const{backgroundClass:n,overlayClass:r,handleBackdropClick:i,handleOverlayBubbleCancel:l}=L(e);return()=>t.createVNode(R,null,{default:()=>[t.withDirectives(t.createVNode("div",{class:n.value,style:e.backgroundStyle,onClick:i},[t.createVNode("div",{class:r.value,style:e.overlayStyle,onClick:l},[t.renderSlot(o.slots,"default")])]),[[t.vShow,e.visible]])]})}}),B=t.defineComponent({name:"DFlexibleOverlay",props:z,emits:N,setup(e,o){const n=t.ref(null),r=t.reactive({position:"absolute"});t.onMounted(async()=>{const v=(c,p,d)=>{const h=$(c,p,d);r.left=`${h.x}px`,r.top=`${h.y}px`},y=t.computed(()=>{const c=n.value,p=P(e.origin);if(!(!c||!p))return{origin:p,overlay:c}}),m=t.toRef(e,"visible"),b=t.toRef(e,"position");t.watch([y,m,b],async([c,p,d],h,O)=>{if(!p||!c)return;const{origin:w,overlay:k}=c;v(d,k.getBoundingClientRect(),w);const K=[G(()=>v(d,k.getBoundingClientRect(),w)),H(k,x=>v(d,x[0].contentRect,w)),I(w,()=>v(d,k.getBoundingClientRect(),w))];O(()=>{K.forEach(x=>x())})})});const{backgroundClass:i,overlayClass:l,handleBackdropClick:s,handleOverlayBubbleCancel:u}=L(e);return()=>t.createVNode(R,null,{default:()=>[t.withDirectives(t.createVNode("div",{style:e.backgroundStyle,class:i.value,onClick:s},[t.createVNode("div",{ref:n,class:l.value,style:r,onClick:u},[t.renderSlot(o.slots,"default")])]),[[t.vShow,e.visible]])]})}});function P(e){return e instanceof Element?e:t.isRef(e)?S(e.value):F(e)?S(e):e}function $(e,o,n){const r=U(n),i=q(r,e);return A(i,o,e)}function U(e){if(e instanceof Element)return e.getBoundingClientRect();const o=e.width||0,n=e.height||0;return{top:e.y,bottom:e.y+n,left:e.x,right:e.x+o,height:n,width:o}}function A(e,o,n){let r;const{width:i,height:l}=o;n.overlayX=="center"?r=e.x-i/2:r=n.overlayX=="left"?e.x:e.x-i;let s;return n.overlayY=="center"?s=e.y-l/2:s=n.overlayY=="top"?e.y:e.y-l,{x:r,y:s}}function q(e,o){let n;if(o.originX=="center")n=e.left+e.width/2;else{const i=e.left,l=e.right;n=o.originX=="left"?i:l}let r;return o.originY=="center"?r=e.top+e.height/2:r=o.originY=="top"?e.top:e.bottom,{x:n,y:r}}function G(e){return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}}function H(e,o){if(e instanceof Element){const n=new ResizeObserver(o);return n.observe(e),()=>n.disconnect()}return()=>{}}function I(e,o){if(e instanceof Element){const n=new MutationObserver(o);return n.observe(e,{attributeFilter:["style"]}),()=>n.disconnect()}return()=>{}}B.install=function(e){e.component(B.name,B)},E.install=function(e){e.component(E.name,E)};var oe="",C=t.defineComponent({name:"DDropdown",props:f,emits:[],setup(e,o){const{isOpen:n,origin:r,trigger:i,closeScope:l,closeOnMouseLeaveMenu:s}=t.toRefs(e),u=t.ref(!1);t.watch(n,b=>{u.value=b},{immediate:!0});const v={originX:"center",originY:"bottom",overlayX:"center",overlayY:"top"},{dropdownEl:y}=_({visible:u,origin:r,trigger:i,closeScope:l,closeOnMouseLeaveMenu:s}),m=t.computed(()=>e.showAnimation?u.value:!0);return()=>t.createVNode(t.Fragment,null,[t.createVNode(B,{origin:e.origin,visible:u.value,"onUpdate:visible":b=>u.value=b,position:v,hasBackdrop:!1},{default:()=>[t.createVNode(t.Transition,{name:"devui-dropdown-fade"},{default:()=>{var b,c;return[t.withDirectives(t.createVNode("div",{ref:y,style:"min-width:102px"},[(c=(b=o.slots).default)==null?void 0:c.call(b)]),[[t.vShow,m.value]])]}})]})])}});C.install=function(e){e.component(C.name,C)};var J={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:"10%",install(e){e.use(C)}};a.Dropdown=C,a.default=J,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module"});
@@ -0,0 +1,7 @@
1
+ import { App } from 'vue';
2
+ declare function install(app: App): void
3
+ declare const _default: {
4
+ install: typeof install;
5
+ version: string;
6
+ };
7
+ export default _default;
@@ -14,7 +14,7 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
- import { defineComponent, createVNode, Fragment, ref, computed, withDirectives, Transition, renderSlot, vShow, resolveDirective } from "vue";
17
+ import { defineComponent, createVNode, ref, computed, withDirectives, Transition, renderSlot, vShow, resolveDirective } from "vue";
18
18
  const editableSelectProps = {
19
19
  modelValue: {
20
20
  type: [String, Number]
@@ -43,6 +43,10 @@ const editableSelectProps = {
43
43
  loading: {
44
44
  type: Boolean
45
45
  },
46
+ enableLazyLoad: {
47
+ type: Boolean,
48
+ default: false
49
+ },
46
50
  remoteMethod: {
47
51
  type: Function
48
52
  },
@@ -84,7 +88,7 @@ var Icon = defineComponent({
84
88
  color,
85
89
  classPrefix
86
90
  } = this;
87
- return createVNode(Fragment, null, [/^((https?):)?\/\//.test(name) ? createVNode("img", {
91
+ return /^((https?):)?\/\//.test(name) ? createVNode("img", {
88
92
  "src": name,
89
93
  "alt": name.split("/")[name.split("/").length - 1],
90
94
  "style": {
@@ -96,7 +100,7 @@ var Icon = defineComponent({
96
100
  fontSize: size,
97
101
  color
98
102
  }
99
- }, null)]);
103
+ }, null);
100
104
  }
101
105
  });
102
106
  Icon.install = function(app) {
@@ -5586,24 +5590,15 @@ var EditableSelect = defineComponent({
5586
5590
  props: editableSelectProps,
5587
5591
  emits: ["update:modelValue"],
5588
5592
  setup(props, ctx2) {
5589
- const inputCls = className("devui-form-control devui-dropdown-origin devui-dropdown-origin-open", {
5590
- disabled: props.disabled
5591
- });
5592
- const getLiCls = (item) => {
5593
- const {
5594
- disabledKey
5595
- } = props;
5596
- return className("devui-dropdown-item", {
5597
- disabled: disabledKey ? !!item[disabledKey] : false
5598
- });
5599
- };
5593
+ const dropdownRef = ref(null);
5600
5594
  const visible = ref(false);
5601
5595
  const inputValue = ref("");
5596
+ const activeIndex = ref(0);
5602
5597
  const query = ref(props.modelValue);
5603
5598
  const wait = computed(() => props.remote ? 300 : 0);
5604
5599
  const emptyText = computed(() => {
5605
5600
  const options = filteredOptions.value;
5606
- if (!props.remote && inputValue.value && options.length === 0) {
5601
+ if (!props.remote && options.length === 0) {
5607
5602
  return "\u6CA1\u6709\u76F8\u5173\u8BB0\u5F55";
5608
5603
  }
5609
5604
  if (options.length === 0) {
@@ -5626,7 +5621,7 @@ var EditableSelect = defineComponent({
5626
5621
  const filteredOptions = computed(() => {
5627
5622
  const isValidOption = (o) => {
5628
5623
  const query2 = inputValue.value;
5629
- const containsQueryString = query2 ? o.name.includes(query2) : true;
5624
+ const containsQueryString = query2 ? o.name.toLocaleLowerCase().indexOf(query2.toLocaleLowerCase()) >= 0 : true;
5630
5625
  return containsQueryString;
5631
5626
  };
5632
5627
  return normalizeOptions.value.map((item) => {
@@ -5636,6 +5631,11 @@ var EditableSelect = defineComponent({
5636
5631
  return null;
5637
5632
  }).filter((item) => item !== null);
5638
5633
  });
5634
+ const findIndex = (o) => {
5635
+ return normalizeOptions.value.findIndex((item) => {
5636
+ return item.name === o.name;
5637
+ });
5638
+ };
5639
5639
  const handleClose = () => {
5640
5640
  visible.value = false;
5641
5641
  };
@@ -5644,11 +5644,11 @@ var EditableSelect = defineComponent({
5644
5644
  visible.value = !visible.value;
5645
5645
  }
5646
5646
  };
5647
- const onInputChange = () => {
5647
+ const onInputChange = (val) => {
5648
5648
  if (props.filterMethod) {
5649
- props.filterMethod(inputValue.value);
5649
+ props.filterMethod(val);
5650
5650
  } else if (props.remote) {
5651
- props.remoteMethod(inputValue.value);
5651
+ props.remoteMethod(val);
5652
5652
  }
5653
5653
  };
5654
5654
  const debouncedOnInputChange = lodash.exports.debounce(onInputChange, wait.value);
@@ -5657,9 +5657,9 @@ var EditableSelect = defineComponent({
5657
5657
  inputValue.value = value;
5658
5658
  query.value = value;
5659
5659
  if (props.remote) {
5660
- debouncedOnInputChange();
5660
+ debouncedOnInputChange(value);
5661
5661
  } else {
5662
- onInputChange();
5662
+ onInputChange(value);
5663
5663
  }
5664
5664
  };
5665
5665
  const selectOptionClick = (e, item) => {
@@ -5670,12 +5670,37 @@ var EditableSelect = defineComponent({
5670
5670
  e.stopPropagation();
5671
5671
  } else {
5672
5672
  query.value = item.name;
5673
+ activeIndex.value = findIndex(item);
5674
+ inputValue.value = "";
5673
5675
  ctx2.emit("update:modelValue", item.name);
5674
5676
  }
5675
5677
  };
5678
+ const loadMore = () => {
5679
+ if (!props.enableLazyLoad)
5680
+ return;
5681
+ const dropdownVal = dropdownRef.value;
5682
+ if (dropdownVal.clientHeight + dropdownVal.scrollTop >= dropdownVal.scrollHeight) {
5683
+ props.remoteMethod(inputValue.value);
5684
+ }
5685
+ };
5676
5686
  return () => {
5687
+ const selectCls = className("devui-form-group devui-has-feedback", {
5688
+ "devui-select-open": visible.value
5689
+ });
5690
+ const inputCls = className("devui-form-control devui-dropdown-origin devui-dropdown-origin-open", {
5691
+ disabled: props.disabled
5692
+ });
5693
+ const getLiCls = (item, index2) => {
5694
+ const {
5695
+ disabledKey
5696
+ } = props;
5697
+ return className("devui-dropdown-item", {
5698
+ disabled: disabledKey ? !!item[disabledKey] : false,
5699
+ selected: activeIndex.value === index2
5700
+ });
5701
+ };
5677
5702
  return withDirectives(createVNode("div", {
5678
- "class": "devui-form-group devui-has-feedback devui-select-open",
5703
+ "class": selectCls,
5679
5704
  "onClick": toggleMenu
5680
5705
  }, [createVNode("input", {
5681
5706
  "class": inputCls,
@@ -5697,12 +5722,14 @@ var EditableSelect = defineComponent({
5697
5722
  "class": "devui-dropdown-menu"
5698
5723
  }, [createVNode("ul", {
5699
5724
  "class": "devui-list-unstyled scroll-height",
5725
+ "ref": dropdownRef,
5700
5726
  "style": {
5701
5727
  maxHeight: props.maxHeight + "px"
5702
- }
5703
- }, [filteredOptions.value.map((item) => {
5728
+ },
5729
+ "onScroll": loadMore
5730
+ }, [filteredOptions.value.map((item, index2) => {
5704
5731
  return createVNode("li", {
5705
- "class": getLiCls(item),
5732
+ "class": getLiCls(item, index2),
5706
5733
  "onClick": ($evnet) => selectOptionClick($evnet, item),
5707
5734
  "key": item.name
5708
5735
  }, [ctx2.slots.default ? renderSlot(ctx2.slots, "default", {
@@ -5723,7 +5750,7 @@ EditableSelect.install = function(app) {
5723
5750
  var index = {
5724
5751
  title: "EditableSelect \u53EF\u8F93\u5165\u4E0B\u62C9\u9009\u62E9\u6846",
5725
5752
  category: "\u6570\u636E\u5F55\u5165",
5726
- status: void 0,
5753
+ status: "10%",
5727
5754
  install(app) {
5728
5755
  app.use(EditableSelect);
5729
5756
  }