noph-ui 0.18.4 → 0.18.6

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.
@@ -1,17 +1,12 @@
1
1
  <script lang="ts">
2
- import { setContext } from 'svelte'
3
- import type { ChipSetContext, ChipSetProps } from './types.ts'
2
+ import type { ChipSetProps } from './types.ts'
4
3
 
5
- let { children, ...attributes }: ChipSetProps = $props()
6
- let chipSet: ChipSetContext = $state({
7
- chips: [],
8
- })
9
- setContext('chipSet', chipSet)
4
+ let { children, chipsCount, ...attributes }: ChipSetProps = $props()
10
5
  </script>
11
6
 
12
7
  {#if children}
13
8
  <div
14
- class={['np-chip-set', chipSet.chips.length > 0 && 'np-chip-set-has-chips', attributes.class]}
9
+ class={['np-chip-set', (chipsCount ?? 0) > 0 && 'np-chip-set-has-chips', attributes.class]}
15
10
  style={attributes.style}
16
11
  role="toolbar"
17
12
  >
@@ -3,8 +3,7 @@
3
3
  import CheckIcon from '../icons/CheckIcon.svelte'
4
4
  import CloseIcon from '../icons/CloseIcon.svelte'
5
5
  import Ripple from '../ripple/Ripple.svelte'
6
- import { getContext, onMount } from 'svelte'
7
- import type { ChipSetContext, FilterChipProps } from './types.ts'
6
+ import type { FilterChipProps } from './types.ts'
8
7
 
9
8
  let {
10
9
  selected = $bindable(),
@@ -24,17 +23,6 @@
24
23
  }: FilterChipProps = $props()
25
24
 
26
25
  let chipLabel: HTMLLabelElement | undefined = $state()
27
- let chipSet: ChipSetContext = getContext('chipSet')
28
-
29
- onMount(() => {
30
- chipSet.chips.push({ label: label, name: name, value: value })
31
- return () => {
32
- const index = chipSet.chips.findIndex((chip) => chip.value === value)
33
- if (index !== -1) {
34
- chipSet.chips.splice(index, 1)
35
- }
36
- }
37
- })
38
26
 
39
27
  $effect(() => {
40
28
  if (group && value) {
@@ -2,8 +2,8 @@
2
2
  import IconButton from '../button/IconButton.svelte'
3
3
  import CloseIcon from '../icons/CloseIcon.svelte'
4
4
  import Ripple from '../ripple/Ripple.svelte'
5
- import { getContext, onMount } from 'svelte'
6
- import type { ChipSetContext, InputChipProps } from './types.ts'
5
+ import { onMount } from 'svelte'
6
+ import type { InputChipProps } from './types.ts'
7
7
 
8
8
  let {
9
9
  selected = $bindable(),
@@ -20,7 +20,6 @@
20
20
 
21
21
  let chipLabel: HTMLDivElement | undefined = $state()
22
22
  let visible = $state(false)
23
- let chipSet: ChipSetContext = getContext('chipSet')
24
23
 
25
24
  onMount(() => {
26
25
  const observer = new IntersectionObserver((entries) => {
@@ -35,14 +34,9 @@
35
34
  if (element) {
36
35
  observer.observe(element)
37
36
  }
38
- chipSet.chips.push({ label: label, name: name, value: value })
39
37
 
40
38
  return () => {
41
39
  observer.disconnect()
42
- const index = chipSet.chips.findIndex((chip) => chip.value === value)
43
- if (index !== -1) {
44
- chipSet.chips.splice(index, 1)
45
- }
46
40
  }
47
41
  })
48
42
  </script>
@@ -1,6 +1,8 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
3
- export type ChipSetProps = HTMLAttributes<HTMLDivElement>;
3
+ export interface ChipSetProps extends HTMLAttributes<HTMLDivElement> {
4
+ chipsCount?: number;
5
+ }
4
6
  interface AssistChipButtonProps extends HTMLButtonAttributes {
5
7
  elevated?: boolean;
6
8
  disabled?: boolean;
@@ -2,13 +2,13 @@
2
2
  import type { MenuProps } from './types.ts'
3
3
 
4
4
  let {
5
- anchor,
6
5
  children,
7
6
  element = $bindable(),
8
7
  showPopover = $bindable(),
9
8
  hidePopover = $bindable(),
10
9
  style,
11
10
  popover = 'auto',
11
+ anchor,
12
12
  ...attributes
13
13
  }: MenuProps = $props()
14
14
 
@@ -24,8 +24,10 @@
24
24
  hidePopover = () => {
25
25
  element?.hidePopover()
26
26
  }
27
-
28
27
  const refreshValues = () => {
28
+ if ('anchorName' in document.documentElement.style) {
29
+ return
30
+ }
29
31
  if (element && anchor && menuOpen) {
30
32
  const anchorRect = anchor.getBoundingClientRect()
31
33
  let maxHeight: number
@@ -83,28 +85,11 @@
83
85
  }
84
86
 
85
87
  $effect(() => {
86
- if (anchor && element) {
87
- if (style) {
88
- const styleEntries = style
89
- .split(';')
90
- .filter(Boolean)
91
- .map((entry) => entry.split(':').map((str) => str.trim()))
92
- styleEntries.forEach(([key, value]) => {
93
- element?.style.setProperty(key, value)
94
- })
95
- }
88
+ if (element && !('anchorName' in document.documentElement.style)) {
96
89
  getScrollableParent(element).addEventListener('scroll', onScroll, { passive: true })
97
- if (
98
- 'anchorName' in document.documentElement.style &&
99
- !anchor.style.getPropertyValue('anchor-name')
100
- ) {
101
- const generatedId = `--${crypto.randomUUID()}`
102
- element.style.setProperty('position-anchor', generatedId)
103
- anchor.style.setProperty('anchor-name', generatedId)
104
- }
105
90
  }
106
91
  return () => {
107
- if (element) {
92
+ if (element && !('anchorName' in document.documentElement.style)) {
108
93
  getScrollableParent(element).removeEventListener('scroll', onScroll)
109
94
  }
110
95
  }
@@ -125,6 +110,7 @@
125
110
  }}
126
111
  {popover}
127
112
  class={['np-menu-container', attributes.class]}
113
+ {style}
128
114
  >
129
115
  <div class="np-menu">
130
116
  {@render children()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.18.4",
3
+ "version": "0.18.6",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {
@@ -53,26 +53,26 @@
53
53
  "svelte": "^5.32.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@eslint/js": "^9.29.0",
56
+ "@eslint/js": "^9.30.1",
57
57
  "@material/material-color-utilities": "^0.3.0",
58
- "@playwright/test": "^1.53.1",
58
+ "@playwright/test": "^1.53.2",
59
59
  "@sveltejs/adapter-vercel": "^5.7.2",
60
- "@sveltejs/kit": "^2.22.0",
61
- "@sveltejs/package": "^2.3.11",
60
+ "@sveltejs/kit": "^2.22.2",
61
+ "@sveltejs/package": "^2.3.12",
62
62
  "@sveltejs/vite-plugin-svelte": "^5.1.0",
63
63
  "@types/eslint": "^9.6.1",
64
- "eslint": "^9.29.0",
64
+ "eslint": "^9.30.1",
65
65
  "eslint-config-prettier": "^10.1.5",
66
- "eslint-plugin-svelte": "^3.9.3",
67
- "globals": "^16.2.0",
68
- "prettier": "^3.6.0",
66
+ "eslint-plugin-svelte": "^3.10.1",
67
+ "globals": "^16.3.0",
68
+ "prettier": "^3.6.2",
69
69
  "prettier-plugin-svelte": "^3.4.0",
70
70
  "publint": "^0.3.12",
71
- "svelte": "^5.34.7",
71
+ "svelte": "^5.35.2",
72
72
  "svelte-check": "^4.2.2",
73
73
  "typescript": "^5.8.3",
74
- "typescript-eslint": "^8.35.0",
75
- "vite": "^6.3.5",
74
+ "typescript-eslint": "^8.35.1",
75
+ "vite": "^7.0.2",
76
76
  "vitest": "^3.2.4"
77
77
  },
78
78
  "svelte": "./dist/index.js",