@dosgato/dialog 0.0.5 → 0.0.8
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/ButtonGroup.svelte +1 -1
- package/Checkbox.svelte +1 -1
- package/Container.svelte +5 -1
- package/FieldAutocomplete.svelte +62 -0
- package/FieldAutocomplete.svelte.d.ts +31 -0
- package/FieldCheckbox.svelte +1 -1
- package/FieldChoices.svelte +1 -1
- package/FieldChooserLink.svelte +2 -2
- package/FieldDate.svelte +1 -1
- package/FieldDateTime.svelte +1 -1
- package/FieldDualListbox.svelte +1 -1
- package/FieldMultiple.svelte +1 -1
- package/FieldMultiselect.svelte +1 -1
- package/FieldNumber.svelte +1 -1
- package/FieldRadio.svelte +1 -1
- package/FieldSelect.svelte +1 -1
- package/FieldSelect.svelte.d.ts +1 -1
- package/FieldStandard.svelte +1 -1
- package/FieldText.svelte +1 -1
- package/FileIcon.svelte +3 -47
- package/Form.svelte +1 -1
- package/Icon.svelte +1 -1
- package/InlineMessage.svelte +1 -1
- package/InlineMessages.svelte +1 -1
- package/Input.svelte +1 -1
- package/Listbox.svelte +1 -1
- package/Radio.svelte +1 -1
- package/Tab.svelte +1 -1
- package/TabStore.js +1 -0
- package/Tabs.svelte +1 -1
- package/chooser/Asset.svelte +1 -1
- package/chooser/AssetFolder.svelte +1 -1
- package/chooser/Chooser.svelte +1 -1
- package/chooser/ChooserStore.js +11 -9
- package/chooser/Details.svelte +2 -2
- package/chooser/Page.svelte +1 -1
- package/chooser/Thumbnail.svelte +1 -1
- package/fileIcons.d.ts +1 -0
- package/fileIcons.js +47 -0
- package/iconpicker/FieldIconPicker.svelte +256 -0
- package/iconpicker/FieldIconPicker.svelte.d.ts +24 -0
- package/iconpicker/iconpicker.d.ts +13 -0
- package/iconpicker/iconpicker.js +24784 -0
- package/iconpicker/index.d.ts +1 -0
- package/iconpicker/index.js +1 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +12 -6
|
@@ -0,0 +1,256 @@
|
|
|
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
|
+
export let id = undefined;
|
|
7
|
+
export let path;
|
|
8
|
+
export let label = '';
|
|
9
|
+
export let required = false;
|
|
10
|
+
export let defaultValue = { icon: 'fa-graduation-cap', prefix: 'fas' };
|
|
11
|
+
export let conditional = undefined;
|
|
12
|
+
const labelid = randomid();
|
|
13
|
+
const descid = randomid();
|
|
14
|
+
let modalOpen = false;
|
|
15
|
+
let selected = defaultValue;
|
|
16
|
+
const iconToPrefix = {};
|
|
17
|
+
const categoriesToIcons = keyby(IconCategories, 'key');
|
|
18
|
+
for (const icon of FontAwesomeIcons) {
|
|
19
|
+
iconToPrefix[icon.class] = icon.free.indexOf('brands') > -1 ? 'fab' : 'fas';
|
|
20
|
+
}
|
|
21
|
+
const iconElements = [];
|
|
22
|
+
let visibleIcons = FontAwesomeIcons;
|
|
23
|
+
let searchVal = '';
|
|
24
|
+
let category = 'all';
|
|
25
|
+
$: iconCountMessage = visibleIcons.length === FontAwesomeIcons.length ? 'Showing all icons' : `Showing ${visibleIcons.length} icons`;
|
|
26
|
+
function onSelectIcon(iconClass) {
|
|
27
|
+
selected = { icon: iconClass, prefix: iconToPrefix[iconClass] };
|
|
28
|
+
}
|
|
29
|
+
function onSaveIconSelection(setVal) {
|
|
30
|
+
return function () {
|
|
31
|
+
setVal(selected);
|
|
32
|
+
category = 'all';
|
|
33
|
+
searchVal = '';
|
|
34
|
+
visibleIcons = FontAwesomeIcons;
|
|
35
|
+
modalOpen = false;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function onCancel(val) {
|
|
39
|
+
return function () {
|
|
40
|
+
selected = val;
|
|
41
|
+
category = 'all';
|
|
42
|
+
searchVal = '';
|
|
43
|
+
visibleIcons = FontAwesomeIcons;
|
|
44
|
+
modalOpen = false;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function onSearch() {
|
|
48
|
+
visibleIcons = FontAwesomeIcons.filter(i => {
|
|
49
|
+
if (i.class.includes(searchVal))
|
|
50
|
+
return true;
|
|
51
|
+
for (const term of i.search.terms) {
|
|
52
|
+
if (term.includes(searchVal))
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
});
|
|
57
|
+
if (visibleIcons.findIndex(i => i.class === selected.icon) < 0) {
|
|
58
|
+
onSelectIcon(visibleIcons[0].class);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function onSelectCategory() {
|
|
62
|
+
if (category === 'all') {
|
|
63
|
+
visibleIcons = FontAwesomeIcons;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
visibleIcons = FontAwesomeIcons.filter(i => {
|
|
67
|
+
return categoriesToIcons[category].icons.includes(i.class);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (visibleIcons.findIndex(i => i.class === selected.icon) < 0) {
|
|
71
|
+
onSelectIcon(visibleIcons[0].class);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function onKeyDown(e) {
|
|
75
|
+
const currentSelectionIndex = visibleIcons.findIndex(i => i.class === selected.icon);
|
|
76
|
+
let newIndex;
|
|
77
|
+
if (modifierKey(e))
|
|
78
|
+
return;
|
|
79
|
+
else if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
if (currentSelectionIndex === visibleIcons.length - 1) {
|
|
82
|
+
newIndex = 0;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
newIndex = currentSelectionIndex + 1;
|
|
86
|
+
}
|
|
87
|
+
onSelectIcon(visibleIcons[newIndex].class);
|
|
88
|
+
iconElements[newIndex].focus();
|
|
89
|
+
}
|
|
90
|
+
else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
if (currentSelectionIndex === 0) {
|
|
93
|
+
newIndex = visibleIcons.length - 1;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
newIndex = currentSelectionIndex - 1;
|
|
97
|
+
}
|
|
98
|
+
onSelectIcon(visibleIcons[newIndex].class);
|
|
99
|
+
iconElements[newIndex].focus();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<FieldStandard bind:id {path} {label} {required} {defaultValue} {conditional} let:value let:valid let:invalid let:id let:onBlur let:setVal>
|
|
105
|
+
<Icon icon={`${value.prefix === 'fab' ? 'fa-brands' : 'fa-solid'}:${value.icon.slice(3)}`}/>
|
|
106
|
+
<button id="btnSelectIcon" on:click={() => { modalOpen = true }}>Select New Icon</button>
|
|
107
|
+
{#if modalOpen}
|
|
108
|
+
<Modal>
|
|
109
|
+
<section>
|
|
110
|
+
<header id={labelid}>
|
|
111
|
+
Select Icon
|
|
112
|
+
</header>
|
|
113
|
+
<div id={descid} class="content">
|
|
114
|
+
<div class="icon-modal-content">
|
|
115
|
+
<div class="filters">
|
|
116
|
+
<div class="search-wrapper">
|
|
117
|
+
<input bind:value={searchVal} id="search_for" placeholder="Search Icons" on:keyup={onSearch}/>
|
|
118
|
+
<label for="search_for" class="fa fa-search" rel="tooltip" title="search"></label>
|
|
119
|
+
</div>
|
|
120
|
+
<select bind:value={category} class="icon-category" aria-label="Select Category" on:change={onSelectCategory}>
|
|
121
|
+
<option value="all">All</option>
|
|
122
|
+
{#each IconCategories as category (category.key)}
|
|
123
|
+
<option value={category.key}>{category.label}</option>
|
|
124
|
+
{/each}
|
|
125
|
+
</select>
|
|
126
|
+
</div>
|
|
127
|
+
<fieldset tabindex="0">
|
|
128
|
+
<ScreenReaderOnly><legend class="sr-only">Icons</legend></ScreenReaderOnly>
|
|
129
|
+
<div class="icon-picker-items" role="radiogroup" on:keydown={onKeyDown}>
|
|
130
|
+
{#each visibleIcons as icon, idx (icon.class)}
|
|
131
|
+
<div bind:this={iconElements[idx]} id={icon.class} class="icon-picker-item" role="radio" aria-checked={icon.class === selected.icon} tabindex={icon.class === selected.icon ? 0 : -1} data-index={idx} on:click={() => onSelectIcon(icon.class)}>
|
|
132
|
+
<Icon icon={`${iconToPrefix[icon.class] === 'fab' ? 'fa-brands' : 'fa-solid'}:${icon.class.slice(3)}`}/>
|
|
133
|
+
<ScreenReaderOnly>{icon.label}</ScreenReaderOnly>
|
|
134
|
+
</div>
|
|
135
|
+
{:else}
|
|
136
|
+
<div id="no-icons">No Icons Found</div>
|
|
137
|
+
{/each}
|
|
138
|
+
</div>
|
|
139
|
+
<ScreenReaderOnly arialive="polite">{iconCountMessage}</ScreenReaderOnly>
|
|
140
|
+
</fieldset>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
<footer class="actions">
|
|
144
|
+
<button aria-describedby="{labelid} {descid}" on:click={onCancel(value)}>Cancel</button>
|
|
145
|
+
<button aria-describedby="{labelid} {descid}" on:click={onSaveIconSelection(setVal)}>Save Changes</button>
|
|
146
|
+
</footer>
|
|
147
|
+
</section>
|
|
148
|
+
</Modal>
|
|
149
|
+
{/if}
|
|
150
|
+
</FieldStandard>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
<style>
|
|
154
|
+
section {
|
|
155
|
+
position: relative;
|
|
156
|
+
background-color: #f4f4f4;
|
|
157
|
+
border-radius: 0.5em;
|
|
158
|
+
padding: 1em;
|
|
159
|
+
overflow: hidden;
|
|
160
|
+
width: 75vw;
|
|
161
|
+
min-width: 250px;
|
|
162
|
+
max-width: 650px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
footer {
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
justify-content: flex-end;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.icon-modal-content {
|
|
172
|
+
display:flex;
|
|
173
|
+
flex-direction: column;
|
|
174
|
+
height: 100%;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.icon-modal-content .filters {
|
|
178
|
+
display: flex;
|
|
179
|
+
justify-content: center;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.icon-modal-content .filters select {
|
|
183
|
+
width: 40%;
|
|
184
|
+
margin: 10px 0 5px 0;
|
|
185
|
+
height: 30px;
|
|
186
|
+
border-radius: 10px;
|
|
187
|
+
background-color: white;
|
|
188
|
+
border: 1px solid #999;
|
|
189
|
+
font-family: 'Nunito Sans', sans-serif !important;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.icon-modal-content fieldset {
|
|
193
|
+
max-height: 80%;
|
|
194
|
+
overflow-y: scroll;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* Styles for search field */
|
|
198
|
+
|
|
199
|
+
.search-wrapper{
|
|
200
|
+
position: relative;
|
|
201
|
+
margin-top: 10px;
|
|
202
|
+
margin-bottom: 5px;
|
|
203
|
+
margin-right: 15px;
|
|
204
|
+
align-self: center;
|
|
205
|
+
width: 50%;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
#search_for{
|
|
209
|
+
width: 90%;
|
|
210
|
+
border-radius: 10px;
|
|
211
|
+
border: 1px solid #999;
|
|
212
|
+
height: 30px;
|
|
213
|
+
padding: 0px 0px 0px 30px;
|
|
214
|
+
font-family: 'Nunito Sans', sans-serif !important;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
#search_for + label{
|
|
218
|
+
position: absolute;
|
|
219
|
+
left: 7px;
|
|
220
|
+
top: 7px;
|
|
221
|
+
color: #999;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Styles for the icon picker grid */
|
|
225
|
+
|
|
226
|
+
.icon-picker-items{
|
|
227
|
+
margin-top: 5px;
|
|
228
|
+
padding: 5px;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.icon-picker-item {
|
|
232
|
+
float: left;
|
|
233
|
+
margin: 0px 11px 12px 11px;
|
|
234
|
+
text-align: center;
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
color: inherit;
|
|
237
|
+
width: 10%;
|
|
238
|
+
position: relative;
|
|
239
|
+
font-size: 28px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.icon-picker-item[aria-checked=true] {
|
|
243
|
+
outline: 4px solid #93BBC4;
|
|
244
|
+
background-color: #eee;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* Message when no icons are returned from search */
|
|
248
|
+
#no-icons{
|
|
249
|
+
margin-top: 10px;
|
|
250
|
+
font-size: 1.5rem;
|
|
251
|
+
text-align: center;
|
|
252
|
+
vertical-align: middle;
|
|
253
|
+
line-height: 250px;
|
|
254
|
+
color: #999;
|
|
255
|
+
}
|
|
256
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
path: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
defaultValue?: {
|
|
9
|
+
icon: string;
|
|
10
|
+
prefix: string;
|
|
11
|
+
};
|
|
12
|
+
conditional?: boolean | undefined;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export declare type FieldIconPickerProps = typeof __propDef.props;
|
|
20
|
+
export declare type FieldIconPickerEvents = typeof __propDef.events;
|
|
21
|
+
export declare type FieldIconPickerSlots = typeof __propDef.slots;
|
|
22
|
+
export default class FieldIconPicker extends SvelteComponentTyped<FieldIconPickerProps, FieldIconPickerEvents, FieldIconPickerSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|