quasar-ui-sellmate-ui-kit 2.2.8 → 2.2.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-sellmate-ui-kit",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "author": "Sellmate Dev Team <dev@sellmate.co.kr>",
5
5
  "description": "Sellmate UI Kit",
6
6
  "license": "MIT",
@@ -7,6 +7,7 @@
7
7
  readonly
8
8
  :disable="isDisable"
9
9
  ref="wrapperInputRef"
10
+ no-error-icon
10
11
  >
11
12
  <template v-slot:before v-if="insideLabel">
12
13
  <div class="date-picker-label">
@@ -46,11 +47,7 @@
46
47
  no-refocus
47
48
  :offset="[0, 6]"
48
49
  no-parent-event
49
- @hide="
50
- () => {
51
- if (wrapperInputRef) wrapperInputRef.validate();
52
- }
53
- "
50
+ @hide="settingFromDate()"
54
51
  >
55
52
  <div class="reset-btn-area flex justify-end">
56
53
  <q-btn
@@ -73,7 +70,7 @@
73
70
  mask="YYYY-MM-DD"
74
71
  :locale="lang ? locale[lang] : {}"
75
72
  :options="optionsStartFn"
76
- @update:modelValue="handleFromMenuHide"
73
+ @update:modelValue="fromMenuRef.hide()"
77
74
  >
78
75
  </q-date>
79
76
  </q-menu>
@@ -109,11 +106,7 @@
109
106
  no-refocus
110
107
  :offset="[0, 6]"
111
108
  no-parent-event
112
- @hide="
113
- () => {
114
- if (wrapperInputRef) wrapperInputRef.validate();
115
- }
116
- "
109
+ @hide="triggerValidation"
117
110
  >
118
111
  <div class="reset-btn-area flex justify-end">
119
112
  <q-btn
@@ -172,11 +165,7 @@
172
165
  no-refocus
173
166
  :offset="[0, 6]"
174
167
  no-parent-event
175
- @hide="
176
- () => {
177
- if (wrapperInputRef) wrapperInputRef.validate();
178
- }
179
- "
168
+ @hide="triggerValidation"
180
169
  >
181
170
  <div class="reset-btn-area flex justify-end">
182
171
  <q-btn
@@ -324,39 +313,33 @@
324
313
  type: Boolean,
325
314
  default: false,
326
315
  },
327
- durationLimit: Number,
328
- rangeDate: { type: [Number, Object], default: () => 1 },
329
- dateLimit: {
316
+ dateRangeLimit: { type: [Number, Object], default: 1 },
317
+ minMaxDate: {
330
318
  type: Object,
331
- default: () => ({ from: '', to: '' }),
319
+ default: () => ({ minDate: '', maxDate: '' }),
332
320
  },
333
321
  },
334
322
 
