@transferwise/components 46.168.2 → 46.169.1

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.
Files changed (41) hide show
  1. package/build/CardWidget/CardWidgetAction.js +7 -4
  2. package/build/CardWidget/CardWidgetAction.js.map +1 -1
  3. package/build/CardWidget/CardWidgetAction.mjs +7 -4
  4. package/build/CardWidget/CardWidgetAction.mjs.map +1 -1
  5. package/build/i18n/nl.json +1 -1
  6. package/build/i18n/nl.json.js +1 -1
  7. package/build/i18n/nl.json.mjs +1 -1
  8. package/build/i18n/zh-CN.json +1 -0
  9. package/build/i18n/zh-CN.json.js +1 -0
  10. package/build/i18n/zh-CN.json.js.map +1 -1
  11. package/build/i18n/zh-CN.json.mjs +1 -0
  12. package/build/i18n/zh-CN.json.mjs.map +1 -1
  13. package/build/main.css +30 -0
  14. package/build/styles/Button/Button.css +2 -0
  15. package/build/styles/CardContainer/CardContainer.css +23 -0
  16. package/build/styles/CardWidget/CardWidget.css +5 -0
  17. package/build/styles/main.css +30 -0
  18. package/build/types/CardContainer/CardContainer.types.d.ts +4 -3
  19. package/build/types/CardContainer/CardContainer.types.d.ts.map +1 -1
  20. package/build/types/CardWidget/CardWidget.types.d.ts +3 -1
  21. package/build/types/CardWidget/CardWidget.types.d.ts.map +1 -1
  22. package/build/types/CardWidget/CardWidgetAction.d.ts +10 -3
  23. package/build/types/CardWidget/CardWidgetAction.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/src/Button/Button.css +2 -0
  26. package/src/Button/Button.less +2 -0
  27. package/src/Button/_stories/Button.test.story.tsx +43 -0
  28. package/src/CardContainer/CardContainer.css +23 -0
  29. package/src/CardContainer/CardContainer.less +32 -0
  30. package/src/CardContainer/CardContainer.types.ts +4 -3
  31. package/src/CardContainer/_stories/CardContainer.story.tsx +25 -2
  32. package/src/CardWidget/CardWidget.css +5 -0
  33. package/src/CardWidget/CardWidget.less +8 -0
  34. package/src/CardWidget/CardWidget.test.tsx +16 -0
  35. package/src/CardWidget/CardWidget.types.ts +3 -1
  36. package/src/CardWidget/CardWidgetAction.tsx +14 -3
  37. package/src/CardWidget/_stories/CardWidget.story.tsx +57 -2
  38. package/src/CardWidget/_stories/CardWidget.test.story.tsx +20 -1
  39. package/src/i18n/nl.json +1 -1
  40. package/src/i18n/zh-CN.json +1 -0
  41. package/src/main.css +30 -0
