@xylabs/react-button 6.0.4 → 6.0.6
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/browser/index.mjs +3 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/types/components/ButtonEx.d.ts +1 -4
- package/dist/types/components/ButtonEx.d.ts.map +1 -1
- package/dist/types/components/ButtonExBase.d.ts +1 -4
- package/dist/types/components/ButtonExBase.d.ts.map +1 -1
- package/dist/types/components/ButtonExProps.d.ts +1 -1
- package/dist/types/components/ButtonExProps.d.ts.map +1 -1
- package/dist/types/components/ButtonExTo.d.ts +1 -4
- package/dist/types/components/ButtonExTo.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/components/ButtonEx.tsx +1 -1
- package/src/components/ButtonExBase.tsx +4 -3
- package/src/components/ButtonExProps.tsx +1 -1
- package/src/components/ButtonExTo.tsx +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import React3 from "react";
|
|
|
6
6
|
|
|
7
7
|
// src/components/ButtonExBase.tsx
|
|
8
8
|
import { Button, useTheme } from "@mui/material";
|
|
9
|
+
import { toPromise } from "@xylabs/promise";
|
|
9
10
|
import { useUserEvents } from "@xylabs/react-pixel";
|
|
10
11
|
import { BusyCircularProgress, BusyLinearProgress, mergeBoxlikeStyles } from "@xylabs/react-shared";
|
|
11
12
|
import React from "react";
|
|
@@ -29,12 +30,12 @@ var ButtonExBase = /* @__PURE__ */ __name(({ ref, funnel, intent, target, placem
|
|
|
29
30
|
event.preventDefault();
|
|
30
31
|
const windowToNav = windowToNavigate();
|
|
31
32
|
if (href) {
|
|
32
|
-
userEvents.userClick({
|
|
33
|
+
toPromise(userEvents.userClick({
|
|
33
34
|
elementName,
|
|
34
35
|
intent,
|
|
35
36
|
funnel,
|
|
36
37
|
placement
|
|
37
|
-
}).then(() => {
|
|
38
|
+
})).then(() => {
|
|
38
39
|
callOnClickAndFollowHref(windowToNav);
|
|
39
40
|
}).catch((ex) => {
|
|
40
41
|
console.error("User event failed", elementName, funnel, placement, ex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/ButtonEx.tsx","../../src/components/ButtonExBase.tsx","../../src/components/ButtonExTo.tsx","../../src/components/ButtonExProps.tsx"],"sourcesContent":["import React from 'react'\n\nimport { ButtonExBase } from './ButtonExBase.tsx'\nimport type { ButtonExProps } from './ButtonExProps.tsx'\nimport { ButtonToEx } from './ButtonExTo.tsx'\n\nconst ButtonEx = ({ ref, ...props }: ButtonExProps
|
|
1
|
+
{"version":3,"sources":["../../src/components/ButtonEx.tsx","../../src/components/ButtonExBase.tsx","../../src/components/ButtonExTo.tsx","../../src/components/ButtonExProps.tsx"],"sourcesContent":["import React from 'react'\n\nimport { ButtonExBase } from './ButtonExBase.tsx'\nimport type { ButtonExProps } from './ButtonExProps.tsx'\nimport { ButtonToEx } from './ButtonExTo.tsx'\n\nconst ButtonEx = ({ ref, ...props }: ButtonExProps) => {\n if (props.to) {\n const { to, ...additionalProps } = props\n return <ButtonToEx to={to} ref={ref} {...additionalProps} />\n } else {\n return <ButtonExBase {...props} />\n }\n}\n\nButtonEx.displayName = 'ButtonExXYLabs'\n\nexport { ButtonEx }\n","import { Button, useTheme } from '@mui/material'\nimport { toPromise } from '@xylabs/promise'\nimport { useUserEvents } from '@xylabs/react-pixel'\nimport {\n BusyCircularProgress, BusyLinearProgress, mergeBoxlikeStyles,\n} from '@xylabs/react-shared'\nimport type { MouseEvent } from 'react'\nimport React from 'react'\n\nimport type { ButtonExProps } from './ButtonExProps.tsx'\n\nconst ButtonExBase = ({\n ref, funnel, intent, target, placement, disableUserEvents, href, ...props\n}: ButtonExProps) => {\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) ?? globalThis : globalThis\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 toPromise(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 from 'react'\nimport { useNavigate } from 'react-router-dom'\n\nimport { ButtonExBase } from './ButtonExBase.tsx'\nimport type { ButtonExProps } from './ButtonExProps.tsx'\n\nconst ButtonToEx = ({\n ref, to, toOptions, onClick, ...props\n}: ButtonExProps) => {\n const navigate = useNavigate()\n const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (to) {\n void navigate(to, toOptions)\n }\n }\n\n return <ButtonExBase ref={ref} onClick={localOnClick} {...props} />\n}\n\nButtonToEx.displayName = 'ButtonToExXYLabs'\n\nexport { ButtonToEx }\n","import type { ButtonProps } from '@mui/material'\nimport type { BoxlikeComponentProps, BusyProps } from '@xylabs/react-shared'\nimport type { NavigateOptions, To } from 'react-router-dom'\n\nexport interface ButtonOnlyHrefProps {\n href?: string\n to?: never\n toOptions?: never\n}\n\nexport interface ButtonOnlyToProps {\n href?: never\n to?: To\n toOptions?: NavigateOptions\n}\n\nexport interface ButtonNoToOrHrefProps {\n href?: never\n to?: never\n toOptions?: never\n}\n\nexport type ButtonHrefOrToOrNoProps = ButtonOnlyHrefProps | ButtonOnlyToProps | ButtonNoToOrHrefProps\n\nexport interface ButtonHrefAndToProps {\n href?: string\n to?: To\n toOptions?: NavigateOptions\n}\n\nexport const asButtonHrefOrToProps = (props: ButtonHrefAndToProps): ButtonHrefOrToOrNoProps => {\n if (props.href && (props.to || props.toOptions)) {\n throw new Error('ButtonExProps: cannot have both href and to')\n }\n return props.href ? { href: props.href } : props.to ? { to: props.to, toOptions: props.toOptions } : {}\n}\n\nexport interface ButtonBaseExProps extends Omit<ButtonProps, 'href'>, BoxlikeComponentProps, BusyProps {\n disableUserEvents?: boolean\n funnel?: string\n intent?: string\n placement?: string\n target?: string\n}\n\nexport type ButtonExProps = ButtonBaseExProps & ButtonHrefOrToOrNoProps\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,SAASC,QAAQC,gBAAgB;AACjC,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;AAC9B,SACEC,sBAAsBC,oBAAoBC,0BACrC;AAEP,OAAOC,WAAW;AAIlB,IAAMC,eAAe,wBAAC,EACpBC,KAAKC,QAAQC,QAAQC,QAAQC,WAAWC,mBAAmBC,MAAM,GAAGC,MAAAA,MACtD;AACd,QAAMC,QAAQC,SAAAA;AACd,QAAMC,aAAaC,cAAAA;AACnB,QAAM,EACJC,MAAMC,cAAc,UAAUC,aAAaC,SAASC,UAAU,GAAGC,UAAAA,IAC/DC,mBAAkCV,OAAOD,KAAAA;AAE7C,QAAMY,eAAe,wBAACC,UAAAA;AACpB,QAAIR,MAAM;AAERQ,YAAMC,eAAc;IACtB,OAAO;AACL,YAAMC,cAAcf,MAAM,Y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AAA;AACpBL,cAAUK,KAAAA;AACV,QAAIP,IAAI;AACN,WAAKI,SAASJ,IAAIC,SAAAA;IACpB;EACF,GALqB;AAOrB,SAAO,gBAAAO,OAAA,cAACC,cAAAA;IAAaV;IAAUG,SAASI;IAAe,GAAGH;;AAC5D,GAZmB;AAcnBL,WAAWY,cAAc;;;AFfzB,IAAMC,WAAW,wBAAC,EAAEC,KAAK,GAAGC,MAAAA,MAAsB;AAChD,MAAIA,MAAMC,IAAI;AACZ,UAAM,EAAEA,IAAI,GAAGC,gBAAAA,IAAoBF;AACnC,WAAO,gBAAAG,OAAA,cAACC,YAAAA;MAAWH;MAAQF;MAAW,GAAGG;;EAC3C,OAAO;AACL,WAAO,gBAAAC,OAAA,cAACE,cAAiBL,KAAAA;EAC3B;AACF,GAPiB;AASjBF,SAASQ,cAAc;;;AGehB,IAAMC,wBAAwB,wBAACC,UAAAA;AACpC,MAAIA,MAAMC,SAASD,MAAME,MAAMF,MAAMG,YAAY;AAC/C,UAAM,IAAIC,MAAM,6CAAA;EAClB;AACA,SAAOJ,MAAMC,OAAO;IAAEA,MAAMD,MAAMC;EAAK,IAAID,MAAME,KAAK;IAAEA,IAAIF,MAAME;IAAIC,WAAWH,MAAMG;EAAU,IAAI,CAAC;AACxG,GALqC;","names":["React","Button","useTheme","toPromise","useUserEvents","BusyCircularProgress","BusyLinearProgress","mergeBoxlikeStyles","React","ButtonExBase","ref","funnel","intent","target","placement","disableUserEvents","href","props","theme","useTheme","userEvents","useUserEvents","busy","busyVariant","busyOpacity","onClick","children","rootProps","mergeBoxlikeStyles","localOnClick","event","preventDefault","elementName","currentTarget","textContent","windowToNavigate","window","open","globalThis","callOnClickAndFollowHref","windowToNav","location","toPromise","userClick","then","catch","ex","console","error","Button","BusyLinearProgress","rounded","opacity","BusyCircularProgress","size","displayName","React","useNavigate","ButtonToEx","ref","to","toOptions","onClick","props","navigate","useNavigate","localOnClick","event","React","ButtonExBase","displayName","ButtonEx","ref","props","to","additionalProps","React","ButtonToEx","ButtonExBase","displayName","asButtonHrefOrToProps","props","href","to","toOptions","Error"]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ButtonExProps } from './ButtonExProps.tsx';
|
|
3
2
|
declare const ButtonEx: {
|
|
4
|
-
({ ref, ...props }: ButtonExProps
|
|
5
|
-
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
6
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ ref, ...props }: ButtonExProps): import("react/jsx-runtime").JSX.Element;
|
|
7
4
|
displayName: string;
|
|
8
5
|
};
|
|
9
6
|
export { ButtonEx };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonEx.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonEx.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,QAAA,MAAM,QAAQ;wBAAuB,aAAa;;CAOjD,CAAA;AAID,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ButtonExProps } from './ButtonExProps.tsx';
|
|
3
2
|
declare const ButtonExBase: {
|
|
4
|
-
({ ref, funnel, intent, target, placement, disableUserEvents, href, ...props }: ButtonExProps
|
|
5
|
-
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
6
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ ref, funnel, intent, target, placement, disableUserEvents, href, ...props }: ButtonExProps): import("react/jsx-runtime").JSX.Element;
|
|
7
4
|
displayName: string;
|
|
8
5
|
};
|
|
9
6
|
export { ButtonExBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonExBase.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExBase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ButtonExBase.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExBase.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,QAAA,MAAM,YAAY;oFAEf,aAAa;;CAoDf,CAAA;AAID,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -23,7 +23,7 @@ export interface ButtonHrefAndToProps {
|
|
|
23
23
|
toOptions?: NavigateOptions;
|
|
24
24
|
}
|
|
25
25
|
export declare const asButtonHrefOrToProps: (props: ButtonHrefAndToProps) => ButtonHrefOrToOrNoProps;
|
|
26
|
-
export interface ButtonBaseExProps extends Omit<ButtonProps, '
|
|
26
|
+
export interface ButtonBaseExProps extends Omit<ButtonProps, 'href'>, BoxlikeComponentProps, BusyProps {
|
|
27
27
|
disableUserEvents?: boolean;
|
|
28
28
|
funnel?: string;
|
|
29
29
|
intent?: string;
|
|
@@ -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,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,KAAK,CAAA;IACV,SAAS,CAAC,EAAE,KAAK,CAAA;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;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iB,GAAG,qBAAqB,CAAA;AAErG,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,eAAO,MAAM,qBAAqB,GAAI,OAAO,oBAAoB,KAAG,uBAKnE,CAAA;AAED,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,qBAAqB,EAAE,SAAS;IACpG,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;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,uBAAuB,CAAA"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ButtonExProps } from './ButtonExProps.tsx';
|
|
3
2
|
declare const ButtonToEx: {
|
|
4
|
-
({ ref, to, toOptions, onClick, ...props }: ButtonExProps
|
|
5
|
-
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
6
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ ref, to, toOptions, onClick, ...props }: ButtonExProps): import("react/jsx-runtime").JSX.Element;
|
|
7
4
|
displayName: string;
|
|
8
5
|
};
|
|
9
6
|
export { ButtonToEx };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonExTo.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExTo.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ButtonExTo.d.ts","sourceRoot":"","sources":["../../../src/components/ButtonExTo.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,QAAA,MAAM,UAAU;gDAEb,aAAa;;CAUf,CAAA;AAID,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/react-button",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"description": "Common React library for all XY Labs projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utility",
|
|
@@ -37,21 +37,22 @@
|
|
|
37
37
|
"packages/*"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@xylabs/
|
|
41
|
-
"@xylabs/react-
|
|
40
|
+
"@xylabs/promise": "^4.6.4",
|
|
41
|
+
"@xylabs/react-pixel": "^6.0.6",
|
|
42
|
+
"@xylabs/react-shared": "^6.0.6",
|
|
42
43
|
"react-router-dom": "^7.3.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@mui/material": "^6.4.
|
|
46
|
-
"@storybook/react": "^8.6.
|
|
46
|
+
"@mui/material": "^6.4.8",
|
|
47
|
+
"@storybook/react": "^8.6.7",
|
|
47
48
|
"@types/react": "^19.0.10",
|
|
48
|
-
"@xylabs/react-flexbox": "^6.0.
|
|
49
|
-
"@xylabs/react-pixel": "^6.0.
|
|
50
|
-
"@xylabs/ts-scripts-yarn3": "^6.
|
|
51
|
-
"@xylabs/tsconfig-react": "^6.
|
|
49
|
+
"@xylabs/react-flexbox": "^6.0.6",
|
|
50
|
+
"@xylabs/react-pixel": "^6.0.6",
|
|
51
|
+
"@xylabs/ts-scripts-yarn3": "^6.1.4",
|
|
52
|
+
"@xylabs/tsconfig-react": "^6.1.4",
|
|
52
53
|
"react": "^19.0.0",
|
|
53
54
|
"react-dom": "^19.0.0",
|
|
54
|
-
"storybook": "^8.6.
|
|
55
|
+
"storybook": "^8.6.7",
|
|
55
56
|
"typescript": "^5.8.2"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
@@ -4,7 +4,7 @@ import { ButtonExBase } from './ButtonExBase.tsx'
|
|
|
4
4
|
import type { ButtonExProps } from './ButtonExProps.tsx'
|
|
5
5
|
import { ButtonToEx } from './ButtonExTo.tsx'
|
|
6
6
|
|
|
7
|
-
const ButtonEx = ({ ref, ...props }: ButtonExProps
|
|
7
|
+
const ButtonEx = ({ ref, ...props }: ButtonExProps) => {
|
|
8
8
|
if (props.to) {
|
|
9
9
|
const { to, ...additionalProps } = props
|
|
10
10
|
return <ButtonToEx to={to} ref={ref} {...additionalProps} />
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Button, useTheme } from '@mui/material'
|
|
2
|
+
import { toPromise } from '@xylabs/promise'
|
|
2
3
|
import { useUserEvents } from '@xylabs/react-pixel'
|
|
3
4
|
import {
|
|
4
5
|
BusyCircularProgress, BusyLinearProgress, mergeBoxlikeStyles,
|
|
@@ -10,7 +11,7 @@ import type { ButtonExProps } from './ButtonExProps.tsx'
|
|
|
10
11
|
|
|
11
12
|
const ButtonExBase = ({
|
|
12
13
|
ref, funnel, intent, target, placement, disableUserEvents, href, ...props
|
|
13
|
-
}: ButtonExProps
|
|
14
|
+
}: ButtonExProps) => {
|
|
14
15
|
const theme = useTheme()
|
|
15
16
|
const userEvents = useUserEvents()
|
|
16
17
|
const {
|
|
@@ -35,9 +36,9 @@ const ButtonExBase = ({
|
|
|
35
36
|
event.preventDefault()
|
|
36
37
|
const windowToNav = windowToNavigate()
|
|
37
38
|
if (href) {
|
|
38
|
-
userEvents.userClick({
|
|
39
|
+
toPromise(userEvents.userClick({
|
|
39
40
|
elementName, intent, funnel, placement,
|
|
40
|
-
}).then(() => {
|
|
41
|
+
})).then(() => {
|
|
41
42
|
callOnClickAndFollowHref(windowToNav)
|
|
42
43
|
}).catch((ex) => {
|
|
43
44
|
console.error('User event failed', elementName, funnel, placement, ex)
|
|
@@ -35,7 +35,7 @@ export const asButtonHrefOrToProps = (props: ButtonHrefAndToProps): ButtonHrefOr
|
|
|
35
35
|
return props.href ? { href: props.href } : props.to ? { to: props.to, toOptions: props.toOptions } : {}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export interface ButtonBaseExProps extends Omit<ButtonProps, '
|
|
38
|
+
export interface ButtonBaseExProps extends Omit<ButtonProps, 'href'>, BoxlikeComponentProps, BusyProps {
|
|
39
39
|
disableUserEvents?: boolean
|
|
40
40
|
funnel?: string
|
|
41
41
|
intent?: string
|
|
@@ -7,7 +7,7 @@ import type { ButtonExProps } from './ButtonExProps.tsx'
|
|
|
7
7
|
|
|
8
8
|
const ButtonToEx = ({
|
|
9
9
|
ref, to, toOptions, onClick, ...props
|
|
10
|
-
}: ButtonExProps
|
|
10
|
+
}: ButtonExProps) => {
|
|
11
11
|
const navigate = useNavigate()
|
|
12
12
|
const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {
|
|
13
13
|
onClick?.(event)
|