@varlet/ui 3.7.2 → 3.7.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.
@@ -3,5 +3,5 @@ import '../../icon/icon.css'
3
3
  import '../../ripple/ripple.css'
4
4
  import '../../popup/popup.css'
5
5
  import '../actionSheet.css'
6
- import '../ActionItemSfc.css'
7
6
  import '../ActionSheetSfc.css'
7
+ import '../ActionItemSfc.css'
@@ -1,5 +1,5 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import {
4
4
  BOTTOM_NAVIGATION_BIND_BOTTOM_NAVIGATION_ITEM_KEY
5
5
  } from "../bottom-navigation/provide.mjs";
@@ -7,9 +7,7 @@ function useBottomNavigation() {
7
7
  const { parentProvider, index, bindParent } = useParent(
8
8
  BOTTOM_NAVIGATION_BIND_BOTTOM_NAVIGATION_ITEM_KEY
9
9
  );
10
- if (!bindParent) {
11
- error("BottomNavigationItem", "<var-bottom-navigation-item/> must in <var-bottom-navigation/>");
12
- }
10
+ assert(!!bindParent, "BottomNavigationItem", "<var-bottom-navigation-item/> must in <var-bottom-navigation/>");
13
11
  return {
14
12
  index,
15
13
  bottomNavigation: parentProvider,
@@ -1,13 +1,11 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { BREADCRUMBS_BIND_BREADCRUMB_ITEM_KEY } from "../breadcrumbs/provide.mjs";
4
4
  function useBreadcrumb() {
5
5
  const { parentProvider, bindParent, index } = useParent(
6
6
  BREADCRUMBS_BIND_BREADCRUMB_ITEM_KEY
7
7
  );
8
- if (!bindParent) {
9
- error("Breadcrumb", "<var-breadcrumb/> must in <var-breadcrumbs/>");
10
- }
8
+ assert(!!bindParent, "Breadcrumb", "<var-breadcrumb/> must in <var-breadcrumbs/>");
11
9
  return {
12
10
  index,
13
11
  breadcrumb: parentProvider,
@@ -1,13 +1,11 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { COLLAPSE_BIND_COLLAPSE_ITEM_KEY } from "../collapse/provide.mjs";
4
4
  function useCollapse() {
5
5
  const { parentProvider, index, bindParent } = useParent(
6
6
  COLLAPSE_BIND_COLLAPSE_ITEM_KEY
7
7
  );
8
- if (!bindParent) {
9
- error("Collapse", "<var-collapse-item/> must in <var-collapse>");
10
- }
8
+ assert(!!bindParent, "Collapse", "<var-collapse-item/> must in <var-collapse>");
11
9
  return {
12
10
  index,
13
11
  collapse: parentProvider,
@@ -28,7 +28,7 @@ import {
28
28
  MONTH_LIST,
29
29
  WEEK_HEADER
30
30
  } from "./props.mjs";
31
- import { isArray, toNumber, doubleRaf, call } from "@varlet/shared";
31
+ import { isArray, toNumber, doubleRaf, call, error } from "@varlet/shared";
32
32
  import { createNamespace, formatElevation } from "../utils/components.mjs";
33
33
  import { padStart } from "../utils/shared.mjs";
34
34
  import { t } from "../locale/index.mjs";
@@ -562,19 +562,21 @@ const __sfc__ = defineComponent({
562
562
  }
563
563
  function checkValue() {
564
564
  if ((props2.multiple || props2.range) && !isArray(props2.modelValue)) {
565
- console.error('[Varlet] DatePicker: type of prop "modelValue" should be an Array');
565
+ error("DatePicker", 'type of prop "modelValue" should be an Array');
566
566
  return false;
567
567
  }
568
568
  if (!props2.multiple && !props2.range && isArray(props2.modelValue)) {
569
- console.error('[Varlet] DatePicker: type of prop "modelValue" should be a String');
569
+ error("DatePicker", 'type of prop "modelValue" should be a String');
570
570
  return false;
571
571
  }
572
572
  return true;
573
573
  }
574
574
  function invalidFormatDate(date) {
575
- if (isArray(date)) return false;
575
+ if (isArray(date)) {
576
+ return false;
577
+ }
576
578
  if (date === "Invalid Date") {
577
- console.error('[Varlet] DatePicker: "modelValue" is an Invalid Date');
579
+ error("DatePicker", '"modelValue" is an Invalid Date');
578
580
  return true;
579
581
  }
580
582
  return false;
@@ -1,13 +1,11 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { INDEX_BAR_BIND_INDEX_ANCHOR_KEY } from "../index-bar/provide.mjs";
4
4
  function useIndexBar() {
5
5
  const { parentProvider, index, bindParent } = useParent(
6
6
  INDEX_BAR_BIND_INDEX_ANCHOR_KEY
7
7
  );
8
- if (!bindParent) {
9
- error("IndexAnchor", 'You should use this component in "IndexBar"');
10
- }
8
+ assert(!!bindParent, "IndexAnchor", 'You should use this component in "IndexBar"');
11
9
  return {
12
10
  index,
13
11
  indexBar: parentProvider,
@@ -280,7 +280,7 @@ import './tooltip/style/index.mjs'
280
280
  import './uploader/style/index.mjs'
281
281
  import './watermark/style/index.mjs'
282
282
 
283
- const version = '3.7.2'
283
+ const version = '3.7.3'
284
284
 
285
285
  function install(app) {
286
286
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -186,7 +186,7 @@ export * from './tooltip/index.mjs'
186
186
  export * from './uploader/index.mjs'
187
187
  export * from './watermark/index.mjs'
188
188
 
189
- const version = '3.7.2'
189
+ const version = '3.7.3'
190
190
 
191
191
  function install(app) {
192
192
  ActionSheet.install && app.use(ActionSheet)
@@ -1,13 +1,11 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { MENU_SELECT_BIND_MENU_OPTION_KEY } from "../menu-select/provide.mjs";
4
4
  function useMenuSelect() {
5
5
  const { index, parentProvider, bindParent } = useParent(
6
6
  MENU_SELECT_BIND_MENU_OPTION_KEY
7
7
  );
8
- if (!bindParent) {
9
- error("MenuOption", "<var-menu-option/> must in <var-menu-select/>");
10
- }
8
+ assert(!!bindParent, "MenuOption", "<var-menu-option/> must in <var-menu-select/>");
11
9
  return {
12
10
  index,
13
11
  menuSelect: parentProvider,
@@ -1,11 +1,9 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { SELECT_BIND_OPTION_KEY } from "../select/provide.mjs";
4
4
  function useSelect() {
5
5
  const { index, parentProvider, bindParent } = useParent(SELECT_BIND_OPTION_KEY);
6
- if (!bindParent) {
7
- error("Option", "<var-option/> must in <var-select/>");
8
- }
6
+ assert(!!bindParent, "Option", "<var-option/> must in <var-select/>");
9
7
  return {
10
8
  index,
11
9
  select: parentProvider,
@@ -5,13 +5,12 @@ import VarOption from "../option/index.mjs";
5
5
  import VarFieldDecorator from "../field-decorator/index.mjs";
6
6
  import VarFormDetails from "../form-details/index.mjs";
7
7
  import { computed, defineComponent, ref, watch, nextTick } from "vue";
8
- import { isArray, isEmpty, call, preventDefault, doubleRaf, isFunction } from "@varlet/shared";
8
+ import { isArray, isEmpty, call, preventDefault, doubleRaf, isFunction, assert } from "@varlet/shared";
9
9
  import { props } from "./props.mjs";
10
10
  import { useValidation, createNamespace, MaybeVNode } from "../utils/components.mjs";
11
11
  import { useOptions } from "./provide.mjs";
12
12
  import { useForm } from "../form/provide.mjs";
13
13
  import { focusChildElementByKey, toPxNum } from "../utils/elements.mjs";
14
- import { error } from "../utils/logger.mjs";
15
14
  import { useSelectController } from "./useSelectController.mjs";
16
15
  import { useEventListener } from "@varlet/use";
17
16
  const { name, n, classes } = createNamespace("select");
@@ -325,10 +324,11 @@ const __sfc__ = defineComponent({
325
324
  watch(
326
325
  () => props2.multiple,
327
326
  () => {
328
- const { multiple: multiple2, modelValue } = props2;
329
- if (multiple2 && !isArray(modelValue)) {
330
- error("Select", "The modelValue must be an array when multiple is true");
331
- }
327
+ assert(
328
+ props2.multiple && isArray(props2.modelValue),
329
+ "Select",
330
+ "The modelValue must be an array when multiple is true"
331
+ );
332
332
  }
333
333
  );
334
334
  bindOptions(selectProvider);
@@ -5,8 +5,7 @@ import { defineComponent, ref, onBeforeUnmount, computed, reactive, nextTick, wa
5
5
  import { useValidation, createNamespace } from "../utils/components.mjs";
6
6
  import { useForm } from "../form/provide.mjs";
7
7
  import { getLeft, toSizeUnit } from "../utils/elements.mjs";
8
- import { warn } from "../utils/logger.mjs";
9
- import { isArray, isNumber, toNumber, getRect, preventDefault, call, hasOwn, clamp } from "@varlet/shared";
8
+ import { isArray, isNumber, toNumber, getRect, preventDefault, call, hasOwn, clamp, error, warn } from "@varlet/shared";
10
9
  import { props, Thumbs } from "./props.mjs";
11
10
  import { onSmartMounted, onWindowResize, useEventListener } from "@varlet/use";
12
11
  const { name, n, classes } = createNamespace("slider");
@@ -449,7 +448,7 @@ const __sfc__ = defineComponent({
449
448
  }
450
449
  function stepValidator() {
451
450
  if (toNumber(props2.step) <= 0) {
452
- warn("[Varlet] Slider", '"step" should be > 0');
451
+ warn("Slider", '"step" should be > 0');
453
452
  return false;
454
453
  }
455
454
  return true;
@@ -457,15 +456,15 @@ const __sfc__ = defineComponent({
457
456
  function valueValidator() {
458
457
  const { range, modelValue } = props2;
459
458
  if (range && !isArray(modelValue)) {
460
- console.error('[Varlet] Slider: "modelValue" should be an Array');
459
+ error("Slider", '"modelValue" should be an Array');
461
460
  return false;
462
461
  }
463
462
  if (!range && isArray(modelValue)) {
464
- console.error('[Varlet] Slider: "modelValue" should be a Number');
463
+ error("Slider", '"modelValue" should be a Number');
465
464
  return false;
466
465
  }
467
466
  if (range && isArray(modelValue) && modelValue.length < 2) {
468
- console.error('[Varlet] Slider: "modelValue" should have two value');
467
+ error("Slider", '"modelValue" should have two value');
469
468
  return false;
470
469
  }
471
470
  return true;
@@ -1,11 +1,9 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { STEPS_BIND_STEP_KEY } from "../steps/provide.mjs";
4
4
  function useSteps() {
5
5
  const { parentProvider, index, bindParent } = useParent(STEPS_BIND_STEP_KEY);
6
- if (!bindParent) {
7
- error("Steps", "<step/> must in <steps>");
8
- }
6
+ assert(!!bindParent, "Steps", "<step/> must in <steps>");
9
7
  return {
10
8
  index,
11
9
  steps: parentProvider,
@@ -1,11 +1,9 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { SWIPE_BIND_SWIPE_ITEM_KEY } from "../swipe/provide.mjs";
4
4
  function useSwipe() {
5
5
  const { bindParent, index, parentProvider } = useParent(SWIPE_BIND_SWIPE_ITEM_KEY);
6
- if (!bindParent) {
7
- error("SwipeItem", "<var-swipe-item/> must in <var-swipe/>");
8
- }
6
+ assert(!!bindParent, "SwipeItem", "<var-swipe-item/> must in <var-swipe/>");
9
7
  return {
10
8
  index,
11
9
  swipe: parentProvider,
@@ -1,11 +1,9 @@
1
1
  import { useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { TABS_BIND_TAB_KEY } from "../tabs/provide.mjs";
4
4
  function useTabs() {
5
5
  const { parentProvider, bindParent, index } = useParent(TABS_BIND_TAB_KEY);
6
- if (!bindParent) {
7
- error("Tab", "<var-tab/> must in <var-tabs/>");
8
- }
6
+ assert(!!bindParent, "Tab", "<var-tab/> must in <var-tabs/>");
9
7
  return {
10
8
  index,
11
9
  tabs: parentProvider,
@@ -1,14 +1,12 @@
1
1
  import { useChildren, useParent } from "@varlet/use";
2
- import { error } from "../utils/logger.mjs";
2
+ import { assert } from "@varlet/shared";
3
3
  import { TABS_ITEMS_BIND_TAB_ITEM_KEY } from "../tabs-items/provide.mjs";
4
4
  const TAB_ITEM_BIND_LIST_KEY = Symbol("TAB_ITEM_BIND_LIST_KEY");
5
5
  function useTabsItems() {
6
6
  const { parentProvider, bindParent, index } = useParent(
7
7
  TABS_ITEMS_BIND_TAB_ITEM_KEY
8
8
  );
9
- if (!bindParent) {
10
- error("TabItem", "<var-tab-item/> must in <var-tabs-items/>");
11
- }
9
+ assert(!!bindParent, "TabItem", "<var-tab-item/> must in <var-tabs-items/>");
12
10
  return {
13
11
  index,
14
12
  tabsItems: parentProvider,
@@ -12,7 +12,7 @@ import {
12
12
  getScrollLeft,
13
13
  isNumeric
14
14
  } from "@varlet/shared";
15
- import { error } from "./logger.mjs";
15
+ import { assert } from "@varlet/shared";
16
16
  function getLeft(element) {
17
17
  const { left } = getRect(element);
18
18
  return left + (document.body.scrollLeft || document.documentElement.scrollLeft);
@@ -55,13 +55,11 @@ function getAllParentScroller(el) {
55
55
  function getTarget(target, componentName) {
56
56
  if (isString(target)) {
57
57
  const el = document.querySelector(target);
58
- if (!el) {
59
- error(componentName, "target element cannot found");
60
- }
58
+ assert(!!el, componentName, "target element cannot found");
61
59
  return el;
62
60
  }
63
- if (isObject(target)) return target;
64
- error(componentName, 'type of prop "target" should be a selector or an element object');
61
+ assert(isObject(target), componentName, 'type of prop "target" should be an element object');
62
+ return target;
65
63
  }
66
64
  function getViewportSize() {
67
65
  const { width, height } = getRect(window);