@geoffcox/sterling-svelte 0.0.31 → 1.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/@types/clickOutside.d.ts +11 -7
- package/Button.svelte +11 -183
- package/Button.svelte.d.ts +2 -6
- package/Callout.svelte +107 -146
- package/Callout.svelte.d.ts +1 -1
- package/Checkbox.svelte +15 -177
- package/Checkbox.svelte.d.ts +2 -2
- package/ColorPicker.svelte +204 -223
- package/ColorPicker.svelte.d.ts +1 -2
- package/Dialog.svelte +90 -187
- package/Dialog.svelte.d.ts +2 -1
- package/Dropdown.svelte +52 -220
- package/Dropdown.svelte.d.ts +4 -8
- package/HexColorSliders.svelte +77 -145
- package/HexColorSliders.svelte.d.ts +28 -1
- package/HslColorSliders.svelte +99 -179
- package/HslColorSliders.svelte.d.ts +28 -1
- package/Input.svelte +27 -136
- package/Input.svelte.d.ts +2 -3
- package/Label.constants.d.ts +1 -0
- package/Label.constants.js +1 -0
- package/Label.svelte +96 -169
- package/Label.svelte.d.ts +6 -1
- package/Label.types.d.ts +3 -1
- package/Link.svelte +9 -106
- package/Link.svelte.d.ts +0 -1
- package/List.svelte +142 -230
- package/List.svelte.d.ts +2 -3
- package/List.types.d.ts +6 -1
- package/ListItem.svelte +25 -94
- package/ListItem.svelte.d.ts +2 -0
- package/Menu.svelte +48 -65
- package/Menu.svelte.d.ts +4 -1
- package/MenuBar.svelte +84 -86
- package/MenuBar.svelte.d.ts +4 -1
- package/MenuButton.svelte +66 -73
- package/MenuButton.svelte.d.ts +7 -3
- package/MenuItem.svelte +256 -288
- package/MenuItem.svelte.d.ts +2 -2
- package/MenuItemDisplay.svelte +12 -116
- package/MenuItemDisplay.svelte.d.ts +21 -7
- package/MenuSeparator.svelte +6 -45
- package/MenuSeparator.svelte.d.ts +8 -78
- package/Popover.constants.d.ts +1 -1
- package/Popover.constants.js +1 -1
- package/Popover.svelte +66 -80
- package/Popover.svelte.d.ts +5 -1
- package/Progress.svelte +28 -126
- package/Progress.svelte.d.ts +4 -3
- package/Radio.svelte +49 -192
- package/Radio.svelte.d.ts +2 -2
- package/RgbColorSliders.svelte +48 -137
- package/RgbColorSliders.svelte.d.ts +5 -5
- package/Select.svelte +122 -250
- package/Select.svelte.d.ts +6 -2
- package/Slider.svelte +90 -259
- package/Slider.svelte.d.ts +1 -2
- package/Switch.svelte +24 -259
- package/Switch.svelte.d.ts +3 -1
- package/Tab.svelte +27 -175
- package/Tab.svelte.d.ts +6 -4
- package/TabList.svelte +146 -171
- package/TabList.svelte.d.ts +3 -2
- package/TabList.types.d.ts +6 -1
- package/TextArea.svelte +32 -129
- package/TextArea.svelte.d.ts +1 -1
- package/Tooltip.svelte +46 -47
- package/Tooltip.svelte.d.ts +8 -3
- package/Tree.constants.d.ts +0 -1
- package/Tree.constants.js +0 -1
- package/Tree.svelte +35 -119
- package/Tree.svelte.d.ts +4 -4
- package/Tree.types.d.ts +1 -3
- package/TreeChevron.svelte +18 -98
- package/TreeChevron.svelte.d.ts +1 -0
- package/TreeItem.constants.d.ts +1 -0
- package/TreeItem.constants.js +1 -0
- package/TreeItem.svelte +251 -211
- package/TreeItem.svelte.d.ts +7 -3
- package/TreeItem.types.d.ts +1 -1
- package/TreeItemDisplay.svelte +20 -104
- package/TreeItemDisplay.svelte.d.ts +2 -2
- package/actions/applyLightDarkMode.d.ts +10 -0
- package/actions/applyLightDarkMode.js +36 -0
- package/actions/forwardEvents.js +3 -3
- package/css/Button.base.css +74 -0
- package/css/Button.colorful.css +17 -0
- package/css/Button.css +7 -0
- package/css/Button.secondary.colorful.css +15 -0
- package/css/Button.secondary.css +11 -0
- package/css/Button.shapes.css +14 -0
- package/css/Button.tool.colorful.css +13 -0
- package/css/Button.tool.css +18 -0
- package/css/Callout.base.css +43 -0
- package/css/Callout.colorful.css +5 -0
- package/css/Callout.css +2 -0
- package/css/Checkbox.base.css +145 -0
- package/css/Checkbox.colorful.css +17 -0
- package/css/Checkbox.css +2 -0
- package/css/ColorPicker.base.css +23 -0
- package/css/ColorPicker.css +1 -0
- package/css/Dialog.base.css +116 -0
- package/css/Dialog.css +1 -0
- package/css/Dropdown.base.css +147 -0
- package/css/Dropdown.colorful.css +23 -0
- package/css/Dropdown.css +2 -0
- package/css/HexColorSliders.base.css +106 -0
- package/css/HexColorSliders.css +1 -0
- package/css/HslColorSliders.base.css +124 -0
- package/css/HslColorSliders.css +1 -0
- package/css/Input.base.css +100 -0
- package/css/Input.colorful.css +22 -0
- package/css/Input.composed.css +8 -0
- package/css/Input.css +3 -0
- package/css/Label.base.css +119 -0
- package/css/Label.boxed.colorful.css +21 -0
- package/css/Label.boxed.css +31 -0
- package/css/Label.colorful.css +3 -0
- package/css/Label.css +4 -0
- package/css/Link.base.css +52 -0
- package/css/Link.colorful.css +15 -0
- package/css/Link.css +6 -0
- package/css/Link.ghost.colorful.css +7 -0
- package/css/Link.ghost.css +11 -0
- package/css/Link.undecorated.colorful.css +6 -0
- package/css/Link.undecorated.css +6 -0
- package/css/List.base.css +98 -0
- package/css/List.css +1 -0
- package/css/ListItem.base.css +59 -0
- package/css/ListItem.css +1 -0
- package/css/Menu.base.css +21 -0
- package/css/Menu.css +1 -0
- package/css/MenuBar.base.css +9 -0
- package/css/MenuBar.css +1 -0
- package/css/MenuButton.base.css +13 -0
- package/css/MenuButton.css +1 -0
- package/css/MenuItem.base.css +48 -0
- package/css/MenuItem.css +1 -0
- package/css/MenuItemDisplay.base.css +104 -0
- package/css/MenuItemDisplay.css +1 -0
- package/css/MenuSeparator.base.css +5 -0
- package/css/MenuSeparator.css +1 -0
- package/css/Popover copy.css +21 -0
- package/css/Popover.css +21 -0
- package/css/Progress.base.css +99 -0
- package/css/Progress.css +1 -0
- package/css/Radio.base.css +135 -0
- package/css/Radio.colorful.css +18 -0
- package/css/Radio.css +2 -0
- package/css/RgbColorSliders.base.css +94 -0
- package/css/RgbColorSliders.css +1 -0
- package/css/Select.base.css +127 -0
- package/css/Select.colorful.css +24 -0
- package/css/Select.composed.css +12 -0
- package/css/Select.css +3 -0
- package/css/Slider.base.css +182 -0
- package/css/Slider.colorful.css +11 -0
- package/css/Slider.composed.css +8 -0
- package/css/Slider.css +3 -0
- package/css/Switch.base.css +193 -0
- package/css/Switch.colorful.css +39 -0
- package/css/Switch.css +2 -0
- package/css/Tab.base.css +135 -0
- package/css/Tab.colorful.css +13 -0
- package/css/Tab.css +2 -0
- package/css/TabList.base.css +34 -0
- package/css/TabList.css +1 -0
- package/css/TextArea.base.css +85 -0
- package/css/TextArea.colorful.css +17 -0
- package/css/TextArea.composed.css +8 -0
- package/css/TextArea.css +3 -0
- package/css/Tooltip.base.css +6 -0
- package/css/Tooltip.css +1 -0
- package/css/Tree.base.css +74 -0
- package/css/Tree.composed.css +8 -0
- package/css/Tree.css +2 -0
- package/css/TreeChevron.base.css +86 -0
- package/css/TreeChevron.css +1 -0
- package/css/TreeItem.base.css +3 -0
- package/css/TreeItem.css +1 -0
- package/css/TreeItemDisplay.base.css +74 -0
- package/css/TreeItemDisplay.colorful.css +9 -0
- package/css/TreeItemDisplay.css +1 -0
- package/css/dark-mode.css +134 -0
- package/css/light-mode.css +134 -0
- package/css/sterling.css +37 -0
- package/index.d.ts +9 -13
- package/index.js +8 -12
- package/mediaQueries/prefersColorSchemeDark.d.ts +2 -0
- package/mediaQueries/prefersColorSchemeDark.js +10 -0
- package/{stores → mediaQueries}/prefersReducedMotion.d.ts +1 -0
- package/{stores → mediaQueries}/usingKeyboard.d.ts +1 -0
- package/package.json +121 -13
- package/Link.constants.d.ts +0 -1
- package/Link.constants.js +0 -1
- package/Link.types.d.ts +0 -4
- package/Link.types.js +0 -1
- package/theme/applyDarkTheme.d.ts +0 -7
- package/theme/applyDarkTheme.js +0 -11
- package/theme/applyLightTheme.d.ts +0 -7
- package/theme/applyLightTheme.js +0 -11
- package/theme/applyTheme.d.ts +0 -7
- package/theme/applyTheme.js +0 -20
- package/theme/colors.d.ts +0 -54
- package/theme/colors.js +0 -82
- package/theme/darkTheme.d.ts +0 -2
- package/theme/darkTheme.js +0 -142
- package/theme/lightTheme.d.ts +0 -2
- package/theme/lightTheme.js +0 -119
- package/theme/toggleDarkTheme.d.ts +0 -18
- package/theme/toggleDarkTheme.js +0 -53
- package/theme/types.d.ts +0 -21
- package/theme/types.js +0 -1
- /package/{stores → mediaQueries}/prefersReducedMotion.js +0 -0
- /package/{stores → mediaQueries}/usingKeyboard.js +0 -0
package/Progress.svelte
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script>//----- Props ----- //
|
|
2
|
+
/** When true, the progress bar is disabled. */
|
|
3
|
+
export let disabled = false;
|
|
4
|
+
/** The maximum value. */
|
|
2
5
|
export let max = 100;
|
|
6
|
+
/** A read-only percentage between 0 and 100 calculated from value and max. */
|
|
3
7
|
export let percent = 0;
|
|
8
|
+
/** The current status of the progress. */
|
|
9
|
+
export let status = 'none';
|
|
10
|
+
/** The current value. */
|
|
11
|
+
export let value = 0;
|
|
12
|
+
/** Additional class names to apply. */
|
|
13
|
+
export let variant = '';
|
|
14
|
+
/** When true, the progress bar is displayed vertically. */
|
|
4
15
|
export let vertical = false;
|
|
5
|
-
|
|
6
|
-
export let disabled = false;
|
|
16
|
+
//----- State ----- //
|
|
7
17
|
let clientHeight;
|
|
8
18
|
let clientWidth;
|
|
9
|
-
$:
|
|
10
|
-
|
|
11
|
-
$:
|
|
12
|
-
clampValue = Math.max(0, Math.min(value, clampMax));
|
|
13
|
-
$:
|
|
14
|
-
ratio = clampValue / clampMax;
|
|
19
|
+
$: clampMax = Math.max(1, max);
|
|
20
|
+
$: clampValue = Math.max(0, Math.min(value, clampMax));
|
|
21
|
+
$: ratio = clampValue / clampMax;
|
|
15
22
|
$: {
|
|
16
|
-
|
|
23
|
+
percent = Math.round(ratio * 100);
|
|
17
24
|
}
|
|
18
|
-
$:
|
|
19
|
-
|
|
20
|
-
$:
|
|
21
|
-
|
|
22
|
-
$:
|
|
23
|
-
indicatorStyle = vertical ? `height: ${percentHeight}px` : `width: ${percentWidth}px`;
|
|
24
|
-
$:
|
|
25
|
-
indicatorColor = status === "auto" ? percent === 100 ? "success" : "info" : status;
|
|
25
|
+
$: percentHeight = clientHeight * ratio;
|
|
26
|
+
$: percentWidth = clientWidth * ratio;
|
|
27
|
+
$: indicatorStyle = vertical ? `height: ${percentHeight}px` : `width: ${percentWidth}px`;
|
|
28
|
+
$: indicatorColor = status === 'auto' ? (percent === 100 ? 'success' : 'info') : status;
|
|
26
29
|
</script>
|
|
27
30
|
|
|
28
31
|
<!--
|
|
@@ -31,11 +34,15 @@ $:
|
|
|
31
34
|
Does not use the HTML progress element.
|
|
32
35
|
-->
|
|
33
36
|
<!-- svelte-ignore a11y-label-has-associated-control -->
|
|
34
|
-
|
|
37
|
+
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
35
38
|
<div
|
|
36
|
-
class=
|
|
39
|
+
class={`sterling-progress ${variant}`}
|
|
37
40
|
class:disabled
|
|
38
41
|
class:vertical
|
|
42
|
+
class:info={indicatorColor === 'info'}
|
|
43
|
+
class:success={indicatorColor === 'success'}
|
|
44
|
+
class:warning={indicatorColor === 'warning'}
|
|
45
|
+
class:error={indicatorColor === 'danger'}
|
|
39
46
|
role="progressbar"
|
|
40
47
|
on:blur
|
|
41
48
|
on:click
|
|
@@ -71,111 +78,6 @@ $:
|
|
|
71
78
|
{...$$restProps}
|
|
72
79
|
>
|
|
73
80
|
<div class="container" bind:clientWidth bind:clientHeight>
|
|
74
|
-
<div
|
|
75
|
-
class="indicator"
|
|
76
|
-
class:info={indicatorColor === 'info'}
|
|
77
|
-
class:success={indicatorColor === 'success'}
|
|
78
|
-
class:warning={indicatorColor === 'warning'}
|
|
79
|
-
class:error={indicatorColor === 'danger'}
|
|
80
|
-
style={indicatorStyle}
|
|
81
|
-
/>
|
|
81
|
+
<div class="indicator" style={indicatorStyle} />
|
|
82
82
|
</div>
|
|
83
83
|
</div>
|
|
84
|
-
|
|
85
|
-
<style>
|
|
86
|
-
.sterling-progress {
|
|
87
|
-
align-content: flex-start;
|
|
88
|
-
align-items: flex-start;
|
|
89
|
-
background: var(--stsv-common__background-color);
|
|
90
|
-
border-width: var(--stsv-common__border-width);
|
|
91
|
-
border-style: var(--stsv-common__border-style);
|
|
92
|
-
border-color: var(--stsv-common__border-color);
|
|
93
|
-
border-radius: var(--stsv-common__border-radius);
|
|
94
|
-
box-sizing: border-box;
|
|
95
|
-
display: block;
|
|
96
|
-
height: 1em;
|
|
97
|
-
padding: 0.25em;
|
|
98
|
-
position: relative;
|
|
99
|
-
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.sterling-progress.disabled::after {
|
|
103
|
-
content: '';
|
|
104
|
-
position: absolute;
|
|
105
|
-
left: 0;
|
|
106
|
-
right: 0;
|
|
107
|
-
top: 0;
|
|
108
|
-
bottom: 0;
|
|
109
|
-
background: repeating-linear-gradient(
|
|
110
|
-
var(--stsv-common--disabled__stripe-angle),
|
|
111
|
-
var(--stsv-common--disabled__stripe-color),
|
|
112
|
-
var(--stsv-common--disabled__stripe-color) var(--stsv-common--disabled__stripe-width),
|
|
113
|
-
var(--stsv-common--disabled__stripe-color--alt) var(--stsv-common--disabled__stripe-width),
|
|
114
|
-
var(--stsv-common--disabled__stripe-color--alt)
|
|
115
|
-
calc(2 * var(--stsv-common--disabled__stripe-width))
|
|
116
|
-
);
|
|
117
|
-
pointer-events: none;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.container {
|
|
121
|
-
display: flex;
|
|
122
|
-
justify-content: flex-start;
|
|
123
|
-
width: 100%;
|
|
124
|
-
height: 100%;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.indicator {
|
|
128
|
-
background-color: var(--stsv-common__border-color);
|
|
129
|
-
box-sizing: border-box;
|
|
130
|
-
height: 100%;
|
|
131
|
-
min-height: 1px;
|
|
132
|
-
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/* ----- Vertical ----- */
|
|
136
|
-
|
|
137
|
-
.sterling-progress.vertical {
|
|
138
|
-
align-items: center;
|
|
139
|
-
align-content: center;
|
|
140
|
-
height: unset;
|
|
141
|
-
width: 1em;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.sterling-progress.vertical .container {
|
|
145
|
-
flex-direction: column;
|
|
146
|
-
justify-content: flex-end;
|
|
147
|
-
min-width: unset;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.sterling-progress.vertical .indicator {
|
|
151
|
-
height: unset;
|
|
152
|
-
min-height: unset;
|
|
153
|
-
min-width: 1px;
|
|
154
|
-
width: 100%;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/* ----- Colorful ----- */
|
|
158
|
-
|
|
159
|
-
.indicator.info {
|
|
160
|
-
background-color: var(--stsv-status--info__border-color);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.indicator.success {
|
|
164
|
-
background-color: var(--stsv-status--success__border-color);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.indicator.warning {
|
|
168
|
-
background-color: var(--stsv-status--warning__border-color);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.indicator.error {
|
|
172
|
-
background-color: var(--stsv-status--danger__border-color);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@media (prefers-reduced-motion) {
|
|
176
|
-
.sterling-progress,
|
|
177
|
-
.indicator {
|
|
178
|
-
transition: none;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
</style>
|
package/Progress.svelte.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
|
|
5
|
+
disabled?: boolean | undefined;
|
|
6
6
|
max?: number | undefined;
|
|
7
7
|
percent?: number | undefined;
|
|
8
|
-
vertical?: boolean | undefined;
|
|
9
8
|
status?: string | undefined;
|
|
10
|
-
|
|
9
|
+
value?: number | undefined;
|
|
10
|
+
variant?: string | undefined;
|
|
11
|
+
vertical?: boolean | undefined;
|
|
11
12
|
};
|
|
12
13
|
events: {
|
|
13
14
|
blur: FocusEvent;
|
package/Radio.svelte
CHANGED
|
@@ -1,57 +1,71 @@
|
|
|
1
|
-
<script>import { idGenerator } from
|
|
1
|
+
<script>import { idGenerator } from './idGenerator';
|
|
2
|
+
// ----- Props ----- //
|
|
2
3
|
export let checked = false;
|
|
3
4
|
export let disabled = false;
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
5
|
+
// bind:group doesn't seem to work properly (yet) in a nested radio.
|
|
6
|
+
// The workaround is to export `checked` and `group` properties
|
|
7
|
+
// and implement the same behavior.
|
|
8
|
+
export let group = undefined;
|
|
9
|
+
export let id = undefined;
|
|
10
|
+
/** Additional class names to apply. */
|
|
11
|
+
export let variant = '';
|
|
12
|
+
// ensure initial state is consistent
|
|
7
13
|
if (checked && $$restProps.value !== group) {
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
14
|
+
group = $$restProps.value;
|
|
15
|
+
}
|
|
16
|
+
else if (!checked && $$restProps.value === group) {
|
|
17
|
+
checked = true;
|
|
11
18
|
}
|
|
19
|
+
// ----- State ----- //
|
|
12
20
|
let inputRef;
|
|
13
21
|
let previousChecked = checked;
|
|
14
22
|
let previousGroup = group;
|
|
15
23
|
const reconcile = () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
if (checked !== previousChecked) {
|
|
25
|
+
// when checked, set group to value
|
|
26
|
+
if (checked && $$restProps.value) {
|
|
27
|
+
group = $$restProps.value;
|
|
28
|
+
previousGroup = $$restProps.value;
|
|
29
|
+
}
|
|
30
|
+
previousChecked = checked;
|
|
20
31
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
else if (group !== previousGroup) {
|
|
33
|
+
// when group changes, update checked
|
|
34
|
+
if ($$restProps.value) {
|
|
35
|
+
checked = $$restProps.value === group;
|
|
36
|
+
previousChecked = checked;
|
|
37
|
+
}
|
|
38
|
+
previousGroup = group;
|
|
26
39
|
}
|
|
27
|
-
previousGroup = group;
|
|
28
|
-
}
|
|
29
40
|
};
|
|
30
|
-
$:
|
|
31
|
-
checked, group, $$restProps.value, reconcile();
|
|
41
|
+
$: checked, group, $$restProps.value, reconcile();
|
|
32
42
|
$: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
if (inputRef && checked && !inputRef.checked) {
|
|
44
|
+
// setting checked doesn't cause raise on:change,
|
|
45
|
+
// so we click the radio to cause it to be checked.
|
|
46
|
+
inputRef.click();
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
49
|
$: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
if ($$slots.default && id === undefined) {
|
|
51
|
+
id = idGenerator.nextId('Radio');
|
|
52
|
+
}
|
|
41
53
|
}
|
|
54
|
+
// ----- Methods ----- //
|
|
42
55
|
export const blur = () => {
|
|
43
|
-
|
|
56
|
+
inputRef?.blur();
|
|
44
57
|
};
|
|
45
58
|
export const click = () => {
|
|
46
|
-
|
|
59
|
+
inputRef?.click();
|
|
47
60
|
};
|
|
48
61
|
export const focus = (options) => {
|
|
49
|
-
|
|
62
|
+
inputRef?.focus(options);
|
|
50
63
|
};
|
|
64
|
+
// ----- Event Handlers ----- //
|
|
51
65
|
const onChange = (e) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
if (e.currentTarget.checked) {
|
|
67
|
+
group = $$restProps.value;
|
|
68
|
+
}
|
|
55
69
|
};
|
|
56
70
|
</script>
|
|
57
71
|
|
|
@@ -59,13 +73,13 @@ const onChange = (e) => {
|
|
|
59
73
|
@component
|
|
60
74
|
A styled HTML input type=radio element with optional label.
|
|
61
75
|
-->
|
|
62
|
-
<div class=
|
|
76
|
+
<div class={`sterling-radio ${variant}`} class:disabled>
|
|
63
77
|
<div class="container">
|
|
64
78
|
<input
|
|
65
79
|
bind:this={inputRef}
|
|
66
80
|
{checked}
|
|
67
81
|
{disabled}
|
|
68
|
-
{group}
|
|
82
|
+
name={group}
|
|
69
83
|
{id}
|
|
70
84
|
type="radio"
|
|
71
85
|
on:blur
|
|
@@ -100,164 +114,7 @@ const onChange = (e) => {
|
|
|
100
114
|
</div>
|
|
101
115
|
{#if $$slots.default}
|
|
102
116
|
<label for={id}>
|
|
103
|
-
<slot {
|
|
117
|
+
<slot {checked} {disabled} {group} inputId={id} value={$$restProps.value} {variant} />
|
|
104
118
|
</label>
|
|
105
119
|
{/if}
|
|
106
120
|
</div>
|
|
107
|
-
|
|
108
|
-
<style>
|
|
109
|
-
.sterling-radio {
|
|
110
|
-
align-content: center;
|
|
111
|
-
align-items: center;
|
|
112
|
-
box-sizing: border-box;
|
|
113
|
-
display: inline-flex;
|
|
114
|
-
font: inherit;
|
|
115
|
-
margin: 0;
|
|
116
|
-
outline: none;
|
|
117
|
-
padding: 0;
|
|
118
|
-
}
|
|
119
|
-
/*
|
|
120
|
-
The container
|
|
121
|
-
- allows the input to be hidden
|
|
122
|
-
- avoids input participating in layout
|
|
123
|
-
- prevents collisions with surrounding slots
|
|
124
|
-
*/
|
|
125
|
-
.container {
|
|
126
|
-
box-sizing: border-box;
|
|
127
|
-
position: relative;
|
|
128
|
-
font: inherit;
|
|
129
|
-
display: flex;
|
|
130
|
-
align-items: center;
|
|
131
|
-
margin-right: 0.25em;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/*
|
|
135
|
-
The input is hidden since the built-in browser radio cannot be customized
|
|
136
|
-
*/
|
|
137
|
-
input {
|
|
138
|
-
font: inherit;
|
|
139
|
-
margin: 0;
|
|
140
|
-
padding: 0;
|
|
141
|
-
position: absolute;
|
|
142
|
-
opacity: 0;
|
|
143
|
-
height: 21px;
|
|
144
|
-
width: 21px;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/*
|
|
148
|
-
The indicator handles both the radio box and circle mark.
|
|
149
|
-
The box cannot be on the container since the adjacent sibling selector is needed
|
|
150
|
-
and there is not a parent CSS selector.
|
|
151
|
-
*/
|
|
152
|
-
.indicator {
|
|
153
|
-
background-color: var(--stsv-input__background-color);
|
|
154
|
-
border-color: var(--stsv-input__border-color);
|
|
155
|
-
border-style: var(--stsv-input__border-style);
|
|
156
|
-
border-width: var(--stsv-input__border-width);
|
|
157
|
-
border-radius: 10000px;
|
|
158
|
-
box-sizing: border-box;
|
|
159
|
-
display: inline-block;
|
|
160
|
-
height: 21px;
|
|
161
|
-
position: relative;
|
|
162
|
-
pointer-events: none;
|
|
163
|
-
transition: background-color 250ms, color 250ms, border-color 250ms;
|
|
164
|
-
width: 21px;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
input:checked + .indicator {
|
|
168
|
-
background-color: var(--stsv-input__background-color);
|
|
169
|
-
border-color: var(--stsv-input__border-color);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.sterling-radio:not(.disabled):hover .indicator {
|
|
173
|
-
background-color: var(--stsv-input__background-color--hover);
|
|
174
|
-
border-color: var(--stsv-input__border-color--hover);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
input:focus-visible + .indicator {
|
|
178
|
-
outline-color: var(--stsv-common__outline-color);
|
|
179
|
-
outline-offset: var(--stsv-common__outline-offset);
|
|
180
|
-
outline-style: var(--stsv-common__outline-style);
|
|
181
|
-
outline-width: var(--stsv-common__outline-width);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.indicator::after {
|
|
185
|
-
background-color: transparent;
|
|
186
|
-
border-radius: 10000px;
|
|
187
|
-
content: '';
|
|
188
|
-
height: 9px;
|
|
189
|
-
left: 50%;
|
|
190
|
-
position: absolute;
|
|
191
|
-
top: 50%;
|
|
192
|
-
transform: translate(-50%, -50%);
|
|
193
|
-
transition: background-color 250ms;
|
|
194
|
-
width: 9px;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
input:checked + .indicator::after {
|
|
198
|
-
background-color: var(--stsv-input__color);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.sterling-radio.colorful .indicator {
|
|
202
|
-
background-color: var(--stsv-input--colorful__background-color);
|
|
203
|
-
border-color: var(--stsv-input--colorful__border-color);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.sterling-radio.colorful input:checked + .indicator {
|
|
207
|
-
background-color: var(--stsv-input--colorful__background-color);
|
|
208
|
-
border-color: var(--stsv-input--colorful__border-color);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.sterling-radio.colorful:not(.disabled):hover .indicator {
|
|
212
|
-
background-color: var(--stsv-input--colorful__background-color--hover);
|
|
213
|
-
border-color: var(--stsv-input--colorful__border-color--hover);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.sterling-radio.colorful input:checked + .indicator::after {
|
|
217
|
-
background-color: var(--stsv-input--colorful__color);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.sterling-radio.disabled * {
|
|
221
|
-
cursor: not-allowed;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.container::after {
|
|
225
|
-
background: repeating-linear-gradient(
|
|
226
|
-
var(--stsv-common--disabled__stripe-angle),
|
|
227
|
-
var(--stsv-common--disabled__stripe-color),
|
|
228
|
-
var(--stsv-common--disabled__stripe-color) var(--stsv-common--disabled__stripe-width),
|
|
229
|
-
var(--stsv-common--disabled__stripe-color--alt) var(--stsv-common--disabled__stripe-width),
|
|
230
|
-
var(--stsv-common--disabled__stripe-color--alt)
|
|
231
|
-
calc(2 * var(--stsv-common--disabled__stripe-width))
|
|
232
|
-
);
|
|
233
|
-
border-radius: 10000px;
|
|
234
|
-
bottom: 0;
|
|
235
|
-
content: '';
|
|
236
|
-
left: 0;
|
|
237
|
-
opacity: 0;
|
|
238
|
-
position: absolute;
|
|
239
|
-
right: 0;
|
|
240
|
-
top: 0;
|
|
241
|
-
pointer-events: none;
|
|
242
|
-
transition: opacity 250ms;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
label {
|
|
246
|
-
color: var(--stsv-common__color);
|
|
247
|
-
transition: color 250ms;
|
|
248
|
-
font: inherit;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.sterling-radio.disabled .container::after {
|
|
252
|
-
opacity: 1;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
@media (prefers-reduced-motion) {
|
|
256
|
-
.indicator,
|
|
257
|
-
.indicator::after,
|
|
258
|
-
.container::after,
|
|
259
|
-
label {
|
|
260
|
-
transition: none;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
</style>
|
package/Radio.svelte.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare const __propDef: {
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
group?: any | undefined | null;
|
|
8
8
|
id?: string | undefined;
|
|
9
|
-
|
|
9
|
+
variant?: string | undefined;
|
|
10
10
|
blur?: (() => void) | undefined;
|
|
11
11
|
click?: (() => void) | undefined;
|
|
12
12
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
@@ -42,12 +42,12 @@ declare const __propDef: {
|
|
|
42
42
|
};
|
|
43
43
|
slots: {
|
|
44
44
|
default: {
|
|
45
|
-
colorful: boolean;
|
|
46
45
|
checked: boolean;
|
|
47
46
|
disabled: boolean;
|
|
48
47
|
group: any;
|
|
49
48
|
inputId: string | undefined;
|
|
50
49
|
value: any;
|
|
50
|
+
variant: string;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
};
|