@@ -25,6 +25,7 @@ const CardWidgetAction = function CardWidgetAction({
25
25
  action: {
26
26
  label,
27
27
  icon,
28
+ iconPosition = 'end',
28
29
  'aria-label': ariaLabel,
29
30
  'data-testid': dataTestId,
30
31
  href,
@@ -47,6 +48,10 @@ const CardWidgetAction = function CardWidgetAction({
47
48
  children: icon
48
49
  });
49
50
  }
51
+ const addon = icon ? {
52
+ type: 'icon',
53
+ value: icon
54
+ } : undefined;
50
55
  return /*#__PURE__*/jsxRuntime.jsx(Button_resolver.default, {
51
56
  v2: true,
52
57
  size: "sm",
@@ -55,10 +60,8 @@ const CardWidgetAction = function CardWidgetAction({
55
60
  href: href,
56
61
  target: target,
57
62
  disabled: disabled,
58
- addonEnd: icon ? {
59
- type: 'icon',
60
- value: icon
61
- } : undefined
63
+ addonStart: iconPosition === 'start' ? addon : undefined,
64
+ addonEnd: iconPosition !== 'start' ? addon : undefined
62
65
  // The v2 resolver drops `Button`'s own `button` default, so an action would submit a form.
63
66
  ,
64
67
  type: "button",
@@ -1 +1 @@
1
- {"version":3,"file":"CardWidgetAction.js","sources":["../../src/CardWidget/CardWidgetAction.tsx"],"sourcesContent":["import { isValidElement, type MouseEventHandler, type ReactNode } from 'react';\n\nimport Button from '../Button';\nimport type { ButtonPriority, ButtonProps } from '../Button/Button.types';\nimport IconButton, { type IconButtonProps } from '../IconButton';\n\n/** The action slot a `CardWidgetActionButton` was passed to, which is what determines its emphasis. */\nexport type CardWidgetActionSlot = 'action' | 'actionSecondary';\n\ntype CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disabled'> & {\n /**\n * `HTMLElement` rather than a narrower target, because an action is a `button` or an `a`\n * depending on whether `href` is set.\n * @default undefined\n */\n onClick?: MouseEventHandler<HTMLElement>;\n\n /**\n * Rendered after `label`, or as the only content of an unlabelled action.\n * Size it yourself — 16px is expected in both cases.\n * @default undefined\n */\n icon?: ReactNode;\n 'data-testid'?: string;\n};\n\n/** An action with a visible label, rendered as a small button. */\ntype CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {\n /** Non-rendering values are excluded, so an unlabelled action has to meet the icon-only rules. */\n label: Exclude<ButtonProps['children'], null | undefined | boolean>;\n /** @default undefined */\n 'aria-label'?: string;\n};\n\n/**\n * An action with no visible label, rendered as a 32px icon button. The icon is\n * the only thing on screen and `aria-label` is the only accessible name, so\n * both are required.\n */\ntype CardWidgetIconActionButton = CardWidgetActionButtonBase & {\n label?: never;\n icon: ReactNode;\n 'aria-label': string;\n};\n\n/**\n * An action the `CardWidget` header renders as a button. With a `label` it is a small `Button`; without\n * one, a 32px `IconButton`, which requires both an `icon` and an `aria-label`. Emphasis is not\n * part of the object — it comes from the slot the action is passed to.\n */\nexport type CardWidgetActionButton = CardWidgetLabelledActionButton | CardWidgetIconActionButton;\n\nconst BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'secondary-neutral',\n} as const satisfies Record<CardWidgetActionSlot, ButtonPriority>;\n\nconst ICON_BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'tertiary',\n} as const satisfies Record<CardWidgetActionSlot, IconButtonProps['priority']>;\n\n/**\n * Tells a `CardWidgetActionButton` object apart from any other node passed to an action slot.\n * Every button action has a `label` or an `icon`, which no React element, portal or array does.\n */\nexport const isCardWidgetActionButton = (value: unknown): value is CardWidgetActionButton =>\n typeof value === 'object' &&\n value !== null &&\n !isValidElement(value) &&\n !Array.isArray(value) &&\n ('label' in value || 'icon' in value);\n\n/** Renders a `CardWidgetActionButton` at the emphasis of the slot it was passed to. */\nconst CardWidgetAction = function CardWidgetAction({\n action: {\n label,\n icon,\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n href,\n target,\n onClick,\n disabled,\n },\n slot,\n}: {\n action: CardWidgetActionButton;\n slot: CardWidgetActionSlot;\n}) {\n if (label === undefined) {\n return (\n <IconButton\n size={32}\n priority={ICON_BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n data-testid={dataTestId}\n onClick={onClick}\n >\n {icon}\n </IconButton>\n );\n }\n\n return (\n <Button\n v2\n size=\"sm\"\n priority={BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n addonEnd={icon ? { type: 'icon', value: icon } : undefined}\n // The v2 resolver drops `Button`'s own `button` default, so an action would submit a form.\n type=\"button\"\n data-testid={dataTestId}\n onClick={onClick}\n >\n {label}\n </Button>\n );\n};\n\nexport default CardWidgetAction;\n"],"names":["BUTTON_PRIORITY","action","actionSecondary","ICON_BUTTON_PRIORITY","isCardWidgetActionButton","value","isValidElement","Array","isArray","CardWidgetAction","label","icon","ariaLabel","dataTestId","href","target","onClick","disabled","slot","undefined","_jsx","IconButton","size","priority","children","Button","v2","addonEnd","type"],"mappings":";;;;;;;;;AAoDA,MAAMA,eAAe,GAAG;AACtBC,EAAAA,MAAM,EAAE,WAAW;AACnBC,EAAAA,eAAe,EAAE;CAC8C;AAEjE,MAAMC,oBAAoB,GAAG;AAC3BF,EAAAA,MAAM,EAAE,WAAW;AACnBC,EAAAA,eAAe,EAAE;CAC2D;AAE9E;;;AAGG;AACI,MAAME,wBAAwB,GAAIC,KAAc,IACrD,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,eAACC,oBAAc,CAACD,KAAK,CAAC,IACtB,CAACE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KACpB,OAAO,IAAIA,KAAK,IAAI,MAAM,IAAIA,KAAK;AAEtC;AACA,MAAMI,gBAAgB,GAAG,SAASA,gBAAgBA,CAAC;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/CardWidgetAction.tsx"],"sourcesContent":["import { isValidElement, type MouseEventHandler, type ReactNode } from 'react';\n\nimport Button from '../Button';\nimport type { ButtonPriority, ButtonProps } from '../Button/Button.types';\nimport IconButton, { type IconButtonProps } from '../IconButton';\n\n/** The action slot a `CardWidgetActionButton` was passed to, which is what determines its emphasis. */\nexport type CardWidgetActionSlot = 'action' | 'actionSecondary';\n\ntype CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disabled'> & {\n /**\n * `HTMLElement` rather than a narrower target, because an action is a `button` or an `a`\n * depending on whether `href` is set.\n * @default undefined\n */\n onClick?: MouseEventHandler<HTMLElement>;\n\n /**\n * Rendered beside `label`, on the side set by `iconPosition`, or as the only content of an\n * unlabelled action. Size it yourself — 16px is expected in both cases.\n * @default undefined\n */\n icon?: ReactNode;\n 'data-testid'?: string;\n};\n\n/** An action with a visible label, rendered as a small button. */\ntype CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {\n /** Non-rendering values are excluded, so an unlabelled action has to meet the icon-only rules. */\n label: Exclude<ButtonProps['children'], null | undefined | boolean>;\n /**\n * Side of the label the `icon` is rendered on.\n * @default 'end'\n */\n iconPosition?: 'start' | 'end';\n /** @default undefined */\n 'aria-label'?: string;\n};\n\n/**\n * An action with no visible label, rendered as a 32px icon button. The icon is\n * the only thing on screen and `aria-label` is the only accessible name, so\n * both are required.\n */\ntype CardWidgetIconActionButton = CardWidgetActionButtonBase & {\n label?: never;\n /** An unlabelled action has no label for the icon to sit beside. */\n iconPosition?: never;\n icon: ReactNode;\n 'aria-label': string;\n};\n\n/**\n * An action the `CardWidget` header renders as a button. With a `label` it is a small `Button`; without\n * one, a 32px `IconButton`, which requires both an `icon` and an `aria-label`. Emphasis is not\n * part of the object — it comes from the slot the action is passed to.\n */\nexport type CardWidgetActionButton = CardWidgetLabelledActionButton | CardWidgetIconActionButton;\n\nconst BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'secondary-neutral',\n} as const satisfies Record<CardWidgetActionSlot, ButtonPriority>;\n\nconst ICON_BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'tertiary',\n} as const satisfies Record<CardWidgetActionSlot, IconButtonProps['priority']>;\n\n/**\n * Tells a `CardWidgetActionButton` object apart from any other node passed to an action slot.\n * Every button action has a `label` or an `icon`, which no React element, portal or array does.\n */\nexport const isCardWidgetActionButton = (value: unknown): value is CardWidgetActionButton =>\n typeof value === 'object' &&\n value !== null &&\n !isValidElement(value) &&\n !Array.isArray(value) &&\n ('label' in value || 'icon' in value);\n\n/** Renders a `CardWidgetActionButton` at the emphasis of the slot it was passed to. */\nconst CardWidgetAction = function CardWidgetAction({\n action: {\n label,\n icon,\n iconPosition = 'end',\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n href,\n target,\n onClick,\n disabled,\n },\n slot,\n}: {\n action: CardWidgetActionButton;\n slot: CardWidgetActionSlot;\n}) {\n if (label === undefined) {\n return (\n <IconButton\n size={32}\n priority={ICON_BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n data-testid={dataTestId}\n onClick={onClick}\n >\n {icon}\n </IconButton>\n );\n }\n\n const addon = icon ? ({ type: 'icon', value: icon } as const) : undefined;\n\n return (\n <Button\n v2\n size=\"sm\"\n priority={BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n addonStart={iconPosition === 'start' ? addon : undefined}\n addonEnd={iconPosition !== 'start' ? addon : undefined}\n // The v2 resolver drops `Button`'s own `button` default, so an action would submit a form.\n type=\"button\"\n data-testid={dataTestId}\n onClick={onClick}\n >\n {label}\n </Button>\n );\n};\n\nexport default CardWidgetAction;\n"],"names":["BUTTON_PRIORITY","action","actionSecondary","ICON_BUTTON_PRIORITY","isCardWidgetActionButton","value","isValidElement","Array","isArray","CardWidgetAction","label","icon","iconPosition","ariaLabel","dataTestId","href","target","onClick","disabled","slot","undefined","_jsx","IconButton","size","priority","children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AAA,IAAI,EAAE,MAAM;AAAEtB,IAAAA,KAAK,EAAEM;AAAI,GAAY,GAAGS,SAAS;EAEzE,oBACEC,cAAA,CAACO,uBAAM,EAAA;IACLC,EAAE,EAAA,IAAA;AACFN,IAAAA,IAAI,EAAC,IAAI;AACTC,IAAAA,QAAQ,EAAExB,eAAe,CAACmB,IAAI,CAAE;AAChC,IAAA,YAAA,EAAYN,SAAU;AACtBE,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfE,IAAAA,QAAQ,EAAEA,QAAS;AACnBY,IAAAA,UAAU,EAAElB,YAAY,KAAK,OAAO,GAAGc,KAAK,GAAGN,SAAU;AACzDW,IAAAA,QAAQ,EAAEnB,YAAY,KAAK,OAAO,GAAGc,KAAK,GAAGN;AAC7C;AAAA;AACAO,IAAAA,IAAI,EAAC,QAAQ;AACb,IAAA,aAAA,EAAab,UAAW;AACxBG,IAAAA,OAAO,EAAEA,OAAQ;AAAAQ,IAAAA,QAAA,EAEhBf;AAAK,GACA,CAAC;AAEb;;;"}
@@ -21,6 +21,7 @@ const CardWidgetAction = function CardWidgetAction({
21
21
  action: {
22
22
  label,
23
23
  icon,
24
+ iconPosition = 'end',
24
25
  'aria-label': ariaLabel,
25
26
  'data-testid': dataTestId,
26
27
  href,
@@ -43,6 +44,10 @@ const CardWidgetAction = function CardWidgetAction({
43
44
  children: icon
44
45
  });
45
46
  }
47
+ const addon = icon ? {
48
+ type: 'icon',
49
+ value: icon
50
+ } : undefined;
46
51
  return /*#__PURE__*/jsx(Button, {
47
52
  v2: true,
48
53
  size: "sm",
@@ -51,10 +56,8 @@ const CardWidgetAction = function CardWidgetAction({
51
56
  href: href,
52
57
  target: target,
53
58
  disabled: disabled,
54
- addonEnd: icon ? {
55
- type: 'icon',
56
- value: icon
57
- } : undefined
59
+ addonStart: iconPosition === 'start' ? addon : undefined,
60
+ addonEnd: iconPosition !== 'start' ? addon : undefined
58
61
  // The v2 resolver drops `Button`'s own `button` default, so an action would submit a form.
59
62
  ,
60
63
  type: "button",
@@ -1 +1 @@
1
- {"version":3,"file":"CardWidgetAction.mjs","sources":["../../src/CardWidget/CardWidgetAction.tsx"],"sourcesContent":["import { isValidElement, type MouseEventHandler, type ReactNode } from 'react';\n\nimport Button from '../Button';\nimport type { ButtonPriority, ButtonProps } from '../Button/Button.types';\nimport IconButton, { type IconButtonProps } from '../IconButton';\n\n/** The action slot a `CardWidgetActionButton` was passed to, which is what determines its emphasis. */\nexport type CardWidgetActionSlot = 'action' | 'actionSecondary';\n\ntype CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disabled'> & {\n /**\n * `HTMLElement` rather than a narrower target, because an action is a `button` or an `a`\n * depending on whether `href` is set.\n * @default undefined\n */\n onClick?: MouseEventHandler<HTMLElement>;\n\n /**\n * Rendered after `label`, or as the only content of an unlabelled action.\n * Size it yourself — 16px is expected in both cases.\n * @default undefined\n */\n icon?: ReactNode;\n 'data-testid'?: string;\n};\n\n/** An action with a visible label, rendered as a small button. */\ntype CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {\n /** Non-rendering values are excluded, so an unlabelled action has to meet the icon-only rules. */\n label: Exclude<ButtonProps['children'], null | undefined | boolean>;\n /** @default undefined */\n 'aria-label'?: string;\n};\n\n/**\n * An action with no visible label, rendered as a 32px icon button. The icon is\n * the only thing on screen and `aria-label` is the only accessible name, so\n * both are required.\n */\ntype CardWidgetIconActionButton = CardWidgetActionButtonBase & {\n label?: never;\n icon: ReactNode;\n 'aria-label': string;\n};\n\n/**\n * An action the `CardWidget` header renders as a button. With a `label` it is a small `Button`; without\n * one, a 32px `IconButton`, which requires both an `icon` and an `aria-label`. Emphasis is not\n * part of the object — it comes from the slot the action is passed to.\n */\nexport type CardWidgetActionButton = CardWidgetLabelledActionButton | CardWidgetIconActionButton;\n\nconst BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'secondary-neutral',\n} as const satisfies Record<CardWidgetActionSlot, ButtonPriority>;\n\nconst ICON_BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'tertiary',\n} as const satisfies Record<CardWidgetActionSlot, IconButtonProps['priority']>;\n\n/**\n * Tells a `CardWidgetActionButton` object apart from any other node passed to an action slot.\n * Every button action has a `label` or an `icon`, which no React element, portal or array does.\n */\nexport const isCardWidgetActionButton = (value: unknown): value is CardWidgetActionButton =>\n typeof value === 'object' &&\n value !== null &&\n !isValidElement(value) &&\n !Array.isArray(value) &&\n ('label' in value || 'icon' in value);\n\n/** Renders a `CardWidgetActionButton` at the emphasis of the slot it was passed to. */\nconst CardWidgetAction = function CardWidgetAction({\n action: {\n label,\n icon,\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n href,\n target,\n onClick,\n disabled,\n },\n slot,\n}: {\n action: CardWidgetActionButton;\n slot: CardWidgetActionSlot;\n}) {\n if (label === undefined) {\n return (\n <IconButton\n size={32}\n priority={ICON_BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n data-testid={dataTestId}\n onClick={onClick}\n >\n {icon}\n </IconButton>\n );\n }\n\n return (\n <Button\n v2\n size=\"sm\"\n priority={BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n addonEnd={icon ? { type: 'icon', value: icon } : undefined}\n // The v2 resolver drops `Button`'s own `button` default, so an action would submit a form.\n type=\"button\"\n data-testid={dataTestId}\n onClick={onClick}\n >\n {label}\n </Button>\n );\n};\n\nexport default CardWidgetAction;\n"],"names":["BUTTON_PRIORITY","action","actionSecondary","ICON_BUTTON_PRIORITY","isCardWidgetActionButton","value","isValidElement","Array","isArray","CardWidgetAction","label","icon","ariaLabel","dataTestId","href","target","onClick","disabled","slot","undefined","_jsx","IconButton","size","priority","children","Button","v2","addonEnd","type"],"mappings":";;;;;AAoDA,MAAMA,eAAe,GAAG;AACtBC,EAAAA,MAAM,EAAE,WAAW;AACnBC,EAAAA,eAAe,E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K;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfE,IAAAA,QAAQ,EAAEA,QAAS;IACnBU,QAAQ,EAAEhB,IAAI,GAAG;AAAEiB,MAAAA,IAAI,EAAE,MAAM;AAAEvB,MAAAA,KAAK,EAAEM;AAAI,KAAE,GAAGQ;AACjD;AAAA;AACAS,IAAAA,IAAI,EAAC,QAAQ;AACb,IAAA,aAAA,EAAaf,UAAW;AACxBG,IAAAA,OAAO,EAAEA,OAAQ;AAAAQ,IAAAA,QAAA,EAEhBd;AAAK,GACA,CAAC;AAEb;;"}
1
+ {"version":3,"file":"CardWidgetAction.mjs","sources":["../../src/CardWidget/CardWidgetAction.tsx"],"sourcesContent":["import { isValidElement, type MouseEventHandler, type ReactNode } from 'react';\n\nimport Button from '../Button';\nimport type { ButtonPriority, ButtonProps } from '../Button/Button.types';\nimport IconButton, { type IconButtonProps } from '../IconButton';\n\n/** The action slot a `CardWidgetActionButton` was passed to, which is what determines its emphasis. */\nexport type CardWidgetActionSlot = 'action' | 'actionSecondary';\n\ntype CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disabled'> & {\n /**\n * `HTMLElement` rather than a narrower target, because an action is a `button` or an `a`\n * depending on whether `href` is set.\n * @default undefined\n */\n onClick?: MouseEventHandler<HTMLElement>;\n\n /**\n * Rendered beside `label`, on the side set by `iconPosition`, or as the only content of an\n * unlabelled action. Size it yourself — 16px is expected in both cases.\n * @default undefined\n */\n icon?: ReactNode;\n 'data-testid'?: string;\n};\n\n/** An action with a visible label, rendered as a small button. */\ntype CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {\n /** Non-rendering values are excluded, so an unlabelled action has to meet the icon-only rules. */\n label: Exclude<ButtonProps['children'], null | undefined | boolean>;\n /**\n * Side of the label the `icon` is rendered on.\n * @default 'end'\n */\n iconPosition?: 'start' | 'end';\n /** @default undefined */\n 'aria-label'?: string;\n};\n\n/**\n * An action with no visible label, rendered as a 32px icon button. The icon is\n * the only thing on screen and `aria-label` is the only accessible name, so\n * both are required.\n */\ntype CardWidgetIconActionButton = CardWidgetActionButtonBase & {\n label?: never;\n /** An unlabelled action has no label for the icon to sit beside. */\n iconPosition?: never;\n icon: ReactNode;\n 'aria-label': string;\n};\n\n/**\n * An action the `CardWidget` header renders as a button. With a `label` it is a small `Button`; without\n * one, a 32px `IconButton`, which requires both an `icon` and an `aria-label`. Emphasis is not\n * part of the object — it comes from the slot the action is passed to.\n */\nexport type CardWidgetActionButton = CardWidgetLabelledActionButton | CardWidgetIconActionButton;\n\nconst BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'secondary-neutral',\n} as const satisfies Record<CardWidgetActionSlot, ButtonPriority>;\n\nconst ICON_BUTTON_PRIORITY = {\n action: 'secondary',\n actionSecondary: 'tertiary',\n} as const satisfies Record<CardWidgetActionSlot, IconButtonProps['priority']>;\n\n/**\n * Tells a `CardWidgetActionButton` object apart from any other node passed to an action slot.\n * Every button action has a `label` or an `icon`, which no React element, portal or array does.\n */\nexport const isCardWidgetActionButton = (value: unknown): value is CardWidgetActionButton =>\n typeof value === 'object' &&\n value !== null &&\n !isValidElement(value) &&\n !Array.isArray(value) &&\n ('label' in value || 'icon' in value);\n\n/** Renders a `CardWidgetActionButton` at the emphasis of the slot it was passed to. */\nconst CardWidgetAction = function CardWidgetAction({\n action: {\n label,\n icon,\n iconPosition = 'end',\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n href,\n target,\n onClick,\n disabled,\n },\n slot,\n}: {\n action: CardWidgetActionButton;\n slot: CardWidgetActionSlot;\n}) {\n if (label === undefined) {\n return (\n <IconButton\n size={32}\n priority={ICON_BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n data-testid={dataTestId}\n onClick={onClick}\n >\n {icon}\n </IconButton>\n );\n }\n\n const addon = icon ? ({ type: 'icon', value: icon } as const) : undefined;\n\n return (\n <Button\n v2\n size=\"sm\"\n priority={BUTTON_PRIORITY[slot]}\n aria-label={ariaLabel}\n href={href}\n target={target}\n disabled={disabled}\n addonStart={iconPosition === 'start' ? addon : undefined}\n addonEnd={iconPosition !== 'start' ? addon : undefined}\n // The v2 resolver drops `Button`'s own `button` default, so an action would submit a form.\n type=\"button\"\n data-testid={dataTestId}\n onClick={onClick}\n >\n {label}\n </Button>\n );\n};\n\nexport default CardWidgetAction;\n"],"names":["BUTTON_PRIORITY","action","actionSecondary","ICON_BUTTON_PRIORITY","isCardWidgetActionButton","value","isValidElement","Array","isArray","CardWidgetAction","label","icon","iconPosition","ariaLabel","dataTestId","href","target","onClick","disabled","slot","undefined","_jsx","IconButton","size","priority","children","addon","type","Button","v2","addonStart","addonEnd"],"mappings":";;;;;AA2DA,MAAMA,eAAe,GAAG;AACtBC,EAAAA,MAAM,EAAE,WAAW;AACnBC,EAAAA,eAAe,EAAE;CAC8C;AAEjE,MAAMC,oBAAoB,GAAG;AAC3BF,EAAAA,MAAM,EAAE,WAAW;AACnBC,EAAAA,eAAe,EAAE;CAC2D;AAE9E;;;AAGG;AACI,MAAME,wBAAwB,GAAIC,KAAc,IACrD,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,eAACC,cAAc,CAACD,KAAK,CAAC,IACtB,CAACE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KACpB,OAAO,IAAIA,KAAK,IAAI,MAAM,IAAIA,KAAK;AAEtC;AACA,MAAMI,gBAAgB,GAAG,SAASA,gBAAgBA,CAAC;AACjDR,EAAAA,MAAM,EAAE;IACNS,KAAK;IACLC,IAAI;AACJC,IAAAA,YAAY,GAAG,KAAK;AACpB,IAAA,YAAY,EAAEC,SAAS;AACvB,IAAA,aAAa,EAAEC,UAAU;IACzBC,IAAI;IACJC,MAAM;IACNC,OAAO;AACPC,IAAAA;GACD;AACDC,EAAAA;AAAI,CAIL,EAAA;EACC,IAAIT,KAAK,KAAKU,SAAS,EAAE;IACvB,oBACEC,GAAA,CAACC,UAAU,EAAA;AACTC,MAAAA,IAAI,EAAE,EAAG;AACTC,MAAAA,QAAQ,EAAErB,oBAAoB,CAACgB,IAAI,CAAE;AACrC,MAAA,YAAA,EAAYN,SAAU;AACtBE,MAAAA,IAAI,EAAEA,IAAK;AACXC,MAAAA,MAAM,EAAEA,MAAO;AACfE,MAAAA,QAAQ,EAAEA,QAAS;AACnB,MAAA,aAAA,EAAaJ,UAAW;AACxBG,MAAAA,OAAO,EAAEA,OAAQ;AAAAQ,MAAAA,QAAA,EAEhBd;AAAI,KACK,CAAC;AAEjB,EAAA;EAEA,MAAMe,KAAK,GAAGf,IAAI,GAAI;AAAEgB,IAAAA,IAAI,EAAE,MAAM;AAAEtB,IAAAA,KAAK,EAAEM;AAAI,GAAY,GAAGS,SAAS;EAEzE,oBACEC,GAAA,CAACO,MAAM,EAAA;IACLC,EAAE,EAAA,IAAA;AACFN,IAAAA,IAAI,EAAC,IAAI;AACTC,IAAAA,QAAQ,EAAExB,eAAe,CAACmB,IAAI,CAAE;AAChC,IAAA,YAAA,EAAYN,SAAU;AACtBE,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfE,IAAAA,QAAQ,EAAEA,QAAS;AACnBY,IAAAA,UAAU,EAAElB,YAAY,KAAK,OAAO,GAAGc,KAAK,GAAGN,SAAU;AACzDW,IAAAA,QAAQ,EAAEnB,YAAY,KAAK,OAAO,GAAGc,KAAK,GAAGN;AAC7C;AAAA;AACAO,IAAAA,IAAI,EAAC,QAAQ;AACb,IAAA,aAAA,EAAab,UAAW;AACxBG,IAAAA,OAAO,EAAEA,OAAQ;AAAAQ,IAAAA,QAAA,EAEhBf;AAAK,GACA,CAAC;AAEb;;"}
@@ -38,7 +38,7 @@
38
38
  "neptune.PhoneNumberInput.phoneNumberPrefix": "Voorvoegsel",
39
39
  "neptune.Select.searchPlaceholder": "Zoeken...",
40
40
  "neptune.SelectInput.noResultsFound": "Geen resultaten gevonden",
41
- "neptune.Snackbar.escapeDismissHint": "Druk op Escape om te verwijderen.",
41
+ "neptune.Snackbar.escapeDismissHint": "Druk op Esc om te sluiten.",
42
42
  "neptune.StatusIcon.iconLabel.error": "Fout:",
43
43
  "neptune.StatusIcon.iconLabel.information": "Informatie:",
44
44
  "neptune.StatusIcon.iconLabel.pending": "In behandeling:",
@@ -42,7 +42,7 @@ var nl = {
42
42
  "neptune.PhoneNumberInput.phoneNumberPrefix": "Voorvoegsel",
43
43
  "neptune.Select.searchPlaceholder": "Zoeken...",
44
44
  "neptune.SelectInput.noResultsFound": "Geen resultaten gevonden",
45
- "neptune.Snackbar.escapeDismissHint": "Druk op Escape om te verwijderen.",
45
+ "neptune.Snackbar.escapeDismissHint": "Druk op Esc om te sluiten.",
46
46
  "neptune.StatusIcon.iconLabel.error": "Fout:",
47
47
  "neptune.StatusIcon.iconLabel.information": "Informatie:",
48
48
  "neptune.StatusIcon.iconLabel.pending": "In behandeling:",
@@ -38,7 +38,7 @@ var nl = {
38
38
  "neptune.PhoneNumberInput.phoneNumberPrefix": "Voorvoegsel",
39
39
  "neptune.Select.searchPlaceholder": "Zoeken...",
40
40
  "neptune.SelectInput.noResultsFound": "Geen resultaten gevonden",
41
- "neptune.Snackbar.escapeDismissHint": "Druk op Escape om te verwijderen.",
41
+ "neptune.Snackbar.escapeDismissHint": "Druk op Esc om te sluiten.",
42
42
  "neptune.StatusIcon.iconLabel.error": "Fout:",
43
43
  "neptune.StatusIcon.iconLabel.information": "Informatie:",
44
44
  "neptune.StatusIcon.iconLabel.pending": "In behandeling:",
@@ -38,6 +38,7 @@
38
38
  "neptune.PhoneNumberInput.phoneNumberPrefix": "前缀",
39
39
  "neptune.Select.searchPlaceholder": "搜索",
40
40
  "neptune.SelectInput.noResultsFound": "找不到结果",
41
+ "neptune.Snackbar.escapeDismissHint": "按 Esc 键关闭。",
41
42
  "neptune.StatusIcon.iconLabel.error": "错误:",
42
43
  "neptune.StatusIcon.iconLabel.information": "信息:",
43
44
  "neptune.StatusIcon.iconLabel.pending": "待处理:",
@@ -42,6 +42,7 @@ var zhCN = {
42
42
  "neptune.PhoneNumberInput.phoneNumberPrefix": "前缀",
43
43
  "neptune.Select.searchPlaceholder": "搜索",
44
44
  "neptune.SelectInput.noResultsFound": "找不到结果",
45
+ "neptune.Snackbar.escapeDismissHint": "按 Esc 键关闭。",
45
46
  "neptune.StatusIcon.iconLabel.error": "错误:",
46
47
  "neptune.StatusIcon.iconLabel.information": "信息:",
47
48
  "neptune.StatusIcon.iconLabel.pending": "待处理:",
@@ -1 +1 @@
1
- {"version":3,"file":"zh-CN.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh-CN.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -38,6 +38,7 @@ var zhCN = {
38
38
  "neptune.PhoneNumberInput.phoneNumberPrefix": "前缀",
39
39
  "neptune.Select.searchPlaceholder": "搜索",
40
40
  "neptune.SelectInput.noResultsFound": "找不到结果",
41
+ "neptune.Snackbar.escapeDismissHint": "按 Esc 键关闭。",
41
42
  "neptune.StatusIcon.iconLabel.error": "错误:",
42
43
  "neptune.StatusIcon.iconLabel.information": "信息:",
43
44
  "neptune.StatusIcon.iconLabel.pending": "待处理:",
@@ -1 +1 @@
1
- {"version":3,"file":"zh-CN.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh-CN.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/build/main.css CHANGED
@@ -26243,6 +26243,29 @@ a[data-toggle="tooltip"] {
26243
26243
  padding-inline: calc(var(--CardContainer-padding-inline) + 1px);
26244
26244
  position: relative;
26245
26245
  }
26246
+ .wds-card-container--interactive:has( > :is(a[href], button:enabled):first-child):not( :has( > * + :not(.wds-card-container__border))) {
26247
+ position: relative;
26248
+ }
26249
+ .wds-card-container--interactive > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
26250
+ border-radius: var(--CardContainer-border-radius);
26251
+ content: "";
26252
+ inset: 0;
26253
+ position: absolute;
26254
+ }
26255
+ .wds-card-container--interactive > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
26256
+ border-radius: var(--CardContainer-border-radius);
26257
+ content: "";
26258
+ inset: 0;
26259
+ position: absolute;
26260
+ }
26261
+ .wds-card-container--interactive.wds-card-container--padding-none > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border))) {
26262
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
26263
+ border-radius: var(--CardContainer-border-radius);
26264
+ }
26265
+ .wds-card-container--interactive.wds-card-container--padding-none > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border))) {
26266
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
26267
+ border-radius: var(--CardContainer-border-radius);
26268
+ }
26246
26269
  .wds-card-container--interactive:has(
26247
26270
  > a[href]:hover,
26248
26271
  > button:enabled:hover,
@@ -26326,6 +26349,11 @@ a[data-toggle="tooltip"] {
26326
26349
  padding-inline-start: var(--CardWidget-inset);
26327
26350
  row-gap: var(--size-8);
26328
26351
  }
26352
+ .wds-card-widget__content {
26353
+ display: flex;
26354
+ flex: 1 0 auto;
26355
+ flex-direction: column;
26356
+ }
26329
26357
  .wds-card-widget__header + .wds-card-widget__content {
26330
26358
  margin-block-start: var(--CardWidget-header-spacing);
26331
26359
  }
@@ -27229,12 +27257,14 @@ a[data-toggle="tooltip"] {
27229
27257
  }
27230
27258
  .wds-Button-avatars {
27231
27259
  display: inline-flex;
27260
+ flex-shrink: 0;
27232
27261
  }
27233
27262
  .wds-Button-avatars .np-avatar-view .np-avatar-view-content {
27234
27263
  color: var(--Button-color);
27235
27264
  }
27236
27265
  .wds-Button-icon {
27237
27266
  display: inline-block;
27267
+ flex-shrink: 0;
27238
27268
  }
27239
27269
  .wds-Button-icon--md {
27240
27270
  --Button-iconSize: 18px;
@@ -175,12 +175,14 @@
175
175
  }
176
176
  .wds-Button-avatars {
177
177
  display: inline-flex;
178
+ flex-shrink: 0;
178
179
  }
179
180
  .wds-Button-avatars .np-avatar-view .np-avatar-view-content {
180
181
  color: var(--Button-color);
181
182
  }
182
183
  .wds-Button-icon {
183
184
  display: inline-block;
185
+ flex-shrink: 0;
184
186
  }
185
187
  .wds-Button-icon--md {
186
188
  --Button-iconSize: 18px;
@@ -38,6 +38,29 @@
38
38
  padding-inline: calc(var(--CardContainer-padding-inline) + 1px);
39
39
  position: relative;
40
40
  }
41
+ .wds-card-container--interactive:has( > :is(a[href], button:enabled):first-child):not( :has( > * + :not(.wds-card-container__border))) {
42
+ position: relative;
43
+ }
44
+ .wds-card-container--interactive > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
45
+ border-radius: var(--CardContainer-border-radius);
46
+ content: "";
47
+ inset: 0;
48
+ position: absolute;
49
+ }
50
+ .wds-card-container--interactive > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
51
+ border-radius: var(--CardContainer-border-radius);
52
+ content: "";
53
+ inset: 0;
54
+ position: absolute;
55
+ }
56
+ .wds-card-container--interactive.wds-card-container--padding-none > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border))) {
57
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
58
+ border-radius: var(--CardContainer-border-radius);
59
+ }
60
+ .wds-card-container--interactive.wds-card-container--padding-none > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border))) {
61
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
62
+ border-radius: var(--CardContainer-border-radius);
63
+ }
41
64
  .wds-card-container--interactive:has(
42
65
  > a[href]:hover,
43
66
  > button:enabled:hover,
@@ -13,6 +13,11 @@
13
13
  padding-inline-start: var(--CardWidget-inset);
14
14
  row-gap: var(--size-8);
15
15
  }
16
+ .wds-card-widget__content {
17
+ display: flex;
18
+ flex: 1 0 auto;
19
+ flex-direction: column;
20
+ }
16
21
  .wds-card-widget__header + .wds-card-widget__content {
17
22
  margin-block-start: var(--CardWidget-header-spacing);
18
23
  }
@@ -26243,6 +26243,29 @@ a[data-toggle="tooltip"] {
26243
26243
  padding-inline: calc(var(--CardContainer-padding-inline) + 1px);
26244
26244
  position: relative;
26245
26245
  }
26246
+ .wds-card-container--interactive:has( > :is(a[href], button:enabled):first-child):not( :has( > * + :not(.wds-card-container__border))) {
26247
+ position: relative;
26248
+ }
26249
+ .wds-card-container--interactive > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
26250
+ border-radius: var(--CardContainer-border-radius);
26251
+ content: "";
26252
+ inset: 0;
26253
+ position: absolute;
26254
+ }
26255
+ .wds-card-container--interactive > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
26256
+ border-radius: var(--CardContainer-border-radius);
26257
+ content: "";
26258
+ inset: 0;
26259
+ position: absolute;
26260
+ }
26261
+ .wds-card-container--interactive.wds-card-container--padding-none > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border))) {
26262
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
26263
+ border-radius: var(--CardContainer-border-radius);
26264
+ }
26265
+ .wds-card-container--interactive.wds-card-container--padding-none > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border))) {
26266
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
26267
+ border-radius: var(--CardContainer-border-radius);
26268
+ }
26246
26269
  .wds-card-container--interactive:has(
26247
26270
  > a[href]:hover,
26248
26271
  > button:enabled:hover,
@@ -26326,6 +26349,11 @@ a[data-toggle="tooltip"] {
26326
26349
  padding-inline-start: var(--CardWidget-inset);
26327
26350
  row-gap: var(--size-8);
26328
26351
  }
26352
+ .wds-card-widget__content {
26353
+ display: flex;
26354
+ flex: 1 0 auto;
26355
+ flex-direction: column;
26356
+ }
26329
26357
  .wds-card-widget__header + .wds-card-widget__content {
26330
26358
  margin-block-start: var(--CardWidget-header-spacing);
26331
26359
  }
@@ -27229,12 +27257,14 @@ a[data-toggle="tooltip"] {
27229
27257
  }
27230
27258
  .wds-Button-avatars {
27231
27259
  display: inline-flex;
27260
+ flex-shrink: 0;
27232
27261
  }
27233
27262
  .wds-Button-avatars .np-avatar-view .np-avatar-view-content {
27234
27263
  color: var(--Button-color);
27235
27264
  }
27236
27265
  .wds-Button-icon {
27237
27266
  display: inline-block;
27267
+ flex-shrink: 0;
27238
27268
  }
27239
27269
  .wds-Button-icon--md {
27240
27270
  --Button-iconSize: 18px;
@@ -43,9 +43,10 @@ export interface CardContainerProps extends HTMLAttributes<HTMLElement> {
43
43
  /**
44
44
  * Shows the card as hovered or pressed while a direct child link (with an `href`) or enabled
45
45
  * button is, such as a link that fills the card, and as hovered while that child has keyboard
46
- * focus. The rest of the card,
47
- * and controls nested deeper, don't trigger the states, so the card is only shown as something
48
- * to act on where it can be clicked.
46
+ * focus. When that link or button is the card's only child, it also covers the card's padding,
47
+ * so the whole card is clickable. Otherwise the rest of the card, and controls nested deeper,
48
+ * don't trigger the states, so the card is only shown as something to act on where it can be
49
+ * clicked.
49
50
  * @default false
50
51
  */
51
52
  interactive?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"CardContainer.types.d.ts","sourceRoot":"","sources":["../../../src/CardContainer/CardContainer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD;;;;;;;;G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,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -47,7 +47,9 @@ export interface CardWidgetProps extends Omit<CardContainerProps, 'padding' | 'i
47
47
  */
48
48
  header?: CardWidgetHeader;
49
49
  /**
50
- * The widget's content, rendered under the header.
50
+ * The widget's content, rendered under the header. Children are stacked in a flex column that
51
+ * fills the rest of the card's height, so `margin-top: auto` on the last child pushes it to the
52
+ * bottom of the card.
51
53
  * @default undefined
52
54
  */
53
55
  children?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"CardWidget.types.d.ts","sourceRoot":"","sources":["../../../src/CardWidget/CardWidget.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;AAEnF,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,KAAK,EAAE,SAAS,CAAC;IAEjB;;;OAGG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC;IAEb;;;OAGG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC;IAEpC;;;;OAIG;IACH,MAAM,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAE5C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,aAAa,CAAC;IAC1F;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB"}
1
+ {"version":3,"file":"CardWidget.types.d.ts","sourceRoot":"","sources":["../../../src/CardWidget/CardWidget.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;AAEnF,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,KAAK,EAAE,SAAS,CAAC;IAEjB;;;OAGG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC;IAEb;;;OAGG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC;IAEpC;;;;OAIG;IACH,MAAM,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAE5C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,aAAa,CAAC;IAC1F;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB"}
@@ -10,8 +10,8 @@ type CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disable
10
10
  */
11
11
  onClick?: MouseEventHandler<HTMLElement>;
12
12
  /**
13
- * Rendered after `label`, or as the only content of an unlabelled action.
14
- * Size it yourself — 16px is expected in both cases.
13
+ * Rendered beside `label`, on the side set by `iconPosition`, or as the only content of an
14
+ * unlabelled action. Size it yourself — 16px is expected in both cases.
15
15
  * @default undefined
16
16
  */
17
17
  icon?: ReactNode;
@@ -21,6 +21,11 @@ type CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disable
21
21
  type CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {
22
22
  /** Non-rendering values are excluded, so an unlabelled action has to meet the icon-only rules. */
23
23
  label: Exclude<ButtonProps['children'], null | undefined | boolean>;
24
+ /**
25
+ * Side of the label the `icon` is rendered on.
26
+ * @default 'end'
27
+ */
28
+ iconPosition?: 'start' | 'end';
24
29
  /** @default undefined */
25
30
  'aria-label'?: string;
26
31
  };
@@ -31,6 +36,8 @@ type CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {
31
36
  */
32
37
  type CardWidgetIconActionButton = CardWidgetActionButtonBase & {
33
38
  label?: never;
39
+ /** An unlabelled action has no label for the icon to sit beside. */
40
+ iconPosition?: never;
34
41
  icon: ReactNode;
35
42
  'aria-label': string;
36
43
  };
@@ -46,7 +53,7 @@ export type CardWidgetActionButton = CardWidgetLabelledActionButton | CardWidget
46
53
  */
47
54
  export declare const isCardWidgetActionButton: (value: unknown) => value is CardWidgetActionButton;
48
55
  /** Renders a `CardWidgetActionButton` at the emphasis of the slot it was passed to. */
49
- declare const CardWidgetAction: ({ action: { label, icon, "aria-label": ariaLabel, "data-testid": dataTestId, href, target, onClick, disabled, }, slot, }: {
56
+ declare const CardWidgetAction: ({ action: { label, icon, iconPosition, "aria-label": ariaLabel, "data-testid": dataTestId, href, target, onClick, disabled, }, slot, }: {
50
57
  action: CardWidgetActionButton;
51
58
  slot: CardWidgetActionSlot;
52
59
  }) => import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"CardWidgetAction.d.ts","sourceR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,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,sBAK5B,CAAC;AAExC,uFAAuF;AACvF,QAAA,MAAM,gBAAgB,GAA6B,wIAahD;IACD,MAAM,EAAE,sBAAsB,CAAC;IAC/B,IAAI,EAAE,oBAAoB,CAAC;CAC5B,gCAuCA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.168.2",
3
+ "version": "46.169.1",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -175,12 +175,14 @@
175
175
  }
176
176
  .wds-Button-avatars {
177
177
  display: inline-flex;
178
+ flex-shrink: 0;
178
179
  }
179
180
  .wds-Button-avatars .np-avatar-view .np-avatar-view-content {
180
181
  color: var(--Button-color);
181
182
  }
182
183
  .wds-Button-icon {
183
184
  display: inline-block;
185
+ flex-shrink: 0;
184
186
  }
185
187
  .wds-Button-icon--md {
186
188
  --Button-iconSize: 18px;
@@ -159,6 +159,7 @@
159
159
 
160
160
  &-avatars {
161
161
  display: inline-flex;
162
+ flex-shrink: 0;
162
163
 
163
164
  .np-avatar-view .np-avatar-view-content {
164
165
  color: var(--Button-color);
@@ -168,6 +169,7 @@
168
169
  // Icon styles
169
170
  &-icon {
170
171
  display: inline-block;
172
+ flex-shrink: 0;
171
173
 
172
174
  &--md{
173
175
  --Button-iconSize: 18px;
@@ -265,3 +265,46 @@ export const RTLDiff: Story = {
265
265
  },
266
266
  }),
267
267
  };
268
+
269
+ export const IconsOnNarrowViewports: Story = {
270
+ parameters: {
271
+ chromatic: { viewports: [300, 320] },
272
+ },
273
+ render: () => (
274
+ <div style={{ display: 'grid', gap: '16px', width: '140px' }}>
275
+ {(['sm', 'md'] as const).map((size) =>
276
+ (['start', 'end'] as const).map((position) => (
277
+ <Button
278
+ key={`${size}-${position}`}
279
+ v2
280
+ size={size}
281
+ block
282
+ addonStart={position === 'start' ? { type: 'icon', value: <Freeze /> } : undefined}
283
+ addonEnd={position === 'end' ? { type: 'icon', value: <ArrowEnd /> } : undefined}
284
+ >
285
+ Recipients
286
+ </Button>
287
+ )),
288
+ )}
289
+ <Button v2 size="md" block addonStart={{ type: 'avatar', value: [{ asset: <Freeze /> }] }}>
290
+ Recipients
291
+ </Button>
292
+ </div>
293
+ ),
294
+ play: async ({ canvasElement }) => {
295
+ await document.fonts.ready;
296
+ const icons = canvasElement.querySelectorAll('.wds-Button-icon');
297
+ await expect(icons).toHaveLength(4);
298
+ for (const icon of icons) {
299
+ const size = icon.classList.contains('wds-Button-icon--sm') ? 16 : 18;
300
+ await expect(getComputedStyle(icon).flexShrink).toBe('0');
301
+ await expect(icon.getBoundingClientRect().width).toBeCloseTo(size, 1);
302
+ const svg = icon.querySelector('svg');
303
+ await expect(svg).not.toBeNull();
304
+ await expect(svg?.getBoundingClientRect().width).toBeCloseTo(size, 1);
305
+ await expect(svg?.getBoundingClientRect().height).toBeCloseTo(size, 1);
306
+ }
307
+ const avatars = canvasElement.querySelector('.wds-Button-avatars');
308
+ await expect(avatars && getComputedStyle(avatars).flexShrink).toBe('0');
309
+ },
310
+ };
@@ -38,6 +38,29 @@
38
38
  padding-inline: calc(var(--CardContainer-padding-inline) + 1px);
39
39
  position: relative;
40
40
  }
41
+ .wds-card-container--interactive:has( > :is(a[href], button:enabled):first-child):not( :has( > * + :not(.wds-card-container__border))) {
42
+ position: relative;
43
+ }
44
+ .wds-card-container--interactive > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
45
+ border-radius: var(--CardContainer-border-radius);
46
+ content: "";
47
+ inset: 0;
48
+ position: absolute;
49
+ }
50
+ .wds-card-container--interactive > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
51
+ border-radius: var(--CardContainer-border-radius);
52
+ content: "";
53
+ inset: 0;
54
+ position: absolute;
55
+ }
56
+ .wds-card-container--interactive.wds-card-container--padding-none > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border))) {
57
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
58
+ border-radius: var(--CardContainer-border-radius);
59
+ }
60
+ .wds-card-container--interactive.wds-card-container--padding-none > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border))) {
61
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
62
+ border-radius: var(--CardContainer-border-radius);
63
+ }
41
64
  .wds-card-container--interactive:has(
42
65
  > a[href]:hover,
43
66
  > button:enabled:hover,
@@ -1,3 +1,7 @@
1
+ // An interactive card's link or button, when it is the card's only content. The inactive
2
+ // spotlight's border is rendered after the children, so it doesn't count.
3
+ @card-container-only-action: ~":is(a[href], button:enabled):first-child:not(:has(~ :not(.wds-card-container__border)))";
4
+
1
5
  // The hover and pressed states, as mixins so CardWidget can apply them to the card when only its
2
6
  // title is hovered or pressed. Applied to the card's root.
3
7
  .wds-card-container-hover-state() {
@@ -90,6 +94,34 @@
90
94
  position: relative;
91
95
  }
92
96
 
97
+ &--interactive {
98
+ // Only when the stretched link applies, so other cards keep their containing block. Spelled
99
+ // out, as `:has()` can't nest the only-action selector's own `:has()`.
100
+ &:has(> :is(a[href], button:enabled):first-child):not(
101
+ :has(> * + :not(.wds-card-container__border))
102
+ ) {
103
+ position: relative;
104
+ }
105
+
106
+ // When a link or button is the card's only content, it stretches over the padding, so the
107
+ // whole card hovers and clicks as it. Rounded like the card, so its corners outside the card's
108
+ // radius don't click.
109
+ > @{card-container-only-action}::before {
110
+ border-radius: var(--CardContainer-border-radius);
111
+ content: "";
112
+ inset: 0;
113
+ position: absolute;
114
+ }
115
+
116
+ // Without padding, the card clips at its edges, so the only link or button's focus ring is
117
+ // drawn inside it, rounded like the card.
118
+ &.wds-card-container--padding-none > @{card-container-only-action} {
119
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
120
+
121
+ border-radius: var(--CardContainer-border-radius);
122
+ }
123
+ }
124
+
93
125
  // An `interactive` card follows its direct child link or button, such as a link that fills the
94
126
  // card, so it only looks clickable where it can be clicked. Keyboard focus on the child shows the
95
127
  // hover state too. A card without a spotlight has no hover or pressed state.
@@ -50,9 +50,10 @@ export interface CardContainerProps extends HTMLAttributes<HTMLElement> {
50
50
  /**
51
51
  * Shows the card as hovered or pressed while a direct child link (with an `href`) or enabled
52
52
  * button is, such as a link that fills the card, and as hovered while that child has keyboard
53
- * focus. The rest of the card,
54
- * and controls nested deeper, don't trigger the states, so the card is only shown as something
55
- * to act on where it can be clicked.
53
+ * focus. When that link or button is the card's only child, it also covers the card's padding,
54
+ * so the whole card is clickable. Otherwise the rest of the card, and controls nested deeper,
55
+ * don't trigger the states, so the card is only shown as something to act on where it can be
56
+ * clicked.
56
57
  * @default false
57
58
  */
58
59
  interactive?: boolean;
@@ -106,6 +106,8 @@ export const Spotlight: Story = {
106
106
  *
107
107
  * Focus rings are clipped at the edges too, so keep `none` for non-interactive content, and lists
108
108
  * on `md`.
109
+ *
110
+ * The last three cards are `interactive`, with a link as their content.
109
111
  */
110
112
  export const Padding: Story = {
111
113
  parameters: { controls: { disable: true } },
@@ -126,14 +128,35 @@ export const Padding: Story = {
126
128
  ),
127
129
  ),
128
130
  )}
131
+ {([undefined, 'active', 'inactive'] as (CardContainerSpotlight | undefined)[]).map(
132
+ (spotlight) => (
133
+ <CardContainer
134
+ key={`interactive-${spotlight ?? 'none'}`}
135
+ padding="none"
136
+ spotlight={spotlight}
137
+ interactive
138
+ >
139
+ <a
140
+ href="#padding"
141
+ aria-label={`Interactive, spotlight: ${spotlight ?? 'not set'}`}
142
+ style={{
143
+ display: 'block',
144
+ height: '120px',
145
+ background: 'var(--color-background-screen-active)',
146
+ }}
147
+ />
148
+ </CardContainer>
149
+ ),
150
+ )}
129
151
  </div>
130
152
  ),
