@dosgato/dialog 0.0.19 → 0.0.20
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/Button.svelte +77 -0
- package/Button.svelte.d.ts +30 -0
- package/Checkbox.svelte +2 -1
- package/Checkbox.svelte.d.ts +1 -0
- package/Container.svelte +18 -19
- package/Container.svelte.d.ts +2 -0
- package/Dialog.svelte +137 -0
- package/Dialog.svelte.d.ts +49 -0
- package/FieldAutocomplete.svelte +4 -7
- package/FieldAutocomplete.svelte.d.ts +1 -1
- package/FieldCheckbox.svelte +3 -2
- package/FieldCheckbox.svelte.d.ts +2 -1
- package/FieldChoices.svelte +3 -2
- package/FieldChoices.svelte.d.ts +1 -0
- package/FieldChooserLink.svelte +4 -2
- package/FieldChooserLink.svelte.d.ts +1 -0
- package/FieldDate.svelte +3 -2
- package/FieldDate.svelte.d.ts +1 -0
- package/FieldDateTime.svelte +3 -2
- package/FieldDateTime.svelte.d.ts +1 -0
- package/FieldMultiple.svelte +14 -7
- package/FieldMultiple.svelte.d.ts +3 -0
- package/FieldMultiselect.svelte +29 -22
- package/FieldNumber.svelte +3 -2
- package/FieldNumber.svelte.d.ts +1 -0
- package/FieldRadio.svelte +9 -4
- package/FieldRadio.svelte.d.ts +6 -0
- package/FieldSelect.svelte +9 -3
- package/FieldSelect.svelte.d.ts +6 -0
- package/FieldStandard.svelte +8 -3
- package/FieldStandard.svelte.d.ts +6 -0
- package/FieldText.svelte +3 -2
- package/FieldText.svelte.d.ts +1 -0
- package/FieldTextArea.svelte +5 -3
- package/FieldTextArea.svelte.d.ts +1 -0
- package/Form.svelte +3 -3
- package/FormDialog.svelte +34 -0
- package/FormDialog.svelte.d.ts +38 -0
- package/Input.svelte +4 -1
- package/Input.svelte.d.ts +1 -0
- package/Radio.svelte +5 -2
- package/Radio.svelte.d.ts +1 -0
- package/Tab.svelte +3 -2
- package/TabStore.d.ts +8 -1
- package/TabStore.js +18 -3
- package/Tabs.svelte +65 -18
- package/Tabs.svelte.d.ts +2 -4
- package/fileIcons.d.ts +2 -1
- package/helpers.d.ts +1 -0
- package/helpers.js +5 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/package.json +13 -9
package/Button.svelte
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<script>import Icon from './Icon.svelte';
|
|
2
|
+
export let type = 'button';
|
|
3
|
+
export let disabled = false;
|
|
4
|
+
export let compact = false;
|
|
5
|
+
export let cancel = false;
|
|
6
|
+
export let destructive = false;
|
|
7
|
+
export let secondary = false;
|
|
8
|
+
export let describedby = undefined;
|
|
9
|
+
export let element = undefined;
|
|
10
|
+
export let icon = undefined;
|
|
11
|
+
let className = undefined;
|
|
12
|
+
export { className as class };
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<button {disabled} bind:this={element} {type} class="reset {className ?? ''}" class:cancel class:destructive class:secondary class:compact aria-describedby={describedby} on:click><Icon {icon} width="1.3em" /><span><slot /></span></button>
|
|
16
|
+
|
|
17
|
+
<style>
|
|
18
|
+
button.reset {
|
|
19
|
+
padding: 0.5em 1em;
|
|
20
|
+
border: 0;
|
|
21
|
+
border-radius: 0.25em;
|
|
22
|
+
background-color: var(--dg-button-bg, #501214);
|
|
23
|
+
color: var(--dg-button-text, white);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
line-height: 1;
|
|
28
|
+
}
|
|
29
|
+
button.reset.compact {
|
|
30
|
+
padding: 0.1em;
|
|
31
|
+
}
|
|
32
|
+
button.reset[disabled] {
|
|
33
|
+
opacity: 0.6;
|
|
34
|
+
cursor: default;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
button.reset > :global(svg:last-child) {
|
|
38
|
+
margin-left: 0.3em;
|
|
39
|
+
margin-right: -0.3em;
|
|
40
|
+
}
|
|
41
|
+
button.reset > :global(svg:first-child) {
|
|
42
|
+
margin-left: -0.3em;
|
|
43
|
+
margin-right: 0.3em;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
button.reset:not([disabled]):hover {
|
|
47
|
+
background-color: var(--dg-button-hover-bg, #622a2c);
|
|
48
|
+
color: var(--dg-button-hover-text, white);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
button.secondary {
|
|
52
|
+
background-color: var(--dg-button-secondary-bg, rgb(18, 184, 134));
|
|
53
|
+
color: var(--dg-button-secondary-text, white);
|
|
54
|
+
}
|
|
55
|
+
button.secondary:not([disabled]):hover {
|
|
56
|
+
background-color: var(--dg-button-secondary-hover-bg, rgb(12, 166, 120));
|
|
57
|
+
color: var(--dg-button-secondary-hover-text, white);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
button.cancel {
|
|
61
|
+
background-color: var(--dg-button-cancel-bg, #808080);
|
|
62
|
+
color: var(--dg-button-cancel-text, white);
|
|
63
|
+
}
|
|
64
|
+
button.cancel:not([disabled]):hover {
|
|
65
|
+
background-color: var(--dg-button-cancel-hover-bg, #595959);
|
|
66
|
+
color: var(--dg-button-cancel-hover-text, white);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
button.destructive {
|
|
70
|
+
background-color: var(--dg-button-delete-bg, rgb(250, 82, 82));
|
|
71
|
+
color: var(--dg-button-delete-text, white);
|
|
72
|
+
}
|
|
73
|
+
button.destructive:not([disabled]):hover {
|
|
74
|
+
background-color: var(--dg-button-delete-hover-bg, rgb(240, 62, 62));
|
|
75
|
+
color: var(--dg-button-delete-hover-text, white);
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { IconifyIcon } from '@iconify/svelte';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
type?: 'button' | 'submit';
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
compact?: boolean;
|
|
8
|
+
cancel?: boolean;
|
|
9
|
+
destructive?: boolean;
|
|
10
|
+
secondary?: boolean;
|
|
11
|
+
describedby?: string | undefined;
|
|
12
|
+
element?: HTMLElement | undefined;
|
|
13
|
+
icon?: IconifyIcon;
|
|
14
|
+
class?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
click: MouseEvent;
|
|
18
|
+
} & {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {
|
|
22
|
+
default: {};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare type ButtonProps = typeof __propDef.props;
|
|
26
|
+
export declare type ButtonEvents = typeof __propDef.events;
|
|
27
|
+
export declare type ButtonSlots = typeof __propDef.slots;
|
|
28
|
+
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/Checkbox.svelte
CHANGED
|
@@ -10,7 +10,8 @@ export let disabled = false;
|
|
|
10
10
|
export let valid = false;
|
|
11
11
|
export let invalid = false;
|
|
12
12
|
export let inputelement = undefined;
|
|
13
|
-
|
|
13
|
+
export let helptextid = undefined;
|
|
14
|
+
$: descby = [descid, messagesid, helptextid].filter(isNotBlank).join(' ');
|
|
14
15
|
</script>
|
|
15
16
|
|
|
16
17
|
<input bind:this={inputelement} {id} type="checkbox" {name} class:valid class:invalid {disabled} aria-describedby={descby} bind:checked={value} on:change={onChange} on:blur={onBlur}>
|
package/Checkbox.svelte.d.ts
CHANGED
package/Container.svelte
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
<script>import { eq } from '@txstate-mws/svelte-components';
|
|
2
2
|
import InlineMessages from './InlineMessages.svelte';
|
|
3
|
+
import { randomid } from 'txstate-utils';
|
|
3
4
|
export let id = undefined;
|
|
4
5
|
export let descid = undefined;
|
|
5
6
|
export let label;
|
|
7
|
+
export let helptext = undefined;
|
|
6
8
|
export let messages;
|
|
7
9
|
export let required = false;
|
|
8
10
|
let messagesid;
|
|
11
|
+
const helptextid = helptext ? randomid() : undefined;
|
|
9
12
|
</script>
|
|
10
13
|
|
|
11
14
|
<div use:eq class="dialog-field-container">
|
|
@@ -15,16 +18,16 @@ let messagesid;
|
|
|
15
18
|
<div id={descid} class="dialog-field-label">{label}{#if required} *{/if}</div>
|
|
16
19
|
{/if}
|
|
17
20
|
<div class="dialog-field-content">
|
|
18
|
-
|
|
21
|
+
{#if helptext}
|
|
22
|
+
<div id={helptextid} class="dialog-field-help">{helptext}</div>
|
|
23
|
+
{/if}
|
|
24
|
+
<slot {messagesid} {helptextid}/>
|
|
19
25
|
</div>
|
|
20
26
|
<InlineMessages bind:id={messagesid} {messages} />
|
|
21
27
|
</div>
|
|
22
28
|
|
|
23
29
|
<style>
|
|
24
30
|
.dialog-field-container {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-wrap: wrap;
|
|
27
|
-
align-items: center;
|
|
28
31
|
border-bottom: var(--dialog-container-border, 1px solid #999999);
|
|
29
32
|
padding: var(--dialog-container-padding, 1em) 0;
|
|
30
33
|
--dialog-container-tab-correct: calc(-1 * var(--tabs-panel-padding, 1em));
|
|
@@ -57,33 +60,29 @@ let messagesid;
|
|
|
57
60
|
:global(.tabs-panel) .dialog-field-container :global(.dialog-field-container) {
|
|
58
61
|
margin-left: 0;
|
|
59
62
|
}
|
|
60
|
-
.dialog-field-content {
|
|
61
|
-
position: relative;
|
|
62
|
-
width: max(70%, calc(100% - 20em));
|
|
63
|
-
}
|
|
64
63
|
.dialog-field-label {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
width: 100%;
|
|
69
|
-
margin-bottom: 0.4em;
|
|
64
|
+
display: block;
|
|
65
|
+
margin-bottom: 0.3em;
|
|
66
|
+
font-weight: 500;
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
.dialog-field-content {
|
|
69
|
+
position: relative;
|
|
73
70
|
}
|
|
74
71
|
.dialog-field-container :global(.dialog-input) {
|
|
75
72
|
width: 100%;
|
|
76
|
-
padding: 0.
|
|
73
|
+
padding: 0.3em 0.5em;
|
|
74
|
+
border: 0;
|
|
75
|
+
border-radius: 0;
|
|
77
76
|
}
|
|
78
77
|
.dialog-field-container:nth-of-type(even) {
|
|
79
|
-
background-color: var(--dialog-field-bg1,
|
|
78
|
+
background-color: var(--dialog-field-bg1, transparent);
|
|
80
79
|
color: var(--dialog-field-text1, inherit);
|
|
81
80
|
}
|
|
82
81
|
.dialog-field-container:nth-of-type(odd) {
|
|
83
|
-
background-color: var(--dialog-field-bg2,
|
|
82
|
+
background-color: var(--dialog-field-bg2, transparent);
|
|
84
83
|
color: var(--dialog-field-text2, inherit);
|
|
85
84
|
}
|
|
86
|
-
.dialog-field-container :global(.field-help
|
|
85
|
+
.dialog-field-container :global(.dialog-field-help) {
|
|
87
86
|
font-size: 0.9em;
|
|
88
87
|
color: #595959;
|
|
89
88
|
}
|
package/Container.svelte.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare const __propDef: {
|
|
|
5
5
|
id?: string | undefined;
|
|
6
6
|
descid?: string | undefined;
|
|
7
7
|
label: string;
|
|
8
|
+
helptext?: string | undefined;
|
|
8
9
|
messages: Feedback[];
|
|
9
10
|
required?: boolean;
|
|
10
11
|
};
|
|
@@ -14,6 +15,7 @@ declare const __propDef: {
|
|
|
14
15
|
slots: {
|
|
15
16
|
default: {
|
|
16
17
|
messagesid: any;
|
|
18
|
+
helptextid: string;
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
};
|
package/Dialog.svelte
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<script context="module">export const DIALOG_TABS_CONTEXT = {};
|
|
2
|
+
</script>
|
|
3
|
+
<script>import arrowLeftLight from '@iconify-icons/ph/arrow-left-light';
|
|
4
|
+
import arrowRightLight from '@iconify-icons/ph/arrow-right-light';
|
|
5
|
+
import { Modal, ScreenReaderOnly } from '@txstate-mws/svelte-components';
|
|
6
|
+
import { createEventDispatcher, setContext } from 'svelte';
|
|
7
|
+
import { isNotBlank, randomid } from 'txstate-utils';
|
|
8
|
+
import { Button, Icon } from './';
|
|
9
|
+
const dispatch = createEventDispatcher();
|
|
10
|
+
export let initialfocus = undefined;
|
|
11
|
+
export let title = '';
|
|
12
|
+
export let icon = undefined;
|
|
13
|
+
export let size = 'normal';
|
|
14
|
+
export let cancelText = undefined;
|
|
15
|
+
export let continueText = 'Ok';
|
|
16
|
+
export let continueIcon = undefined;
|
|
17
|
+
export let escapable = isNotBlank(cancelText);
|
|
18
|
+
export let disabled = false;
|
|
19
|
+
export let labelid = randomid();
|
|
20
|
+
export let descid = randomid();
|
|
21
|
+
const ctx = { change: onTabChange };
|
|
22
|
+
let hasTabs = false;
|
|
23
|
+
let prevTitle;
|
|
24
|
+
let nextTitle;
|
|
25
|
+
let hasRequired = false;
|
|
26
|
+
let onPrev;
|
|
27
|
+
let onNext;
|
|
28
|
+
function onTabChange() {
|
|
29
|
+
({ hasTabs, prevTitle, nextTitle, hasRequired, onPrev, onNext } = ctx);
|
|
30
|
+
}
|
|
31
|
+
setContext(DIALOG_TABS_CONTEXT, ctx);
|
|
32
|
+
$: describedby = [title ? labelid : undefined, descid].filter(isNotBlank).join(' ');
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<Modal {escapable} {initialfocus} hidefocus={false} on:escape>
|
|
36
|
+
<section class="{size}">
|
|
37
|
+
{#if title || icon}
|
|
38
|
+
<header id={labelid}>
|
|
39
|
+
<Icon width="1.4em" {icon} inline />{title}
|
|
40
|
+
</header>
|
|
41
|
+
{/if}
|
|
42
|
+
<div id={descid} class="content">
|
|
43
|
+
<slot></slot>
|
|
44
|
+
</div>
|
|
45
|
+
<footer class="actions">
|
|
46
|
+
<slot name="buttons" {nextTitle} {prevTitle} {hasRequired} onPrev={onPrev} onNext={onNext}>
|
|
47
|
+
{#if prevTitle}
|
|
48
|
+
<Button class="prev" disabled={!prevTitle} on:click={onPrev}><Icon icon={arrowLeftLight} inline /> Previous<ScreenReaderOnly> Tab ({prevTitle})</ScreenReaderOnly></Button>
|
|
49
|
+
{/if}
|
|
50
|
+
{#if isNotBlank(cancelText)}
|
|
51
|
+
<Button cancel {describedby} on:click={() => dispatch('escape')}>{cancelText}</Button>
|
|
52
|
+
{/if}
|
|
53
|
+
<Button class="primary" disabled={disabled || hasRequired} {describedby} on:click={() => dispatch('continue')}><Icon icon={continueIcon} inline />{continueText}</Button>
|
|
54
|
+
{#if nextTitle}
|
|
55
|
+
<Button class="next" disabled={!nextTitle} on:click={onNext}>Next<ScreenReaderOnly> Tab ({nextTitle})</ScreenReaderOnly> <Icon width="1.2em" icon={arrowRightLight} inline /></Button>
|
|
56
|
+
{/if}
|
|
57
|
+
</slot>
|
|
58
|
+
</footer>
|
|
59
|
+
</section>
|
|
60
|
+
</Modal>
|
|
61
|
+
|
|
62
|
+
<style>
|
|
63
|
+
section {
|
|
64
|
+
position: relative;
|
|
65
|
+
background-color: #f4f4f4;
|
|
66
|
+
padding: 1em;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
}
|
|
69
|
+
section.tiny {
|
|
70
|
+
width: 30vw;
|
|
71
|
+
min-width: 200px;
|
|
72
|
+
max-width: 250px;
|
|
73
|
+
}
|
|
74
|
+
section.small {
|
|
75
|
+
width: 50vw;
|
|
76
|
+
min-width: 220px;
|
|
77
|
+
max-width: 400px;
|
|
78
|
+
}
|
|
79
|
+
section.normal {
|
|
80
|
+
width: 75vw;
|
|
81
|
+
min-width: 250px;
|
|
82
|
+
max-width: 650px;
|
|
83
|
+
}
|
|
84
|
+
section.large {
|
|
85
|
+
width: 90vw;
|
|
86
|
+
min-width: 300px;
|
|
87
|
+
max-width: 1000px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
header {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
font-size: 1.1em;
|
|
94
|
+
margin: -1em;
|
|
95
|
+
margin-bottom: 0;
|
|
96
|
+
padding: 0.5em calc(var(--tabs-padding-hori, 1em) + 0.9em - 3px);
|
|
97
|
+
background-color: var(--dg-dialog-header-bg, #DDDDDD);
|
|
98
|
+
color: var(--dg-dialog-header-text, black);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
header :global(svg) {
|
|
102
|
+
margin-right: 0.4em;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.content {
|
|
106
|
+
margin: 0 -1em;
|
|
107
|
+
padding: 1em;
|
|
108
|
+
min-height: 5em;
|
|
109
|
+
overflow: auto;
|
|
110
|
+
background-color: var(--dg-dialog-content-bg, #f4f4f4);
|
|
111
|
+
max-height: calc(100vh - 7em);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
footer {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: flex-end;
|
|
118
|
+
flex-wrap: wrap;
|
|
119
|
+
background-color: var(--dg-dialog-footer-bg, #DDDDDD);
|
|
120
|
+
margin: -1em;
|
|
121
|
+
margin-top: 0;
|
|
122
|
+
padding: 0.5em 1em;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
footer > :global(*:not(:last-child)) {
|
|
126
|
+
margin-right: 0.5em;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:global(.dialog-field-container) {
|
|
130
|
+
background-color: transparent !important;
|
|
131
|
+
border-bottom: 0px !important;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
footer.actions :global(.prev) {
|
|
135
|
+
margin-right: auto;
|
|
136
|
+
}
|
|
137
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
export declare const DIALOG_TABS_CONTEXT: {};
|
|
3
|
+
export interface DialogTabContext {
|
|
4
|
+
change: (..._: any) => void;
|
|
5
|
+
hasTabs?: boolean;
|
|
6
|
+
prevTitle?: string;
|
|
7
|
+
nextTitle?: string;
|
|
8
|
+
hasRequired?: boolean;
|
|
9
|
+
onNext?: () => void;
|
|
10
|
+
onPrev?: () => void;
|
|
11
|
+
}
|
|
12
|
+
import type { IconifyIcon } from '@iconify/svelte';
|
|
13
|
+
declare const __propDef: {
|
|
14
|
+
props: {
|
|
15
|
+
initialfocus?: string | undefined;
|
|
16
|
+
title?: string;
|
|
17
|
+
icon?: IconifyIcon;
|
|
18
|
+
size?: 'tiny' | 'small' | 'normal' | 'large';
|
|
19
|
+
cancelText?: string | undefined;
|
|
20
|
+
continueText?: string;
|
|
21
|
+
continueIcon?: IconifyIcon;
|
|
22
|
+
escapable?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
labelid?: string;
|
|
25
|
+
descid?: string;
|
|
26
|
+
};
|
|
27
|
+
events: {
|
|
28
|
+
escape: CustomEvent<any>;
|
|
29
|
+
continue: CustomEvent<any>;
|
|
30
|
+
} & {
|
|
31
|
+
[evt: string]: CustomEvent<any>;
|
|
32
|
+
};
|
|
33
|
+
slots: {
|
|
34
|
+
default: {};
|
|
35
|
+
buttons: {
|
|
36
|
+
nextTitle: string;
|
|
37
|
+
prevTitle: string;
|
|
38
|
+
hasRequired: boolean;
|
|
39
|
+
onPrev: () => void;
|
|
40
|
+
onNext: () => void;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare type DialogProps = typeof __propDef.props;
|
|
45
|
+
export declare type DialogEvents = typeof __propDef.events;
|
|
46
|
+
export declare type DialogSlots = typeof __propDef.slots;
|
|
47
|
+
export default class Dialog extends SvelteComponentTyped<DialogProps, DialogEvents, DialogSlots> {
|
|
48
|
+
}
|
|
49
|
+
export {};
|
package/FieldAutocomplete.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import FieldStandard from './FieldStandard.svelte';
|
|
3
3
|
import { randomid } from 'txstate-utils';
|
|
4
4
|
import { PopupMenu, ScreenReaderOnly } from '@txstate-mws/svelte-components';
|
|
5
|
+
import { getDescribedBy } from './';
|
|
5
6
|
export let id = undefined;
|
|
6
7
|
export let path;
|
|
7
8
|
export let label = '';
|
|
@@ -14,15 +15,14 @@ export let choices;
|
|
|
14
15
|
export let defaultValue = notNull ? choices[0].value : undefined;
|
|
15
16
|
export let conditional = undefined;
|
|
16
17
|
export let required = false;
|
|
17
|
-
export let helptext = '';
|
|
18
18
|
export let inputelement = undefined;
|
|
19
|
+
export let helptext = undefined;
|
|
19
20
|
let inputvalue = '';
|
|
20
21
|
let popupvalue = undefined;
|
|
21
22
|
let savedLabel = '';
|
|
22
23
|
let changed = false;
|
|
23
24
|
let menuid;
|
|
24
25
|
const liveTextId = randomid();
|
|
25
|
-
const helpTextId = randomid();
|
|
26
26
|
$: filteredChoices = changed
|
|
27
27
|
? choices.filter((item) => {
|
|
28
28
|
return item.label?.toLowerCase().includes(inputvalue.toLowerCase()) || item.value.toLowerCase().includes(inputvalue.toLowerCase());
|
|
@@ -56,13 +56,10 @@ function reactToInitialValue(value) {
|
|
|
56
56
|
}
|
|
57
57
|
</script>
|
|
58
58
|
|
|
59
|
-
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} serialize={!notNull && nullableSerialize} deserialize={!notNull && nullableDeserialize} let:value let:setVal let:valid let:invalid let:id let:onBlur let:onChange let:messagesid>
|
|
59
|
+
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {helptext} serialize={!notNull && nullableSerialize} deserialize={!notNull && nullableDeserialize} let:value let:setVal let:valid let:invalid let:id let:onBlur let:onChange let:messagesid let:helptextid>
|
|
60
60
|
{@const _ = reactToInitialValue(value)}
|
|
61
|
-
<input bind:this={inputelement} bind:value={inputvalue} {id} {placeholder} class="dialog-input {className}" class:valid class:invalid aria-invalid={invalid} aria-expanded={false} aria-controls={menuid} on:blur={onBlur} on:change={onChange} autocapitalize="none" type="text" autocomplete="off" aria-autocomplete="list" role="combobox" {disabled} aria-describedby={
|
|
61
|
+
<input bind:this={inputelement} bind:value={inputvalue} {id} {placeholder} class="dialog-input {className}" class:valid class:invalid aria-invalid={invalid} aria-expanded={false} aria-controls={menuid} on:blur={onBlur} on:change={onChange} autocapitalize="none" type="text" autocomplete="off" aria-autocomplete="list" role="combobox" {disabled} aria-describedby={getDescribedBy([messagesid, helptextid])} on:keydown={checkifchanged}>
|
|
62
62
|
<PopupMenu bind:menuid align="bottomleft" items={filteredChoices} buttonelement={inputelement} bind:value={popupvalue} on:change={onchangepopup(setVal)} emptyText="No options available"/>
|
|
63
|
-
{#if helptext.length}
|
|
64
|
-
<span id={helpTextId} class="field-help-text">{helptext}</span>
|
|
65
|
-
{/if}
|
|
66
63
|
<ScreenReaderOnly arialive="polite" ariaatomic={true} id={liveTextId}>
|
|
67
64
|
{filteredChoices.length} {filteredChoices.length === 1 ? 'option' : 'options'} available.
|
|
68
65
|
</ScreenReaderOnly>
|
|
@@ -16,8 +16,8 @@ declare const __propDef: {
|
|
|
16
16
|
defaultValue?: any;
|
|
17
17
|
conditional?: boolean | undefined;
|
|
18
18
|
required?: boolean;
|
|
19
|
-
helptext?: string;
|
|
20
19
|
inputelement?: HTMLInputElement;
|
|
20
|
+
helptext?: string | undefined;
|
|
21
21
|
};
|
|
22
22
|
events: {
|
|
23
23
|
[evt: string]: CustomEvent<any>;
|
package/FieldCheckbox.svelte
CHANGED
|
@@ -11,6 +11,7 @@ export let defaultValue = undefined;
|
|
|
11
11
|
export let conditional = undefined;
|
|
12
12
|
export let required = false;
|
|
13
13
|
export let inputelement = undefined;
|
|
14
|
+
export let helptext = undefined;
|
|
14
15
|
function onChange(setVal) {
|
|
15
16
|
return function () {
|
|
16
17
|
setVal(this.checked);
|
|
@@ -19,10 +20,10 @@ function onChange(setVal) {
|
|
|
19
20
|
const descid = randomid();
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
|
-
<FieldStandard bind:id {path} {descid} {label} {defaultValue} {conditional} {required} let:value let:messagesid let:valid let:invalid let:id let:onBlur let:setVal>
|
|
23
|
+
<FieldStandard bind:id {path} {descid} {label} {defaultValue} {conditional} {helptext} {required} let:value let:messagesid let:helptextid let:valid let:invalid let:id let:onBlur let:setVal>
|
|
23
24
|
<div class={className}>
|
|
24
25
|
<label for={id}>
|
|
25
|
-
<Checkbox bind:inputelement {id} name={path} {value} {messagesid} {descid} {valid} {invalid} {onBlur} onChange={onChange(setVal)}></Checkbox>
|
|
26
|
+
<Checkbox bind:inputelement {id} name={path} {value} {messagesid} {helptextid} {descid} {valid} {invalid} {onBlur} onChange={onChange(setVal)}></Checkbox>
|
|
26
27
|
<span>{boxLabel}</span>
|
|
27
28
|
</label>
|
|
28
29
|
</div>
|
|
@@ -5,11 +5,12 @@ declare const __propDef: {
|
|
|
5
5
|
id?: string | undefined;
|
|
6
6
|
path: string;
|
|
7
7
|
label?: string;
|
|
8
|
-
boxLabel:
|
|
8
|
+
boxLabel: string;
|
|
9
9
|
defaultValue?: boolean | undefined;
|
|
10
10
|
conditional?: boolean | undefined;
|
|
11
11
|
required?: boolean;
|
|
12
12
|
inputelement?: HTMLInputElement;
|
|
13
|
+
helptext?: string | undefined;
|
|
13
14
|
};
|
|
14
15
|
events: {
|
|
15
16
|
[evt: string]: CustomEvent<any>;
|
package/FieldChoices.svelte
CHANGED
|
@@ -14,6 +14,7 @@ export let defaultValue = [];
|
|
|
14
14
|
export let conditional = undefined;
|
|
15
15
|
export let maxwidth = 250;
|
|
16
16
|
export let leftToRight = false;
|
|
17
|
+
export let helptext = undefined;
|
|
17
18
|
const store = getContext(FORM_CONTEXT);
|
|
18
19
|
const currentWidth = derivedStore(store, 'width');
|
|
19
20
|
$: cols = Math.min(Math.ceil($currentWidth / maxwidth), choices.length);
|
|
@@ -39,14 +40,14 @@ const descid = randomid();
|
|
|
39
40
|
</script>
|
|
40
41
|
|
|
41
42
|
<Field {path} {defaultValue} {conditional} let:path let:value let:onBlur let:setVal let:messages let:valid let:invalid>
|
|
42
|
-
<Container {id} {label} {messages} {descid} let:messagesid>
|
|
43
|
+
<Container {id} {label} {messages} {descid} {helptext} let:messagesid let:helptextid>
|
|
43
44
|
<div class="dialog-choices {className}" class:valid class:invalid>
|
|
44
45
|
{#each choices as choice, idx}
|
|
45
46
|
{@const checkid = `${path}.${idx}`}
|
|
46
47
|
{@const included = value && value.includes(choice.value)}
|
|
47
48
|
{@const label = choice.label || (typeof choice.value === 'string' ? choice.value : '')}
|
|
48
49
|
<label for={checkid} style:width style:order={orders[idx]}>
|
|
49
|
-
<Checkbox id={checkid} name={checkid} value={included} {messagesid} {descid} disabled={choice.disabled} onChange={() => onChangeCheckbox(setVal, choice, included)} {onBlur} />
|
|
50
|
+
<Checkbox id={checkid} name={checkid} value={included} {messagesid} {helptextid} {descid} disabled={choice.disabled} onChange={() => onChangeCheckbox(setVal, choice, included)} {onBlur} />
|
|
50
51
|
<span>{label}</span>
|
|
51
52
|
</label>
|
|
52
53
|
{/each}
|
package/FieldChoices.svelte.d.ts
CHANGED
package/FieldChooserLink.svelte
CHANGED
|
@@ -7,6 +7,7 @@ import { Chooser, ChooserStore, CHOOSER_API_CONTEXT } from './chooser';
|
|
|
7
7
|
import Details from './chooser/Details.svelte';
|
|
8
8
|
import Thumbnail from './chooser/Thumbnail.svelte';
|
|
9
9
|
import FieldStandard from './FieldStandard.svelte';
|
|
10
|
+
import { getDescribedBy } from './';
|
|
10
11
|
export let id = undefined;
|
|
11
12
|
export let path;
|
|
12
13
|
export let label = '';
|
|
@@ -21,6 +22,7 @@ export let urlEntry = false;
|
|
|
21
22
|
export let initialType = undefined;
|
|
22
23
|
export let initialSource = undefined;
|
|
23
24
|
export let initialPath = undefined;
|
|
25
|
+
export let helptext = undefined;
|
|
24
26
|
const formStore = getContext(FORM_CONTEXT);
|
|
25
27
|
const value = formStore.getField(path);
|
|
26
28
|
const chooserClient = getContext(CHOOSER_API_CONTEXT);
|
|
@@ -66,14 +68,14 @@ async function updateSelected(..._) {
|
|
|
66
68
|
$: updateSelected($value);
|
|
67
69
|
</script>
|
|
68
70
|
|
|
69
|
-
<FieldStandard bind:id {path} {descid} {label} {defaultValue} {conditional} {required} let:value let:messagesid let:valid let:invalid let:id let:onBlur let:setVal>
|
|
71
|
+
<FieldStandard bind:id {path} {descid} {label} {defaultValue} {conditional} {required} {helptext} let:value let:messagesid let:helptextid let:valid let:invalid let:id let:onBlur let:setVal>
|
|
70
72
|
{#if selectedAsset}
|
|
71
73
|
<div class="dialog-chooser-container">
|
|
72
74
|
<Thumbnail item={selectedAsset} />
|
|
73
75
|
<Details item={selectedAsset} />
|
|
74
76
|
</div>
|
|
75
77
|
{/if}
|
|
76
|
-
<button type="button" on:click={show} aria-describedby={messagesid}>Select {#if value}New{/if} {#if assets && pages}Link Target{:else if images}Image{:else if assets}Asset{:else}Page{/if}</button>
|
|
78
|
+
<button type="button" on:click={show} aria-describedby={getDescribedBy([descid, messagesid, helptextid])}>Select {#if value}New{/if} {#if assets && pages}Link Target{:else if images}Image{:else if assets}Asset{:else}Page{/if}</button>
|
|
77
79
|
{#if urlEntry && !folders && selectedAsset?.type !== 'folder'}
|
|
78
80
|
<input type="text" value={selectedAsset?.url ?? ''} on:change={userUrlEntry}><br>
|
|
79
81
|
{/if}
|
package/FieldDate.svelte
CHANGED
|
@@ -13,8 +13,9 @@ export let step = undefined;
|
|
|
13
13
|
export let conditional = undefined;
|
|
14
14
|
export let required = false;
|
|
15
15
|
export let inputelement = undefined;
|
|
16
|
+
export let helptext = undefined;
|
|
16
17
|
</script>
|
|
17
18
|
|
|
18
|
-
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} serialize={dateSerialize} deserialize={dateDeserialize} let:value let:valid let:invalid let:id let:onBlur let:onChange let:messagesid>
|
|
19
|
-
<Input bind:inputelement type="date" name={path} {value} {id} class="dialog-input {className}" {onChange} {onBlur} {valid} {invalid} {min} {max} {step} {messagesid} />
|
|
19
|
+
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {helptext} serialize={dateSerialize} deserialize={dateDeserialize} let:value let:valid let:invalid let:id let:onBlur let:onChange let:messagesid let:helptextid>
|
|
20
|
+
<Input bind:inputelement type="date" name={path} {value} {id} class="dialog-input {className}" {onChange} {onBlur} {valid} {invalid} {min} {max} {step} {messagesid} {helptextid}/>
|
|
20
21
|
</FieldStandard>
|
package/FieldDate.svelte.d.ts
CHANGED
package/FieldDateTime.svelte
CHANGED
|
@@ -12,8 +12,9 @@ export let max = undefined;
|
|
|
12
12
|
export let step = undefined;
|
|
13
13
|
export let conditional = undefined;
|
|
14
14
|
export let required = false;
|
|
15
|
+
export let helptext = undefined;
|
|
15
16
|
</script>
|
|
16
17
|
|
|
17
|
-
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} serialize={datetimeSerialize} deserialize={datetimeDeserialize} let:value let:valid let:invalid let:id let:onBlur let:onChange>
|
|
18
|
-
<Input type="datetime-local" name={path} {value} {id} class="dialog-input {className}" {onChange} {onBlur} {valid} {invalid} {min} {max} {step} />
|
|
18
|
+
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} {helptext} serialize={datetimeSerialize} deserialize={datetimeDeserialize} let:value let:valid let:invalid let:id let:onBlur let:onChange let:helptextid>
|
|
19
|
+
<Input type="datetime-local" name={path} {value} {id} class="dialog-input {className}" {onChange} {onBlur} {valid} {invalid} {min} {max} {step} {helptextid}/>
|
|
19
20
|
</FieldStandard>
|