carbon-components-svelte 0.90.3 → 0.91.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 +24 -16
- package/src/ComposedModal/ComposedModal.svelte +4 -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 +13 -5
- 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 +9 -3
- package/src/MultiSelect/MultiSelect.svelte +17 -8
- package/src/Notification/InlineNotification.svelte +2 -1
- package/src/Notification/ToastNotification.svelte +2 -1
- package/src/NumberInput/NumberInput.svelte +9 -9
- 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 +15 -20
- 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 +15 -18
- 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 +18 -24
- package/types/Notification/NotificationButton.svelte.d.ts +1 -1
- package/types/NumberInput/NumberInput.svelte.d.ts +0 -1
- 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.91.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
|
|
|
@@ -89,7 +97,7 @@
|
|
|
89
97
|
|
|
90
98
|
/**
|
|
91
99
|
* Determine if an item should be filtered given the current combobox value
|
|
92
|
-
* @type {(item:
|
|
100
|
+
* @type {(item: Item, value: string) => boolean}
|
|
93
101
|
*/
|
|
94
102
|
export let shouldFilterItem = () => true;
|
|
95
103
|
|
|
@@ -144,7 +152,7 @@
|
|
|
144
152
|
|
|
145
153
|
function change(dir) {
|
|
146
154
|
let index = highlightedIndex + dir;
|
|
147
|
-
let _items =
|
|
155
|
+
let _items = filteredItems?.length ? filteredItems : items;
|
|
148
156
|
if (_items.length === 0) return;
|
|
149
157
|
if (index < 0) {
|
|
150
158
|
index = _items.length - 1;
|
|
@@ -197,15 +205,7 @@
|
|
|
197
205
|
} else {
|
|
198
206
|
highlightedIndex = -1;
|
|
199
207
|
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 {
|
|
208
|
+
if (selectedItem) {
|
|
209
209
|
// Only set value if the input is not focused
|
|
210
210
|
if (!ref.contains(document.activeElement)) {
|
|
211
211
|
// Restore the value if clearFilterOnOpen was used and no new selection was made
|
|
@@ -217,6 +217,14 @@
|
|
|
217
217
|
}
|
|
218
218
|
valueBeforeOpen = "";
|
|
219
219
|
}
|
|
220
|
+
} else {
|
|
221
|
+
selectedId = undefined;
|
|
222
|
+
// Only reset value if the input is not focused and allowCustomValue is false
|
|
223
|
+
if (!ref.contains(document.activeElement) && !allowCustomValue) {
|
|
224
|
+
value = "";
|
|
225
|
+
}
|
|
226
|
+
highlightedIndex = -1;
|
|
227
|
+
highlightedId = undefined;
|
|
220
228
|
}
|
|
221
229
|
}
|
|
222
230
|
});
|
|
@@ -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
|
/**
|
|
@@ -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
|
|
|
@@ -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
|
/**
|
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
|
+
* @generics {Item extends MultiSelectItem = MultiSelectItem} Item
|
|
4
|
+
* @template {MultiSelectItem} Item
|
|
3
5
|
* @typedef {any} MultiSelectItemId
|
|
4
6
|
* @typedef {string} MultiSelectItemText
|
|
5
|
-
* @typedef {
|
|
6
|
-
* @
|
|
7
|
+
* @typedef {object} MultiSelectItem
|
|
8
|
+
* @property {MultiSelectItemId} id
|
|
9
|
+
* @property {MultiSelectItemText} text
|
|
10
|
+
* @property {boolean} [disabled] - Whether the item is disabled
|
|
11
|
+
* @event select
|
|
12
|
+
* @type {object}
|
|
13
|
+
* @property {MultiSelectItemId[]} selectedIds
|
|
14
|
+
* @property {Item[]} selected
|
|
15
|
+
* @property {Item[]} unselected
|
|
7
16
|
* @event {null} clear
|
|
8
17
|
* @event {FocusEvent | CustomEvent<FocusEvent>} blur
|
|
9
|
-
* @slot {{ item:
|
|
18
|
+
* @slot {{ item: Item; index: number }}
|
|
10
19
|
*/
|
|
11
20
|
|
|
12
21
|
/**
|
|
13
22
|
* Set the multiselect items
|
|
14
|
-
* @type {ReadonlyArray<
|
|
23
|
+
* @type {ReadonlyArray<Item>}
|
|
15
24
|
*/
|
|
16
25
|
export let items = [];
|
|
17
26
|
|
|
18
27
|
/**
|
|
19
28
|
* Override the display of a multiselect item
|
|
20
|
-
* @type {(item:
|
|
29
|
+
* @type {(item: Item) => any}
|
|
21
30
|
*/
|
|
22
31
|
export let itemToString = (item) => item.text || item.id;
|
|
23
32
|
|
|
24
33
|
/**
|
|
25
34
|
* Override the item name, title, labelText, or value passed to the user-selectable checkbox input as well as the hidden inputs.
|
|
26
|
-
* @type {(item:
|
|
35
|
+
* @type {(item: Item) => { name?: string; labelText?: any; title?: string; value?: string }}
|
|
27
36
|
*/
|
|
28
37
|
export let itemToInput = (_item) => {};
|
|
29
38
|
|
|
@@ -69,7 +78,7 @@
|
|
|
69
78
|
/**
|
|
70
79
|
* Override the filtering logic
|
|
71
80
|
* The default filtering is an exact string comparison
|
|
72
|
-
* @type {(item:
|
|
81
|
+
* @type {(item: Item, value: string) => boolean}
|
|
73
82
|
*/
|
|
74
83
|
export let filterItem = (item, value) =>
|
|
75
84
|
item.text.toLowerCase().includes(value.trim().toLowerCase());
|
|
@@ -89,7 +98,7 @@
|
|
|
89
98
|
/**
|
|
90
99
|
* Override the sorting logic
|
|
91
100
|
* The default sorting compare the item text value
|
|
92
|
-
* @type {((a:
|
|
101
|
+
* @type {((a: Item, b: Item) => Item) | (() => void)}
|
|
93
102
|
*/
|
|
94
103
|
export let sortItem = (a, b) =>
|
|
95
104
|
a.text.localeCompare(b.text, locale, { numeric: true });
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
|
|
162
162
|
$: incrementLabel = translateWithId("increment");
|
|
163
163
|
$: decrementLabel = translateWithId("decrement");
|
|
164
|
-
$:
|
|
164
|
+
$: hasError =
|
|
165
165
|
(invalid && !readonly) ||
|
|
166
166
|
(!allowEmpty && value == null) ||
|
|
167
167
|
value > max ||
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
on:mouseleave
|
|
231
231
|
>
|
|
232
232
|
<div
|
|
233
|
-
data-invalid={
|
|
233
|
+
data-invalid={hasError || undefined}
|
|
234
234
|
class:bx--number={true}
|
|
235
235
|
class:bx--number--helpertext={true}
|
|
236
236
|
class:bx--number--readonly={readonly}
|
|
@@ -261,8 +261,8 @@
|
|
|
261
261
|
type="text"
|
|
262
262
|
inputmode="decimal"
|
|
263
263
|
aria-describedby={errorId}
|
|
264
|
-
data-invalid={
|
|
265
|
-
aria-invalid={
|
|
264
|
+
data-invalid={hasError || undefined}
|
|
265
|
+
aria-invalid={hasError || undefined}
|
|
266
266
|
aria-label={label ? undefined : ariaLabel}
|
|
267
267
|
{disabled}
|
|
268
268
|
{id}
|
|
@@ -284,8 +284,8 @@
|
|
|
284
284
|
type="number"
|
|
285
285
|
pattern="[0-9]*"
|
|
286
286
|
aria-describedby={errorId}
|
|
287
|
-
data-invalid={
|
|
288
|
-
aria-invalid={
|
|
287
|
+
data-invalid={hasError || undefined}
|
|
288
|
+
aria-invalid={hasError || undefined}
|
|
289
289
|
aria-label={label ? undefined : ariaLabel}
|
|
290
290
|
{disabled}
|
|
291
291
|
{id}
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
</div>
|
|
354
354
|
{/if}
|
|
355
355
|
</div>
|
|
356
|
-
{#if !
|
|
356
|
+
{#if !hasError && !warn && helperText}
|
|
357
357
|
<div
|
|
358
358
|
class:bx--form__helper-text={true}
|
|
359
359
|
class:bx--form__helper-text--disabled={disabled}
|
|
@@ -361,12 +361,12 @@
|
|
|
361
361
|
{helperText}
|
|
362
362
|
</div>
|
|
363
363
|
{/if}
|
|
364
|
-
{#if
|
|
364
|
+
{#if hasError}
|
|
365
365
|
<div id={errorId} class:bx--form-requirement={true}>
|
|
366
366
|
{invalidText}
|
|
367
367
|
</div>
|
|
368
368
|
{/if}
|
|
369
|
-
{#if !
|
|
369
|
+
{#if !hasError && warn}
|
|
370
370
|
<div id={errorId} class:bx--form-requirement={true}>{warnText}</div>
|
|
371
371
|
{/if}
|
|
372
372
|
</div>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
|
-
* @event
|
|
3
|
+
* @event close
|
|
4
|
+
* @property {number} [index]
|
|
5
|
+
* @property {string} [text]
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -32,7 +34,6 @@
|
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Specify the icon to render.
|
|
35
|
-
* Defaults to `<OverflowMenuVertical />`
|
|
36
37
|
* @type {any}
|
|
37
38
|
*/
|
|
38
39
|
export let icon = OverflowMenuVertical;
|