@geoffcox/sterling-svelte 0.0.26 → 0.0.28

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.
Files changed (92) hide show
  1. package/Button.svelte +81 -25
  2. package/Button.svelte.d.ts +3 -0
  3. package/Checkbox.svelte +56 -26
  4. package/Checkbox.svelte.d.ts +2 -0
  5. package/ColorPicker.constants.d.ts +1 -0
  6. package/ColorPicker.constants.js +1 -0
  7. package/ColorPicker.svelte +257 -0
  8. package/ColorPicker.svelte.d.ts +49 -0
  9. package/ColorPicker.types.d.ts +4 -0
  10. package/Dialog.svelte +10 -10
  11. package/Dropdown.svelte +97 -58
  12. package/Dropdown.svelte.d.ts +4 -0
  13. package/HexColorSliders.svelte +171 -0
  14. package/HexColorSliders.svelte.d.ts +22 -0
  15. package/HslColorSliders.svelte +208 -0
  16. package/HslColorSliders.svelte.d.ts +22 -0
  17. package/Input.svelte +59 -25
  18. package/Input.svelte.d.ts +3 -2
  19. package/Label.constants.d.ts +1 -0
  20. package/Label.constants.js +1 -0
  21. package/Label.svelte +212 -14
  22. package/Label.svelte.d.ts +24 -4
  23. package/Label.types.d.ts +4 -0
  24. package/Label.types.js +1 -0
  25. package/Link.svelte +62 -16
  26. package/Link.svelte.d.ts +1 -0
  27. package/List.svelte +29 -16
  28. package/List.svelte.d.ts +1 -0
  29. package/List.types.d.ts +4 -3
  30. package/ListItem.svelte +30 -10
  31. package/ListItem.svelte.d.ts +1 -1
  32. package/Menu.svelte +7 -7
  33. package/MenuBar.svelte +1 -1
  34. package/MenuButton.svelte +3 -9
  35. package/MenuButton.svelte.d.ts +2 -4
  36. package/MenuItem.svelte +34 -12
  37. package/MenuItem.svelte.d.ts +2 -1
  38. package/MenuItemDisplay.svelte +8 -1
  39. package/MenuSeparator.svelte +3 -3
  40. package/Popover.svelte +66 -51
  41. package/Popover.svelte.d.ts +4 -2
  42. package/Progress.constants.d.ts +1 -1
  43. package/Progress.constants.js +1 -1
  44. package/Progress.svelte +34 -28
  45. package/Progress.svelte.d.ts +1 -1
  46. package/Progress.types.d.ts +3 -3
  47. package/Radio.svelte +54 -23
  48. package/Radio.svelte.d.ts +2 -0
  49. package/RgbColorSliders.svelte +182 -0
  50. package/RgbColorSliders.svelte.d.ts +22 -0
  51. package/Select.svelte +32 -25
  52. package/Select.svelte.d.ts +1 -1
  53. package/Slider.svelte +111 -123
  54. package/Slider.svelte.d.ts +1 -0
  55. package/Switch.svelte +112 -41
  56. package/Switch.svelte.d.ts +3 -2
  57. package/Tab.svelte +53 -29
  58. package/Tab.svelte.d.ts +7 -4
  59. package/TabList.svelte +21 -11
  60. package/TabList.svelte.d.ts +1 -0
  61. package/TabList.types.d.ts +1 -0
  62. package/TextArea.svelte +48 -22
  63. package/TextArea.svelte.d.ts +4 -3
  64. package/Tooltip.svelte +59 -16
  65. package/Tooltip.svelte.d.ts +34 -2
  66. package/Tree.svelte +35 -21
  67. package/Tree.svelte.d.ts +2 -0
  68. package/Tree.types.d.ts +6 -8
  69. package/TreeChevron.svelte +1 -1
  70. package/TreeItem.svelte +40 -9
  71. package/TreeItem.svelte.d.ts +2 -0
  72. package/TreeItem.types.d.ts +4 -4
  73. package/TreeItemDisplay.svelte +28 -9
  74. package/TreeItemDisplay.svelte.d.ts +3 -1
  75. package/actions/clickOutside.js +1 -1
  76. package/actions/trapKeyboardFocus.d.ts +3 -0
  77. package/actions/trapKeyboardFocus.js +52 -0
  78. package/floating-ui.types.d.ts +2 -0
  79. package/index.d.ts +14 -10
  80. package/index.js +11 -7
  81. package/package.json +12 -4
  82. package/theme/applyTheme.js +3 -2
  83. package/theme/colors.d.ts +1 -0
  84. package/theme/colors.js +28 -13
  85. package/theme/darkTheme.js +129 -87
  86. package/theme/lightTheme.js +109 -90
  87. package/Field.constants.d.ts +0 -1
  88. package/Field.constants.js +0 -1
  89. package/Field.svelte +0 -265
  90. package/Field.svelte.d.ts +0 -75
  91. package/Field.types.d.ts +0 -4
  92. /package/{Field.types.js → ColorPicker.types.js} +0 -0
