@dosgato/dialog 0.0.26 → 0.0.27
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/FieldRadio.svelte +6 -40
- package/FieldRadio.svelte.d.ts +1 -0
- package/FieldSelect.svelte +2 -1
- package/FieldSelect.svelte.d.ts +1 -0
- package/FieldStandard.svelte +2 -1
- package/FieldStandard.svelte.d.ts +1 -0
- package/Switcher.svelte +67 -0
- package/Switcher.svelte.d.ts +35 -0
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +3 -2
package/FieldRadio.svelte
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import
|
|
3
|
-
import Radio from './Radio.svelte';
|
|
1
|
+
<script>import { Field } from '@txstate-mws/svelte-forms';
|
|
2
|
+
import Switcher from './Switcher.svelte';
|
|
4
3
|
let className = '';
|
|
5
4
|
export { className as class };
|
|
6
5
|
export let id = undefined;
|
|
@@ -16,44 +15,11 @@ export let helptext = undefined;
|
|
|
16
15
|
export let number = false;
|
|
17
16
|
export let date = false;
|
|
18
17
|
export let datetime = false;
|
|
18
|
+
export let boolean = false;
|
|
19
19
|
export let serialize = undefined;
|
|
20
20
|
export let deserialize = undefined;
|
|
21
|
-
const groupid = randomid();
|
|
22
|
-
const width = '100%';
|
|
23
21
|
</script>
|
|
24
22
|
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
{@const radioid = `${path}.${idx}`}
|
|
29
|
-
{@const serializedValue = serialize(choice.value)}
|
|
30
|
-
<label for={radioid} style:width>
|
|
31
|
-
<Radio id={radioid} name={path} value={serializedValue} selected={value === serializedValue} disabled={choice.disabled} {onChange} {onBlur} {helptextid}/>
|
|
32
|
-
<span>{choice.label || serializedValue}</span>
|
|
33
|
-
</label>
|
|
34
|
-
{/each}
|
|
35
|
-
</div>
|
|
36
|
-
</FieldStandard>
|
|
37
|
-
|
|
38
|
-
<style>
|
|
39
|
-
.dialog-radio {
|
|
40
|
-
padding: 0.2em 0;
|
|
41
|
-
}
|
|
42
|
-
label {
|
|
43
|
-
margin-bottom: 0.7em;
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
justify-content: flex-start;
|
|
47
|
-
}
|
|
48
|
-
label:last-child {
|
|
49
|
-
margin-bottom: 0;
|
|
50
|
-
}
|
|
51
|
-
span {
|
|
52
|
-
margin-left: 0.45em;
|
|
53
|
-
max-width: calc(100% - 1.6em);
|
|
54
|
-
}
|
|
55
|
-
label :global(input[type="checkbox"]) {
|
|
56
|
-
transform: none;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
</style>
|
|
23
|
+
<Field {path} {defaultValue} {conditional} {notNull} {number} {date} {datetime} {boolean} {serialize} {deserialize} let:value let:valid let:invalid let:onBlur let:onChange let:messages let:serialize>
|
|
24
|
+
<Switcher bind:id class={className} name={path} {horizontal} {label} iptValue={value} {valid} {invalid} {required} {helptext} {messages} on:change={onChange} {onBlur} choices={choices.map(c => ({ ...c, value: serialize(c.value) }))} />
|
|
25
|
+
</Field>
|
package/FieldRadio.svelte.d.ts
CHANGED
package/FieldSelect.svelte
CHANGED
|
@@ -17,11 +17,12 @@ export let helptext = undefined;
|
|
|
17
17
|
export let number = false;
|
|
18
18
|
export let date = false;
|
|
19
19
|
export let datetime = false;
|
|
20
|
+
export let boolean = false;
|
|
20
21
|
export let serialize = undefined;
|
|
21
22
|
export let deserialize = undefined;
|
|
22
23
|
</script>
|
|
23
24
|
|
|
24
|
-
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {helptext} {notNull} {number} {date} {datetime} {serialize} {deserialize} let:value let:valid let:invalid let:id let:onBlur let:onChange let:messagesid let:helptextid let:serialize>
|
|
25
|
+
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {helptext} {notNull} {number} {date} {datetime} {boolean} {serialize} {deserialize} let:value let:valid let:invalid let:id let:onBlur let:onChange let:messagesid let:helptextid let:serialize>
|
|
25
26
|
<select bind:this={inputelement} {id} name={path} {disabled} class="dialog-input dialog-select {className}" on:change={onChange} on:blur={onBlur} class:valid class:invalid aria-describedby={getDescribedBy([messagesid, helptextid])}>
|
|
26
27
|
{#if !notNull}<option value="" selected={!value}>{placeholder}</option>{/if}
|
|
27
28
|
{#each choices as choice (choice.value)}
|
package/FieldSelect.svelte.d.ts
CHANGED
package/FieldStandard.svelte
CHANGED
|
@@ -10,6 +10,7 @@ export let notNull = false;
|
|
|
10
10
|
export let number = false;
|
|
11
11
|
export let date = false;
|
|
12
12
|
export let datetime = false;
|
|
13
|
+
export let boolean = false;
|
|
13
14
|
export let serialize = undefined;
|
|
14
15
|
export let deserialize = undefined;
|
|
15
16
|
export let conditional = undefined;
|
|
@@ -17,7 +18,7 @@ export let required = false;
|
|
|
17
18
|
export let helptext = undefined;
|
|
18
19
|
</script>
|
|
19
20
|
|
|
20
|
-
<Field {path} {defaultValue} {conditional} {notNull} {number} {date} {datetime} {serialize} {deserialize} let:path let:value let:onBlur let:onChange let:setVal let:messages let:valid let:invalid let:serialize let:deserialize>
|
|
21
|
+
<Field {path} {defaultValue} {conditional} {notNull} {number} {date} {datetime} {boolean} {serialize} {deserialize} let:path let:value let:onBlur let:onChange let:setVal let:messages let:valid let:invalid let:serialize let:deserialize>
|
|
21
22
|
<Container {id} {label} {messages} {descid} {required} {helptext} let:messagesid let:helptextid>
|
|
22
23
|
<slot {id} {path} {value} {onBlur} {onChange} {setVal} {valid} {invalid} {messagesid} {helptextid} {serialize} {deserialize} />
|
|
23
24
|
</Container>
|
package/Switcher.svelte
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script>import { eq } from '@txstate-mws/svelte-components';
|
|
2
|
+
import { Store } from '@txstate-mws/svelte-store';
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
import { randomid } from 'txstate-utils';
|
|
5
|
+
import Container from './Container.svelte';
|
|
6
|
+
import Radio from './Radio.svelte';
|
|
7
|
+
let className = '';
|
|
8
|
+
export { className as class };
|
|
9
|
+
export let id = randomid();
|
|
10
|
+
export let name = randomid();
|
|
11
|
+
export let choices;
|
|
12
|
+
export let horizontal = false;
|
|
13
|
+
export let label;
|
|
14
|
+
export let required = false;
|
|
15
|
+
export let helptext = undefined;
|
|
16
|
+
export let messages;
|
|
17
|
+
export let iptValue = choices[0].value;
|
|
18
|
+
export let valid = false;
|
|
19
|
+
export let invalid = false;
|
|
20
|
+
export let onBlur = undefined;
|
|
21
|
+
const dispatch = createEventDispatcher();
|
|
22
|
+
const store = new Store({ width: 1000 });
|
|
23
|
+
const groupid = randomid();
|
|
24
|
+
function onChange(e) {
|
|
25
|
+
iptValue = this.value;
|
|
26
|
+
dispatch('change', iptValue);
|
|
27
|
+
}
|
|
28
|
+
$: columns = Math.floor($store.width / 250);
|
|
29
|
+
$: width = (horizontal ? 100 / Math.min(choices.length, choices.length === 4 && columns === 3 ? 2 : columns) : 100) + '%';
|
|
30
|
+
</script>
|
|
31
|
+
<Container {id} {label} {messages} descid={groupid} {required} {helptext} let:helptextid>
|
|
32
|
+
<div class="dialog-radio {className}" use:eq={{ store }} class:horizontal role="radiogroup" aria-labelledby={groupid} class:valid class:invalid>
|
|
33
|
+
{#each choices as choice, idx}
|
|
34
|
+
{@const radioid = `${groupid}.${idx}`}
|
|
35
|
+
<label for={radioid} style:width>
|
|
36
|
+
<Radio id={radioid} {name} value={choice.value} selected={iptValue === choice.value} disabled={choice.disabled} {onChange} {onBlur} {helptextid}/>
|
|
37
|
+
<span>{choice.label || choice.value}</span>
|
|
38
|
+
</label>
|
|
39
|
+
{/each}
|
|
40
|
+
</div>
|
|
41
|
+
</Container>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
.dialog-radio {
|
|
45
|
+
padding: 0.2em 0;
|
|
46
|
+
}
|
|
47
|
+
label {
|
|
48
|
+
margin-bottom: 0.7em;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: flex-start;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
width: 25%;
|
|
54
|
+
}
|
|
55
|
+
.dialog-radio:not(.horizontal) label:last-child {
|
|
56
|
+
margin-bottom: 0;
|
|
57
|
+
}
|
|
58
|
+
span {
|
|
59
|
+
margin-left: 0.45em;
|
|
60
|
+
max-width: calc(100% - 1.6em);
|
|
61
|
+
}
|
|
62
|
+
.horizontal {
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-wrap: wrap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Feedback } from '@txstate-mws/svelte-forms';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
class?: string;
|
|
6
|
+
id?: string | undefined;
|
|
7
|
+
name?: string;
|
|
8
|
+
choices: {
|
|
9
|
+
label?: string;
|
|
10
|
+
value: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
horizontal?: boolean;
|
|
14
|
+
label: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
helptext?: string | undefined;
|
|
17
|
+
messages: Feedback[];
|
|
18
|
+
iptValue?: string;
|
|
19
|
+
valid?: boolean;
|
|
20
|
+
invalid?: boolean;
|
|
21
|
+
onBlur?: (() => void | Promise<void>);
|
|
22
|
+
};
|
|
23
|
+
events: {
|
|
24
|
+
change: CustomEvent<any>;
|
|
25
|
+
} & {
|
|
26
|
+
[evt: string]: CustomEvent<any>;
|
|
27
|
+
};
|
|
28
|
+
slots: {};
|
|
29
|
+
};
|
|
30
|
+
export type SwitcherProps = typeof __propDef.props;
|
|
31
|
+
export type SwitcherEvents = typeof __propDef.events;
|
|
32
|
+
export type SwitcherSlots = typeof __propDef.slots;
|
|
33
|
+
export default class Switcher extends SvelteComponentTyped<SwitcherProps, SwitcherEvents, SwitcherSlots> {
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -27,10 +27,11 @@ export { default as Icon } from './Icon.svelte';
|
|
|
27
27
|
export { default as InlineMessage } from './InlineMessage.svelte';
|
|
28
28
|
export { default as InlineMessages } from './InlineMessages.svelte';
|
|
29
29
|
export { default as Input } from './Input.svelte';
|
|
30
|
+
export { default as Listbox } from './Listbox.svelte';
|
|
30
31
|
export { default as Radio } from './Radio.svelte';
|
|
32
|
+
export { default as Switcher } from './Switcher.svelte';
|
|
31
33
|
export { default as Tab } from './Tab.svelte';
|
|
32
34
|
export { default as Tabs } from './Tabs.svelte';
|
|
33
|
-
export { default as Listbox } from './Listbox.svelte';
|
|
34
35
|
export * from './chooser/index.js';
|
|
35
36
|
export * from './fileIcons.js';
|
|
36
37
|
export * from './TabStore.js';
|
package/index.js
CHANGED
|
@@ -27,10 +27,11 @@ export { default as Icon } from './Icon.svelte';
|
|
|
27
27
|
export { default as InlineMessage } from './InlineMessage.svelte';
|
|
28
28
|
export { default as InlineMessages } from './InlineMessages.svelte';
|
|
29
29
|
export { default as Input } from './Input.svelte';
|
|
30
|
+
export { default as Listbox } from './Listbox.svelte';
|
|
30
31
|
export { default as Radio } from './Radio.svelte';
|
|
32
|
+
export { default as Switcher } from './Switcher.svelte';
|
|
31
33
|
export { default as Tab } from './Tab.svelte';
|
|
32
34
|
export { default as Tabs } from './Tabs.svelte';
|
|
33
|
-
export { default as Listbox } from './Listbox.svelte';
|
|
34
35
|
export * from './chooser/index.js';
|
|
35
36
|
export * from './fileIcons.js';
|
|
36
37
|
export * from './TabStore.js';
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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.27",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@txstate-mws/svelte-components": "^1.3.5",
|
|
7
|
-
"@txstate-mws/svelte-forms": "^1.2.
|
|
7
|
+
"@txstate-mws/svelte-forms": "^1.2.1",
|
|
8
8
|
"@iconify/svelte": "^3.0.0",
|
|
9
9
|
"@iconify-icons/mdi": "^1.2.22",
|
|
10
10
|
"@iconify-icons/ph": "^1.2.2",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"./Input.svelte": "./Input.svelte",
|
|
60
60
|
"./Listbox.svelte": "./Listbox.svelte",
|
|
61
61
|
"./Radio.svelte": "./Radio.svelte",
|
|
62
|
+
"./Switcher.svelte": "./Switcher.svelte",
|
|
62
63
|
"./Tab.svelte": "./Tab.svelte",
|
|
63
64
|
"./TabStore": "./TabStore.js",
|
|
64
65
|
"./Tabs.svelte": "./Tabs.svelte",
|