@nutui/nutui 3.1.11-beta.0 → 3.1.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 (119) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/nutui.d.ts +5 -2
  3. package/dist/nutui.es.js +4243 -3673
  4. package/dist/nutui.umd.js +4252 -3679
  5. package/dist/packages/_es/ActionSheet.js +1 -1
  6. package/dist/packages/_es/Address.js +1 -1
  7. package/dist/packages/_es/Avatar.js +1 -1
  8. package/dist/packages/_es/BackTop.js +1 -1
  9. package/dist/packages/_es/Badge.js +1 -1
  10. package/dist/packages/_es/Barrage.js +1 -1
  11. package/dist/packages/_es/Button.js +1 -1
  12. package/dist/packages/_es/Calendar.js +1 -1
  13. package/dist/packages/_es/Card.js +105 -0
  14. package/dist/packages/_es/Cell.js +1 -1
  15. package/dist/packages/_es/CellGroup.js +10 -4
  16. package/dist/packages/_es/Checkbox.js +1 -1
  17. package/dist/packages/_es/CheckboxGroup.js +2 -2
  18. package/dist/packages/_es/CircleProgress.js +1 -1
  19. package/dist/packages/_es/Col.js +1 -1
  20. package/dist/packages/_es/Collapse.js +1 -1
  21. package/dist/packages/_es/CollapseItem.js +1 -1
  22. package/dist/packages/_es/CountDown.js +1 -1
  23. package/dist/packages/_es/CountUp.js +1 -1
  24. package/dist/packages/_es/DatePicker.js +2 -2
  25. package/dist/packages/_es/Dialog.js +10 -23
  26. package/dist/packages/_es/Divider.js +1 -1
  27. package/dist/packages/_es/Drag.js +1 -1
  28. package/dist/packages/_es/Elevator.js +1 -1
  29. package/dist/packages/_es/FixedNav.js +1 -1
  30. package/dist/packages/_es/Form.js +138 -0
  31. package/dist/packages/_es/FormItem.js +110 -0
  32. package/dist/packages/_es/Icon.js +1 -1
  33. package/dist/packages/_es/ImagePreview.js +148 -32
  34. package/dist/packages/_es/InfiniteLoading.js +1 -1
  35. package/dist/packages/_es/Input.js +1 -1
  36. package/dist/packages/_es/InputNumber.js +1 -1
  37. package/dist/packages/_es/Layout.js +1 -1
  38. package/dist/packages/_es/Menu.js +83 -167
  39. package/dist/packages/_es/MenuItem.js +154 -15
  40. package/dist/packages/_es/Navbar.js +1 -1
  41. package/dist/packages/_es/NoticeBar.js +1 -1
  42. package/dist/packages/_es/Notify.js +1 -1
  43. package/dist/packages/_es/NumberKeyboard.js +9 -7
  44. package/dist/packages/_es/OverLay.js +1 -1
  45. package/dist/packages/_es/Pagination.js +1 -1
  46. package/dist/packages/_es/Picker.js +2 -2
  47. package/dist/packages/_es/Popover.js +11 -17
  48. package/dist/packages/_es/Popup.js +52 -13
  49. package/dist/packages/_es/Price.js +1 -1
  50. package/dist/packages/_es/Progress.js +1 -1
  51. package/dist/packages/_es/Radio.js +1 -1
  52. package/dist/packages/_es/RadioGroup.js +1 -1
  53. package/dist/packages/_es/Range.js +4 -32
  54. package/dist/packages/_es/Rate.js +19 -5
  55. package/dist/packages/_es/Row.js +1 -1
  56. package/dist/packages/_es/SearchBar.js +1 -1
  57. package/dist/packages/_es/ShortPassword.js +1 -1
  58. package/dist/packages/_es/Signature.js +1 -1
  59. package/dist/packages/_es/Sku.js +2 -37
  60. package/dist/packages/_es/Step.js +1 -1
  61. package/dist/packages/_es/Steps.js +1 -1
  62. package/dist/packages/_es/Swipe.js +2 -2
  63. package/dist/packages/_es/Swiper.js +11 -11
  64. package/dist/packages/_es/SwiperItem.js +3 -3
  65. package/dist/packages/_es/Switch.js +28 -8
  66. package/dist/packages/_es/TabPane.js +1 -1
  67. package/dist/packages/_es/Tabbar.js +1 -1
  68. package/dist/packages/_es/TabbarItem.js +1 -1
  69. package/dist/packages/_es/Tabs.js +1 -1
  70. package/dist/packages/_es/Tag.js +1 -1
  71. package/dist/packages/_es/TextArea.js +1 -1
  72. package/dist/packages/_es/TimeDetail.js +1 -1
  73. package/dist/packages/_es/TimePannel.js +1 -1
  74. package/dist/packages/_es/TimeSelect.js +1 -1
  75. package/dist/packages/_es/Toast.js +18 -8
  76. package/dist/packages/_es/Uploader.js +30 -22
  77. package/dist/packages/_es/Video.js +3 -3
  78. package/dist/packages/_es/component.js +1 -1
  79. package/dist/packages/_es/index.js +7 -58
  80. package/dist/packages/_es/index2.js +58 -7
  81. package/dist/packages/_es/index3.js +36 -0
  82. package/dist/packages/_es/plugin-vue_export-helper.js +4 -3
  83. package/dist/packages/_es/pxCheck.js +1 -1
  84. package/dist/packages/_es/raf.js +1 -1
  85. package/dist/packages/_es/util.js +47 -0
  86. package/dist/packages/button/index.scss +6 -0
  87. package/dist/packages/card/index.scss +97 -0
  88. package/dist/packages/cellgroup/index.scss +9 -0
  89. package/dist/packages/checkbox/index.scss +1 -1
  90. package/dist/packages/dialog/index.scss +17 -0
  91. package/dist/packages/drag/index.scss +4 -0
  92. package/dist/packages/fixednav/index.scss +6 -1
  93. package/dist/packages/form/index.scss +2 -0
  94. package/dist/packages/formitem/index.scss +63 -0
  95. package/dist/packages/icon/index.scss +2 -1
  96. package/dist/packages/menu/index.scss +32 -60
  97. package/dist/packages/menuitem/index.scss +36 -99
  98. package/dist/packages/numberkeyboard/index.scss +1 -1
  99. package/dist/packages/popover/index.scss +2 -2
  100. package/dist/packages/rate/index.scss +1 -0
  101. package/dist/packages/switch/index.scss +1 -1
  102. package/dist/packages/textarea/index.scss +1 -0
  103. package/dist/packages/timedetail/index.scss +1 -2
  104. package/dist/packages/timeselect/index.scss +3 -0
  105. package/dist/packages/toast/index.scss +6 -0
  106. package/dist/packages/uploader/index.scss +1 -0
  107. package/dist/style.css +1 -1
  108. package/dist/styles/font/config.json +2 -1
  109. package/dist/styles/font/demo_index.html +26 -3
  110. package/dist/styles/font/iconfont.css +7 -3
  111. package/dist/styles/font/iconfont.js +31 -32
  112. package/dist/styles/font/iconfont.json +7 -0
  113. package/dist/styles/font/iconfont.ttf +0 -0
  114. package/dist/styles/font/iconfont.woff +0 -0
  115. package/dist/styles/font/iconfont.woff2 +0 -0
  116. package/dist/styles/themes/default.scss +39 -36
  117. package/dist/styles/variables.scss +29 -2
  118. package/package.json +3 -2
  119. package/dist/packages/_es/style.css +0 -160
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11-beta.0 Sat Nov 13 2021 21:43:55 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -17,18 +17,26 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
20
24
  /*!
21
- * @nutui/nutui v3.1.11-beta.0 Sat Nov 13 2021 21:43:55 GMT+0800 (中国标准时间)
25
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
22
26
  * (c) 2021 @jdf2e.
23
27
  * Released under the MIT License.
24
28
  */
