noph-ui 0.13.0 → 0.13.2

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.
@@ -90,11 +90,15 @@
90
90
  --np-icon-button-container-width="1.75rem"
91
91
  --np-icon-button-icon-size="1.125rem"
92
92
  aria-label={ariaLabelRemove}
93
- onclick={() => {
93
+ onclick={(
94
+ event: MouseEvent & {
95
+ currentTarget: EventTarget & HTMLButtonElement
96
+ },
97
+ ) => {
94
98
  if (element === undefined) {
95
99
  return
96
100
  }
97
- onremove?.(element)
101
+ onremove?.(event)
98
102
  }}
99
103
  >
100
104
  <CloseIcon />
@@ -13,5 +13,7 @@ export interface FilterChipProps extends HTMLAttributes<HTMLDivElement> {
13
13
  value?: string;
14
14
  group?: (string | number)[] | null;
15
15
  defaultSelected?: boolean | null;
16
- onremove?: (chip: HTMLDivElement) => void;
16
+ onremove?: (event: MouseEvent & {
17
+ currentTarget: EventTarget & HTMLButtonElement;
18
+ }) => void;
17
19
  }
@@ -22,6 +22,8 @@
22
22
 
23
23
  let errorRaw: boolean = $state(error)
24
24
  let errorTextRaw: string = $state(errorText)
25
+ let focusOnInvalid = $state(true)
26
+ let checkValidity = $state(false)
25
27
  $effect(() => {
26
28
  errorRaw = error
27
29
  errorTextRaw = errorText
@@ -34,6 +36,9 @@
34
36
  errorRaw = error
35
37
  value = ''
36
38
  })
39
+ textElement.addEventListener('input', () => {
40
+ checkValidity = true
41
+ })
37
42
  textElement.addEventListener('invalid', (event) => {
38
43
  event.preventDefault()
39
44
  const { currentTarget } = event as Event & {
@@ -43,18 +48,22 @@
43
48
  if (errorText === '') {
44
49
  errorTextRaw = currentTarget.validationMessage
45
50
  }
46
- if (isFirstInvalidControlInForm(currentTarget.form, currentTarget)) {
51
+ if (focusOnInvalid && isFirstInvalidControlInForm(currentTarget.form, currentTarget)) {
47
52
  currentTarget.focus()
48
53
  }
49
54
  })
50
55
 
51
- textElement.addEventListener('change', (event) => {
56
+ textElement.addEventListener('blur', (event) => {
52
57
  const { currentTarget } = event as Event & {
53
58
  currentTarget: HTMLInputElement | HTMLTextAreaElement
54
59
  }
55
- if (currentTarget.checkValidity()) {
56
- errorRaw = error
57
- errorTextRaw = errorText
60
+ if (checkValidity) {
61
+ focusOnInvalid = false
62
+ if (currentTarget.checkValidity()) {
63
+ errorRaw = error
64
+ errorTextRaw = errorText
65
+ }
66
+ focusOnInvalid = true
58
67
  }
59
68
  })
60
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {