@likable-hair/svelte 0.0.48 → 0.0.49

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.
@@ -0,0 +1,90 @@
1
+ <script >import Textfield from "../forms/Textfield.svelte";
2
+ import VerticalTextSwitch from "../forms/VerticalTextSwitch.svelte";
3
+ import "./DatePicker.svelte";
4
+ export let hourFormat = "24", dayPeriod = "am", time = undefined, text = "", fieldSeparator = ":", placeholder = "Insert time...", focusedBoxShadow = "#C0D6FF 0px 2px 10px", borderColor = "", borderWeight = "1px", fontSize = "16px", width = "100%";
5
+ let minutes = undefined, hours = undefined, switchValue = false;
6
+ function checkHour(hour) {
7
+ if (hourFormat == "12")
8
+ return hour > 0 && hour <= 12;
9
+ else
10
+ return hour >= 0 && hour < 24;
11
+ }
12
+ function checkMinute(minute) {
13
+ return minute >= 0 && minute < 60;
14
+ }
15
+ $: dayPeriod = switchValue ? "pm" : "am";
16
+ $: {
17
+ let fields = text.split(fieldSeparator);
18
+ hours = +fields[0];
19
+ minutes = +fields[1];
20
+ if (fields[1]?.length != 2) {
21
+ time = undefined;
22
+ }
23
+ else {
24
+ if (!isNaN(hours) && !isNaN(minutes) && checkHour(hours) && checkMinute(minutes) && fields.length == 2) {
25
+ if (hourFormat == '12') {
26
+ if (dayPeriod == 'am' && hours == 12)
27
+ hours = 0;
28
+ else if (dayPeriod == 'pm' && hours != 12)
29
+ hours += 12;
30
+ }
31
+ time = new Date();
32
+ time.setHours(hours, minutes, 0);
33
+ }
34
+ else
35
+ time = undefined;
36
+ }
37
+ }
38
+ let fontSizeNumeric = parseInt(fontSize, 10);
39
+ </script>
40
+
41
+ <div class="container"
42
+ style:width
43
+ >
44
+ <div class="text-field" style:width="100%">
45
+ <Textfield
46
+ {placeholder}
47
+ variant="boxed"
48
+ {borderColor}
49
+ {borderWeight}
50
+ {focusedBoxShadow}
51
+ {fontSize}
52
+ width="100%"
53
+ bind:value={text}
54
+ paddingLeft="10px"
55
+ />
56
+ </div>
57
+ {#if hourFormat == "12"}
58
+ <div class="period-selector" style:height="{fontSizeNumeric+16}px">
59
+ <VerticalTextSwitch
60
+ bind:value={switchValue}
61
+ width="{fontSizeNumeric+16}px"
62
+ hoverBackgroundColor="rgba(0,0,0,0.05)"
63
+ >
64
+ <span slot="trueOption"
65
+ style:font-size={fontSize}
66
+ >
67
+ PM
68
+ </span>
69
+ <span slot="falseOption"
70
+ style:font-size={fontSize}
71
+ >
72
+ AM
73
+ </span>
74
+ </VerticalTextSwitch>
75
+ </div>
76
+ {/if}
77
+ </div>
78
+
79
+ <style>
80
+ .container {
81
+ display: flex;
82
+ }
83
+ .period-selector {
84
+ display: flex;
85
+ justify-content: center;
86
+ align-items: center;
87
+ align-self: flex-start;
88
+ margin-left: 20px;
89
+ }
90
+ </style>
@@ -0,0 +1,26 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ hourFormat?: "12" | "24";
5
+ dayPeriod?: "am" | "pm";
6
+ time?: Date;
7
+ text?: string;
8
+ fieldSeparator?: string;
9
+ placeholder?: string;
10
+ focusedBoxShadow?: string;
11
+ borderColor?: string;
12
+ borderWeight?: string;
13
+ fontSize?: string;
14
+ width?: string;
15
+ };
16
+ events: {
17
+ [evt: string]: CustomEvent<any>;
18
+ };
19
+ slots: {};
20
+ };
21
+ export declare type TimePickerTextFieldProps = typeof __propDef.props;
22
+ export declare type TimePickerTextFieldEvents = typeof __propDef.events;
23
+ export declare type TimePickerTextFieldSlots = typeof __propDef.slots;
24
+ export default class TimePickerTextField extends SvelteComponentTyped<TimePickerTextFieldProps, TimePickerTextFieldEvents, TimePickerTextFieldSlots> {
25
+ }
26
+ export {};
@@ -0,0 +1,63 @@
1
+ <script >import { v4 as uuidv4 } from 'uuid';
2
+ export let label = null, placeholder = "placeholder", textAreaId = uuidv4(), fontFamily = "inherit", value = "", resizable = true, disabled = false, readOnly = false, maxLength = undefined, textColor = "black", border = "none", borderRadius = "5px", focusedBoxShadow = undefined, backgroundColor = null, padding = undefined, paddingLeft = undefined, paddingRight = undefined, paddingBottom = undefined, paddingTop = undefined, fontSize = undefined, labelFontSize = undefined, labelColor = undefined, width = "100%", height = "100%";
3
+ </script>
4
+
5
+ <div
6
+ class="container"
7
+ >
8
+ {#if label}
9
+ <label
10
+ for={textAreaId}
11
+ style:font-size={labelFontSize}
12
+ style:color={labelColor}
13
+ >
14
+ {label}
15
+ </label>
16
+ {/if}
17
+ <textarea
18
+ style:width={width}
19
+ style:height={height}
20
+ style:font-family={fontFamily}
21
+ style:resize={resizable?"both":"none"}
22
+ style:font-size={fontSize}
23
+ style:border-radius={borderRadius}
24
+ style:background-color={backgroundColor}
25
+ style:color={textColor}
26
+ style:padding={padding}
27
+ style:padding-left={paddingLeft}
28
+ style:padding-right={paddingRight}
29
+ style:padding-bottom={paddingBottom}
30
+ style:padding-top={paddingTop}
31
+ style:border={border}
32
+ style:--textarea-focus-box-shadow={focusedBoxShadow}
33
+ bind:value={value}
34
+ id={textAreaId}
35
+ placeholder={placeholder}
36
+ maxlength={maxLength}
37
+ disabled={disabled}
38
+ readonly={readOnly}
39
+ ></textarea>
40
+ </div>
41
+
42
+
43
+ <style>
44
+ textarea {
45
+ display: block;
46
+ transition: all 0.3s;
47
+ }
48
+
49
+ label {
50
+ display: block;
51
+ margin-bottom: 10px;
52
+ margin-left: 10px;
53
+ }
54
+
55
+ textarea:focus{
56
+ outline: none;
57
+ -webkit-box-shadow: var(--textarea-focus-box-shadow);
58
+ -moz-box-shadow: var(--textarea-focus-box-shadow);
59
+ -o-box-shadow: var(--textarea-focus-box-shadow);
60
+ box-shadow: var(--textarea-focus-box-shadow);
61
+ }
62
+
63
+ </style>
@@ -0,0 +1,39 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ label?: string;
5
+ placeholder?: string;
6
+ textAreaId?: string;
7
+ fontFamily?: string;
8
+ value?: string;
9
+ resizable?: boolean;
10
+ disabled?: boolean;
11
+ readOnly?: boolean;
12
+ maxLength?: number;
13
+ textColor?: string;
14
+ border?: string;
15
+ borderRadius?: string;
16
+ focusedBoxShadow?: string;
17
+ backgroundColor?: string;
18
+ padding?: string;
19
+ paddingLeft?: string;
20
+ paddingRight?: string;
21
+ paddingBottom?: string;
22
+ paddingTop?: string;
23
+ fontSize?: string;
24
+ labelFontSize?: string;
25
+ labelColor?: string;
26
+ width?: string;
27
+ height?: string;
28
+ };
29
+ events: {
30
+ [evt: string]: CustomEvent<any>;
31
+ };
32
+ slots: {};
33
+ };
34
+ export declare type TextareaProps = typeof __propDef.props;
35
+ export declare type TextareaEvents = typeof __propDef.events;
36
+ export declare type TextareaSlots = typeof __propDef.slots;
37
+ export default class Textarea extends SvelteComponentTyped<TextareaProps, TextareaEvents, TextareaSlots> {
38
+ }
39
+ export {};
@@ -0,0 +1,123 @@
1
+ <script >export let value = false, height = "60px", width = "30px", rounded = false, backgroundColor = "#90CAF9", selectedOptionColor = backgroundColor, sliderColor = "white", optionColor = sliderColor, fontSize = "11px", animationDuration = "0.1s";
2
+ </script>
3
+
4
+ <div
5
+ class="container"
6
+ style:--vertical-switch-height={height}
7
+ style:--vertical-switch-width={width}
8
+ style:--vertical-switch-container-border-radius={rounded ? "500px" : "4px"}
9
+ style:--vertical-switch-slider-border-radius={rounded ? "100%" : "4px"}
10
+ style:--vertical-switch-background-color={backgroundColor}
11
+ style:--vertical-switch-selected-option-color={selectedOptionColor}
12
+ style:--vertical-switch-slider-color={sliderColor}
13
+ style:--vertical-switch-option-color={optionColor}
14
+ style:--vertical-switch-font-size={fontSize}
15
+ style:--vertical-switch-animation-duration={animationDuration}
16
+ >
17
+ <div
18
+ class="inner-container"
19
+ on:click={()=>value = !value}
20
+ >
21
+ <div
22
+ class={value?"first-option selected":"first-option"}
23
+ >
24
+ <slot name="trueOption">
25
+ 1
26
+ </slot>
27
+ </div>
28
+ <div
29
+ class={value?"second-option":"second-option selected"}
30
+ >
31
+ <slot name="falseOption">
32
+ 0
33
+ </slot>
34
+ </div>
35
+ <input
36
+ bind:checked={value}
37
+ type="checkbox"
38
+ on:change
39
+ />
40
+ <span
41
+ class={value?"slider top":"slider bottom"}
42
+ />
43
+ </div>
44
+ </div>
45
+
46
+ <style>
47
+ .container {
48
+ position: relative;
49
+ box-sizing: border-box;
50
+ width: var(--vertical-switch-width);
51
+ }
52
+
53
+ input {
54
+ position: absolute;
55
+ display: none;
56
+ }
57
+
58
+ .inner-container {
59
+ position: absolute;
60
+ width: 100%;
61
+ height: var(--vertical-switch-height);
62
+ background-color: var(--vertical-switch-background-color);
63
+ cursor: pointer;
64
+ text-align: center;
65
+ border-radius: var(--vertical-switch-container-border-radius)
66
+ }
67
+
68
+ .first-option {
69
+ width: 100%;
70
+ height: calc(var(--vertical-switch-width));
71
+ position: absolute;
72
+ overflow-x: hidden;
73
+ display: flex;
74
+ justify-content: center;
75
+ align-items: center;
76
+ top: 0;
77
+ color: var(--vertical-switch-option-color);
78
+ font-size: var(--vertical-switch-font-size);
79
+ user-select: none;
80
+ transition: var(--vertical-switch-animation-duration);
81
+ }
82
+
83
+ .second-option {
84
+ width: 100%;
85
+ height: calc(var(--vertical-switch-width));
86
+ position: absolute;
87
+ overflow-x: hidden;
88
+ display: flex;
89
+ justify-content: center;
90
+ align-items: center;
91
+ bottom: 0;
92
+ color: var(--vertical-switch-option-color);
93
+ font-size: var(--vertical-switch-font-size);
94
+ user-select: none;
95
+ }
96
+
97
+ .selected {
98
+ color: var(--vertical-switch-selected-option-color);
99
+ z-index: 5;
100
+ font-weight: bold;
101
+ transition: var(--vertical-switch-animation-duration);
102
+ }
103
+
104
+ .slider {
105
+ position: absolute;
106
+ --vertical-switch-slider-diameter: calc(var(--vertical-switch-width) - 4px);
107
+ width: var(--vertical-switch-slider-diameter);
108
+ height: var(--vertical-switch-slider-diameter);
109
+ border-radius: var(--vertical-switch-slider-border-radius);
110
+ background-color: var(--vertical-switch-slider-color);
111
+ left: 2px;
112
+ transition: var(--vertical-switch-animation-duration);
113
+ }
114
+
115
+ .top {
116
+ top: 2px;
117
+ }
118
+
119
+ .bottom {
120
+ top: calc(var(--vertical-switch-height) - var(--vertical-switch-slider-diameter) - 2px)
121
+ }
122
+
123
+ </style>
@@ -0,0 +1,30 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value?: boolean;
5
+ height?: string;
6
+ width?: string;
7
+ rounded?: boolean;
8
+ backgroundColor?: string;
9
+ selectedOptionColor?: string;
10
+ sliderColor?: string;
11
+ optionColor?: string;
12
+ fontSize?: string;
13
+ animationDuration?: string;
14
+ };
15
+ events: {
16
+ change: Event;
17
+ } & {
18
+ [evt: string]: CustomEvent<any>;
19
+ };
20
+ slots: {
21
+ trueOption: {};
22
+ falseOption: {};
23
+ };
24
+ };
25
+ export declare type VerticalSwitchProps = typeof __propDef.props;
26
+ export declare type VerticalSwitchEvents = typeof __propDef.events;
27
+ export declare type VerticalSwitchSlots = typeof __propDef.slots;
28
+ export default class VerticalSwitch extends SvelteComponentTyped<VerticalSwitchProps, VerticalSwitchEvents, VerticalSwitchSlots> {
29
+ }
30
+ export {};
@@ -0,0 +1,65 @@
1
+ <script >import { fly } from 'svelte/transition';
2
+ export let value = false, height = "100%", width = "100%", backgroundColor = undefined, firstColor = undefined, secondColor = firstColor, fontSize = "12px", hoverBackgroundColor = undefined, hoverBoxShadow = undefined, animationDuration = 200;
3
+ let optionHeight = undefined;
4
+ </script>
5
+
6
+ <div
7
+ class="container"
8
+ style:width
9
+ style:height
10
+ style:--vertical-text-switch-height={height}
11
+ style:--vertical-text-switch-hover-background-color={hoverBackgroundColor}
12
+ style:--vertical-text-switch-hover-box-shadow={hoverBoxShadow}
13
+ bind:clientHeight={optionHeight}
14
+ on:click={()=>value = !value}
15
+ style:background-color={backgroundColor}
16
+ style:padding="5px"
17
+ >
18
+ {#if value}
19
+ <div
20
+ in:fly="{{ y: optionHeight/2, duration: animationDuration/2, delay: animationDuration/2}}"
21
+ out:fly="{{ y: -optionHeight/2, duration: animationDuration/2}}"
22
+ class="option"
23
+ style:color={firstColor}
24
+ style:font-size={fontSize}
25
+ >
26
+ <slot name="trueOption"></slot>
27
+ </div>
28
+ {:else}
29
+ <div
30
+ in:fly="{{ y: optionHeight/2, duration: animationDuration/2, delay: animationDuration/2}}"
31
+ out:fly="{{ y: -optionHeight/2, duration: animationDuration/2}}"
32
+ class="option"
33
+ style:color={secondColor}
34
+ style:font-size={fontSize}
35
+ >
36
+ <slot name="falseOption"></slot>
37
+ </div>
38
+ {/if}
39
+ <input type="checkbox" bind:value />
40
+ </div>
41
+
42
+ <style>
43
+ .container {
44
+ cursor: pointer;
45
+ border-radius: 5px;
46
+ overflow-y: hidden;
47
+ }
48
+
49
+ .container:hover {
50
+ background-color: var(--vertical-text-switch-hover-background-color);
51
+ box-shadow: var(--vertical-text-switch-hover-box-shadow);
52
+ }
53
+
54
+ .option {
55
+ height: var(--vertical-text-switch-height);
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: center;
59
+ user-select: none;
60
+ }
61
+
62
+ input {
63
+ display: none;
64
+ }
65
+ </style>
@@ -0,0 +1,28 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value?: boolean;
5
+ height?: string;
6
+ width?: string;
7
+ backgroundColor?: string;
8
+ firstColor?: string;
9
+ secondColor?: string;
10
+ fontSize?: string;
11
+ hoverBackgroundColor?: string;
12
+ hoverBoxShadow?: string;
13
+ animationDuration?: number;
14
+ };
15
+ events: {
16
+ [evt: string]: CustomEvent<any>;
17
+ };
18
+ slots: {
19
+ trueOption: {};
20
+ falseOption: {};
21
+ };
22
+ };
23
+ export declare type VerticalTextSwitchProps = typeof __propDef.props;
24
+ export declare type VerticalTextSwitchEvents = typeof __propDef.events;
25
+ export declare type VerticalTextSwitchSlots = typeof __propDef.slots;
26
+ export default class VerticalTextSwitch extends SvelteComponentTyped<VerticalTextSwitchProps, VerticalTextSwitchEvents, VerticalTextSwitchSlots> {
27
+ }
28
+ export {};
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.48",
4
+ "version": "0.0.49",
5
5
  "devDependencies": {
6
6
  "@sveltejs/adapter-auto": "next",
7
7
  "@sveltejs/kit": "next",
@@ -77,6 +77,7 @@
77
77
  "./dates/Calendar.svelte": "./dates/Calendar.svelte",
78
78
  "./dates/DatePicker.svelte": "./dates/DatePicker.svelte",
79
79
  "./dates/MonthSelector.svelte": "./dates/MonthSelector.svelte",
80
+ "./dates/TimePickerTextField.svelte": "./dates/TimePickerTextField.svelte",
80
81
  "./dates/YearSelector.svelte": "./dates/YearSelector.svelte",
81
82
  "./dates/utils": "./dates/utils.js",
82
83
  "./dialogs/Dialog.svelte": "./dialogs/Dialog.svelte",
@@ -85,7 +86,10 @@
85
86
  "./forms/FileInput.svelte": "./forms/FileInput.svelte",
86
87
  "./forms/FileInputList.svelte": "./forms/FileInputList.svelte",
87
88
  "./forms/Switch.svelte": "./forms/Switch.svelte",
89
+ "./forms/Textarea.svelte": "./forms/Textarea.svelte",
88
90
  "./forms/Textfield.svelte": "./forms/Textfield.svelte",
91
+ "./forms/VerticalSwitch.svelte": "./forms/VerticalSwitch.svelte",
92
+ "./forms/VerticalTextSwitch.svelte": "./forms/VerticalTextSwitch.svelte",
89
93
  ".": "./index.js",
90
94
  "./loaders/CircularLoader.svelte": "./loaders/CircularLoader.svelte",
91
95
  "./loaders/Skeleton.svelte": "./loaders/Skeleton.svelte",