@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.
Files changed (58) hide show
  1. package/dist/Button.svelte +15 -13
  2. package/dist/ButtonGroup.svelte +44 -40
  3. package/dist/Checkbox.svelte +13 -12
  4. package/dist/Container.svelte +50 -46
  5. package/dist/Dialog.svelte +56 -41
  6. package/dist/FieldAutocomplete.svelte +77 -70
  7. package/dist/FieldCheckbox.svelte +25 -22
  8. package/dist/FieldChoices.svelte +74 -68
  9. package/dist/FieldChooserLink.svelte +148 -150
  10. package/dist/FieldDate.svelte +19 -18
  11. package/dist/FieldDateTime.svelte +36 -34
  12. package/dist/FieldDualListbox.svelte +80 -79
  13. package/dist/FieldHidden.svelte +16 -15
  14. package/dist/FieldIdentifier.svelte +18 -17
  15. package/dist/FieldMultiple.svelte +71 -74
  16. package/dist/FieldMultiselect.svelte +81 -72
  17. package/dist/FieldNumber.svelte +20 -19
  18. package/dist/FieldRadio.svelte +42 -41
  19. package/dist/FieldSelect.svelte +45 -45
  20. package/dist/FieldStandard.svelte +28 -27
  21. package/dist/FieldText.svelte +27 -24
  22. package/dist/FieldTextArea.svelte +24 -24
  23. package/dist/FileIcon.svelte +10 -8
  24. package/dist/Form.svelte +40 -18
  25. package/dist/Form.svelte.d.ts +15 -13
  26. package/dist/FormDialog.svelte +40 -25
  27. package/dist/FormDialog.svelte.d.ts +23 -17
  28. package/dist/Icon.svelte +38 -33
  29. package/dist/InlineMessage.svelte +31 -29
  30. package/dist/InlineMessages.svelte +10 -7
  31. package/dist/Input.svelte +40 -39
  32. package/dist/Listbox.svelte +102 -109
  33. package/dist/MaxLength.svelte +19 -18
  34. package/dist/Radio.svelte +18 -15
  35. package/dist/Switcher.svelte +37 -33
  36. package/dist/Tab.svelte +23 -21
  37. package/dist/Tabs.svelte +111 -110
  38. package/dist/Tooltip.svelte +7 -7
  39. package/dist/chooser/Chooser.svelte +83 -76
  40. package/dist/chooser/ChooserPreview.svelte +16 -14
  41. package/dist/chooser/Details.svelte +6 -4
  42. package/dist/chooser/Thumbnail.svelte +20 -16
  43. package/dist/chooser/UploadUI.svelte +78 -69
  44. package/dist/code/CodeEditor.svelte +63 -66
  45. package/dist/code/FieldCodeEditor.svelte +21 -19
  46. package/dist/colorpicker/FieldColorPicker.svelte +36 -35
  47. package/dist/cropper/FieldCropper.svelte +142 -141
  48. package/dist/iconpicker/FieldIconPicker.svelte +102 -94
  49. package/dist/imageposition/FieldImagePosition.svelte +107 -98
  50. package/dist/tagpicker/FieldTagPicker.svelte +63 -54
  51. package/dist/tree/LoadIcon.svelte +0 -1
  52. package/dist/tree/Tree.svelte +198 -192
  53. package/dist/tree/Tree.svelte.d.ts +5 -5
  54. package/dist/tree/TreeCell.svelte +10 -6
  55. package/dist/tree/TreeCell.svelte.d.ts +5 -5
  56. package/dist/tree/TreeNode.svelte +213 -241
  57. package/dist/tree/TreeNode.svelte.d.ts +5 -5
  58. package/package.json +8 -9
