@nutui/nutui 4.0.11 → 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 +2 -2
  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 +48 -48
  135. package/dist/styles/themes/jdb.scss +48 -48
  136. package/dist/styles/themes/jddkh.scss +48 -48
  137. package/dist/styles/themes/jdt.scss +48 -48
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +3 -4
  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,20 +1,28 @@
1
- var B = Object.defineProperty, H = Object.defineProperties;
2
- var R = Object.getOwnPropertyDescriptors;
3
- var k = Object.getOwnPropertySymbols;
4
- var _ = Object.prototype.hasOwnProperty, A = Object.prototype.propertyIsEnumerable;
5
- var I = (e, a, t) => a in e ? B(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t, v = (e, a) => {
6
- for (var t in a || (a = {}))
7
- _.call(a, t) && I(e, t, a[t]);
8
- if (k)
9
- for (var t of k(a))
10
- A.call(a, t) && I(e, t, a[t]);
11
- return e;
12
- }, C = (e, a) => H(e, R(a));
13
- import { reactive as E, watch as F, computed as X, toRefs as D, openBlock as L, createElementBlock as M, normalizeClass as Y, normalizeStyle as O } from "vue";
14
- import { c as T } from "./component-234624bc.js";
15
- import { _ as j } 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, watch, computed, toRefs, openBlock, createElementBlock, normalizeClass, normalizeStyle } from "vue";
21
+ import { c as createComponent } from "./component-81a4c1d0.js";
22
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
16
23
  import "../locale/lang";
