@nutui/nutui 4.0.12-beta.1 → 4.0.12

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 (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +1 -1
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +50 -50
  135. package/dist/styles/themes/jdb.scss +50 -50
  136. package/dist/styles/themes/jddkh.scss +50 -50
  137. package/dist/styles/themes/jdt.scss +50 -50
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +2 -2
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,13 +1,14 @@
1
- import { ref as v, computed as y, onMounted as N, onUnmounted as P, reactive as _, provide as T, resolveComponent as k, openBlock as i, createElementBlock as g, normalizeClass as u, createElementVNode as p, Fragment as D, renderList as I, normalizeStyle as U, toDisplayString as R, renderSlot as b, createBlock as x } from "vue";
2
- import { c as z } from "./component-234624bc.js";
3
- import { u as M } from "./index-192a3ef6.js";
4
- import { ArrowUp2 as j, ArrowDown2 as H } from "@nutui/icons-vue";
5
- import { _ as V } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { ref, computed, onMounted, onUnmounted, reactive, provide, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, Fragment, renderList, normalizeStyle, toDisplayString, renderSlot, createBlock } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { u as useRect } from "./index-29892cda.js";
4
+ import { ArrowUp2, ArrowDown2 } from "@nutui/icons-vue";
5
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
6
6
  import "../locale/lang";
7
- const { componentName: W, create: Y } = z("menu"), q = Y({
7
+ const { componentName, create } = createComponent("menu");
8
+ const _sfc_main = create({
8
9
  components: {
9
- ArrowUp2: j,
10
- ArrowDown2: H
10
+ ArrowUp2,
11
+ ArrowDown2
11
12
  },
12
13
  props: {
13
14
  activeColor: {
@@ -16,11 +17,11 @@ const { componentName: W, create: Y } = z("menu"), q = Y({
16
17
  },
17
18
  overlay: {
18
19
  type: Boolean,
19
- default: !0
20
+ default: true
20
21
  },
21
22
  lockScroll: {
22
23
  type: Boolean,
23
- default: !0
24
+ default: true
24
25
  },
25
26
  duration: {
26
27
  type: [Number, String],
@@ -28,7 +29,7 @@ const { componentName: W, create: Y } = z("menu"), q = Y({
28
29
  },
29
30
  closeOnClickOverlay: {
30
31
  type: Boolean,
31
- default: !0
32
+ default: true
32
33
  },
33
34
  direction: {
34
35
  type: String,
@@ -36,108 +37,162 @@ const { componentName: W, create: Y } = z("menu"), q = Y({
36
37
  },
37
38
  scrollFixed: {
38
39
  type: [Boolean, String, Number],
39
- default: !1
40
+ default: false
40
41
  },
41
42
  titleClass: [String]
42
43
  },
43
- setup(o, { emit: S, slots: $ }) {
44
- const c = v(), a = v(0), f = v(!1), m = () => {
45
- const e = _([]), t = _([]);
44
+ setup(props, { emit, slots }) {
45
+ const barRef = ref();
46
+ const offset = ref(0);
47
+ const isScrollFixed = ref(false);
48
+ const useChildren = () => {
49
+ const publicChildren = reactive([]);
50
+ const internalChildren = reactive([]);
51
+ const linkChildren2 = (value) => {
52
+ const link = (child) => {
53
+ if (child.proxy) {
54
+ internalChildren.push(child);
55
+ publicChildren.push(child.proxy);
56
+ }
57
+ };
58
+ const removeLink = (child) => {
59
+ if (child.proxy) {
60
+ let internalIndex = internalChildren.indexOf(child);
61
+ if (internalIndex > -1) {
62
+ internalChildren.splice(internalIndex, 1);
63
+ }
64
+ let publicIndex = publicChildren.indexOf(child.proxy);
65
+ if (internalIndex > -1) {
66
+ publicChildren.splice(publicIndex, 1);
67
+ }
68
+ }
69
+ };
70
+ provide(
71
+ "menuParent",
72
+ Object.assign(
73
+ {
74
+ removeLink,
75
+ link,
76
+ children: publicChildren,
77
+ internalChildren
78
+ },
79
+ value
80
+ )
81
+ );
82
+ };
46
83
  return {
47
- children: e,
48
- linkChildren: (E) => {
49
- T(
50
- "menuParent",
51
- Object.assign(
52
- {
53
- removeLink: (r) => {
54
- if (r.proxy) {
55
- let w = t.indexOf(r);
56
- w > -1 && t.splice(w, 1);
57
- let L = e.indexOf(r.proxy);
58
- w > -1 && e.splice(L, 1);
59
- }
60
- },
61
- link: (r) => {
62
- r.proxy && (t.push(r), e.push(r.proxy));
63
- },
64
- children: e,
65
- internalChildren: t
66
- },
67
- E
68
- )
69
- );
70
- }
84
+ children: publicChildren,
85
+ linkChildren: linkChildren2
71
86
  };
72
- }, { children: s, linkChildren: n } = m(), d = y(() => s.some((e) => e.state.showWrapper)), h = y(() => ({
73
- [W]: !0,
74
- "scroll-fixed": f.value
75
- })), B = () => {
76
- if (c.value) {
77
- const e = M(c);
78
- o.direction === "down" ? a.value = e.bottom : a.value = window.innerHeight - e.top;
87
+ };
88
+ const { children, linkChildren } = useChildren();
89
+ const opened = computed(() => children.some((item) => item.state.showWrapper));
90
+ const classes = computed(() => {
91
+ const prefixCls = componentName;
92
+ return {
93
+ [prefixCls]: true,
94
+ "scroll-fixed": isScrollFixed.value
95
+ };
96
+ });
97
+ const updateOffset = () => {
98
+ if (barRef.value) {
99
+ const rect = useRect(barRef);
100
+ if (props.direction === "down") {
101
+ offset.value = rect.bottom;
102
+ } else {
103
+ offset.value = window.innerHeight - rect.top;
104
+ }
79
105
  }
80
106
  };
81
- n({ props: o, offset: a });
82
- const O = (e) => {
83
- s.forEach((t, l) => {
84
- l === e ? (B(), t.toggle()) : t.state.showPopup && t.toggle(!1, { immediate: !0 });
107
+ linkChildren({ props, offset });
108
+ const toggleItem = (active) => {
109
+ children.forEach((item, index2) => {
110
+ if (index2 === active) {
111
+ updateOffset();
112
+ item.toggle();
113
+ } else if (item.state.showPopup) {
114
+ item.toggle(false, { immediate: true });
115
+ }
85
116
  });
86
- }, A = (e) => Math.max(0, "scrollTop" in e ? e.scrollTop : e.pageYOffset), C = () => {
87
- const { scrollFixed: e } = o, t = A(window);
88
- f.value = t > (typeof e == "boolean" ? 30 : Number(e));
89
- }, F = (e) => {
90
- let t = "";
91
- const { titleClass: l } = o;
92
- return e && (t += "active"), l && (t += ` ${l}`), t;
93
117
  };
94
- return N(() => {
95
- const { scrollFixed: e } = o;
96
- e && window.addEventListener("scroll", C);
97
- }), P(() => {
98
- const { scrollFixed: e } = o;
99
- e && window.removeEventListener("scroll", C);
100
- }), {
101
- toggleItem: O,
102
- children: s,
103
- opened: d,
104
- classes: h,
105
- barRef: c,
106
- getClasses: F
118
+ const getScrollTop = (el) => {
119
+ return Math.max(0, "scrollTop" in el ? el.scrollTop : el.pageYOffset);
120
+ };
121
+ const onScroll = () => {
122
+ const { scrollFixed } = props;
123
+ const scrollTop = getScrollTop(window);
124
+ isScrollFixed.value = scrollTop > (typeof scrollFixed === "boolean" ? 30 : Number(scrollFixed));
125
+ };
126
+ const getClasses = (showPopup) => {
127
+ let str = "";
128
+ const { titleClass } = props;
129
+ if (showPopup) {
130
+ str += "active";
131
+ }
132
+ if (titleClass) {
133
+ str += ` ${titleClass}`;
134
+ }
135
+ return str;
136
+ };
137
+ onMounted(() => {
138
+ const { scrollFixed } = props;
139
+ if (scrollFixed) {
140
+ window.addEventListener("scroll", onScroll);
141
+ }
142
+ });
143
+ onUnmounted(() => {
144
+ const { scrollFixed } = props;
145
+ if (scrollFixed) {
146
+ window.removeEventListener("scroll", onScroll);
147
+ }
148
+ });
149
+ return {
150
+ toggleItem,
151
+ children,
152
+ opened,
153
+ classes,
154
+ barRef,
155
+ getClasses
107
156
  };
108
157
  }
109
- }), G = ["onClick"], J = { class: "nut-menu__title-text" }, K = { class: "nut-menu__title-icon" };
110
- function Q(o, S, $, c, a, f) {
111
- const m = k("ArrowUp2"), s = k("ArrowDown2");
112
- return i(), g("view", {
113
- class: u(o.classes)
158
+ });
159
+ const _hoisted_1 = ["onClick"];
160
+ const _hoisted_2 = { class: "nut-menu__title-text" };
161
+ const _hoisted_3 = { class: "nut-menu__title-icon" };
162
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
163
+ const _component_ArrowUp2 = resolveComponent("ArrowUp2");
164
+ const _component_ArrowDown2 = resolveComponent("ArrowDown2");
165
+ return openBlock(), createElementBlock("view", {
166
+ class: normalizeClass(_ctx.classes)
114
167
  }, [
115
- p("view", {
116
- class: u(["nut-menu__bar", { opened: o.opened }]),
168
+ createElementVNode("view", {
169
+ class: normalizeClass(["nut-menu__bar", { opened: _ctx.opened }]),
117
170
  ref: "barRef"
118
171
  }, [
119
- (i(!0), g(D, null, I(o.children, (n, d) => (i(), g("view", {
120
- key: d,
121
- class: u(["nut-menu__item", { disabled: n.disabled, active: n.state.showPopup }]),
122
- onClick: (h) => !n.disabled && o.toggleItem(d),
123
- style: U({ color: n.state.showPopup ? o.activeColor : "" })
124
- }, [
125
- p("view", {
126
- class: u(["nut-menu__title", o.getClasses(n.state.showPopup)])
172
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.children, (item, index2) => {
173
+ return openBlock(), createElementBlock("view", {
174
+ key: index2,
175
+ class: normalizeClass(["nut-menu__item", { disabled: item.disabled, active: item.state.showPopup }]),
176
+ onClick: ($event) => !item.disabled && _ctx.toggleItem(index2),
177
+ style: normalizeStyle({ color: item.state.showPopup ? _ctx.activeColor : "" })
127
178
  }, [
128
- p("view", J, R(n.renderTitle()), 1),
129
- p("span", K, [
130
- b(o.$slots, "icon", {}, () => [
131
- o.direction === "up" ? (i(), x(m, { key: 0 })) : (i(), x(s, { key: 1 }))
179
+ createElementVNode("view", {
180
+ class: normalizeClass(["nut-menu__title", _ctx.getClasses(item.state.showPopup)])
181
+ }, [
182
+ createElementVNode("view", _hoisted_2, toDisplayString(item.renderTitle()), 1),
183
+ createElementVNode("span", _hoisted_3, [
184
+ renderSlot(_ctx.$slots, "icon", {}, () => [
185
+ _ctx.direction === "up" ? (openBlock(), createBlock(_component_ArrowUp2, { key: 0 })) : (openBlock(), createBlock(_component_ArrowDown2, { key: 1 }))
186
+ ])
132
187
  ])
133
- ])
134
- ], 2)
135
- ], 14, G))), 128))
188
+ ], 2)
189
+ ], 14, _hoisted_1);
190
+ }), 128))
136
191
  ], 2),
137
- b(o.$slots, "default")
192
+ renderSlot(_ctx.$slots, "default")
138
193
  ], 2);
139
194
  }
140
- const le = /* @__PURE__ */ V(q, [["render", Q]]);
195
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
141
196
  export {
142
- le as default
197
+ index as default
143
198
  };
@@ -1,23 +1,31 @@
1
- var B = Object.defineProperty, D = Object.defineProperties;
2
- var z = Object.getOwnPropertyDescriptors;
3
- var w = Object.getOwnPropertySymbols;
4
- var L = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable;
5
- var g = (e, o, t) => o in e ? B(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t, d = (e, o) => {
6
- for (var t in o || (o = {}))
7
- L.call(o, t) && g(e, t, o[t]);
8
- if (w)
9
- for (var t of w(o))
10
- U.call(o, t) && g(e, t, o[t]);
11
- return e;
12
- }, m = (e, o) => D(e, z(o));
13
- import { reactive as j, computed as P, inject as A, getCurrentInstance as F, onUnmounted as I, resolveComponent as S, withDirectives as V, openBlock as r, createElementBlock as i, normalizeStyle as p, createElementVNode as v, vShow as b, createVNode as $, mergeProps as T, withCtx as q, Fragment as G, renderList as H, normalizeClass as f, renderSlot as O, createCommentVNode as J, toDisplayString as K } from "vue";
14
- import { c as M } from "./component-234624bc.js";
15
- import { P as E } from "./index-360c5092.js";
16
- import { Check as Q } from "@nutui/icons-vue";
17
- import { _ as R } from "./_plugin-vue_export-helper-dad06003.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { reactive, computed, inject, getCurrentInstance, onUnmounted, resolveComponent, withDirectives, openBlock, createElementBlock, normalizeStyle, createElementVNode, vShow, createVNode, mergeProps, withCtx, Fragment, renderList, normalizeClass, renderSlot, createCommentVNode, toDisplayString } from "vue";
21
+ import { c as createComponent } from "./component-81a4c1d0.js";
22
+ import { P as Popup } from "./index-da0a7662.js";
23
+ import { Check } from "@nutui/icons-vue";
24
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
18
25
  import "../locale/lang";
19
26
  import "./Overlay.js";
20
- const { create: X } = M("menu-item"), Y = X({
27
+ const { create } = createComponent("menu-item");
28
+ const _sfc_main = create({
21
29
  props: {
22
30
  title: String,
23
31
  options: {
@@ -26,7 +34,7 @@ const { create: X } = M("menu-item"), Y = X({
26
34
  },
27
35
  disabled: {
28
36
  type: Boolean,
29
- default: !1
37
+ default: false
30
38
  },
31
39
  modelValue: null,
32
40
  cols: {
@@ -37,118 +45,155 @@ const { create: X } = M("menu-item"), Y = X({
37
45
  inactiveTitleClass: String
38
46
  },
39
47
  components: {
40
- [E.name]: E,
41
- Check: Q
48
+ [Popup.name]: Popup,
49
+ Check
42
50
  },
43
51
  emits: ["update:modelValue", "change", "open", "close"],
44
- setup(e, { emit: o }) {
45
- const t = j({
46
- showPopup: !1,
47
- showWrapper: !1
48
- }), h = () => {
49
- const l = A("menuParent", null);
50
- if (l) {
51
- const a = F(), { link: c, removeLink: W } = l;
52
- return c(a), I(() => {
53
- W(a);
54
- }), { parent: l };
52
+ setup(props, { emit }) {
53
+ const state = reactive({
54
+ showPopup: false,
55
+ showWrapper: false
56
+ });
57
+ const useParent = () => {
58
+ const parent2 = inject("menuParent", null);
59
+ if (parent2) {
60
+ const instance = getCurrentInstance();
61
+ const { link, removeLink } = parent2;
62
+ link(instance);
63
+ onUnmounted(() => {
64
+ removeLink(instance);
65
+ });
66
+ return { parent: parent2 };
55
67
  }
56
- }, { parent: s } = h(), C = P(() => s.props.direction === "down" ? {
57
- top: s.offset.value + "px"
58
- } : {
59
- bottom: s.offset.value + "px"
60
- }), u = P(() => {
61
- const l = { height: s.offset.value + "px" };
62
- return s.props.direction === "down" ? m(d({}, l), { top: "0px" }) : m(d({}, l), { bottom: "0px" });
68
+ };
69
+ const { parent } = useParent();
70
+ const style = computed(() => {
71
+ return parent.props.direction === "down" ? {
72
+ top: parent.offset.value + "px"
73
+ } : {
74
+ bottom: parent.offset.value + "px"
75
+ };
63
76
  });
64
- return {
65
- style: C,
66
- placeholderElementStyle: u,
67
- renderTitle: () => {
68
- var a;
69
- if (e.title)
70
- return e.title;
71
- const l = (a = e.options) == null ? void 0 : a.find((c) => c.value === e.modelValue);
72
- return l ? l.text : "";
73
- },
74
- state: t,
75
- parent: s,
76
- toggle: (l = !t.showPopup) => {
77
- l !== t.showPopup && (t.showPopup = l, l && (t.showWrapper = !0, o("open")));
78
- },
79
- onClick: (l) => {
80
- t.showPopup = !1, l.value !== e.modelValue && (o("update:modelValue", l.value), o("change", l.value));
81
- },
82
- handleClose: () => {
83
- o("close"), t.showWrapper = !1;
84
- },
85
- handleClickOutside: () => {
86
- t.showPopup = !1, o("close");
77
+ const placeholderElementStyle = computed(() => {
78
+ const heightStyle = { height: parent.offset.value + "px" };
79
+ if (parent.props.direction === "down") {
80
+ return __spreadProps(__spreadValues({}, heightStyle), { top: "0px" });
81
+ } else {
82
+ return __spreadProps(__spreadValues({}, heightStyle), { bottom: "0px" });
87
83
  }
84
+ });
85
+ const toggle = (show = !state.showPopup) => {
86
+ if (show === state.showPopup) {
87
+ return;
88
+ }
89
+ state.showPopup = show;
90
+ if (show) {
91
+ state.showWrapper = true;
92
+ emit("open");
93
+ }
94
+ };
95
+ const renderTitle = () => {
96
+ var _a;
97
+ if (props.title) {
98
+ return props.title;
99
+ }
100
+ const match = (_a = props.options) == null ? void 0 : _a.find((option) => option.value === props.modelValue);
101
+ return match ? match.text : "";
102
+ };
103
+ const onClick = (option) => {
104
+ state.showPopup = false;
105
+ if (option.value !== props.modelValue) {
106
+ emit("update:modelValue", option.value);
107
+ emit("change", option.value);
108
+ }
109
+ };
110
+ const handleClose = () => {
111
+ emit("close");
112
+ state.showWrapper = false;
113
+ };
114
+ const handleClickOutside = () => {
115
+ state.showPopup = false;
116
+ emit("close");
117
+ };
118
+ return {
119
+ style,
120
+ placeholderElementStyle,
121
+ renderTitle,
122
+ state,
123
+ parent,
124
+ toggle,
125
+ onClick,
126
+ handleClose,
127
+ handleClickOutside
88
128
  };
89
129
  }
90
- }), Z = { class: "nut-menu-item__content nut-menu-item__overflow" }, _ = ["onClick"];
91
- function x(e, o, t, h, s, C) {
92
- const u = S("Check"), y = S("nut-popup");
93
- return V((r(), i("view", {
130
+ });
131
+ const _hoisted_1 = { class: "nut-menu-item__content nut-menu-item__overflow" };
132
+ const _hoisted_2 = ["onClick"];
133
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
134
+ const _component_Check = resolveComponent("Check");
135
+ const _component_nut_popup = resolveComponent("nut-popup");
136
+ return withDirectives((openBlock(), createElementBlock("view", {
94
137
  class: "nut-menu-item",
95
- style: p(e.style)
138
+ style: normalizeStyle(_ctx.style)
96
139
  }, [
97
- V(v("div", {
98
- onClick: o[0] || (o[0] = (...n) => e.handleClickOutside && e.handleClickOutside(...n)),
140
+ withDirectives(createElementVNode("div", {
141
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClickOutside && _ctx.handleClickOutside(...args)),
99
142
  class: "nut-menu-item-placeholder-element",
100
- style: p(e.placeholderElementStyle)
143
+ style: normalizeStyle(_ctx.placeholderElementStyle)
101
144
  }, null, 4), [
102
- [b, e.state.showPopup]
145
+ [vShow, _ctx.state.showPopup]
103
146
  ]),
104
- $(y, T({
147
+ createVNode(_component_nut_popup, mergeProps({
105
148
  style: { position: "absolute" },
106
149
  overlayStyle: { position: "absolute" }
107
- }, e.$attrs, {
108
- visible: e.state.showPopup,
109
- "onUpdate:visible": o[1] || (o[1] = (n) => e.state.showPopup = n),
110
- position: e.parent.props.direction === "down" ? "top" : "bottom",
111
- duration: e.parent.props.duration,
112
- "destroy-on-close": !1,
113
- overlay: e.parent.props.overlay,
114
- onClosed: e.handleClose,
115
- lockScroll: e.parent.props.lockScroll,
116
- teleportDisable: !1,
117
- "close-on-click-overlay": e.parent.props.closeOnClickOverlay
150
+ }, _ctx.$attrs, {
151
+ visible: _ctx.state.showPopup,
152
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => _ctx.state.showPopup = $event),
153
+ position: _ctx.parent.props.direction === "down" ? "top" : "bottom",
154
+ duration: _ctx.parent.props.duration,
155
+ "destroy-on-close": false,
156
+ overlay: _ctx.parent.props.overlay,
157
+ onClosed: _ctx.handleClose,
158
+ lockScroll: _ctx.parent.props.lockScroll,
159
+ teleportDisable: false,
160
+ "close-on-click-overlay": _ctx.parent.props.closeOnClickOverlay
118
161
  }), {
119
- default: q(() => [
120
- v("view", Z, [
121
- (r(!0), i(G, null, H(e.options, (n, k) => (r(), i("view", {
122
- key: k,
123
- class: f(["nut-menu-item__option", [{ active: n.value === e.modelValue }]]),
124
- style: p({ "flex-basis": 100 / e.cols + "%" }),
125
- onClick: (N) => e.onClick(n)
126
- }, [
127
- n.value === e.modelValue ? (r(), i("span", {
128
- key: 0,
129
- class: f(["nut-menu-item__span", [n.value === e.modelValue ? e.activeTitleClass : e.inactiveTitleClass]])
162
+ default: withCtx(() => [
163
+ createElementVNode("view", _hoisted_1, [
164
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (option, index2) => {
165
+ return openBlock(), createElementBlock("view", {
166
+ key: index2,
167
+ class: normalizeClass(["nut-menu-item__option", [{ active: option.value === _ctx.modelValue }]]),
168
+ style: normalizeStyle({ "flex-basis": 100 / _ctx.cols + "%" }),
169
+ onClick: ($event) => _ctx.onClick(option)
130
170
  }, [
131
- O(e.$slots, "icon", {}, () => [
132
- $(u, T(e.$attrs, {
133
- color: e.parent.props.activeColor
134
- }), null, 16, ["color"])
135
- ])
136
- ], 2)) : J("", !0),
137
- v("view", {
138
- class: f([n.value === e.modelValue ? e.activeTitleClass : e.inactiveTitleClass]),
139
- style: p({ color: n.value === e.modelValue ? e.parent.props.activeColor : "" })
140
- }, K(n.text), 7)
141
- ], 14, _))), 128)),
142
- O(e.$slots, "default")
171
+ option.value === _ctx.modelValue ? (openBlock(), createElementBlock("span", {
172
+ key: 0,
173
+ class: normalizeClass(["nut-menu-item__span", [option.value === _ctx.modelValue ? _ctx.activeTitleClass : _ctx.inactiveTitleClass]])
174
+ }, [
175
+ renderSlot(_ctx.$slots, "icon", {}, () => [
176
+ createVNode(_component_Check, mergeProps(_ctx.$attrs, {
177
+ color: _ctx.parent.props.activeColor
178
+ }), null, 16, ["color"])
179
+ ])
180
+ ], 2)) : createCommentVNode("", true),
181
+ createElementVNode("view", {
182
+ class: normalizeClass([option.value === _ctx.modelValue ? _ctx.activeTitleClass : _ctx.inactiveTitleClass]),
183
+ style: normalizeStyle({ color: option.value === _ctx.modelValue ? _ctx.parent.props.activeColor : "" })
184
+ }, toDisplayString(option.text), 7)
185
+ ], 14, _hoisted_2);
186
+ }), 128)),
187
+ renderSlot(_ctx.$slots, "default")
143
188
  ])
144
189
  ]),
145
190
  _: 3
146
191
  }, 16, ["visible", "position", "duration", "overlay", "onClosed", "lockScroll", "close-on-click-overlay"])
147
192
  ], 4)), [
148
- [b, e.state.showWrapper]
193
+ [vShow, _ctx.state.showWrapper]
149
194
  ]);
150
195
  }
151
- const pe = /* @__PURE__ */ R(Y, [["render", x]]);
196
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
152
197
  export {
153
- pe as default
198
+ index as default
154
199
  };