131
153
  };
132
154
 
133
155
  /**
134
156
  * `interactive` shows the card as hovered or pressed while a direct child link or button is, and
135
- * as hovered while that child has keyboard focus. The card's padding, and a link nested deeper
136
- * such as inside text, don't trigger the states.
157
+ * as hovered while that child has keyboard focus. A link or button that is the card's only child
158
+ * covers the card's padding too. A link nested deeper, such as inside text, doesn't trigger the
159
+ * states.
137
160
  */
138
161
  export const Interactive: Story = {
139
162
  parameters: { controls: { disable: true } },
@@ -13,6 +13,11 @@
13
13
  padding-inline-start: var(--CardWidget-inset);
14
14
  row-gap: var(--size-8);
15
15
  }
16
+ .wds-card-widget__content {
17
+ display: flex;
18
+ flex: 1 0 auto;
19
+ flex-direction: column;
20
+ }
16
21
  .wds-card-widget__header + .wds-card-widget__content {
17
22
  margin-block-start: var(--CardWidget-header-spacing);
18
23
  }
@@ -22,6 +22,14 @@
22
22
  row-gap: var(--size-8);
23
23
  }
24
24
 
25
+ // Fills the rest of the card's height, so content can be laid out against its bottom edge, such
26
+ // as a footer pushed down with `margin-top: auto`. Children stack like the card's own.
27
+ &__content {
28
+ display: flex;
29
+ flex: 1 0 auto;
30
+ flex-direction: column;
31
+ }
32
+
25
33
  // On the content rather than the header, as an inactive card's decorative border comes after the
