@homebound/beam 4.33.0 → 4.34.0

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/index.cjs CHANGED
@@ -30913,10 +30913,13 @@ function EnvironmentBannerLayout(props) {
30913
30913
  var import_runtime162 = require("@homebound/truss/runtime");
30914
30914
 
30915
30915
  // src/forms/FormSection/FormSection.tsx
30916
+ var import_react_aria70 = require("react-aria");
30917
+ var import_react_stately18 = require("react-stately");
30916
30918
  var import_runtime160 = require("@homebound/truss/runtime");
30917
30919
 
30918
30920
  // src/forms/FormSection/FormSectionChild.tsx
30919
30921
  var import_react164 = require("react");
30922
+ var import_react_aria69 = require("react-aria");
30920
30923
  var import_runtime159 = require("@homebound/truss/runtime");
30921
30924
  var import_jsx_runtime242 = require("react/jsx-runtime");
30922
30925
  function FormSectionChild(props) {
@@ -30926,7 +30929,10 @@ function FormSectionChild(props) {
30926
30929
  actions,
30927
30930
  fields,
30928
30931
  orderField,
30929
- tag
30932
+ tag,
30933
+ value = title,
30934
+ selection,
30935
+ group
30930
30936
  } = props;
30931
30937
  const tid = useTestIds(props, "formSectionChild");
30932
30938
  const itemRef = (0, import_react164.useRef)(null);
@@ -30938,6 +30944,7 @@ function FormSectionChild(props) {
30938
30944
  id: props.id ?? title,
30939
30945
  itemRef
30940
30946
  });
30947
+ const control = group?.mode === "single" ? /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(FormSectionChildRadio, { state: group.state, value, label: title, ...tid.radio }) : group?.mode === "multiple" ? /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(FormSectionChildCheckbox, { state: group.state, value, label: title, ...tid.checkbox }) : selection ? /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(BoundCheckboxField, { field: selection.field, label: title, checkboxOnly: true, ...tid.checkbox }) : void 0;
30941
30948
  return /* @__PURE__ */ (0, import_jsx_runtime242.jsxs)("div", { ...isDraggable ? {
30942
30949
  ...dragItemProps,
30943
30950
  ref: itemRef
@@ -30957,10 +30964,73 @@ function FormSectionChild(props) {
30957
30964
  borderStyle: "lot_bsn",
30958
30965
  borderWidth: "lot_bw_0"
30959
30966
  }), ...tid, children: [
30960
- /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(ContentHeader, { ...tid.header, title, description, actions, level: 4, rightSlotLead: tag && /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(Tag, { ...tag, ...tid.tag }), startAdornment: isDraggable ? /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(DnDGridItemHandle, { dragHandleProps, icon: "drag", compact: true }) : void 0 }),
30967
+ /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(ContentHeader, { ...tid.header, title, description, actions, level: 4, rightSlotLead: tag && /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(Tag, { ...tag, ...tid.tag }), startAdornment: isDraggable || control ? /* @__PURE__ */ (0, import_jsx_runtime242.jsxs)(import_jsx_runtime242.Fragment, { children: [
30968
+ isDraggable && /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(DnDGridItemHandle, { dragHandleProps, icon: "drag", compact: true }),
30969
+ control
30970
+ ] }) : void 0 }),
30961
30971
  fields
30962
30972
  ] });
30963
30973
  }
