@7shifts/sous-chef 2.3.6 → 2.4.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.
@@ -4,27 +4,28 @@ declare type NoOptionsMessageFunction = (input: {
4
4
  inputValue: string;
5
5
  }) => string | null;
6
6
  declare type Props<T> = {
7
- name: string;
8
- /** If not provided it will generate a random id so the label links properly with the text input */
7
+ asToolbarFilter?: boolean;
8
+ caption?: React.ReactNode;
9
+ disabled?: boolean;
10
+ error?: string;
11
+ /** If not provided it will generate a random id so the l¡abel links properly with the text input */
9
12
  id?: string;
10
- value?: SelectOption<T>;
11
- options: SelectOptions<T>;
13
+ isClearable?: boolean;
14
+ label?: React.ReactNode;
15
+ /** When the user opens the menu, if this prop is `true`, it will scroll the page into to the menu view (if its content falls under a scroll). It is recommended to disable this behaviour when using the `SelectField` inside a modal. */
16
+ menuShouldScrollIntoView?: boolean;
17
+ name: string;
18
+ noOptionsMessage?: string | NoOptionsMessageFunction;
12
19
  onChange?: (e: SelectOption<T>) => void;
13
20
  onBlur?: (e: SelectOption<T>) => void;
14
- CustomOption?: React.ElementType;
15
- SelectedOptionPrefix?: React.ElementType;
16
- label?: React.ReactNode;
17
- caption?: React.ReactNode;
18
- error?: string;
21
+ options: SelectOptions<T>;
19
22
  placeholder?: string;
20
- noOptionsMessage?: string | NoOptionsMessageFunction;
21
- disabled?: boolean;
22
23
  /** Use a prefix for things like currency symbols (“$”, “¥”, “£”) or icons. */
23
24
  prefix?: React.ReactNode;
24
- asToolbarFilter?: boolean;
25
- /** When the user opens the menu, if this prop is `true`, it will scroll the page into to the menu view (if its content falls under a scroll). It is recomended to disable this behaviour when using the `SelectField` inside a modal. */
26
- menuShouldScrollIntoView?: boolean;
25
+ value?: SelectOption<T>;
26
+ CustomOption?: React.ElementType;
27
+ SelectedOptionPrefix?: React.ElementType;
27
28
  };
28
29
  /** Component to make possible choose from a predefined options. */
29
- declare const SelectField: <T extends unknown>({ name, id: inputId, value, options, onChange, onBlur, CustomOption: UserCustomOption, SelectedOptionPrefix, label, caption, error, placeholder, noOptionsMessage, disabled, prefix, asToolbarFilter, menuShouldScrollIntoView }: Props<T>) => JSX.Element;
30
+ declare const SelectField: <T extends unknown>({ asToolbarFilter, caption, disabled, error, id: inputId, isClearable, label, menuShouldScrollIntoView, name, noOptionsMessage, options, onBlur, onChange, placeholder, prefix, value, CustomOption: UserCustomOption, SelectedOptionPrefix }: Props<T>) => JSX.Element;
30
31
  export default SelectField;
package/dist/index.js CHANGED
@@ -4952,40 +4952,42 @@ function CustomOption$1(_ref) {
4952
4952
  }
4953
4953
 
