@dosgato/dialog 0.0.20 → 0.0.22
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/Button.svelte.d.ts +3 -3
- package/ButtonGroup.svelte.d.ts +3 -3
- package/Checkbox.svelte.d.ts +3 -3
- package/Container.svelte.d.ts +3 -3
- package/Dialog.svelte +22 -4
- package/Dialog.svelte.d.ts +5 -4
- package/FieldAutocomplete.svelte.d.ts +3 -3
- package/FieldCheckbox.svelte.d.ts +3 -3
- package/FieldChoices.svelte.d.ts +3 -3
- package/FieldChooserLink.svelte +14 -12
- package/FieldChooserLink.svelte.d.ts +3 -5
- package/FieldDate.svelte.d.ts +3 -3
- package/FieldDateTime.svelte.d.ts +3 -3
- package/FieldDualListbox.svelte.d.ts +3 -3
- package/FieldHidden.svelte.d.ts +3 -3
- package/FieldIdentifier.svelte.d.ts +3 -3
- package/FieldMultiple.svelte.d.ts +3 -3
- package/FieldMultiselect.svelte.d.ts +3 -3
- package/FieldNumber.svelte.d.ts +3 -3
- package/FieldRadio.svelte.d.ts +3 -3
- package/FieldSelect.svelte.d.ts +3 -3
- package/FieldStandard.svelte.d.ts +3 -3
- package/FieldText.svelte.d.ts +3 -3
- package/FieldTextArea.svelte.d.ts +3 -3
- package/FileIcon.svelte.d.ts +3 -3
- package/Form.svelte.d.ts +3 -3
- package/FormDialog.svelte.d.ts +3 -3
- package/Icon.svelte.d.ts +3 -3
- package/InlineMessage.svelte.d.ts +3 -3
- package/InlineMessages.svelte.d.ts +3 -3
- package/Input.svelte.d.ts +3 -3
- package/Listbox.svelte.d.ts +3 -3
- package/Radio.svelte.d.ts +3 -3
- package/Tab.svelte.d.ts +3 -3
- package/TabStore.d.ts +3 -0
- package/TabStore.js +12 -0
- package/Tabs.svelte +5 -4
- package/Tabs.svelte.d.ts +3 -3
- package/chooser/Chooser.svelte +76 -99
- package/chooser/Chooser.svelte.d.ts +5 -5
- package/chooser/ChooserAPI.d.ts +10 -3
- package/chooser/ChooserStore.d.ts +15 -33
- package/chooser/ChooserStore.js +32 -149
- package/chooser/Details.svelte.d.ts +6 -5
- package/chooser/Thumbnail.svelte +9 -2
- package/chooser/Thumbnail.svelte.d.ts +6 -5
- package/colorpicker/FieldColorPicker.svelte +78 -24
- package/colorpicker/FieldColorPicker.svelte.d.ts +5 -6
- package/iconpicker/FieldIconPicker.svelte +4 -2
- package/iconpicker/FieldIconPicker.svelte.d.ts +4 -3
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +9 -6
- package/tree/LoadIcon.svelte +24 -0
- package/tree/LoadIcon.svelte.d.ts +23 -0
- package/tree/Tree.svelte +204 -0
- package/tree/Tree.svelte.d.ts +30 -0
- package/tree/TreeCell.svelte +18 -0
- package/tree/TreeCell.svelte.d.ts +18 -0
- package/tree/TreeNode.svelte +418 -0
- package/tree/TreeNode.svelte.d.ts +30 -0
- package/tree/index.d.ts +3 -0
- package/tree/index.js +3 -0
- package/tree/treestore.d.ts +117 -0
- package/tree/treestore.js +336 -0
- package/chooser/Asset.svelte +0 -83
- package/chooser/Asset.svelte.d.ts +0 -25
- package/chooser/AssetFolder.svelte +0 -127
- package/chooser/AssetFolder.svelte.d.ts +0 -25
- package/chooser/Page.svelte +0 -121
- package/chooser/Page.svelte.d.ts +0 -25
package/TabStore.js
CHANGED
|
@@ -23,11 +23,20 @@ export class TabStore extends Store {
|
|
|
23
23
|
this.initialTab = initialTab;
|
|
24
24
|
}
|
|
25
25
|
set(v) {
|
|
26
|
+
v.tabids ??= {};
|
|
27
|
+
v.panelids ??= {};
|
|
28
|
+
for (const tab of v.tabs) {
|
|
29
|
+
v.tabids[tab.title] ??= randomid();
|
|
30
|
+
v.panelids[tab.title] ??= randomid();
|
|
31
|
+
}
|
|
26
32
|
super.set(checkNext(v));
|
|
27
33
|
}
|
|
28
34
|
currentIdx() {
|
|
29
35
|
return derivedStore(this, v => v.current);
|
|
30
36
|
}
|
|
37
|
+
currentName() {
|
|
38
|
+
return derivedStore(this, v => v.tabs[v.current].name ?? v.tabs[v.current].title);
|
|
39
|
+
}
|
|
31
40
|
currentTitle() {
|
|
32
41
|
return derivedStore(this, v => v.tabs[v.current].title);
|
|
33
42
|
}
|
|
@@ -55,4 +64,7 @@ export class TabStore extends Store {
|
|
|
55
64
|
activate(idx) {
|
|
56
65
|
this.update(v => ({ ...v, current: Math.min(v.tabs.length, Math.max(0, idx)) }));
|
|
57
66
|
}
|
|
67
|
+
activateName(name) {
|
|
68
|
+
this.update(v => ({ ...v, current: findIndex(v.tabs, t => t.name === name) ?? findIndex(v.tabs, t => t.title === name) ?? v.current }));
|
|
69
|
+
}
|
|
58
70
|
}
|
package/Tabs.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { modifierKey, resize, offset } from '@txstate-mws/svelte-components';
|
|
2
2
|
import { Store } from '@txstate-mws/svelte-store';
|
|
3
|
-
import { getContext, setContext } from 'svelte';
|
|
3
|
+
import { getContext, onMount, setContext } from 'svelte';
|
|
4
4
|
import { roundTo } from 'txstate-utils';
|
|
5
5
|
import { DIALOG_TABS_CONTEXT } from './Dialog.svelte';
|
|
6
6
|
import Icon from './Icon.svelte';
|
|
@@ -8,19 +8,19 @@ import { TabStore, TAB_CONTEXT } from './TabStore';
|
|
|
8
8
|
export let tabs;
|
|
9
9
|
export let active = undefined;
|
|
10
10
|
export let store = new TabStore(tabs, active);
|
|
11
|
-
|
|
11
|
+
$: store.update(v => ({ ...v, tabs }));
|
|
12
12
|
const activeStore = new Store({});
|
|
13
13
|
const tabelements = [];
|
|
14
14
|
let activeelement;
|
|
15
15
|
setContext(TAB_CONTEXT, { store, onClick, onKeyDown, tabelements });
|
|
16
|
-
const dialogContext = getContext(DIALOG_TABS_CONTEXT);
|
|
16
|
+
const dialogContext = getContext(DIALOG_TABS_CONTEXT) ?? { change: () => { } };
|
|
17
17
|
dialogContext.onNext = () => { store.right(); };
|
|
18
18
|
dialogContext.onPrev = () => { store.left(); };
|
|
19
19
|
$: dialogContext.prevTitle = $store.prevTitle;
|
|
20
20
|
$: dialogContext.nextTitle = $store.nextTitle;
|
|
21
21
|
$: dialogContext.hasRequired = $store.requireNext;
|
|
22
22
|
$: dialogContext.change($store);
|
|
23
|
-
setContext(DIALOG_TABS_CONTEXT, {}); // reset context so that any sub-tabs do NOT control the Dialog component
|
|
23
|
+
setContext(DIALOG_TABS_CONTEXT, { change: () => { } }); // reset context so that any sub-tabs do NOT control the Dialog component
|
|
24
24
|
const currentTitle = store.currentTitle();
|
|
25
25
|
const currentIdx = store.currentIdx();
|
|
26
26
|
const accordion = store.accordion();
|
|
@@ -80,6 +80,7 @@ async function reactToCurrent(..._) {
|
|
|
80
80
|
}
|
|
81
81
|
$: active = $currentTitle;
|
|
82
82
|
$: reactToCurrent($activeStore);
|
|
83
|
+
onMount(reactToCurrent);
|
|
83
84
|
</script>
|
|
84
85
|
|
|
85
86
|
{#if !$accordion}
|
package/Tabs.svelte.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ declare const __propDef: {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
18
|
+
export type TabsProps = typeof __propDef.props;
|
|
19
|
+
export type TabsEvents = typeof __propDef.events;
|
|
20
|
+
export type TabsSlots = typeof __propDef.slots;
|
|
21
21
|
export default class Tabs extends SvelteComponentTyped<TabsProps, TabsEvents, TabsSlots> {
|
|
22
22
|
}
|
|
23
23
|
export {};
|
package/chooser/Chooser.svelte
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
<script>import applicationOutline from '@iconify-icons/mdi/application-outline';
|
|
2
|
+
import folderLight from '@iconify-icons/ph/folder-light';
|
|
3
|
+
import folderNotchOpenLight from '@iconify-icons/ph/folder-notch-open-light';
|
|
4
4
|
import { derivedStore } from '@txstate-mws/svelte-store';
|
|
5
5
|
import { createEventDispatcher, getContext, onMount, setContext } from 'svelte';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import AssetFolder from './AssetFolder.svelte';
|
|
9
|
-
import ButtonGroup from '../ButtonGroup.svelte';
|
|
6
|
+
import { isNotBlank } from 'txstate-utils';
|
|
7
|
+
import { Dialog, iconForMime, Tabs, Tree, TreeStore } from '..';
|
|
10
8
|
import { CHOOSER_API_CONTEXT } from './ChooserAPI';
|
|
11
9
|
import { CHOOSER_STORE_CONTEXT, ChooserStore } from './ChooserStore';
|
|
12
10
|
import Details from './Details.svelte';
|
|
13
|
-
import Icon from '../Icon.svelte';
|
|
14
|
-
import Page from './Page.svelte';
|
|
15
11
|
import Thumbnail from './Thumbnail.svelte';
|
|
16
12
|
const chooserClient = getContext(CHOOSER_API_CONTEXT);
|
|
17
13
|
export let label = undefined;
|
|
@@ -19,7 +15,7 @@ export let images = false;
|
|
|
19
15
|
export let pages = false;
|
|
20
16
|
export let assets = images;
|
|
21
17
|
export let folders = false;
|
|
22
|
-
export let
|
|
18
|
+
export let required = false;
|
|
23
19
|
export let initialSource = undefined;
|
|
24
20
|
export let initialPath = undefined;
|
|
25
21
|
export let activeSources = undefined;
|
|
@@ -27,99 +23,103 @@ export let passthruFilters = undefined;
|
|
|
27
23
|
export let filter = undefined;
|
|
28
24
|
export let store = new ChooserStore(chooserClient);
|
|
29
25
|
setContext(CHOOSER_STORE_CONTEXT, store);
|
|
30
|
-
$: if (!pages && !assets)
|
|
31
|
-
assets = true;
|
|
32
|
-
$: activeTypes = [...(assets ? ['asset'] : []), ...(pages ? ['page'] : [])];
|
|
33
26
|
const dispatch = createEventDispatcher();
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
let tabStore;
|
|
28
|
+
const { sources, source, preview } = store;
|
|
29
|
+
$: currentName = tabStore?.currentName();
|
|
30
|
+
async function fetchChildren(item) {
|
|
31
|
+
if (item?.type === 'asset' || !$source)
|
|
32
|
+
return [];
|
|
33
|
+
const children = await chooserClient.getChildren($source.name, item?.path ?? '/', filter);
|
|
34
|
+
return children.map(c => ({ ...c, children: undefined }));
|
|
35
|
+
}
|
|
36
|
+
const treeStore = new TreeStore(fetchChildren);
|
|
37
|
+
const selected = derivedStore(treeStore, 'selectedItems.0');
|
|
38
|
+
$: store.setSource($currentName);
|
|
39
|
+
$: selectPreview($preview, $source);
|
|
40
|
+
$: if (['asset', 'page'].includes($selected?.type))
|
|
41
|
+
store.setPreview($selected);
|
|
39
42
|
function onChoose() {
|
|
40
43
|
dispatch('change', $store.preview);
|
|
41
44
|
}
|
|
45
|
+
function onDeselect() {
|
|
46
|
+
store.setPreview(undefined);
|
|
47
|
+
}
|
|
48
|
+
async function openRecursive(pathSplit, depth) {
|
|
49
|
+
console.log($treeStore.rootItems);
|
|
50
|
+
let curr = $treeStore.rootItems?.find(itm => itm.name === pathSplit[0]);
|
|
51
|
+
for (let i = 0; i < depth; i++) {
|
|
52
|
+
curr = curr?.children?.find(c => c.name === pathSplit[i + 1]);
|
|
53
|
+
}
|
|
54
|
+
if (!curr)
|
|
55
|
+
return;
|
|
56
|
+
await treeStore.open(curr, false);
|
|
57
|
+
if (depth + 1 >= pathSplit.length)
|
|
58
|
+
return curr;
|
|
59
|
+
return await openRecursive(pathSplit, depth + 1);
|
|
60
|
+
}
|
|
61
|
+
async function selectPreview(..._) {
|
|
62
|
+
if (!$store.initialized)
|
|
63
|
+
return;
|
|
64
|
+
await treeStore.refresh(undefined);
|
|
65
|
+
const preloadSource = $preview?.source ?? initialSource;
|
|
66
|
+
if ($source?.name !== preloadSource)
|
|
67
|
+
return;
|
|
68
|
+
const preloadPath = $store.preview?.path ?? initialPath;
|
|
69
|
+
initialSource = undefined;
|
|
70
|
+
initialPath = undefined;
|
|
71
|
+
if (preloadPath) {
|
|
72
|
+
const currentSelection = await openRecursive(preloadPath.split('/').filter(isNotBlank), 0);
|
|
73
|
+
treeStore.trigger();
|
|
74
|
+
if (!currentSelection)
|
|
75
|
+
return;
|
|
76
|
+
store.setPreview(currentSelection);
|
|
77
|
+
treeStore.select(currentSelection, {});
|
|
78
|
+
treeStore.trigger();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
42
81
|
onMount(async () => {
|
|
43
|
-
await store.init({
|
|
44
|
-
|
|
45
|
-
|
|
82
|
+
await store.init({ images, pages, assets, folders, activeSources, initialSource, initialPath, passthruFilters, filter });
|
|
83
|
+
tabStore.activateName($source.name);
|
|
84
|
+
await selectPreview();
|
|
46
85
|
});
|
|
47
86
|
</script>
|
|
48
87
|
|
|
49
|
-
<
|
|
88
|
+
<Dialog size="xl" ignoreTabs title={label} on:escape continueText="Choose" disabled={!$store.preview && required} cancelText="Cancel" on:continue={onChoose}>
|
|
50
89
|
<section class="dialog-chooser-window">
|
|
51
|
-
<header>
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
<ButtonGroup value={$store.activetype} choices={[{ value: 'asset', label: 'Assets' }, { value: 'page', label: 'Pages' }]} ariaControls={listid} on:change={e => store.setActiveType(e.detail)} />
|
|
55
|
-
{/if}
|
|
56
|
-
{#if $sources.length > 1}
|
|
57
|
-
<div class="dialog-chooser-source">
|
|
58
|
-
<select on:change={function () { store.changeSource(Number(this.value)) }}>
|
|
59
|
-
{#each $sources as source, i}
|
|
60
|
-
<option value={i}>{source.label || source.name}</option>
|
|
61
|
-
{/each}
|
|
62
|
-
</select>
|
|
63
|
-
</div>
|
|
64
|
-
{/if}
|
|
65
|
-
</div>
|
|
66
|
-
<div id={chooserheadid} class="dialog-chooser-label">
|
|
67
|
-
{label}
|
|
68
|
-
</div>
|
|
69
|
-
{#if $source?.type === 'asset'}
|
|
70
|
-
<div class="dialog-chooser-view">
|
|
71
|
-
<button type="button"><Icon icon={fileTree} /></button>
|
|
72
|
-
<button type="button"><Icon icon={viewGrid} /></button>
|
|
73
|
-
</div>
|
|
90
|
+
<header class="dialog-chooser-controls">
|
|
91
|
+
{#if $sources.length > 1}
|
|
92
|
+
<Tabs bind:store={tabStore} tabs={$sources.map(s => ({ id: s.name, title: s.label ?? s.name }))} />
|
|
74
93
|
{/if}
|
|
75
94
|
</header>
|
|
76
95
|
<section class="dialog-chooser-chooser">
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{@const prev = $source.children[i - 1]}
|
|
83
|
-
{@const next = $source.children[i + 1]}
|
|
84
|
-
{#if child.type === 'folder'}
|
|
85
|
-
<AssetFolder folder={child} {setsize} {posinset} level={1} {prev} {next} on:choose={onChoose} />
|
|
86
|
-
{:else if child.type === 'page'}
|
|
87
|
-
<Page page={child} {setsize} {posinset} level={1} {prev} {next} on:choose={onChoose} />
|
|
88
|
-
{:else}
|
|
89
|
-
<Asset asset={child} {setsize} {posinset} level={1} {prev} {next} on:choose={onChoose} />
|
|
90
|
-
{/if}
|
|
91
|
-
{/each}
|
|
92
|
-
</ul>
|
|
93
|
-
</Loading>
|
|
96
|
+
{#if $store.initialized}
|
|
97
|
+
<Tree headers={[
|
|
98
|
+
{ label: 'Path', id: 'name', grow: 4, icon: item => item.type === 'asset' ? iconForMime(item.mime) : (item.type === 'folder' ? (item.open ? folderNotchOpenLight : folderLight) : applicationOutline), get: 'name' }
|
|
99
|
+
]} singleSelect store={treeStore} on:deselect={onDeselect} on:choose={onChoose} />
|
|
100
|
+
{/if}
|
|
94
101
|
</section>
|
|
95
102
|
<section class="dialog-chooser-preview" tabindex="-1">
|
|
96
103
|
{#if $preview}
|
|
97
104
|
<Thumbnail item={$preview} />
|
|
98
105
|
<Details item={$preview}>
|
|
99
106
|
{#if $preview.type === 'folder'}
|
|
100
|
-
<li>{$
|
|
107
|
+
<li>{$selected.children?.length || 0} sub-items</li>
|
|
101
108
|
{/if}
|
|
102
109
|
</Details>
|
|
103
110
|
{/if}
|
|
104
111
|
</section>
|
|
105
|
-
<footer>
|
|
106
|
-
<button type="button" on:click={() => dispatch('escape')}>Cancel</button>
|
|
107
|
-
<button type="button" disabled={!$store.preview} on:click={onChoose}>Choose</button>
|
|
108
|
-
</footer>
|
|
109
112
|
</section>
|
|
110
|
-
</
|
|
113
|
+
</Dialog>
|
|
111
114
|
|
|
112
115
|
<style>
|
|
113
116
|
.dialog-chooser-window {
|
|
114
117
|
position: relative;
|
|
115
|
-
width: 80vw;
|
|
116
118
|
height: 80vh;
|
|
117
|
-
background-color: lightgray;
|
|
118
119
|
display: flex;
|
|
119
120
|
flex-wrap: wrap;
|
|
120
121
|
align-items: stretch;
|
|
121
122
|
justify-content: flex-end;
|
|
122
|
-
padding: 1em;
|
|
123
123
|
overflow: hidden;
|
|
124
124
|
}
|
|
125
125
|
.dialog-chooser-window * {
|
|
@@ -127,45 +127,22 @@ onMount(async () => {
|
|
|
127
127
|
}
|
|
128
128
|
.dialog-chooser-chooser {
|
|
129
129
|
position: relative;
|
|
130
|
-
width:
|
|
130
|
+
width: 75%;
|
|
131
|
+
min-width: calc(100% - 21em);
|
|
131
132
|
height: calc(100% - 4em);
|
|
132
133
|
background-color: white;
|
|
133
134
|
padding: 0.5em;
|
|
134
135
|
overflow: auto;
|
|
135
136
|
}
|
|
136
137
|
.dialog-chooser-preview {
|
|
137
|
-
width:
|
|
138
|
+
width: 25%;
|
|
139
|
+
max-width: 21em;
|
|
138
140
|
height: calc(100% - 4em);
|
|
139
141
|
padding: 1em;
|
|
140
142
|
overflow-y: auto;
|
|
141
143
|
}
|
|
142
144
|
header {
|
|
145
|
+
position: relative;
|
|
143
146
|
width: 100%;
|
|
144
|
-
height: 2em;
|
|
145
|
-
text-align: center;
|
|
146
|
-
font-weight: bold;
|
|
147
|
-
display: flex;
|
|
148
|
-
align-items: center;
|
|
149
147
|
}
|
|
150
|
-
.dialog-chooser-label {
|
|
151
|
-
flex-grow: 1;
|
|
152
|
-
}
|
|
153
|
-
.dialog-chooser-controls {
|
|
154
|
-
display: flex;
|
|
155
|
-
}
|
|
156
|
-
.dialog-chooser-list {
|
|
157
|
-
list-style: none;
|
|
158
|
-
padding: 0;
|
|
159
|
-
margin: 0;
|
|
160
|
-
}
|
|
161
|
-
.dialog-chooser-list :global(li) {
|
|
162
|
-
line-height: 1;
|
|
163
|
-
padding: 0.25em 0;
|
|
164
|
-
border-bottom: 1px solid var(--asset-chooser-border, #AAAAAA);
|
|
165
|
-
}
|
|
166
|
-
.dialog-chooser-list :global(.isPreview) {
|
|
167
|
-
background-color: var(--asset-chooser-active-bg, #333333);
|
|
168
|
-
color: var(--asset-chooser-active, #FFFFFF);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
148
|
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import { type AnyItem
|
|
2
|
+
import { type AnyItem } from './ChooserAPI';
|
|
3
3
|
import { ChooserStore } from './ChooserStore';
|
|
4
4
|
declare class __sveltets_Render<F> {
|
|
5
5
|
props(): {
|
|
@@ -8,7 +8,7 @@ declare class __sveltets_Render<F> {
|
|
|
8
8
|
pages?: boolean;
|
|
9
9
|
assets?: boolean;
|
|
10
10
|
folders?: boolean;
|
|
11
|
-
|
|
11
|
+
required?: boolean;
|
|
12
12
|
initialSource?: string;
|
|
13
13
|
initialPath?: string;
|
|
14
14
|
activeSources?: string[];
|
|
@@ -24,9 +24,9 @@ declare class __sveltets_Render<F> {
|
|
|
24
24
|
};
|
|
25
25
|
slots(): {};
|
|
26
26
|
}
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
27
|
+
export type ChooserProps<F> = ReturnType<__sveltets_Render<F>['props']>;
|
|
28
|
+
export type ChooserEvents<F> = ReturnType<__sveltets_Render<F>['events']>;
|
|
29
|
+
export type ChooserSlots<F> = ReturnType<__sveltets_Render<F>['slots']>;
|
|
30
30
|
export default class Chooser<F> extends SvelteComponentTyped<ChooserProps<F>, ChooserEvents<F>, ChooserSlots<F>> {
|
|
31
31
|
}
|
|
32
32
|
export {};
|
package/chooser/ChooserAPI.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const CHOOSER_API_CONTEXT: {};
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type ChooserType = 'asset' | 'page';
|
|
3
|
+
export type AnyItem = Asset | Folder | Page;
|
|
4
4
|
export interface Client<F = any> {
|
|
5
5
|
getSources: (type: ChooserType) => Promise<Source[]>;
|
|
6
6
|
getChildren: (source: string, path: string, filters: F) => Promise<AnyItem[]>;
|
|
@@ -24,20 +24,27 @@ interface Item {
|
|
|
24
24
|
* PageLink (see dosgato-templating/src/links.ts)
|
|
25
25
|
*/
|
|
26
26
|
id: string;
|
|
27
|
+
/**
|
|
28
|
+
* path to the item, MUST include the item itself, so ends with /${name}
|
|
29
|
+
*/
|
|
27
30
|
path: string;
|
|
28
31
|
name: string;
|
|
32
|
+
source: string;
|
|
29
33
|
}
|
|
30
34
|
export interface Folder extends Item {
|
|
31
35
|
type: 'folder';
|
|
36
|
+
hasChildren: boolean;
|
|
32
37
|
acceptsUpload: boolean;
|
|
33
38
|
}
|
|
34
39
|
export interface Page extends Item {
|
|
35
40
|
type: 'page';
|
|
41
|
+
title?: string;
|
|
42
|
+
hasChildren: boolean;
|
|
36
43
|
url: string;
|
|
37
|
-
title: string;
|
|
38
44
|
}
|
|
39
45
|
export interface Asset extends Item {
|
|
40
46
|
type: 'asset';
|
|
47
|
+
title?: string;
|
|
41
48
|
mime: string;
|
|
42
49
|
bytes: number;
|
|
43
50
|
url: string;
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TypedTreeItem } from '../tree/treestore.js';
|
|
2
|
+
import { Store } from '@txstate-mws/svelte-store';
|
|
2
3
|
import type { AnyItem, Asset, Client, ChooserType, Folder, Page, Source } from './ChooserAPI.js';
|
|
3
4
|
export interface UISource extends Source {
|
|
4
5
|
children?: AnyUIItem[];
|
|
5
6
|
}
|
|
6
|
-
export interface UIFolder extends Folder {
|
|
7
|
-
children?: (UIFolder | UIAsset)[];
|
|
8
|
-
open?: boolean;
|
|
9
|
-
loading?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface UIPage extends Page {
|
|
12
|
-
children?: UIPage[];
|
|
13
|
-
open?: boolean;
|
|
14
|
-
loading?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface UIAsset extends Asset {
|
|
17
|
-
}
|
|
18
7
|
export interface RawURL {
|
|
19
8
|
type: 'raw';
|
|
20
9
|
id: string;
|
|
21
10
|
url: string;
|
|
22
11
|
}
|
|
23
|
-
export
|
|
12
|
+
export type AnyUIItem = TypedTreeItem<Page | Asset | Folder>;
|
|
24
13
|
export interface IAssetStore {
|
|
25
14
|
sources?: {
|
|
26
15
|
page: UISource[];
|
|
@@ -28,20 +17,19 @@ export interface IAssetStore {
|
|
|
28
17
|
};
|
|
29
18
|
activetype: ChooserType;
|
|
30
19
|
activesource: number;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
focusPath?: string;
|
|
20
|
+
initialized: boolean;
|
|
21
|
+
preview?: AnyItem;
|
|
34
22
|
}
|
|
35
23
|
export interface ChooserStoreOptions<F> {
|
|
24
|
+
pages?: boolean;
|
|
25
|
+
assets?: boolean;
|
|
26
|
+
images?: boolean;
|
|
27
|
+
folders?: boolean;
|
|
36
28
|
filter?: (itm: AnyItem) => boolean | Promise<boolean>;
|
|
37
29
|
passthruFilters?: F;
|
|
38
|
-
activeTypes?: ChooserType[];
|
|
39
30
|
activeSources?: string[];
|
|
40
|
-
initialType?: ChooserType;
|
|
41
31
|
initialSource?: string;
|
|
42
32
|
initialPath?: string;
|
|
43
|
-
chooseFolder?: boolean;
|
|
44
|
-
onlyImages?: boolean;
|
|
45
33
|
}
|
|
46
34
|
interface InternalStoreOptions<F> extends Omit<ChooserStoreOptions<F>, 'activeSources'> {
|
|
47
35
|
activeSources?: Set<string>;
|
|
@@ -49,25 +37,19 @@ interface InternalStoreOptions<F> extends Omit<ChooserStoreOptions<F>, 'activeSo
|
|
|
49
37
|
export declare const CHOOSER_STORE_CONTEXT: {};
|
|
50
38
|
export declare function combinePath(path: string, name: string): string;
|
|
51
39
|
export declare function bytesToHuman(bytes: number): string;
|
|
52
|
-
export declare class ChooserStore<F = any> extends
|
|
40
|
+
export declare class ChooserStore<F = any> extends Store<IAssetStore> {
|
|
53
41
|
client: Client;
|
|
54
42
|
options: InternalStoreOptions<F>;
|
|
55
43
|
constructor(client: Client);
|
|
56
44
|
setOptions(options: ChooserStoreOptions<F>): void;
|
|
45
|
+
sources: import("@txstate-mws/svelte-store").DerivedStore<UISource[], IAssetStore>;
|
|
46
|
+
source: import("@txstate-mws/svelte-store").DerivedStore<UISource, IAssetStore>;
|
|
47
|
+
preview: import("@txstate-mws/svelte-store").DerivedStore<AnyItem, IAssetStore>;
|
|
57
48
|
getSource(state?: IAssetStore): UISource;
|
|
58
49
|
getSourceIndex(name: string, state?: IAssetStore, type?: ChooserType): number;
|
|
59
50
|
init(options: ChooserStoreOptions<F>): Promise<void>;
|
|
60
|
-
|
|
61
|
-
open(folder: UIFolder | UIPage): Promise<void>;
|
|
62
|
-
openPath(path: string): Promise<void>;
|
|
63
|
-
openPathRecursive(path: string): Promise<void>;
|
|
64
|
-
close(folder: UIFolder | UIPage): Promise<void>;
|
|
65
|
-
closePath(path: string): Promise<void>;
|
|
66
|
-
toggle(folder: UIFolder | UIPage): Promise<void>;
|
|
67
|
-
preview(item?: AnyUIItem): void;
|
|
51
|
+
setPreview(item?: AnyItem): void;
|
|
68
52
|
clearPreview(): void;
|
|
69
|
-
|
|
70
|
-
setActiveType(type: ChooserType): Promise<void>;
|
|
71
|
-
setFocus(itm: AnyUIItem): void;
|
|
53
|
+
setSource(name: string, init?: boolean): void;
|
|
72
54
|
}
|
|
73
55
|
export {};
|