From 653a601f9be09b1410ad5097901e57cae535895e Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Fri, 14 Jan 2022 11:29:37 -1000 Subject: [PATCH] Revert "Refactor prop types to omit redundant `null` for `null | HTMLElement` types" (#1008) #996 --- COMPONENT_INDEX.md | 36 +++++++++++------------ docs/src/COMPONENT_API.json | 10 +++---- src/ComboBox/ComboBox.svelte | 2 +- src/ContextMenu/ContextMenu.svelte | 2 +- src/DataTable/ToolbarSearch.svelte | 2 +- src/MultiSelect/MultiSelect.svelte | 4 +-- src/TreeView/TreeViewNode.svelte | 2 +- tests/ComboBox.test.svelte | 2 -- tests/ContextMenu.test.svelte | 5 +--- types/ComboBox/ComboBox.svelte.d.ts | 2 +- types/ContextMenu/ContextMenu.svelte.d.ts | 2 +- types/DataTable/ToolbarSearch.svelte.d.ts | 2 +- types/MultiSelect/MultiSelect.svelte.d.ts | 4 +-- 13 files changed, 35 insertions(+), 40 deletions(-) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 2b1cc6f8..0941acfa 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -658,7 +658,7 @@ export interface ComboBoxItem { | Prop name | Kind | Reactive | Type | Default value | Description | | :--------------- | :-------------------- | :------- | :---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| listRef | let | Yes | HTMLDivElement | null | Obtain a reference to the list HTML element | +| listRef | let | Yes | null | HTMLDivElement | null | Obtain a reference to the list HTML element | | ref | let | Yes | null | HTMLInputElement | null | Obtain a reference to the input HTML element | | open | let | Yes | boolean | false | Set to `true` to open the combobox menu dropdown | | value | let | Yes | string | "" | Specify the selected combobox value | @@ -781,13 +781,13 @@ None. ### Props -| Prop name | Kind | Reactive | Type | Default value | Description | -| :-------- | :--------------- | :------- | :-------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| ref | let | Yes | null | HTMLUListElement | null | Obtain a reference to the unordered list HTML element | -| y | let | Yes | number | 0 | Specify the vertical offset of the menu position | -| x | let | Yes | number | 0 | Specify the horizontal offset of the menu position | -| open | let | Yes | boolean | false | Set to `true` to open the menu
Either `x` and `y` must be greater than zero | -| target | let | No | HTMLElement | HTMLElement[] | null | Specify an element or list of elements to trigger the context menu.
If no element is specified, the context menu applies to the entire window | +| Prop name | Kind | Reactive | Type | Default value | Description | +| :-------- | :--------------- | :------- | :-------------------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| ref | let | Yes | null | HTMLUListElement | null | Obtain a reference to the unordered list HTML element | +| y | let | Yes | number | 0 | Specify the vertical offset of the menu position | +| x | let | Yes | number | 0 | Specify the horizontal offset of the menu position | +| open | let | Yes | boolean | false | Set to `true` to open the menu
Either `x` and `y` must be greater than zero | +| target | let | No | null | HTMLElement | HTMLElement[] | null | Specify an element or list of elements to trigger the context menu.
If no element is specified, the context menu applies to the entire window | ### Slots @@ -2413,8 +2413,8 @@ export interface MultiSelectItem { | Prop name | Kind | Reactive | Type | Default value | Description | | :---------------- | :--------------- | :------- | :--------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | -| selectionRef | let | Yes | HTMLDivElement | null | Obtain a reference to the selection element | -| fieldRef | let | Yes | HTMLDivElement | null | Obtain a reference to the field box element | +| selectionRef | let | Yes | null | HTMLDivElement | null | Obtain a reference to the selection element | +| fieldRef | let | Yes | null | HTMLDivElement | null | Obtain a reference to the field box element | | multiSelectRef | let | Yes | null | HTMLDivElement | null | Obtain a reference to the outer div element | | inputRef | let | Yes | null | HTMLInputElement | null | Obtain a reference to the input HTML element | | open | let | Yes | boolean | false | Set to `true` to open the dropdown | @@ -4614,14 +4614,14 @@ None. ### Props -| Prop name | Kind | Reactive | Type | Default value | Description | -| :--------- | :--------------- | :------- | :-------------------------------- | ------------------ | --------------------------------------------- | -| ref | let | Yes | HTMLInputElement | null | Obtain a reference to the input HTML element | -| expanded | let | Yes | boolean | false | Set to `true` to expand the search bar | -| value | let | Yes | number | string | "" | Specify the value of the search input | -| persistent | let | No | boolean | false | Set to `true` to keep the search bar expanded | -| disabled | let | No | boolean | false | Set to `true` to disable the search bar | -| tabindex | let | No | string | "0" | Specify the tabindex | +| Prop name | Kind | Reactive | Type | Default value | Description | +| :--------- | :--------------- | :------- | :---------------------------------------- | ------------------ | --------------------------------------------- | +| ref | let | Yes | null | HTMLInputElement | null | Obtain a reference to the input HTML element | +| expanded | let | Yes | boolean | false | Set to `true` to expand the search bar | +| value | let | Yes | number | string | "" | Specify the value of the search input | +| persistent | let | No | boolean | false | Set to `true` to keep the search bar expanded | +| disabled | let | No | boolean | false | Set to `true` to disable the search bar | +| tabindex | let | No | string | "0" | Specify the tabindex | ### Slots diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index ed3b3c5e..d9ca5a92 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -1604,7 +1604,7 @@ "name": "listRef", "kind": "let", "description": "Obtain a reference to the list HTML element", - "type": "HTMLDivElement", + "type": "null | HTMLDivElement", "value": "null", "isFunction": false, "isFunctionDeclaration": false, @@ -1824,7 +1824,7 @@ "name": "target", "kind": "let", "description": "Specify an element or list of elements to trigger the context menu.\nIf no element is specified, the context menu applies to the entire window", - "type": "HTMLElement | HTMLElement[]", + "type": "null | HTMLElement | HTMLElement[]", "value": "null", "isFunction": false, "isFunctionDeclaration": false, @@ -6700,7 +6700,7 @@ "name": "fieldRef", "kind": "let", "description": "Obtain a reference to the field box element", - "type": "HTMLDivElement", + "type": "null | HTMLDivElement", "value": "null", "isFunction": false, "isFunctionDeclaration": false, @@ -6711,7 +6711,7 @@ "name": "selectionRef", "kind": "let", "description": "Obtain a reference to the selection element", - "type": "HTMLDivElement", + "type": "null | HTMLDivElement", "value": "null", "isFunction": false, "isFunctionDeclaration": false, @@ -12818,7 +12818,7 @@ "name": "ref", "kind": "let", "description": "Obtain a reference to the input HTML element", - "type": "HTMLInputElement", + "type": "null | HTMLInputElement", "value": "null", "isFunction": false, "isFunctionDeclaration": false, diff --git a/src/ComboBox/ComboBox.svelte b/src/ComboBox/ComboBox.svelte index 9576206d..2fb120c3 100644 --- a/src/ComboBox/ComboBox.svelte +++ b/src/ComboBox/ComboBox.svelte @@ -90,7 +90,7 @@ /** * Obtain a reference to the list HTML element - * @type {HTMLDivElement} + * @type {null | HTMLDivElement} */ export let listRef = null; diff --git a/src/ContextMenu/ContextMenu.svelte b/src/ContextMenu/ContextMenu.svelte index 9397688e..c1490844 100644 --- a/src/ContextMenu/ContextMenu.svelte +++ b/src/ContextMenu/ContextMenu.svelte @@ -6,7 +6,7 @@ /** * Specify an element or list of elements to trigger the context menu. * If no element is specified, the context menu applies to the entire window - * @type {HTMLElement | HTMLElement[]} + * @type {null | HTMLElement | HTMLElement[]} */ export let target = null; diff --git a/src/DataTable/ToolbarSearch.svelte b/src/DataTable/ToolbarSearch.svelte index f527cbee..21c0c256 100644 --- a/src/DataTable/ToolbarSearch.svelte +++ b/src/DataTable/ToolbarSearch.svelte @@ -21,7 +21,7 @@ /** * Obtain a reference to the input HTML element - * @type {HTMLInputElement} + * @type {null | HTMLInputElement} */ export let ref = null; diff --git a/src/MultiSelect/MultiSelect.svelte b/src/MultiSelect/MultiSelect.svelte index 1ef2ed70..add3a9a1 100644 --- a/src/MultiSelect/MultiSelect.svelte +++ b/src/MultiSelect/MultiSelect.svelte @@ -136,13 +136,13 @@ /** * Obtain a reference to the field box element - * @type {HTMLDivElement} + * @type {null | HTMLDivElement} */ export let fieldRef = null; /** * Obtain a reference to the selection element - * @type {HTMLDivElement} + * @type {null | HTMLDivElement} */ export let selectionRef = null; diff --git a/src/TreeView/TreeViewNode.svelte b/src/TreeView/TreeViewNode.svelte index 79bfbeb8..ffcd4ad1 100644 --- a/src/TreeView/TreeViewNode.svelte +++ b/src/TreeView/TreeViewNode.svelte @@ -22,7 +22,7 @@ /** * Finds the nearest parent tree node * @param {HTMLElement} node - * @returns {HTMLElement} + * @returns {null | HTMLElement} */ function findParentTreeNode(node) { if (node.classList.contains("bx--tree-parent-node")) return node; diff --git a/tests/ComboBox.test.svelte b/tests/ComboBox.test.svelte index 9de92cee..6e155313 100644 --- a/tests/ComboBox.test.svelte +++ b/tests/ComboBox.test.svelte @@ -9,7 +9,6 @@ ]; let ref: ComboBox; - let listRef: HTMLDivElement = null; $: ref?.clear({ focus: false }); $: ref?.clear(); @@ -21,7 +20,6 @@ titleText="Contact" placeholder="Select contact method" items="{items}" - bind:listRef /> -
- - +