@varlet/ui 2.11.3-alpha.1685455534947 → 2.11.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.
@@ -6,7 +6,7 @@ import { defineComponent, ref, computed, watch, onUnmounted, onDeactivated, onAc
6
6
  import { useSwipeItems } from './provide.mjs';
7
7
  import { doubleRaf, nextTickFrame } from '../utils/elements.mjs';
8
8
  import { props } from './props.mjs';
9
- import { isNumber, toNumber } from '@varlet/shared';
9
+ import { clamp, isNumber, toNumber } from '@varlet/shared';
10
10
  import { call, createNamespace } from '../utils/components.mjs';
11
11
  import { useEventListener } from '@varlet/use';
12
12
  var SWIPE_DELAY = 250;
@@ -158,20 +158,20 @@ var __sfc__ = defineComponent({
158
158
  return swipeIndex;
159
159
  };
160
160
 
161
- var boundaryIndex = index => {
162
- var {
163
- loop
164
- } = props;
161
+ var clampIndex = index => {
162
+ if (props.loop) {
163
+ if (index < 0) {
164
+ return length.value + index;
165
+ }
165
166
 
166
- if (index < 0) {
167
- return loop ? length.value - 1 : 0;
168
- }
167
+ if (index >= length.value) {
168
+ return index - length.value;
169
+ }
169
170
 
170
- if (index > length.value - 1) {
171
- return loop ? 0 : length.value - 1;
171
+ return index;
172
172
  }
173
173
 
174
- return index;
174
+ return clamp(index, 0, length.value - 1);
175
175
  };
176
176
 
177
177
  var fixPosition = fn => {
@@ -199,7 +199,7 @@ var __sfc__ = defineComponent({
199
199
  return;
200
200
  }
201
201
 
202
- index.value = boundaryIndex(toNumber(props.initialIndex));
202
+ index.value = clampIndex(toNumber(props.initialIndex));
203
203
  initializedIndex = true;
204
204
  };
205
205
 
@@ -337,7 +337,7 @@ var __sfc__ = defineComponent({
337
337
  onChange
338
338
  } = props;
339
339
  var currentIndex = index.value;
340
- index.value = boundaryIndex(currentIndex + 1);
340
+ index.value = clampIndex(currentIndex + 1);
341
341
 
342
342
  if ((options == null ? void 0 : options.event) !== false) {
343
343
  call(onChange, index.value);
@@ -368,7 +368,7 @@ var __sfc__ = defineComponent({
368
368
  onChange
369
369
  } = props;
370
370
  var currentIndex = index.value;
371
- index.value = boundaryIndex(currentIndex - 1);
371
+ index.value = clampIndex(currentIndex - 1);
372
372
 
373
373
  if ((options == null ? void 0 : options.event) !== false) {
374
374
  call(onChange, index.value);
package/es/tabs/Tabs.mjs CHANGED
@@ -6,7 +6,7 @@ import VarSticky from '../sticky/index.mjs';
6
6
  import { defineComponent, watch, ref, computed, Transition, onActivated } from 'vue';
7
7
  import { props } from './props.mjs';
8
8
  import { useTabList } from './provide.mjs';
9
- import { isNumber } from '@varlet/shared';
9
+ import { clamp, isNumber } from '@varlet/shared';
10
10
  import { linear } from '../utils/shared.mjs';
11
11
  import { toSizeUnit, scrollTo, doubleRaf } from '../utils/elements.mjs';
12
12
  import { createNamespace, call, formatElevation } from '../utils/components.mjs';
@@ -131,7 +131,7 @@ var __sfc__ = defineComponent({
131
131
  } = props;
132
132
 
133
133
  if (isNumber(active)) {
134
- var activeIndex = active > length.value - 1 ? length.value - 1 : 0;
134
+ var activeIndex = clamp(active, 0, length.value - 1);
135
135
  call(props['onUpdate:active'], activeIndex);
136
136
  return matchIndex(activeIndex);
137
137
  }
@@ -1,6 +1,8 @@
1
1
  export default {
2
2
  '--picker-background': '#1e1e1e',
3
3
  '--picker-cancel-button-text-color': '#aaa',
4
+ '--picker-title-text-color': '#fff',
5
+ '--picker-option-text-color': '#fff',
4
6
  '--picker-picked-border': '1px solid rgba(255, 255, 255, 0.12)',
5
7
  '--picker-mask-background-image': 'linear-gradient(180deg, hsla(0, 0%, 12%, 0.9), hsla(0, 0%, 12%, 0.4)), linear-gradient(0deg, hsla(0, 0%, 12%, 0.9), hsla(0, 0%, 12%, 0.4))'
6
8
  };