@dosgato/dialog 1.2.8 → 1.3.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/Button.svelte +15 -13
- package/dist/ButtonGroup.svelte +44 -40
- package/dist/Checkbox.svelte +13 -12
- package/dist/Container.svelte +50 -46
- package/dist/Dialog.svelte +56 -41
- package/dist/FieldAutocomplete.svelte +77 -70
- package/dist/FieldCheckbox.svelte +25 -22
- package/dist/FieldChoices.svelte +74 -68
- package/dist/FieldChooserLink.svelte +148 -150
- package/dist/FieldDate.svelte +19 -18
- package/dist/FieldDateTime.svelte +36 -34
- package/dist/FieldDualListbox.svelte +80 -79
- package/dist/FieldHidden.svelte +16 -15
- package/dist/FieldIdentifier.svelte +18 -17
- package/dist/FieldMultiple.svelte +71 -74
- package/dist/FieldMultiselect.svelte +81 -72
- package/dist/FieldNumber.svelte +20 -19
- package/dist/FieldRadio.svelte +42 -41
- package/dist/FieldSelect.svelte +45 -45
- package/dist/FieldStandard.svelte +28 -27
- package/dist/FieldText.svelte +27 -24
- package/dist/FieldTextArea.svelte +24 -24
- package/dist/FileIcon.svelte +10 -8
- package/dist/Form.svelte +40 -18
- package/dist/Form.svelte.d.ts +15 -13
- package/dist/FormDialog.svelte +40 -25
- package/dist/FormDialog.svelte.d.ts +23 -17
- package/dist/Icon.svelte +38 -33
- package/dist/InlineMessage.svelte +31 -29
- package/dist/InlineMessages.svelte +10 -7
- package/dist/Input.svelte +40 -39
- package/dist/Listbox.svelte +102 -109
- package/dist/MaxLength.svelte +19 -18
- package/dist/Radio.svelte +18 -15
- package/dist/Switcher.svelte +37 -33
- package/dist/Tab.svelte +23 -21
- package/dist/Tabs.svelte +111 -110
- package/dist/Tooltip.svelte +7 -7
- package/dist/chooser/Chooser.svelte +83 -76
- package/dist/chooser/ChooserPreview.svelte +16 -14
- package/dist/chooser/Details.svelte +6 -4
- package/dist/chooser/Thumbnail.svelte +20 -16
- package/dist/chooser/UploadUI.svelte +78 -69
- package/dist/code/CodeEditor.svelte +63 -66
- package/dist/code/FieldCodeEditor.svelte +21 -19
- package/dist/colorpicker/FieldColorPicker.svelte +36 -35
- package/dist/cropper/FieldCropper.svelte +142 -141
- package/dist/iconpicker/FieldIconPicker.svelte +102 -94
- package/dist/imageposition/FieldImagePosition.svelte +107 -98
- package/dist/tagpicker/FieldTagPicker.svelte +63 -54
- package/dist/tree/LoadIcon.svelte +0 -1
- package/dist/tree/Tree.svelte +198 -192
- package/dist/tree/Tree.svelte.d.ts +5 -5
- package/dist/tree/TreeCell.svelte +10 -6
- package/dist/tree/TreeCell.svelte.d.ts +5 -5
- package/dist/tree/TreeNode.svelte +213 -241
- package/dist/tree/TreeNode.svelte.d.ts +5 -5
- package/package.json +8 -9
|
@@ -1,116 +1,126 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
let
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { isNotBlank, randomid } from 'txstate-utils'
|
|
3
|
+
import FieldStandard from '../FieldStandard.svelte'
|
|
4
|
+
import Button from '../Button.svelte'
|
|
5
|
+
import arrowsIn from '@iconify-icons/ph/arrows-in'
|
|
6
|
+
import { Dialog, type ImagePositionOutput } from '..'
|
|
7
|
+
import { modifierKey, ScreenReaderOnly } from '@txstate-mws/svelte-components'
|
|
8
|
+
|
|
9
|
+
export let id: string | undefined = undefined
|
|
10
|
+
export let path: string
|
|
11
|
+
export let imageSrc: string | undefined
|
|
12
|
+
export let label: string = ''
|
|
13
|
+
export let required = false
|
|
14
|
+
export let conditional: boolean | undefined = undefined
|
|
15
|
+
export let helptext: string | undefined = undefined
|
|
16
|
+
export let defaultValue: ImagePositionOutput = { x: 50, y: 50 }
|
|
17
|
+
|
|
18
|
+
let initialVal: ImagePositionOutput
|
|
19
|
+
function init (v) {
|
|
17
20
|
if (v) {
|
|
18
|
-
|
|
21
|
+
initialVal = v
|
|
22
|
+
} else {
|
|
23
|
+
initialVal = defaultValue
|
|
19
24
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function showModal() {
|
|
29
|
-
modalOpen = true
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const boxes: HTMLDivElement[] = []
|
|
28
|
+
|
|
29
|
+
const descid = randomid()
|
|
30
|
+
const labelid = randomid()
|
|
31
|
+
let modalOpen: boolean = false
|
|
32
|
+
|
|
33
|
+
function showModal () {
|
|
34
|
+
modalOpen = true
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function hideModal () {
|
|
38
|
+
modalOpen = false
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let x, y
|
|
42
|
+
|
|
43
|
+
function onSave (setVal) {
|
|
44
|
+
setVal({ x: x * 25, y: y * 25 })
|
|
45
|
+
hideModal()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function onSelectBox (newX, newY) {
|
|
49
|
+
x = newX
|
|
50
|
+
y = newY
|
|
51
|
+
boxes[x + y * 5].focus()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function onKeyDown (e: KeyboardEvent) {
|
|
55
|
+
if (modifierKey(e)) return
|
|
47
56
|
if (e.key === 'ArrowDown') {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
e.preventDefault()
|
|
58
|
+
y = Math.min(y + 1, 4)
|
|
59
|
+
} else if (e.key === 'ArrowUp') {
|
|
60
|
+
e.preventDefault()
|
|
61
|
+
y = Math.max(y - 1, 0)
|
|
62
|
+
} else if (e.key === 'ArrowRight') {
|
|
63
|
+
e.preventDefault()
|
|
64
|
+
x = Math.min(x + 1, 4)
|
|
65
|
+
} else if (e.key === 'ArrowLeft') {
|
|
66
|
+
e.preventDefault()
|
|
67
|
+
x = Math.max(0, x - 1)
|
|
58
68
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
const positionText = {
|
|
69
|
+
boxes[y + x * 5].focus()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const positionText: Record<number, Record<number, string>> = {
|
|
66
74
|
0: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
0: 'Top Left Corner',
|
|
76
|
+
1: 'Upper Left',
|
|
77
|
+
2: 'Middle Left',
|
|
78
|
+
3: 'Lower Left',
|
|
79
|
+
4: 'Bottom Left Corner'
|
|
72
80
|
},
|
|
73
81
|
1: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
0: 'Top Left of Center',
|
|
83
|
+
1: 'Upper Left of Center',
|
|
84
|
+
2: 'Middle Left of Center',
|
|
85
|
+
3: 'Below Left of Center',
|
|
86
|
+
4: 'Bottom, Left of Center'
|
|
79
87
|
},
|
|
80
88
|
2: {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
0: 'Top Center',
|
|
90
|
+
1: 'Upper Center',
|
|
91
|
+
2: 'Dead Center',
|
|
92
|
+
3: 'Below Center',
|
|
93
|
+
4: 'Bottom Center'
|
|
86
94
|
},
|
|
87
95
|
3: {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
0: 'Top, Right of Center',
|
|
97
|
+
1: 'Upper Right of Center',
|
|
98
|
+
2: 'Middle Right of Center',
|
|
99
|
+
3: 'Below Right of Center',
|
|
100
|
+
4: 'Bottom, Right of Center'
|
|
93
101
|
},
|
|
94
102
|
4: {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
0: 'Top Right Corner',
|
|
104
|
+
1: 'Upper Right',
|
|
105
|
+
2: 'Middle Right',
|
|
106
|
+
3: 'Lower Right',
|
|
107
|
+
4: 'Bottom Right Corner'
|
|
100
108
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let dialogWasOpened = false
|
|
112
|
+
function onDialogOpen () {
|
|
104
113
|
if (!dialogWasOpened) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
x = (initialVal.x ?? 50) / 25
|
|
115
|
+
y = (initialVal.y ?? 50) / 25
|
|
116
|
+
dialogWasOpened = true
|
|
108
117
|
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function resetPosition () {
|
|
121
|
+
x = 2
|
|
122
|
+
y = 2
|
|
123
|
+
}
|
|
114
124
|
</script>
|
|
115
125
|
|
|
116
126
|
<FieldStandard bind:id {label} {path} {required} {defaultValue} conditional={conditional && isNotBlank(imageSrc)} {helptext} {descid} let:value let:setVal let:helptextid>
|
|
@@ -222,6 +232,5 @@ function resetPosition() {
|
|
|
222
232
|
:global(button.reset-position.reset-position):not([disabled]):hover {
|
|
223
233
|
background-color: var(--dg-button-cancel-hover-bg, #595959);
|
|
224
234
|
}
|
|
225
|
-
|
|
226
235
|
</style>
|
|
227
236
|
|
|
@@ -1,60 +1,70 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
|
|
16
|
-
export let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export let
|
|
20
|
-
|
|
21
|
-
export let
|
|
22
|
-
export let
|
|
23
|
-
export let
|
|
24
|
-
|
|
25
|
-
let
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import FieldMultiselect from '../FieldMultiselect.svelte'
|
|
3
|
+
import { getContext } from 'svelte'
|
|
4
|
+
import { isNotBlank } from 'txstate-utils'
|
|
5
|
+
import { TAG_API_CONTEXT, type Tag, type TagClient, type TagGroup } from './TagAPI'
|
|
6
|
+
import trashIcon from '@iconify-icons/ph/trash-simple-fill'
|
|
7
|
+
import { Icon } from '..';
|
|
8
|
+
import type { PopupMenuItem } from '@txstate-mws/svelte-components'
|
|
9
|
+
|
|
10
|
+
export let path: string
|
|
11
|
+
export let label: string
|
|
12
|
+
export let target: any
|
|
13
|
+
export let conditional: boolean | undefined = undefined
|
|
14
|
+
export let required = false
|
|
15
|
+
export let extradescid: string | undefined = undefined
|
|
16
|
+
export let helptext: string | undefined = undefined
|
|
17
|
+
export let emptyText: string | undefined = undefined
|
|
18
|
+
/** Text to display in the tag picker input field when it's empty. */
|
|
19
|
+
export let placeholder = ''
|
|
20
|
+
/** We might want to show the title in the dialog for clarity, even if it is excluded when rendering tags on a page. */
|
|
21
|
+
export let showTitleInDialog = false
|
|
22
|
+
export let menuContainerClass = ''
|
|
23
|
+
export let menuClass = ''
|
|
24
|
+
export let menuItemClass = 'default-menu-item'
|
|
25
|
+
export let menuItemHilitedClass = ''
|
|
26
|
+
export let menuCategoryClass = 'default-menu-category'
|
|
27
|
+
|
|
28
|
+
const tagClient = getContext<TagClient>(TAG_API_CONTEXT)
|
|
29
|
+
|
|
30
|
+
let lasttarget: any = -1
|
|
31
|
+
let groups: TagGroup[] = []
|
|
32
|
+
let tags: (Tag & { lcname: string, group: TagGroup & { lctitle: string } })[]
|
|
33
|
+
async function fetchAvailableTags () {
|
|
29
34
|
if (lasttarget !== target) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
groups = await tagClient.availableForTarget(target)
|
|
36
|
+
tags = groups.flatMap(g => g.tags.map(t => ({ ...t, lcname: t.name.toLocaleLowerCase(), group: { ...g, lctitle: g.title?.toLocaleLowerCase() ?? '' } })))
|
|
37
|
+
lasttarget = target
|
|
33
38
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function tagToOption (tag: (typeof tags)[0]) {
|
|
42
|
+
let group: string | undefined = undefined
|
|
37
43
|
if (isNotBlank(tag.group.title) && (showTitleInDialog || !tag.group.excludeTitle)) {
|
|
38
|
-
|
|
44
|
+
group = tag.group.title
|
|
39
45
|
}
|
|
40
|
-
return { label: tag.name, value: tag.id, group }
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
return { label: tag.name, value: tag.id, group }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function getOptions (search: string) {
|
|
50
|
+
await fetchAvailableTags()
|
|
51
|
+
const lcsearch = search?.toLocaleLowerCase() ?? ''
|
|
52
|
+
return tags.filter(t => t.lcname.includes(lcsearch) || t.group.lctitle.includes(lcsearch)).map(tagToOption)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function lookupByValue (id: string) {
|
|
56
|
+
await fetchAvailableTags()
|
|
57
|
+
const tag = tags.find(t => t.id === id)
|
|
58
|
+
if (!tag) return undefined
|
|
59
|
+
return tagToOption(tag)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function selectedItemLabel (item: PopupMenuItem) {
|
|
63
|
+
const tag = item.label ?? item.value
|
|
64
|
+
return item.group ? `${item.group}: ${tag}` : tag
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
58
68
|
</script>
|
|
59
69
|
|
|
60
70
|
<FieldMultiselect {path} {label} {getOptions} {lookupByValue} {conditional} {required} {extradescid} {helptext} {emptyText} {placeholder} {menuClass} {menuContainerClass} {menuItemClass} {menuItemHilitedClass} {menuCategoryClass} selectedItemLabel={showTitleInDialog ? selectedItemLabel : undefined} includeDeleteAll confirmDelete="Are you sure you want remove all tag selections?">
|
|
@@ -95,5 +105,4 @@ function selectedItemLabel(item) {
|
|
|
95
105
|
background-color: transparent;
|
|
96
106
|
border: 0;
|
|
97
107
|
}
|
|
98
|
-
|
|
99
108
|
</style>
|