@khanacademy/wonder-blocks-link 10.4.1 → 10.5.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @khanacademy/wonder-blocks-link@10.4.1 build:css /home/runner/work/wonder-blocks/wonder-blocks/packages/wonder-blocks-link
2
+ > @khanacademy/wonder-blocks-link@10.5.0 build:css /home/runner/work/wonder-blocks/wonder-blocks/packages/wonder-blocks-link
3
3
  > pnpm exec wonder-blocks-tokens .
4
4
 
5
5
  CSS variables generated successfully in: /home/runner/work/wonder-blocks/wonder-blocks/packages/wonder-blocks-link/dist/css
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @khanacademy/wonder-blocks-link
2
2
 
3
+ ## 10.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ace2d2b: Link's external-link icon now has an accessible name by default: "(opens in a new tab)", and reads a translated one from `WonderBlocksConfigProvider`. `labels.externalIconAriaLabel` will override the built-in translation.
8
+
9
+ ## 10.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [cbdc909]
14
+ - @khanacademy/wonder-blocks-tokens@18.1.0
15
+ - @khanacademy/wonder-blocks-clickable@8.3.2
16
+ - @khanacademy/wonder-blocks-icon@6.0.3
17
+ - @khanacademy/wonder-blocks-styles@0.4.1
18
+ - @khanacademy/wonder-blocks-typography@5.0.6
19
+
3
20
  ## 10.4.1
4
21
 
5
22
  ### Patch Changes
