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,55 +1,68 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher, onMount } from 'svelte'
|
|
3
|
+
import { mdiUnfoldMoreHorizontal } from '@mdi/js'
|
|
4
|
+
|
|
5
|
+
import { Icon } from '../icon/index.js'
|
|
6
|
+
import { DropDown } from '../menu/index.js'
|
|
7
|
+
import { SelectorList, FormControl, type InputProps } from './index.js'
|
|
8
|
+
|
|
9
|
+
import { type Options, parseOptions } from '../../utils/options.js'
|
|
10
|
+
import type { TippyProps } from '../../utils/tippy.js'
|
|
11
|
+
|
|
12
|
+
type $$Props = Omit<InputProps, 'input' | 'inputElement'> & {
|
|
13
|
+
options: Options
|
|
14
|
+
tippyProps?: TippyProps
|
|
15
|
+
placeholder?: string
|
|
16
|
+
}
|
|
17
|
+
$: ({ value: _value, options, tippyProps, placeholder, ...props } = $$props as $$Props)
|
|
18
|
+
export let value = _value
|
|
19
|
+
|
|
20
|
+
$: _options = parseOptions(options)
|
|
21
|
+
$: selectedOption = _options.find((opt) => opt.value === value)
|
|
22
|
+
|
|
23
|
+
let dropDown: DropDown
|
|
24
|
+
let button: HTMLButtonElement
|
|
25
|
+
const dispatch = createEventDispatcher<{ input: string; select: string }>()
|
|
26
|
+
|
|
27
|
+
let focusIndex = 0
|
|
28
|
+
onMount(() => {
|
|
29
|
+
const index = _options.findIndex((opt) => opt.value === value)
|
|
30
|
+
focusIndex = index === -1 ? 0 : index
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
function onSelect(index: number) {
|
|
34
|
+
focusIndex = index
|
|
35
|
+
value = _options[index].value
|
|
36
|
+
dispatch('input', value)
|
|
37
|
+
dispatch('select', value)
|
|
38
|
+
dropDown.hide()
|
|
39
|
+
}
|
|
29
40
|
</script>
|
|
30
41
|
|
|
31
42
|
<DropDown bind:this={dropDown}>
|
|
32
43
|
<svelte:fragment slot="activator">
|
|
33
|
-
<FormControl {...props}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{#if selectedOption
|
|
42
|
-
|
|
44
|
+
<FormControl {...props}>
|
|
45
|
+
{#snippet children({ key })}
|
|
46
|
+
<button
|
|
47
|
+
bind:this={button}
|
|
48
|
+
id={key}
|
|
49
|
+
type="button"
|
|
50
|
+
class="input-bordered flex h-12 items-center gap-2 rounded-lg border pl-4 pr-2 hover:bg-base-200/50"
|
|
51
|
+
>
|
|
52
|
+
{#if selectedOption}
|
|
53
|
+
{#if selectedOption.icon}
|
|
54
|
+
<Icon path={selectedOption.icon} size={21} class="opacity-70" />
|
|
55
|
+
{/if}
|
|
56
|
+
<span>{selectedOption.label}</span>
|
|
57
|
+
{:else if placeholder}
|
|
58
|
+
<span class="opacity-60">{placeholder}</span>
|
|
43
59
|
{/if}
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
<Icon class="ml-auto" path={mdiUnfoldMoreHorizontal} size={18} />
|
|
61
|
+
</button>
|
|
62
|
+
{#if value !== undefined}
|
|
63
|
+
<input type="hidden" name={key} {value} />
|
|
47
64
|
{/if}
|
|
48
|
-
|
|
49
|
-
</button>
|
|
50
|
-
{#if value !== undefined}
|
|
51
|
-
<input type="hidden" name={key} {value} />
|
|
52
|
-
{/if}
|
|
65
|
+
{/snippet}
|
|
53
66
|
</FormControl>
|
|
54
67
|
</svelte:fragment>
|
|
55
68
|
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { FormControl, bindValueWithParams, type InputProps } from './index.js'
|
|
3
|
+
|
|
4
|
+
type $$Props = InputProps
|
|
5
|
+
$: ({ input, value: _value, classWrapper, bindWithParams, ...props } = $$props as $$Props)
|
|
6
|
+
$: ({ class: inputClass, ...inputProps } = input || {})
|
|
7
|
+
export let value = _value
|
|
8
|
+
export let inputElement: HTMLInputElement | undefined = undefined
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
11
|
<FormControl {...props} enhanceDisabled={props.enhanceDisabled || bindWithParams} let:key>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
{#snippet children({ key })}
|
|
13
|
+
<div class={classWrapper}>
|
|
14
|
+
<slot name="prepend" {value} />
|
|
15
|
+
<input
|
|
16
|
+
bind:value
|
|
17
|
+
on:input
|
|
18
|
+
on:focus
|
|
19
|
+
on:blur
|
|
20
|
+
on:keydown
|
|
21
|
+
on:keyup
|
|
22
|
+
bind:this={inputElement}
|
|
23
|
+
use:bindValueWithParams={{ bindEnable: bindWithParams, initValue: (v) => (value = v) }}
|
|
24
|
+
type="text"
|
|
25
|
+
name={key}
|
|
26
|
+
id={key}
|
|
27
|
+
class="input input-bordered w-full {inputClass || ''}"
|
|
28
|
+
{...inputProps}
|
|
29
|
+
/>
|
|
30
|
+
<slot name="append" {value} />
|
|
31
|
+
</div>
|
|
32
|
+
{/snippet}
|
|
32
33
|
</FormControl>
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
$:
|
|
5
|
-
|
|
6
|
-
export let value = _value
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { FormControl, type TextareaProps } from './index.js'
|
|
3
|
+
type $$Props = TextareaProps
|
|
4
|
+
$: ({ textarea, value: _value, ...props } = $$props as $$Props)
|
|
5
|
+
$: ({ class: inputClass, ...inputProps } = textarea || {})
|
|
6
|
+
export let value = _value
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
|
-
<FormControl {...props}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
<FormControl {...props}>
|
|
10
|
+
{#snippet children({ key })}
|
|
11
|
+
<textarea
|
|
12
|
+
bind:value
|
|
13
|
+
on:input
|
|
14
|
+
on:focus
|
|
15
|
+
on:blur
|
|
16
|
+
name={key}
|
|
17
|
+
id={key}
|
|
18
|
+
class="textarea textarea-bordered {inputClass || ''}"
|
|
19
|
+
rows="4"
|
|
20
|
+
{...inputProps}
|
|
21
|
+
></textarea>
|
|
22
|
+
{/snippet}
|
|
22
23
|
</FormControl>
|
|
@@ -9,11 +9,7 @@ declare const __propDef: {
|
|
|
9
9
|
} & {
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|
|
11
11
|
};
|
|
12
|
-
slots: {
|
|
13
|
-
label_append: {
|
|
14
|
-
slot: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
12
|
+
slots: {};
|
|
17
13
|
};
|
|
18
14
|
export type InputTextareaProps = typeof __propDef.props;
|
|
19
15
|
export type InputTextareaEvents = typeof __propDef.events;
|
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from 'svelte'
|
|
3
|
+
import type { HTMLInputAttributes, FormEventHandler } from 'svelte/elements'
|
|
4
|
+
import { FormControl, type InputProps } from './index.js'
|
|
5
|
+
import dayjs from 'dayjs'
|
|
6
|
+
type $$Props = InputProps<Date>
|
|
7
|
+
|
|
8
|
+
export let value: Date | null | undefined = undefined
|
|
9
|
+
export let input: HTMLInputAttributes = {}
|
|
10
|
+
|
|
11
|
+
$: ({ class: inputClass = '', ...inputProps } = input)
|
|
12
|
+
|
|
13
|
+
const dispatch = createEventDispatcher<{ input: Date | null }>()
|
|
14
|
+
|
|
15
|
+
const onInput: FormEventHandler<HTMLInputElement> = ({ currentTarget }) => {
|
|
16
|
+
value = getDateTime(currentTarget.value)
|
|
17
|
+
dispatch('input', value)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getDateTime(v: string | null | undefined): Date | null | undefined {
|
|
21
|
+
if (!v) return value
|
|
22
|
+
const date = new Date(value || 0)
|
|
23
|
+
const dateString = [
|
|
24
|
+
date.getFullYear().toString(),
|
|
25
|
+
(date.getMonth() + 1).toString().padStart(2, '0'),
|
|
26
|
+
date.getDate().toString().padStart(2, '0')
|
|
27
|
+
].join('-')
|
|
28
|
+
return new Date(`${dateString}T${v}`)
|
|
29
|
+
}
|
|
24
30
|
</script>
|
|
25
31
|
|
|
26
|
-
<FormControl {...$$restProps}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
<FormControl {...$$restProps}>
|
|
33
|
+
{#snippet children({ key })}
|
|
34
|
+
<input
|
|
35
|
+
value={value && dayjs(value).format('HH:mm')}
|
|
36
|
+
on:input={onInput}
|
|
37
|
+
on:focus
|
|
38
|
+
on:blur
|
|
39
|
+
type="time"
|
|
40
|
+
name={key}
|
|
41
|
+
id={key}
|
|
42
|
+
class="input input-bordered {inputClass}"
|
|
43
|
+
{...inputProps}
|
|
44
|
+
/>
|
|
45
|
+
{/snippet}
|
|
38
46
|
</FormControl>
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export let
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fade } from 'svelte/transition'
|
|
3
|
+
import { createEventDispatcher } from 'svelte'
|
|
4
|
+
import { mdiLoading, mdiPlus } from '@mdi/js'
|
|
5
|
+
|
|
6
|
+
import Icon from '../icon/Icon.svelte'
|
|
7
|
+
|
|
8
|
+
export let isLoading: boolean
|
|
9
|
+
export let createUrl = ''
|
|
10
|
+
export let createTitle = ''
|
|
11
|
+
export let createIcon = mdiPlus
|
|
12
|
+
|
|
13
|
+
const dispatch = createEventDispatcher<{ unselect: void; create: void }>()
|
|
10
14
|
</script>
|
|
11
15
|
|
|
12
16
|
{#if isLoading}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
<script generics="Item extends {id: string}">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
|
|
1
|
+
<script lang="ts" generics="Item extends {id: string}">
|
|
2
|
+
import { createEventDispatcher } from 'svelte'
|
|
3
|
+
import { selector } from '../../action/selector.js'
|
|
4
|
+
|
|
5
|
+
let klass = ''
|
|
6
|
+
export { klass as class }
|
|
7
|
+
|
|
8
|
+
export let items: Item[]
|
|
9
|
+
export let isError = false
|
|
10
|
+
export let isLoading = false
|
|
11
|
+
export let focusIndex = 0
|
|
12
|
+
export let trigger: HTMLElement | undefined = undefined
|
|
13
|
+
export let keyDownEvent: KeyboardEvent | undefined = undefined
|
|
14
|
+
export let keyDownPreventDefault = true
|
|
15
|
+
|
|
16
|
+
const dispatch = createEventDispatcher<{ select: number }>()
|
|
13
17
|
</script>
|
|
14
18
|
|
|
15
19
|
<ul
|
|
@@ -11,6 +11,10 @@ declare class __sveltets_Render<Item extends {
|
|
|
11
11
|
trigger?: HTMLElement | undefined;
|
|
12
12
|
keyDownEvent?: KeyboardEvent | undefined;
|
|
13
13
|
keyDownPreventDefault?: boolean | undefined;
|
|
14
|
+
children?: import("svelte").Snippet<[{
|
|
15
|
+
item: Item;
|
|
16
|
+
index: any;
|
|
17
|
+
}]> | undefined;
|
|
14
18
|
};
|
|
15
19
|
events(): {
|
|
16
20
|
select: CustomEvent<number>;
|
|
@@ -1,58 +1,67 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher, onMount, type ComponentProps } from 'svelte'
|
|
3
|
+
import { Editor } from '@tiptap/core'
|
|
4
|
+
import debounce from 'debounce'
|
|
5
|
+
|
|
6
|
+
import { jsonParse } from '../../../utils/jsonParse.js'
|
|
7
|
+
import { FormControl } from '../index.js'
|
|
8
|
+
import ToolsBar from './ToolsBar.svelte'
|
|
9
|
+
import { extensions } from './extensions.js'
|
|
10
|
+
|
|
11
|
+
type $$Props = ComponentProps<FormControl> & { value?: string; classToolbar?: string }
|
|
12
|
+
|
|
13
|
+
export let value = ''
|
|
14
|
+
export let classToolbar = ''
|
|
15
|
+
|
|
16
|
+
let element: HTMLDivElement
|
|
17
|
+
let editor: Editor | null = null
|
|
18
|
+
|
|
19
|
+
const dispatch = createEventDispatcher<{ change: void }>()
|
|
20
|
+
|
|
21
|
+
onMount(() => {
|
|
22
|
+
initEditor()
|
|
23
|
+
return () => {
|
|
24
|
+
if (editor) editor.destroy()
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
function initEditor() {
|
|
29
|
+
const valueAsHtml = !value.startsWith('{') && value !== 'null'
|
|
30
|
+
editor = new Editor({
|
|
31
|
+
element,
|
|
32
|
+
content: valueAsHtml ? value : jsonParse(value, undefined),
|
|
33
|
+
editorProps: {
|
|
34
|
+
attributes: {
|
|
35
|
+
class: 'prose max-w-[210mm] mx-auto focus:outline-none'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
extensions,
|
|
39
|
+
onTransaction() {
|
|
40
|
+
editor = editor
|
|
41
|
+
updateValue()
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const updateValue = debounce(() => {
|
|
47
|
+
if (!editor) return
|
|
48
|
+
const newValue = JSON.stringify(editor.getJSON())
|
|
49
|
+
if (newValue === value) return
|
|
50
|
+
value = newValue
|
|
51
|
+
dispatch('change')
|
|
52
|
+
}, 120)
|
|
46
53
|
</script>
|
|
47
54
|
|
|
48
|
-
<FormControl {...$$restProps}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
<FormControl {...$$restProps}>
|
|
56
|
+
{#snippet children({ key })}
|
|
57
|
+
<div class="bordered relative rounded-lg border">
|
|
58
|
+
{#if editor}
|
|
59
|
+
<ToolsBar {editor} class={classToolbar} />
|
|
60
|
+
{/if}
|
|
61
|
+
<div bind:this={element} class="min-h-[20rem] p-4 pb-10"></div>
|
|
62
|
+
</div>
|
|
63
|
+
{#if key}
|
|
64
|
+
<input type="hidden" name={key} {value} />
|
|
52
65
|
{/if}
|
|
53
|
-
|
|
54
|
-
</div>
|
|
55
|
-
{#if key}
|
|
56
|
-
<input type="hidden" name={key} {value} />
|
|
57
|
-
{/if}
|
|
66
|
+
{/snippet}
|
|
58
67
|
</FormControl>
|
|
@@ -4,13 +4,17 @@ declare const __propDef: {
|
|
|
4
4
|
class?: string | undefined;
|
|
5
5
|
classLabel?: string | undefined;
|
|
6
6
|
key?: string | undefined;
|
|
7
|
-
label?: string | import("svelte").
|
|
7
|
+
label?: string | import("svelte").Snippet<[]> | undefined;
|
|
8
|
+
labelAppend?: import("svelte").Snippet<[]> | null | undefined;
|
|
8
9
|
error?: string | undefined;
|
|
9
10
|
hint?: string | undefined;
|
|
10
11
|
prefix?: string | number | undefined;
|
|
11
12
|
prefixFor?: string | number | undefined;
|
|
12
13
|
enhanceDisabled?: boolean | undefined;
|
|
13
14
|
labelPosition?: ("top" | "left" | "right") | undefined;
|
|
15
|
+
children?: import("svelte").Snippet<[{
|
|
16
|
+
key: string;
|
|
17
|
+
}]> | undefined;
|
|
14
18
|
} & {
|
|
15
19
|
value?: string | undefined;
|
|
16
20
|
classToolbar?: string | undefined;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SuggestionProps } from '@tiptap/suggestion'
|
|
3
|
+
import { SelectorList } from '../index.js'
|
|
4
|
+
import type { SuggestionItem } from './suggestion.js'
|
|
5
|
+
|
|
6
|
+
export let props: SuggestionProps<SuggestionItem>
|
|
7
|
+
export let keyDownEvent: KeyboardEvent | undefined = undefined
|
|
8
|
+
|
|
9
|
+
function handleSelect(index: number) {
|
|
10
|
+
const item = props.items[index]
|
|
11
|
+
if (!item) return
|
|
12
|
+
props.command(item)
|
|
13
|
+
}
|
|
10
14
|
</script>
|
|
11
15
|
|
|
12
16
|
<SelectorList
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core'
|
|
3
|
+
import { Icon } from '../../icon/index.js'
|
|
4
|
+
import { tip } from '../../../action/tip.js'
|
|
5
|
+
|
|
6
|
+
export let editor: Editor
|
|
7
|
+
export let key: string
|
|
8
|
+
export let label: string
|
|
9
|
+
export let icon: string
|
|
10
|
+
export let action: () => void
|
|
11
|
+
|
|
12
|
+
$: isActive = editor.isActive(key)
|
|
10
13
|
</script>
|
|
11
14
|
|
|
12
15
|
<button
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export let
|
|
6
|
-
export let
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon } from '../../icon/index.js'
|
|
3
|
+
import { tip } from '../../../action/tip.js'
|
|
4
|
+
|
|
5
|
+
export let icon: string
|
|
6
|
+
export let label: string
|
|
7
|
+
export let color: string
|
|
8
|
+
export let setColor: (color: string) => void
|
|
9
|
+
|
|
10
|
+
let inputColor: HTMLInputElement
|
|
11
|
+
|
|
12
|
+
function handleClick() {
|
|
13
|
+
inputColor.click()
|
|
14
|
+
setColor(color)
|
|
15
|
+
}
|
|
12
16
|
</script>
|
|
13
17
|
|
|
14
18
|
<div class="flex align-bottom">
|
|
@@ -25,7 +29,7 @@ function handleClick() {
|
|
|
25
29
|
<span
|
|
26
30
|
class="badge indicator-item badge-xs scale-75 border transition-none"
|
|
27
31
|
style:background={color}
|
|
28
|
-
|
|
32
|
+
></span>
|
|
29
33
|
<Icon path={icon} size={19} class="opacity-70" />
|
|
30
34
|
</div>
|
|
31
35
|
</button>
|