@homebound/beam 2.417.7 → 2.417.8

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.
@@ -28,6 +28,31 @@ function newMethodMissingProxy(object, methodMissing) {
28
28
  });
29
29
  }
30
30
 
31
+ // src/utils/inlineStyles.ts
32
+ function isInlineStyleValue(value) {
33
+ return typeof value === "string" || typeof value === "number";
34
+ }
35
+ function setInlineStyles(el, styles) {
36
+ Object.entries(styles).forEach(([prop, value]) => {
37
+ if (!isInlineStyleValue(value)) return;
38
+ if (prop.startsWith("--")) {
39
+ el.style.setProperty(prop, String(value));
40
+ } else {
41
+ el.style[prop] = String(value);
42
+ }
43
+ });
44
+ }
45
+ function clearInlineStyles(el, styles) {
46
+ Object.entries(styles).forEach(([prop, value]) => {
47
+ if (!isInlineStyleValue(value)) return;
48
+ if (prop.startsWith("--")) {
49
+ el.style.removeProperty(prop);
50
+ } else {
51
+ el.style[prop] = "";
52
+ }
53
+ });
54
+ }
55
+
31
56
  // src/utils/index.ts
32
57
  function fail(message) {
33
58
  throw new Error(message || "Failed");
@@ -76,6 +101,8 @@ function pluralize(count, noun, pluralNoun) {
76
101
  }
77
102
 
78
103
  export {
104
+ setInlineStyles,
105
+ clearInlineStyles,
79
106
  defaultTestId,
80
107
  useTestIds,
81
108
  newMethodMissingProxy,
@@ -93,4 +120,4 @@ export {
93
120
  isDefined,
94
121
  pluralize
95
122
  };
96
- //# sourceMappingURL=chunk-XH44AYND.js.map
123
+ //# sourceMappingURL=chunk-ZPT2ZR5B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/defaultTestId.ts","../src/utils/useTestIds.tsx","../src/utils/inlineStyles.ts","../src/utils/index.ts"],"sourcesContent":["import { camelCase } from \"change-case\";\n\n/**\n * Guesses an id based on a label string, i.e. given `Homeowner Contract`,\n * returns `homeownerContract`.\n *\n * This is useful for our (non-bound) form fields that will probably have a label,\n * but may not have a `data-testid` set by the encompassing page.\n *\n * (Bound form fields typically set their test id from their form-state field's key.)\n */\nexport function defaultTestId(label: string): string {\n // Strip `m:4` to `m4` to prevent it from becoming `m_4` which our rtl-utils assumes\n // means \"the 4th element with a data-testid value of 'm'\".\n return camelCase(label.replace(\":\", \"\"));\n}\n","import { defaultTestId } from \"src/utils/defaultTestId\";\n\nexport type TestIds = Record<string, object>;\n\n/**\n * Provides a way to easily generate `data-testid`s.\n *\n * The test ids are made of a `${prefix}_${key}`, where:\n *\n * - The prefix is the component name, like \"profile\", and\n * - The key is the specific DOM element that's being tagged, like \"firstName\"\n *\n * To determine the prefix, the component passes us their props, which we'll use\n * to look for an incoming `data-testid` to become the prefix the `data-testid`s\n * that we create. I.e.:\n *\n * ```tsx\n * const { a, b } = props;\n * const tid = useTestIds(props);\n *\n * return <Foo {...tid.foo} />;\n * ```\n *\n * This allows components that embed the component to customize the prefix, i.e.\n * `<TextField data-testid=\"firstName\" />` and `<TextField data-testid=\"lastName\" />`\n * would produce, within `TextField` itself, ids like:\n *\n * - `firstName_input`\n * - `firstName_errors`\n * - `lastName_input`\n * - `lastName_errors`\n *\n * @param props the component's `props` object, which we'll scan for `data-testid` to use as the prefix\n * @param defaultPrefix the default prefix to use if no `data-testid` is found on `props`\n */\nexport function useTestIds(props: object, defaultPrefix?: string): Record<string, object> {\n const prefix: string | undefined =\n (props as any)[\"data-testid\"] ||\n // Pass defaultPrefix through defaultTestId to allow `useTestIds(..., label)` usage\n (defaultPrefix ? defaultTestId(defaultPrefix) : undefined);\n const rootId = { \"data-testid\": prefix };\n return newMethodMissingProxy(rootId, (key) => {\n // If we get tagged ids, remove the colon so that we can do `r.foo_m2` for `m:2`\n key = key.replace(\":\", \"\");\n return { \"data-testid\": prefix ? `${prefix}_${key}` : key };\n }) as any;\n}\n\n/** Uses `object` for any keys that exist on it, otherwise calls `methodMissing` fn. */\nexport function newMethodMissingProxy<T extends object, Y>(\n object: T,\n methodMissing: (key: string) => Y,\n): T & Record<string, Y> {\n return new Proxy(object, {\n get(object, property) {\n if (Reflect.has(object, property)) {\n return Reflect.get(object, property);\n } else if (property === \"then\") {\n return undefined;\n } else {\n return methodMissing(String(property));\n }\n },\n }) as any;\n}\n","function isInlineStyleValue(value: unknown): value is string | number {\n return typeof value === \"string\" || typeof value === \"number\";\n}\n\nexport function setInlineStyles(el: HTMLElement, styles: object): void {\n Object.entries(styles as Record<string, unknown>).forEach(([prop, value]) => {\n if (!isInlineStyleValue(value)) return;\n if (prop.startsWith(\"--\")) {\n el.style.setProperty(prop, String(value));\n } else {\n (el.style as any)[prop] = String(value);\n }\n });\n}\n\nexport function clearInlineStyles(el: HTMLElement, styles: object): void {\n Object.entries(styles as Record<string, unknown>).forEach(([prop, value]) => {\n if (!isInlineStyleValue(value)) return;\n if (prop.startsWith(\"--\")) {\n el.style.removeProperty(prop);\n } else {\n (el.style as any)[prop] = \"\";\n }\n });\n}\n","import { MutableRefObject } from \"react\";\nimport type { CheckboxGroupState, ToggleState } from \"react-stately\";\n\nexport function fail(message?: string): never {\n throw new Error(message || \"Failed\");\n}\n\n/** Adapts our state to what useToggleState returns in a stateless manner. */\nexport function toToggleState(isSelected: boolean, onChange: (value: boolean) => void): ToggleState {\n return {\n isSelected,\n defaultSelected: false,\n setSelected: onChange,\n toggle: () => onChange(!isSelected),\n };\n}\n\n/** Adapts our state to what use*Group returns in a stateless manner. */\nexport function toGroupState<T extends string>(values: T[], onChange: (value: T[]) => void): CheckboxGroupState {\n const addValue = (value: T) => onChange([...values, value]);\n const removeValue = (value: T) => onChange(values.filter((_value) => _value !== value));\n\n return {\n value: values,\n defaultValue: [],\n setValue: onChange,\n isSelected: (value: T) => values.includes(value),\n addValue,\n removeValue,\n toggleValue: (value: T) => (values.includes(value) ? addValue(value) : removeValue(value)),\n isDisabled: false,\n isReadOnly: false,\n // We do not use the validation state, as our Switch groups do not support error states. However, this field is required by the `CheckboxGroupState` so we need to include it.\n // If we ever update our SwitchGroup component to support error states, we'll need to update this.\n validationState: \"valid\",\n isInvalid: false,\n isRequired: false,\n setInvalid: () => {},\n realtimeValidation: { isInvalid: false, validationErrors: [], validationDetails: {} as ValidityState },\n displayValidation: { isInvalid: false, validationErrors: [], validationDetails: {} as ValidityState },\n updateValidation: () => {},\n resetValidation: () => {},\n commitValidation: () => {},\n };\n}\n\n/**\n * Utility to maybe call a function if undefined with arguments\n *\n * @example\n * maybeCall(onChange, true)\n * maybeCall(onBlur)\n * maybeCall(onSelect, { id: 1, value: \"book 1\"}, true)\n */\nexport function maybeCall(callback: Function | undefined, ...args: any[]) {\n return callback && callback(...args);\n}\n\nexport * from \"./inlineStyles\";\nexport * from \"./useTestIds\";\n\n/** Casts `Object.keys` to \"what it should be\", as long as your instance doesn't have keys it shouldn't. */\nexport function safeKeys<T>(instance: T): (keyof T)[] {\n return Object.getOwnPropertyNames(instance) as any;\n}\n\n// Returns object with specified key removed\nexport const omitKey = <T, K extends keyof T>(key: K, { [key]: _, ...obj }: T) => obj as T;\n\nexport const noop = (..._: any) => {};\n\ntype Entries<T> = {\n [K in keyof T]: [K, T[K]];\n}[keyof T][];\n\nexport function safeEntries<T extends object>(obj: T): Entries<T> {\n return Object.entries(obj) as any;\n}\n\nexport class EmptyRef<T> implements MutableRefObject<T> {\n get current(): T {\n throw new Error(\"BeamProvider is missing\");\n }\n\n set current(_) {\n throw new Error(\"BeamProvider is missing\");\n }\n}\n\nexport const isAbsoluteUrl = (url: string) => /^(http(s?)):\\/\\//i.test(url);\n\nexport function areArraysEqual(a: any[], b: any[]): boolean {\n return a.length === b.length && a.every((val, idx) => val === b[idx]);\n}\n\nexport function isPromise(obj: any | Promise<any>): obj is Promise<any> {\n return typeof obj === \"object\" && \"then\" in obj && typeof obj.then === \"function\";\n}\n\nexport function isFunction(f: any): f is Function {\n return typeof f === \"function\";\n}\n\nexport function isDefined<T extends any>(param: T | undefined | null): param is T {\n return param !== null && param !== undefined;\n}\n\nexport function pluralize(count: number | unknown[], noun: string, pluralNoun?: string): string {\n if ((Array.isArray(count) ? count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Q,UAAU;AACrC;AAEO,SAAS,UAAU,OAA2B,MAAc,YAA6B;AAC9F,OAAK,MAAM,QAAQ,KAAK,IAAI,MAAM,SAAS,WAAW,EAAG,QAAO;AAChE,SAAO,cAAc,GAAG,IAAI;AAC9B;","names":["object"]}
package/dist/index.cjs CHANGED
@@ -4351,6 +4351,31 @@ var import_react_dom = require("react-dom");
4351
4351
  var import_react_popper = require("react-popper");
4352
4352
  var import_react_stately = require("react-stately");
4353
4353
 
4354
+ // src/utils/inlineStyles.ts
4355
+ function isInlineStyleValue(value) {
4356
+ return typeof value === "string" || typeof value === "number";
4357
+ }
4358
+ function setInlineStyles(el, styles) {
4359
+ Object.entries(styles).forEach(([prop, value]) => {
4360
+ if (!isInlineStyleValue(value)) return;
4361
+ if (prop.startsWith("--")) {
4362
+ el.style.setProperty(prop, String(value));
4363
+ } else {
4364
+ el.style[prop] = String(value);
4365
+ }
4366
+ });
4367
+ }
4368
+ function clearInlineStyles(el, styles) {
4369
+ Object.entries(styles).forEach(([prop, value]) => {
4370
+ if (!isInlineStyleValue(value)) return;
4371
+ if (prop.startsWith("--")) {
4372
+ el.style.removeProperty(prop);
4373
+ } else {
4374
+ el.style[prop] = "";
4375
+ }
4376
+ });
4377
+ }
4378
+
4354
4379
  // src/utils/defaultTestId.ts
4355
4380
  var import_change_case = require("change-case");
4356
4381
  function defaultTestId(label) {
@@ -4535,11 +4560,7 @@ var Icon = import_react4.default.memo((props) => {
4535
4560
  viewBox: "0 0 24 24",
4536
4561
  xmlns: "http://www.w3.org/2000/svg",
4537
4562
  css: {
4538
- // Spread these in b/c they don't type-check for some reason...
4539
- ...{
4540
- "& > path": Css.fill(color).$,
4541
- "& > rect": Css.fill(color).$
4542
- },
4563
+ ...Css.fill(color).$,
4543
4564
  ...bgColor && Css.bgColor(bgColor).$,
4544
4565
  ...xss
4545
4566
  },
@@ -5123,20 +5144,8 @@ var Icons = {
5123
5144
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M7.43848 0.0527344C8.92278 0.0527344 10.1259 1.25595 10.126 2.74023C10.126 4.22459 8.78231 5.87619 7.43848 7.66797C6.09464 5.87619 4.75098 4.22459 4.75098 2.74023C4.75107 1.25601 5.95425 0.0528239 7.43848 0.0527344ZM7.4375 1.84473C6.94279 1.84478 6.54203 2.24552 6.54199 2.74023C6.54199 3.23499 6.94276 3.63569 7.4375 3.63574C7.93229 3.63574 8.33301 3.23502 8.33301 2.74023C8.33296 2.24549 7.93226 1.84473 7.4375 1.84473Z" })
5124
5145
  ] }),
5125
5146
  buildings: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
5126
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
5127
- "path",
5128
- {
5129
- d: "M14.1787 3.58594V23.6494H0V3.60449L7.08887 0.347656L14.1787 3.58594ZM3.42285 20.2275H5.86719V17.7832H3.42285V20.2275ZM8.31348 17.7832V20.2275H10.7578V17.7832H8.31348ZM3.42285 16.3174H5.86719V13.873H3.42285V16.3174ZM8.31348 16.3174H10.7578V13.873H8.31348V16.3174ZM3.42285 12.4062H5.86719V9.96191H3.42285V12.4062ZM8.31348 12.4062H10.7578V9.96191H8.31348V12.4062ZM3.42285 8.49414H5.86719V6.0498H3.42285V8.49414ZM8.31348 8.49414H10.7578V6.0498H8.31348V8.49414Z",
5130
- fill: "#8D8D8D"
5131
- }
5132
- ),
5133
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
5134
- "path",
5135
- {
5136
- d: "M22 23.6523H15.6445V8.00684H22V23.6523ZM17.5996 18.7617V21.2061H20.0439V18.7617H17.5996ZM17.5996 17.2959H20.0439V14.8516H17.5996V17.2959ZM17.5996 13.3828H20.0439V10.9385H17.5996V13.3828Z",
5137
- fill: "#8D8D8D"
5138
- }
5139
- )
5147
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M14.1787 3.58594V23.6494H0V3.60449L7.08887 0.347656L14.1787 3.58594ZM3.42285 20.2275H5.86719V17.7832H3.42285V20.2275ZM8.31348 17.7832V20.2275H10.7578V17.7832H8.31348ZM3.42285 16.3174H5.86719V13.873H3.42285V16.3174ZM8.31348 16.3174H10.7578V13.873H8.31348V16.3174ZM3.42285 12.4062H5.86719V9.96191H3.42285V12.4062ZM8.31348 12.4062H10.7578V9.96191H8.31348V12.4062ZM3.42285 8.49414H5.86719V6.0498H3.42285V8.49414ZM8.31348 8.49414H10.7578V6.0498H8.31348V8.49414Z" }),
5148
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M22 23.6523H15.6445V8.00684H22V23.6523ZM17.5996 18.7617V21.2061H20.0439V18.7617H17.5996ZM17.5996 17.2959H20.0439V14.8516H17.5996V17.2959ZM17.5996 13.3828H20.0439V10.9385H17.5996V13.3828Z" })
5140
5149
  ] }),
