hamzus-ui 0.0.57 → 0.0.59
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/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
2
|
+
// import
|
|
3
3
|
|
|
4
4
|
import IconButton from '../IconButton/IconButton.svelte';
|
|
5
5
|
import Loader from '../LoaderCircle/Loader.svelte';
|
|
6
|
-
|
|
6
|
+
// props
|
|
7
7
|
export let variant = 'default';
|
|
8
8
|
export let className = '';
|
|
9
9
|
export let iconSize = '24px';
|
|
@@ -32,17 +32,27 @@
|
|
|
32
32
|
export let formatPattern = [];
|
|
33
33
|
import { onMount } from 'svelte';
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
// local var
|
|
36
36
|
|
|
37
37
|
$: value = formatInput(value);
|
|
38
38
|
|
|
39
39
|
// fnctions
|
|
40
40
|
function formatInput(inputValue) {
|
|
41
|
+
// verifier que c est un nombre
|
|
42
|
+
if (type === 'number') {
|
|
43
|
+
// Remplace les virgules par des points
|
|
44
|
+
inputValue = inputValue.replace(',', '.');
|
|
45
|
+
|
|
46
|
+
// Supprime tout sauf chiffres et un seul point
|
|
47
|
+
inputValue = inputValue.replace(/[^0-9.]/g, '');
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
if (formatPattern.length == 0) {
|
|
42
52
|
return inputValue;
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
inputValue = inputValue.replace(/\s+/g, '');
|
|
46
56
|
|
|
47
57
|
let formattedValue = '';
|
|
48
58
|
let currentIndex = 0;
|
|
@@ -70,12 +80,11 @@
|
|
|
70
80
|
|
|
71
81
|
onMount(() => {
|
|
72
82
|
value = formatInput(value);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
if (formatPattern.length !== 0) {
|
|
84
|
+
initialValue = value;
|
|
85
|
+
}
|
|
76
86
|
});
|
|
77
87
|
|
|
78
|
-
|
|
79
88
|
function handleDisplay() {
|
|
80
89
|
isVisible = !isVisible;
|
|
81
90
|
}
|
|
@@ -92,12 +101,14 @@
|
|
|
92
101
|
|
|
93
102
|
<div
|
|
94
103
|
class="input-container {variant == 'default' ? variant : ''} {className}"
|
|
95
|
-
style={(fullWidth ?
|
|
104
|
+
style={(fullWidth ? 'width:100%;' : '') + style}
|
|
96
105
|
{...$$restProps}
|
|
97
106
|
>
|
|
98
107
|
<label
|
|
99
108
|
class="input {errorMessage ? ' error' : ''}"
|
|
100
|
-
style="{variant == 'collapse'
|
|
109
|
+
style="{variant == 'collapse'
|
|
110
|
+
? `padding:${padding};`
|
|
111
|
+
: ''}--radius:{borderRadius};--default-bg:var({defaultBg});"
|
|
101
112
|
>
|
|
102
113
|
<div class="top-line">
|
|
103
114
|
{#if label}
|
|
@@ -118,18 +129,17 @@
|
|
|
118
129
|
>
|
|
119
130
|
<slot name="startContent" />
|
|
120
131
|
<input
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
on:focus={onFocus}
|
|
133
|
+
on:blur={onBlur}
|
|
123
134
|
on:input={handleChange}
|
|
124
135
|
class="h4"
|
|
125
136
|
{placeholder}
|
|
126
|
-
type={isVisible && type == 'password' ? 'text' : type}
|
|
137
|
+
type={(isVisible && type == 'password') || type === "number" ? 'text' : type}
|
|
127
138
|
{name}
|
|
128
|
-
|
|
139
|
+
bind:value
|
|
129
140
|
{required}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
disabled={isLoading ? true : disabled}
|
|
142
|
+
{step}
|
|
133
143
|
/>
|
|
134
144
|
{#if type == 'password'}
|
|
135
145
|
<IconButton size="24px" variant="ghost" onClick={handleDisplay}>
|
|
@@ -193,119 +203,119 @@
|
|
|
193
203
|
<h5 class="error-message">{errorMessage}</h5>
|
|
194
204
|
{/if}
|
|
195
205
|
</div>
|
|
196
|
-
<style>
|
|
197
206
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
207
|
+
<style>
|
|
208
|
+
.input-container {
|
|
209
|
+
display: flex;
|
|
210
|
+
flex-direction: column;
|
|
211
|
+
transition-property: transform opacity;
|
|
212
|
+
transition-duration: 0.2s;
|
|
213
|
+
transition-timing-function: ease-out;
|
|
214
|
+
user-select: none;
|
|
215
|
+
cursor: text;
|
|
216
|
+
}
|
|
217
|
+
.input-container :global(svg) {
|
|
218
|
+
padding: 2px;
|
|
219
|
+
}
|
|
220
|
+
.input-container :global(svg path) {
|
|
221
|
+
fill: var(--font-2);
|
|
222
|
+
}
|
|
223
|
+
.input-container input {
|
|
224
|
+
text-align: left;
|
|
225
|
+
}
|
|
226
|
+
.input-container.default .input {
|
|
227
|
+
display: flex;
|
|
228
|
+
flex-direction: column;
|
|
229
|
+
row-gap: 0px;
|
|
230
|
+
}
|
|
231
|
+
.input-container:not(.default) .input {
|
|
232
|
+
display: flex;
|
|
233
|
+
flex-direction: column;
|
|
234
|
+
border-radius: var(--radius);
|
|
235
|
+
background-color: var(--default-bg);
|
|
236
|
+
border: 2px solid var(--default-bg);
|
|
237
|
+
transition-property: background, border;
|
|
238
|
+
transition-duration: 0.2s;
|
|
239
|
+
transition-timing-function: ease-out;
|
|
240
|
+
}
|
|
231
241
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
.input-container:not(.default):has(input:user-invalid) .input {
|
|
243
|
+
border: 2px solid var(--red);
|
|
244
|
+
}
|
|
245
|
+
.input-container:not(.default) .input:hover {
|
|
246
|
+
background-color: var(--bg-3);
|
|
247
|
+
}
|
|
248
|
+
.input-container:not(.default) .input:has(input:focus) {
|
|
249
|
+
background-color: var(--bg-1);
|
|
250
|
+
/* border: 2px solid var(--accent); */
|
|
251
|
+
}
|
|
252
|
+
.input svg path {
|
|
253
|
+
fill: var(--font-2);
|
|
254
|
+
}
|
|
245
255
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
256
|
+
.input h6 {
|
|
257
|
+
color: var(--font-2);
|
|
258
|
+
}
|
|
259
|
+
.input .required {
|
|
260
|
+
color: var(--red);
|
|
261
|
+
}
|
|
262
|
+
.input .top-line {
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: space-between;
|
|
266
|
+
column-gap: var(--pad-m);
|
|
267
|
+
}
|
|
268
|
+
.input .top-line .input-loader {
|
|
269
|
+
position: static;
|
|
270
|
+
}
|
|
271
|
+
.input-container.default .input .input-line {
|
|
272
|
+
border-radius: var(--radius);
|
|
273
|
+
background-color: var(--default-bg);
|
|
274
|
+
border: 2px solid var(--default-bg);
|
|
275
|
+
transition-property: background, border;
|
|
276
|
+
transition-duration: 0.2s;
|
|
277
|
+
transition-timing-function: ease-out;
|
|
278
|
+
}
|
|
279
|
+
.input-container.default .input:hover .input-line {
|
|
280
|
+
background-color: var(--bg-3);
|
|
281
|
+
}
|
|
282
|
+
.input-container.default .input:has(input:focus) .input-line {
|
|
283
|
+
background-color: var(--bg-1);
|
|
284
|
+
/* border: 2px solid var(--accent); */
|
|
285
|
+
}
|
|
286
|
+
.input-container.default:has(input:user-invalid) .input-line {
|
|
287
|
+
border: 2px solid var(--red);
|
|
288
|
+
}
|
|
289
|
+
.input .input-line {
|
|
290
|
+
display: flex;
|
|
291
|
+
align-items: center;
|
|
292
|
+
column-gap: var(--pad-s);
|
|
293
|
+
}
|
|
294
|
+
.input input {
|
|
295
|
+
color: var(--font-1);
|
|
296
|
+
width: 100%;
|
|
297
|
+
flex: 1;
|
|
298
|
+
font-weight: 300;
|
|
299
|
+
}
|
|
300
|
+
.input input::placeholder {
|
|
301
|
+
color: var(--font-3);
|
|
302
|
+
}
|
|
303
|
+
.input .input-line svg {
|
|
304
|
+
height: var(--icon-size);
|
|
305
|
+
width: auto;
|
|
306
|
+
}
|
|
297
307
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
308
|
+
.input.error {
|
|
309
|
+
border: 2px solid var(--red) !important;
|
|
310
|
+
border-radius: var(--radius);
|
|
311
|
+
}
|
|
312
|
+
.input-container .error-message {
|
|
313
|
+
color: var(--red);
|
|
314
|
+
margin-left: 4px;
|
|
315
|
+
}
|
|
306
316
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
317
|
+
.input-container:has(input:disabled) .input {
|
|
318
|
+
opacity: 0.6;
|
|
319
|
+
cursor: not-allowed;
|
|
320
|
+
}
|
|
311
321
|
</style>
|