@varlet/ui 2.19.2 → 2.19.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,8 +1,25 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
1
17
  import VarIcon from "../icon/index.mjs";
2
18
  import { toNumber } from "@varlet/shared";
3
19
  import { computed, defineComponent } from "vue";
4
20
  import { props } from "./props.mjs";
5
21
  import { createNamespace } from "../utils/components.mjs";
22
+ import { toSizeUnit } from "../utils/elements.mjs";
6
23
  const { name, n, classes } = createNamespace("badge");
7
24
  import { renderSlot as _renderSlot, resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementBlock as _createElementBlock, vShow as _vShow, mergeProps as _mergeProps, createElementVNode as _createElementVNode, withDirectives as _withDirectives, Transition as _Transition, withCtx as _withCtx, createVNode as _createVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
8
25
  const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
@@ -27,11 +44,11 @@ function __render__(_ctx, _cache) {
27
44
  class: _ctx.classes(
28
45
  _ctx.n("content"),
29
46
  _ctx.n(`--${_ctx.type}`),
30
- [_ctx.$slots.default, _ctx.n(`--${_ctx.position}`)],
47
+ [_ctx.$slots.default, _ctx.n(`--${_ctx.position}`), _ctx.n("--offset")],
31
48
  [_ctx.dot, _ctx.n("--dot")],
32
49
  [_ctx.icon, _ctx.n("--icon")]
33
50
  ),
34
- style: { background: _ctx.color }
51
+ style: __spreadValues({ background: _ctx.color }, _ctx.offsetStyle)
35
52
  }, _ctx.$attrs),
