@geoffcox/sterling-svelte 1.0.0 → 1.0.3

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/Callout.svelte CHANGED
@@ -26,6 +26,8 @@ let popupRef;
26
26
  let arrowRef;
27
27
  let popupPosition = { x: 0, y: 0 };
28
28
  $: floatingUIPlacement = placement;
29
+ let bodyHeight = 0;
30
+ let resizeObserver = undefined;
29
31
  // ----- Portal Host ----- //
30
32
  const ensurePortalHost = () => {
31
33
  if (document) {
@@ -43,11 +45,6 @@ const ensurePortalHost = () => {
43
45
  }
44
46
  };
45
47
  // ----- Body Height Change ----- //
46
- let bodyHeight = 0;
47
- // create an Observer instance
48
- const resizeObserver = new ResizeObserver((entries) => {
49
- bodyHeight = entries[0].target.clientHeight;
50
- });
51
48
  // ----- Position ----- //
52
49
  $: middleware = [
53
50
  offset({ mainAxis: mainAxisOffset, crossAxis: crossAxisOffset }),
@@ -124,10 +121,15 @@ $: fadeMotion = !$prefersReducedMotion ? fade : fadeNoOp;
124
121
  // ----- EventHandlers ----- //
125
122
  onMount(() => {
126
123
  ensurePortalHost();
124
+ resizeObserver = new ResizeObserver((entries) => {
125
+ bodyHeight = entries[0].target.clientHeight;
126
+ });
127
127
  // start observing a DOM node
128
128
  resizeObserver.observe(document.body);
129
129
  return () => {
130
- resizeObserver.unobserve(document.body);
130
+ resizeObserver?.unobserve(document.body);
131
+ resizeObserver?.disconnect();
132
+ resizeObserver = undefined;
131
133
  };
132
134
  });
133
135
  const onKeydown = (event) => {
package/Dialog.svelte CHANGED
@@ -1,5 +1,4 @@
1
- <script>import '$lib/css/sterling.css';
2
- import { onMount, tick } from 'svelte';
1
+ <script>import { onMount, tick } from 'svelte';
3
2
  import Button from './Button.svelte';
4
3
  const dialogFadeDuration = 250;
5
4
  // ----- Props ----- //
@@ -1,5 +1,4 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import '$lib/css/sterling.css';
3
2
  declare const __propDef: {
4
3
  props: {
5
4
  [x: string]: any;
package/Dropdown.svelte CHANGED
@@ -113,12 +113,16 @@ $: slideMotion = !$prefersReducedMotion ? slide : slideNoOp;
113
113
  on:click_outside={onClickOutside}
114
114
  {...$$restProps}
115
115
  >
116
- <div class="value">
117
- <slot name="value" {disabled} {open} {variant} />
118
- </div>
116
+ {#if $$slots.value}
117
+ <div class="value">
118
+ <slot name="value" {disabled} {open} {variant} />
119
+ </div>
120
+ {/if}
119
121
  <slot name="button" {disabled} {open} {variant}>
120
122
  <div class="button">
121
- <div class="chevron" />
123
+ <slot name="icon" {disabled} {open} {variant}>
124
+ <div class="chevron" />
125
+ </slot>
122
126
  </div>
123
127
  </slot>
124
128
 
@@ -52,6 +52,11 @@ declare const __propDef: {
52
52
  open: boolean;
53
53
  variant: string;
54
54
  };
55
+ icon: {
56
+ disabled: boolean;
57
+ open: boolean;
58
+ variant: string;
59
+ };
55
60
  default: {
56
61
  disabled: boolean;
57
62
  open: boolean;
package/Input.svelte CHANGED
@@ -40,7 +40,7 @@ export const setRangeText = (replacement, start, end, selectionMode) => {
40
40
  </script>
41
41
 
42
42
  {#if $$slots.default}
43
- <label class={`sterling-input-label ${variant}`} for={id}>
43
+ <label class={`sterling-input-label ${variant}`} class:disabled for={id}>
44
44
  <slot {disabled} {value} {variant} />
45
45
  </label>
46
46
  {/if}
package/MenuButton.svelte CHANGED
@@ -13,6 +13,8 @@ export let open = false;
13
13
  export let value;
14
14
  /** Additional class names to apply. */
15
15
  export let variant = '';
16
+ /** Additional class names to apply to the Menu*/
17
+ export let menuVariant = '';
16
18
  // ----- State ----- //
17
19
  const instanceId = idGenerator.nextId('MenuButton');
18
20
  let buttonRef;
@@ -144,8 +146,8 @@ setContext(MENU_ITEM_CONTEXT_KEY, {
144
146
  <slot {open} {value} {variant} />
145
147
  </div>
146
148
  <Popover {reference} {open}>
147
- <Menu bind:this={menuRef} id={menuId} {reference} {open}>
148
- <slot name="items" {variant} />
149
+ <Menu bind:this={menuRef} id={menuId} {reference} {open} variant={menuVariant}>
150
+ <slot name="items" />
149
151
  </Menu>
150
152
  </Popover>
151
153
  </Button>
@@ -5,6 +5,7 @@ declare const __propDef: {
5
5
  open?: boolean | undefined;
6
6
  value: string;
7
7
  variant?: string | undefined;
8
+ menuVariant?: string | undefined;
8
9
  click?: (() => void) | undefined;
9
10
  blur?: (() => void) | undefined;
10
11
  focus?: ((options?: FocusOptions) => void) | undefined;
@@ -53,9 +54,7 @@ declare const __propDef: {
53
54
  value: string;
54
55
  variant: string;
55
56
  };
56
- items: {
57
- variant: string;
58
- };
57
+ items: {};
59
58
  };
60
59
  };
61
60
  export type MenuButtonProps = typeof __propDef.props;
package/MenuItem.svelte CHANGED
@@ -24,6 +24,8 @@ export let text = undefined;
24
24
  export let value;
25
25
  /** Additional class names to apply. */
26
26
  export let variant = '';
27
+ /** Additional class names to apply to the sub Menu*/
28
+ export let menuVariant = '';
27
29
  // ----- Get Context ----- //
28
30
  const { isMenuBarItem, openValues = writable([]), rootValue = value, depth = 0, closeContainingMenu = undefined, onOpen = undefined, onClose = undefined, onSelect = undefined } = getContext(MENU_ITEM_CONTEXT_KEY) || {};
29
31
  const { openPreviousMenuBarItem = undefined, openNextMenuBarItem = undefined } = getContext(MENU_BAR_CONTEXT_KEY) || {};
@@ -376,7 +378,7 @@ setContext(MENU_ITEM_CONTEXT_KEY, {
376
378
  placement={isMenuBarItem ? 'bottom-start' : 'right-start'}
377
379
  {open}
378
380
  >
379
- <Menu bind:this={menuRef} id={menuId}>
381
+ <Menu bind:this={menuRef} id={menuId} variant={menuVariant}>
380
382
  <slot {depth} {disabled} />
381
383
  </Menu>
382
384
  </Popover>
@@ -8,6 +8,7 @@ declare const __propDef: {
8
8
  text?: string | undefined;
9
9
  value: string;
10
10
  variant?: string | undefined;
11
+ menuVariant?: string | undefined;
11
12
  blur?: (() => void) | undefined;
12
13
  click?: (() => void) | undefined;
13
14
  focus?: ((options?: FocusOptions) => void) | undefined;
package/Popover.svelte CHANGED
@@ -23,6 +23,8 @@ export let variant = '';
23
23
  let popupRef;
24
24
  let popupPosition = { x: 0, y: 0 };
25
25
  $: floatingUIPlacement = placement;
26
+ let bodyHeight = 0;
27
+ let resizeObserver = undefined;
26
28
  // ----- Portal Host ----- //
27
29
  const ensurePortalHost = () => {
28
30
  if (document) {
@@ -39,12 +41,6 @@ const ensurePortalHost = () => {
39
41
  portalHost = host;
40
42
  }
41
43
  };
42
- // ----- Body Height Change ----- //
43
- let bodyHeight = 0;
44
- // create an Observer instance
45
- const resizeObserver = new ResizeObserver((entries) => {
46
- bodyHeight = entries[0].target.clientHeight;
47
- });
48
44
  // ----- Position ----- //
49
45
  $: middleware = [offset({ mainAxis: mainAxisOffset, crossAxis: crossAxisOffset }), flip()];
50
46
  const computePopoverPosition = async () => {
@@ -71,10 +67,15 @@ $: open, bodyHeight, middleware, floatingUIPlacement, computePopoverPosition();
71
67
  // ----- EventHandlers ----- //
72
68
  onMount(() => {
73
69
  ensurePortalHost();
70
+ resizeObserver = new ResizeObserver((entries) => {
71
+ bodyHeight = entries[0].target.clientHeight;
72
+ });
74
73
  // start observing a DOM node
75
74
  resizeObserver.observe(document.body);
76
75
  return () => {
77
- resizeObserver.unobserve(document.body);
76
+ resizeObserver?.unobserve(document.body);
77
+ resizeObserver?.disconnect();
78
+ resizeObserver = undefined;
78
79
  };
79
80
  });
80
81
  const onKeydown = (event) => {
package/Select.svelte CHANGED
@@ -12,6 +12,8 @@ export let open = false;
12
12
  export let selectedValue = undefined;
13
13
  /** Additional class names to apply. */
14
14
  export let variant = '';
15
+ /** Additional class names to apply to the List*/
16
+ export let listVariant = '';
15
17
  // ----- State ----- //
16
18
  // Tracks the previous open state
17
19
  let prevOpen = false;
@@ -209,7 +211,9 @@ const onListSelect = (event) => {
209
211
  </div>
210
212
  <div class="button">
211
213
  <slot name="button" {disabled} {open} {selectedValue} {variant}>
212
- <div class="chevron" />
214
+ <slot name="icon" {disabled} {open} {selectedValue} {variant}>
215
+ <div class="chevron" />
216
+ </slot>
213
217
  </slot>
214
218
  </div>
215
219
  <Popover reference={selectRef} bind:open id={popupId} conditionalRender={false}>
@@ -222,9 +226,9 @@ const onListSelect = (event) => {
222
226
  on:keydown={onListKeydown}
223
227
  on:select={onListSelect}
224
228
  tabIndex={open ? 0 : -1}
225
- variant={`composed ${variant}`}
229
+ variant={`composed ${listVariant}`}
226
230
  >
227
- <slot {variant} />
231
+ <slot {variant} {listVariant} />
228
232
  </List>
229
233
  </div>
230
234
  </Popover>
@@ -6,6 +6,7 @@ declare const __propDef: {
6
6
  open?: boolean | undefined;
7
7
  selectedValue?: string | undefined;
8
8
  variant?: string | undefined;
9
+ listVariant?: string | undefined;
9
10
  blur?: (() => void) | undefined;
10
11
  click?: (() => void) | undefined;
11
12
  focus?: ((options?: FocusOptions) => void) | undefined;
@@ -56,8 +57,15 @@ declare const __propDef: {
56
57
  selectedValue: string | undefined;
57
58
  variant: string;
58
59
  };
60
+ icon: {
61
+ disabled: boolean;
62
+ open: boolean;
63
+ selectedValue: string | undefined;
64
+ variant: string;
65
+ };
59
66
  default: {
60
67
  variant: string;
68
+ listVariant: string;
61
69
  };
62
70
  };
63
71
  };
@@ -84,7 +84,7 @@ input::placeholder {
84
84
 
85
85
  /* ----- label ----- */
86
86
 
87
- label {
87
+ .sterling-input-label {
88
88
  color: var(--stsv-common__color);
89
89
  transition: color 250ms;
90
90
  font: inherit;
@@ -94,7 +94,7 @@ label {
94
94
 
95
95
  @media (prefers-reduced-motion) {
96
96
  .sterling-input::after,
97
- input {
97
+ .sterling-input-label {
98
98
  transition: none;
99
99
  }
100
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoffcox/sterling-svelte",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "author": "Geoff Cox",
5
5
  "description": "A modern, accessible, and lightweight component library for Svelte.",
6
6
  "license": "MIT",