milk-lib 0.0.19 → 0.0.21
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 +25 -25
- package/dist/components/Checkbox/Checkbox.types.d.ts +1 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.svelte +125 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.svelte.d.ts +4 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.types.d.ts +14 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.types.js +1 -0
- package/dist/components/CheckboxGroup/index.d.ts +1 -0
- package/dist/components/CheckboxGroup/index.js +1 -0
- package/dist/components/Command/CommandRoot.svelte +1 -1
- package/dist/components/Select/Select.svelte +10 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/styles/index.scss +2 -0
- package/package.json +1 -1
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { ICheckboxProps } from './Checkbox.types';
|
|
3
|
-
let {
|
|
3
|
+
let {
|
|
4
|
+
checked = $bindable(),
|
|
5
|
+
disabled,
|
|
6
|
+
id,
|
|
7
|
+
name,
|
|
8
|
+
value,
|
|
9
|
+
required,
|
|
10
|
+
ariaLabel,
|
|
11
|
+
toggleOption
|
|
12
|
+
}: ICheckboxProps = $props();
|
|
4
13
|
|
|
5
|
-
const toggle = () =>
|
|
14
|
+
const toggle = () => {
|
|
15
|
+
checked = !checked;
|
|
16
|
+
if (value) {
|
|
17
|
+
toggleOption?.(value);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
6
20
|
|
|
7
21
|
function handleKeydown(e: KeyboardEvent) {
|
|
8
22
|
if (e.key === ' ' || e.key === 'Enter') {
|
|
@@ -29,20 +43,8 @@
|
|
|
29
43
|
>
|
|
30
44
|
|
|
31
45
|
<span class={`checkbox-icon ${checked ? 'visible1' : ''}`}>
|
|
32
|
-
<svg
|
|
33
|
-
|
|
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 width="12" height="12" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
+
<path d="M23.9141 7.41406L9 22.3281L0.585938 13.9141L3.41406 11.0859L9 16.6719L21.0859 4.58594L23.9141 7.41406Z" fill="currentColor"/>
|
|
46
48
|
</svg>
|
|
47
49
|
</span>
|
|
48
50
|
|
|
@@ -54,15 +56,15 @@
|
|
|
54
56
|
{/if}
|
|
55
57
|
|
|
56
58
|
<style>.checkbox-button {
|
|
57
|
-
--size:
|
|
59
|
+
--size: 16px;
|
|
58
60
|
--border-width: 2px;
|
|
59
|
-
--border-radius:
|
|
61
|
+
--border-radius: 3px;
|
|
60
62
|
--background-color: white;
|
|
61
63
|
--border-color: var(--line-base);
|
|
62
|
-
--background-color-checked: var(--bg-
|
|
63
|
-
--color-checked:
|
|
64
|
+
--background-color-checked: var(--bg-primary-emp-100);
|
|
65
|
+
--color-checked: var(--icon-base-main);
|
|
64
66
|
--border-color-checked: var(--background-color-checked);
|
|
65
|
-
--color-outline-focused: var(--bg-
|
|
67
|
+
--color-outline-focused: var(--bg-primary-emp-100);
|
|
66
68
|
--opacity-disabled: 0.6;
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -91,12 +93,10 @@
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
.checkbox-icon {
|
|
94
|
-
|
|
95
|
-
line-height: 1;
|
|
96
|
+
line-height: 0;
|
|
96
97
|
pointer-events: none;
|
|
97
98
|
opacity: 0;
|
|
98
|
-
|
|
99
|
-
top: 1px;
|
|
99
|
+
box-sizing: border-box;
|
|
100
100
|
}
|
|
101
101
|
.checkbox-icon.visible1 {
|
|
102
102
|
opacity: 1;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import type { CheckboxOption, CheckboxGroupProps } from './CheckboxGroup.types';
|
|
4
|
+
import { Checkbox } from '../..';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
legend = 'Choose options',
|
|
8
|
+
options = [] as CheckboxOption[],
|
|
9
|
+
selectedValues = $bindable([] as string[]),
|
|
10
|
+
name
|
|
11
|
+
}: CheckboxGroupProps = $props();
|
|
12
|
+
|
|
13
|
+
function handleOptionToggle(value: string) {
|
|
14
|
+
toggleOption(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const isSelected = (value: string) => selectedValues.includes(value);
|
|
18
|
+
|
|
19
|
+
function toggleOption(value: string) {
|
|
20
|
+
selectedValues = isSelected(value)
|
|
21
|
+
? selectedValues.filter((item) => item !== value)
|
|
22
|
+
: [...selectedValues, value];
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<fieldset class="checkbox-group">
|
|
27
|
+
{#if legend}
|
|
28
|
+
<legend>{legend}</legend>
|
|
29
|
+
{/if}
|
|
30
|
+
|
|
31
|
+
<ul class="checkbox-list">
|
|
32
|
+
{#if options.length === 0}
|
|
33
|
+
<li class="checkbox-placeholder">Нет вариантов для выбора</li>
|
|
34
|
+
{:else}
|
|
35
|
+
{#each options as option (option.value)}
|
|
36
|
+
<li>
|
|
37
|
+
<label class="checkbox-option" data-disabled={option.disabled || undefined}>
|
|
38
|
+
<Checkbox
|
|
39
|
+
id={option.id} name={option.name}
|
|
40
|
+
checked={isSelected(option.value)}
|
|
41
|
+
value={option.value}
|
|
42
|
+
toggleOption={handleOptionToggle}
|
|
43
|
+
/>
|
|
44
|
+
<span>
|
|
45
|
+
<span>{option.label}</span>
|
|
46
|
+
{#if option.hint}
|
|
47
|
+
<small>{option.hint}</small>
|
|
48
|
+
{/if}
|
|
49
|
+
</span>
|
|
50
|
+
</label>
|
|
51
|
+
</li>
|
|
52
|
+
{/each}
|
|
53
|
+
{/if}
|
|
54
|
+
</ul>
|
|
55
|
+
|
|
56
|
+
<div class="checkbox-selected">
|
|
57
|
+
<strong>Selected:</strong>
|
|
58
|
+
{#if selectedValues.length === 0}
|
|
59
|
+
<span>nothing</span>
|
|
60
|
+
{:else}
|
|
61
|
+
<span>{selectedValues.join(', ')}</span>
|
|
62
|
+
{/if}
|
|
63
|
+
</div>
|
|
64
|
+
</fieldset>
|
|
65
|
+
|
|
66
|
+
<style>.checkbox-group {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
gap: 12px;
|
|
70
|
+
padding: 12px 16px;
|
|
71
|
+
border: 1px solid var(--line-base, #e2e2e2);
|
|
72
|
+
border-radius: 10px;
|
|
73
|
+
background: var(--bg-base, #fff);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
legend {
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
margin-bottom: 8px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.checkbox-list {
|
|
83
|
+
list-style: none;
|
|
84
|
+
margin: 0;
|
|
85
|
+
padding: 0;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
gap: 8px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.checkbox-placeholder {
|
|
92
|
+
color: var(--text-base-placeholder, #7c7c7c);
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.checkbox-option {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: flex-start;
|
|
99
|
+
gap: 8px;
|
|
100
|
+
font-size: 14px;
|
|
101
|
+
line-height: 1.2;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.checkbox-option[data-disabled=true] {
|
|
105
|
+
opacity: 0.6;
|
|
106
|
+
cursor: not-allowed;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.checkbox-option small {
|
|
110
|
+
display: block;
|
|
111
|
+
color: var(--text-base-placeholder, #7c7c7c);
|
|
112
|
+
font-size: 12px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.checkbox-selected {
|
|
116
|
+
font-size: 13px;
|
|
117
|
+
color: var(--text-base-placeholder, #7c7c7c);
|
|
118
|
+
display: flex;
|
|
119
|
+
gap: 6px;
|
|
120
|
+
flex-wrap: wrap;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.checkbox-selected strong {
|
|
124
|
+
color: var(--text-base-main, #222);
|
|
125
|
+
}</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type CheckboxOption = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
hint?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
id?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
};
|
|
9
|
+
export type CheckboxGroupProps = {
|
|
10
|
+
legend: string;
|
|
11
|
+
options: CheckboxOption[];
|
|
12
|
+
selectedValues: string[];
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CheckboxGroup } from './CheckboxGroup.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CheckboxGroup } from './CheckboxGroup.svelte';
|
|
@@ -88,8 +88,12 @@
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
const showMenu = () =>
|
|
92
|
-
|
|
91
|
+
const showMenu = () => {
|
|
92
|
+
isMenuVisible = true;
|
|
93
|
+
}
|
|
94
|
+
const hideMenu = () => {
|
|
95
|
+
isMenuVisible = false;
|
|
96
|
+
}
|
|
93
97
|
|
|
94
98
|
const focusHandler = () => {
|
|
95
99
|
if (!isMenuVisible) {
|
|
@@ -107,7 +111,10 @@
|
|
|
107
111
|
value: item.value
|
|
108
112
|
});
|
|
109
113
|
textInputBlock.focus();
|
|
110
|
-
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
hideMenu();
|
|
116
|
+
}, 50);
|
|
117
|
+
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
const handleCommandInputKeyDown = (e: KeyboardEvent) => {
|
package/dist/components/index.js
CHANGED
package/dist/styles/index.scss
CHANGED