@94ai/nf-timezone-picker 8.3.23 → 10.0.0

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.
@@ -27,7 +27,7 @@ declare var _default: import("vue").DefineComponent<{
27
27
  };
28
28
  };
29
29
  timezone: {
30
- type: StringConstructor;
30
+ type: (StringConstructor | NumberConstructor)[];
31
31
  default: string;
32
32
  };
33
33
  }, {}, {
@@ -70,11 +70,11 @@ declare var _default: import("vue").DefineComponent<{
70
70
  };
71
71
  };
72
72
  timezone: {
73
- type: StringConstructor;
73
+ type: (StringConstructor | NumberConstructor)[];
74
74
  default: string;
75
75
  };
76
76
  }>>, {
77
- timezone: string;
77
+ timezone: string | number;
78
78
  selectionMode: string;
79
79
  rangeState: {
80
80
  endDate: null;
package/lib/index.d.ts CHANGED
@@ -53,7 +53,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
53
53
  default: boolean;
54
54
  };
55
55
  timezone: {
56
- type: StringConstructor;
56
+ type: (StringConstructor | NumberConstructor)[];
57
57
  default(): any;
58
58
  };
59
59
  }>> & Readonly<import("vue-demi").ExtractPropTypes<{
@@ -80,7 +80,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
80
80
  align: string;
81
81
  rangeSeparator: string;
82
82
  validateEvent: boolean;
83
- timezone: string;
83
+ timezone: string | number;
84
84
  } & {
85
85
  type: string;
86
86
  timeArrowControl: boolean;
@@ -132,7 +132,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
132
132
  default: boolean;
133
133
  };
134
134
  timezone: {
135
- type: StringConstructor;
135
+ type: (StringConstructor | NumberConstructor)[];
136
136
  default(): any;
137
137
  };
138
138
  }>> & Readonly<import("vue-demi").ExtractPropTypes<{
@@ -154,7 +154,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
154
154
  valueIsEmpty(): boolean;
155
155
  triggerClass(): any;
156
156
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
157
- haveTrigger(): any;
157
+ haveTrigger(): boolean;
158
158
  displayValue(): any;
159
159
  parsedValue(): any;
160
160
  _elFormItemSize(): any;
@@ -226,7 +226,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
226
226
  default: boolean;
227
227
  };
228
228
  timezone: {
229
- type: StringConstructor;
229
+ type: (StringConstructor | NumberConstructor)[];
230
230
  default(): any;
231
231
  };
232
232
  }, {}, {
@@ -242,7 +242,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
242
242
  valueIsEmpty(): boolean;
243
243
  triggerClass(): any;
244
244
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
245
- haveTrigger(): any;
245
+ haveTrigger(): boolean;
246
246
  displayValue(): any;
247
247
  parsedValue(): any;
248
248
  _elFormItemSize(): any;
@@ -302,7 +302,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
302
302
  default: boolean;
303
303
  };
304
304
  timezone: {
305
- type: StringConstructor;
305
+ type: (StringConstructor | NumberConstructor)[];
306
306
  default(): any;
307
307
  };