@@ -111,14 +111,12 @@ type CommonProps = AriaProps & {
111
111
  */
112
112
  endIcon?: React.ReactElement<React.ComponentProps<typeof PhosphorIcon>>;
113
113
  /**
114
- * The object containing the custom labels used inside this component.
115
- *
116
- * This is useful for internationalization. Defaults to English.
114
+ * The object containing custom labels for this component. This
115
+ * overrides the default labels provided by `WonderBlocksConfigProvider`.
117
116
  */
118
117
  labels?: {
119
118
  /**
120
- * An optional aria-label for the external link icon. This is used to
121
- * provide a translatable description for screen readers.
119
+ * An optional aria-label for the external link icon.
122
120
  */
123
121
  externalIconAriaLabel?: string;
124
122
  };
package/dist/es/index.js CHANGED
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { Link as Link$1, useInRouterContext } from 'react-router-dom-v5-compat';
4
4
  import { isClientSideUrl, getClickableBehavior } from '@khanacademy/wonder-blocks-clickable';
5
5
  import { StyleSheet } from 'aphrodite';
6
+ import { useWonderBlocksI18n } from '@khanacademy/wonder-blocks-config';
6
7
  import { addStyle } from '@khanacademy/wonder-blocks-core';
7
8
  import { mapValuesToCssVars, border, semanticColor, font, sizing } from '@khanacademy/wonder-blocks-tokens';
8
9
  import { minTargetSizeStyles, focusStyles } from '@khanacademy/wonder-blocks-styles';
@@ -13,7 +14,7 @@ var themeDefault = {root:{font:{family:"inherit",weight:"inherit"}}};
13
14
 
14
15
  var theme = mapValuesToCssVars(themeDefault,"--wb-c-link-");
15
16
 
16
- const StyledA=addStyle("a");const StyledLink=addStyle(Link$1);const LinkCore=React.forwardRef(function LinkCore(props,ref){const inRouterContext=useInRouterContext();const{children,skipClientNav,focused,hovered,href,inline=false,disableMinTargetSize=false,pressed,style,testId,waiting:_,target,startIcon,endIcon,labels,viewTransition,state,...restProps}=props;const defaultStyles=[styles.shared,styles.rest,inline&&styles.restInline,!inline&&!disableMinTargetSize&&minTargetSizeStyles.minTargetSize,!pressed&&focused&&styles.focus];const commonProps={"data-testid":testId,style:[defaultStyles,style],target,...restProps};const linkUrl=new URL(href,window.location.origin);const isExternalLink=linkUrl.origin!==window.location.origin;const externalIcon=jsx(PhosphorIcon,{icon:externalLinkIcon,size:"small",style:[styles.endIcon,styles.centered],testId:"external-icon","aria-label":labels?.externalIconAriaLabel});let startIconElement;let endIconElement;if(startIcon){startIconElement=React.cloneElement(startIcon,{style:[styles.startIcon,styles.centered],testId:"start-icon",...startIcon.props});}if(endIcon){endIconElement=React.cloneElement(endIcon,{style:[styles.endIcon,styles.centered],testId:"end-icon",...endIcon.props});}const linkContent=jsxs(Fragment,{children:[startIcon&&startIconElement,children,endIcon?endIconElement:isExternalLink&&target==="_blank"&&externalIcon]});return inRouterContext&&!skipClientNav&&isClientSideUrl(href)?jsx(StyledLink,{...commonProps,to:href,ref:ref,viewTransition:viewTransition,state:state,children:linkContent}):jsx(StyledA,{...commonProps,href:href,ref:ref,children:linkContent})});const focusStyling={...focusStyles.focus[":focus-visible"],borderRadius:border.radius.radius_010,outlineOffset:border.width.medium};const pressStyling={color:semanticColor.link.press,textDecoration:"underline currentcolor solid",textUnderlineOffset:font.textDecoration.underlineOffset};const styles=StyleSheet.create({shared:{fontFamily:theme.root.font.family,fontWeight:theme.root.font.weight,cursor:"pointer",textDecoration:"none",outline:"none",alignItems:"center"},rest:{color:semanticColor.link.rest,":hover":{textDecoration:"underline currentcolor solid",color:semanticColor.link.hover,textUnderlineOffset:font.textDecoration.underlineOffset},":focus-visible":focusStyling,":active":pressStyling},restInline:{textDecoration:"underline currentcolor solid",textDecorationThickness:font.textDecoration.thickness,textUnderlineOffset:font.textDecoration.underlineOffset},focus:focusStyling,press:pressStyling,startIcon:{marginInlineEnd:sizing.size_040},endIcon:{marginInlineStart:sizing.size_040},centered:{verticalAlign:"-10%"}});
17
+ const StyledA=addStyle("a");const StyledLink=addStyle(Link$1);const LinkCore=React.forwardRef(function LinkCore(props,ref){const inRouterContext=useInRouterContext();const{strings}=useWonderBlocksI18n();const{children,skipClientNav,focused,hovered,href,inline=false,disableMinTargetSize=false,pressed,style,testId,waiting:_,target,startIcon,endIcon,labels,viewTransition,state,...restProps}=props;const defaultStyles=[styles.shared,styles.rest,inline&&styles.restInline,!inline&&!disableMinTargetSize&&minTargetSizeStyles.minTargetSize,!pressed&&focused&&styles.focus];const commonProps={"data-testid":testId,style:[defaultStyles,style],target,...restProps};const linkUrl=new URL(href,window.location.origin);const isExternalLink=linkUrl.origin!==window.location.origin;const externalIcon=jsx(PhosphorIcon,{icon:externalLinkIcon,size:"small",style:[styles.endIcon,styles.centered],testId:"external-icon","aria-label":labels?.externalIconAriaLabel||strings.iconAltOpensNewTab});let startIconElement;let endIconElement;if(startIcon){startIconElement=React.cloneElement(startIcon,{style:[styles.startIcon,styles.centered],testId:"start-icon",...startIcon.props});}if(endIcon){endIconElement=React.cloneElement(endIcon,{style:[styles.endIcon,styles.centered],testId:"end-icon",...endIcon.props});}const linkContent=jsxs(Fragment,{children:[startIcon&&startIconElement,children,endIcon?endIconElement:isExternalLink&&target==="_blank"&&externalIcon]});return inRouterContext&&!skipClientNav&&isClientSideUrl(href)?jsx(StyledLink,{...commonProps,to:href,ref:ref,viewTransition:viewTransition,state:state,children:linkContent}):jsx(StyledA,{...commonProps,href:href,ref:ref,children:linkContent})});const focusStyling={...focusStyles.focus[":focus-visible"],borderRadius:border.radius.radius_010,outlineOffset:border.width.medium};const pressStyling={color:semanticColor.link.press,textDecoration:"underline currentcolor solid",textUnderlineOffset:font.textDecoration.underlineOffset};const styles=StyleSheet.create({shared:{fontFamily:theme.root.font.family,fontWeight:theme.root.font.weight,cursor:"pointer",textDecoration:"none",outline:"none",alignItems:"center"},rest:{color:semanticColor.link.rest,":hover":{textDecoration:"underline currentcolor solid",color:semanticColor.link.hover,textUnderlineOffset:font.textDecoration.underlineOffset},":focus-visible":focusStyling,":active":pressStyling},restInline:{textDecoration:"underline currentcolor solid",textDecorationThickness:font.textDecoration.thickness,textUnderlineOffset:font.textDecoration.underlineOffset},focus:focusStyling,press:pressStyling,startIcon:{marginInlineEnd:sizing.size_040},endIcon:{marginInlineStart:sizing.size_040},centered:{verticalAlign:"-10%"}});
17
18
 
18
19
  const Link=React.forwardRef(function Link(props,ref){const{onClick,beforeNav=undefined,safeWithNav,href,skipClientNav,children,tabIndex,onKeyDown,onKeyUp,target=undefined,inline=false,viewTransition=false,state,...sharedProps}=props;const inRouterContext=useInRouterContext();const ClickableBehavior=getClickableBehavior(href,skipClientNav,inRouterContext);if(beforeNav){return jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,beforeNav:beforeNav,safeWithNav:safeWithNav,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,state:state,children:(clickableState,{...childrenProps})=>{return jsx(LinkCore,{...sharedProps,...clickableState,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,ref:ref,viewTransition:viewTransition,state:state,children:children})}})}else {return jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,safeWithNav:safeWithNav,target:target,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,state:state,children:(clickableState,{...childrenProps})=>{return jsx(LinkCore,{...sharedProps,...clickableState,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,ref:ref,viewTransition:viewTransition,state:state,children:children})}})}});
