@xylabs/react-button 5.1.0-rc.1 → 5.1.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/browser/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ var ButtonExBase = /* @__PURE__ */ forwardRef(({ funnel, intent, target, placeme
|
|
|
18
18
|
event.preventDefault();
|
|
19
19
|
} else {
|
|
20
20
|
const elementName = props["aria-label"] ?? event.currentTarget.textContent;
|
|
21
|
-
const windowToNavigate = /* @__PURE__ */ __name(() => target && href ? window.open("", target) ??
|
|
21
|
+
const windowToNavigate = /* @__PURE__ */ __name(() => target && href ? window.open("", target) ?? globalThis : globalThis, "windowToNavigate");
|
|
22
22
|
const callOnClickAndFollowHref = /* @__PURE__ */ __name((windowToNav = windowToNavigate()) => {
|
|
23
23
|
onClick?.(event);
|
|
24
24
|
if (href) {
|
|
@@ -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 { 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) ??
|
|
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) ?? 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 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,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cjB;IAAiB,GAAGe;KACtEL,QAAQC,gBAAgB,WACrB,sBAAA,cAAC0B,oBAAAA;IAAmBC,SAAAA;IAAQC,SAAS3B,eAAe;OACpD,MACHF,QAAQC,gBAAgB,aACrB,sBAAA,cAAC6B,sBAAAA;IAAqBF,SAAAA;IAAQG,MAAM;IAAIF,SAAS3B,eAAe;OAChE,MACHE,QAAAA;AAGP,CAAA;AAEAlB,aAAa8C,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","globalThis","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": "5.1.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Common React library for all XY Labs projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utility",
|
|
@@ -37,22 +37,21 @@
|
|
|
37
37
|
"packages/*"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@xylabs/react-
|
|
41
|
-
"@xylabs/react-
|
|
42
|
-
"
|
|
43
|
-
"react-router-dom": "^6.26.1"
|
|
40
|
+
"@xylabs/react-pixel": "^5.1.0",
|
|
41
|
+
"@xylabs/react-shared": "^5.1.0",
|
|
42
|
+
"react-router-dom": "^6.26.2"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
|
-
"@mui/material": "^6.
|
|
47
|
-
"@storybook/react": "^8.
|
|
48
|
-
"@types/react": "^18.3.
|
|
49
|
-
"@xylabs/react-flexbox": "^5.1.0
|
|
50
|
-
"@xylabs/ts-scripts-yarn3": "^4.0
|
|
51
|
-
"@xylabs/tsconfig-react": "^4.0
|
|
45
|
+
"@mui/material": "^6.1.2",
|
|
46
|
+
"@storybook/react": "^8.3.5",
|
|
47
|
+
"@types/react": "^18.3.11",
|
|
48
|
+
"@xylabs/react-flexbox": "^5.1.0",
|
|
49
|
+
"@xylabs/ts-scripts-yarn3": "^4.1.0",
|
|
50
|
+
"@xylabs/tsconfig-react": "^4.1.0",
|
|
52
51
|
"react": "^18.3.1",
|
|
53
52
|
"react-dom": "^18.3.1",
|
|
54
|
-
"storybook": "^8.
|
|
55
|
-
"typescript": "^5.
|
|
53
|
+
"storybook": "^8.3.5",
|
|
54
|
+
"typescript": "^5.6.2"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
57
|
"@mui/material": "^6",
|
|
@@ -61,6 +60,5 @@
|
|
|
61
60
|
},
|
|
62
61
|
"publishConfig": {
|
|
63
62
|
"access": "public"
|
|
64
|
-
}
|
|
65
|
-
"stableVersion": "5.0.0"
|
|
63
|
+
}
|
|
66
64
|
}
|
|
@@ -24,7 +24,7 @@ const ButtonExBase = forwardRef<HTMLButtonElement, ButtonExProps>(({
|
|
|
24
24
|
} else {
|
|
25
25
|
const elementName = props['aria-label'] ?? event.currentTarget.textContent
|
|
26
26
|
// we do this crazy navigate thing so that we can set it up outside the promise so that safari does not block it
|
|
27
|
-
const windowToNavigate = () => (target && href) ? window.open('', target) ??
|
|
27
|
+
const windowToNavigate = () => (target && href) ? window.open('', target) ?? globalThis : globalThis
|
|
28
28
|
const callOnClickAndFollowHref = (windowToNav = windowToNavigate()) => {
|
|
29
29
|
onClick?.(event)
|
|
30
30
|
if (href) {
|