@varlet/ui 2.6.2 → 2.6.3

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "2.6.1",
4
+ "version": "2.6.2",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -1 +1 @@
1
- :root { --app-bar-color: var(--color-primary); --app-bar-title-padding: 0 12px; --app-bar-text-color: #fff; --app-bar-height: 54px; --app-bar-left-gap: 6px; --app-bar-right-gap: 6px; --app-bar-border-radius: 4px;}.var-app-bar { position: relative; display: flex; width: 100%; justify-content: center; align-items: center; height: var(--app-bar-height); background: var(--app-bar-color); color: var(--app-bar-text-color); transition: background-color 0.25s;}.var-app-bar__title { flex: 1; display: flex; justify-content: center; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; padding: var(--app-bar-title-padding);}.var-app-bar__left,.var-app-bar__right { display: flex; align-items: center; height: 100%; z-index: 2;}.var-app-bar__left { position: absolute; top: 0; left: var(--app-bar-left-gap);}.var-app-bar__right { position: absolute; top: 0; right: var(--app-bar-right-gap);}.var-app-bar--round { border-radius: var(--app-bar-border-radius);}
1
+ :root { --app-bar-color: var(--color-primary); --app-bar-title-padding: 0 12px; --app-bar-title-font-size: var(--font-size-lg); --app-bar-text-color: #fff; --app-bar-height: 54px; --app-bar-left-gap: 6px; --app-bar-right-gap: 6px; --app-bar-border-radius: 4px; --app-bar-font-size: var(--font-size-lg);}.var-app-bar { position: relative; display: flex; width: 100%; font-size: var(--app-bar-font-size); justify-content: center; align-items: center; height: var(--app-bar-height); background: var(--app-bar-color); color: var(--app-bar-text-color); transition: background-color 0.25s;}.var-app-bar__title { font-size: var(--app-bar-title-font-size); flex: 1; display: flex; justify-content: center; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; padding: var(--app-bar-title-padding);}.var-app-bar__left,.var-app-bar__right { display: flex; align-items: center; height: 100%; z-index: 2;}.var-app-bar__left { position: absolute; top: 0; left: var(--app-bar-left-gap);}.var-app-bar__right { position: absolute; top: 0; right: var(--app-bar-right-gap);}.var-app-bar--round { border-radius: var(--app-bar-border-radius);}
@@ -48,7 +48,10 @@ function render(_ctx, _cache) {
48
48
  style: (0, _vue.normalizeStyle)({
49
49
  color: _ctx.active === anchorName && _ctx.highlightColor ? _ctx.highlightColor : ''
50
50
  }),
51
- onClick: $event => _ctx.anchorClick(anchorName, true)
51
+ onClick: $event => _ctx.anchorClick({
52
+ anchorName,
53
+ manualCall: true
54
+ })
52
55
  }, (0, _vue.toDisplayString)(anchorName), 15
53
56
  /* TEXT, CLASS, STYLE, PROPS */
54
57
  , _hoisted_1);
@@ -90,25 +93,40 @@ var _default = (0, _vue.defineComponent)({
90
93
  };
91
94
  bindIndexAnchors(indexBarProvider);
92
95
 
93
- var emitEvent = anchor => {
96
+ var emitEvent = (anchor, options) => {
94
97
  var anchorName = (0, _shared.isPlainObject)(anchor) ? anchor.name.value : anchor;
95
98
  if (anchorName === active.value || anchorName === undefined) return;
96
99
  active.value = anchorName;
97
- (0, _components.call)(props.onChange, anchorName);
100
+
101
+ if ((options == null ? void 0 : options.event) !== false) {
102
+ (0, _components.call)(props.onChange, anchorName);
103
+ }
104
+ };
105
+
106
+ var getOffsetTop = () => {
107
+ if (!('getBoundingClientRect' in scroller.value)) return 0;
108
+ var {
109
+ top: parentTop
110
+ } = scroller.value.getBoundingClientRect();
111
+ var {
112
+ scrollTop
113
+ } = scroller.value;
114
+ var {
115
+ top: targetTop
116
+ } = barEl.value.getBoundingClientRect();
117
+ return scrollTop - parentTop + targetTop;
98
118
  };
99
119
 
100
120
  var handleScroll = () => {
101
121
  var scrollTop = (0, _elements.getScrollTop)(scroller.value);
102
122
  var scrollHeight = scroller.value === window ? document.body.scrollHeight : scroller.value.scrollHeight;
103
- var {
104
- offsetTop
105
- } = barEl.value;
123
+ var offsetTop = getOffsetTop();
106
124
  indexAnchors.forEach((anchor, index) => {
107
125
  var anchorTop = anchor.ownTop.value;
108
126
  var top = scrollTop - anchorTop + stickyOffsetTop.value - offsetTop;
109
127
  var distance = index === indexAnchors.length - 1 ? scrollHeight : indexAnchors[index + 1].ownTop.value - anchor.ownTop.value;
110
128
 
111
- if (top >= 0 && top < distance && !clickedName.value) {
129
+ if (top >= 0 && top < distance && clickedName.value === '') {
112
130
  if (index && !props.cssMode) {
113
131
  indexAnchors[index - 1].setDisabled(true);
114
132
  }
@@ -120,23 +138,26 @@ var _default = (0, _vue.defineComponent)({
120
138
  };
121
139
 
122
140
  var anchorClick = /*#__PURE__*/function () {
123
- var _ref = _asyncToGenerator(function* (anchorName, manualCall) {
141
+ var _ref2 = _asyncToGenerator(function* (_ref) {
124
142
  var {
125
- offsetTop
126
- } = barEl.value;
143
+ anchorName,
144
+ manualCall = false,
145
+ options
146
+ } = _ref;
127
147
  if (manualCall) (0, _components.call)(props.onClick, anchorName);
128
148
  if (anchorName === active.value) return;
129
- var indexAnchor = indexAnchors.find(_ref2 => {
149
+ var indexAnchor = indexAnchors.find(_ref3 => {
130
150
  var {
131
151
  name
132
- } = _ref2;
152
+ } = _ref3;
133
153
  return anchorName === name.value;
134
154
  });
135
155
  if (!indexAnchor) return;
156
+ var offsetTop = getOffsetTop();
136
157
  var top = indexAnchor.ownTop.value - stickyOffsetTop.value + offsetTop;
137
158
  var left = (0, _elements.getScrollLeft)(scroller.value);
138
159
  clickedName.value = anchorName;
139
- emitEvent(anchorName);
160
+ emitEvent(anchorName, options);
140
161
  yield (0, _elements.scrollTo)(scroller.value, {
141
162
  left,
142
163
  top,
@@ -148,23 +169,26 @@ var _default = (0, _vue.defineComponent)({
148
169
  });
149
170
  });
150
171
 
151
- return function anchorClick(_x, _x2) {
152
- return _ref.apply(this, arguments);
172
+ return function anchorClick(_x) {
173
+ return _ref2.apply(this, arguments);
153
174
  };
154
175
  }(); // expose
155
176
 
156
177
 
157
- var scrollTo = index => {
158
- (0, _elements.requestAnimationFrame)(() => anchorClick(index));
178
+ var scrollTo = (index, options) => {
179
+ (0, _elements.requestAnimationFrame)(() => anchorClick({
180
+ anchorName: index,
181
+ options
182
+ }));
159
183
  };
160
184
 
161
185
  (0, _vue.watch)(() => length.value, /*#__PURE__*/_asyncToGenerator(function* () {
162
186
  yield (0, _elements.doubleRaf)();
163
- indexAnchors.forEach(_ref4 => {
187
+ indexAnchors.forEach(_ref5 => {
164
188
  var {
165
189
  name,
166
190
  setOwnTop
167
- } = _ref4;
191
+ } = _ref5;
168
192
  if (name.value) anchorNameList.value.push(name.value);
169
193
  setOwnTop();
170
194
  });
@@ -24,12 +24,6 @@ var {
24
24
  n,
25
25
  classes
26
26
  } = (0, _components.createNamespace)('slider');
27
- var Thumbs;
28
-
29
- (function (Thumbs) {
30
- Thumbs["First"] = "1";
31
- Thumbs["Second"] = "2";
32
- })(Thumbs || (Thumbs = {}));
33
27
 
34
28
  var _withScopeId = n => ((0, _vue.pushScopeId)(""), n = n(), (0, _vue.popScopeId)(), n);
35
29
 
@@ -156,8 +150,8 @@ var _default = (0, _vue.defineComponent)({
156
150
  var maxWidth = (0, _vue.ref)(0);
157
151
  var isScroll = (0, _vue.ref)(false);
158
152
  var thumbsProps = (0, _vue.reactive)({
159
- [Thumbs.First]: getThumbProps(),
160
- [Thumbs.Second]: getThumbProps()
153
+ [_props.Thumbs.First]: getThumbProps(),
154
+ [_props.Thumbs.Second]: getThumbProps()
161
155
  });
162
156
  var scope = (0, _vue.computed)(() => (0, _shared.toNumber)(props.max) - (0, _shared.toNumber)(props.min));
163
157
  var unitWidth = (0, _vue.computed)(() => maxWidth.value / scope.value * (0, _shared.toNumber)(props.step));
@@ -171,17 +165,17 @@ var _default = (0, _vue.defineComponent)({
171
165
  if (range && (0, _shared.isArray)(modelValue)) {
172
166
  list = [{
173
167
  value: getValue(modelValue[0]),
174
- enumValue: Thumbs.First,
168
+ enumValue: _props.Thumbs.First,
175
169
  text: toPrecision(modelValue[0])
176
170
  }, {
177
171
  value: getValue(modelValue[1]),
178
- enumValue: Thumbs.Second,
172
+ enumValue: _props.Thumbs.Second,
179
173
  text: toPrecision(modelValue[1])
180
174
  }];
181
175
  } else if ((0, _shared.isNumber)(modelValue)) {
182
176
  list = [{
183
177
  value: getValue(modelValue),
184
- enumValue: Thumbs.First,
178
+ enumValue: _props.Thumbs.First,
185
179
  text: toPrecision(modelValue)
186
180
  }];
187
181
  }
@@ -246,7 +240,7 @@ var _default = (0, _vue.defineComponent)({
246
240
  thumbsProps[type].percentValue = roundDistance;
247
241
 
248
242
  if (range && (0, _shared.isArray)(modelValue)) {
249
- rangeValue = type === Thumbs.First ? [curValue, modelValue[1]] : [modelValue[0], curValue];
243
+ rangeValue = type === _props.Thumbs.First ? [curValue, modelValue[1]] : [modelValue[0], curValue];
250
244
  }
251
245
 
252
246
  if (prevValue !== curValue) {
@@ -258,12 +252,12 @@ var _default = (0, _vue.defineComponent)({
258
252
  };
259
253
 
260
254
  var getType = offset => {
261
- if (!props.range) return Thumbs.First;
262
- var thumb1Distance = thumbsProps[Thumbs.First].percentValue * unitWidth.value;
263
- var thumb2Distance = thumbsProps[Thumbs.Second].percentValue * unitWidth.value;
255
+ if (!props.range) return _props.Thumbs.First;
256
+ var thumb1Distance = thumbsProps[_props.Thumbs.First].percentValue * unitWidth.value;
257
+ var thumb2Distance = thumbsProps[_props.Thumbs.Second].percentValue * unitWidth.value;
264
258
  var offsetToThumb1 = Math.abs(offset - thumb1Distance);
265
259
  var offsetToThumb2 = Math.abs(offset - thumb2Distance);
266
- return offsetToThumb1 <= offsetToThumb2 ? Thumbs.First : Thumbs.Second;
260
+ return offsetToThumb1 <= offsetToThumb2 ? _props.Thumbs.First : _props.Thumbs.Second;
267
261
  };
268
262
 
269
263
  var start = (event, type) => {
@@ -297,7 +291,7 @@ var _default = (0, _vue.defineComponent)({
297
291
  var curValue = thumbsProps[type].percentValue * (0, _shared.toNumber)(step) + (0, _shared.toNumber)(min);
298
292
 
299
293
  if (range && (0, _shared.isArray)(modelValue)) {
300
- rangeValue = type === Thumbs.First ? [curValue, modelValue[1]] : [modelValue[0], curValue];
294
+ rangeValue = type === _props.Thumbs.First ? [curValue, modelValue[1]] : [modelValue[0], curValue];
301
295
  }
302
296
 
303
297
  (0, _components.call)(onEnd, range ? rangeValue : curValue);
@@ -373,12 +367,12 @@ var _default = (0, _vue.defineComponent)({
373
367
  };
374
368
 
375
369
  if (props.range && (0, _shared.isArray)(modelValue)) {
376
- thumbsProps[Thumbs.First].percentValue = getPercent(modelValue[0]);
377
- thumbsProps[Thumbs.First].currentLeft = thumbsProps[Thumbs.First].percentValue * unitWidth.value;
378
- thumbsProps[Thumbs.Second].percentValue = getPercent(modelValue[1]);
379
- thumbsProps[Thumbs.Second].currentLeft = thumbsProps[Thumbs.Second].percentValue * unitWidth.value;
370
+ thumbsProps[_props.Thumbs.First].percentValue = getPercent(modelValue[0]);
371
+ thumbsProps[_props.Thumbs.First].currentLeft = thumbsProps[_props.Thumbs.First].percentValue * unitWidth.value;
372
+ thumbsProps[_props.Thumbs.Second].percentValue = getPercent(modelValue[1]);
373
+ thumbsProps[_props.Thumbs.Second].currentLeft = thumbsProps[_props.Thumbs.Second].percentValue * unitWidth.value;
380
374
  } else if ((0, _shared.isNumber)(modelValue)) {
381
- thumbsProps[Thumbs.First].currentLeft = getPercent(modelValue) * unitWidth.value;
375
+ thumbsProps[_props.Thumbs.First].currentLeft = getPercent(modelValue) * unitWidth.value;
382
376
  }
383
377
  };
384
378
 
@@ -407,7 +401,7 @@ var _default = (0, _vue.defineComponent)({
407
401
  return {
408
402
  n,
409
403
  classes,
410
- Thumbs,
404
+ Thumbs: _props.Thumbs,
411
405
  sliderEl,
412
406
  getFillStyle,
413
407
  isDisabled,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.props = void 0;
4
+ exports.props = exports.Thumbs = void 0;
5
5
 
6
6
  var _components = require("../utils/components");
7
7
 
@@ -9,6 +9,14 @@ function labelValidator(label) {
9
9
  return ['always', 'normal', 'never'].includes(label);
10
10
  }
11
11
 
12
+ var Thumbs;
13
+ exports.Thumbs = Thumbs;
14
+
15
+ (function (Thumbs) {
16
+ Thumbs["First"] = "1";
17
+ Thumbs["Second"] = "2";
18
+ })(Thumbs || (exports.Thumbs = Thumbs = {}));
19
+
12
20
  var props = {
13
21
  // 当前进度百分比
14
22
  modelValue: {
@@ -1,8 +1,8 @@
1
1
  require('../../styles/common.css')
2
- require('../SnackbarSfc.css')
3
2
  require('../../styles/elevation.css')
4
3
  require('../../loading/loading.css')
5
4
  require('../../button/button.css')
6
5
  require('../../icon/icon.css')
7
6
  require('../snackbar.css')
8
7
  require('../coreSfc.css')
8
+ require('../SnackbarSfc.css')