carbon-components-svelte 0.90.3 → 0.92.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 +2 -3
- package/src/Breakpoint/Breakpoint.svelte +4 -1
- package/src/Breakpoint/breakpointObserver.js +4 -4
- package/src/Breakpoint/breakpoints.d.ts +1 -1
- package/src/ComboBox/ComboBox.svelte +72 -23
- package/src/ComposedModal/ComposedModal.svelte +5 -2
- package/src/ComposedModal/ModalFooter.svelte +2 -1
- package/src/ContextMenu/ContextMenu.svelte +5 -5
- package/src/ContextMenu/ContextMenuGroup.svelte +3 -3
- package/src/DataTable/DataTable.svelte +53 -32
- package/src/DatePicker/DatePicker.svelte +2 -2
- package/src/DatePicker/createCalendar.js +7 -6
- package/src/Dropdown/Dropdown.svelte +20 -12
- package/src/FileUploader/FileUploaderButton.svelte +2 -2
- package/src/Grid/Column.svelte +3 -1
- package/src/LocalStorage/LocalStorage.svelte +3 -1
- package/src/Modal/Modal.svelte +10 -3
- package/src/MultiSelect/MultiSelect.svelte +22 -13
- package/src/Notification/InlineNotification.svelte +2 -1
- package/src/Notification/ToastNotification.svelte +2 -1
- package/src/NumberInput/NumberInput.svelte +14 -14
- package/src/OverflowMenu/OverflowMenu.svelte +3 -2
- package/src/Pagination/Pagination.svelte +15 -4
- package/src/PaginationNav/PaginationNav.svelte +6 -3
- package/src/Popover/Popover.svelte +2 -1
- package/src/RecursiveList/RecursiveList.svelte +4 -1
- package/src/Search/Search.svelte +0 -1
- package/src/SkeletonText/SkeletonText.svelte +1 -1
- package/src/Slider/Slider.svelte +7 -4
- package/src/TextInput/TextInput.svelte +6 -6
- package/src/Theme/Theme.svelte +5 -3
- package/src/Tile/ExpandableTile.svelte +2 -2
- package/src/TreeView/TreeView.svelte +55 -13
- package/src/TreeView/TreeViewNode.svelte +1 -2
- package/src/UIShell/HamburgerMenu.svelte +0 -2
- package/src/UIShell/Header.svelte +0 -2
- package/src/UIShell/HeaderAction.svelte +0 -2
- package/src/UIShell/HeaderSearch.svelte +8 -2
- package/src/index.js +170 -151
- package/src/utils/filterTreeNodes.d.ts +64 -0
- package/src/utils/filterTreeNodes.js +133 -0
- package/src/utils/toHierarchy.js +2 -2
- package/types/Breakpoint/breakpoints.d.ts +1 -1
- package/types/Checkbox/InlineCheckbox.svelte.d.ts +50 -0
- package/types/CodeSnippet/CodeSnippet.svelte.d.ts +0 -1
- package/types/ComboBox/ComboBox.svelte.d.ts +24 -22
- package/types/CopyButton/CopyButton.svelte.d.ts +0 -1
- package/types/DataTable/DataTable.svelte.d.ts +11 -21
- package/types/DataTable/TableHeader.svelte.d.ts +0 -1
- package/types/DataTable/ToolbarBatchActions.svelte.d.ts +0 -1
- package/types/Dropdown/Dropdown.svelte.d.ts +16 -19
- package/types/FileUploader/FileUploaderDropContainer.svelte.d.ts +0 -1
- package/types/Grid/Column.svelte.d.ts +1 -4
- package/types/ListBox/ListBoxField.svelte.d.ts +0 -1
- package/types/ListBox/ListBoxMenuIcon.svelte.d.ts +0 -1
- package/types/ListBox/ListBoxSelection.svelte.d.ts +0 -1
- package/types/MultiSelect/MultiSelect.svelte.d.ts +20 -26
- package/types/Notification/NotificationButton.svelte.d.ts +1 -1
- package/types/NumberInput/NumberInput.svelte.d.ts +2 -3
- package/types/OverflowMenu/OverflowMenu.svelte.d.ts +2 -3
- package/types/Pagination/Pagination.svelte.d.ts +3 -4
- package/types/PaginationNav/PaginationItem.svelte.d.ts +21 -0
- package/types/PaginationNav/PaginationNav.svelte.d.ts +1 -1
- package/types/PaginationNav/PaginationOverflow.svelte.d.ts +21 -0
- package/types/RecursiveList/RecursiveList.svelte.d.ts +5 -5
- package/types/RecursiveList/RecursiveListItem.svelte.d.ts +27 -0
- package/types/Search/Search.svelte.d.ts +1 -2
- package/types/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/types/TreeView/TreeView.svelte.d.ts +39 -8
- package/types/TreeView/TreeViewNode.svelte.d.ts +52 -0
- package/types/TreeView/TreeViewNodeList.svelte.d.ts +60 -0
- package/types/UIShell/HamburgerMenu.svelte.d.ts +46 -0
- package/types/UIShell/Header.svelte.d.ts +2 -4
- package/types/UIShell/HeaderAction.svelte.d.ts +2 -4
- package/types/UIShell/HeaderSearch.svelte.d.ts +2 -2
- package/types/icons/Add.svelte.d.ts +26 -0
- package/types/icons/ArrowUp.svelte.d.ts +26 -0
- package/types/icons/ArrowsVertical.svelte.d.ts +26 -0
- package/types/icons/Calendar.svelte.d.ts +26 -0
- package/types/icons/CaretDown.svelte.d.ts +26 -0
- package/types/icons/CaretLeft.svelte.d.ts +26 -0
- package/types/icons/CaretRight.svelte.d.ts +26 -0
- package/types/icons/Checkmark.svelte.d.ts +26 -0
- package/types/icons/CheckmarkFilled.svelte.d.ts +26 -0
- package/types/icons/CheckmarkOutline.svelte.d.ts +26 -0
- package/types/icons/ChevronDown.svelte.d.ts +26 -0
- package/types/icons/ChevronRight.svelte.d.ts +26 -0
- package/types/icons/CircleDash.svelte.d.ts +26 -0
- package/types/icons/Close.svelte.d.ts +26 -0
- package/types/icons/Copy.svelte.d.ts +26 -0
- package/types/icons/EditOff.svelte.d.ts +26 -0
- package/types/icons/ErrorFilled.svelte.d.ts +26 -0
- package/types/icons/IconSearch.svelte.d.ts +26 -0
- package/types/icons/Incomplete.svelte.d.ts +26 -0
- package/types/icons/Information.svelte.d.ts +26 -0
- package/types/icons/InformationFilled.svelte.d.ts +26 -0
- package/types/icons/InformationSquareFilled.svelte.d.ts +27 -0
- package/types/icons/Launch.svelte.d.ts +26 -0
- package/types/icons/Menu.svelte.d.ts +26 -0
- package/types/icons/OverflowMenuHorizontal.svelte.d.ts +27 -0
- package/types/icons/OverflowMenuVertical.svelte.d.ts +26 -0
- package/types/icons/Settings.svelte.d.ts +26 -0
- package/types/icons/Subtract.svelte.d.ts +26 -0
- package/types/icons/Switcher.svelte.d.ts +26 -0
- package/types/icons/View.svelte.d.ts +26 -0
- package/types/icons/ViewOff.svelte.d.ts +26 -0
- package/types/icons/Warning.svelte.d.ts +26 -0
- package/types/icons/WarningAltFilled.svelte.d.ts +26 -0
- package/types/icons/WarningFilled.svelte.d.ts +26 -0
- package/types/index.d.ts +7 -2
- package/types/utils/filterTreeNodes.d.ts +64 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-components-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Svelte implementation of the Carbon Design System",
|
|
6
6
|
"type": "module",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
"css/*.css"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"postinstall": "ibmtelemetry --config=telemetry.yml"
|
|
34
|
-
"prepare": "lefthook install"
|
|
33
|
+
"postinstall": "ibmtelemetry --config=telemetry.yml"
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
36
|
"@ibm/telemetry-js": "^1.5.0",
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {"sm" | "md" | "lg" | "xlg" | "max"} BreakpointSize
|
|
4
4
|
* @typedef {320 | 672 | 1056 | 1312 | 1584} BreakpointValue
|
|
5
|
-
* @event
|
|
5
|
+
* @event change
|
|
6
|
+
* @type {object}
|
|
7
|
+
* @property {BreakpointSize} size
|
|
8
|
+
* @property {BreakpointValue} breakpointValue
|
|
6
9
|
* @slot {{ size: BreakpointSize; sizes: Record<BreakpointSize, boolean>; }}
|
|
7
10
|
*/
|
|
8
11
|
|
|
@@ -38,14 +38,14 @@ export function breakpointObserver() {
|
|
|
38
38
|
if (matches) store.set(size);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
for (const [_size, queryList] of matchers) {
|
|
42
42
|
queryList.addEventListener("change", handleChange);
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
|
|
45
45
|
return () => {
|
|
46
|
-
|
|
46
|
+
for (const [_size, queryList] of matchers) {
|
|
47
47
|
queryList.removeEventListener("change", handleChange);
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pixel sizes of Carbon grid breakpoints.
|
|
3
3
|
* @type {Record<BreakpointSize, BreakpointValue>}
|
|
4
4
|
*/
|
|
5
|
-
export const breakpoints: Record<BreakpointSize, BreakpointValue>;
|
|
5
|
+
export declare const breakpoints: Record<BreakpointSize, BreakpointValue>;
|
|
6
6
|
|
|
7
7
|
export type BreakpointSize = "sm" | "md" | "lg" | "xlg" | "max";
|
|
8
8
|
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
|
+
* @generics {Item extends ComboBoxItem = ComboBoxItem} Item
|
|
4
|
+
* @template {ComboBoxItem} Item
|
|
3
5
|
* @typedef {any} ComboBoxItemId
|
|
4
|
-
* @typedef {
|
|
5
|
-
* @
|
|
6
|
+
* @typedef {object} ComboBoxItem
|
|
7
|
+
* @property {ComboBoxItemId} id
|
|
8
|
+
* @property {string} text
|
|
9
|
+
* @property {boolean} [disabled] - Whether the item is disabled
|
|
10
|
+
* @event select
|
|
11
|
+
* @type {object}
|
|
12
|
+
* @property {ComboBoxItemId} selectedId
|
|
13
|
+
* @property {Item} selectedItem
|
|
6
14
|
* @event {KeyboardEvent | MouseEvent} clear
|
|
7
|
-
* @slot {{ item:
|
|
15
|
+
* @slot {{ item: Item; index: number }}
|
|
8
16
|
*/
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Set the combobox items
|
|
12
|
-
* @type {ReadonlyArray<
|
|
20
|
+
* @type {ReadonlyArray<Item>}
|
|
13
21
|
*/
|
|
14
22
|
export let items = [];
|
|
15
23
|
|
|
16
24
|
/**
|
|
17
25
|
* Override the display of a combobox item
|
|
18
|
-
* @type {(item:
|
|
26
|
+
* @type {(item: Item) => string}
|
|
19
27
|
*/
|
|
20
28
|
export let itemToString = (item) => item.text || item.id;
|
|
21
29
|
|
|
@@ -44,7 +52,7 @@
|
|
|
44
52
|
export let disabled = false;
|
|
45
53
|
|
|
46
54
|
/** Specify the title text of the combobox */
|
|
47
|
-
export let
|
|
55
|
+
export let labelText = "";
|
|
48
56
|
|
|
49
57
|
/** Set to `true` to visually hide the label text */
|
|
50
58
|
export let hideLabel = false;
|
|
@@ -87,9 +95,13 @@
|
|
|
87
95
|
*/
|
|
88
96
|
export let clearFilterOnOpen = false;
|
|
89
97
|
|
|
98
|
+
/** Set to `true` to enable autocomplete with typeahead */
|
|
99
|
+
export let typeahead = false;
|
|
100
|
+
|
|
90
101
|
/**
|
|
91
|
-
* Determine if an item should be filtered given the current combobox value
|
|
92
|
-
*
|
|
102
|
+
* Determine if an item should be filtered given the current combobox value.
|
|
103
|
+
* Will be ignored if `typeahead` is enabled.
|
|
104
|
+
* @type {(item: Item, value: string) => boolean}
|
|
93
105
|
*/
|
|
94
106
|
export let shouldFilterItem = () => true;
|
|
95
107
|
|
|
@@ -141,10 +153,29 @@
|
|
|
141
153
|
let prevSelectedId = null;
|
|
142
154
|
let highlightedIndex = -1;
|
|
143
155
|
let valueBeforeOpen = "";
|
|
156
|
+
let prevInputLength = 0;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @param {Item} item
|
|
160
|
+
* @param {string} inputValue
|
|
161
|
+
* @returns {boolean}
|
|
162
|
+
*/
|
|
163
|
+
function autocompleteCustomFilter(item, inputValue) {
|
|
164
|
+
if (inputValue.length === 0) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const lowercaseItem = item.text.toLowerCase();
|
|
169
|
+
const lowercaseInput = inputValue.toLowerCase();
|
|
170
|
+
|
|
171
|
+
return lowercaseItem.startsWith(lowercaseInput);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
$: filterFn = typeahead ? autocompleteCustomFilter : shouldFilterItem;
|
|
144
175
|
|
|
145
176
|
function change(dir) {
|
|
146
177
|
let index = highlightedIndex + dir;
|
|
147
|
-
let _items =
|
|
178
|
+
let _items = filteredItems?.length ? filteredItems : items;
|
|
148
179
|
if (_items.length === 0) return;
|
|
149
180
|
if (index < 0) {
|
|
150
181
|
index = _items.length - 1;
|
|
@@ -193,19 +224,11 @@
|
|
|
193
224
|
value = "";
|
|
194
225
|
}
|
|
195
226
|
|
|
196
|
-
filteredItems = items.filter((item) =>
|
|
227
|
+
filteredItems = items.filter((item) => filterFn(item, value));
|
|
197
228
|
} else {
|
|
198
229
|
highlightedIndex = -1;
|
|
199
230
|
filteredItems = [];
|
|
200
|
-
if (
|
|
201
|
-
selectedId = undefined;
|
|
202
|
-
// Only reset value if the input is not focused and allowCustomValue is false
|
|
203
|
-
if (!ref.contains(document.activeElement) && !allowCustomValue) {
|
|
204
|
-
value = "";
|
|
205
|
-
}
|
|
206
|
-
highlightedIndex = -1;
|
|
207
|
-
highlightedId = undefined;
|
|
208
|
-
} else {
|
|
231
|
+
if (selectedItem) {
|
|
209
232
|
// Only set value if the input is not focused
|
|
210
233
|
if (!ref.contains(document.activeElement)) {
|
|
211
234
|
// Restore the value if clearFilterOnOpen was used and no new selection was made
|
|
@@ -217,6 +240,14 @@
|
|
|
217
240
|
}
|
|
218
241
|
valueBeforeOpen = "";
|
|
219
242
|
}
|
|
243
|
+
} else {
|
|
244
|
+
selectedId = undefined;
|
|
245
|
+
// Only reset value if the input is not focused and allowCustomValue is false
|
|
246
|
+
if (!ref.contains(document.activeElement) && !allowCustomValue) {
|
|
247
|
+
value = "";
|
|
248
|
+
}
|
|
249
|
+
highlightedIndex = -1;
|
|
250
|
+
highlightedId = undefined;
|
|
220
251
|
}
|
|
221
252
|
}
|
|
222
253
|
});
|
|
@@ -243,7 +274,25 @@
|
|
|
243
274
|
$: menuId = `menu-${id}`;
|
|
244
275
|
$: comboId = `combo-${id}`;
|
|
245
276
|
$: highlightedId = items[highlightedIndex] ? items[highlightedIndex].id : 0;
|
|
246
|
-
$: filteredItems = items.filter((item) =>
|
|
277
|
+
$: filteredItems = items.filter((item) => filterFn(item, value));
|
|
278
|
+
|
|
279
|
+
$: if (typeahead) {
|
|
280
|
+
const showNewSuggestion =
|
|
281
|
+
value.length > prevInputLength && filteredItems.length > 0;
|
|
282
|
+
|
|
283
|
+
prevInputLength = value.length;
|
|
284
|
+
|
|
285
|
+
if (ref && showNewSuggestion) {
|
|
286
|
+
const suggestion = itemToString(filteredItems[0]).slice(value.length);
|
|
287
|
+
const selectionStart = value.length;
|
|
288
|
+
const selectionEnd = selectionStart + suggestion.length;
|
|
289
|
+
|
|
290
|
+
tick().then(() => {
|
|
291
|
+
ref.value = value + suggestion;
|
|
292
|
+
ref.setSelectionRange(selectionStart, selectionEnd);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
247
296
|
</script>
|
|
248
297
|
|
|
249
298
|
<svelte:window
|
|
@@ -255,15 +304,15 @@
|
|
|
255
304
|
/>
|
|
256
305
|
|
|
257
306
|
<div class:bx--list-box__wrapper={true}>
|
|
258
|
-
{#if
|
|
307
|
+
{#if labelText || $$slots.labelText}
|
|
259
308
|
<label
|
|
260
309
|
for={id}
|
|
261
310
|
class:bx--label={true}
|
|
262
311
|
class:bx--label--disabled={disabled}
|
|
263
312
|
class:bx--visually-hidden={hideLabel}
|
|
264
313
|
>
|
|
265
|
-
<slot name="
|
|
266
|
-
{
|
|
314
|
+
<slot name="labelText">
|
|
315
|
+
{labelText}
|
|
267
316
|
</slot>
|
|
268
317
|
</label>
|
|
269
318
|
{/if}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
|
-
* @event
|
|
4
|
-
* @
|
|
3
|
+
* @event close
|
|
4
|
+
* @property {"escape-key" | "outside-click" | "close-button"} trigger
|
|
5
|
+
* @event transitionend
|
|
6
|
+
* @property {boolean} open
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -138,6 +140,7 @@
|
|
|
138
140
|
class:bx--modal={true}
|
|
139
141
|
class:is-visible={open}
|
|
140
142
|
class:bx--modal--danger={danger}
|
|
143
|
+
inert={open ? undefined : true}
|
|
141
144
|
{...$$restProps}
|
|
142
145
|
on:keydown
|
|
143
146
|
on:keydown={(e) => {
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
|
|
99
99
|
$: if (target != null) {
|
|
100
100
|
if (Array.isArray(target)) {
|
|
101
|
-
|
|
101
|
+
for (const node of target) {
|
|
102
102
|
node?.addEventListener("contextmenu", openMenu);
|
|
103
|
-
}
|
|
103
|
+
}
|
|
104
104
|
} else {
|
|
105
105
|
target.addEventListener("contextmenu", openMenu);
|
|
106
106
|
}
|
|
@@ -110,9 +110,9 @@
|
|
|
110
110
|
return () => {
|
|
111
111
|
if (target != null) {
|
|
112
112
|
if (Array.isArray(target)) {
|
|
113
|
-
|
|
113
|
+
for (const node of target) {
|
|
114
114
|
node?.removeEventListener("contextmenu", openMenu);
|
|
115
|
-
}
|
|
115
|
+
}
|
|
116
116
|
} else {
|
|
117
117
|
target.removeEventListener("contextmenu", openMenu);
|
|
118
118
|
}
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
if (!$hasPopup && options[focusIndex]) options[focusIndex].focus();
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
$: level =
|
|
156
|
+
$: level = ctx ? 2 : 1;
|
|
157
157
|
$: currentIndex.set(focusIndex);
|
|
158
158
|
</script>
|
|
159
159
|
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
* @type {(data: { id: string }) => void}
|
|
27
27
|
*/
|
|
28
28
|
const toggleOption = ({ id }) => {
|
|
29
|
-
if (
|
|
30
|
-
selectedIds = [...selectedIds, id];
|
|
31
|
-
} else {
|
|
29
|
+
if (selectedIds.includes(id)) {
|
|
32
30
|
selectedIds = selectedIds.filter((_) => _ !== id);
|
|
31
|
+
} else {
|
|
32
|
+
selectedIds = [...selectedIds, id];
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -4,45 +4,64 @@
|
|
|
4
4
|
* @template {DataTableRow} Row
|
|
5
5
|
* @typedef {import('./DataTableTypes.d.ts').PropertyPath<Row>} DataTableKey<Row=DataTableRow>
|
|
6
6
|
* @typedef {any} DataTableValue
|
|
7
|
-
* @typedef {
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* }
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* minWidth?: string;
|
|
24
|
-
* }} DataTableNonEmptyHeader<Row=DataTableRow>
|
|
7
|
+
* @typedef {object} DataTableEmptyHeader<Row=DataTableRow>
|
|
8
|
+
* @property {DataTableKey<Row> | (string & {})} key
|
|
9
|
+
* @property {boolean} empty - Whether the header is empty
|
|
10
|
+
* @property {(item: DataTableValue, row: Row) => DataTableValue} [display]
|
|
11
|
+
* @property {false | ((a: DataTableValue, b: DataTableValue) => number)} [sort]
|
|
12
|
+
* @property {boolean} [columnMenu] - Whether the column menu is enabled
|
|
13
|
+
* @property {string} [width]
|
|
14
|
+
* @property {string} [minWidth]
|
|
15
|
+
* @typedef {object} DataTableNonEmptyHeader<Row=DataTableRow>
|
|
16
|
+
* @property {DataTableKey<Row>} key
|
|
17
|
+
* @property {DataTableValue} value
|
|
18
|
+
* @property {(item: DataTableValue, row: Row) => DataTableValue} [display]
|
|
19
|
+
* @property {false | ((a: DataTableValue, b: DataTableValue) => number)} [sort]
|
|
20
|
+
* @property {boolean} [columnMenu] - Whether the column menu is enabled
|
|
21
|
+
* @property {string} [width]
|
|
22
|
+
* @property {string} [minWidth]
|
|
25
23
|
* @typedef {DataTableNonEmptyHeader<Row> | DataTableEmptyHeader<Row>} DataTableHeader<Row=DataTableRow>
|
|
26
24
|
* @typedef {{ id: any; [key: string]: DataTableValue; }} DataTableRow
|
|
27
25
|
* @typedef {any} DataTableRowId
|
|
28
|
-
* @typedef {
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* }} DataTableCell<Row=DataTableRow>
|
|
26
|
+
* @typedef {object} DataTableCell<Row=DataTableRow>
|
|
27
|
+
* @property {DataTableKey<Row> | (string & {})} key
|
|
28
|
+
* @property {DataTableValue} value
|
|
29
|
+
* @property {(item: DataTableValue, row: DataTableRow) => DataTableValue} [display]
|
|
33
30
|
* @slot {{ row: Row; rowSelected: boolean; }} expanded-row
|
|
34
31
|
* @slot {{ header: DataTableNonEmptyHeader; }} cell-header
|
|
35
32
|
* @slot {{ row: Row; cell: DataTableCell<Row>; rowIndex: number; cellIndex: number; rowSelected: boolean; rowExpanded: boolean; }} cell
|
|
36
|
-
* @event
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
33
|
+
* @event click
|
|
34
|
+
* @type {object}
|
|
35
|
+
* @property {DataTableHeader<Row>} [header]
|
|
36
|
+
* @property {Row} [row]
|
|
37
|
+
* @property {DataTableCell<Row>} [cell]
|
|
38
|
+
* @event click:header--expand
|
|
39
|
+
* @type {object}
|
|
40
|
+
* @property {boolean} expanded
|
|
41
|
+
* @event click:header
|
|
42
|
+
* @type {object}
|
|
43
|
+
* @property {DataTableHeader<Row>} header
|
|
44
|
+
* @property {"ascending" | "descending" | "none"} [sortDirection]
|
|
45
|
+
* @event click:header--select
|
|
46
|
+
* @type {object}
|
|
47
|
+
* @property {boolean} indeterminate
|
|
48
|
+
* @property {boolean} selected
|
|
49
|
+
* @event click:row
|
|
50
|
+
* @type {object}
|
|
51
|
+
* @property {Row} row
|
|
41
52
|
* @event {Row} mouseenter:row
|
|
42
53
|
* @event {Row} mouseleave:row
|
|
43
|
-
* @event
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
54
|
+
* @event click:row--expand
|
|
55
|
+
* @type {object}
|
|
56
|
+
* @property {boolean} expanded
|
|
57
|
+
* @property {Row} row
|
|
58
|
+
* @event click:row--select
|
|
59
|
+
* @type {object}
|
|
60
|
+
* @property {boolean} selected
|
|
61
|
+
* @property {Row} row
|
|
62
|
+
* @event click:cell
|
|
63
|
+
* @type {object}
|
|
64
|
+
* @property {DataTableCell<Row>} cell
|
|
46
65
|
* @restProps {div}
|
|
47
66
|
*/
|
|
48
67
|
|
|
@@ -169,6 +188,8 @@
|
|
|
169
188
|
import TableHeader from "./TableHeader.svelte";
|
|
170
189
|
import TableRow from "./TableRow.svelte";
|
|
171
190
|
|
|
191
|
+
const PATH_SPLIT_REGEX = /[.[\]'"]/;
|
|
192
|
+
|
|
172
193
|
const sortDirectionMap = {
|
|
173
194
|
none: "ascending",
|
|
174
195
|
ascending: "descending",
|
|
@@ -198,7 +219,7 @@
|
|
|
198
219
|
const resolvePath = (object, path) => {
|
|
199
220
|
if (path in object) return object[path];
|
|
200
221
|
return path
|
|
201
|
-
.split(
|
|
222
|
+
.split(PATH_SPLIT_REGEX)
|
|
202
223
|
.filter((p) => p)
|
|
203
224
|
.reduce((o, p) => (o && typeof o === "object" ? o[p] : o), object);
|
|
204
225
|
};
|
|
@@ -207,9 +207,9 @@
|
|
|
207
207
|
calendar.set("maxDate", maxDate);
|
|
208
208
|
calendar.set("locale", locale);
|
|
209
209
|
calendar.set("dateFormat", dateFormat);
|
|
210
|
-
|
|
210
|
+
for (const [_option, value] of Object.entries(flatpickrProps)) {
|
|
211
211
|
calendar.set(options, value);
|
|
212
|
-
}
|
|
212
|
+
}
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -17,19 +17,19 @@ function updateClasses(instance) {
|
|
|
17
17
|
.classList.add("bx--date-picker__month");
|
|
18
18
|
|
|
19
19
|
weekdayContainer.classList.add("bx--date-picker__weekdays");
|
|
20
|
-
weekdayContainer.querySelectorAll(".flatpickr-weekday")
|
|
20
|
+
for (const node of weekdayContainer.querySelectorAll(".flatpickr-weekday")) {
|
|
21
21
|
node.classList.add("bx--date-picker__weekday");
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
daysContainer.classList.add("bx--date-picker__days");
|
|
25
|
-
days.querySelectorAll(".flatpickr-day")
|
|
25
|
+
for (const node of days.querySelectorAll(".flatpickr-day")) {
|
|
26
26
|
node.classList.add("bx--date-picker__day");
|
|
27
27
|
if (node.classList.contains("today") && selectedDates.length > 0) {
|
|
28
28
|
node.classList.add("no-border");
|
|
29
29
|
} else if (node.classList.contains("today") && selectedDates.length === 0) {
|
|
30
30
|
node.classList.remove("no-border");
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function updateMonthNode(instance) {
|
|
@@ -51,11 +51,12 @@ async function createCalendar({ options, base, input, dispatch }) {
|
|
|
51
51
|
let locale = options.locale;
|
|
52
52
|
|
|
53
53
|
if (options.locale === "en" && l10n && l10n.en) {
|
|
54
|
-
l10n.en.weekdays.shorthand.
|
|
54
|
+
for (let index = 0; index < l10n.en.weekdays.shorthand.length; index++) {
|
|
55
|
+
const _ = l10n.en.weekdays.shorthand[index];
|
|
55
56
|
const shorthand = _.slice(0, 2);
|
|
56
57
|
l10n.en.weekdays.shorthand[index] =
|
|
57
58
|
shorthand === "Th" ? "Th" : shorthand.charAt(0);
|
|
58
|
-
}
|
|
59
|
+
}
|
|
59
60
|
|
|
60
61
|
locale = l10n.en;
|
|
61
62
|
}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
|
+
* @generics {Item extends DropdownItem = DropdownItem} Item
|
|
4
|
+
* @template {DropdownItem} Item
|
|
3
5
|
* @typedef {any} DropdownItemId
|
|
4
6
|
* @typedef {string} DropdownItemText
|
|
5
|
-
* @typedef {
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
7
|
+
* @typedef {object} DropdownItem
|
|
8
|
+
* @property {DropdownItemId} id
|
|
9
|
+
* @property {DropdownItemText} text
|
|
10
|
+
* @property {boolean} [disabled] - Whether the item is disabled
|
|
11
|
+
* @event select
|
|
12
|
+
* @type {object}
|
|
13
|
+
* @property {DropdownItemId} selectedId
|
|
14
|
+
* @property {Item} selectedItem
|
|
15
|
+
* @slot {{ item: Item; index: number; }}
|
|
8
16
|
*/
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Set the dropdown items
|
|
12
|
-
* @type {ReadonlyArray<
|
|
20
|
+
* @type {ReadonlyArray<Item>}
|
|
13
21
|
*/
|
|
14
22
|
export let items = [];
|
|
15
23
|
|
|
16
24
|
/**
|
|
17
25
|
* Override the display of a dropdown item
|
|
18
|
-
* @type {(item:
|
|
26
|
+
* @type {(item: Item) => string}
|
|
19
27
|
*/
|
|
20
28
|
export let itemToString = (item) => item.text || item.id;
|
|
21
29
|
|
|
@@ -53,7 +61,7 @@
|
|
|
53
61
|
export let disabled = false;
|
|
54
62
|
|
|
55
63
|
/** Specify the title text */
|
|
56
|
-
export let
|
|
64
|
+
export let labelText = "";
|
|
57
65
|
|
|
58
66
|
/** Set to `true` to indicate an invalid state */
|
|
59
67
|
export let invalid = false;
|
|
@@ -169,14 +177,14 @@
|
|
|
169
177
|
class:bx--dropdown__wrapper--inline--invalid={inline && invalid}
|
|
170
178
|
{...$$restProps}
|
|
171
179
|
>
|
|
172
|
-
{#if
|
|
180
|
+
{#if labelText}
|
|
173
181
|
<label
|
|
174
182
|
for={id}
|
|
175
183
|
class:bx--label={true}
|
|
176
184
|
class:bx--label--disabled={disabled}
|
|
177
185
|
class:bx--visually-hidden={hideLabel}
|
|
178
186
|
>
|
|
179
|
-
{
|
|
187
|
+
{labelText}
|
|
180
188
|
</label>
|
|
181
189
|
{/if}
|
|
182
190
|
<ListBox
|
|
@@ -185,10 +193,10 @@
|
|
|
185
193
|
{size}
|
|
186
194
|
{name}
|
|
187
195
|
aria-label={$$props["aria-label"]}
|
|
188
|
-
class="bx--dropdown
|
|
189
|
-
{direction === 'top' && 'bx--list-box--up'}
|
|
190
|
-
{invalid && 'bx--dropdown--invalid'}
|
|
191
|
-
{!invalid && warn && 'bx--dropdown--warning'}
|
|
196
|
+
class="bx--dropdown
|
|
197
|
+
{direction === 'top' && 'bx--list-box--up'}
|
|
198
|
+
{invalid && 'bx--dropdown--invalid'}
|
|
199
|
+
{!invalid && warn && 'bx--dropdown--warning'}
|
|
192
200
|
{open && 'bx--dropdown--open'}
|
|
193
201
|
{size === 'sm' && 'bx--dropdown--sm'}
|
|
194
202
|
{size === 'xl' && 'bx--dropdown--xl'}
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
// Sync input files with component files array.
|
|
70
70
|
try {
|
|
71
71
|
const dt = new DataTransfer();
|
|
72
|
-
|
|
72
|
+
for (const file of files) {
|
|
73
73
|
dt.items.add(file);
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
ref.files = dt.files;
|
|
76
76
|
} catch {
|
|
77
77
|
// Fail open if DataTransfer API is not supported.
|
package/src/Grid/Column.svelte
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {boolean | number} ColumnSize
|
|
4
|
-
* @typedef
|
|
4
|
+
* @typedef ColumnSizeDescriptor
|
|
5
|
+
* @property {ColumnSize} [span]
|
|
6
|
+
* @property {number} offset
|
|
5
7
|
* @typedef {ColumnSize | ColumnSizeDescriptor} ColumnBreakpoint
|
|
6
8
|
* @restProps {div}
|
|
7
9
|
* @slot {{props: { class: string; [key: string]: any; }}}
|
package/src/Modal/Modal.svelte
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
|
-
* @event
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
3
|
+
* @event close
|
|
4
|
+
* @type {object}
|
|
5
|
+
* @property {"escape-key" | "outside-click" | "close-button"} trigger
|
|
6
|
+
* @event transitionend
|
|
7
|
+
* @type {object}
|
|
8
|
+
* @property {boolean} open
|
|
9
|
+
* @event click:button--secondary
|
|
10
|
+
* @type {object}
|
|
11
|
+
* @property {string} text
|
|
6
12
|
*/
|
|
7
13
|
|
|
8
14
|
/**
|
|
@@ -156,6 +162,7 @@
|
|
|
156
162
|
class:bx--modal-tall={!passiveModal}
|
|
157
163
|
class:is-visible={open}
|
|
158
164
|
class:bx--modal--danger={danger}
|
|
165
|
+
inert={open ? undefined : true}
|
|
159
166
|
{...$$restProps}
|
|
160
167
|
on:keydown
|
|
161
168
|
on:keydown={(e) => {
|