@dosgato/dialog 1.2.8 → 1.3.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/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,35 +1,37 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export let
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
export let
|
|
17
|
-
export let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { FORM_CONTEXT, FORM_INHERITED_PATH, type FormStore } from '@txstate-mws/svelte-forms'
|
|
3
|
+
import { getContext, onMount } from 'svelte'
|
|
4
|
+
import { get, isNotBlank, randomid, shouldUseWhiteText } from 'txstate-utils'
|
|
5
|
+
import { Radio } from '..'
|
|
6
|
+
import FieldStandard from '../FieldStandard.svelte'
|
|
7
|
+
import type { ColorPickerOption } from './colorpicker'
|
|
8
|
+
|
|
9
|
+
export let id: string | undefined = undefined
|
|
10
|
+
let className = ''
|
|
11
|
+
export { className as class }
|
|
12
|
+
export let path: string
|
|
13
|
+
export let options: ColorPickerOption[]
|
|
14
|
+
export let addAllOption: boolean = false
|
|
15
|
+
export let label: string = ''
|
|
16
|
+
export let required = false
|
|
17
|
+
export let notNull = false
|
|
18
|
+
export let defaultValue: any = notNull ? (addAllOption ? 'alternating' : options[0].value) : undefined
|
|
19
|
+
export let conditional: boolean | undefined = undefined
|
|
20
|
+
export let helptext: string | undefined = undefined
|
|
21
|
+
const groupid = randomid()
|
|
22
|
+
|
|
23
|
+
const store = getContext<FormStore>(FORM_CONTEXT)
|
|
24
|
+
const inheritedPath = getContext<string>(FORM_INHERITED_PATH)
|
|
25
|
+
const finalPath = [inheritedPath, path].filter(isNotBlank).join('.')
|
|
26
|
+
|
|
27
|
+
async function reactToOptions (..._: any[]) {
|
|
28
|
+
const val = get($store.data, finalPath)
|
|
29
|
+
if (!val) return
|
|
30
|
+
if (!options.length) await store.setField(finalPath, addAllOption ? 'alternating' : undefined)
|
|
31
|
+
else if (val !== 'alternating' && !options.some(o => o.value === val)) await store.setField(finalPath, notNull ? options[0].value : (addAllOption ? 'alternating' : undefined))
|
|
32
|
+
}
|
|
33
|
+
$: reactToOptions(options).catch(console.error)
|
|
34
|
+
onMount(reactToOptions)
|
|
33
35
|
</script>
|
|
34
36
|
|
|
35
37
|
<FieldStandard bind:id descid={groupid} {path} {label} {required} {defaultValue} {conditional} {helptext} let:value let:valid let:invalid let:onBlur let:onChange let:messagesid let:helptextid let:setVal>
|
|
@@ -37,7 +39,7 @@ onMount(reactToOptions);
|
|
|
37
39
|
<div class="color-container {className}" role="radiogroup" aria-labelledby={groupid} class:invalid class:valid>
|
|
38
40
|
{#if addAllOption}
|
|
39
41
|
<label for={`${groupid}.alt`} class="colorsel alternating">
|
|
40
|
-
<Radio id={`${groupid}.alt`} name={groupid} value="alternating" selected={value === 'alternating'} {onChange} {onBlur} {helptextid}/>
|
|
42
|
+
<Radio id={`${groupid}.alt`} name={groupid} value="alternating" selected={value === 'alternating'} {onChange} {onBlur} {helptextid} {messagesid} />
|
|
41
43
|
<span class="alternating-bg">
|
|
42
44
|
{#each options as option (option.value)}
|
|
43
45
|
<span style:background-color={option.color}></span>
|
|
@@ -49,7 +51,7 @@ onMount(reactToOptions);
|
|
|
49
51
|
{#each options as option, idx (option.value) }
|
|
50
52
|
{@const radioid = `${groupid}.${idx}`}
|
|
51
53
|
<label for={radioid} class="colorsel">
|
|
52
|
-
<Radio id={radioid} name={groupid} value={option.value} selected={value === option.value} {onChange} {onBlur} {helptextid}/>
|
|
54
|
+
<Radio id={radioid} name={groupid} value={option.value} selected={value === option.value} {onChange} {onBlur} {helptextid} {messagesid} />
|
|
53
55
|
<span class="picker-text" style:background-color={option.color} class:dark={shouldUseWhiteText(option.color)}>{option.name || option.value}</span>
|
|
54
56
|
</label>
|
|
55
57
|
{/each}
|
|
@@ -137,5 +139,4 @@ onMount(reactToOptions);
|
|
|
137
139
|
color: white;
|
|
138
140
|
text-shadow: 1px 1px 1px #222, 1px -1px 1px #222, -1px 1px 1px #222, -1px -1px 1px #222;
|
|
139
141
|
}
|
|
140
|
-
|
|
141
142
|
</style>
|
|
@@ -1,151 +1,153 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
export let
|
|
17
|
-
export let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { resize, ScreenReaderOnly } from '@txstate-mws/svelte-components'
|
|
3
|
+
import { onMount, tick } from 'svelte'
|
|
4
|
+
import { isNotBlank, randomid } from 'txstate-utils'
|
|
5
|
+
import FieldStandard from '../FieldStandard.svelte'
|
|
6
|
+
import { CropperStore, type CropOutput } from './cropper'
|
|
7
|
+
import { Button } from '..'
|
|
8
|
+
import arrowsOutIcon from '@iconify-icons/ph/arrows-out-fill'
|
|
9
|
+
import arrowsCircleIcon from '@iconify-icons/ph/arrows-clockwise-fill'
|
|
10
|
+
|
|
11
|
+
export let id: string | undefined = undefined
|
|
12
|
+
export let path: string
|
|
13
|
+
export let imageSrc: string | undefined
|
|
14
|
+
export let selectionAspectRatio: number = 1
|
|
15
|
+
export let minSelection: number = 0 // percentage of image, a value 0-1
|
|
16
|
+
export let label: string = ''
|
|
17
|
+
export let required = false
|
|
18
|
+
export let conditional: boolean | undefined = undefined
|
|
19
|
+
export let helptext: string | undefined = undefined
|
|
20
|
+
|
|
21
|
+
const store = new CropperStore({ width: 0, height: 0, minSelection, targetAspect: selectionAspectRatio })
|
|
22
|
+
const { output, outputPct, selection } = store
|
|
23
|
+
|
|
24
|
+
let setVal: (val: any) => void
|
|
25
|
+
let value: CropOutput | undefined
|
|
26
|
+
const initialAspectRatio: number = selectionAspectRatio
|
|
27
|
+
function init (spValue, spSetVal) {
|
|
28
|
+
setVal = spSetVal
|
|
29
|
+
value = spValue
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
$: store.setOutput(value)
|
|
33
|
+
function reactToOutput (...args: any[]) {
|
|
34
|
+
if (mounted) setVal?.($output)
|
|
35
|
+
}
|
|
36
|
+
$: reactToOutput($output)
|
|
37
|
+
|
|
38
|
+
let rect: DOMRect
|
|
39
|
+
function updateRect (..._: any) {
|
|
40
|
+
if (!container) return false
|
|
41
|
+
rect = container.getBoundingClientRect()
|
|
42
|
+
store.updateDimensions(rect.width, rect.height)
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isInside (clientX, clientY) {
|
|
47
|
+
return !(clientX < rect.left || clientX > rect.right || clientY > rect.bottom || clientY < rect.top)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function relativeToRect (clientX, clientY): [number, number] {
|
|
51
|
+
return [Math.min(Math.max(0, clientX - rect.left), rect.width), Math.min(Math.max(0, clientY - rect.top), rect.height)]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let container: HTMLDivElement
|
|
55
|
+
function onMouseDown (e: MouseEvent | TouchEvent) {
|
|
56
|
+
if (!updateRect()) return
|
|
57
|
+
if (window.TouchEvent && TouchEvent && e instanceof TouchEvent && e.touches.length > 1) return
|
|
58
|
+
const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX
|
|
59
|
+
const clientY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY
|
|
55
60
|
if (isInside(clientX, clientY)) {
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
e.preventDefault()
|
|
62
|
+
store.startDrag(clientX - rect.left, clientY - rect.top)
|
|
58
63
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (window.TouchEvent && e instanceof TouchEvent && e.touches.length > 1)
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
store.endDrag();
|
|
76
|
-
const clientX = e instanceof MouseEvent ? e.clientX : e.changedTouches[0].clientX;
|
|
77
|
-
const clientY = e instanceof MouseEvent ? e.clientY : e.changedTouches[0].clientY;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function onMouseMove (e: MouseEvent | TouchEvent) {
|
|
67
|
+
if (!updateRect()) return
|
|
68
|
+
if (window.TouchEvent && e instanceof TouchEvent && e.touches.length > 1) return
|
|
69
|
+
const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX
|
|
70
|
+
const clientY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY
|
|
71
|
+
if (e instanceof MouseEvent && !e.buttons && $store.drag) store.endDrag()
|
|
72
|
+
if (isInside(clientX, clientY) || $store.drag) store.mouseMove(...relativeToRect(clientX, clientY))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function onMouseUp (e: MouseEvent | TouchEvent) {
|
|
76
|
+
if (!updateRect()) return
|
|
77
|
+
store.endDrag()
|
|
78
|
+
const clientX = e instanceof MouseEvent ? e.clientX : e.changedTouches[0].clientX
|
|
79
|
+
const clientY = e instanceof MouseEvent ? e.clientY : e.changedTouches[0].clientY
|
|
78
80
|
if (isInside(clientX, clientY)) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
store.mouseMove(...relativeToRect(clientX, clientY))
|
|
82
|
+
container?.querySelector<HTMLDivElement>('.selectionHilite')?.focus()
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function onMaximize () {
|
|
87
|
+
if (!updateRect()) return
|
|
88
|
+
store.maximize()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function onKeyDown (type: 'move' | 'tl' | 'tr' | 'bl' | 'br') {
|
|
92
|
+
return (e: KeyboardEvent) => {
|
|
93
|
+
const tl = type === 'tl'
|
|
94
|
+
const tr = type === 'tr'
|
|
95
|
+
const bl = type === 'bl'
|
|
96
|
+
const br = type === 'br'
|
|
97
|
+
const left = e.key === 'ArrowLeft'
|
|
98
|
+
const right = e.key === 'ArrowRight'
|
|
99
|
+
const up = e.key === 'ArrowUp'
|
|
100
|
+
const down = e.key === 'ArrowDown'
|
|
101
|
+
if (left || right || up || down) {
|
|
102
|
+
e.preventDefault()
|
|
103
|
+
e.stopPropagation()
|
|
104
|
+
} else return
|
|
105
|
+
const step = e.shiftKey ? (e.altKey || e.metaKey ? 80 : 20) : (e.altKey || e.metaKey ? 40 : 1)
|
|
106
|
+
if (type === 'move') {
|
|
107
|
+
store.move(left ? -1 * step : (right ? step : 0), up ? -1 * step : (down ? step : 0))
|
|
108
|
+
} else {
|
|
109
|
+
store.expand(type, ((tl || bl) && right) || ((tl || tr) && down) || ((tr || br) && left) || ((bl || br) && up) ? -1 * step : step)
|
|
110
|
+
}
|
|
81
111
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
e.preventDefault();
|
|
100
|
-
e.stopPropagation();
|
|
101
|
-
}
|
|
102
|
-
else
|
|
103
|
-
return;
|
|
104
|
-
const step = e.shiftKey ? (e.altKey || e.metaKey ? 80 : 20) : (e.altKey || e.metaKey ? 40 : 1);
|
|
105
|
-
if (type === 'move') {
|
|
106
|
-
store.move(left ? -1 * step : (right ? step : 0), up ? -1 * step : (down ? step : 0));
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
store.expand(type, ((tl || bl) && right) || ((tl || tr) && down) || ((tr || br) && left) || ((bl || br) && up) ? -1 * step : step);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
let mounted = false;
|
|
114
|
-
onMount(() => {
|
|
115
|
-
mounted = true;
|
|
116
|
-
});
|
|
117
|
-
$: updateRect(container);
|
|
118
|
-
const descid = randomid();
|
|
119
|
-
const movedescid = randomid();
|
|
120
|
-
let focusWithin = false;
|
|
121
|
-
let arChanged = false;
|
|
122
|
-
async function reactToAspectRatio(ar) {
|
|
123
|
-
if (!ar)
|
|
124
|
-
return;
|
|
125
|
-
store.updateTargetAspect(ar);
|
|
126
|
-
await tick();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let mounted = false
|
|
115
|
+
onMount(() => {
|
|
116
|
+
mounted = true
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
$: updateRect(container)
|
|
120
|
+
const descid = randomid()
|
|
121
|
+
const movedescid = randomid()
|
|
122
|
+
let focusWithin = false
|
|
123
|
+
|
|
124
|
+
let arChanged = false
|
|
125
|
+
async function reactToAspectRatio (ar) {
|
|
126
|
+
if (!ar) return
|
|
127
|
+
store.updateTargetAspect(ar)
|
|
128
|
+
await tick()
|
|
127
129
|
if (ar !== initialAspectRatio || arChanged) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
store.maximize()
|
|
131
|
+
arChanged = true
|
|
130
132
|
}
|
|
131
|
-
}
|
|
132
|
-
$: void reactToAspectRatio(selectionAspectRatio)
|
|
133
|
-
|
|
134
|
-
let
|
|
135
|
-
let
|
|
136
|
-
|
|
133
|
+
}
|
|
134
|
+
$: void reactToAspectRatio(selectionAspectRatio)
|
|
135
|
+
|
|
136
|
+
let initialLoad = true
|
|
137
|
+
let initialVal
|
|
138
|
+
let srcChanged = false
|
|
139
|
+
async function onimageload (e) {
|
|
137
140
|
if (initialLoad) {
|
|
138
|
-
|
|
139
|
-
|
|
141
|
+
initialVal = e.target.src
|
|
142
|
+
initialLoad = false
|
|
143
|
+
} else {
|
|
144
|
+
if (e.target.src !== initialVal || srcChanged) {
|
|
145
|
+
await tick()
|
|
146
|
+
store.maximize()
|
|
147
|
+
srcChanged = true
|
|
148
|
+
}
|
|
140
149
|
}
|
|
141
|
-
|
|
142
|
-
if (e.target.src !== initialVal || srcChanged) {
|
|
143
|
-
await tick();
|
|
144
|
-
store.maximize();
|
|
145
|
-
srcChanged = true;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
150
|
+
}
|
|
149
151
|
</script>
|
|
150
152
|
|
|
151
153
|
<svelte:window on:mousemove={onMouseMove} on:mouseup={onMouseUp} on:touchend={onMouseUp} on:touchcancel={onMouseUp} />
|
|
@@ -278,5 +280,4 @@ async function onimageload(e) {
|
|
|
278
280
|
bottom: 0;
|
|
279
281
|
right: 0;
|
|
280
282
|
}
|
|
281
|
-
|
|
282
283
|
</style>
|
|
@@ -1,107 +1,116 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import FieldStandard from '../FieldStandard.svelte'
|
|
3
|
+
import { ScreenReaderOnly, Modal, modifierKey } from '@txstate-mws/svelte-components'
|
|
4
|
+
import { FontAwesomeIcons, IconCategories } from './iconpicker'
|
|
5
|
+
import Icon from '@iconify/svelte'
|
|
6
|
+
import { randomid, keyby } from 'txstate-utils'
|
|
7
|
+
import { getDescribedBy } from '../helpers'
|
|
8
|
+
export let id: string | undefined = undefined
|
|
9
|
+
export let path: string
|
|
10
|
+
export let label: string = ''
|
|
11
|
+
export let required = false
|
|
12
|
+
export let defaultValue: { icon: string, prefix: string } = { icon: 'fa-graduation-cap', prefix: 'fas' }
|
|
13
|
+
export let conditional: boolean | undefined = undefined
|
|
14
|
+
export let helptext: string | undefined = undefined
|
|
15
|
+
|
|
16
|
+
const labelid = randomid()
|
|
17
|
+
const descid = randomid()
|
|
18
|
+
|
|
19
|
+
let modalOpen: boolean = false
|
|
20
|
+
let selected: { icon: string, prefix: string } = defaultValue
|
|
21
|
+
|
|
22
|
+
const iconToPrefix: Record<string, string> = {}
|
|
23
|
+
const categoriesToIcons = keyby(IconCategories, 'key')
|
|
24
|
+
|
|
25
|
+
for (const icon of FontAwesomeIcons) {
|
|
26
|
+
iconToPrefix[icon.class] = icon.free.includes('brands') ? 'fab' : 'fas'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const iconElements: HTMLDivElement[] = []
|
|
30
|
+
|
|
31
|
+
let visibleIcons = FontAwesomeIcons
|
|
32
|
+
|
|
33
|
+
let searchVal: string = ''
|
|
34
|
+
let category: string = 'all'
|
|
35
|
+
|
|
36
|
+
$:iconCountMessage = visibleIcons.length === FontAwesomeIcons.length ? 'Showing all icons' : `Showing ${visibleIcons.length} icons`
|
|
37
|
+
|
|
38
|
+
function onSelectIcon (iconClass: string) {
|
|
39
|
+
selected = { icon: iconClass, prefix: iconToPrefix[iconClass] }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function onSaveIconSelection (setVal: (val: any) => void) {
|
|
32
43
|
return function () {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
44
|
+
setVal(selected)
|
|
45
|
+
category = 'all'
|
|
46
|
+
searchVal = ''
|
|
47
|
+
visibleIcons = FontAwesomeIcons
|
|
48
|
+
modalOpen = false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function onCancel (val) {
|
|
41
53
|
return function () {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
54
|
+
selected = val
|
|
55
|
+
category = 'all'
|
|
56
|
+
searchVal = ''
|
|
57
|
+
visibleIcons = FontAwesomeIcons
|
|
58
|
+
modalOpen = false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function onSearch () {
|
|
50
64
|
visibleIcons = FontAwesomeIcons.filter(i => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return false;
|
|
59
|
-
});
|
|
65
|
+
const searchValLC = searchVal.toLowerCase()
|
|
66
|
+
if (i.class.toLowerCase().includes(searchValLC)) return true
|
|
67
|
+
for (const term of i.search.terms) {
|
|
68
|
+
if (term.toLowerCase().includes(searchValLC)) return true
|
|
69
|
+
}
|
|
70
|
+
return false
|
|
71
|
+
})
|
|
60
72
|
if (visibleIcons.findIndex(i => i.class === selected.icon) < 0) {
|
|
61
|
-
|
|
73
|
+
onSelectIcon(visibleIcons[0].class)
|
|
62
74
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function onSelectCategory () {
|
|
65
78
|
if (category === 'all') {
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
79
|
+
visibleIcons = FontAwesomeIcons
|
|
80
|
+
} else {
|
|
81
|
+
visibleIcons = FontAwesomeIcons.filter(i => {
|
|
82
|
+
return categoriesToIcons[category].icons.includes(i.class)
|
|
83
|
+
})
|
|
72
84
|
}
|
|
73
85
|
if (visibleIcons.findIndex(i => i.class === selected.icon) < 0) {
|
|
74
|
-
|
|
86
|
+
onSelectIcon(visibleIcons[0].class)
|
|
75
87
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
let newIndex
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function onKeyDown (e: KeyboardEvent) {
|
|
91
|
+
const currentSelectionIndex = visibleIcons.findIndex(i => i.class === selected.icon)
|
|
92
|
+
if (modifierKey(e)) return
|
|
93
|
+
let newIndex
|
|
82
94
|
if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
e.preventDefault()
|
|
96
|
+
if (currentSelectionIndex === visibleIcons.length - 1) {
|
|
97
|
+
newIndex = 0
|
|
98
|
+
} else {
|
|
99
|
+
newIndex = currentSelectionIndex + 1
|
|
100
|
+
}
|
|
101
|
+
onSelectIcon(visibleIcons[newIndex].class)
|
|
102
|
+
iconElements[newIndex].focus()
|
|
103
|
+
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') {
|
|
104
|
+
e.preventDefault()
|
|
105
|
+
if (currentSelectionIndex === 0) {
|
|
106
|
+
newIndex = visibleIcons.length - 1
|
|
107
|
+
} else {
|
|
108
|
+
newIndex = currentSelectionIndex - 1
|
|
109
|
+
}
|
|
110
|
+
onSelectIcon(visibleIcons[newIndex].class)
|
|
111
|
+
iconElements[newIndex].focus()
|
|
92
112
|
}
|
|
93
|
-
|
|
94
|
-
e.preventDefault();
|
|
95
|
-
if (currentSelectionIndex === 0) {
|
|
96
|
-
newIndex = visibleIcons.length - 1;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
newIndex = currentSelectionIndex - 1;
|
|
100
|
-
}
|
|
101
|
-
onSelectIcon(visibleIcons[newIndex].class);
|
|
102
|
-
iconElements[newIndex].focus();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
113
|
+
}
|
|
105
114
|
</script>
|
|
106
115
|
|
|
107
116
|
<FieldStandard bind:id {path} {descid} {label} {required} {defaultValue} {conditional} {helptext} let:value let:valid let:invalid let:id let:onBlur let:setVal let:messagesid let:helptextid>
|
|
@@ -283,5 +292,4 @@ function onKeyDown(e) {
|
|
|
283
292
|
line-height: 250px;
|
|
284
293
|
color: #999;
|
|
285
294
|
}
|
|
286
|
-
|
|
287
295
|
</style>
|