@dosgato/dialog 1.2.5 → 1.2.6
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.
|
@@ -31,7 +31,7 @@ declare const __propDef: {
|
|
|
31
31
|
value: any;
|
|
32
32
|
onBlur: () => void;
|
|
33
33
|
onChange: (e?: any) => void;
|
|
34
|
-
setVal: (val: string | number | boolean | object | Date | undefined, notDirty?: boolean
|
|
34
|
+
setVal: (val: string | number | boolean | object | Date | undefined, notDirty?: boolean) => void;
|
|
35
35
|
valid: boolean;
|
|
36
36
|
invalid: boolean;
|
|
37
37
|
messagesid: string | undefined;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script>import { FORM_CONTEXT, FORM_INHERITED_PATH } from '@txstate-mws/svelte-forms';
|
|
2
2
|
import { getContext, onMount } from 'svelte';
|
|
3
|
-
import { get, isNotBlank,
|
|
3
|
+
import { get, isNotBlank, randomid, shouldUseWhiteText } from 'txstate-utils';
|
|
4
4
|
import { Radio } from '..';
|
|
5
5
|
import FieldStandard from '../FieldStandard.svelte';
|
|
6
|
-
import { ScreenReaderOnly } from '@txstate-mws/svelte-components';
|
|
7
6
|
export let id = undefined;
|
|
8
7
|
let className = '';
|
|
9
8
|
export { className as class };
|
|
@@ -20,7 +19,6 @@ const groupid = randomid();
|
|
|
20
19
|
const store = getContext(FORM_CONTEXT);
|
|
21
20
|
const inheritedPath = getContext(FORM_INHERITED_PATH);
|
|
22
21
|
const finalPath = [inheritedPath, path].filter(isNotBlank).join('.');
|
|
23
|
-
$: colorsByValue = keyby(options, 'value');
|
|
24
22
|
async function reactToOptions(..._) {
|
|
25
23
|
const val = get($store.data, finalPath);
|
|
26
24
|
if (!val)
|
|
@@ -40,31 +38,22 @@ onMount(reactToOptions);
|
|
|
40
38
|
{#if addAllOption}
|
|
41
39
|
<label for={`${groupid}.alt`} class="colorsel alternating">
|
|
42
40
|
<Radio id={`${groupid}.alt`} name={groupid} value="alternating" selected={value === 'alternating'} {onChange} {onBlur} {helptextid}/>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
41
|
+
<span class="alternating-bg">
|
|
42
|
+
{#each options as option (option.value)}
|
|
43
|
+
<span style:background-color={option.color}></span>
|
|
44
|
+
{/each}
|
|
45
|
+
</span>
|
|
46
|
+
<span class="picker-text">Alternating</span>
|
|
51
47
|
</label>
|
|
52
48
|
{/if}
|
|
53
49
|
{#each options as option, idx (option.value) }
|
|
54
50
|
{@const radioid = `${groupid}.${idx}`}
|
|
55
|
-
<label for={radioid} class="colorsel"
|
|
51
|
+
<label for={radioid} class="colorsel">
|
|
56
52
|
<Radio id={radioid} name={groupid} value={option.value} selected={value === option.value} {onChange} {onBlur} {helptextid}/>
|
|
57
|
-
<
|
|
58
|
-
<ScreenReaderOnly>{option.name || option.value}</ScreenReaderOnly>
|
|
59
|
-
</div>
|
|
53
|
+
<span class="picker-text" style:background-color={option.color} class:dark={shouldUseWhiteText(option.color)}>{option.name || option.value}</span>
|
|
60
54
|
</label>
|
|
61
55
|
{/each}
|
|
62
56
|
</div>
|
|
63
|
-
{#if options.length && isNotNull(get($store.data, finalPath))}
|
|
64
|
-
<div>
|
|
65
|
-
Selected Color: <span class="selected-color">{get($store.data, finalPath) === 'alternating' ? 'Alternating' : (colorsByValue[get($store.data, finalPath)]?.name ?? get($store.data, finalPath))}</span>
|
|
66
|
-
</div>
|
|
67
|
-
{/if}
|
|
68
57
|
</div>
|
|
69
58
|
</FieldStandard>
|
|
70
59
|
|
|
@@ -74,11 +63,21 @@ onMount(reactToOptions);
|
|
|
74
63
|
container-name: color-picker-container;
|
|
75
64
|
}
|
|
76
65
|
.color-container {
|
|
77
|
-
display:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
display: grid;
|
|
67
|
+
grid-gap: 10px;
|
|
68
|
+
grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
69
|
+
}
|
|
70
|
+
@container color-picker-container (max-width: 600px) {
|
|
71
|
+
.color-container {
|
|
72
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
@container color-picker-container (max-width: 350px) {
|
|
76
|
+
.color-container {
|
|
77
|
+
grid-template-columns: 1fr 1fr;
|
|
78
|
+
}
|
|
81
79
|
}
|
|
80
|
+
|
|
82
81
|
label.colorsel :global(input[type="radio"]) {
|
|
83
82
|
border: 0;
|
|
84
83
|
clip: rect(0 0 0 0);
|
|
@@ -89,33 +88,54 @@ onMount(reactToOptions);
|
|
|
89
88
|
position: absolute;
|
|
90
89
|
width: 1px;
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
display:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
width: 50px;
|
|
98
|
-
height: 50px;
|
|
99
|
-
border-radius: 100%;
|
|
91
|
+
|
|
92
|
+
label.colorsel :global(input[type="radio"] + span) {
|
|
93
|
+
display: inline-block;
|
|
94
|
+
padding: 1rem;
|
|
95
|
+
width: 100%;
|
|
100
96
|
text-align: center;
|
|
101
97
|
white-space: nowrap;
|
|
102
98
|
border: 1px solid #D1D1D1;
|
|
103
99
|
}
|
|
104
100
|
|
|
105
|
-
label.colorsel :global(input[type="radio"]:checked +
|
|
101
|
+
label.colorsel :global(input[type="radio"]:checked + span) {
|
|
106
102
|
outline: 5px solid #93BBC4;
|
|
107
103
|
}
|
|
108
104
|
|
|
109
|
-
label.colorsel :global(input[type="radio"]:focus +
|
|
105
|
+
label.colorsel :global(input[type="radio"]:focus + span) {
|
|
110
106
|
outline: 5px solid blue;
|
|
111
107
|
}
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
|
|
109
|
+
label.colorsel.alternating {
|
|
110
|
+
position: relative;
|
|
114
111
|
}
|
|
115
|
-
|
|
112
|
+
|
|
113
|
+
label.colorsel.alternating span.alternating-bg {
|
|
116
114
|
display: flex;
|
|
115
|
+
padding: 0;
|
|
117
116
|
height: 100%;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
label.colorsel.alternating span.alternating-bg span {
|
|
118
120
|
width: 100%;
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
label.colorsel.alternating span.picker-text {
|
|
124
|
+
position: absolute;
|
|
125
|
+
left: 50%;
|
|
126
|
+
top: 50%;
|
|
127
|
+
transform: translate(-50%, -50%);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
label .picker-text {
|
|
131
|
+
font-weight: bold;
|
|
132
|
+
letter-spacing: 0.5px;
|
|
133
|
+
color: black;
|
|
134
|
+
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.6), 1px -1px 1px rgba(255, 255, 255, 0.6), -1px 1px 1px rgba(255, 255, 255, 0.6), -1px -1px 1px rgba(255, 255, 255, 0.6);
|
|
135
|
+
}
|
|
136
|
+
label .picker-text.dark, label.alternating .picker-text {
|
|
137
|
+
color: white;
|
|
138
|
+
text-shadow: 1px 1px 1px #222, 1px -1px 1px #222, -1px 1px 1px #222, -1px -1px 1px #222;
|
|
139
|
+
}
|
|
140
|
+
|
|
121
141
|
</style>
|
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": "1.2.
|
|
4
|
+
"version": "1.2.6",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "svelte-package",
|
|
7
7
|
"dev": "vite dev --force",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@sveltejs/adapter-auto": "^3.0.0",
|
|
36
36
|
"@sveltejs/kit": "^2.0.1",
|
|
37
37
|
"@sveltejs/package": "^2.0.1",
|
|
38
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
|
38
39
|
"eslint-config-standard-with-typescript": "^43.0.0",
|
|
39
40
|
"eslint-plugin-svelte": "^2.0.0",
|
|
40
41
|
"svelte-check": "^3.0.1",
|