@carto/meridian-ds 2.0.0-alpha-external-link.7 → 2.0.0-alpha-external-link.8

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.
@@ -123,11 +123,23 @@ function _Link({
123
123
  external,
124
124
  showExternalIcon = true,
125
125
  fontWeight = 500,
126
+ target,
127
+ rel,
128
+ "aria-describedby": ariaDescribedby,
126
129
  ...otherProps
127
130
  }, ref) {
128
131
  const intl = useIntl();
129
132
  const intlConfig = useImperativeIntl(intl);
130
133
  const isButtonLink = otherProps.component === "button";
134
+ if (process.env.NODE_ENV !== "production") {
135
+ const hasTargetBlank = target === "_blank";
136
+ const hasNoopenerRel = rel === "noopener noreferrer";
137
+ if (hasTargetBlank || hasNoopenerRel) {
138
+ console.error(
139
+ 'Link: You are using target="_blank" and/or rel="noopener noreferrer" directly. Please use the `external` prop instead for better consistency and accessibility:\n\nInstead of:\n<Link target="_blank" rel="noopener noreferrer" href="...">Link text</Link>\n\nUse:\n<Link external href="...">Link text</Link>\n\nThe `external` prop automatically handles target="_blank", rel="noopener noreferrer", and adds proper accessibility attributes and visual indicators.'
140
+ );
141
+ }
142
+ }
131
143
  return /* @__PURE__ */ jsxs(
132
144
  StyledLink,
133
145
  {
@@ -139,14 +151,14 @@ function _Link({
139
151
  role: isButtonLink ? "button" : "link",
140
152
  color,
141
153
  ref,
142
- target: external ? "_blank" : void 0,
143
- rel: external ? "noopener noreferrer" : void 0,
144
- "aria-describedby": external ? "external-hint" : void 0,
154
+ target: external ? "_blank" : target,
155
+ rel: external ? "noopener noreferrer" : rel,
156
+ "aria-describedby": external ? "external-hint" : ariaDescribedby,
145
157
  children: [
146
158
  startIcon && /* @__PURE__ */ jsx(Icon, { variant, iconPosition: "left", children: startIcon }),
147
159
  children,
148
160
  (endIcon || external && showExternalIcon) && /* @__PURE__ */ jsx(Icon, { variant, iconPosition: "right", children: endIcon || /* @__PURE__ */ jsx(OpenInNewOutlined, {}) }),
149
- external && /* @__PURE__ */ jsx(ScreenReaderOnly, { id: "external-hint", children: `(${intlConfig.formatMessage({
161
+ external && /* @__PURE__ */ jsx(ScreenReaderOnly, { id: "external-hint", children: ` (${intlConfig.formatMessage({
150
162
  id: "c4r.button.opensInNewTab"
151
163
  })})` })
152
164
  ]
@@ -124,11 +124,23 @@ function _Link({
124
124
  external,
125
125
  showExternalIcon = true,
126
126
  fontWeight = 500,
127
+ target,
128
+ rel,
129
+ "aria-describedby": ariaDescribedby,
127
130
  ...otherProps
128
131
  }, ref) {
129
132
  const intl = reactIntl.useIntl();
130
133
  const intlConfig = TablePaginationActions.useImperativeIntl(intl);
131
134
  const isButtonLink = otherProps.component === "button";
135
+ if (process.env.NODE_ENV !== "production") {
136
+ const hasTargetBlank = target === "_blank";
137
+ const hasNoopenerRel = rel === "noopener noreferrer";
138
+ if (hasTargetBlank || hasNoopenerRel) {
139
+ console.error(
140
+ 'Link: You are using target="_blank" and/or rel="noopener noreferrer" directly. Please use the `external` prop instead for better consistency and accessibility:\n\nInstead of:\n<Link target="_blank" rel="noopener noreferrer" href="...">Link text</Link>\n\nUse:\n<Link external href="...">Link text</Link>\n\nThe `external` prop automatically handles target="_blank", rel="noopener noreferrer", and adds proper accessibility attributes and visual indicators.'
141
+ );
142
+ }
143
+ }
132
144
  return /* @__PURE__ */ jsxRuntime.jsxs(
133
145
  StyledLink,
134
146
  {
@@ -140,14 +152,14 @@ function _Link({
140
152
  role: isButtonLink ? "button" : "link",
141
153
  color,
142
154
  ref,
143
- target: external ? "_blank" : void 0,
144
- rel: external ? "noopener noreferrer" : void 0,
145
- "aria-describedby": external ? "external-hint" : void 0,
155
+ target: external ? "_blank" : target,
156
+ rel: external ? "noopener noreferrer" : rel,
157
+ "aria-describedby": external ? "external-hint" : ariaDescribedby,
146
158
  children: [
147
159
  startIcon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { variant, iconPosition: "left", children: startIcon }),
148
160
  children,
149
161
  (endIcon || external && showExternalIcon) && /* @__PURE__ */ jsxRuntime.jsx(Icon, { variant, iconPosition: "right", children: endIcon || /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.OpenInNewOutlined, {}) }),
150
- external && /* @__PURE__ */ jsxRuntime.jsx(ScreenReaderOnly, { id: "external-hint", children: `(${intlConfig.formatMessage({
162
+ external && /* @__PURE__ */ jsxRuntime.jsx(ScreenReaderOnly, { id: "external-hint", children: ` (${intlConfig.formatMessage({
151
163
  id: "c4r.button.opensInNewTab"
152
164
  })})` })
153
165
  ]
@@ -6,7 +6,7 @@ const reactIntl = require("react-intl");
6
6
  const material = require("@mui/material");
7
7
  const iconsMaterial = require("@mui/icons-material");
8
8
  const TablePaginationActions = require("../TablePaginationActions-MwqZJoRm.cjs");
9
- const Alert$1 = require("../Alert-C-rl1sPM.cjs");
9
+ const Alert$1 = require("../Alert-a_Y9ZK5R.cjs");
10
10
  const ArrowDown = require("../ArrowDown-DJ0vhbsw.cjs");
11
11
  const OpenDiagonallyRight = require("../OpenDiagonallyRight-CpL4ROwg.cjs");
12
12
  require("cartocolor");
@@ -5,8 +5,8 @@ import { styled, Box, Button as Button$1, CircularProgress, Popper, Grow, Paper,
5
5
  import { OpenInNewOutlined, VisibilityOffOutlined, VisibilityOutlined, Cancel, AddCircleOutlineOutlined, ContentCopyOutlined, CloseOutlined, MenuOutlined, HelpOutline, TodayOutlined, MoreVertOutlined, ErrorOutline, Check } from "@mui/icons-material";
6
6
  import { u as useImperativeIntl, T as Typography, c as ICON_SIZE_SMALL, f as MENU_ITEM_SIZE_EXTENDED, e as MENU_ITEM_SIZE_DENSE, d as MENU_LIST_MAX_SIZE, M as MENU_ITEM_SIZE_DEFAULT, N as NOTIFICATION_DURATION_IN_MS, A as APPBAR_SIZE } from "../TablePaginationActions-BWer8cmX.js";
7
7
  import { a } from "../TablePaginationActions-BWer8cmX.js";
8
- import { S as ScreenReaderOnly, I as IconButton$1, A as Alert$1 } from "../Alert-DmbdMf46.js";
9
- import { L } from "../Alert-DmbdMf46.js";
8
+ import { S as ScreenReaderOnly, I as IconButton$1, A as Alert$1 } from "../Alert-Cw9nu2Pw.js";
9
+ import { L } from "../Alert-Cw9nu2Pw.js";
10
10
  import { A as ArrowDown } from "../ArrowDown-d6bxUL0F.js";
11
11
  import { A as ArrowUp, O as OpenDiagonallyRight, C as CloseDiagonallyRight } from "../OpenDiagonallyRight-CGdCEXlF.js";
12
12
  import "cartocolor";
@@ -10,6 +10,29 @@ export type LinkProps = MUILinkProps<React.ElementType, {
10
10
  * Whether to show the external icon when external is true. Defaults to true.
11
11
  */
12
12
  showExternalIcon?: boolean;
13
+ /**
14
+ * For target="_blank", use the `external` prop instead for better consistency and accessibility.
15
+ *
16
+ * Instead of: `<Link target="_blank" rel="noopener noreferrer" href="...">Link text</Link>`
17
+ *
18
+ * Use: `<Link external href="...">Link text</Link>`
19
+ *
20
+ * The `external` prop automatically handles target="_blank", rel="noopener noreferrer",
21
+ * and adds proper accessibility attributes and visual indicators.
22
+ */
23
+ target?: string;
24
+ /**
25
+ * For rel="noopener noreferrer", use the `external` prop instead for better consistency and accessibility.
26
+ *
27
+ * Instead of: `<Link target="_blank" rel="noopener noreferrer" href="...">Link text</Link>`
28
+ *
29
+ * Use: `<Link external href="...">Link text</Link>`
30
+ *
31
+ * The `external` prop automatically handles target="_blank", rel="noopener noreferrer",
32
+ * and adds proper accessibility attributes and visual indicators.
33
+ */
34
+ rel?: string;
35
+ 'aria-describedby'?: string;
13
36
  }>;
14
37
  declare const Link: import('react').ForwardRefExoticComponent<Omit<LinkProps, "ref"> & import('react').RefAttributes<HTMLAnchorElement>>;
15
38
  export default Link;
@@ -1 +1 @@
1
- {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,SAAS,IAAI,YAAY,EAG1B,MAAM,eAAe,CAAA;AAqDtB,MAAM,MAAM,SAAS,GAAG,YAAY,CAClC,KAAK,CAAC,WAAW,EACjB;IACE,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CACF,CAAA;AA0DD,QAAA,MAAM,IAAI,sHAAoB,CAAA;AAC9B,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,SAAS,IAAI,YAAY,EAG1B,MAAM,eAAe,CAAA;AAqDtB,MAAM,MAAM,SAAS,GAAG,YAAY,CAClC,KAAK,CAAC,WAAW,EACjB;IACE,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;;;;;OASG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,CACF,CAAA;AAmFD,QAAA,MAAM,IAAI,sHAAoB,CAAA;AAC9B,eAAe,IAAI,CAAA"}
@@ -9,7 +9,7 @@ const _ReactEcharts = require("echarts-for-react");
9
9
  const reactWindow = require("react-window");
10
10
  const SwatchSquare = require("../SwatchSquare-B8PIY3Rd.cjs");
11
11
  const iconsMaterial = require("@mui/icons-material");
12
- const Alert = require("../Alert-C-rl1sPM.cjs");
12
+ const Alert = require("../Alert-a_Y9ZK5R.cjs");
13
13
  const paletteUtils = require("../paletteUtils-B9ybmwiI.cjs");
14
14
  function detectTouchscreen() {
15
15
  let result = false;
@@ -7,7 +7,7 @@ import _ReactEcharts from "echarts-for-react";
7
7
  import { FixedSizeList } from "react-window";
8
8
  import { S as Search, a as SwatchSquare } from "../SwatchSquare-CaaLsjAC.js";
9
9
  import { ChevronLeft, ChevronRight, KeyboardArrowDown, ErrorOutline, Cancel, VisibilityOutlined, VisibilityOffOutlined, ExpandLess, ExpandMore, Close, LayersOutlined, MoreVert } from "@mui/icons-material";
10
- import { I as IconButton, L as Link$1, A as Alert } from "../Alert-DmbdMf46.js";
10
+ import { I as IconButton, L as Link$1, A as Alert } from "../Alert-Cw9nu2Pw.js";
11
11
  import { a as getColorByCategory, c as commonPalette, b as getPalette } from "../paletteUtils-BHqJlHm9.js";
12
12
  function detectTouchscreen() {
13
13
  let result = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carto/meridian-ds",
3
- "version": "2.0.0-alpha-external-link.7",
3
+ "version": "2.0.0-alpha-external-link.8",
4
4
  "description": "CARTO Meridian Design System",
5
5
  "type": "module",
6
6
  "scripts": {