noph-ui 0.46.0 → 0.46.1

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.
@@ -9,6 +9,7 @@
9
9
  quick = false,
10
10
  children,
11
11
  headline,
12
+ headlineLevel = 2,
12
13
  icon,
13
14
  supportingText,
14
15
  actions,
@@ -61,13 +62,14 @@
61
62
  </div>
62
63
  {/if}
63
64
  {#if headline}
64
- <h1
65
+ <svelte:element
66
+ this={`h${headlineLevel}`}
65
67
  id="{uid}-dialog-headline"
66
68
  class="np-dialog-headline"
67
69
  style={icon ? 'text-align: center' : ''}
68
70
  >
69
71
  {headline}
70
- </h1>
72
+ </svelte:element>
71
73
  {/if}
72
74
  {#if supportingText}
73
75
  <p id="{uid}-dialog-supporting-text" class="np-dialog-supporting-text">{supportingText}</p>
@@ -3,6 +3,7 @@ import type { HTMLDialogAttributes } from 'svelte/elements';
3
3
  export interface DialogProps extends Omit<HTMLDialogAttributes, 'open'> {
4
4
  icon?: Snippet;
5
5
  headline?: string;
6
+ headlineLevel?: 1 | 2 | 3 | 4 | 5 | 6;
6
7
  supportingText?: string;
7
8
  divider?: boolean;
8
9
  actions?: Snippet;
@@ -1,2 +1,3 @@
1
+ export { default as Item } from './Item.svelte';
1
2
  export { default as List } from './List.svelte';
2
3
  export { default as ListItem } from './ListItem.svelte';
@@ -1,2 +1,3 @@
1
+ export { default as Item } from './Item.svelte';
1
2
  export { default as List } from './List.svelte';
2
3
  export { default as ListItem } from './ListItem.svelte';
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { tick } from 'svelte'
2
+ import { flushSync } from 'svelte'
3
3
  import '../internal/focus-ring.css'
4
4
  import IconButton from '../button/IconButton.svelte'
5
5
  import ArrowBackIcon from '../icons/ArrowBackIcon.svelte'
@@ -35,11 +35,12 @@
35
35
 
36
36
  let pointerFocus = false
37
37
  let focusRing = $state(false)
38
+ let pointerInside = false
38
39
 
39
- export const show = async () => {
40
+ export const show = () => {
40
41
  expanded = true
41
42
  pointerFocus = true
42
- await tick()
43
+ flushSync()
43
44
  inputElement?.focus()
44
45
  }
45
46
 
@@ -49,6 +50,14 @@
49
50
  }
50
51
  </script>
51
52
 
53
+ <svelte:window
54
+ onpointerdown={(event) => {
55
+ pointerInside = event.target instanceof Node && element?.contains(event.target) === true
56
+ }}
57
+ onpointercancel={() => (pointerInside = false)}
58
+ onclick={() => (pointerInside = false)}
59
+ />
60
+
52
61
  <div
53
62
  {...attributes}
54
63
  bind:this={element}
@@ -65,7 +74,8 @@
65
74
  }}
66
75
  onfocusout={(event) => {
67
76
  const next = event.relatedTarget
68
- if (expanded && !(next instanceof Node && element?.contains(next))) expanded = false
77
+ if (expanded && !pointerInside && !(next instanceof Node && element?.contains(next)))
78
+ expanded = false
69
79
  attributes.onfocusout?.(event)
70
80
  }}
71
81
  >
@@ -1,7 +1,7 @@
1
1
  import '../internal/focus-ring.css';
2
2
  import type { SearchProps } from './types.ts';
3
3
  declare const Search: import("svelte").Component<SearchProps, {
4
- show: () => Promise<void>;
4
+ show: () => void;
5
5
  close: () => void;
6
6
  }, "element" | "value" | "inputElement" | "expanded">;
7
7
  type Search = ReturnType<typeof Search>;
@@ -8,6 +8,7 @@
8
8
  placement = 'bottom',
9
9
  handle = true,
10
10
  headline,
11
+ headlineLevel = 2,
11
12
  action,
12
13
  children,
13
14
  element = $bindable(),
@@ -63,7 +64,9 @@
63
64
  {#if headline || action}
64
65
  <div class="np-sheet-header">
65
66
  {#if headline}
66
- <h2 id={headlineId} class="np-sheet-headline">{headline}</h2>
67
+ <svelte:element this={`h${headlineLevel}`} id={headlineId} class="np-sheet-headline">
68
+ {headline}
69
+ </svelte:element>
67
70
  {/if}
68
71
  {#if action}
69
72
  <div class="np-sheet-action">{@render action()}</div>
@@ -6,6 +6,7 @@ export interface SheetProps extends Omit<HTMLDialogAttributes, 'open'> {
6
6
  placement?: 'bottom' | 'top' | 'start' | 'end';
7
7
  handle?: boolean;
8
8
  headline?: string;
9
+ headlineLevel?: 1 | 2 | 3 | 4 | 5 | 6;
9
10
  action?: Snippet;
10
11
  element?: HTMLDialogElement;
11
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.46.0",
3
+ "version": "0.46.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {