milk-lib 0.0.31 → 0.0.33
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/CheckboxGroup/CheckboxGroup.svelte +39 -12
- package/dist/components/CheckboxGroup/CheckboxGroup.types.d.ts +9 -1
- package/dist/components/CheckboxGroup/index.d.ts +1 -0
- package/dist/components/CheckboxGroup/index.js +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.svelte +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { CheckboxGroupItem, CheckboxGroupProps } from './CheckboxGroup.types';
|
|
4
4
|
import { Checkbox } from '../..';
|
|
5
5
|
|
|
6
6
|
let {
|
|
7
7
|
legend = 'Choose options',
|
|
8
|
-
options = [] as
|
|
8
|
+
options = [] as CheckboxGroupItem[],
|
|
9
9
|
selectedValues = $bindable([] as string[]),
|
|
10
10
|
name
|
|
11
11
|
}: CheckboxGroupProps = $props();
|
|
@@ -30,24 +30,34 @@
|
|
|
30
30
|
|
|
31
31
|
<ul class="checkbox-list">
|
|
32
32
|
{#if options.length === 0}
|
|
33
|
-
<li class="checkbox-placeholder"
|
|
33
|
+
<li class="checkbox-placeholder">No option for choice</li>
|
|
34
34
|
{:else}
|
|
35
|
-
{#each options as option (option.value)}
|
|
35
|
+
{#each options as option, index (option.kind === 'header' ? `header-${index}` : option.value)}
|
|
36
36
|
<li>
|
|
37
|
-
|
|
37
|
+
{#if option.kind === 'header'}
|
|
38
|
+
<div class="checkbox-section-title" id={option.id}>
|
|
39
|
+
<span>{option.label}</span>
|
|
40
|
+
{#if option.hint}
|
|
41
|
+
<small>{option.hint}</small>
|
|
42
|
+
{/if}
|
|
43
|
+
</div>
|
|
44
|
+
{:else}
|
|
45
|
+
<label class="checkbox-option" data-disabled={option.disabled || undefined}>
|
|
38
46
|
<Checkbox
|
|
39
47
|
id={option.id} name={option.name}
|
|
48
|
+
disabled={option.disabled}
|
|
40
49
|
checked={isSelected(option.value)}
|
|
41
50
|
value={option.value}
|
|
42
51
|
toggleOption={handleOptionToggle}
|
|
43
52
|
/>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
<span>
|
|
54
|
+
<span>{option.label}</span>
|
|
55
|
+
{#if option.hint}
|
|
56
|
+
<small>{option.hint}</small>
|
|
57
|
+
{/if}
|
|
58
|
+
</span>
|
|
59
|
+
</label>
|
|
60
|
+
{/if}
|
|
51
61
|
</li>
|
|
52
62
|
{/each}
|
|
53
63
|
{/if}
|
|
@@ -93,6 +103,23 @@ legend {
|
|
|
93
103
|
font-size: 14px;
|
|
94
104
|
}
|
|
95
105
|
|
|
106
|
+
.checkbox-section-title {
|
|
107
|
+
font-size: 13px;
|
|
108
|
+
font-weight: 500;
|
|
109
|
+
color: var(--text-base-placeholder, #7c7c7c);
|
|
110
|
+
text-transform: uppercase;
|
|
111
|
+
letter-spacing: 1px;
|
|
112
|
+
margin-top: 0.75em;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.checkbox-section-title small {
|
|
116
|
+
display: block;
|
|
117
|
+
font-size: 12px;
|
|
118
|
+
font-weight: 400;
|
|
119
|
+
text-transform: none;
|
|
120
|
+
letter-spacing: 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
96
123
|
.checkbox-option {
|
|
97
124
|
display: flex;
|
|
98
125
|
align-items: flex-start;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
export type CheckboxGroupHeader = {
|
|
2
|
+
kind: 'header';
|
|
3
|
+
label: string;
|
|
4
|
+
hint?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
};
|
|
1
7
|
export type CheckboxOption = {
|
|
8
|
+
kind?: 'option';
|
|
2
9
|
label: string;
|
|
3
10
|
value: string;
|
|
4
11
|
hint?: string;
|
|
@@ -6,9 +13,10 @@ export type CheckboxOption = {
|
|
|
6
13
|
id?: string;
|
|
7
14
|
name?: string;
|
|
8
15
|
};
|
|
16
|
+
export type CheckboxGroupItem = CheckboxOption | CheckboxGroupHeader;
|
|
9
17
|
export type CheckboxGroupProps = {
|
|
10
18
|
legend: string;
|
|
11
|
-
options:
|
|
19
|
+
options: CheckboxGroupItem[];
|
|
12
20
|
selectedValues: string[];
|
|
13
21
|
name: string;
|
|
14
22
|
};
|