firstly 0.0.12 → 0.0.14
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/CHANGELOG.md +16 -0
- package/esm/ROUTES.d.ts +2 -0
- package/esm/ROUTES.js +1 -0
- package/esm/api/index.d.ts +9 -0
- package/esm/api/index.js +3 -1
- package/esm/auth/AuthController.d.ts +12 -23
- package/esm/auth/AuthController.js +12 -31
- package/esm/auth/server/AuthController.server.d.ts +11 -11
- package/esm/auth/server/AuthController.server.js +99 -34
- package/esm/auth/server/handleGuard.d.ts +16 -0
- package/esm/auth/server/handleGuard.js +67 -0
- package/esm/auth/server/helperFirstly.d.ts +1 -1
- package/esm/auth/server/helperFirstly.js +1 -0
- package/esm/auth/server/index.d.ts +3 -1
- package/esm/auth/server/index.js +3 -1
- package/esm/auth/server/module.d.ts +105 -89
- package/esm/auth/server/module.js +55 -42
- package/esm/auth/server/providers/github.d.ts +4 -2
- package/esm/auth/server/providers/github.js +2 -2
- package/esm/auth/static/assets/Page-B0XXxe0N.d.ts +6 -0
- package/esm/auth/static/assets/Page-B0XXxe0N.js +1 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.d.ts +6 -0
- package/esm/auth/static/assets/Page-DdKMiUZn.js +20 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.d.ts +6 -0
- package/esm/auth/static/assets/Page-UV_hqY7I.js +1 -0
- package/esm/auth/static/assets/Page-mK42zGEw.css +1 -0
- package/esm/auth/static/assets/index-C9jzxOBu.d.ts +151 -0
- package/esm/auth/static/assets/index-C9jzxOBu.js +42 -0
- package/esm/auth/static/assets/index-DKWpA6v7.css +4 -0
- package/esm/auth/static/index.html +11 -11
- package/esm/auth/types.d.ts +26 -3
- package/esm/bin/cmd.js +423 -152
- package/esm/cellsBuildor.js +1 -1
- package/esm/common.d.ts +5 -0
- package/esm/common.js +8 -0
- package/esm/cron/server/index.js +1 -1
- package/esm/feedback/FeedbackController.js +58 -53
- package/esm/feedback/server/index.d.ts +6 -15
- package/esm/feedback/server/index.js +4 -5
- package/esm/feedback/types.d.ts +14 -0
- package/esm/feedback/types.js +4 -0
- package/esm/feedback/ui/DialogIssue.svelte +131 -119
- package/esm/feedback/ui/DialogIssue.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogIssues.svelte +108 -99
- package/esm/feedback/ui/DialogIssues.svelte.d.ts +20 -18
- package/esm/feedback/ui/DialogMilestones.svelte +40 -34
- package/esm/feedback/ui/DialogMilestones.svelte.d.ts +18 -16
- package/esm/feedback/ui/Feedback.svelte +11 -9
- package/esm/feedback/ui/Feedback.svelte.d.ts +16 -14
- package/esm/index.d.ts +2 -5
- package/esm/index.js +2 -8
- package/esm/mail/server/index.d.ts +9 -2
- package/esm/mail/server/index.js +3 -1
- package/esm/mail/templates/DefaultMail.svelte +81 -61
- package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -26
- package/esm/server/index.d.ts +0 -0
- package/esm/server/index.js +1 -0
- package/esm/storeItem.d.ts +1 -4
- package/esm/storeItem.js +1 -1
- package/esm/storeList.d.ts +1 -4
- package/esm/sveltekit/server/index.d.ts +3 -9
- package/esm/sveltekit/server/index.js +3 -0
- package/esm/ui/Button.svelte +112 -89
- package/esm/ui/Button.svelte.d.ts +34 -24
- package/esm/ui/Clipboardable.svelte +24 -17
- package/esm/ui/Clipboardable.svelte.d.ts +34 -23
- package/esm/ui/Field.svelte +328 -285
- package/esm/ui/Field.svelte.d.ts +15 -8
- package/esm/ui/FieldGroup.svelte +112 -91
- package/esm/ui/FieldGroup.svelte.d.ts +17 -6
- package/esm/ui/Grid.svelte +322 -308
- package/esm/ui/Grid.svelte.d.ts +17 -6
- package/esm/ui/GridLoading.svelte +28 -27
- package/esm/ui/GridLoading.svelte.d.ts +19 -17
- package/esm/ui/GridPaginate.svelte +68 -61
- package/esm/ui/GridPaginate.svelte.d.ts +21 -19
- package/esm/ui/Icon.svelte +116 -80
- package/esm/ui/Icon.svelte.d.ts +52 -43
- package/esm/ui/Loading.svelte +10 -8
- package/esm/ui/Loading.svelte.d.ts +29 -18
- package/esm/ui/Tooltip.svelte +38 -35
- package/esm/ui/Tooltip.svelte.d.ts +30 -20
- package/esm/ui/dialog/DialogForm.svelte +70 -63
- package/esm/ui/dialog/DialogForm.svelte.d.ts +18 -16
- package/esm/ui/dialog/DialogManagement.svelte +74 -74
- package/esm/ui/dialog/DialogManagement.svelte.d.ts +22 -21
- package/esm/ui/dialog/DialogPrimitive.svelte +82 -76
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +35 -25
- package/esm/ui/dialog/FormEditAction.svelte +58 -50
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +13 -6
- package/esm/ui/dialog/dialog.d.ts +1 -4
- package/esm/ui/internals/FieldContainer.svelte +24 -17
- package/esm/ui/internals/FieldContainer.svelte.d.ts +37 -28
- package/esm/ui/internals/Input.svelte +136 -102
- package/esm/ui/internals/Input.svelte.d.ts +34 -32
- package/esm/ui/internals/Textarea.svelte +60 -52
- package/esm/ui/internals/Textarea.svelte.d.ts +31 -28
- package/esm/ui/internals/select/MultiSelectMelt.svelte +243 -199
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +29 -27
- package/esm/ui/internals/select/SelectMelt.svelte +254 -219
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +34 -32
- package/esm/ui/internals/select/SelectRadio.svelte +39 -33
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +24 -22
- package/esm/ui/link/Link.svelte +25 -20
- package/esm/ui/link/Link.svelte.d.ts +31 -23
- package/esm/ui/link/LinkPlus.svelte +52 -51
- package/esm/ui/link/LinkPlus.svelte.d.ts +20 -18
- package/esm/vite/index.d.ts +2 -3
- package/esm/vite/index.js +33 -26
- package/package.json +16 -20
- package/esm/auth/static/assets/Page-Bb8bFlrP.d.ts +0 -4
- package/esm/auth/static/assets/Page-Bb8bFlrP.js +0 -1
- package/esm/auth/static/assets/Page-BxomFlZ8.d.ts +0 -4
- package/esm/auth/static/assets/Page-BxomFlZ8.js +0 -1
- package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +0 -6
- package/esm/auth/static/assets/Page-CaIYu0-y.js +0 -19
- package/esm/auth/static/assets/Page-MkYglNtu.css +0 -1
- package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +0 -64
- package/esm/auth/static/assets/index-Bl0Bk5u0.js +0 -2
- package/esm/auth/static/assets/index-R27C_TlP.css +0 -4
|
@@ -1,234 +1,269 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
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
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createCombobox, createSync, type ComboboxOptionProps } from '@melt-ui/svelte'
|
|
3
|
+
import { createEventDispatcher, onMount, tick } from 'svelte'
|
|
4
|
+
import { fly } from 'svelte/transition'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Button,
|
|
8
|
+
LibIcon_Check,
|
|
9
|
+
LibIcon_Cross,
|
|
10
|
+
LibIcon_Search,
|
|
11
|
+
tw,
|
|
12
|
+
type BaseItem,
|
|
13
|
+
type FF_Icon,
|
|
14
|
+
} from '../../../'
|
|
15
|
+
import Icon from '../../Icon.svelte'
|
|
16
|
+
|
|
17
|
+
export let id: string
|
|
18
|
+
export let disabled: boolean = false
|
|
19
|
+
export let placeholder: string = ''
|
|
20
|
+
export let items: BaseItem[] = []
|
|
21
|
+
let totalCount: number | undefined = undefined
|
|
22
|
+
|
|
23
|
+
export let focus: boolean = false
|
|
24
|
+
const focusNow = (node: any) => {
|
|
25
|
+
if (focus) {
|
|
26
|
+
tick().then(() => {
|
|
27
|
+
node.focus()
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export let loadOptions:
|
|
33
|
+
| ((str: string) => Promise<{ items: BaseItem[]; totalCount: number }>)
|
|
34
|
+
| undefined = undefined
|
|
35
|
+
export let value: string | undefined = undefined
|
|
36
|
+
export let clearable = false
|
|
37
|
+
export let createOptionWhenNoResult = false
|
|
38
|
+
export let default_select_if_one_item = false
|
|
39
|
+
|
|
40
|
+
const dispatch = createEventDispatcher()
|
|
41
|
+
|
|
42
|
+
function dispatchSelectedValue(_data: BaseItem | undefined) {
|
|
43
|
+
dispatch('selected', _data)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function dispatchIssue(msg: 'VALUE_NOT_IN_ITEMS') {
|
|
47
|
+
dispatch('issue', msg)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function dispatchCreateRequest(e: any, input: string) {
|
|
51
|
+
e.preventDefault()
|
|
52
|
+
dispatch('createRequest', input)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let lastSearch: string | undefined = undefined
|
|
56
|
+
const localLoadOptions = async (str: string) => {
|
|
57
|
+
if (str === lastSearch) {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
lastSearch = str
|
|
61
|
+
if (loadOptions) {
|
|
62
|
+
const lo = await loadOptions(str)
|
|
63
|
+
items = lo.items
|
|
64
|
+
totalCount = lo.totalCount
|
|
65
|
+
filteredItems = items
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
onMount(async () => {
|
|
70
|
+
localLoadOptions('')
|
|
71
|
+
|
|
72
|
+
// after we load items
|
|
73
|
+
sync.selected(getDefaultValue(value))
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const getDefaultValue = (_selectedValue: string | undefined) => {
|
|
77
|
+
if (!items) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
const found = items.find((c) => String(c?.id) === String(_selectedValue))
|
|
81
|
+
if (found) {
|
|
82
|
+
return toOption(found)
|
|
83
|
+
} else {
|
|
84
|
+
if (value !== null && value !== undefined && items.length > 0) {
|
|
85
|
+
dispatchIssue('VALUE_NOT_IN_ITEMS')
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const toOption = (
|
|
91
|
+
item: BaseItem,
|
|
92
|
+
): ComboboxOptionProps<BaseItem> & {
|
|
93
|
+
icon?: FF_Icon
|
|
94
|
+
} => ({
|
|
95
|
+
value: item,
|
|
96
|
+
label: item.caption,
|
|
97
|
+
// icon: item.icon,
|
|
98
|
+
// disabled: item.disabled,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
elements: { menu, input, option },
|
|
103
|
+
states: { open, inputValue, touchedInput, selected: localSelected },
|
|
104
|
+
// helpers: { isSelected },
|
|
105
|
+
} = createCombobox<BaseItem>({
|
|
106
|
+
forceVisible: true,
|
|
107
|
+
disabled,
|
|
108
|
+
ids: { label: id },
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const clearSelection = () => {
|
|
112
|
+
sync.selected(undefined)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let debounceTimer: ReturnType<typeof setTimeout>
|
|
116
|
+
const debounce = (callback: () => void) => {
|
|
117
|
+
clearTimeout(debounceTimer)
|
|
118
|
+
debounceTimer = setTimeout(
|
|
119
|
+
callback,
|
|
120
|
+
// debounce only if we have a load option
|
|
121
|
+
loadOptions ? 444 : 0,
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const sync = createSync({ selected: localSelected })
|
|
126
|
+
$: items &&
|
|
127
|
+
sync.selected(getDefaultValue(value), (v) => {
|
|
128
|
+
// Only if different
|
|
129
|
+
if (v?.value?.id !== value) {
|
|
130
|
+
dispatchSelectedValue(v?.value)
|
|
131
|
+
}
|
|
132
|
+
value = v?.value?.id
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
$: if (!$open) {
|
|
136
|
+
$inputValue = $localSelected?.label ?? ''
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
$: filteredItems = items
|
|
140
|
+
|
|
141
|
+
$: {
|
|
142
|
+
if (items.length === 1 && default_select_if_one_item) {
|
|
143
|
+
sync.selected(toOption(items[0]))
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const calcFilteredItems = (touched: boolean, str: string, value: any) => {
|
|
148
|
+
if (touched) {
|
|
149
|
+
debounce(async () => {
|
|
150
|
+
const normalizedInput = str.toLowerCase()
|
|
151
|
+
updateFilteredItems(normalizedInput)
|
|
152
|
+
})
|
|
153
|
+
} else {
|
|
154
|
+
updateFilteredItems('')
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const updateFilteredItems = async (normalizedInput: string) => {
|
|
159
|
+
if (loadOptions) {
|
|
160
|
+
await localLoadOptions(normalizedInput)
|
|
161
|
+
} else {
|
|
162
|
+
filteredItems = items.filter((item) => {
|
|
163
|
+
return item.caption?.toLowerCase().includes(normalizedInput)
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
$: calcFilteredItems($touchedInput, $inputValue, value)
|
|
134
169
|
</script>
|
|
135
170
|
|
|
136
171
|
<div class="input input-bordered flex min-w-0 items-center {disabled && 'opacity-40'}">
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
<div class="relative">
|
|
173
|
+
{#if $localSelected?.value?.icon?.data}
|
|
174
|
+
<Icon
|
|
175
|
+
data={$localSelected.value.icon.data}
|
|
176
|
+
class={tw(['relative', $localSelected.value.icon.class])}
|
|
177
|
+
style={$localSelected.value.icon.style}
|
|
178
|
+
size={$localSelected.value.icon.size}
|
|
179
|
+
></Icon>
|
|
180
|
+
{:else}
|
|
181
|
+
<Icon data={LibIcon_Search} class="relative"></Icon>
|
|
182
|
+
{/if}
|
|
183
|
+
</div>
|
|
184
|
+
<!-- {id} -->
|
|
185
|
+
<input
|
|
186
|
+
{...$input}
|
|
187
|
+
use:$input.action
|
|
188
|
+
class="-ml-8 -mr-5 h-full min-w-0 flex-grow bg-transparent px-10"
|
|
189
|
+
{placeholder}
|
|
190
|
+
use:focusNow
|
|
191
|
+
/>
|
|
192
|
+
<div class="pointer-events-none relative right-0 flex gap-2">
|
|
193
|
+
{#if clearable && $localSelected}
|
|
194
|
+
<button on:click={clearSelection} class="pointer-events-auto">
|
|
195
|
+
<Icon data={LibIcon_Cross}></Icon>
|
|
196
|
+
</button>
|
|
197
|
+
{/if}
|
|
198
|
+
<!-- {#if $open}
|
|
164
199
|
<Icon data={LibIcon_ChevronUp}></Icon>
|
|
165
200
|
{:else}
|
|
166
201
|
<Icon data={LibIcon_ChevronDown}></Icon>
|
|
167
202
|
{/if} -->
|
|
168
|
-
|
|
203
|
+
</div>
|
|
169
204
|
</div>
|
|
170
205
|
|
|
171
206
|
{#if $open}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
207
|
+
<ul
|
|
208
|
+
class="border-base-content/20 z-50 flex max-h-[300px] flex-col overflow-hidden rounded-lg border"
|
|
209
|
+
{...$menu}
|
|
210
|
+
use:$menu.action
|
|
211
|
+
transition:fly={{ duration: 150, y: -5 }}
|
|
212
|
+
>
|
|
213
|
+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
214
|
+
<div class="bg-base-100 flex max-h-full flex-col gap-0 overflow-y-auto py-2" tabindex="0">
|
|
215
|
+
{#each filteredItems as item, index (index)}
|
|
216
|
+
<li
|
|
217
|
+
{...$option(toOption(item))}
|
|
218
|
+
use:$option.action
|
|
219
|
+
class="data-[highlighted]:bg-primary data-[highlighted]:text-primary-content relative flex cursor-pointer scroll-my-2 items-center
|
|
185
220
|
rounded-md
|
|
186
221
|
px-1
|
|
187
222
|
py-2
|
|
188
223
|
data-[disabled]:opacity-50"
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
>
|
|
225
|
+
{#if $localSelected?.value?.id === item.id}
|
|
226
|
+
<Icon data={LibIcon_Check} class="w-6"></Icon>
|
|
227
|
+
{:else}
|
|
228
|
+
<!-- just to book the place -->
|
|
229
|
+
<span class="w-6"></span>
|
|
230
|
+
{/if}
|
|
231
|
+
{#if item.icon?.data}
|
|
232
|
+
<Icon
|
|
233
|
+
data={item.icon.data}
|
|
234
|
+
class={tw(['flex-shrink-0', item.icon.class])}
|
|
235
|
+
style={item.icon.style}
|
|
236
|
+
size={item.icon.size}
|
|
237
|
+
></Icon>
|
|
238
|
+
{/if}
|
|
239
|
+
<div class="pl-2">
|
|
240
|
+
<span class="font-medium">{item.caption}</span>
|
|
241
|
+
</div>
|
|
242
|
+
</li>
|
|
243
|
+
{:else}
|
|
244
|
+
{#if createOptionWhenNoResult}
|
|
245
|
+
<div class="p-4">
|
|
246
|
+
<Button
|
|
247
|
+
class="w-full"
|
|
248
|
+
on:click={(e) => {
|
|
249
|
+
dispatchCreateRequest(e, $inputValue)
|
|
250
|
+
}}>Créer "{$inputValue}"</Button
|
|
251
|
+
>
|
|
252
|
+
</div>
|
|
253
|
+
{:else}
|
|
254
|
+
<li class="relative cursor-pointer rounded-md py-1 pl-8 pr-4">Aucun résultat</li>
|
|
255
|
+
{/if}
|
|
256
|
+
{/each}
|
|
257
|
+
</div>
|
|
258
|
+
{#if totalCount}
|
|
259
|
+
<div class="bg-base-300 z-50 text-center text-xs">
|
|
260
|
+
{#if items.length < totalCount}
|
|
261
|
+
({items.length} / {totalCount})
|
|
262
|
+
{:else}
|
|
263
|
+
<!-- yes, items.length can be bigger if the selected item is not in the limit -->
|
|
264
|
+
({items.length})
|
|
265
|
+
{/if}
|
|
266
|
+
</div>
|
|
267
|
+
{/if}
|
|
268
|
+
</ul>
|
|
234
269
|
{/if}
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import { type BaseItem } from '../../../';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}>) | undefined;
|
|
14
|
-
value?: string | undefined;
|
|
15
|
-
clearable?: boolean;
|
|
16
|
-
createOptionWhenNoResult?: boolean;
|
|
17
|
-
default_select_if_one_item?: boolean;
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
18
12
|
};
|
|
19
|
-
|
|
20
|
-
selected: CustomEvent<any>;
|
|
21
|
-
issue: CustomEvent<any>;
|
|
22
|
-
createRequest: CustomEvent<any>;
|
|
23
|
-
} & {
|
|
24
|
-
[evt: string]: CustomEvent<any>;
|
|
25
|
-
};
|
|
26
|
-
slots: {};
|
|
27
|
-
exports?: {} | undefined;
|
|
28
|
-
bindings?: string | undefined;
|
|
29
|
-
};
|
|
30
|
-
export type SelectMeltProps = typeof __propDef.props;
|
|
31
|
-
export type SelectMeltEvents = typeof __propDef.events;
|
|
32
|
-
export type SelectMeltSlots = typeof __propDef.slots;
|
|
33
|
-
export default class SelectMelt extends SvelteComponent<SelectMeltProps, SelectMeltEvents, SelectMeltSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
34
14
|
}
|
|
35
|
-
|
|
15
|
+
declare const SelectMelt: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
id: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
items?: BaseItem[];
|
|
20
|
+
focus?: boolean;
|
|
21
|
+
loadOptions?: ((str: string) => Promise<{
|
|
22
|
+
items: BaseItem[];
|
|
23
|
+
totalCount: number;
|
|
24
|
+
}>) | undefined;
|
|
25
|
+
value?: string | undefined;
|
|
26
|
+
clearable?: boolean;
|
|
27
|
+
createOptionWhenNoResult?: boolean;
|
|
28
|
+
default_select_if_one_item?: boolean;
|
|
29
|
+
}, {
|
|
30
|
+
selected: CustomEvent<any>;
|
|
31
|
+
issue: CustomEvent<any>;
|
|
32
|
+
createRequest: CustomEvent<any>;
|
|
33
|
+
} & {
|
|
34
|
+
[evt: string]: CustomEvent<any>;
|
|
35
|
+
}, {}, {}, string>;
|
|
36
|
+
type SelectMelt = InstanceType<typeof SelectMelt>;
|
|
37
|
+
export default SelectMelt;
|
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from 'svelte'
|
|
3
|
+
|
|
4
|
+
import type { BaseItem } from '../../../'
|
|
5
|
+
import Icon from '../../../ui/Icon.svelte'
|
|
6
|
+
|
|
7
|
+
export let id: string
|
|
8
|
+
export let disabled: boolean = false
|
|
9
|
+
export let placeholder: string = ''
|
|
10
|
+
export let items: BaseItem[] = []
|
|
11
|
+
export let value: string | number | undefined = undefined
|
|
12
|
+
|
|
13
|
+
const dispatch = createEventDispatcher()
|
|
14
|
+
|
|
15
|
+
function dispatchSelected(_data: BaseItem | undefined) {
|
|
16
|
+
dispatch('selected', _data)
|
|
17
|
+
}
|
|
12
18
|
</script>
|
|
13
19
|
|
|
14
20
|
<div {id} class="input input-bordered flex w-fit min-w-0 items-center">
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
<div class="-mx-2 flex gap-2" title={placeholder}>
|
|
22
|
+
{#each items as item}
|
|
23
|
+
<button
|
|
24
|
+
{disabled}
|
|
25
|
+
on:click={() => {
|
|
26
|
+
value = item.id
|
|
27
|
+
dispatchSelected(items.find((i) => i.id === item.id))
|
|
28
|
+
}}
|
|
29
|
+
type="button"
|
|
30
|
+
class="min-w-0 cursor-pointer rounded-md px-1.5 py-1 {value === item.id
|
|
31
|
+
? 'bg-primary text-primary-content'
|
|
32
|
+
: ''}"
|
|
33
|
+
>
|
|
34
|
+
<div class="flex gap-2">
|
|
35
|
+
{#if item.icon}
|
|
36
|
+
<Icon {...item.icon} />
|
|
37
|
+
{/if}
|
|
38
|
+
{item.caption}
|
|
39
|
+
</div>
|
|
40
|
+
</button>
|
|
41
|
+
{/each}
|
|
42
|
+
</div>
|
|
37
43
|
</div>
|