26
34
  // header, so a header-only widget's header isn't its last child.
27
35
  &__header + &__content {
@@ -136,6 +136,22 @@ describe('CardWidget', () => {
136
136
  );
137
137
  });
138
138
 
139
+ it('renders a labelled action icon after the label by default', () => {
140
+ renderWidget({ action: { label: 'Order card', icon: <span data-testid="action-icon" /> } });
141
+ expect(screen.getByTestId('action-icon').parentElement).toHaveClass('wds-Button-icon--end');
142
+ });
143
+
144
+ it('renders a labelled action icon before the label with iconPosition start', () => {
145
+ renderWidget({
146
+ action: {
147
+ label: 'Order card',
148
+ icon: <span data-testid="action-icon" />,
149
+ iconPosition: 'start',
150
+ },
151
+ });
152
+ expect(screen.getByTestId('action-icon').parentElement).toHaveClass('wds-Button-icon--start');
153
+ });
154
+
139
155
  it('names an unlabelled action from its aria-label', () => {
140
156
  renderWidget({ action: { 'aria-label': 'Card settings', icon: <Settings size={16} /> } });
141
157
  expect(screen.getByRole('button', { name: 'Card settings' })).toBeInTheDocument();
@@ -56,7 +56,9 @@ export interface CardWidgetProps extends Omit<CardContainerProps, 'padding' | 'i
56
56
  header?: CardWidgetHeader;
57
57
 
58
58
  /**
59
- * The widget's content, rendered under the header.
59
+ * The widget's content, rendered under the header. Children are stacked in a flex column that
60
+ * fills the rest of the card's height, so `margin-top: auto` on the last child pushes it to the
61
+ * bottom of the card.
60
62
  * @default undefined
61
63
  */
62
64
  children?: ReactNode;
@@ -16,8 +16,8 @@ type CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disable
16
16
  onClick?: MouseEventHandler<HTMLElement>;
17
17
 
18
18
  /**
19
- * Rendered after `label`, or as the only content of an unlabelled action.
20
- * Size it yourself — 16px is expected in both cases.
19
+ * Rendered beside `label`, on the side set by `iconPosition`, or as the only content of an
20
+ * unlabelled action. Size it yourself — 16px is expected in both cases.
21
21
  * @default undefined
22
22
  */
23
23
  icon?: ReactNode;
@@ -28,6 +28,11 @@ type CardWidgetActionButtonBase = Pick<ButtonProps, 'href' | 'target' | 'disable
28
28
  type CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {
29
29
  /** Non-rendering values are excluded, so an unlabelled action has to meet the icon-only rules. */
30
30
  label: Exclude<ButtonProps['children'], null | undefined | boolean>;
31
+ /**
32
+ * Side of the label the `icon` is rendered on.
33
+ * @default 'end'
34
+ */
35
+ iconPosition?: 'start' | 'end';
31
36
  /** @default undefined */
32
37
  'aria-label'?: string;
33
38
  };
@@ -39,6 +44,8 @@ type CardWidgetLabelledActionButton = CardWidgetActionButtonBase & {
39
44
  */
40
45
  type CardWidgetIconActionButton = CardWidgetActionButtonBase & {
41
46
  label?: never;
47
+ /** An unlabelled action has no label for the icon to sit beside. */
48
+ iconPosition?: never;
42
49
  icon: ReactNode;
43
50
  'aria-label': string;
44
51
  };
@@ -76,6 +83,7 @@ const CardWidgetAction = function CardWidgetAction({
76
83
  action: {
77
84
  label,
78
85
  icon,
86
+ iconPosition = 'end',
79
87
  'aria-label': ariaLabel,
80
88
  'data-testid': dataTestId,
81
89
  href,
@@ -105,6 +113,8 @@ const CardWidgetAction = function CardWidgetAction({
105
113
  );
106
114
  }
107
115
 
116
+ const addon = icon ? ({ type: 'icon', value: icon } as const) : undefined;
117
+
108
118
  return (
109
119
  <Button
110
120
  v2
@@ -114,7 +124,8 @@ const CardWidgetAction = function CardWidgetAction({
114
124
  href={href}
115
125
  target={target}
116
126
  disabled={disabled}
117
- addonEnd={icon ? { type: 'icon', value: icon } : undefined}
127
+ addonStart={iconPosition === 'start' ? addon : undefined}
128
+ addonEnd={iconPosition !== 'start' ? addon : undefined}
118
129
  // The v2 resolver drops `Button`'s own `button` default, so an action would submit a form.
119
130
  type="button"
120
131
  data-testid={dataTestId}
@@ -1,4 +1,4 @@
1
- import { Plus, Settings } from '@transferwise/icons';
1
+ import { Cog, Email, Plus, Settings } from '@transferwise/icons';
2
2
  import { Meta, StoryObj } from '@storybook/react-webpack5';
3
3
 
4
4
  import {
@@ -97,7 +97,8 @@ export const TitleLink: Story = {
97
97
 
98
98
  /**
99
99
  * An action object with a `label` renders a small button, and one with only an `icon` a 32px icon
100
- * button, which requires an `aria-label`. `actionSecondary` renders before `action` at a lower
100
+ * button, which requires an `aria-label`. A labelled action's icon follows its label, or leads
101
+ * it with `iconPosition: 'start'`. `actionSecondary` renders before `action` at a lower
101
102
  * emphasis; two actions is the maximum, to keep the title legible. When the header is 360px wide
102
103
  * or narrower, the actions move under a title that doesn't fit beside them on one line.
103
104
  */
@@ -121,6 +122,25 @@ export const Actions: Story = {
121
122
  <SampleContent />
122
123
  </CardWidget>
123
124
  </div>
125
+
126
+ <CardWidget
127
+ header={{
128
+ ...header,
129
+ action: { label: 'Forward to email', icon: <Email size={16} />, iconPosition: 'start' },
130
+ }}
131
+ >
132
+ <SampleContent />
133
+ </CardWidget>
134
+
135
+ <CardWidget
136
+ header={{
137
+ ...header,
138
+ action: { 'aria-label': 'Order card', icon: <Plus size={16} /> },
139
+ actionSecondary: { label: 'Manage', icon: <Cog size={16} />, iconPosition: 'start' },
140
+ }}
141
+ >
142
+ <SampleContent />
143
+ </CardWidget>
124
144
  </div>
125
145
  );
126
146
  },
@@ -184,6 +204,41 @@ export const WithList: Story = {
184
204
  ),
185
205
  };
186
206
 
207
+ /**
208
+ * A widget stretched to a fixed-height container, with a footer of small print after its content.
209
+ * The content fills the rest of the card's height, so the footer's `margin-top: auto` pushes it to
210
+ * the bottom of the card.
211
+ */
212
+ export const FixedHeight: Story = {
213
+ parameters: { controls: { disable: true } },
214
+ render: () => (
215
+ <div
216
+ style={{
217
+ display: 'grid',
218
+ height: '400px',
219
+ maxWidth: '480px',
220
+ }}
221
+ >
222
+ <CardWidget
223
+ spotlight="active"
224
+ header={{
225
+ title: 'Balance',
226
+ titleAction: { href: '#balance' },
227
+ action: { label: 'Add money', icon: <Plus size={16} />, iconPosition: 'start' },
228
+ }}
229
+ >
230
+ <Body type={Typography.BODY_LARGE_BOLD}>10,250.00 GBP</Body>
231
+ <Body>Your money is held with our partner banks.</Body>
232
+ <footer style={{ marginTop: 'auto', paddingTop: 'var(--size-16)' }}>
233
+ <Body style={{ color: 'var(--color-content-secondary)' }}>
234
+ Interest rates are variable and can change. Capital at risk. Terms and conditions apply.
235
+ </Body>
236
+ </footer>
237
+ </CardWidget>
238
+ </div>
239
+ ),
240
+ };
241
+
187
242
  /**
188
243
  * The card shows as hovered or pressed while the title link is, and as hovered while the link has
189
244
  * keyboard focus. Hovering or pressing the rest of
@@ -1,4 +1,4 @@
1
- import { Card, Jar, Plus, Settings, Travel } from '@transferwise/icons';
1
+ import { Card, Cog, Email, Jar, Plus, Settings, Travel } from '@transferwise/icons';
2
2
  import { Meta, StoryObj } from '@storybook/react-webpack5';
3
3
  import { useTheme } from '@wise/components-theming';
4
4
 
@@ -101,6 +101,15 @@ export const HeaderCombinations: Story = {
101
101
  <Body>Content</Body>
102
102
  </CardWidget>
103
103
 
104
+ <CardWidget
105
+ header={{
106
+ title: 'Icon at the start of the label',
107
+ action: { label: 'Forward to email', icon: <Email size={16} />, iconPosition: 'start' },
108
+ }}
109
+ >
110
+ <Body>Content</Body>
111
+ </CardWidget>
112
+
104
113
  <CardWidget
105
114
  header={{
106
115
  title: 'Both actions, icon only',
@@ -111,6 +120,16 @@ export const HeaderCombinations: Story = {
111
120
  <Body>Content</Body>
112
121
  </CardWidget>
113
122
 
123
+ <CardWidget
124
+ header={{
125
+ title: 'Labelled secondary action, icon-only action',
126
+ action: { 'aria-label': 'Add', icon: <Plus size={16} /> },
127
+ actionSecondary: { label: 'Manage', icon: <Cog size={16} />, iconPosition: 'start' },
128
+ }}
129
+ >
130
+ <Body>Content</Body>
131
+ </CardWidget>
132
+
114
133
  <CardWidget
115
134
  header={{
116
135
  title: 'A title long enough to wrap onto more than a single line next to its actions',
package/src/i18n/nl.json CHANGED
@@ -38,7 +38,7 @@
38
38
  "neptune.PhoneNumberInput.phoneNumberPrefix": "Voorvoegsel",
39
39
  "neptune.Select.searchPlaceholder": "Zoeken...",
40
40
  "neptune.SelectInput.noResultsFound": "Geen resultaten gevonden",
41
- "neptune.Snackbar.escapeDismissHint": "Druk op Escape om te verwijderen.",
41
+ "neptune.Snackbar.escapeDismissHint": "Druk op Esc om te sluiten.",
42
42
  "neptune.StatusIcon.iconLabel.error": "Fout:",
43
43
  "neptune.StatusIcon.iconLabel.information": "Informatie:",
44
44
  "neptune.StatusIcon.iconLabel.pending": "In behandeling:",
@@ -38,6 +38,7 @@
38
38
  "neptune.PhoneNumberInput.phoneNumberPrefix": "前缀",
39
39
  "neptune.Select.searchPlaceholder": "搜索",
40
40
  "neptune.SelectInput.noResultsFound": "找不到结果",
41
+ "neptune.Snackbar.escapeDismissHint": "按 Esc 键关闭。",
41
42
  "neptune.StatusIcon.iconLabel.error": "错误:",
42
43
  "neptune.StatusIcon.iconLabel.information": "信息:",
43
44
  "neptune.StatusIcon.iconLabel.pending": "待处理:",
package/src/main.css CHANGED
@@ -26243,6 +26243,29 @@ a[data-toggle="tooltip"] {
26243
26243
  padding-inline: calc(var(--CardContainer-padding-inline) + 1px);
26244
26244
  position: relative;
26245
26245
  }
26246
+ .wds-card-container--interactive:has( > :is(a[href], button:enabled):first-child):not( :has( > * + :not(.wds-card-container__border))) {
26247
+ position: relative;
26248
+ }
26249
+ .wds-card-container--interactive > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
26250
+ border-radius: var(--CardContainer-border-radius);
26251
+ content: "";
26252
+ inset: 0;
26253
+ position: absolute;
26254
+ }
26255
+ .wds-card-container--interactive > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border)))::before {
26256
+ border-radius: var(--CardContainer-border-radius);
26257
+ content: "";
26258
+ inset: 0;
26259
+ position: absolute;
26260
+ }
26261
+ .wds-card-container--interactive.wds-card-container--padding-none > a[href]:first-child:not(:has( ~ :not(.wds-card-container__border))) {
26262
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
26263
+ border-radius: var(--CardContainer-border-radius);
26264
+ }
26265
+ .wds-card-container--interactive.wds-card-container--padding-none > button:enabled:first-child:not(:has( ~ :not(.wds-card-container__border))) {
26266
+ --ring-outline-offset: calc(-1 * var(--ring-outline-width));
26267
+ border-radius: var(--CardContainer-border-radius);
26268
+ }
26246
26269
  .wds-card-container--interactive:has(
26247
26270
  > a[href]:hover,
26248
26271
  > button:enabled:hover,
@@ -26326,6 +26349,11 @@ a[data-toggle="tooltip"] {
26326
26349
  padding-inline-start: var(--CardWidget-inset);
26327
26350
  row-gap: var(--size-8);
26328
26351
  }
26352
+ .wds-card-widget__content {
26353
+ display: flex;
26354
+ flex: 1 0 auto;
26355
+ flex-direction: column;
26356
+ }
26329
26357
  .wds-card-widget__header + .wds-card-widget__content {
26330
26358
  margin-block-start: var(--CardWidget-header-spacing);
26331
26359
  }
@@ -27229,12 +27257,14 @@ a[data-toggle="tooltip"] {
27229
27257
  }
27230
27258
  .wds-Button-avatars {
27231
27259
  display: inline-flex;
27260
+ flex-shrink: 0;
27232
27261
  }
27233
27262
  .wds-Button-avatars .np-avatar-view .np-avatar-view-content {
27234
27263
  color: var(--Button-color);
27235
27264
  }
27236
27265
  .wds-Button-icon {
27237
27266
  display: inline-block;
27267
+ flex-shrink: 0;
27238
27268
  }
27239
27269
  .wds-Button-icon--md {
27240
27270
  --Button-iconSize: 18px;