iconograph-ui 1.5.4 → 1.5.6

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.
@@ -13,6 +13,7 @@
13
13
  import SegmentedSwitchInput from "$lib/iconograph-ui/form/SegmentedSwitchInput.svelte"
14
14
  import Link from "$lib/iconograph-ui/display/Link.svelte";
15
15
  import SelectUserInput from "$lib/iconograph-ui/user/SelectUserInput.svelte";
16
+ import MultiSelect from "$lib/iconograph-ui/form/MultiSelect.svelte";
16
17
 
17
18
  let options = [{ key: "Value" }]
18
19
  let inputs = [
@@ -22,6 +23,7 @@
22
23
  { component: Input, props: { type: "email", name: "email", label: "Email"}, value: "test@example.com" },
23
24
  { component: SexeChoiceInput, props: { name: "sexe", label: "Sexe" } },
24
25
  { component: CustomInput, props: { name: "color", label: "Couleur" } },
26
+ { component: MultiSelect, props: { name: "multiselect", label: "Fruits", options: { APPLE: 'Pomme', BANANA: 'Banane' } }, }
25
27
  ];
26
28
 
27
29
  let button = {
package/index.js CHANGED
@@ -23,6 +23,7 @@ import DateStr from "./lib/display/DateStr.svelte";
23
23
  import Field from "./lib/display/Field.svelte";
24
24
  import Link from "./lib/display/Link.svelte";
25
25
  import ActionButton from "./lib/form/ActionButton.svelte";
26
+ import MultiSelect from "./lib/form/MultiSelect.svelte";
26
27
 
27
28
  export {
28
29
  Button,
@@ -49,5 +50,6 @@ export {
49
50
  Field,
50
51
  Link,
51
52
  ActionButton,
53
+ MultiSelect,
52
54
  addNotification,
53
55
  };
@@ -14,8 +14,8 @@
14
14
 
15
15
  function setDeep(obj, path, value) {
16
16
  let keys = path
17
- .replace(/\]/g, '') // supprime les `]`
18
- .split(/\[/); // découpe sur `[`
17
+ .replace(/\]/g, '')
18
+ .split(/\[/);
19
19
 
20
20
  let current = obj;
21
21
  keys.forEach((k, i) => {
@@ -33,11 +33,12 @@
33
33
  let body = {};
34
34
 
35
35
  inputs.forEach(i => {
36
+ if (i.props.stringify)
37
+ i.value = JSON.stringify(i.value);
36
38
  setDeep(body, i.props.name, i.value);
37
39
  });
38
40
 
39
41
  console.log(body);
40
- //await timeout(500);
41
42
 
42
43
  const response = await fetch(uri, {
43
44
  method: 'POST',
@@ -0,0 +1,53 @@
1
+ <script>
2
+ export let name;
3
+ export let value = [];
4
+ export let options = {};
5
+ export let required = false;
6
+
7
+ function toggleSelection(key) {
8
+ if (value.includes(key))
9
+ value = value.filter(v => v !== key);
10
+ else
11
+ value = [...value, key];
12
+ }
13
+
14
+ $: entries = Object.entries(options);
15
+ </script>
16
+
17
+ <div class="multi-checkbox">
18
+ {#each entries as [key, label]}
19
+ <label class="option">
20
+ <input type="checkbox" name={name} value={key} checked={value.includes(key)}
21
+ on:change={() => toggleSelection(key)} />
22
+ {label}
23
+ </label>
24
+ {/each}
25
+ </div>
26
+
27
+ <style>
28
+ .multi-checkbox {
29
+ display: flex;
30
+ gap: 0.5rem;
31
+ flex-wrap: wrap;
32
+ }
33
+ .option {
34
+ display: flex;
35
+ align-items: center;
36
+ cursor: pointer;
37
+ padding: 12px 16px;
38
+ border-radius: 100px;
39
+ background-color: var(--theme-input-bg-color, #ebebed);
40
+ border: var(--theme-input-border, none);
41
+ font-size: 14px;
42
+ line-height: 16px;
43
+ font-weight: 400;
44
+ font-family: var(--theme-text-font);
45
+ color: var(--theme-input-text-font);
46
+ }
47
+ input[type="checkbox"] {
48
+ transform: scale(1.1);
49
+ cursor: pointer;
50
+ margin-right: 8px;
51
+ background-color: transparent;
52
+ }
53
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iconograph-ui",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "A Svelte Kit components library",
5
5
  "main": "./index.js",
6
6
  "svelte": "./index.js",