@7shifts/sous-chef 2.2.0 → 2.3.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.
@@ -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;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { IconSize } from '../types';
3
+ declare type Props = {
4
+ size?: IconSize;
5
+ color?: string;
6
+ } & React.SVGProps<SVGSVGElement>;
7
+ declare const IconGavel: {
8
+ (props: Props): JSX.Element;
9
+ displayName: string;
10
+ };
11
+ export default IconGavel;
@@ -56,6 +56,7 @@ export { default as IconFile } from './IconFile';
56
56
  export { default as IconFlag } from './IconFlag';
57
57
  export { default as IconFourDotsCircle } from './IconFourDotsCircle';
58
58
  export { default as IconFourSquares } from './IconFourSquares';
59
+ export { default as IconGavel } from './IconGavel';
59
60
  export { default as IconGift } from './IconGift';
60
61
  export { default as IconGrinBeam } from './IconGrinBeam';
61
62
  export { default as IconGripVertical } from './IconGripVertical';
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'));
@@ -1785,6 +1786,21 @@ var IconFourSquares = function IconFourSquares(props) {
1785
1786
 
1786
1787
  IconFourSquares.displayName = 'IconFourSquares';
1787
1788
 
1789
+ var IconGavel = function IconGavel(props) {
1790
+ return React__default.createElement("svg", Object.assign({
1791
+ viewBox: "0 0 60 60",
1792
+ fill: "none",
1793
+ xmlns: "http://www.w3.org/2000/svg",
1794
+ "data-testid": "icon-gavel",
1795
+ style: getIconStyles(props)
1796
+ }, props), React__default.createElement("path", {
1797
+ d: "m58.698 21.863-2.418-2.42a4.442 4.442 0 0 0-5.476-.638l-9.61-9.609a4.442 4.442 0 0 0-.638-5.476l-2.418-2.418a4.438 4.438 0 0 0-6.28 0L18.551 14.605a4.446 4.446 0 0 0 0 6.28l2.42 2.42a4.448 4.448 0 0 0 5.475.637l3.48 3.48-6.891 6.89-.947-.946a5.095 5.095 0 0 0-7.198 0l-13.403 13.4a5.095 5.095 0 0 0 0 7.198l4.548 4.548a5.095 5.095 0 0 0 7.197 0l13.401-13.403a5.095 5.095 0 0 0 0-7.198l-.947-.947 6.891-6.89 3.48 3.479a4.449 4.449 0 0 0 .637 5.476l2.42 2.419a4.446 4.446 0 0 0 6.28 0l13.303-13.305a4.439 4.439 0 0 0 0-6.28ZM23.983 42.457l-13.401 13.4a1.34 1.34 0 0 1-1.894 0l-4.546-4.545a1.34 1.34 0 0 1 0-1.894l13.401-13.4a1.34 1.34 0 0 1 1.894 0l4.546 4.545a1.341 1.341 0 0 1 0 1.894Zm32.065-16.966L42.743 38.796a.69.69 0 0 1-.977 0l-2.42-2.42a.691.691 0 0 1 0-.976l1.932-1.93L26.53 18.721l-1.93 1.931a.692.692 0 0 1-.978 0l-2.419-2.419a.692.692 0 0 1 0-.977L34.51 3.952a.691.691 0 0 1 .977 0l2.419 2.42a.691.691 0 0 1 0 .976l-1.93 1.931L50.72 24.026l1.931-1.93a.69.69 0 0 1 .977 0l2.419 2.418a.692.692 0 0 1 0 .977Z",
1798
+ fill: "currentColor"
1799
+ }));
1800
+ };
1801
+
1802
+ IconGavel.displayName = 'IconGavel';
1803
+
1788
1804
  var IconGift = function IconGift(props) {
1789
1805
  return React__default.createElement("svg", Object.assign({
1790
1806
  viewBox: "0 0 20 20",
@@ -4499,7 +4515,7 @@ var getSelectStyles = function getSelectStyles(_ref) {
4499
4515
  return Object.assign({}, base, {
4500
4516
  flex: '1',
4501
4517
  fontFamily: FONT_FAMILY,
4502
- minWidth: '64px',
4518
+ minWidth: '110px',
4503
4519
  backgroundColor: state.isDisabled && !asToolbarFilter ? GREY100 : WHITE,
4504
4520
  position: 'initial'
4505
4521
  });
@@ -4544,11 +4560,12 @@ var getSelectStyles = function getSelectStyles(_ref) {
4544
4560
  return Object.assign({}, base, {
4545
4561
  color: state.isDisabled ? GREY400 : null,
4546
4562
  marginRight: 0,
4547
- position: 'static',
4563
+ position: asToolbarFilter ? 'static' : 'absolute',
4548
4564
  transform: 'initial',
4549
4565
  overflow: 'hidden',
4550
4566
  textOverflow: 'ellipsis',
4551
- whiteSpace: 'nowrap'
4567
+ whiteSpace: 'nowrap',
4568
+ top: !asToolbarFilter && 'auto'
4552
4569
  });
4553
4570
  },
4554
4571
  dropdownIndicator: function dropdownIndicator(base, state) {
@@ -4563,7 +4580,8 @@ var getSelectStyles = function getSelectStyles(_ref) {
4563
4580
  color: state.isDisabled ? GREY400 : state.isSelected ? EGGPLANT700 : GREY500,
4564
4581
  cursor: 'pointer',
4565
4582
  fontFamily: FONT_FAMILY,
4566
- fontSize: '14px'
4583
+ fontSize: '14px',
4584
+ wordBreak: 'break-word'
4567
4585
  });
4568
4586
  },
4569
4587
  group: function group(base) {
@@ -4622,6 +4640,7 @@ var MultiSelectField = function MultiSelectField(_ref) {
4622
4640
  caption = _ref.caption,
4623
4641
  error = _ref.error,
4624
4642
  placeholder = _ref.placeholder,
4643
+ noOptionsMessage = _ref.noOptionsMessage,
4625
4644
  disabled = _ref.disabled,
4626
4645
  _ref$closeOnSelect = _ref.closeOnSelect,
4627
4646
  closeOnSelect = _ref$closeOnSelect === void 0 ? false : _ref$closeOnSelect,
@@ -4643,12 +4662,16 @@ var MultiSelectField = function MultiSelectField(_ref) {
4643
4662
  caption: caption,
4644
4663
  error: controllers.error
4645
4664
  };
4665
+ var defaultNoOptionsMessage = noOptionsMessage && typeof noOptionsMessage === 'string' ? function () {
4666
+ return noOptionsMessage;
4667
+ } : undefined;
4646
4668
  return React__default.createElement(Field, Object.assign({}, fieldProps), React__default.createElement(Select__default, {
4647
4669
  inputId: controllers.id,
4648
4670
  options: options,
4649
4671
  isDisabled: disabled,
4650
4672
  value: controllers.value,
4651
4673
  placeholder: placeholder,
4674
+ noOptionsMessage: typeof noOptionsMessage === 'function' ? noOptionsMessage : defaultNoOptionsMessage,
4652
4675
  styles: getSelectStyles({
4653
4676
  isInvalid: hasError,
4654
4677
  wrapToNextLine: true
@@ -4674,7 +4697,8 @@ var MultiSelectField = function MultiSelectField(_ref) {
4674
4697
  }
4675
4698
 
4676
4699
  var target = e.target;
4677
- var isScrollingTheMenu = typeof target.className === 'string' && target.className.includes('MenuList');
4700
+ var firstOption = target.children[0];
4701
+ var isScrollingTheMenu = firstOption && typeof firstOption.id === 'string' && firstOption.id.includes('react-select');
4678
4702
  return !isScrollingTheMenu;
4679
4703
  }
4680
4704
  }));
@@ -4781,6 +4805,7 @@ var SelectField = function SelectField(_ref) {
4781
4805
  caption = _ref.caption,
4782
4806
  error = _ref.error,
4783
4807
  placeholder = _ref.placeholder,
4808
+ noOptionsMessage = _ref.noOptionsMessage,
4784
4809
  disabled = _ref.disabled,
4785
4810
  prefix = _ref.prefix,
4786
4811
  _ref$asToolbarFilter = _ref.asToolbarFilter,
@@ -4803,6 +4828,9 @@ var SelectField = function SelectField(_ref) {
4803
4828
  caption: caption,
4804
4829
  error: controllers.error
4805
4830
  };
4831
+ var defaultNoOptionsMessage = noOptionsMessage && typeof noOptionsMessage === 'string' ? function () {
4832
+ return noOptionsMessage;
4833
+ } : undefined;
4806
4834
  return React__default.createElement(Field, Object.assign({}, fieldProps), React__default.createElement(AffixContainer, {
4807
4835
  prefix: prefix
4808
4836
  }, React__default.createElement(Select__default, {
@@ -4811,6 +4839,7 @@ var SelectField = function SelectField(_ref) {
4811
4839
  isDisabled: disabled,
4812
4840
  value: controllers.value,
4813
4841
  placeholder: placeholder,
4842
+ noOptionsMessage: typeof noOptionsMessage === 'function' ? noOptionsMessage : defaultNoOptionsMessage,
4814
4843
  styles: getSelectStyles({
4815
4844
  isInvalid: hasError,
4816
4845
  asToolbarFilter: asToolbarFilter
@@ -4839,7 +4868,8 @@ var SelectField = function SelectField(_ref) {
4839
4868
  }
4840
4869
 
4841
4870
  var target = e.target;
4842
- var isScrollingTheMenu = typeof target.className === 'string' && target.className.includes('MenuList');
4871
+ var firstOption = target.children[0];
4872
+ var isScrollingTheMenu = firstOption && typeof firstOption.id === 'string' && firstOption.id.includes('react-select');
4843
4873
  return !isScrollingTheMenu;
4844
4874
  }
4845
4875
  })));
@@ -4865,7 +4895,7 @@ var useDateFieldControllers = function useDateFieldControllers(_ref) {
4865
4895
  error: error,
4866
4896
  value: value,
4867
4897
  onChange: function onChange(newValue) {
4868
- return _onChange && _onChange(newValue);
4898
+ return _onChange && _onChange(dateFns.isDate(newValue) ? dateFns.startOfDay(newValue) : newValue);
4869
4899
  },
4870
4900
  onBlur: function onBlur() {
4871
4901
  return _onBlur && _onBlur();
@@ -4878,7 +4908,7 @@ var useDateFieldControllers = function useDateFieldControllers(_ref) {
4878
4908
  error: error !== undefined ? controllers.error : formikState.error,
4879
4909
  value: value !== undefined ? controllers.value : formikState.value,
4880
4910
  onChange: _onChange ? controllers.onChange : function (newValue) {
4881
- formik.setFieldValue(name, newValue === undefined ? null : newValue);
4911
+ formik.setFieldValue(name, newValue === undefined ? null : dateFns.startOfDay(newValue));
4882
4912
  },
4883
4913
  onBlur: _onBlur ? controllers.onBlur : function () {
4884
4914
  return formik.setFieldTouched(name);
@@ -5842,6 +5872,7 @@ exports.IconFilePdf = IconFilePdf;
5842
5872
  exports.IconFlag = IconFlag;
5843
5873
  exports.IconFourDotsCircle = IconFourDotsCircle;
5844
5874
  exports.IconFourSquares = IconFourSquares;
5875
+ exports.IconGavel = IconGavel;
5845
5876
  exports.IconGift = IconGift;
5846
5877
  exports.IconGrinBeam = IconGrinBeam;
5847
5878
  exports.IconGripVertical = IconGripVertical;