30974
+ function FormSectionChildRadio(props) {
30975
+ const {
30976
+ state,
30977
+ value,
30978
+ label
30979
+ } = props;
30980
+ const ref = (0, import_react164.useRef)(null);
30981
+ const {
30982
+ inputProps,
30983
+ isDisabled,
30984
+ isSelected
30985
+ } = (0, import_react_aria69.useRadio)({
30986
+ value,
30987
+ "aria-label": label
30988
+ }, state, ref);
30989
+ const {
30990
+ focusProps,
30991
+ isFocusVisible
30992
+ } = (0, import_react_aria69.useFocusRing)();
30993
+ const tid = useTestIds(props);
30994
+ return /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(StyledRadio, { isDisabled, isSelected, isFocusVisible, inputProps: {
30995
+ ...(0, import_react_aria69.mergeProps)(inputProps, focusProps),
30996
+ ref,
30997
+ ...tid
30998
+ } });
30999
+ }
31000
+ function FormSectionChildCheckbox(props) {
31001
+ const {
31002
+ state,
31003
+ value,
31004
+ label
31005
+ } = props;
31006
+ const ref = (0, import_react164.useRef)(null);
31007
+ const {
31008
+ inputProps,
31009
+ isDisabled,
31010
+ isSelected
31011
+ } = (0, import_react_aria69.useCheckboxGroupItem)({
31012
+ value,
31013
+ "aria-label": label
31014
+ }, state, ref);
31015
+ const {
31016
+ focusProps,
31017
+ isFocusVisible
31018
+ } = (0, import_react_aria69.useFocusRing)();
31019
+ const tid = useTestIds(props);
31020
+ return (
31021
+ // `StyledCheckbox` is just the visual box, so the label makes clicking it toggle the hidden input
31022
+ /* @__PURE__ */ (0, import_jsx_runtime242.jsxs)("label", { ...(0, import_runtime159.trussProps)({
31023
+ display: "df",
31024
+ cursor: "cur_pointer",
31025
+ ...isDisabled ? {
31026
+ cursor: "cur_not_allowed"
31027
+ } : {}
31028
+ }), children: [
31029
+ /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(import_react_aria69.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime242.jsx)("input", { ref, ...(0, import_react_aria69.mergeProps)(inputProps, focusProps), ...tid }) }),
31030
+ /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(StyledCheckbox, { isDisabled, isSelected, isFocusVisible })
31031
+ ] })
31032
+ );
31033
+ }
30964
31034
 
30965
31035
  // src/forms/FormSection/FormSection.tsx
30966
31036
  var import_jsx_runtime243 = require("react/jsx-runtime");
@@ -30970,7 +31040,8 @@ function FormSection(props) {
30970
31040
  description,
30971
31041
  actions,
30972
31042
  fields,
30973
- childSections
31043
+ childSections,
31044
+ selection
30974
31045
  } = props;
30975
31046
  const tid = useTestIds(props, "formSection");
30976
31047
  return /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)("div", { id: defaultTestId(title), ...(0, import_runtime160.trussProps)({
@@ -30983,15 +31054,94 @@ function FormSection(props) {
30983
31054
  }), ...tid.section, children: [
30984
31055
  /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(ContentHeader, { ...tid, title, description, actions, level: 3 }),
30985
31056
  fields,
30986
- childSections && (isReorderable(childSections) ? /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(DraggableChildren, { childSections, ...tid.childSection }) : /* @__PURE__ */ (0, import_jsx_runtime243.jsx)("div", { className: "df fdc g_3", children: childSections.map((child) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(FormSectionChild, { ...child, ...tid.childSection }, child.id ?? child.title)) }))
31057
+ childSections && (selection?.mode === "single" ? /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(FormSectionRadioGroup, { field: selection.field, label: title, childSections, ...tid }) : selection?.mode === "multiple" ? /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(FormSectionCheckboxGroup, { field: selection.field, label: title, childSections, ...tid }) : /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(ChildSectionList, { childSections, ...tid.childSection }))
30987
31058
  ] });
30988
31059
  }
