@94ai/nf-timezone-picker 9.0.0 → 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.
@@ -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];
@@ -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];
@@ -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++;