@deot/vc-components 1.0.43 → 1.0.45

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.js CHANGED
@@ -1,10 +1,10 @@
1
- import { reactive, defineComponent, createVNode, ref, watch, getCurrentInstance, computed, TransitionGroup, Transition as Transition$1, h, onMounted, onBeforeUnmount, inject, provide, nextTick, mergeProps, withModifiers, createApp, Fragment as Fragment$1, Teleport, onUnmounted, withDirectives, vShow, shallowRef, isVNode, onBeforeMount, createTextVNode, toRaw, onUpdated, useAttrs as useAttrs$1 } from 'vue';
1
+ import { reactive, defineComponent, createVNode, inject, shallowRef, ref, computed, onMounted, onBeforeUnmount, watch, getCurrentInstance, TransitionGroup, Transition as Transition$1, h, provide, nextTick, mergeProps, withModifiers, createApp, Fragment as Fragment$1, Teleport, onUnmounted, withDirectives, vShow, isVNode, onBeforeMount, createTextVNode, toRaw, onUpdated, resolveComponent, useAttrs as useAttrs$1 } from 'vue';
2
+ import * as $ from '@deot/helper-dom';
3
+ import { getScroller, composedPath, scrollIntoView, prefixStyle, getStyle, removeClass, addClass, hasClass } from '@deot/helper-dom';
2
4
  import * as Utils from '@deot/helper-utils';
3
5
  import { raf, getUid, preZero, getPropByPath, throttle as throttle$1, hasOwn } from '@deot/helper-utils';
4
6
  import { debounce, cloneDeep, pick, isEqualWith, startCase, throttle, concat, max, merge, isEmpty as isEmpty$1, kebabCase, difference } from 'lodash-es';
5
7
  import { useAttrs, useScrollbar, getInstance } from '@deot/vc-hooks';
6
- import * as $ from '@deot/helper-dom';
7
- import { composedPath, scrollIntoView, prefixStyle, getStyle, removeClass, addClass, hasClass } from '@deot/helper-dom';
8
8
  import { Resize } from '@deot/helper-resize';
9
9
  import { Utils as Utils$1, IS_SERVER as IS_SERVER$1 } from '@deot/vc-shared';
10
10
  import { Wheel } from '@deot/helper-wheel';
@@ -79,7 +79,7 @@ class Instance {
79
79
  }
80
80
  const VcInstance = new Instance();
81
81
 
