@enso-ui/filters 3.0.15 → 3.0.19

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/bulma/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import IntervalFilter from '../src/bulma/IntervalFilter.vue';
2
2
  import InputFilter from '../src/bulma/InputFilter.vue';
3
3
  import DateFilter from '../src/bulma/DateFilter.vue';
4
- import DateIntervalFilter from '../src/bulma/DateIntervalFilter.vue';
5
4
  import VueFilter from '../src/bulma/VueFilter.vue';
6
5
  import ToggleFilter from '../src/bulma/ToggleFilter.vue';
7
6
  import SelectFilter from '../src/bulma/SelectFilter.vue';
@@ -9,13 +8,12 @@ import BooleanFilter from '../src/bulma/BooleanFilter.vue';
9
8
  import EnsoIntervalFilter from '../src/bulma/EnsoIntervalFilter.vue';
10
9
  import EnsoInputFilter from '../src/bulma/EnsoInputFilter.vue';
11
10
  import EnsoDateFilter from '../src/bulma/EnsoDateFilter.vue';
12
- import EnsoDateIntervalFilter from '../src/bulma/EnsoDateIntervalFilter.vue';
13
11
  import EnsoFilter from '../src/bulma/EnsoFilter.vue';
14
12
  import EnsoToggleFilter from '../src/bulma/EnsoToggleFilter.vue';
15
13
  import EnsoSelectFilter from '../src/bulma/EnsoSelectFilter.vue';
16
14
 
17
15
  export {
18
16
  InputFilter, IntervalFilter, EnsoIntervalFilter, DateFilter, EnsoDateFilter,
19
- DateIntervalFilter, EnsoDateIntervalFilter, BooleanFilter, VueFilter, ToggleFilter,
20
- EnsoFilter, EnsoToggleFilter, SelectFilter, EnsoSelectFilter, EnsoInputFilter,
17
+ BooleanFilter, VueFilter, ToggleFilter, EnsoFilter, EnsoToggleFilter,
18
+ SelectFilter, EnsoSelectFilter, EnsoInputFilter,
21
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enso-ui/filters",
3
- "version": "3.0.15",
3
+ "version": "3.0.19",
4
4
  "description": "Renderless Vue Filter Components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -30,11 +30,11 @@
30
30
  "@enso-ui/switch": "^2.0",
31
31
  "@enso-ui/transitions": "^2.0",
32
32
  "@fortawesome/fontawesome-svg-core": "^1.2.2",
33
- "@fortawesome/free-solid-svg-icons": "^5.2.0",
33
+ "@fortawesome/free-solid-svg-icons": "^5.11.2",
34
34
  "@fortawesome/vue-fontawesome": "3.0.0-5",
35
35
  "bulma": "^0.9.0",
36
36
  "date-fns": "^2.0.0",
37
- "v-tooltip": "4.0.0-beta.2",
37
+ "v-tooltip": "^4.0.0-beta.2",
38
38
  "vue": "^3.0",
39
39
  "vuex": "^4.0.0"
40
40
  },
@@ -1,8 +1,7 @@
1
1
  import CoreIntervalFilter from '../src/renderless/CoreIntervalFilter.vue';
2
2
  import CoreDateFilter from '../src/renderless/CoreDateFilter.vue';
3
- import CoreDateIntervalFilter from '../src/renderless/CoreDateIntervalFilter.vue';
4
3
  import FilterState from '../src/renderless/FilterState.vue';
5
4
 
6
5
  export {
7
- CoreIntervalFilter, CoreDateFilter, CoreDateIntervalFilter, FilterState,
6
+ CoreIntervalFilter, CoreDateFilter, FilterState,
8
7
  };
@@ -1,6 +1,5 @@
1
1
  <template>
2
- <vue-filter v-bind="$attrs"
3
- icons
2
+ <vue-filter icons
4
3
  :options="options"/>
5
4
  </template>
6
5
 
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <div class="date-filter is-paddingless">
2
+ <div class="date-filter is-paddingless"
3
+ :class="$attrs.class">
3
4
  <core-date-filter v-bind="$attrs">
4
5
  <template #default="{
5
6
  filters, filter, custom, minBindings, minEvents, maxBindings, maxEvents,
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <date-filter v-bind="$attrs"
2
+ <date-filter
3
3
  alt-input
4
4
  :alt-format="altFormat || meta.dateFormat"
