fuma 2.1.5 → 2.2.7
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/_doc/data.d.ts +3 -1
- package/dist/_doc/data.js +6 -2
- package/dist/command/index.d.ts +1 -1
- package/dist/command/index.js +1 -1
- package/dist/command/{command.svelte.js → useCommand.svelte.js} +1 -1
- package/dist/input/InputBoolean.svelte +25 -7
- package/dist/input/InputBoolean.svelte.d.ts +4 -0
- package/dist/input/InputCheckboxes.svelte +116 -0
- package/dist/input/InputCheckboxes.svelte.d.ts +16 -0
- package/dist/input/InputDateTime.svelte +194 -0
- package/dist/input/InputDateTime.svelte.d.ts +23 -0
- package/dist/input/InputMultiSelect.svelte +286 -0
- package/dist/input/{InputRelation.svelte.d.ts → InputMultiSelect.svelte.d.ts} +27 -13
- package/dist/input/InputNumber.svelte +36 -6
- package/dist/input/InputNumber.svelte.d.ts +5 -0
- package/dist/input/InputRadio.svelte +54 -23
- package/dist/input/InputRange.svelte +19 -4
- package/dist/input/InputRange.svelte.d.ts +6 -0
- package/dist/input/InputSelect.svelte +204 -62
- package/dist/input/InputSelect.svelte.d.ts +87 -6
- package/dist/input/InputSelectNative.svelte +44 -19
- package/dist/input/InputSelectNative.svelte.d.ts +5 -0
- package/dist/input/InputString.svelte +36 -6
- package/dist/input/InputString.svelte.d.ts +5 -0
- package/dist/input/InputTextarea.svelte +41 -12
- package/dist/input/InputTextarea.svelte.d.ts +5 -0
- package/dist/input/index.d.ts +4 -1
- package/dist/input/index.js +4 -1
- package/dist/input/useItems.svelte.d.ts +38 -0
- package/dist/input/useItems.svelte.js +142 -0
- package/dist/loading/Loading.svelte +3 -2
- package/dist/loading/Loading.svelte.d.ts +3 -2
- package/dist/popover/Popover.svelte +1 -2
- package/dist/popover/Popover.svelte.d.ts +13 -0
- package/dist/popover/index.d.ts +1 -1
- package/dist/popover/index.js +1 -1
- package/dist/popover/{popover.svelte.d.ts → usePopover.svelte.d.ts} +2 -1
- package/dist/popover/usePopover.svelte.js +145 -0
- package/dist/remote/useForm.d.ts +4 -5
- package/dist/remote/useForm.js +9 -4
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.js +1 -1
- package/dist/ui/button/ButtonDelete.svelte +4 -2
- package/dist/ui/dialog/Dialog.svelte +5 -5
- package/dist/ui/drawer/Drawer.svelte +74 -26
- package/dist/ui/drawer/Drawer.svelte.d.ts +10 -4
- package/dist/ui/drawer/index.d.ts +1 -0
- package/dist/ui/drawer/index.js +1 -0
- package/dist/ui/drawer/inertBackground.d.ts +13 -0
- package/dist/ui/drawer/inertBackground.js +59 -0
- package/dist/ui/drawer/useLayer.svelte.d.ts +1 -1
- package/dist/ui/drawer/useLayer.svelte.js +11 -7
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/menu/ContextMenu.svelte +30 -17
- package/dist/ui/menu/ContextMenu.svelte.d.ts +2 -3
- package/dist/ui/menu/DropDown.svelte +1 -1
- package/dist/ui/menu/DropDown.svelte.d.ts +1 -1
- package/dist/ui/menu/DropDownMenu.svelte +12 -10
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +2 -3
- package/dist/ui/menu/index.d.ts +0 -1
- package/dist/ui/menu/index.js +0 -2
- package/dist/ui/range/RangePicker.svelte +25 -13
- package/dist/ui/range/RangePicker.svelte.d.ts +9 -25
- package/dist/ui/range/RangePickerButton.svelte +49 -32
- package/dist/ui/range/RangePickerButton.svelte.d.ts +1 -1
- package/dist/ui/table/Table.svelte +7 -10
- package/dist/ui/table/Table.svelte.d.ts +1 -1
- package/dist/ui/table/TableFieldsEdition.svelte +24 -22
- package/dist/ui/table/TableHead.svelte +5 -1
- package/dist/ui/table/TableViewSelect.svelte +52 -47
- package/dist/ui/table/cell/TableCellBoolean.svelte +2 -2
- package/dist/ui/table/head/TableHeadDate.svelte +62 -55
- package/dist/ui/table/head/TableHeadNumber.svelte +55 -19
- package/dist/ui/table/head/TableHeadSelect.svelte +30 -27
- package/dist/ui/table/head/TableHeadString.svelte +11 -7
- package/dist/ui/table/index.d.ts +1 -0
- package/dist/ui/table/index.js +1 -0
- package/package.json +7 -4
- package/dist/input/InputRelation.svelte +0 -200
- package/dist/popover/popover.svelte.js +0 -106
- /package/dist/command/{command.svelte.d.ts → useCommand.svelte.d.ts} +0 -0
- /package/dist/state/{param.svelte.d.ts → param.d.ts} +0 -0
- /package/dist/state/{param.svelte.js → param.js} +0 -0
|
@@ -2,36 +2,49 @@
|
|
|
2
2
|
import { CalendarRangeIcon } from '@lucide/svelte'
|
|
3
3
|
import { slide } from 'svelte/transition'
|
|
4
4
|
import { goto } from '$app/navigation'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { InputDateTime } from '../../input/index.js'
|
|
6
|
+
import { usePopover } from '../../popover/index.js'
|
|
7
|
+
import { param, urlParam } from '../../state/param.js'
|
|
7
8
|
import { formatRangeShort } from './format.js'
|
|
8
9
|
import { type RangeAsDate, RangePicker } from './index.js'
|
|
9
10
|
import { jsonParse } from '../../utils/jsonParse.js'
|
|
10
11
|
|
|
11
|
-
let dropDown: DropDown
|
|
12
12
|
let rangePicker: RangePicker
|
|
13
13
|
|
|
14
14
|
let {
|
|
15
15
|
key = 'range',
|
|
16
|
-
range = $bindable(
|
|
17
|
-
jsonParse<RangeAsDate>(param.get(key), {
|
|
18
|
-
start: null,
|
|
19
|
-
end: null
|
|
20
|
-
})
|
|
21
|
-
),
|
|
16
|
+
range = $bindable(parseRange(param.get(key))),
|
|
22
17
|
minDate,
|
|
23
18
|
maxDate,
|
|
24
19
|
class: klass = '',
|
|
25
20
|
classLabel = ''
|
|
26
21
|
}: {
|
|
27
22
|
key?: string
|
|
28
|
-
range
|
|
23
|
+
range?: RangeAsDate
|
|
29
24
|
minDate?: Date | number | string
|
|
30
25
|
maxDate?: Date | number | string
|
|
31
26
|
class?: string
|
|
32
27
|
classLabel?: string
|
|
33
28
|
} = $props()
|
|
34
29
|
|
|
30
|
+
const popover = usePopover()
|
|
31
|
+
|
|
32
|
+
// Le paramètre d'URL porte des chaînes ISO: sans cette reprise, `range` contiendrait des
|
|
33
|
+
// chaînes là où tout le reste — `updateURL`, `InputDateTime` — attend des `Date`.
|
|
34
|
+
function parseRange(value?: string | null): RangeAsDate {
|
|
35
|
+
const { start, end } = jsonParse<{ start?: string; end?: string }>(value, {})
|
|
36
|
+
return { start: start ? new Date(start) : null, end: end ? new Date(end) : null }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Le light-dismiss (clic à l'extérieur) ne passe pas par `hide()`, donc pas par
|
|
40
|
+
// `onHide`: on suit `isOpen` pour que l'URL soit à jour à chaque fermeture.
|
|
41
|
+
let wasOpen = false
|
|
42
|
+
$effect(() => {
|
|
43
|
+
const { isOpen } = popover
|
|
44
|
+
if (wasOpen && !isOpen) updateURL()
|
|
45
|
+
wasOpen = isOpen
|
|
46
|
+
})
|
|
47
|
+
|
|
35
48
|
let isValidPeriod = $derived(!!range.start && !!range.end)
|
|
36
49
|
|
|
37
50
|
function getLabel(_range?: Partial<RangeAsDate>) {
|
|
@@ -53,29 +66,27 @@
|
|
|
53
66
|
}
|
|
54
67
|
</script>
|
|
55
68
|
|
|
56
|
-
<
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
<button
|
|
70
|
+
class={['min-width-0 btn flex-nowrap btn-sm', !isValidPeriod && 'btn-square', klass]}
|
|
71
|
+
{...popover.trigger}
|
|
72
|
+
>
|
|
73
|
+
<CalendarRangeIcon class="opacity-70" size={20} />
|
|
74
|
+
{#if isValidPeriod}
|
|
75
|
+
<span
|
|
76
|
+
transition:slide={{ axis: 'x', duration: 200 }}
|
|
77
|
+
class="text-xs font-medium whitespace-nowrap opacity-80 {classLabel}"
|
|
78
|
+
>
|
|
79
|
+
{getLabel(range)}
|
|
80
|
+
</span>
|
|
81
|
+
{/if}
|
|
82
|
+
</button>
|
|
70
83
|
|
|
84
|
+
<div {...popover.content} class="rounded-box border bg-base-100 p-1 shadow-xl">
|
|
71
85
|
<RangePicker bind:this={rangePicker} numberOfMonths={1} bind:range {minDate} {maxDate} />
|
|
72
86
|
|
|
73
87
|
<div class="flex gap-2 p-2">
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
<InputString label="Jusqu'à" bind:value={range.end} class="grow" />
|
|
77
|
-
-->
|
|
78
|
-
<span>TODO: same problème with input...</span>
|
|
88
|
+
<InputDateTime label="À partir de" bind:value={range.start} class="grow" />
|
|
89
|
+
<InputDateTime label="Jusqu'à" bind:value={range.end} class="grow" />
|
|
79
90
|
</div>
|
|
80
91
|
|
|
81
92
|
<div class="m-2 flex justify-end gap-2">
|
|
@@ -86,12 +97,18 @@
|
|
|
86
97
|
onclick={() => {
|
|
87
98
|
range = { start: null, end: null }
|
|
88
99
|
rangePicker.clear()
|
|
89
|
-
|
|
100
|
+
popover.hide()
|
|
90
101
|
}}
|
|
91
102
|
>
|
|
92
103
|
Effacer
|
|
93
104
|
</button>
|
|
94
105
|
{/if}
|
|
95
|
-
<button class="btn" onclick={() =>
|
|
106
|
+
<button class="btn" onclick={() => popover.hide()}> Valider </button>
|
|
96
107
|
</div>
|
|
97
|
-
</
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<style>
|
|
111
|
+
div[popover] {
|
|
112
|
+
border-color: color-mix(in oklab, var(--color-base-content) 20%, #0000);
|
|
113
|
+
}
|
|
114
|
+
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="Item extends ItemBase">
|
|
2
|
-
import type
|
|
2
|
+
import { type Snippet, untrack } from 'svelte'
|
|
3
3
|
import { afterNavigate } from '$app/navigation'
|
|
4
4
|
import {
|
|
5
5
|
context,
|
|
@@ -35,21 +35,18 @@
|
|
|
35
35
|
onclick?: (item?: Item) => void
|
|
36
36
|
} = $props()
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
KEY_FIELDS_ORDER
|
|
44
|
-
})
|
|
45
|
-
})
|
|
38
|
+
// Posé à l'initialisation et non dans un `$effect`: un effet ne tourne pas au rendu
|
|
39
|
+
// serveur, et `TableFieldsEdition` lirait un contexte vide. `key` identifie la table
|
|
40
|
+
// pour toute sa durée de vie.
|
|
41
|
+
const tableKey = untrack(() => key)
|
|
42
|
+
context.set(tableKey, createKeys(tableKey))
|
|
46
43
|
|
|
47
44
|
const initFields = () => (fields = syncFieldsWithParams(key, fields))
|
|
48
45
|
initFields()
|
|
49
46
|
afterNavigate(initFields)
|
|
50
47
|
</script>
|
|
51
48
|
|
|
52
|
-
<div class="{klass} overflow-x-auto rounded-
|
|
49
|
+
<div class="{klass} overflow-x-auto rounded-box border bg-base-100" class:min-h-[320px]={!hideBody}>
|
|
53
50
|
<table class="table relative">
|
|
54
51
|
<TableHead {fields} {key} {onCreateField} />
|
|
55
52
|
{#if !hideBody && items.length}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
<script lang="ts" generics="Item extends ItemBase">
|
|
2
2
|
import {
|
|
3
3
|
CheckIcon,
|
|
4
|
-
|
|
5
|
-
CircleIcon,
|
|
4
|
+
DotIcon,
|
|
6
5
|
EllipsisIcon,
|
|
6
|
+
FunnelIcon,
|
|
7
7
|
GripIcon,
|
|
8
|
+
LockKeyholeIcon,
|
|
9
|
+
MoveVerticalIcon,
|
|
8
10
|
PlusIcon
|
|
9
11
|
} from '@lucide/svelte'
|
|
10
12
|
import { goto } from '$app/navigation'
|
|
11
13
|
import { page } from '$app/state'
|
|
12
14
|
import { listEditable } from '../../action/list/index.js'
|
|
13
15
|
import { tip } from '../../action/tip.js'
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
+
import { Popover } from '../../popover/index.js'
|
|
17
|
+
import { param, urlParam } from '../../state/param.js'
|
|
16
18
|
import { context } from './context.js'
|
|
17
19
|
import type { ItemBase, TableField } from './index.js'
|
|
18
20
|
import { jsonParse } from '../../utils/jsonParse.js'
|
|
@@ -64,22 +66,19 @@
|
|
|
64
66
|
</script>
|
|
65
67
|
|
|
66
68
|
<th class="sticky right-0 z-10 p-0 px-1" align="right">
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
class="max-h-none px-0"
|
|
70
|
-
tippyProps={{ appendTo: () => document.body, placement: 'bottom-end' }}
|
|
71
|
-
>
|
|
72
|
-
{#snippet activator()}
|
|
69
|
+
<Popover placement="bottom-end" class="px-0 py-1">
|
|
70
|
+
{#snippet trigger(popover)}
|
|
73
71
|
<button
|
|
74
72
|
type="button"
|
|
75
73
|
class="btn btn-square btn-ghost backdrop-blur btn-sm"
|
|
76
|
-
use:tip={{ content: '
|
|
74
|
+
use:tip={{ content: 'Modifier les colonnes' }}
|
|
75
|
+
{...popover.trigger}
|
|
77
76
|
>
|
|
78
77
|
<EllipsisIcon />
|
|
79
78
|
</button>
|
|
80
79
|
{/snippet}
|
|
81
80
|
|
|
82
|
-
{#snippet children(
|
|
81
|
+
{#snippet children(popover)}
|
|
83
82
|
{#if onCreateField}
|
|
84
83
|
<div class="bordered flex items-center gap-2 border-b pr-1 pb-1 pl-2">
|
|
85
84
|
<span class=" font-semibold opacity-70">Champs</span>
|
|
@@ -88,7 +87,7 @@
|
|
|
88
87
|
class="btn ml-auto btn-square btn-sm"
|
|
89
88
|
onclick={() => {
|
|
90
89
|
if (onCreateField) onCreateField()
|
|
91
|
-
|
|
90
|
+
popover.hide()
|
|
92
91
|
}}
|
|
93
92
|
>
|
|
94
93
|
<PlusIcon title="Ajouter un champ" />
|
|
@@ -108,35 +107,38 @@
|
|
|
108
107
|
<a
|
|
109
108
|
draggable="false"
|
|
110
109
|
href={getFieldHref(field)}
|
|
111
|
-
class="menu-item w-full"
|
|
110
|
+
class="menu-item group w-full pr-1"
|
|
112
111
|
class:disabled={field.locked}
|
|
113
112
|
data-sveltekit-keepfocus
|
|
114
113
|
data-sveltekit-replacestate
|
|
115
114
|
data-sveltekit-noscroll
|
|
116
115
|
>
|
|
117
116
|
{#if field.locked}
|
|
118
|
-
<
|
|
117
|
+
<LockKeyholeIcon class="mx-0.5 text-primary" size={17} />
|
|
119
118
|
{:else if param.has(field.key)}
|
|
120
|
-
<
|
|
119
|
+
<FunnelIcon class="mx-0.5 text-primary" size={17} />
|
|
121
120
|
{:else if field._visible}
|
|
122
|
-
<CheckIcon class="
|
|
121
|
+
<CheckIcon class="text-success" size={21} />
|
|
123
122
|
{:else}
|
|
124
|
-
<
|
|
123
|
+
<DotIcon class="text-base-content/50" size={21} />
|
|
125
124
|
{/if}
|
|
126
125
|
|
|
127
|
-
<span>{field.label}</span>
|
|
126
|
+
<span class=" font-normal">{field.label}</span>
|
|
128
127
|
|
|
129
128
|
<span
|
|
130
|
-
class=
|
|
129
|
+
class={[
|
|
130
|
+
'drag-button btn ml-auto btn-square btn-soft btn-xs',
|
|
131
|
+
'opacity-0 group-hover:opacity-100'
|
|
132
|
+
]}
|
|
131
133
|
onclick={(e) => e.preventDefault()}
|
|
132
134
|
role="none"
|
|
133
135
|
>
|
|
134
|
-
<
|
|
136
|
+
<MoveVerticalIcon size={18} class="text-base-content/70" />
|
|
135
137
|
</span>
|
|
136
138
|
</a>
|
|
137
139
|
{/each}
|
|
138
140
|
</div>
|
|
139
141
|
</div>
|
|
140
142
|
{/snippet}
|
|
141
|
-
</
|
|
143
|
+
</Popover>
|
|
142
144
|
</th>
|
|
@@ -34,7 +34,11 @@
|
|
|
34
34
|
{:else if field.type === 'date'}
|
|
35
35
|
<TableHeadDate {field} />
|
|
36
36
|
{:else if field.options}
|
|
37
|
-
<TableHeadSelect
|
|
37
|
+
<TableHeadSelect
|
|
38
|
+
{field}
|
|
39
|
+
options={field.options}
|
|
40
|
+
multiSelect={field.type === 'multiselect'}
|
|
41
|
+
/>
|
|
38
42
|
{/if}
|
|
39
43
|
{/each}
|
|
40
44
|
<TableFieldsEdition {fields} {key} {onCreateField} />
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { ChevronDownIcon, PlusIcon, SaveIcon } from '@lucide/svelte'
|
|
3
3
|
import { page } from '$app/state'
|
|
4
4
|
|
|
5
|
+
import { Popover } from '../../popover/index.js'
|
|
5
6
|
import { Dialog } from '../dialog/index.js'
|
|
6
|
-
import { DropDown } from '../menu/index.js'
|
|
7
7
|
import { SvelteURLSearchParams } from 'svelte/reactivity'
|
|
8
8
|
|
|
9
9
|
// import { InputText } from '../input/index.js';
|
|
@@ -41,69 +41,74 @@
|
|
|
41
41
|
|
|
42
42
|
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable
|
|
43
43
|
@typescript-eslint/no-unused-vars */
|
|
44
|
-
<
|
|
45
|
-
{#snippet
|
|
44
|
+
<Popover class="p-1">
|
|
45
|
+
{#snippet trigger(popover)}
|
|
46
46
|
<button
|
|
47
47
|
type="button"
|
|
48
48
|
class="menu-item bordered gap-1 rounded-lg border font-semibold opacity-90 btn-sm"
|
|
49
|
+
{...popover.trigger}
|
|
49
50
|
>
|
|
50
51
|
<span>{isNewView ? 'Nouvelle vue' : selectedView?.name || 'Vue simple'}</span>
|
|
51
52
|
<ChevronDownIcon size={20} class="translate-x-1 translate-y-px opacity-90" />
|
|
52
53
|
</button>
|
|
53
54
|
{/snippet}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<
|
|
59
|
-
type="button"
|
|
60
|
-
class="menu-item w-full pr-1.5"
|
|
61
|
-
onclick={() => {
|
|
62
|
-
selectedView = undefined
|
|
63
|
-
dialog?.showModal()
|
|
64
|
-
}}
|
|
65
|
-
>
|
|
66
|
-
<span>Ajouter la nouvelle vue</span>
|
|
67
|
-
<PlusIcon class="ml-auto opacity-80" size={21} />
|
|
68
|
-
</button>
|
|
69
|
-
<hr class="my-1" />
|
|
70
|
-
</li>
|
|
71
|
-
{/if}
|
|
72
|
-
|
|
73
|
-
<li>
|
|
74
|
-
<a href={page.url.pathname} class="menu-item" class:active={!query}>
|
|
75
|
-
<span class="grow">Vue simple</span>
|
|
76
|
-
</a>
|
|
77
|
-
</li>
|
|
78
|
-
|
|
79
|
-
{#each views as view (view.id)}
|
|
80
|
-
<li>
|
|
81
|
-
<a
|
|
82
|
-
href="{page.url.pathname}?{view.query}"
|
|
83
|
-
class="menu-item group pr-1"
|
|
84
|
-
class:active={view.id === selectedView?.id}
|
|
85
|
-
>
|
|
86
|
-
<span class="grow">{view.name}</span>
|
|
56
|
+
{#snippet children(popover)}
|
|
57
|
+
<ul class="flex flex-col gap-1">
|
|
58
|
+
{#if isNewView}
|
|
59
|
+
<li>
|
|
87
60
|
<button
|
|
88
61
|
type="button"
|
|
89
|
-
class="
|
|
90
|
-
onclick={(
|
|
91
|
-
|
|
92
|
-
selectedView = view
|
|
62
|
+
class="menu-item w-full pr-1.5"
|
|
63
|
+
onclick={() => {
|
|
64
|
+
selectedView = undefined
|
|
93
65
|
dialog?.showModal()
|
|
66
|
+
popover.hide()
|
|
94
67
|
}}
|
|
95
68
|
>
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
size={18}
|
|
99
|
-
title="Modifier la vue '{view.name}'"
|
|
100
|
-
/>
|
|
69
|
+
<span>Ajouter la nouvelle vue</span>
|
|
70
|
+
<PlusIcon class="ml-auto opacity-80" size={21} />
|
|
101
71
|
</button>
|
|
72
|
+
<hr class="my-1" />
|
|
73
|
+
</li>
|
|
74
|
+
{/if}
|
|
75
|
+
|
|
76
|
+
<li>
|
|
77
|
+
<a href={page.url.pathname} class="menu-item" class:active={!query} onclick={popover.hide}>
|
|
78
|
+
<span class="grow">Vue simple</span>
|
|
102
79
|
</a>
|
|
103
80
|
</li>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
81
|
+
|
|
82
|
+
{#each views as view (view.id)}
|
|
83
|
+
<li>
|
|
84
|
+
<a
|
|
85
|
+
href="{page.url.pathname}?{view.query}"
|
|
86
|
+
class="menu-item group pr-1"
|
|
87
|
+
class:active={view.id === selectedView?.id}
|
|
88
|
+
onclick={popover.hide}
|
|
89
|
+
>
|
|
90
|
+
<span class="grow">{view.name}</span>
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
class="btn btn-square rounded btn-ghost btn-xs"
|
|
94
|
+
onclick={(e) => {
|
|
95
|
+
e.preventDefault()
|
|
96
|
+
selectedView = view
|
|
97
|
+
dialog?.showModal()
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<SaveIcon
|
|
101
|
+
class="opacity-50 group-hover:opacity-80"
|
|
102
|
+
size={18}
|
|
103
|
+
title="Modifier la vue '{view.name}'"
|
|
104
|
+
/>
|
|
105
|
+
</button>
|
|
106
|
+
</a>
|
|
107
|
+
</li>
|
|
108
|
+
{/each}
|
|
109
|
+
</ul>
|
|
110
|
+
{/snippet}
|
|
111
|
+
</Popover>
|
|
107
112
|
|
|
108
113
|
<Dialog bind:dialog>
|
|
109
114
|
{#snippet header()}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { CalendarArrowDownIcon, CalendarArrowUpIcon, CalendarSearchIcon } from '@lucide/svelte'
|
|
3
3
|
import { goto } from '$app/navigation'
|
|
4
4
|
import { page } from '$app/state'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { InputDateTime } from '../../../input/index.js'
|
|
6
|
+
import { Popover, type PopoverType } from '../../../popover/index.js'
|
|
7
|
+
import { urlParam } from '../../../state/param.js'
|
|
7
8
|
import { formatRange } from '../../range/format.js'
|
|
8
9
|
import { type RangeAsDate, RangePicker } from '../../range/index.js'
|
|
9
10
|
import type { ItemBase, TableField } from '../index.js'
|
|
@@ -12,7 +13,6 @@
|
|
|
12
13
|
|
|
13
14
|
let { field }: { field: Omit<TableField<Item>, 'cell'> } = $props()
|
|
14
15
|
|
|
15
|
-
let dropDown: DropDown
|
|
16
16
|
let rangePicker: RangePicker
|
|
17
17
|
|
|
18
18
|
let initialValue = jsonParse<{
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function handleReset() {
|
|
62
|
+
function handleReset(popover: PopoverType) {
|
|
63
63
|
isValidPeriod = false
|
|
64
64
|
range.start = null
|
|
65
65
|
range = { start: null, end: null }
|
|
66
|
-
|
|
66
|
+
popover.hide()
|
|
67
67
|
rangePicker.clear()
|
|
68
68
|
goto(urlParam.without(field.key, 'skip', 'take'), {
|
|
69
69
|
replaceState: true,
|
|
@@ -74,15 +74,10 @@
|
|
|
74
74
|
</script>
|
|
75
75
|
|
|
76
76
|
<th class="p-1">
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
class="max-h-none"
|
|
82
|
-
>
|
|
83
|
-
{#snippet activator()}
|
|
84
|
-
<button class="menu-item min-h-8 w-full flex-wrap gap-y-1">
|
|
85
|
-
<div class="flex gap-2">
|
|
77
|
+
<Popover class="p-1">
|
|
78
|
+
{#snippet trigger(popover)}
|
|
79
|
+
<button class="menu-item min-h-8 w-full flex-wrap gap-y-1" {...popover.trigger}>
|
|
80
|
+
<div class="flex items-center gap-2">
|
|
86
81
|
<span>{field.label}</span>
|
|
87
82
|
{#if !isValidPeriod}
|
|
88
83
|
<CalendarSearchIcon size={15} class="opacity-50" />
|
|
@@ -102,49 +97,61 @@
|
|
|
102
97
|
</button>
|
|
103
98
|
{/snippet}
|
|
104
99
|
|
|
105
|
-
{#
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
{#snippet children(popover)}
|
|
101
|
+
{#if field.sortable !== false}
|
|
102
|
+
<OrderButtons
|
|
103
|
+
bind:order
|
|
104
|
+
onChange={() => {
|
|
105
|
+
updateUrl()
|
|
106
|
+
popover.hide()
|
|
107
|
+
}}
|
|
108
|
+
IconAsc={CalendarArrowDownIcon}
|
|
109
|
+
IconDesc={CalendarArrowUpIcon}
|
|
110
|
+
/>
|
|
111
|
+
{/if}
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}}
|
|
122
|
-
data-sveltekit-replacestate
|
|
123
|
-
class="flex flex-col font-normal"
|
|
124
|
-
class:mt-6={field.sortable !== false}
|
|
125
|
-
>
|
|
126
|
-
<RangePicker
|
|
127
|
-
bind:this={rangePicker}
|
|
128
|
-
numberOfMonths={1}
|
|
129
|
-
on:change={({ detail: newRange }) => {
|
|
130
|
-
range = newRange
|
|
131
|
-
updateUrl()
|
|
113
|
+
<form
|
|
114
|
+
onsubmit={(e) => {
|
|
115
|
+
e.preventDefault()
|
|
116
|
+
popover.hide()
|
|
132
117
|
}}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
118
|
+
data-sveltekit-replacestate
|
|
119
|
+
class="flex flex-col font-normal"
|
|
120
|
+
class:mt-6={field.sortable !== false}
|
|
121
|
+
>
|
|
122
|
+
<RangePicker
|
|
123
|
+
bind:this={rangePicker}
|
|
124
|
+
numberOfMonths={1}
|
|
125
|
+
onchange={(newRange) => {
|
|
126
|
+
range = newRange
|
|
127
|
+
updateUrl()
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
137
130
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
131
|
+
<div class="m-2 flex gap-2">
|
|
132
|
+
<InputDateTime
|
|
133
|
+
label="À partir de"
|
|
134
|
+
name="start"
|
|
135
|
+
bind:value={range.start}
|
|
136
|
+
class="grow"
|
|
137
|
+
onchange={updateUrl}
|
|
138
|
+
/>
|
|
139
|
+
<InputDateTime
|
|
140
|
+
label="Jusqu'à"
|
|
141
|
+
name="end"
|
|
142
|
+
bind:value={range.end}
|
|
143
|
+
class="grow"
|
|
144
|
+
onchange={updateUrl}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
<div class="m-2 flex flex-row-reverse gap-2">
|
|
149
|
+
<button class="btn">Ok</button>
|
|
150
|
+
<button class="btn btn-ghost" type="button" onclick={() => handleReset(popover)}>
|
|
151
|
+
Effacer
|
|
152
|
+
</button>
|
|
153
|
+
</div>
|
|
154
|
+
</form>
|
|
155
|
+
{/snippet}
|
|
156
|
+
</Popover>
|
|
150
157
|
</th>
|