@likable-hair/svelte 0.0.35 → 0.0.38
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/forms/Textfield.svelte +89 -35
- package/forms/Textfield.svelte.d.ts +4 -0
- package/package.json +1 -1
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 */
|
|
@@ -44,7 +45,7 @@ $: if (!!labelElement) {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
.focused .fieldset-outlined {
|
|
47
|
-
border: var(--textfield-border-weight) solid var(--textfield-final-color);
|
|
48
|
+
border: var(--textfield-border-weight) solid var(--textfield-final-border-color);
|
|
48
49
|
color: var(--textfield-final-color);
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -74,11 +75,14 @@ $: if (!!labelElement) {
|
|
|
74
75
|
/* boxed input */
|
|
75
76
|
|
|
76
77
|
.fieldset-boxed {
|
|
77
|
-
border: var(--textfield-border-weight) solid var(--textfield-final-color);
|
|
78
78
|
padding: 5px;
|
|
79
79
|
transition: border 0.3s ease, box-shadow 0.3s ease;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
.not-focused .fieldset-boxed {
|
|
83
|
+
border: var(--textfield-border-weight) solid var(--textfield-final-border-color);
|
|
84
|
+
}
|
|
85
|
+
|
|
82
86
|
.focused .fieldset-boxed {
|
|
83
87
|
border: var(--textfield-border-weight) solid var(--textfield-focus-border-color, var(--textfield-final-color));
|
|
84
88
|
box-shadow: var(--textfield-focused-box-shadow);
|
|
@@ -115,12 +119,12 @@ $: if (!!labelElement) {
|
|
|
115
119
|
style:--textfield-focused-box-shadow={focusedBoxShadow}
|
|
116
120
|
class="input-container"
|
|
117
121
|
class:focused={focused}
|
|
122
|
+
class:not-focused={!focused}
|
|
118
123
|
class:texted={focused || !!value}
|
|
119
124
|
>
|
|
120
125
|
<fieldset
|
|
121
126
|
aria-hidden="true"
|
|
122
127
|
style:border-radius={borderRadius}
|
|
123
|
-
style:border-color={borderColor}
|
|
124
128
|
style:background-color={backgroundColor}
|
|
125
129
|
style:padding={padding}
|
|
126
130
|
style:padding-left={paddingLeft}
|
|
@@ -148,14 +152,87 @@ $: if (!!labelElement) {
|
|
|
148
152
|
<div>
|
|
149
153
|
<slot name="prepend-inner"></slot>
|
|
150
154
|
</div>
|
|
151
|
-
|
|
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
|
+
on:keydown
|
|
172
|
+
on:keypress
|
|
173
|
+
on:keyup
|
|
174
|
+
/>
|
|
175
|
+
{:else if type == 'text'}
|
|
176
|
+
<input
|
|
177
|
+
style:background-color={backgroundColor}
|
|
178
|
+
style:color={textColor}
|
|
179
|
+
style:font-size={fontSize}
|
|
180
|
+
id={inputId}
|
|
181
|
+
class="input-outlined"
|
|
182
|
+
type="text"
|
|
183
|
+
placeholder={placeholder}
|
|
184
|
+
bind:value={value}
|
|
185
|
+
on:change
|
|
186
|
+
on:input
|
|
187
|
+
on:focus={handleFocus}
|
|
188
|
+
on:focus
|
|
189
|
+
on:blur={handleBlur}
|
|
190
|
+
on:blur
|
|
191
|
+
on:keydown
|
|
192
|
+
on:keypress
|
|
193
|
+
on:keyup
|
|
194
|
+
/>
|
|
195
|
+
{/if}
|
|
196
|
+
<div>
|
|
197
|
+
<slot name="append-inner"></slot>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
{:else if variant == 'boxed'}
|
|
201
|
+
<div
|
|
202
|
+
style:display="flex"
|
|
203
|
+
>
|
|
204
|
+
<div>
|
|
205
|
+
<slot name="prepend-inner"></slot>
|
|
206
|
+
</div>
|
|
207
|
+
{#if type == 'password'}
|
|
208
|
+
<input
|
|
152
209
|
style:background-color={backgroundColor}
|
|
153
210
|
style:color={textColor}
|
|
154
211
|
style:font-size={fontSize}
|
|
155
|
-
id={inputId}
|
|
156
|
-
class="input-
|
|
212
|
+
id={inputId}
|
|
213
|
+
class="input-boxed"
|
|
214
|
+
type="password"
|
|
215
|
+
placeholder={placeholder || label}
|
|
216
|
+
bind:value={value}
|
|
217
|
+
on:change
|
|
218
|
+
on:input
|
|
219
|
+
on:focus={handleFocus}
|
|
220
|
+
on:focus
|
|
221
|
+
on:blur={handleBlur}
|
|
222
|
+
on:blur
|
|
223
|
+
on:keydown
|
|
224
|
+
on:keypress
|
|
225
|
+
on:keyup
|
|
226
|
+
/>
|
|
227
|
+
{:else if type == 'text'}
|
|
228
|
+
<input
|
|
229
|
+
style:background-color={backgroundColor}
|
|
230
|
+
style:color={textColor}
|
|
231
|
+
style:font-size={fontSize}
|
|
232
|
+
id={inputId}
|
|
233
|
+
class="input-boxed"
|
|
157
234
|
type="text"
|
|
158
|
-
placeholder={placeholder}
|
|
235
|
+
placeholder={placeholder || label}
|
|
159
236
|
bind:value={value}
|
|
160
237
|
on:change
|
|
161
238
|
on:input
|
|
@@ -163,34 +240,11 @@ $: if (!!labelElement) {
|
|
|
163
240
|
on:focus
|
|
164
241
|
on:blur={handleBlur}
|
|
165
242
|
on:blur
|
|
243
|
+
on:keydown
|
|
244
|
+
on:keypress
|
|
245
|
+
on:keyup
|
|
166
246
|
/>
|
|
167
|
-
|
|
168
|
-
<slot name="append-inner"></slot>
|
|
169
|
-
</div>
|
|
170
|
-
</div>
|
|
171
|
-
{:else if variant == 'boxed'}
|
|
172
|
-
<div
|
|
173
|
-
style:display="flex"
|
|
174
|
-
>
|
|
175
|
-
<div>
|
|
176
|
-
<slot name="prepend-inner"></slot>
|
|
177
|
-
</div>
|
|
178
|
-
<input
|
|
179
|
-
style:background-color={backgroundColor}
|
|
180
|
-
style:color={textColor}
|
|
181
|
-
style:font-size={fontSize}
|
|
182
|
-
id={inputId}
|
|
183
|
-
class="input-boxed"
|
|
184
|
-
type="text"
|
|
185
|
-
placeholder={placeholder || label}
|
|
186
|
-
bind:value={value}
|
|
187
|
-
on:change
|
|
188
|
-
on:input
|
|
189
|
-
on:focus={handleFocus}
|
|
190
|
-
on:focus
|
|
191
|
-
on:blur={handleBlur}
|
|
192
|
-
on:blur
|
|
193
|
-
/>
|
|
247
|
+
{/if}
|
|
194
248
|
<div>
|
|
195
249
|
<slot name="append-inner"></slot>
|
|
196
250
|
</div>
|
|
@@ -20,12 +20,16 @@ declare const __propDef: {
|
|
|
20
20
|
paddingBottom?: string;
|
|
21
21
|
paddingTop?: string;
|
|
22
22
|
fontSize?: string;
|
|
23
|
+
type?: 'text' | 'password';
|
|
23
24
|
};
|
|
24
25
|
events: {
|
|
25
26
|
change: Event;
|
|
26
27
|
input: Event;
|
|
27
28
|
focus: FocusEvent;
|
|
28
29
|
blur: FocusEvent;
|
|
30
|
+
keydown: KeyboardEvent;
|
|
31
|
+
keypress: KeyboardEvent;
|
|
32
|
+
keyup: KeyboardEvent;
|
|
29
33
|
} & {
|
|
30
34
|
[evt: string]: CustomEvent<any>;
|
|
31
35
|
};
|