@varlet/ui 2.9.3 → 2.9.4-alpha.1679850560801

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.1679850560801'
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.1679850560801'
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 {
@@ -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,14 @@ 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');
109
110
  } // example 1rem
110
111
 
111
112
  export var isRem = value => isString(value) && value.endsWith('rem'); // e.g. 1 || 1px
@@ -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
+ }