milk-lib 0.0.18 → 0.0.20
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/components/Checkbox/Checkbox.svelte +111 -0
- package/dist/components/Checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +10 -0
- package/dist/components/Checkbox/Checkbox.types.js +1 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ICheckboxProps } from './Checkbox.types';
|
|
3
|
+
let { checked = $bindable(), disabled, id, name, value, required, ariaLabel }: ICheckboxProps = $props();
|
|
4
|
+
|
|
5
|
+
const toggle = () => checked = !checked;
|
|
6
|
+
|
|
7
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
8
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
toggle();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<button
|
|
17
|
+
type="button"
|
|
18
|
+
class="checkbox-button"
|
|
19
|
+
role="checkbox"
|
|
20
|
+
aria-label={ariaLabel}
|
|
21
|
+
aria-checked={checked}
|
|
22
|
+
{disabled}
|
|
23
|
+
{id}
|
|
24
|
+
{name}
|
|
25
|
+
{value}
|
|
26
|
+
tabindex="0"
|
|
27
|
+
onclick={toggle}
|
|
28
|
+
onkeydown={handleKeydown}
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
<span class={`checkbox-icon ${checked ? 'visible1' : ''}`}>
|
|
32
|
+
<svg
|
|
33
|
+
width="16"
|
|
34
|
+
height="16"
|
|
35
|
+
viewBox="0 0 24 24"
|
|
36
|
+
fill="none"
|
|
37
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
38
|
+
>
|
|
39
|
+
<path
|
|
40
|
+
d="M20 6L9 17L4 12"
|
|
41
|
+
stroke="currentColor"
|
|
42
|
+
stroke-width="2"
|
|
43
|
+
stroke-linecap="round"
|
|
44
|
+
stroke-linejoin="round"
|
|
45
|
+
/>
|
|
46
|
+
</svg>
|
|
47
|
+
</span>
|
|
48
|
+
|
|
49
|
+
</button>
|
|
50
|
+
|
|
51
|
+
{#if name}
|
|
52
|
+
<!-- скрытый input для участия в формах -->
|
|
53
|
+
<input type="hidden" name={name} value={value || ''} {disabled} {checked} />
|
|
54
|
+
{/if}
|
|
55
|
+
|
|
56
|
+
<style>.checkbox-button {
|
|
57
|
+
--size: 16px;
|
|
58
|
+
--border-width: 2px;
|
|
59
|
+
--border-radius: 3px;
|
|
60
|
+
--background-color: white;
|
|
61
|
+
--border-color: var(--line-base);
|
|
62
|
+
--background-color-checked: var(--bg-primary-emp-100);
|
|
63
|
+
--color-checked: var(--icon-base-main);
|
|
64
|
+
--border-color-checked: var(--background-color-checked);
|
|
65
|
+
--color-outline-focused: var(--bg-primary-emp-100);
|
|
66
|
+
--opacity-disabled: 0.6;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.checkbox-button {
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
width: var(--size);
|
|
74
|
+
height: var(--size);
|
|
75
|
+
border: var(--border-width) solid var(--border-color);
|
|
76
|
+
border-radius: var(--border-radius);
|
|
77
|
+
background: var(--background-color);
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
user-select: none;
|
|
80
|
+
transition: all 0.2s ease-in-out;
|
|
81
|
+
margin: 0;
|
|
82
|
+
padding: 0;
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.checkbox-button[aria-checked=true],
|
|
87
|
+
.checkbox-button[aria-checked=mixed] {
|
|
88
|
+
background: var(--background-color-checked);
|
|
89
|
+
color: var(--color-checked);
|
|
90
|
+
border-color: var(--border-color-checked);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.checkbox-icon {
|
|
94
|
+
line-height: 0;
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
opacity: 0;
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
}
|
|
99
|
+
.checkbox-icon.visible1 {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.checkbox-button:focus-visible {
|
|
104
|
+
outline: 2px solid var(--color-outline-focused);
|
|
105
|
+
outline-offset: 1px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.checkbox-button[disabled] {
|
|
109
|
+
opacity: var(--opacity-disabled);
|
|
110
|
+
pointer-events: none;
|
|
111
|
+
}</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/components/index.js
CHANGED