@dev-fastn-ai/react-core 2.0.0 → 2.0.2

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/dist/index.esm.js CHANGED
@@ -984,7 +984,7 @@ const activateConnector = async ({ connectorId, action, dependencyConnector, aut
984
984
  formData: input,
985
985
  });
986
986
  if ((response === null || response === void 0 ? void 0 : response.status) === "CANCELLED") {
987
- return response;
987
+ return { data: null, status: "CANCELLED" };
988
988
  }
989
989
  // Execute the action handler
990
990
  response = await executeActionHandler(action === null || action === void 0 ? void 0 : action.handler, addCustomAuthContextHeader({}, { resourceId: connectorId, action: ResourceAction.ACTIVATION }));
@@ -1295,7 +1295,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1295
1295
  const handler = async (formData = {}) => {
1296
1296
  var _a, _b, _c, _d, _e, _f, _g, _h;
1297
1297
  if (((_a = configSubscription === null || configSubscription === void 0 ? void 0 : configSubscription.connector) === null || _a === void 0 ? void 0 : _a.status) === "ACTIVE")
1298
- return { data: null, status: "SUCCESS" };
1298
+ return { status: "SUCCESS" };
1299
1299
  const result = await activateConnector({
1300
1300
  connectorId: configSubscription.connector.id,
1301
1301
  action: (_c = (_b = configSubscription === null || configSubscription === void 0 ? void 0 : configSubscription.connector) === null || _b === void 0 ? void 0 : _b.actions) === null || _c === void 0 ? void 0 : _c.find((action) => action.actionType === ResourceAction.ACTIVATION),
@@ -1305,7 +1305,7 @@ async function getConfigurations({ configurationId, status = "ALL", }) {
1305
1305
  });
1306
1306
  sendEvent("REFETCH_CONFIGURATIONS");
1307
1307
  sendEvent("REFETCH_CONNECTORS");
1308
- return { data: result, status: "SUCCESS" };
1308
+ return result;
1309
1309
  };
1310
1310
  actions.push({
1311
1311
  name: "Enable",
@@ -1407,7 +1407,10 @@ function openGoogleFilesPicker(parentArgs) {
1407
1407
  const config = getConfig();
1408
1408
  let accessToken = null;
1409
1409
  let apiKey = null;
1410
- const cachedToken = localStorage.getItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token");
1410
+ const cachedToken = localStorage.getItem(config.spaceId +
1411
+ parentArgs.connectorId +
1412
+ config.tenantId +
1413
+ "access_token");
1411
1414
  if (cachedToken) {
1412
1415
  const token = safeParse(cachedToken);
1413
1416
  if ((token === null || token === void 0 ? void 0 : token.expires_at) && token.expires_at > Date.now()) {
@@ -1425,7 +1428,10 @@ function openGoogleFilesPicker(parentArgs) {
1425
1428
  });
1426
1429
  const token = data === null || data === void 0 ? void 0 : data.connectorConnection;
1427
1430
  // cache token in local storage
1428
- localStorage.setItem(config.spaceId + parentArgs.connectorId + config.tenantId + "access_token", safeStringify({
1431
+ localStorage.setItem(config.spaceId +
1432
+ parentArgs.connectorId +
1433
+ config.tenantId +
1434
+ "access_token", safeStringify({
1429
1435
  access_token: token.access_token,
1430
1436
  api_key: (_a = token.metadata) === null || _a === void 0 ? void 0 : _a.google_picker_api_key,
1431
1437
  expires_at: token.expires_at || Date.now() + token.expires_in * 1000,
@@ -1530,7 +1536,7 @@ async function fetchOptions(context, pagination, resetCursor = false, query) {
1530
1536
  const total = (_b = response.total) !== null && _b !== void 0 ? _b : pagination.total;
1531
1537
  const cursor = response.cursor || response.curser;
1532
1538
  const hasNextPage = Boolean(cursor || response.hasNextPage) ||
1533
- (typeof total === 'number'
1539
+ (typeof total === "number"
1534
1540
  ? total > newOffset
1535
1541
  : newOptions.length === limit && !pagination.cursor);
1536
1542
  return {
@@ -1558,8 +1564,8 @@ async function refreshOptions(pagination, context) {
1558
1564
  /**
1559
1565
  * Gets options for a select field.
1560
1566
  */
1561
- async function getOptions(pagination, context) {
1562
- return fetchOptions(context || {}, pagination, false);
1567
+ async function getOptions(pagination, context, query) {
1568
+ return fetchOptions(context || {}, pagination, false, query);
1563
1569
  }
1564
1570
  /**
1565
1571
  * Searches options for a select field.
@@ -1599,7 +1605,9 @@ async function getConfigurationForm(input) {
1599
1605
  loadMore: loadMoreOptions,
1600
1606
  refresh: refreshOptions,
1601
1607
  searchOptions,
1602
- openGoogleFilesPicker: openGoogleFilesPicker({ connectorId: input.connectorId }),
1608
+ openGoogleFilesPicker: openGoogleFilesPicker({
1609
+ connectorId: input.connectorId,
1610
+ }),
1603
1611
  });
1604
1612
  return {
1605
1613
  name: ((_g = input === null || input === void 0 ? void 0 : input.configuration) === null || _g === void 0 ? void 0 : _g.name) || "",
@@ -1727,6 +1735,666 @@ const useConnectors = () => {
1727
1735
  return query;
1728
1736
  };
1729
1737
 
1738
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1739
+
1740
+ function getDefaultExportFromCjs (x) {
1741
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1742
+ }
1743
+
1744
+ /**
1745
+ * Checks if `value` is the
1746
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1747
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1748
+ *
1749
+ * @static
1750
+ * @memberOf _
1751
+ * @since 0.1.0
1752
+ * @category Lang
1753
+ * @param {*} value The value to check.
1754
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1755
+ * @example
1756
+ *
1757
+ * _.isObject({});
1758
+ * // => true
1759
+ *
1760
+ * _.isObject([1, 2, 3]);
1761
+ * // => true
1762
+ *
1763
+ * _.isObject(_.noop);
1764
+ * // => true
1765
+ *
1766
+ * _.isObject(null);
1767
+ * // => false
1768
+ */
1769
+
1770
+ var isObject_1;
1771
+ var hasRequiredIsObject;
1772
+
1773
+ function requireIsObject () {
1774
+ if (hasRequiredIsObject) return isObject_1;
1775
+ hasRequiredIsObject = 1;
1776
+ function isObject(value) {
1777
+ var type = typeof value;
1778
+ return value != null && (type == 'object' || type == 'function');
1779
+ }
1780
+
1781
+ isObject_1 = isObject;
1782
+ return isObject_1;
1783
+ }
1784
+
1785
+ /** Detect free variable `global` from Node.js. */
1786
+
1787
+ var _freeGlobal;
1788
+ var hasRequired_freeGlobal;
1789
+
1790
+ function require_freeGlobal () {
1791
+ if (hasRequired_freeGlobal) return _freeGlobal;
1792
+ hasRequired_freeGlobal = 1;
1793
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1794
+
1795
+ _freeGlobal = freeGlobal;
1796
+ return _freeGlobal;
1797
+ }
1798
+
1799
+ var _root;
1800
+ var hasRequired_root;
1801
+
1802
+ function require_root () {
1803
+ if (hasRequired_root) return _root;
1804
+ hasRequired_root = 1;
1805
+ var freeGlobal = require_freeGlobal();
1806
+
1807
+ /** Detect free variable `self`. */
1808
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1809
+
1810
+ /** Used as a reference to the global object. */
1811
+ var root = freeGlobal || freeSelf || Function('return this')();
1812
+
1813
+ _root = root;
1814
+ return _root;
1815
+ }
1816
+
1817
+ var now_1;
1818
+ var hasRequiredNow;
1819
+
1820
+ function requireNow () {
1821
+ if (hasRequiredNow) return now_1;
1822
+ hasRequiredNow = 1;
1823
+ var root = require_root();
1824
+
1825
+ /**
1826
+ * Gets the timestamp of the number of milliseconds that have elapsed since
1827
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
1828
+ *
1829
+ * @static
1830
+ * @memberOf _
1831
+ * @since 2.4.0
1832
+ * @category Date
1833
+ * @returns {number} Returns the timestamp.
1834
+ * @example
1835
+ *
1836
+ * _.defer(function(stamp) {
1837
+ * console.log(_.now() - stamp);
1838
+ * }, _.now());
1839
+ * // => Logs the number of milliseconds it took for the deferred invocation.
1840
+ */
1841
+ var now = function() {
1842
+ return root.Date.now();
1843
+ };
1844
+
1845
+ now_1 = now;
1846
+ return now_1;
1847
+ }
1848
+
1849
+ /** Used to match a single whitespace character. */
1850
+
1851
+ var _trimmedEndIndex;
1852
+ var hasRequired_trimmedEndIndex;
1853
+
1854
+ function require_trimmedEndIndex () {
1855
+ if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
1856
+ hasRequired_trimmedEndIndex = 1;
1857
+ var reWhitespace = /\s/;
1858
+
1859
+ /**
1860
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
1861
+ * character of `string`.
1862
+ *
1863
+ * @private
1864
+ * @param {string} string The string to inspect.
1865
+ * @returns {number} Returns the index of the last non-whitespace character.
1866
+ */
1867
+ function trimmedEndIndex(string) {
1868
+ var index = string.length;
1869
+
1870
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
1871
+ return index;
1872
+ }
1873
+
1874
+ _trimmedEndIndex = trimmedEndIndex;
1875
+ return _trimmedEndIndex;
1876
+ }
1877
+
1878
+ var _baseTrim;
1879
+ var hasRequired_baseTrim;
1880
+
1881
+ function require_baseTrim () {
1882
+ if (hasRequired_baseTrim) return _baseTrim;
1883
+ hasRequired_baseTrim = 1;
1884
+ var trimmedEndIndex = require_trimmedEndIndex();
1885
+
1886
+ /** Used to match leading whitespace. */
1887
+ var reTrimStart = /^\s+/;
1888
+
1889
+ /**
1890
+ * The base implementation of `_.trim`.
1891
+ *
1892
+ * @private
1893
+ * @param {string} string The string to trim.
1894
+ * @returns {string} Returns the trimmed string.
1895
+ */
1896
+ function baseTrim(string) {
1897
+ return string
1898
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
1899
+ : string;
1900
+ }
1901
+
1902
+ _baseTrim = baseTrim;
1903
+ return _baseTrim;
1904
+ }
1905
+
1906
+ var _Symbol;
1907
+ var hasRequired_Symbol;
1908
+
1909
+ function require_Symbol () {
1910
+ if (hasRequired_Symbol) return _Symbol;
1911
+ hasRequired_Symbol = 1;
1912
+ var root = require_root();
1913
+
1914
+ /** Built-in value references. */
1915
+ var Symbol = root.Symbol;
1916
+
1917
+ _Symbol = Symbol;
1918
+ return _Symbol;
1919
+ }
1920
+
1921
+ var _getRawTag;
1922
+ var hasRequired_getRawTag;
1923
+
1924
+ function require_getRawTag () {
1925
+ if (hasRequired_getRawTag) return _getRawTag;
1926
+ hasRequired_getRawTag = 1;
1927
+ var Symbol = require_Symbol();
1928
+
1929
+ /** Used for built-in method references. */
1930
+ var objectProto = Object.prototype;
1931
+
1932
+ /** Used to check objects for own properties. */
1933
+ var hasOwnProperty = objectProto.hasOwnProperty;
1934
+
1935
+ /**
1936
+ * Used to resolve the
1937
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1938
+ * of values.
1939
+ */
1940
+ var nativeObjectToString = objectProto.toString;
1941
+
1942
+ /** Built-in value references. */
1943
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1944
+
1945
+ /**
1946
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1947
+ *
1948
+ * @private
1949
+ * @param {*} value The value to query.
1950
+ * @returns {string} Returns the raw `toStringTag`.
1951
+ */
1952
+ function getRawTag(value) {
1953
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
1954
+ tag = value[symToStringTag];
1955
+
1956
+ try {
1957
+ value[symToStringTag] = undefined;
1958
+ var unmasked = true;
1959
+ } catch (e) {}
1960
+
1961
+ var result = nativeObjectToString.call(value);
1962
+ if (unmasked) {
1963
+ if (isOwn) {
1964
+ value[symToStringTag] = tag;
1965
+ } else {
1966
+ delete value[symToStringTag];
1967
+ }
1968
+ }
1969
+ return result;
1970
+ }
1971
+
1972
+ _getRawTag = getRawTag;
1973
+ return _getRawTag;
1974
+ }
1975
+
1976
+ /** Used for built-in method references. */
1977
+
1978
+ var _objectToString;
1979
+ var hasRequired_objectToString;
1980
+
1981
+ function require_objectToString () {
1982
+ if (hasRequired_objectToString) return _objectToString;
1983
+ hasRequired_objectToString = 1;
1984
+ var objectProto = Object.prototype;
1985
+
1986
+ /**
1987
+ * Used to resolve the
1988
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1989
+ * of values.
1990
+ */
1991
+ var nativeObjectToString = objectProto.toString;
1992
+
1993
+ /**
1994
+ * Converts `value` to a string using `Object.prototype.toString`.
1995
+ *
1996
+ * @private
1997
+ * @param {*} value The value to convert.
1998
+ * @returns {string} Returns the converted string.
1999
+ */
2000
+ function objectToString(value) {
2001
+ return nativeObjectToString.call(value);
2002
+ }
2003
+
2004
+ _objectToString = objectToString;
2005
+ return _objectToString;
2006
+ }
2007
+
2008
+ var _baseGetTag;
2009
+ var hasRequired_baseGetTag;
2010
+
2011
+ function require_baseGetTag () {
2012
+ if (hasRequired_baseGetTag) return _baseGetTag;
2013
+ hasRequired_baseGetTag = 1;
2014
+ var Symbol = require_Symbol(),
2015
+ getRawTag = require_getRawTag(),
2016
+ objectToString = require_objectToString();
2017
+
2018
+ /** `Object#toString` result references. */
2019
+ var nullTag = '[object Null]',
2020
+ undefinedTag = '[object Undefined]';
2021
+
2022
+ /** Built-in value references. */
2023
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
2024
+
2025
+ /**
2026
+ * The base implementation of `getTag` without fallbacks for buggy environments.
2027
+ *
2028
+ * @private
2029
+ * @param {*} value The value to query.
2030
+ * @returns {string} Returns the `toStringTag`.
2031
+ */
2032
+ function baseGetTag(value) {
2033
+ if (value == null) {
2034
+ return value === undefined ? undefinedTag : nullTag;
2035
+ }
2036
+ return (symToStringTag && symToStringTag in Object(value))
2037
+ ? getRawTag(value)
2038
+ : objectToString(value);
2039
+ }
2040
+
2041
+ _baseGetTag = baseGetTag;
2042
+ return _baseGetTag;
2043
+ }
2044
+
2045
+ /**
2046
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
2047
+ * and has a `typeof` result of "object".
2048
+ *
2049
+ * @static
2050
+ * @memberOf _
2051
+ * @since 4.0.0
2052
+ * @category Lang
2053
+ * @param {*} value The value to check.
2054
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2055
+ * @example
2056
+ *
2057
+ * _.isObjectLike({});
2058
+ * // => true
2059
+ *
2060
+ * _.isObjectLike([1, 2, 3]);
2061
+ * // => true
2062
+ *
2063
+ * _.isObjectLike(_.noop);
2064
+ * // => false
2065
+ *
2066
+ * _.isObjectLike(null);
2067
+ * // => false
2068
+ */
2069
+
2070
+ var isObjectLike_1;
2071
+ var hasRequiredIsObjectLike;
2072
+
2073
+ function requireIsObjectLike () {
2074
+ if (hasRequiredIsObjectLike) return isObjectLike_1;
2075
+ hasRequiredIsObjectLike = 1;
2076
+ function isObjectLike(value) {
2077
+ return value != null && typeof value == 'object';
2078
+ }
2079
+
2080
+ isObjectLike_1 = isObjectLike;
2081
+ return isObjectLike_1;
2082
+ }
2083
+
2084
+ var isSymbol_1;
2085
+ var hasRequiredIsSymbol;
2086
+
2087
+ function requireIsSymbol () {
2088
+ if (hasRequiredIsSymbol) return isSymbol_1;
2089
+ hasRequiredIsSymbol = 1;
2090
+ var baseGetTag = require_baseGetTag(),
2091
+ isObjectLike = requireIsObjectLike();
2092
+
2093
+ /** `Object#toString` result references. */
2094
+ var symbolTag = '[object Symbol]';
2095
+
2096
+ /**
2097
+ * Checks if `value` is classified as a `Symbol` primitive or object.
2098
+ *
2099
+ * @static
2100
+ * @memberOf _
2101
+ * @since 4.0.0
2102
+ * @category Lang
2103
+ * @param {*} value The value to check.
2104
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2105
+ * @example
2106
+ *
2107
+ * _.isSymbol(Symbol.iterator);
2108
+ * // => true
2109
+ *
2110
+ * _.isSymbol('abc');
2111
+ * // => false
2112
+ */
2113
+ function isSymbol(value) {
2114
+ return typeof value == 'symbol' ||
2115
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
2116
+ }
2117
+
2118
+ isSymbol_1 = isSymbol;
2119
+ return isSymbol_1;
2120
+ }
2121
+
2122
+ var toNumber_1;
2123
+ var hasRequiredToNumber;
2124
+
2125
+ function requireToNumber () {
2126
+ if (hasRequiredToNumber) return toNumber_1;
2127
+ hasRequiredToNumber = 1;
2128
+ var baseTrim = require_baseTrim(),
2129
+ isObject = requireIsObject(),
2130
+ isSymbol = requireIsSymbol();
2131
+
2132
+ /** Used as references for various `Number` constants. */
2133
+ var NAN = 0 / 0;
2134
+
2135
+ /** Used to detect bad signed hexadecimal string values. */
2136
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
2137
+
2138
+ /** Used to detect binary string values. */
2139
+ var reIsBinary = /^0b[01]+$/i;
2140
+
2141
+ /** Used to detect octal string values. */
2142
+ var reIsOctal = /^0o[0-7]+$/i;
2143
+
2144
+ /** Built-in method references without a dependency on `root`. */
2145
+ var freeParseInt = parseInt;
2146
+
2147
+ /**
2148
+ * Converts `value` to a number.
2149
+ *
2150
+ * @static
2151
+ * @memberOf _
2152
+ * @since 4.0.0
2153
+ * @category Lang
2154
+ * @param {*} value The value to process.
2155
+ * @returns {number} Returns the number.
2156
+ * @example
2157
+ *
2158
+ * _.toNumber(3.2);
2159
+ * // => 3.2
2160
+ *
2161
+ * _.toNumber(Number.MIN_VALUE);
2162
+ * // => 5e-324
2163
+ *
2164
+ * _.toNumber(Infinity);
2165
+ * // => Infinity
2166
+ *
2167
+ * _.toNumber('3.2');
2168
+ * // => 3.2
2169
+ */
2170
+ function toNumber(value) {
2171
+ if (typeof value == 'number') {
2172
+ return value;
2173
+ }
2174
+ if (isSymbol(value)) {
2175
+ return NAN;
2176
+ }
2177
+ if (isObject(value)) {
2178
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
2179
+ value = isObject(other) ? (other + '') : other;
2180
+ }
2181
+ if (typeof value != 'string') {
2182
+ return value === 0 ? value : +value;
2183
+ }
2184
+ value = baseTrim(value);
2185
+ var isBinary = reIsBinary.test(value);
2186
+ return (isBinary || reIsOctal.test(value))
2187
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
2188
+ : (reIsBadHex.test(value) ? NAN : +value);
2189
+ }
2190
+
2191
+ toNumber_1 = toNumber;
2192
+ return toNumber_1;
2193
+ }
2194
+
2195
+ var debounce_1;
2196
+ var hasRequiredDebounce;
2197
+
2198
+ function requireDebounce () {
2199
+ if (hasRequiredDebounce) return debounce_1;
2200
+ hasRequiredDebounce = 1;
2201
+ var isObject = requireIsObject(),
2202
+ now = requireNow(),
2203
+ toNumber = requireToNumber();
2204
+
2205
+ /** Error message constants. */
2206
+ var FUNC_ERROR_TEXT = 'Expected a function';
2207
+
2208
+ /* Built-in method references for those with the same name as other `lodash` methods. */
2209
+ var nativeMax = Math.max,
2210
+ nativeMin = Math.min;
2211
+
2212
+ /**
2213
+ * Creates a debounced function that delays invoking `func` until after `wait`
2214
+ * milliseconds have elapsed since the last time the debounced function was
2215
+ * invoked. The debounced function comes with a `cancel` method to cancel
2216
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
2217
+ * Provide `options` to indicate whether `func` should be invoked on the
2218
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
2219
+ * with the last arguments provided to the debounced function. Subsequent
2220
+ * calls to the debounced function return the result of the last `func`
2221
+ * invocation.
2222
+ *
2223
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
2224
+ * invoked on the trailing edge of the timeout only if the debounced function
2225
+ * is invoked more than once during the `wait` timeout.
2226
+ *
2227
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
2228
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
2229
+ *
2230
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
2231
+ * for details over the differences between `_.debounce` and `_.throttle`.
2232
+ *
2233
+ * @static
2234
+ * @memberOf _
2235
+ * @since 0.1.0
2236
+ * @category Function
2237
+ * @param {Function} func The function to debounce.
2238
+ * @param {number} [wait=0] The number of milliseconds to delay.
2239
+ * @param {Object} [options={}] The options object.
2240
+ * @param {boolean} [options.leading=false]
2241
+ * Specify invoking on the leading edge of the timeout.
2242
+ * @param {number} [options.maxWait]
2243
+ * The maximum time `func` is allowed to be delayed before it's invoked.
2244
+ * @param {boolean} [options.trailing=true]
2245
+ * Specify invoking on the trailing edge of the timeout.
2246
+ * @returns {Function} Returns the new debounced function.
2247
+ * @example
2248
+ *
2249
+ * // Avoid costly calculations while the window size is in flux.
2250
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
2251
+ *
2252
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
2253
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
2254
+ * 'leading': true,
2255
+ * 'trailing': false
2256
+ * }));
2257
+ *
2258
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
2259
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
2260
+ * var source = new EventSource('/stream');
2261
+ * jQuery(source).on('message', debounced);
2262
+ *
2263
+ * // Cancel the trailing debounced invocation.
2264
+ * jQuery(window).on('popstate', debounced.cancel);
2265
+ */
2266
+ function debounce(func, wait, options) {
2267
+ var lastArgs,
2268
+ lastThis,
2269
+ maxWait,
2270
+ result,
2271
+ timerId,
2272
+ lastCallTime,
2273
+ lastInvokeTime = 0,
2274
+ leading = false,
2275
+ maxing = false,
2276
+ trailing = true;
2277
+
2278
+ if (typeof func != 'function') {
2279
+ throw new TypeError(FUNC_ERROR_TEXT);
2280
+ }
2281
+ wait = toNumber(wait) || 0;
2282
+ if (isObject(options)) {
2283
+ leading = !!options.leading;
2284
+ maxing = 'maxWait' in options;
2285
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
2286
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
2287
+ }
2288
+
2289
+ function invokeFunc(time) {
2290
+ var args = lastArgs,
2291
+ thisArg = lastThis;
2292
+
2293
+ lastArgs = lastThis = undefined;
2294
+ lastInvokeTime = time;
2295
+ result = func.apply(thisArg, args);
2296
+ return result;
2297
+ }
2298
+
2299
+ function leadingEdge(time) {
2300
+ // Reset any `maxWait` timer.
2301
+ lastInvokeTime = time;
2302
+ // Start the timer for the trailing edge.
2303
+ timerId = setTimeout(timerExpired, wait);
2304
+ // Invoke the leading edge.
2305
+ return leading ? invokeFunc(time) : result;
2306
+ }
2307
+
2308
+ function remainingWait(time) {
2309
+ var timeSinceLastCall = time - lastCallTime,
2310
+ timeSinceLastInvoke = time - lastInvokeTime,
2311
+ timeWaiting = wait - timeSinceLastCall;
2312
+
2313
+ return maxing
2314
+ ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
2315
+ : timeWaiting;
2316
+ }
2317
+
2318
+ function shouldInvoke(time) {
2319
+ var timeSinceLastCall = time - lastCallTime,
2320
+ timeSinceLastInvoke = time - lastInvokeTime;
2321
+
2322
+ // Either this is the first call, activity has stopped and we're at the
2323
+ // trailing edge, the system time has gone backwards and we're treating
2324
+ // it as the trailing edge, or we've hit the `maxWait` limit.
2325
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
2326
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
2327
+ }
2328
+
2329
+ function timerExpired() {
2330
+ var time = now();
2331
+ if (shouldInvoke(time)) {
2332
+ return trailingEdge(time);
2333
+ }
2334
+ // Restart the timer.
2335
+ timerId = setTimeout(timerExpired, remainingWait(time));
2336
+ }
2337
+
2338
+ function trailingEdge(time) {
2339
+ timerId = undefined;
2340
+
2341
+ // Only invoke if we have `lastArgs` which means `func` has been
2342
+ // debounced at least once.
2343
+ if (trailing && lastArgs) {
2344
+ return invokeFunc(time);
2345
+ }
2346
+ lastArgs = lastThis = undefined;
2347
+ return result;
2348
+ }
2349
+
2350
+ function cancel() {
2351
+ if (timerId !== undefined) {
2352
+ clearTimeout(timerId);
2353
+ }
2354
+ lastInvokeTime = 0;
2355
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
2356
+ }
2357
+
2358
+ function flush() {
2359
+ return timerId === undefined ? result : trailingEdge(now());
2360
+ }
2361
+
2362
+ function debounced() {
2363
+ var time = now(),
2364
+ isInvoking = shouldInvoke(time);
2365
+
2366
+ lastArgs = arguments;
2367
+ lastThis = this;
2368
+ lastCallTime = time;
2369
+
2370
+ if (isInvoking) {
2371
+ if (timerId === undefined) {
2372
+ return leadingEdge(lastCallTime);
2373
+ }
2374
+ if (maxing) {
2375
+ // Handle invocations in a tight loop.
2376
+ clearTimeout(timerId);
2377
+ timerId = setTimeout(timerExpired, wait);
2378
+ return invokeFunc(lastCallTime);
2379
+ }
2380
+ }
2381
+ if (timerId === undefined) {
2382
+ timerId = setTimeout(timerExpired, wait);
2383
+ }
2384
+ return result;
2385
+ }
2386
+ debounced.cancel = cancel;
2387
+ debounced.flush = flush;
2388
+ return debounced;
2389
+ }
2390
+
2391
+ debounce_1 = debounce;
2392
+ return debounce_1;
2393
+ }
2394
+
2395
+ var debounceExports = requireDebounce();
2396
+ var debounce = /*@__PURE__*/getDefaultExportFromCjs(debounceExports);
2397
+
1730
2398
  /**
1731
2399
  * Custom hook to manage async select field options with search, pagination, and error handling using React Query.
1732
2400
  *
@@ -1754,10 +2422,10 @@ function useFieldOptions(field) {
1754
2422
  var _a, _b, _c, _d, _e, _f;
1755
2423
  const [searchQuery, setSearchQuery] = useState("");
1756
2424
  const queryClient = useQueryClient();
1757
- // Generate a unique query key for this field
2425
+ // Generate a unique query key for this field including search query
1758
2426
  const queryKey = useMemo(() => {
1759
- return ["field-options", field.key, field.name];
1760
- }, [field.key, field.name]);
2427
+ return ["field-options", field.key, field.name, searchQuery];
2428
+ }, [field.key, field.name, searchQuery]);
1761
2429
  // Initial fetch query for static options or first page
1762
2430
  const initialQuery = useQuery({
1763
2431
  queryKey: [...queryKey, "initial"],
@@ -1769,7 +2437,8 @@ function useFieldOptions(field) {
1769
2437
  .pagination) !== null && _b !== void 0 ? _b : {
1770
2438
  sourceId: "",
1771
2439
  sourceProject: "",
1772
- limit: 10,
2440
+ limit: 20,
2441
+ query: searchQuery,
1773
2442
  offset: 0,
1774
2443
  type: "OFFSET",
1775
2444
  hasNextPage: false,
@@ -1793,7 +2462,8 @@ function useFieldOptions(field) {
1793
2462
  initialPageParam: ((_c = (_b = field.optionsSource) === null || _b === void 0 ? void 0 : _b.pagination) !== null && _c !== void 0 ? _c : {
1794
2463
  sourceId: "",
1795
2464
  sourceProject: "",
1796
- limit: 10,
2465
+ query: searchQuery,
2466
+ limit: 20,
1797
2467
  offset: 0,
1798
2468
  type: "OFFSET",
1799
2469
  hasNextPage: false,
@@ -1830,10 +2500,20 @@ function useFieldOptions(field) {
1830
2500
  // and create a separate query for search results
1831
2501
  return allOptions.filter((option) => option.label.toLowerCase().includes(searchQuery.toLowerCase()));
1832
2502
  }, [allOptions, searchQuery]);
1833
- // Search handler
1834
- const search = useCallback((query) => {
2503
+ // Create debounced search function
2504
+ const debouncedSearch = useMemo(() => debounce((query) => {
1835
2505
  setSearchQuery(query);
1836
- }, []);
2506
+ }, 500), []);
2507
+ // Search handler with debounce
2508
+ const search = useCallback((query) => {
2509
+ debouncedSearch(query);
2510
+ }, [debouncedSearch]);
2511
+ // Cleanup debounced function
2512
+ useEffect(() => {
2513
+ return () => {
2514
+ debouncedSearch.cancel();
2515
+ };
2516
+ }, [debouncedSearch]);
1837
2517
  // Load more handler
1838
2518
  const loadMore = useCallback(async () => {
1839
2519
  if (infiniteQuery.hasNextPage && !infiniteQuery.isFetchingNextPage) {