@likable-hair/svelte 0.0.57 → 0.0.60

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.
@@ -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
- gap: 1px;
84
+ height: 100%;
84
85
  }
85
86
 
86
87
  .day-slot {
@@ -15,6 +15,7 @@ declare const __propDef: {
15
15
  dayHoverColor?: string;
16
16
  daySelectedColor?: string;
17
17
  selectedTextColor?: string;
18
+ gridGap?: string;
18
19
  dayBackgroundColor?: string;
19
20
  animationDuration?: number;
20
21
  };
@@ -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 = '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%";
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 = 'date';
10
- $: visibleSelector = view == 'day' || view == 'month';
9
+ let elementDisabled = "date";
10
+ $: visibleSelector = view == "day" || view == "month";
11
11
  $: {
12
12
  selectorText =
13
- view == 'day'
13
+ view == "day"
14
14
  ? getMonthName(selectedMonth, locale) + " " + selectedYear
15
15
  : selectedYear.toString();
16
16
  }
17
- $: elementDisabled = view == 'year' ? 'year' : 'date';
17
+ $: elementDisabled = view == "year" ? "year" : "date";
18
18
  function next() {
19
- if (view == 'day') {
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 == 'day') {
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 == 'month')
50
- view = 'year';
49
+ if (view == "month")
50
+ view = "year";
51
51
  else
52
- view = 'month';
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
- class="container"
64
- style:background={cardBackGroundColor}
65
- style:color={cardColor}
66
- style:height
67
- style:width
63
+ class="container"
64
+ style:background={cardBackGroundColor}
65
+ style:color={cardColor}
66
+ style:height
67
+ style:width
68
68
  >
69
- <div
70
- class="header"
71
- style:height="25%"
72
- style:background={headerBackgroundColor}
73
- style:color={headerColor}
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
- <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>
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
- {/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>
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
- .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
- }
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?: 'year' | 'month' | 'day';
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
@@ -90,7 +90,6 @@ export const getDateRows = (monthIndex, year, locale = 'it') => {
90
90
  else
91
91
  startIndex -= 1;
92
92
  }
93
- console.log(startIndex);
94
93
  let lastIndex = new Date(year, monthIndex + 1, 0).getDay();
95
94
  if (locale == 'it') {
96
95
  if (lastIndex === 0)
@@ -1,4 +1,5 @@
1
- <script >import { beforeUpdate } from "svelte";
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
@@ -13,6 +13,7 @@
13
13
  id={id}
14
14
  type="checkbox"
15
15
  bind:checked={value}
16
+ on:change
16
17
  disabled={disabled}
17
18
  >
18
19
 
@@ -14,6 +14,8 @@ declare const __propDef: {
14
14
  disabledInnerColor?: string;
15
15
  };
16
16
  events: {
17
+ change: Event;
18
+ } & {
17
19
  [evt: string]: CustomEvent<any>;
18
20
  };
19
21
  slots: {};
@@ -1,6 +1,6 @@
1
1
  <script context="module"></script>
2
2
 
3
- <script >export let label = "", placeholder = "", color = null, value = "", disabled = false, variant = 'outlined', width = "100%", height = "50px", maxWidth = undefined, minWidth = undefined, 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', inputElement = undefined;
3
+ <script >export let label = "", placeholder = "", color = null, value = "", disabled = false, variant = 'outlined', width = "100%", height = "50px", maxWidth = undefined, minWidth = undefined, 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', readonly = false, inputElement = undefined;
4
4
  import { v4 as uuidv4 } from 'uuid';
5
5
  import { onMount } from 'svelte';
6
6
  let inputId = uuidv4(), focused = false, legendWidth = 0, labelElement = undefined;
@@ -166,6 +166,7 @@ $: if (!!labelElement) {
166
166
  type="password"
167
167
  placeholder={placeholder}
168
168
  disabled={disabled}
169
+ readonly={readonly}
169
170
  bind:value={value}
170
171
  on:change
171
172
  on:input
@@ -188,6 +189,7 @@ $: if (!!labelElement) {
188
189
  type="text"
189
190
  placeholder={placeholder}
190
191
  disabled={disabled}
192
+ readonly={readonly}
191
193
  bind:value={value}
192
194
  on:change
193
195
  on:input
@@ -222,6 +224,7 @@ $: if (!!labelElement) {
222
224
  type="password"
223
225
  placeholder={placeholder || label}
224
226
  disabled={disabled}
227
+ readonly={readonly}
225
228
  bind:value={value}
226
229
  on:change
227
230
  on:input
@@ -244,6 +247,7 @@ $: if (!!labelElement) {
244
247
  type="text"
245
248
  placeholder={placeholder || label}
246
249
  disabled={disabled}
250
+ readonly={readonly}
247
251
  bind:value={value}
248
252
  on:change
249
253
  on:input
@@ -26,6 +26,7 @@ declare const __propDef: {
26
26
  paddingTop?: string;
27
27
  fontSize?: string;
28
28
  type?: 'text' | 'password';
29
+ readonly?: boolean;
29
30
  inputElement?: HTMLElement;
30
31
  };
31
32
  events: {
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.57",
4
+ "version": "0.0.60",
5
5
  "devDependencies": {
6
6
  "@sveltejs/adapter-auto": "next",
7
7
  "@sveltejs/kit": "next",