5141
5150
  community: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
5142
5151
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M6.41018 0.520509C6.61589 0.334405 6.93017 0.334214 7.13576 0.520509L11.1797 4.20899C11.1553 4.22924 11.1302 4.24904 11.1065 4.27051L11.1016 4.27539L7.85549 7.23535V6.22266H5.69045V8.96289C5.69045 9.2644 5.44619 9.51172 5.14846 9.51172H3.52444C3.22683 9.51157 2.98342 9.26431 2.98342 8.96289V5.12598H2.0635C1.81449 5.12598 1.70074 4.8129 1.88479 4.64844L6.41018 0.520509ZM10.5615 8.96289C10.5615 9.2644 10.3183 9.51172 10.0205 9.51172H8.39651C8.24437 9.51169 8.10738 9.44603 8.00881 9.34277L10.5615 7.01465V8.96289Z" }),
@@ -6824,13 +6833,13 @@ function AvatarButton(props) {
6824
6833
  menuTriggerProps,
6825
6834
  openInNew,
6826
6835
  forceFocusStyles = false,
6827
- forcePressedStyles = false,
6836
+ __storyState,
6828
6837
  ...avatarProps
6829
6838
  } = props;
6830
6839
  const isDisabled = !!disabled;
6831
6840
  const ariaProps = { onPress, isDisabled, autoFocus, ...menuTriggerProps };