19
20
 
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ var React = require('react');
5
5
  var reactRouterDomV5Compat = require('react-router-dom-v5-compat');
6
6
  var wonderBlocksClickable = require('@khanacademy/wonder-blocks-clickable');
7
7
  var aphrodite = require('aphrodite');
8
+ var wonderBlocksConfig = require('@khanacademy/wonder-blocks-config');
8
9
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
9
10
  var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
10
11
  var wonderBlocksStyles = require('@khanacademy/wonder-blocks-styles');
@@ -38,7 +39,7 @@ var themeDefault = {root:{font:{family:"inherit",weight:"inherit"}}};
38
39
 
39
40
  var theme = wonderBlocksTokens.mapValuesToCssVars(themeDefault,"--wb-c-link-");
40
41
 
41
- const StyledA=wonderBlocksCore.addStyle("a");const StyledLink=wonderBlocksCore.addStyle(reactRouterDomV5Compat.Link);const LinkCore=React__namespace.forwardRef(function LinkCore(props,ref){const inRouterContext=reactRouterDomV5Compat.useInRouterContext();const{children,skipClientNav,focused,hovered,href,inline=false,disableMinTargetSize=false,pressed,style,testId,waiting:_,target,startIcon,endIcon,labels,viewTransition,state,...restProps}=props;const defaultStyles=[styles.shared,styles.rest,inline&&styles.restInline,!inline&&!disableMinTargetSize&&wonderBlocksStyles.minTargetSizeStyles.minTargetSize,!pressed&&focused&&styles.focus];const commonProps={"data-testid":testId,style:[defaultStyles,style],target,...restProps};const linkUrl=new URL(href,window.location.origin);const isExternalLink=linkUrl.origin!==window.location.origin;const externalIcon=jsxRuntime.jsx(wonderBlocksIcon.PhosphorIcon,{icon:externalLinkIcon__default["default"],size:"small",style:[styles.endIcon,styles.centered],testId:"external-icon","aria-label":labels?.externalIconAriaLabel});let startIconElement;let endIconElement;if(startIcon){startIconElement=React__namespace.cloneElement(startIcon,{style:[styles.startIcon,styles.centered],testId:"start-icon",...startIcon.props});}if(endIcon){endIconElement=React__namespace.cloneElement(endIcon,{style:[styles.endIcon,styles.centered],testId:"end-icon",...endIcon.props});}const linkContent=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[startIcon&&startIconElement,children,endIcon?endIconElement:isExternalLink&&target==="_blank"&&externalIcon]});return inRouterContext&&!skipClientNav&&wonderBlocksClickable.isClientSideUrl(href)?jsxRuntime.jsx(StyledLink,{...commonProps,to:href,ref:ref,viewTransition:viewTransition,state:state,children:linkContent}):jsxRuntime.jsx(StyledA,{...commonProps,href:href,ref:ref,children:linkContent})});const focusStyling={...wonderBlocksStyles.focusStyles.focus[":focus-visible"],borderRadius:wonderBlocksTokens.border.radius.radius_010,outlineOffset:wonderBlocksTokens.border.width.medium};const pressStyling={color:wonderBlocksTokens.semanticColor.link.press,textDecoration:"underline currentcolor solid",textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset};const styles=aphrodite.StyleSheet.create({shared:{fontFamily:theme.root.font.family,fontWeight:theme.root.font.weight,cursor:"pointer",textDecoration:"none",outline:"none",alignItems:"center"},rest:{color:wonderBlocksTokens.semanticColor.link.rest,":hover":{textDecoration:"underline currentcolor solid",color:wonderBlocksTokens.semanticColor.link.hover,textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset},":focus-visible":focusStyling,":active":pressStyling},restInline:{textDecoration:"underline currentcolor solid",textDecorationThickness:wonderBlocksTokens.font.textDecoration.thickness,textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset},focus:focusStyling,press:pressStyling,startIcon:{marginInlineEnd:wonderBlocksTokens.sizing.size_040},endIcon:{marginInlineStart:wonderBlocksTokens.sizing.size_040},centered:{verticalAlign:"-10%"}});
42
+ const StyledA=wonderBlocksCore.addStyle("a");const StyledLink=wonderBlocksCore.addStyle(reactRouterDomV5Compat.Link);const LinkCore=React__namespace.forwardRef(function LinkCore(props,ref){const inRouterContext=reactRouterDomV5Compat.useInRouterContext();const{strings}=wonderBlocksConfig.useWonderBlocksI18n();const{children,skipClientNav,focused,hovered,href,inline=false,disableMinTargetSize=false,pressed,style,testId,waiting:_,target,startIcon,endIcon,labels,viewTransition,state,...restProps}=props;const defaultStyles=[styles.shared,styles.rest,inline&&styles.restInline,!inline&&!disableMinTargetSize&&wonderBlocksStyles.minTargetSizeStyles.minTargetSize,!pressed&&focused&&styles.focus];const commonProps={"data-testid":testId,style:[defaultStyles,style],target,...restProps};const linkUrl=new URL(href,window.location.origin);const isExternalLink=linkUrl.origin!==window.location.origin;const externalIcon=jsxRuntime.jsx(wonderBlocksIcon.PhosphorIcon,{icon:externalLinkIcon__default["default"],size:"small",style:[styles.endIcon,styles.centered],testId:"external-icon","aria-label":labels?.externalIconAriaLabel||strings.iconAltOpensNewTab});let startIconElement;let endIconElement;if(startIcon){startIconElement=React__namespace.cloneElement(startIcon,{style:[styles.startIcon,styles.centered],testId:"start-icon",...startIcon.props});}if(endIcon){endIconElement=React__namespace.cloneElement(endIcon,{style:[styles.endIcon,styles.centered],testId:"end-icon",...endIcon.props});}const linkContent=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[startIcon&&startIconElement,children,endIcon?endIconElement:isExternalLink&&target==="_blank"&&externalIcon]});return inRouterContext&&!skipClientNav&&wonderBlocksClickable.isClientSideUrl(href)?jsxRuntime.jsx(StyledLink,{...commonProps,to:href,ref:ref,viewTransition:viewTransition,state:state,children:linkContent}):jsxRuntime.jsx(StyledA,{...commonProps,href:href,ref:ref,children:linkContent})});const focusStyling={...wonderBlocksStyles.focusStyles.focus[":focus-visible"],borderRadius:wonderBlocksTokens.border.radius.radius_010,outlineOffset:wonderBlocksTokens.border.width.medium};const pressStyling={color:wonderBlocksTokens.semanticColor.link.press,textDecoration:"underline currentcolor solid",textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset};const styles=aphrodite.StyleSheet.create({shared:{fontFamily:theme.root.font.family,fontWeight:theme.root.font.weight,cursor:"pointer",textDecoration:"none",outline:"none",alignItems:"center"},rest:{color:wonderBlocksTokens.semanticColor.link.rest,":hover":{textDecoration:"underline currentcolor solid",color:wonderBlocksTokens.semanticColor.link.hover,textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset},":focus-visible":focusStyling,":active":pressStyling},restInline:{textDecoration:"underline currentcolor solid",textDecorationThickness:wonderBlocksTokens.font.textDecoration.thickness,textUnderlineOffset:wonderBlocksTokens.font.textDecoration.underlineOffset},focus:focusStyling,press:pressStyling,startIcon:{marginInlineEnd:wonderBlocksTokens.sizing.size_040},endIcon:{marginInlineStart:wonderBlocksTokens.sizing.size_040},centered:{verticalAlign:"-10%"}});
42
43
 
