@varlet/ui 3.15.0 → 3.15.2

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": "3.15.0",
4
+ "version": "3.15.2",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -2887,6 +2887,15 @@
2887
2887
  "type": "boolean",
2888
2888
  "kind": "expression"
2889
2889
  }
2890
+ },
2891
+ {
2892
+ "name": "fallback-view-date",
2893
+ "description": "Controls the panel view fallback date when there is no usable selected value. It does not update `v-model`.",
2894
+ "default": "-",
2895
+ "value": {
2896
+ "type": "string",
2897
+ "kind": "expression"
2898
+ }
2890
2899
  }
2891
2900
  ],
2892
2901
  "events": [
@@ -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": "3.15.0",
4
+ "version": "3.15.2",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -2938,6 +2938,15 @@
2938
2938
  "type": "boolean",
2939
2939
  "kind": "expression"
2940
2940
  }
2941
+ },
2942
+ {
2943
+ "name": "fallback-view-date",
2944
+ "description": "在没有可用选中值时,控制面板视图回退到的日期(不会写回 `v-model`)",
2945
+ "default": "-",
2946
+ "value": {
2947
+ "type": "string",
2948
+ "kind": "expression"
2949
+ }
2941
2950
  }
2942
2951
  ],
2943
2952
  "events": [
package/lib/varlet.cjs.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  let vue = require("vue");
6
- //#region ../../node_modules/.pnpm/rattail@2.0.5_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._oaa5dabgz63tacyacthirbl23y/node_modules/rattail/dist/chunk-D1SwGrFN.mjs
6
+ //#region ../../node_modules/.pnpm/rattail@2.0.7_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._6rwx5eoj5ijtwiwneistv24bcq/node_modules/rattail/dist/chunk-D1SwGrFN.mjs
7
7
  var __defProp$37 = Object.defineProperty;
8
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
9
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -29,7 +29,7 @@ var __copyProps = (to, from, except, desc) => {
29
29
  };
30
30
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
31
31
  //#endregion
32
- //#region ../../node_modules/.pnpm/rattail@2.0.5_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._oaa5dabgz63tacyacthirbl23y/node_modules/rattail/dist/isString-eoLxw4CX.mjs
32
+ //#region ../../node_modules/.pnpm/rattail@2.0.7_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._6rwx5eoj5ijtwiwneistv24bcq/node_modules/rattail/dist/isString-eoLxw4CX.mjs
33
33
  function isArray(val) {
34
34
  return Array.isArray(val);
35
35
  }
@@ -37,7 +37,7 @@ function isString(val) {
37
37
  return typeof val === "string";
38
38
  }
39
39
  //#endregion
40
- //#region ../../node_modules/.pnpm/rattail@2.0.5_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._oaa5dabgz63tacyacthirbl23y/node_modules/rattail/dist/callOrReturn-MpTzoGlG.mjs
40
+ //#region ../../node_modules/.pnpm/rattail@2.0.7_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._6rwx5eoj5ijtwiwneistv24bcq/node_modules/rattail/dist/callOrReturn-MpTzoGlG.mjs
41
41
  function isFunction(val) {
42
42
  return typeof val === "function";
43
43
  }
@@ -280,7 +280,7 @@ function init(converter, defaultAttributes) {
280
280
  }
281
281
  var api = init(defaultConverter, { path: "/" });
282
282
  //#endregion
283
- //#region ../../node_modules/.pnpm/rattail@2.0.5_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._oaa5dabgz63tacyacthirbl23y/node_modules/rattail/dist/index.mjs
283
+ //#region ../../node_modules/.pnpm/rattail@2.0.7_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._6rwx5eoj5ijtwiwneistv24bcq/node_modules/rattail/dist/index.mjs
284
284
  function at(arr, index) {
285
285
  if (!arr.length) return;
286
286
  if (index < 0) index += arr.length;
@@ -634,6 +634,13 @@ function omitBy(object, fn) {
634
634
  return result;
635
635
  }, {});
636
636
  }
