@homebound/beam 2.235.3 → 2.235.4
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/Filters/MultiFilter.js +15 -4
- package/dist/components/Filters/testDomain.d.ts +1 -0
- package/dist/components/Filters/testDomain.js +7 -1
- package/dist/inputs/ToggleChipGroup.d.ts +7 -0
- package/dist/inputs/ToggleChipGroup.js +20 -13
- package/dist/inputs/internal/SelectFieldBase.d.ts +5 -1
- package/dist/inputs/internal/SelectFieldBase.js +2 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.multiFilter = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const BaseFilter_1 = require("./BaseFilter");
|
|
6
|
+
const SelectFieldBase_1 = require("../../inputs/internal/SelectFieldBase");
|
|
6
7
|
const MultiSelectField_1 = require("../../inputs/MultiSelectField");
|
|
7
8
|
const ToggleChipGroup_1 = require("../../inputs/ToggleChipGroup");
|
|
8
9
|
const defaultTestId_1 = require("../../utils/defaultTestId");
|
|
@@ -12,11 +13,21 @@ function multiFilter(props) {
|
|
|
12
13
|
exports.multiFilter = multiFilter;
|
|
13
14
|
class MultiFilter extends BaseFilter_1.BaseFilter {
|
|
14
15
|
render(value, setValue, tid, inModal, vertical) {
|
|
16
|
+
var _a;
|
|
15
17
|
if (inModal && this.props.options.length > 0 && this.props.options.length <= 8) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const { disabledOptions } = this.props;
|
|
19
|
+
const disabledOptionsWithReasons = Object.fromEntries((_a = disabledOptions === null || disabledOptions === void 0 ? void 0 : disabledOptions.map(SelectFieldBase_1.disabledOptionToKeyedTuple)) !== null && _a !== void 0 ? _a : []);
|
|
20
|
+
const disabledKeys = Object.keys(disabledOptionsWithReasons);
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)(ToggleChipGroup_1.ToggleChipGroup, { label: this.label, options: this.props.options.map((o) => {
|
|
22
|
+
const value = this.props.getOptionValue(o);
|
|
23
|
+
const disabled = value && disabledKeys.includes(value.toString());
|
|
24
|
+
const disabledReason = disabled ? disabledOptionsWithReasons[value.toString()] : undefined;
|
|
25
|
+
return {
|
|
26
|
+
label: this.props.getOptionLabel(o),
|
|
27
|
+
value: value,
|
|
28
|
+
disabled: disabledReason !== null && disabledReason !== void 0 ? disabledReason : disabled,
|
|
29
|
+
};
|
|
30
|
+
}), onChange: (values) => {
|
|
20
31
|
setValue(values.length === 0 ? undefined : values);
|
|
21
32
|
}, values: value || [], hideLabel: true, ...tid[(0, defaultTestId_1.defaultTestId)(this.label)] }));
|
|
22
33
|
}
|
|
@@ -49,6 +49,7 @@ export type StageSingleFilter = NonNullable<FilterDefs<ProjectFilter>["stageSing
|
|
|
49
49
|
export type DateFilter = NonNullable<FilterDefs<ProjectFilter>["date"]>;
|
|
50
50
|
export type DateRangeFilter = NonNullable<FilterDefs<ProjectFilter>["dateRange"]>;
|
|
51
51
|
export declare const stageFilter: StageFilter;
|
|
52
|
+
export declare const stageFilterDisabledOptions: StageFilter;
|
|
52
53
|
export declare const stageSingleFilter: StageSingleFilter;
|
|
53
54
|
export declare const taskDueFilter: DateFilter;
|
|
54
55
|
export declare const taskCompleteFilter: DateRangeFilter;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScheduleTypes = exports.TaskStatus = exports.taskCompleteFilter = exports.taskDueFilter = exports.stageSingleFilter = exports.stageFilter = exports.Stage = void 0;
|
|
3
|
+
exports.ScheduleTypes = exports.TaskStatus = exports.taskCompleteFilter = exports.taskDueFilter = exports.stageSingleFilter = exports.stageFilterDisabledOptions = exports.stageFilter = exports.Stage = void 0;
|
|
4
4
|
const DateFilter_1 = require("./DateFilter");
|
|
5
5
|
const DateRangeFilter_1 = require("./DateRangeFilter");
|
|
6
6
|
const MultiFilter_1 = require("./MultiFilter");
|
|
@@ -19,6 +19,12 @@ exports.stageFilter = (0, MultiFilter_1.multiFilter)({
|
|
|
19
19
|
getOptionValue: (s) => s.code,
|
|
20
20
|
getOptionLabel: (s) => s.name,
|
|
21
21
|
});
|
|
22
|
+
exports.stageFilterDisabledOptions = (0, MultiFilter_1.multiFilter)({
|
|
23
|
+
options: stageOptions,
|
|
24
|
+
getOptionValue: (s) => s.code,
|
|
25
|
+
getOptionLabel: (s) => s.name,
|
|
26
|
+
disabledOptions: [{ value: Stage.StageOne, reason: "I have a reason to be disabled." }, Stage.StageTwo],
|
|
27
|
+
});
|
|
22
28
|
exports.stageSingleFilter = (0, SingleFilter_1.singleFilter)({
|
|
23
29
|
options: stageOptions,
|
|
24
30
|
getOptionValue: (s) => s.code,
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
type ToggleChipItemProps = {
|
|
2
3
|
label: string;
|
|
3
4
|
value: string;
|
|
5
|
+
/**
|
|
6
|
+
* Whether the interactive element is disabled.
|
|
7
|
+
*
|
|
8
|
+
* If a ReactNode, it's treated as a "disabled reason" that's shown in a tooltip.
|
|
9
|
+
*/
|
|
10
|
+
disabled?: boolean | ReactNode;
|
|
4
11
|
};
|
|
5
12
|
export interface ToggleChipGroupProps {
|
|
6
13
|
label: string;
|
|
@@ -5,6 +5,7 @@ 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
7
|
const react_stately_1 = require("react-stately");
|
|
8
|
+
const components_1 = require("../components");
|
|
8
9
|
const Label_1 = require("../components/Label");
|
|
9
10
|
const Css_1 = require("../Css");
|
|
10
11
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
@@ -13,22 +14,28 @@ function ToggleChipGroup(props) {
|
|
|
13
14
|
const state = (0, react_stately_1.useCheckboxGroupState)({ ...props, value: values });
|
|
14
15
|
const { groupProps, labelProps } = (0, react_aria_1.useCheckboxGroup)(props, state);
|
|
15
16
|
const tid = (0, useTestIds_1.useTestIds)(props, "toggleChip");
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ...groupProps, css: Css_1.Css.relative.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, hidden: hideLabel }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.gap1.add("flexWrap", "wrap").$, children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, { value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label, ...tid[o.value] }, o.value))) })] }));
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ...groupProps, css: Css_1.Css.relative.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, hidden: hideLabel }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.gap1.add("flexWrap", "wrap").$, children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, { value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label, disabled: o.disabled, ...tid[o.value] }, o.value))) })] }));
|
|
17
18
|
}
|
|
18
19
|
exports.ToggleChipGroup = ToggleChipGroup;
|
|
19
20
|
function ToggleChip(props) {
|
|
20
|
-
const { label, value, groupState, selected: isSelected, ...others } = props;
|
|
21
|
+
const { label, value, groupState, selected: isSelected, disabled = false, ...others } = props;
|
|
22
|
+
const isDisabled = !!disabled;
|
|
21
23
|
const ref = (0, react_1.useRef)(null);
|
|
22
|
-
const { inputProps } = (0, react_aria_1.useCheckboxGroupItem)({ value, "aria-label": label }, groupState, ref);
|
|
24
|
+
const { inputProps } = (0, react_aria_1.useCheckboxGroupItem)({ value, "aria-label": label, isDisabled }, groupState, ref);
|
|
23
25
|
const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const tooltip = (0, components_1.resolveTooltip)(disabled);
|
|
27
|
+
return (0, components_1.maybeTooltip)({
|
|
28
|
+
title: tooltip,
|
|
29
|
+
placement: "top",
|
|
30
|
+
children: ((0, jsx_runtime_1.jsxs)("label", { css: {
|
|
31
|
+
...Css_1.Css.relative.dib.br16.sm.px1.cursorPointer.pyPx(4).bgGray200.if(isDisabled).cursorNotAllowed.gray600.pr1.$,
|
|
32
|
+
...(isSelected
|
|
33
|
+
? {
|
|
34
|
+
...Css_1.Css.white.bgLightBlue700.$,
|
|
35
|
+
":hover:not([data-disabled='true'])": Css_1.Css.bgLightBlue800.$,
|
|
36
|
+
}
|
|
37
|
+
: { ":hover:not([data-disabled='true'])": Css_1.Css.bgGray300.$ }),
|
|
38
|
+
...(isFocusVisible ? Css_1.Css.bshFocus.$ : {}),
|
|
39
|
+
}, "data-selected": isSelected, "data-disabled": isDisabled, "aria-disabled": isDisabled, ...others, children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ...inputProps, ...focusProps }) }), label] })),
|
|
40
|
+
});
|
|
34
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
import { PresentationFieldProps } from "../../components/PresentationContext";
|
|
3
3
|
import { Value } from "../Value";
|
|
4
4
|
import { BeamFocusableProps } from "../../interfaces";
|
|
@@ -57,4 +57,8 @@ type OptionsOrLoad<O> = O[] | {
|
|
|
57
57
|
};
|
|
58
58
|
export declare function initializeOptions<O>(options: OptionsOrLoad<O>, unsetLabel: string | undefined): OptionsOrLoad<O>;
|
|
59
59
|
export declare const unsetOption: {};
|
|
60
|
+
export declare function disabledOptionToKeyedTuple(disabledOption: Value | {
|
|
61
|
+
value: Value;
|
|
62
|
+
reason: string;
|
|
63
|
+
}): [React.Key, string | undefined];
|
|
60
64
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unsetOption = exports.initializeOptions = exports.SelectFieldBase = void 0;
|
|
3
|
+
exports.disabledOptionToKeyedTuple = exports.unsetOption = exports.initializeOptions = exports.SelectFieldBase = void 0;
|
|
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");
|
|
@@ -279,3 +279,4 @@ function disabledOptionToKeyedTuple(disabledOption) {
|
|
|
279
279
|
return [(0, Value_1.valueToKey)(disabledOption), undefined];
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
+
exports.disabledOptionToKeyedTuple = disabledOptionToKeyedTuple;
|