6832
6841
  const ref = useGetRef(buttonRef);
6833
- const { buttonProps, isPressed } = (0, import_react_aria6.useButton)(
6842
+ const { buttonProps, isPressed: isPressedFromEvents } = (0, import_react_aria6.useButton)(
6834
6843
  {
6835
6844
  ...ariaProps,
6836
6845
  onPress: typeof onPress === "string" ? noop : onPress,
@@ -6838,8 +6847,11 @@ function AvatarButton(props) {
6838
6847
  },
6839
6848
  ref
6840
6849
  );
6841
- const { focusProps, isFocusVisible } = (0, import_react_aria6.useFocusRing)(ariaProps);
6842
- const { hoverProps, isHovered } = (0, import_react_aria6.useHover)(ariaProps);
6850
+ const { focusProps, isFocusVisible: isFocusVisibleFromEvents } = (0, import_react_aria6.useFocusRing)(ariaProps);
6851
+ const { hoverProps, isHovered: isHoveredFromEvents } = (0, import_react_aria6.useHover)(ariaProps);
6852
+ const isHovered = __storyState?.hovered ?? isHoveredFromEvents;
6853
+ const isFocusVisible = __storyState?.focusVisible ?? isFocusVisibleFromEvents;
6854
+ const isPressed = __storyState?.pressed ?? isPressedFromEvents;
6843
6855
  const tid = useTestIds(props, avatarProps.name);
6844
6856
  const styles = (0, import_react22.useMemo)(
6845
6857
  () => ({
@@ -6862,7 +6874,7 @@ function AvatarButton(props) {
6862
6874
  };
6863
6875
  const content = /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
6864
6876
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Avatar, { ...avatarProps, ...tid, disableTooltip: true }),
6865
- (isPressed || forcePressedStyles) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { css: pressedOverlayCss })
6877
+ isPressed && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { css: pressedOverlayCss })
6866
6878
  ] });
