@homebound/beam 2.407.0 → 2.408.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
@@ -6676,14 +6676,10 @@ var import_react25 = require("react");
6676
6676
  var import_react_aria10 = require("react-aria");
6677
6677
  var import_react_stately2 = require("react-stately");
6678
6678
 
6679
- // src/components/Button.tsx
6679
+ // src/components/internal/OverlayTrigger.tsx
6680
6680
  var import_react24 = require("react");
6681
6681
  var import_react_aria9 = require("react-aria");
6682
6682
 
6683
- // src/components/internal/OverlayTrigger.tsx
6684
- var import_react23 = require("react");
6685
- var import_react_aria8 = require("react-aria");
6686
-
6687
6683
  // src/components/Avatar/AvatarButton.tsx
6688
6684
  var import_react21 = require("react");
6689
6685
  var import_react_aria6 = require("react-aria");
@@ -6804,10 +6800,185 @@ var pressedStyles = Css.addIn(
6804
6800
  Css.br100.bgGray900.contentEmpty.w100.h100.absolute.top0.left0.add("opacity", "0.2").$
6805
6801
  ).$;
6806
6802
 
6807
- // src/components/NavLink.tsx
6803
+ // src/components/Button.tsx
6808
6804
  var import_react22 = require("react");
6809
6805
  var import_react_aria7 = require("react-aria");
6810
6806
  var import_jsx_runtime23 = require("@emotion/react/jsx-runtime");
