@7shifts/sous-chef 2.3.1 → 2.3.5

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,7 +4,7 @@ declare type Props<T> = {
4
4
  /** Each element represents a row and each key of the object represents a column */
5
5
  items: Item<T>[];
6
6
  /** For each column element, the `name` property should match the key on `items` */
7
- columns: Column[];
7
+ columns?: Column[];
8
8
  /** A custom component for customizing how the each item is rendered. It pass as props: `item`, `index`, `columnSizes` and `columns` */
9
9
  itemComponent?: React.ComponentType<CustomComponent<T>>;
10
10
  maxHeight?: number;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { Column } from './types';
3
3
  export declare type DataTableContextType = {
4
- columns: Column[];
4
+ columns?: Column[];
5
5
  showActionMenu?: boolean;
6
6
  numberOfRows: number;
7
7
  hasVerticalBorders?: boolean;
@@ -1,18 +1,3 @@
1
- import type { SelectOption } from '../SelectField/types';
2
- import { DateRange } from '../../utils/date';
3
- export declare type FormikType = {
4
- handleSubmit: (e: Object) => void;
5
- setFieldValue: (_: string, __: string | boolean | SelectOption<any> | SelectOption<any>[] | Date | DateRange | null) => void;
6
- setFieldTouched: (e: string) => void;
7
- values: {
8
- [key: string]: any;
9
- };
10
- touched: {
11
- [key: string]: boolean;
12
- };
13
- errors: {
14
- [key: string]: string;
15
- };
16
- isValid: boolean;
17
- dirty: boolean;
18
- };
1
+ import { FormikState, FormikHelpers, FormikHandlers } from 'formik';
2
+ /** The FormValues are `any` here as in Sous Chef we don't care about the shape of the form. We just need to link form fields with the formik state */
3
+ export declare type FormikType = FormikState<any> & FormikHelpers<any> & FormikHandlers;
@@ -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 IconGif: {
8
+ (props: Props): JSX.Element;
9
+ displayName: string;
10
+ };
11
+ export default IconGif;
@@ -57,6 +57,7 @@ export { default as IconFlag } from './IconFlag';
57
57
  export { default as IconFourDotsCircle } from './IconFourDotsCircle';
58
58
  export { default as IconFourSquares } from './IconFourSquares';
59
59
  export { default as IconGavel } from './IconGavel';
60
+ export { default as IconGif } from './IconGif';
60
61
  export { default as IconGift } from './IconGift';
61
62
  export { default as IconGrinBeam } from './IconGrinBeam';
62
63
  export { default as IconGripVertical } from './IconGripVertical';
package/dist/index.css CHANGED
@@ -598,7 +598,7 @@ Please ask a designer if you have questions about which colours to use.
598
598
  border: 1px solid #fff;
599
599
  border-bottom: 1px solid #e0e0e0;
600
600
  }
601
- ._3DlpO:last-child {
601
+ ._3DlpO:last-child:not(._NS-B9) {
602
602
  border-bottom: 1px solid #fff;
603
603
  }
604
604
 
@@ -621,11 +621,20 @@ Please ask a designer if you have questions about which colours to use.
621
621
  box-shadow: 0 0 8px #a7b7ea;
622
622
  }
623
623
  ._NS-B9:first-child {
624
- border-radius: 8px 8px 0 0;
624
+ border-top-left-radius: 8px;
625
+ border-top-right-radius: 8px;
626
+ }
627
+ ._NS-B9:first-child:not(:last-child) {
628
+ border-bottom-left-radius: 0;
629
+ border-bottom-right-radius: 0;
625
630
  }
626
631
  ._NS-B9:last-child {
627
- border-radius: 0 0 8px 8px;
628
- border-bottom: 1px solid #6d87dd;
632
+ border-bottom-left-radius: 8px;
633
+ border-bottom-right-radius: 8px;
634
+ }
635
+ ._NS-B9:last-child:not(:first-child) {
636
+ border-top-left-radius: 0;
637
+ border-top-right-radius: 0;
629
638
  }
630
639
 
631
640
  ._3ENNn {
@@ -664,6 +673,7 @@ Please ask a designer if you have questions about which colours to use.
664
673
  ._3-nHz {
665
674
  display: flex;
666
675
  align-items: center;
676
+ line-height: 21px;
667
677
  }
668
678
  ._2Rh0i {
669
679
  cursor: pointer;
@@ -682,6 +692,7 @@ Please ask a designer if you have questions about which colours to use.
682
692
  ._W7CnY {
683
693
  display: inline-block;
684
694
  padding: 0 8px;
695
+ line-height: 1em;
685
696
  }
686
697
 
687
698
  ._2ygIH {
@@ -734,7 +745,7 @@ Please ask a designer if you have questions about which colours to use.
734
745
  ._1d8Ci {
735
746
  display: flex;
736
747
  }
737
- ._1d8Ci:not(:last-child) {
748
+ ._1d8Ci:not(:last-child):not(._3tb7U) {
738
749
  border-bottom: 1px solid #e0e0e0;
739
750
  }
740
751
 
@@ -757,11 +768,20 @@ Please ask a designer if you have questions about which colours to use.
757
768
  box-shadow: 0 0 8px #a7b7ea;
758
769
  }
759
770
  ._3tb7U:first-child {
760
- border-radius: 8px 8px 0 0;
771
+ border-top-left-radius: 8px;
772
+ border-top-right-radius: 8px;
773
+ }
774
+ ._3tb7U:first-child:not(:last-child) {
775
+ border-bottom-left-radius: 0;
776
+ border-bottom-right-radius: 0;
761
777
  }
762
778
  ._3tb7U:last-child {
763
- border-radius: 0 0 8px 8px;
764
- border-bottom: 1px solid #6d87dd;
779
+ border-bottom-left-radius: 8px;
780
+ border-bottom-right-radius: 8px;
781
+ }
782
+ ._3tb7U:last-child:not(:first-child) {
783
+ border-top-left-radius: 0;
784
+ border-top-right-radius: 0;
765
785
  }
766
786
 
767
787
  ._OTcMc {
@@ -809,6 +829,7 @@ Please ask a designer if you have questions about which colours to use.
809
829
  ._27x4v {
810
830
  display: flex;
811
831
  align-items: center;
832
+ line-height: 21px;
812
833
  }
813
834
  ._27x4v:not(._27x4v:first-child) {
814
835
  padding-left: 16px;
@@ -837,6 +858,7 @@ Please ask a designer if you have questions about which colours to use.
837
858
  ._3VjFP {
838
859
  display: inline-block;
839
860
  padding: 0 8px;
861
+ line-height: 1em;
840
862
  }
841
863
 
842
864
  ._1bTmd {
package/dist/index.js CHANGED
@@ -393,7 +393,9 @@ var TooltipOverlay = function TooltipOverlay(_ref) {
393
393
  }, []);
394
394
  var tooltipRectPosition = tooltipRef === null || tooltipRef === void 0 ? void 0 : (_tooltipRef$current = tooltipRef.current) === null || _tooltipRef$current === void 0 ? void 0 : _tooltipRef$current.getBoundingClientRect();
395
395
  var position = calculatePosition(placement, anchorPosition, tooltipRectPosition);
396
- return React__default.createElement(Portal, null, React__default.createElement("div", null, React__default.createElement("div", {
396
+ return React__default.createElement(Portal, null, React__default.createElement("div", {
397
+ role: "tooltip"
398
+ }, React__default.createElement("div", {
397
399
  ref: tooltipRef,
398
400
  style: _extends({}, position.overlay, {
399
401
  zIndex: Z_INDEX_LAYERS.TOOLTIP
@@ -429,6 +431,7 @@ var Tooltip = function Tooltip(_ref, forwardedRef) {
429
431
  header = _ref.header,
430
432
  extraClass = _ref.extraClass,
431
433
  onClose = _ref.onClose,
434
+ onVisibleChange = _ref.onVisibleChange,
432
435
  children = _ref.children;
433
436
  var checkIsMounted = useIsMounted();
434
437
  var internalRef = React.useRef(null);
@@ -440,6 +443,11 @@ var Tooltip = function Tooltip(_ref, forwardedRef) {
440
443
 
441
444
  var isFocusingOnTooltip = React.useRef(false);
442
445
  var isFocusingOnAnchor = React.useRef(false);
446
+ React.useEffect(function () {
447
+ if (isVisible && !header && !overlay) {
448
+ setIsVisible(false);
449
+ }
450
+ }, [isVisible, header, overlay]);
443
451
 
444
452
  var updateOverlayVisibility = function updateOverlayVisibility(shouldShow) {
445
453
  setIsVisible(shouldShow);
@@ -447,6 +455,10 @@ var Tooltip = function Tooltip(_ref, forwardedRef) {
447
455
  if (!shouldShow) {
448
456
  onClose === null || onClose === void 0 ? void 0 : onClose();
449
457
  }
458
+
459
+ if (onVisibleChange) {
460
+ onVisibleChange(shouldShow);
461
+ }
450
462
  };
451
463
 
452
464
  var onAnchorFocusIn = function onAnchorFocusIn() {
@@ -1801,6 +1813,25 @@ var IconGavel = function IconGavel(props) {
1801
1813
 
1802
1814
  IconGavel.displayName = 'IconGavel';
1803
1815
 
1816
+ var IconGif = function IconGif(props) {
1817
+ return React__default.createElement("svg", Object.assign({
1818
+ viewBox: "0 0 20 20",
1819
+ xmlns: "http://www.w3.org/2000/svg",
1820
+ "data-testid": "icon-gif",
1821
+ style: getIconStyles(props)
1822
+ }, props), React__default.createElement("path", {
1823
+ d: "M18.096 2.85H1.906c-.79 0-1.43.64-1.43 1.429v11.428c0 .79.64 1.429 1.43 1.429h16.19c.789 0 1.428-.64 1.428-1.429V4.28c0-.79-.64-1.429-1.428-1.429Z",
1824
+ stroke: "currentColor",
1825
+ strokeWidth: 0.952,
1826
+ fill: "none"
1827
+ }), React__default.createElement("path", {
1828
+ d: "M7.124 12.541c.876 0 1.592-.373 2.087-.93V9.715H6.804v.785h1.524v.785c-.23.22-.686.457-1.204.457-1.006 0-1.753-.777-1.753-1.836 0-1.074.747-1.836 1.753-1.836a1.64 1.64 0 0 1 1.318.678l.724-.42c-.404-.578-1.052-1.05-2.042-1.05-1.478 0-2.667 1.028-2.667 2.628 0 1.592 1.189 2.636 2.667 2.636Zm3.907-.099V7.36h-.892v5.082h.892Zm1.971 0V10.24h2.538v-.785h-2.538v-1.31h2.59V7.36h-3.481v5.082h.891Z",
1829
+ fill: "currentColor"
1830
+ }));
1831
+ };
1832
+
1833
+ IconGif.displayName = 'IconGif';
1834
+
1804
1835
  var IconGift = function IconGift(props) {
1805
1836
  return React__default.createElement("svg", Object.assign({
1806
1837
  viewBox: "0 0 20 20",
@@ -2861,7 +2892,7 @@ var IconWrench = function IconWrench(props) {
2861
2892
 
2862
2893
  IconWrench.displayName = 'IconWrench';
2863
2894
 
2864
- var styles$6 = {"item":"_3DlpO","clickable":"_2jPpF","selected":"_NS-B9","item-column":"_3ENNn","actions":"_1FTaE"};
2895
+ var styles$6 = {"item":"_3DlpO","selected":"_NS-B9","clickable":"_2jPpF","item-column":"_3ENNn","actions":"_1FTaE"};
2865
2896
 
2866
2897
  var ResourceTableRow = function ResourceTableRow(_ref) {
2867
2898
  var _classnames;
@@ -3178,7 +3209,7 @@ var useDataTableContext = function useDataTableContext() {
3178
3209
  return context;
3179
3210
  };
3180
3211
 
3181
- var styles$9 = {"item":"_1d8Ci","clickable":"_thFcO","selected":"_3tb7U","item-column":"_OTcMc","item-column--default-padding":"_lNHQ8","item-column--right-align":"_13YLe","item-column--vertical-border":"_1rrRr","actions":"_azbIG"};
3212
+ var styles$9 = {"item":"_1d8Ci","selected":"_3tb7U","clickable":"_thFcO","item-column":"_OTcMc","item-column--default-padding":"_lNHQ8","item-column--right-align":"_13YLe","item-column--vertical-border":"_1rrRr","actions":"_azbIG"};
3182
3213
 
3183
3214
  var DataTableRow = function DataTableRow(_ref) {
3184
3215
  var _classnames;
@@ -3366,7 +3397,7 @@ var DataTable = function DataTable(_ref) {
3366
3397
  numberOfRows: numberOfRows,
3367
3398
  hasVerticalBorders: hasVerticalBorders
3368
3399
  }
3369
- }, React__default.createElement("div", null, React__default.createElement(DataTableHeader, {
3400
+ }, React__default.createElement("div", null, columns && React__default.createElement(DataTableHeader, {
3370
3401
  columns: columns,
3371
3402
  onSort: onSort,
3372
3403
  showActionMenu: showActionMenu
@@ -3426,7 +3457,7 @@ var DataTableCell = function DataTableCell(_ref) {
3426
3457
  var _useDataTableContext = useDataTableContext(),
3427
3458
  columns = _useDataTableContext.columns;
3428
3459
 
3429
- var column = (_columns$columnIndex = columns[columnIndex]) != null ? _columns$columnIndex : null;
3460
+ var column = (_columns$columnIndex = columns === null || columns === void 0 ? void 0 : columns[columnIndex]) != null ? _columns$columnIndex : null;
3430
3461
  var isRightAligned = column ? column.isRightAligned : false;
3431
3462
  return React__default.createElement("div", {
3432
3463
  className: classnames((_classnames = {}, _classnames[styles$b['data-table-cell--right-aligned']] = isRightAligned, _classnames), styles$b['data-table-cell'])
@@ -3453,49 +3484,33 @@ var getFormikState = function getFormikState(name, formik) {
3453
3484
  return null;
3454
3485
  }
3455
3486
 
3456
- if (Object.keys(formik.values).includes(name)) {
3457
- return {
3458
- error: formik.touched[name] ? formik.errors[name] : undefined,
3459
- value: formik.values[name]
3460
- };
3461
- }
3487
+ var formikPath = getFormikArrayPath(name);
3462
3488
 
3463
- var formikArray = getFormikArrayPath(name);
3489
+ if (formikPath.length === 0) {
3490
+ return null;
3491
+ }
3464
3492
 
3465
- if (formikArray) {
3466
- var _formik$touched, _formik$touched$array, _formik$touched$array2, _formik$errors, _formik$errors$arrayN, _formik$errors$arrayN2, _formik$values, _formik$values$arrayN, _formik$values$arrayN2;
3493
+ var formikLatestLevel = formikPath.reduce(function (acc, path) {
3494
+ var _acc$touched, _acc$error, _acc$value;
3467
3495
 
3468
- var arrayName = formikArray.arrayName,
3469
- itemIndex = formikArray.itemIndex,
3470
- fieldName = formikArray.fieldName;
3471
3496
  return {
3472
- error: (_formik$touched = formik.touched) !== null && _formik$touched !== void 0 && (_formik$touched$array = _formik$touched[arrayName]) !== null && _formik$touched$array !== void 0 && (_formik$touched$array2 = _formik$touched$array[itemIndex]) !== null && _formik$touched$array2 !== void 0 && _formik$touched$array2[fieldName] ? (_formik$errors = formik.errors) === null || _formik$errors === void 0 ? void 0 : (_formik$errors$arrayN = _formik$errors[arrayName]) === null || _formik$errors$arrayN === void 0 ? void 0 : (_formik$errors$arrayN2 = _formik$errors$arrayN[itemIndex]) === null || _formik$errors$arrayN2 === void 0 ? void 0 : _formik$errors$arrayN2[fieldName] : undefined,
3473
- value: (_formik$values = formik.values) === null || _formik$values === void 0 ? void 0 : (_formik$values$arrayN = _formik$values[arrayName]) === null || _formik$values$arrayN === void 0 ? void 0 : (_formik$values$arrayN2 = _formik$values$arrayN[itemIndex]) === null || _formik$values$arrayN2 === void 0 ? void 0 : _formik$values$arrayN2[fieldName]
3497
+ touched: (_acc$touched = acc.touched) === null || _acc$touched === void 0 ? void 0 : _acc$touched[path],
3498
+ error: (_acc$error = acc.error) === null || _acc$error === void 0 ? void 0 : _acc$error[path],
3499
+ value: (_acc$value = acc.value) === null || _acc$value === void 0 ? void 0 : _acc$value[path]
3474
3500
  };
3475
- }
3476
-
3477
- return null;
3478
- };
3479
-
3480
- var getFormikArrayPath = function getFormikArrayPath(name) {
3481
- if (!name.includes('[')) {
3482
- return false;
3483
- }
3484
-
3485
- var _name$split = name.split('['),
3486
- arrayName = _name$split[0],
3487
- missingSplit = _name$split[1];
3488
-
3489
- var _missingSplit$split = missingSplit.split('].'),
3490
- itemIndex = _missingSplit$split[0],
3491
- fieldName = _missingSplit$split[1];
3492
-
3501
+ }, {
3502
+ touched: formik.touched,
3503
+ error: formik.errors,
3504
+ value: formik.values
3505
+ });
3493
3506
  return {
3494
- arrayName: arrayName,
3495
- itemIndex: itemIndex,
3496
- fieldName: fieldName
3507
+ error: formikLatestLevel.touched ? formikLatestLevel.error : undefined,
3508
+ value: formikLatestLevel.value
3497
3509
  };
3498
3510
  };
3511
+ var getFormikArrayPath = function getFormikArrayPath(name) {
3512
+ return name.split(/[^a-zA-Z0-9]/).filter(Boolean);
3513
+ };
3499
3514
 
3500
3515
  var useFieldControllers = function useFieldControllers(_ref) {
3501
3516
  var name = _ref.name,
@@ -3695,9 +3710,9 @@ var DataTableEditableCell = function DataTableEditableCell(_ref) {
3695
3710
  columns = _useDataTableContext.columns,
3696
3711
  numberOfRows = _useDataTableContext.numberOfRows;
3697
3712
 
3698
- var column = (_columns$columnIndex = columns[columnIndex]) != null ? _columns$columnIndex : null;
3713
+ var column = (_columns$columnIndex = columns === null || columns === void 0 ? void 0 : columns[columnIndex]) != null ? _columns$columnIndex : null;
3699
3714
  var isRightAligned = column ? column.isRightAligned : false;
3700
- var numberOfColumns = columns === null || columns === void 0 ? void 0 : columns.length;
3715
+ var numberOfColumns = (columns === null || columns === void 0 ? void 0 : columns.length) || 0;
3701
3716
  var isTopLeftCell = columnIndex === 0 && rowIndex === 0;
3702
3717
  var isTopRightCell = columnIndex === numberOfColumns - 1 && rowIndex === 0;
3703
3718
  var isBottomLeftCell = columnIndex === 0 && rowIndex === numberOfRows - 1;
@@ -4895,7 +4910,7 @@ var useDateFieldControllers = function useDateFieldControllers(_ref) {
4895
4910
  error: error,
4896
4911
  value: value,
4897
4912
  onChange: function onChange(newValue) {
4898
- return newValue && _onChange && _onChange(dateFns.startOfDay(newValue));
4913
+ return _onChange && _onChange(dateFns.isDate(newValue) ? dateFns.startOfDay(newValue) : newValue);
4899
4914
  },
4900
4915
  onBlur: function onBlur() {
4901
4916
  return _onBlur && _onBlur();
@@ -5873,6 +5888,7 @@ exports.IconFlag = IconFlag;
5873
5888
  exports.IconFourDotsCircle = IconFourDotsCircle;
5874
5889
  exports.IconFourSquares = IconFourSquares;
5875
5890
  exports.IconGavel = IconGavel;
5891
+ exports.IconGif = IconGif;
5876
5892
  exports.IconGift = IconGift;
5877
5893
  exports.IconGrinBeam = IconGrinBeam;
5878
5894
  exports.IconGripVertical = IconGripVertical;