6867
6879
  return maybeTooltip({
6868
6880
  // Default the tooltip to the avatar's name, if defined.
@@ -12557,6 +12569,7 @@ function Switch(props) {
12557
12569
  label,
12558
12570
  labelStyle = "inline",
12559
12571
  hideLabel = false,
12572
+ __storyState,
12560
12573
  ...otherProps
12561
12574
  } = props;
12562
12575
  const isDisabled = !!disabled;
@@ -12564,8 +12577,10 @@ function Switch(props) {
12564
12577
  const state = toToggleState(isSelected, onChange);
12565
12578
  const ref = (0, import_react63.useRef)(null);
12566
12579
  const { inputProps } = (0, import_react_aria35.useSwitch)({ ...ariaProps, "aria-label": label }, state, ref);
12567
- const { isFocusVisible: isKeyboardFocus, focusProps } = (0, import_react_aria35.useFocusRing)(otherProps);
12568
- const { hoverProps, isHovered } = (0, import_react_aria35.useHover)(ariaProps);
12580
+ const { isFocusVisible: isFocusVisibleFromEvents, focusProps } = (0, import_react_aria35.useFocusRing)(otherProps);
12581
+ const { hoverProps, isHovered: isHoveredFromEvents } = (0, import_react_aria35.useHover)(ariaProps);
12582
+ const isFocusVisible = __storyState?.focusVisible ?? isFocusVisibleFromEvents;
12583
+ const isHovered = __storyState?.hovered ?? isHoveredFromEvents;
12569
12584
  const tooltip = resolveTooltip(disabled, props.tooltip);
12570
12585
  const tid = useTestIds(otherProps, label);
12571
12586
  return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
@@ -12598,7 +12613,7 @@ function Switch(props) {
12598
12613
  css: {
12599
12614
  ...Css.wPx(toggleWidth(compact)).hPx(toggleHeight(compact)).bgGray200.br12.relative.transition.$,
12600
12615
  ...isHovered && switchHoverStyles,
12601
- ...isKeyboardFocus && switchFocusStyles,
12616
+ ...isFocusVisible && switchFocusStyles,
12602
12617
  ...isDisabled && Css.bgGray300.$,
12603
12618
  ...isSelected && Css.bgBlue700.$,
12604
12619
  ...isSelected && isHovered && switchSelectedHoverStyles
@@ -12765,7 +12780,7 @@ var import_react_aria38 = require("react-aria");
12765
12780
  var import_react_stately15 = require("react-stately");
12766
12781
  var import_jsx_runtime77 = require("@emotion/react/jsx-runtime");
12767
12782
  function ToggleButton(props) {
12768
- const { selected: isSelected = false, disabled = false, label, onChange, icon, ...otherProps } = props;
12783
+ const { selected: isSelected = false, disabled = false, label, onChange, icon, __storyState, ...otherProps } = props;
12769
12784
  const [asyncInProgress, setAsyncInProgress] = (0, import_react66.useState)(false);
12770
12785
  const isDisabled = !!disabled || asyncInProgress;
12771
12786
  const ariaProps = { "aria-label": label, isSelected, isDisabled, ...otherProps };
@@ -12782,11 +12797,14 @@ function ToggleButton(props) {
12782
12797
  });
12783
12798
  const labelRef = (0, import_react66.useRef)(null);
12784
12799
  const ref = (0, import_react66.useRef)(null);
12785
- const tid = useTestIds(props, label);
12786
- const { isPressed, pressProps } = (0, import_react_aria38.usePress)({ ref: labelRef, isDisabled });
12800
+ const tid = useTestIds(otherProps, label);
12801
+ const { isPressed: isPressedFromEvents, pressProps } = (0, import_react_aria38.usePress)({ ref: labelRef, isDisabled });
12787
12802
  const { inputProps } = (0, import_react_aria38.useSwitch)(ariaProps, state, ref);
12788
- const { isFocusVisible: isKeyboardFocus, focusProps } = (0, import_react_aria38.useFocusRing)({ ...otherProps, within: true });
12789
- const { hoverProps, isHovered } = (0, import_react_aria38.useHover)({ isDisabled });
12803
+ const { isFocusVisible: isFocusVisibleFromEvents, focusProps } = (0, import_react_aria38.useFocusRing)({ ...otherProps, within: true });
12804
+ const { hoverProps, isHovered: isHoveredFromEvents } = (0, import_react_aria38.useHover)({ isDisabled });
12805
+ const isHovered = __storyState?.hovered ?? isHoveredFromEvents;
12806
+ const isPressed = __storyState?.pressed ?? isPressedFromEvents;
12807
+ const isFocusVisible = __storyState?.focusVisible ?? isFocusVisibleFromEvents;
12790
12808
  const tooltip = resolveTooltip(disabled);
12791
12809
  const labelAttrs = {
12792
12810
  ...focusProps,
@@ -12797,7 +12815,7 @@ function ToggleButton(props) {
12797
12815
  ...isHovered && toggleHoverStyles,
12798
12816
  ...isPressed && togglePressStyles,
12799
12817
  ...isSelected && !isDisabled && Css.blue700.$,
12800
- ...isKeyboardFocus && toggleFocusStyles,
12818
+ ...isFocusVisible && toggleFocusStyles,
12801
12819
  ...isDisabled && Css.gray300.cursorNotAllowed.$
12802
12820
  },
12803
12821
  ...tid
@@ -16004,17 +16022,18 @@ function FormLines(props) {
16004
16022
  {
16005
16023
  css: {
16006
16024
  // Note that we're purposefully not using display:flex so that our children's margins will collapse.
16007
- ...Css.w(sizes[width2]).$,
16008
- // Purposefully use this instead of childGap3 to put margin-bottom on the last line
16009
- "& > *": Css.mb(gap).$
16025
+ ...Css.w(sizes[width2]).$
16010
16026
  },
16011
16027
  children: import_react86.Children.map(children, (child) => {
16028
+ if (child === null || child === void 0 || typeof child === "boolean") {
16029
+ return child;
16030
+ }
16012
16031
  if (child && typeof child === "object" && "type" in child && child.type.isFormHeading) {
16013
16032
  const clone = (0, import_react86.cloneElement)(child, { isFirst: firstFormHeading });
16014
16033
  firstFormHeading = false;
16015
- return clone;
16034
+ return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { css: Css.mb(gap).$, children: clone });
16016
16035
  } else {
16017
- return child;
16036
+ return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { css: Css.mb(gap).$, children: child });
16018
16037
  }
16019
16038
  })
16020
16039
  }
@@ -16188,45 +16207,46 @@ function CompoundField({ children }) {
16188
16207
  }
16189
16208
  const commonStyles = Css.df.aic.fs1.maxwPx(550).bt.bb.bcGray300.$;
16190
16209
  const internalProps = { compound: true };
16191
- return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
16192
- "div",
16193
- {
16194
- css: {
16195
- ...Css.df.$,
16196
- "&:focus-within > div:nth-of-type(2)": Css.bgBlue700.$
16197
- // Separation line when inputs are focused
16198
- },
16199
- children: [
16200
- /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
16201
- "div",
16202
- {
16203
- css: {
16204
- ...commonStyles,
16205
- ...Css.bl.borderRadius("4px 0 0 4px").$,
16206
- "&:focus-within": Css.bcBlue700.$
16207
- },
16208
- children: (0, import_react88.cloneElement)(children[0], {
16209
- internalProps
16210
- })
16211
- }
16212
- ),
16213
- /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { css: Css.wPx(1).fn.bgGray300.$ }),
16214
- /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
16215
- "div",
16216
- {
16217
- css: {
16218
- ...commonStyles,
16219
- ...Css.fg1.br.borderRadius("0 4px 4px 0").$,
16220
- "&:focus-within": Css.bcBlue700.$
16221
- },
16222
- children: (0, import_react88.cloneElement)(children[1], {
16223
- internalProps
16224
- })
16225
- }
16226
- )
16227
- ]
16210
+ const [hasFocusWithin, setHasFocusWithin] = (0, import_react88.useState)(false);
16211
+ function onFocusCapture() {
16212
+ setHasFocusWithin(true);
16213
+ }
16214
+ function onBlurCapture(e) {
16215
+ const nextFocusedElement = e.relatedTarget;
16216
+ if (nextFocusedElement instanceof Node && e.currentTarget.contains(nextFocusedElement)) {
16217
+ return;
16228
16218
  }
16229
- );
16219
+ setHasFocusWithin(false);
16220
+ }
16221
+ return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { css: Css.df.$, onFocusCapture, onBlurCapture, children: [
16222
+ /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
16223
+ "div",
16224
+ {
16225
+ css: {
16226
+ ...commonStyles,
16227
+ ...Css.bl.borderRadius("4px 0 0 4px").$,
16228
+ "&:focus-within": Css.bcBlue700.$
16229
+ },
16230
+ children: (0, import_react88.cloneElement)(children[0], {
16231
+ internalProps
16232
+ })
16233
+ }
16234
+ ),
16235
+ /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { css: { ...Css.wPx(1).fn.bgGray300.$, ...hasFocusWithin && Css.bgBlue700.$ } }),
16236
+ /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
16237
+ "div",
16238
+ {
16239
+ css: {
16240
+ ...commonStyles,
16241
+ ...Css.fg1.br.borderRadius("0 4px 4px 0").$,
16242
+ "&:focus-within": Css.bcBlue700.$
16243
+ },
16244
+ children: (0, import_react88.cloneElement)(children[1], {
16245
+ internalProps
16246
+ })
16247
+ }
16248
+ )
16249
+ ] });
16230
16250
  }
