@dosgato/dialog 0.0.63 → 0.0.64
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.
|
@@ -33,12 +33,11 @@ export let lookupByValue = async (val) => { const options = await getOptions(val
|
|
|
33
33
|
export let related = 0;
|
|
34
34
|
export let extradescid = undefined;
|
|
35
35
|
export let helptext = undefined;
|
|
36
|
-
|
|
37
|
-
// that it finds, so that we can display labels on pills.
|
|
36
|
+
/** Each time we run getOptions we will save the value -> label mappings that it finds, so that we can display labels on pills. */
|
|
38
37
|
const valueToLabel = {};
|
|
39
38
|
async function wrapGetOptions(search) {
|
|
40
39
|
const opts = await getOptions(search);
|
|
41
|
-
|
|
40
|
+
/* If no options are returned with the search term, we can end up with an infinite loop the first time reactToValue calls wrapGetOptions */
|
|
42
41
|
// if (opts.length === 0) opts = await getOptions('')
|
|
43
42
|
for (const opt of opts) {
|
|
44
43
|
valueToLabel[opt.value] = opt.label || opt.value;
|
|
@@ -54,10 +53,9 @@ onMount(async () => {
|
|
|
54
53
|
await reactToValue(defaultValue);
|
|
55
54
|
hasInit = true;
|
|
56
55
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// is currently unknown.
|
|
56
|
+
/**
|
|
57
|
+
If we get a value from the form that we haven't seen in the popup menu yet, we won't have a label for it.
|
|
58
|
+
This function runs getOptions on any selected values for which the label is currently unknown. */
|
|
61
59
|
async function reactToValue(value) {
|
|
62
60
|
await Promise.all(value.map(async (v) => {
|
|
63
61
|
if (!valueToLabel[v]) {
|
|
@@ -75,7 +73,11 @@ async function reactToValue(value) {
|
|
|
75
73
|
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {related} {helptext} let:value let:valid let:invalid let:id let:onBlur let:setVal let:messagesid let:helptextid>
|
|
76
74
|
{@const _ = reactToValue(value)}
|
|
77
75
|
<div class:valid class:invalid>
|
|
78
|
-
<MultiSelect {id} name={path} usePortal={portal} descid={getDescribedBy([messagesid, helptextid, extradescid])}
|
|
76
|
+
<MultiSelect {id} name={path} usePortal={portal} descid={getDescribedBy([messagesid, helptextid, extradescid])}
|
|
77
|
+
{disabled} {maxSelections} selected={$selectedStore} {placeholder} getOptions={wrapGetOptions}
|
|
78
|
+
inputClass='multiselect-input'
|
|
79
|
+
on:change={e => setVal(e.detail.map(itm => itm.value))} on:blur={onBlur}
|
|
80
|
+
/>
|
|
79
81
|
</div>
|
|
80
82
|
</FieldStandard>
|
|
81
83
|
{/if}
|
|
@@ -84,5 +86,8 @@ async function reactToValue(value) {
|
|
|
84
86
|
.invalid {
|
|
85
87
|
--multiselect-border: 1px solid red;
|
|
86
88
|
}
|
|
89
|
+
:global(.multiselect-input) {
|
|
90
|
+
width: 100%
|
|
91
|
+
}
|
|
87
92
|
|
|
88
93
|
</style>
|
|
@@ -90,7 +90,7 @@ const previewId = randomid();
|
|
|
90
90
|
<section class="dialog-chooser-chooser">
|
|
91
91
|
{#if $store.initialized}
|
|
92
92
|
<Tree headers={[
|
|
93
|
-
{ label: 'Path', id: 'name', grow: 4, icon: item => item.type === 'asset' ?
|
|
93
|
+
{ label: 'Path', id: 'name', grow: 4, icon: item => ({ icon: item.type === 'asset' ? iconForMime(item.mime) : (item.type === 'folder' ? (item.open ? folderNotchOpen : folderIcon) : applicationOutline) }), get: 'name' }
|
|
94
94
|
]} singleSelect store={treeStore} on:deselect={onDeselect} on:choose={onChoose} />
|
|
95
95
|
{/if}
|
|
96
96
|
</section>
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
<script>import { get
|
|
1
|
+
<script>import { get } from 'txstate-utils';
|
|
2
2
|
import { Icon } from '..';
|
|
3
3
|
export let header;
|
|
4
4
|
export let item;
|
|
5
|
-
$: icon = typeof header.icon === 'function' ? header.icon(item)
|
|
6
|
-
$: iconLabel = typeof header.icon === 'function' ? header.icon(item).label : header.icon?.label;
|
|
5
|
+
$: icon = (typeof header.icon === 'function' ? header.icon(item) : header.icon);
|
|
7
6
|
$: headerComponent = header.component;
|
|
8
7
|
</script>
|
|
9
8
|
|
|
10
|
-
{#if
|
|
9
|
+
{#if icon}
|
|
11
10
|
<span class="icon">
|
|
12
|
-
<Icon {icon} tooltip={
|
|
11
|
+
<Icon icon={icon.icon} tooltip={icon.label} inline width="1.5em" hiddenLabel={icon.label} />
|
|
13
12
|
</span>
|
|
14
13
|
{/if}
|
|
15
14
|
{#if header.component}
|
package/dist/tree/treestore.d.ts
CHANGED
|
@@ -41,11 +41,11 @@ export interface TreeHeader<T extends TreeItemFromDB> {
|
|
|
41
41
|
grow?: number;
|
|
42
42
|
icon?: {
|
|
43
43
|
icon: IconifyIcon;
|
|
44
|
-
label?: string
|
|
44
|
+
label?: string;
|
|
45
45
|
} | ((item: TypedTreeItem<T>) => {
|
|
46
46
|
icon: IconifyIcon;
|
|
47
47
|
label?: string;
|
|
48
|
-
});
|
|
48
|
+
} | undefined);
|
|
49
49
|
get?: string;
|
|
50
50
|
render?: (item: TypedTreeItem<T>) => string;
|
|
51
51
|
component?: SvelteComponent;
|
package/package.json
CHANGED