335
323
  setup(props, { emit }) {
336
324
  const dateModel = useModelBinder(props);
337
- const singleMenuRef = ref(null);
338
325
  const fromMenuRef = ref(null);
339
326
  const toMenuRef = ref(null);
340
327
  const wrapperInputRef = ref(null);
341
- const menuModel = ref({
342
- single: false,
343
- from: false,
344
- to: false,
345
- });
346
328
 
347
329
  function resetDate(key) {
348
330
  const todayDate = date.formatDate(new Date(), 'YYYY-MM-DD');
349
- const durationBeforeToday = date.formatDate(
350
- date.subtractFromDate(new Date(), { month: props.durationLimit }),
351
- 'YYYY-MM-DD',
352
- );
353
331
 
354
332
  if (!props.isRange) {
355
333
  dateModel.value = todayDate;
356
334
  return;
357
335
  }
358
336
 
359
- if (props.noLimit && !!props.durationLimit) {
337
+ const durationBeforeToday = date.formatDate(
338
+ date.subtractFromDate(new Date(), { month: props.dateRangeLimit }),
339
+ 'YYYY-MM-DD',
340
+ );
341
+
342
+ if (props.noLimit && !!props.dateRangeLimit) {
360
343
  if (typeof dateModel.value !== 'object' || !dateModel.value.from) {
361
344
  dateModel.value = { from: durationBeforeToday, to: todayDate };
362
345
  return;
@@ -374,9 +357,9 @@
374
357
  - fromDate.getMonth()
375
358
  + 12 * (toDate.getFullYear() - fromDate.getFullYear());
376
359
 
377
- if (monthDifference >= props.durationLimit) {
360
+ if (monthDifference >= props.dateRangeLimit) {
378
361
  dateModel.value.from = date.formatDate(
379
- date.subtractFromDate(toDate, { month: props.durationLimit }),
362
+ date.subtractFromDate(toDate, { month: props.dateRangeLimit }),
380
363
  'YYYY-MM-DD',
381
364
  );
382
365
  }
@@ -395,8 +378,10 @@
395
378
  function optionsFn(day) {
396
379
  if (props.noLimit) return true;
397
380
 
398
- const minDate = props.dateLimit.from && date.formatDate(new Date(props.dateLimit.from), 'YYYY/MM/DD');
399
- const maxDate = props.dateLimit.to && date.formatDate(new Date(props.dateLimit.to), 'YYYY/MM/DD');
381
+ const minDate = props.minMaxDate.minDate
382
+ && date.formatDate(new Date(props.minMaxDate.minDate), 'YYYY/MM/DD');
383
+ const maxDate = props.minMaxDate.maxDate
384
+ && date.formatDate(new Date(props.minMaxDate.maxDate), 'YYYY/MM/DD');
400
385
 
401
386
  if (minDate && maxDate) {
402
387
  return minDate <= day && day <= maxDate;
@@ -414,79 +399,97 @@
414
399
  }
415
400
 
416
401
  function optionsStartFn(day) {
417
- if (props.noLimit && dateModel.value.to) {
418
- const selectedEndDay = date.formatDate(dateModel.value.to, 'YYYY/MM/DD');
419
- return day <= selectedEndDay;
402
+ if (props.noLimit) {
403
+ return true;
420
404
  }
421
405
 
422
406
  const dayTo = date.formatDate(dateModel.value.to, 'YYYY/MM/DD');
423
- let maxFromDate = date.formatDate(
424
- date.subtractFromDate(
425
- new Date(dateModel.value.to),
426
- typeof props.rangeDate === 'number' ? { month: props.rangeDate } : props.rangeDate,
427
- ),
428
- 'YYYY/MM/DD',
429
- );
407
+ let maxFromDate = dayTo
408
+ ? date.formatDate(
409
+ date.subtractFromDate(
410
+ new Date(dateModel.value.to),
411
+ typeof props.dateRangeLimit === 'number'
412
+ ? { month: props.dateRangeLimit }
413
+ : props.dateRangeLimit,
414
+ ),
415
+ 'YYYY/MM/DD',
416
+ )
417
+ : null;
418
+
419
+ if (props.minMaxDate.minDate) {
420
+ maxFromDate = maxFromDate
421
+ ? date.formatDate(
422
+ new Date(Math.max(new Date(maxFromDate), new Date(props.minMaxDate.minDate))),
423
+ 'YYYY/MM/DD',
424
+ )
425
+ : date.formatDate(new Date(props.minMaxDate.minDate), 'YYYY/MM/DD');
426
+ }
430
427
 
431
- if (props.dateLimit.from) {
432
- maxFromDate = date.formatDate(
433
- new Date(Math.max(new Date(maxFromDate), new Date(props.dateLimit.from))),
434
- 'YYYY/MM/DD',
435
- );
428
+ if (maxFromDate && dayTo) {
429
+ return maxFromDate <= day && day <= dayTo;
436
430
  }
437
431
 
438
- if (!dateModel.value.to) {
439
- return true;
432
+ if (maxFromDate) {
433
+ return maxFromDate <= day;
440
434
  }
441
- return maxFromDate <= day && day <= dayTo;
435
+
436
+ if (dayTo) {
437
+ return day <= dayTo;
438
+ }
439
+
440
+ return true;
442
441
  }
443
442
 
444
443
  function optionsEndFn(day) {
445
- const today = date.formatDate(new Date(), 'YYYY/MM/DD');
444
+ const dayFrom = date.formatDate(dateModel.value.from, 'YYYY/MM/DD');
446
445
 
447
- // isRange와 noLimit이 모두 true일 때, 종료 날짜에 제한을 두지 않는다.
448
- if (props.isRange && props.noLimit) {
449
- const dayFrom = date.formatDate(dateModel.value.from, 'YYYY/MM/DD');
450
- return dayFrom <= day && day <= today;
446
+ let maxToDate = dayFrom
447
+ ? date.formatDate(
448
+ date.addToDate(
449
+ new Date(dateModel.value.from),
450
+ typeof props.dateRangeLimit === 'number'
451
+ ? { month: props.dateRangeLimit }
452
+ : props.dateRangeLimit,
453
+ ),
454
+ 'YYYY/MM/DD',
455
+ )
456
+ : null;
457
+
458
+ if (props.minMaxDate.maxDate) {
459
+ maxToDate = maxToDate
460
+ ? date.formatDate(
461
+ new Date(Math.min(new Date(maxToDate), new Date(props.minMaxDate.maxDate))),
462
+ 'YYYY/MM/DD',
463
+ )
464
+ : date.formatDate(new Date(props.minMaxDate.maxDate), 'YYYY/MM/DD');
451
465
  }
452
466
 
453
- if (props.noLimit && !!props.durationLimit) {
454
- let maxToDate = today;
455
- if (dateModel.value.from) {
456
- const dayFrom = date.formatDate(dateModel.value.from, 'YYYY/MM/DD');
457
- maxToDate = today;
458
- return dayFrom <= day && day <= maxToDate;
459
- }
460
- return day <= maxToDate;
467
+ if (dayFrom && maxToDate) {
468
+ return dayFrom <= day && day <= maxToDate;
461
469
  }
462
470
 
463
- const dayFrom = date.formatDate(dateModel.value.from, 'YYYY/MM/DD');
464
- let maxToDate = date.formatDate(
465
- date.addToDate(
466
- new Date(dateModel.value.from),
467
- typeof props.rangeDate === 'number' ? { month: props.rangeDate } : props.rangeDate,
468
- ),
469
- 'YYYY/MM/DD',
470
- );
471
-
472
- if (props.dateLimit.to) {
473
- maxToDate = date.formatDate(
474
- new Date(Math.min(new Date(maxToDate), new Date(props.dateLimit.to))),
475
- 'YYYY/MM/DD',
476
- );
471
+ if (dayFrom) {
472
+ return dayFrom <= day;
477
473
  }
478
- if (!dateModel.value.from) {
479
- return day <= today;
474
+
475
+ if (maxToDate) {
476
+ return day <= maxToDate;
480
477
  }
481
478
 
482
- return dayFrom <= day && day <= maxToDate && day <= today;
479
+ return true;
483
480
  }
484
481
 
485
- function handleFromMenuHide() {
486
- if (props.noLimit && !!props.durationLimit) {
482
+ function triggerValidation() {
483
+ if (wrapperInputRef.value) wrapperInputRef.value.validate();
484
+ }
485
+
486
+ function settingFromDate() {
487
+ triggerValidation();
488
+
489
+ if (props.noLimit && !!props.dateRangeLimit) {
487
490
  const fromDate = new Date(dateModel.value.from);
488
491
  const monthsLater = new Date(fromDate).setMonth(
489
- fromDate.getMonth() + props.durationLimit,
492
+ fromDate.getMonth() + props.dateRangeLimit,
490
493
  );
491
494
  const maxToDate = date.formatDate(Math.min(monthsLater, new Date()), 'YYYY-MM-DD'); // 최대개월 후 또는 오늘 중 더 이른 날짜
492
495
 
@@ -495,14 +498,19 @@
495
498
  // 선택된 'to' 날짜가 최대개월을 초과하는 경우
496
499
  dateModel.value.to = maxToDate;
497
500
  }
501
+
502
+ if (fromDate > toDate) {
503
+ dateModel.value.to = '';
504
+ }
498
505
  }
499
- fromMenuRef.value.hide();
500
506
  }
501
507
 
502
508
  function handleToMenuHide() {
503
- if (props.noLimit && !!props.durationLimit) {
509
+ // FIXME: 종료 일자는 보통 시작 일자에 의해 제한 되기 때문에
510
+ // 종료 일자가 시작 일자를 제한하는 경우는 없을 것으로 보임, 추후 확인 후 삭제
511
+ if (props.noLimit && !!props.dateRangeLimit) {
504
512
  const toDate = new Date(dateModel.value.to);
505
- const monthsBefore = new Date(toDate).setMonth(toDate.getMonth() - props.durationLimit);
513
+ const monthsBefore = new Date(toDate).setMonth(toDate.getMonth() - props.dateRangeLimit);
506
514
  const minFromDate = date.formatDate(monthsBefore, 'YYYY-MM-DD'); // 'to' 날짜로부터 최대개월 이전
507
515
 
508
516
  const fromDate = new Date(dateModel.value.from);
@@ -518,20 +526,23 @@
518
526
  if (!props.isRange) {
519
527
  dateModel.value = '';
520
528
  emit('update:modelValue', dateModel.value);
529
+ return;
521
530
  }
522
531
 
523
- if (dateModel.value.from && dateModel.value.to) {
524
- dateModel.value.from = '';
525
- dateModel.value.to = '';
526
- emit('update:modelValue', dateModel.value);
527
- }
532
+ dateModel.value.from = '';
533
+ dateModel.value.to = '';
534
+ emit('update:modelValue', dateModel.value);
528
535
  }
529
536
 
530
537
  return {
531
538
  locale,
539
+ menuModel: ref({
540
+ single: false,
541
+ from: false,
542
+ to: false,
543
+ }),
532
544
  dateModel,
533
- menuModel,
534
- singleMenuRef,
545
+ singleMenuRef: ref(null),
535
546
  fromMenuRef,
536
547
  toMenuRef,
537
548
  wrapperInputRef,
@@ -542,9 +553,10 @@
542
553
  optionsFn,
543
554
  optionsStartFn,
544
555
  optionsEndFn,
545
- handleFromMenuHide,
556
+ settingFromDate,
546
557
  handleToMenuHide,
547
558
  deleteDate,
559
+ triggerValidation,
548
560
  };
549
561
  },
550
562
  };
@@ -195,7 +195,7 @@
195
195
  @extend %select;
196
196
 
197
197
  &.q-field--disabled {
198
- .q-field__control > div {
198
+ .q-field__control > .q-field__prepend {
199
199
  opacity: 1 !important;
200
200
  border-right: 1px solid $Grey_Lighten-2;
201
201
  }