@dosgato/dialog 0.0.28 → 0.0.30
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/FieldChooserLink.svelte +7 -4
- package/FieldCodeEditor.svelte +7 -5
- package/FieldCodeEditor.svelte.d.ts +1 -1
- package/FieldSelect.svelte.d.ts +1 -1
- package/Tab.svelte +12 -7
- package/Tab.svelte.d.ts +1 -1
- package/TabStore.d.ts +2 -2
- package/TabStore.js +5 -4
- package/package.json +1 -1
package/FieldChooserLink.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<script>import { FORM_CONTEXT } from '@txstate-mws/svelte-forms';
|
|
1
|
+
<script>import { FORM_CONTEXT, FORM_INHERITED_PATH } from '@txstate-mws/svelte-forms';
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
|
-
import { randomid } from 'txstate-utils';
|
|
3
|
+
import { isNotBlank, randomid } from 'txstate-utils';
|
|
4
4
|
import { Chooser, ChooserStore, CHOOSER_API_CONTEXT } from './chooser';
|
|
5
5
|
import Details from './chooser/Details.svelte';
|
|
6
6
|
import Thumbnail from './chooser/Thumbnail.svelte';
|
|
@@ -21,7 +21,9 @@ export let initialSource = undefined;
|
|
|
21
21
|
export let initialPath = undefined;
|
|
22
22
|
export let helptext = undefined;
|
|
23
23
|
const formStore = getContext(FORM_CONTEXT);
|
|
24
|
-
const
|
|
24
|
+
const inheritedPath = getContext(FORM_INHERITED_PATH);
|
|
25
|
+
const finalPath = [inheritedPath, path].filter(isNotBlank).join('.');
|
|
26
|
+
const value = formStore.getField(finalPath);
|
|
25
27
|
const chooserClient = getContext(CHOOSER_API_CONTEXT);
|
|
26
28
|
const store = new ChooserStore(chooserClient);
|
|
27
29
|
const descid = randomid();
|
|
@@ -55,7 +57,8 @@ async function userUrlEntry() {
|
|
|
55
57
|
id: newVal,
|
|
56
58
|
url
|
|
57
59
|
};
|
|
58
|
-
formStore.setField(
|
|
60
|
+
formStore.setField(finalPath, newVal);
|
|
61
|
+
formStore.dirtyField(finalPath);
|
|
59
62
|
}
|
|
60
63
|
let selectedAsset;
|
|
61
64
|
async function updateSelected(..._) {
|
package/FieldCodeEditor.svelte
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script>import { passActions } from '@txstate-mws/svelte-components';
|
|
2
|
-
import { nullableSerialize, nullableDeserialize, FORM_CONTEXT, FormStore } from '@txstate-mws/svelte-forms';
|
|
2
|
+
import { nullableSerialize, nullableDeserialize, FORM_CONTEXT, FormStore, FORM_INHERITED_PATH } from '@txstate-mws/svelte-forms';
|
|
3
3
|
import CodeFlask from 'codeflask';
|
|
4
4
|
import { getContext, onMount } from 'svelte';
|
|
5
|
+
import { isNotBlank } from 'txstate-utils';
|
|
5
6
|
import { getDescribedBy, FieldStandard } from './';
|
|
6
7
|
let className = '';
|
|
7
8
|
export { className as class };
|
|
@@ -10,7 +11,7 @@ export let path;
|
|
|
10
11
|
export let label = '';
|
|
11
12
|
export let notNull = false;
|
|
12
13
|
export let defaultValue = notNull ? '' : undefined;
|
|
13
|
-
export let rows =
|
|
14
|
+
export let rows = 8;
|
|
14
15
|
export let conditional = undefined;
|
|
15
16
|
export let required = false;
|
|
16
17
|
export let use = [];
|
|
@@ -18,13 +19,13 @@ export let inputelement = undefined;
|
|
|
18
19
|
export let helptext = undefined;
|
|
19
20
|
export let language;
|
|
20
21
|
const store = getContext(FORM_CONTEXT);
|
|
21
|
-
const
|
|
22
|
+
const inheritedPath = getContext(FORM_INHERITED_PATH);
|
|
23
|
+
const finalPath = [inheritedPath, path].filter(isNotBlank).join('.');
|
|
24
|
+
const value = store.getField(finalPath);
|
|
22
25
|
let editorelement;
|
|
23
26
|
let flask;
|
|
24
|
-
let codeValue = '';
|
|
25
27
|
onMount(() => {
|
|
26
28
|
flask = new CodeFlask(editorelement, { language, lineNumbers: true, areaId: id });
|
|
27
|
-
flask.onUpdate(code => { codeValue = code; });
|
|
28
29
|
inputelement = editorelement.querySelector(`#${id}`);
|
|
29
30
|
if (className)
|
|
30
31
|
inputelement.classList.add(...className.split(' '));
|
|
@@ -60,6 +61,7 @@ function updateValidState(invalidIn, messagesIdIn) {
|
|
|
60
61
|
|
|
61
62
|
<style>
|
|
62
63
|
div {
|
|
64
|
+
position: relative;
|
|
63
65
|
overflow: hidden;
|
|
64
66
|
resize: vertical;
|
|
65
67
|
}
|
package/FieldSelect.svelte.d.ts
CHANGED
package/Tab.svelte
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { derivedStore } from '@txstate-mws/svelte-store';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
2
3
|
import Icon from './Icon.svelte';
|
|
3
4
|
import { TabStore, TAB_CONTEXT } from './TabStore';
|
|
4
|
-
export let
|
|
5
|
+
export let name;
|
|
5
6
|
const { store, onClick, onKeyDown, tabelements } = getContext(TAB_CONTEXT);
|
|
6
7
|
const accordion = store.accordion();
|
|
7
|
-
const current = store.
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
const current = store.currentName();
|
|
9
|
+
const def = derivedStore(store, v => v.tabs.find(t => t.name === name));
|
|
10
|
+
const title = derivedStore(def, 'title');
|
|
11
|
+
const tabid = derivedStore(store, v => v.tabids[name]);
|
|
12
|
+
const panelid = derivedStore(store, v => v.panelids[name]);
|
|
13
|
+
$: active = $current === name;
|
|
14
|
+
const idx = $store.tabs.findIndex(t => t.name === name);
|
|
10
15
|
const last = idx === $store.tabs.length - 1;
|
|
11
16
|
</script>
|
|
12
17
|
|
|
13
18
|
{#if $accordion}
|
|
14
|
-
<div bind:this={tabelements[idx]} id={$
|
|
19
|
+
<div bind:this={tabelements[idx]} id={$tabid} class="tabs-tab" class:last aria-selected={active} aria-controls={$panelid} role="tab" tabindex={0} on:click={onClick(idx)} on:keydown={onKeyDown(idx)}><Icon icon={$store.tabs[idx].icon} inline />{$title}<i class="tabs-accordion-arrow" aria-hidden="true"></i></div>
|
|
15
20
|
{/if}
|
|
16
|
-
<div id={$
|
|
21
|
+
<div id={$panelid} hidden={!active} role="tabpanel" tabindex="-1" aria-labelledby={$tabid} class="tabs-panel" class:accordion={$accordion}>
|
|
17
22
|
<slot />
|
|
18
23
|
</div>
|
|
19
24
|
|
package/Tab.svelte.d.ts
CHANGED
package/TabStore.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { ElementSize } from '@txstate-mws/svelte-components';
|
|
|
3
3
|
import type { IconifyIcon } from '@iconify/svelte';
|
|
4
4
|
export declare const TAB_CONTEXT: {};
|
|
5
5
|
export interface TabDef {
|
|
6
|
-
name
|
|
7
|
-
title
|
|
6
|
+
name: string;
|
|
7
|
+
title?: string;
|
|
8
8
|
icon?: IconifyIcon;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
}
|
package/TabStore.js
CHANGED
|
@@ -26,6 +26,7 @@ export class TabStore extends Store {
|
|
|
26
26
|
v.tabids ??= {};
|
|
27
27
|
v.panelids ??= {};
|
|
28
28
|
for (const tab of v.tabs) {
|
|
29
|
+
tab.title ??= tab.name;
|
|
29
30
|
v.tabids[tab.title] ??= randomid();
|
|
30
31
|
v.panelids[tab.title] ??= randomid();
|
|
31
32
|
}
|
|
@@ -35,16 +36,16 @@ export class TabStore extends Store {
|
|
|
35
36
|
return derivedStore(this, v => v.current);
|
|
36
37
|
}
|
|
37
38
|
currentName() {
|
|
38
|
-
return derivedStore(this, v => v.tabs[v.current].name
|
|
39
|
+
return derivedStore(this, v => v.tabs[v.current].name);
|
|
39
40
|
}
|
|
40
41
|
currentTitle() {
|
|
41
42
|
return derivedStore(this, v => v.tabs[v.current].title);
|
|
42
43
|
}
|
|
43
44
|
currentTabId() {
|
|
44
|
-
return derivedStore(this, v => v.tabids[v.tabs[v.current].
|
|
45
|
+
return derivedStore(this, v => v.tabids[v.tabs[v.current].name]);
|
|
45
46
|
}
|
|
46
47
|
currentPanelId() {
|
|
47
|
-
return derivedStore(this, v => v.panelids[v.tabs[v.current].
|
|
48
|
+
return derivedStore(this, v => v.panelids[v.tabs[v.current].name]);
|
|
48
49
|
}
|
|
49
50
|
accordion() {
|
|
50
51
|
return derivedStore(this, v => v.clientWidth < 500);
|
|
@@ -65,6 +66,6 @@ export class TabStore extends Store {
|
|
|
65
66
|
this.update(v => ({ ...v, current: Math.min(v.tabs.length, Math.max(0, idx)) }));
|
|
66
67
|
}
|
|
67
68
|
activateName(name) {
|
|
68
|
-
this.update(v => ({ ...v, current: findIndex(v.tabs, t => t.name === name) ??
|
|
69
|
+
this.update(v => ({ ...v, current: findIndex(v.tabs, t => t.name === name) ?? v.current }));
|
|
69
70
|
}
|
|
70
71
|
}
|
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.30",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@txstate-mws/svelte-components": "^1.3.5",
|
|
7
7
|
"@txstate-mws/svelte-forms": "^1.2.1",
|