noph-ui 0.11.2 → 0.11.4

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.
@@ -22,6 +22,7 @@
22
22
 
23
23
  $effect(() => {
24
24
  if (disabled && element) {
25
+ // eslint-disable-next-line no-undef
25
26
  const formElements: NodeListOf<
26
27
  HTMLButtonElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
27
28
  > = element.querySelectorAll('input, button, select, textarea')
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
4
+ let { children }: { children?: Snippet } = $props()
5
+ </script>
6
+
7
+ {#if children}
8
+ <div class="np-chip-set" role="toolbar">
9
+ {@render children()}
10
+ </div>
11
+ {/if}
12
+
13
+ <style>
14
+ .np-chip-set {
15
+ display: flex;
16
+ flex-wrap: wrap;
17
+ gap: 0.5rem;
18
+ }
19
+ </style>
@@ -0,0 +1,7 @@
1
+ import type { Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ children?: Snippet;
4
+ };
5
+ declare const ChipSet: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type ChipSet = ReturnType<typeof ChipSet>;
7
+ export default ChipSet;
@@ -12,7 +12,11 @@
12
12
  disabled = false,
13
13
  label = '',
14
14
  icon,
15
+ element = $bindable(),
15
16
  ariaLabelRemove = 'Remove',
17
+ remove,
18
+ select,
19
+ deselect,
16
20
  ...attributes
17
21
  }: FilterChipProps = $props()
18
22
 
@@ -21,6 +25,7 @@
21
25
 
22
26
  <div
23
27
  {...attributes}
28
+ bind:this={element}
24
29
  class={[
25
30
  'np-filter-chip',
26
31
  elevated ? 'np-filter-chip-elevated' : 'np-filter-chip-default',
@@ -36,7 +41,12 @@
36
41
  class="np-filter-chip-btn"
37
42
  {disabled}
38
43
  onclick={() => {
39
- console.log('click')
44
+ if (element === undefined) return
45
+ if (selected) {
46
+ deselect?.(element)
47
+ } else {
48
+ select?.(element)
49
+ }
40
50
  selected = !selected
41
51
  }}
42
52
  >
@@ -58,8 +68,11 @@
58
68
  --np-icon-button-container-width="1.75rem"
59
69
  --np-icon-button-icon-size="1.125rem"
60
70
  aria-label={ariaLabelRemove}
61
- onclick={(event: Event) => {
62
- event.stopPropagation()
71
+ onclick={() => {
72
+ if (element === undefined) {
73
+ return
74
+ }
75
+ remove?.(element)
63
76
  }}
64
77
  >
65
78
  <CloseIcon />
@@ -1,4 +1,4 @@
1
1
  import type { FilterChipProps } from './types.ts';
2
- declare const FilterChip: import("svelte").Component<FilterChipProps, {}, "selected">;
2
+ declare const FilterChip: import("svelte").Component<FilterChipProps, {}, "element" | "selected">;
3
3
  type FilterChip = ReturnType<typeof FilterChip>;
4
4
  export default FilterChip;
@@ -1 +1,2 @@
1
1
  export { default as FilterChip } from './FilterChip.svelte';
2
+ export { default as ChipSet } from './ChipSet.svelte';
@@ -1 +1,2 @@
1
1
  export { default as FilterChip } from './FilterChip.svelte';
2
+ export { default as ChipSet } from './ChipSet.svelte';
@@ -8,4 +8,8 @@ export interface FilterChipProps extends HTMLAttributes<HTMLDivElement> {
8
8
  label?: string;
9
9
  icon?: Snippet;
10
10
  ariaLabelRemove?: string;
11
+ element?: HTMLDivElement;
12
+ remove?: (chip: HTMLDivElement) => void;
13
+ select?: (chip: HTMLDivElement) => void;
14
+ deselect?: (chip: HTMLDivElement) => void;
11
15
  }
@@ -47,6 +47,6 @@
47
47
  </style>
48
48
  </svelte:head>
49
49
 
50
- <span {...attributes} class={['np-icon', attributes.class]} bind:this={element}
50
+ <span {...attributes} class={['np-icon', 'notranslate', attributes.class]} bind:this={element}
51
51
  >{@render children()}</span
52
52
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {