noph-ui 0.9.13 → 0.9.15
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.
- package/dist/button/SegmentedButton.svelte +32 -13
- package/dist/button/SegmentedButton.svelte.d.ts +1 -1
- package/dist/button/types.d.ts +1 -0
- package/dist/checkbox/Checkbox.svelte +2 -0
- package/dist/checkbox/Checkbox.svelte.d.ts +1 -1
- package/dist/checkbox/types.d.ts +1 -0
- package/dist/menu/Menu.svelte +1 -0
- package/dist/radio/Radio.svelte +2 -1
- package/dist/radio/Radio.svelte.d.ts +1 -1
- package/dist/radio/types.d.ts +1 -0
- package/dist/select/Select.svelte +9 -21
- package/package.json +7 -7
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
options,
|
|
9
9
|
multiSelect = false,
|
|
10
10
|
element = $bindable(),
|
|
11
|
+
group = $bindable(),
|
|
11
12
|
...attributes
|
|
12
13
|
}: SegmentedButtonProps = $props()
|
|
13
14
|
let hoverState = $state(-1)
|
|
@@ -43,19 +44,37 @@
|
|
|
43
44
|
{#if !option.disabled}
|
|
44
45
|
<Ripple forceHover={i === hoverState} />
|
|
45
46
|
{/if}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
{#if multiSelect}
|
|
48
|
+
<input
|
|
49
|
+
type="checkbox"
|
|
50
|
+
onclick={option.onclick}
|
|
51
|
+
bind:group
|
|
52
|
+
onfocus={(event) => {
|
|
53
|
+
if (event) hoverState = i
|
|
54
|
+
}}
|
|
55
|
+
onblur={() => (hoverState = -1)}
|
|
56
|
+
{name}
|
|
57
|
+
aria-label={typeof option.label === 'function' ? `${name}-${i}` : option.label}
|
|
58
|
+
value={option.label}
|
|
59
|
+
disabled={option.disabled}
|
|
60
|
+
checked={option.selected}
|
|
61
|
+
/>
|
|
62
|
+
{:else}
|
|
63
|
+
<input
|
|
64
|
+
type="radio"
|
|
65
|
+
onclick={option.onclick}
|
|
66
|
+
bind:group
|
|
67
|
+
onfocus={(event) => {
|
|
68
|
+
if (event) hoverState = i
|
|
69
|
+
}}
|
|
70
|
+
onblur={() => (hoverState = -1)}
|
|
71
|
+
{name}
|
|
72
|
+
aria-label={typeof option.label === 'function' ? `${name}-${i}` : option.label}
|
|
73
|
+
value={option.label}
|
|
74
|
+
disabled={option.disabled}
|
|
75
|
+
checked={option.selected}
|
|
76
|
+
/>
|
|
77
|
+
{/if}
|
|
59
78
|
</label>
|
|
60
79
|
{/each}
|
|
61
80
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SegmentedButtonProps } from './types.ts';
|
|
2
|
-
declare const SegmentedButton: import("svelte").Component<SegmentedButtonProps, {}, "element">;
|
|
2
|
+
declare const SegmentedButton: import("svelte").Component<SegmentedButtonProps, {}, "element" | "group">;
|
|
3
3
|
type SegmentedButton = ReturnType<typeof SegmentedButton>;
|
|
4
4
|
export default SegmentedButton;
|
package/dist/button/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
indeterminate = $bindable(),
|
|
7
7
|
checked = $bindable(),
|
|
8
8
|
element = $bindable(),
|
|
9
|
+
group = $bindable(),
|
|
9
10
|
style,
|
|
10
11
|
...attributes
|
|
11
12
|
}: CheckboxProps = $props()
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
type="checkbox"
|
|
21
22
|
bind:indeterminate
|
|
22
23
|
bind:checked
|
|
24
|
+
bind:group
|
|
23
25
|
aria-checked={indeterminate ? 'mixed' : undefined}
|
|
24
26
|
/>
|
|
25
27
|
{#if !attributes.disabled}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CheckboxProps } from './types.ts';
|
|
2
|
-
declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "element" | "checked" | "indeterminate">;
|
|
2
|
+
declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "element" | "group" | "checked" | "indeterminate">;
|
|
3
3
|
type Checkbox = ReturnType<typeof Checkbox>;
|
|
4
4
|
export default Checkbox;
|
package/dist/checkbox/types.d.ts
CHANGED
package/dist/menu/Menu.svelte
CHANGED
package/dist/radio/Radio.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
checked,
|
|
7
7
|
defaultChecked,
|
|
8
8
|
element = $bindable(),
|
|
9
|
+
group = $bindable(),
|
|
9
10
|
style,
|
|
10
11
|
...attributes
|
|
11
12
|
}: RadioProps = $props()
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
</script>
|
|
15
16
|
|
|
16
17
|
<label {style} class={['np-host', attributes.class]} bind:this={element}>
|
|
17
|
-
<input {...attributes} type="radio" class="np-input" {checked} {defaultChecked} />
|
|
18
|
+
<input {...attributes} type="radio" class="np-input" {checked} {defaultChecked} bind:group />
|
|
18
19
|
<div class="np-container" aria-hidden="true">
|
|
19
20
|
{#if !attributes.disabled}
|
|
20
21
|
<Ripple forElement={touchEl} class="np-radio-ripple" />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RadioProps } from './types.ts';
|
|
2
|
-
declare const Radio: import("svelte").Component<RadioProps, {}, "element">;
|
|
2
|
+
declare const Radio: import("svelte").Component<RadioProps, {}, "element" | "group">;
|
|
3
3
|
type Radio = ReturnType<typeof Radio>;
|
|
4
4
|
export default Radio;
|
package/dist/radio/types.d.ts
CHANGED
|
@@ -31,9 +31,7 @@
|
|
|
31
31
|
}: SelectProps = $props()
|
|
32
32
|
|
|
33
33
|
let errorTextRaw: string = $state(errorText)
|
|
34
|
-
$
|
|
35
|
-
errorTextRaw = errorText
|
|
36
|
-
})
|
|
34
|
+
let errorRaw = $state(error)
|
|
37
35
|
let selectElement: HTMLSelectElement | undefined = $state()
|
|
38
36
|
let menuElement: HTMLDivElement | undefined = $state()
|
|
39
37
|
let field: HTMLDivElement | undefined = $state()
|
|
@@ -43,22 +41,22 @@
|
|
|
43
41
|
return options.find((option) => option.value === value)?.label || ''
|
|
44
42
|
})
|
|
45
43
|
$effect(() => {
|
|
46
|
-
if (value !== '') {
|
|
47
|
-
|
|
44
|
+
if (value !== '' && selectElement?.checkValidity()) {
|
|
45
|
+
errorRaw = error
|
|
48
46
|
errorTextRaw = errorText
|
|
49
47
|
}
|
|
50
48
|
})
|
|
51
49
|
$effect(() => {
|
|
52
50
|
if (selectElement) {
|
|
53
51
|
selectElement.form?.addEventListener('reset', () => {
|
|
54
|
-
|
|
52
|
+
errorRaw = error
|
|
55
53
|
})
|
|
56
54
|
selectElement.addEventListener('invalid', (event) => {
|
|
57
55
|
event.preventDefault()
|
|
58
56
|
const { currentTarget } = event as Event & {
|
|
59
57
|
currentTarget: HTMLInputElement | HTMLTextAreaElement
|
|
60
58
|
}
|
|
61
|
-
|
|
59
|
+
errorRaw = true
|
|
62
60
|
if (errorText === '') {
|
|
63
61
|
errorTextRaw = currentTarget.validationMessage
|
|
64
62
|
}
|
|
@@ -66,16 +64,6 @@
|
|
|
66
64
|
currentTarget.focus()
|
|
67
65
|
}
|
|
68
66
|
})
|
|
69
|
-
|
|
70
|
-
selectElement.addEventListener('select', (event) => {
|
|
71
|
-
const { currentTarget } = event as Event & {
|
|
72
|
-
currentTarget: HTMLSelectElement
|
|
73
|
-
}
|
|
74
|
-
if (currentTarget.checkValidity()) {
|
|
75
|
-
error = false
|
|
76
|
-
errorTextRaw = errorText
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
67
|
}
|
|
80
68
|
})
|
|
81
69
|
</script>
|
|
@@ -100,7 +88,7 @@
|
|
|
100
88
|
<div
|
|
101
89
|
{id}
|
|
102
90
|
class="field"
|
|
103
|
-
class:error
|
|
91
|
+
class:error={errorRaw}
|
|
104
92
|
class:no-label={!label?.length}
|
|
105
93
|
class:with-start={start}
|
|
106
94
|
class:menu-open={menuOpen}
|
|
@@ -202,10 +190,10 @@
|
|
|
202
190
|
</div>
|
|
203
191
|
</div>
|
|
204
192
|
</div>
|
|
205
|
-
{#if supportingText || (errorTextRaw &&
|
|
206
|
-
<div class="supporting-text" role={
|
|
193
|
+
{#if supportingText || (errorTextRaw && errorRaw)}
|
|
194
|
+
<div class="supporting-text" role={errorRaw ? 'alert' : undefined}>
|
|
207
195
|
<span>
|
|
208
|
-
{
|
|
196
|
+
{errorRaw && errorTextRaw ? errorTextRaw : supportingText}
|
|
209
197
|
</span>
|
|
210
198
|
</div>
|
|
211
199
|
{/if}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noph-ui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://noph.dev",
|
|
6
6
|
"repository": {
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
61
61
|
"@types/eslint": "^9.6.1",
|
|
62
62
|
"eslint": "^9.18.0",
|
|
63
|
-
"eslint-config-prettier": "^
|
|
63
|
+
"eslint-config-prettier": "^10.0.1",
|
|
64
64
|
"eslint-plugin-svelte": "^2.46.1",
|
|
65
65
|
"globals": "^15.14.0",
|
|
66
66
|
"prettier": "^3.4.2",
|
|
67
|
-
"prettier-plugin-svelte": "^3.3.
|
|
68
|
-
"publint": "^0.3.
|
|
69
|
-
"svelte": "^5.
|
|
70
|
-
"svelte-check": "^4.1.
|
|
67
|
+
"prettier-plugin-svelte": "^3.3.3",
|
|
68
|
+
"publint": "^0.3.2",
|
|
69
|
+
"svelte": "^5.18.0",
|
|
70
|
+
"svelte-check": "^4.1.4",
|
|
71
71
|
"typescript": "^5.7.3",
|
|
72
|
-
"typescript-eslint": "^8.
|
|
72
|
+
"typescript-eslint": "^8.20.0",
|
|
73
73
|
"vite": "^6.0.7",
|
|
74
74
|
"vitest": "^2.1.8"
|
|
75
75
|
},
|