carbon-components-svelte 0.88.3 → 0.89.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/package.json +1 -1
- package/src/ComboBox/ComboBox.svelte +9 -1
- package/src/ListBox/ListBoxMenuItem.svelte +1 -0
- package/src/ListBox/ListBoxSelection.svelte +7 -6
- package/src/RadioButton/RadioButton.svelte +2 -0
- package/src/Select/SelectItem.svelte +6 -2
- package/src/TextArea/TextArea.svelte +1 -1
- package/src/Tile/RadioTile.svelte +1 -0
- package/src/utils/toHierarchy.js +11 -24
- package/types/ComboBox/ComboBox.svelte.d.ts +6 -0
- package/types/RadioButton/RadioButton.svelte.d.ts +5 -1
- package/types/Select/SelectItem.svelte.d.ts +2 -1
package/package.json
CHANGED
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
/** Specify the title text of the combobox */
|
|
47
47
|
export let titleText = "";
|
|
48
48
|
|
|
49
|
+
/** Set to `true` to visually hide the label text */
|
|
50
|
+
export let hideLabel = false;
|
|
51
|
+
|
|
49
52
|
/** Specify the placeholder text */
|
|
50
53
|
export let placeholder = "";
|
|
51
54
|
|
|
@@ -226,7 +229,12 @@
|
|
|
226
229
|
|
|
227
230
|
<div class:bx--list-box__wrapper={true}>
|
|
228
231
|
{#if titleText || $$slots.titleText}
|
|
229
|
-
<label
|
|
232
|
+
<label
|
|
233
|
+
for={id}
|
|
234
|
+
class:bx--label={true}
|
|
235
|
+
class:bx--label--disabled={disabled}
|
|
236
|
+
class:bx--visually-hidden={hideLabel}
|
|
237
|
+
>
|
|
230
238
|
<slot name="titleText">
|
|
231
239
|
{titleText}
|
|
232
240
|
</slot>
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
class:bx--list-box__menu-item--active={active}
|
|
26
26
|
class:bx--list-box__menu-item--highlighted={highlighted || active}
|
|
27
27
|
aria-selected={active}
|
|
28
|
+
aria-disabled={disabled ? true : undefined}
|
|
28
29
|
disabled={disabled ? true : undefined}
|
|
29
30
|
{...$$restProps}
|
|
30
31
|
on:click
|
|
@@ -44,11 +44,12 @@
|
|
|
44
44
|
$: if (ctx && ref) {
|
|
45
45
|
ctx.declareRef({ key: "selection", ref });
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
$: translationId =
|
|
48
|
+
selectionCount === undefined
|
|
49
|
+
? translationIds.clearSelection
|
|
50
|
+
: translationIds.clearAll;
|
|
51
|
+
$: buttonLabel =
|
|
52
|
+
translateWithId?.(translationId) ?? defaultTranslations[translationId];
|
|
52
53
|
$: description =
|
|
53
54
|
translateWithId?.(translationId) ?? defaultTranslations[translationId];
|
|
54
55
|
</script>
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
}
|
|
80
81
|
}}
|
|
81
82
|
{disabled}
|
|
82
|
-
aria-label={
|
|
83
|
+
aria-label={buttonLabel}
|
|
83
84
|
title={description}
|
|
84
85
|
>
|
|
85
86
|
<Close />
|
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export let value = "";
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Specify the option text
|
|
10
|
+
* If not specified, the value will be used as the text.
|
|
11
|
+
* @type {string}
|
|
12
|
+
*/
|
|
13
|
+
export let text = undefined;
|
|
10
14
|
|
|
11
15
|
/** Set to `true` to hide the option */
|
|
12
16
|
export let hidden = false;
|
package/src/utils/toHierarchy.js
CHANGED
|
@@ -13,35 +13,22 @@
|
|
|
13
13
|
export function toHierarchy(flatArray, getParentId) {
|
|
14
14
|
/** @type {NodeLike[]} */
|
|
15
15
|
const tree = [];
|
|
16
|
-
const
|
|
17
|
-
const itemsMap = new Map(flatArray.map((item) => [item.id, item]));
|
|
16
|
+
const nodeMap = new Map();
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
for (const item of flatArray) {
|
|
20
19
|
const parentId = getParentId(item);
|
|
20
|
+
nodeMap.set(item.id, item);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
const children = childrenOf.get(item.id);
|
|
24
|
-
if (children) {
|
|
25
|
-
item.nodes = children;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Check if parentId exists using Map instead of array lookup.
|
|
29
|
-
const parentExists = parentId && itemsMap.has(parentId);
|
|
30
|
-
|
|
31
|
-
if (parentId && parentExists) {
|
|
32
|
-
if (!childrenOf.has(parentId)) {
|
|
33
|
-
childrenOf.set(parentId, []);
|
|
34
|
-
}
|
|
35
|
-
childrenOf.get(parentId).push(item);
|
|
36
|
-
|
|
37
|
-
const parent = itemsMap.get(parentId);
|
|
38
|
-
if (parent) {
|
|
39
|
-
parent.nodes = childrenOf.get(parentId);
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
22
|
+
if (!parentId || !nodeMap.has(parentId)) {
|
|
42
23
|
tree.push(item);
|
|
24
|
+
} else {
|
|
25
|
+
const parent = nodeMap.get(parentId);
|
|
26
|
+
if (!parent.nodes) {
|
|
27
|
+
parent.nodes = [];
|
|
28
|
+
}
|
|
29
|
+
parent.nodes.push(item);
|
|
43
30
|
}
|
|
44
|
-
}
|
|
31
|
+
}
|
|
45
32
|
|
|
46
33
|
return tree;
|
|
47
34
|
}
|
|
@@ -71,6 +71,10 @@ export type RadioButtonProps = Omit<$RestProps, keyof $Props> & $Props;
|
|
|
71
71
|
|
|
72
72
|
export default class RadioButton extends SvelteComponentTyped<
|
|
73
73
|
RadioButtonProps,
|
|
74
|
-
{
|
|
74
|
+
{
|
|
75
|
+
focus: WindowEventMap["focus"];
|
|
76
|
+
blur: WindowEventMap["blur"];
|
|
77
|
+
change: WindowEventMap["change"];
|
|
78
|
+
},
|
|
75
79
|
{ labelText: {} }
|
|
76
80
|
> {}
|