noph-ui 0.18.4 → 0.18.5

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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.18.4",
3
+ "version": "0.18.5",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {