fuma 0.5.1 → 1.0.1
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/README.md +1 -1
- package/dist/private/Meta.svelte +32 -27
- package/dist/private/Meta.svelte.d.ts +1 -0
- package/dist/private/api.d.ts +1 -1
- package/dist/ui/badge/Badge.svelte +4 -3
- package/dist/ui/button/ButtonCopy.svelte +32 -26
- package/dist/ui/button/ButtonDelete.svelte +23 -21
- package/dist/ui/button/ButtonDelete.svelte.d.ts +1 -0
- package/dist/ui/card/Card.svelte +13 -10
- package/dist/ui/card/Card.svelte.d.ts +1 -0
- package/dist/ui/card/CardBasic.svelte +5 -4
- package/dist/ui/card/CardBasic.svelte.d.ts +1 -0
- package/dist/ui/card/CardCollapse.svelte +35 -31
- package/dist/ui/card/CardCollapse.svelte.d.ts +1 -0
- package/dist/ui/card/CardFullScreen.svelte +8 -6
- package/dist/ui/card/CardFullScreen.svelte.d.ts +3 -0
- package/dist/ui/card/CardLink.svelte +5 -4
- package/dist/ui/card/CardLink.svelte.d.ts +1 -0
- package/dist/ui/dialog/Dialog.svelte +41 -34
- package/dist/ui/dialog/Dialog.svelte.d.ts +1 -0
- package/dist/ui/dialog/DialogConfirm.svelte +6 -4
- package/dist/ui/dialog/DialogConfirm.svelte.d.ts +1 -0
- package/dist/ui/drawer/Drawer.svelte +47 -38
- package/dist/ui/drawer/Drawer.svelte.d.ts +16 -0
- package/dist/ui/form/Form.svelte +101 -83
- package/dist/ui/form/Form.svelte.d.ts +1 -0
- package/dist/ui/form/FormInput.svelte +12 -6
- package/dist/ui/form/FormInput.svelte.d.ts +30 -8
- package/dist/ui/form/FormSection.svelte +24 -17
- package/dist/ui/form/formInput.d.ts +7 -4
- package/dist/ui/icon/Icon.svelte +35 -32
- package/dist/ui/index.d.ts +0 -1
- package/dist/ui/index.js +0 -1
- package/dist/ui/input/FormControl.svelte +48 -36
- package/dist/ui/input/FormControl.svelte.d.ts +7 -9
- package/dist/ui/input/InputBoolean.svelte +29 -22
- package/dist/ui/input/InputBoolean.svelte.d.ts +5 -1
- package/dist/ui/input/InputCheckboxs.svelte +37 -34
- package/dist/ui/input/InputCheckboxs.svelte.d.ts +5 -1
- package/dist/ui/input/InputCheckboxsMenu.svelte +64 -47
- package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +5 -1
- package/dist/ui/input/InputCheckboxsTree.svelte +9 -6
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte +36 -28
- package/dist/ui/input/InputCombo.svelte +76 -65
- package/dist/ui/input/InputCombo.svelte.d.ts +5 -1
- package/dist/ui/input/InputDate.svelte +36 -29
- package/dist/ui/input/InputDateTime.svelte +37 -30
- package/dist/ui/input/InputImage.svelte +52 -45
- package/dist/ui/input/InputImage.svelte.d.ts +1 -0
- package/dist/ui/input/InputImagePreview.svelte +24 -20
- package/dist/ui/input/InputNumber.svelte +28 -22
- package/dist/ui/input/InputNumber.svelte.d.ts +1 -5
- package/dist/ui/input/InputOptionInParam.svelte +12 -10
- package/dist/ui/input/InputOptions.svelte +40 -34
- package/dist/ui/input/InputPassword.svelte +22 -18
- package/dist/ui/input/InputPassword.svelte.d.ts +5 -1
- package/dist/ui/input/InputRadio.svelte +51 -46
- package/dist/ui/input/InputRadio.svelte.d.ts +5 -1
- package/dist/ui/input/InputRelation.svelte +119 -111
- package/dist/ui/input/InputRelation.svelte.d.ts +6 -12
- package/dist/ui/input/InputRelations.svelte +94 -90
- package/dist/ui/input/InputRelations.svelte.d.ts +5 -12
- package/dist/ui/input/InputSearch.svelte +13 -10
- package/dist/ui/input/InputSelect.svelte +59 -46
- package/dist/ui/input/InputText.svelte +29 -28
- package/dist/ui/input/InputText.svelte.d.ts +0 -3
- package/dist/ui/input/InputTextarea.svelte +20 -19
- package/dist/ui/input/InputTextarea.svelte.d.ts +1 -5
- package/dist/ui/input/InputTime.svelte +43 -35
- package/dist/ui/input/RelationAfter.svelte +13 -9
- package/dist/ui/input/SelectorList.svelte +16 -12
- package/dist/ui/input/SelectorList.svelte.d.ts +4 -0
- package/dist/ui/input/textRich/InputTextRich.svelte +63 -54
- package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +5 -1
- package/dist/ui/input/textRich/SuggesionList.svelte +13 -9
- package/dist/ui/input/textRich/ToolMark.svelte +12 -9
- package/dist/ui/input/textRich/ToolMarkColor.svelte +16 -12
- package/dist/ui/input/textRich/ToolMarkLink.svelte +46 -38
- package/dist/ui/input/textRich/ToolMenu.svelte +34 -19
- package/dist/ui/input/textRich/ToolMenuAlign.svelte +13 -9
- package/dist/ui/input/textRich/ToolMenuInsert.svelte +12 -7
- package/dist/ui/input/textRich/ToolMenuNode.svelte +14 -10
- package/dist/ui/input/textRich/ToolsBar.svelte +17 -13
- package/dist/ui/login/Login.svelte +37 -31
- package/dist/ui/menu/ContextMenu.svelte +37 -31
- package/dist/ui/menu/ContextMenu.svelte.d.ts +1 -0
- package/dist/ui/menu/DropDown.svelte +92 -83
- package/dist/ui/menu/DropDown.svelte.d.ts +1 -0
- package/dist/ui/menu/DropDownMenu.svelte +25 -18
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +1 -0
- package/dist/ui/mode/ToggleMode.svelte +19 -15
- package/dist/ui/mode/ToggleMode.svelte.d.ts +7 -1
- package/dist/ui/pagination/Pagination.svelte +9 -8
- package/dist/ui/placeholder/Placeholder.svelte +4 -3
- package/dist/ui/placeholder/Placeholder.svelte.d.ts +1 -0
- package/dist/ui/placeholder/PlaceholderImage.svelte +6 -4
- package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +1 -0
- package/dist/ui/range/RangePicker.svelte +76 -63
- package/dist/ui/range/RangePickerButton.svelte +43 -35
- package/dist/ui/table/Table.svelte +35 -28
- package/dist/ui/table/TableBody.svelte +18 -12
- package/dist/ui/table/TableCell.svelte +13 -10
- package/dist/ui/table/TableFieldsEdition.svelte +57 -51
- package/dist/ui/table/TableHead.svelte +19 -20
- package/dist/ui/table/TableViewSelect.svelte +50 -37
- package/dist/ui/table/cell/TableCellArray.svelte +5 -3
- package/dist/ui/table/cell/TableCellBoolean.svelte +4 -3
- package/dist/ui/table/cell/TableCellNumber.svelte +2 -1
- package/dist/ui/table/cell/TableCellString.svelte +5 -2
- package/dist/ui/table/head/TableHeadBoolean.svelte +6 -3
- package/dist/ui/table/head/TableHeadDate.svelte +54 -47
- package/dist/ui/table/head/TableHeadDefault.svelte +5 -2
- package/dist/ui/table/head/TableHeadNumber.svelte +65 -53
- package/dist/ui/table/head/TableHeadSelect.svelte +47 -41
- package/dist/ui/table/head/TableHeadString.svelte +14 -8
- package/dist/ui/tabs/Tabs.svelte +8 -5
- package/dist/ui/tabs/TabsIcon.svelte +31 -28
- package/package.json +32 -33
- package/dist/ui/slot/Slot.svelte +0 -35
- package/dist/ui/slot/Slot.svelte.d.ts +0 -22
- package/dist/ui/slot/Span.svelte +0 -4
- package/dist/ui/slot/Span.svelte.d.ts +0 -16
- package/dist/ui/slot/index.d.ts +0 -1
- package/dist/ui/slot/index.js +0 -1
|
@@ -1,54 +1,60 @@
|
|
|
1
|
-
<script generics="Item extends {id: string}">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
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
|
-
|
|
1
|
+
<script lang="ts" generics="Item extends {id: string}">
|
|
2
|
+
import {
|
|
3
|
+
mdiCheck,
|
|
4
|
+
mdiCheckCircleOutline,
|
|
5
|
+
mdiCircleSmall,
|
|
6
|
+
mdiDotsHorizontal,
|
|
7
|
+
mdiDrag,
|
|
8
|
+
mdiPlus
|
|
9
|
+
} from '@mdi/js'
|
|
10
|
+
import type { TippyInstance } from '../../utils/tippy.js'
|
|
11
|
+
import { goto } from '$app/navigation'
|
|
12
|
+
import { page } from '$app/stores'
|
|
13
|
+
import { urlParam } from '../../store/param.js'
|
|
14
|
+
import { listEditable } from '../../action/list/index.js'
|
|
15
|
+
import { jsonParse } from '../../utils/jsonParse.js'
|
|
16
|
+
import { context } from './context.js'
|
|
17
|
+
import { Icon } from '../icon/index.js'
|
|
18
|
+
import { DropDown } from '../menu/index.js'
|
|
19
|
+
import type { TableField } from './index.js'
|
|
20
|
+
|
|
21
|
+
export let fields: TableField<Item>[]
|
|
22
|
+
export let key: string
|
|
23
|
+
export let onCreateField: (() => void) | undefined = undefined
|
|
24
|
+
|
|
25
|
+
let tip: TippyInstance
|
|
26
|
+
|
|
27
|
+
const { KEY_FIELDS_VISIBLE, KEY_FIELDS_HIDDEN, KEY_FIELDS_ORDER } = context.get(key)
|
|
28
|
+
|
|
29
|
+
function getFieldHref(field: TableField) {
|
|
30
|
+
if (field.locked) return
|
|
31
|
+
const url = toggleParam(field.visible ? KEY_FIELDS_HIDDEN : KEY_FIELDS_VISIBLE, field.key)
|
|
32
|
+
if (url.searchParams.has(field.key)) {
|
|
33
|
+
url.searchParams.delete(field.key)
|
|
34
|
+
url.searchParams.delete('skip')
|
|
35
|
+
url.searchParams.delete('take')
|
|
36
|
+
}
|
|
37
|
+
return url.pathname + url.search
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function toggleParam(paramKey: string, fieldKey: string): URL {
|
|
41
|
+
const url = new URL($page.url)
|
|
42
|
+
const fieldsKeys = jsonParse<string[]>($page.url.searchParams.get(paramKey), [])
|
|
43
|
+
if (!fieldsKeys.includes(fieldKey)) fieldsKeys.push(fieldKey)
|
|
44
|
+
else fieldsKeys.splice(fieldsKeys.indexOf(fieldKey), 1)
|
|
45
|
+
|
|
46
|
+
if (fieldsKeys.length) url.searchParams.set(paramKey, JSON.stringify(fieldsKeys))
|
|
47
|
+
else url.searchParams.delete(paramKey)
|
|
48
|
+
|
|
49
|
+
return url
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function handleReorder(newFieldsOrder: TableField<Item>[]) {
|
|
53
|
+
fields = newFieldsOrder
|
|
54
|
+
const fieldsOrder = fields.map((f) => f.key)
|
|
55
|
+
const newUrl = $urlParam.with({ [KEY_FIELDS_ORDER]: JSON.stringify(fieldsOrder) })
|
|
56
|
+
goto(newUrl, { replaceState: true, noScroll: true, keepFocus: true })
|
|
57
|
+
}
|
|
52
58
|
</script>
|
|
53
59
|
|
|
54
60
|
<th class="sticky right-0 z-10 p-0 px-1" align="right">
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
<script generics="Item extends {id: string}">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
1
|
+
<script lang="ts" generics="Item extends {id: string}">
|
|
2
|
+
import { component, type ComponentAndProps } from '../../utils/component.js'
|
|
3
|
+
import { type TableField, TableFieldsEdition } from './index.js'
|
|
4
|
+
import { tableHeadComponent } from './head/index.js'
|
|
5
|
+
import TableHeadDefault from './head/TableHeadDefault.svelte'
|
|
6
|
+
|
|
7
|
+
export let fields: TableField<Item>[]
|
|
8
|
+
export let key: string
|
|
9
|
+
export let onCreateField: (() => void) | undefined = undefined
|
|
10
|
+
|
|
11
|
+
function getComponent(field: TableField): ComponentAndProps {
|
|
12
|
+
if (field.type === 'select' || field.type === 'multiselect')
|
|
13
|
+
return tableHeadComponent(field.type, { options: field.options || [] })(field)
|
|
14
|
+
if (field.type) return tableHeadComponent(field.type, {})(field)
|
|
15
|
+
if (!field.head) return component(TableHeadDefault, { field })
|
|
16
|
+
if (typeof field.head === 'function') return field.head(field)
|
|
17
|
+
if (typeof field.head === 'string') return tableHeadComponent(field.head, {})(field)
|
|
18
|
+
return field.head
|
|
19
|
+
}
|
|
21
20
|
</script>
|
|
22
21
|
|
|
23
22
|
<thead>
|
|
@@ -1,40 +1,53 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
let
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import { mdiChevronDown, mdiContentSaveEditOutline, mdiPlus } from '@mdi/js'
|
|
4
|
+
import { page } from '$app/stores'
|
|
5
|
+
import { enhance } from '$app/forms'
|
|
6
|
+
|
|
7
|
+
import { Icon } from '../icon/index.js'
|
|
8
|
+
import { Dialog } from '../dialog/index.js'
|
|
9
|
+
import { DropDown } from '../menu/index.js'
|
|
10
|
+
import { InputText } from '../input/index.js'
|
|
11
|
+
import { useForm } from '../../validation/form.js'
|
|
12
|
+
|
|
13
|
+
type View = {
|
|
14
|
+
id: string
|
|
15
|
+
name: string
|
|
16
|
+
query: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export let key: string
|
|
20
|
+
export let views: View[]
|
|
21
|
+
export let action = ''
|
|
22
|
+
export let actionCreate = '?/view_create'
|
|
23
|
+
export let actionUpdate = '?/view_update'
|
|
24
|
+
export let actionDelete = '?/view_delete'
|
|
25
|
+
|
|
26
|
+
let dialog: HTMLDialogElement
|
|
27
|
+
const form = useForm({
|
|
28
|
+
onSuccess() {
|
|
29
|
+
dialog.close()
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
let query = getQuery($page.url)
|
|
34
|
+
let selectedView = views.find((v) => v.query === query)
|
|
35
|
+
let isNewView = !!query && !selectedView
|
|
36
|
+
|
|
37
|
+
onMount(() =>
|
|
38
|
+
page.subscribe(({ url }) => {
|
|
39
|
+
query = getQuery(url)
|
|
40
|
+
selectedView = views.find((v) => v.query === query)
|
|
41
|
+
isNewView = !!query && !selectedView
|
|
42
|
+
})
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
function getQuery({ searchParams }: URL) {
|
|
46
|
+
const searchParam = new URLSearchParams(searchParams)
|
|
47
|
+
searchParam.delete('skip')
|
|
48
|
+
searchParam.delete('take')
|
|
49
|
+
return searchParam.toString()
|
|
50
|
+
}
|
|
38
51
|
</script>
|
|
39
52
|
|
|
40
53
|
<DropDown>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Badge } from '../../badge/index.js'
|
|
3
|
+
import { component, type ComponentAndProps } from '../../../utils/component.js'
|
|
4
|
+
|
|
5
|
+
export let value: (ComponentAndProps | string | number | boolean)[]
|
|
4
6
|
</script>
|
|
5
7
|
|
|
6
8
|
<td>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { mdiCheck, mdiClose } from '@mdi/js'
|
|
3
|
+
import { Icon } from '../../icon/index.js'
|
|
4
|
+
export let value: boolean
|
|
4
5
|
</script>
|
|
5
6
|
|
|
6
7
|
<td>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TableField } from '../index.js'
|
|
3
|
+
|
|
4
|
+
export let value: string
|
|
5
|
+
export let field: TableField
|
|
3
6
|
</script>
|
|
4
7
|
|
|
5
8
|
<td data-field-key={field.key} data-field-type={field.type === 'textarea' ? 'textarea' : 'string'}>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { mdiCheck, mdiClose } from '@mdi/js'
|
|
3
|
+
import type { TableField } from '../index.js'
|
|
4
|
+
import TableHeadSelect from './TableHeadSelect.svelte'
|
|
5
|
+
|
|
6
|
+
export let field: TableField
|
|
4
7
|
</script>
|
|
5
8
|
|
|
6
9
|
<TableHeadSelect
|
|
@@ -1,50 +1,57 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let
|
|
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
|
-
}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { goto } from '$app/navigation'
|
|
3
|
+
import { page } from '$app/stores'
|
|
4
|
+
import { mdiCalendarFilterOutline } from '@mdi/js'
|
|
5
|
+
|
|
6
|
+
import { DropDown } from '../../menu/index.js'
|
|
7
|
+
import { InputTime } from '../../input/index.js'
|
|
8
|
+
import type { TableField } from '../index.js'
|
|
9
|
+
import { formatRange } from '../../range/format.js'
|
|
10
|
+
import { RangePicker } from '../../range/index.js'
|
|
11
|
+
import { urlParam } from '../../../store/param.js'
|
|
12
|
+
import { jsonParse } from '../../../utils/jsonParse.js'
|
|
13
|
+
import { Icon } from '../../icon/index.js'
|
|
14
|
+
|
|
15
|
+
export let field: Omit<TableField, 'getCell' | 'type'>
|
|
16
|
+
|
|
17
|
+
let dropDown: DropDown
|
|
18
|
+
let rangePicker: RangePicker
|
|
19
|
+
const initialValue = jsonParse<{ start?: string; end?: string }>(
|
|
20
|
+
$page.url.searchParams.get(field.key),
|
|
21
|
+
{}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
let range = {
|
|
25
|
+
start: initialValue.start ? new Date(initialValue.start) : null,
|
|
26
|
+
end: initialValue.end ? new Date(initialValue.end) : null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$: isValidPeriod = !!range.start && !!range.end
|
|
30
|
+
|
|
31
|
+
function handleSubmit() {
|
|
32
|
+
dropDown.hide()
|
|
33
|
+
if (!isValidPeriod) return
|
|
34
|
+
goto(
|
|
35
|
+
$urlParam.with(
|
|
36
|
+
{
|
|
37
|
+
[field.key]: JSON.stringify({
|
|
38
|
+
start: range.start?.toJSON(),
|
|
39
|
+
end: range.end?.toJSON()
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
'skip',
|
|
43
|
+
'take'
|
|
44
|
+
),
|
|
45
|
+
{ replaceState: true, noScroll: true }
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleReset() {
|
|
50
|
+
dropDown.hide()
|
|
51
|
+
range = { start: null, end: null }
|
|
52
|
+
rangePicker.clear()
|
|
53
|
+
goto($urlParam.without(field.key, 'skip', 'take'), { replaceState: true, noScroll: true })
|
|
54
|
+
}
|
|
48
55
|
</script>
|
|
49
56
|
|
|
50
57
|
<th class="p-1">
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TableField } from '../index.js'
|
|
3
|
+
import { tip } from '../../../action/tip.js'
|
|
4
|
+
|
|
5
|
+
export let field: TableField
|
|
3
6
|
</script>
|
|
4
7
|
|
|
5
8
|
<th use:tip={{ disable: !field.hint, content: field.hint }}>
|
|
@@ -1,56 +1,68 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import type { TippyInstance } from '../../../utils/tippy.js'
|
|
4
|
+
import debounce from 'debounce'
|
|
5
|
+
import { goto } from '$app/navigation'
|
|
6
|
+
import { page } from '$app/stores'
|
|
7
|
+
|
|
8
|
+
import { DropDown } from '../../menu/index.js'
|
|
9
|
+
import { InputNumber } from '../../input/index.js'
|
|
10
|
+
import { urlParam } from '../../../store/param.js'
|
|
11
|
+
import { jsonParse } from '../../../utils/jsonParse.js'
|
|
12
|
+
import type { TableField } from '../field.js'
|
|
13
|
+
import { mdiFilterMultipleOutline } from '@mdi/js'
|
|
14
|
+
import { Icon } from '../../icon/index.js'
|
|
15
|
+
|
|
16
|
+
export let field: TableField
|
|
17
|
+
|
|
18
|
+
let tip: TippyInstance
|
|
19
|
+
type Range = { min: number | undefined; max: number | undefined }
|
|
20
|
+
|
|
21
|
+
let { min, max } = initRange($page.url)
|
|
22
|
+
onMount(() => page.subscribe(({ url }) => ({ min, max } = initRange(url))))
|
|
23
|
+
|
|
24
|
+
function initRange({ searchParams }: URL) {
|
|
25
|
+
return jsonParse<Range>(searchParams.get(field.key), {
|
|
26
|
+
min: undefined,
|
|
27
|
+
max: undefined
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const udpateUrl = debounce(() => {
|
|
32
|
+
if (isDefined(min) || isDefined(max)) {
|
|
33
|
+
goto(
|
|
34
|
+
$urlParam.with(
|
|
35
|
+
{
|
|
36
|
+
[field.key]: JSON.stringify({
|
|
37
|
+
...(isDefined(min) ? { min } : {}),
|
|
38
|
+
...(isDefined(max) ? { max } : {})
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
'skip',
|
|
42
|
+
'take'
|
|
43
|
+
),
|
|
44
|
+
{
|
|
45
|
+
noScroll: true,
|
|
46
|
+
keepFocus: true
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
goto($urlParam.without(field.key, 'skip', 'take'), { noScroll: true, keepFocus: true })
|
|
52
|
+
}, 250)
|
|
53
|
+
|
|
54
|
+
function handleReset() {
|
|
55
|
+
min = undefined
|
|
56
|
+
max = undefined
|
|
57
|
+
tip.hide()
|
|
58
|
+
goto($urlParam.without(field.key, 'skip', 'take'), { noScroll: true, keepFocus: true })
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isDefined(v: number | undefined | null): v is number {
|
|
62
|
+
return typeof v === 'number'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
$: isNegatifRange = isDefined(min) && isDefined(max) && max < min
|
|
54
66
|
</script>
|
|
55
67
|
|
|
56
68
|
<th class="p-1">
|