@backstage/core-components 0.9.6-next.1 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # @backstage/core-components
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 32204fa794: Add `transformLinkUri` and `transformImageUri` to `MarkdownContent`
8
+
9
+ ### Patch Changes
10
+
11
+ - 3c440ea77e: Change BackstageIconLinkVertical style to use pallette instead of explicit color
12
+ - c3cfc83af2: Updated JSDoc to be MDX compatible.
13
+ - b4b711bcc2: Fix the EntityLayout header style so that EntityContextMenu button can display in correct shape when user hover on it
14
+ - 944af7f2a8: Work around a bug calling `onChange` twice in `mui` for `RoutedTab` so you don't have to press back twice to navigate through tabs
15
+ - 7f5e79961d: Fix relative `sub-paths` by concatenating the app's base path with them.
16
+ - a70869e775: Updated dependency `msw` to `^0.43.0`.
17
+ - 693990d4fe: Updated dependency `@react-hookz/web` to `^15.0.0`.
18
+ - 8006d0f9bf: Updated dependency `msw` to `^0.44.0`.
19
+ - 15201b1032: Updated dependency `rc-progress` to `3.4.0`.
20
+ - 7e115d42f9: Support displaying subtitle text in `SidebarSubmenuItem`
21
+ - ae746946f7: Improve accessibility for CopyTextButton
22
+ - 385389d23c: Updated to remove usage of the `bursts` object in the theme palette
23
+ - Updated dependencies
24
+ - @backstage/core-plugin-api@1.0.4
25
+ - @backstage/theme@0.2.16
26
+ - @backstage/errors@1.1.0
27
+
28
+ ## 0.10.0-next.3
29
+
30
+ ### Patch Changes
31
+
32
+ - 7f5e79961d: Fix relative `sub-paths` by concatenating the app's base path with them.
33
+ - a70869e775: Updated dependency `msw` to `^0.43.0`.
34
+ - 693990d4fe: Updated dependency `@react-hookz/web` to `^15.0.0`.
35
+ - Updated dependencies
36
+ - @backstage/core-plugin-api@1.0.4-next.0
37
+
38
+ ## 0.10.0-next.2
39
+
40
+ ### Minor Changes
41
+
42
+ - 32204fa794: Add `transformLinkUri` and `transformImageUri` to `MarkdownContent`
43
+
44
+ ### Patch Changes
45
+
46
+ - b4b711bcc2: Fix the EntityLayout header style so that EntityContextMenu button can display in correct shape when user hover on it
47
+ - 15201b1032: Updated dependency `rc-progress` to `3.4.0`.
48
+ - 385389d23c: Updated to remove usage of the `bursts` object in the theme palette
49
+ - Updated dependencies
50
+ - @backstage/theme@0.2.16-next.1
51
+
3
52
  ## 0.9.6-next.1
4
53
 
5
54
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -177,6 +177,14 @@ interface CopyTextButtonProps {
177
177
  * Default: "Text copied to clipboard"
178
178
  */
179
179
  tooltipText?: string;
180
+ /**
181
+ * Text to use as aria-label prop on the button
182
+ *
183
+ * @remarks
184
+ *
185
+ * Default: "Copy text"
186
+ */
187
+ 'aria-label'?: string;
180
188
  }
181
189
  /**
182
190
  * Copy text button with visual feedback
@@ -191,7 +199,11 @@ interface CopyTextButtonProps {
191
199
  *
192
200
  * @example
193
201
  *
194
- * `<CopyTextButton text="My text that I want to be copied to the clipboard" />`
202
+ * ```
203
+ * <CopyTextButton
204
+ * text="My text that I want to be copied to the clipboard"
205
+ * arial-label="Accessible label for this button" />
206
+ * ```
195
207
  */
196
208
  declare function CopyTextButton(props: CopyTextButtonProps): JSX.Element;
197
209
 
@@ -686,6 +698,8 @@ declare type Props$b = {
686
698
  content: string;
687
699
  dialect?: 'gfm' | 'common-mark';
688
700
  linkTarget?: Options['linkTarget'];
701
+ transformLinkUri?: (href: string) => string;
702
+ transformImageUri?: (href: string) => string;
689
703
  };
