noph-ui 0.45.1 → 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.
@@ -35,6 +35,7 @@
35
35
  let {
36
36
  value = $bindable(),
37
37
  defaultValue,
38
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- pulled out of the rest props on purpose
38
39
  type,
39
40
  'aria-invalid': ariaInvalid,
40
41
  style,
@@ -49,6 +49,7 @@
49
49
  let {
50
50
  value = $bindable(),
51
51
  defaultValue,
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- pulled out of the rest props on purpose
52
53
  type,
53
54
  'aria-invalid': ariaInvalid,
54
55
  style,
@@ -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,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { flushSync } from 'svelte'
2
3
  import '../internal/focus-ring.css'
3
4
  import IconButton from '../button/IconButton.svelte'
4
5
  import ArrowBackIcon from '../icons/ArrowBackIcon.svelte'
@@ -34,8 +35,29 @@
34
35
 
35
36
  let pointerFocus = false
36
37
  let focusRing = $state(false)
38
+ let pointerInside = false
39
+
40
+ export const show = () => {
41
+ expanded = true
42
+ pointerFocus = true
43
+ flushSync()
44
+ inputElement?.focus()
45
+ }
46
+
47
+ export const close = () => {
48
+ expanded = false
49
+ inputElement?.blur()
50
+ }
37
51
  </script>
38
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
+
39
61
  <div
40
62
  {...attributes}
41
63
  bind:this={element}
@@ -52,7 +74,8 @@
52
74
  }}
53
75
  onfocusout={(event) => {
54
76
  const next = event.relatedTarget
55
- if (expanded && !(next instanceof Node && element?.contains(next))) expanded = false
77
+ if (expanded && !pointerInside && !(next instanceof Node && element?.contains(next)))
78
+ expanded = false
56
79
  attributes.onfocusout?.(event)
57
80
  }}
58
81
  >
@@ -388,4 +411,14 @@
388
411
  .np-search-divided.np-search-full-screen.np-search-expanded .np-search-bar {
389
412
  height: 4.5rem;
390
413
  }
414
+
415
+ @media (prefers-reduced-motion: no-preference) {
416
+ @starting-style {
417
+ .np-search-full-screen.np-search-expanded,
418
+ .np-search-divided.np-search-full-screen.np-search-expanded {
419
+ padding-block-start: 0;
420
+ padding-inline: var(--np-search-pane-margin, 1.5rem);
421
+ }
422
+ }
423
+ }
391
424
  </style>
@@ -1,5 +1,8 @@
1
1
  import '../internal/focus-ring.css';
2
2
  import type { SearchProps } from './types.ts';
3
- declare const Search: import("svelte").Component<SearchProps, {}, "element" | "value" | "inputElement" | "expanded">;
3
+ declare const Search: import("svelte").Component<SearchProps, {
4
+ show: () => void;
5
+ close: () => void;
6
+ }, "element" | "value" | "inputElement" | "expanded">;
4
7
  type Search = ReturnType<typeof Search>;
5
8
  export default 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.45.1",
3
+ "version": "0.46.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {