@xylabs/react-button 4.2.12 → 5.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonExBase.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExBase.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,QAAA,MAAM,YAAY,yFA0DhB,CAAA;AAIF,OAAO,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"ButtonExBase.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExBase.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,QAAA,MAAM,YAAY,yFAsDhB,CAAA;AAIF,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -2,10 +2,9 @@ import type { ButtonProps } from '@mui/material';
2
2
  import type { BoxlikeComponentProps, BusyProps } from '@xylabs/react-shared';
3
3
  import type { NavigateOptions, To } from 'react-router-dom';
4
4
  interface ButtonExProps extends Omit<ButtonProps, 'ref'>, BoxlikeComponentProps, BusyProps {
5
- disableMixpanel?: boolean;
6
5
  disableUserEvents?: boolean;
7
- eventName?: string;
8
6
  funnel?: string;
7
+ intent?: string;
9
8
  placement?: string;
10
9
  target?: string;
11
10
  to?: To;
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonExProps.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAE3D,UAAU,aAAc,SAAQ,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,qBAAqB,EAAE,SAAS;IACxF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,YAAY,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"ButtonExProps.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAE3D,UAAU,aAAc,SAAQ,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,qBAAqB,EAAE,SAAS;IACxF,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,YAAY,EAAE,aAAa,EAAE,CAAA"}
@@ -6,19 +6,18 @@ import React3, { forwardRef as forwardRef3 } from "react";
6
6
 
7
7
  // src/components/ButtonExBase.tsx
8
8
  import { Button, useTheme } from "@mui/material";
9
- import { useMixpanel } from "@xylabs/react-mixpanel";
10
9
  import { useUserEvents } from "@xylabs/react-pixel";
11
10
  import { BusyCircularProgress, BusyLinearProgress, mergeBoxlikeStyles } from "@xylabs/react-shared";
12
11
  import React, { forwardRef } from "react";