690
704
  /**
691
705
  * MarkdownContent
package/dist/index.esm.js CHANGED
@@ -3,14 +3,15 @@ import Snackbar from '@material-ui/core/Snackbar';
3
3
  import IconButton from '@material-ui/core/IconButton';
4
4
  import CloseIcon from '@material-ui/icons/Close';
5
5
  import { Alert } from '@material-ui/lab';
6
- import { useApi, alertApiRef, useAnalytics, errorApiRef, storageApiRef, useApp, oauthRequestApiRef, useApiHolder, configApiRef, useElementFilter, attachComponentData, discoveryApiRef } from '@backstage/core-plugin-api';
6
+ import { useApi, alertApiRef, useAnalytics, configApiRef, errorApiRef, storageApiRef, useApp, oauthRequestApiRef, useApiHolder, useElementFilter, attachComponentData, discoveryApiRef } from '@backstage/core-plugin-api';
7
7
  import pluralize from 'pluralize';
8
8
  import { makeStyles, createStyles, useTheme, darken, lighten, withStyles, styled, ThemeProvider } from '@material-ui/core/styles';
9
9
  import MaterialAvatar from '@material-ui/core/Avatar';
10
10
  import Button$1 from '@material-ui/core/Button';
11
11
  import classNames from 'classnames';
12
12
  import Link$1 from '@material-ui/core/Link';
13
- import { Link as Link$2, useSearchParams, useLocation, useResolvedPath, resolvePath } from 'react-router-dom';
13
+ import { Link as Link$2, useSearchParams, useLocation, useResolvedPath as useResolvedPath$1, resolvePath } from 'react-router-dom';
14
+ import { trimEnd, isEqual, orderBy, isMatch, transform } from 'lodash';
14
15
  import Tooltip from '@material-ui/core/Tooltip';
15
16
  import CopyIcon from '@material-ui/icons/FileCopy';
16
17
  import useCopyToClipboard from 'react-use/lib/useCopyToClipboard';
@@ -86,7 +87,6 @@ import TableCell from '@material-ui/core/TableCell';
86
87
  import TableRow from '@material-ui/core/TableRow';
87
88
  import ListItemIcon from '@material-ui/core/ListItemIcon';
88
89
  import Popover from '@material-ui/core/Popover';
89
- import { isEqual, orderBy, isMatch, transform } from 'lodash';
90
90
  import qs from 'qs';
91
91
  import MuiBrokenImageIcon from '@material-ui/icons/BrokenImage';
92
92
  import { Helmet } from 'react-helmet';
@@ -224,6 +224,31 @@ const useStyles$R = makeStyles({
224
224
  }
225
225
  }, { name: "Link" });
226
226
  const isExternalUri = (uri) => /^([a-z+.-]+):/.test(uri);
227
+ const useBaseUrl = () => {
228
+ try {
229
+ const config = useApi(configApiRef);
230
+ return config.getOptionalString("app.baseUrl");
231
+ } catch {
232
+ return void 0;
233
+ }
234
+ };
235
+ const useBasePath = () => {
236
+ var _a;
237
+ const base = "http://dummy.dev";
238
+ const url = (_a = useBaseUrl()) != null ? _a : "/";
239
+ const { pathname } = new URL(url, base);
240
+ return trimEnd(pathname, "/");
241
+ };
242
+ const useResolvedPath = (uri) => {
243
+ let resolvedPath = String(uri);
244
+ const basePath = useBasePath();
245
+ const external = isExternalUri(resolvedPath);
246
+ const startsWithBasePath = resolvedPath.startsWith(basePath);
247
+ if (!external && !startsWithBasePath) {
248
+ resolvedPath = basePath.concat(resolvedPath);
249
+ }
250
+ return resolvedPath;
251
+ };
227
252
  const getNodeText = (node) => {
228
253
  var _a;
229
254
  if (node instanceof Array) {
@@ -240,7 +265,7 @@ const getNodeText = (node) => {
240
265
  const Link = React.forwardRef(({ onClick, noTrack, ...props }, ref) => {
241
266
  const classes = useStyles$R();
242
267
  const analytics = useAnalytics();
243
- const to = String(props.to);
268
+ const to = useResolvedPath(props.to);
244
269
  const linkText = getNodeText(props.children) || to;
245
270
  const external = isExternalUri(to);
246
271
  const newWindow = external && !!/^https?:/.exec(to);
@@ -251,19 +276,20 @@ const Link = React.forwardRef(({ onClick, noTrack, ...props }, ref) => {
251
276
  }
252
277
  };
253
278
  return external ? /* @__PURE__ */ React.createElement(Link$1, {
279
+ ...newWindow ? { target: "_blank", rel: "noopener" } : {},
280
+ ...props,
254
281
  ref,
255
282
  href: to,
256
283
  onClick: handleClick,
257
- ...newWindow ? { target: "_blank", rel: "noopener" } : {},
258
- ...props,
259
284
  className: classNames(classes.externalLink, props.className)
260
285
  }, props.children, /* @__PURE__ */ React.createElement("span", {
261
286
  className: classes.visuallyHidden
262
287
  }, ", Opens in a new window")) : /* @__PURE__ */ React.createElement(Link$1, {
288
+ ...props,
263
289
  ref,
264
290
  component: Link$2,
265
- onClick: handleClick,
266
- ...props
291
+ to,
292
+ onClick: handleClick
267
293
  });