637
+ function rekey(object, mapping) {
638
+ return [...Object.keys(object), ...Object.getOwnPropertySymbols(object)].reduce((result, key) => {
639
+ const nextKey = hasOwn(mapping, key) ? mapping[key] : key;
640
+ result[nextKey] = object[key];
641
+ return result;
642
+ }, {});
643
+ }
637
644
  function mapObject(object, fn) {
638
645
  return Object.entries(object).reduce((result, [key, value]) => {
639
646
  const entry = fn(key, value);
@@ -1524,6 +1531,7 @@ __reExport(/* @__PURE__ */ __exportAll({
1524
1531
  randomColor: () => randomColor,
1525
1532
  randomNumber: () => randomNumber,
1526
1533
  randomString: () => randomString,
1534
+ rekey: () => rekey,
1527
1535
  removeArrayBlank: () => removeArrayBlank,
1528
1536
  removeArrayEmpty: () => removeArrayEmpty,
1529
1537
  removeItem: () => removeItem,
@@ -13510,6 +13518,7 @@ var props$26 = {
13510
13518
  default: "date"
13511
13519
  },
13512
13520
  hint: String,
13521
+ fallbackViewDate: String,
13513
13522
  allowedDates: Function,
13514
13523
  color: String,
13515
13524
  titleColor: String,
@@ -14490,7 +14499,7 @@ function __render__$51(_ctx, _cache) {
14490
14499
  key: 0,
14491
14500
  class: (0, vue.normalizeClass)(_ctx.classes(_ctx.n("title-year"), [_ctx.isYearPanel, _ctx.n("title-year--active")])),
14492
14501
  onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickEl("year"))
14493
- }, [(0, vue.renderSlot)(_ctx.$slots, "year", { year: _ctx.chooseYear }, () => [(0, vue.createTextVNode)((0, vue.toDisplayString)(_ctx.chooseYear), 1)])], 2)) : (0, vue.createCommentVNode)("v-if", true)], 2), (0, vue.createElementVNode)("div", {
14502
+ }, [(0, vue.renderSlot)(_ctx.$slots, "year", { year: _ctx.displayYear }, () => [(0, vue.createTextVNode)((0, vue.toDisplayString)(_ctx.displayYear), 1)])], 2)) : (0, vue.createCommentVNode)("v-if", true)], 2), (0, vue.createElementVNode)("div", {
14494
14503
  class: (0, vue.normalizeClass)(_ctx.classes(_ctx.n("title-date"), [!_ctx.isYearPanel || _ctx.type === "year", _ctx.n("title-date--active")], [_ctx.range, _ctx.n("title-date--range")])),
14495
14504
  onClick: _cache[1] || (_cache[1] = ($event) => _ctx.clickEl("date"))
14496
14505
  }, [(0, vue.createVNode)(vue.Transition, { name: _ctx.multiple ? "" : `${_ctx.n()}${_ctx.reverse ? "-reverse" : ""}-translatey` }, {
@@ -14645,6 +14654,7 @@ var __sfc__$51 = (0, vue.defineComponent)({
14645
14654
  previewMonth: previewMonth.value,
14646
14655
  previewYear: previewYear.value
14647
14656
  }));
14657
+ const displayYear = (0, vue.computed)(() => previewYear.value || chooseYear.value || "");
14648
14658
  const getYearTitle = (0, vue.computed)(() => {
14649
14659
  var _a;
14650
14660
  const { multiple, range } = props2;
@@ -14702,7 +14712,7 @@ var __sfc__$51 = (0, vue.defineComponent)({
14702
14712
  let checkType = "";
14703
14713
  let touchDirection;
14704
14714
  (0, vue.watch)(() => props2.modelValue, (value) => {
14705
- if (!checkValue() || invalidFormatDate(value)) return;
14715
+ if (!checkValue()) return;
14706
14716
  if (props2.range) {
14707
14717
  if (!isArray(value)) return;
14708
14718
  rangeDone.value = value.length !== 1;
@@ -14710,7 +14720,7 @@ var __sfc__$51 = (0, vue.defineComponent)({
14710
14720
  } else if (props2.multiple) {
14711
14721
  if (!isArray(value)) return;
14712
14722
  multipleInit(value, props2.type);
14713
- } else dateInit(value);
14723
+ } else dateInit(getSingleDate(value));
14714
14724
  }, { immediate: true });
14715
14725
  (0, vue.watch)(getPanelType, resetState);
14716
14726
  function clickEl(type) {
@@ -14854,29 +14864,50 @@ var __sfc__$51 = (0, vue.defineComponent)({
14854
14864
  }
14855
14865
  return false;
14856
14866
  }
14867
+ function getFallbackDate() {
14868
+ if (props2.fallbackViewDate) {
14869
+ if (dayjs(props2.fallbackViewDate).format("YYYY-MM-D") !== "Invalid Date") return props2.fallbackViewDate;
14870
+ }
14871
+ return dayjs().format("YYYY-MM-D");
14872
+ }
14873
+ function getSingleDate(value) {
14874
+ if (value && !invalidFormatDate(dayjs(value).format("YYYY-MM-D"))) return value;
14875
+ return getFallbackDate();
14876
+ }
14877
+ function getFirstValidDate(value, type) {
14878
+ const formatType = type === "year" ? "YYYY" : type === "month" ? "YYYY-MM" : "YYYY-MM-D";
14879
+ return value.find((choose) => !invalidFormatDate(dayjs(choose).format(formatType)));
14880
+ }
14857
14881
  function rangeInit(value, type) {
14882
+ var _a;
14858
14883
  const rangeDate = type === "year" ? chooseRangeYear : type === "month" ? chooseRangeMonth : chooseRangeDay;
14859
14884
  const formatType = type === "year" ? "YYYY" : type === "month" ? "YYYY-MM" : "YYYY-MM-D";
14860
- const formatDateList = value.map((choose) => dayjs(choose).format(formatType)).slice(0, 2);
14861
- if (rangeDate.value.some((date) => invalidFormatDate(date))) return;
14862
- rangeDate.value = formatDateList;
14885
+ rangeDate.value = value.map((choose) => dayjs(choose).format(formatType)).filter((date) => !invalidFormatDate(date)).slice(0, 2);
14863
14886
  const isChangeOrder = dayjs(rangeDate.value[0]).isAfter(rangeDate.value[1]);
14864
14887
  if (rangeDate.value.length === 2 && isChangeOrder) rangeDate.value = [rangeDate.value[1], rangeDate.value[0]];
14888
+ previewInit((_a = getFirstValidDate(value, type)) != null ? _a : getFallbackDate());
14865
14889
  }
14866
14890
  function multipleInit(value, type) {
14891
+ var _a;
14867
14892
  const rangeDate = type === "year" ? chooseYears : type === "month" ? chooseMonths : chooseDays;
14868
14893
  const formatType = type === "year" ? "YYYY" : type === "month" ? "YYYY-MM" : "YYYY-MM-D";
14869
14894
  rangeDate.value = Array.from(new Set(value.map((choose) => dayjs(choose).format(formatType)))).filter((date) => date !== "Invalid Date");
14895
+ previewInit((_a = getFirstValidDate(value, type)) != null ? _a : getFallbackDate());
14870
14896
  }
14871
14897
  function dateInit(value) {
14872
- const formatDate = (value ? dayjs(value) : dayjs()).format("YYYY-MM-D");
14898
+ const formatDate = (value ? dayjs(value) : dayjs(getFallbackDate())).format("YYYY-MM-D");
14873
14899
  if (invalidFormatDate(formatDate)) return;
14874
14900
  const [yearValue, monthValue, dayValue] = formatDate.split("-");
14875
- const monthDes2 = MONTH_LIST.find((month) => month === monthValue);
14876
- chooseMonth.value = monthDes2;
14901
+ chooseMonth.value = MONTH_LIST.find((month) => month === monthValue);
14877
14902
  chooseYear.value = yearValue;
14878
14903
  chooseDay.value = dayValue;
14879
- previewMonth.value = monthDes2;
14904
+ previewInit(formatDate);
14905
+ }
14906
+ function previewInit(value) {
14907
+ const formatDate = (value ? dayjs(value) : dayjs(getFallbackDate())).format("YYYY-MM-D");
14908
+ if (invalidFormatDate(formatDate)) return;
14909
+ const [yearValue, monthValue] = formatDate.split("-");
14910
+ previewMonth.value = MONTH_LIST.find((month) => month === monthValue);
14880
14911
  previewYear.value = yearValue;
14881
14912
  }
14882
14913
  function resetState() {
@@ -14895,6 +14926,7 @@ var __sfc__$51 = (0, vue.defineComponent)({
14895
14926
  chooseYear,
14896
14927
  chooseDay,
14897
14928
  previewYear,
14929
+ displayYear,
14898
14930
  isYearPanel,
14899
14931
  isMonthPanel,
14900
14932
  getMonthTitle,
@@ -28508,7 +28540,7 @@ var _WatermarkComponent = stdin_default$99;
28508
28540
  var stdin_default$93 = stdin_default$99;
28509
28541
  //#endregion
28510
28542
  //#region es/index.bundle.mjs
28511
- var version = "3.15.0";
28543
+ var version = "3.15.2";
28512
28544
  function install(app) {
28513
28545
  stdin_default.install && app.use(stdin_default);
28514
28546
  stdin_default$1.install && app.use(stdin_default$1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/ui",
3
- "version": "3.15.0",
3
+ "version": "3.15.2",
4
4
  "description": "A Vue3 component library based on Material Design 2 and 3, supporting mobile and desktop.",
5
5
  "keywords": [
6
6
  "Vue3",
@@ -44,9 +44,9 @@
44
44
  "@popperjs/core": "^2.11.6",
45
45
  "dayjs": "^1.10.4",
46
46
  "decimal.js": "^10.2.1",
47
- "@varlet/icons": "3.15.0",
48
- "@varlet/use": "3.15.0",
49
- "@varlet/shared": "3.15.0"
47
+ "@varlet/icons": "3.15.2",
48
+ "@varlet/shared": "3.15.2",
49
+ "@varlet/use": "3.15.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/node": "^20.19.0",
@@ -62,9 +62,9 @@
62
62
  "vue": "3.5.21",
63
63
  "vue-router": "4.5.1",
64
64
  "zod": "^3.23.8",
65
- "@varlet/cli": "3.15.0",
66
- "@varlet/ui": "3.15.0",
67
- "@varlet/touch-emulator": "3.15.0"
65
+ "@varlet/cli": "3.15.2",
66
+ "@varlet/ui": "3.15.2",
67
+ "@varlet/touch-emulator": "3.15.2"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "vue": "^3.2.0"
@@ -22,6 +22,7 @@ export interface DatePickerProps extends BasicAttributes {
22
22
  multiple?: boolean
23
23
  range?: boolean
24
24
  touchable?: boolean
25
+ fallbackViewDate?: string
25
26
  onPreview?: ListenerProp<(year: number, month: number, day?: number) => void>
26
27
  onChange?: ListenerProp<(value: string | string[]) => void>
27
28
  'onUpdate:modelValue'?: ListenerProp<(value: string | string[]) => void>