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.
@@ -1,11 +1,11 @@
1
1
  <script lang="ts">
2
2
 
3
- import type { CheckboxOption, CheckboxGroupProps } from './CheckboxGroup.types';
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 CheckboxOption[],
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">Нет вариантов для выбора</li>
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
- <label class="checkbox-option" data-disabled={option.disabled || undefined}>
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
- <span>
45
- <span>{option.label}</span>
46
- {#if option.hint}
47
- <small>{option.hint}</small>
48
- {/if}
49
- </span>
50
- </label>
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: CheckboxOption[];
19
+ options: CheckboxGroupItem[];
12
20
  selectedValues: string[];
13
21
  name: string;
14
22
  };
@@ -1 +1,2 @@
1
1
  export { default as CheckboxGroup } from './CheckboxGroup.svelte';
2
+ export * from './CheckboxGroup.types';
@@ -1 +1,2 @@
1
1
  export { default as CheckboxGroup } from './CheckboxGroup.svelte';
2
+ export * from './CheckboxGroup.types';
@@ -165,7 +165,7 @@
165
165
 
166
166
  <div
167
167
  class={`SegmentedControlRoot ${classNames}`}
168
- role="group"
168
+ role="radiogroup"
169
169
  aria-orientation={orientation}
170
170
  aria-disabled={disabled}
171
171
  data-orientation={orientation}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "milk-lib",
3
3
  "license": "MIT",
4
- "version": "0.0.31",
4
+ "version": "0.0.33",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run prepack",