@dosgato/dialog 0.0.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/ButtonGroup.svelte +74 -0
- package/ButtonGroup.svelte.d.ts +28 -0
- package/Checkbox.svelte +68 -0
- package/Checkbox.svelte.d.ts +25 -0
- package/Container.svelte +86 -0
- package/Container.svelte.d.ts +25 -0
- package/FieldCheckbox.svelte +28 -0
- package/FieldCheckbox.svelte.d.ts +23 -0
- package/FieldChoices.svelte +75 -0
- package/FieldChoices.svelte.d.ts +28 -0
- package/FieldChooserLink.svelte +100 -0
- package/FieldChooserLink.svelte.d.ts +30 -0
- package/FieldDate.svelte +19 -0
- package/FieldDate.svelte.d.ts +29 -0
- package/FieldDateTime.svelte +19 -0
- package/FieldDateTime.svelte.d.ts +29 -0
- package/FieldMultiple.svelte +83 -0
- package/FieldMultiple.svelte.d.ts +33 -0
- package/FieldMultiselect.svelte +50 -0
- package/FieldMultiselect.svelte.d.ts +25 -0
- package/FieldNumber.svelte +20 -0
- package/FieldNumber.svelte.d.ts +26 -0
- package/FieldRadio.svelte +52 -0
- package/FieldRadio.svelte.d.ts +29 -0
- package/FieldSelect.svelte +24 -0
- package/FieldSelect.svelte.d.ts +30 -0
- package/FieldStandard.svelte +19 -0
- package/FieldStandard.svelte.d.ts +36 -0
- package/FieldText.svelte +20 -0
- package/FieldText.svelte.d.ts +26 -0
- package/FileIcon.svelte +56 -0
- package/FileIcon.svelte.d.ts +21 -0
- package/Form.svelte +56 -0
- package/Form.svelte.d.ts +9 -0
- package/Icon.svelte +16 -0
- package/Icon.svelte.d.ts +22 -0
- package/InlineMessage.svelte +42 -0
- package/InlineMessage.svelte.d.ts +17 -0
- package/InlineMessages.svelte +21 -0
- package/InlineMessages.svelte.d.ts +18 -0
- package/Input.svelte +33 -0
- package/Input.svelte.d.ts +36 -0
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/Radio.svelte +65 -0
- package/Radio.svelte.d.ts +25 -0
- package/Tab.svelte +57 -0
- package/Tab.svelte.d.ts +18 -0
- package/TabStore.d.ts +28 -0
- package/TabStore.js +42 -0
- package/Tabs.svelte +105 -0
- package/Tabs.svelte.d.ts +25 -0
- package/chooser/Asset.svelte +77 -0
- package/chooser/Asset.svelte.d.ts +25 -0
- package/chooser/AssetFolder.svelte +124 -0
- package/chooser/AssetFolder.svelte.d.ts +25 -0
- package/chooser/Chooser.svelte +169 -0
- package/chooser/Chooser.svelte.d.ts +30 -0
- package/chooser/ChooserAPI.d.ts +48 -0
- package/chooser/ChooserAPI.js +1 -0
- package/chooser/ChooserStore.d.ts +72 -0
- package/chooser/ChooserStore.js +200 -0
- package/chooser/Details.svelte +29 -0
- package/chooser/Details.svelte.d.ts +19 -0
- package/chooser/Page.svelte +118 -0
- package/chooser/Page.svelte.d.ts +25 -0
- package/chooser/Thumbnail.svelte +40 -0
- package/chooser/Thumbnail.svelte.d.ts +17 -0
- package/chooser/index.d.ts +6 -0
- package/chooser/index.js +6 -0
- package/index.d.ts +24 -0
- package/index.js +24 -0
- package/package.json +63 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script >import { modifierKey } from '@txstate-mws/svelte-components';
|
|
2
|
+
import { createEventDispatcher } from 'svelte';
|
|
3
|
+
export let name = undefined;
|
|
4
|
+
export let choices;
|
|
5
|
+
export let value = choices[0].value;
|
|
6
|
+
export let groupid = undefined;
|
|
7
|
+
export let messagesid = undefined;
|
|
8
|
+
export let ariaControls = undefined;
|
|
9
|
+
export let disabled = false;
|
|
10
|
+
export let valid = false;
|
|
11
|
+
export let invalid = false;
|
|
12
|
+
const dispatch = createEventDispatcher();
|
|
13
|
+
const elements = [];
|
|
14
|
+
function update(newVal) {
|
|
15
|
+
value = newVal;
|
|
16
|
+
dispatch('change', value);
|
|
17
|
+
}
|
|
18
|
+
function onClick(choice, idx) {
|
|
19
|
+
return () => {
|
|
20
|
+
update(choice.value);
|
|
21
|
+
elements[idx].focus();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function onKeyDown(choice, idx) {
|
|
25
|
+
return e => {
|
|
26
|
+
if (modifierKey(e))
|
|
27
|
+
return;
|
|
28
|
+
if ((e.key === 'ArrowRight' || e.key === 'ArrowDown') && idx < choices.length - 1) {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
update(choices[idx + 1].value);
|
|
32
|
+
elements[idx + 1].focus();
|
|
33
|
+
}
|
|
34
|
+
else if ((e.key === 'ArrowLeft' || e.key === 'ArrowUp') && idx > 0) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
update(choices[idx - 1].value);
|
|
38
|
+
elements[idx - 1].focus();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
{#if name}
|
|
45
|
+
<input type="hidden" {name} {value}>
|
|
46
|
+
{/if}
|
|
47
|
+
<ul class="dialog-btn-group" class:disabled class:valid class:invalid aria-disabled={disabled} role="radiogroup" aria-labelledby={groupid} on:blur>
|
|
48
|
+
{#each choices as choice, i}
|
|
49
|
+
{@const selected = choice.value === value}
|
|
50
|
+
<li bind:this={elements[i]} role="radio" class:selected tabindex={selected ? 0 : -1} aria-controls={ariaControls} on:click={onClick(choice, i)} on:keydown={onKeyDown(choice, i)} on:blur aria-describedby="{groupid} {messagesid}">{choice.label || choice.value}</li>
|
|
51
|
+
{/each}
|
|
52
|
+
</ul>
|
|
53
|
+
|
|
54
|
+
<style>
|
|
55
|
+
.dialog-btn-group {
|
|
56
|
+
display: flex;
|
|
57
|
+
border-radius: 0.25em;
|
|
58
|
+
border: 1px solid var(--dialog-btngrp-active-bg, #333333);
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
padding: 0;
|
|
61
|
+
margin: 0;
|
|
62
|
+
list-style: none;
|
|
63
|
+
}
|
|
64
|
+
li {
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
padding: 0.4em .8em;
|
|
67
|
+
background-color: var(--dialog-btngrp-text, transparent);
|
|
68
|
+
color: var(--dialog-btngrp-bg, inherit);
|
|
69
|
+
}
|
|
70
|
+
.selected {
|
|
71
|
+
background-color: var(--dialog-btngrp-active-bg, #333333);
|
|
72
|
+
color: var(--dialog-btngrp-active-text, white);
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type PopupMenuItem } from '@txstate-mws/svelte-components';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
name?: string;
|
|
6
|
+
choices: PopupMenuItem[];
|
|
7
|
+
value?: string;
|
|
8
|
+
groupid?: string | undefined;
|
|
9
|
+
messagesid?: string | undefined;
|
|
10
|
+
ariaControls?: string | undefined;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
valid?: boolean;
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
blur: FocusEvent;
|
|
17
|
+
change: CustomEvent<any>;
|
|
18
|
+
} & {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export declare type ButtonGroupProps = typeof __propDef.props;
|
|
24
|
+
export declare type ButtonGroupEvents = typeof __propDef.events;
|
|
25
|
+
export declare type ButtonGroupSlots = typeof __propDef.slots;
|
|
26
|
+
export default class ButtonGroup extends SvelteComponentTyped<ButtonGroupProps, ButtonGroupEvents, ButtonGroupSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/Checkbox.svelte
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script >import { isNotBlank } from 'txstate-utils';
|
|
2
|
+
export let id = undefined;
|
|
3
|
+
export let name;
|
|
4
|
+
export let value;
|
|
5
|
+
export let onChange = undefined;
|
|
6
|
+
export let onBlur = undefined;
|
|
7
|
+
export let descid = undefined;
|
|
8
|
+
export let messagesid = undefined;
|
|
9
|
+
export let disabled = false;
|
|
10
|
+
export let valid = false;
|
|
11
|
+
export let invalid = false;
|
|
12
|
+
$: descby = [descid, messagesid].filter(isNotBlank).join(' ');
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<input {id} type="checkbox" {name} class:valid class:invalid {disabled} aria-describedby={descby} bind:checked={value} on:change={onChange} on:blur={onBlur}>
|
|
16
|
+
|
|
17
|
+
<style>
|
|
18
|
+
input, input:before, input:after {
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
input[type="checkbox"] {
|
|
23
|
+
-webkit-appearance: none;
|
|
24
|
+
appearance: none;
|
|
25
|
+
background-color: var(--dialog-checkbox-bg, #ffffff);
|
|
26
|
+
margin: 0;
|
|
27
|
+
|
|
28
|
+
font: inherit;
|
|
29
|
+
color: var(--dialog-checkbox-border, currentColor);
|
|
30
|
+
width: 1.15em;
|
|
31
|
+
height: 1.15em;
|
|
32
|
+
border: 0.15em solid currentColor;
|
|
33
|
+
border-radius: 0.15em;
|
|
34
|
+
transform: translateY(-0.075em);
|
|
35
|
+
|
|
36
|
+
display: inline-grid;
|
|
37
|
+
place-content: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
input[type="checkbox"]::before {
|
|
41
|
+
content: "";
|
|
42
|
+
width: 0.65em;
|
|
43
|
+
height: 0.65em;
|
|
44
|
+
clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
|
|
45
|
+
transform: scale(0);
|
|
46
|
+
transform-origin: bottom left;
|
|
47
|
+
transition: 120ms transform ease-in-out;
|
|
48
|
+
box-shadow: inset 1em 1em var(--dialog-checkbox-color, currentColor);
|
|
49
|
+
/* Windows High Contrast Mode */
|
|
50
|
+
background-color: CanvasText;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
input[type="checkbox"]:checked::before {
|
|
54
|
+
transform: scale(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
input[type="checkbox"]:focus {
|
|
58
|
+
outline: max(2px, 0.15em) solid var(--dialog-checkbox-focus, #4D90FE);
|
|
59
|
+
outline-offset: max(2px, 0.15em);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
input[type="checkbox"]:disabled {
|
|
63
|
+
--dialog-checkbox-color: var(--dialog-checkbox-disabled, #999999);
|
|
64
|
+
|
|
65
|
+
color: var(--dialog-checkbox-color);
|
|
66
|
+
cursor: not-allowed;
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
name: string;
|
|
6
|
+
value: boolean;
|
|
7
|
+
onChange?: any;
|
|
8
|
+
onBlur?: any;
|
|
9
|
+
descid?: string | undefined;
|
|
10
|
+
messagesid?: string | undefined;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
valid?: boolean;
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
};
|
|
18
|
+
slots: {};
|
|
19
|
+
};
|
|
20
|
+
export declare type CheckboxProps = typeof __propDef.props;
|
|
21
|
+
export declare type CheckboxEvents = typeof __propDef.events;
|
|
22
|
+
export declare type CheckboxSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Checkbox extends SvelteComponentTyped<CheckboxProps, CheckboxEvents, CheckboxSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/Container.svelte
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script >import { eq } from '@txstate-mws/svelte-components';
|
|
2
|
+
import InlineMessages from './InlineMessages.svelte';
|
|
3
|
+
export let id = undefined;
|
|
4
|
+
export let descid = undefined;
|
|
5
|
+
export let label;
|
|
6
|
+
export let messages;
|
|
7
|
+
export let required = false;
|
|
8
|
+
let messagesid;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div use:eq class="dialog-field-container">
|
|
12
|
+
{#if descid == null}
|
|
13
|
+
<label class="dialog-field-label" for={id}>{label}{#if required} *{/if}</label>
|
|
14
|
+
{:else}
|
|
15
|
+
<div id={descid} class="dialog-field-label">{label}{#if required} *{/if}</div>
|
|
16
|
+
{/if}
|
|
17
|
+
<div class="dialog-field-content">
|
|
18
|
+
<slot {messagesid} />
|
|
19
|
+
</div>
|
|
20
|
+
<InlineMessages bind:id={messagesid} {messages} />
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
.dialog-field-container {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
align-items: center;
|
|
28
|
+
border-bottom: var(--dialog-container-border, 1px solid #999999);
|
|
29
|
+
padding: var(--dialog-container-padding, 1em) 0;
|
|
30
|
+
--dialog-container-tab-correct: calc(-1 * var(--tabs-panel-padding, 1em));
|
|
31
|
+
}
|
|
32
|
+
.dialog-field-container:last-child {
|
|
33
|
+
border-bottom: 0;
|
|
34
|
+
}
|
|
35
|
+
.dialog-field-container div.dialog-field-content :global(.dialog-field-container) {
|
|
36
|
+
border-bottom: 0;
|
|
37
|
+
background-color: transparent;
|
|
38
|
+
color: inherit;
|
|
39
|
+
padding: 0;
|
|
40
|
+
margin: 0 0 1em 0;
|
|
41
|
+
}
|
|
42
|
+
.dialog-field-container div.dialog-field-content :global(.dialog-field-container:last-child) {
|
|
43
|
+
margin-bottom: 0;
|
|
44
|
+
}
|
|
45
|
+
:global(.tabs-panel) .dialog-field-container {
|
|
46
|
+
margin-left: var(--dialog-container-tab-correct);
|
|
47
|
+
margin-right: var(--dialog-container-tab-correct);
|
|
48
|
+
padding-left: var(--tabs-panel-padding, 1em);
|
|
49
|
+
padding-right: var(--tabs-panel-padding, 1em);
|
|
50
|
+
}
|
|
51
|
+
:global(.tabs-panel) .dialog-field-container:first-child {
|
|
52
|
+
margin-top: var(--dialog-container-tab-correct);
|
|
53
|
+
}
|
|
54
|
+
:global(.tabs-panel) .dialog-field-container:last-child {
|
|
55
|
+
margin-bottom: var(--dialog-container-tab-correct);
|
|
56
|
+
}
|
|
57
|
+
:global(.tabs-panel) .dialog-field-container :global(.dialog-field-container) {
|
|
58
|
+
margin-left: 0;
|
|
59
|
+
}
|
|
60
|
+
.dialog-field-content {
|
|
61
|
+
position: relative;
|
|
62
|
+
width: max(70%, calc(100% - 20em));
|
|
63
|
+
}
|
|
64
|
+
.dialog-field-label {
|
|
65
|
+
width: min(30%, 20em);
|
|
66
|
+
}
|
|
67
|
+
:global([data-eq~="500px"]) .dialog-field-label {
|
|
68
|
+
width: 100%;
|
|
69
|
+
margin-bottom: 0.4em;
|
|
70
|
+
}
|
|
71
|
+
:global([data-eq~="500px"]) .dialog-field-content {
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
.dialog-field-container :global(.dialog-input) {
|
|
75
|
+
width: 100%;
|
|
76
|
+
padding: 0.4em 0.6em;
|
|
77
|
+
}
|
|
78
|
+
.dialog-field-container:nth-of-type(even) {
|
|
79
|
+
background-color: var(--dialog-field-bg1, #e6e6e6);
|
|
80
|
+
color: var(--dialog-field-text1, inherit);
|
|
81
|
+
}
|
|
82
|
+
.dialog-field-container:nth-of-type(odd) {
|
|
83
|
+
background-color: var(--dialog-field-bg2, #ffffff);
|
|
84
|
+
color: var(--dialog-field-text2, inherit);
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Feedback } from '@txstate-mws/svelte-forms';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
descid?: string | undefined;
|
|
7
|
+
label: string;
|
|
8
|
+
messages: Feedback[];
|
|
9
|
+
required?: boolean;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {
|
|
15
|
+
default: {
|
|
16
|
+
messagesid: any;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare type ContainerProps = typeof __propDef.props;
|
|
21
|
+
export declare type ContainerEvents = typeof __propDef.events;
|
|
22
|
+
export declare type ContainerSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Container extends SvelteComponentTyped<ContainerProps, ContainerEvents, ContainerSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script >import { randomid } from 'txstate-utils';
|
|
2
|
+
import FieldStandard from './FieldStandard.svelte';
|
|
3
|
+
import Checkbox from './Checkbox.svelte';
|
|
4
|
+
let className = '';
|
|
5
|
+
export { className as class };
|
|
6
|
+
export let id = undefined;
|
|
7
|
+
export let path;
|
|
8
|
+
export let label = '';
|
|
9
|
+
export let boxLabel;
|
|
10
|
+
export let defaultValue = undefined;
|
|
11
|
+
export let conditional = undefined;
|
|
12
|
+
export let required = false;
|
|
13
|
+
function onChange(setVal) {
|
|
14
|
+
return function () {
|
|
15
|
+
setVal(this.checked);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const descid = randomid();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<FieldStandard bind:id {path} {descid} {label} {defaultValue} {conditional} {required} let:value let:messagesid let:valid let:invalid let:id let:onBlur let:setVal>
|
|
22
|
+
<div class={className}>
|
|
23
|
+
<label for={id}>
|
|
24
|
+
<Checkbox {id} name={path} {value} {messagesid} {descid} {valid} {invalid} {onBlur} onChange={onChange(setVal)}></Checkbox>
|
|
25
|
+
<span>{boxLabel}</span>
|
|
26
|
+
</label>
|
|
27
|
+
</div>
|
|
28
|
+
</FieldStandard>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
class?: string;
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
path: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
boxLabel: any;
|
|
9
|
+
defaultValue?: boolean | undefined;
|
|
10
|
+
conditional?: boolean | undefined;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export declare type FieldCheckboxProps = typeof __propDef.props;
|
|
19
|
+
export declare type FieldCheckboxEvents = typeof __propDef.events;
|
|
20
|
+
export declare type FieldCheckboxSlots = typeof __propDef.slots;
|
|
21
|
+
export default class FieldCheckbox extends SvelteComponentTyped<FieldCheckboxProps, FieldCheckboxEvents, FieldCheckboxSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script >import { getContext } from 'svelte';
|
|
2
|
+
import { Field, FORM_CONTEXT } from '@txstate-mws/svelte-forms';
|
|
3
|
+
import { derivedStore } from '@txstate-mws/svelte-store';
|
|
4
|
+
import { randomid } from 'txstate-utils';
|
|
5
|
+
import Container from './Container.svelte';
|
|
6
|
+
import Checkbox from './Checkbox.svelte';
|
|
7
|
+
let className = '';
|
|
8
|
+
export { className as class };
|
|
9
|
+
export let id = undefined;
|
|
10
|
+
export let path;
|
|
11
|
+
export let label = '';
|
|
12
|
+
export let choices;
|
|
13
|
+
export let defaultValue = [];
|
|
14
|
+
export let conditional = undefined;
|
|
15
|
+
export let maxwidth = 250;
|
|
16
|
+
export let leftToRight = false;
|
|
17
|
+
const store = getContext(FORM_CONTEXT);
|
|
18
|
+
const currentWidth = derivedStore(store, 'width');
|
|
19
|
+
$: cols = Math.min(Math.ceil($currentWidth / maxwidth), choices.length);
|
|
20
|
+
let orders;
|
|
21
|
+
let width = '100%';
|
|
22
|
+
function redoLayout(..._) {
|
|
23
|
+
width = `${100 / cols}%`;
|
|
24
|
+
const rows = Math.ceil(choices.length / cols);
|
|
25
|
+
orders = choices.map((_, i) => leftToRight ? i : Math.floor((i + 1) / cols) + rows * (i % cols));
|
|
26
|
+
}
|
|
27
|
+
$: redoLayout(choices, cols);
|
|
28
|
+
function onChangeCheckbox(setVal, choice, included) {
|
|
29
|
+
setVal(v => {
|
|
30
|
+
if (v == null)
|
|
31
|
+
return included ? [] : [choice.value];
|
|
32
|
+
if (included)
|
|
33
|
+
return v.filter(s => s !== choice.value);
|
|
34
|
+
else
|
|
35
|
+
return [...v, choice.value];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const descid = randomid();
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<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
|
+
<div class="dialog-choices {className}" class:valid class:invalid>
|
|
44
|
+
{#each choices as choice, idx}
|
|
45
|
+
{@const checkid = `${path}.${idx}`}
|
|
46
|
+
{@const included = value && value.includes(choice.value)}
|
|
47
|
+
{@const label = choice.label || (typeof choice.value === 'string' ? choice.value : '')}
|
|
48
|
+
<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
|
+
<span>{label}</span>
|
|
51
|
+
</label>
|
|
52
|
+
{/each}
|
|
53
|
+
</div>
|
|
54
|
+
</Container>
|
|
55
|
+
</Field>
|
|
56
|
+
|
|
57
|
+
<style>
|
|
58
|
+
.dialog-choices {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-wrap: wrap;
|
|
61
|
+
}
|
|
62
|
+
label {
|
|
63
|
+
margin-bottom: 0.7em;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: flex-start;
|
|
67
|
+
}
|
|
68
|
+
span {
|
|
69
|
+
margin-left: 0.45em;
|
|
70
|
+
max-width: calc(100% - 1.6em);
|
|
71
|
+
}
|
|
72
|
+
label :global(input[type="checkbox"]) {
|
|
73
|
+
transform: none;
|
|
74
|
+
}
|
|
75
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
class?: string;
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
path: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
choices: {
|
|
9
|
+
label?: string;
|
|
10
|
+
value: any;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
defaultValue?: any;
|
|
14
|
+
conditional?: boolean | undefined;
|
|
15
|
+
maxwidth?: number;
|
|
16
|
+
leftToRight?: boolean;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export declare type FieldChoicesProps = typeof __propDef.props;
|
|
24
|
+
export declare type FieldChoicesEvents = typeof __propDef.events;
|
|
25
|
+
export declare type FieldChoicesSlots = typeof __propDef.slots;
|
|
26
|
+
export default class FieldChoices extends SvelteComponentTyped<FieldChoicesProps, FieldChoicesEvents, FieldChoicesSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<script context="module">export {};
|
|
2
|
+
</script>
|
|
3
|
+
<script >import { FORM_CONTEXT } from '@txstate-mws/svelte-forms';
|
|
4
|
+
import { getContext, setContext } from 'svelte';
|
|
5
|
+
import { randomid } from 'txstate-utils';
|
|
6
|
+
import { Chooser, ChooserStore, ASSET_STORE_CONTEXT } from './chooser';
|
|
7
|
+
import Details from './chooser/Details.svelte';
|
|
8
|
+
import Thumbnail from './chooser/Thumbnail.svelte';
|
|
9
|
+
import FieldStandard from './FieldStandard.svelte';
|
|
10
|
+
import { ASSET_API_CONTEXT } from './Form.svelte';
|
|
11
|
+
export let id = undefined;
|
|
12
|
+
export let path;
|
|
13
|
+
export let label = '';
|
|
14
|
+
export let defaultValue = undefined;
|
|
15
|
+
export let conditional = undefined;
|
|
16
|
+
export let required = false;
|
|
17
|
+
export let images = false;
|
|
18
|
+
export let pages = false;
|
|
19
|
+
export let assets = images;
|
|
20
|
+
export let folders = false;
|
|
21
|
+
export let urlEntry = false;
|
|
22
|
+
export let initialType = undefined;
|
|
23
|
+
export let initialSource = undefined;
|
|
24
|
+
export let initialPath = undefined;
|
|
25
|
+
const formStore = getContext(FORM_CONTEXT);
|
|
26
|
+
const value = formStore.getField(path);
|
|
27
|
+
const chooserClient = getContext(ASSET_API_CONTEXT);
|
|
28
|
+
const store = new ChooserStore(chooserClient);
|
|
29
|
+
const descid = randomid();
|
|
30
|
+
let modalshown = false;
|
|
31
|
+
async function show() {
|
|
32
|
+
if (selectedAsset && selectedAsset.type !== 'raw')
|
|
33
|
+
store.preview(selectedAsset);
|
|
34
|
+
modalshown = true;
|
|
35
|
+
}
|
|
36
|
+
function hide() {
|
|
37
|
+
modalshown = false;
|
|
38
|
+
}
|
|
39
|
+
function onChange(setVal) {
|
|
40
|
+
return (e) => {
|
|
41
|
+
selectedAsset = e.detail;
|
|
42
|
+
setVal(e.detail.id);
|
|
43
|
+
hide();
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function userUrlEntry() {
|
|
47
|
+
const url = this.value;
|
|
48
|
+
if (chooserClient.findByUrl) {
|
|
49
|
+
const item = await chooserClient.findByUrl(url);
|
|
50
|
+
if (item)
|
|
51
|
+
return store.preview(item);
|
|
52
|
+
}
|
|
53
|
+
store.clearPreview();
|
|
54
|
+
const newVal = chooserClient.urlToValue?.(url) ?? url;
|
|
55
|
+
selectedAsset = {
|
|
56
|
+
type: 'raw',
|
|
57
|
+
id: newVal,
|
|
58
|
+
url
|
|
59
|
+
};
|
|
60
|
+
formStore.setField(path, newVal);
|
|
61
|
+
}
|
|
62
|
+
let selectedAsset;
|
|
63
|
+
async function updateSelected(..._) {
|
|
64
|
+
if ($value && selectedAsset?.id !== $value)
|
|
65
|
+
selectedAsset = await chooserClient.findById($value);
|
|
66
|
+
}
|
|
67
|
+
$: updateSelected($value);
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<FieldStandard bind:id {path} {descid} {label} {defaultValue} {conditional} {required} let:value let:messagesid let:valid let:invalid let:id let:onBlur let:setVal>
|
|
71
|
+
{#if selectedAsset}
|
|
72
|
+
<div class="dialog-chooser-container">
|
|
73
|
+
<Thumbnail item={selectedAsset} />
|
|
74
|
+
<Details item={selectedAsset} />
|
|
75
|
+
</div>
|
|
76
|
+
{/if}
|
|
77
|
+
<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
|
+
{#if urlEntry && !folders && selectedAsset?.type !== 'folder'}
|
|
79
|
+
<input type="text" value={selectedAsset?.url ?? ''} on:change={userUrlEntry}><br>
|
|
80
|
+
{/if}
|
|
81
|
+
{#if modalshown}
|
|
82
|
+
<Chooser {store} {label} {initialType} {pages} {assets} {images} {initialSource} {initialPath} {folders} on:change={onChange(setVal)} on:escape={hide} />
|
|
83
|
+
{/if}
|
|
84
|
+
</FieldStandard>
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
.dialog-chooser-container {
|
|
88
|
+
display: flex;
|
|
89
|
+
margin-bottom: 0.25em;
|
|
90
|
+
font-size: 0.9em;
|
|
91
|
+
}
|
|
92
|
+
div.dialog-chooser-container > :global(.dialog-chooser-thumbnail) {
|
|
93
|
+
width: 8em;
|
|
94
|
+
padding-top: 0;
|
|
95
|
+
height: 5em;
|
|
96
|
+
}
|
|
97
|
+
input {
|
|
98
|
+
width: 100%;
|
|
99
|
+
}
|
|
100
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { ChooserType } from './chooser/ChooserAPI';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
path: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
defaultValue?: boolean | undefined;
|
|
9
|
+
conditional?: boolean | undefined;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
images?: boolean;
|
|
12
|
+
pages?: boolean;
|
|
13
|
+
assets?: boolean;
|
|
14
|
+
folders?: boolean;
|
|
15
|
+
urlEntry?: boolean;
|
|
16
|
+
initialType?: ChooserType | undefined;
|
|
17
|
+
initialSource?: string | undefined;
|
|
18
|
+
initialPath?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {};
|
|
24
|
+
};
|
|
25
|
+
export declare type FieldChooserLinkProps = typeof __propDef.props;
|
|
26
|
+
export declare type FieldChooserLinkEvents = typeof __propDef.events;
|
|
27
|
+
export declare type FieldChooserLinkSlots = typeof __propDef.slots;
|
|
28
|
+
export default class FieldChooserLink extends SvelteComponentTyped<FieldChooserLinkProps, FieldChooserLinkEvents, FieldChooserLinkSlots> {
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/FieldDate.svelte
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script >import { dateSerialize, dateDeserialize } from '@txstate-mws/svelte-forms';
|
|
2
|
+
import FieldStandard from './FieldStandard.svelte';
|
|
3
|
+
import Input from './Input.svelte';
|
|
4
|
+
let className = '';
|
|
5
|
+
export { className as class };
|
|
6
|
+
export let id = undefined;
|
|
7
|
+
export let path;
|
|
8
|
+
export let label = '';
|
|
9
|
+
export let defaultValue = undefined;
|
|
10
|
+
export let min = undefined;
|
|
11
|
+
export let max = undefined;
|
|
12
|
+
export let step = undefined;
|
|
13
|
+
export let conditional = undefined;
|
|
14
|
+
export let required = false;
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<FieldStandard bind:id {label} {path} {required} {defaultValue} {conditional} serialize={dateSerialize} deserialize={dateDeserialize} let:value let:valid let:invalid let:id let:onBlur let:onChange>
|
|
18
|
+
<Input type="date" name={path} {value} {id} class="dialog-input {className}" {onChange} {onBlur} {valid} {invalid} {min} {max} {step} />
|
|
19
|
+
</FieldStandard>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
class?: string;
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
path: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
defaultValue?: any;
|
|
9
|
+
min?: Date | {
|
|
10
|
+
toJSDate: () => Date;
|
|
11
|
+
} | undefined;
|
|
12
|
+
max?: Date | {
|
|
13
|
+
toJSDate: () => Date;
|
|
14
|
+
} | undefined;
|
|
15
|
+
step?: number | undefined;
|
|
16
|
+
conditional?: boolean | undefined;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
};
|
|
19
|
+
events: {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
};
|
|
22
|
+
slots: {};
|
|
23
|
+
};
|
|
24
|
+
export declare type FieldDateProps = typeof __propDef.props;
|
|
25
|
+
export declare type FieldDateEvents = typeof __propDef.events;
|
|
26
|
+
export declare type FieldDateSlots = typeof __propDef.slots;
|
|
27
|
+
export default class FieldDate extends SvelteComponentTyped<FieldDateProps, FieldDateEvents, FieldDateSlots> {
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script >import { datetimeSerialize, datetimeDeserialize } from '@txstate-mws/svelte-forms';
|
|
2
|
+
import FieldStandard from './FieldStandard.svelte';
|
|
3
|
+
import Input from './Input.svelte';
|
|
4
|
+
let className = '';
|
|
5
|
+
export { className as class };
|
|
6
|
+
export let id = undefined;
|
|
7
|
+
export let path;
|
|
8
|
+
export let label = '';
|
|
9
|
+
export let defaultValue = undefined;
|
|
10
|
+
export let min = undefined;
|
|
11
|
+
export let max = undefined;
|
|
12
|
+
export let step = undefined;
|
|
13
|
+
export let conditional = undefined;
|
|
14
|
+
export let required = false;
|
|
15
|
+
</script>
|
|
16
|
+
|
|
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} />
|
|
19
|
+
</FieldStandard>
|