@@ -1,35 +1,37 @@
1
- <script>import { FORM_CONTEXT, FORM_INHERITED_PATH } from '@txstate-mws/svelte-forms';
2
- import { getContext, onMount } from 'svelte';
3
- import { get, isNotBlank, randomid, shouldUseWhiteText } from 'txstate-utils';
4
- import { Radio } from '..';
5
- import FieldStandard from '../FieldStandard.svelte';
6
- export let id = undefined;
7
- let className = '';
8
- export { className as class };
9
- export let path;
10
- export let options;
11
- export let addAllOption = false;
12
- export let label = '';
13
- export let required = false;
14
- export let notNull = false;
15
- export let defaultValue = notNull ? (addAllOption ? 'alternating' : options[0].value) : undefined;
16
- export let conditional = undefined;
17
- export let helptext = undefined;
18
- const groupid = randomid();
19
- const store = getContext(FORM_CONTEXT);
20
- const inheritedPath = getContext(FORM_INHERITED_PATH);
21
- const finalPath = [inheritedPath, path].filter(isNotBlank).join('.');
22
- async function reactToOptions(..._) {
23
- const val = get($store.data, finalPath);
24
- if (!val)
25
- return;
26
- if (!options.length)
27
- await store.setField(finalPath, addAllOption ? 'alternating' : undefined);
28
- else if (val !== 'alternating' && !options.some(o => o.value === val))
29
- await store.setField(finalPath, notNull ? options[0].value : (addAllOption ? 'alternating' : undefined));
30
- }
31
- $: reactToOptions(options).catch(console.error);
32
- onMount(reactToOptions);
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>import { resize, ScreenReaderOnly } from '@txstate-mws/svelte-components';
2
- import { onMount, tick } from 'svelte';
3
- import { isNotBlank, randomid } from 'txstate-utils';
4
- import FieldStandard from '../FieldStandard.svelte';
5
- import { CropperStore } from './cropper';
6
- import { Button } from '..';
7
- import arrowsOutIcon from '@iconify-icons/ph/arrows-out-fill';
8
- import arrowsCircleIcon from '@iconify-icons/ph/arrows-clockwise-fill';
9
- export let id = undefined;
10
- export let path;
11
- export let imageSrc;
12
- export let selectionAspectRatio = 1;
13
- export let minSelection = 0; // percentage of image, a value 0-1
14
- export let label = '';
15
- export let required = false;
16
- export let conditional = undefined;
17
- export let helptext = undefined;
18
- const store = new CropperStore({ width: 0, height: 0, minSelection, targetAspect: selectionAspectRatio });
19
- const { output, outputPct, selection } = store;
20
- let setVal;
21
- let value;
22
- const initialAspectRatio = selectionAspectRatio;
23
- function init(spValue, spSetVal) {
24
- setVal = spSetVal;
25
- value = spValue;
26
- }
27
- $: store.setOutput(value);
28
- function reactToOutput(...args) {
29
- if (mounted)
30
- setVal?.($output);
31
- }
32
- $: reactToOutput($output);
33
- let rect;
34
- function updateRect(..._) {
35
- if (!container)
36
- return false;
37
- rect = container.getBoundingClientRect();
38
- store.updateDimensions(rect.width, rect.height);
39
- return true;
40
- }
41
- function isInside(clientX, clientY) {
42
- return !(clientX < rect.left || clientX > rect.right || clientY > rect.bottom || clientY < rect.top);
43
- }
44
- function relativeToRect(clientX, clientY) {
45
- return [Math.min(Math.max(0, clientX - rect.left), rect.width), Math.min(Math.max(0, clientY - rect.top), rect.height)];
46
- }
47
- let container;
48
- function onMouseDown(e) {
49
- if (!updateRect())
50
- return;
51
- if (window.TouchEvent && TouchEvent && e instanceof TouchEvent && e.touches.length > 1)
52
- return;
53
- const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
54
- const clientY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
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
- e.preventDefault();
57
- store.startDrag(clientX - rect.left, clientY - rect.top);
61
+ e.preventDefault()
62
+ store.startDrag(clientX - rect.left, clientY - rect.top)
58
63
  }
