@7shifts/sous-chef 2.3.0 → 2.3.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.
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SelectOption, SelectOptions } from '../SelectField/types';
|
|
3
|
+
declare type NoOptionsMessageFunction = (input: {
|
|
4
|
+
inputValue: string;
|
|
5
|
+
}) => string | null;
|
|
3
6
|
declare type Props<T> = {
|
|
4
7
|
name: string;
|
|
5
8
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
@@ -13,11 +16,12 @@ declare type Props<T> = {
|
|
|
13
16
|
caption?: React.ReactNode;
|
|
14
17
|
error?: string;
|
|
15
18
|
placeholder?: string;
|
|
19
|
+
noOptionsMessage?: string | NoOptionsMessageFunction;
|
|
16
20
|
disabled?: boolean;
|
|
17
21
|
closeOnSelect?: boolean;
|
|
18
22
|
/** 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 `MultiSelectField` inside a modal. */
|
|
19
23
|
menuShouldScrollIntoView?: boolean;
|
|
20
24
|
};
|
|
21
25
|
/** Component to make possible choose from a predefined options. */
|
|
22
|
-
declare const MultiSelectField: <T extends unknown>({ name, id: inputId, value, options, onChange, onBlur, CustomOption: UserCustomOption, label, caption, error, placeholder, disabled, closeOnSelect, menuShouldScrollIntoView }: Props<T>) => JSX.Element;
|
|
26
|
+
declare const MultiSelectField: <T extends unknown>({ name, id: inputId, value, options, onChange, onBlur, CustomOption: UserCustomOption, label, caption, error, placeholder, noOptionsMessage, disabled, closeOnSelect, menuShouldScrollIntoView }: Props<T>) => JSX.Element;
|
|
23
27
|
export default MultiSelectField;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SelectOption, SelectOptions } from './types';
|
|
3
|
+
declare type NoOptionsMessageFunction = (input: {
|
|
4
|
+
inputValue: string;
|
|
5
|
+
}) => string | null;
|
|
3
6
|
declare type Props<T> = {
|
|
4
7
|
name: string;
|
|
5
8
|
/** If not provided it will generate a random id so the label links properly with the text input */
|
|
@@ -14,6 +17,7 @@ declare type Props<T> = {
|
|
|
14
17
|
caption?: React.ReactNode;
|
|
15
18
|
error?: string;
|
|
16
19
|
placeholder?: string;
|
|
20
|
+
noOptionsMessage?: string | NoOptionsMessageFunction;
|
|
17
21
|
disabled?: boolean;
|
|
18
22
|
/** Use a prefix for things like currency symbols (“$”, “¥”, “£”) or icons. */
|
|
19
23
|
prefix?: React.ReactNode;
|
|
@@ -22,5 +26,5 @@ declare type Props<T> = {
|
|
|
22
26
|
menuShouldScrollIntoView?: boolean;
|
|
23
27
|
};
|
|
24
28
|
/** Component to make possible choose from a predefined options. */
|
|
25
|
-
declare const SelectField: <T extends unknown>({ name, id: inputId, value, options, onChange, onBlur, CustomOption: UserCustomOption, SelectedOptionPrefix, label, caption, error, placeholder, disabled, prefix, asToolbarFilter, menuShouldScrollIntoView }: Props<T>) => JSX.Element;
|
|
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;
|
|
26
30
|
export default SelectField;
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var ReactDOM = _interopDefault(require('react-dom'));
|
|
|
7
7
|
var Select = require('react-select');
|
|
8
8
|
var Select__default = _interopDefault(Select);
|
|
9
9
|
var DayPickerInput = _interopDefault(require('react-day-picker/DayPickerInput'));
|
|
10
|
+
var dateFns = require('date-fns');
|
|
10
11
|
var reactDayPicker = require('react-day-picker');
|
|
11
12
|
var dateFnsFormat = _interopDefault(require('date-fns/format'));
|
|
12
13
|
var dateFnsParse = _interopDefault(require('date-fns/parse'));
|
|
@@ -4639,6 +4640,7 @@ var MultiSelectField = function MultiSelectField(_ref) {
|
|
|
4639
4640
|
caption = _ref.caption,
|
|
4640
4641
|
error = _ref.error,
|
|
4641
4642
|
placeholder = _ref.placeholder,
|
|
4643
|
+
noOptionsMessage = _ref.noOptionsMessage,
|
|
4642
4644
|
disabled = _ref.disabled,
|
|
4643
4645
|
_ref$closeOnSelect = _ref.closeOnSelect,
|
|
4644
4646
|
closeOnSelect = _ref$closeOnSelect === void 0 ? false : _ref$closeOnSelect,
|
|
@@ -4660,12 +4662,16 @@ var MultiSelectField = function MultiSelectField(_ref) {
|
|
|
4660
4662
|
caption: caption,
|
|
4661
4663
|
error: controllers.error
|
|
4662
4664
|
};
|
|
4665
|
+
var defaultNoOptionsMessage = noOptionsMessage && typeof noOptionsMessage === 'string' ? function () {
|
|
4666
|
+
return noOptionsMessage;
|
|
4667
|
+
} : undefined;
|
|
4663
4668
|
return React__default.createElement(Field, Object.assign({}, fieldProps), React__default.createElement(Select__default, {
|
|
4664
4669
|
inputId: controllers.id,
|
|
4665
4670
|
options: options,
|
|
4666
4671
|
isDisabled: disabled,
|
|
4667
4672
|
value: controllers.value,
|
|
4668
4673
|
placeholder: placeholder,
|
|
4674
|
+
noOptionsMessage: typeof noOptionsMessage === 'function' ? noOptionsMessage : defaultNoOptionsMessage,
|
|
4669
4675
|
styles: getSelectStyles({
|
|
4670
4676
|
isInvalid: hasError,
|
|
4671
4677
|
wrapToNextLine: true
|
|
@@ -4691,7 +4697,8 @@ var MultiSelectField = function MultiSelectField(_ref) {
|
|
|
4691
4697
|
}
|
|
4692
4698
|
|
|
4693
4699
|
var target = e.target;
|
|
4694
|
-
var
|
|
4700
|
+
var firstOption = target.children[0];
|
|
4701
|
+
var isScrollingTheMenu = firstOption && typeof firstOption.id === 'string' && firstOption.id.includes('react-select');
|
|
4695
4702
|
return !isScrollingTheMenu;
|
|
4696
4703
|
}
|
|
4697
4704
|
}));
|
|
@@ -4798,6 +4805,7 @@ var SelectField = function SelectField(_ref) {
|
|
|
4798
4805
|
caption = _ref.caption,
|
|
4799
4806
|
error = _ref.error,
|
|
4800
4807
|
placeholder = _ref.placeholder,
|
|
4808
|
+
noOptionsMessage = _ref.noOptionsMessage,
|
|
4801
4809
|
disabled = _ref.disabled,
|
|
4802
4810
|
prefix = _ref.prefix,
|
|
4803
4811
|
_ref$asToolbarFilter = _ref.asToolbarFilter,
|
|
@@ -4820,6 +4828,9 @@ var SelectField = function SelectField(_ref) {
|
|
|
4820
4828
|
caption: caption,
|
|
4821
4829
|
error: controllers.error
|
|
4822
4830
|
};
|
|
4831
|
+
var defaultNoOptionsMessage = noOptionsMessage && typeof noOptionsMessage === 'string' ? function () {
|
|
4832
|
+
return noOptionsMessage;
|
|
4833
|
+
} : undefined;
|
|
4823
4834
|
return React__default.createElement(Field, Object.assign({}, fieldProps), React__default.createElement(AffixContainer, {
|
|
4824
4835
|
prefix: prefix
|
|
4825
4836
|
}, React__default.createElement(Select__default, {
|
|
@@ -4828,6 +4839,7 @@ var SelectField = function SelectField(_ref) {
|
|
|
4828
4839
|
isDisabled: disabled,
|
|
4829
4840
|
value: controllers.value,
|
|
4830
4841
|
placeholder: placeholder,
|
|
4842
|
+
noOptionsMessage: typeof noOptionsMessage === 'function' ? noOptionsMessage : defaultNoOptionsMessage,
|
|
4831
4843
|
styles: getSelectStyles({
|
|
4832
4844
|
isInvalid: hasError,
|
|
4833
4845
|
asToolbarFilter: asToolbarFilter
|
|
@@ -4856,7 +4868,8 @@ var SelectField = function SelectField(_ref) {
|
|
|
4856
4868
|
}
|
|
4857
4869
|
|
|
4858
4870
|
var target = e.target;
|
|
4859
|
-
var
|
|
4871
|
+
var firstOption = target.children[0];
|
|
4872
|
+
var isScrollingTheMenu = firstOption && typeof firstOption.id === 'string' && firstOption.id.includes('react-select');
|
|
4860
4873
|
return !isScrollingTheMenu;
|
|
4861
4874
|
}
|
|
4862
4875
|
})));
|
|
@@ -4882,7 +4895,7 @@ var useDateFieldControllers = function useDateFieldControllers(_ref) {
|
|
|
4882
4895
|
error: error,
|
|
4883
4896
|
value: value,
|
|
4884
4897
|
onChange: function onChange(newValue) {
|
|
4885
|
-
return _onChange && _onChange(newValue);
|
|
4898
|
+
return newValue && _onChange && _onChange(dateFns.startOfDay(newValue));
|
|
4886
4899
|
},
|
|
4887
4900
|
onBlur: function onBlur() {
|
|
4888
4901
|
return _onBlur && _onBlur();
|
|
@@ -4895,7 +4908,7 @@ var useDateFieldControllers = function useDateFieldControllers(_ref) {
|
|
|
4895
4908
|
error: error !== undefined ? controllers.error : formikState.error,
|
|
4896
4909
|
value: value !== undefined ? controllers.value : formikState.value,
|
|
4897
4910
|
onChange: _onChange ? controllers.onChange : function (newValue) {
|
|
4898
|
-
formik.setFieldValue(name, newValue === undefined ? null : newValue);
|
|
4911
|
+
formik.setFieldValue(name, newValue === undefined ? null : dateFns.startOfDay(newValue));
|
|
4899
4912
|
},
|
|
4900
4913
|
onBlur: _onBlur ? controllers.onBlur : function () {
|
|
4901
4914
|
return formik.setFieldTouched(name);
|