82
- const props$1s = {
82
+ const props$1t = {
83
83
  tag: {
84
84
  type: String,
85
85
  default: "div"
@@ -88,10 +88,10 @@ const props$1s = {
88
88
 
89
89
  /** @jsxImportSource vue */
90
90
 
91
- const COMPONENT_NAME$27 = 'vc-action-sheet';
91
+ const COMPONENT_NAME$28 = 'vc-action-sheet';
92
92
  const ActionSheet = /* @__PURE__ */ defineComponent({
93
- name: COMPONENT_NAME$27,
94
- props: props$1s,
93
+ name: COMPONENT_NAME$28,
94
+ props: props$1t,
95
95
  setup(props, {
96
96
  slots
97
97
  }) {
@@ -105,6 +105,184 @@ const ActionSheet = /* @__PURE__ */ defineComponent({
105
105
 
106
106
  const MActionSheet = ActionSheet;
107
107
 
108
+ const props$1s = {
109
+ zIndex: {
110
+ type: [Number, String],
111
+ default: 1
112
+ },
113
+ // TODO: left/right
114
+ placement: {
115
+ type: String,
116
+ default: "top"
117
+ },
118
+ disabled: {
119
+ type: Boolean,
120
+ default: false
121
+ },
122
+ fixed: {
123
+ type: Boolean,
124
+ default: true
125
+ },
126
+ offset: {
127
+ type: Number,
128
+ default: 0
129
+ },
130
+ // -> 固钉始终保持在容器内, 超过范围则隐藏(请注意容器避免出现滚动条) 仅fixed为true有效
131
+ target: {
132
+ type: String
133
+ }
134
+ };
135
+
136
+ /** @jsxImportSource vue */
137
+
138
+ const COMPONENT_NAME$27 = 'vc-affix';
139
+ const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
140
+ const Affix = /* @__PURE__ */ defineComponent({
141
+ name: COMPONENT_NAME$27,
142
+ props: props$1s,
143
+ setup(props, {
144
+ slots,
145
+ expose
146
+ }) {
147
+ const scrollerInstance = inject('vc-scroller', null);
148
+ const scroller = shallowRef(); // 当前元素所在的滚动容器
149
+ const base = shallowRef(); // 当前元素(props.tagret)的参考容器
150
+ const current = shallowRef(); // 当前元素
151
+
152
+ const currentRect = reactive({
153
+ top: 0,
154
+ bottom: 0,
155
+ width: 0,
156
+ height: 0
157
+ });
158
+ const isActive = ref(false);
159
+ const transformY = ref(0);
160
+ const windowHeight = ref(window.innerHeight);
161
+ const isVcScrollerWheel = computed(() => {
162
+ return SCROLLER_WHEEL_REG.test(scroller.value?.className || '');
163
+ });
164
+ const currentStyle = computed(() => {
165
+ if (!isActive.value) return {};
166
+ return {
167
+ height: `${currentRect.height}px`,
168
+ width: `${currentRect.width}px`
169
+ };
170
+ });
171
+ const contentStyle = computed(() => {
172
+ if (!isActive.value) return {};
173
+ const offset = `${props.offset}px`;
174
+ return {
175
+ height: `${currentRect.height}px`,
176
+ width: `${currentRect.width}px`,
177
+ top: props.placement === 'top' ? offset : '',
178
+ bottom: props.placement === 'bottom' ? offset : '',
179
+ zIndex: props.zIndex,
180
+ transform: transformY.value ? `translateY(${transformY.value}px)` : ''
181
+ };
182
+ });
183
+ const setCurrentRect = () => {
184
+ const rect = current.value.getBoundingClientRect();
185
+ Object.assign(currentRect, {
186
+ top: rect.top,
187
+ bottom: rect.bottom,
188
+ width: rect.width,
189
+ height: rect.height
190
+ });
191
+ };
192
+ const setAbsoluteStatus = () => {
193
+ const {
194
+ placement,
195
+ offset
196
+ } = props;
197
+ const currentHeightOffset = offset + currentRect.height;
198
+ const containerRect = scroller.value.getBoundingClientRect();
199
+ let transformOffsetY = 0;
200
+
201
+ // scroller-wheel滚动条偏移
202
+ if (scrollerInstance && isVcScrollerWheel.value) {
203
+ const maxMoveY = scrollerInstance.scrollHeight - scrollerInstance.clientHeight;
204
+ transformOffsetY = scrollerInstance.scrollTop >= maxMoveY ? maxMoveY : scrollerInstance.scrollTop;
205
+ }
206
+ if (placement === 'top') {
207
+ isActive.value = currentRect.top - containerRect.top <= props.offset;
208
+ transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0) + transformOffsetY;
209
+ } else {
210
+ isActive.value = currentRect.bottom - containerRect.top >= containerRect.height - props.offset;
211
+ transformY.value = Math.max(containerRect.height - containerRect.top - currentHeightOffset, 0) + transformOffsetY;
212
+ }
213
+ };
214
+ const setFixedStatus = () => {
215
+ const {
216
+ placement,
217
+ target,
218
+ offset
219
+ } = props;
220
+ const currentHeightOffset = offset + currentRect.height;
221
+ const containerRect = target && base.value.getBoundingClientRect();
222
+ if (placement === 'top') {
223
+ if (target) {
224
+ isActive.value = offset > currentRect.top && containerRect.bottom > 0;
225
+ transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0);
226
+ } else {
227
+ isActive.value = offset > currentRect.top;
228
+ }
229
+ } else {
230
+ if (target) {
231
+ isActive.value = windowHeight.value - offset < currentRect.bottom && windowHeight.value > containerRect.top;
232
+ transformY.value = -Math.min(windowHeight.value - containerRect.top - currentHeightOffset, 0);
233
+ } else {
234
+ isActive.value = windowHeight.value - offset < currentRect.bottom;
235
+ }
236
+ }
237
+ };
238
+ const refresh = () => {
239
+ setCurrentRect();
240
+ scroller.value instanceof Window || props.fixed ? setFixedStatus() : setAbsoluteStatus();
241
+ };
242
+ onMounted(() => {
243
+ if (typeof props.target === 'string') {
244
+ base.value = document.querySelector(props.target) ?? void 0;
245
+ }
246
+ !base.value && (base.value = document.documentElement);
247
+ scroller.value = getScroller(current.value, {
248
+ className: SCROLLER_WHEEL_REG
249
+ });
250
+ if (isVcScrollerWheel.value) {
251
+ scrollerInstance?.on(refresh);
252
+ } else {
253
+ scroller.value?.addEventListener('scroll', refresh);
254
+ }
255
+ refresh();
256
+ });
257
+ onBeforeUnmount(() => {
258
+ if (isVcScrollerWheel.value) {
259
+ scrollerInstance?.off(refresh);
260
+ } else {
261
+ scroller.value?.removeEventListener('scroll', refresh);
262
+ }
263
+ });
264
+ expose({
265
+ refresh
266
+ });
267
+ return () => {
268
+ return createVNode("div", {
269
+ "ref": current,
270
+ "class": "vc-affix",
271
+ "style": currentStyle.value
272
+ }, [createVNode("div", {
273
+ "class": {
274
+ [`vc-affix__${props.fixed ? 'fixed' : 'absolute'}`]: isActive.value
275
+ },
276
+ "style": contentStyle.value
277
+ }, [slots?.default?.({
278
+ active: isActive.value
279
+ })])]);
280
+ };
281
+ }
282
+ });
283
+
284
+ const MAffix = Affix;
285
+
108
286
  const props$1r = {
109
287
  modelValue: {
110
288
  type: Boolean,
@@ -791,7 +969,7 @@ const COMPONENT_NAME$1$ = 'vc-alert';
791
969
 
792
970
  // [color, borderColor, backgroundColor], -> CSS
793
971
  const THEME_MAP = {
794
- info: ['#2B72FD', '#91d5ff', '#e6f7ff'],
972
+ info: ['#456CF6', '#91d5ff', '#e6f7ff'],
795
973
  success: ['#52c41a', '#b7eb8f', '#f6ffed'],
796
974
  error: ['#ed4014', '#ffb08f', '#fbe9e9'],
797
975
  warning: ['#ffbf00', '#ffe58f', '#fffbe6']
@@ -9128,6 +9306,7 @@ const useScroller = (expose) => {
9128
9306
  refreshSize();
9129
9307
  refreshPosition(options);
9130
9308
  };
9309
+ const listeners = [];
9131
9310
  const triggerScrollDelegate = (options) => {
9132
9311
  const delegates = {
9133
9312
  scrollLeft: (options && options.x) ?? scrollX.value,
@@ -9135,12 +9314,15 @@ const useScroller = (expose) => {
9135
9314
  clientWidth: wrapperW.value,
9136
9315
  clientHeight: wrapperH.value,
9137
9316
  scrollWidth: contentW.value,
9138
- scrollHeight: contentH.value
9317
+ scrollHeight: contentH.value,
9318
+ getBoundingClientRect: () => wrapper.value?.getBoundingClientRect()
9139
9319
  };
9140
- instance.emit("scroll", {
9320
+ const e = {
9141
9321
  target: delegates,
9142
9322
  currentTarget: delegates
9143
- });
9323
+ };
9324
+ instance.emit("scroll", e);
9325
+ listeners.forEach((listener) => listener(e));
9144
9326
  };
9145
9327
  const scrollTo = (options) => {
9146
9328
  refreshPosition(options);
@@ -9167,8 +9349,9 @@ const useScroller = (expose) => {
9167
9349
  Resize.off(wrapper.value, refresh);
9168
9350
  Resize.off(content.value, refresh);
9169
9351
  }
9352
+ listeners.splice(0, listeners.length);
9170
9353
  });
9171
- expose({
9354
+ const exposed = {
9172
9355
  wrapper,
9173
9356
  content,
9174
9357
  scrollTo,
@@ -9184,8 +9367,16 @@ const useScroller = (expose) => {
9184
9367
  },
9185
9368
  setScrollLeft: (value) => {
9186
9369
  scrollTo({ x: value });
9370
+ },
9371
+ on: (listener) => {
9372
+ listeners.push(listener);
9373
+ },
9374
+ off: (listener) => {
9375
+ listeners.splice(listeners.indexOf(listener), 1);
9187
9376
  }
9188
- });
9377
+ };
9378
+ expose(exposed);
9379
+ provide("vc-scroller", reactive(exposed));
9189
9380
  return {
9190
9381
  bar,
9191
9382
  wrapper,
@@ -14842,7 +15033,7 @@ const props$n = {
14842
15033
  color: {
14843
15034
  type: [Object, String],
14844
15035
  default: () => ({
14845
- normal: "#2B72FD",
15036
+ normal: "#456CF6",
14846
15037
  success: "#52c41a",
14847
15038
  error: "#f5222d"
14848
15039
  })
@@ -19790,6 +19981,7 @@ const useTabs = (options = {}) => {
19790
19981
  emit("update:modelValue", currentValue.value);
19791
19982
  emit("change", currentValue.value);
19792
19983
  emit("click", currentValue.value);
19984
+ nav.anchor && document.querySelector(nav.anchor)?.scrollIntoView?.({ behavior: "smooth" });
19793
19985
  };
19794
19986
  const handleResize = () => {
19795
19987
  if (instance.isUnmounted) return;
@@ -20042,12 +20234,16 @@ const Tabs = /* @__PURE__ */ defineComponent({
20042
20234
 
20043
20235
  const props$b = {
20044
20236
  value: {
20045
- type: [String, Number, Boolean]
20237
+ type: [String, Number, Boolean],
20238
+ default: void 0
20046
20239
  },
20047
20240
  label: {
20048
20241
  type: [String, Function],
20049
20242
  default: ""
20050
20243
  },
20244
+ anchor: {
20245
+ type: String
20246
+ },
20051
20247
  /**
20052
20248
  * 服务端渲染时,lazy设置为false,可以把内容渲染出来;
20053
20249
  * 不能设置为!IS_SERVER, 会影响客服端激活,不一样会存在问题
@@ -20390,7 +20586,7 @@ const MTabs = /* @__PURE__ */ defineComponent({
20390
20586
  "class": [{
20391
20587
  'is-fixed': isFixed
20392
20588
  }, 'vcm-tabs__bar']
20393
- }, [createVNode("slot", {
20589
+ }, [createVNode(resolveComponent("slot"), {
20394
20590
  "name": "prepend"
20395
20591
  }, null), slots.prepend?.(), props.showStep && tabs.scrollable.value && createVNode("div", {
20396
20592
  "class": "vcm-tabs__step is-left",
@@ -20504,6 +20700,10 @@ const props$9 = {
20504
20700
  default: (props$) => {
20505
20701
  return props$.value;
20506
20702
  }
20703
+ },
20704
+ theme: {
20705
+ type: String,
20706
+ default: "dark"
20507
20707
  }
20508
20708
  };
20509
20709
 
@@ -20556,7 +20756,7 @@ const Text = /* @__PURE__ */ defineComponent({
20556
20756
  // 确保不重复创建
20557
20757
  triggerEl: e.target,
20558
20758
  hover: true,
20559
- theme: 'dark',
20759
+ theme: props.theme,
20560
20760
  placement: props.placement,
20561
20761
  portalClass: props.portalClass,
20562
20762
  portalStyle: [props.portalStyle || `width: ${e.target.clientWidth}px`, 'word-break: break-all'],
@@ -23517,4 +23717,4 @@ const UploadPicker = /* @__PURE__ */ defineComponent({
23517
23717
 
23518
23718
  const MUploadPicker = UploadPicker;
23519
23719
 
23520
- export { ActionSheet, Alert, Artboard, Button, ButtonGroup, Calendar, Card, Carousel, Cascader, Chart, Checkbox, CheckboxGroup, Clipboard, Collapse, CollapseItem, ColorPicker, Countdown, Customer, DatePicker, Debounce, Divider, Drawer, DrawerView, Dropdown, DropdownItem, DropdownMenu, Editor, EditorView, Expand$1 as Expand, Form, FormItem, Fragment, HTMLToImage, Icon, IconManager, Image$1 as Image, ImageCrop, ImagePreview, ImageProcessing, Input, InputNumber, InputSearch, MList as List, MListItem as ListItem, MActionSheet, MAlert, MArtboard, MButton, MButtonGroup, MCalendar, MCard, MCarousel, MCascader, MChart, MCheckbox, MCheckboxGroup, MClipboard, MCollapse, MCollapseItem, MColorPicker, MCountdown, MCustomer, MDatePicker, Debounce as MDebounce, MDivider, MDrawer, MDrawerView, MDropdown, MDropdownItem, MDropdownMenu, MEditor, MExpand, MForm, MFormItem, MFragment, MHTMLToImage, MIcon, MImage, MImageCrop, MImagePreview, MImageProcessing, MInput, MInputNumber, MInputSearch, MList, MListItem, MMarquee, MMessage, modal as MModal, MModalView, MNotice, MOption, MPagination, MPicker, MPopconfirm, MPopover, MPopup, MPortal, MPrint, MProgress, MRadio, MRadioGroup, MRate, MRecycleList, MResizer, MScroller, MSelect, MSlider, MSortList, MSpin, MSteps, MSwitch, MTable, MTableColumn, MTabs, MTabsPane, MTag, MText, MTextarea, MTimePicker, MTimeline, MToast, MToastView, MTouch, MTransition, MTransitionCollapse, MTransitionFade, MTransitionScale, MTransitionSlide, MTransitionZoom, MTree, MTreeSelect, MUpload, MUploadPicker, Marquee, Message, MessageView, Modal, ModalView, Notice, NoticeView, Option$1 as Option, Pagination, Picker, Popconfirm, Popover, Popup, Portal, PortalView, Print, Progress, Radio, RadioGroup, Rate, RecycleList, Resizer, Scroller, ScrollerWheel, Select, Slider, SortList, Spin, Steps, Switch, Table, TableColumn, Tabs, TabsPane, Tag, Text, Textarea, Theme, ThemeImage, ThemeText, ThemeView, TimePicker, Timeline, Toast, ToastView, Touch, Transition, TransitionCollapse, TransitionFade, TransitionScale, TransitionSlide, TransitionZoom, Tree, TreeSelect, Upload, UploadPicker, VcError, VcInstance };
23720
+ export { ActionSheet, Affix, Alert, Artboard, Button, ButtonGroup, Calendar, Card, Carousel, Cascader, Chart, Checkbox, CheckboxGroup, Clipboard, Collapse, CollapseItem, ColorPicker, Countdown, Customer, DatePicker, Debounce, Divider, Drawer, DrawerView, Dropdown, DropdownItem, DropdownMenu, Editor, EditorView, Expand$1 as Expand, Form, FormItem, Fragment, HTMLToImage, Icon, IconManager, Image$1 as Image, ImageCrop, ImagePreview, ImageProcessing, Input, InputNumber, InputSearch, MList as List, MListItem as ListItem, MActionSheet, MAffix, MAlert, MArtboard, MButton, MButtonGroup, MCalendar, MCard, MCarousel, MCascader, MChart, MCheckbox, MCheckboxGroup, MClipboard, MCollapse, MCollapseItem, MColorPicker, MCountdown, MCustomer, MDatePicker, Debounce as MDebounce, MDivider, MDrawer, MDrawerView, MDropdown, MDropdownItem, MDropdownMenu, MEditor, MExpand, MForm, MFormItem, MFragment, MHTMLToImage, MIcon, MImage, MImageCrop, MImagePreview, MImageProcessing, MInput, MInputNumber, MInputSearch, MList, MListItem, MMarquee, MMessage, modal as MModal, MModalView, MNotice, MOption, MPagination, MPicker, MPopconfirm, MPopover, MPopup, MPortal, MPrint, MProgress, MRadio, MRadioGroup, MRate, MRecycleList, MResizer, MScroller, MSelect, MSlider, MSortList, MSpin, MSteps, MSwitch, MTable, MTableColumn, MTabs, MTabsPane, MTag, MText, MTextarea, MTimePicker, MTimeline, MToast, MToastView, MTouch, MTransition, MTransitionCollapse, MTransitionFade, MTransitionScale, MTransitionSlide, MTransitionZoom, MTree, MTreeSelect, MUpload, MUploadPicker, Marquee, Message, MessageView, Modal, ModalView, Notice, NoticeView, Option$1 as Option, Pagination, Picker, Popconfirm, Popover, Popup, Portal, PortalView, Print, Progress, Radio, RadioGroup, Rate, RecycleList, Resizer, Scroller, ScrollerWheel, Select, Slider, SortList, Spin, Steps, Switch, Table, TableColumn, Tabs, TabsPane, Tag, Text, Textarea, Theme, ThemeImage, ThemeText, ThemeView, TimePicker, Timeline, Toast, ToastView, Touch, Transition, TransitionCollapse, TransitionFade, TransitionScale, TransitionSlide, TransitionZoom, Tree, TreeSelect, Upload, UploadPicker, VcError, VcInstance };