@likable-hair/svelte 0.0.34 → 0.0.37
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/buttons/Button.svelte +13 -3
- package/buttons/Button.svelte.d.ts +8 -1
- package/buttons/ToggleButton.svelte +0 -0
- package/buttons/ToggleButton.svelte.d.ts +19 -0
- package/common/scroller.d.ts +1 -0
- package/common/scroller.js +8 -0
- package/dates/Calendar.svelte +114 -1
- package/dates/Calendar.svelte.d.ts +33 -2
- package/dates/MonthSelector.svelte +50 -0
- package/dates/MonthSelector.svelte.d.ts +31 -0
- package/dates/YearSelector.svelte +63 -0
- package/dates/YearSelector.svelte.d.ts +30 -0
- package/dates/utils.d.ts +7 -0
- package/dates/utils.js +32 -0
- package/forms/Switch.svelte +79 -0
- package/forms/Switch.svelte.d.ts +25 -0
- package/forms/Textfield.svelte +88 -36
- package/forms/Textfield.svelte.d.ts +4 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +6 -1
package/buttons/Button.svelte
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
<script >export let type = 'default', loading = false, icon = undefined, iconSize = 15, clazz = '', maxWidth = undefined, maxHeight = undefined, minWidth = undefined, minHeight = undefined, width = undefined, height = undefined, textAlign = "center", cursor = "pointer", padding = "5px", fontSize = undefined, color = undefined, backgroundColor = undefined, hoverBackgroundColor = '#88888847', borderRadius = undefined, boxShadow = undefined;
|
|
1
|
+
<script >export let type = 'default', active = false, loading = false, icon = undefined, iconSize = 15, clazz = '', maxWidth = undefined, maxHeight = undefined, minWidth = undefined, minHeight = undefined, width = undefined, height = undefined, textAlign = "center", cursor = "pointer", padding = "5px", fontSize = undefined, color = undefined, display = undefined, justifyContent = undefined, alignItems = undefined, backgroundColor = undefined, hoverBackgroundColor = '#88888847', activeBackgroundColor = hoverBackgroundColor, borderRadius = undefined, boxShadow = undefined;
|
|
2
2
|
export { clazz as class };
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
function handleClick(event) {
|
|
6
|
+
dispatch('click', {
|
|
7
|
+
nativeEvent: event
|
|
8
|
+
});
|
|
9
|
+
}
|
|
3
10
|
$: defaultBorderRadius = type == 'icon' ? '50%' : '5px';
|
|
4
11
|
$: position = !!$$slots.append ? 'relative' : undefined;
|
|
5
12
|
import Icon from '../media/Icon.svelte';
|
|
@@ -19,8 +26,11 @@ import CircularLoader from '../loaders/CircularLoader.svelte';
|
|
|
19
26
|
style:padding={padding}
|
|
20
27
|
style:font-size={fontSize}
|
|
21
28
|
style:color={color}
|
|
29
|
+
style:display={display}
|
|
30
|
+
style:justify-content={justifyContent}
|
|
31
|
+
style:align-items={alignItems}
|
|
22
32
|
style:--button-border-radius={!!borderRadius ? borderRadius : defaultBorderRadius}
|
|
23
|
-
style:--button-background-color={backgroundColor}
|
|
33
|
+
style:--button-background-color={active ? activeBackgroundColor : backgroundColor}
|
|
24
34
|
style:--button-hover-background-color={hoverBackgroundColor}
|
|
25
35
|
style:--button-box-shadow={boxShadow}
|
|
26
36
|
style:--button-icon-height={(iconSize + 5) + 'pt'}
|
|
@@ -29,7 +39,7 @@ import CircularLoader from '../loaders/CircularLoader.svelte';
|
|
|
29
39
|
class:button-default={type === 'default'}
|
|
30
40
|
class:button-text={type === 'text'}
|
|
31
41
|
class:button-icon={type === 'icon'}
|
|
32
|
-
on:click
|
|
42
|
+
on:click={handleClick}
|
|
33
43
|
>
|
|
34
44
|
{#if loading}
|
|
35
45
|
<CircularLoader
|
|
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
type?: 'default' | 'text' | 'icon';
|
|
5
|
+
active?: boolean;
|
|
5
6
|
loading?: boolean;
|
|
6
7
|
icon?: string;
|
|
7
8
|
iconSize?: number;
|
|
@@ -17,13 +18,19 @@ declare const __propDef: {
|
|
|
17
18
|
padding?: string;
|
|
18
19
|
fontSize?: string;
|
|
19
20
|
color?: string;
|
|
21
|
+
display?: string;
|
|
22
|
+
justifyContent?: string;
|
|
23
|
+
alignItems?: string;
|
|
20
24
|
backgroundColor?: string;
|
|
21
25
|
hoverBackgroundColor?: string;
|
|
26
|
+
activeBackgroundColor?: string;
|
|
22
27
|
borderRadius?: string;
|
|
23
28
|
boxShadow?: string;
|
|
24
29
|
};
|
|
25
30
|
events: {
|
|
26
|
-
click:
|
|
31
|
+
click: CustomEvent<{
|
|
32
|
+
nativeEvent: MouseEvent;
|
|
33
|
+
}>;
|
|
27
34
|
} & {
|
|
28
35
|
[evt: string]: CustomEvent<any>;
|
|
29
36
|
};
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} ToggleButtonProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} ToggleButtonEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} ToggleButtonSlots */
|
|
4
|
+
export default class ToggleButton extends SvelteComponentTyped<{}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> {
|
|
7
|
+
}
|
|
8
|
+
export type ToggleButtonProps = typeof __propDef.props;
|
|
9
|
+
export type ToggleButtonEvents = typeof __propDef.events;
|
|
10
|
+
export type ToggleButtonSlots = typeof __propDef.slots;
|
|
11
|
+
import { SvelteComponentTyped } from "svelte";
|
|
12
|
+
declare const __propDef: {
|
|
13
|
+
props: {};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function scrollAtCenter(parentElement: HTMLElement, targetElement: HTMLElement): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function scrollAtCenter(parentElement, targetElement) {
|
|
2
|
+
const parentElementHeight = parentElement.offsetHeight;
|
|
3
|
+
const targetElementheight = targetElement.offsetHeight;
|
|
4
|
+
parentElement.scroll({
|
|
5
|
+
top: targetElement.offsetTop - parentElement.offsetTop - (parentElementHeight - targetElementheight) / 2,
|
|
6
|
+
behavior: "smooth"
|
|
7
|
+
});
|
|
8
|
+
}
|
package/dates/Calendar.svelte
CHANGED
|
@@ -1,3 +1,116 @@
|
|
|
1
|
-
<script >import {
|
|
1
|
+
<script >import { onMount } from 'svelte';
|
|
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;
|
|
5
|
+
onMount(() => {
|
|
6
|
+
});
|
|
7
|
+
import { createEventDispatcher } from 'svelte';
|
|
8
|
+
const dispatch = createEventDispatcher();
|
|
9
|
+
function handleDayClick(dateStat, extraMonth) {
|
|
10
|
+
if (!extraMonth) {
|
|
11
|
+
selectedDate = new Date(dateStat.year, dateStat.month, dateStat.dayOfMonth, 0, 0, 0, 0);
|
|
12
|
+
}
|
|
13
|
+
dispatch('day-click', {
|
|
14
|
+
dateStat: dateStat,
|
|
15
|
+
selected: !extraMonth,
|
|
16
|
+
extraMonth: extraMonth
|
|
17
|
+
});
|
|
18
|
+
}
|
|
2
19
|
</script>
|
|
3
20
|
|
|
21
|
+
<div
|
|
22
|
+
style:height={height}
|
|
23
|
+
style:width={width}
|
|
24
|
+
>
|
|
25
|
+
{#key visibleMonth }
|
|
26
|
+
<div
|
|
27
|
+
in:fly="{{delay: animationDuration, duration: animationDuration, y: 30}}"
|
|
28
|
+
out:fly="{{duration: animationDuration, y: -30}}"
|
|
29
|
+
class="grid-layout"
|
|
30
|
+
>
|
|
31
|
+
{#if showHeader}
|
|
32
|
+
{#each ['L', 'M', 'M', 'G', 'V', 'S', 'D'] as weekHeader, index}
|
|
33
|
+
<slot
|
|
34
|
+
name="weekHeader"
|
|
35
|
+
header={weekHeader}
|
|
36
|
+
index={index}
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
class="week-header-slot"
|
|
40
|
+
>{weekHeader}</div>
|
|
41
|
+
</slot>
|
|
42
|
+
{/each}
|
|
43
|
+
{/if}
|
|
44
|
+
{#each getDateRowsStats(visibleMonth, visibleYear) as day}
|
|
45
|
+
{@const selected = !!selectedDate && selectedDate.getDate() == day.dayOfMonth && selectedDate.getMonth() == day.month && selectedDate.getFullYear() == day.year}
|
|
46
|
+
{@const extraMonth = day.month != visibleMonth}
|
|
47
|
+
<slot
|
|
48
|
+
name="day"
|
|
49
|
+
dayStat={day}
|
|
50
|
+
extraMonth={extraMonth}
|
|
51
|
+
selected={selected}
|
|
52
|
+
>
|
|
53
|
+
{#if (!showExtraMonthDays && day.month == visibleMonth) || showExtraMonthDays }
|
|
54
|
+
<div
|
|
55
|
+
style:border-radius="50%"
|
|
56
|
+
style:background-color={dayBackgroundColor}
|
|
57
|
+
style:height={dayHeight}
|
|
58
|
+
style:width={dayWidth}
|
|
59
|
+
style:cursor={extraMonth ? 'default' : 'pointer'}
|
|
60
|
+
style:--calendar-hover-color={extraMonth ? '' : dayHoverColor}
|
|
61
|
+
style:--calendar-selected-color={daySelectedColor}
|
|
62
|
+
class="day-slot"
|
|
63
|
+
class:extra-month={extraMonth}
|
|
64
|
+
class:selected={selected}
|
|
65
|
+
class:not-selected={!selected}
|
|
66
|
+
on:click={() => handleDayClick(day, extraMonth)}
|
|
67
|
+
>{day.dayOfMonth}</div>
|
|
68
|
+
{:else}
|
|
69
|
+
<div></div>
|
|
70
|
+
{/if}
|
|
71
|
+
</slot>
|
|
72
|
+
{/each}
|
|
73
|
+
</div>
|
|
74
|
+
{/key}
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<style>
|
|
78
|
+
|
|
79
|
+
.grid-layout {
|
|
80
|
+
display: grid;
|
|
81
|
+
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
|
82
|
+
gap: 1px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.day-slot {
|
|
86
|
+
display: flex;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
align-items: center;
|
|
89
|
+
justify-self: center;
|
|
90
|
+
align-self: center;
|
|
91
|
+
transition: background-color .1s ease-in;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.extra-month {
|
|
95
|
+
opacity: 30%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.selected {
|
|
99
|
+
background-color: var(--calendar-selected-color);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.day-slot.not-selected:hover {
|
|
103
|
+
background-color: var(--calendar-hover-color);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.week-header-slot {
|
|
107
|
+
display: flex;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-self: center;
|
|
111
|
+
align-self: center;
|
|
112
|
+
font-weight: 800;
|
|
113
|
+
margin-bottom: 10px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
</style>
|
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { DateStat } from './utils';
|
|
2
3
|
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
+
props: {
|
|
5
|
+
selectedDate?: Date;
|
|
6
|
+
visibleMonth?: number;
|
|
7
|
+
visibleYear?: number;
|
|
8
|
+
showExtraMonthDays?: boolean;
|
|
9
|
+
showHeader?: boolean;
|
|
10
|
+
height?: string;
|
|
11
|
+
width?: string;
|
|
12
|
+
dayWidth?: string;
|
|
13
|
+
dayHeight?: string;
|
|
14
|
+
dayHoverColor?: string;
|
|
15
|
+
daySelectedColor?: string;
|
|
16
|
+
dayBackgroundColor?: string;
|
|
17
|
+
animationDuration?: number;
|
|
18
|
+
};
|
|
4
19
|
events: {
|
|
20
|
+
"day-click": CustomEvent<{
|
|
21
|
+
dateStat: DateStat;
|
|
22
|
+
selected: boolean;
|
|
23
|
+
extraMonth: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
} & {
|
|
5
26
|
[evt: string]: CustomEvent<any>;
|
|
6
27
|
};
|
|
7
|
-
slots: {
|
|
28
|
+
slots: {
|
|
29
|
+
weekHeader: {
|
|
30
|
+
header: string;
|
|
31
|
+
index: any;
|
|
32
|
+
};
|
|
33
|
+
day: {
|
|
34
|
+
dayStat: DateStat;
|
|
35
|
+
extraMonth: any;
|
|
36
|
+
selected: any;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
8
39
|
};
|
|
9
40
|
export declare type CalendarProps = typeof __propDef.props;
|
|
10
41
|
export declare type CalendarEvents = typeof __propDef.events;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script >import { getMonthName } from './utils';
|
|
2
|
+
export let selectedMonth = undefined, height = "100%", width = "100%";
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
function handleMonthClick(monthIndex) {
|
|
6
|
+
selectedMonth = monthIndex;
|
|
7
|
+
dispatch('click', {
|
|
8
|
+
monthIndex
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
import Button from '../buttons/Button.svelte';
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div
|
|
15
|
+
style:height={height}
|
|
16
|
+
style:width={width}
|
|
17
|
+
class="selector-container"
|
|
18
|
+
>
|
|
19
|
+
{#each [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] as monthIndex}
|
|
20
|
+
<slot
|
|
21
|
+
name="selector"
|
|
22
|
+
month={monthIndex}
|
|
23
|
+
monthName={getMonthName(monthIndex)}
|
|
24
|
+
>
|
|
25
|
+
<Button
|
|
26
|
+
active={monthIndex == selectedMonth}
|
|
27
|
+
display="flex"
|
|
28
|
+
alignItems="center"
|
|
29
|
+
justifyContent="center"
|
|
30
|
+
on:click={() => handleMonthClick(monthIndex)}
|
|
31
|
+
>
|
|
32
|
+
<slot
|
|
33
|
+
name="label"
|
|
34
|
+
month={monthIndex}
|
|
35
|
+
monthName={getMonthName(monthIndex)}
|
|
36
|
+
>
|
|
37
|
+
{getMonthName(monthIndex)}
|
|
38
|
+
</slot>
|
|
39
|
+
</Button>
|
|
40
|
+
</slot>
|
|
41
|
+
{/each}
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.selector-container {
|
|
46
|
+
display: grid;
|
|
47
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
48
|
+
gap: 5px;
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
selectedMonth?: number;
|
|
5
|
+
height?: string;
|
|
6
|
+
width?: string;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
click: CustomEvent<{
|
|
10
|
+
monthIndex: number;
|
|
11
|
+
}>;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {
|
|
16
|
+
selector: {
|
|
17
|
+
month: number;
|
|
18
|
+
monthName: string;
|
|
19
|
+
};
|
|
20
|
+
label: {
|
|
21
|
+
month: number;
|
|
22
|
+
monthName: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare type MonthSelectorProps = typeof __propDef.props;
|
|
27
|
+
export declare type MonthSelectorEvents = typeof __propDef.events;
|
|
28
|
+
export declare type MonthSelectorSlots = typeof __propDef.slots;
|
|
29
|
+
export default class MonthSelector extends SvelteComponentTyped<MonthSelectorProps, MonthSelectorEvents, MonthSelectorSlots> {
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script >import { scrollAtCenter } from "../common/scroller";
|
|
2
|
+
import { createEventDispatcher, onMount } from 'svelte';
|
|
3
|
+
export let selectedYear = undefined, selectableYears = [...Array(150).keys()].map(i => i + (new Date().getFullYear() - 75)), height = "100%", width = "100%";
|
|
4
|
+
let container, targetButtons = {};
|
|
5
|
+
onMount(() => {
|
|
6
|
+
scrollAtCenter(container, targetButtons[selectedYear]);
|
|
7
|
+
});
|
|
8
|
+
const dispatch = createEventDispatcher();
|
|
9
|
+
function handleYearClick(year) {
|
|
10
|
+
selectedYear = year;
|
|
11
|
+
scrollAtCenter(container, targetButtons[selectedYear]);
|
|
12
|
+
dispatch('click', {
|
|
13
|
+
year
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
import Button from '../buttons/Button.svelte';
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div
|
|
20
|
+
bind:this={container}
|
|
21
|
+
style:height={height}
|
|
22
|
+
style:width={width}
|
|
23
|
+
class="selector-container"
|
|
24
|
+
>
|
|
25
|
+
{#each selectableYears as year}
|
|
26
|
+
<slot
|
|
27
|
+
name="selector"
|
|
28
|
+
year={year}
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
bind:this={targetButtons[year]}
|
|
32
|
+
>
|
|
33
|
+
<Button
|
|
34
|
+
height="30px"
|
|
35
|
+
active={year == selectedYear}
|
|
36
|
+
display="flex"
|
|
37
|
+
alignItems="center"
|
|
38
|
+
justifyContent="center"
|
|
39
|
+
on:click={() => handleYearClick(year)}
|
|
40
|
+
>
|
|
41
|
+
<slot
|
|
42
|
+
name="label"
|
|
43
|
+
year={year}
|
|
44
|
+
>
|
|
45
|
+
<div
|
|
46
|
+
style:transition="all .1s"
|
|
47
|
+
style:font-weight={year == selectedYear ? '700' : '400'}
|
|
48
|
+
style:font-size={year == selectedYear ? '16pt' : '13pt'}
|
|
49
|
+
>
|
|
50
|
+
{year}
|
|
51
|
+
</div>
|
|
52
|
+
</slot>
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
55
|
+
</slot>
|
|
56
|
+
{/each}
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<style>
|
|
60
|
+
.selector-container {
|
|
61
|
+
overflow-y: auto;
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
selectedYear?: number;
|
|
5
|
+
selectableYears?: number[];
|
|
6
|
+
height?: string;
|
|
7
|
+
width?: string;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
click: CustomEvent<{
|
|
11
|
+
year: number;
|
|
12
|
+
}>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
selector: {
|
|
18
|
+
year: number;
|
|
19
|
+
};
|
|
20
|
+
label: {
|
|
21
|
+
year: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare type YearSelectorProps = typeof __propDef.props;
|
|
26
|
+
export declare type YearSelectorEvents = typeof __propDef.events;
|
|
27
|
+
export declare type YearSelectorSlots = typeof __propDef.slots;
|
|
28
|
+
export default class YearSelector extends SvelteComponentTyped<YearSelectorProps, YearSelectorEvents, YearSelectorSlots> {
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/dates/utils.d.ts
CHANGED
|
@@ -9,6 +9,13 @@ export declare type MonthStats = {
|
|
|
9
9
|
days: number;
|
|
10
10
|
};
|
|
11
11
|
export declare const getDateRows: (monthIndex: number, year: number) => number[];
|
|
12
|
+
export declare type DateStat = {
|
|
13
|
+
dayOfMonth: number;
|
|
14
|
+
dayOfWeek: number;
|
|
15
|
+
month: number;
|
|
16
|
+
year: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const getDateRowsStats: (monthIndex: number, year: number) => DateStat[];
|
|
12
19
|
declare type dateFormat = 'extended' | 'extendedMonthAndYear';
|
|
13
20
|
export declare const dateToString: (date: Date, format?: dateFormat) => string;
|
|
14
21
|
export {};
|
package/dates/utils.js
CHANGED
|
@@ -57,6 +57,38 @@ export const getDateRows = (monthIndex, year) => {
|
|
|
57
57
|
}
|
|
58
58
|
return rows.filter(el => !Array.isArray(el));
|
|
59
59
|
};
|
|
60
|
+
export const getDateRowsStats = (monthIndex, year) => {
|
|
61
|
+
let results = [];
|
|
62
|
+
const days = getDateRows(monthIndex, year);
|
|
63
|
+
for (let i = 0; i < days.length; i += 1) {
|
|
64
|
+
let dateStat = {
|
|
65
|
+
dayOfMonth: days[i],
|
|
66
|
+
dayOfWeek: i % 7,
|
|
67
|
+
month: monthIndex,
|
|
68
|
+
year: year
|
|
69
|
+
};
|
|
70
|
+
if (days[i] >= 20 && Math.floor(i / 7) == 0) {
|
|
71
|
+
if (monthIndex === 0) {
|
|
72
|
+
dateStat.month = 11;
|
|
73
|
+
dateStat.year = year - 1;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
dateStat.month = monthIndex - 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (days[i] < 10 && Math.floor(i / 7) > 2) {
|
|
80
|
+
if (monthIndex === 11) {
|
|
81
|
+
dateStat.month = 0;
|
|
82
|
+
dateStat.year = year + 1;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
dateStat.month = monthIndex + 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
results.push(dateStat);
|
|
89
|
+
}
|
|
90
|
+
return results;
|
|
91
|
+
};
|
|
60
92
|
const dateToExtendedString = (date) => {
|
|
61
93
|
const day = date.getDate();
|
|
62
94
|
const month = getMonthName(date.getMonth());
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script >export let value = false, height = "20px", width = "40px", padding = "6px", borderRadius = "10px", toggleActiveColor = "#5c5c5c", toggleDeactiveColor = "#5c5c5c", backgroundActiveColor = "#e6e6e6", backgroundDeactiveColor = "#e6e6e6", animationDuration = "0.1s";
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<span
|
|
5
|
+
style:--switch-toggle-active-color={toggleActiveColor}
|
|
6
|
+
style:--switch-toggle-deactive-color={toggleDeactiveColor}
|
|
7
|
+
style:--switch-animation-duration={animationDuration}
|
|
8
|
+
style:--switch-height={height}
|
|
9
|
+
style:--switch-width={width}
|
|
10
|
+
style:--switch-padding={padding}
|
|
11
|
+
style:--switch-border-radius={borderRadius}
|
|
12
|
+
class="container"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
class="inner-container"
|
|
16
|
+
style:background-color={value ? backgroundActiveColor : backgroundDeactiveColor}
|
|
17
|
+
on:click={() => value = !value}
|
|
18
|
+
>
|
|
19
|
+
<input
|
|
20
|
+
bind:checked={value}
|
|
21
|
+
type="checkbox"
|
|
22
|
+
>
|
|
23
|
+
<span
|
|
24
|
+
class="slider"
|
|
25
|
+
></span>
|
|
26
|
+
</div>
|
|
27
|
+
</span>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
.container {
|
|
31
|
+
position: relative;
|
|
32
|
+
width: var(--switch-width);
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
input {
|
|
37
|
+
position: absolute;
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.inner-container {
|
|
42
|
+
position: absolute;
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: var(--switch-height);
|
|
45
|
+
border-radius: var(--switch-border-radius);
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
transition: background-color var(--switch-animation-duration) ease;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.slider {
|
|
51
|
+
position: absolute;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
border-radius: var(--switch-border-radius);
|
|
55
|
+
transition: var(--switch-animation-duration);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.slider::before {
|
|
59
|
+
--switch-toggle-top-padding: calc(var(--switch-padding) / 2);
|
|
60
|
+
--switch-toggle-left-padding: calc(var(--switch-padding) / 2);
|
|
61
|
+
--switch-toggle-right-padding: calc(var(--switch-padding) / 2);
|
|
62
|
+
--switch-toggle-bottom-padding: calc(var(--switch-padding) / 2);
|
|
63
|
+
content: "";
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: var(--switch-toggle-top-padding);
|
|
66
|
+
left: var(--switch-toggle-left-padding);
|
|
67
|
+
width: calc(var(--switch-width) / 2 - var(--switch-toggle-right-padding) - var(--switch-toggle-left-padding));
|
|
68
|
+
height: calc(var(--switch-height) - var(--switch-toggle-top-padding) - var(--switch-toggle-bottom-padding));
|
|
69
|
+
border-radius: var(--switch-border-radius);
|
|
70
|
+
background-color: var(--switch-toggle-deactive-color);
|
|
71
|
+
transition: var(--switch-animation-duration);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
input:checked ~ .slider::before {
|
|
75
|
+
transform: translateX(calc(var(--switch-width) / 2));
|
|
76
|
+
background-color: var(--switch-toggle-active-color);
|
|
77
|
+
box-shadow: none;
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
value?: boolean;
|
|
5
|
+
height?: string;
|
|
6
|
+
width?: string;
|
|
7
|
+
padding?: string;
|
|
8
|
+
borderRadius?: string;
|
|
9
|
+
toggleActiveColor?: string;
|
|
10
|
+
toggleDeactiveColor?: string;
|
|
11
|
+
backgroundActiveColor?: string;
|
|
12
|
+
backgroundDeactiveColor?: string;
|
|
13
|
+
animationDuration?: string;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
};
|
|
18
|
+
slots: {};
|
|
19
|
+
};
|
|
20
|
+
export declare type SwitchProps = typeof __propDef.props;
|
|
21
|
+
export declare type SwitchEvents = typeof __propDef.events;
|
|
22
|
+
export declare type SwitchSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Switch extends SvelteComponentTyped<SwitchProps, SwitchEvents, SwitchSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/forms/Textfield.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script >export let label = "", placeholder = "", color =
|
|
1
|
+
<script >export let label = "", placeholder = "", color = null, value = "", variant = 'outlined', width = "100%", textColor = "black", borderWeight = "2px", borderRadius = "5px", borderColor = null, focusBorderColor = null, focusedBoxShadow = undefined, backgroundColor = null, padding = undefined, paddingLeft = undefined, paddingRight = undefined, paddingBottom = undefined, paddingTop = undefined, fontSize = undefined, type = 'text';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import { onMount } from 'svelte';
|
|
4
4
|
let inputId = uuidv4(), focused = false, legendWidth = 0, labelElement = undefined;
|
|
@@ -23,6 +23,7 @@ $: if (!!labelElement) {
|
|
|
23
23
|
height: 50px;
|
|
24
24
|
position: relative;
|
|
25
25
|
--textfield-final-color: var(--textfield-theme-color, --textfield-border-color, rgb(88, 88, 88));
|
|
26
|
+
--textfield-final-border-color: var(--textfield-border-color, var(--textfield-final-color))
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/* outlined input */
|
|
@@ -39,12 +40,12 @@ $: if (!!labelElement) {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
.fieldset-outlined {
|
|
42
|
-
border:
|
|
43
|
+
border: var(--textfield-border-weight) solid rgb(122, 122, 122);
|
|
43
44
|
padding-left: 4px;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
.focused .fieldset-outlined {
|
|
47
|
-
border:
|
|
48
|
+
border: var(--textfield-border-weight) solid var(--textfield-final-border-color);
|
|
48
49
|
color: var(--textfield-final-color);
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -74,7 +75,17 @@ $: if (!!labelElement) {
|
|
|
74
75
|
/* boxed input */
|
|
75
76
|
|
|
76
77
|
.fieldset-boxed {
|
|
77
|
-
|
|
78
|
+
padding: 5px;
|
|
79
|
+
transition: border 0.3s ease, box-shadow 0.3s ease;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.not-focused .fieldset-boxed {
|
|
83
|
+
border: var(--textfield-border-weight) solid var(--textfield-final-border-color);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.focused .fieldset-boxed {
|
|
87
|
+
border: var(--textfield-border-weight) solid var(--textfield-focus-border-color, var(--textfield-final-color));
|
|
88
|
+
box-shadow: var(--textfield-focused-box-shadow);
|
|
78
89
|
padding: 5px;
|
|
79
90
|
}
|
|
80
91
|
|
|
@@ -102,15 +113,18 @@ $: if (!!labelElement) {
|
|
|
102
113
|
style:width={width}
|
|
103
114
|
style:--textfield-theme-color={color}
|
|
104
115
|
style:--textfield-border-color={borderColor}
|
|
116
|
+
style:--textfield-border-weight={borderWeight}
|
|
117
|
+
style:--textfield-focus-border-color={focusBorderColor}
|
|
105
118
|
style:--textfield-legend-width={legendWidth + 'px'}
|
|
119
|
+
style:--textfield-focused-box-shadow={focusedBoxShadow}
|
|
106
120
|
class="input-container"
|
|
107
121
|
class:focused={focused}
|
|
122
|
+
class:not-focused={!focused}
|
|
108
123
|
class:texted={focused || !!value}
|
|
109
124
|
>
|
|
110
125
|
<fieldset
|
|
111
126
|
aria-hidden="true"
|
|
112
127
|
style:border-radius={borderRadius}
|
|
113
|
-
style:border-color={borderColor}
|
|
114
128
|
style:background-color={backgroundColor}
|
|
115
129
|
style:padding={padding}
|
|
116
130
|
style:padding-left={paddingLeft}
|
|
@@ -138,14 +152,78 @@ $: if (!!labelElement) {
|
|
|
138
152
|
<div>
|
|
139
153
|
<slot name="prepend-inner"></slot>
|
|
140
154
|
</div>
|
|
141
|
-
|
|
155
|
+
{#if type == 'password'}
|
|
156
|
+
<input
|
|
157
|
+
style:background-color={backgroundColor}
|
|
158
|
+
style:color={textColor}
|
|
159
|
+
style:font-size={fontSize}
|
|
160
|
+
id={inputId}
|
|
161
|
+
class="input-outlined"
|
|
162
|
+
type="password"
|
|
163
|
+
placeholder={placeholder}
|
|
164
|
+
bind:value={value}
|
|
165
|
+
on:change
|
|
166
|
+
on:input
|
|
167
|
+
on:focus={handleFocus}
|
|
168
|
+
on:focus
|
|
169
|
+
on:blur={handleBlur}
|
|
170
|
+
on:blur
|
|
171
|
+
/>
|
|
172
|
+
{:else if type == 'text'}
|
|
173
|
+
<input
|
|
174
|
+
style:background-color={backgroundColor}
|
|
175
|
+
style:color={textColor}
|
|
176
|
+
style:font-size={fontSize}
|
|
177
|
+
id={inputId}
|
|
178
|
+
class="input-outlined"
|
|
179
|
+
type="text"
|
|
180
|
+
placeholder={placeholder}
|
|
181
|
+
bind:value={value}
|
|
182
|
+
on:change
|
|
183
|
+
on:input
|
|
184
|
+
on:focus={handleFocus}
|
|
185
|
+
on:focus
|
|
186
|
+
on:blur={handleBlur}
|
|
187
|
+
on:blur
|
|
188
|
+
/>
|
|
189
|
+
{/if}
|
|
190
|
+
<div>
|
|
191
|
+
<slot name="append-inner"></slot>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
{:else if variant == 'boxed'}
|
|
195
|
+
<div
|
|
196
|
+
style:display="flex"
|
|
197
|
+
>
|
|
198
|
+
<div>
|
|
199
|
+
<slot name="prepend-inner"></slot>
|
|
200
|
+
</div>
|
|
201
|
+
{#if type == 'password'}
|
|
202
|
+
<input
|
|
203
|
+
style:background-color={backgroundColor}
|
|
204
|
+
style:color={textColor}
|
|
205
|
+
style:font-size={fontSize}
|
|
206
|
+
id={inputId}
|
|
207
|
+
class="input-boxed"
|
|
208
|
+
type="password"
|
|
209
|
+
placeholder={placeholder || label}
|
|
210
|
+
bind:value={value}
|
|
211
|
+
on:change
|
|
212
|
+
on:input
|
|
213
|
+
on:focus={handleFocus}
|
|
214
|
+
on:focus
|
|
215
|
+
on:blur={handleBlur}
|
|
216
|
+
on:blur
|
|
217
|
+
/>
|
|
218
|
+
{:else if type == 'text'}
|
|
219
|
+
<input
|
|
142
220
|
style:background-color={backgroundColor}
|
|
143
221
|
style:color={textColor}
|
|
144
222
|
style:font-size={fontSize}
|
|
145
|
-
id={inputId}
|
|
146
|
-
class="input-
|
|
223
|
+
id={inputId}
|
|
224
|
+
class="input-boxed"
|
|
147
225
|
type="text"
|
|
148
|
-
placeholder={placeholder}
|
|
226
|
+
placeholder={placeholder || label}
|
|
149
227
|
bind:value={value}
|
|
150
228
|
on:change
|
|
151
229
|
on:input
|
|
@@ -154,33 +232,7 @@ $: if (!!labelElement) {
|
|
|
154
232
|
on:blur={handleBlur}
|
|
155
233
|
on:blur
|
|
156
234
|
/>
|
|
157
|
-
|
|
158
|
-
<slot name="append-inner"></slot>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
{:else if variant == 'boxed'}
|
|
162
|
-
<div
|
|
163
|
-
style:display="flex"
|
|
164
|
-
>
|
|
165
|
-
<div>
|
|
166
|
-
<slot name="prepend-inner"></slot>
|
|
167
|
-
</div>
|
|
168
|
-
<input
|
|
169
|
-
style:background-color={backgroundColor}
|
|
170
|
-
style:color={textColor}
|
|
171
|
-
style:font-size={fontSize}
|
|
172
|
-
id={inputId}
|
|
173
|
-
class="input-boxed"
|
|
174
|
-
type="text"
|
|
175
|
-
placeholder={placeholder || label}
|
|
176
|
-
bind:value={value}
|
|
177
|
-
on:change
|
|
178
|
-
on:input
|
|
179
|
-
on:focus={handleFocus}
|
|
180
|
-
on:focus
|
|
181
|
-
on:blur={handleBlur}
|
|
182
|
-
on:blur
|
|
183
|
-
/>
|
|
235
|
+
{/if}
|
|
184
236
|
<div>
|
|
185
237
|
<slot name="append-inner"></slot>
|
|
186
238
|
</div>
|
|
@@ -8,8 +8,11 @@ declare const __propDef: {
|
|
|
8
8
|
variant?: "outlined" | "boxed";
|
|
9
9
|
width?: string;
|
|
10
10
|
textColor?: string;
|
|
11
|
+
borderWeight?: string;
|
|
11
12
|
borderRadius?: string;
|
|
12
13
|
borderColor?: string;
|
|
14
|
+
focusBorderColor?: string;
|
|
15
|
+
focusedBoxShadow?: string;
|
|
13
16
|
backgroundColor?: string;
|
|
14
17
|
padding?: string;
|
|
15
18
|
paddingLeft?: string;
|
|
@@ -17,6 +20,7 @@ declare const __propDef: {
|
|
|
17
20
|
paddingBottom?: string;
|
|
18
21
|
paddingTop?: string;
|
|
19
22
|
fontSize?: string;
|
|
23
|
+
type?: 'text' | 'password';
|
|
20
24
|
};
|
|
21
25
|
events: {
|
|
22
26
|
change: Event;
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as IntersectionObserver } from './common/IntersectionObserver.s
|
|
|
5
5
|
export { default as MediaQuery } from './common/MediaQuery.svelte';
|
|
6
6
|
export { default as Dialog } from './dialogs/Dialog.svelte';
|
|
7
7
|
export { default as TextField } from './forms/Textfield.svelte';
|
|
8
|
+
export { default as Switch } from './forms/Switch.svelte';
|
|
8
9
|
export { default as Skeleton } from './loaders/Skeleton.svelte';
|
|
9
10
|
export { default as CircularLoader } from './loaders/CircularLoader.svelte';
|
|
10
11
|
export { default as AttachmentDownloader } from './media/AttachmentDownloader.svelte';
|
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { default as MediaQuery } from './common/MediaQuery.svelte';
|
|
|
9
9
|
export { default as Dialog } from './dialogs/Dialog.svelte';
|
|
10
10
|
// forms
|
|
11
11
|
export { default as TextField } from './forms/Textfield.svelte';
|
|
12
|
+
export { default as Switch } from './forms/Switch.svelte';
|
|
12
13
|
// loaders
|
|
13
14
|
export { default as Skeleton } from './loaders/Skeleton.svelte';
|
|
14
15
|
export { default as CircularLoader } from './loaders/CircularLoader.svelte';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likable-hair/svelte",
|
|
3
3
|
"description": "A Svelte component for likablehair",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.37",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@sveltejs/adapter-auto": "next",
|
|
7
7
|
"@sveltejs/kit": "next",
|
|
@@ -25,14 +25,19 @@
|
|
|
25
25
|
"exports": {
|
|
26
26
|
"./package.json": "./package.json",
|
|
27
27
|
"./buttons/Button.svelte": "./buttons/Button.svelte",
|
|
28
|
+
"./buttons/ToggleButton.svelte": "./buttons/ToggleButton.svelte",
|
|
28
29
|
"./common/Card.svelte": "./common/Card.svelte",
|
|
29
30
|
"./common/Gesture.svelte": "./common/Gesture.svelte",
|
|
30
31
|
"./common/IntersectionObserver.svelte": "./common/IntersectionObserver.svelte",
|
|
31
32
|
"./common/MediaQuery.svelte": "./common/MediaQuery.svelte",
|
|
32
33
|
"./common/materialDesign.css": "./common/materialDesign.css",
|
|
34
|
+
"./common/scroller": "./common/scroller.js",
|
|
33
35
|
"./dates/Calendar.svelte": "./dates/Calendar.svelte",
|
|
36
|
+
"./dates/MonthSelector.svelte": "./dates/MonthSelector.svelte",
|
|
37
|
+
"./dates/YearSelector.svelte": "./dates/YearSelector.svelte",
|
|
34
38
|
"./dates/utils": "./dates/utils.js",
|
|
35
39
|
"./dialogs/Dialog.svelte": "./dialogs/Dialog.svelte",
|
|
40
|
+
"./forms/Switch.svelte": "./forms/Switch.svelte",
|
|
36
41
|
"./forms/Textfield.svelte": "./forms/Textfield.svelte",
|
|
37
42
|
".": "./index.js",
|
|
38
43
|
"./loaders/CircularLoader.svelte": "./loaders/CircularLoader.svelte",
|