@homebound/beam 2.71.1 → 2.71.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.
- package/dist/components/Modal/OpenModal.d.ts +11 -6
- package/dist/components/Modal/OpenModal.js +15 -5
- package/dist/components/internal/Option.js +1 -5
- package/dist/forms/FormLines.js +2 -1
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/index.js +1 -0
- package/dist/inputs/internal/ListBox.d.ts +2 -2
- package/dist/inputs/internal/ListBox.js +15 -5
- package/dist/inputs/internal/SelectFieldBase.js +2 -1
- package/package.json +1 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { ModalProps } from "./Modal";
|
|
2
|
+
export interface OpenModalProps {
|
|
3
|
+
/** The custom modal content to show. */
|
|
4
|
+
children: JSX.Element;
|
|
5
|
+
/** The size to use. */
|
|
6
|
+
size?: ModalProps["size"];
|
|
7
|
+
/** Whether to force the modal to stay open. This is useful for stories where ruler/tape extensions cause the modal to close. */
|
|
8
|
+
keepOpen?: boolean;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
|
-
* A component for testing open modals in unit tests.
|
|
11
|
+
* A component for testing open modals in stories and unit tests.
|
|
4
12
|
*
|
|
5
|
-
*
|
|
13
|
+
* Currently, calling `render(<ModalComponent />)` in a test currently doesn't work, because
|
|
6
14
|
* nothing has called `useModal` to get the header & footer mounted into the DOM.
|
|
7
15
|
*
|
|
8
16
|
* So instead tests can call:
|
|
@@ -18,7 +26,4 @@ import { ModalProps } from "./Modal";
|
|
|
18
26
|
* And `OpenModal` will do a boilerplate `openModal` call, so that the content
|
|
19
27
|
* shows up in the DOM as expected.
|
|
20
28
|
*/
|
|
21
|
-
export declare function OpenModal(props:
|
|
22
|
-
children: JSX.Element;
|
|
23
|
-
size?: ModalProps["size"];
|
|
24
|
-
}): JSX.Element;
|
|
29
|
+
export declare function OpenModal(props: OpenModalProps): JSX.Element;
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OpenModal = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const Modal_1 = require("./Modal");
|
|
6
7
|
const useModal_1 = require("./useModal");
|
|
7
8
|
/**
|
|
8
|
-
* A component for testing open modals in unit tests.
|
|
9
|
+
* A component for testing open modals in stories and unit tests.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
+
* Currently, calling `render(<ModalComponent />)` in a test currently doesn't work, because
|
|
11
12
|
* nothing has called `useModal` to get the header & footer mounted into the DOM.
|
|
12
13
|
*
|
|
13
14
|
* So instead tests can call:
|
|
@@ -25,8 +26,17 @@ const useModal_1 = require("./useModal");
|
|
|
25
26
|
*/
|
|
26
27
|
function OpenModal(props) {
|
|
27
28
|
const { openModal } = (0, useModal_1.useModal)();
|
|
28
|
-
const { size, children } = props;
|
|
29
|
-
(0, react_1.useEffect)(() =>
|
|
30
|
-
|
|
29
|
+
const { size, children, keepOpen } = props;
|
|
30
|
+
(0, react_1.useEffect)(() => {
|
|
31
|
+
if (!keepOpen) {
|
|
32
|
+
openModal({ size, content: children });
|
|
33
|
+
}
|
|
34
|
+
}, [keepOpen, openModal, size, children]);
|
|
35
|
+
if (keepOpen) {
|
|
36
|
+
return (0, jsx_runtime_1.jsx)(Modal_1.Modal, { size: size, content: children }, void 0);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return (0, jsx_runtime_1.jsx)("div", { children: "dummy content" }, void 0);
|
|
40
|
+
}
|
|
31
41
|
}
|
|
32
42
|
exports.OpenModal = OpenModal;
|
|
@@ -27,11 +27,7 @@ function Option({ item, state, contrast = false, }) {
|
|
|
27
27
|
key: item.key,
|
|
28
28
|
isDisabled,
|
|
29
29
|
isSelected,
|
|
30
|
-
|
|
31
|
-
// 2) have the menu drawn under their mouse cursor, 3) release their press
|
|
32
|
-
// and useSelectableItem will fire onPress/select and cause the
|
|
33
|
-
// accidentally-selected item to be added to the list.
|
|
34
|
-
shouldSelectOnPressUp: false,
|
|
30
|
+
shouldSelectOnPressUp: true,
|
|
35
31
|
shouldFocusOnHover: true,
|
|
36
32
|
shouldUseVirtualFocus: true,
|
|
37
33
|
}, state, ref);
|
package/dist/forms/FormLines.js
CHANGED
|
@@ -16,7 +16,8 @@ function FormLines(props) {
|
|
|
16
16
|
const { children, width = "full", labelSuffix = settings.labelSuffix } = props;
|
|
17
17
|
let firstFormHeading = true;
|
|
18
18
|
return ((0, jsx_runtime_1.jsx)(FormContext_1.FormContext.Provider, Object.assign({ value: { labelSuffix } }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
|
|
19
|
-
|
|
19
|
+
// Note that we're purposefully not using display:flex so that our children's margins will collapse.
|
|
20
|
+
...Css_1.Css.w(sizes[width]).$,
|
|
20
21
|
// Purposefully use this instead of childGap3 to put margin-bottom on the last line
|
|
21
22
|
"& > *": Css_1.Css.mb2.$,
|
|
22
23
|
} }, { children: react_1.Children.map(children, (child) => {
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./BoundSwitchField";
|
|
|
10
10
|
export * from "./BoundTextAreaField";
|
|
11
11
|
export * from "./BoundTextField";
|
|
12
12
|
export * from "./BoundToggleChipGroupField";
|
|
13
|
+
export * from "./FormHeading";
|
|
13
14
|
export * from "./FormLines";
|
|
14
15
|
export * from "./StaticField";
|
|
15
16
|
export * from "./StaticLinkField";
|
package/dist/forms/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./BoundSwitchField"), exports);
|
|
|
22
22
|
__exportStar(require("./BoundTextAreaField"), exports);
|
|
23
23
|
__exportStar(require("./BoundTextField"), exports);
|
|
24
24
|
__exportStar(require("./BoundToggleChipGroupField"), exports);
|
|
25
|
+
__exportStar(require("./FormHeading"), exports);
|
|
25
26
|
__exportStar(require("./FormLines"), exports);
|
|
26
27
|
__exportStar(require("./StaticField"), exports);
|
|
27
28
|
__exportStar(require("./StaticLinkField"), exports);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Key, MutableRefObject } from "react";
|
|
1
|
+
import React, { Key, MutableRefObject } from "react";
|
|
2
2
|
import { SelectState } from "react-stately";
|
|
3
3
|
interface ListBoxProps<O, V extends Key> {
|
|
4
4
|
compact: boolean;
|
|
5
5
|
listBoxRef: MutableRefObject<HTMLDivElement | null>;
|
|
6
6
|
state: SelectState<O>;
|
|
7
|
-
maxListHeight?: number;
|
|
8
7
|
selectedOptions: O[];
|
|
9
8
|
getOptionLabel: (opt: O) => string;
|
|
10
9
|
getOptionValue: (opt: O) => V;
|
|
11
10
|
contrast?: boolean;
|
|
11
|
+
positionProps: React.HTMLAttributes<Element>;
|
|
12
12
|
}
|
|
13
13
|
/** A ListBox is an internal component used by SelectField and MultiSelectField to display the list of options */
|
|
14
14
|
export declare function ListBox<O, V extends Key>(props: ListBoxProps<O, V>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -10,11 +10,19 @@ const index_1 = require("../../components/internal/index");
|
|
|
10
10
|
const Css_1 = require("../../Css");
|
|
11
11
|
/** A ListBox is an internal component used by SelectField and MultiSelectField to display the list of options */
|
|
12
12
|
function ListBox(props) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// 6.5 options in view at a time (doing `.5` so the user can easily tell if there are more).
|
|
16
|
-
maxListHeight = 273, selectedOptions, getOptionLabel, getOptionValue, contrast = false, ...otherProps } = props;
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { state, compact, listBoxRef, selectedOptions, getOptionLabel, getOptionValue, contrast = false, positionProps, ...otherProps } = props;
|
|
17
15
|
const { listBoxProps } = (0, react_aria_1.useListBox)({ disallowEmptySelection: true, ...otherProps }, state, listBoxRef);
|
|
16
|
+
const positionMaxHeight = (_a = positionProps.style) === null || _a === void 0 ? void 0 : _a.maxHeight;
|
|
17
|
+
// The maxListHeight will be based on the value defined by the positionProps returned from `useOverlayPosition` (which will always be a defined as a `number` based on React-Aria's `calculatePosition`).
|
|
18
|
+
// If `maxHeight` is set use that, otherwise use `273` as a default (`42px` is the min-height of each option, so this allows
|
|
19
|
+
// 6.5 options in view at a time (doing `.5` so the user can easily tell if there are more).
|
|
20
|
+
const maxListHeight = positionMaxHeight && typeof positionMaxHeight === "number" ? positionMaxHeight : 273;
|
|
21
|
+
// We define some spacing between the ListBox and the trigger element, and depending on where the list box renders (above or below) we need to adjust the spacing.
|
|
22
|
+
// We can determine if the position was flipped based on what style is defined, `top` (for positioned below the trigger), and `bottom` (for above the trigger).
|
|
23
|
+
// The above assumption regarding `top` and `bottom` is true as long as we use `bottom` as our default `OverlayPosition.placement` (set in SelectFieldBase).
|
|
24
|
+
// The reason the placement may not be on bottom even though we set `bottom` is because also set `shouldFlip: true`
|
|
25
|
+
const isPositionedAbove = !((_b = positionProps.style) === null || _b === void 0 ? void 0 : _b.top);
|
|
18
26
|
const [listHeight, setListHeight] = (0, react_1.useState)(maxListHeight);
|
|
19
27
|
const isMultiSelect = state.selectionManager.selectionMode === "multiple";
|
|
20
28
|
const virtuosoRef = (0, react_1.useRef)(null);
|
|
@@ -26,7 +34,9 @@ function ListBox(props) {
|
|
|
26
34
|
}
|
|
27
35
|
}, [focusedItem]);
|
|
28
36
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
29
|
-
...Css_1.Css.
|
|
37
|
+
...Css_1.Css.bgWhite.br4.w100.bshBasic.if(contrast).bgGray700.$,
|
|
38
|
+
// Add spacing based on menu's position relative to the trigger element
|
|
39
|
+
...(isPositionedAbove ? Css_1.Css.mbPx(4).$ : Css_1.Css.mtPx(4).$),
|
|
30
40
|
"&:hover": Css_1.Css.bshHover.$,
|
|
31
41
|
}, ref: listBoxRef }, listBoxProps, { children: [isMultiSelect && state.selectionManager.selectedKeys.size > 0 && ((0, jsx_runtime_1.jsx)("ul", Object.assign({ css: Css_1.Css.listReset.pt2.pl2.pb1.pr1.df.bb.bGray200.add("flexWrap", "wrap").$ }, { children: selectedOptions.map((o) => ((0, jsx_runtime_1.jsx)(ListBoxChip, { state: state, option: o, getOptionValue: getOptionValue, getOptionLabel: getOptionLabel, disabled: state.disabledKeys.has(getOptionValue(o)) }, getOptionValue(o)))) }), void 0)), (0, jsx_runtime_1.jsx)("ul", Object.assign({ css: Css_1.Css.listReset.hPx(Math.min(maxListHeight, listHeight)).$ }, { children: (0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ref: virtuosoRef, totalListHeightChanged: setListHeight, totalCount: state.collection.size,
|
|
32
42
|
// We don't really need to set this, but it's handy for tests, which would
|
|
@@ -171,11 +171,12 @@ function SelectFieldBase(props) {
|
|
|
171
171
|
shouldFlip: true,
|
|
172
172
|
isOpen: state.isOpen,
|
|
173
173
|
onClose: state.close,
|
|
174
|
+
placement: "bottom",
|
|
174
175
|
});
|
|
175
176
|
positionProps.style = {
|
|
176
177
|
...positionProps.style,
|
|
177
178
|
width: (_a = comboBoxRef === null || comboBoxRef === void 0 ? void 0 : comboBoxRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth,
|
|
178
179
|
};
|
|
179
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.
|
|
180
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.fdc.w100.maxw((0, Css_1.px)(550)).$, ref: comboBoxRef }, { children: [(0, jsx_runtime_1.jsx)(SelectFieldInput_1.SelectFieldInput, { buttonProps: buttonProps, buttonRef: triggerRef, compact: compact, errorMsg: errorMsg, helperText: helperText, fieldDecoration: fieldDecoration, inputProps: inputProps, inputRef: inputRef, inputWrapRef: inputWrapRef, isDisabled: isDisabled, required: required, isReadOnly: isReadOnly, state: state, onBlur: onBlur, onFocus: onFocus, inlineLabel: inlineLabel, label: label, hideLabel: hideLabel, labelProps: labelProps, selectedOptions: fieldState.selectedOptions, getOptionValue: getOptionValue, getOptionLabel: getOptionLabel, sizeToContent: sizeToContent, contrast: contrast, nothingSelectedText: nothingSelectedText }, void 0), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, Object.assign({ triggerRef: triggerRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen }, { children: (0, jsx_runtime_1.jsx)(ListBox_1.ListBox, Object.assign({}, listBoxProps, { positionProps: positionProps, state: state, compact: compact, listBoxRef: listBoxRef, selectedOptions: fieldState.selectedOptions, getOptionLabel: getOptionLabel, getOptionValue: (o) => (0, Value_1.valueToKey)(getOptionValue(o)), contrast: contrast }), void 0) }), void 0))] }), void 0));
|
|
180
181
|
}
|
|
181
182
|
exports.SelectFieldBase = SelectFieldBase;
|