@likable-hair/svelte 0.0.42 → 0.0.45

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.
Files changed (38) hide show
  1. package/common/Menu.svelte +92 -0
  2. package/common/Menu.svelte.d.ts +30 -0
  3. package/common/SimpleTable.svelte +74 -0
  4. package/common/SimpleTable.svelte.d.ts +51 -0
  5. package/common/scroller.d.ts +1 -1
  6. package/common/scroller.js +2 -2
  7. package/dates/Calendar.svelte +12 -10
  8. package/dates/Calendar.svelte.d.ts +3 -1
  9. package/dates/DatePicker.svelte +210 -0
  10. package/dates/DatePicker.svelte.d.ts +31 -0
  11. package/dates/MonthSelector.svelte +6 -4
  12. package/dates/MonthSelector.svelte.d.ts +4 -0
  13. package/dates/YearSelector.svelte +2 -2
  14. package/dates/utils.d.ts +8 -7
  15. package/dates/utils.js +135 -36
  16. package/dialogs/Dialog.svelte +10 -4
  17. package/forms/Checkbox.svelte +3 -3
  18. package/forms/FileInput.svelte +90 -0
  19. package/forms/FileInput.svelte.d.ts +43 -0
  20. package/forms/FileInputList.svelte +121 -0
  21. package/forms/FileInputList.svelte.d.ts +28 -0
  22. package/loaders/Skeleton.svelte +1 -2
  23. package/media/Avatar.svelte +28 -13
  24. package/media/Avatar.svelte.d.ts +2 -0
  25. package/media/DescriptiveAvatar.svelte +2 -1
  26. package/media/DescriptiveAvatar.svelte.d.ts +1 -0
  27. package/media/Icon.svelte +15 -13
  28. package/media/Icon.svelte.d.ts +4 -1
  29. package/media/ImageGrid.svelte +1 -2
  30. package/navigation/Breadcrumb.svelte +1 -2
  31. package/navigation/Chip.svelte +86 -0
  32. package/navigation/Chip.svelte.d.ts +31 -0
  33. package/navigation/Navigator.svelte +1 -2
  34. package/navigation/TabSwitcher.svelte +1 -2
  35. package/package.json +49 -3
  36. package/timeline/ScrollTimeLine.svelte +1 -2
  37. package/timeline/SimpleTimeLine.svelte +1 -2
  38. package/timeline/SimpleTimeLine.svelte.d.ts +1 -1
