@invopop/popui 0.0.108 → 0.1.2
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/dist/AlertDialog.svelte +84 -59
- package/dist/AlertDialog.svelte.d.ts +5 -29
- package/dist/BaseButton.svelte +106 -101
- package/dist/BaseButton.svelte.d.ts +4 -34
- package/dist/BaseCard.svelte +20 -12
- package/dist/BaseCard.svelte.d.ts +4 -26
- package/dist/BaseCounter.svelte +13 -9
- package/dist/BaseCounter.svelte.d.ts +4 -17
- package/dist/BaseDropdown.svelte +54 -38
- package/dist/BaseDropdown.svelte.d.ts +6 -26
- package/dist/BaseFlag.svelte +6 -4
- package/dist/BaseFlag.svelte.d.ts +4 -17
- package/dist/BaseTable.svelte +226 -188
- package/dist/BaseTable.svelte.d.ts +4 -39
- package/dist/BaseTableActions.svelte +43 -33
- package/dist/BaseTableActions.svelte.d.ts +6 -21
- package/dist/BaseTableCellContent.svelte +19 -13
- package/dist/BaseTableCellContent.svelte.d.ts +4 -24
- package/dist/BaseTableCheckbox.svelte +19 -12
- package/dist/BaseTableCheckbox.svelte.d.ts +4 -21
- package/dist/BaseTableHeaderContent.svelte +30 -22
- package/dist/BaseTableHeaderContent.svelte.d.ts +4 -21
- package/dist/BaseTableHeaderOrderBy.svelte +24 -0
- package/dist/BaseTableHeaderOrderBy.svelte.d.ts +4 -0
- package/dist/BaseTableRow.svelte +78 -60
- package/dist/BaseTableRow.svelte.d.ts +4 -32
- package/dist/Breadcrumbs.svelte +14 -10
- package/dist/Breadcrumbs.svelte.d.ts +4 -19
- package/dist/ButtonFile.svelte +40 -29
- package/dist/ButtonFile.svelte.d.ts +4 -25
- package/dist/ButtonUuidCopy.svelte +27 -20
- package/dist/ButtonUuidCopy.svelte.d.ts +4 -22
- package/dist/CardCheckbox.svelte +28 -19
- package/dist/CardCheckbox.svelte.d.ts +4 -28
- package/dist/CardRelation.svelte +9 -8
- package/dist/CardRelation.svelte.d.ts +4 -22
- package/dist/CompanySelector.svelte +49 -43
- package/dist/CompanySelector.svelte.d.ts +4 -22
- package/dist/CounterWorkflow.svelte +12 -8
- package/dist/CounterWorkflow.svelte.d.ts +4 -17
- package/dist/DataListItem.svelte +24 -14
- package/dist/DataListItem.svelte.d.ts +4 -22
- package/dist/DatePicker.svelte +186 -386
- package/dist/DatePicker.svelte.d.ts +4 -22
- package/dist/DrawerContext.svelte +33 -22
- package/dist/DrawerContext.svelte.d.ts +4 -24
- package/dist/DrawerContextItem.svelte +69 -56
- package/dist/DrawerContextItem.svelte.d.ts +4 -23
- package/dist/DrawerContextSeparator.svelte +1 -1
- package/dist/DrawerContextSeparator.svelte.d.ts +22 -19
- package/dist/DrawerContextWorkspace.svelte +31 -32
- package/dist/DrawerContextWorkspace.svelte.d.ts +4 -20
- package/dist/DropdownSelect.svelte +93 -81
- package/dist/DropdownSelect.svelte.d.ts +4 -27
- package/dist/EmptyStateIcon.svelte +13 -7
- package/dist/EmptyStateIcon.svelte.d.ts +4 -22
- package/dist/EmptyStateIllustration.svelte +41 -33
- package/dist/EmptyStateIllustration.svelte.d.ts +4 -21
- package/dist/FeedEvents.svelte +5 -2
- package/dist/FeedEvents.svelte.d.ts +4 -17
- package/dist/FeedIconEvent.svelte +5 -3
- package/dist/FeedIconEvent.svelte.d.ts +4 -19
- package/dist/FeedIconStatus.svelte +23 -18
- package/dist/FeedIconStatus.svelte.d.ts +4 -17
- package/dist/FeedItem.svelte +33 -28
- package/dist/FeedItem.svelte.d.ts +4 -30
- package/dist/FeedItemDetail.svelte +21 -13
- package/dist/FeedItemDetail.svelte.d.ts +4 -23
- package/dist/FeedViewer.svelte +6 -13
- package/dist/FeedViewer.svelte.d.ts +4 -21
- package/dist/FormLayoutModal.svelte +9 -3
- package/dist/FormLayoutModal.svelte.d.ts +4 -29
- package/dist/GlobalSearch.svelte +38 -31
- package/dist/GlobalSearch.svelte.d.ts +4 -18
- package/dist/InputCheckbox.svelte +23 -14
- package/dist/InputCheckbox.svelte.d.ts +4 -23
- package/dist/InputError.svelte +4 -1
- package/dist/InputError.svelte.d.ts +4 -16
- package/dist/InputLabel.svelte +5 -3
- package/dist/InputLabel.svelte.d.ts +4 -18
- package/dist/InputRadio.svelte +25 -19
- package/dist/InputRadio.svelte.d.ts +4 -21
- package/dist/InputSearch.svelte +66 -46
- package/dist/InputSearch.svelte.d.ts +9 -32
- package/dist/InputSelect.svelte +36 -33
- package/dist/InputSelect.svelte.d.ts +4 -31
- package/dist/InputText.svelte +64 -48
- package/dist/InputText.svelte.d.ts +4 -28
- package/dist/InputTextarea.svelte +38 -29
- package/dist/InputTextarea.svelte.d.ts +4 -25
- package/dist/InputToggle.svelte +29 -22
- package/dist/InputToggle.svelte.d.ts +4 -20
- package/dist/MenuItem.svelte +99 -87
- package/dist/MenuItem.svelte.d.ts +5 -29
- package/dist/MenuItemCollapsible.svelte +26 -18
- package/dist/MenuItemCollapsible.svelte.d.ts +4 -24
- package/dist/Notification.svelte +35 -31
- package/dist/Notification.svelte.d.ts +4 -20
- package/dist/ProfileAvatar.svelte +26 -19
- package/dist/ProfileAvatar.svelte.d.ts +4 -21
- package/dist/ProfileSelector.svelte +25 -17
- package/dist/ProfileSelector.svelte.d.ts +4 -22
- package/dist/SectionLayout.svelte +6 -3
- package/dist/SectionLayout.svelte.d.ts +4 -18
- package/dist/SeparatorHorizontal.svelte +1 -1
- package/dist/SeparatorHorizontal.svelte.d.ts +22 -19
- package/dist/ShortcutWrapper.svelte +7 -1
- package/dist/ShortcutWrapper.svelte.d.ts +4 -27
- package/dist/StatusLabel.svelte +16 -12
- package/dist/StatusLabel.svelte.d.ts +4 -18
- package/dist/StepIconList.svelte +44 -41
- package/dist/StepIconList.svelte.d.ts +4 -17
- package/dist/TagBeta.svelte.d.ts +22 -19
- package/dist/TagSearch.svelte +19 -20
- package/dist/TagSearch.svelte.d.ts +4 -22
- package/dist/TagStatus.svelte +42 -37
- package/dist/TagStatus.svelte.d.ts +4 -19
- package/dist/TitleMain.svelte +9 -2
- package/dist/TitleMain.svelte.d.ts +4 -18
- package/dist/TitleSection.svelte +9 -2
- package/dist/TitleSection.svelte.d.ts +4 -18
- package/dist/UuidCopy.svelte +61 -48
- package/dist/UuidCopy.svelte.d.ts +4 -26
- package/dist/alert-dialog/alert-dialog-action.svelte +15 -15
- package/dist/alert-dialog/alert-dialog-action.svelte.d.ts +5 -26
- package/dist/alert-dialog/alert-dialog-cancel.svelte +13 -10
- package/dist/alert-dialog/alert-dialog-cancel.svelte.d.ts +3 -22
- package/dist/alert-dialog/alert-dialog-content.svelte +19 -15
- package/dist/alert-dialog/alert-dialog-content.svelte.d.ts +6 -15
- package/dist/alert-dialog/alert-dialog-description.svelte +11 -6
- package/dist/alert-dialog/alert-dialog-description.svelte.d.ts +3 -16
- package/dist/alert-dialog/alert-dialog-footer.svelte +11 -5
- package/dist/alert-dialog/alert-dialog-footer.svelte.d.ts +4 -16
- package/dist/alert-dialog/alert-dialog-header.svelte +14 -5
- package/dist/alert-dialog/alert-dialog-header.svelte.d.ts +4 -16
- package/dist/alert-dialog/alert-dialog-overlay.svelte +10 -13
- package/dist/alert-dialog/alert-dialog-overlay.svelte.d.ts +3 -14
- package/dist/alert-dialog/alert-dialog-title.svelte +11 -8
- package/dist/alert-dialog/alert-dialog-title.svelte.d.ts +3 -16
- package/dist/alert-dialog/alert-dialog-trigger.svelte +6 -0
- package/dist/alert-dialog/alert-dialog-trigger.svelte.d.ts +4 -0
- package/dist/alert-dialog/index.d.ts +3 -4
- package/dist/alert-dialog/index.js +2 -2
- package/dist/button/button.svelte +76 -18
- package/dist/button/button.svelte.d.ts +62 -14
- package/dist/button/index.d.ts +2 -60
- package/dist/button/index.js +1 -26
- package/dist/helpers.d.ts +4 -1
- package/dist/helpers.js +35 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.js +0 -4
- package/dist/range-calendar/index.d.ts +20 -0
- package/dist/range-calendar/index.js +22 -0
- package/dist/range-calendar/range-calendar-caption.svelte +71 -0
- package/dist/range-calendar/range-calendar-caption.svelte.d.ts +19 -0
- package/dist/range-calendar/range-calendar-cell.svelte +18 -0
- package/dist/range-calendar/range-calendar-cell.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-day.svelte +41 -0
- package/dist/range-calendar/range-calendar-day.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-grid-row.svelte +11 -0
- package/dist/range-calendar/range-calendar-grid-row.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-grid.svelte +15 -0
- package/dist/range-calendar/range-calendar-grid.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-head-cell.svelte +18 -0
- package/dist/range-calendar/range-calendar-head-cell.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-header.svelte +18 -0
- package/dist/range-calendar/range-calendar-header.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-heading.svelte +15 -0
- package/dist/range-calendar/range-calendar-heading.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-month-select.svelte +44 -0
- package/dist/range-calendar/range-calendar-month-select.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar-month.svelte +14 -0
- package/dist/range-calendar/range-calendar-month.svelte.d.ts +5 -0
- package/dist/range-calendar/range-calendar-months.svelte +18 -0
- package/dist/range-calendar/range-calendar-months.svelte.d.ts +5 -0
- package/dist/range-calendar/range-calendar-nav.svelte +18 -0
- package/dist/range-calendar/range-calendar-nav.svelte.d.ts +5 -0
- package/dist/range-calendar/range-calendar-next-button.svelte +30 -0
- package/dist/range-calendar/range-calendar-next-button.svelte.d.ts +8 -0
- package/dist/range-calendar/range-calendar-prev-button.svelte +30 -0
- package/dist/range-calendar/range-calendar-prev-button.svelte.d.ts +8 -0
- package/dist/range-calendar/range-calendar-year-select.svelte +43 -0
- package/dist/range-calendar/range-calendar-year-select.svelte.d.ts +4 -0
- package/dist/range-calendar/range-calendar.svelte +109 -0
- package/dist/range-calendar/range-calendar.svelte.d.ts +21 -0
- package/dist/svg/BgPattern.svelte.d.ts +22 -19
- package/dist/svg/IconContact.svelte +6 -1
- package/dist/svg/IconContact.svelte.d.ts +5 -15
- package/dist/svg/IconEmpty.svelte.d.ts +22 -19
- package/dist/svg/IconFile.svelte +6 -1
- package/dist/svg/IconFile.svelte.d.ts +5 -15
- package/dist/svg/IconInvoice.svelte +6 -1
- package/dist/svg/IconInvoice.svelte.d.ts +5 -15
- package/dist/svg/IconNoResults.svelte +6 -1
- package/dist/svg/IconNoResults.svelte.d.ts +5 -15
- package/dist/svg/IconPdf.svelte +6 -1
- package/dist/svg/IconPdf.svelte.d.ts +5 -15
- package/dist/svg/IconProduct.svelte +6 -1
- package/dist/svg/IconProduct.svelte.d.ts +5 -15
- package/dist/table/table-body.svelte +10 -5
- package/dist/table/table-body.svelte.d.ts +4 -16
- package/dist/table/table-caption.svelte +14 -5
- package/dist/table/table-caption.svelte.d.ts +4 -16
- package/dist/table/table-cell.svelte +16 -7
- package/dist/table/table-cell.svelte.d.ts +4 -19
- package/dist/table/table-footer.svelte +14 -5
- package/dist/table/table-footer.svelte.d.ts +4 -16
- package/dist/table/table-head.svelte +11 -5
- package/dist/table/table-head.svelte.d.ts +4 -16
- package/dist/table/table-header.svelte +17 -8
- package/dist/table/table-header.svelte.d.ts +4 -19
- package/dist/table/table-row.svelte +22 -8
- package/dist/table/table-row.svelte.d.ts +4 -22
- package/dist/table/table.svelte +11 -6
- package/dist/table/table.svelte.d.ts +4 -16
- package/dist/tabs/tabs-content.svelte +13 -8
- package/dist/tabs/tabs-content.svelte.d.ts +3 -16
- package/dist/tabs/tabs-list.svelte +7 -6
- package/dist/tabs/tabs-list.svelte.d.ts +3 -16
- package/dist/tabs/tabs-trigger.svelte +13 -9
- package/dist/tabs/tabs-trigger.svelte.d.ts +3 -14
- package/dist/tabs/tabs.svelte +12 -7
- package/dist/tabs/tabs.svelte.d.ts +3 -16
- package/dist/tooltip/index.d.ts +5 -3
- package/dist/tooltip/index.js +5 -3
- package/dist/tooltip/tooltip-content.svelte +42 -23
- package/dist/tooltip/tooltip-content.svelte.d.ts +5 -15
- package/dist/tooltip/tooltip-trigger.svelte +8 -0
- package/dist/tooltip/tooltip-trigger.svelte.d.ts +4 -0
- package/dist/tw.theme.d.ts +2 -9
- package/dist/tw.theme.js +0 -5
- package/dist/types.d.ts +484 -25
- package/dist/utils.d.ts +10 -1
- package/package.json +32 -41
- package/README.md +0 -234
- package/dist/BaseTableHeaderSortBy.svelte +0 -22
- package/dist/BaseTableHeaderSortBy.svelte.d.ts +0 -20
- package/dist/ComboBox.svelte +0 -12
- package/dist/ComboBox.svelte.d.ts +0 -21
- package/dist/ComboBoxContent.svelte +0 -33
- package/dist/ComboBoxContent.svelte.d.ts +0 -20
- package/dist/ProgressBar.svelte +0 -6
- package/dist/ProgressBar.svelte.d.ts +0 -16
- package/dist/alert-dialog/alert-dialog-portal.svelte +0 -6
- package/dist/alert-dialog/alert-dialog-portal.svelte.d.ts +0 -17
- package/dist/popui.css +0 -1
- package/dist/wcdispatch.d.ts +0 -1
- package/dist/wcdispatch.js +0 -9
package/dist/DatePicker.svelte
CHANGED
|
@@ -1,194 +1,193 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
let selectedPeriod = "custom";
|
|
41
|
-
const today = /* @__PURE__ */ new Date();
|
|
42
|
-
const startOfThisWeek = startOfWeek(today, { weekStartsOn: 1 });
|
|
43
|
-
const endOfThisWeek = endOfWeek(today, { weekStartsOn: 1 });
|
|
44
|
-
const startOfLastWeek = subWeeks(startOfThisWeek, 1);
|
|
45
|
-
const endOfLastWeek = endOfWeek(startOfLastWeek, { weekStartsOn: 1 });
|
|
46
|
-
const startOfThisMonth = startOfMonth(today);
|
|
47
|
-
const endOfThisMonth = endOfMonth(today);
|
|
48
|
-
const startOfLastMonth = subMonths(startOfThisMonth, 1);
|
|
49
|
-
const endOfLastMonth = endOfMonth(startOfLastMonth);
|
|
50
|
-
const startOfThisQuarter = startOfQuarter(today);
|
|
51
|
-
const endOfThisQuarter = endOfQuarter(today);
|
|
52
|
-
const startOfLastQuarter = subQuarters(startOfThisQuarter, 1);
|
|
53
|
-
const endOfLastQuarter = endOfQuarter(startOfLastQuarter);
|
|
54
|
-
const periods = [
|
|
55
|
-
{
|
|
56
|
-
slug: "this-week",
|
|
57
|
-
label: "This Week",
|
|
58
|
-
action: () => {
|
|
59
|
-
selectedPeriod = "this-week";
|
|
60
|
-
datepicker.setDate([startOfThisWeek, endOfThisWeek], true);
|
|
61
|
-
datepicker.jumpToDate(startOfThisWeek);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
slug: "last-week",
|
|
66
|
-
label: "Last Week",
|
|
67
|
-
action: () => {
|
|
68
|
-
selectedPeriod = "last-week";
|
|
69
|
-
datepicker.setDate([startOfLastWeek, endOfLastWeek], true);
|
|
70
|
-
datepicker.jumpToDate(startOfLastWeek);
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
slug: "this-month",
|
|
75
|
-
label: "This month",
|
|
76
|
-
action: () => {
|
|
77
|
-
selectedPeriod = "this-month";
|
|
78
|
-
datepicker.setDate([startOfThisMonth, endOfThisMonth], true);
|
|
79
|
-
datepicker.jumpToDate(startOfThisMonth);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
slug: "last-month",
|
|
84
|
-
label: "Last month",
|
|
85
|
-
action: () => {
|
|
86
|
-
selectedPeriod = "last-month";
|
|
87
|
-
datepicker.setDate([startOfLastMonth, endOfLastMonth], true);
|
|
88
|
-
datepicker.jumpToDate(startOfLastMonth);
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
slug: "this-quarter",
|
|
93
|
-
label: "This quarter",
|
|
94
|
-
action: () => {
|
|
95
|
-
selectedPeriod = "this-quarter";
|
|
96
|
-
datepicker.setDate([startOfThisQuarter, endOfThisQuarter], true);
|
|
97
|
-
datepicker.jumpToDate(startOfThisQuarter);
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
slug: "last-quarter",
|
|
102
|
-
label: "Last quarter",
|
|
103
|
-
action: () => {
|
|
104
|
-
selectedPeriod = "last-quarter";
|
|
105
|
-
datepicker.setDate([startOfLastQuarter, endOfLastQuarter], true);
|
|
106
|
-
datepicker.jumpToDate(startOfLastQuarter);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
slug: "custom",
|
|
111
|
-
label: "Custom",
|
|
112
|
-
action: () => {
|
|
113
|
-
datepicker.clear();
|
|
114
|
-
selectedPeriod = "custom";
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
];
|
|
118
|
-
onMount(() => {
|
|
119
|
-
datepicker = flatpickr(datePickerEl, {
|
|
120
|
-
onChange: function(dates) {
|
|
121
|
-
if (dates.length === 0) {
|
|
122
|
-
selectedLabel = label;
|
|
123
|
-
return;
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import RangeCalendar from './range-calendar/range-calendar.svelte'
|
|
4
|
+
import { parseDate, type DateValue } from '@internationalized/date'
|
|
5
|
+
import type { DateRange } from 'bits-ui'
|
|
6
|
+
import { Icon } from '@steeze-ui/svelte-icon'
|
|
7
|
+
import { Calendar } from '@invopop/ui-icons'
|
|
8
|
+
import Transition from 'svelte-transition'
|
|
9
|
+
import type { DatePickerProps } from './types'
|
|
10
|
+
import { clickOutside } from './clickOutside'
|
|
11
|
+
import BaseButton from './BaseButton.svelte'
|
|
12
|
+
import { datesFromToday, toCalendarDate } from './helpers'
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
startOfThisWeek,
|
|
16
|
+
endOfThisWeek,
|
|
17
|
+
startOfLastWeek,
|
|
18
|
+
endOfLastWeek,
|
|
19
|
+
startOfThisMonth,
|
|
20
|
+
endOfThisMonth,
|
|
21
|
+
startOfLastMonth,
|
|
22
|
+
endOfLastMonth,
|
|
23
|
+
startOfThisQuarter,
|
|
24
|
+
endOfThisQuarter,
|
|
25
|
+
startOfLastQuarter,
|
|
26
|
+
endOfLastQuarter,
|
|
27
|
+
today
|
|
28
|
+
} = datesFromToday()
|
|
29
|
+
|
|
30
|
+
const periods = [
|
|
31
|
+
{
|
|
32
|
+
slug: 'this-week',
|
|
33
|
+
label: 'This Week',
|
|
34
|
+
action: () => {
|
|
35
|
+
value = {
|
|
36
|
+
start: toCalendarDate(startOfThisWeek),
|
|
37
|
+
end: toCalendarDate(endOfThisWeek)
|
|
38
|
+
}
|
|
39
|
+
selectedPeriod = 'this-week'
|
|
124
40
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
slug: 'last-week',
|
|
44
|
+
label: 'Last Week',
|
|
45
|
+
action: () => {
|
|
46
|
+
value = {
|
|
47
|
+
start: toCalendarDate(startOfLastWeek),
|
|
48
|
+
end: toCalendarDate(endOfLastWeek)
|
|
49
|
+
}
|
|
50
|
+
selectedPeriod = 'last-week'
|
|
128
51
|
}
|
|
129
|
-
const from2 = getDate(dates[0]);
|
|
130
|
-
const to2 = getDate(dates[1]);
|
|
131
|
-
selectedDates = { from: from2, to: to2 };
|
|
132
52
|
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
53
|
+
{
|
|
54
|
+
slug: 'this-month',
|
|
55
|
+
label: 'This month',
|
|
56
|
+
action: () => {
|
|
57
|
+
value = {
|
|
58
|
+
start: toCalendarDate(startOfThisMonth),
|
|
59
|
+
end: toCalendarDate(endOfThisMonth)
|
|
60
|
+
}
|
|
61
|
+
selectedPeriod = 'this-month'
|
|
138
62
|
}
|
|
139
63
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
64
|
+
{
|
|
65
|
+
slug: 'last-month',
|
|
66
|
+
label: 'Last month',
|
|
67
|
+
action: () => {
|
|
68
|
+
value = {
|
|
69
|
+
start: toCalendarDate(startOfLastMonth),
|
|
70
|
+
end: toCalendarDate(endOfLastMonth)
|
|
71
|
+
}
|
|
72
|
+
selectedPeriod = 'last-month'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
slug: 'this-quarter',
|
|
77
|
+
label: 'This quarter',
|
|
78
|
+
action: () => {
|
|
79
|
+
value = {
|
|
80
|
+
start: toCalendarDate(startOfThisQuarter),
|
|
81
|
+
end: toCalendarDate(endOfThisQuarter)
|
|
82
|
+
}
|
|
83
|
+
selectedPeriod = 'this-quarter'
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
slug: 'last-quarter',
|
|
88
|
+
label: 'Last quarter',
|
|
89
|
+
action: () => {
|
|
90
|
+
value = {
|
|
91
|
+
start: toCalendarDate(startOfLastQuarter),
|
|
92
|
+
end: toCalendarDate(endOfLastQuarter)
|
|
93
|
+
}
|
|
94
|
+
selectedPeriod = 'last-quarter'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
slug: 'custom',
|
|
99
|
+
label: 'Custom',
|
|
100
|
+
action: () => {
|
|
101
|
+
value = {
|
|
102
|
+
start: toCalendarDate(today),
|
|
103
|
+
end: undefined
|
|
104
|
+
}
|
|
105
|
+
selectedPeriod = 'custom'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
let {
|
|
111
|
+
label = 'Date',
|
|
112
|
+
position = 'left',
|
|
113
|
+
from = '',
|
|
114
|
+
to = '',
|
|
115
|
+
onSelect
|
|
116
|
+
}: DatePickerProps = $props()
|
|
117
|
+
|
|
118
|
+
let selectedPeriod = $state('this-week')
|
|
119
|
+
let value = $state<DateRange>({
|
|
120
|
+
start: undefined,
|
|
121
|
+
end: undefined
|
|
122
|
+
})
|
|
123
|
+
let isOpen = $state(false)
|
|
124
|
+
let styles = $derived(
|
|
125
|
+
clsx({
|
|
126
|
+
'border-workspace-accent focus:border-workspace-accent shadow-active': isOpen,
|
|
127
|
+
'border-neutral-200 hover:border-neutral-300': !isOpen
|
|
128
|
+
})
|
|
129
|
+
)
|
|
130
|
+
let selectedLabel = $state(label)
|
|
131
|
+
|
|
132
|
+
$effect(() => {
|
|
133
|
+
if (!value.end) {
|
|
134
|
+
selectedPeriod = 'custom'
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
$effect(() => {
|
|
139
|
+
if (from) {
|
|
140
|
+
value = {
|
|
141
|
+
start: parseDate(from),
|
|
142
|
+
end: to ? parseDate(to) : undefined
|
|
143
|
+
}
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
value = {
|
|
147
|
+
start: toCalendarDate(startOfThisWeek),
|
|
148
|
+
end: toCalendarDate(endOfThisWeek)
|
|
149
|
+
}
|
|
150
|
+
selectedPeriod = 'this-week'
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
function cancel() {
|
|
154
|
+
isOpen = false
|
|
155
|
+
onSelect?.({ from: '', to: '' })
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function getDisplayFromValue(value: DateValue | undefined) {
|
|
159
|
+
if (!value) return ''
|
|
160
|
+
|
|
161
|
+
const date = value.toString()
|
|
162
|
+
|
|
163
|
+
const parts = date.split('-')
|
|
164
|
+
|
|
165
|
+
return `${parts[2]}/${parts[1]}/${parts[0]}`
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function getLabel() {
|
|
169
|
+
if (!value.start) return label
|
|
170
|
+
|
|
171
|
+
if (value.start === value.end) return getDisplayFromValue(value.start)
|
|
172
|
+
|
|
173
|
+
return `${getDisplayFromValue(value.start)} → ${getDisplayFromValue(value.end)}`
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function confirm() {
|
|
177
|
+
isOpen = false
|
|
178
|
+
selectedLabel = getLabel()
|
|
179
|
+
|
|
180
|
+
onSelect?.({ from: value.start?.toString() || '', to: value.end?.toString() || '' })
|
|
181
|
+
}
|
|
183
182
|
</script>
|
|
184
183
|
|
|
185
184
|
<div>
|
|
186
185
|
<div class="relative">
|
|
187
186
|
<button
|
|
188
|
-
|
|
187
|
+
onclick={() => {
|
|
189
188
|
isOpen = !isOpen
|
|
190
189
|
}}
|
|
191
|
-
class="{styles} datepicker-trigger w-full py-1.25 pl-7 pr-8 border rounded-md text-neutral-800 placeholder-neutral-800 text-base"
|
|
190
|
+
class="{styles} datepicker-trigger w-full py-1.25 pl-7 pr-8 border rounded-md text-neutral-800 placeholder-neutral-800 text-base cursor-pointer"
|
|
192
191
|
>
|
|
193
192
|
{selectedLabel}
|
|
194
193
|
</button>
|
|
@@ -211,230 +210,31 @@ function getDisplayFromValue(value) {
|
|
|
211
210
|
class:right-0={position === 'right'}
|
|
212
211
|
class="bg-white inline-flex flex-col shadow rounded-lg absolute right-0 top-2 z-40"
|
|
213
212
|
use:clickOutside
|
|
214
|
-
|
|
213
|
+
onclick_outside={() => {
|
|
215
214
|
if (!isOpen) return
|
|
216
215
|
cancel()
|
|
217
216
|
}}
|
|
218
217
|
>
|
|
219
|
-
<div class="flex border-b border-neutral-100 h-[300px]">
|
|
218
|
+
<div class="flex border-b border-neutral-100 min-h-[300px] rounded-lg shadow-calendar">
|
|
220
219
|
<div class="flex flex-col space-y-2 items-start p-3 border-r border-neutral-100">
|
|
221
220
|
{#each periods as period}
|
|
222
221
|
<button
|
|
223
|
-
|
|
222
|
+
onclick={period.action}
|
|
224
223
|
class="{selectedPeriod === period.slug
|
|
225
|
-
? 'selected-period text-workspace-accent
|
|
226
|
-
: 'text-neutral-500
|
|
224
|
+
? 'selected-period text-workspace-accent-600 bg-workspace-accent-100'
|
|
225
|
+
: 'text-neutral-500'} whitespace-nowrap text-base px-2 py-1 tracking-normal rounded cursor-pointer"
|
|
227
226
|
>
|
|
228
227
|
{period.label}
|
|
229
228
|
</button>
|
|
230
229
|
{/each}
|
|
231
230
|
</div>
|
|
232
|
-
<
|
|
231
|
+
<RangeCalendar bind:value numberOfMonths={2} />
|
|
233
232
|
</div>
|
|
234
233
|
<div class="p-3 flex justify-end items-center space-x-3">
|
|
235
|
-
<BaseButton variant="secondary"
|
|
236
|
-
<BaseButton variant="primary"
|
|
237
|
-
Confirm
|
|
238
|
-
</BaseButton>
|
|
234
|
+
<BaseButton variant="secondary" onclick={cancel}>Cancel</BaseButton>
|
|
235
|
+
<BaseButton variant="primary" onclick={confirm} disabled={!value.end}>Confirm</BaseButton>
|
|
239
236
|
</div>
|
|
240
237
|
</div>
|
|
241
238
|
</Transition>
|
|
242
239
|
</div>
|
|
243
240
|
</div>
|
|
244
|
-
|
|
245
|
-
<style>
|
|
246
|
-
:global(.flatpickr-calendar) {
|
|
247
|
-
width: 508px !important;
|
|
248
|
-
padding-left: 12px;
|
|
249
|
-
padding-right: 12px;
|
|
250
|
-
padding-top: 4px;
|
|
251
|
-
padding-bottom: 8px;
|
|
252
|
-
font-family: 'Inter' !important;
|
|
253
|
-
top: 0 !important;
|
|
254
|
-
border-radius: 0;
|
|
255
|
-
box-shadow: none;
|
|
256
|
-
}
|
|
257
|
-
:global(.flatpickr-weekdaycontainer:nth-child(2)) {
|
|
258
|
-
margin-left: 28px;
|
|
259
|
-
}
|
|
260
|
-
:global(.dayContainer:nth-child(1)) {
|
|
261
|
-
margin-right: 28px;
|
|
262
|
-
}
|
|
263
|
-
:global(.flatpickr-months) {
|
|
264
|
-
padding-top: 8px;
|
|
265
|
-
padding-bottom: 12px;
|
|
266
|
-
}
|
|
267
|
-
:global(.flatpickr-current-month) {
|
|
268
|
-
padding-top: 0px;
|
|
269
|
-
display: flex;
|
|
270
|
-
align-items: center;
|
|
271
|
-
justify-content: center;
|
|
272
|
-
font-size: 14px;
|
|
273
|
-
height: 24px !important;
|
|
274
|
-
letter-spacing: -0.07px;
|
|
275
|
-
}
|
|
276
|
-
:global(.flatpickr-monthDropdown-months) {
|
|
277
|
-
font-weight: 500 !important;
|
|
278
|
-
height: 22px !important;
|
|
279
|
-
color: #09101c !important;
|
|
280
|
-
}
|
|
281
|
-
:global(.cur-month:hover) {
|
|
282
|
-
background-color: transparent !important;
|
|
283
|
-
}
|
|
284
|
-
:global(.numInputWrapper:hover) {
|
|
285
|
-
background-color: #fafbfb !important;
|
|
286
|
-
border: 1px solid #f3f5f5 !important;
|
|
287
|
-
}
|
|
288
|
-
:global(.numInputWrapper span.arrowUp) {
|
|
289
|
-
right: -4px;
|
|
290
|
-
border: 0;
|
|
291
|
-
background-color: transparent;
|
|
292
|
-
}
|
|
293
|
-
:global(.numInputWrapper span.arrowDown) {
|
|
294
|
-
right: -4px;
|
|
295
|
-
border: 0;
|
|
296
|
-
background-color: transparent;
|
|
297
|
-
}
|
|
298
|
-
:global(.cur-year, .cur-month) {
|
|
299
|
-
font-weight: 600 !important;
|
|
300
|
-
color: #09101c !important;
|
|
301
|
-
}
|
|
302
|
-
:global(.numInputWrapper) {
|
|
303
|
-
display: flex !important;
|
|
304
|
-
align-items: center;
|
|
305
|
-
justify-content: center;
|
|
306
|
-
height: 22px;
|
|
307
|
-
}
|
|
308
|
-
:global(.flatpickr-next-month) {
|
|
309
|
-
display: flex;
|
|
310
|
-
align-items: center;
|
|
311
|
-
justify-content: center;
|
|
312
|
-
height: 24px !important;
|
|
313
|
-
width: 24px !important;
|
|
314
|
-
border: 1px solid #e9ebeb;
|
|
315
|
-
right: 12px !important;
|
|
316
|
-
top: 12px !important;
|
|
317
|
-
padding: 0 !important;
|
|
318
|
-
border-radius: 4px;
|
|
319
|
-
}
|
|
320
|
-
:global(.flatpickr-prev-month) {
|
|
321
|
-
display: flex;
|
|
322
|
-
align-items: center;
|
|
323
|
-
justify-content: center;
|
|
324
|
-
height: 24px !important;
|
|
325
|
-
width: 24px !important;
|
|
326
|
-
border: 1px solid #e9ebeb;
|
|
327
|
-
left: 12px !important;
|
|
328
|
-
top: 12px !important;
|
|
329
|
-
padding: 0 !important;
|
|
330
|
-
border-radius: 4px;
|
|
331
|
-
}
|
|
332
|
-
:global(.flatpickr-weekdays) {
|
|
333
|
-
height: 32px;
|
|
334
|
-
}
|
|
335
|
-
:global(.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange) {
|
|
336
|
-
background-color: var(--workspace-accent-color, #169958) !important;
|
|
337
|
-
border: 0;
|
|
338
|
-
border-radius: 4px !important;
|
|
339
|
-
box-shadow: 0px 0px 0px 2px
|
|
340
|
-
color-mix(in lab, transparent 88%, var(--workspace-accent-color, #169958)) !important;
|
|
341
|
-
}
|
|
342
|
-
:global(
|
|
343
|
-
.flatpickr-day.selected:hover,
|
|
344
|
-
.flatpickr-day.startRange:hover,
|
|
345
|
-
.flatpickr-day.endRange:hover
|
|
346
|
-
) {
|
|
347
|
-
border: 0;
|
|
348
|
-
}
|
|
349
|
-
:global(.flatpickr-day.inRange) {
|
|
350
|
-
background-color: #f4f5f5;
|
|
351
|
-
border: 1px solid #f4f5f5;
|
|
352
|
-
box-shadow: none !important;
|
|
353
|
-
}
|
|
354
|
-
:global(.prevMonthDay, .nextMonthDay) {
|
|
355
|
-
color: #cccece !important;
|
|
356
|
-
font-weight: 500;
|
|
357
|
-
font-size: 13px;
|
|
358
|
-
}
|
|
359
|
-
:global(.prevMonthDay.inRange, .nextMonthDay.inRange) {
|
|
360
|
-
background-color: #f4f5f5 !important;
|
|
361
|
-
border: 1px solid #f4f5f5 !important;
|
|
362
|
-
}
|
|
363
|
-
:global(.flatpickr-weekday) {
|
|
364
|
-
width: 32px;
|
|
365
|
-
height: 32px;
|
|
366
|
-
display: flex !important;
|
|
367
|
-
align-items: center;
|
|
368
|
-
justify-content: center;
|
|
369
|
-
font-weight: 400 !important;
|
|
370
|
-
color: #9ca3af !important;
|
|
371
|
-
font-size: 12px !important;
|
|
372
|
-
}
|
|
373
|
-
:global(.flatpickr-weekdaycontainer) {
|
|
374
|
-
flex: 0 !important;
|
|
375
|
-
border-bottom: 1px solid #f3f5f5 !important;
|
|
376
|
-
}
|
|
377
|
-
:global(.flatpickr-prev-month svg) {
|
|
378
|
-
fill: #0a0a0a;
|
|
379
|
-
height: 10px !important;
|
|
380
|
-
width: 10px !important;
|
|
381
|
-
}
|
|
382
|
-
:global(.flatpickr-next-month svg) {
|
|
383
|
-
fill: #0a0a0a;
|
|
384
|
-
height: 10px !important;
|
|
385
|
-
width: 10px !important;
|
|
386
|
-
}
|
|
387
|
-
:global(.flatpickr-prev-month:hover svg, .flatpickr-next-month:hover svg) {
|
|
388
|
-
fill: #0a0a0a !important;
|
|
389
|
-
}
|
|
390
|
-
:global(.flatpickr-days) {
|
|
391
|
-
width: 496px !important;
|
|
392
|
-
}
|
|
393
|
-
:global(.dayContainer) {
|
|
394
|
-
width: 224px;
|
|
395
|
-
min-width: 224px;
|
|
396
|
-
max-width: 224px;
|
|
397
|
-
justify-content: start;
|
|
398
|
-
box-shadow: none !important;
|
|
399
|
-
}
|
|
400
|
-
:global(.flatpickr-day) {
|
|
401
|
-
margin-top: 2px !important;
|
|
402
|
-
border-radius: 4px;
|
|
403
|
-
width: 32px;
|
|
404
|
-
max-width: 32px;
|
|
405
|
-
height: 32px;
|
|
406
|
-
line-height: 32px;
|
|
407
|
-
display: flex !important;
|
|
408
|
-
font-weight: 500 !important;
|
|
409
|
-
align-items: center;
|
|
410
|
-
justify-content: center;
|
|
411
|
-
color: #0a0a0a;
|
|
412
|
-
}
|
|
413
|
-
:global(.flatpickr-day.today) {
|
|
414
|
-
border: 0;
|
|
415
|
-
border-bottom: 1px solid var(--workspace-accent-color, #169958);
|
|
416
|
-
border-radius: 0;
|
|
417
|
-
}
|
|
418
|
-
:global(.flatpickr-day.today:hover) {
|
|
419
|
-
background-color: #fafbfb !important;
|
|
420
|
-
border: 1px solid #f3f5f5 !important;
|
|
421
|
-
color: #0a0a0a;
|
|
422
|
-
border-radius: 4px;
|
|
423
|
-
}
|
|
424
|
-
:global(.flatpickr-day:hover) {
|
|
425
|
-
background-color: #fafbfb;
|
|
426
|
-
border: 1px solid #f3f5f5;
|
|
427
|
-
}
|
|
428
|
-
:global(.prevMonthDay:hover, .nextMonthDay:hover) {
|
|
429
|
-
background-color: #fafbfb !important;
|
|
430
|
-
border: 1px solid #f3f5f5 !important;
|
|
431
|
-
}
|
|
432
|
-
.datepicker-trigger {
|
|
433
|
-
appearance: none;
|
|
434
|
-
-webkit-appearance: none;
|
|
435
|
-
-moz-appearance: none;
|
|
436
|
-
background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3QgeD0iMiIgeT0iMiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiByeD0iNCIgZmlsbD0iI0YzRjRGNiIvPgo8cGF0aCBkPSJNNi41IDguMjUwMDRMMTAgMTEuNzVMMTMuNSA4LjI1IiBzdHJva2U9IiMwMzA3MTIiIHN0cm9rZS13aWR0aD0iMS4xIi8+Cjwvc3ZnPg==');
|
|
437
|
-
background-repeat: no-repeat;
|
|
438
|
-
background-position: center right 8px;
|
|
439
|
-
}
|
|
440
|
-
</style>
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
label?: string | undefined;
|
|
6
|
-
position?: "right" | "left" | undefined;
|
|
7
|
-
from?: string | undefined;
|
|
8
|
-
to?: string | undefined;
|
|
9
|
-
};
|
|
10
|
-
events: {
|
|
11
|
-
selected: CustomEvent<any>;
|
|
12
|
-
} & {
|
|
13
|
-
[evt: string]: CustomEvent<any>;
|
|
14
|
-
};
|
|
15
|
-
slots: {};
|
|
16
|
-
};
|
|
17
|
-
export type DatePickerProps = typeof __propDef.props;
|
|
18
|
-
export type DatePickerEvents = typeof __propDef.events;
|
|
19
|
-
export type DatePickerSlots = typeof __propDef.slots;
|
|
20
|
-
export default class DatePicker extends SvelteComponent<DatePickerProps, DatePickerEvents, DatePickerSlots> {
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
1
|
+
import type { DatePickerProps } from './types';
|
|
2
|
+
declare const DatePicker: import("svelte").Component<DatePickerProps, {}, "">;
|
|
3
|
+
type DatePicker = ReturnType<typeof DatePicker>;
|
|
4
|
+
export default DatePicker;
|