36
53
  [
37
54
  _ctx.icon ? (_openBlock(), _createBlock(_component_var_icon, {
@@ -75,8 +92,13 @@ const __sfc__ = defineComponent({
75
92
  const { value: value2, maxValue } = props2;
76
93
  return value2 != null && maxValue != null && toNumber(value2) > toNumber(maxValue) ? `${maxValue}+` : value2;
77
94
  });
95
+ const offsetStyle = computed(() => ({
96
+ [`--badge-offset-y`]: toSizeUnit(props2.offsetY),
97
+ [`--badge-offset-x`]: toSizeUnit(props2.offsetX)
98
+ }));
78
99
  return {
79
100
  value,
101
+ offsetStyle,
80
102
  n,
81
103
  classes
82
104
  };
@@ -1 +1 @@
1
- :root { --badge-content-padding: 2px 6px; --badge-content-border: none; --badge-content-border-radius: 100px; --badge-content-font-size: 12px; --badge-icon-size: 12px; --badge-default-color: #e0e0e0; --badge-primary-color: var(--color-primary); --badge-danger-color: var(--color-danger); --badge-success-color: var(--color-success); --badge-warning-color: var(--color-warning); --badge-info-color: var(--color-info); --badge-dot-width: 8px; --badge-dot-height: 8px;}.var-badge { display: inline-block; position: relative; transition: background-color 0.25s;}.var-badge__content { display: inline-block; vertical-align: middle; text-align: center; padding: var(--badge-content-padding); border: var(--badge-content-border); border-radius: var(--badge-content-border-radius); color: #fff; font-size: var(--badge-content-font-size);}.var-badge__icon[var-badge-cover] { font-size: var(--badge-icon-size);}.var-badge--icon { padding: 2px 4px;}.var-badge--dot { box-sizing: content-box; width: var(--badge-dot-width); height: var(--badge-dot-height); padding: 0;}.var-badge--default { background: var(--badge-default-color);}.var-badge--primary { background: var(--badge-primary-color);}.var-badge--info { background: var(--badge-info-color);}.var-badge--warning { background: var(--badge-warning-color);}.var-badge--success { background: var(--badge-success-color);}.var-badge--danger { background: var(--badge-danger-color);}.var-badge--right-top { position: absolute; top: 0; right: 0; transform: translateY(-50%) translateX(50%);}.var-badge--left-top { position: absolute; top: 0; left: 0; transform: translateY(-50%) translateX(-50%);}.var-badge--right-bottom { position: absolute; bottom: 0; right: 0; transform: translateY(50%) translateX(50%);}.var-badge--left-bottom { position: absolute; bottom: 0; left: 0; transform: translateY(50%) translateX(-50%);}.var-badge-fade-enter-active,.var-badge-fade-leave-active { transition: opacity 0.15s var(--cubic-bezier);}.var-badge-fade-enter-from,.var-badge-fade-leave-to { opacity: 0;}
1
+ :root { --badge-content-padding: 2px 6px; --badge-content-border: none; --badge-content-border-radius: 100px; --badge-content-font-size: 12px; --badge-icon-size: 12px; --badge-default-color: #e0e0e0; --badge-primary-color: var(--color-primary); --badge-danger-color: var(--color-danger); --badge-success-color: var(--color-success); --badge-warning-color: var(--color-warning); --badge-info-color: var(--color-info); --badge-dot-width: 8px; --badge-dot-height: 8px;}.var-badge { display: inline-block; position: relative; transition: background-color 0.25s;}.var-badge__content { display: inline-block; vertical-align: middle; text-align: center; padding: var(--badge-content-padding); border: var(--badge-content-border); border-radius: var(--badge-content-border-radius); color: #fff; font-size: var(--badge-content-font-size);}.var-badge--offset { transform: translateX(var(--badge-offset-x)) translateY(var(--badge-offset-y));}.var-badge__icon[var-badge-cover] { font-size: var(--badge-icon-size);}.var-badge--icon { padding: 2px 4px;}.var-badge--dot { box-sizing: content-box; width: var(--badge-dot-width); height: var(--badge-dot-height); padding: 0;}.var-badge--default { background: var(--badge-default-color);}.var-badge--primary { background: var(--badge-primary-color);}.var-badge--info { background: var(--badge-info-color);}.var-badge--warning { background: var(--badge-warning-color);}.var-badge--success { background: var(--badge-success-color);}.var-badge--danger { background: var(--badge-danger-color);}.var-badge--right-top { position: absolute; top: 0; right: 0; transform: translateY(calc(-50% + var(--badge-offset-y))) translateX(calc(50% + var(--badge-offset-x)));}.var-badge--left-top { position: absolute; top: 0; left: 0; transform: translateY(calc(-50% + var(--badge-offset-y))) translateX(calc(-50% + var(--badge-offset-x)));}.var-badge--right-bottom { position: absolute; bottom: 0; right: 0; transform: translateY(calc(50% + var(--badge-offset-y))) translateX(calc(50% + var(--badge-offset-x)));}.var-badge--left-bottom { position: absolute; bottom: 0; left: 0; transform: translateY(calc(50% + var(--badge-offset-y))) translateX(calc(-50% + var(--badge-offset-x)));}.var-badge-fade-enter-active,.var-badge-fade-leave-active { transition: opacity 0.15s var(--cubic-bezier);}.var-badge-fade-enter-from,.var-badge-fade-leave-to { opacity: 0;}
@@ -18,7 +18,15 @@ const props = {
18
18
  dot: Boolean,
19
19
  icon: pickProps(iconProps, "name"),
20
20
  namespace: pickProps(iconProps, "namespace"),
21
- color: String
21
+ color: String,
22
+ offsetX: {
23
+ type: [String, Number],
24
+ default: 0
25
+ },
26
+ offsetY: {
27
+ type: [String, Number],
28
+ default: 0
29
+ }
22
30
  };
23
31
  export {
24
32
  props
@@ -2,7 +2,7 @@ import { computed, defineComponent, nextTick, watch } from "vue";
2
2
  import { useCollapseItem } from "./provide.mjs";
3
3
  import { props } from "./props.mjs";
4
4
  import { createNamespace } from "../utils/components.mjs";
5
- import { isArray, call } from "@varlet/shared";
5
+ import { normalizeToArray, call, removeArrayBlank } from "@varlet/shared";
6
6
  const { name, n } = createNamespace("collapse");
7
7
  import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
8
8
  function __render__(_ctx, _cache) {
@@ -22,13 +22,12 @@ const __sfc__ = defineComponent({
22
22
  name,
23
23
  props,
24
24
  setup(props2) {
25
- const active = computed(() => props2.modelValue);
26
25
  const offset = computed(() => props2.offset);
27
26
  const divider = computed(() => props2.divider);
28
27
  const elevation = computed(() => props2.elevation);
29
- const { length, collapseItem, bindCollapseItem } = useCollapseItem();
28
+ const normalizeValues = computed(() => normalizeToArray(props2.modelValue));
29
+ const { length, collapseItems, bindCollapseItems } = useCollapseItem();
30
30
  const collapseProvider = {
31
- active,
32
31
  offset,
33
32
  divider,
34
33
  elevation,
@@ -42,64 +41,44 @@ const __sfc__ = defineComponent({
42
41
  () => props2.modelValue,
43
42
  () => nextTick().then(resize)
44
43
  );
45
- bindCollapseItem(collapseProvider);
46
- function checkValue() {
47
- if (!props2.accordion && !isArray(props2.modelValue)) {
48
- console.error('[Varlet] Collapse: type of prop "modelValue" should be an Array');
49
- return false;
50
- }
51
- if (props2.accordion && isArray(props2.modelValue)) {
52
- console.error('[Varlet] Collapse: type of prop "modelValue" should be a String or Number');
53
- return false;
44
+ bindCollapseItems(collapseProvider);
45
+ function updateItem(itemValue, targetExpand) {
46
+ if (props2.accordion) {
47
+ const modelValue2 = targetExpand ? itemValue : void 0;
48
+ updateModelValue(modelValue2);
49
+ return;
54
50
  }
55
- return true;
51
+ const modelValue = targetExpand ? [...normalizeValues.value, itemValue] : normalizeValues.value.filter((value) => value !== itemValue);
52
+ updateModelValue(modelValue);
56
53
  }
57
- function getValue(value, isExpand) {
58
- if (!checkValue())
59
- return null;
60
- if (isExpand)
61
- return props2.accordion ? value : [...props2.modelValue, value];
62
- return props2.accordion ? null : props2.modelValue.filter((name2) => name2 !== value);
63
- }
64
- function updateItem(value, isExpand) {
65
- const modelValue = getValue(value, isExpand);
54
+ function updateModelValue(modelValue) {
66
55
  call(props2["onUpdate:modelValue"], modelValue);
67
56
  call(props2.onChange, modelValue);
68
57
  }
69
- function matchName() {
70
- if (props2.accordion) {
71
- return collapseItem.find(({ name: name2 }) => props2.modelValue === name2.value);
72
- }
73
- const filterItem = collapseItem.filter(({ name: name2 }) => {
74
- if (name2.value === void 0)
75
- return false;
76
- return props2.modelValue.includes(name2.value);
77
- });
78
- return filterItem.length ? filterItem : void 0;
79
- }
80
- function matchIndex() {
58
+ function matchItems() {
81
59
  if (props2.accordion) {
82
- return collapseItem.find(
83
- ({ index, name: name2 }) => name2.value === void 0 && props2.modelValue === index.value
84
- );
60
+ const [value] = normalizeValues.value;
61
+ if (value == null) {
62
+ return;
63
+ }
64
+ const matchedNameItem = collapseItems.find(({ name: name2 }) => value === name2.value);
65
+ if (matchedNameItem == null) {
66
+ return collapseItems.find(({ index, name: name2 }) => name2.value == null && value === index.value);
67
+ }
68
+ return matchedNameItem;
85
69
  }
86
- return collapseItem.filter(
87
- ({ index, name: name2 }) => name2.value === void 0 && props2.modelValue.includes(index.value)
70
+ const matchedNameItems = collapseItems.filter(
71
+ ({ name: name2 }) => name2.value != null && normalizeValues.value.includes(name2.value)
72
+ );
73
+ const matchedIndexItems = collapseItems.filter(
74
+ ({ index, name: name2 }) => name2.value == null && normalizeValues.value.includes(index.value)
88
75
  );
76
+ return [...matchedNameItems, ...matchedIndexItems];
89
77
  }
90
78
  function resize() {
91
- if (!checkValue())
92
- return;
93
- const matchProviders = matchName() || matchIndex();
94
- if (props2.accordion && !matchProviders || !props2.accordion && !matchProviders.length) {
95
- collapseItem.forEach((provider) => {
96
- provider.init(props2.accordion, false);
97
- });
98
- return;
99
- }
100
- collapseItem.forEach((provider) => {
101
- const isShow = props2.accordion ? matchProviders === provider : matchProviders.includes(provider);
102
- provider.init(props2.accordion, isShow);
79
+ const matchedItems = removeArrayBlank(normalizeToArray(matchItems()));
80
+ collapseItems.forEach((collapseItem) => {
81
+ collapseItem.init(matchedItems.includes(collapseItem));
103
82
  });
104
83
  }
105
84
  return {
@@ -6,8 +6,8 @@ function useCollapseItem() {
6
6
  );
7
7
  return {
8
8
  length,
9
- collapseItem: childProviders,
10
- bindCollapseItem: bindChildren
9
+ collapseItems: childProviders,
10
+ bindCollapseItems: bindChildren
11
11
  };
12
12
  }
13
13
  export {
@@ -20,7 +20,7 @@ var __async = (__this, __arguments, generator) => {
20
20
  };
21
21
  import VarIcon from "../icon/index.mjs";
22
22
  import { defineComponent, ref, watch, computed } from "vue";
23
- import { isArray, doubleRaf, raf } from "@varlet/shared";
23
+ import { doubleRaf, raf } from "@varlet/shared";
24
24
  import { createNamespace, formatElevation } from "../utils/components.mjs";
25
25
  import { useCollapse } from "./provide.mjs";
26
26
  import { props } from "./props.mjs";
@@ -48,7 +48,7 @@ function __render__(_ctx, _cache) {
48
48
  "div",
49
49
  {
50
50
  class: _normalizeClass(_ctx.n("header")),
51
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.toggle())
51
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.toggle && _ctx.toggle(...args))
52
52
  },
53
53
  [
54
54
  _createElementVNode(
@@ -138,7 +138,7 @@ const __sfc__ = defineComponent({
138
138
  const contentEl = ref(null);
139
139
  const name2 = computed(() => props2.name);
140
140
  const { index, collapse, bindCollapse } = useCollapse();
141
- const { active, offset, divider, elevation, updateItem } = collapse;
141
+ const { offset, divider, elevation, updateItem } = collapse;
142
142
  const collapseItemProvider = {
143
143
  index,
144
144
  name: name2,
@@ -187,18 +187,15 @@ const __sfc__ = defineComponent({
187
187
  contentEl.value.style.height = "0px";
188
188
  });
189
189
  }
190
- function init(accordion, show) {
191
- if (active.value === void 0 || accordion && isArray(active.value) || show === isShow.value)
192
- return;
190
+ function init(show) {
193
191
  isShow.value = show;
194
- toggle(true);
195
192
  }
196
- function toggle(initOrAccordion) {
197
- if (props2.disabled)
193
+ function toggle() {
194
+ var _a;
195
+ if (props2.disabled) {
198
196
  return;
199
- if (!initOrAccordion) {
200
- updateItem(props2.name || index.value, !isShow.value);
201
197
  }
198
+ updateItem((_a = props2.name) != null ? _a : index.value, !isShow.value);
202
199
  }
203
200
  function start() {
204
201
  isInitToTrigger = false;
@@ -189,9 +189,10 @@ const __sfc__ = defineComponent({
189
189
  );
190
190
  const sortWeekList = computed(() => {
191
191
  const index = WEEK_HEADER.findIndex((week) => week === props.componentProps.firstDayOfWeek);
192
- if (index === -1 || index === 0)
192
+ if (index === -1 || index === 0) {
193
193
  return WEEK_HEADER;
194
- return WEEK_HEADER.slice(index).concat(WEEK_HEADER.slice(0, index));
194
+ }
195
+ return [...WEEK_HEADER.slice(index), ...WEEK_HEADER.slice(0, index)];
195
196
  });
196
197
  const getDayAbbr = (key) => {
197
198
  var _a, _b;
@@ -259,7 +259,7 @@ import './tooltip/style/index.mjs'
259
259
  import './uploader/style/index.mjs'
260
260
  import './watermark/style/index.mjs'
261
261
 
262
- const version = '2.19.2'
262
+ const version = '2.19.3'
263
263
 
264
264
  function install(app) {
265
265
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -172,7 +172,7 @@ export * from './tooltip/index.mjs'
172
172
  export * from './uploader/index.mjs'
173
173
  export * from './watermark/index.mjs'
174
174
 
175
- const version = '2.19.2'
175
+ const version = '2.19.3'
176
176
 
177
177
  function install(app) {
178
178
  ActionSheet.install && app.use(ActionSheet)
@@ -248,7 +248,11 @@ const __sfc__ = defineComponent({
248
248
  if (props2.type === "number") {
249
249
  value = formatNumber(value);
250
250
  }
251
- return withMaxlength(withTrim(value));
251
+ const targetValue = withMaxlength(withTrim(value));
252
+ if (targetValue === props2.modelValue) {
253
+ target.value = targetValue;
254
+ }
255
+ return targetValue;
252
256
  }
253
257
  function handleCompositionStart() {
254
258
  isComposing.value = true;
@@ -1,8 +1,8 @@
1
1
  import '../../styles/common.css'
2
+ import '../SnackbarSfc.css'
2
3
  import '../../styles/elevation.css'
3
4
  import '../../loading/loading.css'
4
5
  import '../../button/button.css'
5
6
  import '../../icon/icon.css'
6
7
  import '../snackbar.css'
7
8
  import '../coreSfc.css'
8
- import '../SnackbarSfc.css'