268
294
  });
269
295
 
@@ -282,7 +308,8 @@ function CopyTextButton(props) {
282
308
  const {
283
309
  text,
284
310
  tooltipDelay = 1e3,
285
- tooltipText = "Text copied to clipboard"
311
+ tooltipText = "Text copied to clipboard",
312
+ "aria-label": ariaLabel = "Copy text"
286
313
  } = props;
287
314
  const errorApi = useApi(errorApiRef);
288
315
  const [open, setOpen] = useState(false);
@@ -305,7 +332,8 @@ function CopyTextButton(props) {
305
332
  onClose: () => setOpen(false),
306
333
  open
307
334
  }, /* @__PURE__ */ React.createElement(IconButton, {
308
- onClick: handleCopyClick
335
+ onClick: handleCopyClick,
336
+ "aria-label": ariaLabel
309
337
  }, /* @__PURE__ */ React.createElement(CopyIcon, null))));
310
338
  }
311
339
 
@@ -1697,14 +1725,22 @@ const components = {
1697
1725
  }
1698
1726
  };
1699
1727
  function MarkdownContent(props) {
1700
- const { content, dialect = "gfm", linkTarget } = props;
1728
+ const {
1729
+ content,
1730
+ dialect = "gfm",
1731
+ linkTarget,
1732
+ transformLinkUri,
1733
+ transformImageUri
1734
+ } = props;
1701
1735
  const classes = useStyles$B();
1702
1736
  return /* @__PURE__ */ React.createElement(ReactMarkdown, {
1703
1737
  remarkPlugins: dialect === "gfm" ? [gfm] : [],
1704
1738
  className: classes.markdown,
1705
1739
  children: content,
1706
1740
  components,
1707
- linkTarget
1741
+ linkTarget,
1742
+ transformLinkUri,
1743
+ transformImageUri
1708
1744
  });
1709
1745
  }
1710
1746
 
