@94ai/nf-double-year 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.
package/lib/index.d.ts CHANGED
@@ -16,11 +16,11 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
16
16
  placeholder: StringConstructor;
17
17
  startPlaceholder: {
18
18
  type: StringConstructor;
19
- default: string;
19
+ default: undefined;
20
20
  };
21
21
  endPlaceholder: {
22
22
  type: StringConstructor;
23
- default: string;
23
+ default: undefined;
24
24
  };
25
25
  prefixIcon: StringConstructor;
26
26
  clearIcon: {
@@ -103,11 +103,11 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
103
103
  placeholder: StringConstructor;
104
104
  startPlaceholder: {
105
105
  type: StringConstructor;
106
- default: string;
106
+ default: undefined;
107
107
  };
108
108
  endPlaceholder: {
109
109
  type: StringConstructor;
110
- default: string;
110
+ default: undefined;
111
111
  };
112
112
  prefixIcon: StringConstructor;
113
113
  clearIcon: {
@@ -162,13 +162,17 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
162
162
  valueOnOpen: null;
163
163
  unwatchPickerOptions: null;
164
164
  } & import("vue/types/v3-component-options").ExtractComputedReturns<{
165
+ localeText(): {
166
+ startPlaceholder: any;
167
+ endPlaceholder: any;
168
+ };
165
169
  ranged(): boolean;
166
170
  reference(): any;
167
171
  refInput(): never[];
168
172
  valueIsEmpty(): boolean;
169
173
  triggerClass(): any;
170
174
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
171
- haveTrigger(): any;
175
+ haveTrigger(): boolean;
172
176
  displayValue(): any;
173
177
  parsedValue(): any;
174
178
  _elFormItemSize(): any;
@@ -203,11 +207,11 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
203
207
  placeholder: StringConstructor;
204
208
  startPlaceholder: {
205
209
  type: StringConstructor;
206
- default: string;
210
+ default: undefined;
207
211
  };
208
212
  endPlaceholder: {
209
213
  type: StringConstructor;
210
- default: string;
214
+ default: undefined;
211
215
  };
212
216
  prefixIcon: StringConstructor;
213
217
  clearIcon: {
@@ -256,13 +260,17 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
256
260
  valueOnOpen: null;
257
261
  unwatchPickerOptions: null;
258
262
  }, {
263
+ localeText(): {
264
+ startPlaceholder: any;
265
+ endPlaceholder: any;
266
+ };
259
267
  ranged(): boolean;
260
268
  reference(): any;
261
269
  refInput(): never[];
262
270
  valueIsEmpty(): boolean;
263
271
  triggerClass(): any;
264
272
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
265
- haveTrigger(): any;
273
+ haveTrigger(): boolean;
266
274
  displayValue(): any;
267
275
  parsedValue(): any;
268
276
  _elFormItemSize(): any;
@@ -285,11 +293,11 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
285
293
  placeholder: StringConstructor;
286
294
  startPlaceholder: {
287
295
  type: StringConstructor;
288
- default: string;
296
+ default: undefined;
289
297
  };
290
298
  endPlaceholder: {
291
299
  type: StringConstructor;
292
- default: string;
300
+ default: undefined;
293
301
  };
294
302
  prefixIcon: StringConstructor;
295
303
  clearIcon: {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const commonUtils = require("@94ai/common-utils");
3
4
  const Vue = require("vue");
4
5
  const dateUtil = require("element-ui/src/utils/date-util");
5
6
  const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
@@ -389,14 +390,14 @@ var popper$1 = { exports: {} };
389
390
  this._popper = popper2.jquery ? popper2[0] : popper2;
390
391
  }
391
392
  this._options = Object.assign({}, DEFAULTS, options);
392
- this._options.modifiers = this._options.modifiers.map((function(modifier) {
393
+ this._options.modifiers = this._options.modifiers.map(function(modifier) {
393
394
  if (this._options.modifiersIgnored.indexOf(modifier) !== -1)
394
395
  return;
395
396
  if (modifier === "applyStyle") {
396
397
  this._popper.setAttribute("x-placement", this._options.placement);
397
398
  }
398
399
  return this.modifiers[modifier] || modifier;
399
- }).bind(this));
400
+ }.bind(this));
400
401
  this.state.position = this._getPosition(this._popper, this._reference);
401
402
  setStyle(this._popper, {
402
403
  position: this.state.position,
@@ -609,11 +610,11 @@ var popper$1 = { exports: {} };
609
610
  if (ends !== void 0) {
610
611
  modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
611
612
  }
612
- modifiersToRun.forEach((function(modifier) {
613
+ modifiersToRun.forEach(function(modifier) {
613
614
  if (isFunction(modifier)) {
614
615
  data = modifier.call(this, data);
615
616
  }
616
- }).bind(this));
617
+ }.bind(this));
617
618
  return data;
618
619
  };
619
620
  Popper2.prototype.isModifierRequired = function(requesting, requested) {
@@ -757,7 +758,7 @@ var popper$1 = { exports: {} };
757
758
  } else {
758
759
  flipOrder = this._options.flipBehavior;
759
760
  }
760
- flipOrder.forEach((function(step, index) {
761
+ flipOrder.forEach(function(step, index) {
761
762
  if (placement !== step || flipOrder.length === index + 1) {
762
763
  return;
763
764
  }
@@ -774,7 +775,7 @@ var popper$1 = { exports: {} };
774
775
  data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
775
776
  data = this.runModifiers(data, this._options.modifiers, this._flip);
776
777
  }
777
- }).bind(this));
778
+ }.bind(this));
778
779
  return data;
779
780
  };
780
781
  Popper2.prototype.modifiers.offset = function(data) {
@@ -1279,13 +1280,9 @@ const RANGE_PARSER = function(array, format, separator) {
1279
1280
  const TYPE_VALUE_RESOLVER_MAP = {
1280
1281
  default: {
1281
1282
  formatter(value) {
1282
- if (!value)
1283
- return "";
1284
1283
  return "" + value;
1285
1284
  },
1286
1285
  parser(text) {
1287
- if (text === void 0 || text === "")
1288
- return null;
1289
1286
  return text;
1290
1287
  }
1291
1288
  },
@@ -1348,8 +1345,6 @@ const TYPE_VALUE_RESOLVER_MAP = {
1348
1345
  },
1349
1346
  number: {
1350
1347
  formatter(value) {
1351
- if (!value)
1352
- return "";
1353
1348
  return "" + value;
1354
1349
  },
1355
1350
  parser(text) {
@@ -1421,7 +1416,7 @@ const validator = function(val) {
1421
1416
  return val === null || val === void 0 || isString(val) || Array.isArray(val) && val.length === 2 && val.every(isString);
1422
1417
  };
1423
1418
  const _sfc_main$3 = {
1424
- mixins: [Emitter, NewPopper],
1419
+ mixins: [commonUtils.LocaleMixin, Emitter, NewPopper],
1425
1420
  inject: {
1426
1421
  elForm: {
1427
1422
  default: ""
@@ -1441,11 +1436,11 @@ const _sfc_main$3 = {
1441
1436
  placeholder: String,
1442
1437
  startPlaceholder: {
1443
1438
  type: String,
1444
- default: "开始年份"
1439
+ default: void 0
1445
1440
  },
1446
1441
  endPlaceholder: {
1447
1442
  type: String,
1448
- default: "结束年份"
1443
+ default: void 0
1449
1444
  },
1450
1445
  prefixIcon: String,
1451
1446
  clearIcon: {
@@ -1539,6 +1534,13 @@ const _sfc_main$3 = {
1539
1534
  }
1540
1535
  },
1541
1536
  computed: {
1537
+ localeText() {
1538
+ var _a, _b;
1539
+ return {
1540
+ startPlaceholder: (_a = this.startPlaceholder) != null ? _a : this.t("nf.date.startYear"),
1541
+ endPlaceholder: (_b = this.endPlaceholder) != null ? _b : this.t("nf.date.endYear")
1542
+ };
1543
+ },
1542
1544
  ranged() {
1543
1545
  return this.type.indexOf("range") > -1;
1544
1546
  },
@@ -1547,10 +1549,7 @@ const _sfc_main$3 = {
1547
1549
  return reference.$el || reference;
1548
1550
  },
1549
1551
  refInput() {
1550
- if (this.reference) {
1551
- return [].slice.call(this.reference.querySelectorAll("input"));
1552
- }
1553
- return [];
1552
+ return [].slice.call(this.reference.querySelectorAll("input"));
1554
1553
  },
1555
1554
  valueIsEmpty() {
1556
1555
  const val = this.value;
@@ -1583,9 +1582,6 @@ const _sfc_main$3 = {
1583
1582
  return "day";
1584
1583
  },
1585
1584
  haveTrigger() {
1586
- if (typeof this.showTrigger !== "undefined") {
1587
- return this.showTrigger;
1588
- }
1589
1585
  return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
1590
1586
  },
1591
1587
  displayValue() {
@@ -1825,9 +1821,6 @@ const _sfc_main$3 = {
1825
1821
  event.stopPropagation();
1826
1822
  return;
1827
1823
  }
1828
- if (this.picker && this.picker.handleKeydown) {
1829
- this.picker.handleKeydown(event);
1830
- }
1831
1824
  },
1832
1825
  handleRangeClick() {
1833
1826
  const type = this.type;
@@ -1838,7 +1831,6 @@ const _sfc_main$3 = {
1838
1831
  },
1839
1832
  hidePicker() {
1840
1833
  if (this.picker) {
1841
- this.picker.resetView && this.picker.resetView();
1842
1834
  this.pickerVisible = this.picker.visible = false;
1843
1835
  this.destroyPopper();
1844
1836
  }
@@ -1852,10 +1844,6 @@ const _sfc_main$3 = {
1852
1844
  this.pickerVisible = this.picker.visible = true;
1853
1845
  this.updatePopper();
1854
1846
  this.picker.value = this.parsedValue;
1855
- this.picker.resetView && this.picker.resetView();
1856
- this.$nextTick(() => {
1857
- this.picker.adjustSpinners && this.picker.adjustSpinners();
1858
- });
1859
1847
  },
1860
1848
  mountPicker() {
1861
1849
  this.picker = new Vue(this.panel).$mount();
@@ -1895,13 +1883,11 @@ const _sfc_main$3 = {
1895
1883
  deep: true
1896
1884
  });
1897
1885
  this.$el.appendChild(this.picker.$el);
1898
- this.picker.resetView && this.picker.resetView();
1899
1886
  this.picker.$on("dodestroy", this.doDestroy);
1900
1887
  this.picker.$on("pick", (date = "", visible = false) => {
1901
1888
  this.userInput = null;
1902
1889
  this.pickerVisible = this.picker.visible = visible;
1903
1890
  this.emitInput(date);
1904
- this.picker.resetView && this.picker.resetView();
1905
1891
  });
1906
1892
  this.picker.$on("select-range", (start, end, pos) => {
1907
1893
  if (this.refInput.length === 0)
@@ -1946,11 +1932,7 @@ const _sfc_main$3 = {
1946
1932
  if (!this.picker) {
1947
1933
  this.mountPicker();
1948
1934
  }
1949
- if (this.picker.isValidValue) {
1950
- return value && this.picker.isValidValue(value);
1951
- } else {
1952
- return true;
1953
- }
1935
+ return this.picker.isValidValue(value);
1954
1936
  }
1955
1937
  }
1956
1938
  };
@@ -2035,7 +2017,7 @@ var _sfc_render$3 = function render() {
2035
2017
  staticClass: "el-range-input",
2036
2018
  attrs: {
2037
2019
  "autocomplete": "off",
2038
- "placeholder": _vm.startPlaceholder,
2020
+ "placeholder": _vm.localeText.startPlaceholder,
2039
2021
  "disabled": _vm.pickerDisabled,
2040
2022
  "readonly": !_vm.editable || _vm.readonly,
2041
2023
  "name": _vm.name && _vm.name[0]
@@ -2056,7 +2038,7 @@ var _sfc_render$3 = function render() {
2056
2038
  staticClass: "el-range-input",
2057
2039
  attrs: {
2058
2040
  "autocomplete": "off",
2059
- "placeholder": _vm.endPlaceholder,
2041
+ "placeholder": _vm.localeText.endPlaceholder,
2060
2042
  "disabled": _vm.pickerDisabled,
2061
2043
  "readonly": !_vm.editable || _vm.readonly,
2062
2044
  "name": _vm.name && _vm.name[1]
@@ -2132,6 +2114,12 @@ const _sfc_main$2 = {
2132
2114
  return Math.floor(this.date.getFullYear() / 12) * 12;
2133
2115
  }
2134
2116
  },
2117
+ data() {
2118
+ return {
2119
+ lastRow: null,
2120
+ lastColumn: null
2121
+ };
2122
+ },
2135
2123
  methods: {
2136
2124
  getCellStyle(year) {
2137
2125
  const style = {};
@@ -2172,6 +2160,8 @@ const _sfc_main$2 = {
2172
2160
  const year = Number(target.textContent || target.innerText);
2173
2161
  if (this.selectionMode === "range") {
2174
2162
  if (!this.rangeState.selecting) {
2163
+ this.lastRow = null;
2164
+ this.lastColumn = null;
2175
2165
  this.$emit("pick", {
2176
2166
  minDate: year,
2177
2167
  maxDate: null
@@ -2195,7 +2185,6 @@ const _sfc_main$2 = {
2195
2185
  } else {
2196
2186
  this.$emit("pick", year);
2197
2187
  }
2198
- this.handleMouseMove(event);
2199
2188
  },
2200
2189
  handleMouseMove(event) {
2201
2190
  let target = event.target;
@@ -2211,9 +2200,11 @@ const _sfc_main$2 = {
2211
2200
  return;
2212
2201
  const row = target.parentNode.rowIndex;
2213
2202
  const column = target.cellIndex;
2214
- if (hasClass(target.parentNode, "disabled"))
2203
+ if (hasClass(target, "disabled"))
2215
2204
  return;
2216
2205
  if (row !== this.lastRow || column !== this.lastColumn) {
2206
+ this.lastRow = row;
2207
+ this.lastColumn = column;
2217
2208
  this.$emit("changerange", {
2218
2209
  minDate: this.minDate,
2219
2210
  maxDate: this.maxDate,
@@ -2389,6 +2380,13 @@ const _sfc_main$1 = {
2389
2380
  }
2390
2381
  },
2391
2382
  methods: {
2383
+ isValidValue(value) {
2384
+ const validDate = (date) => date instanceof Date && !isNaN(date.getTime());
2385
+ if (!Array.isArray(value)) {
2386
+ return validDate(value) && (!this.disabledDate || !this.disabledDate(value));
2387
+ }
2388
+ return value.length === 2 && value.every(validDate) && value[0].getTime() <= value[1].getTime() && (!this.disabledDate || value.every((date) => !this.disabledDate(date)));
2389
+ },
2392
2390
  handleClear() {
2393
2391
  this.minDate = null;
2394
2392
  this.maxDate = null;
@@ -1,3 +1,4 @@
1
+ import { LocaleMixin } from "@94ai/common-utils";
1
2
  import Vue from "vue";
2
3
  import { isDateObject, getWeekNumber, formatDate, parseDate, isDate, getDayCountOfYear, range, nextDate, toDate, modifyWithTimeString } from "element-ui/src/utils/date-util";
3
4
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
@@ -387,14 +388,14 @@ var popper$1 = { exports: {} };
387
388
  this._popper = popper2.jquery ? popper2[0] : popper2;
388
389
  }
389
390
  this._options = Object.assign({}, DEFAULTS, options);
390
- this._options.modifiers = this._options.modifiers.map((function(modifier) {
391
+ this._options.modifiers = this._options.modifiers.map(function(modifier) {
391
392
  if (this._options.modifiersIgnored.indexOf(modifier) !== -1)
392
393
  return;
393
394
  if (modifier === "applyStyle") {
394
395
  this._popper.setAttribute("x-placement", this._options.placement);
395
396
  }
396
397
  return this.modifiers[modifier] || modifier;
397
- }).bind(this));
398
+ }.bind(this));
398
399
  this.state.position = this._getPosition(this._popper, this._reference);
399
400
  setStyle(this._popper, {
400
401
  position: this.state.position,
@@ -607,11 +608,11 @@ var popper$1 = { exports: {} };
607
608
  if (ends !== void 0) {
608
609
  modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
609
610
  }
610
- modifiersToRun.forEach((function(modifier) {
611
+ modifiersToRun.forEach(function(modifier) {
611
612
  if (isFunction(modifier)) {
612
613
  data = modifier.call(this, data);
613
614
  }
614
- }).bind(this));
615
+ }.bind(this));
615
616
  return data;
616
617
  };
617
618
  Popper2.prototype.isModifierRequired = function(requesting, requested) {
@@ -755,7 +756,7 @@ var popper$1 = { exports: {} };
755
756
  } else {
756
757
  flipOrder = this._options.flipBehavior;
757
758
  }
758
- flipOrder.forEach((function(step, index) {
759
+ flipOrder.forEach(function(step, index) {
759
760
  if (placement !== step || flipOrder.length === index + 1) {
760
761
  return;
761
762
  }
@@ -772,7 +773,7 @@ var popper$1 = { exports: {} };
772
773
  data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
773
774
  data = this.runModifiers(data, this._options.modifiers, this._flip);
774
775
  }
775
- }).bind(this));
776
+ }.bind(this));
776
777
  return data;
777
778
  };
778
779
  Popper2.prototype.modifiers.offset = function(data) {
@@ -1277,13 +1278,9 @@ const RANGE_PARSER = function(array, format, separator) {
1277
1278
  const TYPE_VALUE_RESOLVER_MAP = {
1278
1279
  default: {
1279
1280
  formatter(value) {
1280
- if (!value)
1281
- return "";
1282
1281
  return "" + value;
1283
1282
  },
1284
1283
  parser(text) {
1285
- if (text === void 0 || text === "")
1286
- return null;
1287
1284
  return text;
1288
1285
  }
1289
1286
  },
@@ -1346,8 +1343,6 @@ const TYPE_VALUE_RESOLVER_MAP = {
1346
1343
  },
1347
1344
  number: {
1348
1345
  formatter(value) {
1349
- if (!value)
1350
- return "";
1351
1346
  return "" + value;
1352
1347
  },
1353
1348
  parser(text) {
@@ -1419,7 +1414,7 @@ const validator = function(val) {
1419
1414
  return val === null || val === void 0 || isString(val) || Array.isArray(val) && val.length === 2 && val.every(isString);
1420
1415
  };
1421
1416
  const _sfc_main$3 = {
1422
- mixins: [Emitter, NewPopper],
1417
+ mixins: [LocaleMixin, Emitter, NewPopper],
1423
1418
  inject: {
1424
1419
  elForm: {
1425
1420
  default: ""
@@ -1439,11 +1434,11 @@ const _sfc_main$3 = {
1439
1434
  placeholder: String,
1440
1435
  startPlaceholder: {
1441
1436
  type: String,
1442
- default: "开始年份"
1437
+ default: void 0
1443
1438
  },
1444
1439
  endPlaceholder: {
1445
1440
  type: String,
1446
- default: "结束年份"
1441
+ default: void 0
1447
1442
  },
1448
1443
  prefixIcon: String,
1449
1444
  clearIcon: {
@@ -1537,6 +1532,13 @@ const _sfc_main$3 = {
1537
1532
  }
1538
1533
  },
1539
1534
  computed: {
1535
+ localeText() {
1536
+ var _a, _b;
1537
+ return {
1538
+ startPlaceholder: (_a = this.startPlaceholder) != null ? _a : this.t("nf.date.startYear"),
1539
+ endPlaceholder: (_b = this.endPlaceholder) != null ? _b : this.t("nf.date.endYear")
1540
+ };
1541
+ },
1540
1542
  ranged() {
1541
1543
  return this.type.indexOf("range") > -1;
1542
1544
  },
@@ -1545,10 +1547,7 @@ const _sfc_main$3 = {
1545
1547
  return reference.$el || reference;
1546
1548
  },
1547
1549
  refInput() {
1548
- if (this.reference) {
1549
- return [].slice.call(this.reference.querySelectorAll("input"));
1550
- }
1551
- return [];
1550
+ return [].slice.call(this.reference.querySelectorAll("input"));
1552
1551
  },
1553
1552
  valueIsEmpty() {
1554
1553
  const val = this.value;
@@ -1581,9 +1580,6 @@ const _sfc_main$3 = {
1581
1580
  return "day";
1582
1581
  },
1583
1582
  haveTrigger() {
1584
- if (typeof this.showTrigger !== "undefined") {
1585
- return this.showTrigger;
1586
- }
1587
1583
  return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
1588
1584
  },
1589
1585
  displayValue() {
@@ -1823,9 +1819,6 @@ const _sfc_main$3 = {
1823
1819
  event.stopPropagation();
1824
1820
  return;
1825
1821
  }
1826
- if (this.picker && this.picker.handleKeydown) {
1827
- this.picker.handleKeydown(event);
1828
- }
1829
1822
  },
1830
1823
  handleRangeClick() {
1831
1824
  const type = this.type;
@@ -1836,7 +1829,6 @@ const _sfc_main$3 = {
1836
1829
  },
1837
1830
  hidePicker() {
1838
1831
  if (this.picker) {
1839
- this.picker.resetView && this.picker.resetView();
1840
1832
  this.pickerVisible = this.picker.visible = false;
1841
1833
  this.destroyPopper();
1842
1834
  }
@@ -1850,10 +1842,6 @@ const _sfc_main$3 = {
1850
1842
  this.pickerVisible = this.picker.visible = true;
1851
1843
  this.updatePopper();
1852
1844
  this.picker.value = this.parsedValue;
1853
- this.picker.resetView && this.picker.resetView();
1854
- this.$nextTick(() => {
1855
- this.picker.adjustSpinners && this.picker.adjustSpinners();
1856
- });
1857
1845
  },
1858
1846
  mountPicker() {
1859
1847
  this.picker = new Vue(this.panel).$mount();
@@ -1893,13 +1881,11 @@ const _sfc_main$3 = {
1893
1881
  deep: true
1894
1882
  });
1895
1883
  this.$el.appendChild(this.picker.$el);
1896
- this.picker.resetView && this.picker.resetView();
1897
1884
  this.picker.$on("dodestroy", this.doDestroy);
1898
1885
  this.picker.$on("pick", (date = "", visible = false) => {
1899
1886
  this.userInput = null;
1900
1887
  this.pickerVisible = this.picker.visible = visible;
1901
1888
  this.emitInput(date);
1902
- this.picker.resetView && this.picker.resetView();
1903
1889
  });
1904
1890
  this.picker.$on("select-range", (start, end, pos) => {
1905
1891
  if (this.refInput.length === 0)
@@ -1944,11 +1930,7 @@ const _sfc_main$3 = {
1944
1930
  if (!this.picker) {
1945
1931
  this.mountPicker();
1946
1932
  }
1947
- if (this.picker.isValidValue) {
1948
- return value && this.picker.isValidValue(value);
1949
- } else {
1950
- return true;
1951
- }
1933
+ return this.picker.isValidValue(value);
1952
1934
  }
1953
1935
  }
1954
1936
  };
@@ -2033,7 +2015,7 @@ var _sfc_render$3 = function render() {
2033
2015
  staticClass: "el-range-input",
2034
2016
  attrs: {
2035
2017
  "autocomplete": "off",
2036
- "placeholder": _vm.startPlaceholder,
2018
+ "placeholder": _vm.localeText.startPlaceholder,
2037
2019
  "disabled": _vm.pickerDisabled,
2038
2020
  "readonly": !_vm.editable || _vm.readonly,
2039
2021
  "name": _vm.name && _vm.name[0]
@@ -2054,7 +2036,7 @@ var _sfc_render$3 = function render() {
2054
2036
  staticClass: "el-range-input",
2055
2037
  attrs: {
2056
2038
  "autocomplete": "off",
2057
- "placeholder": _vm.endPlaceholder,
2039
+ "placeholder": _vm.localeText.endPlaceholder,
2058
2040
  "disabled": _vm.pickerDisabled,
2059
2041
  "readonly": !_vm.editable || _vm.readonly,
2060
2042
  "name": _vm.name && _vm.name[1]
@@ -2130,6 +2112,12 @@ const _sfc_main$2 = {
2130
2112
  return Math.floor(this.date.getFullYear() / 12) * 12;
2131
2113
  }
2132
2114
  },
2115
+ data() {
2116
+ return {
2117
+ lastRow: null,
2118
+ lastColumn: null
2119
+ };
2120
+ },
2133
2121
  methods: {
2134
2122
  getCellStyle(year) {
2135
2123
  const style = {};
@@ -2170,6 +2158,8 @@ const _sfc_main$2 = {
2170
2158
  const year = Number(target.textContent || target.innerText);
2171
2159
  if (this.selectionMode === "range") {
2172
2160
  if (!this.rangeState.selecting) {
2161
+ this.lastRow = null;
2162
+ this.lastColumn = null;
2173
2163
  this.$emit("pick", {
2174
2164
  minDate: year,
2175
2165
  maxDate: null
@@ -2193,7 +2183,6 @@ const _sfc_main$2 = {
2193
2183
  } else {
2194
2184
  this.$emit("pick", year);
2195
2185
  }
2196
- this.handleMouseMove(event);
2197
2186
  },
2198
2187
  handleMouseMove(event) {
2199
2188
  let target = event.target;
@@ -2209,9 +2198,11 @@ const _sfc_main$2 = {
2209
2198
  return;
2210
2199
  const row = target.parentNode.rowIndex;
2211
2200
  const column = target.cellIndex;
2212
- if (hasClass(target.parentNode, "disabled"))
2201
+ if (hasClass(target, "disabled"))
2213
2202
  return;
2214
2203
  if (row !== this.lastRow || column !== this.lastColumn) {
2204
+ this.lastRow = row;
2205
+ this.lastColumn = column;
2215
2206
  this.$emit("changerange", {
2216
2207
  minDate: this.minDate,
2217
2208
  maxDate: this.maxDate,
@@ -2387,6 +2378,13 @@ const _sfc_main$1 = {
2387
2378
  }
2388
2379
  },
2389
2380
  methods: {
2381
+ isValidValue(value) {
2382
+ const validDate = (date) => date instanceof Date && !isNaN(date.getTime());
2383
+ if (!Array.isArray(value)) {
2384
+ return validDate(value) && (!this.disabledDate || !this.disabledDate(value));
2385
+ }
2386
+ return value.length === 2 && value.every(validDate) && value[0].getTime() <= value[1].getTime() && (!this.disabledDate || value.every((date) => !this.disabledDate(date)));
2387
+ },
2390
2388
  handleClear() {
2391
2389
  this.minDate = null;
2392
2390
  this.maxDate = null;
@@ -15,11 +15,11 @@ declare var _default: import("vue").DefineComponent<{
15
15
  placeholder: StringConstructor;
16
16
  startPlaceholder: {
17
17
  type: StringConstructor;
18
- default: string;
18
+ default: undefined;
19
19
  };
20
20
  endPlaceholder: {
21
21
  type: StringConstructor;
22
- default: string;
22
+ default: undefined;
23
23
  };
24
24
  prefixIcon: StringConstructor;
25
25
  clearIcon: {
@@ -68,13 +68,17 @@ declare var _default: import("vue").DefineComponent<{
68
68
  valueOnOpen: null;
69
69
  unwatchPickerOptions: null;
70
70
  }, {
71
+ localeText(): {
72
+ startPlaceholder: any;
73
+ endPlaceholder: any;
74
+ };
71
75
  ranged(): boolean;
72
76
  reference(): any;
73
77
  refInput(): never[];
74
78
  valueIsEmpty(): boolean;
75
79
  triggerClass(): any;
76
80
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
77
- haveTrigger(): any;
81
+ haveTrigger(): boolean;
78
82
  displayValue(): any;
79
83
  parsedValue(): any;
80
84
  _elFormItemSize(): any;
@@ -97,11 +101,11 @@ declare var _default: import("vue").DefineComponent<{
97
101
  placeholder: StringConstructor;
98
102
  startPlaceholder: {
99
103
  type: StringConstructor;
100
- default: string;
104
+ default: undefined;
101
105
  };
102
106
  endPlaceholder: {
103
107
  type: StringConstructor;
104
- default: string;
108
+ default: undefined;
105
109
  };
106
110
  prefixIcon: StringConstructor;
107
111
  clearIcon: {
@@ -9,11 +9,11 @@ declare var _default: import("vue").DefineComponent<{
9
9
  placeholder: StringConstructor;
10
10
  startPlaceholder: {
11
11
  type: StringConstructor;
12
- default: string;
12
+ default: undefined;
13
13
  };
14
14
  endPlaceholder: {
15
15
  type: StringConstructor;
16
- default: string;
16
+ default: undefined;
17
17
  };
18
18
  prefixIcon: StringConstructor;
19
19
  clearIcon: {
@@ -62,13 +62,17 @@ declare var _default: import("vue").DefineComponent<{
62
62
  valueOnOpen: null;
63
63
  unwatchPickerOptions: null;
64
64
  }, {
65
+ localeText(): {
66
+ startPlaceholder: any;
67
+ endPlaceholder: any;
68
+ };
65
69
  ranged(): boolean;
66
70
  reference(): any;
67
71
  refInput(): never[];
68
72
  valueIsEmpty(): boolean;
69
73
  triggerClass(): any;
70
74
  selectionMode(): "week" | "month" | "year" | "dates" | "day";
71
- haveTrigger(): any;
75
+ haveTrigger(): boolean;
72
76
  displayValue(): any;
73
77
  parsedValue(): any;
74
78
  _elFormItemSize(): any;
@@ -91,11 +95,11 @@ declare var _default: import("vue").DefineComponent<{
91
95
  placeholder: StringConstructor;
92
96
  startPlaceholder: {
93
97
  type: StringConstructor;
94
- default: string;
98
+ default: undefined;
95
99
  };
96
100
  endPlaceholder: {
97
101
  type: StringConstructor;
98
- default: string;
102
+ default: undefined;
99
103
  };
100
104
  prefixIcon: StringConstructor;
101
105
  clearIcon: {
@@ -17,7 +17,10 @@ declare var _default: import("vue").DefineComponent<{
17
17
  selecting: boolean;
18
18
  };
19
19
  };
20
- }, {}, {}, {
20
+ }, {}, {
21
+ lastRow: null;
22
+ lastColumn: null;
23
+ }, {
21
24
  startYear(): number;
22
25
  }, {
23
26
  getCellStyle(year: any): {
@@ -49,7 +49,7 @@
49
49
  <i :class="['el-input__icon', 'el-range__icon', triggerClass]"></i>
50
50
  <input
51
51
  autocomplete="off"
52
- :placeholder="startPlaceholder"
52
+ :placeholder="localeText.startPlaceholder"
53
53
  :value="displayValue && displayValue[0]"
54
54
  :disabled="pickerDisabled"
55
55
  v-bind="firstInputId"
@@ -64,7 +64,7 @@
64
64
  </slot>
65
65
  <input
66
66
  autocomplete="off"
67
- :placeholder="endPlaceholder"
67
+ :placeholder="localeText.endPlaceholder"
68
68
  :value="displayValue && displayValue[1]"
69
69
  :disabled="pickerDisabled"
70
70
  v-bind="secondInputId"
@@ -84,6 +84,8 @@
84
84
  </template>
85
85
 
86
86
  <script>
87
+ import { LocaleMixin } from '@94ai/common-utils'
88
+
87
89
  import Vue from 'vue';
88
90
  import Clickoutside from 'element-ui/src/utils/clickoutside';
89
91
  import { formatDate, parseDate, isDateObject, getWeekNumber } from 'element-ui/src/utils/date-util';
@@ -167,11 +169,9 @@ const RANGE_PARSER = function(array, format, separator) {
167
169
  const TYPE_VALUE_RESOLVER_MAP = {
168
170
  default: {
169
171
  formatter(value) {
170
- if (!value) return '';
171
172
  return '' + value;
172
173
  },
173
174
  parser(text) {
174
- if (text === undefined || text === '') return null;
175
175
  return text;
176
176
  }
177
177
  },
@@ -238,7 +238,6 @@ const TYPE_VALUE_RESOLVER_MAP = {
238
238
  },
239
239
  number: {
240
240
  formatter(value) {
241
- if (!value) return '';
242
241
  return '' + value;
243
242
  },
244
243
  parser(text) {
@@ -336,7 +335,7 @@ const validator = function(val) {
336
335
  };
337
336
 
338
337
  export default {
339
- mixins: [Emitter, NewPopper],
338
+ mixins: [LocaleMixin, Emitter, NewPopper],
340
339
 
341
340
  inject: {
342
341
  elForm: {
@@ -358,11 +357,11 @@ export default {
358
357
  placeholder: String,
359
358
  startPlaceholder: {
360
359
  type: String,
361
- default: '开始年份'
360
+ default: undefined
362
361
  },
363
362
  endPlaceholder: {
364
363
  type: String,
365
- default: '结束年份'
364
+ default: undefined
366
365
  },
367
366
  prefixIcon: String,
368
367
  clearIcon: {
@@ -458,6 +457,12 @@ export default {
458
457
  },
459
458
 
460
459
  computed: {
460
+ localeText() {
461
+ return {
462
+ startPlaceholder: this.startPlaceholder ?? this.t('nf.date.startYear'),
463
+ endPlaceholder: this.endPlaceholder ?? this.t('nf.date.endYear'),
464
+ }
465
+ },
461
466
  ranged() {
462
467
  return this.type.indexOf('range') > -1;
463
468
  },
@@ -468,10 +473,7 @@ export default {
468
473
  },
469
474
 
470
475
  refInput() {
471
- if (this.reference) {
472
- return [].slice.call(this.reference.querySelectorAll('input'));
473
- }
474
- return [];
476
+ return [].slice.call(this.reference.querySelectorAll('input'));
475
477
  },
476
478
 
477
479
  valueIsEmpty() {
@@ -509,9 +511,6 @@ export default {
509
511
  },
510
512
 
511
513
  haveTrigger() {
512
- if (typeof this.showTrigger !== 'undefined') {
513
- return this.showTrigger;
514
- }
515
514
  return HAVE_TRIGGER_TYPES.indexOf(this.type) !== -1;
516
515
  },
517
516
 
@@ -794,10 +793,6 @@ export default {
794
793
  return;
795
794
  }
796
795
 
797
- // delegate other keys to panel
798
- if (this.picker && this.picker.handleKeydown) {
799
- this.picker.handleKeydown(event);
800
- }
801
796
  },
802
797
 
803
798
  handleRangeClick() {
@@ -811,7 +806,6 @@ export default {
811
806
 
812
807
  hidePicker() {
813
808
  if (this.picker) {
814
- this.picker.resetView && this.picker.resetView();
815
809
  this.pickerVisible = this.picker.visible = false;
816
810
  this.destroyPopper();
817
811
  }
@@ -827,11 +821,6 @@ export default {
827
821
  this.updatePopper();
828
822
 
829
823
  this.picker.value = this.parsedValue;
830
- this.picker.resetView && this.picker.resetView();
831
-
832
- this.$nextTick(() => {
833
- this.picker.adjustSpinners && this.picker.adjustSpinners();
834
- });
835
824
  },
836
825
 
837
826
  mountPicker() {
@@ -877,14 +866,12 @@ export default {
877
866
  updateOptions();
878
867
  this.unwatchPickerOptions = this.$watch('pickerOptions', () => updateOptions(), { deep: true });
879
868
  this.$el.appendChild(this.picker.$el);
880
- this.picker.resetView && this.picker.resetView();
881
869
 
882
870
  this.picker.$on('dodestroy', this.doDestroy);
883
871
  this.picker.$on('pick', (date = '', visible = false) => {
884
872
  this.userInput = null;
885
873
  this.pickerVisible = this.picker.visible = visible;
886
874
  this.emitInput(date);
887
- this.picker.resetView && this.picker.resetView();
888
875
  });
889
876
 
890
877
  this.picker.$on('select-range', (start, end, pos) => {
@@ -934,11 +921,7 @@ export default {
934
921
  if (!this.picker) {
935
922
  this.mountPicker();
936
923
  }
937
- if (this.picker.isValidValue) {
938
- return value && this.picker.isValidValue(value);
939
- } else {
940
- return true;
941
- }
924
+ return this.picker.isValidValue(value);
942
925
  }
943
926
  }
944
927
  };
@@ -168,6 +168,15 @@ export default {
168
168
  }
169
169
  },
170
170
  methods: {
171
+ isValidValue(value) {
172
+ const validDate = date => date instanceof Date && !isNaN(date.getTime());
173
+ if (!Array.isArray(value)) {
174
+ return validDate(value) && (!this.disabledDate || !this.disabledDate(value));
175
+ }
176
+ return value.length === 2 && value.every(validDate) &&
177
+ value[0].getTime() <= value[1].getTime() &&
178
+ (!this.disabledDate || value.every(date => !this.disabledDate(date)));
179
+ },
171
180
  handleClear() {
172
181
  this.minDate = null;
173
182
  this.maxDate = null;
@@ -117,6 +117,10 @@
117
117
  }
118
118
  },
119
119
 
120
+ data() {
121
+ return { lastRow: null, lastColumn: null };
122
+ },
123
+
120
124
  methods: {
121
125
  getCellStyle(year) {
122
126
  const style = {};
@@ -165,6 +169,8 @@
165
169
  const year = Number(target.textContent || target.innerText);
166
170
  if (this.selectionMode === 'range') {
167
171
  if (!this.rangeState.selecting) {
172
+ this.lastRow = null;
173
+ this.lastColumn = null;
168
174
  this.$emit('pick', {minDate: year, maxDate: null});
169
175
  // eslint-disable-next-line
170
176
  this.rangeState.selecting = true;
@@ -182,7 +188,7 @@
182
188
  } else {
183
189
  this.$emit('pick', year);
184
190
  }
185
- this.handleMouseMove(event);
191
+
186
192
  },
187
193
 
188
194
  handleMouseMove(event) {
@@ -198,8 +204,10 @@
198
204
  if (target.tagName !== 'TD') return;
199
205
  const row = target.parentNode.rowIndex;
200
206
  const column = target.cellIndex;
201
- if (hasClass(target.parentNode, 'disabled')) return;
207
+ if (hasClass(target, 'disabled')) return;
202
208
  if (row !== this.lastRow || column !== this.lastColumn) {
209
+ this.lastRow = row;
210
+ this.lastColumn = column;
203
211
  this.$emit('changerange', {
204
212
  minDate: this.minDate,
205
213
  maxDate: this.maxDate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-double-year",
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/zoujiahe/common-ui.git"
14
+ "url": "http://gitlab.94ai.pro/zoujiahe/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-double-year.cjs.js",
32
- "module": "lib/nf-double-year.esm-bundler.js",
33
- "gitHead": "74e871c7972dc4576480bee02b1dc61a3eafc6ba"
34
+ "module": "lib/nf-double-year.esm-bundler.js"
34
35
  }