@dosgato/dialog 0.0.6 → 0.0.7
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/Container.svelte +4 -0
- package/FieldAutocomplete.svelte +62 -0
- package/FieldAutocomplete.svelte.d.ts +31 -0
- package/FileIcon.svelte +2 -46
- package/chooser/ChooserStore.js +9 -9
- package/chooser/Details.svelte +2 -2
- package/fileIcons.d.ts +1 -0
- package/fileIcons.js +47 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +3 -1
package/Container.svelte
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script>import { nullableSerialize, nullableDeserialize } from '@txstate-mws/svelte-forms';
|
|
2
|
+
import FieldStandard from './FieldStandard.svelte';
|
|
3
|
+
import { randomid } from 'txstate-utils';
|
|
4
|
+
import { PopupMenu, ScreenReaderOnly } from '@txstate-mws/svelte-components';
|
|
5
|
+
export let id = undefined;
|
|
6
|
+
export let path;
|
|
7
|
+
export let label = '';
|
|
8
|
+
export let placeholder = 'Select' + (label ? ' ' + label : '');
|
|
9
|
+
let className = '';
|
|
10
|
+
export { className as class };
|
|
11
|
+
export let notNull = false;
|
|
12
|
+
export let disabled = false;
|
|
13
|
+
export let choices;
|
|
14
|
+
export let defaultValue = notNull ? choices[0].value : undefined;
|
|
15
|
+
export let conditional = undefined;
|
|
16
|
+
export let required = false;
|
|
17
|
+
export let helptext = '';
|
|
18
|
+
let inputelement;
|
|
19
|
+
let inputvalue = '';
|
|
20
|
+
let popupvalue = undefined;
|
|
21
|
+
let savedLabel = '';
|
|
22
|
+
let changed = false;
|
|
23
|
+
if (defaultValue) {
|
|
24
|
+
const selected = choices.find(c => c.value === defaultValue);
|
|
25
|
+
inputvalue = selected.label || selected.value;
|
|
26
|
+
savedLabel = inputvalue;
|
|
27
|
+
}
|
|
28
|
+
const listId = randomid();
|
|
29
|
+
const liveTextId = randomid();
|
|
30
|
+
const helpTextId = randomid();
|
|
31
|
+
$: filteredChoices = changed
|
|
32
|
+
? choices.filter((item) => {
|
|
33
|
+
return item.label?.toLowerCase().includes(inputvalue.toLowerCase()) || item.value.toLowerCase().includes(inputvalue.toLowerCase());
|
|
34
|
+
})
|
|
35
|
+
: choices;
|
|
36
|
+
function onchangepopup(setVal) {
|
|
37
|
+
return (e) => {
|
|
38
|
+
inputvalue = e.detail.label || e.detail.value;
|
|
39
|
+
savedLabel = inputvalue;
|
|
40
|
+
popupvalue = undefined;
|
|
41
|
+
setVal(e.detail.value);
|
|
42
|
+
changed = false;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function checkifchanged(e) {
|
|
46
|
+
await setTimeout(function () {
|
|
47
|
+
if (inputelement.value !== savedLabel)
|
|
48
|
+
changed = true;
|
|
49
|
+
}, 1);
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} serialize={!notNull && nullableSerialize} deserialize={!notNull && nullableDeserialize} let:setVal let:valid let:invalid let:id let:onBlur let:onChange>
|
|
54
|
+
<input bind:this={inputelement} bind:value={inputvalue} {id} {placeholder} class="dialog-input {className}" class:valid class:invalid aria-invalid={invalid} {onBlur} {onChange} aria-owns={listId} autocapitalize="none" type="text" autocomplete="off" aria-autocomplete="list" role="combobox" aria-expanded="false" {disabled} aria-describedby={helptext.length ? helpTextId : ''} on:keydown={checkifchanged}>
|
|
55
|
+
<PopupMenu align="bottomleft" items={filteredChoices} buttonelement={inputelement} bind:value={popupvalue} on:change={onchangepopup(setVal)} emptyText="No options available"/>
|
|
56
|
+
{#if helptext.length}
|
|
57
|
+
<span id={helpTextId} class="field-help-text">{helptext}</span>
|
|
58
|
+
{/if}
|
|
59
|
+
<ScreenReaderOnly arialive="polite" ariaatomic={true} id={liveTextId}>
|
|
60
|
+
{filteredChoices.length} {filteredChoices.length === 1 ? 'option' : 'options'} available.
|
|
61
|
+
</ScreenReaderOnly>
|
|
62
|
+
</FieldStandard>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
path: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
class?: string;
|
|
9
|
+
notNull?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
choices: {
|
|
12
|
+
label?: string;
|
|
13
|
+
value: any;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
defaultValue?: any;
|
|
17
|
+
conditional?: boolean | undefined;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
helptext?: string;
|
|
20
|
+
};
|
|
21
|
+
events: {
|
|
22
|
+
[evt: string]: CustomEvent<any>;
|
|
23
|
+
};
|
|
24
|
+
slots: {};
|
|
25
|
+
};
|
|
26
|
+
export declare type FieldAutocompleteProps = typeof __propDef.props;
|
|
27
|
+
export declare type FieldAutocompleteEvents = typeof __propDef.events;
|
|
28
|
+
export declare type FieldAutocompleteSlots = typeof __propDef.slots;
|
|
29
|
+
export default class FieldAutocomplete extends SvelteComponentTyped<FieldAutocompleteProps, FieldAutocompleteEvents, FieldAutocompleteSlots> {
|
|
30
|
+
}
|
|
31
|
+
export {};
|
package/FileIcon.svelte
CHANGED
|
@@ -1,56 +1,12 @@
|
|
|
1
|
-
<script context="module">import archiveOutline from '@iconify-icons/mdi/archive-outline.js';
|
|
2
|
-
import fileCodeOutline from '@iconify-icons/mdi/file-code-outline.js';
|
|
3
|
-
import fileDocumentOutline from '@iconify-icons/mdi/file-document-outline.js';
|
|
4
|
-
import fileMusicOutline from '@iconify-icons/mdi/file-music-outline.js';
|
|
5
|
-
import fileOutline from '@iconify-icons/mdi/file-outline.js';
|
|
6
|
-
import fileTableOutline from '@iconify-icons/mdi/file-table-outline.js';
|
|
7
|
-
import fileVideoOutline from '@iconify-icons/mdi/file-video-outline.js';
|
|
8
|
-
import fileImageOutline from '@iconify-icons/mdi/file-image-outline.js';
|
|
9
|
-
import microsoftExcel from '@iconify-icons/mdi/microsoft-excel.js';
|
|
10
|
-
import microsoftWord from '@iconify-icons/mdi/microsoft-word.js';
|
|
11
|
-
import noteTextOutline from '@iconify-icons/mdi/note-text-outline.js';
|
|
12
|
-
const icons = {
|
|
13
|
-
'application/vnd.ms-excel': microsoftExcel,
|
|
14
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': microsoftExcel,
|
|
15
|
-
'application/vnd.oasis.opendocument.spreadsheet': microsoftExcel,
|
|
16
|
-
'text/csv': fileTableOutline,
|
|
17
|
-
'application/msword': microsoftWord,
|
|
18
|
-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': microsoftWord,
|
|
19
|
-
'application/vnd.oasis.opendocument.text': microsoftWord,
|
|
20
|
-
'application/rtf': microsoftWord,
|
|
21
|
-
'application/pdf': fileDocumentOutline,
|
|
22
|
-
'application/json': fileCodeOutline,
|
|
23
|
-
'application/x-httpd-php': fileCodeOutline,
|
|
24
|
-
'application/x-sh': fileCodeOutline,
|
|
25
|
-
'application/xml': fileCodeOutline,
|
|
26
|
-
'text/css': fileCodeOutline,
|
|
27
|
-
'text/html': fileCodeOutline,
|
|
28
|
-
'text/javascript': fileCodeOutline,
|
|
29
|
-
'application/gzip': archiveOutline,
|
|
30
|
-
'application/java-archive': archiveOutline,
|
|
31
|
-
'application/zip': archiveOutline,
|
|
32
|
-
'application/vnd.apple.installer+xml': archiveOutline,
|
|
33
|
-
'application/vnd.rar': archiveOutline,
|
|
34
|
-
'application/x-7z-compressed': archiveOutline,
|
|
35
|
-
'application/x-bzip': archiveOutline,
|
|
36
|
-
'application/x-bzip2': archiveOutline,
|
|
37
|
-
'application/x-tar': archiveOutline
|
|
38
|
-
};
|
|
39
|
-
const prefixes = {
|
|
40
|
-
image: fileImageOutline,
|
|
41
|
-
text: noteTextOutline,
|
|
42
|
-
video: fileVideoOutline,
|
|
43
|
-
audio: fileMusicOutline
|
|
44
|
-
};
|
|
45
|
-
</script>
|
|
46
1
|
<script>import Icon from './Icon.svelte';
|
|
2
|
+
import { iconForMime } from './fileIcons';
|
|
47
3
|
export let mime;
|
|
48
4
|
export let hiddenLabel = undefined;
|
|
49
5
|
export let inline = false;
|
|
50
6
|
export let width = '1em';
|
|
51
7
|
export let height = width;
|
|
52
8
|
export let vAlign = 'middle';
|
|
53
|
-
$: icon =
|
|
9
|
+
$: icon = iconForMime(mime);
|
|
54
10
|
</script>
|
|
55
11
|
|
|
56
12
|
<Icon {icon} {hiddenLabel} {inline} {width} {height} {vAlign} />
|
package/chooser/ChooserStore.js
CHANGED
|
@@ -58,7 +58,7 @@ export class ChooserStore extends SafeStore {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
if (this.value.preview)
|
|
61
|
-
await this.openPathRecursive(
|
|
61
|
+
await this.openPathRecursive(this.value.preview.path);
|
|
62
62
|
else if (this.options.initialPath)
|
|
63
63
|
await this.openPathRecursive(this.options.initialPath);
|
|
64
64
|
else
|
|
@@ -77,7 +77,7 @@ export class ChooserStore extends SafeStore {
|
|
|
77
77
|
return item;
|
|
78
78
|
}
|
|
79
79
|
async open(folder) {
|
|
80
|
-
return await this.openPath(
|
|
80
|
+
return await this.openPath(folder.path);
|
|
81
81
|
}
|
|
82
82
|
async openPath(path) {
|
|
83
83
|
const folder = this.itemByPath(this.value, path);
|
|
@@ -118,7 +118,7 @@ export class ChooserStore extends SafeStore {
|
|
|
118
118
|
if (!current || current.type === 'asset')
|
|
119
119
|
break;
|
|
120
120
|
if (!current.open) {
|
|
121
|
-
current.children = await filterAsync(await this.client.getChildren(source.name,
|
|
121
|
+
current.children = await filterAsync(await this.client.getChildren(source.name, current.path, this.options.passthruFilters), this.options.filter);
|
|
122
122
|
current.loading = false;
|
|
123
123
|
current.open = true;
|
|
124
124
|
}
|
|
@@ -132,12 +132,12 @@ export class ChooserStore extends SafeStore {
|
|
|
132
132
|
if (!current)
|
|
133
133
|
return v;
|
|
134
134
|
v.focus = current.id;
|
|
135
|
-
v.focusPath =
|
|
135
|
+
v.focusPath = current.path;
|
|
136
136
|
return v;
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
async close(folder) {
|
|
140
|
-
return await this.closePath(
|
|
140
|
+
return await this.closePath(folder.path);
|
|
141
141
|
}
|
|
142
142
|
async closePath(path) {
|
|
143
143
|
this.update(v => {
|
|
@@ -158,7 +158,7 @@ export class ChooserStore extends SafeStore {
|
|
|
158
158
|
return this.clearPreview();
|
|
159
159
|
if (item.type === 'folder' && !this.options.chooseFolder)
|
|
160
160
|
return;
|
|
161
|
-
this.update(v => ({ ...v, preview: item, focus: item.id, focusPath:
|
|
161
|
+
this.update(v => ({ ...v, preview: item, focus: item.id, focusPath: item.path }));
|
|
162
162
|
}
|
|
163
163
|
clearPreview() {
|
|
164
164
|
this.update(v => ({ ...v, preview: undefined }));
|
|
@@ -172,7 +172,7 @@ export class ChooserStore extends SafeStore {
|
|
|
172
172
|
if (source.children?.length) {
|
|
173
173
|
const firstchild = source.children[0];
|
|
174
174
|
v.focus = firstchild.id;
|
|
175
|
-
v.focusPath =
|
|
175
|
+
v.focusPath = firstchild.path;
|
|
176
176
|
}
|
|
177
177
|
return v;
|
|
178
178
|
});
|
|
@@ -182,7 +182,7 @@ export class ChooserStore extends SafeStore {
|
|
|
182
182
|
const source = this.getSource(v);
|
|
183
183
|
source.children = children;
|
|
184
184
|
v.focus = children[0]?.id;
|
|
185
|
-
v.focusPath = children[0] ?
|
|
185
|
+
v.focusPath = children[0] ? children[0]?.path : undefined;
|
|
186
186
|
return v;
|
|
187
187
|
});
|
|
188
188
|
}
|
|
@@ -195,7 +195,7 @@ export class ChooserStore extends SafeStore {
|
|
|
195
195
|
return;
|
|
196
196
|
this.update(v => {
|
|
197
197
|
v.focus = itm.id;
|
|
198
|
-
v.focusPath =
|
|
198
|
+
v.focusPath = itm.path;
|
|
199
199
|
return v;
|
|
200
200
|
});
|
|
201
201
|
}
|
package/chooser/Details.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { bytesToHuman
|
|
1
|
+
<script>import { bytesToHuman } from './ChooserStore';
|
|
2
2
|
export let item;
|
|
3
3
|
</script>
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ export let item;
|
|
|
11
11
|
{:else if item.type === 'page'}
|
|
12
12
|
<li>{item.title}</li>
|
|
13
13
|
{:else if item.type === 'folder'}
|
|
14
|
-
<li>{
|
|
14
|
+
<li>{item.path}</li>
|
|
15
15
|
{/if}
|
|
16
16
|
{#if item.type === 'asset'}
|
|
17
17
|
<li>{item.mime}</li>
|
package/fileIcons.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function iconForMime(mime: string): import("@iconify/types").IconifyIcon;
|
package/fileIcons.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import archiveOutline from '@iconify-icons/mdi/archive-outline.js';
|
|
2
|
+
import fileCodeOutline from '@iconify-icons/mdi/file-code-outline.js';
|
|
3
|
+
import fileDocumentOutline from '@iconify-icons/mdi/file-document-outline.js';
|
|
4
|
+
import fileMusicOutline from '@iconify-icons/mdi/file-music-outline.js';
|
|
5
|
+
import fileOutline from '@iconify-icons/mdi/file-outline.js';
|
|
6
|
+
import fileTableOutline from '@iconify-icons/mdi/file-table-outline.js';
|
|
7
|
+
import fileVideoOutline from '@iconify-icons/mdi/file-video-outline.js';
|
|
8
|
+
import fileImageOutline from '@iconify-icons/mdi/file-image-outline.js';
|
|
9
|
+
import microsoftExcel from '@iconify-icons/mdi/microsoft-excel.js';
|
|
10
|
+
import microsoftWord from '@iconify-icons/mdi/microsoft-word.js';
|
|
11
|
+
import noteTextOutline from '@iconify-icons/mdi/note-text-outline.js';
|
|
12
|
+
const fileIconsByMime = {
|
|
13
|
+
'application/vnd.ms-excel': microsoftExcel,
|
|
14
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': microsoftExcel,
|
|
15
|
+
'application/vnd.oasis.opendocument.spreadsheet': microsoftExcel,
|
|
16
|
+
'text/csv': fileTableOutline,
|
|
17
|
+
'application/msword': microsoftWord,
|
|
18
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': microsoftWord,
|
|
19
|
+
'application/vnd.oasis.opendocument.text': microsoftWord,
|
|
20
|
+
'application/rtf': microsoftWord,
|
|
21
|
+
'application/pdf': fileDocumentOutline,
|
|
22
|
+
'application/json': fileCodeOutline,
|
|
23
|
+
'application/x-httpd-php': fileCodeOutline,
|
|
24
|
+
'application/x-sh': fileCodeOutline,
|
|
25
|
+
'application/xml': fileCodeOutline,
|
|
26
|
+
'text/css': fileCodeOutline,
|
|
27
|
+
'text/html': fileCodeOutline,
|
|
28
|
+
'text/javascript': fileCodeOutline,
|
|
29
|
+
'application/gzip': archiveOutline,
|
|
30
|
+
'application/java-archive': archiveOutline,
|
|
31
|
+
'application/zip': archiveOutline,
|
|
32
|
+
'application/vnd.apple.installer+xml': archiveOutline,
|
|
33
|
+
'application/vnd.rar': archiveOutline,
|
|
34
|
+
'application/x-7z-compressed': archiveOutline,
|
|
35
|
+
'application/x-bzip': archiveOutline,
|
|
36
|
+
'application/x-bzip2': archiveOutline,
|
|
37
|
+
'application/x-tar': archiveOutline
|
|
38
|
+
};
|
|
39
|
+
const prefixes = {
|
|
40
|
+
image: fileImageOutline,
|
|
41
|
+
text: noteTextOutline,
|
|
42
|
+
video: fileVideoOutline,
|
|
43
|
+
audio: fileMusicOutline
|
|
44
|
+
};
|
|
45
|
+
export function iconForMime(mime) {
|
|
46
|
+
return fileIconsByMime[mime] ?? prefixes[mime.split('/', 2)[0]] ?? fileOutline;
|
|
47
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Checkbox } from './Checkbox.svelte';
|
|
2
2
|
export { default as Container } from './Container.svelte';
|
|
3
|
+
export { default as FieldAutocomplete } from './FieldAutocomplete.svelte';
|
|
3
4
|
export { default as FieldCheckbox } from './FieldCheckbox.svelte';
|
|
4
5
|
export { default as FieldChoices } from './FieldChoices.svelte';
|
|
5
6
|
export { default as FieldChooserLink } from './FieldChooserLink.svelte';
|
|
@@ -23,4 +24,5 @@ export { default as Tab } from './Tab.svelte';
|
|
|
23
24
|
export { default as Tabs } from './Tabs.svelte';
|
|
24
25
|
export { default as Listbox } from './Listbox.svelte';
|
|
25
26
|
export * from './chooser/index.js';
|
|
27
|
+
export * from './fileIcons.js';
|
|
26
28
|
export * from './TabStore.js';
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Checkbox } from './Checkbox.svelte';
|
|
2
2
|
export { default as Container } from './Container.svelte';
|
|
3
|
+
export { default as FieldAutocomplete } from './FieldAutocomplete.svelte';
|
|
3
4
|
export { default as FieldCheckbox } from './FieldCheckbox.svelte';
|
|
4
5
|
export { default as FieldChoices } from './FieldChoices.svelte';
|
|
5
6
|
export { default as FieldChooserLink } from './FieldChooserLink.svelte';
|
|
@@ -23,4 +24,5 @@ export { default as Tab } from './Tab.svelte';
|
|
|
23
24
|
export { default as Tabs } from './Tabs.svelte';
|
|
24
25
|
export { default as Listbox } from './Listbox.svelte';
|
|
25
26
|
export * from './chooser/index.js';
|
|
27
|
+
export * from './fileIcons.js';
|
|
26
28
|
export * from './TabStore.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dosgato/dialog",
|
|
3
3
|
"description": "A component library for building forms that edit a JSON document.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@txstate-mws/svelte-components": "^1.2.9",
|
|
7
7
|
"@txstate-mws/svelte-forms": "^0.0.18",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"./ButtonGroup.svelte": "./ButtonGroup.svelte",
|
|
28
28
|
"./Checkbox.svelte": "./Checkbox.svelte",
|
|
29
29
|
"./Container.svelte": "./Container.svelte",
|
|
30
|
+
"./FieldAutocomplete.svelte": "./FieldAutocomplete.svelte",
|
|
30
31
|
"./FieldCheckbox.svelte": "./FieldCheckbox.svelte",
|
|
31
32
|
"./FieldChoices.svelte": "./FieldChoices.svelte",
|
|
32
33
|
"./FieldChooserLink.svelte": "./FieldChooserLink.svelte",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"./chooser/Page.svelte": "./chooser/Page.svelte",
|
|
61
62
|
"./chooser/Thumbnail.svelte": "./chooser/Thumbnail.svelte",
|
|
62
63
|
"./chooser": "./chooser/index.js",
|
|
64
|
+
"./fileIcons": "./fileIcons.js",
|
|
63
65
|
".": "./index.js"
|
|
64
66
|
},
|
|
65
67
|
"svelte": "./index.js"
|