@homebound/beam 4.28.0 → 4.29.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
@@ -23066,6 +23066,7 @@ function RadioGroupField(props) {
23066
23066
  isDisabled: disabled,
23067
23067
  isRequired: required
23068
23068
  }, state);
23069
+ const isThumbnail = layout === "thumbnail";
23069
23070
  return (
23070
23071
  // default styling to position `<Label />` above.
23071
23072
  /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("div", { ...(0, import_runtime106.trussProps)({
@@ -23083,20 +23084,24 @@ function RadioGroupField(props) {
23083
23084
  /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("div", { ...radioGroupProps, children: [
23084
23085
  /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { ...(0, import_runtime106.trussProps)({
23085
23086
  display: "df",
23086
- ...layout === "horizontal" ? {
23087
+ flexDirection: "fdc",
23088
+ gap: "g_1",
23089
+ ...layout !== "vertical" ? {
23087
23090
  flexDirection: "fdr",
23088
- flexWrap: "fww",
23091
+ flexWrap: "fww"
23092
+ } : {},
23093
+ ...layout === "horizontal" ? {
23089
23094
  gap: "g_3"
23090
- } : {
23091
- flexDirection: "fdc",
23092
- gap: "g_1"
23093
- }
23095
+ } : {}
23094
23096
  }), children: options.map((option) => {
23095
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_react101.Fragment, { children: maybeTooltip({
23096
- title: resolveTooltip(option.disabled),
23097
- placement: "bottom",
23098
- children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Radio, { parentId: name, option, state, isOptionDisabled: !!option.disabled, ...otherProps, ...tid[option.value] })
23099
- }) }, option.value);
23097
+ const radioProps = {
23098
+ option,
23099
+ state,
23100
+ isOptionDisabled: !!option.disabled,
23101
+ ...otherProps,
23102
+ ...tid[option.value]
23103
+ };
23104
+ return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_react101.Fragment, { children: isThumbnail ? /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(ThumbnailRadio, { ...radioProps }) : /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(Radio, { parentId: name, ...radioProps }) }, option.value);
23100
23105
  }) }),
23101
23106
  errorMsg && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(ErrorMessage, { errorMsg, ...tid.errorMsg }),
23102
23107
  helperText && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(HelperText, { helperText })
@@ -23110,7 +23115,8 @@ function Radio(props) {
23110
23115
  option: {
23111
23116
  description,
23112
23117
  label,
23113
- value
23118
+ value,
23119
+ disabled: disabledReason
23114
23120
  },
23115
23121
  state,
23116
23122
  isOptionDisabled,
@@ -23139,71 +23145,198 @@ function Radio(props) {
23139
23145
  } = (0, import_react_aria49.useHover)({
23140
23146
  isDisabled: disabled
23141
23147
  });
23142
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("label", { ...(0, import_runtime106.trussProps)({
23143
- display: "df",
23144
- cursor: "cur_pointer",
23145
- ...disabled ? {
23146
- cursor: "cur_initial"
23147
- } : {}
23148
- }), ...hoverProps, children: [
23149
- /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
23150
- "input",
23151
- {
23152
- type: "radio",
23153
- ref,
23154
- ...(0, import_runtime106.trussProps)({
23155
- ...radioReset,
23156
- ...radioDefault,
23157
- ...getRadioStateStyles({
23158
- isDisabled: disabled,
23159
- isSelected
23148
+ return maybeTooltip({
23149
+ title: resolveTooltip(disabledReason),
23150
+ placement: "bottom",
23151
+ children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("label", { ...(0, import_runtime106.trussProps)({
23152
+ display: "df",
23153
+ cursor: "cur_pointer",
23154
+ ...disabled ? {
23155
+ cursor: "cur_initial"
23156
+ } : {}
23157
+ }), ...hoverProps, children: [
23158
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
23159
+ "input",
23160
+ {
23161
+ type: "radio",
23162
+ ref,
23163
+ ...(0, import_runtime106.trussProps)({
23164
+ ...radioReset,
23165
+ ...radioDefault,
23166
+ ...getRadioStateStyles({
23167
+ isDisabled: disabled,
23168
+ isSelected
23169
+ }),
23170
+ ...isHovered && !disabled ? radioHover : {},
23171
+ ...isFocusVisible ? radioFocus : {},
23172
+ // Nudge down so the center of the circle lines up with the label text
23173
+ ...{
23174
+ marginTop: "mt_2px",
23175
+ marginRight: "mr1"
23176
+ }
23160
23177
  }),
23161
- ...isHovered && !disabled ? radioHover : {},
23162
- ...isFocusVisible ? radioFocus : {},
23163
- // Nudge down so the center of the circle lines up with the label text
23164
- ...{
23165
- marginTop: "mt_2px",
23166
- marginRight: "mr1"
23167
- }
23168
- }),
23169
- disabled,
23170
- "aria-labelledby": labelId,
23171
- ...inputProps,
23172
- ...focusProps,
23173
- ...others
23174
- }
23175
- ),
23176
- /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("div", { children: [
23177
- /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { id: labelId, ...(0, import_runtime106.trussProps)({
23178
- fontWeight: "fw4",
23179
- fontSize: "fz_14px",
23180
- lineHeight: "lh_20px",
23181
- color: ["color_var", {
23182
- "--color": "var(--b-on-surface)"
23183
- }],
23184
- ...disabled ? {
23178
+ disabled,
23179
+ "aria-labelledby": labelId,
23180
+ ...inputProps,
23181
+ ...focusProps,
23182
+ ...others
23183
+ }
23184
+ ),
23185
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("div", { children: [
23186
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { id: labelId, ...(0, import_runtime106.trussProps)({
23187
+ fontWeight: "fw4",
23188
+ fontSize: "fz_14px",
23189
+ lineHeight: "lh_20px",
23185
23190
  color: ["color_var", {
23186
- "--color": "var(--b-text-disabled)"
23187
- }]
23188
- } : {}
23189
- }), ...description ? {
23190
- "aria-describedby": descriptionId
23191
- } : {}, children: label }),
23192
- description && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { id: descriptionId, ...(0, import_runtime106.trussProps)({
23193
- fontWeight: "fw4",
23194
- fontSize: "fz_14px",
23195
- lineHeight: "lh_20px",
23196
- color: ["color_var", {
23197
- "--color": "var(--b-on-surface-muted)"
23198
- }],
23199
- ...disabled ? {
23191
+ "--color": "var(--b-on-surface)"
23192
+ }],
23193
+ ...disabled ? {
23194
+ color: ["color_var", {
23195
+ "--color": "var(--b-text-disabled)"
23196
+ }]
23197
+ } : {}
23198
+ }), ...description ? {
23199
+ "aria-describedby": descriptionId
23200
+ } : {}, children: label }),
23201
+ description && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("div", { id: descriptionId, ...(0, import_runtime106.trussProps)({
23202
+ fontWeight: "fw4",
23203
+ fontSize: "fz_14px",
23204
+ lineHeight: "lh_20px",
23200
23205
  color: ["color_var", {
23201
- "--color": "var(--b-text-disabled)"
23202
- }]
23203
- } : {}
23204
- }), children: typeof description === "function" ? description() : description })
23206
+ "--color": "var(--b-on-surface-muted)"
23207
+ }],
23208
+ ...disabled ? {
23209
+ color: ["color_var", {
23210
+ "--color": "var(--b-text-disabled)"
23211
+ }]
23212
+ } : {}
23213
+ }), children: typeof description === "function" ? description() : description })
23214
+ ] })
23205
23215
  ] })
23206
- ] });
23216
+ });
23217
+ }
23218
+ function ThumbnailRadio(props) {
23219
+ const {
23220
+ option: {
23221
+ label,
23222
+ value,
23223
+ imgSrc,
23224
+ disabled: disabledReason
23225
+ },
23226
+ state,
23227
+ isOptionDisabled,
23228
+ ...others
23229
+ } = props;
23230
+ const ref = (0, import_react101.useRef)(null);
23231
+ const {
23232
+ inputProps,
23233
+ isDisabled
23234
+ } = (0, import_react_aria49.useRadio)({
23235
+ value,
23236
+ "aria-label": label,
23237
+ isDisabled: isOptionDisabled
23238
+ }, state, ref);
23239
+ const isSelected = !isDisabled && state.selectedValue === value;
23240
+ const {
23241
+ focusProps,
23242
+ isFocusVisible
23243
+ } = (0, import_react_aria49.useFocusRing)();
23244
+ const {
23245
+ hoverProps,
23246
+ isHovered
23247
+ } = (0, import_react_aria49.useHover)({
23248
+ isDisabled
23249
+ });
23250
+ const {
23251
+ pressProps,
23252
+ isPressed
23253
+ } = (0, import_react_aria49.usePress)({
23254
+ isDisabled,
23255
+ preventFocusOnPress: true
23256
+ });
23257
+ return maybeTooltip({
23258
+ // Thumbnails have no visible text, so their label doubles as the tooltip, unless there's a disabled reason.
23259
+ title: resolveTooltip(disabledReason) ?? label,
23260
+ placement: "top",
23261
+ children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("label", { ...(0, import_runtime106.trussProps)({
23262
+ // The padding over the white background is the inner ring between the border and the image.
23263
+ ...{
23264
+ display: "db",
23265
+ flexShrink: "fs0",
23266
+ height: "h_32px",
23267
+ width: "w_32px",
23268
+ paddingTop: "pt_2px",
23269
+ paddingBottom: "pb_2px",
23270
+ paddingRight: "pr_2px",
23271
+ paddingLeft: "pl_2px",
23272
+ borderRadius: "br8",
23273
+ borderStyle: "bss",
23274
+ borderWidth: "bw1",
23275
+ borderColor: ["bc_var", {
23276
+ "--borderColor": "var(--b-field-border-default)"
23277
+ }],
23278
+ backgroundColor: ["bgColor_var", {
23279
+ "--backgroundColor": "var(--b-surface-raised)"
23280
+ }],
23281
+ outline: "ol_0",
23282
+ cursor: "cur_pointer"
23283
+ },
23284
+ // Lets a wrapping `Carousel` snap to each thumbnail.
23285
+ ...{
23286
+ scrollSnapAlign: "ssa_start"
23287
+ },
23288
+ ...isHovered && !isFocusVisible ? {
23289
+ boxShadow: "bshHover"
23290
+ } : {},
23291
+ ...isSelected || isPressed ? {
23292
+ borderColor: ["bc_var", {
23293
+ "--borderColor": "var(--b-primary)"
23294
+ }]
23295
+ } : {},
23296
+ ...isFocusVisible ? {
23297
+ boxShadow: "bshFocus"
23298
+ } : {},
23299
+ ...isDisabled ? {
23300
+ cursor: "cur_not_allowed"
23301
+ } : {}
23302
+ }), "data-selected": isSelected, "data-disabled": isDisabled, ...(0, import_react_aria49.mergeProps)(hoverProps, pressProps), children: [
23303
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_react_aria49.VisuallyHidden, { elementType: "span", children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("input", { ...(0, import_react_aria49.mergeProps)(inputProps, focusProps, others), ref }) }),
23304
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("span", { className: "relative db w100 h100 oh br4", children: [
23305
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("img", { src: imgSrc, alt: label, loading: "lazy", ...(0, import_runtime106.trussProps)({
23306
+ width: "w100",
23307
+ height: "h100",
23308
+ objectFit: "obf_cover",
23309
+ display: "db",
23310
+ ...isDisabled ? {
23311
+ opacity: "o50"
23312
+ } : {}
23313
+ }) }),
23314
+ (isSelected || isPressed) && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("span", { ...(0, import_runtime106.trussProps)({
23315
+ ...{
23316
+ position: "absolute",
23317
+ top: "top0",
23318
+ left: "l_0",
23319
+ width: "w100",
23320
+ height: "h100",
23321
+ pointerEvents: "pen"
23322
+ },
23323
+ ...isSelected ? {
23324
+ backgroundColor: ["bgColor_var", {
23325
+ "--backgroundColor": "var(--b-selection-fill)"
23326
+ }],
23327
+ mixBlendMode: "mbm_multiply"
23328
+ } : {},
23329
+ ...isPressed ? {
23330
+ backgroundColor: ["bgColor_var", {
23331
+ "--backgroundColor": "var(--b-primary)"
23332
+ }],
23333
+ opacity: "o_0_28",
23334
+ mixBlendMode: "mbm_normal"
23335
+ } : {}
23336
+ }) })
23337
+ ] })
23338
+ ] })
23339
+ });
23207
23340
  }
23208
23341
 
23209
23342
  // src/forms/BoundRadioGroupField.tsx