@kengic/uni 0.3.2-beta.10

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 (166) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +1 -0
  3. package/dist/kengic-uni.js +5 -0
  4. package/dist/src/consts/i18n/en.d.ts +45 -0
  5. package/dist/src/consts/i18n/index.d.ts +90 -0
  6. package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
  7. package/dist/src/consts/index.d.ts +1 -0
  8. package/dist/src/index.d.ts +2 -0
  9. package/dist/src/utils/index.d.ts +1 -0
  10. package/dist/src/utils/kg.util.d.ts +5 -0
  11. package/dist/uni-ui/index.ts +11 -0
  12. package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
  13. package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
  14. package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
  15. package/dist/uni-ui/uni-calendar/calendar.js +546 -0
  16. package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
  17. package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
  18. package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
  19. package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
  20. package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
  21. package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
  22. package/dist/uni-ui/uni-calendar/util.js +360 -0
  23. package/dist/uni-ui/uni-card/uni-card.vue +281 -0
  24. package/dist/uni-ui/uni-col/uni-col.vue +317 -0
  25. package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
  26. package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
  27. package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
  28. package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
  29. package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
  30. package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
  31. package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
  32. package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
  33. package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
  34. package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
  35. package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
  36. package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
  37. package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
  38. package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
  39. package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
  40. package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
  41. package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
  42. package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
  43. package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
  44. package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
  45. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
  46. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
  47. package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
  48. package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
  49. package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
  50. package/dist/uni-ui/uni-drawer/keypress.js +45 -0
  51. package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
  52. package/dist/uni-ui/uni-easyinput/common.js +56 -0
  53. package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
  54. package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
  55. package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
  56. package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
  57. package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
  58. package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
  59. package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
  60. package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
  61. package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
  62. package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
  63. package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
  64. package/dist/uni-ui/uni-file-picker/utils.js +109 -0
  65. package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
  66. package/dist/uni-ui/uni-forms/utils.js +293 -0
  67. package/dist/uni-ui/uni-forms/validate.js +486 -0
  68. package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
  69. package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
  70. package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
  71. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
  72. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
  73. package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
  74. package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
  75. package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
  76. package/dist/uni-ui/uni-group/uni-group.vue +134 -0
  77. package/dist/uni-ui/uni-icons/icons.js +1169 -0
  78. package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
  79. package/dist/uni-ui/uni-icons/uniicons.css +663 -0
  80. package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
  81. package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
  82. package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
  83. package/dist/uni-ui/uni-link/uni-link.vue +128 -0
  84. package/dist/uni-ui/uni-list/uni-list.vue +123 -0
  85. package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
  86. package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
  87. package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
  88. package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
  89. package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
  90. package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
  91. package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
  92. package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
  93. package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
  94. package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
  95. package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
  96. package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
  97. package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
  98. package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
  99. package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
  100. package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
  101. package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
  102. package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
  103. package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
  104. package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
  105. package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
  106. package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
  107. package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
  108. package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
  109. package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
  110. package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
  111. package/dist/uni-ui/uni-popup/keypress.js +45 -0
  112. package/dist/uni-ui/uni-popup/popup.js +23 -0
  113. package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
  114. package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
  115. package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
  116. package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
  117. package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
  118. package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
  119. package/dist/uni-ui/uni-row/uni-row.vue +190 -0
  120. package/dist/uni-ui/uni-scss/changelog.md +8 -0
  121. package/dist/uni-ui/uni-scss/index.scss +1 -0
  122. package/dist/uni-ui/uni-scss/package.json +82 -0
  123. package/dist/uni-ui/uni-scss/readme.md +4 -0
  124. package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
  125. package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
  126. package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
  127. package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
  128. package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
  129. package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
  130. package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
  131. package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
  132. package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
  133. package/dist/uni-ui/uni-scss/theme.scss +31 -0
  134. package/dist/uni-ui/uni-scss/variables.scss +62 -0
  135. package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
  136. package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
  137. package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
  138. package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
  139. package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
  140. package/dist/uni-ui/uni-section/uni-section.vue +167 -0
  141. package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
  142. package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
  143. package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
  144. package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
  145. package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
  146. package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
  147. package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
  148. package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
  149. package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
  150. package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
  151. package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
  152. package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
  153. package/dist/uni-ui/uni-table/uni-table.vue +455 -0
  154. package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
  155. package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
  156. package/dist/uni-ui/uni-td/uni-td.vue +90 -0
  157. package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
  158. package/dist/uni-ui/uni-th/uni-th.vue +285 -0
  159. package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
  160. package/dist/uni-ui/uni-title/uni-title.vue +171 -0
  161. package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
  162. package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
  163. package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
  164. package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
  165. package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
  166. package/package.json +90 -0
