@deot/vc-components 1.0.42 → 1.0.44

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.
package/dist/index.cjs CHANGED
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const vue = require('vue');
6
+ const $ = require('@deot/helper-dom');
6
7
  const Utils = require('@deot/helper-utils');
7
8
  const lodashEs = require('lodash-es');
8
9
  const vcHooks = require('@deot/vc-hooks');
9
- const $ = require('@deot/helper-dom');
10
10
  const helperResize = require('@deot/helper-resize');
11
11
  const vcShared = require('@deot/vc-shared');
12
12
  const helperWheel = require('@deot/helper-wheel');
@@ -34,8 +34,8 @@ function _interopNamespaceDefault(e) {
34
34
  return Object.freeze(n);
35
35
  }
36
36
 
37
- const Utils__namespace = /*#__PURE__*/_interopNamespaceDefault(Utils);
38
37
  const $__namespace = /*#__PURE__*/_interopNamespaceDefault($);
38
+ const Utils__namespace = /*#__PURE__*/_interopNamespaceDefault(Utils);
39
39
  const Load__namespace = /*#__PURE__*/_interopNamespaceDefault(Load);
40
40
 
41
41
  class VcError {
@@ -101,7 +101,7 @@ class Instance {
101
101
  }
102
102
  const VcInstance = new Instance();
103
103
 
104
- const props$1s = {
104
+ const props$1t = {
105
105
  tag: {
106
106
  type: String,
107
107
  default: "div"
@@ -110,10 +110,10 @@ const props$1s = {
110
110
 
111
111
  /** @jsxImportSource vue */
112
112
 
113
- const COMPONENT_NAME$27 = 'vc-action-sheet';
113
+ const COMPONENT_NAME$28 = 'vc-action-sheet';
114
114
  const ActionSheet = /* @__PURE__ */ vue.defineComponent({
115
- name: COMPONENT_NAME$27,
116
- props: props$1s,
115
+ name: COMPONENT_NAME$28,
116
+ props: props$1t,
117
117
  setup(props, {
118
118
  slots
119
119
  }) {
@@ -127,6 +127,182 @@ const ActionSheet = /* @__PURE__ */ vue.defineComponent({
127
127
 
128
128
  const MActionSheet = ActionSheet;
129
129
 
130
+ const props$1s = {
131
+ zIndex: {
132
+ type: [Number, String],
133
+ default: 1
134
+ },
135
+ // TODO: left/right
136
+ placement: {
137
+ type: String,
138
+ default: "top"
139
+ },
140
+ disabled: {
141
+ type: Boolean,
142
+ default: false
143
+ },
144
+ fixed: {
145
+ type: Boolean,
146
+ default: true
147
+ },
148
+ offset: {
149
+ type: Number,
150
+ default: 0
151
+ },
152
+ // -> 固钉始终保持在容器内, 超过范围则隐藏(请注意容器避免出现滚动条) 仅fixed为true有效
153
+ target: {
154
+ type: String
155
+ }
156
+ };
157
+
158
+ /** @jsxImportSource vue */
159
+
160
+ const COMPONENT_NAME$27 = 'vc-affix';
161
+ const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
162
+ const Affix = /* @__PURE__ */ vue.defineComponent({
163
+ name: COMPONENT_NAME$27,
164
+ props: props$1s,
165
+ setup(props, {
166
+ slots,
167
+ expose
168
+ }) {
169
+ const scrollerInstance = vue.inject('vc-scroller', null);
170
+ const scroller = vue.shallowRef(); // 当前元素所在的滚动容器
171
+ const base = vue.shallowRef(); // 当前元素(props.tagret)的参考容器
172
+ const current = vue.shallowRef(); // 当前元素
173
+
174
+ const currentRect = vue.reactive({
175
+ top: 0,
176
+ bottom: 0,
177
+ width: 0,
178
+ height: 0
179
+ });
180
+ const isActive = vue.ref(false);
181
+ const transformY = vue.ref(0);
182
+ const windowHeight = vue.ref(window.innerHeight);
183
+ const isVcScrollerWheel = vue.computed(() => {
184
+ return SCROLLER_WHEEL_REG.test(scroller.value?.className || '');
185
+ });
186
+ const currentStyle = vue.computed(() => {
187
+ if (!isActive.value) return {};
188
+ return {
189
+ height: `${currentRect.height}px`,
190
+ width: `${currentRect.width}px`
191
+ };
192
+ });
193
+ const contentStyle = vue.computed(() => {
194
+ if (!isActive.value) return {};
195
+ const offset = `${props.offset}px`;
196
+ return {
197
+ height: `${currentRect.height}px`,
198
+ width: `${currentRect.width}px`,
199
+ top: props.placement === 'top' ? offset : '',
200
+ bottom: props.placement === 'bottom' ? offset : '',
201
+ zIndex: props.zIndex,
202
+ transform: transformY.value ? `translateY(${transformY.value}px)` : ''
203
+ };
204
+ });
205
+ const setCurrentRect = () => {
206
+ const rect = current.value.getBoundingClientRect();
207
+ Object.assign(currentRect, {
208
+ top: rect.top,
209
+ bottom: rect.bottom,
210
+ width: rect.width,
211
+ height: rect.height
212
+ });
213
+ };
214
+ const setAbsoluteStatus = () => {
215
+ const {
216
+ placement,
217
+ offset
218
+ } = props;
219
+ const currentHeightOffset = offset + currentRect.height;
220
+ const containerRect = scroller.value.getBoundingClientRect();
221
+ let transformOffsetY = 0;
222
+
223
+ // scroller-wheel滚动条偏移
224
+ if (scrollerInstance && isVcScrollerWheel.value) {
225
+ const maxMoveY = scrollerInstance.scrollHeight - scrollerInstance.clientHeight;
226
+ transformOffsetY = scrollerInstance.scrollTop >= maxMoveY ? maxMoveY : scrollerInstance.scrollTop;
227
+ }
228
+ if (placement === 'top') {
229
+ isActive.value = currentRect.top - containerRect.top <= props.offset;
230
+ transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0) + transformOffsetY;
231
+ } else {
232
+ isActive.value = currentRect.bottom - containerRect.top >= containerRect.height - props.offset;
233
+ transformY.value = Math.max(containerRect.height - containerRect.top - currentHeightOffset, 0) + transformOffsetY;
234
+ }
235
+ };
236
+ const setFixedStatus = () => {
237
+ const {
238
+ placement,
239
+ target,
240
+ offset
241
+ } = props;
242
+ const currentHeightOffset = offset + currentRect.height;
243
+ const containerRect = target && base.value.getBoundingClientRect();
244
+ if (placement === 'top') {
245
+ if (target) {
246
+ isActive.value = offset > currentRect.top && containerRect.bottom > 0;
247
+ transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0);
248
+ } else {
249
+ isActive.value = offset > currentRect.top;
250
+ }
251
+ } else {
252
+ if (target) {
253
+ isActive.value = windowHeight.value - offset < currentRect.bottom && windowHeight.value > containerRect.top;
254
+ transformY.value = -Math.min(windowHeight.value - containerRect.top - currentHeightOffset, 0);
255
+ } else {
256
+ isActive.value = windowHeight.value - offset < currentRect.bottom;
257
+ }
258
+ }
259
+ };
260
+ const refresh = () => {
261
+ setCurrentRect();
262
+ scroller.value instanceof Window || props.fixed ? setFixedStatus() : setAbsoluteStatus();
263
+ };
264
+ vue.onMounted(() => {
265
+ if (typeof props.target === 'string') {
266
+ base.value = document.querySelector(props.target) ?? void 0;
267
+ }
268
+ !base.value && (base.value = document.documentElement);
269
+ scroller.value = $.getScroller(current.value, {
270
+ className: SCROLLER_WHEEL_REG
271
+ });
272
+ if (isVcScrollerWheel.value) {
273
+ scrollerInstance?.on(refresh);
274
+ } else {
275
+ scroller.value?.addEventListener('scroll', refresh);
276
+ }
277
+ refresh();
278
+ });
279
+ vue.onBeforeUnmount(() => {
280
+ if (isVcScrollerWheel.value) {
281
+ scrollerInstance?.off(refresh);
282
+ } else {
283
+ scroller.value?.removeEventListener('scroll', refresh);
284
+ }
285
+ });
286
+ expose({
287
+ refresh
288
+ });
289
+ return () => {
290
+ return vue.createVNode("div", {
291
+ "ref": current,
292
+ "class": "vc-affix",
293
+ "style": currentStyle.value
294
+ }, [vue.createVNode("div", {
295
+ "class": {
296
+ [`vc-affix__${props.fixed ? 'fixed' : 'absolute'}`]: isActive.value
297
+ },
298
+ "style": contentStyle.value
299
+ }, [slots?.default?.()])]);
300
+ };
301
+ }
302
+ });
303
+
304
+ const MAffix = Affix;
305
+
130
306
  const props$1r = {
131
307
  modelValue: {
132
308
  type: Boolean,
@@ -813,7 +989,7 @@ const COMPONENT_NAME$1$ = 'vc-alert';
813
989
 
814
990
  // [color, borderColor, backgroundColor], -> CSS
815
991
  const THEME_MAP = {
816
- info: ['#2B72FD', '#91d5ff', '#e6f7ff'],
992
+ info: ['#456CF6', '#91d5ff', '#e6f7ff'],
817
993
  success: ['#52c41a', '#b7eb8f', '#f6ffed'],
818
994
  error: ['#ed4014', '#ffb08f', '#fbe9e9'],
819
995
  warning: ['#ffbf00', '#ffe58f', '#fffbe6']
@@ -9150,6 +9326,7 @@ const useScroller = (expose) => {
9150
9326
  refreshSize();
9151
9327
  refreshPosition(options);
9152
9328
  };
9329
+ const listeners = [];
9153
9330
  const triggerScrollDelegate = (options) => {
9154
9331
  const delegates = {
9155
9332
  scrollLeft: (options && options.x) ?? scrollX.value,
@@ -9157,12 +9334,15 @@ const useScroller = (expose) => {
9157
9334
  clientWidth: wrapperW.value,
9158
9335
  clientHeight: wrapperH.value,
9159
9336
  scrollWidth: contentW.value,
9160
- scrollHeight: contentH.value
9337
+ scrollHeight: contentH.value,
9338
+ getBoundingClientRect: () => wrapper.value?.getBoundingClientRect()
9161
9339
  };
9162
- instance.emit("scroll", {
9340
+ const e = {
9163
9341
  target: delegates,
9164
9342
  currentTarget: delegates
9165
- });
9343
+ };
9344
+ instance.emit("scroll", e);
9345
+ listeners.forEach((listener) => listener(e));
9166
9346
  };
9167
9347
  const scrollTo = (options) => {
9168
9348
  refreshPosition(options);
@@ -9189,8 +9369,9 @@ const useScroller = (expose) => {
9189
9369
  helperResize.Resize.off(wrapper.value, refresh);
9190
9370
  helperResize.Resize.off(content.value, refresh);
9191
9371
  }
9372
+ listeners.splice(0, listeners.length);
9192
9373
  });
9193
- expose({
9374
+ const exposed = {
9194
9375
  wrapper,
9195
9376
  content,
9196
9377
  scrollTo,
@@ -9206,8 +9387,16 @@ const useScroller = (expose) => {
9206
9387
  },
9207
9388
  setScrollLeft: (value) => {
9208
9389
  scrollTo({ x: value });
9390
+ },
9391
+ on: (listener) => {
9392
+ listeners.push(listener);
9393
+ },
9394
+ off: (listener) => {
9395
+ listeners.splice(listeners.indexOf(listener), 1);
9209
9396
  }
9210
- });
9397
+ };
9398
+ expose(exposed);
9399
+ vue.provide("vc-scroller", vue.reactive(exposed));
9211
9400
  return {
9212
9401
  bar,
9213
9402
  wrapper,
@@ -14864,7 +15053,7 @@ const props$n = {
14864
15053
  color: {
14865
15054
  type: [Object, String],
14866
15055
  default: () => ({
14867
- normal: "#2B72FD",
15056
+ normal: "#456CF6",
14868
15057
  success: "#52c41a",
14869
15058
  error: "#f5222d"
14870
15059
  })
@@ -18225,10 +18414,38 @@ const TableBody = /* @__PURE__ */ vue.defineComponent({
18225
18414
  }
18226
18415
  });
18227
18416
 
18228
- // import TableSort from './table-sort';
18417
+ const TableSort = /* @__PURE__ */ vue.defineComponent({
18418
+ name: 'vc-table-sort',
18419
+ props: {
18420
+ order: String
18421
+ },
18422
+ emits: ['click'],
18423
+ setup(props, {
18424
+ emit
18425
+ }) {
18426
+ const handleClick = v => {
18427
+ emit('click', props.order !== v ? v : '');
18428
+ };
18429
+ return () => {
18430
+ return vue.createVNode("span", {
18431
+ "class": "vc-table-sort"
18432
+ }, [vue.createVNode("span", {
18433
+ "class": [{
18434
+ 'is-ascending': props.order === 'ascending'
18435
+ }, 'vc-table-sort__icon vc-table-sort__icon--ascending'],
18436
+ "onClick": vue.withModifiers(() => handleClick('ascending'), ['stop'])
18437
+ }, null), vue.createVNode("span", {
18438
+ "class": [{
18439
+ 'is-descending': props.order === 'descending'
18440
+ }, 'vc-table-sort__icon vc-table-sort__icon--descending'],
18441
+ "onClick": vue.withModifiers(() => handleClick('descending'), ['stop'])
18442
+ }, null)]);
18443
+ };
18444
+ }
18445
+ });
18446
+
18229
18447
  // import TableFilter from './table-filter';
18230
18448
 
18231
- const TableSort = 'div';
18232
18449
  const TableFilter = 'div';
18233
18450
  const TableHeader = /* @__PURE__ */ vue.defineComponent({
18234
18451
  name: 'vc-table-header',
@@ -18236,7 +18453,7 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
18236
18453
  fixed: [Boolean, String],
18237
18454
  border: Boolean,
18238
18455
  // 排序全部交给外部处理,内部不处理数据,只做交互
18239
- defaultSort: {
18456
+ sort: {
18240
18457
  type: Object,
18241
18458
  default: () => ({})
18242
18459
  }
@@ -18434,10 +18651,12 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
18434
18651
  document.body.style.cursor = '';
18435
18652
  };
18436
18653
  const handleSort = (prop, order) => {
18437
- table.emit('sort-change', {
18654
+ const v = {
18438
18655
  prop,
18439
18656
  order
18440
- });
18657
+ };
18658
+ table.emit('update:sort', v);
18659
+ table.emit('sort-change', v);
18441
18660
  };
18442
18661
  const handleFilter = (column, value) => {
18443
18662
  const {
@@ -18493,9 +18712,10 @@ const TableHeader = /* @__PURE__ */ vue.defineComponent({
18493
18712
  store: table.store
18494
18713
  }) : column.label, column.tooltip ? vue.createVNode(Icon, {
18495
18714
  "type": "o-info",
18715
+ "class": "vc-table__tooltip",
18496
18716
  "onMouseenter": e => handleCellMouseEnter(e, column)
18497
18717
  }, null) : null, column.sortable ? vue.createVNode(TableSort, {
18498
- "order": column.prop === props.defaultSort.prop ? props.defaultSort.order : '',
18718
+ "order": column.prop === props.sort.prop ? props.sort.order : '',
18499
18719
  "onClick": order => handleSort(column.prop, order)
18500
18720
  }, null) : null, column.filters ? vue.createVNode(TableFilter, {
18501
18721
  "data": column.filters,
@@ -18710,7 +18930,7 @@ const props$d = {
18710
18930
  * 排序全部交给外部处理,内部不处理数据,只做交互
18711
18931
  * 列与列之间互斥
18712
18932
  */
18713
- defaultSort: {
18933
+ sort: {
18714
18934
  type: Object,
18715
18935
  default: () => ({})
18716
18936
  },
@@ -18724,7 +18944,7 @@ const COMPONENT_NAME$j = 'vc-table';
18724
18944
  const Table = /* @__PURE__ */ vue.defineComponent({
18725
18945
  name: COMPONENT_NAME$j,
18726
18946
  props: props$d,
18727
- emits: ['select', 'select-all', 'selection-change', 'cell-mouse-enter', 'cell-mouse-leave', 'cell-click', 'cell-dblclick', 'row-click', 'row-contextmenu', 'row-dblclick', 'header-click', 'header-contextmenu', 'current-change', 'header-dragend ', 'expand-change', 'sort-change'],
18947
+ emits: ['select', 'select-all', 'selection-change', 'cell-mouse-enter', 'cell-mouse-leave', 'cell-click', 'cell-dblclick', 'row-click', 'row-contextmenu', 'row-dblclick', 'header-click', 'header-contextmenu', 'current-change', 'header-dragend ', 'expand-change', 'sort-change', 'update:sort'],
18728
18948
  setup(props, {
18729
18949
  slots,
18730
18950
  expose,
@@ -19130,7 +19350,7 @@ const Table = /* @__PURE__ */ vue.defineComponent({
19130
19350
  }, [vue.createVNode(TableHeader, {
19131
19351
  "ref": tableHeader,
19132
19352
  "border": props.border,
19133
- "default-sort": props.defaultSort,
19353
+ "sort": props.sort,
19134
19354
  "style": bodyWidthStyle.value
19135
19355
  }, null)]), states.columns.length > 0 && vue.createVNode(ScrollerWheel, {
19136
19356
  "ref": scroller,
@@ -19179,7 +19399,7 @@ const Table = /* @__PURE__ */ vue.defineComponent({
19179
19399
  }, [vue.createVNode(TableHeader, {
19180
19400
  "ref": leftFixedTableHeader,
19181
19401
  "border": props.border,
19182
- "default-sort": props.defaultSort,
19402
+ "sort": props.sort,
19183
19403
  "style": bodyWidthStyle.value,
19184
19404
  "fixed": "left"
19185
19405
  }, null)]), vue.createVNode("div", {
@@ -19218,7 +19438,7 @@ const Table = /* @__PURE__ */ vue.defineComponent({
19218
19438
  }, [vue.createVNode(TableHeader, {
19219
19439
  "ref": rightFixedTableHeader,
19220
19440
  "border": props.border,
19221
- "default-sort": props.defaultSort,
19441
+ "sort": props.sort,
19222
19442
  "style": bodyWidthStyle.value,
19223
19443
  "fixed": "right"
19224
19444
  }, null)]), vue.createVNode("div", {
@@ -20033,7 +20253,8 @@ const Tabs = /* @__PURE__ */ vue.defineComponent({
20033
20253
 
20034
20254
  const props$b = {
20035
20255
  value: {
20036
- type: [String, Number, Boolean]
20256
+ type: [String, Number, Boolean],
20257
+ default: void 0
20037
20258
  },
20038
20259
  label: {
20039
20260
  type: [String, Function],
@@ -20381,7 +20602,7 @@ const MTabs = /* @__PURE__ */ vue.defineComponent({
20381
20602
  "class": [{
20382
20603
  'is-fixed': isFixed
20383
20604
  }, 'vcm-tabs__bar']
20384
- }, [vue.createVNode("slot", {
20605
+ }, [vue.createVNode(vue.resolveComponent("slot"), {
20385
20606
  "name": "prepend"
20386
20607
  }, null), slots.prepend?.(), props.showStep && tabs.scrollable.value && vue.createVNode("div", {
20387
20608
  "class": "vcm-tabs__step is-left",
@@ -23509,6 +23730,7 @@ const UploadPicker = /* @__PURE__ */ vue.defineComponent({
23509
23730
  const MUploadPicker = UploadPicker;
23510
23731
 
23511
23732
  exports.ActionSheet = ActionSheet;
23733
+ exports.Affix = Affix;
23512
23734
  exports.Alert = Alert;
23513
23735
  exports.Artboard = Artboard;
23514
23736
  exports.Button = Button;
@@ -23553,6 +23775,7 @@ exports.InputSearch = InputSearch;
23553
23775
  exports.List = MList;
23554
23776
  exports.ListItem = MListItem;
23555
23777
  exports.MActionSheet = MActionSheet;
23778
+ exports.MAffix = MAffix;
23556
23779
  exports.MAlert = MAlert;
23557
23780
  exports.MArtboard = MArtboard;
23558
23781
  exports.MButton = MButton;