@varlet/ui 2.19.2 → 2.19.3-alpha.1701190302604

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,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "2.19.2",
4
+ "version": "2.19.3-alpha.1701190302604",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "2.19.2",
4
+ "version": "2.19.3-alpha.1701190302604",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
package/lib/varlet.cjs.js CHANGED
@@ -55,6 +55,7 @@ var removeItem = (arr, item) => {
55
55
  }
56
56
  }
57
57
  };
58
+ var removeArrayBlank = (arr) => arr.filter((item) => item != null);
58
59
  var find = (arr, callback, from = "start") => {
59
60
  let i = from === "start" ? 0 : arr.length - 1;
60
61
  while (arr.length > 0 && i >= 0 && i <= arr.length - 1) {
@@ -5325,8 +5326,8 @@ function useCollapseItem() {
5325
5326
  );
5326
5327
  return {
5327
5328
  length,
5328
- collapseItem: childProviders,
5329
- bindCollapseItem: bindChildren
5329
+ collapseItems: childProviders,
5330
+ bindCollapseItems: bindChildren
5330
5331
  };
5331
5332
  }
5332
5333
  const props$U = {
@@ -5365,13 +5366,12 @@ const __sfc__$10 = vue.defineComponent({
5365
5366
  name: name$U,
5366
5367
  props: props$U,
5367
5368
  setup(props2) {
5368
- const active = vue.computed(() => props2.modelValue);
5369
5369
  const offset2 = vue.computed(() => props2.offset);
5370
5370
  const divider2 = vue.computed(() => props2.divider);
5371
5371
  const elevation2 = vue.computed(() => props2.elevation);
5372
- const { length, collapseItem: collapseItem2, bindCollapseItem } = useCollapseItem();
5372
+ const normalizeValues = vue.computed(() => normalizeToArray(props2.modelValue));
5373
+ const { length, collapseItems, bindCollapseItems } = useCollapseItem();
5373
5374
  const collapseProvider = {
5374
- active,
5375
5375
  offset: offset2,
5376
5376
  divider: divider2,
5377
5377
  elevation: elevation2,
@@ -5385,64 +5385,44 @@ const __sfc__$10 = vue.defineComponent({
5385
5385
  () => props2.modelValue,
5386
5386
  () => vue.nextTick().then(resize)
5387
5387
  );
5388
- bindCollapseItem(collapseProvider);
5389
- function checkValue() {
5390
- if (!props2.accordion && !isArray(props2.modelValue)) {
5391
- console.error('[Varlet] Collapse: type of prop "modelValue" should be an Array');
5392
- return false;
5393
- }
5394
- if (props2.accordion && isArray(props2.modelValue)) {
5395
- console.error('[Varlet] Collapse: type of prop "modelValue" should be a String or Number');
5396
- return false;
5388
+ bindCollapseItems(collapseProvider);
5389
+ function updateItem(itemValue, targetExpand) {
5390
+ if (props2.accordion) {
5391
+ const value2 = targetExpand ? itemValue : void 0;
5392
+ updateModelValue(isArray(props2.modelValue) ? removeArrayBlank([value2]) : value2);
5393
+ return;
5397
5394
  }
5398
- return true;
5395
+ const value = targetExpand ? [...normalizeValues.value, itemValue] : normalizeValues.value.filter((value2) => value2 !== itemValue);
5396
+ updateModelValue(value);
5399
5397
  }
5400
- function getValue(value, isExpand) {
5401
- if (!checkValue())
5402
- return null;
5403
- if (isExpand)
5404
- return props2.accordion ? value : [...props2.modelValue, value];
5405
- return props2.accordion ? null : props2.modelValue.filter((name2) => name2 !== value);
5406
- }
5407
- function updateItem(value, isExpand) {
5408
- const modelValue = getValue(value, isExpand);
5398
+ function updateModelValue(modelValue) {
5409
5399
  call(props2["onUpdate:modelValue"], modelValue);
5410
5400
  call(props2.onChange, modelValue);
5411
5401
  }
5412
- function matchName() {
5413
- if (props2.accordion) {
5414
- return collapseItem2.find(({ name: name2 }) => props2.modelValue === name2.value);
5415
- }
5416
- const filterItem = collapseItem2.filter(({ name: name2 }) => {
5417
- if (name2.value === void 0)
5418
- return false;
5419
- return props2.modelValue.includes(name2.value);
5420
- });
5421
- return filterItem.length ? filterItem : void 0;
5422
- }
5423
- function matchIndex() {
5402
+ function matchItems() {
5424
5403
  if (props2.accordion) {
5425
- return collapseItem2.find(
5426
- ({ index, name: name2 }) => name2.value === void 0 && props2.modelValue === index.value
5427
- );
5404
+ const [value] = normalizeValues.value;
5405
+ if (value == null) {
5406
+ return;
5407
+ }
5408
+ const matchedNameItem = collapseItems.find(({ name: name2 }) => value === name2.value);
5409
+ if (matchedNameItem == null) {
5410
+ return collapseItems.find(({ index, name: name2 }) => name2.value == null && value === index.value);
5411
+ }
5412
+ return matchedNameItem;
5428
5413
  }
5429
- return collapseItem2.filter(
5430
- ({ index, name: name2 }) => name2.value === void 0 && props2.modelValue.includes(index.value)
5414
+ const matchedNameItems = collapseItems.filter(
5415
+ ({ name: name2 }) => name2.value != null && normalizeValues.value.includes(name2.value)
5416
+ );
5417
+ const matchedIndexItems = collapseItems.filter(
5418
+ ({ index, name: name2 }) => name2.value == null && normalizeValues.value.includes(index.value)
5431
5419
  );
5420
+ return [...matchedNameItems, ...matchedIndexItems];
5432
5421
  }
5433
5422
  function resize() {
5434
- if (!checkValue())
5435
- return;
5436
- const matchProviders = matchName() || matchIndex();
5437
- if (props2.accordion && !matchProviders || !props2.accordion && !matchProviders.length) {
5438
- collapseItem2.forEach((provider) => {
5439
- provider.init(props2.accordion, false);
5440
- });
5441
- return;
5442
- }
5443
- collapseItem2.forEach((provider) => {
5444
- const isShow = props2.accordion ? matchProviders === provider : matchProviders.includes(provider);
5445
- provider.init(props2.accordion, isShow);
5423
+ const matchedItems = removeArrayBlank(normalizeToArray(matchItems()));
5424
+ collapseItems.forEach((collapseItem2) => {
5425
+ collapseItem2.init(matchedItems.includes(collapseItem2));
5446
5426
  });
5447
5427
  }
5448
5428
  return {
@@ -5522,7 +5502,7 @@ function __render__$_(_ctx, _cache) {
5522
5502
  "div",
5523
5503
  {
5524
5504
  class: vue.normalizeClass(_ctx.n("header")),
5525
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.toggle())
5505
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.toggle && _ctx.toggle(...args))
5526
5506
  },
5527
5507
  [
5528
5508
  vue.createElementVNode(
@@ -5612,7 +5592,7 @@ const __sfc__$$ = vue.defineComponent({
5612
5592
  const contentEl = vue.ref(null);
5613
5593
  const name2 = vue.computed(() => props2.name);
5614
5594
  const { index, collapse, bindCollapse } = useCollapse();
5615
- const { active, offset: offset2, divider: divider2, elevation: elevation2, updateItem } = collapse;
5595
+ const { offset: offset2, divider: divider2, elevation: elevation2, updateItem } = collapse;
5616
5596
  const collapseItemProvider = {
5617
5597
  index,
5618
5598
  name: name2,
@@ -5661,18 +5641,15 @@ const __sfc__$$ = vue.defineComponent({
5661
5641
  contentEl.value.style.height = "0px";
5662
5642
  });
5663
5643
  }
5664
- function init(accordion, show) {
5665
- if (active.value === void 0 || accordion && isArray(active.value) || show === isShow.value)
5666
- return;
5644
+ function init(show) {
5667
5645
  isShow.value = show;
5668
- toggle(true);
5669
5646
  }
5670
- function toggle(initOrAccordion) {
5671
- if (props2.disabled)
5647
+ function toggle() {
5648
+ var _a;
5649
+ if (props2.disabled) {
5672
5650
  return;
5673
- if (!initOrAccordion) {
5674
- updateItem(props2.name || index.value, !isShow.value);
5675
5651
  }
5652
+ updateItem((_a = props2.name) != null ? _a : index.value, !isShow.value);
5676
5653
  }
5677
5654
  function start2() {
5678
5655
  isInitToTrigger = false;
@@ -10087,9 +10064,10 @@ const __sfc__$U = vue.defineComponent({
10087
10064
  );
10088
10065
  const sortWeekList = vue.computed(() => {
10089
10066
  const index = WEEK_HEADER.findIndex((week) => week === props2.componentProps.firstDayOfWeek);
10090
- if (index === -1 || index === 0)
10067
+ if (index === -1 || index === 0) {
10091
10068
  return WEEK_HEADER;
10092
- return WEEK_HEADER.slice(index).concat(WEEK_HEADER.slice(0, index));
10069
+ }
10070
+ return [...WEEK_HEADER.slice(index), ...WEEK_HEADER.slice(0, index)];
10093
10071
  });
10094
10072
  const getDayAbbr = (key) => {
10095
10073
  var _a, _b;
@@ -16155,7 +16133,11 @@ const __sfc__$E = vue.defineComponent({
16155
16133
  if (props2.type === "number") {
16156
16134
  value = formatNumber(value);
16157
16135
  }
16158
- return withMaxlength(withTrim(value));
16136
+ const targetValue = withMaxlength(withTrim(value));
16137
+ if (targetValue === props2.modelValue) {
16138
+ target.value = targetValue;
16139
+ }
16140
+ return targetValue;
16159
16141
  }
16160
16142
  function handleCompositionStart() {
16161
16143
  isComposing.value = true;
@@ -25038,7 +25020,7 @@ const uploader = "";
25038
25020
  const UploaderSfc = "";
25039
25021
  const watermark = "";
25040
25022
  const WatermarkSfc = "";
25041
- const version = "2.19.2";
25023
+ const version = "2.19.3-alpha.1701190302604";
25042
25024
  function install(app) {
25043
25025
  stdin_default$3k.install && app.use(stdin_default$3k);
25044
25026
  stdin_default$3i.install && app.use(stdin_default$3i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/ui",
3
- "version": "2.19.2",
3
+ "version": "2.19.3-alpha.1701190302604",
4
4
  "description": "A material like components library",
5
5
  "main": "lib/varlet.cjs.js",
6
6
  "module": "es/index.mjs",
@@ -48,9 +48,9 @@
48
48
  "@popperjs/core": "^2.11.6",
49
49
  "dayjs": "^1.10.4",
50
50
  "decimal.js": "^10.2.1",
51
- "@varlet/shared": "2.19.2",
52
- "@varlet/icons": "2.19.2",
53
- "@varlet/use": "2.19.2"
51
+ "@varlet/icons": "2.19.3-alpha.1701190302604",
52
+ "@varlet/shared": "2.19.3-alpha.1701190302604",
53
+ "@varlet/use": "2.19.3-alpha.1701190302604"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@vue/runtime-core": "3.3.4",
@@ -66,9 +66,9 @@
66
66
  "typescript": "^5.1.5",
67
67
  "vue": "3.3.4",
68
68
  "vue-router": "4.2.0",
69
- "@varlet/cli": "2.19.2",
70
- "@varlet/touch-emulator": "2.19.2",
71
- "@varlet/ui": "2.19.2"
69
+ "@varlet/cli": "2.19.3-alpha.1701190302604",
70
+ "@varlet/ui": "2.19.3-alpha.1701190302604",
71
+ "@varlet/touch-emulator": "2.19.3-alpha.1701190302604"
72
72
  },
73
73
  "scripts": {
74
74
  "dev": "varlet-cli dev",
@@ -3,7 +3,7 @@ import { VNode } from 'vue'
3
3
 
4
4
  export declare const collapseProps: Record<keyof CollapseProps, any>
5
5
 
6
- export type CollapseModelValue = null | string | number | Array<string | number>
6
+ export type CollapseModelValue = undefined | string | number | Array<string | number | undefined>
7
7
 
8
8
  export interface CollapseProps extends BasicAttributes {
9
9
  modelValue?: CollapseModelValue