@dosgato/dialog 0.0.68 → 0.0.70
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/Container.svelte +2 -2
- package/dist/FieldChooserLink.svelte +8 -1
- package/dist/FieldMultiple.svelte +46 -29
- package/dist/chooser/Chooser.svelte +0 -1
- package/dist/chooser/ChooserAPI.d.ts +1 -0
- package/dist/chooser/ChooserStore.d.ts +1 -0
- package/dist/chooser/ChooserStore.js +11 -2
- package/dist/chooser/Details.svelte +11 -3
- package/dist/chooser/Thumbnail.svelte +1 -0
- package/dist/chooser/UploadUI.svelte +1 -0
- package/dist/tree/treestore.js +1 -1
- package/package.json +2 -2
package/dist/Container.svelte
CHANGED
|
@@ -137,11 +137,11 @@ $: setNeedsShowHelp(helpelement);
|
|
|
137
137
|
line-height: 1.25em;
|
|
138
138
|
overflow: hidden;
|
|
139
139
|
text-overflow: ellipsis;
|
|
140
|
-
|
|
140
|
+
height: 1.25em;
|
|
141
141
|
}
|
|
142
142
|
.dialog-field-help.expanded {
|
|
143
|
-
white-space: normal;
|
|
144
143
|
max-height: fit-content;
|
|
144
|
+
height: auto;
|
|
145
145
|
}
|
|
146
146
|
.dialog-field-help.needsShowHelp {
|
|
147
147
|
padding-right: 6em;
|
|
@@ -116,7 +116,11 @@ async function userUrlEntryDebounced() {
|
|
|
116
116
|
}
|
|
117
117
|
const urlToValueCache = {};
|
|
118
118
|
async function updateSelected(..._) {
|
|
119
|
-
if (
|
|
119
|
+
if (selectedAsset?.id !== $value) {
|
|
120
|
+
if (!$value) {
|
|
121
|
+
selectedAsset = undefined;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
120
124
|
const valueBeforeFind = $value;
|
|
121
125
|
const asset = await chooserClient.findById($value);
|
|
122
126
|
if ($value !== valueBeforeFind)
|
|
@@ -192,6 +196,9 @@ $: updateSelected($value);
|
|
|
192
196
|
padding-top: 0;
|
|
193
197
|
height: 5em;
|
|
194
198
|
}
|
|
199
|
+
.dialog-chooser-right {
|
|
200
|
+
flex-grow: 1;
|
|
201
|
+
}
|
|
195
202
|
.dialog-chooser-right button {
|
|
196
203
|
margin-top: 0.5em;
|
|
197
204
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<script context="module">export const DG_DIALOG_FIELD_MULTIPLE = {};
|
|
2
2
|
function noOp(..._) { return ''; }
|
|
3
3
|
</script>
|
|
4
|
-
<script>import
|
|
4
|
+
<script>import caretCircleDown from '@iconify-icons/ph/caret-circle-down';
|
|
5
|
+
import caretCircleUp from '@iconify-icons/ph/caret-circle-up';
|
|
6
|
+
import plusCircleLight from '@iconify-icons/ph/plus-circle-light';
|
|
7
|
+
import xCircle from '@iconify-icons/ph/x-circle';
|
|
5
8
|
import { AddMore, FORM_CONTEXT, FORM_INHERITED_PATH } from '@txstate-mws/svelte-forms';
|
|
6
9
|
import { derivedStore } from '@txstate-mws/svelte-store';
|
|
7
10
|
import { getContext, setContext } from 'svelte';
|
|
8
11
|
import { isNotNull } from 'txstate-utils';
|
|
9
12
|
import Button from './Button.svelte';
|
|
10
13
|
import Container from './Container.svelte';
|
|
14
|
+
import Icon from './Icon.svelte';
|
|
11
15
|
export let path;
|
|
12
16
|
export let label;
|
|
13
17
|
export let initialState = undefined;
|
|
@@ -28,11 +32,28 @@ const inheritedPath = getContext(FORM_INHERITED_PATH);
|
|
|
28
32
|
const finalPath = [inheritedPath, path].filter(isNotNull).join('.');
|
|
29
33
|
const store = getContext(FORM_CONTEXT);
|
|
30
34
|
const messageStore = derivedStore(store, ({ messages }) => messages.all.filter(m => m.path?.startsWith(finalPath)));
|
|
31
|
-
const
|
|
32
|
-
|
|
35
|
+
const reorderupelements = [];
|
|
36
|
+
const reorderdownelements = [];
|
|
37
|
+
function moveUpAndFocus(onMove, idx) {
|
|
33
38
|
return () => {
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
onMove();
|
|
40
|
+
let newFocus = reorderupelements[idx - 1];
|
|
41
|
+
if (newFocus) {
|
|
42
|
+
if (newFocus.disabled)
|
|
43
|
+
newFocus = reorderdownelements[idx - 1];
|
|
44
|
+
newFocus.focus();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function moveDownAndFocus(onMove, idx) {
|
|
49
|
+
return () => {
|
|
50
|
+
onMove();
|
|
51
|
+
let newFocus = reorderdownelements[idx + 1];
|
|
52
|
+
if (newFocus) {
|
|
53
|
+
if (newFocus.disabled)
|
|
54
|
+
newFocus = reorderupelements[idx + 1];
|
|
55
|
+
newFocus.focus();
|
|
56
|
+
}
|
|
36
57
|
};
|
|
37
58
|
}
|
|
38
59
|
$: messages = compact ? $messageStore : [];
|
|
@@ -40,16 +61,19 @@ $: messages = compact ? $messageStore : [];
|
|
|
40
61
|
|
|
41
62
|
<Container {label} {messages} {conditional} {related} {helptext} let:helptextid>
|
|
42
63
|
{noOp(fieldMultipleContext.helptextid = helptextid)}
|
|
43
|
-
<AddMore {path} {initialState} {minLength} {maxLength} {conditional} let:path let:currentLength let:maxLength let:index let:minned let:maxed let:value let:onDelete let:onMoveUp>
|
|
64
|
+
<AddMore {path} {initialState} {minLength} {maxLength} {conditional} let:path let:currentLength let:maxLength let:index let:minned let:maxed let:value let:onDelete let:onMoveUp let:onMoveDown>
|
|
44
65
|
{@const showDelete = removable && !minned}
|
|
45
|
-
{@const showMove = reorder &&
|
|
46
|
-
<div class="dialog-multiple" class:has-delete-icon={showDelete} class:has-move-icon={showMove}>
|
|
66
|
+
{@const showMove = reorder && currentLength > 1}
|
|
67
|
+
<div class="dialog-multiple" class:has-delete-icon={showDelete} class:has-move-icon={showMove} class:first={index === 0}>
|
|
47
68
|
<div class="dialog-multiple-content">
|
|
48
69
|
<slot {path} {index} {value} {maxed} {maxLength} {currentLength}/>
|
|
49
70
|
</div>
|
|
50
71
|
{#if showDelete || showMove}<div class="dialog-multiple-buttons">
|
|
51
|
-
{#if
|
|
52
|
-
|
|
72
|
+
{#if showMove}
|
|
73
|
+
<button bind:this={reorderdownelements[index]} class="dialog-multiple-move" type="button" disabled={index === currentLength - 1} on:click|preventDefault|stopPropagation={moveDownAndFocus(onMoveDown, index)}><Icon icon={caretCircleDown} hiddenLabel="move down in the list" /></button>
|
|
74
|
+
<button bind:this={reorderupelements[index]} class="dialog-multiple-move" type="button" disabled={index === 0} on:click|preventDefault|stopPropagation={moveUpAndFocus(onMoveUp, index)}><Icon icon={caretCircleUp} hiddenLabel="move up in the list" /></button>
|
|
75
|
+
{/if}
|
|
76
|
+
{#if showDelete}<button class="dialog-multiple-delete" type="button" on:click|preventDefault|stopPropagation={onDelete}><Icon icon={xCircle} hiddenLabel="remove from list" /></button>{/if}
|
|
53
77
|
</div>{/if}
|
|
54
78
|
</div>
|
|
55
79
|
<svelte:fragment slot="addbutton" let:maxed let:onClick>
|
|
@@ -61,10 +85,10 @@ $: messages = compact ? $messageStore : [];
|
|
|
61
85
|
<style>
|
|
62
86
|
.dialog-multiple {
|
|
63
87
|
position: relative;
|
|
64
|
-
border: var(--dialog-container-border,
|
|
65
|
-
padding: var(--dialog-container-padding,
|
|
88
|
+
border: var(--dialog-container-border, 1px dashed #CCCCCC);
|
|
89
|
+
padding: var(--dialog-container-padding, 1.5em);
|
|
66
90
|
}
|
|
67
|
-
.dialog-multiple:not(
|
|
91
|
+
.dialog-multiple:not(.first) {
|
|
68
92
|
border-top: 0;
|
|
69
93
|
}
|
|
70
94
|
.dialog-multiple:nth-of-type(even) {
|
|
@@ -75,25 +99,18 @@ $: messages = compact ? $messageStore : [];
|
|
|
75
99
|
background-color: var(--dialog-field-bg2, transparent);
|
|
76
100
|
color: var(--dialog-field-text2, inherit);
|
|
77
101
|
}
|
|
78
|
-
:global(.dialog-multiple-button) {
|
|
79
|
-
margin-left: var(--dialog-container-padding, 1em);
|
|
80
|
-
}
|
|
81
|
-
.dialog-multiple.has-delete-icon, .dialog-multiple.has-move-icon {
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
justify-content: space-between;
|
|
85
|
-
}
|
|
86
102
|
.dialog-multiple-buttons {
|
|
87
|
-
|
|
103
|
+
position: absolute;
|
|
104
|
+
top: 0;
|
|
105
|
+
right: 0.1em;
|
|
106
|
+
display: flex;
|
|
88
107
|
}
|
|
89
108
|
.dialog-multiple-buttons button {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.dialog-multiple-content {
|
|
96
|
-
flex-grow: 1;
|
|
109
|
+
border: 0;
|
|
110
|
+
background: transparent;
|
|
111
|
+
padding: 0.15em;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
font-size: 1.3em;
|
|
97
114
|
}
|
|
98
115
|
|
|
99
116
|
</style>
|
|
@@ -62,4 +62,5 @@ export declare class ChooserStore<F = any> extends Store<IAssetStore> {
|
|
|
62
62
|
setSource(name?: string, init?: boolean): void;
|
|
63
63
|
}
|
|
64
64
|
export declare function cleanUrl(url: string): string;
|
|
65
|
+
export declare function humanFileType(mime: string, extension: string): string;
|
|
65
66
|
export {};
|
|
@@ -97,7 +97,7 @@ export class ChooserStore extends Store {
|
|
|
97
97
|
}
|
|
98
98
|
export function cleanUrl(url) {
|
|
99
99
|
if (url.startsWith('//'))
|
|
100
|
-
url = '
|
|
100
|
+
url = 'http:' + url;
|
|
101
101
|
if (url.startsWith('/'))
|
|
102
102
|
return url;
|
|
103
103
|
try {
|
|
@@ -105,7 +105,7 @@ export function cleanUrl(url) {
|
|
|
105
105
|
return url;
|
|
106
106
|
}
|
|
107
107
|
catch (e) {
|
|
108
|
-
const fixed = '
|
|
108
|
+
const fixed = 'http://' + url;
|
|
109
109
|
try {
|
|
110
110
|
const _ = new URL(fixed);
|
|
111
111
|
return fixed;
|
|
@@ -115,3 +115,12 @@ export function cleanUrl(url) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
export function humanFileType(mime, extension) {
|
|
119
|
+
if (mime.startsWith('image/') || mime.startsWith('video/'))
|
|
120
|
+
return mime;
|
|
121
|
+
if (mime.startsWith('text/'))
|
|
122
|
+
return 'text - ' + extension;
|
|
123
|
+
if (extension === 'js')
|
|
124
|
+
return 'javascript';
|
|
125
|
+
return extension;
|
|
126
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script>import { bytesToHuman, cleanUrl } from './ChooserStore';
|
|
1
|
+
<script>import { bytesToHuman, cleanUrl, humanFileType } from './ChooserStore';
|
|
2
2
|
export let item;
|
|
3
3
|
export let singleLine = false;
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<dl class="dialog-chooser-info" aria-live="polite" class:multiLine={!singleLine}>
|
|
6
|
+
<dl class="dialog-chooser-info" aria-live="polite" class:multiLine={!singleLine} class:asset={item.type === 'asset'}>
|
|
7
7
|
{#if item.type === 'raw' && item.id}
|
|
8
8
|
<div class="top-row">
|
|
9
9
|
<dt>External Link:</dt>
|
|
@@ -29,7 +29,7 @@ export let singleLine = false;
|
|
|
29
29
|
{/if}
|
|
30
30
|
<div>
|
|
31
31
|
<dt>File Type:</dt>
|
|
32
|
-
<dd>{item.mime}</dd>
|
|
32
|
+
<dd>{humanFileType(item.mime, item.extension)}</dd>
|
|
33
33
|
</div>
|
|
34
34
|
<div>
|
|
35
35
|
<dt>File Size:</dt>
|
|
@@ -72,5 +72,13 @@ export let singleLine = false;
|
|
|
72
72
|
.multiLine .top-row {
|
|
73
73
|
width: 100%;
|
|
74
74
|
}
|
|
75
|
+
.top-row {
|
|
76
|
+
max-width: calc(100% - 9em);
|
|
77
|
+
}
|
|
78
|
+
dl.asset .top-row {
|
|
79
|
+
max-width: calc(100% - 20em);
|
|
80
|
+
white-space: nowrap;
|
|
81
|
+
text-overflow: ellipsis;
|
|
82
|
+
}
|
|
75
83
|
|
|
76
84
|
</style>
|
package/dist/tree/treestore.js
CHANGED
|
@@ -203,7 +203,7 @@ export class TreeStore extends ActiveStore {
|
|
|
203
203
|
}
|
|
204
204
|
async openAndRefresh(item, notify = true) {
|
|
205
205
|
await this.refresh(item, true);
|
|
206
|
-
item.open = !!item.children?.length;
|
|
206
|
+
this.value.itemsById[item.id].open = !!item.children?.length;
|
|
207
207
|
if (notify)
|
|
208
208
|
this.trigger();
|
|
209
209
|
}
|
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.70",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "svelte-package",
|
|
7
7
|
"dev": "vite dev --force",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@iconify-icons/mdi": "^1.2.22",
|
|
28
28
|
"@iconify-icons/ph": "^1.2.2",
|
|
29
29
|
"@txstate-mws/svelte-components": "^1.5.3",
|
|
30
|
-
"@txstate-mws/svelte-forms": "^1.3.
|
|
30
|
+
"@txstate-mws/svelte-forms": "^1.3.6",
|
|
31
31
|
"codemirror": "^6.0.1",
|
|
32
32
|
"txstate-utils": "^1.8.0"
|
|
33
33
|
},
|