@7shifts/sous-chef 3.44.14 → 3.44.16
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,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Props } from './SelectField';
|
|
3
|
-
export declare const useSelectField: <T extends unknown>({ asToolbarFilter, caption, disabled, error, id, isClearable, label, menuShouldScrollIntoView
|
|
3
|
+
export declare const useSelectField: <T extends unknown>({ asToolbarFilter, caption, disabled, error, id, isClearable, label, menuShouldScrollIntoView, name, noOptionsMessage, options, onBlur, onChange, placeholder, value, defaultValue, CustomOption: UserCustomOption, SelectedOptionPrefix, testId, creatableButton, onCreate, isSearchable, autoFocus }: Props<T>) => {
|
|
4
4
|
selectProps: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
[x: number]: any;
|
package/dist/index.js
CHANGED
|
@@ -6280,7 +6280,7 @@ var useDropdownContext = function useDropdownContext() {
|
|
|
6280
6280
|
|
|
6281
6281
|
var styles$f = {"dropdown-pane":"_XcD7g"};
|
|
6282
6282
|
|
|
6283
|
-
var
|
|
6283
|
+
var DROPDOWN_PANE_PADDING = 14;
|
|
6284
6284
|
var calculateOverlayPosition$1 = function calculateOverlayPosition(triggerPosition, triggerOffsetHeight, panePosition, alignment) {
|
|
6285
6285
|
var calculateLeftPosition = alignment === 'right' ? getRightAlignmentPosition : getLeftAlignmentPosition;
|
|
6286
6286
|
return {
|
|
@@ -6294,20 +6294,20 @@ var getTopPosition = function getTopPosition(triggerPosition, triggerOffsetHeigh
|
|
|
6294
6294
|
var fitTop = triggerPosition.top - paneHeight > 0;
|
|
6295
6295
|
var cannotFitBotton = top + paneHeight > documentHeight;
|
|
6296
6296
|
if (cannotFitBotton && fitTop) {
|
|
6297
|
-
return top - paneHeight - triggerOffsetHeight -
|
|
6297
|
+
return top - paneHeight - triggerOffsetHeight - DROPDOWN_PANE_PADDING;
|
|
6298
6298
|
}
|
|
6299
6299
|
return top;
|
|
6300
6300
|
};
|
|
6301
6301
|
var getRightAlignmentPosition = function getRightAlignmentPosition(triggerPosition, paneWidth) {
|
|
6302
6302
|
var left = triggerPosition.left + triggerPosition.width - paneWidth;
|
|
6303
|
-
if (left <
|
|
6303
|
+
if (left < DROPDOWN_PANE_PADDING) {
|
|
6304
6304
|
return triggerPosition.left;
|
|
6305
6305
|
}
|
|
6306
6306
|
return left;
|
|
6307
6307
|
};
|
|
6308
6308
|
var getLeftAlignmentPosition = function getLeftAlignmentPosition(triggerPosition, paneWidth) {
|
|
6309
6309
|
var left = triggerPosition.left;
|
|
6310
|
-
if (left + paneWidth > window.innerWidth -
|
|
6310
|
+
if (left + paneWidth > window.innerWidth - DROPDOWN_PANE_PADDING) {
|
|
6311
6311
|
return triggerPosition.left + triggerPosition.width - paneWidth;
|
|
6312
6312
|
}
|
|
6313
6313
|
return left;
|
|
@@ -6318,6 +6318,15 @@ var getDocumentHeight = function getDocumentHeight() {
|
|
|
6318
6318
|
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
6319
6319
|
return height;
|
|
6320
6320
|
};
|
|
6321
|
+
var calculateMaxHeight = function calculateMaxHeight(triggerPosition, customMaxHeight) {
|
|
6322
|
+
var MIN_HEIGHT_FIT = 200;
|
|
6323
|
+
var triggerDistanceFromTheBottom = window.innerHeight - triggerPosition.top - triggerPosition.height;
|
|
6324
|
+
var calculatedMaxHeight = triggerPosition.top - DROPDOWN_PANE_PADDING;
|
|
6325
|
+
if (triggerDistanceFromTheBottom > MIN_HEIGHT_FIT) {
|
|
6326
|
+
calculatedMaxHeight = triggerDistanceFromTheBottom - DROPDOWN_PANE_PADDING;
|
|
6327
|
+
}
|
|
6328
|
+
return customMaxHeight !== undefined && customMaxHeight < calculatedMaxHeight ? customMaxHeight : calculatedMaxHeight;
|
|
6329
|
+
};
|
|
6321
6330
|
|
|
6322
6331
|
function useOnClickOutsideRole(role, cb) {
|
|
6323
6332
|
React__default.useEffect(function () {
|
|
@@ -6367,20 +6376,7 @@ var PaneOverlay = function PaneOverlay(_ref) {
|
|
|
6367
6376
|
return customMaxHeight;
|
|
6368
6377
|
}
|
|
6369
6378
|
var triggerPosition = triggerRef.current.getBoundingClientRect();
|
|
6370
|
-
|
|
6371
|
-
var triggerDistanceFromTheBottom = window.innerHeight - triggerPosition.top + triggerPosition.height;
|
|
6372
|
-
console.log({
|
|
6373
|
-
triggerDistanceFromTheBottom: triggerDistanceFromTheBottom,
|
|
6374
|
-
'window.innerHeight': window.innerHeight,
|
|
6375
|
-
'triggerPosition.top': triggerPosition.top,
|
|
6376
|
-
'triggerPosition.height': triggerPosition.height
|
|
6377
|
-
});
|
|
6378
|
-
if (triggerDistanceFromTheBottom > MIN_HEIGHT_FIT) {
|
|
6379
|
-
console.log('fit bottom', triggerDistanceFromTheBottom - 36);
|
|
6380
|
-
return triggerDistanceFromTheBottom - 36;
|
|
6381
|
-
}
|
|
6382
|
-
console.log('fit top', triggerPosition.top - 36);
|
|
6383
|
-
return triggerPosition.top - 36;
|
|
6379
|
+
return calculateMaxHeight(triggerPosition, customMaxHeight);
|
|
6384
6380
|
}),
|
|
6385
6381
|
maxHeight = _useState2[0];
|
|
6386
6382
|
React.useEffect(function () {
|
|
@@ -6423,11 +6419,11 @@ var PaneOverlay = function PaneOverlay(_ref) {
|
|
|
6423
6419
|
}, children);
|
|
6424
6420
|
};
|
|
6425
6421
|
|
|
6426
|
-
var GAP
|
|
6422
|
+
var GAP = 15;
|
|
6427
6423
|
var isGoingTowardsPane = function isGoingTowardsPane(panePosition, mouseYAxisPosition) {
|
|
6428
|
-
var isGoingTowardsPane = mouseYAxisPosition + GAP
|
|
6424
|
+
var isGoingTowardsPane = mouseYAxisPosition + GAP > panePosition.top;
|
|
6429
6425
|
if (mouseYAxisPosition > panePosition.top) {
|
|
6430
|
-
return mouseYAxisPosition - GAP
|
|
6426
|
+
return mouseYAxisPosition - GAP < panePosition.bottom;
|
|
6431
6427
|
}
|
|
6432
6428
|
return isGoingTowardsPane;
|
|
6433
6429
|
};
|
|
@@ -9483,18 +9479,6 @@ function CustomMenu(_ref) {
|
|
|
9483
9479
|
}, __('createButton'))))));
|
|
9484
9480
|
}
|
|
9485
9481
|
|
|
9486
|
-
var useShouldScrollMenuIntoView = function useShouldScrollMenuIntoView(menuShouldScrollIntoView) {
|
|
9487
|
-
var _useModalContext = useModalContext(),
|
|
9488
|
-
isModalMounted = _useModalContext.isModalMounted;
|
|
9489
|
-
if (menuShouldScrollIntoView !== undefined) {
|
|
9490
|
-
return menuShouldScrollIntoView;
|
|
9491
|
-
}
|
|
9492
|
-
if (isModalMounted) {
|
|
9493
|
-
return false;
|
|
9494
|
-
}
|
|
9495
|
-
return true;
|
|
9496
|
-
};
|
|
9497
|
-
|
|
9498
9482
|
var useSelectField = function useSelectField(_ref) {
|
|
9499
9483
|
var _ref$asToolbarFilter = _ref.asToolbarFilter,
|
|
9500
9484
|
asToolbarFilter = _ref$asToolbarFilter === void 0 ? false : _ref$asToolbarFilter,
|
|
@@ -9505,7 +9489,8 @@ var useSelectField = function useSelectField(_ref) {
|
|
|
9505
9489
|
_ref$isClearable = _ref.isClearable,
|
|
9506
9490
|
isClearable = _ref$isClearable === void 0 ? false : _ref$isClearable,
|
|
9507
9491
|
label = _ref.label,
|
|
9508
|
-
|
|
9492
|
+
_ref$menuShouldScroll = _ref.menuShouldScrollIntoView,
|
|
9493
|
+
menuShouldScrollIntoView = _ref$menuShouldScroll === void 0 ? false : _ref$menuShouldScroll,
|
|
9509
9494
|
name = _ref.name,
|
|
9510
9495
|
noOptionsMessage = _ref.noOptionsMessage,
|
|
9511
9496
|
options = _ref.options,
|
|
@@ -9522,7 +9507,6 @@ var useSelectField = function useSelectField(_ref) {
|
|
|
9522
9507
|
_ref$isSearchable = _ref.isSearchable,
|
|
9523
9508
|
isSearchable = _ref$isSearchable === void 0 ? true : _ref$isSearchable,
|
|
9524
9509
|
autoFocus = _ref.autoFocus;
|
|
9525
|
-
var menuShouldScrollIntoView = useShouldScrollMenuIntoView(menuShouldScrollIntoViewProp);
|
|
9526
9510
|
var _useState = React.useState(false),
|
|
9527
9511
|
isMenuInputFocus = _useState[0],
|
|
9528
9512
|
setIsMenuInputFocus = _useState[1];
|
|
@@ -10611,6 +10595,18 @@ var PasswordField = function PasswordField(_ref) {
|
|
|
10611
10595
|
}))));
|
|
10612
10596
|
};
|
|
10613
10597
|
|
|
10598
|
+
var useShouldScrollMenuIntoView = function useShouldScrollMenuIntoView(menuShouldScrollIntoView) {
|
|
10599
|
+
var _useModalContext = useModalContext(),
|
|
10600
|
+
isModalMounted = _useModalContext.isModalMounted;
|
|
10601
|
+
if (menuShouldScrollIntoView !== undefined) {
|
|
10602
|
+
return menuShouldScrollIntoView;
|
|
10603
|
+
}
|
|
10604
|
+
if (isModalMounted) {
|
|
10605
|
+
return false;
|
|
10606
|
+
}
|
|
10607
|
+
return true;
|
|
10608
|
+
};
|
|
10609
|
+
|
|
10614
10610
|
var MultiSelectField = function MultiSelectField(_ref) {
|
|
10615
10611
|
var name = _ref.name,
|
|
10616
10612
|
inputId = _ref.id,
|