@geoffcox/sterling-svelte 0.0.24 → 0.0.26

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/Popover.svelte ADDED
@@ -0,0 +1,124 @@
1
+ <script>import { onMount } from "svelte";
2
+ import { autoUpdate, computePosition, flip, offset } from "@floating-ui/dom";
3
+ import { portal } from "./actions/portal";
4
+ export let placement = "bottom-start";
5
+ export let open = false;
6
+ export let reference;
7
+ export let portalHost = void 0;
8
+ let popupRef;
9
+ let popupPosition = { x: 0, y: 0 };
10
+ const hostId = "SterlingPopoverPortal";
11
+ const ensurePortalHost = () => {
12
+ if (portalHost) {
13
+ return portalHost;
14
+ }
15
+ let host = document.querySelector(`#${hostId}`);
16
+ if (!host) {
17
+ host = document.createElement("div");
18
+ host.id = hostId;
19
+ host.style.overflow = "visible";
20
+ document.body.append(host);
21
+ }
22
+ portalHost = host;
23
+ };
24
+ let bodyHeight = 0;
25
+ const resizeObserver = new ResizeObserver((entries) => {
26
+ bodyHeight = entries[0].target.clientHeight;
27
+ });
28
+ const middleware = [offset({ mainAxis: -2 }), flip()];
29
+ const computePopupPosition = async () => {
30
+ if (reference && popupRef) {
31
+ popupPosition = await computePosition(reference, popupRef, {
32
+ placement,
33
+ middleware
34
+ });
35
+ } else {
36
+ popupPosition = { x: 0, y: 0 };
37
+ }
38
+ };
39
+ let cleanupAutoUpdate = () => {
40
+ };
41
+ const autoUpdateMenuPosition = () => {
42
+ cleanupAutoUpdate();
43
+ if (reference && popupRef) {
44
+ cleanupAutoUpdate = autoUpdate(reference, popupRef, computePopupPosition);
45
+ }
46
+ };
47
+ $:
48
+ popupRef, reference, autoUpdateMenuPosition();
49
+ $:
50
+ open, bodyHeight, placement, computePopupPosition();
51
+ onMount(() => {
52
+ ensurePortalHost();
53
+ resizeObserver.observe(document.body);
54
+ return () => {
55
+ resizeObserver.unobserve(document.body);
56
+ };
57
+ });
58
+ </script>
59
+
60
+ <div use:portal={{ target: portalHost ?? document.body }} class="sterling-popover-portal">
61
+ <div
62
+ bind:this={popupRef}
63
+ class="sterling-popover"
64
+ class:open
65
+ on:blur
66
+ on:click
67
+ on:copy
68
+ on:cut
69
+ on:dblclick
70
+ on:dragend
71
+ on:dragenter
72
+ on:dragleave
73
+ on:dragover
74
+ on:dragstart
75
+ on:drop
76
+ on:focus
77
+ on:focusin
78
+ on:focusout
79
+ on:keydown
80
+ on:keypress
81
+ on:keyup
82
+ on:mousedown
83
+ on:mouseenter
84
+ on:mouseleave
85
+ on:mousemove
86
+ on:mouseover
87
+ on:mouseout
88
+ on:mouseup
89
+ on:scroll
90
+ on:wheel
91
+ on:paste
92
+ {...$$restProps}
93
+ style="left:{popupPosition.x}px; top:{popupPosition.y}px"
94
+ >
95
+ <slot />
96
+ </div>
97
+ </div>
98
+
99
+ <style>
100
+ .sterling-popover-portal {
101
+ position: relative;
102
+ overflow: visible;
103
+ background: rgba(255, 0, 0, 0.1);
104
+ }
105
+
106
+ .sterling-popover {
107
+ box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
108
+ box-sizing: border-box;
109
+ display: none;
110
+ grid-template-columns: 1fr;
111
+ grid-template-rows: 1fr;
112
+ height: fit-content;
113
+ left: 0;
114
+ overflow: hidden;
115
+ position: absolute;
116
+ top: 0;
117
+ width: max-content;
118
+ z-index: 1;
119
+ }
120
+
121
+ .sterling-popover.open {
122
+ display: grid;
123
+ }
124
+ </style>
@@ -0,0 +1,51 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Placement } from '@floating-ui/dom';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ placement?: Placement | undefined;
7
+ open?: boolean | undefined;
8
+ reference: HTMLElement;
9
+ portalHost?: HTMLElement | undefined;
10
+ };
11
+ events: {
12
+ blur: FocusEvent;
13
+ click: MouseEvent;
14
+ copy: ClipboardEvent;
15
+ cut: ClipboardEvent;
16
+ dblclick: MouseEvent;
17
+ dragend: DragEvent;
18
+ dragenter: DragEvent;
19
+ dragleave: DragEvent;
20
+ dragover: DragEvent;
21
+ dragstart: DragEvent;
22
+ drop: DragEvent;
23
+ focus: FocusEvent;
24
+ focusin: FocusEvent;
25
+ focusout: FocusEvent;
26
+ keydown: KeyboardEvent;
27
+ keypress: KeyboardEvent;
28
+ keyup: KeyboardEvent;
29
+ mousedown: MouseEvent;
30
+ mouseenter: MouseEvent;
31
+ mouseleave: MouseEvent;
32
+ mousemove: MouseEvent;
33
+ mouseover: MouseEvent;
34
+ mouseout: MouseEvent;
35
+ mouseup: MouseEvent;
36
+ scroll: Event;
37
+ wheel: WheelEvent;
38
+ paste: ClipboardEvent;
39
+ } & {
40
+ [evt: string]: CustomEvent<any>;
41
+ };
42
+ slots: {
43
+ default: {};
44
+ };
45
+ };
46
+ export type PopoverProps = typeof __propDef.props;
47
+ export type PopoverEvents = typeof __propDef.events;
48
+ export type PopoverSlots = typeof __propDef.slots;
49
+ export default class Popover extends SvelteComponentTyped<PopoverProps, PopoverEvents, PopoverSlots> {
50
+ }
51
+ export {};
package/Progress.svelte CHANGED
@@ -3,6 +3,7 @@ export let max = 100;
3
3
  export let percent = 0;