25
- import { toRefs, reactive, watch, resolveComponent, openBlock, createElementBlock, createVNode, withCtx, createBlock, Fragment, renderList, createElementVNode, createCommentVNode, toDisplayString } from "vue";
29
+ import { toRefs, reactive, watch, onMounted, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, withModifiers, createElementBlock, Fragment, renderList, createVNode, createCommentVNode, toDisplayString, render, h } from "vue";
26
30
  import { c as createComponent } from "./component.js";
27
31
  import Popup from "./Popup.js";
32
+ import Video from "./Video.js";
33
+ import Swiper from "./Swiper.js";
34
+ import SwiperItem from "./SwiperItem.js";
28
35
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
29
36
  import "./OverLay.js";
30
37
  import "./Icon.js";
31
38
  import "./pxCheck.js";
39
+ import "./index.js";
32
40
  const { componentName, create } = createComponent("imagepreview");
33
41
  const _sfc_main = create({
34
42
  props: {
@@ -39,21 +47,59 @@ const _sfc_main = create({
39
47
  images: {
40
48
  type: Array,
41
49
  default: () => []
50
+ },
51
+ videos: {
52
+ type: Array,
53
+ default: () => []
54
+ },
55
+ contentClose: {
56
+ type: Boolean,
57
+ default: false
58
+ },
59
+ initNo: {
60
+ type: Number,
61
+ default: 1
62
+ },
63
+ paginationVisible: {
64
+ type: Boolean,
65
+ default: false
66
+ },
67
+ paginationColor: {
68
+ type: String,
69
+ default: "#fff"
42
70
  }
43
71
  },
72
+ emits: ["close"],
44
73
  components: {
45
- [Popup.name]: Popup
74
+ [Popup.name]: Popup,
75
+ [Video.name]: Video,
76
+ [Swiper.name]: Swiper,
77
+ [SwiperItem.name]: SwiperItem
46
78
  },
47
79
  setup(props, { emit }) {
48
- const { show, images } = toRefs(props);
80
+ toRefs(props);
49
81
  const state = reactive({
50
- showPop: show,
51
- active: 1
82
+ showPop: false,
83
+ active: 1,
84
+ maxNo: 1,
85
+ source: {
86
+ src: "https://storage.jd.com/about/big-final.mp4?Expires=3730193075&AccessKey=3LoYX1dQWa6ZXzQl&Signature=ViMFjz%2BOkBxS%2FY1rjtUVqbopbJI%3D",
87
+ type: "video/mp4"
88
+ },
89
+ options: {
90
+ muted: true,
91
+ controls: true
92
+ }
52
93
  });
53
94
  const slideChangeEnd = function(page) {
54
95
  state.active = page + 1;
55
96
  };
56
- const closePop = function() {
97
+ const closeOnImg = () => {
98
+ if (props.contentClose) {
99
+ onClose();
100
+ }
101
+ };
102
+ const onClose = () => {
57
103
  state.showPop = false;
58
104
  state.active = 1;
59
105
  emit("close");
@@ -61,56 +107,126 @@ const _sfc_main = create({
61
107
  watch(() => props.show, (val) => {
62
108
  state.showPop = val;
63
109
  });
110
+ onMounted(() => {
111
+ state.active = props.initNo;
112
+ state.showPop = props.show;
113
+ state.maxNo = props.images.length + props.videos.length;
114
+ });
64
115
  return __spreadProps(__spreadValues({}, toRefs(state)), {
65
116
  slideChangeEnd,
66
- closePop
117
+ onClose,
118
+ closeOnImg
67
119
  });
68
120
  }
69
121
  });
70
- const _hoisted_1 = { class: "nut-imagepreview" };
71
- const _hoisted_2 = ["src"];
72
- const _hoisted_3 = { class: "nut-imagepreview-index" };
122
+ const _hoisted_1 = ["src"];
123
+ const _hoisted_2 = { class: "nut-imagepreview-index" };
73
124
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
125
+ const _component_nut_video = resolveComponent("nut-video");
74
126
  const _component_nut_swiper_item = resolveComponent("nut-swiper-item");
75
127
  const _component_nut_swiper = resolveComponent("nut-swiper");
76
128
  const _component_nut_popup = resolveComponent("nut-popup");
77
- return openBlock(), createElementBlock("view", _hoisted_1, [
78
- createVNode(_component_nut_popup, {
79
- "pop-class": "custom-pop",
80
- visible: _ctx.showPop,
81
- "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => _ctx.showPop = $event),
82
- onClick: _ctx.closePop
83
- }, {
84
- default: withCtx(() => [
129
+ return openBlock(), createBlock(_component_nut_popup, {
130
+ "pop-class": "custom-pop",
131
+ visible: _ctx.showPop,
132
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => _ctx.showPop = $event),
133
+ onClick: _ctx.onClose
134
+ }, {
135
+ default: withCtx(() => [
136
+ createElementVNode("view", {
137
+ class: "nut-imagepreview",
138
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => _ctx.closeOnImg && _ctx.closeOnImg(...args), ["stop"]))
139
+ }, [
85
140
  _ctx.showPop ? (openBlock(), createBlock(_component_nut_swiper, {
86
141
  key: 0,
87
142
  "auto-play": 3e3,
88
143
  class: "nut-imagepreview-swiper",
89
144
  loop: true,
145
+ "is-preventDefault": false,
90
146
  direction: "horizontal",
91
147
  onChange: _ctx.slideChangeEnd,
92
- "is-preventDefault": false
148
+ "init-page": _ctx.initNo > _ctx.maxNo ? _ctx.maxNo - 1 : _ctx.initNo - 1,
149
+ "pagination-visible": _ctx.paginationVisible,
150
+ "pagination-color": _ctx.paginationColor
93
151
  }, {
94
152
  default: withCtx(() => [
95
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.images, (item, index2) => {
96
- return openBlock(), createBlock(_component_nut_swiper_item, { key: index2 }, {
153
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.videos, (item, index) => {
154
+ return openBlock(), createBlock(_component_nut_swiper_item, { key: index }, {
155
+ default: withCtx(() => [
156
+ createVNode(_component_nut_video, {
157
+ source: item.source,
158
+ options: item.options
159
+ }, null, 8, ["source", "options"])
160
+ ]),
161
+ _: 2
162
+ }, 1024);
163
+ }), 128)),
164
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.images, (item, index) => {
165
+ return openBlock(), createBlock(_component_nut_swiper_item, { key: index }, {
97
166
  default: withCtx(() => [
98
167
  createElementVNode("img", {
99
- src: item.imgSrc,
168
+ src: item.src,
100
169
  class: "nut-imagepreview-img"
101
- }, null, 8, _hoisted_2)
170
+ }, null, 8, _hoisted_1)
102
171
  ]),
103
172
  _: 2
104
173
  }, 1024);
105
174
  }), 128))
106
175
  ]),
107
176
  _: 1
108
- }, 8, ["onChange"])) : createCommentVNode("", true),
109
- createElementVNode("view", _hoisted_3, toDisplayString(_ctx.active) + " / " + toDisplayString(_ctx.images.length), 1)
110
- ]),
111
- _: 1
112
- }, 8, ["visible", "onClick"])
113
- ]);
177
+ }, 8, ["onChange", "init-page", "pagination-visible", "pagination-color"])) : createCommentVNode("", true),
178
+ createElementVNode("view", _hoisted_2, toDisplayString(_ctx.active) + " / " + toDisplayString(_ctx.images.length + _ctx.videos.length), 1)
179
+ ])
180
+ ]),
181
+ _: 1
182
+ }, 8, ["visible", "onClick"]);
183
+ }
184
+ var ImagePreview = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
185
+ class ImagePreviewOptions {
186
+ constructor() {
187
+ __publicField(this, "show", false);
188
+ __publicField(this, "images", []);
189
+ __publicField(this, "initNo", 1);
190
+ __publicField(this, "paginationVisible", false);
191
+ __publicField(this, "paginationColor", "");
192
+ __publicField(this, "teleport", "body");
193
+ __publicField(this, "onClose", () => {
194
+ });
195
+ }
114
196
  }
