@majoo-ui/react 1.59.3-rc.6 → 1.59.3-rc.8

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.
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ControllerStateAndHelpers, DownshiftProps } from 'downshift';
2
+ import { ControllerStateAndHelpers, DownshiftProps, StateChangeOptions } from 'downshift';
3
3
  import { CSS } from '../../../../config/stitches.config';
4
4
  export declare const SelectContainer: import("@stitches/react/types/styled-component").StyledComponent<"div", {
5
5
  mobileOnly?: boolean | "true" | undefined;
@@ -824,6 +824,10 @@ interface InputSelectProps extends Omit<DownshiftProps<Option>, 'initialSelected
824
824
  * Only show in desktop view.
825
825
  */
826
826
  desktopOnly?: boolean;
827
+ /**
828
+ * Called whenever the InputSelect state changes.
829
+ */
830
+ onStateChange?(state: StateChangeOptions<Option>): void;
827
831
  }
828
832
  export declare const InputSelect: React.ForwardRefExoticComponent<InputSelectProps & React.RefAttributes<HTMLInputElement>>;
829
833
  export default InputSelect;
package/index.esm.js CHANGED
@@ -11530,9 +11530,10 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
11530
11530
  optionCss,
11531
11531
  emptyDataMessage,
11532
11532
  mobileOnly,
11533
- desktopOnly
11533
+ desktopOnly,
11534
+ onStateChange
11534
11535
  } = _a,
11535
- props = __rest(_a, ["option", "onChange", "value", "placeholder", "searchPlaceholder", "embedSearch", "size", "disabled", "search", "iconColor", "hideArrowicon", "showLeadingIcon", "placement", "disabledOptions", "textSelector", "valueSelector", "readOnly", "isInvalid", "noOptionIcon", "fetchData", "onSearch", "isLoading", "showTooltip", "css", "renderFooter", "optionCss", "emptyDataMessage", "mobileOnly", "desktopOnly"]);
11536
+ props = __rest(_a, ["option", "onChange", "value", "placeholder", "searchPlaceholder", "embedSearch", "size", "disabled", "search", "iconColor", "hideArrowicon", "showLeadingIcon", "placement", "disabledOptions", "textSelector", "valueSelector", "readOnly", "isInvalid", "noOptionIcon", "fetchData", "onSearch", "isLoading", "showTooltip", "css", "renderFooter", "optionCss", "emptyDataMessage", "mobileOnly", "desktopOnly", "onStateChange"]);
11536
11537
  const {
11537
11538
  t
11538
11539
  } = useTranslation(['MajooUI/inputSelect', 'translation']);
@@ -11551,6 +11552,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
11551
11552
  }, [query]);
11552
11553
  const handleInputValue = (value, isReset = false) => {
11553
11554
  if (onSearch && !isReset) onSearch(value);
11555
+ if (fetchData) return;
11554
11556
  if (value === '') {
11555
11557
  return setItem(options);
11556
11558
  } else {
@@ -11606,6 +11608,7 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
11606
11608
  onSearch('');
11607
11609
  setQuery('');
11608
11610
  }
11611
+ if (onStateChange) onStateChange(state);
11609
11612
  }
11610
11613
  }, {
11611
11614
  children: ({
@@ -11789,7 +11792,8 @@ const InputSelect = /*#__PURE__*/React.forwardRef((_a, ref) => {
11789
11792
  children: jsx(InputSearchbox, {
11790
11793
  size: 'sm',
11791
11794
  onChange: handleInputValue,
11792
- placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...')
11795
+ placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...'),
11796
+ withDebounce: true
11793
11797
  }, void 0)
11794
11798
  }), void 0), item.length > 0 || isLoading ? jsx(ConditionalWrapper, Object.assign({
11795
11799
  condition: !!fetchData && item.length > 0,
package/index.umd.js CHANGED
@@ -11622,7 +11622,8 @@
11622
11622
  emptyDataMessage = _a.emptyDataMessage,
11623
11623
  mobileOnly = _a.mobileOnly,
11624
11624
  desktopOnly = _a.desktopOnly,
11625
- props = __rest(_a, ["option", "onChange", "value", "placeholder", "searchPlaceholder", "embedSearch", "size", "disabled", "search", "iconColor", "hideArrowicon", "showLeadingIcon", "placement", "disabledOptions", "textSelector", "valueSelector", "readOnly", "isInvalid", "noOptionIcon", "fetchData", "onSearch", "isLoading", "showTooltip", "css", "renderFooter", "optionCss", "emptyDataMessage", "mobileOnly", "desktopOnly"]);
11625
+ onStateChange = _a.onStateChange,
11626
+ props = __rest(_a, ["option", "onChange", "value", "placeholder", "searchPlaceholder", "embedSearch", "size", "disabled", "search", "iconColor", "hideArrowicon", "showLeadingIcon", "placement", "disabledOptions", "textSelector", "valueSelector", "readOnly", "isInvalid", "noOptionIcon", "fetchData", "onSearch", "isLoading", "showTooltip", "css", "renderFooter", "optionCss", "emptyDataMessage", "mobileOnly", "desktopOnly", "onStateChange"]);
11626
11627
  var t = reactI18next.useTranslation(['MajooUI/inputSelect', 'translation']).t;
11627
11628
  var _r = React.useState([]),
11628
11629
  options = _r[0],
@@ -11652,6 +11653,7 @@
11652
11653
  isReset = false;
11653
11654
  }
11654
11655
  if (onSearch && !isReset) onSearch(value);
11656
+ if (fetchData) return;
11655
11657
  if (value === '') {
11656
11658
  return setItem(options);
11657
11659
  } else {
@@ -11724,6 +11726,7 @@
11724
11726
  onSearch('');
11725
11727
  setQuery('');
11726
11728
  }
11729
+ if (onStateChange) onStateChange(state);
11727
11730
  }
11728
11731
  }, {
11729
11732
  children: function (_a) {
@@ -11910,7 +11913,8 @@
11910
11913
  children: jsxRuntime.jsx(InputSearchbox, {
11911
11914
  size: 'sm',
11912
11915
  onChange: handleInputValue,
11913
- placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...')
11916
+ placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : t('searchPlaceholder', 'Cari ...'),
11917
+ withDebounce: true
11914
11918
  }, void 0)
11915
11919
  }), void 0), item.length > 0 || isLoading ? jsxRuntime.jsx(ConditionalWrapper, __assign({
11916
11920
  condition: !!fetchData && item.length > 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@majoo-ui/react",
3
- "version": "1.59.3-rc.6",
3
+ "version": "1.59.3-rc.8",
4
4
  "dependencies": {
5
5
  "@majoo-ui/core": "^1.31.3",
6
6
  "@majoo-ui/helpers": "^1.30.5",