iconograph-ui 1.2.16 → 1.2.18
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/index.js +8 -0
- package/lib/form/FlexForm.svelte +92 -0
- package/lib/form/SegmentedSwitchInput.svelte +63 -0
- package/lib/layout/Modal.svelte +92 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,17 +9,23 @@ import MainMenu from "./lib/navigation/MainMenu.svelte"
|
|
|
9
9
|
import Button from "./lib/navigation/Button.svelte"
|
|
10
10
|
import Notification from "./lib/notification/Notification.svelte";
|
|
11
11
|
import NotificationWrapper from "./lib/notification/NotificationWrapper.svelte";
|
|
12
|
+
import { addNotification } from "./lib/notification/NotificationWrapper.svelte";
|
|
12
13
|
import Table from "./lib/table/Table.svelte"
|
|
13
14
|
import CellLink from "./lib/table/CellLink.svelte"
|
|
14
15
|
import UserPicture from "./lib/user/UserPicture.svelte";
|
|
15
16
|
import NavBar from "./lib/navigation/NavBar.svelte";
|
|
16
17
|
import SelectUserInput from "./lib/user/SelectUserInput.svelte";
|
|
18
|
+
import Modal from "./lib/layout/Modal.svelte"
|
|
19
|
+
import FlexForm from "./lib/form/FlexForm.svelte";
|
|
20
|
+
import SegmentedSwitchInput from "./lib/form/SegmentedSwitchInput.svelte"
|
|
17
21
|
|
|
18
22
|
export {
|
|
19
23
|
Button,
|
|
20
24
|
FormButton,
|
|
21
25
|
Form,
|
|
26
|
+
FlexForm,
|
|
22
27
|
Input,
|
|
28
|
+
SegmentedSwitchInput,
|
|
23
29
|
SexeChoiceInput,
|
|
24
30
|
BodySection,
|
|
25
31
|
HeadSection,
|
|
@@ -32,4 +38,6 @@ export {
|
|
|
32
38
|
UserPicture,
|
|
33
39
|
NavBar,
|
|
34
40
|
SelectUserInput,
|
|
41
|
+
Modal,
|
|
42
|
+
addNotification,
|
|
35
43
|
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import FormButton from "./FormButton.svelte";
|
|
3
|
+
import { addNotification } from "../notification/NotificationWrapper.svelte";
|
|
4
|
+
|
|
5
|
+
export let inputs = [];
|
|
6
|
+
export let button= { label: "Enregistrer"};
|
|
7
|
+
export let uri;
|
|
8
|
+
|
|
9
|
+
let waiting = false;
|
|
10
|
+
|
|
11
|
+
function setDeep(obj, path, value) {
|
|
12
|
+
let keys = path
|
|
13
|
+
.replace(/\]/g, '') // supprime les `]`
|
|
14
|
+
.split(/\[/); // découpe sur `[`
|
|
15
|
+
|
|
16
|
+
let current = obj;
|
|
17
|
+
keys.forEach((k, i) => {
|
|
18
|
+
if (i === keys.length - 1) {
|
|
19
|
+
current[k] = value;
|
|
20
|
+
} else {
|
|
21
|
+
if (!(k in current)) current[k] = {};
|
|
22
|
+
current = current[k];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function handleSubmit() {
|
|
28
|
+
waiting = true;
|
|
29
|
+
let body = {};
|
|
30
|
+
|
|
31
|
+
inputs.forEach(i => {
|
|
32
|
+
setDeep(body, i.props.name, i.value);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
console.log(body);
|
|
36
|
+
//await timeout(500);
|
|
37
|
+
|
|
38
|
+
const response = await fetch(uri, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body: JSON.stringify(body),
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
waiting = false;
|
|
47
|
+
|
|
48
|
+
if (!response.ok && response.status == 404)
|
|
49
|
+
return addNotification({'status': 'failure', 'message': 'Erreur ' + response.status })
|
|
50
|
+
|
|
51
|
+
const data = await response.json();
|
|
52
|
+
console.log(data);
|
|
53
|
+
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
addNotification({'status': 'failure', 'message': response.status + ': ' + data.message})
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
addNotification({'status': 'success', 'message': data.message})
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<form>
|
|
64
|
+
<slot></slot>
|
|
65
|
+
|
|
66
|
+
<FormButton button={button} clickEvent={handleSubmit} ></FormButton>
|
|
67
|
+
|
|
68
|
+
</form>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
form :global(.form-row) {
|
|
72
|
+
display: flex;
|
|
73
|
+
margin-bottom: 6px;
|
|
74
|
+
}
|
|
75
|
+
form :global(.form-row > div) {
|
|
76
|
+
flex: 1;
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
justify-content: space-between;
|
|
80
|
+
margin-right: 12px;
|
|
81
|
+
}
|
|
82
|
+
form :global(label) {
|
|
83
|
+
display: inline-block;
|
|
84
|
+
padding: 0px 0px;
|
|
85
|
+
margin: 4px 6px;
|
|
86
|
+
font-family: var(--theme-text-font);
|
|
87
|
+
font-size: 14px;
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
color: #222;
|
|
90
|
+
width: fit-content;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
export let options = [];
|
|
4
|
+
export let selected;
|
|
5
|
+
|
|
6
|
+
function select(e) {
|
|
7
|
+
selected = e;
|
|
8
|
+
}
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class={`segmented-container`}>
|
|
12
|
+
{#each options as opt, idx}
|
|
13
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
14
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
15
|
+
<div class="segment {opt === selected ? 'selected' : ''}" on:click={() => select(opt)}>
|
|
16
|
+
<div>{opt}</div>
|
|
17
|
+
</div>
|
|
18
|
+
{/each}
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
.segmented-container {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
background-color: var(--theme-input-bg-color, #ebebed);
|
|
26
|
+
height: var(--theme-input-height, 40px);
|
|
27
|
+
border: var(--theme-input-border, none);
|
|
28
|
+
border-radius: 50px;
|
|
29
|
+
padding: 0px;
|
|
30
|
+
}
|
|
31
|
+
.segment {
|
|
32
|
+
padding: 0px 16px;
|
|
33
|
+
margin: 3px;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
border-radius: 50px;
|
|
36
|
+
border: none;
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
text-align: center;
|
|
40
|
+
background: transparent;
|
|
41
|
+
transition: all 0.2s, color 0.2s;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
line-height: 16px;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
font-family: var(--theme-text-font);
|
|
46
|
+
color: var(--theme-input-text-font);
|
|
47
|
+
}
|
|
48
|
+
.segment:not(:last-of-type) {
|
|
49
|
+
margin-right: 0px
|
|
50
|
+
}
|
|
51
|
+
.segment:not(:first-of-type) {
|
|
52
|
+
margin-left: 0px
|
|
53
|
+
}
|
|
54
|
+
.segment.selected {
|
|
55
|
+
background: var(--theme-main-color);
|
|
56
|
+
color: white;
|
|
57
|
+
}
|
|
58
|
+
.segment.disabled {
|
|
59
|
+
background: #e0e0e0;
|
|
60
|
+
color: #888;
|
|
61
|
+
cursor: not-allowed;
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Portal from 'svelte-portal';
|
|
3
|
+
|
|
4
|
+
export let open = true;
|
|
5
|
+
|
|
6
|
+
function handleClose() {
|
|
7
|
+
open = false;
|
|
8
|
+
}
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
{#if open}
|
|
12
|
+
|
|
13
|
+
<Portal target="body" >
|
|
14
|
+
<div id="bgk" class="{!open ? 'hidden' : ''}">
|
|
15
|
+
<div class="container">
|
|
16
|
+
<div on:click|stopPropagation|preventDefault={handleClose} class="croix">+</div>
|
|
17
|
+
|
|
18
|
+
<slot></slot>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</Portal>
|
|
23
|
+
|
|
24
|
+
{/if}
|
|
25
|
+
|
|
26
|
+
<style>
|
|
27
|
+
#bgk {
|
|
28
|
+
position: fixed;
|
|
29
|
+
top: 0px;
|
|
30
|
+
left: 0px;
|
|
31
|
+
width: 100vw;
|
|
32
|
+
height: 100vh;
|
|
33
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
align-items: center;
|
|
37
|
+
transition: all ease-in-out 0.35s;
|
|
38
|
+
@starting-style {
|
|
39
|
+
opacity: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
#bgk.hidden {
|
|
43
|
+
opacity: 0;
|
|
44
|
+
@starting-style {
|
|
45
|
+
opacity: 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
#bgk .container {
|
|
49
|
+
max-width: calc(100% - 48px);
|
|
50
|
+
max-height: calc(100vh - 48px);
|
|
51
|
+
min-width: 300px;
|
|
52
|
+
min-height: 200px;
|
|
53
|
+
background-color: var(--main-bg-color);
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
border-radius: 16px;
|
|
56
|
+
overflow: auto;
|
|
57
|
+
position: relative;
|
|
58
|
+
top: 0vh;
|
|
59
|
+
transition: all ease-in-out 0.3s;
|
|
60
|
+
@starting-style {
|
|
61
|
+
top: -300px;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
#bgk.hidden .container {
|
|
65
|
+
top: -300px;
|
|
66
|
+
@starting-style {
|
|
67
|
+
top: 0vh;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
.croix {
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
margin-left: 8px;
|
|
73
|
+
height: 24px;
|
|
74
|
+
width: 24px;
|
|
75
|
+
min-width: 24px;
|
|
76
|
+
background-color: #ddd;
|
|
77
|
+
border-radius: 20px;
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
font-size: 20px;
|
|
80
|
+
text-align: center;
|
|
81
|
+
line-height: 24px;
|
|
82
|
+
color: #777;
|
|
83
|
+
transform: rotate(45deg);
|
|
84
|
+
transition: all ease-in-out 0.14s;
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: 8px;
|
|
87
|
+
right: 8px;
|
|
88
|
+
}
|
|
89
|
+
.croix:hover {
|
|
90
|
+
background-color: #ccc;
|
|
91
|
+
}
|
|
92
|
+
</style>
|