@varlet/ui 2.9.3 → 2.9.4-alpha.1679927847009

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,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { BOTTOM_NAVIGATION_BIND_BOTTOM_NAVIGATION_ITEM_KEY } from '../bottom-navigation/provide.mjs';
3
4
  export function useBottomNavigation() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useBottomNavigation() {
8
9
  } = useParent(BOTTOM_NAVIGATION_BIND_BOTTOM_NAVIGATION_ITEM_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('<var-bottom-navigation-item/> must in <var-bottom-navigation/>');
12
+ error('BottomNavigationItem', '<var-bottom-navigation-item/> must in <var-bottom-navigation/>');
12
13
  }
13
14
 
14
15
  return {
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { BREADCRUMBS_BIND_BREADCRUMB_ITEM_KEY } from '../breadcrumbs/provide.mjs';
3
4
  export function useBreadcrumb() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useBreadcrumb() {
8
9
  } = useParent(BREADCRUMBS_BIND_BREADCRUMB_ITEM_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('<var-breadcrumb/> must in <var-breadcrumbs/>');
12
+ error('Breadcrumb', '<var-breadcrumb/> must in <var-breadcrumbs/>');
12
13
  }
13
14
 
14
15
  return {
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { COLLAPSE_BIND_COLLAPSE_ITEM_KEY } from '../collapse/provide.mjs';
3
4
  export function useCollapse() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useCollapse() {
8
9
  } = useParent(COLLAPSE_BIND_COLLAPSE_ITEM_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('[Varlet] Collapse: <var-collapse-item/> must in <var-collapse>');
12
+ error('Collapse', '<var-collapse-item/> must in <var-collapse>');
12
13
  }
13
14
 
14
15
  return {
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { INDEX_BAR_BIND_INDEX_ANCHOR_KEY } from '../index-bar/provide.mjs';
3
4
  export function useIndexBar() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useIndexBar() {
8
9
  } = useParent(INDEX_BAR_BIND_INDEX_ANCHOR_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('[Varlet] IndexAnchor: You should use this component in "IndexBar"');
12
+ error('IndexAnchor', 'You should use this component in "IndexBar"');
12
13
  }
13
14
 
14
15
  return {
@@ -241,7 +241,7 @@ import './time-picker/style/index.mjs'
241
241
  import './tooltip/style/index.mjs'
242
242
  import './uploader/style/index.mjs'
243
243
 
244
- const version = '2.9.3'
244
+ const version = '2.9.4-alpha.1679927847009'
245
245
 
246
246
  function install(app) {
247
247
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -160,7 +160,7 @@ export * from './time-picker/index.mjs'
160
160
  export * from './tooltip/index.mjs'
161
161
  export * from './uploader/index.mjs'
162
162
 
163
- const version = '2.9.3'
163
+ const version = '2.9.4-alpha.1679927847009'
164
164
 
165
165
  function install(app) {
166
166
  ActionSheet.install && app.use(ActionSheet)
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { SELECT_BIND_OPTION_KEY } from '../select/provide.mjs';
3
4
  export function useSelect() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useSelect() {
8
9
  } = useParent(SELECT_BIND_OPTION_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('<var-option/> must in <var-select/>');
12
+ error('Option', '<var-option/> must in <var-select/>');
12
13
  }
13
14
 
14
15
  return {
@@ -3,7 +3,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
3
3
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
4
 
5
5
  import VarIcon from '../icon/index.mjs';
6
- import { defineComponent, ref, computed, watch } from 'vue';
6
+ import { defineComponent, ref, computed, watch, nextTick } from 'vue';
7
7
  import { getParentScroller, getScrollTop, getTarget } from '../utils/elements.mjs';
8
8
  import { props } from './props.mjs';
9
9
  import { isString, toNumber } from '@varlet/shared';
@@ -150,7 +150,9 @@ var __sfc__ = defineComponent({
150
150
  refreshStatus.value = 'loading';
151
151
  distance.value = maxDistance.value * 0.3;
152
152
  call(props['onUpdate:modelValue'], true);
153
- call(props.onRefresh);
153
+ nextTick(() => {
154
+ call(props.onRefresh);
155
+ });
154
156
  lockEvent('remove');
155
157
  } else {
156
158
  refreshStatus.value = 'loosing';
@@ -9,6 +9,7 @@ import { useValidation, createNamespace, call } from '../utils/components.mjs';
9
9
  import { useOptions } from './provide.mjs';
10
10
  import { useForm } from '../form/provide.mjs';
11
11
  import { toPxNum } from '../utils/elements.mjs';
12
+ import { error } from '../utils/logger.mjs';
12
13
  var {
13
14
  n,
14
15
  classes
@@ -466,7 +467,7 @@ var __sfc__ = defineComponent({
466
467
  } = props;
467
468
 
468
469
  if (multiple && !isArray(modelValue)) {
469
- throw Error('The modelValue must be an array when multiple is true');
470
+ error('Select', 'The modelValue must be an array when multiple is true');
470
471
  }
471
472
  });
472
473
  watch(() => props.modelValue, syncOptions, {
@@ -5,6 +5,7 @@ import { useForm } from '../form/provide.mjs';
5
5
  import VarHoverOverlay, { useHoverOverlay } from '../hover-overlay/index.mjs';
6
6
  import Hover from '../hover/index.mjs';
7
7
  import { getLeft, multiplySizeUnit } from '../utils/elements.mjs';
8
+ import { warn } from '../utils/logger.mjs';
8
9
  import { isArray, isNumber, toNumber } from '@varlet/shared';
9
10
  import { props, Thumbs } from './props.mjs';
10
11
  import { useMounted } from '@varlet/use';
@@ -338,12 +339,12 @@ var __sfc__ = defineComponent({
338
339
  var stepNumber = toNumber(props.step);
339
340
 
340
341
  if (isNaN(stepNumber)) {
341
- console.warn('[Varlet] Slider: type of prop "step" should be Number');
342
+ warn('Slider', 'type of prop "step" should be Number');
342
343
  return false;
343
344
  }
344
345
 
345
346
  if (stepNumber < 0) {
346
- console.warn('[Varlet] Slider: "step" should be > 0');
347
+ warn('Slider', '"step" should be > 0');
347
348
  return false;
348
349
  }
349
350
 
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { STEPS_BIND_STEP_KEY } from '../steps/provide.mjs';
3
4
  export function useSteps() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useSteps() {
8
9
  } = useParent(STEPS_BIND_STEP_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('[Varlet] Steps: <step/> must in <steps>');
12
+ error('Steps', '<step/> must in <steps>');
12
13
  }
13
14
 
14
15
  return {
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { SWIPE_BIND_SWIPE_ITEM_KEY } from '../swipe/provide.mjs';
3
4
  export function useSwipe() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useSwipe() {
8
9
  } = useParent(SWIPE_BIND_SWIPE_ITEM_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('<var-swipe-item/> must in <var-swipe/>');
12
+ error('SwipeItem', '<var-swipe-item/> must in <var-swipe/>');
12
13
  }
13
14
 
14
15
  return {
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { TABS_BIND_TAB_KEY } from '../tabs/provide.mjs';
3
4
  export function useTabs() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useTabs() {
8
9
  } = useParent(TABS_BIND_TAB_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('<var-tab/> must in <var-tabs/>');
12
+ error('Tab', '<var-tab/> must in <var-tabs/>');
12
13
  }
13
14
 
14
15
  return {
@@ -1,4 +1,5 @@
1
1
  import { useParent } from '@varlet/use';
2
+ import { error } from '../utils/logger.mjs';
2
3
  import { TABS_ITEMS_BIND_TAB_ITEM_KEY } from '../tabs-items/provide.mjs';
3
4
  export function useTabsItems() {
4
5
  var {
@@ -8,7 +9,7 @@ export function useTabsItems() {
8
9
  } = useParent(TABS_ITEMS_BIND_TAB_ITEM_KEY);
9
10
 
10
11
  if (!bindParent) {
11
- throw Error('<var-tab-item/> must in <var-tabs-items/>');
12
+ error('TabItem', '<var-tab-item/> must in <var-tabs-items/>');
12
13
  }
13
14
 
14
15
  return {
@@ -4,6 +4,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
4
4
 
5
5
  import { isNumber, isObject, isString, kebabCase, toNumber } from '@varlet/shared';
6
6
  import { getGlobalThis } from './shared.mjs';
7
+ import { error } from '../utils/logger.mjs';
7
8
  export function getLeft(element) {
8
9
  var {
9
10
  left
@@ -98,14 +99,27 @@ export function getTarget(target, componentName) {
98
99
  var el = document.querySelector(target);
99
100
 
100
101
  if (!el) {
101
- throw Error("[Varlet] " + componentName + ": target element cannot found");
102
+ error(componentName, 'target element cannot found');
102
103
  }
103
104
 
104
105
  return el;
105
106
  }
106
107
 
107
108
  if (isObject(target)) return target;
108
- throw Error("[Varlet] " + componentName + ": type of prop \"target\" should be a selector or an element object");
109
+ error(componentName, 'type of prop "target" should be a selector or an element object');
110
+ }
111
+ export function getViewportSize() {
112
+ var {
113
+ innerWidth,
114
+ innerHeight
115
+ } = window;
116
+ return innerWidth > innerHeight ? {
117
+ vMin: innerHeight,
118
+ vMax: innerWidth
119
+ } : {
120
+ vMin: innerWidth,
121
+ vMax: innerHeight
122
+ };
109
123
  } // example 1rem
110
124
 
111
125
  export var isRem = value => isString(value) && value.endsWith('rem'); // e.g. 1 || 1px
@@ -116,7 +130,11 @@ export var isPercent = value => isString(value) && value.endsWith('%'); // e.g.
116
130
 
117
131
  export var isVw = value => isString(value) && value.endsWith('vw'); // e.g. 1vh
118
132
 
119
- export var isVh = value => isString(value) && value.endsWith('vh'); // e.g. calc(1px + 1px)
133
+ export var isVh = value => isString(value) && value.endsWith('vh'); // e.g. 1vmin
134
+
135
+ export var isVMin = value => isString(value) && value.endsWith('vmin'); // e.g. 1vmax
136
+
137
+ export var isVMax = value => isString(value) && value.endsWith('vmax'); // e.g. calc(1px + 1px)
120
138
 
121
139
  export var isCalc = value => isString(value) && value.startsWith('calc('); // e.g. var(--color-primary)
122
140
 
@@ -145,6 +163,14 @@ export var toPxNum = value => {
145
163
  return num * parseFloat(rootFontSize);
146
164
  }
147
165
 
166
+ if (isVMin(value)) {
167
+ return getViewportSize().vMin;
168
+ }
169
+
170
+ if (isVMax(value)) {
171
+ return getViewportSize().vMax;
172
+ }
173
+
148
174
  if (isString(value)) {
149
175
  return toNumber(value);
150
176
  } // % and other
@@ -158,7 +184,7 @@ export var toSizeUnit = value => {
158
184
  return undefined;
159
185
  }
160
186
 
161
- if (isPercent(value) || isVw(value) || isVh(value) || isRem(value) || isCalc(value) || isVar(value)) {
187
+ if (isPercent(value) || isVw(value) || isVh(value) || isRem(value) || isCalc(value) || isVar(value) || isVMin(value) || isVMax(value)) {
162
188
  return value;
163
189
  }
164
190
 
@@ -0,0 +1,6 @@
1
+ export function error(source, message) {
2
+ throw Error("Varlet [" + source + "]: " + message);
3
+ }
4
+ export function warn(source, message) {
5
+ console.warn("Varlet [" + source + "]: " + message);
6
+ }