16231
16251
 
16232
16252
  // src/forms/BoundSelectAndTextField.tsx
@@ -17974,18 +17994,42 @@ function ButtonGroup(props) {
17974
17994
  const tid = useTestIds(props, "buttonGroup");
17975
17995
  return (
17976
17996
  // Adding `line-height: 0` prevent inheriting line-heights that might throw off sizing within the button group.
17977
- /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("div", { ...tid, css: Css.df.lh(0).add({ ...sizeStyles2[size] }).$, children: buttons.map(({ disabled: buttonDisabled, ...buttonProps }, i) => /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(GroupButton, { ...buttonProps, disabled: disabled || buttonDisabled, size, ...tid }, i)) })
17997
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("div", { ...tid, css: Css.df.lh(0).add({ ...sizeStyles2[size] }).$, children: buttons.map(({ disabled: buttonDisabled, ...buttonProps }, i) => /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
17998
+ GroupButton,
17999
+ {
18000
+ ...buttonProps,
18001
+ disabled: disabled || buttonDisabled,
18002
+ size,
18003
+ isFirst: i === 0,
18004
+ isLast: i === buttons.length - 1,
18005
+ ...tid
18006
+ },
18007
+ i
18008
+ )) })
17978
18009
  );
17979
18010
  }
17980
18011
  function GroupButton(props) {
17981
- const { icon, iconInc, iconColor, text, active, onClick: onPress, disabled, size, tooltip, ...otherProps } = props;
18012
+ const {
18013
+ icon,
18014
+ iconInc,
18015
+ iconColor,
18016
+ text,
18017
+ active,
18018
+ onClick: onPress,
18019
+ disabled,
18020
+ size,
18021
+ tooltip,
18022
+ isFirst,
18023
+ isLast,
18024
+ ...otherProps
18025
+ } = props;
17982
18026
  const ariaProps = { onPress, isDisabled: !!disabled, ...otherProps };
17983
18027
  const ref = (0, import_react106.useRef)(null);
17984
18028
  const { buttonProps, isPressed } = (0, import_react_aria47.useButton)(ariaProps, ref);
17985
18029
  const { isFocusVisible, focusProps } = (0, import_react_aria47.useFocusRing)();
17986
18030
  const { hoverProps, isHovered } = (0, import_react_aria47.useHover)(ariaProps);
17987
18031
  const tid = useTestIds(props);
17988
- return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("span", { css: getButtonStyles2(), children: maybeTooltip({
18032
+ return /* @__PURE__ */ (0, import_jsx_runtime152.jsx)("span", { css: getButtonStyles2(isFirst, isLast), children: maybeTooltip({
17989
18033
  title: resolveTooltip(disabled, tooltip),
17990
18034
  placement: "top",
17991
18035
  children: /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
@@ -18016,15 +18060,15 @@ var pressedStyles = Css.bgGray200.$;
18016
18060
  var activeStyles3 = Css.bgGray300.$;
18017
18061
  var hoverStyles3 = Css.bgGray100.$;
18018
18062
  var defaultFocusRingStyles2 = Css.relative.z2.bshFocus.$;
18019
- function getButtonStyles2() {
18063
+ function getButtonStyles2(isFirst, isLast) {
18020
18064
  return {
18021
18065
  ...Css.z1.bgWhite.bcGray300.bw1.ba.gray900.br0.oh.$,
18022
- // Our first button should have a rounded left border
18023
- "&:first-of-type": Css.add("borderRadius", "4px 0 0 4px").$,
18024
- // Our last button should have a rounded right border
18025
- "&:last-of-type": Css.add("borderRadius", "0 4px 4px 0").$,
18026
- // Nudge buttons one pixel to the left so they visually share a border
18027
- "&:not(:first-of-type)": Css.mlPx(-1).$
18066
+ // Our first button should have a rounded left border.
18067
+ ...isFirst && Css.add("borderRadius", "4px 0 0 4px").$,
18068
+ // Our last button should have a rounded right border.
18069
+ ...isLast && Css.add("borderRadius", "0 4px 4px 0").$,
18070
+ // Nudge buttons one pixel to the left so they visually share a border.
18071
+ ...!isFirst && Css.mlPx(-1).$
18028
18072
  };
18029
18073
  }
18030
18074
  var sizeStyles2 = {
@@ -18154,9 +18198,9 @@ function Copy(props) {
18154
18198
  return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(
18155
18199
  "div",
18156
18200
  {
18201
+ className: "beam-copy",
18157
18202
  css: {
18158
- ...Css.sm.gray700.mt2.mb3.wPx(480).$,
18159
- "& > p": Css.my2.$
18203
+ ...Css.sm.gray700.mt2.mb3.wPx(480).$
18160
18204
  },
18161
18205
  children: props.children
18162
18206
  }
@@ -18189,6 +18233,7 @@ function DnDGrid(props) {
18189
18233
  const reorderViaKeyboard = (0, import_react110.useRef)(false);
18190
18234
  const transformFrom = (0, import_react110.useRef)({ x: 0, y: 0 });
18191
18235
  const tid = useTestIds(props, "dndGrid");
18236
+ const activeStyles4 = activeItemStyles ?? Css.bshModal.$;
18192
18237
  const getGridItems = (0, import_react110.useCallback)(() => {
18193
18238
  return gridEl.current ? Array.from(gridEl.current.querySelectorAll(`[${gridItemIdKey}]`)) : [];
18194
18239
  }, []);
@@ -18198,19 +18243,19 @@ function DnDGrid(props) {
18198
18243
  const initReorder = (0, import_react110.useCallback)(() => {
18199
18244
  if (gridEl.current && dragEl.current) {
18200
18245
  initialOrder.current = getGridItemIdOrder();
18201
- dragEl.current.classList.add(activeGridItemClass);
18246
+ setInlineStyles(dragEl.current, activeStyles4);
18202
18247
  }
18203
- }, [getGridItemIdOrder]);
18248
+ }, [getGridItemIdOrder, activeStyles4]);
18204
18249
  const commitReorder = (0, import_react110.useCallback)(() => {
18205
18250
  if (gridEl.current && dragEl.current) {
18206
18251
  const currentOrder = getGridItemIdOrder();
18207
18252
  if (!(0, import_fast_deep_equal2.default)(currentOrder, initialOrder.current)) onReorder(currentOrder);
18208
- dragEl.current.classList.remove(activeGridItemClass);
18253
+ clearInlineStyles(dragEl.current, activeStyles4);
18209
18254
  dragEl.current = void 0;
18210
18255
  reorderViaKeyboard.current = false;
18211
18256
  initialOrder.current = currentOrder;
18212
18257
  }
18213
- }, [onReorder, getGridItemIdOrder]);
18258
+ }, [onReorder, getGridItemIdOrder, activeStyles4]);
18214
18259
  const cancelReorder = (0, import_react110.useCallback)(() => {
18215
18260
  if (gridEl.current && dragEl.current && initialOrder.current) {
18216
18261
  const currentOrder = getGridItemIdOrder();
@@ -18228,11 +18273,11 @@ function DnDGrid(props) {
18228
18273
  }
18229
18274
  }
18230
18275
  }
18231
- dragEl.current.classList.remove(activeGridItemClass);
18276
+ clearInlineStyles(dragEl.current, activeStyles4);
18232
18277
  dragEl.current = void 0;
18233
18278
  reorderViaKeyboard.current = false;
18234
18279
  }
18235
- }, [getGridItemIdOrder, getGridItems]);
18280
+ }, [getGridItemIdOrder, getGridItems, activeStyles4]);
18236
18281
  const onMove = (0, import_react110.useCallback)((e) => {
18237
18282
  if (!reorderViaKeyboard.current && dragEl.current && cloneEl.current && gridEl.current) {
18238
18283
  const clientX = "clientX" in e ? e.clientX : e.touches[0].clientX;
@@ -18271,18 +18316,21 @@ function DnDGrid(props) {
18271
18316
  );
18272
18317
  cloneEl.current?.setAttribute(gridCloneKey, "true");
18273
18318
  cloneEl.current.removeAttribute("id");
18274
- cloneEl.current?.classList.remove(activeGridItemClass);
18275
18319
  gridEl.current.insertBefore(cloneEl.current, dragEl.current.nextSibling);
18276
- dragEl.current.setAttribute(
18277
- "style",
18278
- `pointer-events: none; position:fixed; z-index: 9999; top:${top}px; left:${left}px; width:${rect.width}px; height:${rect.height}px;`
18279
- );
18320
+ dragEl.current.style.pointerEvents = "none";
18321
+ dragEl.current.style.position = "fixed";
18322
+ dragEl.current.style.zIndex = "9999";
18323
+ dragEl.current.style.top = `${top}px`;
18324
+ dragEl.current.style.left = `${left}px`;
18325
+ dragEl.current.style.width = `${rect.width}px`;
18326
+ dragEl.current.style.height = `${rect.height}px`;
18327
+ setInlineStyles(dragEl.current, activeStyles4);
18280
18328
  gridEl.current.style.cursor = "grabbing";
18281
18329
  gridEl.current.addEventListener("mousemove", onMove);
18282
18330
  gridEl.current.addEventListener("touchmove", onMove);
18283
18331
  }
18284
18332
  },
18285
- [initReorder, onMove]
18333
+ [initReorder, onMove, activeStyles4]
18286
18334
  );
18287
18335
  const onDragEnd = (0, import_react110.useCallback)(
18288
18336
  (e) => {
@@ -18356,7 +18404,7 @@ function DnDGrid(props) {
18356
18404
  {
18357
18405
  ref: gridEl,
18358
18406
  css: {
18359
- ...Css.ctis.dg.addIn(`& .${activeGridItemClass}`, activeItemStyles ?? Css.bshModal.$).$,
18407
+ ...Css.ctis.dg.$,
18360
18408
  ...gridStyles
18361
18409
  },
18362
18410
  onTouchStart: onDragStart,
@@ -18370,7 +18418,6 @@ function DnDGrid(props) {
18370
18418
  }
18371
18419
  var gridItemIdKey = "dndgrid-itemid";
18372
18420
  var gridCloneKey = "dndgrid-clone";
18373
- var activeGridItemClass = "dndgrid-active";
18374
18421
 
18375
18422
  // src/components/DnDGrid/DnDGridItemHandle.tsx
18376
18423
  var import_react_aria49 = require("react-aria");