31060
+ function FormSectionRadioGroup(props) {
31061
+ const {
31062
+ field,
31063
+ label,
31064
+ childSections
31065
+ } = props;
31066
+ const tid = useTestIds(props);
31067
+ const {
31068
+ value,
31069
+ readOnly
31070
+ } = useComputed(() => ({
31071
+ value: field.value ?? null,
31072
+ readOnly: field.readOnly
31073
+ }), [field]);
31074
+ const state = (0, import_react_stately18.useRadioGroupState)({
31075
+ value,
31076
+ onChange: (value2) => {
31077
+ field.set(value2);
31078
+ field.maybeAutoSave();
31079
+ },
31080
+ isDisabled: readOnly
31081
+ });
31082
+ const {
31083
+ radioGroupProps
31084
+ } = (0, import_react_aria70.useRadioGroup)({
31085
+ "aria-label": label,
31086
+ isDisabled: readOnly,
31087
+ onFocus: () => field.focus(),
31088
+ onBlur: () => field.blur()
31089
+ }, state);
31090
+ return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)("div", { ...radioGroupProps, ...tid.childGroup, children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(ChildSectionList, { childSections, group: {
31091
+ mode: "single",
31092
+ state
31093
+ }, ...tid.childSection }) });
31094
+ }
31095
+ function FormSectionCheckboxGroup(props) {
31096
+ const {
31097
+ field,
31098
+ label,
31099
+ childSections
31100
+ } = props;
31101
+ const tid = useTestIds(props);
31102
+ const {
31103
+ value,
31104
+ readOnly
31105
+ } = useComputed(() => ({
31106
+ value: field.value ?? [],
31107
+ readOnly: field.readOnly
31108
+ }), [field]);
31109
+ const state = (0, import_react_stately18.useCheckboxGroupState)({
31110
+ value,
31111
+ onChange: (values) => {
31112
+ field.set(values);
31113
+ field.maybeAutoSave();
31114
+ },
31115
+ isDisabled: readOnly
31116
+ });
31117
+ const {
31118
+ groupProps
31119
+ } = (0, import_react_aria70.useCheckboxGroup)({
31120
+ "aria-label": label,
31121
+ isDisabled: readOnly,
31122
+ onFocus: () => field.focus(),
31123
+ onBlur: () => field.blur()
31124
+ }, state);
31125
+ return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)("div", { ...groupProps, ...tid.childGroup, children: /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(ChildSectionList, { childSections, group: {
31126
+ mode: "multiple",
31127
+ state
31128
+ }, ...tid.childSection }) });
31129
+ }
31130
+ function ChildSectionList(props) {
31131
+ const {
31132
+ childSections,
31133
+ group,
31134
+ ...tid
31135
+ } = props;
31136
+ return isReorderable(childSections) ? /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(DraggableChildren, { childSections, group, ...tid }) : /* @__PURE__ */ (0, import_jsx_runtime243.jsx)("div", { className: "df fdc g_3", children: childSections.map((child) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(FormSectionChild, { ...child, group, ...tid }, child.id ?? child.title)) });
31137
+ }
30989
31138
  function isReorderable(childSections) {
30990
31139
  return childSections.length > 0 && childSections.every((c) => !!c.orderField);
30991
31140
  }
30992
31141
  function DraggableChildren(props) {
30993
31142
  const {
30994
31143
  childSections,
31144
+ group,
30995
31145
  ...tid
30996
31146
  } = props;
30997
31147
  const sorted = sortByOrderField(childSections);
@@ -31009,7 +31159,7 @@ function DraggableChildren(props) {
31009
31159
  return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(DnDGrid, { onReorder: handleReorder, lockAxis: "y", gridStyles: {
31010
31160
  gridTemplateColumns: "gtc_minmax_0_1fr",
31011
31161
  gap: "g_3"
31012
- }, children: sorted.map((child) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(FormSectionChild, { ...child, ...tid }, child.id)) });
31162
+ }, children: sorted.map((child) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(FormSectionChild, { ...child, group, ...tid }, child.id)) });
31013
31163
  }