43
44
  const Link=React__namespace.forwardRef(function Link(props,ref){const{onClick,beforeNav=undefined,safeWithNav,href,skipClientNav,children,tabIndex,onKeyDown,onKeyUp,target=undefined,inline=false,viewTransition=false,state,...sharedProps}=props;const inRouterContext=reactRouterDomV5Compat.useInRouterContext();const ClickableBehavior=wonderBlocksClickable.getClickableBehavior(href,skipClientNav,inRouterContext);if(beforeNav){return jsxRuntime.jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,beforeNav:beforeNav,safeWithNav:safeWithNav,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,state:state,children:(clickableState,{...childrenProps})=>{return jsxRuntime.jsx(LinkCore,{...sharedProps,...clickableState,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,ref:ref,viewTransition:viewTransition,state:state,children:children})}})}else {return jsxRuntime.jsx(ClickableBehavior,{disabled:false,href:href,role:"link",onClick:onClick,safeWithNav:safeWithNav,target:target,onKeyDown:onKeyDown,onKeyUp:onKeyUp,viewTransition:viewTransition,state:state,children:(clickableState,{...childrenProps})=>{return jsxRuntime.jsx(LinkCore,{...sharedProps,...clickableState,...childrenProps,skipClientNav:skipClientNav,href:href,target:target,tabIndex:tabIndex,inline:inline,ref:ref,viewTransition:viewTransition,state:state,children:children})}})}});
44
45
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Link component for Wonder Blocks design system.",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "10.4.1",
6
+ "version": "10.5.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -28,12 +28,13 @@
28
28
  "./styles.css": "./dist/css/vars.css"
29
29
  },
30
30
  "dependencies": {
31
- "@khanacademy/wonder-blocks-clickable": "8.3.1",
31
+ "@khanacademy/wonder-blocks-clickable": "8.3.2",
32
+ "@khanacademy/wonder-blocks-config": "0.5.0",
32
33
  "@khanacademy/wonder-blocks-core": "12.5.0",
33
- "@khanacademy/wonder-blocks-icon": "6.0.2",
34
- "@khanacademy/wonder-blocks-tokens": "18.0.0",
35
- "@khanacademy/wonder-blocks-typography": "5.0.5",
36
- "@khanacademy/wonder-blocks-styles": "0.4.0"
34
+ "@khanacademy/wonder-blocks-icon": "6.0.3",
35
+ "@khanacademy/wonder-blocks-tokens": "18.1.0",
36
+ "@khanacademy/wonder-blocks-styles": "0.4.1",
37
+ "@khanacademy/wonder-blocks-typography": "5.0.6"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "@phosphor-icons/core": "^2.0.2",