@homebound/beam 2.226.0 → 2.227.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/Css.d.ts +9 -9
- package/dist/components/Accordion.d.ts +1 -1
- package/dist/components/Accordion.js +4 -4
- package/dist/components/AccordionList.js +1 -1
- package/dist/components/AutoSaveIndicator.js +5 -5
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +2 -2
- package/dist/components/AvatarButton.js +1 -1
- package/dist/components/BeamContext.js +1 -1
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Button.js +1 -1
- package/dist/components/ButtonDatePicker.js +2 -2
- package/dist/components/ButtonGroup.d.ts +2 -2
- package/dist/components/ButtonGroup.js +6 -6
- package/dist/components/ButtonMenu.d.ts +5 -5
- package/dist/components/ButtonMenu.js +1 -1
- package/dist/components/ButtonModal.js +1 -1
- package/dist/components/Chip.d.ts +1 -1
- package/dist/components/Chip.js +2 -2
- package/dist/components/Chips.d.ts +1 -1
- package/dist/components/Chips.js +3 -3
- package/dist/components/Copy.js +2 -2
- package/dist/components/CssReset.js +1 -1
- package/dist/components/Filters/BooleanFilter.d.ts +1 -1
- package/dist/components/Filters/BooleanFilter.js +2 -2
- package/dist/components/Filters/DateFilter.d.ts +2 -2
- package/dist/components/Filters/DateFilter.js +2 -2
- package/dist/components/Filters/DateRangeFilter.d.ts +2 -2
- package/dist/components/Filters/DateRangeFilter.js +2 -2
- package/dist/components/Filters/FilterModal.js +4 -4
- package/dist/components/Filters/Filters.d.ts +4 -2
- package/dist/components/Filters/Filters.js +12 -13
- package/dist/components/Filters/MultiFilter.d.ts +1 -1
- package/dist/components/Filters/MultiFilter.js +4 -4
- package/dist/components/Filters/NumberRangeFilter.d.ts +2 -2
- package/dist/components/Filters/NumberRangeFilter.js +5 -5
- package/dist/components/Filters/SingleFilter.d.ts +1 -1
- package/dist/components/Filters/SingleFilter.js +1 -1
- package/dist/components/Filters/ToggleFilter.d.ts +1 -1
- package/dist/components/Filters/ToggleFilter.js +2 -2
- package/dist/components/Filters/index.js +5 -1
- package/dist/components/Filters/testDomain.d.ts +9 -9
- package/dist/components/Filters/types.d.ts +2 -2
- package/dist/components/HbLoadingSpinner.js +9 -5
- package/dist/components/HelperText.js +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +97 -97
- package/dist/components/IconButton.js +1 -1
- package/dist/components/Label.js +3 -3
- package/dist/components/Layout/PreventBrowserScroll.js +1 -1
- package/dist/components/Layout/RightPaneLayout/RightPaneContext.d.ts +1 -1
- package/dist/components/Layout/RightPaneLayout/RightPaneContext.js +6 -2
- package/dist/components/Layout/RightPaneLayout/RightPaneLayout.js +3 -3
- package/dist/components/Layout/RightPaneLayout/index.js +5 -1
- package/dist/components/Layout/ScrollableContent.js +3 -3
- package/dist/components/Layout/ScrollableParent.js +2 -2
- package/dist/components/Layout/index.js +5 -1
- package/dist/components/Loader.js +1 -1
- package/dist/components/LoadingSkeleton.d.ts +2 -2
- package/dist/components/LoadingSkeleton.js +1 -1
- package/dist/components/Modal/Modal.d.ts +3 -3
- package/dist/components/Modal/Modal.js +5 -5
- package/dist/components/Modal/OpenModal.js +2 -2
- package/dist/components/Modal/TestModalContent.js +3 -3
- package/dist/components/Modal/index.js +5 -1
- package/dist/components/NavLink.d.ts +1 -1
- package/dist/components/NavLink.js +2 -2
- package/dist/components/PresentationContext.d.ts +2 -2
- package/dist/components/PresentationContext.js +1 -1
- package/dist/components/Snackbar/Snackbar.d.ts +1 -1
- package/dist/components/Snackbar/Snackbar.js +1 -1
- package/dist/components/Snackbar/SnackbarContext.d.ts +1 -1
- package/dist/components/Snackbar/SnackbarContext.js +1 -1
- package/dist/components/Snackbar/SnackbarNotice.d.ts +1 -1
- package/dist/components/Snackbar/SnackbarNotice.js +1 -1
- package/dist/components/Stepper.js +11 -11
- package/dist/components/SuperDrawer/ConfirmCloseModal.js +2 -2
- package/dist/components/SuperDrawer/SuperDrawer.js +3 -3
- package/dist/components/SuperDrawer/SuperDrawerContent.js +3 -3
- package/dist/components/SuperDrawer/components/SuperDrawerHeader.js +2 -2
- package/dist/components/SuperDrawer/index.js +5 -1
- package/dist/components/SuperDrawer/useSuperDrawer.d.ts +1 -1
- package/dist/components/SuperDrawer/useSuperDrawer.js +2 -2
- package/dist/components/Table/GridTable.d.ts +1 -1
- package/dist/components/Table/GridTable.js +33 -29
- package/dist/components/Table/GridTableApi.d.ts +1 -1
- package/dist/components/Table/TableActions.d.ts +1 -1
- package/dist/components/Table/TableActions.js +1 -1
- package/dist/components/Table/TableStyles.d.ts +1 -1
- package/dist/components/Table/components/CollapseToggle.js +1 -1
- package/dist/components/Table/components/EditColumnsButton.js +2 -2
- package/dist/components/Table/components/ExpandableHeader.js +2 -2
- package/dist/components/Table/components/Row.d.ts +2 -2
- package/dist/components/Table/components/Row.js +7 -3
- package/dist/components/Table/components/SelectToggle.js +1 -1
- package/dist/components/Table/components/SortHeader.js +3 -3
- package/dist/components/Table/components/cell.d.ts +2 -2
- package/dist/components/Table/components/cell.js +6 -6
- package/dist/components/Table/index.js +5 -1
- package/dist/components/Table/types.d.ts +13 -13
- package/dist/components/Table/utils/TableState.d.ts +4 -4
- package/dist/components/Table/utils/columns.js +2 -2
- package/dist/components/Table/utils/simpleHelpers.d.ts +1 -1
- package/dist/components/Table/utils/utils.js +5 -5
- package/dist/components/Tabs.d.ts +1 -1
- package/dist/components/Tabs.js +7 -7
- package/dist/components/Tag.d.ts +2 -2
- package/dist/components/Tag.js +1 -1
- package/dist/components/Toast/Toast.d.ts +1 -1
- package/dist/components/Toast/Toast.js +1 -1
- package/dist/components/Toast/ToastContext.d.ts +1 -1
- package/dist/components/Toast/ToastContext.js +1 -1
- package/dist/components/ToggleChip.d.ts +1 -1
- package/dist/components/ToggleChip.js +2 -2
- package/dist/components/ToggleChips.d.ts +1 -1
- package/dist/components/ToggleChips.js +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip.js +9 -5
- package/dist/components/index.js +5 -1
- package/dist/components/internal/CompoundField.js +6 -6
- package/dist/components/internal/ContextualModal.js +1 -1
- package/dist/components/internal/DatePicker/DatePicker.js +2 -2
- package/dist/components/internal/DatePicker/DatePickerOverlay.js +1 -1
- package/dist/components/internal/DatePicker/DateRangePicker.js +2 -2
- package/dist/components/internal/DatePicker/Day.js +6 -6
- package/dist/components/internal/DatePicker/Header.js +2 -2
- package/dist/components/internal/DatePicker/WeekHeader.js +1 -1
- package/dist/components/internal/DatePicker/index.js +5 -1
- package/dist/components/internal/Menu.js +3 -3
- package/dist/components/internal/MenuItem.js +6 -6
- package/dist/components/internal/MenuSection.js +1 -1
- package/dist/components/internal/OverlayTrigger.js +1 -1
- package/dist/components/internal/Popover.js +1 -1
- package/dist/components/internal/index.js +5 -1
- package/dist/components/testData.d.ts +1 -1
- package/dist/components/testData.js +5 -5
- package/dist/forms/BoundCheckboxField.d.ts +1 -1
- package/dist/forms/BoundCheckboxField.js +3 -3
- package/dist/forms/BoundCheckboxGroupField.d.ts +1 -1
- package/dist/forms/BoundCheckboxGroupField.js +2 -2
- package/dist/forms/BoundChipSelectField.js +3 -3
- package/dist/forms/BoundDateField.d.ts +1 -1
- package/dist/forms/BoundDateField.js +2 -2
- package/dist/forms/BoundDateRangeField.d.ts +1 -1
- package/dist/forms/BoundDateRangeField.js +2 -2
- package/dist/forms/BoundMultiSelectField.d.ts +1 -1
- package/dist/forms/BoundMultiSelectField.js +3 -3
- package/dist/forms/BoundNumberField.d.ts +1 -1
- package/dist/forms/BoundNumberField.js +2 -2
- package/dist/forms/BoundRadioGroupField.d.ts +1 -1
- package/dist/forms/BoundRadioGroupField.js +2 -2
- package/dist/forms/BoundRichTextField.d.ts +1 -1
- package/dist/forms/BoundRichTextField.js +2 -2
- package/dist/forms/BoundSelectAndTextField.d.ts +2 -2
- package/dist/forms/BoundSelectAndTextField.js +1 -1
- package/dist/forms/BoundSelectField.d.ts +1 -1
- package/dist/forms/BoundSelectField.js +3 -3
- package/dist/forms/BoundSwitchField.d.ts +1 -1
- package/dist/forms/BoundSwitchField.js +3 -3
- package/dist/forms/BoundTextAreaField.d.ts +1 -1
- package/dist/forms/BoundTextAreaField.js +2 -2
- package/dist/forms/BoundTextField.d.ts +1 -1
- package/dist/forms/BoundTextField.js +2 -2
- package/dist/forms/BoundToggleChipGroupField.d.ts +1 -1
- package/dist/forms/BoundToggleChipGroupField.js +1 -1
- package/dist/forms/FormHeading.js +2 -2
- package/dist/forms/FormLines.d.ts +1 -1
- package/dist/forms/FormLines.js +5 -5
- package/dist/forms/FormStateApp.js +5 -5
- package/dist/forms/StaticField.js +1 -1
- package/dist/forms/StepperFormApp.js +10 -10
- package/dist/forms/index.js +5 -1
- package/dist/hooks/index.js +5 -1
- package/dist/hooks/useBreakpoint.d.ts +1 -1
- package/dist/hooks/useQueryState.d.ts +1 -1
- package/dist/hooks/useSessionStorage.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/inputs/Checkbox.js +1 -1
- package/dist/inputs/CheckboxBase.js +6 -6
- package/dist/inputs/CheckboxGroup.js +2 -2
- package/dist/inputs/ChipSelectField.d.ts +2 -2
- package/dist/inputs/ChipSelectField.js +14 -14
- package/dist/inputs/ChipTextField.js +3 -3
- package/dist/inputs/DateFields/DateField.js +1 -1
- package/dist/inputs/DateFields/DateField.mock.js +2 -2
- package/dist/inputs/DateFields/DateFieldBase.js +7 -7
- package/dist/inputs/DateFields/DateRangeField.js +1 -1
- package/dist/inputs/DateFields/index.js +5 -1
- package/dist/inputs/DateFields/utils.d.ts +2 -2
- package/dist/inputs/ErrorMessage.js +2 -2
- package/dist/inputs/MultiSelectField.js +2 -2
- package/dist/inputs/MultiSelectField.mock.js +4 -4
- package/dist/inputs/NumberField.d.ts +1 -1
- package/dist/inputs/NumberField.js +4 -4
- package/dist/inputs/RadioGroupField.js +3 -3
- package/dist/inputs/RichTextField.js +3 -3
- package/dist/inputs/RichTextField.mock.js +2 -2
- package/dist/inputs/SelectField.js +2 -2
- package/dist/inputs/SelectField.mock.js +4 -4
- package/dist/inputs/Switch.js +5 -5
- package/dist/inputs/SwitchGroup.d.ts +1 -1
- package/dist/inputs/SwitchGroup.js +1 -1
- package/dist/inputs/TextAreaField.js +1 -1
- package/dist/inputs/TextField.d.ts +1 -1
- package/dist/inputs/TextField.js +1 -1
- package/dist/inputs/TextFieldBase.js +10 -10
- package/dist/inputs/ToggleButton.js +1 -1
- package/dist/inputs/ToggleChipGroup.d.ts +1 -1
- package/dist/inputs/ToggleChipGroup.js +3 -3
- package/dist/inputs/Value.d.ts +1 -1
- package/dist/inputs/index.js +5 -1
- package/dist/inputs/internal/ListBox.js +3 -3
- package/dist/inputs/internal/ListBoxChip.js +1 -1
- package/dist/inputs/internal/ListBoxSection.js +1 -1
- package/dist/inputs/internal/ListBoxToggleChip.js +2 -2
- package/dist/inputs/internal/LoadingDots.js +2 -2
- package/dist/inputs/internal/MenuSearchField.js +1 -1
- package/dist/inputs/internal/Option.js +3 -3
- package/dist/inputs/internal/SelectFieldBase.d.ts +1 -1
- package/dist/inputs/internal/SelectFieldBase.js +2 -2
- package/dist/inputs/internal/SelectFieldInput.js +4 -4
- package/dist/inputs/internal/VirtualizedOptions.js +2 -2
- package/dist/interfaces.d.ts +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/utils/getInteractiveElement.js +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +5 -1
- package/dist/utils/rtl.js +1 -1
- package/dist/utils/sb.d.ts +2 -2
- package/dist/utils/sb.js +4 -4
- package/dist/utils/useTestIds.d.ts +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/inputs/Checkbox.js
CHANGED
|
@@ -16,6 +16,6 @@ function Checkbox(props) {
|
|
|
16
16
|
const ref = (0, react_1.useRef)(null);
|
|
17
17
|
const toggleState = (0, react_stately_1.useToggleState)(ariaProps);
|
|
18
18
|
const { inputProps } = (0, react_aria_1.useCheckbox)(checkboxProps, toggleState, ref);
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)(CheckboxBase_1.CheckboxBase,
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(CheckboxBase_1.CheckboxBase, { ariaProps: ariaProps, isDisabled: isDisabled, isIndeterminate: isIndeterminate, isSelected: isSelected, inputProps: inputProps, label: label, ...otherProps }));
|
|
20
20
|
}
|
|
21
21
|
exports.Checkbox = Checkbox;
|
|
@@ -16,14 +16,14 @@ function CheckboxBase(props) {
|
|
|
16
16
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled });
|
|
17
17
|
const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
|
|
18
18
|
const markIcon = isIndeterminate ? dashSmall : isSelected ? checkmarkSmall : "";
|
|
19
|
-
return ((0, jsx_runtime_1.jsxs)("label",
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)("label", { css: Css_1.Css.df.cursorPointer.relative
|
|
20
20
|
// Prevents accidental checkbox clicks due to label width being longer
|
|
21
21
|
// than the content.
|
|
22
22
|
.w("max-content")
|
|
23
23
|
.maxw((0, Css_1.px)(320))
|
|
24
24
|
.if(description !== undefined)
|
|
25
25
|
.maxw((0, Css_1.px)(344))
|
|
26
|
-
.if(isDisabled).cursorNotAllowed.$, "aria-label": label
|
|
26
|
+
.if(isDisabled).cursorNotAllowed.$, "aria-label": label, children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...(0, react_aria_1.mergeProps)(inputProps, focusProps), ...tid }) }), (0, jsx_runtime_1.jsx)("span", { ...hoverProps, css: {
|
|
27
27
|
...baseStyles,
|
|
28
28
|
...(((isSelected && !isDisabled) || isIndeterminate) && filledBoxStyles),
|
|
29
29
|
...(((isSelected && !isDisabled) || isIndeterminate) && isHovered && filledBoxHoverStyles),
|
|
@@ -32,10 +32,10 @@ function CheckboxBase(props) {
|
|
|
32
32
|
...(isFocusVisible && focusRingStyles),
|
|
33
33
|
...(isHovered && hoverBorderStyles),
|
|
34
34
|
...markStyles,
|
|
35
|
-
}, "aria-hidden": "true"
|
|
35
|
+
}, "aria-hidden": "true", children: markIcon }), !checkboxOnly && (
|
|
36
36
|
// Use a mtPx(-2) to better align the label with the checkbox.
|
|
37
37
|
// Not using align-items: center as the checkbox would align with all content below, where we really want it to stay only aligned with the label
|
|
38
|
-
(0, jsx_runtime_1.jsxs)("div",
|
|
38
|
+
(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.ml1.mtPx(-2).$, children: [label && (0, jsx_runtime_1.jsx)("div", { css: { ...labelStyles, ...(isDisabled && disabledColor) }, children: label }), description && (0, jsx_runtime_1.jsx)("div", { css: { ...descStyles, ...(isDisabled && disabledColor) }, children: description }), errorMsg && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { errorMsg: errorMsg, ...tid.errorMsg }), helperText && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { helperText: helperText, ...tid.helperText })] }))] }));
|
|
39
39
|
}
|
|
40
40
|
exports.CheckboxBase = CheckboxBase;
|
|
41
41
|
const baseStyles = Css_1.Css.hPx(16).mw((0, Css_1.px)(16)).relative.ba.bGray300.br4.bgWhite.transition.$;
|
|
@@ -49,5 +49,5 @@ const hoverBorderStyles = Css_1.Css.bLightBlue900.$;
|
|
|
49
49
|
const markStyles = { svg: Css_1.Css.absolute.topPx(-1).leftPx(-1).$ };
|
|
50
50
|
const labelStyles = Css_1.Css.smMd.$;
|
|
51
51
|
const descStyles = Css_1.Css.sm.gray700.$;
|
|
52
|
-
const checkmarkSmall = ((0, jsx_runtime_1.jsx)("svg",
|
|
53
|
-
const dashSmall = ((0, jsx_runtime_1.jsx)("svg",
|
|
52
|
+
const checkmarkSmall = ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", children: (0, jsx_runtime_1.jsx)("path", { d: "M6.66669 10.3907L4.47135 8.19533L3.52869 9.138L6.66669 12.276L13.138 5.80467L12.1954 4.862L6.66669 10.3907Z", fill: Css_1.Palette.White }) }));
|
|
53
|
+
const dashSmall = ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", children: (0, jsx_runtime_1.jsx)("rect", { x: "4", y: "7.5", width: "8", height: "1.35", fill: Css_1.Palette.White }) }));
|
|
@@ -16,7 +16,7 @@ function CheckboxGroup(props) {
|
|
|
16
16
|
const state = (0, react_stately_1.useCheckboxGroupState)({ ...props, value: values });
|
|
17
17
|
const { groupProps, labelProps } = (0, react_aria_1.useCheckboxGroup)(props, state);
|
|
18
18
|
const tid = (0, utils_1.useTestIds)(props);
|
|
19
|
-
return ((0, jsx_runtime_1.jsxs)("div",
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ...groupProps, onBlur: onBlur, onFocus: onFocus, ...tid, children: [!hideLabel && (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, ...tid.label }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.dg.gtc(`repeat(${columns}, auto)`).gap2.$, children: options.map((option) => ((0, jsx_runtime_1.jsx)(CheckboxGroupItem, { ...option, groupState: state, selected: state.value.includes(option.value) }, option.value))) }), errorMsg && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { errorMsg: errorMsg, ...tid.errorMsg }), helperText && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { helperText: helperText, ...tid.helperText })] }));
|
|
20
20
|
}
|
|
21
21
|
exports.CheckboxGroup = CheckboxGroup;
|
|
22
22
|
function CheckboxGroupItem(props) {
|
|
@@ -25,5 +25,5 @@ function CheckboxGroupItem(props) {
|
|
|
25
25
|
const checkboxProps = { ...ariaProps, "aria-label": label };
|
|
26
26
|
const ref = (0, react_1.useRef)(null);
|
|
27
27
|
const { inputProps } = (0, react_aria_1.useCheckboxGroupItem)(checkboxProps, groupState, ref);
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)(CheckboxBase_1.CheckboxBase,
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(CheckboxBase_1.CheckboxBase, { ariaProps: ariaProps, description: description, isDisabled: isDisabled, isIndeterminate: isIndeterminate, isSelected: isSelected, inputProps: inputProps, label: label, ...otherProps }));
|
|
29
29
|
}
|
|
@@ -18,13 +18,13 @@ export interface ChipSelectFieldProps<O, V extends Value> {
|
|
|
18
18
|
export declare function ChipSelectField<O, V extends Value>(props: ChipSelectFieldProps<O, V>): JSX.Element;
|
|
19
19
|
export declare function ChipSelectField<O extends HasIdAndName<V>, V extends Value>(props: Optional<ChipSelectFieldProps<O, V>, "getOptionValue" | "getOptionLabel">): JSX.Element;
|
|
20
20
|
export declare const persistentItemPrefix = "persistentItem:";
|
|
21
|
-
|
|
21
|
+
type PersistentItem = {
|
|
22
22
|
id: string;
|
|
23
23
|
name: string;
|
|
24
24
|
};
|
|
25
25
|
export declare function isPersistentItem<T extends PersistentItem>(opt: any): opt is PersistentItem;
|
|
26
26
|
export declare function isPersistentKey(key: Key): boolean;
|
|
27
|
-
|
|
27
|
+
type ListBoxSection<O> = {
|
|
28
28
|
title: string;
|
|
29
29
|
options: O[];
|
|
30
30
|
isPersistent?: boolean;
|
|
@@ -83,16 +83,16 @@ function ChipSelectField(props) {
|
|
|
83
83
|
}, [options]);
|
|
84
84
|
const selectChildren = (0, react_1.useMemo)(() => listData.items.map((s) => {
|
|
85
85
|
if (isListBoxSection(s)) {
|
|
86
|
-
return ((0, jsx_runtime_1.jsx)(react_stately_1.Section,
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(react_stately_1.Section, { title: s.title, items: s.options, children: (item) => {
|
|
87
87
|
if (isPersistentItem(item)) {
|
|
88
|
-
return ((0, jsx_runtime_1.jsx)(react_stately_1.Item,
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)(react_stately_1.Item, { textValue: item.name, children: item.name }, item.id));
|
|
89
89
|
}
|
|
90
90
|
const label = getOptionLabel(item);
|
|
91
|
-
return ((0, jsx_runtime_1.jsx)(react_stately_1.Item,
|
|
92
|
-
} }
|
|
91
|
+
return ((0, jsx_runtime_1.jsx)(react_stately_1.Item, { textValue: label, children: (0, jsx_runtime_1.jsx)(ListBoxChip_1.ListBoxChip, { label: label }) }, getOptionValue(item)));
|
|
92
|
+
} }, (0, change_case_1.camelCase)(s.title)));
|
|
93
93
|
}
|
|
94
94
|
const label = getOptionLabel(s);
|
|
95
|
-
return ((0, jsx_runtime_1.jsx)(react_stately_1.Item,
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(react_stately_1.Item, { textValue: label, children: (0, jsx_runtime_1.jsx)(ListBoxChip_1.ListBoxChip, { label: label }) }, getOptionValue(s)));
|
|
96
96
|
}), [listData.items, getOptionLabel, getOptionValue]);
|
|
97
97
|
const selectHookProps = {
|
|
98
98
|
label,
|
|
@@ -150,30 +150,30 @@ function ChipSelectField(props) {
|
|
|
150
150
|
};
|
|
151
151
|
// State management for the "Create new" flow with ChipTextField.
|
|
152
152
|
const [showInput, setShowInput] = (0, react_1.useState)(false);
|
|
153
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showInput && onCreateNew && ((0, jsx_runtime_1.jsx)(CreateNewField,
|
|
153
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showInput && onCreateNew && ((0, jsx_runtime_1.jsx)(CreateNewField, { onBlur: () => setShowInput(false), onEnter: async (value) => {
|
|
154
154
|
await onCreateNew(value);
|
|
155
155
|
setShowInput(false);
|
|
156
|
-
}
|
|
156
|
+
}, ...tid.createNewField })), (0, components_1.maybeTooltip)({
|
|
157
157
|
title: (0, components_1.resolveTooltip)(disabled),
|
|
158
158
|
placement: "top",
|
|
159
|
-
children: ((0, jsx_runtime_1.jsxs)("div",
|
|
159
|
+
children: ((0, jsx_runtime_1.jsxs)("div", { ref: wrapperRef, css: {
|
|
160
160
|
...chipStyles,
|
|
161
161
|
...Css_1.Css.dif.relative.p0.mwPx(32).if(!value).bgGray200.$,
|
|
162
162
|
...(visualFocus ? Css_1.Css.bshFocus.$ : {}),
|
|
163
163
|
...(showInput ? Css_1.Css.dn.$ : {}),
|
|
164
|
-
}
|
|
164
|
+
}, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, labelProps: labelProps, hidden: true, ...tid.label }), (0, jsx_runtime_1.jsx)("button", { ...(0, react_aria_1.mergeProps)(focusProps, buttonProps), ref: buttonRef, css: {
|
|
165
165
|
...Css_1.Css.tl.br16.pxPx(10).pyPx(2).outline0.if(showClearButton).prPx(4).borderRadius("16px 0 0 16px").$,
|
|
166
166
|
...(isDisabled ? Css_1.Css.cursorNotAllowed.gray700.$ : {}),
|
|
167
167
|
"&:hover:not(:disabled)": Css_1.Css.bgGray400.if(!value).bgGray300.$,
|
|
168
|
-
}, title: state.selectedItem ? state.selectedItem.textValue : placeholder
|
|
168
|
+
}, title: state.selectedItem ? state.selectedItem.textValue : placeholder, ...tid, children: (0, jsx_runtime_1.jsx)("span", { ...valueProps, css: Css_1.Css.lineClamp1.breakAll.$, children: state.selectedItem ? state.selectedItem.textValue : placeholder }) }), showClearButton && ((0, jsx_runtime_1.jsx)("button", { ...clearFocusProps, css: {
|
|
169
169
|
...Css_1.Css.prPx(4).borderRadius("0 16px 16px 0").outline0.$,
|
|
170
170
|
"&:hover": Css_1.Css.bgGray400.$,
|
|
171
171
|
...(isClearFocused ? Css_1.Css.boxShadow(`0px 0px 0px 2px rgba(3,105,161,1)`).$ : {}),
|
|
172
172
|
}, onClick: () => {
|
|
173
173
|
onSelect(undefined, undefined);
|
|
174
174
|
setIsClearFocused(false);
|
|
175
|
-
}, "aria-label": "Remove"
|
|
176
|
-
}), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover,
|
|
175
|
+
}, "aria-label": "Remove", ...tid.clearButton, children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: "x", inc: typeScale === "xs" ? 2 : undefined }) }))] })),
|
|
176
|
+
}), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, { triggerRef: buttonRef, popoverRef: popoverRef, positionProps: overlayProps, onClose: state.close, isOpen: state.isOpen, shouldCloseOnBlur: true, children: (0, jsx_runtime_1.jsx)(ListBox_1.ListBox, { ...menuProps, listBoxRef: listBoxRef, state: state, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, positionProps: overlayProps }) }))] }));
|
|
177
177
|
}
|
|
178
178
|
exports.ChipSelectField = ChipSelectField;
|
|
179
179
|
exports.persistentItemPrefix = "persistentItem:";
|
|
@@ -190,7 +190,7 @@ function isPersistentKey(key) {
|
|
|
190
190
|
}
|
|
191
191
|
exports.isPersistentKey = isPersistentKey;
|
|
192
192
|
function isListBoxSection(obj) {
|
|
193
|
-
return typeof obj === "object" && "options" in obj;
|
|
193
|
+
return obj && typeof obj === "object" && "options" in obj;
|
|
194
194
|
}
|
|
195
195
|
exports.isListBoxSection = isListBoxSection;
|
|
196
196
|
// Wrapper for the ChipTextField used in the "Create New" flow on ChipSelectField
|
|
@@ -198,5 +198,5 @@ function CreateNewField(props) {
|
|
|
198
198
|
const { onBlur, onEnter } = props;
|
|
199
199
|
const [value, setValue] = (0, react_1.useState)("Add new");
|
|
200
200
|
const tid = (0, utils_1.useTestIds)(props);
|
|
201
|
-
return ((0, jsx_runtime_1.jsx)(ChipTextField_1.ChipTextField,
|
|
201
|
+
return ((0, jsx_runtime_1.jsx)(ChipTextField_1.ChipTextField, { autoFocus: true, label: "Add new", value: value, onChange: setValue, onEnter: () => onEnter(value), onBlur: onBlur, ...tid }));
|
|
202
202
|
}
|
|
@@ -40,7 +40,7 @@ function ChipTextField(props) {
|
|
|
40
40
|
autoFocus && ((_a = fieldRef.current) === null || _a === void 0 ? void 0 : _a.focus());
|
|
41
41
|
}, []);
|
|
42
42
|
// React doesn't like contentEditable because it takes the children of the node out of React's scope. This is fine in this case as it is just a text value and we are managing it.
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)("span",
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)("span", { ref: fieldRef, contentEditable: true, suppressContentEditableWarning: true, "aria-required": required, "aria-label": label, onKeyDown: (e) => {
|
|
44
44
|
if (e.key === "Enter") {
|
|
45
45
|
e.preventDefault();
|
|
46
46
|
(0, utils_1.maybeCall)(onEnter);
|
|
@@ -54,9 +54,9 @@ function ChipTextField(props) {
|
|
|
54
54
|
const target = e.target;
|
|
55
55
|
target.textContent = (_b = (_a = target.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[\n\r]/g, " ")) !== null && _b !== void 0 ? _b : "";
|
|
56
56
|
onChange((_c = target.textContent) !== null && _c !== void 0 ? _c : "");
|
|
57
|
-
}
|
|
57
|
+
}, ...focusProps, css: {
|
|
58
58
|
...Css_1.Css[typeScale].dib.br16.pl1.pxPx(10).pyPx(2).gray900.bgGray300.outline0.mwPx(32).$,
|
|
59
59
|
...(isFocused ? Css_1.Css.bshFocus.$ : {}),
|
|
60
|
-
}
|
|
60
|
+
}, ...tid, children: valueRef.current }));
|
|
61
61
|
}
|
|
62
62
|
exports.ChipTextField = ChipTextField;
|
|
@@ -4,6 +4,6 @@ exports.DateField = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const DateFieldBase_1 = require("./DateFieldBase");
|
|
6
6
|
function DateField(props) {
|
|
7
|
-
return (0, jsx_runtime_1.jsx)(DateFieldBase_1.DateFieldBase,
|
|
7
|
+
return (0, jsx_runtime_1.jsx)(DateFieldBase_1.DateFieldBase, { ...props, mode: "single" });
|
|
8
8
|
}
|
|
9
9
|
exports.DateField = DateField;
|
|
@@ -10,10 +10,10 @@ function DateField(props) {
|
|
|
10
10
|
const { onChange = () => { }, errorMsg, onBlur, onFocus } = props;
|
|
11
11
|
const [value, setValue] = (0, react_1.useState)(props.value ? (0, date_fns_1.format)(props.value, "MM/dd/yy") : "");
|
|
12
12
|
const tid = (0, utils_1.useTestIds)(props, "date");
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)("input",
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("input", { ...tid, "data-error": !!errorMsg, value: value, onChange: (e) => {
|
|
14
14
|
const { value } = e.target;
|
|
15
15
|
setValue(value);
|
|
16
16
|
onChange((0, date_fns_1.parse)(value, "MM/dd/yy", new Date()));
|
|
17
|
-
}, onBlur: () => (0, utils_1.maybeCall)(onBlur), onFocus: () => (0, utils_1.maybeCall)(onFocus), disabled: !!props.disabled, readOnly: !!props.readOnly, "data-disabled-days": JSON.stringify(props.disabledDays) })
|
|
17
|
+
}, onBlur: () => (0, utils_1.maybeCall)(onBlur), onFocus: () => (0, utils_1.maybeCall)(onFocus), disabled: !!props.disabled, readOnly: !!props.readOnly, "data-disabled-days": JSON.stringify(props.disabledDays) }));
|
|
18
18
|
}
|
|
19
19
|
exports.DateField = DateField;
|
|
@@ -157,10 +157,10 @@ function DateFieldBase(props) {
|
|
|
157
157
|
const clearButton = ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: inputValue !== "" && !state.isOpen && ((0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "xCircle", color: Css_1.Palette.Gray700, onClick: () => {
|
|
158
158
|
setInputValue("");
|
|
159
159
|
onChange(undefined);
|
|
160
|
-
} }
|
|
161
|
-
const calendarButton = ((0, jsx_runtime_1.jsx)("button",
|
|
162
|
-
const EndFieldButtons = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRangeFilterField && clearButton, !hideCalendarIcon && calendarButton] }
|
|
163
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase,
|
|
160
|
+
} })) }));
|
|
161
|
+
const calendarButton = ((0, jsx_runtime_1.jsx)("button", { ref: buttonRef, ...buttonProps, disabled: isDisabled, css: Css_1.Css.if(isDisabled).cursorNotAllowed.$, tabIndex: -1, ...tid.calendarButton, children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: "calendar", color: isDisabled ? Css_1.Palette.Gray400 : Css_1.Palette.Gray700 }) }));
|
|
162
|
+
const EndFieldButtons = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRangeFilterField && clearButton, !hideCalendarIcon && calendarButton] }));
|
|
163
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...textFieldProps, errorMsg: errorMsg, helperText: helperText, required: required, labelProps: labelProps, inputProps: { ...inputProps, size: inputSize }, inputRef: inputRef, inputWrapRef: inputWrapRef, inlineLabel: inlineLabel, onChange: (v) => {
|
|
164
164
|
// hide the calendar if the user is manually entering the date
|
|
165
165
|
state.close();
|
|
166
166
|
if (v) {
|
|
@@ -173,17 +173,17 @@ function DateFieldBase(props) {
|
|
|
173
173
|
else if (v === undefined) {
|
|
174
174
|
setInputValue("");
|
|
175
175
|
}
|
|
176
|
-
}, endAdornment: !iconLeft && EndFieldButtons, startAdornment: !hideCalendarIcon && iconLeft && calendarButton, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly)
|
|
176
|
+
}, endAdornment: !iconLeft && EndFieldButtons, startAdornment: !hideCalendarIcon && iconLeft && calendarButton, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), ...others }), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, { triggerRef: inputWrapRef, popoverRef: overlayRef, positionProps: positionProps, onClose: state.close, isOpen: state.isOpen, children: (0, jsx_runtime_1.jsx)(DatePickerOverlay_1.DatePickerOverlay, { overlayProps: overlayProps, children: isRangeMode ? ((0, jsx_runtime_1.jsx)(internal_1.DateRangePicker, { range: wipValue, disabledDays: disabledDays, onSelect: (dr) => {
|
|
177
177
|
var _a;
|
|
178
178
|
// Note: Do not close date range picker on select to allow the user to select multiple dates at a time
|
|
179
179
|
setInputValue((_a = (0, utils_1.formatDateRange)(dr, utils_1.dateFormats.short)) !== null && _a !== void 0 ? _a : "");
|
|
180
180
|
onChange(dr);
|
|
181
|
-
}, useYearPicker: isRangeFilterField
|
|
181
|
+
}, useYearPicker: isRangeFilterField, ...tid.datePicker })) : ((0, jsx_runtime_1.jsx)(internal_1.DatePicker, { value: wipValue, disabledDays: disabledDays, onSelect: (d) => {
|
|
182
182
|
var _a;
|
|
183
183
|
setInputValue((_a = (0, utils_1.formatDate)(d, utils_1.dateFormats.short)) !== null && _a !== void 0 ? _a : "");
|
|
184
184
|
onChange(d);
|
|
185
185
|
state.close();
|
|
186
|
-
}
|
|
186
|
+
}, ...tid.datePicker })) }) }))] }));
|
|
187
187
|
}
|
|
188
188
|
exports.DateFieldBase = DateFieldBase;
|
|
189
189
|
function isParsedDateValid(d) {
|
|
@@ -4,6 +4,6 @@ exports.DateRangeField = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const DateFieldBase_1 = require("./DateFieldBase");
|
|
6
6
|
function DateRangeField(props) {
|
|
7
|
-
return (0, jsx_runtime_1.jsx)(DateFieldBase_1.DateFieldBase,
|
|
7
|
+
return (0, jsx_runtime_1.jsx)(DateFieldBase_1.DateFieldBase, { ...props, mode: "range" });
|
|
8
8
|
}
|
|
9
9
|
exports.DateRangeField = DateRangeField;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateRange } from "../../types";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type DateFieldModeTuple = readonly ["range", DateRange] | readonly ["single", Date];
|
|
3
|
+
export type DateFieldMode = "single" | "range";
|
|
4
4
|
export declare const dateFormats: {
|
|
5
5
|
short: string;
|
|
6
6
|
medium: string;
|
|
@@ -12,7 +12,7 @@ const Css_1 = require("../Css");
|
|
|
12
12
|
*/
|
|
13
13
|
function ErrorMessage(props) {
|
|
14
14
|
const { id, errorMsg, contrast = false, hidden = false, ...others } = props;
|
|
15
|
-
const errorEl = errorMsg ? ((0, jsx_runtime_1.jsxs)("div",
|
|
16
|
-
return hidden ? (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: errorEl }
|
|
15
|
+
const errorEl = errorMsg ? ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.red600.sm.df.mtPx(4).if(contrast).red400.$, children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: "error" }) }), (0, jsx_runtime_1.jsx)("span", { id: id, css: Css_1.Css.ml1.mtPx(2).$, ...others, children: errorMsg })] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
|
|
16
|
+
return hidden ? (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: errorEl }) : errorEl;
|
|
17
17
|
}
|
|
18
18
|
exports.ErrorMessage = ErrorMessage;
|
|
@@ -7,7 +7,7 @@ function MultiSelectField(props) {
|
|
|
7
7
|
const { getOptionValue = (opt) => opt.id, // if unset, assume O implements HasId
|
|
8
8
|
getOptionLabel = (opt) => opt.name, // if unset, assume O implements HasName
|
|
9
9
|
options, onSelect, values, ...otherProps } = props;
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(SelectFieldBase_1.SelectFieldBase,
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(SelectFieldBase_1.SelectFieldBase, { multiselect: true, ...otherProps, options: options, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, values: values, onSelect: (values) => {
|
|
11
11
|
const [selectedValues, selectedOptions] = options
|
|
12
12
|
.filter((o) => values.includes(getOptionValue(o)))
|
|
13
13
|
.reduce((acc, o) => {
|
|
@@ -16,6 +16,6 @@ function MultiSelectField(props) {
|
|
|
16
16
|
return acc;
|
|
17
17
|
}, [[], []]);
|
|
18
18
|
onSelect(selectedValues, selectedOptions);
|
|
19
|
-
} })
|
|
19
|
+
} }));
|
|
20
20
|
}
|
|
21
21
|
exports.MultiSelectField = MultiSelectField;
|
|
@@ -10,7 +10,7 @@ function MultiSelectField(props) {
|
|
|
10
10
|
getOptionLabel = (o) => o.name, // if unset, assume O implements HasName
|
|
11
11
|
values, options, onSelect, readOnly = false, errorMsg, onFocus, onBlur, disabled, label, disabledOptions = [], helperText, } = props;
|
|
12
12
|
const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)("label",
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)("label", { ...tid.label, children: [label, (0, jsx_runtime_1.jsxs)("select", { ...tid,
|
|
14
14
|
// We're cheating and assume the values are strings...what we should really do is either:
|
|
15
15
|
// a) use beam's valueToKey mapping to string-encode any Value, or
|
|
16
16
|
// b) instead of using `values` directly, use the index of each value's `option` in `options`
|
|
@@ -38,8 +38,8 @@ function MultiSelectField(props) {
|
|
|
38
38
|
onBlur();
|
|
39
39
|
},
|
|
40
40
|
// Read Only does not apply to `select` fields, instead we'll add in disabled for tests to verify.
|
|
41
|
-
disabled: !!(readOnly || disabled), "data-error": !!errorMsg, "data-errormsg": errorMsg, "data-readonly": readOnly
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)("option",
|
|
43
|
-
})] }),
|
|
41
|
+
disabled: !!(readOnly || disabled), "data-error": !!errorMsg, "data-errormsg": errorMsg, "data-readonly": readOnly, children: [(0, jsx_runtime_1.jsx)("option", { disabled: true, value: "" }), options.map((option, i) => {
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)("option", { value: getOptionValue(option), disabled: disabledOptions.includes(getOptionValue(option)), children: getOptionLabel(option) }, i));
|
|
43
|
+
})] }), helperText && (0, jsx_runtime_1.jsx)("div", { ...tid.helperText, children: helperText })] }));
|
|
44
44
|
}
|
|
45
45
|
exports.MultiSelectField = MultiSelectField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { Xss } from "../Css";
|
|
3
|
-
export
|
|
3
|
+
export type NumberFieldType = "cents" | "dollars" | "percent" | "basisPoints" | "days";
|
|
4
4
|
export interface NumberFieldProps {
|
|
5
5
|
label: string;
|
|
6
6
|
/** If set, the label will be defined as 'aria-label` on the input element */
|
|
@@ -26,7 +26,7 @@ function NumberField(props) {
|
|
|
26
26
|
...(numIntegerDigits !== undefined && { minimumIntegerDigits: numIntegerDigits }),
|
|
27
27
|
useGrouping,
|
|
28
28
|
signDisplay,
|
|
29
|
-
}), [truncate, numIntegerDigits, useGrouping, signDisplay]);
|
|
29
|
+
}), [truncate, numIntegerDigits, useGrouping, signDisplay, numFractionDigits]);
|
|
30
30
|
const { locale } = (0, react_aria_1.useLocale)();
|
|
31
31
|
// If formatOptions isn't memo'd, a useEffect in useNumberStateField will cause jank,
|
|
32
32
|
// see: https://github.com/adobe/react-spectrum/issues/1893.
|
|
@@ -46,7 +46,7 @@ function NumberField(props) {
|
|
|
46
46
|
? { style: "unit", unit: "day", unitDisplay: "long", maximumFractionDigits: 0 }
|
|
47
47
|
: {};
|
|
48
48
|
return { ...defaultFormatOptions, ...typeFormat };
|
|
49
|
-
}, [type, numberFormatOptions]);
|
|
49
|
+
}, [type, numberFormatOptions, defaultFormatOptions, numFractionDigits]);
|
|
50
50
|
const numberParser = (0, react_1.useMemo)(() => new number_1.NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
51
51
|
const valueRef = (0, react_1.useRef)({ wip: false });
|
|
52
52
|
// We can use this for both useNumberFieldState + useNumberField
|
|
@@ -86,14 +86,14 @@ function NumberField(props) {
|
|
|
86
86
|
if (readOnly && !inputRef.current) {
|
|
87
87
|
inputRef.current = document.createElement("input");
|
|
88
88
|
}
|
|
89
|
-
return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase,
|
|
89
|
+
return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { xss: { ...alignment, ...xss }, groupProps: groupProps, labelProps: labelProps, label: label, required: required, inputProps: (0, react_aria_1.mergeProps)(inputProps, {
|
|
90
90
|
size: sizeToContent ? String((_a = inputProps.value) !== null && _a !== void 0 ? _a : "").length || 1 : undefined,
|
|
91
91
|
}),
|
|
92
92
|
// This is called on each DOM change, to push the latest value into the field
|
|
93
93
|
onChange: (rawInputValue) => {
|
|
94
94
|
const parsedValue = numberParser.parse(rawInputValue || "");
|
|
95
95
|
onChange(formatValue(parsedValue, factor, numFractionDigits, numIntegerDigits));
|
|
96
|
-
}, inputRef: inputRef, onBlur: onBlur, onFocus: onFocus, errorMsg: errorMsg, helperText: helperText, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly)
|
|
96
|
+
}, inputRef: inputRef, onBlur: onBlur, onFocus: onFocus, errorMsg: errorMsg, helperText: helperText, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), ...otherProps }));
|
|
97
97
|
}
|
|
98
98
|
exports.NumberField = NumberField;
|
|
99
99
|
function formatValue(value, factor, numFractionDigits, numIntegerDigits) {
|
|
@@ -38,7 +38,7 @@ function RadioGroupField(props) {
|
|
|
38
38
|
const anyDescriptions = options.some((o) => !!o.description);
|
|
39
39
|
return (
|
|
40
40
|
// width of `max-content` is used to limit invisible label clicking
|
|
41
|
-
(0, jsx_runtime_1.jsxs)("div",
|
|
41
|
+
(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.w("max-content").maxw(anyDescriptions ? "344px" : "320px").$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, ...tid.label, hidden: hideLabel }), (0, jsx_runtime_1.jsx)("div", { ...radioGroupProps, children: options.map((option) => ((0, jsx_runtime_1.jsx)(Radio, { parentId: name, option: option, state: state, ...otherProps, ...tid[option.value] }, option.value))) }), errorMsg && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { errorMsg: errorMsg, ...tid.errorMsg }), helperText && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { helperText: helperText })] }));
|
|
42
42
|
}
|
|
43
43
|
exports.RadioGroupField = RadioGroupField;
|
|
44
44
|
// Not meant to be standalone, but its own component so it can use hooks
|
|
@@ -51,7 +51,7 @@ function Radio(props) {
|
|
|
51
51
|
const { inputProps } = (0, react_aria_1.useRadio)({ value, "aria-labelledby": labelId }, state, ref);
|
|
52
52
|
const { focusProps, isFocusVisible } = (0, react_aria_1.useFocusRing)();
|
|
53
53
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled: disabled });
|
|
54
|
-
return ((0, jsx_runtime_1.jsxs)("label",
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)("label", { css: Css_1.Css.df.cursorPointer.mb1.if(disabled).add("cursor", "initial").$, ...hoverProps, children: [(0, jsx_runtime_1.jsx)("input", { type: "radio", ref: ref, css: {
|
|
55
55
|
...exports.radioReset,
|
|
56
56
|
...exports.radioDefault,
|
|
57
57
|
...(!disabled && state.selectedValue === value ? exports.radioChecked : exports.radioUnchecked),
|
|
@@ -60,7 +60,7 @@ function Radio(props) {
|
|
|
60
60
|
...(isFocusVisible ? exports.radioFocus : {}),
|
|
61
61
|
// Nudge down so the center of the circle lines up with the label text
|
|
62
62
|
...Css_1.Css.mtPx(2).mr1.$,
|
|
63
|
-
}, disabled: disabled, "aria-labelledby": labelId
|
|
63
|
+
}, disabled: disabled, "aria-labelledby": labelId, ...inputProps, ...focusProps, ...others }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { id: labelId, css: Css_1.Css.smMd.gray800.if(disabled).gray400.$, ...(description ? { "aria-describedby": descriptionId } : {}), children: label }), description && ((0, jsx_runtime_1.jsx)("div", { id: descriptionId, css: Css_1.Css.sm.gray700.if(disabled).gray400.$, children: description }))] })] }));
|
|
64
64
|
}
|
|
65
65
|
const whiteCircle = "data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='4'/%3e%3c/svg%3e";
|
|
66
66
|
// Didn't put these in radioReset yet, are they needed?
|
|
@@ -95,16 +95,16 @@ function RichTextField(props) {
|
|
|
95
95
|
}, [value, readOnly, editor]);
|
|
96
96
|
const { placeholder, autoFocus } = props;
|
|
97
97
|
if (!readOnly) {
|
|
98
|
-
return ((0, jsx_runtime_1.jsxs)("div",
|
|
98
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.w100.maxw("550px").$, children: [label && (0, jsx_runtime_1.jsx)(Label_1.Label, { labelProps: {}, label: label }), (0, jsx_runtime_1.jsxs)("div", { css: { ...Css_1.Css.br4.bgWhite.$, ...trixCssOverrides }, children: [(0, jsx_runtime_1.jsx)("input", { type: "hidden", id: `input-${id}`, value: value }), (0, react_2.createElement)("trix-editor", {
|
|
99
99
|
id: id,
|
|
100
100
|
input: `input-${id}`,
|
|
101
101
|
// Autofocus attribute is case sensitive since this is standard HTML
|
|
102
102
|
...(autoFocus ? { autofocus: true } : {}),
|
|
103
103
|
...(placeholder ? { placeholder } : {}),
|
|
104
|
-
})] }),
|
|
104
|
+
})] }), (0, jsx_runtime_1.jsx)(react_1.Global, { styles: [tributeOverrides] })] }));
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
|
-
return ((0, jsx_runtime_1.jsxs)("div",
|
|
107
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.w100.maxw("550px").$, children: [label && (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.mh("120px").bgWhite.sm.gray900.bn.p1.br4.bGray300.ba.$, dangerouslySetInnerHTML: { __html: dompurify_1.default.sanitize(value) || placeholder || "" }, "data-readonly": "true" })] }));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
exports.RichTextField = RichTextField;
|
|
@@ -10,11 +10,11 @@ function RichTextField(props) {
|
|
|
10
10
|
const { onBlur = () => { }, onFocus = () => { }, readOnly } = props;
|
|
11
11
|
const [value, setValue] = (0, react_1.useState)(props.value || "");
|
|
12
12
|
const tid = (0, utils_1.useTestIds)(props, defaultTestId(props.label || "richTextField"));
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)("input",
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("input", { type: "text", value: value, onChange: (e) => {
|
|
14
14
|
const { value } = e.target;
|
|
15
15
|
setValue(value);
|
|
16
16
|
props.onChange(value, value, props.mergeTags || []);
|
|
17
|
-
}, onBlur: onBlur, onFocus: onFocus, readOnly: readOnly
|
|
17
|
+
}, onBlur: onBlur, onFocus: onFocus, readOnly: readOnly, ...tid }));
|
|
18
18
|
}
|
|
19
19
|
exports.RichTextField = RichTextField;
|
|
20
20
|
function defaultTestId(label) {
|
|
@@ -7,11 +7,11 @@ function SelectField(props) {
|
|
|
7
7
|
const { getOptionValue = (opt) => opt.id, // if unset, assume O implements HasId
|
|
8
8
|
getOptionLabel = (opt) => opt.name, // if unset, assume O implements HasName
|
|
9
9
|
options, onSelect, value, ...otherProps } = props;
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(SelectFieldBase_1.SelectFieldBase,
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(SelectFieldBase_1.SelectFieldBase, { ...otherProps, options: options, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, values: [value], onSelect: (values, options) => {
|
|
11
11
|
if (values.length > 0 && options.length > 0) {
|
|
12
12
|
const option = options[0];
|
|
13
13
|
onSelect(values[0], option === SelectFieldBase_1.unsetOption ? undefined : option);
|
|
14
14
|
}
|
|
15
|
-
} })
|
|
15
|
+
} }));
|
|
16
16
|
}
|
|
17
17
|
exports.SelectField = SelectField;
|
|
@@ -18,7 +18,7 @@ function SelectField(props) {
|
|
|
18
18
|
setOptions(maybeOptions);
|
|
19
19
|
}
|
|
20
20
|
}, [maybeOptions]);
|
|
21
|
-
return ((0, jsx_runtime_1.jsxs)("label",
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)("label", { ...tid.label, children: [label, (0, jsx_runtime_1.jsxs)("select", { ...tid, value:
|
|
22
22
|
// @ts-ignore - allow `value` to be seen as a string
|
|
23
23
|
value !== undefined && value !== "" && currentOption ? getOptionValue(currentOption) : "", onChange: (e) => {
|
|
24
24
|
const option = options.find((o) => `${getOptionValue(o)}` === e.target.value) || options[0];
|
|
@@ -35,8 +35,8 @@ function SelectField(props) {
|
|
|
35
35
|
onBlur();
|
|
36
36
|
},
|
|
37
37
|
// Read Only does not apply to `select` fields, instead we'll add in disabled for tests to verify.
|
|
38
|
-
disabled: !!(disabled || readOnly), "data-error": !!errorMsg, "data-errormsg": errorMsg, "data-readonly": readOnly
|
|
39
|
-
return ((0, jsx_runtime_1.jsx)("option",
|
|
40
|
-
})] }),
|
|
38
|
+
disabled: !!(disabled || readOnly), "data-error": !!errorMsg, "data-errormsg": errorMsg, "data-readonly": readOnly, children: [(0, jsx_runtime_1.jsx)("option", { disabled: true, value: "" }), options.map((option, i) => {
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)("option", { value: `${getOptionValue(option)}`, disabled: disabledOptions.includes(getOptionValue(option)), children: getOptionLabel(option) }, i));
|
|
40
|
+
})] }), helperText && (0, jsx_runtime_1.jsx)("div", { ...tid.helperText, children: helperText })] }));
|
|
41
41
|
}
|
|
42
42
|
exports.SelectField = SelectField;
|
package/dist/inputs/Switch.js
CHANGED
|
@@ -22,27 +22,27 @@ function Switch(props) {
|
|
|
22
22
|
return (0, components_1.maybeTooltip)({
|
|
23
23
|
title: tooltip,
|
|
24
24
|
placement: "top",
|
|
25
|
-
children: ((0, jsx_runtime_1.jsxs)("label",
|
|
25
|
+
children: ((0, jsx_runtime_1.jsxs)("label", { ...hoverProps, css: {
|
|
26
26
|
...Css_1.Css.relative.cursorPointer.df.w("max-content").smMd.selectNone.$,
|
|
27
27
|
...(labelStyle === "form" && Css_1.Css.fdc.$),
|
|
28
28
|
...(labelStyle === "inline" && Css_1.Css.gap2.aic.$),
|
|
29
29
|
...(labelStyle === "filter" && Css_1.Css.jcsb.gap1.aic.w("auto").sm.$),
|
|
30
30
|
...(isDisabled && Css_1.Css.cursorNotAllowed.gray400.$),
|
|
31
|
-
}, "aria-label": label
|
|
31
|
+
}, "aria-label": label, children: [!hideLabel && labelStyle === "form" && (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label }), !hideLabel && labelStyle === "filter" && (0, jsx_runtime_1.jsx)("span", { children: label }), (0, jsx_runtime_1.jsx)("div", { "aria-hidden": "true", css: {
|
|
32
32
|
...Css_1.Css.wPx(40).hPx(toggleHeight(compact)).bgGray200.br12.relative.transition.$,
|
|
33
33
|
...(isHovered && exports.switchHoverStyles),
|
|
34
34
|
...(isKeyboardFocus && exports.switchFocusStyles),
|
|
35
35
|
...(isDisabled && Css_1.Css.bgGray300.$),
|
|
36
36
|
...(isSelected && Css_1.Css.bgLightBlue700.$),
|
|
37
37
|
...(isSelected && isHovered && exports.switchSelectedHoverStyles),
|
|
38
|
-
}
|
|
38
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { css: {
|
|
39
39
|
...switchCircleDefaultStyles(compact),
|
|
40
40
|
...(isDisabled && Css_1.Css.bgGray100.$),
|
|
41
41
|
...(isSelected && switchCircleSelectedStyles(compact)),
|
|
42
|
-
}
|
|
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 })) }) }), !hideLabel && labelStyle === "inline" && ((0, jsx_runtime_1.jsx)("span", { css: {
|
|
43
43
|
// LineHeight is conditionally applied to handle compact version text alignment
|
|
44
44
|
...Css_1.Css.if(compact).add("lineHeight", "1").$,
|
|
45
|
-
}
|
|
45
|
+
}, children: label })), (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...inputProps, ...focusProps }) })] })),
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
exports.Switch = Switch;
|
|
@@ -19,6 +19,6 @@ function SwitchGroup(props) {
|
|
|
19
19
|
const groupState = (0, utils_1.toGroupState)(values, onChange);
|
|
20
20
|
const { groupProps, labelProps } = (0, react_aria_1.useCheckboxGroup)({ ...props, "aria-label": label }, groupState);
|
|
21
21
|
const { isSelected, addValue, removeValue } = groupState;
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)("fieldset",
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)("fieldset", { ...groupProps, children: [(0, jsx_runtime_1.jsx)("legend", { ...labelProps, css: Css_1.Css.sm.gray500.mb1.$, children: label }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.fdc.gap2.$, children: options.map(({ label, value }) => ((0, jsx_runtime_1.jsx)(Switch_1.Switch, { compact: compact, label: label, onChange: (isSelected) => (isSelected ? addValue(value) : removeValue(value)), selected: isSelected(value), withIcon: withIcon }, value))) })] }));
|
|
23
23
|
}
|
|
24
24
|
exports.SwitchGroup = SwitchGroup;
|
|
@@ -63,6 +63,6 @@ function TextAreaField(props) {
|
|
|
63
63
|
}
|
|
64
64
|
: {}),
|
|
65
65
|
}, inputRef);
|
|
66
|
-
return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase,
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...(0, react_aria_1.mergeProps)(otherProps, { onBlur, onFocus }), multiline: true, labelProps: labelProps, inputProps: inputProps, inputRef: inputRef, inputWrapRef: inputWrapRef, textAreaMinHeight: preventNewLines ? 0 : undefined, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly) }));
|
|
67
67
|
}
|
|
68
68
|
exports.TextAreaField = TextAreaField;
|