4954
4954
  var SelectField = function SelectField(_ref) {
4955
- var name = _ref.name,
4955
+ var _ref$asToolbarFilter = _ref.asToolbarFilter,
4956
+ asToolbarFilter = _ref$asToolbarFilter === void 0 ? false : _ref$asToolbarFilter,
4957
+ caption = _ref.caption,
4958
+ disabled = _ref.disabled,
4959
+ error = _ref.error,
4956
4960
  inputId = _ref.id,
4957
- value = _ref.value,
4961
+ _ref$isClearable = _ref.isClearable,
4962
+ isClearable = _ref$isClearable === void 0 ? false : _ref$isClearable,
4963
+ label = _ref.label,
4964
+ _ref$menuShouldScroll = _ref.menuShouldScrollIntoView,
4965
+ menuShouldScrollIntoView = _ref$menuShouldScroll === void 0 ? true : _ref$menuShouldScroll,
4966
+ name = _ref.name,
4967
+ noOptionsMessage = _ref.noOptionsMessage,
4958
4968
  options = _ref.options,
4959
- onChange = _ref.onChange,
4960
4969
  onBlur = _ref.onBlur,
4961
- UserCustomOption = _ref.CustomOption,
4962
- SelectedOptionPrefix = _ref.SelectedOptionPrefix,
4963
- label = _ref.label,
4964
- caption = _ref.caption,
4965
- error = _ref.error,
4970
+ onChange = _ref.onChange,
4966
4971
  placeholder = _ref.placeholder,
4967
- noOptionsMessage = _ref.noOptionsMessage,
4968
- disabled = _ref.disabled,
4969
4972
  prefix = _ref.prefix,
4970
- _ref$asToolbarFilter = _ref.asToolbarFilter,
4971
- asToolbarFilter = _ref$asToolbarFilter === void 0 ? false : _ref$asToolbarFilter,
4972
- _ref$menuShouldScroll = _ref.menuShouldScrollIntoView,
4973
- menuShouldScrollIntoView = _ref$menuShouldScroll === void 0 ? true : _ref$menuShouldScroll;
4973
+ value = _ref.value,
4974
+ UserCustomOption = _ref.CustomOption,
4975
+ SelectedOptionPrefix = _ref.SelectedOptionPrefix;
4974
4976
  var controllers = useSelectFieldControllers({
4975
- name: name,
4977
+ error: error,
4976
4978
  id: inputId,
4977
- value: value,
4979
+ name: name,
4978
4980
  onChange: onChange,
4979
4981
  onBlur: onBlur,
4980
- error: error
4982
+ value: value
4981
4983
  });
4982
4984
  var hasError = !!controllers.error;
4983
4985
  var fieldProps = {
4984
- name: name,
4986
+ caption: caption,
4987
+ error: controllers.error,
4985
4988
  id: controllers.id,
4986
4989
  label: label,
4987
- caption: caption,
4988
- error: controllers.error
4990
+ name: name
4989
4991
  };
4990
4992
  var defaultNoOptionsMessage = noOptionsMessage && typeof noOptionsMessage === 'string' ? function () {
4991
4993
  return noOptionsMessage;
@@ -4993,19 +4995,16 @@ var SelectField = function SelectField(_ref) {
4993
4995
  return React__default.createElement(Field, Object.assign({}, fieldProps), React__default.createElement(AffixContainer, {
4994
4996
  prefix: prefix
4995
4997
  }, React__default.createElement(Select__default, {
4996
- inputId: controllers.id,
4997
- options: options,
4998
- isDisabled: disabled,
4999
- value: controllers.value,
5000
- placeholder: placeholder,
5001
- noOptionsMessage: typeof noOptionsMessage === 'function' ? noOptionsMessage : defaultNoOptionsMessage,
5002
- styles: getSelectStyles$1({
5003
- isInvalid: hasError,
5004
- asToolbarFilter: asToolbarFilter
5005
- }),
5006
- menuPortalTarget: document.body,
5007
- onChange: controllers.onChange,
5008
- onBlur: controllers.onBlur,
4998
+ closeMenuOnScroll: function closeMenuOnScroll(e) {
4999
+ if (menuShouldScrollIntoView || !e.target) {
5000
+ return false;
5001
+ }
5002
+
5003
+ var target = e.target;
5004
+ var firstOption = target.children[0];
5005
+ var isScrollingTheMenu = firstOption && typeof firstOption.id === 'string' && firstOption.id.includes('react-select');
5006
+ return !isScrollingTheMenu;
5007
+ },
5009
5008
  components: {
5010
5009
  Option: UserCustomOption ? function (props) {
5011
5010
  return React__default.createElement(CustomOption$1, Object.assign({
@@ -5018,19 +5017,23 @@ var SelectField = function SelectField(_ref) {
5018
5017
  }, props));
5019
5018
  } : Select.components.Control
5020
5019
  },
5021
- menuShouldScrollIntoView: menuShouldScrollIntoView,
5020
+ inputId: controllers.id,
5021
+ isClearable: isClearable,
5022
+ isDisabled: disabled,
5023
+ menuPortalTarget: document.body,
5022
5024
  menuPlacement: menuShouldScrollIntoView ? 'bottom' : 'auto',
5023
5025
  menuPosition: menuShouldScrollIntoView ? 'absolute' : 'fixed',
5024
- closeMenuOnScroll: function closeMenuOnScroll(e) {
5025
- if (menuShouldScrollIntoView || !e.target) {
5026
- return false;
5027
- }
5028
-
5029
- var target = e.target;
5030
- var firstOption = target.children[0];
5031
- var isScrollingTheMenu = firstOption && typeof firstOption.id === 'string' && firstOption.id.includes('react-select');
5032
- return !isScrollingTheMenu;
5033
- }
5026
+ noOptionsMessage: typeof noOptionsMessage === 'function' ? noOptionsMessage : defaultNoOptionsMessage,
5027
+ menuShouldScrollIntoView: menuShouldScrollIntoView,
5028
+ onBlur: controllers.onBlur,
5029
+ onChange: controllers.onChange,
5030
+ options: options,
5031
+ placeholder: placeholder,
5032
+ styles: getSelectStyles$1({
5033
+ isInvalid: hasError,
5034
+ asToolbarFilter: asToolbarFilter
5035
+ }),
5036
+ value: controllers.value
5034
5037
  })));
5035
5038
  };
5036
5039