fuma 2.1.6 → 2.5.0
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 +41 -8
- package/dist/input/InputBoolean.svelte.d.ts +7 -0
- package/dist/input/InputCheckboxes.svelte +123 -0
- package/dist/input/InputCheckboxes.svelte.d.ts +19 -0
- package/dist/input/InputDateTime.svelte +199 -0
- package/dist/input/InputDateTime.svelte.d.ts +26 -0
- package/dist/input/InputMultiSelect.svelte +324 -0
- package/dist/input/{InputRelation.svelte.d.ts → InputMultiSelect.svelte.d.ts} +32 -13
- package/dist/input/InputNumber.svelte +43 -6
- package/dist/input/InputNumber.svelte.d.ts +8 -0
- package/dist/input/InputRadio.svelte +62 -24
- package/dist/input/InputRadio.svelte.d.ts +3 -0
- package/dist/input/InputRange.svelte +24 -4
- package/dist/input/InputRange.svelte.d.ts +9 -0
- package/dist/input/InputSelect.svelte +216 -62
- package/dist/input/InputSelect.svelte.d.ts +91 -6
- package/dist/input/InputSelectNative.svelte +51 -19
- package/dist/input/InputSelectNative.svelte.d.ts +8 -0
- package/dist/input/InputString.svelte +21 -6
- package/dist/input/InputString.svelte.d.ts +7 -0
- package/dist/input/InputTextarea.svelte +58 -11
- package/dist/input/InputTextarea.svelte.d.ts +14 -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 +6 -3
- package/dist/ui/button/ButtonDelete.svelte.d.ts +1 -1
- 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 +16 -16
- package/dist/ui/table/Table.svelte.d.ts +1 -1
- package/dist/ui/table/TableFieldsEdition.svelte +25 -23
- package/dist/ui/table/TableHead.svelte +5 -1
- package/dist/ui/table/cell/TableCellBoolean.svelte +2 -2
- package/dist/ui/table/head/OrderButtons.svelte +21 -20
- package/dist/ui/table/head/OrderButtons.svelte.d.ts +2 -0
- package/dist/ui/table/head/TableHeadDate.svelte +66 -57
- package/dist/ui/table/head/TableHeadNumber.svelte +58 -22
- package/dist/ui/table/head/TableHeadSelect.svelte +31 -28
- package/dist/ui/table/head/TableHeadString.svelte +12 -8
- package/dist/ui/table/index.d.ts +1 -1
- package/dist/ui/table/index.js +1 -1
- package/package.json +7 -4
- package/dist/input/InputRelation.svelte +0 -200
- package/dist/popover/popover.svelte.js +0 -106
- package/dist/ui/table/TableViewSelect.svelte +0 -142
- package/dist/ui/table/TableViewSelect.svelte.d.ts +0 -11
- /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,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="Item extends ItemBase">
|
|
2
|
-
import type
|
|
3
|
-
import { afterNavigate } from '$app/navigation'
|
|
2
|
+
import { type Snippet, untrack } from 'svelte'
|
|
4
3
|
import {
|
|
5
4
|
context,
|
|
6
5
|
createKeys,
|
|
@@ -35,25 +34,26 @@
|
|
|
35
34
|
onclick?: (item?: Item) => void
|
|
36
35
|
} = $props()
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
KEY_FIELDS_ORDER
|
|
44
|
-
})
|
|
45
|
-
})
|
|
37
|
+
// Posé à l'initialisation et non dans un `$effect`: un effet ne tourne pas au rendu
|
|
38
|
+
// serveur, et `TableFieldsEdition` lirait un contexte vide. `key` identifie la table
|
|
39
|
+
// pour toute sa durée de vie.
|
|
40
|
+
const tableKey = untrack(() => key)
|
|
41
|
+
context.set(tableKey, createKeys(tableKey))
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
// Dérivé, et non écrit dans la prop `fields`: Svelte annule l'écriture locale d'une prop
|
|
44
|
+
// non liée dès que le parent en recalcule la valeur. Un parent qui déclare ses colonnes
|
|
45
|
+
// dans un `$derived` les reproduit à chaque rafraîchissement de `load` — celui que
|
|
46
|
+
// déclenche une remote function, sans navigation — et la table repartait alors sans
|
|
47
|
+
// `_visible`, donc sans une seule colonne. `syncFieldsWithParams` lit `page.url`: le
|
|
48
|
+
// dérivé suit aussi les changements de paramètres, ce dont `afterNavigate` se chargeait.
|
|
49
|
+
const fieldsSynced = $derived(syncFieldsWithParams(tableKey, fields))
|
|
50
50
|
</script>
|
|
51
51
|
|
|
52
|
-
<div class="{klass} overflow-x-auto rounded-
|
|
52
|
+
<div class="{klass} overflow-x-auto rounded-box border bg-base-100" class:min-h-[320px]={!hideBody}>
|
|
53
53
|
<table class="table relative">
|
|
54
|
-
<TableHead {
|
|
54
|
+
<TableHead fields={fieldsSynced} {key} {onCreateField} />
|
|
55
55
|
{#if !hideBody && items.length}
|
|
56
|
-
<TableBody {
|
|
56
|
+
<TableBody fields={fieldsSynced} {items} {actions} {classRow} {onclick} />
|
|
57
57
|
{/if}
|
|
58
58
|
</table>
|
|
59
59
|
|
|
@@ -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,31 +66,28 @@
|
|
|
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
|
-
<div class="
|
|
83
|
+
<div class="flex items-center gap-2 border-b pr-1 pb-1 pl-2">
|
|
85
84
|
<span class=" font-semibold opacity-70">Champs</span>
|
|
86
85
|
<button
|
|
87
86
|
type="button"
|
|
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} />
|
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
order = $bindable(),
|
|
8
8
|
IconAsc = ArrowDownNarrowWideIcon,
|
|
9
9
|
IconDesc = ArrowDownWideNarrowIcon,
|
|
10
|
+
labelAsc = 'Ascendant',
|
|
11
|
+
labelDesc = 'Descendant',
|
|
10
12
|
onChange
|
|
11
13
|
}: {
|
|
12
14
|
order: Order
|
|
13
15
|
IconAsc?: Component<IconProps>
|
|
14
16
|
IconDesc?: Component<IconProps>
|
|
17
|
+
labelAsc?: string
|
|
18
|
+
labelDesc?: string
|
|
15
19
|
onChange?: (order: Order) => void
|
|
16
20
|
} = $props()
|
|
17
21
|
|
|
@@ -22,24 +26,21 @@
|
|
|
22
26
|
}
|
|
23
27
|
</script>
|
|
24
28
|
|
|
25
|
-
<div class="
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
>
|
|
41
|
-
|
|
42
|
-
<span>Descendant</span>
|
|
43
|
-
</button>
|
|
44
|
-
</div>
|
|
29
|
+
<div class="m-2 grid grid-cols-2 gap-1">
|
|
30
|
+
<button
|
|
31
|
+
class="btn ring-primary btn-sm"
|
|
32
|
+
class:ring-2={order === 'asc'}
|
|
33
|
+
onclick={handleOrderClick('asc')}
|
|
34
|
+
>
|
|
35
|
+
<IconAsc size={16} />
|
|
36
|
+
<span>{labelAsc}</span>
|
|
37
|
+
</button>
|
|
38
|
+
<button
|
|
39
|
+
class="btn ring-primary btn-sm"
|
|
40
|
+
class:ring-2={order === 'desc'}
|
|
41
|
+
onclick={handleOrderClick('desc')}
|
|
42
|
+
>
|
|
43
|
+
<IconDesc size={16} />
|
|
44
|
+
<span>{labelDesc}</span>
|
|
45
|
+
</button>
|
|
45
46
|
</div>
|
|
@@ -5,6 +5,8 @@ type $$ComponentProps = {
|
|
|
5
5
|
order: Order;
|
|
6
6
|
IconAsc?: Component<IconProps>;
|
|
7
7
|
IconDesc?: Component<IconProps>;
|
|
8
|
+
labelAsc?: string;
|
|
9
|
+
labelDesc?: string;
|
|
8
10
|
onChange?: (order: Order) => void;
|
|
9
11
|
};
|
|
10
12
|
declare const OrderButtons: Component<$$ComponentProps, {}, "order">;
|
|
@@ -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" />
|
|
@@ -95,56 +90,70 @@
|
|
|
95
90
|
</span>
|
|
96
91
|
{/if}
|
|
97
92
|
{#if order === 'asc'}
|
|
98
|
-
<CalendarArrowDownIcon size={
|
|
93
|
+
<CalendarArrowDownIcon size={15} class="text-primary" />
|
|
99
94
|
{:else if order === 'desc'}
|
|
100
|
-
<CalendarArrowUpIcon size={
|
|
95
|
+
<CalendarArrowUpIcon size={15} class="text-primary" />
|
|
101
96
|
{/if}
|
|
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
|
+
labelAsc="Ancien d'abord"
|
|
111
|
+
labelDesc="Récent d'abord"
|
|
112
|
+
/>
|
|
113
|
+
{/if}
|
|
116
114
|
|
|
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()
|
|
115
|
+
<form
|
|
116
|
+
onsubmit={(e) => {
|
|
117
|
+
e.preventDefault()
|
|
118
|
+
popover.hide()
|
|
132
119
|
}}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
120
|
+
data-sveltekit-replacestate
|
|
121
|
+
class="flex flex-col font-normal"
|
|
122
|
+
class:mt-6={field.sortable !== false}
|
|
123
|
+
>
|
|
124
|
+
<RangePicker
|
|
125
|
+
bind:this={rangePicker}
|
|
126
|
+
numberOfMonths={1}
|
|
127
|
+
onchange={(newRange) => {
|
|
128
|
+
range = newRange
|
|
129
|
+
updateUrl()
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
137
132
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
<div class="m-2 flex gap-2">
|
|
134
|
+
<InputDateTime
|
|
135
|
+
label="À partir de"
|
|
136
|
+
name="start"
|
|
137
|
+
bind:value={range.start}
|
|
138
|
+
class="grow"
|
|
139
|
+
onchange={updateUrl}
|
|
140
|
+
/>
|
|
141
|
+
<InputDateTime
|
|
142
|
+
label="Jusqu'à"
|
|
143
|
+
name="end"
|
|
144
|
+
bind:value={range.end}
|
|
145
|
+
class="grow"
|
|
146
|
+
onchange={updateUrl}
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
143
149
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
<div class="m-2 flex flex-row-reverse gap-2">
|
|
151
|
+
<button class="btn">Ok</button>
|
|
152
|
+
<button class="btn btn-ghost" type="button" onclick={() => handleReset(popover)}>
|
|
153
|
+
Effacer
|
|
154
|
+
</button>
|
|
155
|
+
</div>
|
|
156
|
+
</form>
|
|
157
|
+
{/snippet}
|
|
158
|
+
</Popover>
|
|
150
159
|
</th>
|