@geoffcox/sterling-svelte 0.0.17 → 0.0.19

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/Input.svelte CHANGED
@@ -1,58 +1,58 @@
1
1
  <script>import { v4 as uuid } from "uuid";
2
2
  import Label from "./Label.svelte";
3
- export let value = "";
3
+ export let composed = false;
4
4
  export let disabled = false;
5
- const inputId = uuid();
5
+ export let id = void 0;
6
+ export let value = "";
7
+ $: {
8
+ if ($$slots.default && id === void 0) {
9
+ id = uuid();
10
+ }
11
+ }
6
12
  </script>
7
13
 
8
- <!--
9
- @component
10
- A styled HTML input element with optional label.
11
- -->
12
- <div class="sterling-input">
13
- {#if $$slots.label}
14
- <Label {disabled} for={inputId}>
15
- <slot name="label" />
16
- </Label>
17
- {/if}
18
- <input
19
- bind:value
20
- on:blur
21
- on:click
22
- on:change
23
- on:copy
24
- on:cut
25
- on:paste
26
- on:dblclick
27
- on:focus
28
- on:focusin
29
- on:focusout
30
- on:input
31
- on:invalid
32
- on:keydown
33
- on:keypress
34
- on:keyup
35
- on:mousedown
36
- on:mouseenter
37
- on:mouseleave
38
- on:mousemove
39
- on:mouseover
40
- on:mouseout
41
- on:mouseup
42
- on:select
43
- on:submit
44
- on:reset
45
- on:wheel
46
- {...$$restProps}
47
- {disabled}
48
- id={inputId}
49
- />
50
- </div>
14
+ {#if $$slots.default}
15
+ <Label {disabled} for={id}>
16
+ <slot {composed} {disabled} {value} />
17
+ </Label>
18
+ {/if}
19
+ <input
20
+ bind:value
21
+ class="sterling-input"
22
+ class:composed
23
+ {disabled}
24
+ {id}
25
+ on:blur
26
+ on:click
27
+ on:change
28
+ on:copy
29
+ on:cut
30
+ on:paste
31
+ on:dblclick
32
+ on:focus
33
+ on:focusin
34
+ on:focusout
35
+ on:input
36
+ on:invalid
37
+ on:keydown
38
+ on:keypress
39
+ on:keyup
40
+ on:mousedown
41
+ on:mouseenter
42
+ on:mouseleave
43
+ on:mousemove
44
+ on:mouseover
45
+ on:mouseout
46
+ on:mouseup
47
+ on:select
48
+ on:submit
49
+ on:reset
50
+ on:wheel
51
+ {...$$restProps}
52
+ />
51
53
 
52
54
  <style>
53
55
  .sterling-input {
54
- display: flex;
55
- flex-direction: column;
56
56
  background-color: var(--stsv-Input__background-color);
57
57
  border-color: var(--stsv-Input__border-color);
58
58
  border-radius: var(--stsv-Input__border-radius);
@@ -61,6 +61,8 @@ const inputId = uuid();
61
61
  color: var(--stsv-Input__color);
62
62
  font: inherit;
63
63
  margin: 0;
64
+ outline: none;
65
+ padding: 0.5em;
64
66
  transition: background-color 250ms, color 250ms, border-color 250ms;
65
67
  }
66
68
 
@@ -70,7 +72,7 @@ const inputId = uuid();
70
72
  color: var(--stsv-Input__color--hover);
71
73
  }
72
74
 
73
- .sterling-input:focus-within {
75
+ .sterling-input:focus {
74
76
  background-color: var(--stsv-Input__background-color--focus);
75
77
  border-color: var(--stsv-Input__border-color--focus);
76
78
  color: var(--stsv-Input__color--focus);
@@ -87,42 +89,26 @@ const inputId = uuid();
87
89
  cursor: not-allowed;
88
90
  }
89
91
 
90
- .sterling-input input {
91
- font: inherit;
92
- color: inherit;
93
- padding: 0.5em;
94
- }
95
-
96
- .sterling-input input,
97
- .sterling-input input:hover,
98
- .sterling-input input:focus-within,
99
- .sterling-input input:disabled {
100
- background-color: transparent;
92
+ .sterling-input.composed,
93
+ .sterling-input.composed:hover,
94
+ .sterling-input.composed:focus,
95
+ .sterling-input.composed.disabled {
96
+ background: transparent;
101
97
  border: none;
102
98
  outline: none;
103
99
  }
104
100
 
105
- .sterling-input input::placeholder {
101
+ .sterling-input::placeholder {
106
102
  color: var(--stsv-Display__color--faint);
107
103
  transition: background-color 250ms, color 250ms, border-color 250ms;
108
104
  }
109
105
 
110
- .sterling-input input:disabled::placeholder {
106
+ .sterling-input:disabled::placeholder {
111
107
  color: var(--stsv-Display__color--disabled);
112
108
  }
113
109
 
114
- .sterling-input > :global(label) {
115
- font-size: 0.7em;
116
- margin: 0.5em 0 0 0.7em;
117
- }
118
-
119
- .sterling-input > :global(label):empty {
120
- margin: 0;
121
- }
122
-
123
110
  @media (prefers-reduced-motion) {
124
- .sterling-input,
125
- .sterling-input input::placeholder {
111
+ .sterling-input {
126
112
  transition: none;
127
113
  }
128
114
  }
package/Input.svelte.d.ts CHANGED
@@ -2,8 +2,10 @@ import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
- value?: string | undefined;
5
+ composed?: boolean | undefined;
6
6
  disabled?: boolean | undefined;
7
+ id?: string | undefined;
8
+ value?: string | undefined;
7
9
  };
8
10
  events: {
9
11
  blur: FocusEvent;
@@ -36,13 +38,16 @@ declare const __propDef: {
36
38
  [evt: string]: CustomEvent<any>;
37
39
  };
38
40
  slots: {
39
- label: {};
41
+ default: {
42
+ composed: boolean;
43
+ disabled: boolean;
44
+ value: string;
45
+ };
40
46
  };
41
47
  };
42
48
  export type InputProps = typeof __propDef.props;
43
49
  export type InputEvents = typeof __propDef.events;
44
50
  export type InputSlots = typeof __propDef.slots;
45
- /** A styled HTML input element with optional label. */
46
51
  export default class Input extends SvelteComponentTyped<InputProps, InputEvents, InputSlots> {
47
52
  }
48
53
  export {};
package/Label.svelte CHANGED
@@ -1,7 +1,9 @@
1
1
  <script>export let disabled = false;
2
+ HTMLLabelElement;
2
3
  </script>
3
4
 
4
5
  <label
6
+ aria-disabled={disabled}
5
7
  class="sterling-label"
6
8
  class:disabled
7
9
  on:blur
@@ -30,18 +32,15 @@
30
32
  <slot />
31
33
  </label>
32
34
 
33
- <!--
34
- @component
35
- A styled HTML label element
36
- -->
37
35
  <style>
38
36
  label {
39
- transition: opacity 250ms;
37
+ color: var(--stsv-Display__color);
38
+ transition: color 250ms;
40
39
  font: inherit;
41
40
  }
42
41
 
43
42
  label.disabled {
44
- opacity: 0.5;
43
+ color: var(--stsv-Common__color--disabled);
45
44
  }
46
45
 
47
46
  @media (prefers-reduced-motion) {
package/Label.svelte.d.ts CHANGED
@@ -36,7 +36,6 @@ declare const __propDef: {
36
36
  export type LabelProps = typeof __propDef.props;
37
37
  export type LabelEvents = typeof __propDef.events;
38
38
  export type LabelSlots = typeof __propDef.slots;
39
- /** A styled HTML label element */
40
39
  export default class Label extends SvelteComponentTyped<LabelProps, LabelEvents, LabelSlots> {
41
40
  }
42
41
  export {};
package/List.svelte CHANGED
@@ -2,7 +2,6 @@
2
2
  import { createEventDispatcher, onMount, setContext } from "svelte";
3
3
  import { writable } from "svelte/store";
4
4
  import { v4 as uuid } from "uuid";
5
- import Label from "./Label.svelte";
6
5
  import { listContextKey } from "./List.constants";
7
6
  export let composed = false;
8
7
  export let disabled = false;
@@ -186,54 +185,44 @@ A list of items where a single item can be selected.
186
185
  -->
187
186
  <!-- svelte-ignore a11y-no-noninteractive-tabindex -->
188
187
  <div
188
+ aria-activedescendant={selectedValue}
189
+ aria-disabled={disabled}
190
+ aria-orientation={horizontal ? 'horizontal' : 'vertical'}
191
+ bind:this={listRef}
189
192
  class="sterling-list"
190
- class:horizontal
191
- class:disabled
192
193
  class:composed
194
+ class:disabled
195
+ class:horizontal
193
196
  class:using-keyboard={usingKeyboard}
197
+ id={listId}
198
+ role="list"
199
+ tabindex={0}
200
+ on:blur
201
+ on:click
202
+ on:click={onClick}
203
+ on:copy
204
+ on:cut
205
+ on:dblclick
206
+ on:focus
207
+ on:focusin
208
+ on:focusout
209
+ on:keydown
210
+ on:keydown={onKeydown}
211
+ on:keypress
212
+ on:keyup
213
+ on:mousedown
214
+ on:mouseenter
215
+ on:mouseleave
216
+ on:mousemove
217
+ on:mouseover
218
+ on:mouseout
219
+ on:mouseup
220
+ on:scroll
221
+ on:wheel
222
+ on:paste
223
+ {...$$restProps}
194
224
  >
195
- {#if $$slots.label}
196
- <Label {disabled} for={listId}>
197
- <slot name="label" {composed} {disabled} {horizontal} {selectedValue} />
198
- </Label>
199
- {/if}
200
- <div
201
- aria-activedescendant={selectedValue}
202
- aria-orientation={horizontal ? 'horizontal' : 'vertical'}
203
- bind:this={listRef}
204
- class="list"
205
- class:disabled
206
- class:horizontal
207
- id={listId}
208
- role="list"
209
- tabindex={0}
210
- on:blur
211
- on:click
212
- on:click={onClick}
213
- on:copy
214
- on:cut
215
- on:dblclick
216
- on:focus
217
- on:focusin
218
- on:focusout
219
- on:keydown
220
- on:keydown={onKeydown}
221
- on:keypress
222
- on:keyup
223
- on:mousedown
224
- on:mouseenter
225
- on:mouseleave
226
- on:mousemove
227
- on:mouseover
228
- on:mouseout
229
- on:mouseup
230
- on:scroll
231
- on:wheel
232
- on:paste
233
- {...$$restProps}
234
- >
235
- <slot {composed} {disabled} {horizontal} {selectedValue} />
236
- </div>
225
+ <slot {composed} {disabled} {horizontal} {selectedValue} />
237
226
  </div>
238
227
 
239
228
  <style>
@@ -245,18 +234,24 @@ A list of items where a single item can be selected.
245
234
  border-width: var(--stsv-Common__border-width);
246
235
  box-sizing: border-box;
247
236
  color: var(--stsv-Common__color);
248
- display: grid;
249
- grid-template-columns: 1fr;
250
- grid-template-rows: auto 1fr;
237
+ display: flex;
238
+ flex-direction: column;
239
+ flex-wrap: nowrap;
251
240
  height: 100%;
252
241
  margin: 0;
253
- overflow: hidden;
242
+ overflow-x: hidden;
243
+ overflow-y: scroll;
244
+ outline: none;
254
245
  padding: 0;
246
+ position: relative;
255
247
  transition: background-color 250ms, color 250ms, border-color 250ms;
256
248
  }
257
249
 
258
250
  .sterling-list.horizontal {
251
+ flex-direction: row;
259
252
  height: unset;
253
+ overflow-x: scroll;
254
+ overflow-y: hidden;
260
255
  width: 100%;
261
256
  }
262
257
 
@@ -282,40 +277,14 @@ A list of items where a single item can be selected.
282
277
  }
283
278
 
284
279
  .sterling-list.composed,
285
- .sterling-list:hover.composed,
286
- .sterling-list:focus-visible.composed,
287
- .sterling-list.disabled.composed {
280
+ .sterling-list.composed:hover,
281
+ .sterling-list.composed.using-keyboard:focus-within,
282
+ .sterling-list.composed.disabled {
288
283
  background: none;
289
284
  border: none;
290
285
  outline: none;
291
286
  }
292
287
 
293
- .list {
294
- display: flex;
295
- flex-direction: column;
296
- flex-wrap: nowrap;
297
- grid-row: 2 / span 1;
298
- overflow-x: hidden;
299
- overflow-y: scroll;
300
- outline: none;
301
- position: relative;
302
- }
303
-
304
- .list.horizontal {
305
- flex-direction: row;
306
- overflow-x: scroll;
307
- overflow-y: hidden;
308
- }
309
-
310
- .sterling-list > :global(label) {
311
- font-size: 0.7em;
312
- margin: 0.5em 0.7em;
313
- }
314
-
315
- .sterling-list > :global(label):empty {
316
- margin: 0;
317
- }
318
-
319
288
  @media (prefers-reduced-motion) {
320
289
  .sterling-list {
321
290
  transition: none;
package/List.svelte.d.ts CHANGED
@@ -40,12 +40,6 @@ declare const __propDef: {
40
40
  [evt: string]: CustomEvent<any>;
41
41
  };
42
42
  slots: {
43
- label: {
44
- composed: boolean;
45
- disabled: boolean;
46
- horizontal: boolean;
47
- selectedValue: string | undefined;
48
- };
49
43
  default: {
50
44
  composed: boolean;
51
45
  disabled: boolean;
package/ListItem.svelte CHANGED
@@ -1,5 +1,4 @@
1
1
  <script>import { getContext } from "svelte";
2
- import { v4 as uuid } from "uuid";
3
2
  import { listContextKey } from "./List.constants";
4
3
  export let disabled = false;
5
4
  export let value;
package/Progress.svelte CHANGED
@@ -1,12 +1,9 @@
1
- <script>import { v4 as uuid } from "uuid";
2
- import Label from "./Label.svelte";
3
- export let value = 0;
1
+ <script>export let value = 0;
4
2
  export let max = 100;
5
3
  export let percent = 0;
6
4
  export let vertical = false;
7
5
  export let colorful = "none";
8
6
  export let disabled = false;
9
- const inputId = uuid();
10
7
  let clientHeight;
11
8
  let clientWidth;
12
9
  $:
@@ -25,7 +22,7 @@ $:
25
22
  $:
26
23
  indicatorStyle = vertical ? `height: ${percentHeight}px` : `width: ${percentWidth}px`;
27
24
  $:
28
- indicatorColor = colorful === "auto" ? percent === 100 ? "success" : "progress" : colorful;
25
+ indicatorColor = colorful === "auto" ? percent === 100 ? "success" : "info" : colorful;
29
26
  </script>
30
27
 
31
28
  <!--
@@ -39,6 +36,7 @@ $:
39
36
  class="sterling-progress"
40
37
  class:disabled
41
38
  class:vertical
39
+ role="progressbar"
42
40
  on:click
43
41
  on:dblclick
44
42
  on:focus
@@ -53,22 +51,15 @@ $:
53
51
  on:wheel
54
52
  {...$$restProps}
55
53
  >
56
- {#if $$slots.label}
57
- <Label {disabled} for={inputId}>
58
- <slot name="label" />
59
- </Label>
60
- {/if}
61
- <div class="progress-bar" id={inputId}>
62
- <div class="container" bind:clientWidth bind:clientHeight>
63
- <div
64
- class="indicator"
65
- class:progress={indicatorColor === 'progress'}
66
- class:success={indicatorColor === 'success'}
67
- class:warning={indicatorColor === 'warning'}
68
- class:error={indicatorColor === 'error'}
69
- style={indicatorStyle}
70
- />
71
- </div>
54
+ <div class="container" bind:clientWidth bind:clientHeight>
55
+ <div
56
+ class="indicator"
57
+ class:info={indicatorColor === 'info'}
58
+ class:success={indicatorColor === 'success'}
59
+ class:warning={indicatorColor === 'warning'}
60
+ class:error={indicatorColor === 'error'}
61
+ style={indicatorStyle}
62
+ />
72
63
  </div>
73
64
  </div>
74
65
 
@@ -78,18 +69,6 @@ $:
78
69
  flex-direction: column;
79
70
  align-content: flex-start;
80
71
  align-items: flex-start;
81
- }
82
-
83
- .sterling-progress > :global(label) {
84
- font-size: 0.7em;
85
- margin: 0.5em 0.7em;
86
- }
87
-
88
- .sterling-progress > :global(label):empty {
89
- margin: 0;
90
- }
91
-
92
- .progress-bar {
93
72
  display: block;
94
73
  background: var(--stsv-Common__background-color);
95
74
  box-sizing: border-box;
@@ -111,7 +90,7 @@ $:
111
90
  }
112
91
 
113
92
  .indicator {
114
- background-color: var(--stsv-Display__color);
93
+ background-color: var(--stsv-Display__border-color);
115
94
  box-sizing: border-box;
116
95
  height: 100%;
117
96
  min-height: 1px;
@@ -123,9 +102,6 @@ $:
123
102
  .sterling-progress.vertical {
124
103
  align-items: center;
125
104
  align-content: center;
126
- }
127
-
128
- .sterling-progress.vertical .progress-bar {
129
105
  height: unset;
130
106
  width: 1em;
131
107
  }
@@ -146,25 +122,25 @@ $:
146
122
 
147
123
  /* ----- Colorful ----- */
148
124
 
149
- .indicator.progress {
150
- background-color: var(--stsv-Display__color--progress);
125
+ .indicator.info {
126
+ background-color: var(--stsv-Info__border-color);
151
127
  }
152
128
 
153
129
  .indicator.success {
154
- background-color: var(--stsv-Display__color--success);
130
+ background-color: var(--stsv-Success__border-color);
155
131
  }
156
132
 
157
133
  .indicator.warning {
158
- background-color: var(--stsv-Display__color--warning);
134
+ background-color: var(--stsv-Warning__border-color);
159
135
  }
160
136
 
161
137
  .indicator.error {
162
- background-color: var(--stsv-Display__color--error);
138
+ background-color: var(--stsv-Error__border-color);
163
139
  }
164
140
 
165
141
  /* ----- Disabled ----- */
166
142
 
167
- .sterling-progress.disabled .progress-bar {
143
+ .sterling-progress.disabled {
168
144
  background: var(--stsv-Common__background-color--disabled);
169
145
  border-color: var(--stsv-Common__border-color--disabled);
170
146
  }
@@ -174,7 +150,7 @@ $:
174
150
  }
175
151
 
176
152
  @media (prefers-reduced-motion) {
177
- .progress-bar,
153
+ .sterling-progress,
178
154
  .indicator {
179
155
  transition: none;
180
156
  }
@@ -26,9 +26,7 @@ declare const __propDef: {
26
26
  } & {
27
27
  [evt: string]: CustomEvent<any>;
28
28
  };
29
- slots: {
30
- label: {};
31
- };
29
+ slots: {};
32
30
  };
33
31
  export type ProgressProps = typeof __propDef.props;
34
32
  export type ProgressEvents = typeof __propDef.events;
@@ -1 +1 @@
1
- export type ProgressColorful = 'none' | 'auto' | 'progress' | 'success' | 'warning' | 'error';
1
+ export type ProgressColorful = 'none' | 'auto' | 'info' | 'success' | 'warning' | 'error';
package/Radio.svelte CHANGED
@@ -2,26 +2,31 @@
2
2
  import { v4 as uuid } from "uuid";
3
3
  import Label from "./Label.svelte";
4
4
  export let checked = false;
5
- export let group = void 0;
6
5
  export let disabled = false;
7
- const inputId = uuid();
6
+ export let group = void 0;
7
+ export let id = void 0;
8
+ let mounted = false;
9
+ $: {
10
+ if ($$slots.default && id === void 0) {
11
+ id = uuid();
12
+ }
13
+ }
14
+ $: {
15
+ if (mounted) {
16
+ checked = group === $$restProps.value;
17
+ }
18
+ }
8
19
  const onChange = (e) => {
9
20
  if (e.currentTarget.checked) {
10
21
  group = $$restProps.value;
11
22
  }
12
23
  };
13
- let mounted = false;
14
24
  onMount(() => {
15
25
  if (checked) {
16
26
  group = $$restProps.value;
17
27
  }
18
28
  mounted = true;
19
29
  });
20
- $: {
21
- if (mounted) {
22
- checked = group === $$restProps.value;
23
- }
24
- }
25
30
  </script>
26
31
 
27
32
  <!--
@@ -31,6 +36,9 @@ $: {
31
36
  <div class="sterling-radio">
32
37
  <div class="container">
33
38
  <input
39
+ checked={group === $$restProps.value}
40
+ {disabled}
41
+ {id}
34
42
  type="radio"
35
43
  on:blur
36
44
  on:click
@@ -53,17 +61,14 @@ $: {
53
61
  on:mouseup
54
62
  on:toggle
55
63
  on:wheel
56
- checked={group === $$restProps.value}
57
64
  {...$$restProps}
58
- {disabled}
59
- id={inputId}
60
65
  />
61
66
  <div class="indicator" />
62
67
  </div>
63
- {#if $$slots.label}
68
+ {#if $$slots.default}
64
69
  <div class="label">
65
- <Label {disabled} for={inputId}>
66
- <slot name="label" />
70
+ <Label {disabled} for={id}>
71
+ <slot {checked} {disabled} {group} />
67
72
  </Label>
68
73
  </div>
69
74
  {/if}
package/Radio.svelte.d.ts CHANGED
@@ -3,8 +3,9 @@ declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
5
  checked?: boolean | undefined;
6
- group?: any | undefined | null;
7
6
  disabled?: boolean | undefined;
7
+ group?: any | undefined | null;
8
+ id?: string | undefined;
8
9
  };
9
10
  events: {
10
11
  blur: FocusEvent;
@@ -31,7 +32,11 @@ declare const __propDef: {
31
32
  [evt: string]: CustomEvent<any>;
32
33
  };
33
34
  slots: {
34
- label: {};
35
+ default: {
36
+ checked: boolean;
37
+ disabled: boolean;
38
+ group: any;
39
+ };
35
40
  };
36
41
  };
37
42
  export type RadioProps = typeof __propDef.props;