@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.
@@ -1,142 +1,142 @@
1
- declare var _default: import("vue").DefineComponent<{
2
- size: StringConstructor;
3
- format: StringConstructor;
4
- valueFormat: StringConstructor;
5
- readonly: BooleanConstructor;
6
- placeholder: StringConstructor;
7
- startPlaceholder: StringConstructor;
8
- endPlaceholder: StringConstructor;
9
- prefixIcon: StringConstructor;
10
- clearIcon: {
11
- type: StringConstructor;
12
- default: string;
13
- };
14
- name: {
15
- default: string;
16
- validator: (val: any) => boolean;
17
- };
18
- disabled: BooleanConstructor;
19
- clearable: {
20
- type: BooleanConstructor;
21
- default: boolean;
22
- };
23
- id: {
24
- default: string;
25
- validator: (val: any) => boolean;
26
- };
27
- popperClass: StringConstructor;
28
- editable: {
29
- type: BooleanConstructor;
30
- default: boolean;
31
- };
32
- align: {
33
- type: StringConstructor;
34
- default: string;
35
- };
36
- value: {};
37
- defaultValue: {};
38
- defaultTime: {};
39
- rangeSeparator: {
40
- default: string;
41
- };
42
- pickerOptions: {};
43
- unlinkPanels: BooleanConstructor;
44
- validateEvent: {
45
- type: BooleanConstructor;
46
- default: boolean;
47
- };
48
- timezone: {
49
- type: StringConstructor;
50
- default(): any;
51
- };
52
- }, {}, {
53
- pickerVisible: boolean;
54
- showClose: boolean;
55
- userInput: null;
56
- valueOnOpen: null;
57
- unwatchPickerOptions: null;
58
- }, {
59
- ranged(): boolean;
60
- reference(): any;
61
- refInput(): never[];
62
- valueIsEmpty(): boolean;
63
- triggerClass(): any;
64
- selectionMode(): "week" | "month" | "year" | "dates" | "day";
65
- haveTrigger(): any;
66
- displayValue(): any;
67
- parsedValue(): any;
68
- _elFormItemSize(): any;
69
- pickerSize(): any;
70
- pickerDisabled(): any;
71
- firstInputId(): {
72
- id: any;
73
- };
74
- secondInputId(): {
75
- id: any;
76
- };
77
- }, {}, any, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
78
- size: StringConstructor;
79
- format: StringConstructor;
80
- valueFormat: StringConstructor;
81
- readonly: BooleanConstructor;
82
- placeholder: StringConstructor;
83
- startPlaceholder: StringConstructor;
84
- endPlaceholder: StringConstructor;
85
- prefixIcon: StringConstructor;
86
- clearIcon: {
87
- type: StringConstructor;
88
- default: string;
89
- };
90
- name: {
91
- default: string;
92
- validator: (val: any) => boolean;
93
- };
94
- disabled: BooleanConstructor;
95
- clearable: {
96
- type: BooleanConstructor;
97
- default: boolean;
98
- };
99
- id: {
100
- default: string;
101
- validator: (val: any) => boolean;
102
- };
103
- popperClass: StringConstructor;
104
- editable: {
105
- type: BooleanConstructor;
106
- default: boolean;
107
- };
108
- align: {
109
- type: StringConstructor;
110
- default: string;
111
- };
112
- value: {};
113
- defaultValue: {};
114
- defaultTime: {};
115
- rangeSeparator: {
116
- default: string;
117
- };
118
- pickerOptions: {};
119
- unlinkPanels: BooleanConstructor;
120
- validateEvent: {
121
- type: BooleanConstructor;
122
- default: boolean;
123
- };
124
- timezone: {
125
- type: StringConstructor;
126
- default(): any;
127
- };
128
- }>>, {
129
- name: string;
130
- readonly: boolean;
131
- disabled: boolean;
132
- unlinkPanels: boolean;
133
- clearIcon: string;
134
- clearable: boolean;
135
- id: string;
136
- editable: boolean;
137
- align: string;
138
- rangeSeparator: string;
139
- validateEvent: boolean;
140
- timezone: string;
141
- }>;
142
- export default _default;
1
+ declare var _default: import("vue").DefineComponent<{
2
+ size: StringConstructor;
3
+ format: StringConstructor;
4
+ valueFormat: StringConstructor;
5
+ readonly: BooleanConstructor;
6
+ placeholder: StringConstructor;
7
+ startPlaceholder: StringConstructor;
8
+ endPlaceholder: StringConstructor;
9
+ prefixIcon: StringConstructor;
10
+ clearIcon: {
11
+ type: StringConstructor;
12
+ default: string;
13
+ };
14
+ name: {
15
+ default: string;
16
+ validator: (val: any) => boolean;
17
+ };
18
+ disabled: BooleanConstructor;
19
+ clearable: {
20
+ type: BooleanConstructor;
21
+ default: boolean;
22
+ };
23
+ id: {
24
+ default: string;
25
+ validator: (val: any) => boolean;
26
+ };
27
+ popperClass: StringConstructor;
28
+ editable: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ align: {
33
+ type: StringConstructor;
34
+ default: string;
35
+ };
36
+ value: {};
37
+ defaultValue: {};
38
+ defaultTime: {};
39
+ rangeSeparator: {
40
+ default: string;
41
+ };
42
+ pickerOptions: {};
43
+ unlinkPanels: BooleanConstructor;
44
+ validateEvent: {
45
+ type: BooleanConstructor;
46
+ default: boolean;
47
+ };
48
+ timezone: {
49
+ type: (StringConstructor | NumberConstructor)[];
50
+ default(): any;
51
+ };
52
+ }, {}, {
53
+ pickerVisible: boolean;
54
+ showClose: boolean;
55
+ userInput: null;
56
+ valueOnOpen: null;
57
+ unwatchPickerOptions: null;
58
+ }, {
59
+ ranged(): boolean;
60
+ reference(): any;
61
+ refInput(): never[];
62
+ valueIsEmpty(): boolean;
63
+ triggerClass(): any;
64
+ selectionMode(): "week" | "month" | "year" | "dates" | "day";
65
+ haveTrigger(): boolean;
66
+ displayValue(): any;
67
+ parsedValue(): any;
68
+ _elFormItemSize(): any;
69
+ pickerSize(): any;
70
+ pickerDisabled(): any;
71
+ firstInputId(): {
72
+ id: any;
73
+ };
74
+ secondInputId(): {
75
+ id: any;
76
+ };
77
+ }, {}, any, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
78
+ size: StringConstructor;
79
+ format: StringConstructor;
80
+ valueFormat: StringConstructor;
81
+ readonly: BooleanConstructor;
82
+ placeholder: StringConstructor;
83
+ startPlaceholder: StringConstructor;
84
+ endPlaceholder: StringConstructor;
85
+ prefixIcon: StringConstructor;
86
+ clearIcon: {
87
+ type: StringConstructor;
88
+ default: string;
89
+ };
90
+ name: {
91
+ default: string;
92
+ validator: (val: any) => boolean;
93
+ };
94
+ disabled: BooleanConstructor;
95
+ clearable: {
96
+ type: BooleanConstructor;
97
+ default: boolean;
98
+ };
99
+ id: {
100
+ default: string;
101
+ validator: (val: any) => boolean;
102
+ };
103
+ popperClass: StringConstructor;
104
+ editable: {
105
+ type: BooleanConstructor;
106
+ default: boolean;
107
+ };
108
+ align: {
109
+ type: StringConstructor;
110
+ default: string;
111
+ };
112
+ value: {};
113
+ defaultValue: {};
114
+ defaultTime: {};
115
+ rangeSeparator: {
116
+ default: string;
117
+ };
118
+ pickerOptions: {};
119
+ unlinkPanels: BooleanConstructor;
120
+ validateEvent: {
121
+ type: BooleanConstructor;
122
+ default: boolean;
123
+ };
124
+ timezone: {
125
+ type: (StringConstructor | NumberConstructor)[];
126
+ default(): any;
127
+ };
128
+ }>>, {
129
+ name: string;
130
+ readonly: boolean;
131
+ disabled: boolean;
132
+ unlinkPanels: boolean;
133
+ clearIcon: string;
134
+ clearable: boolean;
135
+ id: string;
136
+ editable: boolean;
137
+ align: string;
138
+ rangeSeparator: string;
139
+ validateEvent: boolean;
140
+ timezone: string | number;
141
+ }>;
142
+ export default _default;
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -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": "9.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,8 +14,10 @@
14
14
  "url": "http://gitlab.94ai.pro/ui/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^9.0.0",
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": "afe3016f0e42dfb7fedf6cbbe400ec08bf4b8662"
34
+ "module": "lib/nf-timezone-picker.esm-bundler.js"
34
35
  }