@@ -0,0 +1,22 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ red?: number | undefined;
5
+ green?: number | undefined;
6
+ blue?: number | undefined;
7
+ alpha?: number | undefined;
8
+ /** When true, applies colorful theme styles. */ colorful?: boolean | undefined;
9
+ };
10
+ events: {
11
+ change: CustomEvent<any>;
12
+ } & {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {};
16
+ };
17
+ export type RgbColorSlidersProps = typeof __propDef.props;
18
+ export type RgbColorSlidersEvents = typeof __propDef.events;
19
+ export type RgbColorSlidersSlots = typeof __propDef.slots;
20
+ export default class RgbColorSliders extends SvelteComponentTyped<RgbColorSlidersProps, RgbColorSlidersEvents, RgbColorSlidersSlots> {
21
+ }
22
+ export {};
package/Select.svelte CHANGED
@@ -4,8 +4,8 @@ import { idGenerator } from "./idGenerator";
4
4
  import List from "./List.svelte";
5
5
  import Popup from "./Popover.svelte";
6
6
  const popupId = idGenerator.nextId("Select-popup");
7
- export let composed = false;
8
7
  export let disabled = false;
8
+ export let composed = false;
9
9
  export let open = false;
10
10
  export let selectedValue = void 0;
11
11
  let prevOpen = false;