5
5
  :i18n="i18n"
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <vue-filter v-bind="$attrs"
2
+ <vue-filter
3
3
  :i18n="i18n"/>
4
4
  </template>
5
5
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <input-filter v-bind="$attrs"
2
+ <input-filter
3
3
  :i18n="i18n"/>
4
4
  </template>
5
5
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <interval-filter v-bind="$attrs"
2
+ <interval-filter
3
3
  :i18n="i18n"/>
4
4
  </template>
5
5
 
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <base-select-filter :compact="compact"
2
+ <base-select-filter :class="$attrs.class"
3
+ :compact="compact"
3
4
  :i18n="i18n"
4
5
  :name="name">
5
6
  <enso-select v-bind="{...$attrs, class: 'select-wrapper'}"
@@ -24,6 +25,8 @@ export default {
24
25
 
25
26
  inject: ['i18n'],
26
27
 
28
+ inheritAttrs: false,
29
+
27
30
  props: {
28
31
  compact: {
29
32
  type: Boolean,
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <toggle-filter v-bind="$attrs"
2
+ <toggle-filter
3
3
  :i18n="i18n"/>
4
4
  </template>
5
5
 
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <div class="interval-filter is-paddingless">
2
+ <div class="interval-filter is-paddingless"
3
+ :class="$attrs.class">
3
4
  <div v-if="!compact"
4
5
  class="header has-text-centered has-background-light">
5
6
  <b>{{ i18n(name) }}</b>
@@ -44,6 +45,8 @@ export default {
44
45
 
45
46
  components: { CoreInputFilter },
46
47
 
48
+ inheritAttrs: false,
49
+
47
50
  props: {
48
51
  compact: {
49
52
  type: Boolean,
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <div class="interval-filter is-paddingless">
2
+ <div class="interval-filter is-paddingless"
3
+ :class="$attrs.class">
3
4
  <div v-if="!compact"
4
5
  class="header has-text-centered has-background-light">
5
6
  <b>{{ i18n(name) }}</b>
@@ -59,6 +60,8 @@ export default {
59
60
 
60
61
  components: { CoreIntervalFilter },
61
62
 
63
+ inheritAttrs: false,
64
+
62
65
  props: {
63
66
  compact: {
64
67
  type: Boolean,
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <base-select-filter :compact="compact"
2
+ <base-select-filter :class="$attrs.class"
3
+ :compact="compact"
3
4
  :i18n="i18n"
4
5
  :name="name">
5
6
  <vue-select v-bind="{...$attrs, class: 'select-wrapper'}"
@@ -23,6 +24,8 @@ export default {
23
24
 
24
25
  components: { BaseSelectFilter, VueSelect },
25
26
 
27
+ inheritAttrs: false,
28
+
26
29
  props: {
27
30
  compact: {
28
31
  type: Boolean,
@@ -1,10 +1,10 @@
1
1
  <script>
2
2
  import {
3
- format, addDays, startOfDay, endOfDay, addWeeks, startOfWeek, endOfWeek,
4
- addMonths, startOfMonth, endOfMonth, addYears, startOfYear, endOfYear,
3
+ compareAsc, format, addDays, startOfDay, endOfDay, addWeeks,
4
+ startOfWeek, endOfWeek, addMonths, startOfMonth, endOfMonth,
5
+ addYears, startOfYear, endOfYear, parse,
5
6
  } from 'date-fns';
6
7
  import { lcwords } from '@enso-ui/strings';
7
- import dateIntervals from './dateIntervals';
8
8
  import {
9
9
  Intervals, Base, Past, Future, Adjustments,
10
10
  } from './intervals';
@@ -12,36 +12,42 @@ import {
12
12
  export default {
13
13
  name: 'CoreDateFilter',
14
14
 
15
- mixins: [dateIntervals],
16
-
17
15
  inheritAttrs: false,
18
16
 
19
17
  props: {
20
- default: {
21
- type: String,
22
- default: Intervals.today,
23
- validator: v => Base.concat(Past)
24
- .concat(Future).includes(v),
25
- },
26
18
  direction: {
27
19
  type: Boolean,
28
20
  default: false,
29
21
  },
30
- disabledOptions: {
22
+ excluded: {
31
23
  type: Array,
32
24
  default: () => ([]),
33
25
  validator: v => !v.some(val => !Base.concat(Past)
34
26
  .concat(Future).includes(val)),
35
27
  },
28
+ filter: {
29
+ type: String,
30
+ required: true,
31
+ validator: v => Base.concat(Past)
32
+ .concat(Future).includes(v),
33
+ },
34
+ format: {
35
+ type: String,
36
+ default: 'Y-m-d H:i:s',
37
+ },
36
38
  future: {
37
39
  type: Boolean,
38
40
  default: false,
39
41
  },
40
- modelValue: {
42
+ interval: {
43
+ type: Object,
44
+ required: true,
45
+ validator: v => Object.keys(v).includes('min')
46
+ && Object.keys(v).includes('max'),
47
+ },
48
+ locale: {
41
49
  type: String,
42
- default: null,
43
- validator: v => Base.concat(Past)
44
- .concat(Future).includes(v),
50
+ default: 'en',
45
51
  },
46
52
  weekStartsOn: {
47
53
  type: Number,
@@ -50,11 +56,10 @@ export default {
50
56
  },
51
57
  },
52
58
 
53
- emits: ['update', 'update:modelValue'],
59
+ emits: ['update:filter', 'update:interval'],
54
60
 
55
61
  data: v => ({
56
- filter: v.modelValue || v.default,
57
- isFuture: false,
62
+ isFuture: v.future,
58
63
  }),
59
64
 
60
65
  computed: {
@@ -64,6 +69,14 @@ export default {
64
69
  custom() {
65
70
  return this.filter === Intervals.custom;
66
71
  },
72
+ default() {
73
+ return Base.find(value => !this.excluded.includes(value));
74
+ },
75
+ equals() {
76
+ return !!this.interval.min
77
+ && !!this.interval.max
78
+ && compareAsc(this.parsedMin, this.parsedMax) === 0;
79
+ },
67
80
  filters() {
68
81
  return Object.keys(Intervals)
69
82
  .filter(option => this.options.includes(Intervals[option]))
@@ -72,20 +85,27 @@ export default {
72
85
  return filters;
73
86
  }, {});
74
87
  },
88
+ internalFormat() {
89
+ return this.format.replace('d', 'dd')
90
+ .replace('m', 'MM')
91
+ .replace('Y', 'yyyy')
92
+ .replace('H', 'HH')
93
+ .replace('i', 'mm')
94
+ .replace('s', 'ss');
95
+ },
75
96
  options() {
76
97
  return Base.concat(this.isFuture ? Future : Past);
77
98
  },
78
- },
79
-
80
- watch: {
81
- modelValue(value) {
82
- this.filter = value;
83
- this.update();
99
+ parsedMax() {
100
+ return parse(this.interval.max, this.internalFormat, new Date());
101
+ },
102
+ parsedMin() {
103
+ return parse(this.interval.min, this.internalFormat, new Date());
84
104
  },
85
105
  },
86
106
 
87
- beforeMount() {
88
- this.isFuture = this.future;
107
+ watch: {
108
+ filter: 'update',
89
109
  },
90
110
 
91
111
  created() {
@@ -93,20 +113,8 @@ export default {
93
113
  },
94
114
 
95
115
  methods: {
96
- set(filter) {
97
- this.filter = filter;
98
- this.$emit('update:modelValue', filter);
99
- this.update();
100
- },
101
- update() {
102
- this.adjust();
103
- this.$emit('update', this.sanitizedInterval);
104
- },
105
- label(option) {
106
- return lcwords(option);
107
- },
108
- adjust() {
109
- switch (this.filter) {
116
+ update(filter = this.filter) {
117
+ switch (filter) {
110
118
  case Intervals.today:
111
119
  case Intervals.yesterday:
112
120
  case Intervals.tomorrow:
@@ -136,32 +144,46 @@ export default {
136
144
  throw Error('Unknown Interval');
137
145
  }
138
146
  },
147
+ label(option) {
148
+ return lcwords(option);
149
+ },
139
150
  daily() {
140
151
  const min = startOfDay(addDays(new Date(), this.adjustment));
141
152
  const max = endOfDay(addDays(new Date(), this.adjustment));
142
153
 
143
- this.interval.min = this.date(min);
144
- this.interval.max = this.date(max);
154
+ const interval = { min: this.date(min), max: this.date(max) };
155
+
156
+ this.$emit('update:interval', interval);
145
157
  },
146
158
  weekly() {
147
159
  const options = { weekStartsOn: this.weekStartsOn };
148
160
  const min = startOfWeek(addWeeks(new Date(), this.adjustment), options);
149
161
  const max = endOfWeek(addWeeks(new Date(), this.adjustment), options);
150
162
 
151
- this.interval.min = this.date(min);
152
- this.interval.max = this.date(max);
163
+ const interval = { min: this.date(min), max: this.date(max) };
164
+
165
+ this.$emit('update:interval', interval);
153
166
  },
154
167
  monthly() {
155
- this.interval.min = this.date(startOfMonth(addMonths(new Date(), this.adjustment)));
156
- this.interval.max = this.date(endOfMonth(addMonths(new Date(), this.adjustment)));
168
+ const min = startOfMonth(addMonths(new Date(), this.adjustment));
169
+ const max = endOfMonth(addMonths(new Date(), this.adjustment));
170
+
171
+ const interval = { min: this.date(min), max: this.date(max) };
172
+
173
+ this.$emit('update:interval', interval);
157
174
  },
158
175
  yearly() {
159
- this.interval.min = this.date(startOfYear(addYears(new Date(), this.adjustment)));
160
- this.interval.max = this.date(endOfYear(addYears(new Date(), this.adjustment)));
176
+ const min = startOfYear(addYears(new Date(), this.adjustment));
177
+ const max = endOfYear(addYears(new Date(), this.adjustment));
178
+
179
+ const interval = { min: this.date(min), max: this.date(max) };
180
+
181
+ this.$emit('update:interval', interval);
161
182
  },
162
183
  all() {
163
- this.interval.min = null;
164
- this.interval.max = null;
184
+ const interval = { min: null, max: null };
185
+
186
+ this.$emit('update:interval', interval);
165
187
  },
166
188
  date(date) {
167
189
  return format(date, this.internalFormat);
@@ -171,7 +193,7 @@ export default {
171
193
  render() {
172
194
  return this.$slots.default({
173
195
  backEvents: {
174
- click: () => this.set(this.default),
196
+ click: () => this.$emit('update:filter', this.default),
175
197
  },
176
198
  custom: this.custom,
177
199
  direction: this.direction,
@@ -181,18 +203,18 @@ export default {
181
203
  directionEvents: {
182
204
  'update:modelValue': e => {
183
205
  this.isFuture = e;
184
- this.filter = 'today';
206
+ this.$emit('update:filter', this.default);
185
207
  },
186
208
  },
187
209
  filter: this.filter,
188
210
  filters: Object.keys(this.filters)
189
- .filter(key => !this.disabledOptions.includes(key))
211
+ .filter(key => !this.excluded.includes(key))
190
212
  .reduce((filters, key) => {
191
213
  filters[key] = this.filters[key];
192
214
  return filters;
193
215
  }, {}),
194
- filterEvents: type => ({
195
- click: () => this.set(type),
216
+ filterEvents: filter => ({
217
+ click: () => this.$emit('update:filter', filter),
196
218
  }),
197
219
  minBindings: {
198
220
  modelValue: this.interval.min,
@@ -204,8 +226,8 @@ export default {
204
226
  },
205
227
  minEvents: {
206
228
  'update:modelValue': e => {
207
- this.interval.min = e;
208
- this.update();
229
+ const interval = { min: e, max: this.interval.max };
230
+ this.$emit('update:interval', interval);
209
231
  },
210
232
  },
211
233
  maxBindings: {
@@ -218,8 +240,8 @@ export default {
218
240
  },
219
241
  maxEvents: {
220
242
  'update:modelValue': e => {
221
- this.interval.max = e;
222
- this.update();
243
+ const interval = { min: this.interval.min, max: e };
244
+ this.$emit('update:interval', interval);
223
245
  },
224
246
  },
225
247
  });
@@ -2,6 +2,8 @@
2
2
  export default {
3
3
  name: 'CoreInputFilter',
4
4
 
5
+ inheritAttrs: false,
6
+
5
7
  props: {
6
8
  modelValue: {
7
9
  type: String,
@@ -15,8 +17,6 @@ export default {
15
17
 
16
18
  emits: ['update:modelValue'],
17
19
 
18
- inheritAttrs: false,
19
-
20
20
  render() {
21
21
  return this.$slots.default({
22
22
  modelValue: this.modelValue,
@@ -2,6 +2,8 @@
2
2
  export default {
3
3
  name: 'CoreIntervalFilter',
4
4
 
5
+ inheritAttrs: false,
6
+
5
7
  props: {
6
8
  modelValue: {
7
9
  type: Object,
@@ -20,14 +22,13 @@ export default {
20
22
 
21
23
  emits: ['change', 'update:modelValue'],
22
24
 
23
- inheritAttrs: false,
24
-
25
25
  computed: {
26
26
  invalid() {
27
27
  return ![null, ''].includes(this.modelValue.min)
28
28
  && ![null, ''].includes(this.modelValue.max)
29
29
  && (this.type === 'number'
30
- ? Number.parseFloat(this.modelValue.min) > Number.parseFloat(this.modelValue.max)
30
+ ? Number.parseFloat(this.modelValue.min)
31
+ > Number.parseFloat(this.modelValue.max)
31
32
  : this.modelValue.min > this.modelValue.max);
32
33
  },
33
34
  },
@@ -35,6 +35,7 @@ export default {
35
35
  defaultParams: null,
36
36
  state: null,
37
37
  keys: null,
38
+ ready: false,
38
39
  }),
39
40
 
40
41
  computed: {
@@ -61,6 +62,7 @@ export default {
61
62
  created() {
62
63
  this.init();
63
64
  this.load();
65
+ this.ready = true;
64
66
  },
65
67
 
66
68
  methods: {
@@ -93,7 +95,9 @@ export default {
93
95
  });
94
96
  },
95
97
  persist() {
96
- localStorage.setItem(this.name, JSON.stringify(this.state));
98
+ if (this.ready) {
99
+ localStorage.setItem(this.name, JSON.stringify(this.state));
100
+ }
97
101
  },
98
102
  reset() {
99
103
  localStorage.removeItem(this.name);
@@ -17,7 +17,7 @@ const Intervals = {
17
17
 
18
18
  const Base = [
19
19
  Intervals.today, Intervals.thisWeek, Intervals.thisMonth,
20
- Intervals.thisYear, Intervals.custom, Intervals.all,
20
+ Intervals.thisYear, Intervals.all, Intervals.custom,
21
21
  ];
22
22
 
23
23
  const Past = [Intervals.yesterday, Intervals.lastWeek, Intervals.lastMonth, Intervals.lastYear];
@@ -1,102 +0,0 @@
1
- <template>
2
- <div class="date-interval-filter is-paddingless">
3
- <div class="header has-background-light has-text-centered"
4
- v-if="!compact">
5
- <strong>
6
- {{ i18n(name) }}
7
- </strong>
8
- </div>
9
- <div v-tooltip="compact ? i18n(name) : null"
10
- class="dates-wrapper"
11
- :class="{ 'has-background-light': compact }">
12
- <core-date-interval-filter v-bind="$attrs">
13
- <template #default="{ minBindings, minEvents, maxBindings, maxEvents }">
14
- <div class="columns is-mobile is-variable is-1 is-centered">
15
- <div class="column">
16
- <datepicker v-bind="minBindings"
17
- :placeholder="i18n(minLabel)"
18
- :alt-format="altFormat"
19
- :alt-input="altInput"
20
- v-on="minEvents"/>
21
- </div>
22
- <div class="column">
23
- <datepicker v-bind="maxBindings"
24
- :placeholder="i18n(maxLabel)"
25
- :alt-format="altFormat"
26
- :alt-input="altInput"
27
- v-on="maxEvents"/>
28
- </div>
29
- </div>
30
- </template>
31
- </core-date-interval-filter>
32
- </div>
33
- </div>
34
- </template>
35
-
36
- <script>
37
- import 'v-tooltip/dist/v-tooltip.css';
38
- import { VTooltip } from 'v-tooltip';
39
- import { Datepicker } from '@enso-ui/datepicker/bulma';
40
- import CoreDateIntervalFilter from '../renderless/CoreDateIntervalFilter.vue';
41
-
42
- export default {
43
- name: 'DateIntervalFilter',
44
-
45
- directives: { tooltip: VTooltip },
46
-
47
- components: { CoreDateIntervalFilter, Datepicker },
48
-
49
- props: {
50
- altFormat: {
51
- type: String,
52
- default: null,
53
- },
54
- altInput: {
55
- type: Boolean,
56
- default: false,
57
- },
58
- compact: {
59
- type: Boolean,
60
- default: false,
61
- },
62
- i18n: {
63
- type: Function,
64
- default: v => v,
65
- },
66
- maxLabel: {
67
- type: String,
68
- default: 'To',
69
- },
70
- minLabel: {
71
- type: String,
72
- default: 'From',
73
- },
74
- name: {
75
- type: String,
76
- default: null,
77
- },
78
- },
79
-
80
- data: () => ({
81
- interval: {
82
- min: null,
83
- max: null,
84
- },
85
- }),
86
- };
87
- </script>
88
-
89
- <style lang="scss">
90
- .date-interval-filter {
91
- .header {
92
- border-top-left-radius: inherit;
93
- border-top-right-radius: inherit;
94
- padding-top: 0.5em;
95
- }
96
-
97
- .dates-wrapper {
98
- border-radius: inherit;
99
- padding: 0.25em;
100
- }
101
- }
102
- </style>
@@ -1,32 +0,0 @@
1
- <template>
2
- <enso-date-filter v-bind="$attrs"
3
- alt-input
4
- :alt-format="altFormat || meta.dateFormat"
5
- :i18n="i18n"
6
- :locale="lang"/>
7
- </template>
8
-
9
- <script>
10
- import { mapState, mapGetters } from 'vuex';
11
- import EnsoDateFilter from './EnsoDateFilter.vue';
12
-
13
- export default {
14
- name: 'EnsoDateIntervalFilter',
15
-
16
- components: { EnsoDateFilter },
17
-
18
- inject: ['i18n'],
19
-
20
- props: {
21
- altFormat: {
22
- type: String,
23
- default: null,
24
- },
25
- },
26
-
27
- computed: {
28
- ...mapState(['meta']),
29
- ...mapGetters('preferences', ['lang']),
30
- },
31
- };
32
- </script>
@@ -1,50 +0,0 @@
1
- <script>
2
- import dateIntervals from './dateIntervals';
3
-
4
- export default {
5
- name: 'CoreDateIntervalFilter',
6
-
7
- mixins: [dateIntervals],
8
-
9
- emits: ['update'],
10
-
11
- inheritAttrs: false,
12
-
13
- methods: {
14
- update() {
15
- this.$emit('update', this.sanitizedInterval);
16
- },
17
- },
18
-
19
- render() {
20
- return this.$slots.default({
21
- minBindings: {
22
- modelValue: this.interval.min,
23
- format: this.format,
24
- isWarning: this.equals,
25
- locale: this.locale,
26
- max: this.interval.max,
27
- },
28
- minEvents: {
29
- 'update:modelValue': e => {
30
- this.interval.min = e;
31
- this.update();
32
- },
33
- },
34
- maxBindings: {
35
- modelValue: this.interval.max,
36
- format: this.format,
37
- isWarning: this.equals,
38
- locale: this.locale,
39
- min: this.interval.min,
40
- },
41
- maxEvents: {
42
- 'update:modelValue': e => {
43
- this.interval.max = e;
44
- this.update();
45
- },
46
- },
47
- });
48
- },
49
- };
50
- </script>
@@ -1,51 +0,0 @@
1
- import { compareAsc, parse } from 'date-fns';
2
-
3
- export default {
4
- props: {
5
- format: {
6
- type: String,
7
- default: 'Y-m-d H:i:s',
8
- },
9
- interval: {
10
- type: Object,
11
- default: () => ({
12
- min: null,
13
- max: null,
14
- }),
15
- validator: v => Object.keys(v).includes('min')
16
- && Object.keys(v).includes('max'),
17
- },
18
- locale: {
19
- type: String,
20
- default: 'en',
21
- },
22
- },
23
-
24
- computed: {
25
- internalFormat() {
26
- return this.format.replace('d', 'dd')
27
- .replace('m', 'MM')
28
- .replace('Y', 'yyyy')
29
- .replace('H', 'HH')
30
- .replace('i', 'mm')
31
- .replace('s', 'ss');
32
- },
33
- sanitizedInterval() {
34
- return {
35
- min: this.interval.min || null,
36
- max: this.interval.max || null,
37
- };
38
- },
39
- parsedMax() {
40
- return parse(this.interval.max, this.internalFormat, new Date());
41
- },
42
- parsedMin() {
43
- return parse(this.interval.min, this.internalFormat, new Date());
44
- },
45
- equals() {
46
- return !!this.interval.min
47
- && !!this.interval.max
48
- && compareAsc(this.parsedMin, this.parsedMax) === 0;
49
- },
50
- },
51
- };