@deot/vc-components 1.0.43 → 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
  })
@@ -20064,7 +20253,8 @@ const Tabs = /* @__PURE__ */ vue.defineComponent({
20064
20253
 
20065
20254
  const props$b = {
20066
20255
  value: {
20067
- type: [String, Number, Boolean]
20256
+ type: [String, Number, Boolean],
20257
+ default: void 0
20068
20258
  },
20069
20259
  label: {
20070
20260
  type: [String, Function],
@@ -20412,7 +20602,7 @@ const MTabs = /* @__PURE__ */ vue.defineComponent({
20412
20602
  "class": [{
20413
20603
  'is-fixed': isFixed
20414
20604
  }, 'vcm-tabs__bar']
20415
- }, [vue.createVNode("slot", {
20605
+ }, [vue.createVNode(vue.resolveComponent("slot"), {
20416
20606
  "name": "prepend"
20417
20607
  }, null), slots.prepend?.(), props.showStep && tabs.scrollable.value && vue.createVNode("div", {
20418
20608
  "class": "vcm-tabs__step is-left",
@@ -23540,6 +23730,7 @@ const UploadPicker = /* @__PURE__ */ vue.defineComponent({
23540
23730
  const MUploadPicker = UploadPicker;
23541
23731
 
23542
23732
  exports.ActionSheet = ActionSheet;
23733
+ exports.Affix = Affix;
23543
23734
  exports.Alert = Alert;
23544
23735
  exports.Artboard = Artboard;
23545
23736
  exports.Button = Button;
@@ -23584,6 +23775,7 @@ exports.InputSearch = InputSearch;
23584
23775
  exports.List = MList;
23585
23776
  exports.ListItem = MListItem;
23586
23777
  exports.MActionSheet = MActionSheet;
23778
+ exports.MAffix = MAffix;
23587
23779
  exports.MAlert = MAlert;
23588
23780
  exports.MArtboard = MArtboard;
23589
23781
  exports.MButton = MButton;