17
- const { componentName: q, create: G } = T("watermark"), J = G({
24
+ const { componentName, create } = createComponent("watermark");
25
+ const _sfc_main = create({
18
26
  props: {
19
27
  name: {
20
28
  type: String,
@@ -86,91 +94,116 @@ const { componentName: q, create: G } = T("watermark"), J = G({
86
94
  }
87
95
  },
88
96
  emits: ["click"],
89
- setup(e, { emit: a }) {
90
- const t = E({
97
+ setup(props, { emit }) {
98
+ const state = reactive({
91
99
  base64Url: ""
92
- }), {
93
- zIndex: h,
94
- gapX: l,
95
- gapY: s,
96
- width: m,
97
- height: c,
98
- rotate: u,
99
- image: f,
100
- imageWidth: d,
101
- imageHeight: p,
102
- content: g,
103
- fontStyle: b,
104
- fontWeight: S,
105
- fontColor: x,
106
- fontSize: $,
107
- fontFamily: w
108
- } = e, N = () => {
109
- const o = document.createElement("canvas"), n = window.devicePixelRatio, r = o.getContext("2d"), U = `${(l + m) * n}px`, W = `${(s + c) * n}px`, z = m * n, y = c * n;
110
- if (o.setAttribute("width", U), o.setAttribute("height", W), r) {
111
- if (f) {
112
- r.translate(z / 2, y / 2), r.rotate(Math.PI / 180 * Number(u));
113
- const i = new Image();
114
- i.crossOrigin = "anonymous", i.referrerPolicy = "no-referrer", i.src = f, i.onload = () => {
115
- r.drawImage(
116
- i,
117
- -d * n / 2,
118
- -p * n / 2,
119
- d * n,
120
- p * n
121
- ), r.restore(), t.base64Url = o.toDataURL();
100
+ });
101
+ const {
102
+ zIndex,
103
+ gapX,
104
+ gapY,
105
+ width,
106
+ height,
107
+ rotate,
108
+ image,
109
+ imageWidth,
110
+ imageHeight,
111
+ content,
112
+ fontStyle,
113
+ fontWeight,
114
+ fontColor,
115
+ fontSize,
116
+ fontFamily
117
+ } = props;
118
+ const init = () => {
119
+ const canvas = document.createElement("canvas");
120
+ const ratio = window.devicePixelRatio;
121
+ const ctx = canvas.getContext("2d");
122
+ const canvasWidth = `${(gapX + width) * ratio}px`;
123
+ const canvasHeight = `${(gapY + height) * ratio}px`;
124
+ const markWidth = width * ratio;
125
+ const markHeight = height * ratio;
126
+ canvas.setAttribute("width", canvasWidth);
127
+ canvas.setAttribute("height", canvasHeight);
128
+ if (ctx) {
129
+ if (image) {
130
+ ctx.translate(markWidth / 2, markHeight / 2);
131
+ ctx.rotate(Math.PI / 180 * Number(rotate));
132
+ const img = new Image();
133
+ img.crossOrigin = "anonymous";
134
+ img.referrerPolicy = "no-referrer";
135
+ img.src = image;
136
+ img.onload = () => {
137
+ ctx.drawImage(
138
+ img,
139
+ -imageWidth * ratio / 2,
140
+ -imageHeight * ratio / 2,
141
+ imageWidth * ratio,
142
+ imageHeight * ratio
143
+ );
144
+ ctx.restore();
145
+ state.base64Url = canvas.toDataURL();
122
146
  };
123
- } else if (g) {
124
- r.textBaseline = "middle", r.textAlign = "center", r.translate(z / 2, y / 2), r.rotate(Math.PI / 180 * Number(u));
125
- const i = Number($) * n;
126
- r.font = `${b} normal ${S} ${i}px/${y}px ${w}`, r.fillStyle = x, r.fillText(g, 0, 0), r.restore(), t.base64Url = o.toDataURL();
147
+ } else if (content) {
148
+ ctx.textBaseline = "middle";
149
+ ctx.textAlign = "center";
150
+ ctx.translate(markWidth / 2, markHeight / 2);
151
+ ctx.rotate(Math.PI / 180 * Number(rotate));
152
+ const markSize = Number(fontSize) * ratio;
153
+ ctx.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
154
+ ctx.fillStyle = fontColor;
155
+ ctx.fillText(content, 0, 0);
156
+ ctx.restore();
157
+ state.base64Url = canvas.toDataURL();
127
158
  }
128
- } else
159
+ } else {
129
160
  throw new Error("当前环境不支持Canvas");
161
+ }
130
162
  };
131
- N(), F(
163
+ init();
164
+ watch(
132
165
  () => [
133
- h,
134
- l,
135
- s,
136
- m,
137
- c,
138
- u,
139
- f,
140
- d,
141
- p,
142
- g,
143
- b,
144
- S,
145
- x,
146
- $,
147
- w
166
+ zIndex,
167
+ gapX,
168
+ gapY,
169
+ width,
170
+ height,
171
+ rotate,
172
+ image,
173
+ imageWidth,
174
+ imageHeight,
175
+ content,
176
+ fontStyle,
177
+ fontWeight,
178
+ fontColor,
179
+ fontSize,
180
+ fontFamily
148
181
  ],
149
182
  () => {
150
- N();
183
+ init();
151
184
  }
152
185
  );
153
- const P = X(() => {
154
- const o = q;
186
+ const classes = computed(() => {
187
+ const prefixCls = componentName;
155
188
  return {
156
- [o]: !0,
157
- [`${o}-full-page`]: e.fullPage
189
+ [prefixCls]: true,
190
+ [`${prefixCls}-full-page`]: props.fullPage
158
191
  };
159
192
  });
160
- return C(v({}, D(t)), { classes: P });
193
+ return __spreadProps(__spreadValues({}, toRefs(state)), { classes });
161
194
  }
162
195
  });
163
- function K(e, a, t, h, l, s) {
164
- return L(), M("view", {
165
- class: Y(e.classes),
166
- style: O({
167
- zIndex: e.zIndex,
168
- backgroundSize: `${e.gapX + e.width}px`,
169
- backgroundImage: `url('${e.base64Url}')`
196
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
197
+ return openBlock(), createElementBlock("view", {
198
+ class: normalizeClass(_ctx.classes),
199
+ style: normalizeStyle({
200
+ zIndex: _ctx.zIndex,
201
+ backgroundSize: `${_ctx.gapX + _ctx.width}px`,
202
+ backgroundImage: `url('${_ctx.base64Url}')`
170
203
  })
171
204
  }, null, 6);
172
205
  }
173
- const ae = /* @__PURE__ */ j(J, [["render", K]]);
206
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
174
207
  export {
175
- ae as default
208
+ index as default
176
209
  };
@@ -0,0 +1,10 @@
1
+ const _export_sfc = (sfc, props) => {
2
+ const target = sfc.__vccOpts || sfc;
3
+ for (const [key, val] of props) {
4
+ target[key] = val;
5
+ }
6
+ return target;
7
+ };
8
+ export {
9
+ _export_sfc as _
10
+ };
@@ -0,0 +1,145 @@
1
+ import { shallowReactive, getCurrentInstance, provide, markRaw, isVNode, computed, h } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { p as pxCheck } from "./pxCheck-c6b9f6b7.js";
4
+ function flattenVNodes(children, childName) {
5
+ const result = [];
6
+ const traverse = (children2) => {
7
+ if (!Array.isArray(children2))
8
+ return;
9
+ children2.forEach((child) => {
10
+ var _a;
11
+ if (!isVNode(child))
12
+ return;
13
+ if (childName) {
14
+ if (child.type && child.type.name === childName) {
15
+ result.push(child);
16
+ return;
17
+ }
18
+ } else {
19
+ result.push(child);
20
+ }
21
+ if ((_a = child.component) == null ? void 0 : _a.subTree) {
22
+ traverse(child.component.subTree.children);
23
+ }
24
+ if (child.children) {
25
+ traverse(child.children);
26
+ }
27
+ });
28
+ };
29
+ traverse(children);
30
+ return result;
31
+ }
32
+ function sortChildren(parent, internalChildren, childName) {
33
+ const vnodes = flattenVNodes(parent.subTree.children, childName);
34
+ internalChildren.sort((a, b) => {
35
+ return vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode);
36
+ });
37
+ }
38
+ function useProvide(key, childName) {
39
+ const internalChildren = shallowReactive([]);
40
+ const parent = getCurrentInstance();
41
+ const add = (child) => {
42
+ if (!child.proxy)
43
+ return;
44
+ internalChildren.push(markRaw(child));
45
+ sortChildren(parent, internalChildren, childName);
46
+ };
47
+ const remove = (child) => {
48
+ internalChildren.splice(internalChildren.indexOf(markRaw(child)), 1);
49
+ };
50
+ const extend = Object.assign;
51
+ return (value) => {
52
+ provide(
53
+ key,
54
+ extend(
55
+ {
56
+ add,
57
+ remove,
58
+ internalChildren
59
+ },
60
+ value
61
+ )
62
+ );
63
+ return {
64
+ internalChildren
65
+ };
66
+ };
67
+ }
68
+ const { componentName } = createComponent("grid");
69
+ const GRID_KEY = Symbol("grid");
70
+ const gridProps = {
71
+ // 列数
72
+ columnNum: {
73
+ type: [Number, String],
74
+ default: 4
75
+ },
76
+ // 是否显示边框
77
+ border: {
78
+ type: Boolean,
79
+ default: true
80
+ },
81
+ // 格子之间间隔距离
82
+ gutter: {
83
+ type: [Number, String],
84
+ default: 0
85
+ },
86
+ // 是否内容居中
87
+ center: {
88
+ type: Boolean,
89
+ default: true
90
+ },
91
+ // 是否固定正方形
92
+ square: {
93
+ type: Boolean,
94
+ default: false
95
+ },
96
+ // 内容与文字翻转
97
+ reverse: {
98
+ type: Boolean,
99
+ default: false
100
+ },
101
+ // 内容排列方向
102
+ direction: {
103
+ type: String
104
+ },
105
+ // 是否开启点击反馈
106
+ clickable: {
107
+ type: Boolean,
108
+ default: false
109
+ }
110
+ };
111
+ const component = {
112
+ props: gridProps,
113
+ setup(props, { slots }) {
114
+ useProvide(GRID_KEY, `${componentName}-item`)({ props });
115
+ const rootClass = computed(() => {
116
+ const prefixCls = componentName;
117
+ return {
118
+ [prefixCls]: true,
119
+ [`${prefixCls}--border`]: props.border && !props.gutter
120
+ };
121
+ });
122
+ const rootStyle = computed(() => {
123
+ const style = {};
124
+ if (props.gutter) {
125
+ style.paddingLeft = pxCheck(props.gutter);
126
+ }
127
+ return style;
128
+ });
129
+ return () => {
130
+ var _a;
131
+ return h(
132
+ "view",
133
+ {
134
+ class: rootClass.value,
135
+ style: rootStyle.value
136
+ },
137
+ (_a = slots.default) == null ? void 0 : _a.call(slots)
138
+ );
139
+ };
140
+ }
141
+ };
142
+ export {
143
+ GRID_KEY as G,
144
+ component as c
145
+ };
@@ -0,0 +1,145 @@
1
+ import { defineComponent } from "vue";
2
+ import locale from "../locale/lang";
3
+ const TypeOfFun = (value) => {
4
+ if (null === value) {
5
+ return "null";
6
+ }
7
+ const type = typeof value;
8
+ if ("undefined" === type || "string" === type) {
9
+ return type;
10
+ }
11
+ const typeString = toString.call(value);
12
+ switch (typeString) {
13
+ case "[object Array]":
14
+ return "array";
15
+ case "[object Date]":
16
+ return "date";
17
+ case "[object Boolean]":
18
+ return "boolean";
19
+ case "[object Number]":
20
+ return "number";
21
+ case "[object Function]":
22
+ return "function";
23
+ case "[object RegExp]":
24
+ return "regexp";
25
+ case "[object Object]":
26
+ if (void 0 !== value.nodeType) {
27
+ if (3 == value.nodeType) {
28
+ return /\S/.test(value.nodeValue) ? "textnode" : "whitespace";
29
+ } else {
30
+ return "element";
31
+ }
32
+ } else {
33
+ return "object";
34
+ }
35
+ default:
36
+ return "unknow";
37
+ }
38
+ };
39
+ const isArray = Array.isArray;
40
+ const isDate = (val) => val instanceof Date;
41
+ const isFunction = (val) => typeof val === "function";
42
+ const isString = (val) => typeof val === "string";
43
+ const isObject = (val) => val !== null && typeof val === "object";
44
+ const isPromise = (val) => {
45
+ return isObject(val) && isFunction(val.then) && isFunction(val.catch);
46
+ };
47
+ const docu = document;
48
+ const body = docu.body;
49
+ const getPropByPath = (obj, keyPath) => {
50
+ try {
51
+ return keyPath.split(".").reduce((prev, curr) => prev[curr], obj);
52
+ } catch (error) {
53
+ return "";
54
+ }
55
+ };
56
+ const floatData = (format, dataOp, mapOps) => {
57
+ let mergeFormat = Object.assign({}, format);
58
+ let mergeMapOps = Object.assign({}, mapOps);
59
+ if (Object.keys(dataOp).length > 0) {
60
+ Object.keys(mergeFormat).forEach((keys) => {
61
+ if (mergeMapOps.hasOwnProperty(keys)) {
62
+ const tof = TypeOfFun(mergeMapOps[keys]);
63
+ if (tof == "function") {
64
+ mergeFormat[keys] = mergeMapOps[keys](dataOp);
65
+ }
66
+ if (tof == "string") {
67
+ mergeFormat[keys] = dataOp[mergeMapOps[keys]];
68
+ }
69
+ } else {
70
+ if (dataOp[keys])
71
+ mergeFormat[keys] = dataOp[keys];
72
+ }
73
+ });
74
+ return mergeFormat;
75
+ }
76
+ return format;
77
+ };
78
+ function myFixed(num, digit = 2) {
79
+ if (Object.is(parseFloat(num), NaN)) {
80
+ return console.log(`传入的值:${num}不是一个数字`);
81
+ }
82
+ num = parseFloat(num);
83
+ return (Math.round((num + Number.EPSILON) * Math.pow(10, digit)) / Math.pow(10, digit)).toFixed(digit);
84
+ }
85
+ function preventDefault(event, isStopPropagation) {
86
+ if (typeof event.cancelable !== "boolean" || event.cancelable) {
87
+ event.preventDefault();
88
+ }
89
+ if (isStopPropagation) {
90
+ event.stopPropagation();
91
+ }
92
+ }
93
+ const padZero = (num, length = 2) => {
94
+ num += "";
95
+ while (num.length < length) {
96
+ num = "0" + num;
97
+ }
98
+ return num.toString();
99
+ };
100
+ const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
101
+ const getScrollTopRoot = () => {
102
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
103
+ };
104
+ function createComponent(name) {
105
+ const componentName = "nut-" + name;
106
+ return {
107
+ componentName,
108
+ translate(keyPath, ...args) {
109
+ const languages = locale.languages();
110
+ const text = getPropByPath(languages, `${name.replace("-", "")}.${keyPath}`) || getPropByPath(languages, keyPath);
111
+ return isFunction(text) ? text(...args) : text;
112
+ },
113
+ create: function(_component) {
114
+ _component.baseName = name;
115
+ _component.name = componentName;
116
+ _component.install = (vue) => {
117
+ vue.component(_component.name, _component);
118
+ };
119
+ return defineComponent(_component);
120
+ },
121
+ createDemo: function(_component) {
122
+ _component.baseName = name;
123
+ _component.name = "demo-" + name;
124
+ return defineComponent(_component);
125
+ }
126
+ };
127
+ }
128
+ export {
129
+ TypeOfFun as T,
130
+ isDate as a,
131
+ body as b,
132
+ createComponent as c,
133
+ preventDefault as d,
134
+ clamp as e,
135
+ isPromise as f,
136
+ isObject as g,
137
+ getPropByPath as h,
138
+ isArray as i,
139
+ isString as j,
140
+ isFunction as k,
141
+ getScrollTopRoot as l,
142
+ myFixed as m,
143
+ floatData as n,
144
+ padZero as p
145
+ };
@@ -0,0 +1,33 @@
1
+ import { unref } from "vue";
2
+ function isWindow(val) {
3
+ return val === window;
4
+ }
5
+ const useRect = (elementRef) => {
6
+ const element = unref(elementRef);
7
+ if (isWindow(element)) {
8
+ const width = element.innerWidth;
9
+ const height = element.innerHeight;
10
+ return {
11
+ top: 0,
12
+ left: 0,
13
+ right: width,
14
+ bottom: height,
15
+ width,
16
+ height
17
+ };
18
+ }
19
+ if (element && element.getBoundingClientRect) {
20
+ return element.getBoundingClientRect();
21
+ }
22
+ return {
23
+ top: 0,
24
+ left: 0,
25
+ right: 0,
26
+ bottom: 0,
27
+ width: 0,
28
+ height: 0
29
+ };
30
+ };
31
+ export {
32
+ useRect as u
33
+ };
@@ -0,0 +1,30 @@
1
+ import { ref, onMounted } from "vue";
2
+ const overflowScrollReg = /scroll|auto|overlay/i;
3
+ const defaultRoot = window;
4
+ function isElement(node) {
5
+ const ELEMENT_NODE_TYPE = 1;
6
+ return node.tagName !== "HTML" && node.tagName !== "BODY" && node.nodeType === ELEMENT_NODE_TYPE;
7
+ }
8
+ function getScrollParent(el, root = defaultRoot) {
9
+ let node = el;
10
+ while (node && node !== root && isElement(node)) {
11
+ const { overflowY } = window.getComputedStyle(node);
12
+ if (overflowScrollReg.test(overflowY)) {
13
+ return node;
14
+ }
15
+ node = node.parentNode;
16
+ }
17
+ return root;
18
+ }
19
+ function useScrollParent(el, root = defaultRoot) {
20
+ const scrollParent = ref();
21
+ onMounted(() => {
22
+ if (el.value) {
23
+ scrollParent.value = getScrollParent(el.value, root);
24
+ }
25
+ });
26
+ return scrollParent;
27
+ }
28
+ export {
29
+ useScrollParent as u
30
+ };
@@ -0,0 +1,8 @@
1
+ import { getCurrentInstance } from "vue";
2
+ function useRouter() {
3
+ const proxy = getCurrentInstance().proxy;
4
+ return proxy.$router || null;
5
+ }
6
+ export {
7
+ useRouter as u
8
+ };
@@ -0,0 +1,10 @@
1
+ import { getCurrentInstance } from "vue";
2
+ function useExpose(apis) {
3
+ const instance = getCurrentInstance();
4
+ if (instance) {
5
+ Object.assign(instance.proxy, apis);
6
+ }
7
+ }
8
+ export {
9
+ useExpose as u
10
+ };
@@ -0,0 +1,67 @@
1
+ import { ref } from "vue";
2
+ const MIN_DISTANCE = 10;
3
+ function getDirection(x, y) {
4
+ if (x > y && x > MIN_DISTANCE) {
5
+ return "horizontal";
6
+ }
7
+ if (y > x && y > MIN_DISTANCE) {
8
+ return "vertical";
9
+ }
10
+ return "";
11
+ }
12
+ function useTouch() {
13
+ const startX = ref(0);
14
+ const startY = ref(0);
15
+ const moveX = ref(0);
16
+ const moveY = ref(0);
17
+ const deltaX = ref(0);
18
+ const deltaY = ref(0);
19
+ const offsetX = ref(0);
20
+ const offsetY = ref(0);
21
+ const direction = ref("");
22
+ const isVertical = () => direction.value === "vertical";
23
+ const isHorizontal = () => direction.value === "horizontal";
24
+ const reset = () => {
25
+ deltaX.value = 0;
26
+ deltaY.value = 0;
27
+ offsetX.value = 0;
28
+ offsetY.value = 0;
29
+ direction.value = "";
30
+ };
31
+ const start = (event) => {
32
+ reset();
33
+ startX.value = event.touches[0].clientX;
34
+ startY.value = event.touches[0].clientY;
35
+ };
36
+ const move = (event) => {
37
+ const touch = event.touches[0];
38
+ deltaX.value = touch.clientX - startX.value;
39
+ deltaY.value = touch.clientY - startY.value;
40
+ moveX.value = touch.clientX;
41
+ moveY.value = touch.clientY;
42
+ offsetX.value = Math.abs(deltaX.value);
43
+ offsetY.value = Math.abs(deltaY.value);
44
+ if (!direction.value) {
45
+ direction.value = getDirection(offsetX.value, offsetY.value);
46
+ }
47
+ };
48
+ return {
49
+ move,
50
+ start,
51
+ reset,
52
+ startX,
53
+ startY,
54
+ moveX,
55
+ moveY,
56
+ deltaX,
57
+ deltaY,
58
+ offsetX,
59
+ offsetY,
60
+ direction,
61
+ isVertical,
62
+ isHorizontal
63
+ };
64
+ }
65
+ export {
66
+ useTouch as u
67
+ };