@dosgato/dialog 1.1.23 → 1.2.1
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 +1 -1
- package/dist/Form.svelte +3 -1
- package/dist/Form.svelte.d.ts +2 -1
- package/dist/FormDialog.svelte +2 -1
- package/dist/FormDialog.svelte.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tagpicker/FieldTagPicker.svelte +36 -0
- package/dist/tagpicker/FieldTagPicker.svelte.d.ts +18 -0
- package/dist/tagpicker/TagAPI.d.ts +19 -0
- package/dist/tagpicker/TagAPI.js +1 -0
- package/dist/tagpicker/index.d.ts +2 -0
- package/dist/tagpicker/index.js +2 -0
- package/package.json +1 -1
package/dist/Container.svelte
CHANGED
|
@@ -38,7 +38,7 @@ function setNeedsShowHelp(..._) {
|
|
|
38
38
|
$: setNeedsShowHelp(helpelement);
|
|
39
39
|
const tabContext = getContext(TAB_CONTEXT);
|
|
40
40
|
const tabNameStore = getContext(TAB_NAME_CONTEXT);
|
|
41
|
-
$: if (messages.length) {
|
|
41
|
+
$: if (messages.length && messages.some(m => m.type === 'error')) {
|
|
42
42
|
tabContext?.store.notifyErrorPath($tabNameStore, path);
|
|
43
43
|
}
|
|
44
44
|
else {
|
package/dist/Form.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { Form } from '@txstate-mws/svelte-forms';
|
|
2
2
|
import { setContext } from 'svelte';
|
|
3
|
-
import { CHOOSER_API_CONTEXT, messageIcons } from './';
|
|
3
|
+
import { CHOOSER_API_CONTEXT, messageIcons, TAG_API_CONTEXT } from './';
|
|
4
4
|
import Icon from './Icon.svelte';
|
|
5
5
|
let className = '';
|
|
6
6
|
export { className as class };
|
|
@@ -8,10 +8,12 @@ export let submit = undefined;
|
|
|
8
8
|
export let validate = undefined;
|
|
9
9
|
export let store = undefined;
|
|
10
10
|
export let chooserClient = undefined;
|
|
11
|
+
export let tagClient = undefined;
|
|
11
12
|
export let autocomplete = undefined;
|
|
12
13
|
export let name = undefined;
|
|
13
14
|
export let preload = undefined;
|
|
14
15
|
setContext(CHOOSER_API_CONTEXT, chooserClient);
|
|
16
|
+
setContext(TAG_API_CONTEXT, tagClient);
|
|
15
17
|
</script>
|
|
16
18
|
|
|
17
19
|
<Form bind:store class="{className} dialog-form" {submit} {validate} on:saved {autocomplete} {name} {preload} let:messages let:allMessages let:showingInlineErrors let:saved let:valid let:invalid let:validating let:submitting let:data>
|
package/dist/Form.svelte.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import { type FormStore, type Feedback, type SubmitResponse } from '@txstate-mws/svelte-forms';
|
|
3
|
-
import { type Client } from './';
|
|
3
|
+
import { type Client, type TagClient } from './';
|
|
4
4
|
declare class __sveltets_Render<T extends Record<string, any>, F extends any> {
|
|
5
5
|
props(): {
|
|
6
6
|
class?: string;
|
|
@@ -8,6 +8,7 @@ declare class __sveltets_Render<T extends Record<string, any>, F extends any> {
|
|
|
8
8
|
validate?: ((state: T) => Promise<Feedback[]>) | undefined;
|
|
9
9
|
store?: FormStore<T> | undefined;
|
|
10
10
|
chooserClient?: Client<F> | undefined;
|
|
11
|
+
tagClient?: TagClient | undefined;
|
|
11
12
|
autocomplete?: string | undefined;
|
|
12
13
|
name?: string | undefined;
|
|
13
14
|
preload?: T | undefined;
|
package/dist/FormDialog.svelte
CHANGED
|
@@ -6,6 +6,7 @@ export let submit;
|
|
|
6
6
|
export let validate = undefined;
|
|
7
7
|
export let store = undefined;
|
|
8
8
|
export let chooserClient = undefined;
|
|
9
|
+
export let tagClient = undefined;
|
|
9
10
|
export let autocomplete = undefined;
|
|
10
11
|
export let name = undefined;
|
|
11
12
|
export let title = '';
|
|
@@ -22,7 +23,7 @@ setContext(CHOOSER_API_CONTEXT, chooserClient);
|
|
|
22
23
|
</script>
|
|
23
24
|
|
|
24
25
|
<Dialog continueText="Save" continueIcon={contentSave} cancelText="Cancel" on:escape on:continue={onSubmit} {title} {icon} {size} escapable={false} expandable>
|
|
25
|
-
<Form bind:store {submit} {validate} {chooserClient} {autocomplete} {name} {preload} on:saved let:messages let:allMessages let:showingInlineErrors let:saved let:valid let:invalid let:validating let:submitting let:data>
|
|
26
|
+
<Form bind:store {submit} {validate} {chooserClient} {tagClient} {autocomplete} {name} {preload} on:saved let:messages let:allMessages let:showingInlineErrors let:saved let:valid let:invalid let:validating let:submitting let:data>
|
|
26
27
|
<slot {messages} {allMessages} {saved} {validating} {submitting} {valid} {invalid} {data} {showingInlineErrors} />
|
|
27
28
|
</Form>
|
|
28
29
|
</Dialog>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { IconifyIcon } from '@iconify/svelte';
|
|
3
3
|
import type { Feedback, FormStore, SubmitResponse } from '@txstate-mws/svelte-forms';
|
|
4
|
-
import { type Client } from './';
|
|
4
|
+
import { type Client, type TagClient } from './';
|
|
5
5
|
declare class __sveltets_Render<T extends Record<string, any>> {
|
|
6
6
|
props(): {
|
|
7
7
|
submit: (state: T) => Promise<SubmitResponse<T>>;
|
|
8
8
|
validate?: ((state: T) => Promise<Feedback[]>) | undefined;
|
|
9
9
|
store?: FormStore<T> | undefined;
|
|
10
10
|
chooserClient?: Client | undefined;
|
|
11
|
+
tagClient?: TagClient | undefined;
|
|
11
12
|
autocomplete?: string | undefined;
|
|
12
13
|
name?: string | undefined;
|
|
13
14
|
title?: string;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script>import FieldMultiselect from '../FieldMultiselect.svelte';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import { isNotBlank } from 'txstate-utils';
|
|
4
|
+
import { TAG_API_CONTEXT } from './TagAPI';
|
|
5
|
+
export let path;
|
|
6
|
+
export let label;
|
|
7
|
+
export let target;
|
|
8
|
+
const tagClient = getContext(TAG_API_CONTEXT);
|
|
9
|
+
let lasttarget = -1;
|
|
10
|
+
let groups = [];
|
|
11
|
+
let tags;
|
|
12
|
+
async function fetchAvailableTags() {
|
|
13
|
+
if (lasttarget !== target) {
|
|
14
|
+
groups = await tagClient.availableForTarget(target);
|
|
15
|
+
tags = groups.flatMap(g => g.tags.map(t => ({ ...t, lcname: t.name.toLocaleLowerCase(), group: { ...g, lctitle: g.title?.toLocaleLowerCase() ?? '' } })));
|
|
16
|
+
lasttarget = target;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function tagToOption(tag) {
|
|
20
|
+
return { label: `${tag.group.title ?? ''}${isNotBlank(tag.group.title) ? ': ' : ''}${tag.name}`, value: tag.id };
|
|
21
|
+
}
|
|
22
|
+
async function getOptions(search) {
|
|
23
|
+
await fetchAvailableTags();
|
|
24
|
+
const lcsearch = search?.toLocaleLowerCase() ?? '';
|
|
25
|
+
return tags.filter(t => t.lcname.includes(lcsearch) || t.group.lctitle.includes(lcsearch)).map(tagToOption);
|
|
26
|
+
}
|
|
27
|
+
async function lookupByValue(id) {
|
|
28
|
+
await fetchAvailableTags();
|
|
29
|
+
const tag = tags.find(t => t.id === id);
|
|
30
|
+
if (!tag)
|
|
31
|
+
return undefined;
|
|
32
|
+
return tagToOption(tag);
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<FieldMultiselect {path} {label} {getOptions} {lookupByValue} />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
path: string;
|
|
5
|
+
label: string;
|
|
6
|
+
target: any;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export type FieldTagPickerProps = typeof __propDef.props;
|
|
14
|
+
export type FieldTagPickerEvents = typeof __propDef.events;
|
|
15
|
+
export type FieldTagPickerSlots = typeof __propDef.slots;
|
|
16
|
+
export default class FieldTagPicker extends SvelteComponentTyped<FieldTagPickerProps, FieldTagPickerEvents, FieldTagPickerSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const TAG_API_CONTEXT: {};
|
|
2
|
+
export interface Tag {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export interface TagGroup {
|
|
7
|
+
id: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
tags: Tag[];
|
|
10
|
+
}
|
|
11
|
+
export interface TagClient<TargetTypes = any> {
|
|
12
|
+
availableForTarget: (target: TargetTypes,
|
|
13
|
+
/**
|
|
14
|
+
* true -> only public tags,
|
|
15
|
+
* false -> only internal tags,
|
|
16
|
+
* undefined -> all tags
|
|
17
|
+
*/
|
|
18
|
+
publicTags?: boolean) => Promise<TagGroup[]>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TAG_API_CONTEXT = {};
|
package/package.json
CHANGED