@likable-hair/svelte 0.0.58 → 0.0.59
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/dates/DatePicker.svelte +152 -151
- package/dates/DatePicker.svelte.d.ts +7 -1
- package/package.json +1 -1
package/dates/DatePicker.svelte
CHANGED
|
@@ -3,20 +3,20 @@ import YearSelector from "./YearSelector.svelte";
|
|
|
3
3
|
import MonthSelector from "./MonthSelector.svelte";
|
|
4
4
|
import Calendar from "./Calendar.svelte";
|
|
5
5
|
import Button from "../buttons/Button.svelte";
|
|
6
|
-
export let selectedYear = new Date().getFullYear(), selectedMonth = new Date().getMonth(), selectedDate = new Date(), view =
|
|
6
|
+
export let selectedYear = new Date().getFullYear(), selectedMonth = new Date().getMonth(), selectedDate = new Date(), view = "day", locale = "it", primaryColor = "#008080", headerBackgroundColor = primaryColor, arrowColor = primaryColor, hoverColor = "#00808012", selectedDayColor = "black", headerColor = "white", cardColor = "black", cardBackGroundColor = "rgba(255,255,255,0)", height = "100%", width = "100%";
|
|
7
7
|
let selectorText = undefined;
|
|
8
8
|
let selectableYears = [...Array(150).keys()].map((i) => i + (new Date().getFullYear() - 75));
|
|
9
|
-
let elementDisabled =
|
|
10
|
-
$: visibleSelector = view ==
|
|
9
|
+
let elementDisabled = "date";
|
|
10
|
+
$: visibleSelector = view == "day" || view == "month";
|
|
11
11
|
$: {
|
|
12
12
|
selectorText =
|
|
13
|
-
view ==
|
|
13
|
+
view == "day"
|
|
14
14
|
? getMonthName(selectedMonth, locale) + " " + selectedYear
|
|
15
15
|
: selectedYear.toString();
|
|
16
16
|
}
|
|
17
|
-
$: elementDisabled = view ==
|
|
17
|
+
$: elementDisabled = view == "year" ? "year" : "date";
|
|
18
18
|
function next() {
|
|
19
|
-
if (view ==
|
|
19
|
+
if (view == "day") {
|
|
20
20
|
if (selectedMonth == 11) {
|
|
21
21
|
selectedMonth = 0;
|
|
22
22
|
selectedYear += 1;
|
|
@@ -31,7 +31,7 @@ function next() {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
function previous() {
|
|
34
|
-
if (view ==
|
|
34
|
+
if (view == "day") {
|
|
35
35
|
if (selectedMonth == 0) {
|
|
36
36
|
selectedMonth = 11;
|
|
37
37
|
selectedYear -= 1;
|
|
@@ -46,10 +46,10 @@ function previous() {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
function SelectorHandler() {
|
|
49
|
-
if (view ==
|
|
50
|
-
view =
|
|
49
|
+
if (view == "month")
|
|
50
|
+
view = "year";
|
|
51
51
|
else
|
|
52
|
-
view =
|
|
52
|
+
view = "month";
|
|
53
53
|
}
|
|
54
54
|
function handleYearChange() {
|
|
55
55
|
view = "month";
|
|
@@ -60,151 +60,152 @@ function handleMonthChange() {
|
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
62
|
<div
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
class="container"
|
|
64
|
+
style:background={cardBackGroundColor}
|
|
65
|
+
style:color={cardColor}
|
|
66
|
+
style:height
|
|
67
|
+
style:width
|
|
68
68
|
>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
<div
|
|
70
|
+
class="header"
|
|
71
|
+
style:height="25%"
|
|
72
|
+
style:background={headerBackgroundColor}
|
|
73
|
+
style:color={headerColor}
|
|
74
|
+
>
|
|
75
|
+
<span
|
|
76
|
+
class:disabled={elementDisabled == "year"}
|
|
77
|
+
on:click={() => {
|
|
78
|
+
view = "year";
|
|
79
|
+
}}>{selectedYear}</span
|
|
74
80
|
>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{#key selectorText}
|
|
105
|
-
<div
|
|
106
|
-
on:click={SelectorHandler}
|
|
107
|
-
style:--primary-color={primaryColor}
|
|
108
|
-
>
|
|
109
|
-
{selectorText}
|
|
110
|
-
</div>
|
|
111
|
-
{/key}
|
|
112
|
-
</div>
|
|
113
|
-
<div class="row-elem">
|
|
114
|
-
<Button
|
|
115
|
-
color={arrowColor}
|
|
116
|
-
hoverBackgroundColor={hoverColor}
|
|
117
|
-
type="icon"
|
|
118
|
-
iconSize={25}
|
|
119
|
-
icon="mdi-chevron-right"
|
|
120
|
-
on:click={next}
|
|
121
|
-
/>
|
|
122
|
-
</div>
|
|
81
|
+
<h2
|
|
82
|
+
class:disabled={elementDisabled == "date"}
|
|
83
|
+
on:click={() => {
|
|
84
|
+
view = "day";
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
{dateToString(selectedDate, "dayAndMonth", locale)}
|
|
88
|
+
</h2>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="body" style:height="75%">
|
|
91
|
+
{#if visibleSelector}
|
|
92
|
+
<div class="selector-row" style:height="25%">
|
|
93
|
+
<div class="row-elem">
|
|
94
|
+
<Button
|
|
95
|
+
color={arrowColor}
|
|
96
|
+
hoverBackgroundColor={hoverColor}
|
|
97
|
+
type="icon"
|
|
98
|
+
iconSize={25}
|
|
99
|
+
icon="mdi-chevron-left"
|
|
100
|
+
on:click={previous}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="row-elem selector">
|
|
104
|
+
{#key selectorText}
|
|
105
|
+
<div
|
|
106
|
+
on:click={SelectorHandler}
|
|
107
|
+
style:--primary-color={primaryColor}
|
|
108
|
+
>
|
|
109
|
+
{selectorText}
|
|
123
110
|
</div>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
111
|
+
{/key}
|
|
112
|
+
</div>
|
|
113
|
+
<div class="row-elem">
|
|
114
|
+
<Button
|
|
115
|
+
color={arrowColor}
|
|
116
|
+
hoverBackgroundColor={hoverColor}
|
|
117
|
+
type="icon"
|
|
118
|
+
iconSize={25}
|
|
119
|
+
icon="mdi-chevron-right"
|
|
120
|
+
on:click={next}
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
{/if}
|
|
125
|
+
{#if view == "month"}
|
|
126
|
+
<MonthSelector
|
|
127
|
+
height="75%"
|
|
128
|
+
{width}
|
|
129
|
+
bind:selectedMonth
|
|
130
|
+
on:click={handleMonthChange}
|
|
131
|
+
{locale}
|
|
132
|
+
monthSelectedColor={primaryColor}
|
|
133
|
+
monthSelectedTextColor={selectedDayColor}
|
|
134
|
+
/>
|
|
135
|
+
{:else if view == "year"}
|
|
136
|
+
<YearSelector
|
|
137
|
+
height="100%"
|
|
138
|
+
{width}
|
|
139
|
+
bind:selectedYear
|
|
140
|
+
{selectableYears}
|
|
141
|
+
on:click={handleYearChange}
|
|
142
|
+
/>
|
|
143
|
+
{:else}
|
|
144
|
+
<Calendar
|
|
145
|
+
height="75%"
|
|
146
|
+
{width}
|
|
147
|
+
bind:visibleMonth={selectedMonth}
|
|
148
|
+
bind:visibleYear={selectedYear}
|
|
149
|
+
bind:selectedDate
|
|
150
|
+
dayHoverColor={hoverColor}
|
|
151
|
+
daySelectedColor={primaryColor}
|
|
152
|
+
selectedTextColor={selectedDayColor}
|
|
153
|
+
{locale}
|
|
154
|
+
on:day-click
|
|
155
|
+
/>
|
|
156
|
+
{/if}
|
|
157
|
+
</div>
|
|
157
158
|
</div>
|
|
158
159
|
|
|
159
160
|
<style>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
161
|
+
.container {
|
|
162
|
+
border-radius: 5px;
|
|
163
|
+
}
|
|
164
|
+
.header {
|
|
165
|
+
border-radius: 5px 5px 0 0;
|
|
166
|
+
}
|
|
167
|
+
.header > h2 {
|
|
168
|
+
margin-left: 30px;
|
|
169
|
+
transition: 0.1s;
|
|
170
|
+
opacity: 0.8;
|
|
171
|
+
}
|
|
172
|
+
.header > h2:hover {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
cursor: pointer;
|
|
175
|
+
}
|
|
176
|
+
.header > span {
|
|
177
|
+
display: inline-block;
|
|
178
|
+
line-height: 100%;
|
|
179
|
+
margin-left: 15px;
|
|
180
|
+
margin-top: 10px;
|
|
181
|
+
opacity: 0.8;
|
|
182
|
+
transition: 0.1s;
|
|
183
|
+
}
|
|
184
|
+
.header > span:hover {
|
|
185
|
+
opacity: 1;
|
|
186
|
+
cursor: pointer;
|
|
187
|
+
}
|
|
188
|
+
.selector-row {
|
|
189
|
+
display: flex;
|
|
190
|
+
justify-content: space-between;
|
|
191
|
+
line-height: 100%;
|
|
192
|
+
}
|
|
193
|
+
.row-elem {
|
|
194
|
+
margin: auto;
|
|
195
|
+
}
|
|
196
|
+
.selector {
|
|
197
|
+
width: 50%;
|
|
198
|
+
text-align: center;
|
|
199
|
+
}
|
|
200
|
+
.selector > div {
|
|
201
|
+
transition: 0.1s;
|
|
202
|
+
}
|
|
203
|
+
.selector > div:hover {
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
color: var(--primary-color);
|
|
206
|
+
}
|
|
207
|
+
.disabled {
|
|
208
|
+
pointer-events: none;
|
|
209
|
+
opacity: 1 !important;
|
|
210
|
+
}
|
|
210
211
|
</style>
|
|
@@ -5,7 +5,7 @@ declare const __propDef: {
|
|
|
5
5
|
selectedYear?: number;
|
|
6
6
|
selectedMonth?: number;
|
|
7
7
|
selectedDate?: Date;
|
|
8
|
-
view?:
|
|
8
|
+
view?: "year" | "month" | "day";
|
|
9
9
|
locale?: Locale;
|
|
10
10
|
primaryColor?: string;
|
|
11
11
|
headerBackgroundColor?: string;
|
|
@@ -19,6 +19,12 @@ declare const __propDef: {
|
|
|
19
19
|
width?: string;
|
|
20
20
|
};
|
|
21
21
|
events: {
|
|
22
|
+
'day-click': CustomEvent<{
|
|
23
|
+
dateStat: import("./utils").DateStat;
|
|
24
|
+
selected: boolean;
|
|
25
|
+
extraMonth: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
} & {
|
|
22
28
|
[evt: string]: CustomEvent<any>;
|
|
23
29
|
};
|
|
24
30
|
slots: {};
|