grav-svelte 0.0.83 → 0.0.85
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/dist/Inputs/InputFormBool.svelte +59 -57
- package/dist/Inputs/InputFormCascade.svelte +94 -93
- package/dist/Inputs/InputFormColor.svelte +107 -105
- package/dist/Inputs/InputFormColor.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormColorPicker.svelte +281 -261
- package/dist/Inputs/InputFormColorPicker.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormDate.svelte +122 -120
- package/dist/Inputs/InputFormDate.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormDateAndHours.svelte +122 -120
- package/dist/Inputs/InputFormDateAndHours.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormImage.svelte +195 -203
- package/dist/Inputs/InputFormImage.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormNumber.svelte +101 -98
- package/dist/Inputs/InputFormNumber.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormPassword.svelte +159 -149
- package/dist/Inputs/InputFormPassword.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormSelect.svelte +104 -91
- package/dist/Inputs/InputFormSelect.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormText.svelte +102 -99
- package/dist/Inputs/InputFormText.svelte.d.ts +1 -0
- package/dist/Inputs/InputFormTextArea.svelte +103 -100
- package/dist/Inputs/InputFormTextArea.svelte.d.ts +1 -0
- package/package.json +91 -91
|
@@ -1,71 +1,73 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import "../typography.css";
|
|
3
|
+
|
|
4
|
+
export let valueVar = false;
|
|
5
|
+
export let label;
|
|
6
|
+
export let disabled = false;
|
|
5
7
|
</script>
|
|
6
8
|
|
|
7
9
|
<div class="input-container">
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
{#if valueVar}
|
|
11
|
+
<button
|
|
12
|
+
aria-label="checkbox"
|
|
13
|
+
{disabled}
|
|
14
|
+
on:click={() => (valueVar = false)}
|
|
15
|
+
class="checkbox-button checked"
|
|
16
|
+
>
|
|
17
|
+
<i class="fas fa-check checkwhite"></i>
|
|
18
|
+
</button>
|
|
19
|
+
{:else}
|
|
20
|
+
<button
|
|
21
|
+
aria-label="checkbox"
|
|
22
|
+
{disabled}
|
|
23
|
+
on:click={() => (valueVar = true)}
|
|
24
|
+
class="checkbox-button"
|
|
25
|
+
>
|
|
26
|
+
<i class="fas fa-minus"></i>
|
|
27
|
+
</button>
|
|
28
|
+
{/if}
|
|
29
|
+
<h1 class="label">{label}</h1>
|
|
28
30
|
</div>
|
|
29
31
|
|
|
30
32
|
<style>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
.input-container {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
height: fit-content;
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
margin-top: 1.95rem;
|
|
40
|
+
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
.checkbox-button {
|
|
43
|
+
margin-right: 0.5rem;
|
|
44
|
+
height: 2.7rem;
|
|
45
|
+
width: 2.7rem;
|
|
46
|
+
background: transparent;
|
|
47
|
+
border: var(--grav-crud-input-border-width) solid
|
|
48
|
+
var(--grav-crud-color-neutral);
|
|
49
|
+
color: var(--grav-crud-color-neutral);
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
border-radius: 0.5rem;
|
|
52
|
+
padding-left: 0.5rem;
|
|
53
|
+
padding-right: 0.5rem;
|
|
54
|
+
padding-top: 0.2rem;
|
|
55
|
+
padding-bottom: 0.2rem;
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
.checkbox-button.checked {
|
|
59
|
+
background-color: var(--grav-crud-color-primary);
|
|
60
|
+
color: var(--grav-crud-color-icon);
|
|
61
|
+
}
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
.label {
|
|
64
|
+
font-size: 1rem;
|
|
65
|
+
margin: 0;
|
|
66
|
+
color: var(--grav-crud-color-neutral);
|
|
67
|
+
}
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
button:disabled {
|
|
70
|
+
opacity: 0.5;
|
|
71
|
+
cursor: not-allowed;
|
|
72
|
+
}
|
|
71
73
|
</style>
|
|
@@ -1,108 +1,109 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import "../typography.css";
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
import InputFormSelect from "./InputFormSelect.svelte";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export let levels = []; // [{ label, fetchFn, default, field, showPlusIcon?, onPlusClick? }]
|
|
7
|
+
// Cargar datos iniciales para el primer nivel
|
|
8
|
+
let varS = false;
|
|
9
|
+
let fetchFnCloned = [];
|
|
10
|
+
export let selectedValues = {};
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
onMount(async () => {
|
|
13
|
+
varS = false;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// Clonar las funciones fetch
|
|
16
|
+
levels.forEach((item) => {
|
|
17
|
+
fetchFnCloned.push({ fetchFn: item.fetchFn });
|
|
18
|
+
});
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// Si hay valores iniciales, cargar y establecer los objetos Select completos
|
|
21
|
+
for (let i = 0; i < levels.length; i++) {
|
|
22
|
+
const level = levels[i];
|
|
23
|
+
const initialValue = selectedValues[level.field];
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
if (initialValue) {
|
|
26
|
+
// Cargar las opciones para este nivel
|
|
27
|
+
let options = [];
|
|
28
|
+
if (i === 0) {
|
|
29
|
+
options = await fetchFnCloned[i].fetchFn();
|
|
30
|
+
} else {
|
|
31
|
+
// Para niveles subsecuentes, necesitamos el valor del nivel anterior
|
|
32
|
+
const parentValue = selectedValues[levels[i - 1].field];
|
|
33
|
+
if (parentValue) {
|
|
34
|
+
options = await fetchFnCloned[i].fetchFn(parentValue);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
// Buscar el objeto Select que coincida con el valor inicial
|
|
39
|
+
const selectedOption = options.find((opt) => opt.value == initialValue);
|
|
40
|
+
if (selectedOption) {
|
|
41
|
+
levels[i].default = selectedOption;
|
|
42
|
+
cacheResults[i] = options; // Cachear los resultados
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
selectedValues[level.field] = level.default?.value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
varS = true;
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
let cacheResults = {};
|
|
53
|
+
// Función para actualizar valores y cargar el siguiente nivel
|
|
54
|
+
let ultimoIndexActualizado = 0;
|
|
55
|
+
function handleChange(index, value, field) {
|
|
56
|
+
levels[index].default = value;
|
|
57
|
+
for (let i = index + 1; i < levels.length; i++) {
|
|
58
|
+
levels[i].default = null;
|
|
59
|
+
selectedValues[levels[i].field] = null;
|
|
60
|
+
}
|
|
61
|
+
selectedValues[field] = value?.value;
|
|
62
|
+
ultimoIndexActualizado = index;
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
console.log(cacheResults);
|
|
65
|
+
}
|
|
65
66
|
</script>
|
|
66
67
|
|
|
67
68
|
{#if varS}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
{#each levels as level, i}
|
|
70
|
+
{#if i == 0}
|
|
71
|
+
{#await fetchFnCloned[0].fetchFn()}
|
|
72
|
+
cargando {level.label}...
|
|
73
|
+
{:then res}
|
|
74
|
+
<InputFormSelect
|
|
75
|
+
value={level?.default}
|
|
76
|
+
label={level.label}
|
|
77
|
+
{res}
|
|
78
|
+
changeFunction={(e) => handleChange(0, e.detail, level.field)}
|
|
79
|
+
onClear={() => handleChange(0, null, level.field)}
|
|
80
|
+
showPlusIcon={level.showPlusIcon ?? false}
|
|
81
|
+
onPlusClick={level.onPlusClick ?? (() => {})}
|
|
82
|
+
/>
|
|
83
|
+
{/await}
|
|
84
|
+
{/if}
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
86
|
+
{#if i > 0}
|
|
87
|
+
{#if levels[i - 1]?.default?.value}
|
|
88
|
+
{#await ultimoIndexActualizado >= i ? cacheResults[i] : fetchFnCloned[i].fetchFn(levels[i - 1]?.default?.value)}
|
|
89
|
+
cargando {level.label}...
|
|
90
|
+
{:then res}
|
|
91
|
+
<div class=" hidden">
|
|
92
|
+
{(cacheResults[i] = res)}
|
|
93
|
+
</div>
|
|
94
|
+
<InputFormSelect
|
|
95
|
+
value={level?.default}
|
|
96
|
+
label={level.label}
|
|
97
|
+
{res}
|
|
98
|
+
changeFunction={(e) => handleChange(i, e.detail, level.field)}
|
|
99
|
+
onClear={() => handleChange(i, null, level.field)}
|
|
100
|
+
showPlusIcon={level.showPlusIcon ?? false}
|
|
101
|
+
onPlusClick={level.onPlusClick ?? (() => {})}
|
|
102
|
+
/>
|
|
103
|
+
{/await}
|
|
104
|
+
{:else}
|
|
105
|
+
<h1>Selecciona {level.label}</h1>
|
|
106
|
+
{/if}
|
|
107
|
+
{/if}
|
|
108
|
+
{/each}
|
|
108
109
|
{/if}
|
|
@@ -1,114 +1,116 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import "../typography.css";
|
|
3
|
+
|
|
4
|
+
export let valueVar: string = "";
|
|
5
|
+
export let label: string;
|
|
6
|
+
export let disabled = false;
|
|
7
|
+
export let obligatory = false;
|
|
8
|
+
export let icon: string | null = null;
|
|
7
9
|
</script>
|
|
8
10
|
|
|
9
11
|
<div class="input-container">
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</div>
|
|
14
|
-
{/if}
|
|
15
|
-
<div class="input-wrapper">
|
|
16
|
-
<input
|
|
17
|
-
{disabled}
|
|
18
|
-
type="color"
|
|
19
|
-
bind:value={valueVar}
|
|
20
|
-
placeholder=" "
|
|
21
|
-
class="input-field"
|
|
22
|
-
/>
|
|
23
|
-
|
|
24
|
-
<label for={valueVar} class="input-label"
|
|
25
|
-
>{label}
|
|
26
|
-
{#if obligatory}
|
|
27
|
-
<span class="required-mark"> *</span>
|
|
28
|
-
{/if}</label
|
|
29
|
-
>
|
|
12
|
+
{#if icon}
|
|
13
|
+
<div class="icon-wrapper">
|
|
14
|
+
<i class="{icon} icon"></i>
|
|
30
15
|
</div>
|
|
16
|
+
{/if}
|
|
17
|
+
<div class="input-wrapper">
|
|
18
|
+
<input
|
|
19
|
+
{disabled}
|
|
20
|
+
type="color"
|
|
21
|
+
bind:value={valueVar}
|
|
22
|
+
placeholder=" "
|
|
23
|
+
class="input-field"
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<label for={valueVar} class="input-label"
|
|
27
|
+
>{label}
|
|
28
|
+
{#if obligatory}
|
|
29
|
+
<span class="required-mark"> *</span>
|
|
30
|
+
{/if}</label
|
|
31
|
+
>
|
|
32
|
+
</div>
|
|
31
33
|
</div>
|
|
32
34
|
|
|
33
35
|
<style>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
36
|
+
.input-container {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
|
|
40
|
+
height: fit-content;
|
|
41
|
+
|
|
42
|
+
margin-top: 1.95rem;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.icon-wrapper {
|
|
46
|
+
width: 1rem;
|
|
47
|
+
position: relative;
|
|
48
|
+
margin-right: 0.5rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.icon {
|
|
52
|
+
position: absolute;
|
|
53
|
+
top: -0.4rem;
|
|
54
|
+
left: 0.25rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.input-wrapper {
|
|
58
|
+
position: relative;
|
|
59
|
+
z-index: 0;
|
|
60
|
+
width: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.input-field {
|
|
64
|
+
display: block;
|
|
65
|
+
width: 100%;
|
|
66
|
+
font-size: 1rem;
|
|
67
|
+
height: 1.8rem;
|
|
68
|
+
color: var(--grav-crud-color-neutral);
|
|
69
|
+
background: transparent;
|
|
70
|
+
appearance: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.input-field:focus {
|
|
74
|
+
outline: none;
|
|
75
|
+
border-color: black;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.input-label {
|
|
79
|
+
position: absolute;
|
|
80
|
+
font-size: 1rem;
|
|
81
|
+
text-align: left;
|
|
82
|
+
color: var(--grav-crud-color-neutral);
|
|
83
|
+
transition: all 0.3s;
|
|
84
|
+
top: 0.25rem;
|
|
85
|
+
left: 0.25rem;
|
|
86
|
+
z-index: -10;
|
|
87
|
+
transform-origin: left;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.input-field:focus + .input-label,
|
|
91
|
+
.input-field:not(:placeholder-shown) + .input-label {
|
|
92
|
+
left: 0;
|
|
93
|
+
top: 0;
|
|
94
|
+
color: var(--grav-crud-color-neutral);
|
|
95
|
+
translate: -0.6rem -2.05rem;
|
|
96
|
+
scale: 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.input-field:placeholder-shown + .input-label {
|
|
100
|
+
transform: translateY(0) scale(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.required-mark {
|
|
104
|
+
color: #dc2626;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.no-margin {
|
|
108
|
+
margin-top: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.no-margin .input-field:focus + .input-label,
|
|
112
|
+
.no-margin .input-field:not(:placeholder-shown) + .input-label {
|
|
113
|
+
translate: -0.6rem -1.4rem;
|
|
114
|
+
font-size: 0.7rem;
|
|
115
|
+
}
|
|
114
116
|
</style>
|