@@ -3271,13 +3307,13 @@ const useStyles$l = makeStyles((theme) => ({
3271
3307
  }),
3272
3308
  overlayHeader: {
3273
3309
  display: "flex",
3274
- color: theme.palette.bursts.fontColor,
3310
+ color: theme.palette.text.primary,
3275
3311
  alignItems: "center",
3276
3312
  justifyContent: "space-between",
3277
3313
  padding: theme.spacing(2, 3)
3278
3314
  },
3279
3315
  overlayHeaderClose: {
3280
- color: theme.palette.bursts.fontColor
3316
+ color: theme.palette.text.primary
3281
3317
  },
3282
3318
  marginMobileSidebar: (props) => ({
3283
3319
  marginBottom: `${props.sidebarConfig.mobileSidebarHeight}px`
@@ -3588,7 +3624,7 @@ const SidebarSubmenuItem = (props) => {
3588
3624
  const closeSubmenu = () => {
3589
3625
  setIsHoveredOn(false);
3590
3626
  };
3591
- const toLocation = useResolvedPath(to != null ? to : "");
3627
+ const toLocation = useResolvedPath$1(to != null ? to : "");
3592
3628
  const currentLocation = useLocation();
3593
3629
  let isActive = isLocationMatch(currentLocation, toLocation);
3594
3630
  const [showDropDown, setShowDropDown] = useState(false);
@@ -3938,7 +3974,7 @@ const WorkaroundNavLink = React.forwardRef(function WorkaroundNavLinkWithRef({
3938
3974
  ...rest
3939
3975
  }, ref) {
3940
3976
  let { pathname: locationPathname } = useLocation();
3941
- let { pathname: toPathname } = useResolvedPath(to);
3977
+ let { pathname: toPathname } = useResolvedPath$1(to);
3942
3978
  if (!caseSensitive) {
3943
3979
  locationPathname = locationPathname.toLocaleLowerCase("en-US");
3944
3980
  toPathname = toPathname.toLocaleLowerCase("en-US");
@@ -4365,13 +4401,13 @@ function HeaderTabs(props) {
4365
4401
  const { tabs, onChange, selectedIndex } = props;
4366
4402
  const [selectedTab, setSelectedTab] = useState(selectedIndex != null ? selectedIndex : 0);
4367
4403
  const styles = useStyles$d();
4368
- const handleChange = (_, index) => {
4404
+ const handleChange = useCallback((_, index) => {
4369
4405
  if (selectedIndex === void 0) {
4370
4406
  setSelectedTab(index);
4371
4407
  }
4372
- if (onChange)
4408
+ if (onChange && selectedIndex !== index)
4373
4409
  onChange(index);
4374
- };
4410
+ }, [selectedIndex, onChange]);
4375
4411
  useEffect(() => {
4376
4412
  if (selectedIndex !== void 0) {
4377
4413
  setSelectedTab(selectedIndex);
@@ -5348,16 +5384,17 @@ const useStyles$5 = makeStyles((theme) => ({
5348
5384
  flexGrow: 1
5349
5385
  },
5350
5386
  rightItemsBox: {
5351
- width: "auto"
5387
+ width: "auto",
5388
+ alignItems: "center"
5352
5389
  },
5353
5390
  title: {
5354
- color: theme.palette.bursts.fontColor,
5391
+ color: theme.page.fontColor,
5355
5392
  wordBreak: "break-word",
5356
5393
  fontSize: theme.typography.h3.fontSize,
5357
5394
  marginBottom: 0
5358
5395
  },
5359
5396
  subtitle: {
5360
- color: theme.palette.bursts.fontColor,
5397
+ color: theme.page.fontColor,
5361
5398
  opacity: 0.8,
5362
5399
  display: "inline-block",
5363
5400
  marginTop: theme.spacing(1),
@@ -5368,10 +5405,10 @@ const useStyles$5 = makeStyles((theme) => ({
5368
5405
  fontSize: 11,
5369
5406
  opacity: 0.8,
5370
5407
  marginBottom: theme.spacing(1),
5371
- color: theme.palette.bursts.fontColor
5408
+ color: theme.page.fontColor
5372
5409
  },
5373
5410
  breadcrumb: {
5374
- color: theme.palette.bursts.fontColor
5411
+ color: theme.page.fontColor
5375
5412
  },
5376
5413
  breadcrumbType: {
5377
5414
  fontSize: "inherit",
@@ -5574,7 +5611,7 @@ const styles$1 = (theme) => createStyles({
5574
5611
  root: {
5575
5612
  color: theme.palette.common.white,
5576
5613
  padding: theme.spacing(2, 2, 3),
5577
- backgroundImage: theme.palette.bursts.gradient.linear,
5614
+ backgroundImage: theme.getPageTheme({ themeId: "card" }).backgroundImage,
5578
5615
  backgroundPosition: 0,
5579
5616
  backgroundSize: "inherit"
5580
5617
  }