308
308
  }>>, {
@@ -317,7 +317,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
317
317
  align: string;
318
318
  rangeSeparator: string;
319
319
  validateEvent: boolean;
320
- timezone: string;
320
+ timezone: string | number;
321
321
  }>, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, {
322
322
  type: string;
323
323
  timeArrowControl: boolean;
@@ -16,9 +16,7 @@ const Vue = require("vue");
16
16
  const dateUtil = require("element-ui/src/utils/date-util");
17
17
  const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
18
18
  const Locale = require("element-ui/lib/mixins/locale");
19
- require("fs");
20
- require("path");
21
- require("vue-demi");
19
+ const util = require("@94ai/common-utils/lib/util");
22
20
  function _mergeNamespaces(n, m) {
23
21
  for (var i = 0; i < m.length; i++) {
24
22
  const e = m[i];
@@ -428,14 +426,14 @@ var popper$1 = { exports: {} };
428
426
  this._popper = popper2.jquery ? popper2[0] : popper2;
429
427
  }
430
428
  this._options = Object.assign({}, DEFAULTS, options);
431
- this._options.modifiers = this._options.modifiers.map((function(modifier) {
429
+ this._options.modifiers = this._options.modifiers.map(function(modifier) {
432
430
  if (this._options.modifiersIgnored.indexOf(modifier) !== -1)
433
431
  return;
434
432
  if (modifier === "applyStyle") {
435
433
  this._popper.setAttribute("x-placement", this._options.placement);
436
434
  }
437
435
  return this.modifiers[modifier] || modifier;
438
- }).bind(this));
436
+ }.bind(this));
439
437
  this.state.position = this._getPosition(this._popper, this._reference);
440
438
  setStyle(this._popper, {
441
439
  position: this.state.position,
@@ -648,11 +646,11 @@ var popper$1 = { exports: {} };
648
646
  if (ends !== void 0) {
649
647
  modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
650
648
  }
651
- modifiersToRun.forEach((function(modifier) {
649
+ modifiersToRun.forEach(function(modifier) {
652
650
  if (isFunction(modifier)) {
653
651
  data = modifier.call(this, data);
654
652
  }
655
- }).bind(this));
653
+ }.bind(this));
656
654
  return data;
657
655
  };
658
656
  Popper2.prototype.isModifierRequired = function(requesting, requested) {
@@ -796,7 +794,7 @@ var popper$1 = { exports: {} };
796
794
  } else {
797
795
  flipOrder = this._options.flipBehavior;
798
796
  }
799
- flipOrder.forEach((function(step, index) {
797
+ flipOrder.forEach(function(step, index) {
800
798
  if (placement !== step || flipOrder.length === index + 1) {
801
799
  return;
802
800
  }
@@ -813,7 +811,7 @@ var popper$1 = { exports: {} };
813
811
  data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
814
812
  data = this.runModifiers(data, this._options.modifiers, this._flip);
815
813
  }
816
- }).bind(this));
814
+ }.bind(this));
817
815
  return data;
818
816
  };
819
817
  Popper2.prototype.modifiers.offset = function(data) {
@@ -1317,13 +1315,9 @@ const RANGE_PARSER = function(array, format, separator) {
1317
1315
  const TYPE_VALUE_RESOLVER_MAP = {
1318
1316
  default: {
1319
1317
  formatter(value) {
1320
- if (!value)
1321
- return "";
1322
1318
  return "" + value;
1323
1319
  },
1324
1320
  parser(text) {
1325
- if (text === void 0 || text === "")
1326
- return null;
1327
1321
  return text;
1328
1322
  }
1329
1323
  },
@@ -1382,8 +1376,6 @@ const TYPE_VALUE_RESOLVER_MAP = {
1382
1376
  },
1383
1377
  number: {
1384
1378
  formatter(value) {
1385
- if (!value)
1386
- return "";
1387
1379
  return "" + value;
1388
1380
  },
1389
1381
  parser(text) {
@@ -1515,9 +1507,9 @@ const _sfc_main$9 = {
1515
1507
  default: true
1516
1508
  },
1517
1509
  timezone: {
1518
- type: String || Number,
1510
+ type: [String, Number],
1519
1511
  default() {
1520
- return window.timezone || "";
1512
+ return typeof window === "undefined" ? "" : window.timezone || "";
1521
1513
  }
1522
1514
  }
1523
1515
  },
@@ -1540,10 +1532,7 @@ const _sfc_main$9 = {
1540
1532
  return reference.$el || reference;
1541
1533
  },
1542
1534
  refInput() {
1543
- if (this.reference) {
1544
- return [].slice.call(this.reference.querySelectorAll("input"));
1545
- }
1546
- return [];
1535
+ return [].slice.call(this.reference.querySelectorAll("input"));
1547
1536
  },
1548
1537
  valueIsEmpty() {
1549
1538
  const val = this.value;
@@ -1576,9 +1565,6 @@ const _sfc_main$9 = {
1576
1565
  return "day";
1577
1566
  },
1578
1567
  haveTrigger() {
1579
- if (typeof this.showTrigger !== "undefined") {
1580
- return this.showTrigger;
1581
- }
1582
1568
  return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
1583
1569
  },
1584
1570
  displayValue() {
@@ -1942,8 +1928,6 @@ const _sfc_main$9 = {
1942
1928
  this.picker.resetView && this.picker.resetView();
1943
1929
  });
1944
1930
  this.picker.$on("select-range", (start, end, pos) => {
1945
- if (this.refInput.length === 0)
1946
- return;
1947
1931
  if (!pos || pos === "min") {
1948
1932
  this.refInput[0].setSelectionRange(start, end);
1949
1933
  this.refInput[0].focus();
@@ -1982,11 +1966,7 @@ const _sfc_main$9 = {
1982
1966
  if (!this.picker) {
1983
1967
  this.mountPicker();
1984
1968
  }
1985
- if (this.picker.isValidValue) {
1986
- return value && this.picker.isValidValue(value);
1987
- } else {
1988
- return true;
1989
- }
1969
+ return value && this.picker.isValidValue(value);
1990
1970
  }
1991
1971
  }
1992
1972
  };
@@ -2590,7 +2570,7 @@ const _sfc_main$7 = {
2590
2570
  let date;
2591
2571
  if (newVal instanceof Date) {
2592
2572
  date = dateUtil.limitTimeRange(newVal, this.selectableRange, this.format);
2593
- } else if (!newVal) {
2573
+ } else {
2594
2574
  date = this.defaultValue ? new Date(this.defaultValue) : /* @__PURE__ */ new Date();
2595
2575
  }
2596
2576
  this.date = date;
@@ -2914,7 +2894,6 @@ const _sfc_main$5 = {
2914
2894
  rows() {
2915
2895
  const rows = this.tableRows;
2916
2896
  const disabledDate = this.disabledDate;
2917
- const selectedDate = [];
2918
2897
  const now = getMonthTimestamp(/* @__PURE__ */ new Date());
2919
2898
  for (let i = 0; i < 3; i++) {
2920
2899
  const row = rows[i];
@@ -2943,7 +2922,6 @@ const _sfc_main$5 = {
2943
2922
  cell.text = index;
2944
2923
  const cellDate = new Date(time);
2945
2924
  cell.disabled = typeof disabledDate === "function" && disabledDate(cellDate);
2946
- cell.selected = arrayFind(selectedDate, (date) => date.getTime() === cellDate.getTime());
2947
2925
  this.$set(row, j, cell);
2948
2926
  }
2949
2927
  }
@@ -3108,54 +3086,6 @@ var _sfc_render$5 = function render5() {
3108
3086
  var _sfc_staticRenderFns$5 = [];
3109
3087
  var __component__$5 = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main$5, _sfc_render$5, _sfc_staticRenderFns$5, false, null, null, null, null);
3110
3088
  const MonthTable = __component__$5.exports;
3111
- const add = (arg1, arg2) => {
3112
- let r1, r2, m;
3113
- try {
3114
- r1 = (arg1.toString().split(".")[1] || "").length;
3115
- } catch (e) {
3116
- r1 = 0;
3117
- }
3118
- try {
3119
- r2 = (arg2.toString().split(".")[1] || "").length;
3120
- } catch (e) {
3121
- r2 = 0;
3122
- }
3123
- m = Math.pow(10, Math.max(r1, r2));
3124
- return div(mul(arg1, m) + mul(arg2, m), m);
3125
- };
3126
- const mul = (arg1, arg2) => {
3127
- let m = 0;
3128
- const s1 = arg1.toString();
3129
- const s2 = arg2.toString();
3130
- m += (s1.split(".")[1] || "").length;
3131
- m += (s2.split(".")[1] || "").length;
3132
- return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
3133
- };
3134
- const div = (arg1, arg2) => {
3135
- const t1 = (arg1.toString().split(".")[1] || "").length;
3136
- const t2 = (arg2.toString().split(".")[1] || "").length;
3137
- const r1 = Number(arg1.toString().replace(".", ""));
3138
- const r2 = Number(arg2.toString().replace(".", ""));
3139
- return r1 / r2 * Math.pow(10, t2 - t1);
3140
- };
3141
- function getLocalTime(i) {
3142
- let time = i;
3143
- if (typeof time === "string") {
3144
- const arr = time.split(":");
3145
- if (arr.length < 2) {
3146
- return /* @__PURE__ */ new Date();
3147
- }
3148
- time = add(Number(arr[0]), div(Math.floor(Number(arr[1])), 60));
3149
- }
3150
- if (typeof time !== "number") {
3151
- return /* @__PURE__ */ new Date();
3152
- }
3153
- const d = /* @__PURE__ */ new Date();
3154
- const len = d.getTime();
3155
- const offset = d.getTimezoneOffset() * 6e4;
3156
- const utcTime = len + offset;
3157
- return new Date(utcTime + 36e5 * time);
3158
- }
3159
3089
  const WEEKS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
3160
3090
  const getDateTimestamp = function(time) {
3161
3091
  if (typeof time === "number" || typeof time === "string") {
@@ -3167,7 +3097,7 @@ const getDateTimestamp = function(time) {
3167
3097
  }
3168
3098
  };
3169
3099
  const removeFromArray = function(arr, pred) {
3170
- const idx = typeof pred === "function" ? arrayFindIndex(arr, pred) : arr.indexOf(pred);
3100
+ const idx = arrayFindIndex(arr, pred);
3171
3101
  return idx >= 0 ? [...arr.slice(0, idx), ...arr.slice(idx + 1)] : arr;
3172
3102
  };
3173
3103
  const _sfc_main$4 = {
@@ -3205,7 +3135,7 @@ const _sfc_main$4 = {
3205
3135
  }
3206
3136
  },
3207
3137
  timezone: {
3208
- type: String || Number,
3138
+ type: [String, Number],
3209
3139
  default: ""
3210
3140
  // 没有传则使用本地的时区
3211
3141
  }
@@ -3248,7 +3178,7 @@ const _sfc_main$4 = {
3248
3178
  const disabledDate = this.disabledDate;
3249
3179
  const cellClassName = this.cellClassName;
3250
3180
  const selectedDate = this.selectionMode === "dates" ? coerceTruthyValueToArray(this.value) : [];
3251
- const now = getDateTimestamp(getLocalTime(this.timezone));
3181
+ const now = getDateTimestamp(util.getLocalTime(this.timezone));
3252
3182
  for (let i = 0; i < 6; i++) {
3253
3183
  const row = rows[i];
3254
3184
  if (this.showWeekNumber) {
@@ -3281,7 +3211,7 @@ const _sfc_main$4 = {
3281
3211
  if (isToday) {
3282
3212
  cell.type = "today";
3283
3213
  }
3284
- if (i >= 0 && i <= 1) {
3214
+ if (i <= 1) {
3285
3215
  const numberOfDaysFromPreviousMonth = day + offset < 0 ? 7 + day + offset : day + offset;
3286
3216
  if (j + i * 7 >= numberOfDaysFromPreviousMonth) {
3287
3217
  cell.text = count++;
@@ -14,9 +14,7 @@ import Vue from "vue";
14
14
  import { isDateObject, getWeekNumber, formatDate, parseDate, getRangeHours, getRangeMinutes, modifyTime, limitTimeRange, isDate, clearMilliseconds, timeWithinRange, getDayCountOfYear, range, nextDate, getDayCountOfMonth, getStartDateOfMonth, getFirstDayOfMonth, prevDate, clearTime, extractTimeFormat, extractDateFormat, prevMonth, nextMonth, prevYear, nextYear, modifyWithTimeString, modifyDate, changeYearMonthAndClampDate } from "element-ui/src/utils/date-util";
15
15
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
16
16
  import Locale from "element-ui/lib/mixins/locale";
17
- import "fs";
18
- import "path";
19
- import "vue-demi";
17
+ import { getLocalTime } from "@94ai/common-utils/lib/util";
20
18
  function _mergeNamespaces(n, m) {
21
19
  for (var i = 0; i < m.length; i++) {
22
20
  const e = m[i];
@@ -426,14 +424,14 @@ var popper$1 = { exports: {} };
426
424
  this._popper = popper2.jquery ? popper2[0] : popper2;
427
425
  }
428
426
  this._options = Object.assign({}, DEFAULTS, options);
429
- this._options.modifiers = this._options.modifiers.map((function(modifier) {
427
+ this._options.modifiers = this._options.modifiers.map(function(modifier) {
430
428
  if (this._options.modifiersIgnored.indexOf(modifier) !== -1)
431
429
  return;
432
430
  if (modifier === "applyStyle") {
433
431
  this._popper.setAttribute("x-placement", this._options.placement);
434
432
  }
435
433
  return this.modifiers[modifier] || modifier;
436
- }).bind(this));
434
+ }.bind(this));
437
435
  this.state.position = this._getPosition(this._popper, this._reference);
438
436
  setStyle(this._popper, {
439
437
  position: this.state.position,
@@ -646,11 +644,11 @@ var popper$1 = { exports: {} };
646
644
  if (ends !== void 0) {
647
645
  modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
648
646
  }
649
- modifiersToRun.forEach((function(modifier) {
647
+ modifiersToRun.forEach(function(modifier) {
650
648
  if (isFunction(modifier)) {
651
649
  data = modifier.call(this, data);
652
650
  }
653
- }).bind(this));
651
+ }.bind(this));
654
652
  return data;
655
653
  };
656
654
  Popper2.prototype.isModifierRequired = function(requesting, requested) {
@@ -794,7 +792,7 @@ var popper$1 = { exports: {} };
794
792
  } else {
795
793
  flipOrder = this._options.flipBehavior;
796
794
  }
797
- flipOrder.forEach((function(step, index) {
795
+ flipOrder.forEach(function(step, index) {
798
796
  if (placement !== step || flipOrder.length === index + 1) {
799
797
  return;
800
798
  }
@@ -811,7 +809,7 @@ var popper$1 = { exports: {} };
811
809
  data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
812
810
  data = this.runModifiers(data, this._options.modifiers, this._flip);
813
811
  }
814
- }).bind(this));
812
+ }.bind(this));
815
813
  return data;
816
814
  };
817
815
  Popper2.prototype.modifiers.offset = function(data) {
@@ -1315,13 +1313,9 @@ const RANGE_PARSER = function(array, format, separator) {
1315
1313
  const TYPE_VALUE_RESOLVER_MAP = {
1316
1314
  default: {
1317
1315
  formatter(value) {
1318
- if (!value)
1319
- return "";
1320
1316
  return "" + value;
1321
1317
  },
1322
1318
  parser(text) {
1323
- if (text === void 0 || text === "")
1324
- return null;
1325
1319
  return text;
1326
1320
  }
1327
1321
  },
@@ -1380,8 +1374,6 @@ const TYPE_VALUE_RESOLVER_MAP = {
1380
1374
  },
1381
1375
  number: {
1382
1376
  formatter(value) {
1383
- if (!value)
1384
- return "";
1385
1377
  return "" + value;
1386
1378
  },
1387
1379
  parser(text) {
@@ -1513,9 +1505,9 @@ const _sfc_main$9 = {
1513
1505
  default: true
1514
1506
  },
1515
1507
  timezone: {
1516
- type: String || Number,
1508
+ type: [String, Number],
1517
1509
  default() {
1518
- return window.timezone || "";
1510
+ return typeof window === "undefined" ? "" : window.timezone || "";
1519
1511
  }
1520
1512
  }
1521
1513
  },
@@ -1538,10 +1530,7 @@ const _sfc_main$9 = {
1538
1530
  return reference.$el || reference;
1539
1531
  },
1540
1532
  refInput() {
1541
- if (this.reference) {
1542
- return [].slice.call(this.reference.querySelectorAll("input"));
1543
- }
1544
- return [];
1533
+ return [].slice.call(this.reference.querySelectorAll("input"));
1545
1534
  },
1546
1535
  valueIsEmpty() {
1547
1536
  const val = this.value;
@@ -1574,9 +1563,6 @@ const _sfc_main$9 = {
1574
1563
  return "day";
1575
1564
  },
1576
1565
  haveTrigger() {
1577
- if (typeof this.showTrigger !== "undefined") {
1578
- return this.showTrigger;
1579
- }
1580
1566
  return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
1581
1567
  },
1582
1568
  displayValue() {
@@ -1940,8 +1926,6 @@ const _sfc_main$9 = {
1940
1926
  this.picker.resetView && this.picker.resetView();
1941
1927
  });
1942
1928
  this.picker.$on("select-range", (start, end, pos) => {
1943
- if (this.refInput.length === 0)
1944
- return;
1945
1929
  if (!pos || pos === "min") {
1946
1930
  this.refInput[0].setSelectionRange(start, end);
1947
1931
  this.refInput[0].focus();
@@ -1980,11 +1964,7 @@ const _sfc_main$9 = {
1980
1964
  if (!this.picker) {
1981
1965
  this.mountPicker();
1982
1966
  }
1983
- if (this.picker.isValidValue) {
1984
- return value && this.picker.isValidValue(value);
1985
- } else {
1986
- return true;
1987
- }
1967
+ return value && this.picker.isValidValue(value);
1988
1968
  }
1989
1969
  }
1990
1970
  };
@@ -2588,7 +2568,7 @@ const _sfc_main$7 = {
2588
2568
  let date;
2589
2569
  if (newVal instanceof Date) {
2590
2570
  date = limitTimeRange(newVal, this.selectableRange, this.format);
2591
- } else if (!newVal) {
2571
+ } else {
2592
2572
  date = this.defaultValue ? new Date(this.defaultValue) : /* @__PURE__ */ new Date();
2593
2573
  }
2594
2574
  this.date = date;
@@ -2912,7 +2892,6 @@ const _sfc_main$5 = {
2912
2892
  rows() {
2913
2893
  const rows = this.tableRows;
2914
2894
  const disabledDate = this.disabledDate;
2915
- const selectedDate = [];
2916
2895
  const now = getMonthTimestamp(/* @__PURE__ */ new Date());
2917
2896
  for (let i = 0; i < 3; i++) {
2918
2897
  const row = rows[i];
@@ -2941,7 +2920,6 @@ const _sfc_main$5 = {
2941
2920
  cell.text = index;
2942
2921
  const cellDate = new Date(time);
2943
2922
  cell.disabled = typeof disabledDate === "function" && disabledDate(cellDate);
2944
- cell.selected = arrayFind(selectedDate, (date) => date.getTime() === cellDate.getTime());
2945
2923
  this.$set(row, j, cell);
2946
2924
  }
2947
2925
  }
@@ -3106,54 +3084,6 @@ var _sfc_render$5 = function render5() {
3106
3084
  var _sfc_staticRenderFns$5 = [];
3107
3085
  var __component__$5 = /* @__PURE__ */ normalizeComponent(_sfc_main$5, _sfc_render$5, _sfc_staticRenderFns$5, false, null, null, null, null);
3108
3086
  const MonthTable = __component__$5.exports;
3109
- const add = (arg1, arg2) => {
3110
- let r1, r2, m;
3111
- try {
3112
- r1 = (arg1.toString().split(".")[1] || "").length;
3113
- } catch (e) {
3114
- r1 = 0;
3115
- }
3116
- try {
3117
- r2 = (arg2.toString().split(".")[1] || "").length;
3118
- } catch (e) {
3119
- r2 = 0;
3120
- }
3121
- m = Math.pow(10, Math.max(r1, r2));
3122
- return div(mul(arg1, m) + mul(arg2, m), m);
3123
- };
3124
- const mul = (arg1, arg2) => {
3125
- let m = 0;
3126
- const s1 = arg1.toString();
3127
- const s2 = arg2.toString();
3128
- m += (s1.split(".")[1] || "").length;
3129
- m += (s2.split(".")[1] || "").length;
3130
- return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
3131
- };
3132
- const div = (arg1, arg2) => {
3133
- const t1 = (arg1.toString().split(".")[1] || "").length;
3134
- const t2 = (arg2.toString().split(".")[1] || "").length;
3135
- const r1 = Number(arg1.toString().replace(".", ""));
3136
- const r2 = Number(arg2.toString().replace(".", ""));
3137
- return r1 / r2 * Math.pow(10, t2 - t1);
3138
- };
3139
- function getLocalTime(i) {
3140
- let time = i;
3141
- if (typeof time === "string") {
3142
- const arr = time.split(":");
3143
- if (arr.length < 2) {
3144
- return /* @__PURE__ */ new Date();
3145
- }
3146
- time = add(Number(arr[0]), div(Math.floor(Number(arr[1])), 60));
3147
- }
3148
- if (typeof time !== "number") {
3149
- return /* @__PURE__ */ new Date();
3150
- }
3151
- const d = /* @__PURE__ */ new Date();
3152
- const len = d.getTime();
3153
- const offset = d.getTimezoneOffset() * 6e4;
3154
- const utcTime = len + offset;
3155
- return new Date(utcTime + 36e5 * time);
3156
- }
3157
3087
  const WEEKS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
3158
3088
  const getDateTimestamp = function(time) {
3159
3089
  if (typeof time === "number" || typeof time === "string") {
@@ -3165,7 +3095,7 @@ const getDateTimestamp = function(time) {
3165
3095
  }
3166
3096
  };
3167
3097
  const removeFromArray = function(arr, pred) {
3168
- const idx = typeof pred === "function" ? arrayFindIndex(arr, pred) : arr.indexOf(pred);
3098
+ const idx = arrayFindIndex(arr, pred);
3169
3099
  return idx >= 0 ? [...arr.slice(0, idx), ...arr.slice(idx + 1)] : arr;
3170
3100
  };
3171
3101
  const _sfc_main$4 = {
@@ -3203,7 +3133,7 @@ const _sfc_main$4 = {
3203
3133
  }
3204
3134
  },
3205
3135
  timezone: {
3206
- type: String || Number,
3136
+ type: [String, Number],
3207
3137
  default: ""
3208
3138
  // 没有传则使用本地的时区
3209
3139
  }
@@ -3279,7 +3209,7 @@ const _sfc_main$4 = {
3279
3209
  if (isToday) {
3280
3210
  cell.type = "today";
3281
3211
  }
3282
- if (i >= 0 && i <= 1) {
3212
+ if (i <= 1) {
3283
3213
  const numberOfDaysFromPreviousMonth = day + offset < 0 ? 7 + day + offset : day + offset;
3284
3214
  if (j + i * 7 >= numberOfDaysFromPreviousMonth) {
3285
3215
  cell.text = count++;
@@ -52,7 +52,7 @@ declare var _default: import("vue").DefineComponent<{
52
52
  default: boolean;
53
53
  };
54
54
  timezone: {
55
- type: StringConstructor;
55
+ type: (StringConstructor | NumberConstructor)[];
56
56
  default(): any;
57
57
  };
58
58
  }, {}, {
@@ -68,7 +68,7 @@ declare var _default: import("vue").DefineComponent<{
68
68
  valueIsEmpty(): boolean;
69
69
  triggerClass(): any;
70
70
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
71
- haveTrigger(): any;
71
+ haveTrigger(): boolean;
72
72
  displayValue(): any;
73
73
  parsedValue(): any;
74
74
  _elFormItemSize(): any;
@@ -128,7 +128,7 @@ declare var _default: import("vue").DefineComponent<{
128
128
  default: boolean;
129
129
  };
130
130
  timezone: {
131
- type: StringConstructor;
131
+ type: (StringConstructor | NumberConstructor)[];
132
132
  default(): any;
133
133
  };
134
134
  }>>, {
@@ -143,7 +143,7 @@ declare var _default: import("vue").DefineComponent<{
143
143
  align: string;
144
144
  rangeSeparator: string;
145
145
  validateEvent: boolean;
146
- timezone: string;
146
+ timezone: string | number;
147
147
  }>, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
148
148
  type: {
149
149
  type: StringConstructor;
@@ -46,7 +46,7 @@ declare var _default: import("vue").DefineComponent<{
46
46
  default: boolean;
47
47
  };
48
48
  timezone: {
49
- type: StringConstructor;
49
+ type: (StringConstructor | NumberConstructor)[];
50
50
  default(): any;
51
51
  };
52
52
  }, {}, {
@@ -62,7 +62,7 @@ declare var _default: import("vue").DefineComponent<{
62
62
  valueIsEmpty(): boolean;
63
63
  triggerClass(): any;
64
64
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
65
- haveTrigger(): any;
65
+ haveTrigger(): boolean;
66
66
  displayValue(): any;
67
67
  parsedValue(): any;
68
68
  _elFormItemSize(): any;
@@ -122,7 +122,7 @@ declare var _default: import("vue").DefineComponent<{
122
122
  default: boolean;
123
123
  };
124
124
  timezone: {
125
- type: StringConstructor;
125
+ type: (StringConstructor | NumberConstructor)[];
126
126
  default(): any;
127
127
  };
128
128
  }>>, {
@@ -137,6 +137,6 @@ declare var _default: import("vue").DefineComponent<{
137
137
  align: string;
138
138
  rangeSeparator: string;
139
139
  validateEvent: boolean;
140
- timezone: string;
140
+ timezone: string | number;
141
141
  }>;
142
142
  export default _default;
@@ -54,7 +54,7 @@ const getDateTimestamp = function(time) {
54
54
  // return a new array if modification occurs
55
55
  // return the original array otherwise
56
56
  const removeFromArray = function(arr, pred) {
57
- const idx = typeof pred === 'function' ? arrayFindIndex(arr, pred) : arr.indexOf(pred)
57
+ const idx = arrayFindIndex(arr, pred)
58
58
  return idx >= 0 ? [...arr.slice(0, idx), ...arr.slice(idx + 1)] : arr
59
59
  }
60
60
 
@@ -105,7 +105,7 @@ export default {
105
105
  }
106
106
  },
107
107
  timezone: {
108
- type: String || Number,
108
+ type: [String, Number],
109
109
  default: '' // 没有传则使用本地的时区
110
110
  },
111
111
  },
@@ -189,7 +189,7 @@ export default {
189
189
  cell.type = 'today'
190
190
  }
191
191
 
192
- if (i >= 0 && i <= 1) {
192
+ if (i <= 1) {
193
193
  const numberOfDaysFromPreviousMonth = day + offset < 0 ? 7 + day + offset : day + offset
194
194
 
195
195
  if (j + i * 7 >= numberOfDaysFromPreviousMonth) {
@@ -16,7 +16,7 @@
16
16
  import Locale from 'element-ui/lib/mixins/locale'
17
17
  import { isDate, range, getDayCountOfMonth, nextDate } from 'element-ui/src/utils/date-util'
18
18
  import { hasClass } from 'element-ui/src/utils/dom'
19
- import { arrayFindIndex, coerceTruthyValueToArray, arrayFind } from 'element-ui/src/utils/util'
19
+ import { arrayFindIndex, coerceTruthyValueToArray } from 'element-ui/src/utils/util'
20
20
 
21
21
  const datesInMonth = (year, month) => {
22
22
  const numOfDays = getDayCountOfMonth(year, month)
@@ -80,7 +80,6 @@ export default {
80
80
  // TODO: refactory rows / getCellClasses
81
81
  const rows = this.tableRows
82
82
  const disabledDate = this.disabledDate
83
- const selectedDate = []
84
83
  const now = getMonthTimestamp(new Date())
85
84
 
86
85
  for (let i = 0; i < 3; i++) {
@@ -106,7 +105,6 @@ export default {
106
105
  cell.text = index
107
106
  const cellDate = new Date(time)
108
107
  cell.disabled = typeof disabledDate === 'function' && disabledDate(cellDate)
109
- cell.selected = arrayFind(selectedDate, date => date.getTime() === cellDate.getTime())
110
108
 
111
109
  this.$set(row, j, cell)
112
110
  }
@@ -30,6 +30,7 @@ const parseTime = function(time) {
30
30
  const hours = parseInt(values[0], 10)
31
31
  const minutes = parseInt(values[1], 10)
32
32
 
33
+ if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return null
33
34
  return {
34
35
  hours,
35
36
  minutes
@@ -100,6 +101,10 @@ export default {
100
101
  const result = []
101
102
 
102
103
  if (start && end && step) {
104
+ const startTime = parseTime(start)
105
+ const endTime = parseTime(end)
106
+ const stepTime = parseTime(step)
107
+ if (!startTime || !endTime || !stepTime || stepTime.hours * 60 + stepTime.minutes <= 0) return result
103
108
  let current = start
104
109
  while (compareTime(current, end) <= 0) {
105
110
  result.push({
@@ -94,7 +94,7 @@ export default {
94
94
  let date
95
95
  if (newVal instanceof Date) {
96
96
  date = limitTimeRange(newVal, this.selectableRange, this.format)
97
- } else if (!newVal) {
97
+ } else {
98
98
  date = this.defaultValue ? new Date(this.defaultValue) : new Date()
99
99
  }
100
100
 
@@ -1,7 +1,7 @@
1
- import Picker from '../picker'
2
- import DatePanel from '../panel/date'
3
- import DateRangePanel from '../panel/date-range'
4
- import MonthRangePanel from '../panel/month-range'
1
+ import Picker from '../picker.vue'
2
+ import DatePanel from '../panel/date.vue'
3
+ import DateRangePanel from '../panel/date-range.vue'
4
+ import MonthRangePanel from '../panel/month-range.vue'
5
5
 
6
6
  const getPanel = function(type) {
7
7
  if (type === 'daterange' || type === 'datetimerange') {
@@ -1,6 +1,6 @@
1
- import Picker from '../picker'
2
- import TimePanel from '../panel/time'
3
- import TimeRangePanel from '../panel/time-range'
1
+ import Picker from '../picker.vue'
2
+ import TimePanel from '../panel/time.vue'
3
+ import TimeRangePanel from '../panel/time-range.vue'
4
4
 
5
5
  export default {
6
6
  mixins: [Picker],
@@ -1,5 +1,5 @@
1
- import Picker from '../picker'
2
- import Panel from '../panel/time-select'
1
+ import Picker from '../picker.vue'
2
+ import Panel from '../panel/time-select.vue'
3
3
 
4
4
  export default {
5
5
  mixins: [Picker],
@@ -171,11 +171,9 @@ const RANGE_PARSER = function(array, format, separator) {
171
171
  const TYPE_VALUE_RESOLVER_MAP = {
172
172
  default: {
173
173
  formatter(value) {
174
- if (!value) return ''
175
174
  return '' + value
176
175
  },
177
176
  parser(text) {
178
- if (text === undefined || text === '') return null
179
177
  return text
180
178
  }
181
179
  },
@@ -238,7 +236,6 @@ const TYPE_VALUE_RESOLVER_MAP = {
238
236
  },
239
237
  number: {
240
238
  formatter(value) {
241
- if (!value) return ''
242
239
  return '' + value
243
240
  },
244
241
  parser(text) {
@@ -397,9 +394,9 @@ export default {
397
394
  default: true
398
395
  },
399
396
  timezone: {
400
- type: String || Number,
397
+ type: [String, Number],
401
398
  default() {
402
- return window.timezone || '' // 没有传则使用本地的时区
399
+ return typeof window === 'undefined' ? '' : window.timezone || '' // 没有传则使用本地的时区
403
400
  }
404
401
  }
405
402
  },
@@ -425,10 +422,7 @@ export default {
425
422
  },
426
423
 
427
424
  refInput() {
428
- if (this.reference) {
429
- return [].slice.call(this.reference.querySelectorAll('input'))
430
- }
431
- return []
425
+ return [].slice.call(this.reference.querySelectorAll('input'))
432
426
  },
433
427
 
434
428
  valueIsEmpty() {
@@ -466,9 +460,6 @@ export default {
466
460
  },
467
461
 
468
462
  haveTrigger() {
469
- if (typeof this.showTrigger !== 'undefined') {
470
- return this.showTrigger
471
- }
472
463
  return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1
473
464
  },
474
465
 
@@ -890,7 +881,6 @@ export default {
890
881
  })
891
882
 
892
883
  this.picker.$on('select-range', (start, end, pos) => {
893
- if (this.refInput.length === 0) return
894
884
  if (!pos || pos === 'min') {
895
885
  this.refInput[0].setSelectionRange(start, end)
896
886
  this.refInput[0].focus()
@@ -934,11 +924,7 @@ export default {
934
924
  if (!this.picker) {
935
925
  this.mountPicker()
936
926
  }
937
- if (this.picker.isValidValue) {
938
- return value && this.picker.isValidValue(value)
939
- } else {
940
- return true
941
- }
927
+ return value && this.picker.isValidValue(value)
942
928
  }
943
929
  }
944
930
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-timezone-picker",
3
- "version": "8.3.23",
3
+ "version": "10.0.0",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -11,11 +11,13 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "http://94ai.gitlab.com/ui/common-ui.git"
14
+ "url": "http://gitlab.94ai.pro/ui/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^8.3.23",
18
- "vue-demi": "^0.14.5"
17
+ "@94ai/common-utils": "^10.0.0",
18
+ "@94ai/nf-theme-chalk": "^10.0.0",
19
+ "vue-demi": "^0.14.5",
20
+ "@94ai/vue2-runtime-helpers": "1.0.1"
19
21
  },
20
22
  "peerDependenciesMeta": {
21
23
  "@vue/composition-api": {
@@ -24,11 +26,10 @@
24
26
  },
25
27
  "peerDependencies": {
26
28
  "@vue/composition-api": "^1.0.0-rc.1",
27
- "element-ui": ">=2.13.2",
28
- "vue": "^2.0.0 || >=3.0.0"
29
+ "vue": "^2.0.0 || >=3.0.0",
30
+ "element-ui": ">=2.13.2"
29
31
  },
30
32
  "types": "lib/index.d.ts",
31
33
  "main": "lib/nf-timezone-picker.cjs.js",
32
- "module": "lib/nf-timezone-picker.esm-bundler.js",
33
- "gitHead": "74e871c7972dc4576480bee02b1dc61a3eafc6ba"
34
+ "module": "lib/nf-timezone-picker.esm-bundler.js"
34
35
  }