115
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
116
- export { index as default };
197
+ class ImagePreviewFunction {
198
+ constructor(_options) {
199
+ __publicField(this, "options", new ImagePreviewOptions());
200
+ let options = Object.assign(this.options, _options);
201
+ let elWarp = document.body;
202
+ let teleport = options.teleport;
203
+ if (teleport != "body") {
204
+ if (typeof teleport == "string") {
205
+ elWarp = document.querySelector(teleport);
206
+ } else {
207
+ elWarp = options.teleport;
208
+ }
209
+ }
210
+ const root = document.createElement("view");
211
+ root.id = "imagepreview-" + new Date().getTime();
212
+ const Wrapper = {
213
+ setup() {
214
+ options.teleport = `#${root.id}`;
215
+ return () => {
216
+ return h(ImagePreview, options);
217
+ };
218
+ }
219
+ };
220
+ const instance = createVNode(Wrapper);
221
+ elWarp.appendChild(root);
222
+ render(instance, root);
223
+ }
224
+ }
225
+ const _ImagePreview = function(options) {
226
+ return new ImagePreviewFunction(options);
227
+ };
228
+ _ImagePreview.install = (app) => {
229
+ app.use(ImagePreview);
230
+ app.config.globalProperties.$imagepreview = _ImagePreview;
231
+ };
232
+ export { ImagePreview, ImagePreviewOptions, _ImagePreview as default };
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  /*!
21
- * @nutui/nutui v3.1.11-beta.0 Sat Nov 13 2021 21:43:55 GMT+0800 (中国标准时间)
21
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
22
22
  * (c) 2021 @jdf2e.
23
23
  * Released under the MIT License.
24
24
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11-beta.0 Sat Nov 13 2021 21:43:55 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11-beta.0 Sat Nov 13 2021 21:43:55 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11-beta.0 Sat Nov 13 2021 21:43:55 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,203 +1,119 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11-beta.0 Sat Nov 13 2021 21:43:55 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { reactive, ref, computed, resolveComponent, openBlock, createElementBlock, createVNode, mergeProps, createElementVNode, normalizeClass, normalizeStyle, Fragment, renderList, createTextVNode, toDisplayString, createBlock, withDirectives, createCommentVNode, vShow, renderSlot } from "vue";
6
+ import { ref, computed, reactive, provide, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, Fragment, renderList, normalizeStyle, toDisplayString, createVNode, renderSlot } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
- import _sfc_main$1 from "./Icon.js";
8
+ import { u as useRect } from "./index3.js";
9
9
  import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
10
- import "./pxCheck.js";
11
- var index_vue_vue_type_style_index_0_lang = "";
12
10
  const { componentName, create } = createComponent("menu");
13
11
  const _sfc_main = create({
14
- components: {
15
- [_sfc_main$1.name]: _sfc_main$1
16
- },
17
12
  props: {
18
- col: {
19
- type: [String, Number],
20
- default: 1
21
- },
22
13
  activeColor: {
23
14
  type: String,
24
- default: "#f00"
15
+ default: "#FA2C19"
16
+ },
17
+ overlay: {
18
+ type: Boolean,
19
+ default: true
20
+ },
21
+ duration: {
22
+ type: [Number, String],
23
+ default: 0
25
24
  }
26
25
  },
27
- emits: ["choose"],
28
- setup(props, { slots, emit }) {
29
- const menuList = reactive([]);
30
- let activeTitle = ref("");
31
- let showMask = ref(false);
32
- let styleObj = reactive({
33
- flexBasis: 100 / Number(props.col) + "%"
34
- });
35
- let nutMenuIndex = ref("auto");
36
- let hasOptions = ref(true);
37
- let isShowCustomer = ref(false);
38
- if (slots.default) {
39
- for (let i = 0; i < slots.default().length; i++) {
40
- if (slots.default()[i].type["name"] === "nut-menu-item") {
41
- let item = {
42
- title: slots.default()[i].props["title"],
43
- disabled: !!slots.default()[i].props["disabled"]
44
- };
45
- if (slots.default()[i].props["options"]) {
46
- item["options"] = slots.default()[i].props["options"];
47
- } else {
48
- hasOptions.value = false;
26
+ setup(props, { emit, slots }) {
27
+ const barRef = ref();
28
+ const offset = ref(0);
29
+ const useChildren = () => {
30
+ const publicChildren = reactive([]);
31
+ const internalChildren = reactive([]);
32
+ const linkChildren2 = (value) => {
33
+ const link = (child) => {
34
+ if (child.proxy) {
35
+ internalChildren.push(child);
36
+ publicChildren.push(child.proxy);
49
37
  }
50
- menuList.push(item);
51
- }
52
- }
53
- }
54
- const handleClickTitle = (title, index2) => {
55
- if (!hasOptions.value) {
56
- if (activeTitle.value) {
57
- activeTitle.value = "";
58
- isShowCustomer.value = false;
59
- showMask.value = false;
60
- nutMenuIndex.value = "auto";
61
- } else {
62
- activeTitle.value = title;
63
- isShowCustomer.value = true;
64
- showMask.value = true;
65
- nutMenuIndex.value = 2001;
66
- }
67
- return;
68
- }
69
- if (menuList.length > 1) {
70
- if (activeTitle.value === title) {
71
- activeTitle.value = "";
72
- nutMenuIndex.value = "auto";
73
- showMask.value = false;
74
- } else {
75
- activeTitle.value = title;
76
- nutMenuIndex.value = 2001;
77
- showMask.value = true;
78
- }
79
- } else {
80
- if (activeTitle.value) {
81
- activeTitle.value = "";
82
- nutMenuIndex.value = "auto";
83
- showMask.value = false;
84
- } else {
85
- activeTitle.value = title;
86
- nutMenuIndex.value = 2001;
87
- showMask.value = true;
88
- }
89
- }
90
- };
91
- const handleClickOption = (text, index2, value) => {
92
- menuList[index2].title = text;
93
- activeTitle.value = "";
94
- showMask.value = false;
95
- nutMenuIndex.value = "auto";
96
- emit("choose", text, value);
38
+ };
39
+ provide("menuParent", Object.assign({
40
+ link,
41
+ children: publicChildren,
42
+ internalChildren
43
+ }, value));
44
+ };
45
+ return {
46
+ children: publicChildren,
47
+ linkChildren: linkChildren2
48
+ };
97
49
  };
50
+ const { children, linkChildren } = useChildren();
51
+ const opened = computed(() => children.some((item) => item.state.showWrapper));
98
52
  const classes = computed(() => {
99
53
  const prefixCls = componentName;
100
54
  return {
101
55
  [prefixCls]: true
102
56
  };
103
57
  });
104
- const handleClose = () => {
105
- activeTitle.value = "";
106
- nutMenuIndex.value = "auto";
107
- if (isShowCustomer.value) {
108
- isShowCustomer.value = false;
58
+ const updateOffset = () => {
59
+ if (barRef.value) {
60
+ const rect = useRect(barRef);
61
+ offset.value = rect.bottom;
109
62
  }
110
63
  };
64
+ linkChildren({ props, offset });
65
+ const toggleItem = (active) => {
66
+ children.forEach((item, index2) => {
67
+ if (index2 === active) {
68
+ updateOffset();
69
+ item.toggle();
70
+ } else if (item.state.showPopup) {
71
+ item.toggle(false, { immediate: true });
72
+ }
73
+ });
74
+ };
111
75
  return {
112
- menuList,
113
- activeTitle,
76
+ toggleItem,
77
+ children,
78
+ opened,
114
79
  classes,
115
- showMask,
116
- styleObj,
117
- nutMenuIndex,
118
- hasOptions,
119
- isShowCustomer,
120
- handleClickTitle,
121
- handleClickOption,
122
- handleClose
80
+ barRef
123
81
  };
124
82
  }
125
83
  });
126
- const _hoisted_1 = { class: "title-list" };
127
- const _hoisted_2 = ["onClick"];
128
- const _hoisted_3 = ["onClick"];
129
- const _hoisted_4 = { class: "customer-item" };
84
+ const _hoisted_1 = ["onClick"];
85
+ const _hoisted_2 = { class: "nut-menu__title-text" };
130
86
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
131
- const _component_nut_popup = resolveComponent("nut-popup");
132
87
  const _component_nut_icon = resolveComponent("nut-icon");
133
- return openBlock(), createElementBlock("view", null, [
134
- createVNode(_component_nut_popup, mergeProps(_ctx.$attrs, {
135
- visible: _ctx.showMask,
136
- "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => _ctx.showMask = $event),
137
- onClose: _ctx.handleClose
138
- }), null, 16, ["visible", "onClose"]),
139
- createElementVNode("div", {
140
- class: normalizeClass(_ctx.classes),
141
- style: normalizeStyle({ "z-index": _ctx.nutMenuIndex })
88
+ return openBlock(), createElementBlock("view", {
89
+ class: normalizeClass(_ctx.classes)
90
+ }, [
91
+ createElementVNode("view", {
92
+ class: normalizeClass(["nut-menu__bar", { opened: _ctx.opened }]),
93
+ ref: "barRef"
142
94
  }, [
143
- createElementVNode("div", _hoisted_1, [
144
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuList, (menu, index2) => {
145
- return openBlock(), createElementBlock("div", {
146
- key: index2,
147
- class: normalizeClass(["title", {
148
- "is-active": _ctx.activeTitle === menu.title,
149
- disabled: menu.disabled
150
- }]),
151
- onClick: ($event) => !menu.disabled && _ctx.handleClickTitle(menu.title, index2)
152
- }, [
153
- createTextVNode(toDisplayString(menu.title) + " ", 1),
154
- _ctx.activeTitle === menu.title ? (openBlock(), createBlock(_component_nut_icon, {
155
- key: 0,
156
- size: "10",
157
- color: "#333",
158
- name: "arrow-up"
159
- })) : (openBlock(), createBlock(_component_nut_icon, {
160
- key: 1,
161
- size: "10",
162
- color: "#999",
163
- name: "arrow-down"
164
- }))
165
- ], 10, _hoisted_2);
166
- }), 128))
167
- ]),
168
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuList, (menu, index2) => {
169
- return withDirectives((openBlock(), createElementBlock("div", {
95
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.children, (item, index2) => {
96
+ return openBlock(), createElementBlock("view", {
170
97
  key: index2,
171
- class: "option-list"
98
+ class: normalizeClass(["nut-menu__item", { disabled: item.disabled }]),
99
+ onClick: ($event) => !item.disabled && _ctx.toggleItem(index2),
100
+ style: normalizeStyle({ color: item.state.showPopup ? _ctx.activeColor : "" })
172
101
  }, [
173
- createElementVNode("ul", null, [
174
- (openBlock(true), createElementBlock(Fragment, null, renderList(menu.options, (option, index22) => {
175
- return openBlock(), createElementBlock("li", {
176
- key: index22,
177
- onClick: ($event) => _ctx.handleClickOption(option.text, index2, option.value),
178
- style: normalizeStyle(_ctx.styleObj)
179
- }, [
180
- menu.title === option.text ? (openBlock(), createBlock(_component_nut_icon, {
181
- key: 0,
182
- size: "20",
183
- color: _ctx.activeColor,
184
- name: "Check"
185
- }, null, 8, ["color"])) : createCommentVNode("", true),
186
- createTextVNode(toDisplayString(option.text), 1)
187
- ], 12, _hoisted_3);
188
- }), 128))
189
- ])
190
- ], 512)), [
191
- [vShow, _ctx.hasOptions && _ctx.activeTitle === menu.title]
192
- ]);
193
- }), 128)),
194
- withDirectives(createElementVNode("view", _hoisted_4, [
195
- renderSlot(_ctx.$slots, "default")
196
- ], 512), [
197
- [vShow, !_ctx.hasOptions && _ctx.isShowCustomer]
198
- ])
199
- ], 6)
200
- ]);
102
+ createElementVNode("view", {
103
+ class: normalizeClass(["nut-menu__title", { active: item.state.showPopup }])
104
+ }, [
105
+ createElementVNode("view", _hoisted_2, toDisplayString(item.renderTitle()), 1),
106
+ createVNode(_component_nut_icon, {
107
+ name: item.titleIcon,
108
+ size: "10",
109
+ class: "nut-menu__title-icon"
110
+ }, null, 8, ["name"])
111
+ ], 2)
112
+ ], 14, _hoisted_1);
113
+ }), 128))
114
+ ], 2),
115
+ renderSlot(_ctx.$slots, "default")
116
+ ], 2);
201
117
  }
202
118
  var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
203
119
  export { index as default };