@vector-im/compound-web 7.11.0 → 8.0.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/components/Breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.cjs.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Button/IconButton/IconButton.cjs +4 -2
- package/dist/components/Button/IconButton/IconButton.cjs.map +1 -1
- package/dist/components/Button/IconButton/IconButton.d.ts +10 -1
- package/dist/components/Button/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/Button/IconButton/IconButton.js +4 -2
- package/dist/components/Button/IconButton/IconButton.js.map +1 -1
- package/dist/components/Button/IconButton/IconButton.module.css.cjs +3 -3
- package/dist/components/Button/IconButton/IconButton.module.css.js +3 -3
- package/dist/components/Menu/ContextMenu.cjs +2 -1
- package/dist/components/Menu/ContextMenu.cjs.map +1 -1
- package/dist/components/Menu/ContextMenu.d.ts +5 -0
- package/dist/components/Menu/ContextMenu.d.ts.map +1 -1
- package/dist/components/Menu/ContextMenu.js +2 -1
- package/dist/components/Menu/ContextMenu.js.map +1 -1
- package/dist/style.css.css +39 -16
- package/package.json +1 -1
- package/src/components/Breadcrumb/Breadcrumb.tsx +1 -1
- package/src/components/Button/IconButton/IconButton.module.css +32 -9
- package/src/components/Button/IconButton/IconButton.tsx +14 -3
- package/src/components/Menu/ContextMenu.tsx +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumb.cjs","sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { HTMLProps, JSX, MouseEventHandler, KeyboardEvent } from \"react\";\nimport { IconButton } from \"../Button\";\nimport Chevron from \"@vector-im/compound-design-tokens/assets/web/icons/chevron-left\";\nimport styles from \"./Breadcrumb.module.css\";\nimport { Link } from \"../Link/Link.tsx\";\nimport classNames from \"classnames\";\n\ninterface BreadcrumbProps extends HTMLProps<HTMLElement> {\n /**\n * The label for the back button.\n */\n backLabel: string;\n /**\n * The click handler for the back button.\n */\n onBackClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * The pages to display in the breadcrumb.\n * All the pages except the last one are displayed as links.\n */\n pages: string[];\n /**\n * The click handler for a page.\n * @param page - The page that was clicked.\n * @param index - The index of the page that was clicked.\n */\n onPageClick: (page: string, index: number) => void;\n}\n\n/**\n * A breadcrumb component.\n */\nexport function Breadcrumb({\n backLabel,\n onBackClick,\n pages,\n onPageClick,\n className,\n ...props\n}: BreadcrumbProps): JSX.Element {\n return (\n <nav className={classNames(styles.breadcrumb, className)} {...props}>\n <IconButton\n
|
|
1
|
+
{"version":3,"file":"Breadcrumb.cjs","sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { HTMLProps, JSX, MouseEventHandler, KeyboardEvent } from \"react\";\nimport { IconButton } from \"../Button\";\nimport Chevron from \"@vector-im/compound-design-tokens/assets/web/icons/chevron-left\";\nimport styles from \"./Breadcrumb.module.css\";\nimport { Link } from \"../Link/Link.tsx\";\nimport classNames from \"classnames\";\n\ninterface BreadcrumbProps extends HTMLProps<HTMLElement> {\n /**\n * The label for the back button.\n */\n backLabel: string;\n /**\n * The click handler for the back button.\n */\n onBackClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * The pages to display in the breadcrumb.\n * All the pages except the last one are displayed as links.\n */\n pages: string[];\n /**\n * The click handler for a page.\n * @param page - The page that was clicked.\n * @param index - The index of the page that was clicked.\n */\n onPageClick: (page: string, index: number) => void;\n}\n\n/**\n * A breadcrumb component.\n */\nexport function Breadcrumb({\n backLabel,\n onBackClick,\n pages,\n onPageClick,\n className,\n ...props\n}: BreadcrumbProps): JSX.Element {\n return (\n <nav className={classNames(styles.breadcrumb, className)} {...props}>\n <IconButton\n kind=\"secondary\"\n size=\"28px\"\n aria-label={backLabel}\n onClick={onBackClick}\n >\n <Chevron />\n </IconButton>\n <ol className={styles.pages}>\n {pages.map((page, index) => (\n <Page\n key={index}\n page={page}\n isLastPage={index === pages.length - 1}\n onClick={() => onPageClick(page, index)}\n />\n ))}\n </ol>\n </nav>\n );\n}\n\ninterface PageProps {\n /**\n * The page to display.\n */\n page: string;\n /**\n * Whether this is the last page in the breadcrumb.\n */\n isLastPage: boolean;\n /**\n * The click handler for the page, ignore for last page.\n */\n onClick: () => void;\n}\n\n/**\n * A breadcrumb page.\n * If not the last page, the page is displayed in a link.\n */\nfunction Page({ page, isLastPage, onClick }: PageProps): JSX.Element {\n const onKeyDown = (event: KeyboardEvent<HTMLAnchorElement>) => {\n if (event.key === \" \") {\n onClick();\n }\n };\n\n return (\n <li>\n {isLastPage ? (\n <span className={styles[\"last-page\"]} aria-current=\"page\">\n {page}\n </span>\n ) : (\n <Link\n size=\"small\"\n role=\"button\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n tabIndex={0}\n >\n {page}\n </Link>\n )}\n </li>\n );\n}\n"],"names":["jsxs","styles","jsx","IconButton","Link"],"mappings":";;;;;;;;AAuCO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAiC;AAE7B,SAAAA,gCAAC,SAAI,WAAW,WAAWC,0BAAO,YAAY,SAAS,GAAI,GAAG,OAC5D,UAAA;AAAA,IAAAC,2BAAA;AAAA,MAACC,WAAA;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,MAAK;AAAA,QACL,cAAY;AAAA,QACZ,SAAS;AAAA,QAET,yCAAC,SAAQ,CAAA,CAAA;AAAA,MAAA;AAAA,IACX;AAAA,IACAD,2BAAAA,IAAC,QAAG,WAAWD,kBAAA,QAAO,OACnB,UAAM,MAAA,IAAI,CAAC,MAAM,UAChBC,2BAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC;AAAA,QACA,YAAY,UAAU,MAAM,SAAS;AAAA,QACrC,SAAS,MAAM,YAAY,MAAM,KAAK;AAAA,MAAA;AAAA,MAHjC;AAAA,IAAA,CAKR,EACH,CAAA;AAAA,EAAA,GACF;AAEJ;AAqBA,SAAS,KAAK,EAAE,MAAM,YAAY,WAAmC;AAC7D,QAAA,YAAY,CAAC,UAA4C;AACzD,QAAA,MAAM,QAAQ,KAAK;AACb,cAAA;AAAA,IAAA;AAAA,EAEZ;AAEA,SACGA,2BAAAA,IAAA,MAAA,EACE,UACC,aAAAA,2BAAAA,IAAC,QAAK,EAAA,WAAWD,kBAAAA,QAAO,WAAW,GAAG,gBAAa,QAChD,UAAA,KACH,CAAA,IAEAC,2BAAA;AAAA,IAACE,KAAA;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MAET,UAAA;AAAA,IAAA;AAAA,EAAA,GAGP;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumb.js","sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { HTMLProps, JSX, MouseEventHandler, KeyboardEvent } from \"react\";\nimport { IconButton } from \"../Button\";\nimport Chevron from \"@vector-im/compound-design-tokens/assets/web/icons/chevron-left\";\nimport styles from \"./Breadcrumb.module.css\";\nimport { Link } from \"../Link/Link.tsx\";\nimport classNames from \"classnames\";\n\ninterface BreadcrumbProps extends HTMLProps<HTMLElement> {\n /**\n * The label for the back button.\n */\n backLabel: string;\n /**\n * The click handler for the back button.\n */\n onBackClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * The pages to display in the breadcrumb.\n * All the pages except the last one are displayed as links.\n */\n pages: string[];\n /**\n * The click handler for a page.\n * @param page - The page that was clicked.\n * @param index - The index of the page that was clicked.\n */\n onPageClick: (page: string, index: number) => void;\n}\n\n/**\n * A breadcrumb component.\n */\nexport function Breadcrumb({\n backLabel,\n onBackClick,\n pages,\n onPageClick,\n className,\n ...props\n}: BreadcrumbProps): JSX.Element {\n return (\n <nav className={classNames(styles.breadcrumb, className)} {...props}>\n <IconButton\n
|
|
1
|
+
{"version":3,"file":"Breadcrumb.js","sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { HTMLProps, JSX, MouseEventHandler, KeyboardEvent } from \"react\";\nimport { IconButton } from \"../Button\";\nimport Chevron from \"@vector-im/compound-design-tokens/assets/web/icons/chevron-left\";\nimport styles from \"./Breadcrumb.module.css\";\nimport { Link } from \"../Link/Link.tsx\";\nimport classNames from \"classnames\";\n\ninterface BreadcrumbProps extends HTMLProps<HTMLElement> {\n /**\n * The label for the back button.\n */\n backLabel: string;\n /**\n * The click handler for the back button.\n */\n onBackClick: MouseEventHandler<HTMLButtonElement>;\n /**\n * The pages to display in the breadcrumb.\n * All the pages except the last one are displayed as links.\n */\n pages: string[];\n /**\n * The click handler for a page.\n * @param page - The page that was clicked.\n * @param index - The index of the page that was clicked.\n */\n onPageClick: (page: string, index: number) => void;\n}\n\n/**\n * A breadcrumb component.\n */\nexport function Breadcrumb({\n backLabel,\n onBackClick,\n pages,\n onPageClick,\n className,\n ...props\n}: BreadcrumbProps): JSX.Element {\n return (\n <nav className={classNames(styles.breadcrumb, className)} {...props}>\n <IconButton\n kind=\"secondary\"\n size=\"28px\"\n aria-label={backLabel}\n onClick={onBackClick}\n >\n <Chevron />\n </IconButton>\n <ol className={styles.pages}>\n {pages.map((page, index) => (\n <Page\n key={index}\n page={page}\n isLastPage={index === pages.length - 1}\n onClick={() => onPageClick(page, index)}\n />\n ))}\n </ol>\n </nav>\n );\n}\n\ninterface PageProps {\n /**\n * The page to display.\n */\n page: string;\n /**\n * Whether this is the last page in the breadcrumb.\n */\n isLastPage: boolean;\n /**\n * The click handler for the page, ignore for last page.\n */\n onClick: () => void;\n}\n\n/**\n * A breadcrumb page.\n * If not the last page, the page is displayed in a link.\n */\nfunction Page({ page, isLastPage, onClick }: PageProps): JSX.Element {\n const onKeyDown = (event: KeyboardEvent<HTMLAnchorElement>) => {\n if (event.key === \" \") {\n onClick();\n }\n };\n\n return (\n <li>\n {isLastPage ? (\n <span className={styles[\"last-page\"]} aria-current=\"page\">\n {page}\n </span>\n ) : (\n <Link\n size=\"small\"\n role=\"button\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n tabIndex={0}\n >\n {page}\n </Link>\n )}\n </li>\n );\n}\n"],"names":[],"mappings":";;;;;;AAuCO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAiC;AAE7B,SAAA,qBAAC,SAAI,WAAW,WAAW,OAAO,YAAY,SAAS,GAAI,GAAG,OAC5D,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,MAAK;AAAA,QACL,cAAY;AAAA,QACZ,SAAS;AAAA,QAET,8BAAC,SAAQ,CAAA,CAAA;AAAA,MAAA;AAAA,IACX;AAAA,IACA,oBAAC,QAAG,WAAW,OAAO,OACnB,UAAM,MAAA,IAAI,CAAC,MAAM,UAChB;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC;AAAA,QACA,YAAY,UAAU,MAAM,SAAS;AAAA,QACrC,SAAS,MAAM,YAAY,MAAM,KAAK;AAAA,MAAA;AAAA,MAHjC;AAAA,IAAA,CAKR,EACH,CAAA;AAAA,EAAA,GACF;AAEJ;AAqBA,SAAS,KAAK,EAAE,MAAM,YAAY,WAAmC;AAC7D,QAAA,YAAY,CAAC,UAA4C;AACzD,QAAA,MAAM,QAAQ,KAAK;AACb,cAAA;AAAA,IAAA;AAAA,EAEZ;AAEA,SACG,oBAAA,MAAA,EACE,UACC,aAAA,oBAAC,QAAK,EAAA,WAAW,OAAO,WAAW,GAAG,gBAAa,QAChD,UAAA,KACH,CAAA,IAEA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MAET,UAAA;AAAA,IAAA;AAAA,EAAA,GAGP;AAEJ;"}
|
|
@@ -8,6 +8,7 @@ const UnstyledButton = require("../UnstyledButton.cjs");
|
|
|
8
8
|
const IndicatorIcon = require("../../Icon/IndicatorIcon/IndicatorIcon.cjs");
|
|
9
9
|
const Tooltip = require("../../Tooltip/Tooltip.cjs");
|
|
10
10
|
const IconButton = React.forwardRef(function IconButton2({
|
|
11
|
+
kind = "primary",
|
|
11
12
|
children,
|
|
12
13
|
className,
|
|
13
14
|
indicator,
|
|
@@ -16,12 +17,12 @@ const IconButton = React.forwardRef(function IconButton2({
|
|
|
16
17
|
disabled,
|
|
17
18
|
destructive,
|
|
18
19
|
tooltip,
|
|
19
|
-
|
|
20
|
+
noBackground = false,
|
|
20
21
|
...props
|
|
21
22
|
}, ref) {
|
|
22
23
|
const classes = classNames(IconButton_module.default["icon-button"], className, {
|
|
23
24
|
[IconButton_module.default.destructive]: destructive,
|
|
24
|
-
[IconButton_module.default["
|
|
25
|
+
[IconButton_module.default["no-background"]]: noBackground
|
|
25
26
|
});
|
|
26
27
|
const button = /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
28
|
UnstyledButton.UnstyledButton,
|
|
@@ -36,6 +37,7 @@ const IconButton = React.forwardRef(function IconButton2({
|
|
|
36
37
|
disabled,
|
|
37
38
|
...props,
|
|
38
39
|
"data-indicator": indicator,
|
|
40
|
+
"data-kind": kind,
|
|
39
41
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
42
|
IndicatorIcon.IndicatorIcon,
|
|
41
43
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.cjs","sources":["../../../../src/components/Button/IconButton/IconButton.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { PropsWithChildren, forwardRef } from \"react\";\nimport classnames from \"classnames\";\n\nimport styles from \"./IconButton.module.css\";\nimport { UnstyledButton, UnstyledButtonPropsFor } from \"../UnstyledButton\";\nimport { IndicatorIcon } from \"../../Icon/IndicatorIcon/IndicatorIcon\";\nimport { Tooltip } from \"../../Tooltip/Tooltip\";\n\ntype IconButtonProps = UnstyledButtonPropsFor<\"button\"> & {\n /**\n * The CSS class name.\n */\n className?: string;\n /**\n * The size of the button in CSS units, e.g. `\"24px\"`.\n * Note that this is the size of the *button* itself: the icon will be 0.75 * this size\n * @default 32px\n */\n size?: CSSStyleDeclaration[\"height\"];\n /**\n * The icon button indicator dot displayed on the top right\n * As in IndicatorIcon\n */\n indicator?: \"default\" | \"success\" | \"critical\";\n /**\n * Whether the button is interactable\n */\n disabled?: boolean;\n /**\n * Whether this button triggers a destructive action.\n * @default false\n */\n destructive?: boolean;\n /**\n * Optional tooltip for the button\n */\n tooltip?: string;\n
|
|
1
|
+
{"version":3,"file":"IconButton.cjs","sources":["../../../../src/components/Button/IconButton/IconButton.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { PropsWithChildren, forwardRef } from \"react\";\nimport classnames from \"classnames\";\n\nimport styles from \"./IconButton.module.css\";\nimport { UnstyledButton, UnstyledButtonPropsFor } from \"../UnstyledButton\";\nimport { IndicatorIcon } from \"../../Icon/IndicatorIcon/IndicatorIcon\";\nimport { Tooltip } from \"../../Tooltip/Tooltip\";\n\ntype IconButtonProps = UnstyledButtonPropsFor<\"button\"> & {\n /**\n * The type of button.\n * @default \"primary\"\n */\n kind?: \"primary\" | \"secondary\";\n /**\n * The CSS class name.\n */\n className?: string;\n /**\n * The size of the button in CSS units, e.g. `\"24px\"`.\n * Note that this is the size of the *button* itself: the icon will be 0.75 * this size\n * @default 32px\n */\n size?: CSSStyleDeclaration[\"height\"];\n /**\n * The icon button indicator dot displayed on the top right\n * As in IndicatorIcon\n */\n indicator?: \"default\" | \"success\" | \"critical\";\n /**\n * Whether the button is interactable\n */\n disabled?: boolean;\n /**\n * Whether this button triggers a destructive action.\n * @default false\n */\n destructive?: boolean;\n /**\n * Optional tooltip for the button\n */\n tooltip?: string;\n /**\n * Hide the background when the button is not active or hovered.\n * @default false\n */\n noBackground?: boolean;\n};\n\n/**\n * Display an icon as a button. Can render an indicator\n */\nexport const IconButton = forwardRef<\n HTMLButtonElement,\n PropsWithChildren<IconButtonProps>\n>(function IconButton(\n {\n kind = \"primary\",\n children,\n className,\n indicator,\n size = \"32px\",\n style,\n disabled,\n destructive,\n tooltip,\n noBackground = false,\n ...props\n },\n ref,\n) {\n const classes = classnames(styles[\"icon-button\"], className, {\n [styles.destructive]: destructive,\n [styles[\"no-background\"]]: noBackground,\n });\n\n const button = (\n <UnstyledButton\n as=\"button\"\n ref={ref}\n className={classes}\n style={\n {\n \"--cpd-icon-button-size\": size,\n ...style,\n } as React.CSSProperties\n }\n disabled={disabled}\n {...props}\n data-indicator={indicator}\n data-kind={kind}\n >\n <IndicatorIcon\n indicator={indicator}\n colour={disabled ? \"var(--cpd-color-icon-disabled)\" : undefined}\n >\n {React.Children.only(children)}\n </IndicatorIcon>\n </UnstyledButton>\n );\n\n return tooltip ? <Tooltip label={tooltip}>{button}</Tooltip> : button;\n});\n"],"names":["forwardRef","IconButton","classnames","styles","jsx","UnstyledButton","IndicatorIcon","Tooltip"],"mappings":";;;;;;;;;AA2Da,MAAA,aAAaA,MAAAA,WAGxB,SAASC,YACT;AAAA,EACE,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,GAAG;AACL,GACA,KACA;AACA,QAAM,UAAUC,WAAWC,kBAAO,QAAA,aAAa,GAAG,WAAW;AAAA,IAC3D,CAACA,kBAAAA,QAAO,WAAW,GAAG;AAAA,IACtB,CAACA,kBAAAA,QAAO,eAAe,CAAC,GAAG;AAAA,EAAA,CAC5B;AAED,QAAM,SACJC,2BAAA;AAAA,IAACC,eAAA;AAAA,IAAA;AAAA,MACC,IAAG;AAAA,MACH;AAAA,MACA,WAAW;AAAA,MACX,OACE;AAAA,QACE,0BAA0B;AAAA,QAC1B,GAAG;AAAA,MACL;AAAA,MAEF;AAAA,MACC,GAAG;AAAA,MACJ,kBAAgB;AAAA,MAChB,aAAW;AAAA,MAEX,UAAAD,2BAAA;AAAA,QAACE,cAAA;AAAA,QAAA;AAAA,UACC;AAAA,UACA,QAAQ,WAAW,mCAAmC;AAAA,UAErD,UAAA,MAAM,SAAS,KAAK,QAAQ;AAAA,QAAA;AAAA,MAAA;AAAA,IAC/B;AAAA,EACF;AAGF,SAAO,UAAWF,+BAAAG,QAAAA,SAAA,EAAQ,OAAO,SAAU,iBAAO,CAAA,IAAa;AACjE,CAAC;;"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { UnstyledButtonPropsFor } from '../UnstyledButton';
|
|
3
3
|
type IconButtonProps = UnstyledButtonPropsFor<"button"> & {
|
|
4
|
+
/**
|
|
5
|
+
* The type of button.
|
|
6
|
+
* @default "primary"
|
|
7
|
+
*/
|
|
8
|
+
kind?: "primary" | "secondary";
|
|
4
9
|
/**
|
|
5
10
|
* The CSS class name.
|
|
6
11
|
*/
|
|
@@ -29,7 +34,11 @@ type IconButtonProps = UnstyledButtonPropsFor<"button"> & {
|
|
|
29
34
|
* Optional tooltip for the button
|
|
30
35
|
*/
|
|
31
36
|
tooltip?: string;
|
|
32
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Hide the background when the button is not active or hovered.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
noBackground?: boolean;
|
|
33
42
|
};
|
|
34
43
|
/**
|
|
35
44
|
* Display an icon as a button. Can render an indicator
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/IconButton/IconButton.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAkB,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAI3E,KAAK,eAAe,GAAG,sBAAsB,CAAC,QAAQ,CAAC,GAAG;IACxD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;IAC/C;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/IconButton/IconButton.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAkB,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAI3E,KAAK,eAAe,GAAG,sBAAsB,CAAC,QAAQ,CAAC,GAAG;IACxD;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;IAC/C;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,iIAkDrB,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { UnstyledButton } from "../UnstyledButton.js";
|
|
|
6
6
|
import { IndicatorIcon } from "../../Icon/IndicatorIcon/IndicatorIcon.js";
|
|
7
7
|
import { Tooltip } from "../../Tooltip/Tooltip.js";
|
|
8
8
|
const IconButton = forwardRef(function IconButton2({
|
|
9
|
+
kind = "primary",
|
|
9
10
|
children,
|
|
10
11
|
className,
|
|
11
12
|
indicator,
|
|
@@ -14,12 +15,12 @@ const IconButton = forwardRef(function IconButton2({
|
|
|
14
15
|
disabled,
|
|
15
16
|
destructive,
|
|
16
17
|
tooltip,
|
|
17
|
-
|
|
18
|
+
noBackground = false,
|
|
18
19
|
...props
|
|
19
20
|
}, ref) {
|
|
20
21
|
const classes = classNames(styles["icon-button"], className, {
|
|
21
22
|
[styles.destructive]: destructive,
|
|
22
|
-
[styles["
|
|
23
|
+
[styles["no-background"]]: noBackground
|
|
23
24
|
});
|
|
24
25
|
const button = /* @__PURE__ */ jsx(
|
|
25
26
|
UnstyledButton,
|
|
@@ -34,6 +35,7 @@ const IconButton = forwardRef(function IconButton2({
|
|
|
34
35
|
disabled,
|
|
35
36
|
...props,
|
|
36
37
|
"data-indicator": indicator,
|
|
38
|
+
"data-kind": kind,
|
|
37
39
|
children: /* @__PURE__ */ jsx(
|
|
38
40
|
IndicatorIcon,
|
|
39
41
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","sources":["../../../../src/components/Button/IconButton/IconButton.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { PropsWithChildren, forwardRef } from \"react\";\nimport classnames from \"classnames\";\n\nimport styles from \"./IconButton.module.css\";\nimport { UnstyledButton, UnstyledButtonPropsFor } from \"../UnstyledButton\";\nimport { IndicatorIcon } from \"../../Icon/IndicatorIcon/IndicatorIcon\";\nimport { Tooltip } from \"../../Tooltip/Tooltip\";\n\ntype IconButtonProps = UnstyledButtonPropsFor<\"button\"> & {\n /**\n * The CSS class name.\n */\n className?: string;\n /**\n * The size of the button in CSS units, e.g. `\"24px\"`.\n * Note that this is the size of the *button* itself: the icon will be 0.75 * this size\n * @default 32px\n */\n size?: CSSStyleDeclaration[\"height\"];\n /**\n * The icon button indicator dot displayed on the top right\n * As in IndicatorIcon\n */\n indicator?: \"default\" | \"success\" | \"critical\";\n /**\n * Whether the button is interactable\n */\n disabled?: boolean;\n /**\n * Whether this button triggers a destructive action.\n * @default false\n */\n destructive?: boolean;\n /**\n * Optional tooltip for the button\n */\n tooltip?: string;\n
|
|
1
|
+
{"version":3,"file":"IconButton.js","sources":["../../../../src/components/Button/IconButton/IconButton.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { PropsWithChildren, forwardRef } from \"react\";\nimport classnames from \"classnames\";\n\nimport styles from \"./IconButton.module.css\";\nimport { UnstyledButton, UnstyledButtonPropsFor } from \"../UnstyledButton\";\nimport { IndicatorIcon } from \"../../Icon/IndicatorIcon/IndicatorIcon\";\nimport { Tooltip } from \"../../Tooltip/Tooltip\";\n\ntype IconButtonProps = UnstyledButtonPropsFor<\"button\"> & {\n /**\n * The type of button.\n * @default \"primary\"\n */\n kind?: \"primary\" | \"secondary\";\n /**\n * The CSS class name.\n */\n className?: string;\n /**\n * The size of the button in CSS units, e.g. `\"24px\"`.\n * Note that this is the size of the *button* itself: the icon will be 0.75 * this size\n * @default 32px\n */\n size?: CSSStyleDeclaration[\"height\"];\n /**\n * The icon button indicator dot displayed on the top right\n * As in IndicatorIcon\n */\n indicator?: \"default\" | \"success\" | \"critical\";\n /**\n * Whether the button is interactable\n */\n disabled?: boolean;\n /**\n * Whether this button triggers a destructive action.\n * @default false\n */\n destructive?: boolean;\n /**\n * Optional tooltip for the button\n */\n tooltip?: string;\n /**\n * Hide the background when the button is not active or hovered.\n * @default false\n */\n noBackground?: boolean;\n};\n\n/**\n * Display an icon as a button. Can render an indicator\n */\nexport const IconButton = forwardRef<\n HTMLButtonElement,\n PropsWithChildren<IconButtonProps>\n>(function IconButton(\n {\n kind = \"primary\",\n children,\n className,\n indicator,\n size = \"32px\",\n style,\n disabled,\n destructive,\n tooltip,\n noBackground = false,\n ...props\n },\n ref,\n) {\n const classes = classnames(styles[\"icon-button\"], className, {\n [styles.destructive]: destructive,\n [styles[\"no-background\"]]: noBackground,\n });\n\n const button = (\n <UnstyledButton\n as=\"button\"\n ref={ref}\n className={classes}\n style={\n {\n \"--cpd-icon-button-size\": size,\n ...style,\n } as React.CSSProperties\n }\n disabled={disabled}\n {...props}\n data-indicator={indicator}\n data-kind={kind}\n >\n <IndicatorIcon\n indicator={indicator}\n colour={disabled ? \"var(--cpd-color-icon-disabled)\" : undefined}\n >\n {React.Children.only(children)}\n </IndicatorIcon>\n </UnstyledButton>\n );\n\n return tooltip ? <Tooltip label={tooltip}>{button}</Tooltip> : button;\n});\n"],"names":["IconButton","classnames"],"mappings":";;;;;;;AA2Da,MAAA,aAAa,WAGxB,SAASA,YACT;AAAA,EACE,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,GAAG;AACL,GACA,KACA;AACA,QAAM,UAAUC,WAAW,OAAO,aAAa,GAAG,WAAW;AAAA,IAC3D,CAAC,OAAO,WAAW,GAAG;AAAA,IACtB,CAAC,OAAO,eAAe,CAAC,GAAG;AAAA,EAAA,CAC5B;AAED,QAAM,SACJ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAG;AAAA,MACH;AAAA,MACA,WAAW;AAAA,MACX,OACE;AAAA,QACE,0BAA0B;AAAA,QAC1B,GAAG;AAAA,MACL;AAAA,MAEF;AAAA,MACC,GAAG;AAAA,MACJ,kBAAgB;AAAA,MAChB,aAAW;AAAA,MAEX,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,QAAQ,WAAW,mCAAmC;AAAA,UAErD,UAAA,MAAM,SAAS,KAAK,QAAQ;AAAA,QAAA;AAAA,MAAA;AAAA,IAC/B;AAAA,EACF;AAGF,SAAO,UAAW,oBAAA,SAAA,EAAQ,OAAO,SAAU,iBAAO,CAAA,IAAa;AACjE,CAAC;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const destructive = "
|
|
3
|
+
const destructive = "_destructive_1pz9o_95";
|
|
4
4
|
const styles = {
|
|
5
|
-
"icon-button": "_icon-
|
|
6
|
-
"
|
|
5
|
+
"icon-button": "_icon-button_1pz9o_8",
|
|
6
|
+
"no-background": "_no-background_1pz9o_42",
|
|
7
7
|
destructive
|
|
8
8
|
};
|
|
9
9
|
exports.default = styles;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const destructive = "
|
|
1
|
+
const destructive = "_destructive_1pz9o_95";
|
|
2
2
|
const styles = {
|
|
3
|
-
"icon-button": "_icon-
|
|
4
|
-
"
|
|
3
|
+
"icon-button": "_icon-button_1pz9o_8",
|
|
4
|
+
"no-background": "_no-background_1pz9o_42",
|
|
5
5
|
destructive
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
@@ -16,6 +16,7 @@ const ContextMenuItemWrapper = ({
|
|
|
16
16
|
}) => /* @__PURE__ */ jsxRuntime.jsx(reactContextMenu.ContextMenuItem, { onSelect: onSelect ?? void 0, asChild: true, children });
|
|
17
17
|
const ContextMenu = ({
|
|
18
18
|
title,
|
|
19
|
+
showTitle = true,
|
|
19
20
|
onOpenChange: onOpenChangeProp,
|
|
20
21
|
trigger: triggerProp,
|
|
21
22
|
hasAccessibleAlternative,
|
|
@@ -56,7 +57,7 @@ const ContextMenu = ({
|
|
|
56
57
|
] }) })
|
|
57
58
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(reactContextMenu.Root, { onOpenChange, children: [
|
|
58
59
|
trigger,
|
|
59
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactContextMenu.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(reactContextMenu.Content, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FloatingMenu.FloatingMenu, { title, children }) }) })
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactContextMenu.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(reactContextMenu.Content, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(FloatingMenu.FloatingMenu, { showTitle, title, children }) }) })
|
|
60
61
|
] });
|
|
61
62
|
};
|
|
62
63
|
exports.ContextMenu = ContextMenu;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.cjs","sources":["../../../src/components/Menu/ContextMenu.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { FC, ReactNode, useCallback, useMemo, useState } from \"react\";\nimport {\n Root,\n Trigger,\n Portal,\n Content,\n ContextMenuItem,\n} from \"@radix-ui/react-context-menu\";\nimport { FloatingMenu } from \"./FloatingMenu\";\nimport { Drawer } from \"vaul\";\nimport classnames from \"classnames\";\nimport drawerStyles from \"./DrawerMenu.module.css\";\nimport { MenuContext, MenuData, MenuItemWrapperProps } from \"./MenuContext\";\nimport { DrawerMenu } from \"./DrawerMenu\";\nimport { getPlatform } from \"../../utils/platform\";\n\ninterface Props {\n /**\n * The menu title.\n */\n title: string;\n /**\n * Event handler called when the open state of the menu changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger that can be right-clicked or long-pressed to open the menu.\n * This must be a component that accepts a ref and spreads props.\n * https://www.radix-ui.com/primitives/docs/guides/composition\n */\n trigger: ReactNode;\n /**\n * Whether the functionality of this menu is available through some other\n * keyboard-accessible means. Preferably this should be true, because context\n * menus are potentially difficult to discover, but if false the trigger will\n * become focusable so that it can be opened via keyboard navigation.\n */\n hasAccessibleAlternative: boolean;\n /**\n * The menu contents.\n */\n children: ReactNode;\n}\n\nconst ContextMenuItemWrapper: FC<MenuItemWrapperProps> = ({\n onSelect,\n children,\n}) => (\n <ContextMenuItem onSelect={onSelect ?? undefined} asChild>\n {children}\n </ContextMenuItem>\n);\n\n/**\n * A menu opened by right-clicking or long-pressing another UI element.\n */\nexport const ContextMenu: FC<Props> = ({\n title,\n onOpenChange: onOpenChangeProp,\n trigger: triggerProp,\n hasAccessibleAlternative,\n children: childrenProp,\n}) => {\n const [open, setOpen] = useState(false);\n const onOpenChange = useCallback(\n (value: boolean) => {\n setOpen(value);\n onOpenChangeProp?.(value);\n },\n [setOpen, onOpenChangeProp],\n );\n\n // Normally, the menu takes the form of a floating box. But on Android and\n // iOS, the menu should morph into a drawer\n const platform = getPlatform();\n const drawer = platform === \"android\" || platform === \"ios\";\n const context: MenuData = useMemo(\n () => ({\n MenuItemWrapper: drawer ? null : ContextMenuItemWrapper,\n onOpenChange,\n }),\n [onOpenChange],\n );\n const children = (\n <MenuContext.Provider value={context}>{childrenProp}</MenuContext.Provider>\n );\n\n const trigger = (\n <Trigger\n aria-haspopup=\"menu\"\n tabIndex={hasAccessibleAlternative ? undefined : 0}\n asChild\n >\n {triggerProp}\n </Trigger>\n );\n\n // This is a small hack: Vaul drawers only support buttons as triggers, so\n // we end up mounting an empty Radix context menu tree alongside the\n // drawer tree, purely so we can use its Trigger component (which supports\n // touch for free). The resulting behavior and DOM tree looks exactly the\n // same as if Vaul provided a long-press trigger of its own, so I think\n // this is fine.\n return drawer ? (\n <>\n <Root onOpenChange={onOpenChange}>{trigger}</Root>\n <Drawer.Root open={open} onOpenChange={onOpenChange}>\n <Drawer.Portal>\n <Drawer.Overlay className={classnames(drawerStyles.bg)} />\n <Drawer.Content asChild>\n <DrawerMenu title={title}>{children}</DrawerMenu>\n </Drawer.Content>\n </Drawer.Portal>\n </Drawer.Root>\n </>\n ) : (\n <Root onOpenChange={onOpenChange}>\n {trigger}\n <Portal>\n <Content asChild>\n <FloatingMenu title={title}
|
|
1
|
+
{"version":3,"file":"ContextMenu.cjs","sources":["../../../src/components/Menu/ContextMenu.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { FC, ReactNode, useCallback, useMemo, useState } from \"react\";\nimport {\n Root,\n Trigger,\n Portal,\n Content,\n ContextMenuItem,\n} from \"@radix-ui/react-context-menu\";\nimport { FloatingMenu } from \"./FloatingMenu\";\nimport { Drawer } from \"vaul\";\nimport classnames from \"classnames\";\nimport drawerStyles from \"./DrawerMenu.module.css\";\nimport { MenuContext, MenuData, MenuItemWrapperProps } from \"./MenuContext\";\nimport { DrawerMenu } from \"./DrawerMenu\";\nimport { getPlatform } from \"../../utils/platform\";\n\ninterface Props {\n /**\n * The menu title.\n */\n title: string;\n /**\n * Wether the title is displayed.\n * @default true\n */\n showTitle?: boolean;\n /**\n * Event handler called when the open state of the menu changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger that can be right-clicked or long-pressed to open the menu.\n * This must be a component that accepts a ref and spreads props.\n * https://www.radix-ui.com/primitives/docs/guides/composition\n */\n trigger: ReactNode;\n /**\n * Whether the functionality of this menu is available through some other\n * keyboard-accessible means. Preferably this should be true, because context\n * menus are potentially difficult to discover, but if false the trigger will\n * become focusable so that it can be opened via keyboard navigation.\n */\n hasAccessibleAlternative: boolean;\n /**\n * The menu contents.\n */\n children: ReactNode;\n}\n\nconst ContextMenuItemWrapper: FC<MenuItemWrapperProps> = ({\n onSelect,\n children,\n}) => (\n <ContextMenuItem onSelect={onSelect ?? undefined} asChild>\n {children}\n </ContextMenuItem>\n);\n\n/**\n * A menu opened by right-clicking or long-pressing another UI element.\n */\nexport const ContextMenu: FC<Props> = ({\n title,\n showTitle = true,\n onOpenChange: onOpenChangeProp,\n trigger: triggerProp,\n hasAccessibleAlternative,\n children: childrenProp,\n}) => {\n const [open, setOpen] = useState(false);\n const onOpenChange = useCallback(\n (value: boolean) => {\n setOpen(value);\n onOpenChangeProp?.(value);\n },\n [setOpen, onOpenChangeProp],\n );\n\n // Normally, the menu takes the form of a floating box. But on Android and\n // iOS, the menu should morph into a drawer\n const platform = getPlatform();\n const drawer = platform === \"android\" || platform === \"ios\";\n const context: MenuData = useMemo(\n () => ({\n MenuItemWrapper: drawer ? null : ContextMenuItemWrapper,\n onOpenChange,\n }),\n [onOpenChange],\n );\n const children = (\n <MenuContext.Provider value={context}>{childrenProp}</MenuContext.Provider>\n );\n\n const trigger = (\n <Trigger\n aria-haspopup=\"menu\"\n tabIndex={hasAccessibleAlternative ? undefined : 0}\n asChild\n >\n {triggerProp}\n </Trigger>\n );\n\n // This is a small hack: Vaul drawers only support buttons as triggers, so\n // we end up mounting an empty Radix context menu tree alongside the\n // drawer tree, purely so we can use its Trigger component (which supports\n // touch for free). The resulting behavior and DOM tree looks exactly the\n // same as if Vaul provided a long-press trigger of its own, so I think\n // this is fine.\n return drawer ? (\n <>\n <Root onOpenChange={onOpenChange}>{trigger}</Root>\n <Drawer.Root open={open} onOpenChange={onOpenChange}>\n <Drawer.Portal>\n <Drawer.Overlay className={classnames(drawerStyles.bg)} />\n <Drawer.Content asChild>\n <DrawerMenu title={title}>{children}</DrawerMenu>\n </Drawer.Content>\n </Drawer.Portal>\n </Drawer.Root>\n </>\n ) : (\n <Root onOpenChange={onOpenChange}>\n {trigger}\n <Portal>\n <Content asChild>\n <FloatingMenu showTitle={showTitle} title={title}>\n {children}\n </FloatingMenu>\n </Content>\n </Portal>\n </Root>\n );\n};\n"],"names":["ContextMenuItem","useState","useCallback","platform","getPlatform","useMemo","jsx","MenuContext","Trigger","jsxs","Fragment","Root","Drawer","classnames","drawerStyles","DrawerMenu","Portal","Content","FloatingMenu"],"mappings":";;;;;;;;;;;;AAwDA,MAAM,yBAAmD,CAAC;AAAA,EACxD;AAAA,EACA;AACF,qCACGA,kCAAgB,EAAA,UAAU,YAAY,QAAW,SAAO,MACtD,UACH;AAMK,MAAM,cAAyB,CAAC;AAAA,EACrC;AAAA,EACA,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,SAAS;AAAA,EACT;AAAA,EACA,UAAU;AACZ,MAAM;AACJ,QAAM,CAAC,MAAM,OAAO,IAAIC,MAAAA,SAAS,KAAK;AACtC,QAAM,eAAeC,MAAA;AAAA,IACnB,CAAC,UAAmB;AAClB,cAAQ,KAAK;AACb,yBAAmB,KAAK;AAAA,IAC1B;AAAA,IACA,CAAC,SAAS,gBAAgB;AAAA,EAC5B;AAIA,QAAMC,aAAWC,SAAAA,YAAY;AACvB,QAAA,SAASD,eAAa,aAAaA,eAAa;AACtD,QAAM,UAAoBE,MAAA;AAAA,IACxB,OAAO;AAAA,MACL,iBAAiB,SAAS,OAAO;AAAA,MACjC;AAAA,IAAA;AAAA,IAEF,CAAC,YAAY;AAAA,EACf;AACA,QAAM,WACHC,+BAAAC,YAAAA,YAAY,UAAZ,EAAqB,OAAO,SAAU,UAAa,cAAA;AAGtD,QAAM,UACJD,2BAAA;AAAA,IAACE,iBAAA;AAAA,IAAA;AAAA,MACC,iBAAc;AAAA,MACd,UAAU,2BAA2B,SAAY;AAAA,MACjD,SAAO;AAAA,MAEN,UAAA;AAAA,IAAA;AAAA,EACH;AASF,SAAO,SAEHC,2BAAAA,KAAAC,WAAA,UAAA,EAAA,UAAA;AAAA,IAACJ,2BAAAA,IAAAK,iBAAAA,MAAA,EAAK,cAA6B,UAAQ,QAAA,CAAA;AAAA,IAC3CL,2BAAAA,IAACM,YAAO,MAAP,EAAY,MAAY,cACvB,UAAAH,gCAACG,KAAAA,OAAO,QAAP,EACC,UAAA;AAAA,MAAAN,+BAACM,KAAAA,OAAO,SAAP,EAAe,WAAWC,WAAWC,kBAAA,QAAa,EAAE,GAAG;AAAA,MACxDR,2BAAAA,IAACM,KAAO,OAAA,SAAP,EAAe,SAAO,MACrB,UAACN,2BAAAA,IAAAS,WAAAA,YAAA,EAAW,OAAe,SAAS,CAAA,EACtC,CAAA;AAAA,IAAA,EAAA,CACF,EACF,CAAA;AAAA,EACF,EAAA,CAAA,IAECN,2BAAA,KAAAE,iBAAA,MAAA,EAAK,cACH,UAAA;AAAA,IAAA;AAAA,IACAL,2BAAA,IAAAU,iBAAA,QAAA,EACC,UAACV,2BAAA,IAAAW,iBAAA,SAAA,EAAQ,SAAO,MACd,UAACX,2BAAA,IAAAY,aAAA,cAAA,EAAa,WAAsB,OACjC,SACH,CAAA,EAAA,CACF,EACF,CAAA;AAAA,EAAA,GACF;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/ContextMenu.tsx"],"names":[],"mappings":"AAOA,OAAc,EAAE,EAAE,EAAE,SAAS,EAAkC,MAAM,OAAO,CAAC;AAgB7E,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;;OAKG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAWD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"ContextMenu.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/ContextMenu.tsx"],"names":[],"mappings":"AAOA,OAAc,EAAE,EAAE,EAAE,SAAS,EAAkC,MAAM,OAAO,CAAC;AAgB7E,UAAU,KAAK;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;;OAKG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAWD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,KAAK,CAwEjC,CAAC"}
|
|
@@ -14,6 +14,7 @@ const ContextMenuItemWrapper = ({
|
|
|
14
14
|
}) => /* @__PURE__ */ jsx(ContextMenuItem, { onSelect: onSelect ?? void 0, asChild: true, children });
|
|
15
15
|
const ContextMenu = ({
|
|
16
16
|
title,
|
|
17
|
+
showTitle = true,
|
|
17
18
|
onOpenChange: onOpenChangeProp,
|
|
18
19
|
trigger: triggerProp,
|
|
19
20
|
hasAccessibleAlternative,
|
|
@@ -54,7 +55,7 @@ const ContextMenu = ({
|
|
|
54
55
|
] }) })
|
|
55
56
|
] }) : /* @__PURE__ */ jsxs(Root, { onOpenChange, children: [
|
|
56
57
|
trigger,
|
|
57
|
-
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Content, { asChild: true, children: /* @__PURE__ */ jsx(FloatingMenu, { title, children }) }) })
|
|
58
|
+
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Content, { asChild: true, children: /* @__PURE__ */ jsx(FloatingMenu, { showTitle, title, children }) }) })
|
|
58
59
|
] });
|
|
59
60
|
};
|
|
60
61
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sources":["../../../src/components/Menu/ContextMenu.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { FC, ReactNode, useCallback, useMemo, useState } from \"react\";\nimport {\n Root,\n Trigger,\n Portal,\n Content,\n ContextMenuItem,\n} from \"@radix-ui/react-context-menu\";\nimport { FloatingMenu } from \"./FloatingMenu\";\nimport { Drawer } from \"vaul\";\nimport classnames from \"classnames\";\nimport drawerStyles from \"./DrawerMenu.module.css\";\nimport { MenuContext, MenuData, MenuItemWrapperProps } from \"./MenuContext\";\nimport { DrawerMenu } from \"./DrawerMenu\";\nimport { getPlatform } from \"../../utils/platform\";\n\ninterface Props {\n /**\n * The menu title.\n */\n title: string;\n /**\n * Event handler called when the open state of the menu changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger that can be right-clicked or long-pressed to open the menu.\n * This must be a component that accepts a ref and spreads props.\n * https://www.radix-ui.com/primitives/docs/guides/composition\n */\n trigger: ReactNode;\n /**\n * Whether the functionality of this menu is available through some other\n * keyboard-accessible means. Preferably this should be true, because context\n * menus are potentially difficult to discover, but if false the trigger will\n * become focusable so that it can be opened via keyboard navigation.\n */\n hasAccessibleAlternative: boolean;\n /**\n * The menu contents.\n */\n children: ReactNode;\n}\n\nconst ContextMenuItemWrapper: FC<MenuItemWrapperProps> = ({\n onSelect,\n children,\n}) => (\n <ContextMenuItem onSelect={onSelect ?? undefined} asChild>\n {children}\n </ContextMenuItem>\n);\n\n/**\n * A menu opened by right-clicking or long-pressing another UI element.\n */\nexport const ContextMenu: FC<Props> = ({\n title,\n onOpenChange: onOpenChangeProp,\n trigger: triggerProp,\n hasAccessibleAlternative,\n children: childrenProp,\n}) => {\n const [open, setOpen] = useState(false);\n const onOpenChange = useCallback(\n (value: boolean) => {\n setOpen(value);\n onOpenChangeProp?.(value);\n },\n [setOpen, onOpenChangeProp],\n );\n\n // Normally, the menu takes the form of a floating box. But on Android and\n // iOS, the menu should morph into a drawer\n const platform = getPlatform();\n const drawer = platform === \"android\" || platform === \"ios\";\n const context: MenuData = useMemo(\n () => ({\n MenuItemWrapper: drawer ? null : ContextMenuItemWrapper,\n onOpenChange,\n }),\n [onOpenChange],\n );\n const children = (\n <MenuContext.Provider value={context}>{childrenProp}</MenuContext.Provider>\n );\n\n const trigger = (\n <Trigger\n aria-haspopup=\"menu\"\n tabIndex={hasAccessibleAlternative ? undefined : 0}\n asChild\n >\n {triggerProp}\n </Trigger>\n );\n\n // This is a small hack: Vaul drawers only support buttons as triggers, so\n // we end up mounting an empty Radix context menu tree alongside the\n // drawer tree, purely so we can use its Trigger component (which supports\n // touch for free). The resulting behavior and DOM tree looks exactly the\n // same as if Vaul provided a long-press trigger of its own, so I think\n // this is fine.\n return drawer ? (\n <>\n <Root onOpenChange={onOpenChange}>{trigger}</Root>\n <Drawer.Root open={open} onOpenChange={onOpenChange}>\n <Drawer.Portal>\n <Drawer.Overlay className={classnames(drawerStyles.bg)} />\n <Drawer.Content asChild>\n <DrawerMenu title={title}>{children}</DrawerMenu>\n </Drawer.Content>\n </Drawer.Portal>\n </Drawer.Root>\n </>\n ) : (\n <Root onOpenChange={onOpenChange}>\n {trigger}\n <Portal>\n <Content asChild>\n <FloatingMenu title={title}
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sources":["../../../src/components/Menu/ContextMenu.tsx"],"sourcesContent":["/*\nCopyright 2023 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { FC, ReactNode, useCallback, useMemo, useState } from \"react\";\nimport {\n Root,\n Trigger,\n Portal,\n Content,\n ContextMenuItem,\n} from \"@radix-ui/react-context-menu\";\nimport { FloatingMenu } from \"./FloatingMenu\";\nimport { Drawer } from \"vaul\";\nimport classnames from \"classnames\";\nimport drawerStyles from \"./DrawerMenu.module.css\";\nimport { MenuContext, MenuData, MenuItemWrapperProps } from \"./MenuContext\";\nimport { DrawerMenu } from \"./DrawerMenu\";\nimport { getPlatform } from \"../../utils/platform\";\n\ninterface Props {\n /**\n * The menu title.\n */\n title: string;\n /**\n * Wether the title is displayed.\n * @default true\n */\n showTitle?: boolean;\n /**\n * Event handler called when the open state of the menu changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger that can be right-clicked or long-pressed to open the menu.\n * This must be a component that accepts a ref and spreads props.\n * https://www.radix-ui.com/primitives/docs/guides/composition\n */\n trigger: ReactNode;\n /**\n * Whether the functionality of this menu is available through some other\n * keyboard-accessible means. Preferably this should be true, because context\n * menus are potentially difficult to discover, but if false the trigger will\n * become focusable so that it can be opened via keyboard navigation.\n */\n hasAccessibleAlternative: boolean;\n /**\n * The menu contents.\n */\n children: ReactNode;\n}\n\nconst ContextMenuItemWrapper: FC<MenuItemWrapperProps> = ({\n onSelect,\n children,\n}) => (\n <ContextMenuItem onSelect={onSelect ?? undefined} asChild>\n {children}\n </ContextMenuItem>\n);\n\n/**\n * A menu opened by right-clicking or long-pressing another UI element.\n */\nexport const ContextMenu: FC<Props> = ({\n title,\n showTitle = true,\n onOpenChange: onOpenChangeProp,\n trigger: triggerProp,\n hasAccessibleAlternative,\n children: childrenProp,\n}) => {\n const [open, setOpen] = useState(false);\n const onOpenChange = useCallback(\n (value: boolean) => {\n setOpen(value);\n onOpenChangeProp?.(value);\n },\n [setOpen, onOpenChangeProp],\n );\n\n // Normally, the menu takes the form of a floating box. But on Android and\n // iOS, the menu should morph into a drawer\n const platform = getPlatform();\n const drawer = platform === \"android\" || platform === \"ios\";\n const context: MenuData = useMemo(\n () => ({\n MenuItemWrapper: drawer ? null : ContextMenuItemWrapper,\n onOpenChange,\n }),\n [onOpenChange],\n );\n const children = (\n <MenuContext.Provider value={context}>{childrenProp}</MenuContext.Provider>\n );\n\n const trigger = (\n <Trigger\n aria-haspopup=\"menu\"\n tabIndex={hasAccessibleAlternative ? undefined : 0}\n asChild\n >\n {triggerProp}\n </Trigger>\n );\n\n // This is a small hack: Vaul drawers only support buttons as triggers, so\n // we end up mounting an empty Radix context menu tree alongside the\n // drawer tree, purely so we can use its Trigger component (which supports\n // touch for free). The resulting behavior and DOM tree looks exactly the\n // same as if Vaul provided a long-press trigger of its own, so I think\n // this is fine.\n return drawer ? (\n <>\n <Root onOpenChange={onOpenChange}>{trigger}</Root>\n <Drawer.Root open={open} onOpenChange={onOpenChange}>\n <Drawer.Portal>\n <Drawer.Overlay className={classnames(drawerStyles.bg)} />\n <Drawer.Content asChild>\n <DrawerMenu title={title}>{children}</DrawerMenu>\n </Drawer.Content>\n </Drawer.Portal>\n </Drawer.Root>\n </>\n ) : (\n <Root onOpenChange={onOpenChange}>\n {trigger}\n <Portal>\n <Content asChild>\n <FloatingMenu showTitle={showTitle} title={title}>\n {children}\n </FloatingMenu>\n </Content>\n </Portal>\n </Root>\n );\n};\n"],"names":["classnames","drawerStyles"],"mappings":";;;;;;;;;;AAwDA,MAAM,yBAAmD,CAAC;AAAA,EACxD;AAAA,EACA;AACF,0BACG,iBAAgB,EAAA,UAAU,YAAY,QAAW,SAAO,MACtD,UACH;AAMK,MAAM,cAAyB,CAAC;AAAA,EACrC;AAAA,EACA,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,SAAS;AAAA,EACT;AAAA,EACA,UAAU;AACZ,MAAM;AACJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,eAAe;AAAA,IACnB,CAAC,UAAmB;AAClB,cAAQ,KAAK;AACb,yBAAmB,KAAK;AAAA,IAC1B;AAAA,IACA,CAAC,SAAS,gBAAgB;AAAA,EAC5B;AAIA,QAAM,WAAW,YAAY;AACvB,QAAA,SAAS,aAAa,aAAa,aAAa;AACtD,QAAM,UAAoB;AAAA,IACxB,OAAO;AAAA,MACL,iBAAiB,SAAS,OAAO;AAAA,MACjC;AAAA,IAAA;AAAA,IAEF,CAAC,YAAY;AAAA,EACf;AACA,QAAM,WACH,oBAAA,YAAY,UAAZ,EAAqB,OAAO,SAAU,UAAa,cAAA;AAGtD,QAAM,UACJ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,iBAAc;AAAA,MACd,UAAU,2BAA2B,SAAY;AAAA,MACjD,SAAO;AAAA,MAEN,UAAA;AAAA,IAAA;AAAA,EACH;AASF,SAAO,SAEH,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAC,oBAAA,MAAA,EAAK,cAA6B,UAAQ,QAAA,CAAA;AAAA,IAC3C,oBAAC,OAAO,MAAP,EAAY,MAAY,cACvB,UAAA,qBAAC,OAAO,QAAP,EACC,UAAA;AAAA,MAAA,oBAAC,OAAO,SAAP,EAAe,WAAWA,WAAWC,WAAa,EAAE,GAAG;AAAA,MACxD,oBAAC,OAAO,SAAP,EAAe,SAAO,MACrB,UAAC,oBAAA,YAAA,EAAW,OAAe,SAAS,CAAA,EACtC,CAAA;AAAA,IAAA,EAAA,CACF,EACF,CAAA;AAAA,EACF,EAAA,CAAA,IAEC,qBAAA,MAAA,EAAK,cACH,UAAA;AAAA,IAAA;AAAA,IACA,oBAAA,QAAA,EACC,UAAC,oBAAA,SAAA,EAAQ,SAAO,MACd,UAAC,oBAAA,cAAA,EAAa,WAAsB,OACjC,SACH,CAAA,EAAA,CACF,EACF,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
package/dist/style.css.css
CHANGED
|
@@ -247,7 +247,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
247
247
|
Please see LICENSE files in the repository root for full details.
|
|
248
248
|
*/
|
|
249
249
|
|
|
250
|
-
._icon-
|
|
250
|
+
._icon-button_1pz9o_8 {
|
|
251
251
|
--cpd-icon-button-indicator-border-size: calc(
|
|
252
252
|
var(--cpd-icon-button-size) * 0.0625
|
|
253
253
|
);
|
|
@@ -258,7 +258,6 @@ Please see LICENSE files in the repository root for full details.
|
|
|
258
258
|
/* the icon is 0.75 the size of the button, so add padding to put it in the middle */
|
|
259
259
|
padding: calc(var(--cpd-icon-button-size) * 0.125);
|
|
260
260
|
aspect-ratio: 1 / 1;
|
|
261
|
-
color: var(--cpd-color-icon-tertiary);
|
|
262
261
|
border: 0;
|
|
263
262
|
appearance: none;
|
|
264
263
|
cursor: pointer;
|
|
@@ -268,14 +267,30 @@ Please see LICENSE files in the repository root for full details.
|
|
|
268
267
|
line-height: 0px;
|
|
269
268
|
}
|
|
270
269
|
|
|
271
|
-
.
|
|
272
|
-
|
|
270
|
+
._icon-button_1pz9o_8[data-kind="primary"] {
|
|
271
|
+
* {
|
|
272
|
+
color: var(--cpd-color-icon-tertiary);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
._icon-button_1pz9o_8[data-kind="secondary"] {
|
|
273
277
|
background: var(--cpd-color-bg-subtle-secondary);
|
|
278
|
+
|
|
279
|
+
* {
|
|
280
|
+
color: var(--cpd-color-icon-secondary);
|
|
281
|
+
}
|
|
274
282
|
}
|
|
275
283
|
|
|
276
|
-
.
|
|
277
|
-
|
|
284
|
+
._no-background_1pz9o_42[data-kind="secondary"] {
|
|
285
|
+
background: transparent;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
._icon-button_1pz9o_8[aria-disabled="true"] {
|
|
278
289
|
cursor: not-allowed;
|
|
290
|
+
|
|
291
|
+
* {
|
|
292
|
+
color: var(--cpd-color-icon-disabled);
|
|
293
|
+
}
|
|
279
294
|
}
|
|
280
295
|
|
|
281
296
|
/**
|
|
@@ -283,19 +298,25 @@ Please see LICENSE files in the repository root for full details.
|
|
|
283
298
|
*/
|
|
284
299
|
|
|
285
300
|
@media (hover) {
|
|
286
|
-
._icon-
|
|
287
|
-
color: var(--cpd-color-icon-primary);
|
|
301
|
+
._icon-button_1pz9o_8:not([aria-disabled="true"]):hover {
|
|
288
302
|
background: var(--cpd-color-bg-subtle-primary);
|
|
303
|
+
|
|
304
|
+
* {
|
|
305
|
+
color: var(--cpd-color-icon-primary);
|
|
306
|
+
}
|
|
289
307
|
}
|
|
290
308
|
}
|
|
291
309
|
|
|
292
|
-
._icon-
|
|
293
|
-
color: var(--cpd-color-icon-primary);
|
|
310
|
+
._icon-button_1pz9o_8:not([aria-disabled="true"]):active {
|
|
294
311
|
background: var(--cpd-color-bg-subtle-primary);
|
|
312
|
+
|
|
313
|
+
* {
|
|
314
|
+
color: var(--cpd-color-icon-primary);
|
|
315
|
+
}
|
|
295
316
|
}
|
|
296
317
|
|
|
297
318
|
@media (hover) {
|
|
298
|
-
._icon-
|
|
319
|
+
._icon-button_1pz9o_8:not([aria-disabled="true"])[data-indicator]:is(:hover)::before {
|
|
299
320
|
/* Same colour as the background */
|
|
300
321
|
border: var(--cpd-icon-button-indicator-border-size) solid
|
|
301
322
|
var(--cpd-color-bg-subtle-primary);
|
|
@@ -304,7 +325,7 @@ Please see LICENSE files in the repository root for full details.
|
|
|
304
325
|
}
|
|
305
326
|
}
|
|
306
327
|
|
|
307
|
-
._icon-
|
|
328
|
+
._icon-button_1pz9o_8:not([aria-disabled="true"])[data-indicator]:is(:active)::before {
|
|
308
329
|
/* Same colour as the background */
|
|
309
330
|
border: var(--cpd-icon-button-indicator-border-size) solid
|
|
310
331
|
var(--cpd-color-bg-subtle-primary);
|
|
@@ -313,14 +334,16 @@ Please see LICENSE files in the repository root for full details.
|
|
|
313
334
|
}
|
|
314
335
|
|
|
315
336
|
@media (hover) {
|
|
316
|
-
._icon-
|
|
317
|
-
background: var(--cpd-color-bg-critical-subtle);
|
|
337
|
+
._icon-button_1pz9o_8:not([aria-disabled="true"])._destructive_1pz9o_95:hover {
|
|
338
|
+
background: var(--cpd-color-bg-critical-subtle-hovered);
|
|
318
339
|
outline: 1px solid var(--cpd-color-border-critical-subtle);
|
|
319
340
|
}
|
|
320
341
|
}
|
|
321
342
|
|
|
322
|
-
._icon-
|
|
323
|
-
|
|
343
|
+
._icon-button_1pz9o_8:not([aria-disabled="true"])._destructive_1pz9o_95 {
|
|
344
|
+
* {
|
|
345
|
+
color: var(--cpd-color-icon-critical-primary);
|
|
346
|
+
}
|
|
324
347
|
}
|
|
325
348
|
/*
|
|
326
349
|
Copyright 2024 New Vector Ltd.
|
package/package.json
CHANGED
|
@@ -16,7 +16,6 @@ Please see LICENSE files in the repository root for full details.
|
|
|
16
16
|
/* the icon is 0.75 the size of the button, so add padding to put it in the middle */
|
|
17
17
|
padding: calc(var(--cpd-icon-button-size) * 0.125);
|
|
18
18
|
aspect-ratio: 1 / 1;
|
|
19
|
-
color: var(--cpd-color-icon-tertiary);
|
|
20
19
|
border: 0;
|
|
21
20
|
appearance: none;
|
|
22
21
|
cursor: pointer;
|
|
@@ -26,14 +25,30 @@ Please see LICENSE files in the repository root for full details.
|
|
|
26
25
|
line-height: 0px;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
.
|
|
30
|
-
|
|
28
|
+
.icon-button[data-kind="primary"] {
|
|
29
|
+
* {
|
|
30
|
+
color: var(--cpd-color-icon-tertiary);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.icon-button[data-kind="secondary"] {
|
|
31
35
|
background: var(--cpd-color-bg-subtle-secondary);
|
|
36
|
+
|
|
37
|
+
* {
|
|
38
|
+
color: var(--cpd-color-icon-secondary);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.no-background[data-kind="secondary"] {
|
|
43
|
+
background: transparent;
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
.icon-button[aria-disabled="true"] {
|
|
35
|
-
color: var(--cpd-color-icon-disabled);
|
|
36
47
|
cursor: not-allowed;
|
|
48
|
+
|
|
49
|
+
* {
|
|
50
|
+
color: var(--cpd-color-icon-disabled);
|
|
51
|
+
}
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
/**
|
|
@@ -42,14 +57,20 @@ Please see LICENSE files in the repository root for full details.
|
|
|
42
57
|
|
|
43
58
|
@media (hover) {
|
|
44
59
|
.icon-button:not([aria-disabled="true"]):hover {
|
|
45
|
-
color: var(--cpd-color-icon-primary);
|
|
46
60
|
background: var(--cpd-color-bg-subtle-primary);
|
|
61
|
+
|
|
62
|
+
* {
|
|
63
|
+
color: var(--cpd-color-icon-primary);
|
|
64
|
+
}
|
|
47
65
|
}
|
|
48
66
|
}
|
|
49
67
|
|
|
50
68
|
.icon-button:not([aria-disabled="true"]):active {
|
|
51
|
-
color: var(--cpd-color-icon-primary);
|
|
52
69
|
background: var(--cpd-color-bg-subtle-primary);
|
|
70
|
+
|
|
71
|
+
* {
|
|
72
|
+
color: var(--cpd-color-icon-primary);
|
|
73
|
+
}
|
|
53
74
|
}
|
|
54
75
|
|
|
55
76
|
@media (hover) {
|
|
@@ -72,11 +93,13 @@ Please see LICENSE files in the repository root for full details.
|
|
|
72
93
|
|
|
73
94
|
@media (hover) {
|
|
74
95
|
.icon-button:not([aria-disabled="true"]).destructive:hover {
|
|
75
|
-
background: var(--cpd-color-bg-critical-subtle);
|
|
96
|
+
background: var(--cpd-color-bg-critical-subtle-hovered);
|
|
76
97
|
outline: 1px solid var(--cpd-color-border-critical-subtle);
|
|
77
98
|
}
|
|
78
99
|
}
|
|
79
100
|
|
|
80
|
-
.icon-button:not([aria-disabled="true"]).destructive
|
|
81
|
-
|
|
101
|
+
.icon-button:not([aria-disabled="true"]).destructive {
|
|
102
|
+
* {
|
|
103
|
+
color: var(--cpd-color-icon-critical-primary);
|
|
104
|
+
}
|
|
82
105
|
}
|
|
@@ -14,6 +14,11 @@ import { IndicatorIcon } from "../../Icon/IndicatorIcon/IndicatorIcon";
|
|
|
14
14
|
import { Tooltip } from "../../Tooltip/Tooltip";
|
|
15
15
|
|
|
16
16
|
type IconButtonProps = UnstyledButtonPropsFor<"button"> & {
|
|
17
|
+
/**
|
|
18
|
+
* The type of button.
|
|
19
|
+
* @default "primary"
|
|
20
|
+
*/
|
|
21
|
+
kind?: "primary" | "secondary";
|
|
17
22
|
/**
|
|
18
23
|
* The CSS class name.
|
|
19
24
|
*/
|
|
@@ -42,7 +47,11 @@ type IconButtonProps = UnstyledButtonPropsFor<"button"> & {
|
|
|
42
47
|
* Optional tooltip for the button
|
|
43
48
|
*/
|
|
44
49
|
tooltip?: string;
|
|
45
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Hide the background when the button is not active or hovered.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
noBackground?: boolean;
|
|
46
55
|
};
|
|
47
56
|
|
|
48
57
|
/**
|
|
@@ -53,6 +62,7 @@ export const IconButton = forwardRef<
|
|
|
53
62
|
PropsWithChildren<IconButtonProps>
|
|
54
63
|
>(function IconButton(
|
|
55
64
|
{
|
|
65
|
+
kind = "primary",
|
|
56
66
|
children,
|
|
57
67
|
className,
|
|
58
68
|
indicator,
|
|
@@ -61,14 +71,14 @@ export const IconButton = forwardRef<
|
|
|
61
71
|
disabled,
|
|
62
72
|
destructive,
|
|
63
73
|
tooltip,
|
|
64
|
-
|
|
74
|
+
noBackground = false,
|
|
65
75
|
...props
|
|
66
76
|
},
|
|
67
77
|
ref,
|
|
68
78
|
) {
|
|
69
79
|
const classes = classnames(styles["icon-button"], className, {
|
|
70
80
|
[styles.destructive]: destructive,
|
|
71
|
-
[styles["
|
|
81
|
+
[styles["no-background"]]: noBackground,
|
|
72
82
|
});
|
|
73
83
|
|
|
74
84
|
const button = (
|
|
@@ -85,6 +95,7 @@ export const IconButton = forwardRef<
|
|
|
85
95
|
disabled={disabled}
|
|
86
96
|
{...props}
|
|
87
97
|
data-indicator={indicator}
|
|
98
|
+
data-kind={kind}
|
|
88
99
|
>
|
|
89
100
|
<IndicatorIcon
|
|
90
101
|
indicator={indicator}
|
|
@@ -26,6 +26,11 @@ interface Props {
|
|
|
26
26
|
* The menu title.
|
|
27
27
|
*/
|
|
28
28
|
title: string;
|
|
29
|
+
/**
|
|
30
|
+
* Wether the title is displayed.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
showTitle?: boolean;
|
|
29
34
|
/**
|
|
30
35
|
* Event handler called when the open state of the menu changes.
|
|
31
36
|
*/
|
|
@@ -63,6 +68,7 @@ const ContextMenuItemWrapper: FC<MenuItemWrapperProps> = ({
|
|
|
63
68
|
*/
|
|
64
69
|
export const ContextMenu: FC<Props> = ({
|
|
65
70
|
title,
|
|
71
|
+
showTitle = true,
|
|
66
72
|
onOpenChange: onOpenChangeProp,
|
|
67
73
|
trigger: triggerProp,
|
|
68
74
|
hasAccessibleAlternative,
|
|
@@ -125,7 +131,9 @@ export const ContextMenu: FC<Props> = ({
|
|
|
125
131
|
{trigger}
|
|
126
132
|
<Portal>
|
|
127
133
|
<Content asChild>
|
|
128
|
-
<FloatingMenu title={title}>
|
|
134
|
+
<FloatingMenu showTitle={showTitle} title={title}>
|
|
135
|
+
{children}
|
|
136
|
+
</FloatingMenu>
|
|
129
137
|
</Content>
|
|
130
138
|
</Portal>
|
|
131
139
|
</Root>
|