6807
+ function Button(props) {
6808
+ const {
6809
+ onClick: onPress,
6810
+ disabled,
6811
+ endAdornment,
6812
+ menuTriggerProps,
6813
+ tooltip,
6814
+ openInNew,
6815
+ download,
6816
+ contrast = false,
6817
+ forceFocusStyles = false,
6818
+ labelInFlight,
6819
+ ...otherProps
6820
+ } = props;
6821
+ const asLink = typeof onPress === "string";
6822
+ const showExternalLinkIcon = asLink && isAbsoluteUrl(onPress) || openInNew;
6823
+ const [asyncInProgress, setAsyncInProgress] = (0, import_react22.useState)(false);
6824
+ const isDisabled = !!disabled;
6825
+ const ariaProps = { onPress, isDisabled: isDisabled || asyncInProgress, ...otherProps, ...menuTriggerProps };
6826
+ const {
6827
+ label,
6828
+ // Default the icon based on other properties.
6829
+ icon = download ? "download" : showExternalLinkIcon ? "linkExternal" : void 0,
6830
+ variant = "primary",
6831
+ size = "sm",
6832
+ buttonRef
6833
+ } = ariaProps;
6834
+ const ref = useGetRef(buttonRef);
6835
+ const tid = useTestIds(props, labelOr(ariaProps, "button"));
6836
+ const { buttonProps, isPressed } = (0, import_react_aria7.useButton)(
6837
+ {
6838
+ ...ariaProps,
6839
+ onPress: asLink ? noop : (e) => {
6840
+ const result = onPress(e);
6841
+ if (isPromise(result)) {
6842
+ setAsyncInProgress(true);
6843
+ result.finally(() => setAsyncInProgress(false));
6844
+ }
6845
+ return result;
6846
+ },
6847
+ elementType: asLink ? "a" : "button"
6848
+ },
6849
+ ref
6850
+ );
6851
+ const { isFocusVisible, focusProps } = (0, import_react_aria7.useFocusRing)(ariaProps);
6852
+ const { hoverProps, isHovered } = (0, import_react_aria7.useHover)(ariaProps);
6853
+ const { baseStyles: baseStyles5, hoverStyles: hoverStyles4, disabledStyles: disabledStyles4, pressedStyles: pressedStyles3, focusStyles: focusStyles2 } = (0, import_react22.useMemo)(
6854
+ () => getButtonStyles(variant, size, contrast),
6855
+ [variant, size, contrast]
6856
+ );
6857
+ const buttonContent = /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
6858
+ icon && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Icon, { xss: iconStyles[size], icon }),
6859
+ labelInFlight && asyncInProgress ? labelInFlight : label,
6860
+ (endAdornment || asyncInProgress) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { css: Css.ml1.$, children: asyncInProgress ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader, { size: "xs", contrast }) : endAdornment })
6861
+ ] });
6862
+ const buttonAttrs = {
6863
+ ref,
6864
+ ...buttonProps,
6865
+ ...focusProps,
6866
+ ...hoverProps,
6867
+ className: asLink ? navLink : void 0,
6868
+ css: {
6869
+ ...Css.buttonBase.tt("inherit").$,
6870
+ ...baseStyles5,
6871
+ ...isHovered && !isPressed ? hoverStyles4 : {},
6872
+ ...isPressed ? pressedStyles3 : {},
6873
+ ...isDisabled || asyncInProgress ? { ...disabledStyles4, ...Css.cursorNotAllowed.$ } : {},
6874
+ ...isFocusVisible || forceFocusStyles ? focusStyles2 : {}
6875
+ },
6876
+ ...tid
6877
+ };
6878
+ return maybeTooltip({
6879
+ title: resolveTooltip(disabled, tooltip),
6880
+ placement: "top",
6881
+ children: getButtonOrLink(buttonContent, onPress, buttonAttrs, openInNew, download)
6882
+ });
6883
+ }
6884
+ function getButtonStyles(variant, size, contrast) {
6885
+ const styles = variantStyles(contrast)[variant];
6886
+ if (variant === "text") {
6887
+ return styles;
6888
+ }
6889
+ return {
6890
+ ...styles,
6891
+ baseStyles: { ...styles.baseStyles, ...sizeStyles[size] }
6892
+ };
6893
+ }
6894
+ var variantStyles = (contrast) => ({
6895
+ primary: {
6896
+ baseStyles: Css.bgBlue600.white.$,
6897
+ hoverStyles: Css.bgBlue700.$,
6898
+ pressedStyles: Css.bgBlue800.$,
6899
+ disabledStyles: Css.bgBlue200.if(contrast).gray600.bgBlue900.$,
6900
+ focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
6901
+ },
6902
+ secondary: {
6903
+ baseStyles: Css.bgWhite.bcGray300.bw1.ba.blue600.$,
6904
+ hoverStyles: Css.bgGray100.if(contrast).bgGray300.$,
6905
+ pressedStyles: Css.bgGray200.if(contrast).bgGray100.$,
6906
+ disabledStyles: Css.bgWhite.blue300.$,
6907
+ focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
6908
+ },
6909
+ secondaryBlack: {
6910
+ baseStyles: Css.bgWhite.bcGray300.bw1.ba.gray900.$,
6911
+ hoverStyles: Css.bgGray100.if(contrast).bgGray700.white.$,
6912
+ pressedStyles: Css.gray900.if(contrast).bgWhite.gray900.$,
6913
+ disabledStyles: Css.gray400.if(contrast).gray700.$,
6914
+ focusStyles: Css.boxShadow(`0px 0px 0px 2px ${"rgba(255,255,255,1)" /* White */}, 0px 0px 0px 4px ${"rgba(36, 36, 36, 1)" /* Gray900 */}`).if(contrast).boxShadow(`0px 0px 0px 2px ${"rgba(175, 175, 175, 1)" /* Gray500 */}`).$
6915
+ },
6916
+ tertiary: {
6917
+ baseStyles: Css.bgTransparent.blue600.if(contrast).white.$,
6918
+ hoverStyles: Css.bgGray100.if(contrast).bgGray700.white.$,
6919
+ pressedStyles: Css.blue800.if(contrast).bgWhite.gray900.$,
6920
+ disabledStyles: Css.gray400.if(contrast).gray700.$,
6921
+ focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(96, 165, 250, 1)" /* Blue400 */}`).bgGray700.white.$
6922
+ },
6923
+ tertiaryDanger: {
6924
+ baseStyles: Css.bgTransparent.red600.if(contrast).red400.$,
6925
+ hoverStyles: Css.bgGray100.if(contrast).bgGray700.white.$,
6926
+ pressedStyles: Css.red800.if(contrast).bgWhite.gray900.$,
6927
+ disabledStyles: Css.gray400.if(contrast).gray700.$,
6928
+ focusStyles: Css.boxShadow(`0px 0px 0px 2px ${"rgba(255,255,255,1)" /* White */}, 0px 0px 0px 4px ${"rgba(239, 68, 68, 1)" /* Red500 */}`).if(contrast).boxShadow(`0px 0px 0px 2px ${"rgba(239, 68, 68, 1)" /* Red500 */}`).$
6929
+ },
6930
+ danger: {
6931
+ baseStyles: Css.bgRed600.white.$,
6932
+ hoverStyles: Css.bgRed700.$,
6933
+ pressedStyles: Css.bgRed800.$,
6934
+ disabledStyles: Css.bgRed200.if(contrast).bgRed900.gray600.$,
6935
+ focusStyles: Css.bshDanger.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
6936
+ },
6937
+ quaternary: {
6938
+ baseStyles: Css.bgTransparent.gray900.if(contrast).gray400.$,
6939
+ hoverStyles: Css.bgGray100.if(contrast).bgGray700.white.$,
6940
+ pressedStyles: Css.gray900.if(contrast).bgWhite.gray900.$,
6941
+ disabledStyles: Css.gray400.if(contrast).gray700.$,
6942
+ focusStyles: Css.boxShadow(`0px 0px 0px 2px ${"rgba(255,255,255,1)" /* White */}, 0px 0px 0px 4px ${"rgba(36, 36, 36, 1)" /* Gray900 */}`).if(contrast).boxShadow(`0px 0px 0px 2px ${"rgba(175, 175, 175, 1)" /* Gray500 */}`).$
6943
+ },
6944
+ caution: {
6945
+ baseStyles: Css.bgYellow200.gray900.$,
6946
+ hoverStyles: Css.bgYellow300.$,
6947
+ pressedStyles: Css.bgYellow400.$,
6948
+ disabledStyles: Css.bgYellow200.if(contrast).bgYellow900.white.$,
6949
+ focusStyles: Css.bshDanger.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
6950
+ },
6951
+ text: {
6952
+ baseStyles: Css.blue700.add("fontSize", "inherit").if(contrast).blue400.$,
6953
+ hoverStyles: Css.blue600.if(contrast).blue300.$,
6954
+ pressedStyles: Css.blue700.if(contrast).blue200.$,
6955
+ disabledStyles: Css.blue300.if(contrast).blue700.$,
6956
+ focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
6957
+ },
6958
+ // Todo: handle contrast variant
6959
+ textSecondary: {
6960
+ baseStyles: Css.blue600.add("fontSize", "inherit").$,
6961
+ hoverStyles: Css.bgGray100.$,
6962
+ pressedStyles: Css.blue600.$,
6963
+ disabledStyles: Css.bgWhite.blue300.$,
6964
+ focusStyles: Css.blue600.$
6965
+ }
6966
+ });
6967
+ var sizeStyles = {
6968
+ sm: Css.hPx(32).pxPx(12).$,
6969
+ md: Css.hPx(40).px2.$,
6970
+ lg: Css.hPx(48).px3.$
6971
+ };
6972
+ var iconStyles = {
6973
+ sm: Css.mrPx(4).$,
6974
+ md: Css.mr1.$,
6975
+ lg: Css.mrPx(10).$
6976
+ };
6977
+
6978
+ // src/components/NavLink.tsx
6979
+ var import_react23 = require("react");
6980
+ var import_react_aria8 = require("react-aria");
6981
+ var import_jsx_runtime24 = require("@emotion/react/jsx-runtime");
6811
6982
  function NavLink(props) {
6812
6983
  const {
6813
6984
  disabled: isDisabled,
@@ -6821,10 +6992,10 @@ function NavLink(props) {
6821
6992
  const ariaProps = { children: label, isDisabled, ...menuTriggerProps, ...otherProps };
6822
6993
  const { href, active = false, icon = false, variant } = ariaProps;
6823
6994
  const ref = useGetRef(buttonRef);
6824
- const { buttonProps, isPressed } = (0, import_react_aria7.useButton)({ ...ariaProps, elementType: href ? "a" : "button" }, ref);
6825
- const { hoverProps, isHovered } = (0, import_react_aria7.useHover)({ isDisabled });
6826
- const { isFocusVisible, focusProps } = (0, import_react_aria7.useFocusRing)(ariaProps);
6827
- const { baseStyles: baseStyles5, activeStyles: activeStyles4, focusRingStyles: focusRingStyles2, hoverStyles: hoverStyles4, disabledStyles: disabledStyles4, pressedStyles: pressedStyles3 } = (0, import_react22.useMemo)(
6995
+ const { buttonProps, isPressed } = (0, import_react_aria8.useButton)({ ...ariaProps, elementType: href ? "a" : "button" }, ref);
6996
+ const { hoverProps, isHovered } = (0, import_react_aria8.useHover)({ isDisabled });
6997
+ const { isFocusVisible, focusProps } = (0, import_react_aria8.useFocusRing)(ariaProps);
6998
+ const { baseStyles: baseStyles5, activeStyles: activeStyles4, focusRingStyles: focusRingStyles2, hoverStyles: hoverStyles4, disabledStyles: disabledStyles4, pressedStyles: pressedStyles3 } = (0, import_react23.useMemo)(
6828
6999
  () => getNavLinkStyles(variant, contrast),
6829
7000
  [variant, contrast]
6830
7001
  );
@@ -6844,11 +7015,11 @@ function NavLink(props) {
6844
7015
  ...isPressed && pressedStyles3
6845
7016
  }
6846
7017
  };
6847
- const linkContent = /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
7018
+ const linkContent = /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
6848
7019
  label,
6849
- icon && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { css: Css.ml1.$, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Icon, { icon }) })
7020
+ icon && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { css: Css.ml1.$, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Icon, { icon }) })
6850
7021
  ] });
