noph-ui 0.24.19 → 0.25.0
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/checkbox/Checkbox.svelte +36 -49
- package/package.json +1 -1
|
@@ -8,21 +8,22 @@
|
|
|
8
8
|
element = $bindable(),
|
|
9
9
|
group = $bindable(),
|
|
10
10
|
style,
|
|
11
|
+
value,
|
|
11
12
|
...attributes
|
|
12
13
|
}: CheckboxProps = $props()
|
|
13
14
|
|
|
14
15
|
$effect(() => {
|
|
15
|
-
if (group &&
|
|
16
|
-
checked = group.includes(
|
|
16
|
+
if (group && value) {
|
|
17
|
+
checked = group.includes(value)
|
|
17
18
|
}
|
|
18
19
|
})
|
|
19
20
|
|
|
20
21
|
$effect(() => {
|
|
21
|
-
if (
|
|
22
|
-
const index = group.indexOf(
|
|
22
|
+
if (value && group) {
|
|
23
|
+
const index = group.indexOf(value)
|
|
23
24
|
if (checked) {
|
|
24
25
|
if (index < 0) {
|
|
25
|
-
group?.push(
|
|
26
|
+
group?.push(value)
|
|
26
27
|
group = group
|
|
27
28
|
}
|
|
28
29
|
} else {
|
|
@@ -36,59 +37,48 @@
|
|
|
36
37
|
let inputEl: HTMLInputElement | undefined = $state()
|
|
37
38
|
</script>
|
|
38
39
|
|
|
39
|
-
<div {style} class={['np-
|
|
40
|
-
<div class="np-
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</label>
|
|
55
|
-
|
|
56
|
-
<div class="np-outline"></div>
|
|
57
|
-
<div class="np-background"></div>
|
|
58
|
-
<svg class="np-icon" viewBox="0 0 18 18" aria-hidden="true">
|
|
59
|
-
<rect class="mark short" />
|
|
60
|
-
<rect class="mark long" />
|
|
61
|
-
</svg>
|
|
40
|
+
<div {style} class={['np-container', attributes.class]} bind:this={element}>
|
|
41
|
+
<div class="np-input-wrapper">
|
|
42
|
+
{#if !attributes.disabled}
|
|
43
|
+
<Ripple forElement={inputEl} />
|
|
44
|
+
{/if}
|
|
45
|
+
<input
|
|
46
|
+
{...attributes}
|
|
47
|
+
{value}
|
|
48
|
+
class="np-input"
|
|
49
|
+
type="checkbox"
|
|
50
|
+
bind:indeterminate
|
|
51
|
+
bind:checked
|
|
52
|
+
bind:this={inputEl}
|
|
53
|
+
aria-checked={indeterminate ? 'mixed' : undefined}
|
|
54
|
+
/>
|
|
62
55
|
</div>
|
|
56
|
+
<div class="np-outline"></div>
|
|
57
|
+
<div class="np-background"></div>
|
|
58
|
+
<svg class="np-icon" viewBox="0 0 18 18" aria-hidden="true">
|
|
59
|
+
<rect class="mark short" />
|
|
60
|
+
<rect class="mark long" />
|
|
61
|
+
</svg>
|
|
63
62
|
</div>
|
|
64
63
|
|
|
65
64
|
<style>
|
|
66
|
-
.np-
|
|
67
|
-
border-
|
|
68
|
-
border-start-end-radius: var(--np-checkbox-container-shape, 2px);
|
|
69
|
-
border-end-end-radius: var(--np-checkbox-container-shape, 2px);
|
|
70
|
-
border-end-start-radius: var(--np-checkbox-container-shape, 2px);
|
|
65
|
+
.np-container {
|
|
66
|
+
border-radius: var(--np-checkbox-container-shape, 2px);
|
|
71
67
|
display: inline-flex;
|
|
68
|
+
place-content: center;
|
|
69
|
+
place-items: center;
|
|
70
|
+
position: relative;
|
|
72
71
|
height: 18px;
|
|
73
72
|
position: relative;
|
|
74
73
|
vertical-align: top;
|
|
75
74
|
width: 18px;
|
|
76
|
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
77
75
|
cursor: pointer;
|
|
76
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
78
77
|
margin: var(--np-checkbox-margin, max(0px, (48px - 18px)/2));
|
|
79
78
|
}
|
|
80
|
-
.np-
|
|
79
|
+
.np-container:has(input:disabled) {
|
|
81
80
|
cursor: default;
|
|
82
81
|
}
|
|
83
|
-
.np-container {
|
|
84
|
-
border-radius: inherit;
|
|
85
|
-
display: flex;
|
|
86
|
-
height: 100%;
|
|
87
|
-
place-content: center;
|
|
88
|
-
place-items: center;
|
|
89
|
-
position: relative;
|
|
90
|
-
width: 100%;
|
|
91
|
-
}
|
|
92
82
|
.np-input {
|
|
93
83
|
height: 48px;
|
|
94
84
|
width: 48px;
|
|
@@ -144,11 +134,8 @@
|
|
|
144
134
|
border-width: 2px;
|
|
145
135
|
box-sizing: border-box;
|
|
146
136
|
}
|
|
147
|
-
:
|
|
148
|
-
|
|
149
|
-
border-width: 2px;
|
|
150
|
-
}
|
|
151
|
-
:where(:focus-within) .np-outline {
|
|
137
|
+
.np-container:focus-within .np-outline,
|
|
138
|
+
.np-container:hover .np-outline {
|
|
152
139
|
border-color: var(--np-color-on-surface);
|
|
153
140
|
border-width: 2px;
|
|
154
141
|
}
|