59
- }
60
- function onMouseMove(e) {
61
- if (!updateRect())
62
- return;
63
- if (window.TouchEvent && e instanceof TouchEvent && e.touches.length > 1)
64
- return;
65
- const clientX = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
66
- const clientY = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
67
- if (e instanceof MouseEvent && !e.buttons && $store.drag)
68
- store.endDrag();
69
- if (isInside(clientX, clientY) || $store.drag)
70
- store.mouseMove(...relativeToRect(clientX, clientY));
71
- }
72
- function onMouseUp(e) {
73
- if (!updateRect())
74
- return;
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
- store.mouseMove(...relativeToRect(clientX, clientY));
80
- container?.querySelector('.selectionHilite')?.focus();
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
- function onMaximize() {
84
- if (!updateRect())
85
- return;
86
- store.maximize();
87
- }
88
- function onKeyDown(type) {
89
- return (e) => {
90
- const tl = type === 'tl';
91
- const tr = type === 'tr';
92
- const bl = type === 'bl';
93
- const br = type === 'br';
94
- const left = e.key === 'ArrowLeft';
95
- const right = e.key === 'ArrowRight';
96
- const up = e.key === 'ArrowUp';
97
- const down = e.key === 'ArrowDown';
98
- if (left || right || up || down) {
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
- store.maximize();
129
- arChanged = true;
130
+ store.maximize()
131
+ arChanged = true
130
132
  }
131
- }
132
- $: void reactToAspectRatio(selectionAspectRatio);
133
- let initialLoad = true;
134
- let initialVal;
135
- let srcChanged = false;
136
- async function onimageload(e) {
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
- initialVal = e.target.src;
139
- initialLoad = false;
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
- else {
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>import FieldStandard from '../FieldStandard.svelte';
2
- import { ScreenReaderOnly, Modal, modifierKey } from '@txstate-mws/svelte-components';
3
- import { FontAwesomeIcons, IconCategories } from './iconpicker';
4
- import Icon from '@iconify/svelte';
5
- import { randomid, keyby } from 'txstate-utils';
6
- import { getDescribedBy } from '../helpers';
7
- export let id = undefined;
8
- export let path;
9
- export let label = '';
10
- export let required = false;
11
- export let defaultValue = { icon: 'fa-graduation-cap', prefix: 'fas' };
12
- export let conditional = undefined;
13
- export let helptext = undefined;
14
- const labelid = randomid();
15
- const descid = randomid();
16
- let modalOpen = false;
17
- let selected = defaultValue;
18
- const iconToPrefix = {};
19
- const categoriesToIcons = keyby(IconCategories, 'key');
20
- for (const icon of FontAwesomeIcons) {
21
- iconToPrefix[icon.class] = icon.free.includes('brands') ? 'fab' : 'fas';
22
- }
23
- const iconElements = [];
24
- let visibleIcons = FontAwesomeIcons;
25
- let searchVal = '';
26
- let category = 'all';
27
- $: iconCountMessage = visibleIcons.length === FontAwesomeIcons.length ? 'Showing all icons' : `Showing ${visibleIcons.length} icons`;
28
- function onSelectIcon(iconClass) {
29
- selected = { icon: iconClass, prefix: iconToPrefix[iconClass] };
30
- }
31
- function onSaveIconSelection(setVal) {
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
- setVal(selected);
34
- category = 'all';
35
- searchVal = '';
36
- visibleIcons = FontAwesomeIcons;
37
- modalOpen = false;
38
- };
39
- }
40
- function onCancel(val) {
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
- selected = val;
43
- category = 'all';
44
- searchVal = '';
45
- visibleIcons = FontAwesomeIcons;
46
- modalOpen = false;
47
- };
48
- }
49
- function onSearch() {
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
- const searchValLC = searchVal.toLowerCase();
52
- if (i.class.toLowerCase().includes(searchValLC))
53
- return true;
54
- for (const term of i.search.terms) {
55
- if (term.toLowerCase().includes(searchValLC))
56
- return true;
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
- onSelectIcon(visibleIcons[0].class);
73
+ onSelectIcon(visibleIcons[0].class)
62
74
  }
63
- }
64
- function onSelectCategory() {
75
+ }
76
+
77
+ function onSelectCategory () {
65
78
  if (category === 'all') {
66
- visibleIcons = FontAwesomeIcons;
67
- }
68
- else {
69
- visibleIcons = FontAwesomeIcons.filter(i => {
70
- return categoriesToIcons[category].icons.includes(i.class);
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
- onSelectIcon(visibleIcons[0].class);
86
+ onSelectIcon(visibleIcons[0].class)
75
87
  }
76
- }
77
- function onKeyDown(e) {
78
- const currentSelectionIndex = visibleIcons.findIndex(i => i.class === selected.icon);
79
- if (modifierKey(e))
80
- return;
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
- e.preventDefault();
84
- if (currentSelectionIndex === visibleIcons.length - 1) {
85
- newIndex = 0;
86
- }
87
- else {
88
- newIndex = currentSelectionIndex + 1;
89
- }
90
- onSelectIcon(visibleIcons[newIndex].class);
91
- iconElements[newIndex].focus();
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
- else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') {
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>