@@ -0,0 +1,92 @@
1
+ <script >import { v4 as uuidv4 } from 'uuid';
2
+ import { fly } from 'svelte/transition';
3
+ export let open = false, top = undefined, left = undefined, width, height, activator = undefined, anchor = 'bottom', closeOnClickOutside = false, inAnimation = fly, inAnimationConfig = {
4
+ duration: 100,
5
+ y: 10
6
+ }, outAnimation = fly, outAnimationConfig = {
7
+ duration: 100,
8
+ y: 10
9
+ };
10
+ let zIndex = 50, menuElement, currentUid = uuidv4();
11
+ function calculateMenuPosition(params) {
12
+ if (!!params.menuElement) {
13
+ if (!!params.activator) {
14
+ if (anchor == 'bottom') {
15
+ let { left: activatorLeft, top: activatorTop } = params.activator.getBoundingClientRect();
16
+ let activatorHeight = params.activator.offsetHeight;
17
+ top = activatorTop + window.scrollY + activatorHeight;
18
+ left = activatorLeft + window.scrollX;
19
+ }
20
+ else if (anchor == 'bottom-center') {
21
+ let { left: activatorLeft, top: activatorTop } = params.activator.getBoundingClientRect();
22
+ let activatorHeight = params.activator.offsetHeight;
23
+ let activatorWidth = params.activator.offsetWidth;
24
+ let menuWidth = params.menuElement.offsetWidth;
25
+ top = activatorTop + window.scrollY + activatorHeight;
26
+ left = activatorLeft + window.scrollX;
27
+ if (menuWidth > activatorWidth) {
28
+ left = left - ((menuWidth - activatorWidth) / 2);
29
+ }
30
+ else {
31
+ left = left - ((activatorWidth - menuWidth) / 2);
32
+ }
33
+ }
34
+ }
35
+ if ((window.innerWidth + window.scrollX) < (left + menuElement.offsetWidth)) {
36
+ left = Math.max((window.innerWidth + window.scrollX) - menuElement.offsetWidth, 0);
37
+ }
38
+ }
39
+ }
40
+ $: if (open) {
41
+ let otherMenus = document.querySelectorAll("[data-menu=true]");
42
+ let otherDialogs = document.querySelectorAll("[data-dialog=true]");
43
+ let maxZIndex = undefined;
44
+ if (otherDialogs.length > 0) {
45
+ otherDialogs.forEach((dialog) => {
46
+ if (!maxZIndex || maxZIndex < Number(dialog.style.zIndex))
47
+ maxZIndex = Number(dialog.style.zIndex);
48
+ });
49
+ }
50
+ if (otherMenus.length > 0) {
51
+ let maxZIndex;
52
+ otherMenus.forEach((menu) => {
53
+ if (!maxZIndex || maxZIndex < Number(menu.style.zIndex))
54
+ maxZIndex = Number(menu.style.zIndex);
55
+ });
56
+ }
57
+ calculateMenuPosition({ activator, menuElement });
58
+ if (!!maxZIndex)
59
+ zIndex = maxZIndex + 2;
60
+ }
61
+ $: if (closeOnClickOutside && !!menuElement) {
62
+ window.addEventListener('click', (event) => {
63
+ open = false;
64
+ });
65
+ if (!!activator) {
66
+ activator.addEventListener('click', (event) => {
67
+ event.stopPropagation();
68
+ });
69
+ }
70
+ menuElement.addEventListener('click', (event) => {
71
+ event.stopPropagation();
72
+ });
73
+ }
74
+ </script>
75
+
76
+ {#if open}
77
+ <div
78
+ bind:this={menuElement}
79
+ data-menu
80
+ data-uid={currentUid}
81
+ style:z-index={zIndex}
82
+ style:position="absolute"
83
+ style:top={top + "px"}
84
+ style:left={left + "px"}
85
+ style:height={height}
86
+ style:width={width}
87
+ in:inAnimation={inAnimationConfig}
88
+ out:outAnimation={outAnimationConfig}
89
+ >
90
+ <slot></slot>
91
+ </div>
92
+ {/if}
@@ -0,0 +1,30 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import { type FadeParams, type FlyParams, type SlideParams, type TransitionConfig } from 'svelte/transition';
3
+ declare const __propDef: {
4
+ props: {
5
+ open?: boolean;
6
+ top?: number;
7
+ left?: number;
8
+ width: string;
9
+ height: string;
10
+ activator?: HTMLElement;
11
+ anchor?: 'bottom' | 'bottom-center';
12
+ closeOnClickOutside?: boolean;
13
+ inAnimation?: (node: Element, params?: SlideParams | FlyParams | FadeParams) => TransitionConfig;
14
+ inAnimationConfig?: SlideParams | FlyParams | FadeParams;
15
+ outAnimation?: (node: Element, params?: SlideParams | FlyParams | FadeParams) => TransitionConfig;
16
+ outAnimationConfig?: SlideParams | FlyParams | FadeParams;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {
22
+ default: {};
23
+ };
24
+ };
25
+ export declare type MenuProps = typeof __propDef.props;
26
+ export declare type MenuEvents = typeof __propDef.events;
27
+ export declare type MenuSlots = typeof __propDef.slots;
28
+ export default class Menu extends SvelteComponentTyped<MenuProps, MenuEvents, MenuSlots> {
29
+ }
30
+ export {};
@@ -0,0 +1,74 @@
1
+ <script context="module" ></script>
2
+
3
+ <script >import { dateToString } from "../dates/utils";
4
+ export let headers = undefined, items = undefined, backgroundColor = "rgba(255,255,255,0)", headerColor = "rgba(0,0,0,0.05)", rowSeparatorColor = headerColor, headerHeight = "30px", rowHeight = "70px", minWidth = undefined, height = "100%", width = "100%";
5
+ </script>
6
+
7
+ <div class="container" style:height style:width>
8
+ <table
9
+ style:background-color={backgroundColor}
10
+ style:width="100%"
11
+ style:min-width={minWidth}
12
+ >
13
+ <thead
14
+ style:background-color={headerColor}
15
+ style:height={headerHeight}
16
+ >
17
+ {#each headers as head}
18
+ <th
19
+ style:width={head.width}
20
+ style:min-width={head.minWidth}
21
+ >
22
+ {head.label}
23
+ </th>
24
+ {/each}
25
+ {#if $$slots.appendLastColumn}
26
+ <th></th>
27
+ {/if}
28
+ </thead>
29
+ <tbody>
30
+ {#each items as item, i}
31
+ <tr
32
+ style:border-color={rowSeparatorColor}
33
+ style:height={rowHeight}
34
+ >
35
+ {#each headers as header , j}
36
+ <td>
37
+ {#if header.type=='custom'}
38
+ <slot name="customColumn" index={i} columnIndex={j} item={item}></slot>
39
+ {:else if header.type=='date'}
40
+ {dateToString(item[header.value], 'dayAndHours', 'it')}
41
+ {:else}
42
+ {item[header.value]}
43
+ {/if}
44
+ </td>
45
+ {/each}
46
+ {#if $$slots.appendLastColumn}
47
+ <td>
48
+ <slot name="appendLastColumn" index={i} item={item}></slot>
49
+ </td>
50
+ {/if}
51
+ </tr>
52
+ {/each}
53
+ </tbody>
54
+ </table>
55
+ </div>
56
+
57
+ <style>
58
+ table {
59
+ border-collapse: collapse;
60
+ width: 100%;
61
+ }
62
+ th {
63
+ text-align: start;
64
+ padding-left: 10px;
65
+ min-width: 100px;
66
+ }
67
+ td {
68
+ padding-left: 10px;
69
+ }
70
+ tr:not(:first-child) {
71
+ border: solid;
72
+ border-width: 2px 0;
73
+ }
74
+ </style>
@@ -0,0 +1,51 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ export declare type Header = {
3
+ value: string;
4
+ label: string;
5
+ type: 'boolean' | 'string' | 'number' | 'date' | 'custom';
6
+ width?: string;
7
+ minWidth?: string;
8
+ data?: {
9
+ [key: string]: any;
10
+ };
11
+ };
12
+ declare const __propDef: {
13
+ props: {
14
+ headers?: Header[];
15
+ items?: {
16
+ [key: string]: any;
17
+ }[];
18
+ backgroundColor?: string;
19
+ headerColor?: string;
20
+ rowSeparatorColor?: string;
21
+ headerHeight?: string;
22
+ rowHeight?: string;
23
+ minWidth?: string;
24
+ height?: string;
25
+ width?: string;
26
+ };
27
+ events: {
28
+ [evt: string]: CustomEvent<any>;
29
+ };
30
+ slots: {
31
+ customColumn: {
32
+ index: any;
33
+ columnIndex: any;
34
+ item: {
35
+ [key: string]: any;
36
+ };
37
+ };
38
+ appendLastColumn: {
39
+ index: any;
40
+ item: {
41
+ [key: string]: any;
42
+ };
43
+ };
44
+ };
45
+ };
46
+ export declare type SimpleTableProps = typeof __propDef.props;
47
+ export declare type SimpleTableEvents = typeof __propDef.events;
48
+ export declare type SimpleTableSlots = typeof __propDef.slots;
49
+ export default class SimpleTable extends SvelteComponentTyped<SimpleTableProps, SimpleTableEvents, SimpleTableSlots> {
50
+ }
51
+ export {};
@@ -1 +1 @@
1
- export declare function scrollAtCenter(parentElement: HTMLElement, targetElement: HTMLElement): void;
1
+ export declare function scrollAtCenter(parentElement: HTMLElement, targetElement: HTMLElement, mode: ScrollBehavior): void;
@@ -1,8 +1,8 @@
1
- export function scrollAtCenter(parentElement, targetElement) {
1
+ export function scrollAtCenter(parentElement, targetElement, mode) {
2
2
  const parentElementHeight = parentElement.offsetHeight;
3
3
  const targetElementheight = targetElement.offsetHeight;
4
4
  parentElement.scroll({
5
5
  top: targetElement.offsetTop - parentElement.offsetTop - (parentElementHeight - targetElementheight) / 2,
6
- behavior: "smooth"
6
+ behavior: mode
7
7
  });
8
8
  }
@@ -1,7 +1,7 @@
1
1
  <script >import { onMount } from 'svelte';
2
2
  import { fly } from 'svelte/transition';
3
- import { getDateRowsStats, getMonthName } from './utils';
4
- export let selectedDate = undefined, visibleMonth = new Date().getMonth(), visibleYear = new Date().getFullYear(), showExtraMonthDays = true, showHeader = true, height = "100%", width = "100%", dayWidth = '30px', dayHeight = '30px', dayHoverColor = '#c9c8c873', daySelectedColor = '#adadad', dayBackgroundColor = undefined, animationDuration = 200;
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;
5
5
  onMount(() => {
6
6
  });
7
7
  import { createEventDispatcher } from 'svelte';
@@ -18,18 +18,18 @@ function handleDayClick(dateStat, extraMonth) {
18
18
  }
19
19
  </script>
20
20
 
21
- <div
21
+ <div
22
22
  style:height={height}
23
23
  style:width={width}
24
24
  >
25
25
  {#key visibleMonth }
26
- <div
26
+ <div
27
27
  in:fly="{{delay: animationDuration, duration: animationDuration, y: 30}}"
28
- out:fly="{{duration: animationDuration, y: -30}}"
28
+ out:fly|local="{{duration: animationDuration, y: -30}}"
29
29
  class="grid-layout"
30
30
  >
31
31
  {#if showHeader}
32
- {#each ['L', 'M', 'M', 'G', 'V', 'S', 'D'] as weekHeader, index}
32
+ {#each getDaysNames(locale).map(name => name[0]) as weekHeader, index}
33
33
  <slot
34
34
  name="weekHeader"
35
35
  header={weekHeader}
@@ -41,16 +41,16 @@ function handleDayClick(dateStat, extraMonth) {
41
41
  </slot>
42
42
  {/each}
43
43
  {/if}
44
- {#each getDateRowsStats(visibleMonth, visibleYear) as day}
44
+ {#each getDateRowsStats(visibleMonth, visibleYear, locale) as day}
45
45
  {@const selected = !!selectedDate && selectedDate.getDate() == day.dayOfMonth && selectedDate.getMonth() == day.month && selectedDate.getFullYear() == day.year}
46
46
  {@const extraMonth = day.month != visibleMonth}
47
- <slot
48
- name="day"
47
+ <slot
48
+ name="day"
49
49
  dayStat={day}
50
50
  extraMonth={extraMonth}
51
51
  selected={selected}
52
52
  >
53
- {#if (!showExtraMonthDays && day.month == visibleMonth) || showExtraMonthDays }
53
+ {#if (!showExtraMonthDays && day.month == visibleMonth) || showExtraMonthDays }
54
54
  <div
55
55
  style:border-radius="50%"
56
56
  style:background-color={dayBackgroundColor}
@@ -59,6 +59,7 @@ function handleDayClick(dateStat, extraMonth) {
59
59
  style:cursor={extraMonth ? 'default' : 'pointer'}
60
60
  style:--calendar-hover-color={extraMonth ? '' : dayHoverColor}
61
61
  style:--calendar-selected-color={daySelectedColor}
62
+ style:--calendar-selected-text-color={selectedTextColor}
62
63
  class="day-slot"
63
64
  class:extra-month={extraMonth}
64
65
  class:selected={selected}
@@ -97,6 +98,7 @@ function handleDayClick(dateStat, extraMonth) {
97
98
 
98
99
  .selected {
99
100
  background-color: var(--calendar-selected-color);
101
+ color: var(--calendar-selected-text-color);
100
102
  }
101
103
 
102
104
  .day-slot.not-selected:hover {
@@ -1,10 +1,11 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { DateStat } from './utils';
2
+ import type { DateStat, Locale } from './utils';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  selectedDate?: Date;
6
6
  visibleMonth?: number;
7
7
  visibleYear?: number;
8
+ locale?: Locale;
8
9
  showExtraMonthDays?: boolean;
9
10
  showHeader?: boolean;
10
11
  height?: string;
@@ -13,6 +14,7 @@ declare const __propDef: {
13
14
  dayHeight?: string;
14
15
  dayHoverColor?: string;
15
16
  daySelectedColor?: string;
17
+ selectedTextColor?: string;
16
18
  dayBackgroundColor?: string;
17
19
  animationDuration?: number;
18
20
  };
@@ -0,0 +1,210 @@
1
+ <script >import { getMonthName, dateToString } from "./utils";
2
+ import YearSelector from "./YearSelector.svelte";
3
+ import MonthSelector from "./MonthSelector.svelte";
4
+ import Calendar from "./Calendar.svelte";
5
+ import Button from "../buttons/Button.svelte";
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
+ let selectorText = undefined;
8
+ let selectableYears = [...Array(150).keys()].map((i) => i + (new Date().getFullYear() - 75));
9
+ let elementDisabled = 'date';
10
+ $: visibleSelector = view == 'day' || view == 'month';
11
+ $: {
12
+ selectorText =
13
+ view == 'day'
14
+ ? getMonthName(selectedMonth, locale) + " " + selectedYear
15
+ : selectedYear.toString();
16
+ }
17
+ $: elementDisabled = view == 'year' ? 'year' : 'date';
18
+ function next() {
19
+ if (view == 'day') {
20
+ if (selectedMonth == 11) {
21
+ selectedMonth = 0;
22
+ selectedYear += 1;
23
+ }
24
+ else {
25
+ selectedMonth += 1;
26
+ }
27
+ }
28
+ else {
29
+ if (selectedYear != selectableYears[selectableYears.length - 1])
30
+ selectedYear++;
31
+ }
32
+ }
33
+ function previous() {
34
+ if (view == 'day') {
35
+ if (selectedMonth == 0) {
36
+ selectedMonth = 11;
37
+ selectedYear -= 1;
38
+ }
39
+ else {
40
+ selectedMonth -= 1;
41
+ }
42
+ }
43
+ else {
44
+ if (selectedYear != selectableYears[0])
45
+ selectedYear--;
46
+ }
47
+ }
48
+ function SelectorHandler() {
49
+ if (view == 'month')
50
+ view = 'year';
51
+ else
52
+ view = 'month';
53
+ }
54
+ function handleYearChange() {
55
+ view = "month";
56
+ }
57
+ function handleMonthChange() {
58
+ view = "day";
59
+ }
60
+ </script>
61
+
62
+ <div
63
+ class="container"
64
+ style:background={cardBackGroundColor}
65
+ style:color={cardColor}
66
+ style:height
67
+ style:width
68
+ >
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
80
+ >
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}
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>
123
+ </div>
124
+ {/if}
125
+ {#if view == 'month'}
126
+ <MonthSelector
127
+ height="75%"
128
+ {width}
129
+ bind:selectedMonth
130
+ on:click={handleMonthChange}
131
+ locale={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={selectedDate}
150
+ dayHoverColor={hoverColor}
151
+ daySelectedColor={primaryColor}
152
+ selectedTextColor={selectedDayColor}
153
+ locale={locale}
154
+ />
155
+ {/if}
156
+ </div>
157
+ </div>
158
+
159
+ <style>
160
+ .container {
161
+ border-radius: 5px;
162
+ }
163
+ .header {
164
+ border-radius: 5px 5px 0 0;
165
+ }
166
+ .header > h2 {
167
+ margin-left: 30px;
168
+ transition: 0.1s;
169
+ opacity: 0.8;
170
+ }
171
+ .header > h2:hover {
172
+ opacity: 1;
173
+ cursor: pointer;
174
+ }
175
+ .header > span {
176
+ display: inline-block;
177
+ line-height: 100%;
178
+ margin-left: 15px;
179
+ margin-top: 10px;
180
+ opacity: 0.8;
181
+ transition: 0.1s;
182
+ }
183
+ .header > span:hover {
184
+ opacity: 1;
185
+ cursor: pointer;
186
+ }
187
+ .selector-row {
188
+ display: flex;
189
+ justify-content: space-between;
190
+ line-height: 100%;
191
+ }
192
+ .row-elem {
193
+ margin: auto;
194
+ }
195
+ .selector {
196
+ width: 50%;
197
+ text-align: center;
198
+ }
199
+ .selector > div {
200
+ transition: 0.1s;
201
+ }
202
+ .selector > div:hover {
203
+ cursor: pointer;
204
+ color: var(--primary-color);
205
+ }
206
+ .disabled {
207
+ pointer-events: none;
208
+ opacity: 1 !important;
209
+ }
210
+ </style>
@@ -0,0 +1,31 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Locale } from "./utils";
3
+ declare const __propDef: {
4
+ props: {
5
+ selectedYear?: number;
6
+ selectedMonth?: number;
7
+ selectedDate?: Date;
8
+ view?: 'year' | 'month' | 'day';
9
+ locale?: Locale;
10
+ primaryColor?: string;
11
+ headerBackgroundColor?: string;
12
+ arrowColor?: string;
13
+ hoverColor?: string;
14
+ selectedDayColor?: string;
15
+ headerColor?: string;
16
+ cardColor?: string;
17
+ cardBackGroundColor?: string;
18
+ height?: string;
19
+ width?: string;
20
+ };
21
+ events: {
22
+ [evt: string]: CustomEvent<any>;
23
+ };
24
+ slots: {};
25
+ };
26
+ export declare type DatePickerProps = typeof __propDef.props;
27
+ export declare type DatePickerEvents = typeof __propDef.events;
28
+ export declare type DatePickerSlots = typeof __propDef.slots;
29
+ export default class DatePicker extends SvelteComponentTyped<DatePickerProps, DatePickerEvents, DatePickerSlots> {
30
+ }
31
+ export {};
@@ -1,5 +1,5 @@
1
1
  <script >import { getMonthName } from './utils';
2
- export let selectedMonth = undefined, height = "100%", width = "100%";
2
+ export let selectedMonth = undefined, locale = 'it', height = "100%", width = "100%", monthSelectedColor = '#adadad', monthSelectedTextColor = '#21a';
3
3
  import { createEventDispatcher } from 'svelte';
4
4
  const dispatch = createEventDispatcher();
5
5
  function handleMonthClick(monthIndex) {
@@ -20,21 +20,23 @@ import Button from '../buttons/Button.svelte';
20
20
  <slot
21
21
  name="selector"
22
22
  month={monthIndex}
23
- monthName={getMonthName(monthIndex)}
23
+ monthName={getMonthName(monthIndex, locale)}
24
24
  >
25
25
  <Button
26
26
  active={monthIndex == selectedMonth}
27
27
  display="flex"
28
28
  alignItems="center"
29
29
  justifyContent="center"
30
+ activeBackgroundColor={monthSelectedColor}
31
+ color={monthIndex == selectedMonth ? monthSelectedTextColor : null}
30
32
  on:click={() => handleMonthClick(monthIndex)}
31
33
  >
32
34
  <slot
33
35
  name="label"
34
36
  month={monthIndex}
35
- monthName={getMonthName(monthIndex)}
37
+ monthName={getMonthName(monthIndex, locale)}
36
38
  >
37
- {getMonthName(monthIndex)}
39
+ {getMonthName(monthIndex, locale)}
38
40
  </slot>
39
41
  </Button>
40
42
  </slot>
@@ -1,9 +1,13 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
+ import type { Locale } from './utils';
2
3
  declare const __propDef: {
3
4
  props: {
4
5
  selectedMonth?: number;
6
+ locale?: Locale;
5
7
  height?: string;
6
8
  width?: string;
9
+ monthSelectedColor?: string;
10
+ monthSelectedTextColor?: string;
7
11
  };
8
12
  events: {
9
13
  click: CustomEvent<{
@@ -3,12 +3,12 @@ import { createEventDispatcher, onMount } from 'svelte';
3
3
  export let selectedYear = undefined, selectableYears = [...Array(150).keys()].map(i => i + (new Date().getFullYear() - 75)), height = "100%", width = "100%";
4
4
  let container, targetButtons = {};
5
5
  onMount(() => {
6
- scrollAtCenter(container, targetButtons[selectedYear]);
6
+ scrollAtCenter(container, targetButtons[selectedYear], "auto");
7
7
  });
8
8
  const dispatch = createEventDispatcher();
9
9
  function handleYearClick(year) {
10
10
  selectedYear = year;
11
- scrollAtCenter(container, targetButtons[selectedYear]);
11
+ scrollAtCenter(container, targetButtons[selectedYear], "smooth");
12
12
  dispatch('click', {
13
13
  year
14
14
  });