@eightshift/ui-components 5.2.0 → 5.2.1
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.
|
@@ -40,6 +40,10 @@ import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyn
|
|
|
40
40
|
* @param {Function} [props.getIcon] - Function to get the icon for the item from the fetched data. `(item: Object<string, any>) => JSX.Element | string`
|
|
41
41
|
* @param {Function} [props.getSubtitle] - Function to get the subtitle for the item from the fetched data. `(item: Object<string, any>) => string`
|
|
42
42
|
* @param {Function} [props.getData] - Function to pre-process the fetched data before it is used in the select. `(data: Object<string, any>[]) => Object<string, any>[]`
|
|
43
|
+
* @param {Function} [props.fetchUrl] - Function to get the URL for fetching data. Provides typed search text if entered. `(searchText: string) => string`
|
|
44
|
+
* @param {Object} [props.fetchConfig] - Configuration object for the fetch request, passed to the `fetch` function.
|
|
45
|
+
* @param {Function} [props.fetchFunction] - Allows overriding the default fetch function. `fetchFunction: (url: string, fetchOptions: Object<string, any>, searchText?: string) => Promise<Object<string, any>>`
|
|
46
|
+
* @param {Function} [props.processLoadedOptions] - Allows processing the options fetched from the source. `(options: Object<string, any>[]) => Object<string, any>[]`
|
|
43
47
|
* @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu. `({ value: string, label: string, subtitle: string, metadata: any }) => JSX.Element`
|
|
44
48
|
* @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item. `({ value: string, label: string, subtitle: string, metadata: any }) => JSX.Element`
|
|
45
49
|
* @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
|
|
@@ -79,8 +83,9 @@ const __AsyncMultiSelectNext = (props) => {
|
|
|
79
83
|
placeholder = __("Select...", "eightshift-ui-components"),
|
|
80
84
|
fetchUrl,
|
|
81
85
|
fetchConfig = {},
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
fetchFunction,
|
|
87
|
+
getLabel = (item) => item?.label,
|
|
88
|
+
getValue = (item) => item?.value,
|
|
84
89
|
getMeta,
|
|
85
90
|
getIcon,
|
|
86
91
|
getSubtitle,
|
|
@@ -98,8 +103,14 @@ const __AsyncMultiSelectNext = (props) => {
|
|
|
98
103
|
initialSelectedKeys: Array.isArray(value) ? value.map((item) => item?.value) : [],
|
|
99
104
|
getKey: (item) => item.value,
|
|
100
105
|
async load({ signal, filterText }) {
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
let json = [];
|
|
107
|
+
if (fetchFunction) {
|
|
108
|
+
const res = await fetchFunction(filterText, signal);
|
|
109
|
+
json = processLoadedOptions ? processLoadedOptions(getData(res)) : getData(res);
|
|
110
|
+
} else {
|
|
111
|
+
const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
|
|
112
|
+
json = processLoadedOptions ? processLoadedOptions(getData(await res.json())) : getData(res);
|
|
113
|
+
}
|
|
103
114
|
const output = json?.map((item, index) => {
|
|
104
115
|
const id = getValue?.(item) ?? index;
|
|
105
116
|
const entry = { label: unescapeHTML(getLabel?.(item) ?? ""), value: id };
|
|
@@ -38,6 +38,10 @@ import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyn
|
|
|
38
38
|
* @param {Function} [props.getIcon] - Function to get the icon for the item from the fetched data. `(item: Object<string, any>) => JSX.Element | string`
|
|
39
39
|
* @param {Function} [props.getSubtitle] - Function to get the subtitle for the item from the fetched data. `(item: Object<string, any>) => string`
|
|
40
40
|
* @param {Function} [props.getData] - Function to pre-process the fetched data before it is used in the select. `(data: Object<string, any>[]) => Object<string, any>[]`
|
|
41
|
+
* @param {Function} [props.fetchUrl] - Function to get the URL for fetching data. Provides typed search text if entered. `(searchText: string) => string`
|
|
42
|
+
* @param {Object} [props.fetchConfig] - Configuration object for the fetch request, passed to the `fetch` function.
|
|
43
|
+
* @param {Function} [props.fetchFunction] - Allows overriding the default fetch function. `fetchFunction: (url: string, fetchOptions: Object<string, any>, searchText?: string) => Promise<Object<string, any>>`
|
|
44
|
+
* @param {Function} [props.processLoadedOptions] - Allows processing the options fetched from the source. `(options: Object<string, any>[]) => Object<string, any>[]`
|
|
41
45
|
* @param {JSX.Element} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu. `({ value: string, label: string, subtitle: string, metadata: any }) => JSX.Element`
|
|
42
46
|
* @param {JSX.Element} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item. `({ value: string, label: string, subtitle: string, metadata: any }) => JSX.Element`
|
|
43
47
|
* @param {JSX.Element} [props.customDropdownArrow] - If provided, replaces the default dropdown arrow indicator.
|
|
@@ -81,8 +85,9 @@ const AsyncSelectNext = (props) => {
|
|
|
81
85
|
processLoadedOptions = (options) => options,
|
|
82
86
|
fetchUrl,
|
|
83
87
|
fetchConfig = {},
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
fetchFunction,
|
|
89
|
+
getLabel = (item) => item?.label,
|
|
90
|
+
getValue = (item) => item?.value,
|
|
86
91
|
getMeta,
|
|
87
92
|
getIcon,
|
|
88
93
|
getSubtitle,
|
|
@@ -94,8 +99,14 @@ const AsyncSelectNext = (props) => {
|
|
|
94
99
|
const list = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
|
|
95
100
|
getKey: (item) => item.value,
|
|
96
101
|
async load({ signal, filterText }) {
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
let json = [];
|
|
103
|
+
if (fetchFunction) {
|
|
104
|
+
const res = await fetchFunction(filterText, signal);
|
|
105
|
+
json = processLoadedOptions ? processLoadedOptions(getData(res)) : getData(res);
|
|
106
|
+
} else {
|
|
107
|
+
const res = await fetch(fetchUrl(filterText), { ...fetchConfig, signal });
|
|
108
|
+
json = processLoadedOptions ? processLoadedOptions(getData(await res.json())) : getData(res);
|
|
109
|
+
}
|
|
99
110
|
const output = json?.map((item, index) => {
|
|
100
111
|
const id = getValue?.(item) ?? index;
|
|
101
112
|
const entry = { label: unescapeHTML(getLabel?.(item) ?? ""), value: id };
|