@homebound/beam 2.123.3 → 2.124.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.
- package/dist/components/Table/styles.js +1 -1
- package/dist/components/internal/DatePicker.d.ts +1 -0
- package/dist/components/internal/DatePicker.js +7 -3
- package/dist/forms/BoundSwitchField.d.ts +1 -1
- package/dist/forms/BoundSwitchField.js +2 -2
- package/dist/inputs/Switch.d.ts +5 -2
- package/dist/inputs/Switch.js +29 -22
- package/package.json +1 -1
|
@@ -65,7 +65,7 @@ exports.beamTotalsFixedStyle = {
|
|
|
65
65
|
};
|
|
66
66
|
exports.beamFlexibleStyle = {
|
|
67
67
|
...exports.beamFixedStyle,
|
|
68
|
-
cellCss: Css_1.Css.xs.bgWhite.aic.
|
|
68
|
+
cellCss: Css_1.Css.xs.bgWhite.aic.py2.pxPx(12).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
|
|
69
69
|
presentationSettings: { borderless: true, typeScale: "xs", wrap: true },
|
|
70
70
|
};
|
|
71
71
|
exports.beamNestedFlexibleStyle = {
|
|
@@ -11,7 +11,7 @@ const Css_1 = require("../../Css");
|
|
|
11
11
|
const utils_1 = require("../../utils");
|
|
12
12
|
require("./DatePicker.css");
|
|
13
13
|
function DatePicker(props) {
|
|
14
|
-
const { value, onSelect, disabledDays } = props;
|
|
14
|
+
const { value, onSelect, disabledDays, dottedDays } = props;
|
|
15
15
|
const tid = (0, utils_1.useTestIds)(props, "datePicker");
|
|
16
16
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
|
|
17
17
|
...Css_1.Css.dib.bgWhite.xs.$,
|
|
@@ -20,7 +20,7 @@ function DatePicker(props) {
|
|
|
20
20
|
// Un-collapse the borders so we can hover each cell
|
|
21
21
|
"& .DayPicker-Month": Css_1.Css.add({ borderCollapse: "separate" }).$,
|
|
22
22
|
// // Make the boxes smaller, this ends up being 32x32 which matches figma
|
|
23
|
-
"& .DayPicker-Day": Css_1.Css.
|
|
23
|
+
"& .DayPicker-Day": Css_1.Css.px1.ptPx(6).pbPx(10).xs.ba.bWhite.br4.relative.$,
|
|
24
24
|
// For today, use a background
|
|
25
25
|
"& .DayPicker-Day--today": Css_1.Css.bgGray100.$,
|
|
26
26
|
// For selected, use a background - `--outside` modifier is set on placeholder days not within the viewed month
|
|
@@ -33,12 +33,16 @@ function DatePicker(props) {
|
|
|
33
33
|
"& .DayPicker-Day--disabled": Css_1.Css.cursorNotAllowed.$,
|
|
34
34
|
// Override `.DayPicker-Day:active` background when the day is disabled
|
|
35
35
|
"& .DayPicker-Day--disabled:active": Css_1.Css.bgWhite.$,
|
|
36
|
+
// Display dottedDays using positioned pseudo elements.
|
|
37
|
+
"& .DayPicker-Day--indicatorDot": Css_1.Css.addIn("&:after", Css_1.Css.wPx(4).hPx(4).br4.absolute.bottomPx(5).left("calc(50% - 2px)").bgLightBlue700.add("content", "''").$).$,
|
|
38
|
+
// Update dottedDays color if day is "selected"
|
|
39
|
+
"& .DayPicker-Day--selected.DayPicker-Day--indicatorDot": Css_1.Css.addIn("&:after", Css_1.Css.bgWhite.$).$,
|
|
36
40
|
} }, tid, { children: (0, jsx_runtime_1.jsx)(react_day_picker_1.default, { navbarElement: NavbarElement, weekdayElement: Weekday, selectedDays: [value], initialMonth: value !== null && value !== void 0 ? value : new Date(), onDayClick: (day, modifiers) => {
|
|
37
41
|
if (modifiers.disabled)
|
|
38
42
|
return;
|
|
39
43
|
// Set the day value
|
|
40
44
|
onSelect(day);
|
|
41
|
-
}, disabledDays: disabledDays }, void 0) }), void 0));
|
|
45
|
+
}, disabledDays: disabledDays, modifiers: { indicatorDot: dottedDays } }, void 0) }), void 0));
|
|
42
46
|
}
|
|
43
47
|
exports.DatePicker = DatePicker;
|
|
44
48
|
/** Customize the prev/next button to be our SVG icons. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldState } from "@homebound/form-state";
|
|
2
2
|
import { SwitchProps } from "../inputs";
|
|
3
|
-
export declare type BoundSwitchFieldProps = Omit<SwitchProps, "selected" | "onChange" | "label"
|
|
3
|
+
export declare type BoundSwitchFieldProps = Omit<SwitchProps, "selected" | "onChange" | "label"> & {
|
|
4
4
|
field: FieldState<any, boolean | null | undefined>;
|
|
5
5
|
/** Make optional so that callers can override if they want to. */
|
|
6
6
|
onChange?: (value: boolean) => void;
|
|
@@ -8,11 +8,11 @@ const utils_1 = require("../utils");
|
|
|
8
8
|
const defaultLabel_1 = require("../utils/defaultLabel");
|
|
9
9
|
/** Wraps `Switch` and binds it to a form field. */
|
|
10
10
|
function BoundSwitchField(props) {
|
|
11
|
-
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), ...others } = props;
|
|
11
|
+
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), labelStyle = "form", ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
14
14
|
var _a;
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(inputs_1.Switch, Object.assign({ label: label, labelStyle:
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(inputs_1.Switch, Object.assign({ label: label, labelStyle: labelStyle, selected: (_a = field.value) !== null && _a !== void 0 ? _a : false, onChange: (selected) => {
|
|
16
16
|
onChange(selected);
|
|
17
17
|
field.maybeAutoSave();
|
|
18
18
|
} }, testId, others), void 0));
|
package/dist/inputs/Switch.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
export interface SwitchProps {
|
|
2
3
|
/** Whether the element should receive focus on render. */
|
|
3
4
|
autoFocus?: boolean;
|
|
4
5
|
/** Whether to render a compact version of Switch */
|
|
5
6
|
compact?: boolean;
|
|
6
|
-
/** Whether the
|
|
7
|
-
disabled?: boolean;
|
|
7
|
+
/** Whether the field is disabled. If a ReactNode, it's treated as a "disabled reason" that's shown in a tooltip. */
|
|
8
|
+
disabled?: boolean | ReactNode;
|
|
8
9
|
/** Input label */
|
|
9
10
|
label: string;
|
|
10
11
|
/** Where to put the label. */
|
|
11
12
|
labelStyle?: "form" | "inline" | "filter";
|
|
13
|
+
/** Whether or not to hide the label */
|
|
14
|
+
hideLabel?: boolean;
|
|
12
15
|
/** Handler when the interactive element state changes. */
|
|
13
16
|
onChange: (value: boolean) => void;
|
|
14
17
|
/** Whether the switch is selected */
|
package/dist/inputs/Switch.js
CHANGED
|
@@ -4,39 +4,46 @@ exports.switchSelectedHoverStyles = exports.switchFocusStyles = exports.switchHo
|
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_aria_1 = require("react-aria");
|
|
7
|
+
const components_1 = require("../components");
|
|
7
8
|
const Label_1 = require("../components/Label");
|
|
8
9
|
const Css_1 = require("../Css");
|
|
9
10
|
const Icon_1 = require("../components/Icon");
|
|
10
11
|
const utils_1 = require("../utils");
|
|
11
12
|
function Switch(props) {
|
|
12
|
-
const { selected: isSelected, disabled
|
|
13
|
+
const { selected: isSelected, disabled = false, onChange, withIcon, compact = false, label, labelStyle = "inline", hideLabel = false, ...otherProps } = props;
|
|
14
|
+
const isDisabled = !!disabled;
|
|
13
15
|
const ariaProps = { isSelected, isDisabled, ...otherProps };
|
|
14
16
|
const state = (0, utils_1.toToggleState)(isSelected, onChange);
|
|
15
17
|
const ref = (0, react_1.useRef)(null);
|
|
16
18
|
const { inputProps } = (0, react_aria_1.useSwitch)({ ...ariaProps, "aria-label": label }, state, ref);
|
|
17
19
|
const { isFocusVisible: isKeyboardFocus, focusProps } = (0, react_aria_1.useFocusRing)(otherProps);
|
|
18
20
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...
|
|
34
|
-
...(
|
|
35
|
-
...(isSelected &&
|
|
36
|
-
} }, { children:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
const tooltip = (0, components_1.resolveTooltip)(disabled);
|
|
22
|
+
return (0, components_1.maybeTooltip)({
|
|
23
|
+
title: tooltip,
|
|
24
|
+
placement: "top",
|
|
25
|
+
children: ((0, jsx_runtime_1.jsxs)("label", Object.assign({}, hoverProps, { css: {
|
|
26
|
+
...Css_1.Css.relative.cursorPointer.df.w("max-content").smEm.selectNone.$,
|
|
27
|
+
...(labelStyle === "form" && Css_1.Css.fdc.$),
|
|
28
|
+
...(labelStyle === "inline" && Css_1.Css.childGap2.aic.$),
|
|
29
|
+
...(labelStyle === "filter" && Css_1.Css.jcsb.aic.w("auto").sm.$),
|
|
30
|
+
...(isDisabled && Css_1.Css.cursorNotAllowed.gray400.$),
|
|
31
|
+
}, "aria-label": label }, { children: [!hideLabel && labelStyle === "form" && (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label }, void 0), !hideLabel && labelStyle === "filter" && (0, jsx_runtime_1.jsx)("span", { children: label }, void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({ "aria-hidden": "true", css: {
|
|
32
|
+
...Css_1.Css.wPx(toggleWidth(compact)).hPx(toggleHeight(compact)).bgGray200.br12.relative.transition.$,
|
|
33
|
+
...(isHovered && exports.switchHoverStyles),
|
|
34
|
+
...(isKeyboardFocus && exports.switchFocusStyles),
|
|
35
|
+
...(isDisabled && Css_1.Css.bgGray300.$),
|
|
36
|
+
...(isSelected && Css_1.Css.bgLightBlue700.$),
|
|
37
|
+
...(isSelected && isHovered && exports.switchSelectedHoverStyles),
|
|
38
|
+
} }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
|
|
39
|
+
...switchCircleDefaultStyles(compact),
|
|
40
|
+
...(isDisabled && Css_1.Css.bgGray100.$),
|
|
41
|
+
...(isSelected && switchCircleSelectedStyles(compact)),
|
|
42
|
+
} }, { children: withIcon && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: isSelected ? "check" : "x", color: isSelected ? Css_1.Palette.LightBlue700 : Css_1.Palette.Gray400 }, void 0)) }), void 0) }), void 0), !hideLabel && labelStyle === "inline" && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: {
|
|
43
|
+
// LineHeight is conditionally applied to handle compact version text alignment
|
|
44
|
+
...Css_1.Css.if(compact).add("lineHeight", "1").$,
|
|
45
|
+
} }, { children: label }), void 0)), (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, inputProps, focusProps), void 0) }, void 0)] }), void 0)),
|
|
46
|
+
});
|
|
40
47
|
}
|
|
41
48
|
exports.Switch = Switch;
|
|
42
49
|
/** Styles */
|