13
- var ButtonExBase = /* @__PURE__ */ forwardRef(({ eventName = "Button Click", funnel, target, placement, disableUserEvents, href, disableMixpanel, ...props }, ref) => {
12
+ var ButtonExBase = /* @__PURE__ */ forwardRef(({ funnel, intent, target, placement, disableUserEvents, href, ...props }, ref) => {
14
13
  const theme = useTheme();
15
14
  const userEvents = useUserEvents();
16
- const mixpanel = useMixpanel(false);
17
15
  const { busy, busyVariant = "linear", busyOpacity, onClick, children, ...rootProps } = mergeBoxlikeStyles(theme, props);
18
16
  const localOnClick = /* @__PURE__ */ __name((event) => {
19
17
  if (busy) {
20
18
  event.preventDefault();
21
19
  } else {
20
+ const elementName = props["aria-label"] ?? event.currentTarget.textContent;
22
21
  const windowToNavigate = /* @__PURE__ */ __name(() => target && href ? window.open("", target) ?? window : window, "windowToNavigate");
23
22
  const callOnClickAndFollowHref = /* @__PURE__ */ __name((windowToNav = windowToNavigate()) => {
24
23
  onClick?.(event);
@@ -26,23 +25,19 @@ var ButtonExBase = /* @__PURE__ */ forwardRef(({ eventName = "Button Click", fun
26
25
  windowToNav.location.href = href;
27
26
  }
28
27
  }, "callOnClickAndFollowHref");
29
- if (!disableMixpanel && mixpanel) {
30
- mixpanel.track(eventName, {
31
- funnel,
32
- placement: placement ?? rootProps["aria-label"] ?? event.currentTarget.textContent
33
- });
34
- }
35
28
  if (!disableUserEvents && userEvents) {
36
29
  event.preventDefault();
37
30
  const windowToNav = windowToNavigate();
38
31
  if (href) {
39
32
  userEvents.userClick({
40
- elementName: eventName,
41
- elementType: placement
33
+ elementName,
34
+ intent,
35
+ funnel,
36
+ placement
42
37
  }).then(() => {
43
38
  callOnClickAndFollowHref(windowToNav);
44
39
  }).catch((ex) => {
45
- console.error("User event failed", eventName, ex);
40
+ console.error("User event failed", elementName, funnel, placement, ex);
46
41
  callOnClickAndFollowHref(windowToNav);
47
42
  });
48
43
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/ButtonEx.tsx","../../src/components/ButtonExBase.tsx","../../src/components/ButtonExTo.tsx"],"sourcesContent":["import React, { forwardRef } from 'react'\n\nimport { ButtonExBase } from './ButtonExBase.tsx'\nimport type { ButtonExProps } from './ButtonExProps.tsx'\nimport { ButtonToEx } from './ButtonExTo.tsx'\n\nconst ButtonEx = forwardRef<HTMLButtonElement, ButtonExProps>(({ to, ...props }, ref) => {\n return to ? <ButtonToEx to={to} ref={ref} {...props} /> : <ButtonExBase {...props} />\n})\n\nButtonEx.displayName = 'ButtonExXYLabs'\n\nexport { ButtonEx }\n","import { Button, useTheme } from '@mui/material'\nimport { useMixpanel } from '@xylabs/react-mixpanel'\nimport { useUserEvents } from '@xylabs/react-pixel'\nimport {\n BusyCircularProgress, BusyLinearProgress, mergeBoxlikeStyles,\n} from '@xylabs/react-shared'\nimport type { MouseEvent } from 'react'\nimport React, { forwardRef } from 'react'\n\nimport type { ButtonExProps } from './ButtonExProps.tsx'\n\nconst ButtonExBase = forwardRef<HTMLButtonElement, ButtonExProps>(({\n eventName = 'Button Click', funnel, target, placement, disableUserEvents, href, disableMixpanel, ...props\n}, ref) => {\n const theme = useTheme()\n const userEvents = useUserEvents()\n const mixpanel = useMixpanel(false)\n const {\n busy, busyVariant = 'linear', busyOpacity, onClick, children, ...rootProps\n } = mergeBoxlikeStyles<ButtonExProps>(theme, props)\n\n const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {\n if (busy) {\n // If it is busy, do not allow href clicks\n event.preventDefault()\n } else {\n // we do this crazy navigate thing so that we can set it up outside the promise so that safari does not block it\n const windowToNavigate = () => (target && href) ? window.open('', target) ?? window : window\n const callOnClickAndFollowHref = (windowToNav = windowToNavigate()) => {\n onClick?.(event)\n if (href) {\n windowToNav.location.href = href\n }\n }\n if (!disableMixpanel && mixpanel) {\n mixpanel.track(eventName, {\n funnel,\n placement: placement ?? rootProps['aria-label'] ?? event.currentTarget.textContent,\n })\n }\n if (!disableUserEvents && userEvents) {\n event.preventDefault()\n const windowToNav = windowToNavigate()\n if (href) {\n userEvents.userClick({ elementName: eventName, elementType: placement }).then(() => {\n callOnClickAndFollowHref(windowToNav)\n }).catch((ex) => {\n console.error('User event failed', eventName, ex)\n callOnClickAndFollowHref(windowToNav)\n })\n }\n onClick?.(event)\n } else {\n callOnClickAndFollowHref()\n }\n }\n }\n\n return (\n <Button ref={ref} href={href} onClick={localOnClick} target={target} {...rootProps}>\n {busy && busyVariant === 'linear'\n ? <BusyLinearProgress rounded opacity={busyOpacity ?? 0} />\n : null}\n {busy && busyVariant === 'circular'\n ? <BusyCircularProgress rounded size={24} opacity={busyOpacity ?? 0.5} />\n : null}\n {children}\n </Button>\n )\n})\n\nButtonExBase.displayName = 'ButtonExBaseXYLabs'\n\nexport { ButtonExBase }\n","import type { MouseEvent } from 'react'\nimport React, { forwardRef } from 'react'\nimport { useNavigate } from 'react-router-dom'\n\nimport { ButtonExBase } from './ButtonExBase.tsx'\nimport type { ButtonExProps } from './ButtonExProps.tsx'\n\nconst ButtonToEx = forwardRef<HTMLButtonElement, ButtonExProps>(({\n to, toOptions, onClick, ...props\n}, ref) => {\n const navigate = useNavigate()\n const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (to) {\n navigate(to, toOptions)\n }\n }\n\n return <ButtonExBase ref={ref} onClick={localOnClick} {...props} />\n})\n\nButtonToEx.displayName = 'ButtonToExXYLabs'\n\nexport { ButtonToEx }\n"],"mappings":";;;;AAAA,OAAOA,UAASC,cAAAA,mBAAkB;;;ACAlC,SAASC,QAAQC,gBAAgB;AACjC,SAASC,mBAAmB;AAC5B,SAASC,qBAAqB;AAC9B,SACEC,sBAAsBC,oBAAoBC,0BACrC;AAEP,OAAOC,SAASC,kBAAkB;AAIlC,IAAMC,eAAeC,2BAA6C,CAAC,EACjEC,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I;IAAcpB;IAAiB,GAAGkB;KACtEL,QAAQC,gBAAgB,WACrB,sBAAA,cAAC2B,oBAAAA;IAAmBC,SAAAA;IAAQC,SAAS5B,eAAe;OACpD,MACHF,QAAQC,gBAAgB,aACrB,sBAAA,cAAC8B,sBAAAA;IAAqBF,SAAAA;IAAQG,MAAM;IAAIF,SAAS5B,eAAe;OAChE,MACHE,QAAAA;AAGP,CAAA;AAEArB,aAAakD,cAAc;;;ACtE3B,OAAOC,UAASC,cAAAA,mBAAkB;AAClC,SAASC,mBAAmB;AAK5B,IAAMC,aAAaC,gBAAAA,YAA6C,CAAC,EAC/DC,IAAIC,WAAWC,SAAS,GAAGC,MAAAA,GAC1BC,QAAAA;AACD,QAAMC,WAAWC,YAAAA;AACjB,QAAMC,eAAe,wBAACC,UAAAA;AACpBN,cAAUM,KAAAA;AACV,QAAIR,IAAI;AACNK,eAASL,IAAIC,SAAAA;IACf;EACF,GALqB;AAOrB,SAAO,gBAAAQ,OAAA,cAACC,cAAAA;IAAaN;IAAUF,SAASK;IAAe,GAAGJ;;AAC5D,CAAA;AAEAL,WAAWa,cAAc;;;AFfzB,IAAMC,WAAWC,gBAAAA,YAA6C,CAAC,EAAEC,IAAI,GAAGC,MAAAA,GAASC,QAAAA;AAC/E,SAAOF,KAAK,gBAAAG,OAAA,cAACC,YAAAA;IAAWJ;IAAQE;IAAW,GAAGD;OAAY,gBAAAE,OAAA,cAACE,cAAiBJ,KAAAA;AAC9E,CAAA;AAEAH,SAASQ,cAAc;","names":["React","forwardRef","Button","useTheme","useMixpanel","useUserEvents","BusyCircularProgress","BusyLinearProgress","mergeBoxlikeStyles","React","forwardRef","ButtonExBase","forwardRef","eventName","funnel","target","placement","disableUserEvents","href","disableMixpanel","props","ref","theme","useTheme","userEvents","useUserEvents","mixpanel","useMixpanel","busy","busyVariant","busyOpacity","onClick","children","rootProps","mergeBoxlikeStyles","localOnClick","event","preventDefault","windowToNavigate","window","open","callOnClickAndFollowHref","windowToNav","location","track","currentTarget","textContent","userClick","elementName","elementType","then","catch","ex","console","error","Button","BusyLinearProgress","rounded","opacity","BusyCircularProgress","size","displayName","React","forwardRef","useNavigate","ButtonToEx","forwardRef","to","toOptions","onClick","props","ref","navigate","useNavigate","localOnClick","event","React","ButtonExBase","displayName","ButtonEx","forwardRef","to","props","ref","React","ButtonToEx","ButtonExBase","displayName"]}
1
+ {"version":3,"sources":["../../src/components/ButtonEx.tsx","../../src/components/ButtonExBase.tsx","../../src/components/ButtonExTo.tsx"],"sourcesContent":["import React, { forwardRef } from 'react'\n\nimport { ButtonExBase } from './ButtonExBase.tsx'\nimport type { ButtonExProps } from './ButtonExProps.tsx'\nimport { ButtonToEx } from './ButtonExTo.tsx'\n\nconst ButtonEx = forwardRef<HTMLButtonElement, ButtonExProps>(({ to, ...props }, ref) => {\n return to ? <ButtonToEx to={to} ref={ref} {...props} /> : <ButtonExBase {...props} />\n})\n\nButtonEx.displayName = 'ButtonExXYLabs'\n\nexport { ButtonEx }\n","import { Button, useTheme } from '@mui/material'\nimport { useUserEvents } from '@xylabs/react-pixel'\nimport {\n BusyCircularProgress, BusyLinearProgress, mergeBoxlikeStyles,\n} from '@xylabs/react-shared'\nimport type { MouseEvent } from 'react'\nimport React, { forwardRef } from 'react'\n\nimport type { ButtonExProps } from './ButtonExProps.tsx'\n\nconst ButtonExBase = forwardRef<HTMLButtonElement, ButtonExProps>(({\n funnel, intent, target, placement, disableUserEvents, href, ...props\n}, ref) => {\n const theme = useTheme()\n const userEvents = useUserEvents()\n const {\n busy, busyVariant = 'linear', busyOpacity, onClick, children, ...rootProps\n } = mergeBoxlikeStyles<ButtonExProps>(theme, props)\n\n const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {\n if (busy) {\n // If it is busy, do not allow href clicks\n event.preventDefault()\n } else {\n const elementName = props['aria-label'] ?? event.currentTarget.textContent\n // we do this crazy navigate thing so that we can set it up outside the promise so that safari does not block it\n const windowToNavigate = () => (target && href) ? window.open('', target) ?? window : window\n const callOnClickAndFollowHref = (windowToNav = windowToNavigate()) => {\n onClick?.(event)\n if (href) {\n windowToNav.location.href = href\n }\n }\n if (!disableUserEvents && userEvents) {\n event.preventDefault()\n const windowToNav = windowToNavigate()\n if (href) {\n userEvents.userClick({\n elementName, intent, funnel, placement,\n }).then(() => {\n callOnClickAndFollowHref(windowToNav)\n }).catch((ex) => {\n console.error('User event failed', elementName, funnel, placement, ex)\n callOnClickAndFollowHref(windowToNav)\n })\n }\n onClick?.(event)\n } else {\n callOnClickAndFollowHref()\n }\n }\n }\n\n return (\n <Button ref={ref} href={href} onClick={localOnClick} target={target} {...rootProps}>\n {busy && busyVariant === 'linear'\n ? <BusyLinearProgress rounded opacity={busyOpacity ?? 0} />\n : null}\n {busy && busyVariant === 'circular'\n ? <BusyCircularProgress rounded size={24} opacity={busyOpacity ?? 0.5} />\n : null}\n {children}\n </Button>\n )\n})\n\nButtonExBase.displayName = 'ButtonExBaseXYLabs'\n\nexport { ButtonExBase }\n","import type { MouseEvent } from 'react'\nimport React, { forwardRef } from 'react'\nimport { useNavigate } from 'react-router-dom'\n\nimport { ButtonExBase } from './ButtonExBase.tsx'\nimport type { ButtonExProps } from './ButtonExProps.tsx'\n\nconst ButtonToEx = forwardRef<HTMLButtonElement, ButtonExProps>(({\n to, toOptions, onClick, ...props\n}, ref) => {\n const navigate = useNavigate()\n const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (to) {\n navigate(to, toOptions)\n }\n }\n\n return <ButtonExBase ref={ref} onClick={localOnClick} {...props} />\n})\n\nButtonToEx.displayName = 'ButtonToExXYLabs'\n\nexport { ButtonToEx }\n"],"mappings":";;;;AAAA,OAAOA,UAASC,cAAAA,mBAAkB;;;ACAlC,SAASC,QAAQC,gBAAgB;AACjC,SAASC,qBAAqB;AAC9B,SACEC,sBAAsBC,oBAAoBC,0BACrC;AAEP,OAAOC,SAASC,kBAAkB;AAIlC,IAAMC,eAAeC,2BAA6C,CAAC,EACjEC,QAAQ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BAAgB,aACrB,sBAAA,cAAC4B,sBAAAA;IAAqBF,SAAAA;IAAQG,MAAM;IAAIF,SAAS1B,eAAe;OAChE,MACHE,QAAAA;AAGP,CAAA;AAEAlB,aAAa6C,cAAc;;;ACjE3B,OAAOC,UAASC,cAAAA,mBAAkB;AAClC,SAASC,mBAAmB;AAK5B,IAAMC,aAAaC,gBAAAA,YAA6C,CAAC,EAC/DC,IAAIC,WAAWC,SAAS,GAAGC,MAAAA,GAC1BC,QAAAA;AACD,QAAMC,WAAWC,YAAAA;AACjB,QAAMC,eAAe,wBAACC,UAAAA;AACpBN,cAAUM,KAAAA;AACV,QAAIR,IAAI;AACNK,eAASL,IAAIC,SAAAA;IACf;EACF,GALqB;AAOrB,SAAO,gBAAAQ,OAAA,cAACC,cAAAA;IAAaN;IAAUF,SAASK;IAAe,GAAGJ;;AAC5D,CAAA;AAEAL,WAAWa,cAAc;;;AFfzB,IAAMC,WAAWC,gBAAAA,YAA6C,CAAC,EAAEC,IAAI,GAAGC,MAAAA,GAASC,QAAAA;AAC/E,SAAOF,KAAK,gBAAAG,OAAA,cAACC,YAAAA;IAAWJ;IAAQE;IAAW,GAAGD;OAAY,gBAAAE,OAAA,cAACE,cAAiBJ,KAAAA;AAC9E,CAAA;AAEAH,SAASQ,cAAc;","names":["React","forwardRef","Button","useTheme","useUserEvents","BusyCircularProgress","BusyLinearProgress","mergeBoxlikeStyles","React","forwardRef","ButtonExBase","forwardRef","funnel","intent","target","placement","disableUserEvents","href","props","ref","theme","useTheme","userEvents","useUserEvents","busy","busyVariant","busyOpacity","onClick","children","rootProps","mergeBoxlikeStyles","localOnClick","event","preventDefault","elementName","currentTarget","textContent","windowToNavigate","window","open","callOnClickAndFollowHref","windowToNav","location","userClick","then","catch","ex","console","error","Button","BusyLinearProgress","rounded","opacity","BusyCircularProgress","size","displayName","React","forwardRef","useNavigate","ButtonToEx","forwardRef","to","toOptions","onClick","props","ref","navigate","useNavigate","localOnClick","event","React","ButtonExBase","displayName","ButtonEx","forwardRef","to","props","ref","React","ButtonToEx","ButtonExBase","displayName"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/react-button",
3
- "version": "4.2.12",
3
+ "version": "5.0.0-rc.1",
4
4
  "description": "Common React library for all XY Labs projects that use React",
5
5
  "keywords": [
6
6
  "utility",
@@ -37,16 +37,16 @@
37
37
  "packages/*"
38
38
  ],
39
39
  "dependencies": {
40
- "@xylabs/react-mixpanel": "^4.2.12",
41
- "@xylabs/react-pixel": "^4.2.12",
42
- "@xylabs/react-shared": "^4.2.12",
40
+ "@xylabs/react-mixpanel": "^5.0.0-rc.1",
41
+ "@xylabs/react-pixel": "^5.0.0-rc.1",
42
+ "@xylabs/react-shared": "^5.0.0-rc.1",
43
43
  "react-router-dom": "^6.26.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@mui/material": "^6.0.2",
47
47
  "@storybook/react": "^8.2.9",
48
48
  "@types/react": "^18.3.5",
49
- "@xylabs/react-flexbox": "^4.2.12",
49
+ "@xylabs/react-flexbox": "^5.0.0-rc.1",
50
50
  "@xylabs/ts-scripts-yarn3": "^4.0.7",
51
51
  "@xylabs/tsconfig-react": "^4.0.7",
52
52
  "react": "^18.3.1",
@@ -55,11 +55,12 @@
55
55
  "typescript": "^5.5.4"
56
56
  },
57
57
  "peerDependencies": {
58
- "@mui/material": ">5",
58
+ "@mui/material": "^6",
59
59
  "react": "^18",
60
60
  "react-dom": "^18"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"
64
- }
64
+ },
65
+ "stableVersion": "4.2.13"
65
66
  }
@@ -1,5 +1,4 @@
1
1
  import { Button, useTheme } from '@mui/material'
2
- import { useMixpanel } from '@xylabs/react-mixpanel'
3
2
  import { useUserEvents } from '@xylabs/react-pixel'
4
3
  import {
5
4
  BusyCircularProgress, BusyLinearProgress, mergeBoxlikeStyles,
@@ -10,11 +9,10 @@ import React, { forwardRef } from 'react'
10
9
  import type { ButtonExProps } from './ButtonExProps.tsx'
11
10
 
12
11
  const ButtonExBase = forwardRef<HTMLButtonElement, ButtonExProps>(({
13
- eventName = 'Button Click', funnel, target, placement, disableUserEvents, href, disableMixpanel, ...props
12
+ funnel, intent, target, placement, disableUserEvents, href, ...props
14
13
  }, ref) => {
15
14
  const theme = useTheme()
16
15
  const userEvents = useUserEvents()
17
- const mixpanel = useMixpanel(false)
18
16
  const {
19
17
  busy, busyVariant = 'linear', busyOpacity, onClick, children, ...rootProps
20
18
  } = mergeBoxlikeStyles<ButtonExProps>(theme, props)
@@ -24,6 +22,7 @@ const ButtonExBase = forwardRef<HTMLButtonElement, ButtonExProps>(({
24
22
  // If it is busy, do not allow href clicks
25
23
  event.preventDefault()
26
24
  } else {
25
+ const elementName = props['aria-label'] ?? event.currentTarget.textContent
27
26
  // we do this crazy navigate thing so that we can set it up outside the promise so that safari does not block it
28
27
  const windowToNavigate = () => (target && href) ? window.open('', target) ?? window : window
29
28
  const callOnClickAndFollowHref = (windowToNav = windowToNavigate()) => {
@@ -32,20 +31,16 @@ const ButtonExBase = forwardRef<HTMLButtonElement, ButtonExProps>(({
32
31
  windowToNav.location.href = href
33
32
  }
34
33
  }
35
- if (!disableMixpanel && mixpanel) {
36
- mixpanel.track(eventName, {
37
- funnel,
38
- placement: placement ?? rootProps['aria-label'] ?? event.currentTarget.textContent,
39
- })
40
- }
41
34
  if (!disableUserEvents && userEvents) {
42
35
  event.preventDefault()
43
36
  const windowToNav = windowToNavigate()
44
37
  if (href) {
45
- userEvents.userClick({ elementName: eventName, elementType: placement }).then(() => {
38
+ userEvents.userClick({
39
+ elementName, intent, funnel, placement,
40
+ }).then(() => {
46
41
  callOnClickAndFollowHref(windowToNav)
47
42
  }).catch((ex) => {
48
- console.error('User event failed', eventName, ex)
43
+ console.error('User event failed', elementName, funnel, placement, ex)
49
44
  callOnClickAndFollowHref(windowToNav)
50
45
  })
51
46
  }
@@ -3,10 +3,9 @@ import type { BoxlikeComponentProps, BusyProps } from '@xylabs/react-shared'
3
3
  import type { NavigateOptions, To } from 'react-router-dom'
4
4
 
5
5
  interface ButtonExProps extends Omit<ButtonProps, 'ref'>, BoxlikeComponentProps, BusyProps {
6
- disableMixpanel?: boolean
7
6
  disableUserEvents?: boolean
8
- eventName?: string
9
7
  funnel?: string
8
+ intent?: string
10
9
  placement?: string
11
10
  target?: string
12
11
  to?: To