31014
31164
  function sortByOrderField(childSections) {
31015
31165
  return [...childSections].sort((a, b) => (a.orderField.value ?? 0) - (b.orderField.value ?? 0));
@@ -32224,8 +32374,8 @@ function useFilter4({ filterDefs }) {
32224
32374
 
32225
32375
  // src/inputs/Autocomplete.tsx
32226
32376
  var import_react180 = require("react");
32227
- var import_react_aria69 = require("react-aria");
32228
- var import_react_stately18 = require("react-stately");
32377
+ var import_react_aria71 = require("react-aria");
32378
+ var import_react_stately19 = require("react-stately");
32229
32379
  var import_jsx_runtime264 = require("react/jsx-runtime");
32230
32380
  function Autocomplete(props) {
32231
32381
  const {
@@ -32244,7 +32394,7 @@ function Autocomplete(props) {
32244
32394
  const { effectiveValue, proposalProps } = useAiProposal(value, proposedValue);
32245
32395
  const disabledOptionsWithReasons = Object.fromEntries(disabledOptions?.map(disabledOptionToKeyedTuple) ?? []);
32246
32396
  const comboBoxChildren = (0, import_react180.useCallback)(
32247
- (item) => /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_react_stately18.Item, { textValue: getOptionLabel(item), children: getOptionMenuLabel ? getOptionMenuLabel(item) : getOptionLabel(item) }, getOptionValue(item)),
32397
+ (item) => /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_react_stately19.Item, { textValue: getOptionLabel(item), children: getOptionMenuLabel ? getOptionMenuLabel(item) : getOptionLabel(item) }, getOptionValue(item)),
32248
32398
  [getOptionValue, getOptionLabel, getOptionMenuLabel]
32249
32399
  );
32250
32400
  const comboBoxProps = {
@@ -32267,12 +32417,12 @@ function Autocomplete(props) {
32267
32417
  },
32268
32418
  ...others
32269
32419
  };
32270
- const state = (0, import_react_stately18.useComboBoxState)(comboBoxProps);
32420
+ const state = (0, import_react_stately19.useComboBoxState)(comboBoxProps);
32271
32421
  const inputWrapRef = (0, import_react180.useRef)(null);
32272
32422
  const inputRef = (0, import_react180.useRef)(null);
32273
32423
  const listBoxRef = (0, import_react180.useRef)(null);
32274
32424
  const popoverRef = (0, import_react180.useRef)(null);
32275
- const { inputProps, listBoxProps, labelProps } = (0, import_react_aria69.useComboBox)(
32425
+ const { inputProps, listBoxProps, labelProps } = (0, import_react_aria71.useComboBox)(
32276
32426
  {
32277
32427
  ...comboBoxProps,
32278
32428
  inputRef,
@@ -32283,7 +32433,7 @@ function Autocomplete(props) {
32283
32433
  },
32284
32434
  state
32285
32435
  );
32286
- const { overlayProps: positionProps } = (0, import_react_aria69.useOverlayPosition)({
32436
+ const { overlayProps: positionProps } = (0, import_react_aria71.useOverlayPosition)({
32287
32437
  targetRef: inputWrapRef,
32288
32438
  overlayRef: popoverRef,
32289
32439
  scrollRef: listBoxRef,
@@ -32340,8 +32490,8 @@ function Autocomplete(props) {
32340
32490
 
32341
32491
  // src/inputs/ToggleButton.tsx
32342
32492
  var import_react181 = require("react");
32343
- var import_react_aria70 = require("react-aria");
32344
- var import_react_stately19 = require("react-stately");
32493
+ var import_react_aria72 = require("react-aria");
32494
+ var import_react_stately20 = require("react-stately");
32345
32495
  var import_runtime172 = require("@homebound/truss/runtime");
32346
32496
  var import_jsx_runtime265 = require("react/jsx-runtime");
32347
32497
  function ToggleButton(props) {
@@ -32362,7 +32512,7 @@ function ToggleButton(props) {
32362
32512
  isDisabled,
32363
32513
  ...otherProps
32364
32514
  };
32365
- const state = (0, import_react_stately19.useToggleState)({
32515
+ const state = (0, import_react_stately20.useToggleState)({
32366
32516
  ...ariaProps,
32367
32517
  onChange: (e) => {
32368
32518
  const result = onChange(e);
@@ -32379,24 +32529,24 @@ function ToggleButton(props) {
32379
32529
  const {
32380
32530
  isPressed: isPressedFromEvents,
32381
32531
  pressProps
32382
- } = (0, import_react_aria70.usePress)({
32532
+ } = (0, import_react_aria72.usePress)({
32383
32533
  ref: labelRef,
32384
32534
  isDisabled
32385
32535
  });
32386
32536
  const {
32387
32537
  inputProps
32388
- } = (0, import_react_aria70.useSwitch)(ariaProps, state, ref);
32538
+ } = (0, import_react_aria72.useSwitch)(ariaProps, state, ref);
32389
32539
  const {
32390
32540
  isFocusVisible: isFocusVisibleFromEvents,
32391
32541
  focusProps
32392
- } = (0, import_react_aria70.useFocusRing)({
32542
+ } = (0, import_react_aria72.useFocusRing)({
32393
32543
  ...otherProps,
32394
32544
  within: true
32395
32545
  });
32396
32546
  const {
32397
32547
  hoverProps,
32398
32548
  isHovered: isHoveredFromEvents
32399
- } = (0, import_react_aria70.useHover)({
32549
+ } = (0, import_react_aria72.useHover)({
32400
32550
  isDisabled
32401
32551
  });
32402
32552
  const isHovered = __storyState?.hovered ?? isHoveredFromEvents;
@@ -32450,7 +32600,7 @@ function ToggleButton(props) {
32450
32600
  children: /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)("label", { ...labelAttrs, children: [
32451
32601
  icon && /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(Icon, { icon }),
32452
32602
  label,
32453
- /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_react_aria70.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("input", { ref, ...inputProps, ...tid.value }) })
32603
+ /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_react_aria72.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("input", { ref, ...inputProps, ...tid.value }) })
32454
32604
  ] })
32455
32605
  });
32456
32606
  }