@@ -178,7 +178,7 @@ const onListSelect = (event) => {
178
178
  on:mouseover
179
179
  on:mouseout
180
180
  on:mouseup
181
- on:wheel
181
+ on:wheel|passive
182
182
  on:paste
183
183
  on:click={onSelectClick}
184
184
  on:click_outside={() => (open = false)}
@@ -199,7 +199,7 @@ const onListSelect = (event) => {
199
199
  <div class="chevron" />
200
200
  </slot>
201
201
  </div>
202
- <Popup reference={selectRef} bind:open id={popupId}>
202
+ <Popup reference={selectRef} bind:open id={popupId} persistent>
203
203
  <div class="popup-content">
204
204
  <List
205
205
  bind:this={listRef}
@@ -221,12 +221,12 @@ const onListSelect = (event) => {
221
221
  .sterling-select {
222
222
  align-content: center;
223
223
  align-items: center;
224
- background-color: var(--stsv-Input__background-color);
225
- border-color: var(--stsv-Input__border-color);
226
- border-radius: var(--stsv-Input__border-radius);
227
- border-style: var(--stsv-Input__border-style);
228
- border-width: var(--stsv-Input__border-width);
229
- color: var(--stsv-Input__color);
224
+ background-color: var(--stsv-input__background-color);
225
+ border-color: var(--stsv-input__border-color);
226
+ border-radius: var(--stsv-input__border-radius);
227
+ border-style: var(--stsv-input__border-style);
228
+ border-width: var(--stsv-input__border-width);
229
+ color: var(--stsv-input__color);
230
230
  cursor: pointer;
231
231
  display: grid;
232
232
  grid-template-columns: 1fr auto;
@@ -238,19 +238,19 @@ const onListSelect = (event) => {
238
238
  }
239
239
 
240
240
  .sterling-select:hover {
241
- background-color: var(--stsv-Input__background-color--hover);
242
- border-color: var(--stsv-Input__border-color--hover);
243
- color: var(--stsv-Input__color--hover);
241
+ background-color: var(--stsv-input__background-color--hover);
242
+ border-color: var(--stsv-input__border-color--hover);
243
+ color: var(--stsv-input__color--hover);
244
244
  }
245
245
 
246
246
  .sterling-select:focus {
247
- background-color: var(--stsv-Input__background-color--focus);
248
- border-color: var(--stsv-Input__border-color--focus);
249
- color: var(--stsv-Input__color--focus);
250
- outline-color: var(--stsv-Common__outline-color);
251
- outline-offset: var(--stsv-Common__outline-offset);
252
- outline-style: var(--stsv-Common__outline-style);
253
- outline-width: var(--stsv-Common__outline-width);
247
+ background-color: var(--stsv-input__background-color--focus);
248
+ border-color: var(--stsv-input__border-color--focus);
249
+ color: var(--stsv-input__color--focus);
250
+ outline-color: var(--stsv-common__outline-color);
251
+ outline-offset: var(--stsv-common__outline-offset);
252
+ outline-style: var(--stsv-common__outline-style);
253
+ outline-width: var(--stsv-common__outline-width);
254
254
  }
255
255
 
256
256
  .sterling-select.disabled {
@@ -259,7 +259,14 @@ const onListSelect = (event) => {
259
259
  }
260
260
 
261
261
  .sterling-select::after {
262
- background: var(--stsv-Disabled__background);
262
+ background: repeating-linear-gradient(
263
+ var(--stsv-common--disabled__stripe-angle),
264
+ var(--stsv-common--disabled__stripe-color),
265
+ var(--stsv-common--disabled__stripe-color) var(--stsv-common--disabled__stripe-width),
266
+ var(--stsv-common--disabled__stripe-color--alt) var(--stsv-common--disabled__stripe-width),
267
+ var(--stsv-common--disabled__stripe-color--alt)
268
+ calc(2 * var(--stsv-common--disabled__stripe-width))
269
+ );
263
270
  bottom: 0;
264
271
  content: '';
265
272
  left: 0;
@@ -329,11 +336,11 @@ const onListSelect = (event) => {
329
336
  }
330
337
 
331
338
  .popup-content {
332
- background-color: var(--stsv-Common__background-color);
333
- border-color: var(--stsv-Common__border-color);
334
- border-radius: var(--stsv-Common__border-radius);
335
- border-style: var(--stsv-Common__border-style);
336
- border-width: var(--stsv-Common__border-width);
339
+ background-color: var(--stsv-common__background-color);
340
+ border-color: var(--stsv-common__border-color);
341
+ border-radius: var(--stsv-common__border-radius);
342
+ border-style: var(--stsv-common__border-style);
343
+ border-width: var(--stsv-common__border-width);
337
344
  padding: 0.25em;
338
345
  display: grid;
339
346
  grid-template-columns: 1fr;
@@ -2,8 +2,8 @@ import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
- composed?: boolean | undefined;
6
5
  disabled?: boolean | undefined;
6
+ composed?: boolean | undefined;
7
7
  open?: boolean | undefined;
8
8
  selectedValue?: string | undefined;
9
9
  blur?: (() => void) | undefined;
package/Slider.svelte CHANGED
@@ -1,11 +1,12 @@
1
1
  <script>import { createEventDispatcher } from "svelte";
2
2
  import { round } from "lodash-es";
3
+ export let colorful = false;
3
4
  export let composed = false;
4
5
  export let disabled = false;
5
6
  export let min = 0;
6
7
  export let max = 100;
7
- export let precision = 0;
8
- export let step = void 0;
8
+ export let precision = void 0;
9
+ export let step = 1;
9
10
  export let value = 0;
10
11
  export let vertical = false;
11
12
  let sliderRef;
@@ -22,52 +23,19 @@ const dispatch = createEventDispatcher();
22
23
  const raiseChange = (newValue) => {
23
24
  dispatch("change", { value: newValue });
24
25
  };
25
- const getPrecision = (value2) => {
26
- if (value2 !== void 0 && Number !== null && !Number.isNaN(value2)) {
27
- const text = value2.toString();
28
- const position = text.indexOf(".");
29
- if (position !== -1) {
30
- const fraction = text.substring(position + 1);
31
- if (fraction) {
32
- return fraction.length;
33
- }
34
- }
35
- }
36
- return 0;
37
- };
38
- $:
39
- highestPrecision = Math.max(
40
- precision,
41
- getPrecision(min),
42
- getPrecision(max),
43
- getPrecision(step)
44
- );
45
26
  const setValue = (newValue) => {
46
- value = round(Math.max(min, Math.min(max, newValue)), highestPrecision);
27
+ const clamped = Math.max(min, Math.min(max, newValue));
28
+ value = precision !== void 0 ? round(clamped, precision) : clamped;
47
29
  };
48
30
  $: {
49
31
  if (min > max) {
50
32
  min = max;
51
33
  }
52
34
  }
53
- $: {
54
- if (value < min || value > max || value !== round(value, highestPrecision)) {
55
- setValue(value);
56
- }
57
- }
58
- $: {
59
- if (step) {
60
- let stepValue = Math.max(min, Math.min(value, max));
61
- stepValue = Math.round(stepValue / step) * step + min;
62
- if (stepValue !== value) {
63
- setValue(stepValue);
64
- }
65
- }
66
- }
67
35
  $:
68
- ratio = (value - min) / (max - min);
36
+ min, max, precision, setValue(value);
69
37
  $:
70
- changeBy = step ? step : 1;
38
+ ratio = (value - min) / (max - min);
71
39
  const setValueByOffset = (offset) => {
72
40
  if (sliderSize > 0) {
73
41
  const positionRatio = Math.max(0, Math.min(1, offset / sliderSize));
@@ -113,13 +81,13 @@ const onKeyDown = (event) => {
113
81
  switch (event.code) {
114
82
  case "ArrowDown":
115
83
  case "ArrowLeft":
116
- setValue(value - changeBy);
84
+ setValue(value - step);
117
85
  event.preventDefault();
118
86
  event.stopPropagation();
119
87
  return;
120
88
  case "ArrowRight":
121
89
  case "ArrowUp":
122
- setValue(value + changeBy);
90
+ setValue(value + step);
123
91
  event.preventDefault();
124
92
  event.stopPropagation();
125
93
  return;
@@ -137,6 +105,7 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
137
105
  aria-valuenow={value}
138
106
  aria-valuemax={max}
139
107
  class="sterling-slider"
108
+ class:colorful
140
109
  class:composed
141
110
  class:disabled
142
111
  class:horizontal={!vertical}
@@ -177,7 +146,7 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
177
146
  on:pointerout
178
147
  on:pointerup
179
148
  on:pointerup={onPointerUp}
180
- on:wheel
149
+ on:wheel|passive
181
150
  {...$$restProps}
182
151
  >
183
152
  <div
@@ -202,34 +171,106 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
202
171
  transition: background-color 250ms, color 250ms, border-color 250ms;
203
172
  }
204
173
 
174
+ .sterling-slider.horizontal {
175
+ height: 2em;
176
+ }
177
+
205
178
  .sterling-slider.vertical {
206
179
  height: 100%;
180
+ width: 2em;
207
181
  }
208
182
 
183
+ .sterling-slider.composed,
184
+ .sterling-slider.composed:hover,
185
+ .sterling-slider.composed.focus,
186
+ .sterling-slider.composed.disabled {
187
+ background: none;
188
+ border: none;
189
+ outline: none;
190
+ }
191
+
192
+ /* ----- container ----- */
193
+
209
194
  .container {
210
195
  position: relative;
211
196
  }
212
197
 
198
+ .sterling-slider.horizontal .container {
199
+ margin: 0 0.75em;
200
+ }
201
+
202
+ .sterling-slider.vertical .container {
203
+ margin: 0.75em 0;
204
+ }
205
+
206
+ /* ----- track ----- */
207
+
213
208
  .track {
214
209
  position: absolute;
215
- background: var(--stsv-Display__background-color);
210
+ background: var(--stsv-common__background-color--secondary);
216
211
  transition: background-color 250ms, color 250ms, border-color 250ms;
217
212
  }
218
213
 
214
+ .sterling-slider.horizontal .track {
215
+ left: 0;
216
+ right: 0;
217
+ top: 50%;
218
+ height: 3px;
219
+ transform: translate(0, -50%);
220
+ }
221
+
222
+ .sterling-slider.vertical .track {
223
+ bottom: 0;
224
+ left: 50%;
225
+ top: 0;
226
+ transform: translate(-50%, 0);
227
+ width: 3px;
228
+ }
229
+
230
+ .sterling-slider:focus-visible {
231
+ outline-color: var(--stsv-common__outline-color);
232
+ outline-offset: var(--stsv-common__outline-offset);
233
+ outline-style: var(--stsv-common__outline-style);
234
+ outline-width: var(--stsv-common__outline-width);
235
+ }
236
+
237
+ /* ----- fill ----- */
238
+
219
239
  .fill {
220
- background: var(--stsv-Display__color);
240
+ background: var(--stsv-common__color);
221
241
  position: absolute;
222
242
  transition: background-color 250ms, color 250ms, border-color 250ms;
223
243
  }
224
244
 
245
+ .sterling-slider.horizontal .fill {
246
+ height: 3px;
247
+ top: 50%;
248
+ transform: translate(0, -50%);
249
+ }
250
+
251
+ .sterling-slider.vertical .fill {
252
+ bottom: 0;
253
+ left: 50%;
254
+ transform: translate(-50%, 0);
255
+ width: 3px;
256
+ }
257
+
258
+ .sterling-slider.colorful .fill {
259
+ background: var(--stsv-input--colorful__border-color--selected);
260
+ position: absolute;
261
+ transition: background-color 250ms, color 250ms, border-color 250ms;
262
+ }
263
+
264
+ /* ----- thumb ----- */
265
+
225
266
  .thumb {
226
- background-color: var(--stsv-Button__background-color);
227
- border-color: var(--stsv-Button__border-color);
267
+ background-color: var(--stsv-button__background-color);
268
+ border-color: var(--stsv-button__border-color);
228
269
  border-radius: 10000px;
229
- border-style: var(--stsv-Button__border-style);
230
- border-width: var(--stsv-Button__border-width);
270
+ border-style: var(--stsv-button__border-style);
271
+ border-width: var(--stsv-button__border-width);
231
272
  box-sizing: border-box;
232
- color: var(--stsv-Button__color);
273
+ color: var(--stsv-button__color);
233
274
  cursor: pointer;
234
275
  display: block;
235
276
  font: inherit;
@@ -244,89 +285,37 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
244
285
  width: 1.5em;
245
286
  }
246
287
 
247
- /* ----- horizontal ----- */
248
-
249
- .sterling-slider.horizontal {
250
- height: 2em;
251
- }
252
-
253
- .sterling-slider.horizontal .container {
254
- margin: 0 0.75em;
255
- }
256
-
257
- .sterling-slider.horizontal .track {
258
- left: 0;
259
- right: 0;
260
- top: 50%;
261
- height: 3px;
262
- transform: translate(0, -50%);
263
- }
264
-
265
- .sterling-slider.horizontal .fill {
266
- height: 3px;
267
- top: 50%;
268
- transform: translate(0, -50%);
269
- }
270
-
271
288
  .sterling-slider.horizontal .thumb {
272
289
  top: 50%;
273
290
  transform: translate(-50%, -50%);
274
291
  }
275
292
 
276
- /* ----- vertical ----- */
277
-
278
- .sterling-slider.vertical {
279
- width: 2em;
280
- }
281
- .sterling-slider.vertical .container {
282
- margin: 0.75em 0;
283
- }
284
-
285
- .sterling-slider.vertical .track {
286
- bottom: 0;
287
- left: 50%;
288
- top: 0;
289
- transform: translate(-50%, 0);
290
- width: 3px;
291
- }
292
-
293
- .sterling-slider.vertical .fill {
294
- bottom: 0;
295
- left: 50%;
296
- transform: translate(-50%, 0);
297
- width: 3px;
298
- }
299
-
300
293
  .sterling-slider.vertical .thumb {
301
294
  left: 50%;
302
295
  transform: translate(-50%, 50%);
303
296
  }
304
297
 
305
- /* ----- hover ----- */
306
-
307
298
  .thumb:hover {
308
- background-color: var(--stsv-Button__background-color--hover);
309
- border-color: var(--stsv-Button__border-color--hover);
310
- color: var(--stsv-Button__color--hover);
299
+ background-color: var(--stsv-button__background-color--hover);
300
+ border-color: var(--stsv-button__border-color--hover);
301
+ color: var(--stsv-button__color--hover);
311
302
  }
312
303
 
313
- /* ----- active ----- */
314
-
315
304
  .thumb:active {
316
- background-color: var(--stsv-Button__background-color--active);
317
- border-color: var(--stsv-Button__border-color--active);
318
- color: var(--stsv-Button__color--active);
305
+ background-color: var(--stsv-button__background-color--active);
306
+ border-color: var(--stsv-button__border-color--active);
307
+ color: var(--stsv-button__color--active);
319
308
  }
320
309
 
321
- /* ----- focus ----- */
322
- .sterling-slider:focus-visible {
323
- outline-color: var(--stsv-Common__outline-color);
324
- outline-offset: var(--stsv-Common__outline-offset);
325
- outline-style: var(--stsv-Common__outline-style);
326
- outline-width: var(--stsv-Common__outline-width);
310
+ /* ----- thumb colorful ----- */
311
+
312
+ .sterling-slider.colorful .thumb {
313
+ background-color: var(--stsv-button--colorful__background-color);
314
+ border-color: var(--stsv-button--colorful__border-color);
315
+ color: var(--stsv-button--colorful__color);
327
316
  }
328
317
 
329
- /* ----- disabled ----- */
318
+ /* ----- thumb disabled ----- */
330
319
 
331
320
  .sterling-slider.disabled .thumb {
332
321
  cursor: not-allowed;
@@ -334,7 +323,13 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
334
323
  }
335
324
 
336
325
  .sterling-slider .thumb::after {
337
- background: var(--stsv-Disabled__background);
326
+ background: repeating-linear-gradient(
327
+ var(--stsv-common--disabled__stripe-angle),
328
+ var(--stsv-common--disabled__stripe-color),
329
+ var(--stsv-common--disabled__stripe-color) 3px,
330
+ var(--stsv-common__background-color2_disabled) 3px,
331
+ var(--stsv-common__background-color2_disabled) 6px
332
+ );
338
333
  bottom: 0;
339
334
  content: '';
340
335
  left: 0;
@@ -350,14 +345,7 @@ Slider lets the user chose a value within a min/max range by dragging a thumb bu
350
345
  opacity: 1;
351
346
  }
352
347
 
353
- .sterling-slider.composed,
354
- .sterling-slider.composed:hover,
355
- .sterling-slider.composed.focus,
356
- .sterling-slider.composed.disabled {
357
- background: none;
358
- border: none;
359
- outline: none;
360
- }
348
+ /* ----- reduced motion ----- */
361
349
 
362
350
  @media (prefers-reduced-motion) {
363
351
  .sterling-slider,
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  [x: string]: any;
5
+ colorful?: boolean | undefined;
5
6
  composed?: boolean | undefined;
6
7
  disabled?: boolean | undefined;
7
8
  min?: number | undefined;