@@ -0,0 +1,317 @@
1
+ <template>
2
+ <!-- #ifndef APP-NVUE -->
3
+ <view :class="['uni-col', sizeClass, pointClassList]" :style="{
4
+ paddingLeft:`${Number(gutter)}rpx`,
5
+ paddingRight:`${Number(gutter)}rpx`,
6
+ }">
7
+ <slot></slot>
8
+ </view>
9
+ <!-- #endif -->
10
+ <!-- #ifdef APP-NVUE -->
11
+ <!-- 在nvue上,类名样式不生效,换为style -->
12
+ <!-- 设置right正值失效,设置 left 负值 -->
13
+ <view :class="['uni-col']" :style="{
14
+ paddingLeft:`${Number(gutter)}rpx`,
15
+ paddingRight:`${Number(gutter)}rpx`,
16
+ width:`${nvueWidth}rpx`,
17
+ position:'relative',
18
+ marginLeft:`${marginLeft}rpx`,
19
+ left:`${right === 0 ? left : -right}rpx`
20
+ }">
21
+ <slot></slot>
22
+ </view>
23
+ <!-- #endif -->
24
+ </template>
25
+
26
+ <script>
27
+ /**
28
+ * Col 布局-列
29
+ * @description 搭配uni-row使用,构建布局。
30
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=3958
31
+ *
32
+ * @property {span} type = Number 栅格占据的列数
33
+ * 默认 24
34
+ * @property {offset} type = Number 栅格左侧的间隔格数
35
+ * @property {push} type = Number 栅格向右移动格数
36
+ * @property {pull} type = Number 栅格向左移动格数
37
+ * @property {xs} type = [Number, Object] <768px 响应式栅格数或者栅格属性对象
38
+ * @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
39
+ * @property {sm} type = [Number, Object] ≥768px 响应式栅格数或者栅格属性对象
40
+ * @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
41
+ * @property {md} type = [Number, Object] ≥992px 响应式栅格数或者栅格属性对象
42
+ * @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
43
+ * @property {lg} type = [Number, Object] ≥1200px 响应式栅格数或者栅格属性对象
44
+ * @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
45
+ * @property {xl} type = [Number, Object] ≥1920px 响应式栅格数或者栅格属性对象
46
+ * @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
47
+ */
48
+ const ComponentClass = 'uni-col';
49
+
50
+ // -1 默认值,因为在微信小程序端只给Number会有默认值0
51
+ export default {
52
+ name: 'uniCol',
53
+ // #ifdef MP-WEIXIN
54
+ options: {
55
+ virtualHost: true // 在微信小程序中将组件节点渲染为虚拟节点,更加接近Vue组件的表现
56
+ },
57
+ // #endif
58
+ props: {
59
+ span: {
60
+ type: Number,
61
+ default: 24
62
+ },
63
+ offset: {
64
+ type: Number,
65
+ default: -1
66
+ },
67
+ pull: {
68
+ type: Number,
69
+ default: -1
70
+ },
71
+ push: {
72
+ type: Number,
73
+ default: -1
74
+ },
75
+ xs: [Number, Object],
76
+ sm: [Number, Object],
77
+ md: [Number, Object],
78
+ lg: [Number, Object],
79
+ xl: [Number, Object]
80
+ },
81
+ data() {
82
+ return {
83
+ gutter: 0,
84
+ sizeClass: '',
85
+ parentWidth: 0,
86
+ nvueWidth: 0,
87
+ marginLeft: 0,
88
+ right: 0,
89
+ left: 0
90
+ }
91
+ },
92
+ created() {
93
+ // 字节小程序中,在computed中读取$parent为undefined
94
+ let parent = this.$parent;
95
+
96
+ while (parent && parent.$options.componentName !== 'uniRow') {
97
+ parent = parent.$parent;
98
+ }
99
+
100
+ this.updateGutter(parent.gutter)
101
+ parent.$watch('gutter', (gutter) => {
102
+ this.updateGutter(gutter)
103
+ })
104
+
105
+ // #ifdef APP-NVUE
106
+ this.updateNvueWidth(parent.width)
107
+ parent.$watch('width', (width) => {
108
+ this.updateNvueWidth(width)
109
+ })
110
+ // #endif
111
+ },
112
+ computed: {
113
+ sizeList() {
114
+ let {
115
+ span,
116
+ offset,
117
+ pull,
118
+ push
119
+ } = this;
120
+
121
+ return {
122
+ span,
123
+ offset,
124
+ pull,
125
+ push
126
+ }
127
+ },
128
+ // #ifndef APP-NVUE
129
+ pointClassList() {
130
+ let classList = [];
131
+
132
+ ['xs', 'sm', 'md', 'lg', 'xl'].forEach(point => {
133
+ const props = this[point];
134
+ if (typeof props === 'number') {
135
+ classList.push(`${ComponentClass}-${point}-${props}`)
136
+ } else if (typeof props === 'object' && props) {
137
+ Object.keys(props).forEach(pointProp => {
138
+ classList.push(
139
+ pointProp === 'span' ?
140
+ `${ComponentClass}-${point}-${props[pointProp]}` :
141
+ `${ComponentClass}-${point}-${pointProp}-${props[pointProp]}`
142
+ )
143
+ })
144
+ }
145
+ });
146
+
147
+ // 支付宝小程序使用 :class=[ ['a','b'] ],渲染错误
148
+ return classList.join(' ');
149
+ }
150
+ // #endif
151
+ },
152
+ methods: {
153
+ updateGutter(parentGutter) {
154
+ parentGutter = Number(parentGutter);
155
+ if (!isNaN(parentGutter)) {
156
+ this.gutter = parentGutter / 2
157
+ }
158
+ },
159
+ // #ifdef APP-NVUE
160
+ updateNvueWidth(width) {
161
+ // 用于在nvue端,span,offset,pull,push的计算
162
+ this.parentWidth = width;
163
+ ['span', 'offset', 'pull', 'push'].forEach(size => {
164
+ const curSize = this[size];
165
+ if ((curSize || curSize === 0) && curSize !== -1) {
166
+ let RPX = 1 / 24 * curSize * width
167
+ RPX = Number(RPX);
168
+ switch (size) {
169
+ case 'span':
170
+ this.nvueWidth = RPX
171
+ break;
172
+ case 'offset':
173
+ this.marginLeft = RPX
174
+ break;
175
+ case 'pull':
176
+ this.right = RPX
177
+ break;
178
+ case 'push':
179
+ this.left = RPX
180
+ break;
181
+ }
182
+ }
183
+ });
184
+ }
185
+ // #endif
186
+ },
187
+ watch: {
188
+ sizeList: {
189
+ immediate: true,
190
+ handler(newVal) {
191
+ // #ifndef APP-NVUE
192
+ let classList = [];
193
+ for (let size in newVal) {
194
+ const curSize = newVal[size];
195
+ if ((curSize || curSize === 0) && curSize !== -1) {
196
+ classList.push(
197
+ size === 'span' ?
198
+ `${ComponentClass}-${curSize}` :
199
+ `${ComponentClass}-${size}-${curSize}`
200
+ )
201
+ }
202
+ }
203
+ // 支付宝小程序使用 :class=[ ['a','b'] ],渲染错误
204
+ this.sizeClass = classList.join(' ');
205
+ // #endif
206
+ // #ifdef APP-NVUE
207
+ this.updateNvueWidth(this.parentWidth);
208
+ // #endif
209
+ }
210
+ }
211
+ }
212
+ }
213
+ </script>
214
+
215
+ <style lang='scss' >
216
+ /* breakpoints */
217
+ $--sm: 768px !default;
218
+ $--md: 992px !default;
219
+ $--lg: 1200px !default;
220
+ $--xl: 1920px !default;
221
+
222
+ $breakpoints: ('xs' : (max-width: $--sm - 1),
223
+ 'sm' : (min-width: $--sm),
224
+ 'md' : (min-width: $--md),
225
+ 'lg' : (min-width: $--lg),
226
+ 'xl' : (min-width: $--xl));
227
+
228
+ $layout-namespace: ".uni-";
229
+ $col: $layout-namespace+"col";
230
+
231
+ @function getSize($size) {
232
+ /* TODO 1/24 * $size * 100 * 1%; 使用计算后的值,为了解决 vue3 控制台报错 */
233
+ @return 0.04166666666 * $size * 100 * 1%;
234
+ }
235
+
236
+ @mixin res($key, $map:$breakpoints) {
237
+ @if map-has-key($map, $key) {
238
+ @media screen and #{inspect(map-get($map,$key))} {
239
+ @content;
240
+ }
241
+ }
242
+
243
+ @else {
244
+ @warn "Undeinfed point: `#{$key}`";
245
+ }
246
+ }
247
+
248
+ /* #ifndef APP-NVUE */
249
+ #{$col} {
250
+ float: left;
251
+ box-sizing: border-box;
252
+ }
253
+
254
+ #{$col}-0 {
255
+ /* #ifdef APP-NVUE */
256
+ width: 0;
257
+ height: 0;
258
+ margin-top: 0;
259
+ margin-right: 0;
260
+ margin-bottom: 0;
261
+ margin-left: 0;
262
+ /* #endif */
263
+ /* #ifndef APP-NVUE */
264
+ display: none;
265
+ /* #endif */
266
+ }
267
+
268
+ @for $i from 0 through 24 {
269
+ #{$col}-#{$i} {
270
+ width: getSize($i);
271
+ }
272
+
273
+ #{$col}-offset-#{$i} {
274
+ margin-left: getSize($i);
275
+ }
276
+
277
+ #{$col}-pull-#{$i} {
278
+ position: relative;
279
+ right: getSize($i);
280
+ }
281
+
282
+ #{$col}-push-#{$i} {
283
+ position: relative;
284
+ left: getSize($i);
285
+ }
286
+ }
287
+
288
+ @each $point in map-keys($breakpoints) {
289
+ @include res($point) {
290
+ #{$col}-#{$point}-0 {
291
+ display: none;
292
+ }
293
+
294
+ @for $i from 0 through 24 {
295
+ #{$col}-#{$point}-#{$i} {
296
+ width: getSize($i);
297
+ }
298
+
299
+ #{$col}-#{$point}-offset-#{$i} {
300
+ margin-left: getSize($i);
301
+ }
302
+
303
+ #{$col}-#{$point}-pull-#{$i} {
304
+ position: relative;
305
+ right: getSize($i);
306
+ }
307
+
308
+ #{$col}-#{$point}-push-#{$i} {
309
+ position: relative;
310
+ left: getSize($i);
311
+ }
312
+ }
313
+ }
314
+ }
315
+
316
+ /* #endif */
317
+ </style>
@@ -0,0 +1,147 @@
1
+ <template>
2
+ <view class="uni-collapse">
3
+ <slot />
4
+ </view>
5
+ </template>
6
+ <script>
7
+ /**
8
+ * Collapse 折叠面板
9
+ * @description 展示可以折叠 / 展开的内容区域
10
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=23
11
+ * @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式,参数类型为string,否则为array)
12
+ * @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
13
+ * @event {Function} change 切换面板时触发,如果是手风琴模式,返回类型为string,否则为array
14
+ */
15
+ export default {
16
+ name: 'uniCollapse',
17
+ emits:['change','activeItem','input','update:modelValue'],
18
+ props: {
19
+ value: {
20
+ type: [String, Array],
21
+ default: ''
22
+ },
23
+ modelValue: {
24
+ type: [String, Array],
25
+ default: ''
26
+ },
27
+ accordion: {
28
+ // 是否开启手风琴效果
29
+ type: [Boolean, String],
30
+ default: false
31
+ },
32
+ },
33
+ data() {
34
+ return {}
35
+ },
36
+ computed: {
37
+ // TODO 兼容 vue2 和 vue3
38
+ dataValue() {
39
+ let value = (typeof this.value === 'string' && this.value === '') ||
40
+ (Array.isArray(this.value) && this.value.length === 0)
41
+ let modelValue = (typeof this.modelValue === 'string' && this.modelValue === '') ||
42
+ (Array.isArray(this.modelValue) && this.modelValue.length === 0)
43
+ if (value) {
44
+ return this.modelValue
45
+ }
46
+ if (modelValue) {
47
+ return this.value
48
+ }
49
+
50
+ return this.value
51
+ }
52
+ },
53
+ watch: {
54
+ dataValue(val) {
55
+ this.setOpen(val)
56
+ }
57
+ },
58
+ created() {
59
+ this.childrens = []
60
+ this.names = []
61
+ },
62
+ mounted() {
63
+ this.$nextTick(()=>{
64
+ this.setOpen(this.dataValue)
65
+ })
66
+ },
67
+ methods: {
68
+ setOpen(val) {
69
+ let str = typeof val === 'string'
70
+ let arr = Array.isArray(val)
71
+ this.childrens.forEach((vm, index) => {
72
+ if (str) {
73
+ if (val === vm.nameSync) {
74
+ if (!this.accordion) {
75
+ console.warn('accordion 属性为 false ,v-model 类型应该为 array')
76
+ return
77
+ }
78
+ vm.isOpen = true
79
+ }
80
+ }
81
+ if (arr) {
82
+ val.forEach(v => {
83
+ if (v === vm.nameSync) {
84
+ if (this.accordion) {
85
+ console.warn('accordion 属性为 true ,v-model 类型应该为 string')
86
+ return
87
+ }
88
+ vm.isOpen = true
89
+ }
90
+ })
91
+ }
92
+ })
93
+ this.emit(val)
94
+ },
95
+ setAccordion(self) {
96
+ if (!this.accordion) return
97
+ this.childrens.forEach((vm, index) => {
98
+ if (self !== vm) {
99
+ vm.isOpen = false
100
+ }
101
+ })
102
+ },
103
+ resize() {
104
+ this.childrens.forEach((vm, index) => {
105
+ // #ifndef APP-NVUE
106
+ vm.getCollapseHeight()
107
+ // #endif
108
+ // #ifdef APP-NVUE
109
+ vm.getNvueHwight()
110
+ // #endif
111
+ })
112
+ },
113
+ onChange(isOpen, self) {
114
+ let activeItem = []
115
+
116
+ if (this.accordion) {
117
+ activeItem = isOpen ? self.nameSync : ''
118
+ } else {
119
+ this.childrens.forEach((vm, index) => {
120
+ if (vm.isOpen) {
121
+ activeItem.push(vm.nameSync)
122
+ }
123
+ })
124
+ }
125
+ this.$emit('change', activeItem)
126
+ this.emit(activeItem)
127
+ },
128
+ emit(val){
129
+ this.$emit('input', val)
130
+ this.$emit('update:modelValue', val)
131
+ }
132
+ }
133
+ }
134
+ </script>
135
+ <style lang="scss" >
136
+ .uni-collapse {
137
+ /* #ifndef APP-NVUE */
138
+ width: 100%;
139
+ display: flex;
140
+ /* #endif */
141
+ /* #ifdef APP-NVUE */
142
+ flex: 1;
143
+ /* #endif */
144
+ flex-direction: column;
145
+ background-color: #fff;
146
+ }
147
+ </style>