@likable-hair/svelte 0.0.56 → 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/Calendar.svelte +3 -2
- package/dates/Calendar.svelte.d.ts +1 -0
- package/dates/DatePicker.svelte +152 -151
- package/dates/DatePicker.svelte.d.ts +7 -1
- package/dates/utils.js +0 -1
- package/dialogs/Dialog.svelte +13 -3
- package/media/DescriptiveAvatar.svelte +2 -2
- package/media/DescriptiveAvatar.svelte.d.ts +3 -1
- package/package.json +1 -1
package/dates/Calendar.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script >import { onMount } from 'svelte';
|
|
2
2
|
import { fly } from 'svelte/transition';
|
|
3
3
|
import { getDateRowsStats, getDaysNames } from './utils';
|
|
4
|
-
export let selectedDate = undefined, visibleMonth = new Date().getMonth(), visibleYear = new Date().getFullYear(), locale = 'it', showExtraMonthDays = true, showHeader = true, height = "100%", width = "100%", dayWidth = '30px', dayHeight = '30px', dayHoverColor = '#c9c8c873', daySelectedColor = '#adadad', selectedTextColor = "black", dayBackgroundColor = undefined, animationDuration = 200;
|
|
4
|
+
export let selectedDate = undefined, visibleMonth = new Date().getMonth(), visibleYear = new Date().getFullYear(), locale = 'it', showExtraMonthDays = true, showHeader = true, height = "100%", width = "100%", dayWidth = '30px', dayHeight = '30px', dayHoverColor = '#c9c8c873', daySelectedColor = '#adadad', selectedTextColor = "black", gridGap = "1px", dayBackgroundColor = undefined, animationDuration = 200;
|
|
5
5
|
onMount(() => {
|
|
6
6
|
});
|
|
7
7
|
import { createEventDispatcher } from 'svelte';
|
|
@@ -26,6 +26,7 @@ function handleDayClick(dateStat, extraMonth) {
|
|
|
26
26
|
<div
|
|
27
27
|
in:fly="{{delay: animationDuration, duration: animationDuration, y: 30}}"
|
|
28
28
|
out:fly|local="{{duration: animationDuration, y: -30}}"
|
|
29
|
+
style:gap={gridGap}
|
|
29
30
|
class="grid-layout"
|
|
30
31
|
>
|
|
31
32
|
{#if showHeader}
|
|
@@ -80,7 +81,7 @@ function handleDayClick(dateStat, extraMonth) {
|
|
|
80
81
|
.grid-layout {
|
|
81
82
|
display: grid;
|
|
82
83
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
|
83
|
-
|
|
84
|
+
height: 100%;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
.day-slot {
|
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: {};
|
package/dates/utils.js
CHANGED
package/dialogs/Dialog.svelte
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script >import {
|
|
1
|
+
<script >import { browser } from "$app/env";
|
|
2
|
+
import { beforeUpdate } from "svelte";
|
|
2
3
|
export let open = false, overlayOpacity = "30%", overlayColor = "#282828";
|
|
3
4
|
let zIndex = 50, localOpen = open;
|
|
4
5
|
beforeUpdate(() => {
|
|
@@ -12,6 +13,15 @@ beforeUpdate(() => {
|
|
|
12
13
|
});
|
|
13
14
|
zIndex = maxZIndex + 2;
|
|
14
15
|
}
|
|
16
|
+
document.body.style.overflow = 'hidden';
|
|
17
|
+
}
|
|
18
|
+
else if (!open) {
|
|
19
|
+
if (browser) {
|
|
20
|
+
let otherDialogs = document.querySelectorAll("[data-dialog=true]");
|
|
21
|
+
if (otherDialogs.length <= 1) {
|
|
22
|
+
document.body.style.overflow = 'auto';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
26
|
localOpen = open;
|
|
17
27
|
});
|
|
@@ -33,14 +43,14 @@ function handleOverlayClick() {
|
|
|
33
43
|
style:justify-content="space-between"
|
|
34
44
|
class="overlay-container"
|
|
35
45
|
class:overlay-container-active={localOpen}
|
|
36
|
-
on:touchmove|preventDefault={() => {}}
|
|
37
|
-
on:wheel|preventDefault={() => {}}
|
|
38
46
|
>
|
|
39
47
|
<div
|
|
40
48
|
style:background-color={overlayColor}
|
|
41
49
|
class="overlay"
|
|
42
50
|
class:overlay-active={localOpen}
|
|
43
51
|
on:click={handleOverlayClick}
|
|
52
|
+
on:touchmove|preventDefault={() => {}}
|
|
53
|
+
on:wheel|preventDefault={() => {}}
|
|
44
54
|
></div>
|
|
45
55
|
{#if localOpen }
|
|
46
56
|
<div
|
|
@@ -43,7 +43,7 @@ import Avatar from "./Avatar.svelte";
|
|
|
43
43
|
class="descriptive-avatar-container"
|
|
44
44
|
>
|
|
45
45
|
<div class="avatar-container">
|
|
46
|
-
<
|
|
46
|
+
<slot name="avatar">
|
|
47
47
|
<Avatar
|
|
48
48
|
src={src}
|
|
49
49
|
width={width}
|
|
@@ -56,7 +56,7 @@ import Avatar from "./Avatar.svelte";
|
|
|
56
56
|
lazyLoaded={lazyLoaded}
|
|
57
57
|
referrerpolicy={referrerpolicy}
|
|
58
58
|
></Avatar>
|
|
59
|
-
</
|
|
59
|
+
</slot>
|
|
60
60
|
</div>
|
|
61
61
|
<div
|
|
62
62
|
style:margin-left={!reverse && direction === 'row' ? avatarSpacing : undefined}
|
|
@@ -20,7 +20,9 @@ declare const __propDef: {
|
|
|
20
20
|
events: {
|
|
21
21
|
[evt: string]: CustomEvent<any>;
|
|
22
22
|
};
|
|
23
|
-
slots: {
|
|
23
|
+
slots: {
|
|
24
|
+
avatar: {};
|
|
25
|
+
};
|
|
24
26
|
};
|
|
25
27
|
export declare type DescriptiveAvatarProps = typeof __propDef.props;
|
|
26
28
|
export declare type DescriptiveAvatarEvents = typeof __propDef.events;
|