6851
- return getButtonOrLink(linkContent, href, { ...(0, import_react_aria7.mergeProps)(buttonProps, focusProps, hoverProps), ...linkAttributes });
7022
+ return getButtonOrLink(linkContent, href, { ...(0, import_react_aria8.mergeProps)(buttonProps, focusProps, hoverProps), ...linkAttributes });
6852
7023
  }
6853
7024
  function getNavLinkStyles(variant, contrast) {
6854
7025
  return navLinkVariantStyles(contrast)[variant];
@@ -6877,7 +7048,7 @@ var navLinkVariantStyles = (contrast) => ({
6877
7048
  });
6878
7049
 
6879
7050
  // src/components/internal/OverlayTrigger.tsx
6880
- var import_jsx_runtime24 = (
7051
+ var import_jsx_runtime25 = (
6881
7052
  // Add `line-height: 0` to prevent the Icon button and Avatar buttons from inheriting the line-height, causing them to be taller than they should.
6882
7053
  require("@emotion/react/jsx-runtime")
6883
7054
  );
@@ -6896,8 +7067,8 @@ function OverlayTrigger(props) {
6896
7067
  showActiveBorder = false,
6897
7068
  contrast = false
6898
7069
  } = props;
6899
- const popoverRef = (0, import_react23.useRef)(null);
6900
- const { overlayProps: positionProps } = (0, import_react_aria8.useOverlayPosition)({
7070
+ const popoverRef = (0, import_react24.useRef)(null);
7071
+ const { overlayProps: positionProps } = (0, import_react_aria9.useOverlayPosition)({
6901
7072
  targetRef: buttonRef,
6902
7073
  overlayRef: popoverRef,
6903
7074
  shouldFlip: true,
@@ -6910,8 +7081,8 @@ function OverlayTrigger(props) {
6910
7081
  props,
6911
7082
  isTextButton(trigger) ? defaultTestId(labelOr(trigger, "overlayTrigger")) : isNavLinkButton(trigger) ? defaultTestId(trigger.navLabel) : isIconButton(trigger) ? trigger.icon : trigger.name
6912
7083
  );
6913
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { css: Css.dib.add("lineHeight", 0).$, children: [
6914
- isTextButton(trigger) ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7084
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { css: Css.dib.add("lineHeight", 0).$, children: [
7085
+ isTextButton(trigger) ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6915
7086
  Button,
6916
7087
  {
6917
7088
  variant: variant ? variant : "secondary",
@@ -6919,14 +7090,14 @@ function OverlayTrigger(props) {
6919
7090
  ...trigger,
6920
7091
  menuTriggerProps,
6921
7092
  buttonRef,
6922
- endAdornment: !hideEndAdornment ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Icon, { icon: state.isOpen ? "chevronUp" : "chevronDown" }) : null,
7093
+ endAdornment: !hideEndAdornment ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Icon, { icon: state.isOpen ? "chevronUp" : "chevronDown" }) : null,
6923
7094
  disabled,
6924
7095
  tooltip,
6925
7096
  onClick: menuTriggerProps.onPress ?? noop,
6926
7097
  forceFocusStyles: showActiveBorder && state.isOpen,
6927
7098
  ...tid
6928
7099
  }
6929
- ) : isNavLinkButton(trigger) ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7100
+ ) : isNavLinkButton(trigger) ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6930
7101
  NavLink,
6931
7102
  {
6932
7103
  ...trigger,
@@ -6937,7 +7108,7 @@ function OverlayTrigger(props) {
6937
7108
  buttonRef,
6938
7109
  ...tid
6939
7110
  }
6940
- ) : isIconButton(trigger) ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7111
+ ) : isIconButton(trigger) ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6941
7112
  IconButton,
6942
7113
  {
6943
7114
  ...trigger,
@@ -6949,7 +7120,7 @@ function OverlayTrigger(props) {
6949
7120
  onClick: menuTriggerProps.onPress ?? noop,
6950
7121
  forceFocusStyles: showActiveBorder && state.isOpen
6951
7122
  }
6952
- ) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7123
+ ) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6953
7124
  AvatarButton,
6954
7125
  {
6955
7126
  ...trigger,
@@ -6962,7 +7133,7 @@ function OverlayTrigger(props) {
6962
7133
  forceFocusStyles: showActiveBorder && state.isOpen
6963
7134
  }
6964
7135
  ),
6965
- state.isOpen && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
7136
+ state.isOpen && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6966
7137
  Popover,
6967
7138
  {
6968
7139
  triggerRef: buttonRef,
@@ -6988,176 +7159,10 @@ function labelOr(trigger, fallback) {
6988
7159
  return typeof trigger.label === "string" ? trigger.label : fallback;
6989
7160
  }
6990
7161
 
6991
- // src/components/Button.tsx
6992
- var import_jsx_runtime25 = require("@emotion/react/jsx-runtime");
6993
- function Button(props) {
6994
- const {
6995
- onClick: onPress,
6996
- disabled,
6997
- endAdornment,
6998
- menuTriggerProps,
6999
- tooltip,
7000
- openInNew,
7001
- download,
7002
- contrast = false,
7003
- forceFocusStyles = false,
7004
- labelInFlight,
7005
- ...otherProps
7006
- } = props;
7007
- const asLink = typeof onPress === "string";
7008
- const showExternalLinkIcon = asLink && isAbsoluteUrl(onPress) || openInNew;
7009
- const [asyncInProgress, setAsyncInProgress] = (0, import_react24.useState)(false);
7010
- const isDisabled = !!disabled;
7011
- const ariaProps = { onPress, isDisabled: isDisabled || asyncInProgress, ...otherProps, ...menuTriggerProps };
7012
- const {
7013
- label,
7014
- // Default the icon based on other properties.
7015
- icon = download ? "download" : showExternalLinkIcon ? "linkExternal" : void 0,
7016
- variant = "primary",
7017
- size = "sm",
7018
- buttonRef
7019
- } = ariaProps;
7020
- const ref = useGetRef(buttonRef);
7021
- const tid = useTestIds(props, labelOr(ariaProps, "button"));
7022
- const { buttonProps, isPressed } = (0, import_react_aria9.useButton)(
7023
- {
7024
- ...ariaProps,
7025
- onPress: asLink ? noop : (e) => {
7026
- const result = onPress(e);
7027
- if (isPromise(result)) {
7028
- setAsyncInProgress(true);
7029
- result.finally(() => setAsyncInProgress(false));
7030
- }
7031
- return result;
7032
- },
7033
- elementType: asLink ? "a" : "button"
7034
- },
7035
- ref
7036
- );
7037
- const { isFocusVisible, focusProps } = (0, import_react_aria9.useFocusRing)(ariaProps);
7038
- const { hoverProps, isHovered } = (0, import_react_aria9.useHover)(ariaProps);
7039
- const { baseStyles: baseStyles5, hoverStyles: hoverStyles4, disabledStyles: disabledStyles4, pressedStyles: pressedStyles3, focusStyles: focusStyles2 } = (0, import_react24.useMemo)(
7040
- () => getButtonStyles(variant, size, contrast),
7041
- [variant, size, contrast]
7042
- );
7043
- const buttonContent = /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
7044
- icon && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Icon, { xss: iconStyles[size], icon }),
7045
- labelInFlight && asyncInProgress ? labelInFlight : label,
7046
- (endAdornment || asyncInProgress) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { css: Css.ml1.$, children: asyncInProgress ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Loader, { size: "xs", contrast }) : endAdornment })
7047
- ] });
7048
- const buttonAttrs = {
7049
- ref,
7050
- ...buttonProps,
7051
- ...focusProps,
7052
- ...hoverProps,
7053
- className: asLink ? navLink : void 0,
7054
- css: {
7055
- ...Css.buttonBase.tt("inherit").$,
7056
- ...baseStyles5,
7057
- ...isHovered && !isPressed ? hoverStyles4 : {},
7058
- ...isPressed ? pressedStyles3 : {},
7059
- ...isDisabled || asyncInProgress ? { ...disabledStyles4, ...Css.cursorNotAllowed.$ } : {},
7060
- ...isFocusVisible || forceFocusStyles ? focusStyles2 : {}
7061
- },
7062
- ...tid
7063
- };
7064
- return maybeTooltip({
7065
- title: resolveTooltip(disabled, tooltip),
7066
- placement: "top",
7067
- children: getButtonOrLink(buttonContent, onPress, buttonAttrs, openInNew, download)
7068
- });
7069
- }
7070
- function getButtonStyles(variant, size, contrast) {
7071
- const styles = variantStyles(contrast)[variant];
7072
- if (variant === "text") {
7073
- return styles;
7074
- }
7075
- return {
7076
- ...styles,
7077
- baseStyles: { ...styles.baseStyles, ...sizeStyles[size] }
7078
- };
7079
- }
7080
- var variantStyles = (contrast) => ({
7081
- primary: {
7082
- baseStyles: Css.bgBlue600.white.$,
7083
- hoverStyles: Css.bgBlue700.$,
7084
- pressedStyles: Css.bgBlue800.$,
7085
- disabledStyles: Css.bgBlue200.if(contrast).gray600.bgBlue900.$,
7086
- focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
7087
- },
7088
- secondary: {
7089
- baseStyles: Css.bgWhite.bcGray300.bw1.ba.blue600.$,
7090
- hoverStyles: Css.bgGray100.if(contrast).bgGray300.$,
7091
- pressedStyles: Css.bgGray200.if(contrast).bgGray100.$,
7092
- disabledStyles: Css.bgWhite.blue300.$,
7093
- focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
7094
- },
7095
- tertiary: {
7096
- baseStyles: Css.bgTransparent.blue600.if(contrast).white.$,
7097
- hoverStyles: Css.bgGray100.if(contrast).bgGray700.white.$,
7098
- pressedStyles: Css.blue800.if(contrast).bgWhite.gray900.$,
7099
- disabledStyles: Css.gray400.if(contrast).gray700.$,
7100
- focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(96, 165, 250, 1)" /* Blue400 */}`).bgGray700.white.$
7101
- },
7102
- tertiaryDanger: {
7103
- baseStyles: Css.bgTransparent.red600.if(contrast).red400.$,
7104
- hoverStyles: Css.bgGray100.if(contrast).bgGray700.white.$,
7105
- pressedStyles: Css.red800.if(contrast).bgWhite.gray900.$,
7106
- disabledStyles: Css.gray400.if(contrast).gray700.$,
7107
- focusStyles: Css.boxShadow(`0px 0px 0px 2px ${"rgba(255,255,255,1)" /* White */}, 0px 0px 0px 4px ${"rgba(239, 68, 68, 1)" /* Red500 */}`).if(contrast).boxShadow(`0px 0px 0px 2px ${"rgba(239, 68, 68, 1)" /* Red500 */}`).$
7108
- },
7109
- danger: {
7110
- baseStyles: Css.bgRed600.white.$,
7111
- hoverStyles: Css.bgRed700.$,
7112
- pressedStyles: Css.bgRed800.$,
7113
- disabledStyles: Css.bgRed200.if(contrast).bgRed900.gray600.$,
7114
- focusStyles: Css.bshDanger.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
7115
- },
7116
- quaternary: {
7117
- baseStyles: Css.bgTransparent.gray900.if(contrast).gray400.$,
7118
- hoverStyles: Css.bgGray100.if(contrast).bgGray700.white.$,
7119
- pressedStyles: Css.gray900.if(contrast).bgWhite.gray900.$,
7120
- disabledStyles: Css.gray400.if(contrast).gray700.$,
7121
- focusStyles: Css.boxShadow(`0px 0px 0px 2px ${"rgba(255,255,255,1)" /* White */}, 0px 0px 0px 4px ${"rgba(36, 36, 36, 1)" /* Gray900 */}`).if(contrast).boxShadow(`0px 0px 0px 2px ${"rgba(175, 175, 175, 1)" /* Gray500 */}`).$
7122
- },
7123
- caution: {
7124
- baseStyles: Css.bgYellow200.gray900.$,
7125
- hoverStyles: Css.bgYellow300.$,
7126
- pressedStyles: Css.bgYellow400.$,
7127
- disabledStyles: Css.bgYellow200.if(contrast).bgYellow900.white.$,
7128
- focusStyles: Css.bshDanger.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
7129
- },
7130
- text: {
7131
- baseStyles: Css.blue700.add("fontSize", "inherit").if(contrast).blue400.$,
7132
- hoverStyles: Css.blue600.if(contrast).blue300.$,
7133
- pressedStyles: Css.blue700.if(contrast).blue200.$,
7134
- disabledStyles: Css.blue300.if(contrast).blue700.$,
7135
- focusStyles: Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${"rgba(255,255,255,1)" /* White */}`).$
7136
- },
7137
- // Todo: handle contrast variant
7138
- textSecondary: {
7139
- baseStyles: Css.blue600.add("fontSize", "inherit").$,
7140
- hoverStyles: Css.bgGray100.$,
7141
- pressedStyles: Css.blue600.$,
7142
- disabledStyles: Css.bgWhite.blue300.$,
7143
- focusStyles: Css.blue600.$
7144
- }
7145
- });
7146
- var sizeStyles = {
7147
- sm: Css.hPx(32).pxPx(12).$,
7148
- md: Css.hPx(40).px2.$,
7149
- lg: Css.hPx(48).px3.$
7150
- };
7151
- var iconStyles = {
7152
- sm: Css.mrPx(4).$,
7153
- md: Css.mr1.$,
7154
- lg: Css.mrPx(10).$
7155
- };
7156
-
7157
7162
  // src/components/Table/components/EditColumnsButton.tsx
7158
7163
  var import_jsx_runtime26 = require("@emotion/react/jsx-runtime");
7159
7164
  function EditColumnsButton(props) {
7160
- const { defaultOpen, disabled, columns, trigger, title, api } = props;
7165
+ const { defaultOpen, disabled, columns, trigger, api } = props;
7161
7166
  const state = (0, import_react_stately2.useMenuTriggerState)({ isOpen: defaultOpen });
7162
7167
  const buttonRef = (0, import_react25.useRef)(null);
7163
7168
  const { menuTriggerProps } = (0, import_react_aria10.useMenuTrigger)({ isDisabled: !!disabled }, state, buttonRef);
@@ -7184,28 +7189,29 @@ function EditColumnsButton(props) {
7184
7189
  },
7185
7190
  [columns, api]
7186
7191
  );
7187
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(OverlayTrigger, { ...props, menuTriggerProps, state, buttonRef, ...tid, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
7192
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(OverlayTrigger, { ...props, menuTriggerProps, state, buttonRef, ...tid, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
7188
7193
  "div",
7189
7194
  {
7190
7195
  css: {
7191
- ...Css.bgWhite.py5.px3.maxwPx(380).bshBasic.$,
7196
+ ...Css.dg.gtc("1fr auto").gap2.bgWhite.p2.maxwPx(326).$,
7192
7197
  "&:hover": Css.bshHover.$
7193
7198
  },
7194
- children: [
7195
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { css: Css.gray500.xsSb.mb1.ttu.$, children: title || "Select columns to show" }),
7199
+ children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_react25.Fragment, { children: [
7200
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { css: Css.sm.truncate.pr1.$, children: option.label }),
7196
7201
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
7197
- CheckboxGroup,
7202
+ Switch,
7198
7203
  {
7199
- label: title || "Select columns to show",
7200
- onChange: (values) => setSelectedValues(values),
7201
- values: selectedValues,
7202
- options,
7203
- columns: 2,
7204
- labelStyle: "hidden"
7204
+ compact: true,
7205
+ selected: selectedValues.includes(option.value),
7206
+ onChange: (value) => setSelectedValues(
7207
+ value ? [...selectedValues, option.value] : selectedValues.filter((v) => v !== option.value)
7208
+ ),
7209
+ labelStyle: "hidden",
7210
+ label: option.label,
7211
+ ...tid[`option${option.value}`]
7205
7212
  }
7206
- ),
7207
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { css: Css.mt1.$, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button, { variant: "tertiary", label: "Clear selections", onClick: () => setSelectedValues([]) }) })
7208
- ]
7213
+ )
7214
+ ] }, option.value))
7209
7215
  }
7210
7216
  ) });
7211
7217
  }
@@ -12475,13 +12481,13 @@ function SelectToggle({ id, disabled }) {
12475
12481
  // src/components/Table/utils/columns.tsx
12476
12482
  var import_jsx_runtime78 = require("@emotion/react/jsx-runtime");
12477
12483
  function column(columnDef) {
12478
- return { ...columnDef };
12484
+ return { canHide: true, initVisible: true, ...columnDef };
12479
12485
  }
12480
12486
  function dateColumn(columnDef) {
12481
- return { ...columnDef, align: "left" };
12487
+ return { canHide: true, initVisible: true, ...columnDef, align: "left" };
12482
12488
  }
12483
12489
  function numericColumn(columnDef) {
12484
- return { ...columnDef, align: "right" };
12490
+ return { canHide: true, initVisible: true, ...columnDef, align: "right" };
12485
12491
  }
12486
12492
  function actionColumn(columnDef) {
12487
12493
  return { clientSideSort: false, ...columnDef, align: "center", isAction: true, wrapAction: false };
@@ -16649,11 +16655,38 @@ function isGridTableProps(props) {
16649
16655
  return "rows" in props;
16650
16656
  }
16651
16657
  function GridTableLayoutComponent(props) {
16652
- const { pageTitle, breadcrumb, tableProps, layoutState, primaryAction, secondaryAction, tertiaryAction } = props;
16658
+ const {
16659
+ pageTitle,
16660
+ breadcrumb,
16661
+ tableProps,
16662
+ layoutState,
16663
+ primaryAction,
16664
+ secondaryAction,
16665
+ tertiaryAction,
16666
+ hideEditColumns = false
16667
+ } = props;
16668
+ const tid = useTestIds(props);
16669
+ const columns = tableProps.columns;
16670
+ const hasHideableColumns = (0, import_react95.useMemo)(() => {
16671
+ if (hideEditColumns) return false;
16672
+ validateColumns(columns);
16673
+ return columns.some((c) => c.canHide);
16674
+ }, [columns, hideEditColumns]);
16675
+ const api = (0, import_react95.useMemo)(
16676
+ () => tableProps.api ?? new GridTableApiImpl(),
16677
+ [tableProps.api]
16678
+ );
16653
16679
  const clientSearch = layoutState?.search === "client" ? layoutState.searchString : void 0;
16654
- const showTableActions = layoutState?.filterDefs || layoutState?.search;
16680
+ const showTableActions = layoutState?.filterDefs || layoutState?.search || hasHideableColumns;
16655
16681
  const isVirtualized = tableProps.as === "virtual";
16656
16682
  const breakpoints = useBreakpoint();
16683
+ const visibleColumnIds = useComputed(() => api.getVisibleColumnIds(), [api]);
16684
+ (0, import_react95.useEffect)(() => {
16685
+ if (layoutState?.setVisibleColumnIds) {
16686
+ layoutState.setVisibleColumnIds(visibleColumnIds);
16687
+ }
16688
+ }, [visibleColumnIds, layoutState]);
16689
+ const visibleColumnsStorageKey = layoutState?.persistedColumnsStorageKey;
16657
16690
  return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_jsx_runtime142.Fragment, { children: [
16658
16691
  /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
16659
16692
  Header2,
@@ -16665,33 +16698,65 @@ function GridTableLayoutComponent(props) {
16665
16698
  tertiaryAction
16666
16699
  }
16667
16700
  ),
16668
- showTableActions && /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(TableActions, { onlyRight: !layoutState?.search, children: [
16669
- layoutState?.search && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(SearchBox, { onSearch: layoutState.setSearchString }),
16670
- layoutState?.filterDefs && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
16671
- _Filters,
16701
+ showTableActions && /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(TableActions, { onlyRight: !layoutState?.search && hasHideableColumns, children: [
16702
+ /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)("div", { css: Css.df.gap1.$, children: [
16703
+ layoutState?.search && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(SearchBox, { onSearch: layoutState.setSearchString }),
16704
+ layoutState?.filterDefs && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
16705
+ _Filters,
16706
+ {
16707
+ filterDefs: layoutState.filterDefs,
16708
+ filter: layoutState.filter,
16709
+ onChange: layoutState.setFilter,
16710
+ groupBy: layoutState.groupBy,
16711
+ numberOfInlineFilters: breakpoints.mdAndDown ? 2 : void 0
16712
+ }
16713
+ )
16714
+ ] }),
16715
+ hasHideableColumns && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
16716
+ EditColumnsButton,
16672
16717
  {
16673
- filterDefs: layoutState.filterDefs,
16674
- filter: layoutState.filter,
16675
- onChange: layoutState.setFilter,
16676
- groupBy: layoutState.groupBy,
16677
- numberOfInlineFilters: breakpoints.mdAndDown ? 2 : void 0
16718
+ columns,
16719
+ api,
16720
+ tooltip: "Display columns",
16721
+ trigger: { icon: "kanban", label: "", variant: "secondaryBlack" },
16722
+ ...tid.editColumnsButton
16678
16723
  }
16679
16724
  )
16680
16725
  ] }),
16681
- /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(ScrollableContent, { virtualized: isVirtualized, children: isGridTableProps(tableProps) ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(GridTable, { ...tableProps, filter: clientSearch, style: { allWhite: true }, stickyHeader: true }) : /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
16726
+ /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(ScrollableContent, { virtualized: isVirtualized, children: isGridTableProps(tableProps) ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
16727
+ GridTable,
16728
+ {
16729
+ ...tableProps,
16730
+ api,
16731
+ filter: clientSearch,
16732
+ style: { allWhite: true },
16733
+ stickyHeader: true,
16734
+ visibleColumnsStorageKey
16735
+ }
16736
+ ) : /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(
16682
16737
  QueryTable,
16683
16738
  {
16684
16739
  ...tableProps,
16740
+ api,
16685
16741
  filter: clientSearch,
16686
16742
  style: { allWhite: true },
16687
- stickyHeader: true
16743
+ stickyHeader: true,
16744
+ visibleColumnsStorageKey
16688
16745
  }
16689
16746
  ) })
16690
16747
  ] });
16691
16748
  }
16692
16749
  var GridTableLayout = import_react95.default.memo(GridTableLayoutComponent);
16750
+ function validateColumns(columns) {
16751
+ for (const col of columns) {
16752
+ if (!col.id || !col.name) {
16753
+ throw new Error("Columns must have id and name properties when EditColumnsButtons is enabled");
16754
+ }
16755
+ }
16756
+ }
16693
16757
  function useGridTableLayoutState({
16694
16758
  persistedFilter,
16759
+ persistedColumns,
16695
16760
  search,
16696
16761
  groupBy: maybeGroupBy
16697
16762
  }) {
@@ -16699,6 +16764,11 @@ function useGridTableLayoutState({
16699
16764
  const { filter, setFilter } = usePersistedFilter(persistedFilter ?? filterFallback);
16700
16765
  const groupBy = useGroupBy(maybeGroupBy ?? { none: "none" });
16701
16766
  const [searchString, setSearchString] = (0, import_react95.useState)("");
16767
+ const columnsFallback = "unset-columns";
16768
+ const [visibleColumnIds, setVisibleColumnIds] = useSessionStorage(
16769
+ persistedColumns?.storageKey ?? columnsFallback,
16770
+ void 0
16771
+ );
16702
16772
  return {
16703
16773
  filter,
16704
16774
  setFilter,
@@ -16706,7 +16776,10 @@ function useGridTableLayoutState({
16706
16776
  searchString,
16707
16777
  setSearchString,
16708
16778
  search,
16709
- groupBy: maybeGroupBy ? groupBy : void 0
16779
+ groupBy: maybeGroupBy ? groupBy : void 0,
16780
+ visibleColumnIds: persistedColumns ? visibleColumnIds : void 0,
16781
+ setVisibleColumnIds: persistedColumns ? setVisibleColumnIds : void 0,
16782
+ persistedColumnsStorageKey: persistedColumns?.storageKey
16710
16783
  };
16711
16784
  }
16712
16785
  function Header2(props) {