@mptw/skylens-ui 1.4.59 → 1.4.61

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/app.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- SLProfileButton(
3
- username='Sherwin'
2
+ SLCalendarButton(
3
+ :allow-quicks="['last7Days']"
4
4
  )
5
5
  </template>
@@ -4,10 +4,10 @@
4
4
  ref="button"
5
5
  )
6
6
  a(
7
- href="javascript:;"
8
- @click="onClickedToggle"
9
- ref="toggle"
10
- ).toggle-button
7
+ href="javascript:;"
8
+ @click="onClickedToggle"
9
+ ref="toggle"
10
+ ).toggle-button
11
11
  .date-range
12
12
  SLIcon(icon="calendar")
13
13
  span.divider
@@ -19,17 +19,18 @@
19
19
  ClientOnly
20
20
  Teleport(to="body")
21
21
  SLCalendarPopup(
22
- :data-source-type='dataSourceType'
23
- :show-quicks="showQuicks"
24
- :showCompareSwitch="showCompareSwitch"
25
- :min-date="minDate"
26
- :maxDate="maxDate"
27
- :maxDays="maxDays"
28
- :modelValue="modelValue"
29
- @compare:change="onCompareChanged"
30
- @update:modelValue="onInputed"
31
- ref="popup"
32
- )
22
+ :data-source-type='dataSourceType'
23
+ :show-quicks="showQuicks"
24
+ :allow-quicks='allowQuicks'
25
+ :showCompareSwitch="showCompareSwitch"
26
+ :min-date="minDate"
27
+ :maxDate="maxDate"
28
+ :maxDays="maxDays"
29
+ :modelValue="modelValue"
30
+ @compare:change="onCompareChanged"
31
+ @update:modelValue="onInputed"
32
+ ref="popup"
33
+ )
33
34
  </template>
34
35
 
35
36
  <script lang="ts">
@@ -57,6 +58,15 @@ export default defineComponent({
57
58
  type: Boolean,
58
59
  default: true,
59
60
  },
61
+ allowQuicks: {
62
+ type: Array as PropType<Array<string>>,
63
+ default: () => [
64
+ 'last7Days',
65
+ 'last30Days',
66
+ 'last90Days',
67
+ 'lastMonth'
68
+ ],
69
+ },
60
70
  showCompareSwitch: {
61
71
  type: Boolean,
62
72
  default: true,
@@ -141,6 +141,15 @@ export default defineComponent({
141
141
  type: Boolean,
142
142
  default: true,
143
143
  },
144
+ allowQuicks: {
145
+ type: Array as PropType<Array<string>>,
146
+ default: () => [
147
+ 'last7Days',
148
+ 'last30Days',
149
+ 'last90Days',
150
+ 'lastMonth'
151
+ ],
152
+ },
144
153
  showCompareSwitch: {
145
154
  type: Boolean,
146
155
  default: true,
@@ -168,7 +177,7 @@ export default defineComponent({
168
177
  setup(props, { emit }) {
169
178
  const runtimeConfig = useRuntimeConfig();
170
179
 
171
- const { dataSourceType, minDate, maxDate, maxDays, modelValue } =
180
+ const { allowQuicks, dataSourceType, minDate, maxDate, maxDays, modelValue } =
172
181
  toRefs(props);
173
182
 
174
183
  const el = shallowRef<HTMLElement | null>(null);
@@ -328,14 +337,25 @@ export default defineComponent({
328
337
  return formatDate(baseDate.value, "yyyy/MM/dd");
329
338
  });
330
339
  const quicks = computed(() => {
331
- const quicks = [
332
- { key: "last7Days", label: "過去7天" },
333
- { key: "last30Days", label: "過去30天" },
334
- ];
335
-
336
- if (maxDaysProxy.value >= 90) {
337
- quicks.push({ key: "last90Days", label: "過去90天" });
338
- }
340
+ const quicks: {
341
+ key: 'last7Days' | 'last30Days' | 'last90Days' | 'lastMonth';
342
+ label: string;
343
+ }[] = [];
344
+
345
+ allowQuicks.value.forEach((allowQuick) => {
346
+ if (allowQuick === 'last7Days') {
347
+ quicks.push({ key: "last7Days", label: "過去7天" });
348
+ }
349
+ if (allowQuick === 'last30Days') {
350
+ quicks.push({ key: "last30Days", label: "過去30天" });
351
+ }
352
+ if (allowQuick === 'last90Days' && maxDaysProxy.value >= 90) {
353
+ quicks.push({ key: "last90Days", label: "過去90天" });
354
+ }
355
+ if (allowQuick === 'lastMonth') {
356
+ quicks.push({ key: "lastMonth", label: "上個月" });
357
+ }
358
+ });
339
359
 
340
360
  // if (diffNow.value <= 0) {
341
361
  // quicks.push({ key: 'yesterday', label: '昨天' });
@@ -343,7 +363,7 @@ export default defineComponent({
343
363
  // quicks.push({ key: 'yesterday', label: '過去1天' });
344
364
  // }
345
365
 
346
- return [...quicks, { key: "lastMonth", label: "上個月" }];
366
+ return quicks;
347
367
  });
348
368
  const maxDate1 = computed(() => {
349
369
  return maxDate.value;
@@ -381,8 +401,8 @@ export default defineComponent({
381
401
  if (!dateRange1.value) return "";
382
402
 
383
403
  return `${dateRange1.value.start
384
- ? formatDate(dateRange1.value.start, "yyyy/MM/dd")
385
- : ""
404
+ ? formatDate(dateRange1.value.start, "yyyy/MM/dd")
405
+ : ""
386
406
  }${dateRange1.value.end
387
407
  ? `-${formatDate(dateRange1.value.end, "yyyy/MM/dd")}`
388
408
  : ""
@@ -425,8 +445,8 @@ export default defineComponent({
425
445
  if (!dateRange2.value) return "";
426
446
 
427
447
  return `${dateRange2.value.start
428
- ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
429
- : ""
448
+ ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
449
+ : ""
430
450
  }${dateRange2.value.end
431
451
  ? `-${formatDate(dateRange2.value.end, "yyyy/MM/dd")}`
432
452
  : ""
@@ -435,8 +455,8 @@ export default defineComponent({
435
455
  const dateRange2Style2 = computed(() => {
436
456
  if (!dateRange2.value) return "";
437
457
  return `${dateRange2.value.start
438
- ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
439
- : ""
458
+ ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
459
+ : ""
440
460
  }${dateRange2.value.end
441
461
  ? ` - ${formatDate(dateRange2.value.end, "yyyy/MM/dd")}`
442
462
  : ""
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mptw/skylens-ui",
3
3
  "type": "module",
4
- "version": "1.4.59",
4
+ "version": "1.4.61",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",