4
4
  export let vertical = false;
5
5
  export let colorful = "none";
6
+ export let disabled = false;
6
7
  let clientHeight;
7
8
  let clientWidth;
8
9
  $:
@@ -33,6 +34,7 @@ $:
33
34
 
34
35
  <div
35
36
  class="sterling-progress"
37
+ class:disabled
36
38
  class:vertical
37
39
  role="progressbar"
38
40
  on:blur
@@ -103,7 +105,6 @@ $:
103
105
  justify-content: flex-start;
104
106
  width: 100%;
105
107
  height: 100%;
106
- min-width: 100px;
107
108
  }
108
109
 
109
110
  .indicator {
@@ -127,7 +128,6 @@ $:
127
128
  flex-direction: column;
128
129
  justify-content: flex-end;
129
130
  min-width: unset;
130
- min-height: 100px;
131
131
  }
132
132
 
133
133
  .sterling-progress.vertical .indicator {
@@ -155,6 +155,17 @@ $:
155
155
  background-color: var(--stsv-Error__border-color);
156
156
  }
157
157
 
158
+ /* ----- Disabled ----- */
159
+
160
+ .sterling-progress.disabled {
161
+ background: var(--stsv-Common__background-color--disabled);
162
+ border-color: var(--stsv-Common__border-color--disabled);
163
+ }
164
+
165
+ .sterling-progress.disabled .indicator {
166
+ background-color: var(--stsv-Display__color--disabled);
167
+ }
168
+
158
169
  @media (prefers-reduced-motion) {
159
170
  .sterling-progress,
160
171
  .indicator {
@@ -7,6 +7,7 @@ declare const __propDef: {
7
7
  percent?: number | undefined;
8
8
  vertical?: boolean | undefined;
9
9
  colorful?: string | undefined;
10
+ disabled?: boolean | undefined;
10
11
  };
11
12
  events: {
12
13
  blur: FocusEvent;
package/Radio.svelte CHANGED
@@ -1,42 +1,58 @@
1
- <script>import { onMount } from "svelte";
2
- import { idGenerator } from "./idGenerator";
1
+ <script>import { idGenerator } from "./idGenerator";
3
2
  import Label from "./Label.svelte";
4
3
  export let checked = false;
5
4
  export let disabled = false;
6
5
  export let group = void 0;
7
6
  export let id = void 0;
8
- let mounted = false;
9
- let radioRef;
7
+ if (checked && $$restProps.value !== group) {
8
+ group = $$restProps.value;
9
+ } else if (!checked && $$restProps.value === group) {
10
+ checked = true;
11
+ }
12
+ let inputRef;
13
+ let previousChecked = checked;
14
+ let previousGroup = group;
15
+ const reconcile = () => {
16
+ if (checked !== previousChecked) {
17
+ if (checked && $$restProps.value) {
18
+ group = $$restProps.value;
19
+ previousGroup = $$restProps.value;
20
+ }
21
+ previousChecked = checked;
22
+ } else if (group !== previousGroup) {
23
+ if ($$restProps.value) {
24
+ checked = $$restProps.value === group;
25
+ previousChecked = checked;
26
+ }
27
+ previousGroup = group;
28
+ }
29
+ };
30
+ $:
31
+ checked, group, $$restProps.value, reconcile();
10
32
  $: {
11
- if ($$slots.default && id === void 0) {
12
- id = idGenerator.nextId("Radio");
33
+ if (inputRef && checked && !inputRef.checked) {
34
+ inputRef.click();
13
35
  }
14
36
  }
15
37
  $: {
16
- if (mounted) {
17
- checked = group === $$restProps.value;
38
+ if ($$slots.default && id === void 0) {
39
+ id = idGenerator.nextId("Radio");
18
40
  }
19
41
  }
20
- const onChange = (e) => {
21
- if (e.currentTarget.checked) {
22
- group = $$restProps.value;
23
- }
24
- };
25
42
  export const blur = () => {
26
- radioRef?.blur();
43
+ inputRef?.blur();
27
44
  };
28
45
  export const click = () => {
29
- radioRef?.click();
46
+ inputRef?.click();
30
47
  };
31
48
  export const focus = (options) => {
32
- radioRef?.focus(options);
49
+ inputRef?.focus(options);
33
50
  };
34
- onMount(() => {
35
- if (checked) {
51
+ const onChange = (e) => {
52
+ if (e.currentTarget.checked) {
36
53
  group = $$restProps.value;
37
54
  }
38
- mounted = true;
39
- });
55
+ };
40
56
  </script>
41
57
 
42
58
  <!--
@@ -46,9 +62,10 @@ onMount(() => {
46
62
  <div class="sterling-radio" class:disabled>
47
63
  <div class="container">
48
64
  <input
49
- bind:this={radioRef}
50
- checked={group === $$restProps.value}
65
+ bind:this={inputRef}
66
+ {checked}
51
67
  {disabled}
68
+ {group}
52
69
  {id}
53
70
  type="radio"
54
71
  on:blur
package/Select.svelte CHANGED
@@ -1,8 +1,8 @@
1
- <script>import { computePosition, flip, offset, shift, autoUpdate } from "@floating-ui/dom";
2
- import { createEventDispatcher, onMount, tick } from "svelte";
1
+ <script>import { createEventDispatcher, tick } from "svelte";
3
2
  import { clickOutside } from "./actions/clickOutside";
4
3
  import { idGenerator } from "./idGenerator";
5
4
  import List from "./List.svelte";
5
+ import Popup from "./Popover.svelte";
6
6
  const popupId = idGenerator.nextId("Select-popup");
7
7
  export let composed = false;
8
8
  export let disabled = false;
@@ -11,12 +11,7 @@ export let selectedValue = void 0;
11
11
  let prevOpen = false;
12
12
  let pendingSelectedValue = selectedValue;
13
13
  let selectRef;
14
- let popupRef;
15
14
  let listRef;
16
- let popupPosition = {
17
- x: void 0,
18
- y: void 0
19
- };
20
15
  const dispatch = createEventDispatcher();
21
16
  const raiseSelect = (value) => {
22
17
  dispatch("select", { value });
@@ -39,8 +34,10 @@ $: {
39
34
  if (open && !prevOpen) {
40
35
  prevOpen = true;
41
36
  tick().then(() => {
42
- listRef?.focus();
43
- listRef?.scrollToSelectedItem();
37
+ setTimeout(() => {
38
+ listRef?.focus();
39
+ listRef?.scrollToSelectedItem();
40
+ }, 10);
44
41
  });
45
42
  } else if (prevOpen) {
46
43
  prevOpen = false;
@@ -61,20 +58,6 @@ export const scrollToSelectedItem = () => {
61
58
  listRef?.scrollToSelectedItem();
62
59
  }
63
60
  };
64
- let mounted = false;
65
- onMount(() => {
66
- mounted = true;
67
- const cleanup = autoUpdate(selectRef, popupRef, async () => {
68
- const { x, y } = await computePosition(selectRef, popupRef, {
69
- placement: "bottom-end",
70
- middleware: [offset({ mainAxis: 2 }), flip(), shift({ padding: 0 })]
71
- });
72
- if (open) {
73
- popupPosition = { x, y };
74
- }
75
- });
76
- return cleanup;
77
- });
78
61
  const onSelectClick = (event) => {
79
62
  if (!disabled) {
80
63
  open = !open;
@@ -216,16 +199,11 @@ const onListSelect = (event) => {
216
199
  <div class="chevron" />
217
200
  </slot>
218
201
  </div>
219
- <div
220
- bind:this={popupRef}
221
- class="popup"
222
- class:open
223
- id={popupId}
224
- style="left:{popupPosition.x}px; top:{popupPosition.y}px"
225
- >
202
+ <Popup reference={selectRef} bind:open id={popupId}>
226
203
  <div class="popup-content">
227
204
  <List
228
205
  bind:this={listRef}
206
+ composed
229
207
  {disabled}
230
208
  selectedValue={pendingSelectedValue}
231
209
  on:click={onListClick}
@@ -236,7 +214,7 @@ const onListSelect = (event) => {
236
214
  <slot />
237
215
  </List>
238
216
  </div>
239
- </div>
217
+ </Popup>
240
218
  </div>
241
219
 
242
220
  <style>
@@ -350,27 +328,18 @@ const onListSelect = (event) => {
350
328
  transform-origin: 50% 50%;
351
329
  }
352
330
 
353
- .popup {
331
+ .popup-content {
354
332
  background-color: var(--stsv-Common__background-color);
355
- box-sizing: border-box;
356
- display: none;
357
- overflow: visible;
358
- outline: none;
359
- position: absolute;
360
- box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
361
- width: fit-content;
362
- height: fit-content;
363
- z-index: 1;
364
- }
365
-
366
- .popup.open {
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);
337
+ padding: 0.25em;
367
338
  display: grid;
368
339
  grid-template-columns: 1fr;
369
340
  grid-template-rows: 1fr;
370
- }
371
-
372
- .popup-content {
373
- max-height: 15em;
341
+ overflow: hidden;
342
+ max-height: 20em;
374
343
  }
375
344
 
376
345
  @media (prefers-reduced-motion) {
package/Switch.svelte CHANGED
@@ -117,17 +117,21 @@ export const focus = (options) => {
117
117
  }
118
118
 
119
119
  .sterling-switch:not(.vertical) {
120
+ align-content: center;
120
121
  align-items: center;
121
122
  column-gap: 0.5em;
122
- grid-template-columns: auto 1fr auto;
123
+ grid-template-columns: auto auto auto;
123
124
  grid-template-rows: auto;
124
- justify-items: stretch;
125
+ justify-content: flex-start;
126
+ justify-items: flex-start;
125
127
  }
126
128
 
127
129
  .sterling-switch.vertical {
128
- align-items: stretch;
130
+ align-content: flex-start;
131
+ align-items: flex-start;
129
132
  grid-template-columns: auto;
130
133
  grid-template-rows: auto auto auto;
134
+ justify-content: center;
131
135
  justify-items: center;
132
136
  row-gap: 0.5em;
133
137
  }
package/Tab.svelte CHANGED
@@ -1,5 +1,6 @@
1
1
  <script>import { getContext } from "svelte";
2
2
  import { TAB_LIST_CONTEXT_KEY } from "./TabList.constants";
3
+ import { usingKeyboard } from "./stores/usingKeyboard";
3
4
  export let disabled = false;
4
5
  export let selected = false;
5
6
  export let text = void 0;
@@ -8,7 +9,6 @@ let tabRef;
8
9
  const {
9
10
  disabled: tabListDisabled,
10
11
  selectedValue,
11
- usingKeyboard,
12
12
  vertical
13
13
  } = getContext(TAB_LIST_CONTEXT_KEY);
14
14
  $:
package/TabList.svelte CHANGED
@@ -1,20 +1,14 @@
1
- <script>import { createKeyborg } from "keyborg";
2
- import { createEventDispatcher, onMount, setContext } from "svelte";
1
+ <script>import { createEventDispatcher, setContext } from "svelte";
3
2
  import { writable } from "svelte/store";
4
3
  import { TAB_LIST_CONTEXT_KEY } from "./TabList.constants";
4
+ import { usingKeyboard } from "./stores/usingKeyboard";
5
5
  export let disabled = false;
6
6
  export let vertical = false;
7
7
  export let selectedValue = void 0;
8
- let keyborg = createKeyborg(window);
9
- let usingKeyboard = keyborg.isNavigatingWithKeyboard();
10
- const keyborgHandler = (value) => {
11
- usingKeyboard = value;
12
- };
13
8
  let tabListRef;
14
9
  let lastSelectedTabRef;
15
10
  const disabledStore = writable(disabled);
16
11
  const selectedValueStore = writable(selectedValue);
17
- const usingKeyboardStore = writable(usingKeyboard);
18
12
  const verticalStore = writable(vertical);
19
13
  $:
20
14
  disabledStore.set(disabled);
@@ -23,8 +17,6 @@ $:
23
17
  $: {
24
18
  selectedValue = $selectedValueStore;
25
19
  }
26
- $:
27
- usingKeyboardStore.set(usingKeyboard);
28
20
  $:
29
21
  verticalStore.set(vertical);
30
22
  const dispatch = createEventDispatcher();
@@ -106,12 +98,6 @@ export const selectLastTab = () => {
106
98
  }
107
99
  return false;
108
100
  };
109
- onMount(() => {
110
- keyborg.subscribe(keyborgHandler);
111
- return () => {
112
- keyborg.unsubscribe(keyborgHandler);
113
- };
114
- });
115
101
  const onClick = (event) => {
116
102
  if (!disabled) {
117
103
  let candidate = event.target;
@@ -126,7 +112,6 @@ const onClick = (event) => {
126
112
  }
127
113
  };
128
114
  const onKeydown = (event) => {
129
- console.log("tabList onKeydown", event);
130
115
  if (!disabled && !event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) {
131
116
  switch (event.key) {
132
117
  case "Home":
@@ -175,7 +160,6 @@ const onKeydown = (event) => {
175
160
  setContext(TAB_LIST_CONTEXT_KEY, {
176
161
  disabled: disabledStore,
177
162
  selectedValue: selectedValueStore,
178
- usingKeyboard: usingKeyboardStore,
179
163
  vertical: verticalStore
180
164
  });
181
165
  </script>
@@ -2,6 +2,5 @@ import type { Readable, Writable } from 'svelte/store';
2
2
  export type TabListContext = {
3
3
  disabled: Readable<boolean>;
4
4
  selectedValue: Writable<string | undefined>;
5
- usingKeyboard: Readable<boolean>;
6
5
  vertical: Readable<boolean>;
7
6
  };
package/TextArea.svelte CHANGED
@@ -2,7 +2,7 @@
2
2
  export let autoHeight = false;
3
3
  export let disabled = false;
4
4
  export let resize = "none";
5
- export let value;
5
+ export let value = "";
6
6
  let textAreaRef;
7
7
  const autoSetHeight = () => {
8
8
  if (autoHeight && textAreaRef) {
@@ -42,7 +42,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
42
42
  };
43
43
  </script>
44
44
 
45
- <div class="sterling-text-area2" class:disabled>
45
+ <div class="sterling-text-area" class:disabled>
46
46
  <textarea
47
47
  bind:this={textAreaRef}
48
48
  bind:value
@@ -88,8 +88,10 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
88
88
  </div>
89
89
 
90
90
  <style>
91
- .sterling-text-area2 {
91
+ .sterling-text-area {
92
92
  position: relative;
93
+ height: 100%;
94
+ width: 100%;
93
95
  }
94
96
 
95
97
  textarea {
@@ -130,12 +132,12 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
130
132
  outline-width: var(--stsv-Common__outline-width);
131
133
  }
132
134
 
133
- .sterling-text-area2:disabled {
135
+ .sterling-text-area:disabled {
134
136
  cursor: not-allowed;
135
137
  outline: none;
136
138
  }
137
139
 
138
- .sterling-text-area2::after {
140
+ .sterling-text-area::after {
139
141
  background: var(--stsv-Disabled__background);
140
142
  bottom: 0;
141
143
  content: '';
@@ -148,7 +150,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
148
150
  transition: opacity 250ms;
149
151
  }
150
152
 
151
- .sterling-text-area2.disabled::after {
153
+ .sterling-text-area.disabled::after {
152
154
  opacity: 1;
153
155
  }
154
156
 
@@ -159,8 +161,8 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
159
161
 
160
162
  @media (prefers-reduced-motion) {
161
163
  textarea,
162
- .sterling-text-area2,
163
- .sterling-text-area2::after {
164
+ .sterling-text-area,
165
+ .sterling-text-area::after {
164
166
  transition: none;
165
167
  }
166
168
  }
@@ -5,7 +5,7 @@ declare const __propDef: {
5
5
  autoHeight?: boolean | undefined;
6
6
  disabled?: boolean | undefined;
7
7
  resize?: "none" | "horizontal" | "vertical" | "both" | undefined;
8
- value: string;
8
+ value?: string | undefined;
9
9
  blur?: (() => void) | undefined;
10
10
  click?: (() => void) | undefined;
11
11
  focus?: ((options?: FocusOptions) => void) | undefined;
package/Tree.svelte CHANGED
@@ -1,7 +1,7 @@
1
- <script>import { createKeyborg } from "keyborg";
2
- import { createEventDispatcher, onMount, setContext } from "svelte";
1
+ <script>import { createEventDispatcher, setContext } from "svelte";
3
2
  import { writable } from "svelte/store";
4
3
  import { TREE_CONTEXT_KEY } from "./Tree.constants";
4
+ import { usingKeyboard } from "./stores/usingKeyboard";
5
5
  export let composed = false;
6
6
  export let disabled = false;
7
7
  export let selectedValue = void 0;
@@ -23,11 +23,6 @@ const raiseExpandCollapse = (expandedValues2) => {
23
23
  const raiseSelect = (selectedValue2) => {
24
24
  dispatch("select", { selectedValue: selectedValue2 });
25
25
  };
26
- let keyborg = createKeyborg(window);
27
- let usingKeyboard = keyborg.isNavigatingWithKeyboard();
28
- const keyborgHandler = (value) => {
29
- usingKeyboard = value;
30
- };
31
26
  $: {
32
27
  selectedValueStore.set(selectedValue);
33
28
  }
@@ -45,12 +40,6 @@ $: {
45
40
  $: {
46
41
  disabledStore.set(disabled);
47
42
  }
48
- onMount(() => {
49
- keyborg.subscribe(keyborgHandler);
50
- return () => {
51
- keyborg.unsubscribe(keyborgHandler);
52
- };
53
- });
54
43
  setContext(TREE_CONTEXT_KEY, {
55
44
  expandedValues: expandedValuesStore,
56
45
  selectedValue: selectedValueStore,
@@ -65,7 +54,7 @@ setContext(TREE_CONTEXT_KEY, {
65
54
  class="sterling-tree"
66
55
  class:composed
67
56
  class:disabled
68
- class:using-keyboard={usingKeyboard}
57
+ class:using-keyboard={$usingKeyboard}
69
58
  role="tree"
70
59
  on:blur
71
60
  on:click
package/TreeItem.svelte CHANGED
@@ -3,8 +3,14 @@ import { slide } from "svelte/transition";
3
3
  import { TREE_CONTEXT_KEY, TREE_ITEM_CONTEXT_KEY } from "./Tree.constants";
4
4
  import TreeItemDisplay from "./TreeItemDisplay.svelte";
5
5
  import { writable } from "svelte/store";
6
+ import { prefersReducedMotion } from "./stores/prefersReducedMotion";
6
7
  export let disabled = false;
7
8
  export let value;
9
+ const slidNoOp = (node, params) => {
10
+ return { delay: 0, duration: 0 };
11
+ };
12
+ $:
13
+ slideMotion = !$prefersReducedMotion ? slide : slidNoOp;
8
14
  const {
9
15
  expandedValues,
10
16
  selectedValue,
@@ -293,7 +299,7 @@ A item in a Tree displaying the item and children.
293
299
  </slot>
294
300
  </div>
295
301
  {#if expanded && hasChildren}
296
- <div class="children" transition:slide={{ duration: 200 }} role="group">
302
+ <div class="children" transition:slideMotion={{ duration: 200 }} role="group">
297
303
  <slot {depth} {selected} {value} />
298
304
  </div>
299
305
  {/if}