@geoffcox/sterling-svelte 0.0.17 → 0.0.18

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/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;
package/Select.svelte CHANGED
@@ -2,10 +2,9 @@
2
2
  import { createEventDispatcher, onMount, tick } from "svelte";
3
3
  import { v4 as uuid } from "uuid";
4
4
  import { clickOutside } from "./actions/clickOutside";
5
- import Label from "./Label.svelte";
6
5
  import List from "./List.svelte";
7
- const inputId = uuid();
8
6
  const popupId = uuid();
7
+ export let composed = false;
9
8
  export let disabled = false;
10
9
  export let open = false;
11
10
  export let selectedValue = void 0;
@@ -147,16 +146,13 @@ const onListSelect = (event) => {
147
146
  };
148
147
  </script>
149
148
 
150
- <!--
151
- @component
152
- A single item that can be selected from a popup list of items.
153
- -->
154
149
  <div
155
150
  bind:this={selectRef}
156
151
  aria-controls={popupId}
157
152
  aria-haspopup="listbox"
158
153
  aria-expanded={open}
159
154
  class="sterling-select"
155
+ class:composed
160
156
  class:disabled
161
157
  role="combobox"
162
158
  tabindex="0"
@@ -186,26 +182,19 @@ A single item that can be selected from a popup list of items.
186
182
  on:keydown={onSelectKeydown}
187
183
  {...$$restProps}
188
184
  >
189
- {#if $$slots.label}
190
- <Label {disabled} for={inputId}>
191
- <slot name="label" {disabled} {selectedValue} />
192
- </Label>
193
- {/if}
194
- <div class="input" id={inputId}>
195
- <div class="value">
196
- <slot name="value" {disabled} {open} {selectedValue}>
197
- {#if selectedValue}
198
- {selectedValue}
199
- {:else}
200
- <span>&nbsp;</span>
201
- {/if}
202
- </slot>
203
- </div>
204
- <div class="button">
205
- <slot name="button" {open}>
206
- <div class="chevron" />
207
- </slot>
208
- </div>
185
+ <div class="value">
186
+ <slot name="value" {disabled} {open} {selectedValue}>
187
+ {#if selectedValue}
188
+ {selectedValue}
189
+ {:else}
190
+ <span>&nbsp;</span>
191
+ {/if}
192
+ </slot>
193
+ </div>
194
+ <div class="button">
195
+ <slot name="button" {open}>
196
+ <div class="chevron" />
197
+ </slot>
209
198
  </div>
210
199
  <div
211
200
  bind:this={popupRef}
@@ -232,6 +221,8 @@ A single item that can be selected from a popup list of items.
232
221
 
233
222
  <style>
234
223
  .sterling-select {
224
+ align-content: center;
225
+ align-items: center;
235
226
  background-color: var(--stsv-Input__background-color);
236
227
  border-color: var(--stsv-Input__border-color);
237
228
  border-radius: var(--stsv-Input__border-radius);
@@ -239,6 +230,10 @@ A single item that can be selected from a popup list of items.
239
230
  border-width: var(--stsv-Input__border-width);
240
231
  color: var(--stsv-Input__color);
241
232
  cursor: pointer;
233
+ display: grid;
234
+ grid-template-columns: 1fr auto;
235
+ grid-template-rows: auto;
236
+ outline: none;
242
237
  padding: 0;
243
238
  transition: background-color 250ms, color 250ms, border-color 250ms;
244
239
  }
@@ -249,7 +244,7 @@ A single item that can be selected from a popup list of items.
249
244
  color: var(--stsv-Input__color--hover);
250
245
  }
251
246
 
252
- .sterling-select:focus-visible {
247
+ .sterling-select:focus {
253
248
  background-color: var(--stsv-Input__background-color--focus);
254
249
  border-color: var(--stsv-Input__border-color--focus);
255
250
  color: var(--stsv-Input__color--focus);
@@ -267,21 +262,13 @@ A single item that can be selected from a popup list of items.
267
262
  outline: none;
268
263
  }
269
264
 
270
- .sterling-select > :global(label) {
271
- font-size: 0.7em;
272
- margin: 0.5em 0 0 0.7em;
273
- }
274
-
275
- .sterling-select > :global(label):empty {
276
- margin: 0;
277
- }
278
-
279
- .input {
280
- display: grid;
281
- grid-template-columns: 1fr auto;
282
- grid-template-rows: auto;
283
- align-content: center;
284
- align-items: center;
265
+ .sterling-select.composed,
266
+ .sterling-select.composed:hover,
267
+ .sterling-select.composed.focus,
268
+ .sterling-select.composed.disabled {
269
+ background: none;
270
+ border: none;
271
+ outline: none;
285
272
  }
286
273
 
287
274
  .value {
@@ -329,6 +316,7 @@ A single item that can be selected from a popup list of items.
329
316
  box-sizing: border-box;
330
317
  display: none;
331
318
  overflow: visible;
319
+ outline: none;
332
320
  position: absolute;
333
321
  box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
334
322
  width: fit-content;
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
+ composed?: boolean | undefined;
5
6
  disabled?: boolean | undefined;
6
7
  open?: boolean | undefined;
7
8
  selectedValue?: string | undefined;
@@ -33,10 +34,6 @@ declare const __propDef: {
33
34
  [evt: string]: CustomEvent<any>;
34
35
  };
35
36
  slots: {
36
- label: {
37
- disabled: boolean;
38
- selectedValue: string | undefined;
39
- };
40
37
  value: {
41
38
  disabled: boolean;
42
39
  open: boolean;
@@ -51,7 +48,6 @@ declare const __propDef: {
51
48
  export type SelectProps = typeof __propDef.props;
52
49
  export type SelectEvents = typeof __propDef.events;
53
50
  export type SelectSlots = typeof __propDef.slots;
54
- /** A single item that can be selected from a popup list of items. */
55
51
  export default class Select extends SvelteComponentTyped<SelectProps, SelectEvents, SelectSlots> {
56
52
  }
57
53
  export {};