@transferwise/components 45.10.1 → 45.12.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/build/es/no-polyfill/common/card/Card.js +21 -0
- package/build/es/no-polyfill/common/card/Card.spec.js +6 -0
- package/build/es/no-polyfill/common/card/Card.story.js +1 -0
- package/build/es/no-polyfill/common/card/index.js +1 -0
- package/build/es/no-polyfill/common/closeButton/CloseButton.js +1 -1
- package/build/es/no-polyfill/display/Display.js +1 -1
- package/build/es/no-polyfill/image/Image.js +1 -1
- package/build/es/no-polyfill/index.js +1 -1
- package/build/es/no-polyfill/loader/Loader.js +1 -1
- package/build/es/no-polyfill/modal/Modal.js +1 -1
- package/build/es/no-polyfill/modal/Modal.story.js +1 -1
- package/build/es/no-polyfill/promoCard/PromoCard.js +51 -0
- package/build/es/no-polyfill/promoCard/PromoCard.spec.js +13 -0
- package/build/es/no-polyfill/promoCard/PromoCard.story.js +1 -0
- package/build/es/no-polyfill/promoCard/PromoCardContext.js +19 -0
- package/build/es/no-polyfill/promoCard/PromoCardContext.spec.js +4 -0
- package/build/es/no-polyfill/promoCard/PromoCardGroup.js +20 -0
- package/build/es/no-polyfill/promoCard/PromoCardGroup.spec.js +5 -0
- package/build/es/no-polyfill/promoCard/PromoCardGroup.story.js +1 -0
- package/build/es/no-polyfill/promoCard/PromoCardIndicator.js +16 -0
- package/build/es/no-polyfill/promoCard/index.js +1 -0
- package/build/es/polyfill/common/card/Card.js +21 -0
- package/build/es/polyfill/common/card/Card.spec.js +6 -0
- package/build/es/polyfill/common/card/Card.story.js +1 -0
- package/build/es/polyfill/common/card/index.js +1 -0
- package/build/es/polyfill/common/closeButton/CloseButton.js +1 -1
- package/build/es/polyfill/display/Display.js +1 -1
- package/build/es/polyfill/image/Image.js +1 -1
- package/build/es/polyfill/index.js +1 -1
- package/build/es/polyfill/loader/Loader.js +1 -1
- package/build/es/polyfill/modal/Modal.js +1 -1
- package/build/es/polyfill/modal/Modal.story.js +1 -1
- package/build/es/polyfill/promoCard/PromoCard.js +51 -0
- package/build/es/polyfill/promoCard/PromoCard.spec.js +13 -0
- package/build/es/polyfill/promoCard/PromoCard.story.js +1 -0
- package/build/es/polyfill/promoCard/PromoCardContext.js +19 -0
- package/build/es/polyfill/promoCard/PromoCardContext.spec.js +4 -0
- package/build/es/polyfill/promoCard/PromoCardGroup.js +20 -0
- package/build/es/polyfill/promoCard/PromoCardGroup.spec.js +5 -0
- package/build/es/polyfill/promoCard/PromoCardGroup.story.js +1 -0
- package/build/es/polyfill/promoCard/PromoCardIndicator.js +16 -0
- package/build/es/polyfill/promoCard/index.js +1 -0
- package/build/main.css +1 -1
- package/build/styles/common/card/Card.css +1 -0
- package/build/styles/main.css +1 -1
- package/build/styles/promoCard/PromoCard.css +1 -0
- package/build/types/avatar/index.d.ts +1 -0
- package/build/types/common/card/Card.d.ts +40 -0
- package/build/types/common/card/Card.spec.d.ts +1 -0
- package/build/types/common/card/Card.story.d.ts +6 -0
- package/build/types/common/card/index.d.ts +1 -0
- package/build/types/common/closeButton/CloseButton.d.ts +4 -0
- package/build/types/display/Display.d.ts +1 -1
- package/build/types/image/Image.d.ts +1 -0
- package/build/types/index.d.ts +3 -0
- package/build/types/modal/Modal.d.ts +2 -1
- package/build/types/modal/Modal.story.d.ts +1 -1
- package/build/types/promoCard/PromoCard.d.ts +83 -0
- package/build/types/promoCard/PromoCard.spec.d.ts +1 -0
- package/build/types/promoCard/PromoCard.story.d.ts +11 -0
- package/build/types/promoCard/PromoCardContext.d.ts +45 -0
- package/build/types/promoCard/PromoCardContext.spec.d.ts +1 -0
- package/build/types/promoCard/PromoCardGroup.d.ts +38 -0
- package/build/types/promoCard/PromoCardGroup.spec.d.ts +1 -0
- package/build/types/promoCard/PromoCardGroup.story.d.ts +8 -0
- package/build/types/promoCard/PromoCardIndicator.d.ts +31 -0
- package/build/types/promoCard/index.d.ts +2 -0
- package/build/umd/no-polyfill/main.js +1 -1
- package/build/umd/polyfill/main.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{render,fireEvent,screen}from"@testing-library/react";import React from"react";import PromoCard from"./PromoCard";import{jsx as _jsx}from"react/jsx-runtime";describe("PromoCard",function(){var a,b={title:"Test Title",imageSource:"test.jpg",imageAlt:"Test Image",description:"Test Description",indicatorLabel:"Test Indicator Label",testId:"test-promo-card"};beforeEach(function(){var c=render(/*#__PURE__*/_jsx(PromoCard,_objectSpread({},b))),d=c.rerender;a=function(a){d(/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),a)))}}),it("matches snapshot",function(){var a=render(/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),{},{id:"test-promo-card"}))),c=a.container;expect(c.firstChild).toMatchSnapshot()}),it("renders",function(){var c=_objectSpread(_objectSpread({},b),{},{title:"Test text"});// Change props
|
|
2
|
+
expect(screen.getByTestId("test-promo-card")).toBeInTheDocument(),expect(screen.getByTestId("test-promo-card")).toHaveClass("np-Card--promoCard"),a(c),expect(screen.getByText("Test text")).toBeInTheDocument()}),it("renders title as an `h3`",function(){var c=_objectSpread(_objectSpread({},b),{},{headingLevel:"h4"});// Change props
|
|
3
|
+
expect(screen.getByRole("heading",{level:3})).toBeInTheDocument(),expect(screen.queryByRole("heading",{level:4})).not.toBeInTheDocument(),a(c),expect(screen.getByRole("heading",{level:4})).toBeInTheDocument(),expect(screen.queryByRole("heading",{level:3})).not.toBeInTheDocument()}),it("renders as an link element",function(){var c=_objectSpread(_objectSpread({},b),{},{href:"https://wise.com/"});// Change props
|
|
4
|
+
expect(screen.getByTestId("test-promo-card")).not.toHaveClass("np-Card--link"),expect(screen.getByText("Test Title")).not.toHaveAttribute("href"),a(c),expect(screen.getByTestId("test-promo-card")).toHaveClass("np-Card--link"),expect(screen.getByText("Test Title")).toHaveAttribute("href")}),it("renders the component with checkbox props",function(){var c=_objectSpread(_objectSpread({},b),{},{type:"checkbox"// or 'radio'
|
|
5
|
+
});// Change props
|
|
6
|
+
expect(screen.getByTestId("test-promo-card")).not.toHaveClass("np-Card--checked"),expect(screen.queryByRole("checkbox")).not.toBeInTheDocument(),a(c),expect(screen.getByTestId("test-promo-card")).toHaveClass("np-Card--checked"),expect(screen.getByRole("checkbox")).toBeInTheDocument()}),it("renders the component with radio props",function(){var c=_objectSpread(_objectSpread({},b),{},{type:"radio"// or 'checkbox'
|
|
7
|
+
});// Change props
|
|
8
|
+
expect(screen.getByTestId("test-promo-card")).not.toHaveClass("np-Card--checked"),expect(screen.queryByRole("radio")).not.toBeInTheDocument(),a(c),expect(screen.getByTestId("test-promo-card")).toHaveClass("np-Card--checked"),expect(screen.getByRole("radio")).toBeInTheDocument()}),it("doesnt render as a link or checked card when `herf` or `type` has been set",function(){var c=_objectSpread(_objectSpread({},b),{},{type:"radio",// or 'checkbox'
|
|
9
|
+
href:"https://wise.com/"});// Change props
|
|
10
|
+
a(c),expect(screen.getByTestId("test-promo-card")).not.toHaveClass("np-Card--checked"),expect(screen.getByTestId("test-promo-card")).not.toHaveClass("np-Card--link"),expect(screen.queryByRole("radio")).not.toBeInTheDocument(),expect(screen.getByText("Test Title")).not.toHaveAttribute("href")}),it("is set with class by the `className` prop",function(){var c=_objectSpread(_objectSpread({},b),{},{className:"test-custom"});// Change props
|
|
11
|
+
expect(screen.getByTestId("test-promo-card")).not.toHaveClass("test-custom"),a(c),expect(screen.getByTestId("test-promo-card")).toHaveClass("test-custom")}),it("applies `is-disabled` class when isDisabled is true",function(){var c=_objectSpread(_objectSpread({},b),{},{isDisabled:!0});// Change props
|
|
12
|
+
expect(screen.getByTestId("test-promo-card")).not.toHaveClass("is-disabled"),a(c),expect(screen.getByTestId("test-promo-card")).toHaveClass("is-disabled")}),it("calls the onClick function when the checkbox is clicked",function(){var c=_objectSpread(_objectSpread({},b),{},{type:"checkbox",isChecked:!1});// Change props
|
|
13
|
+
a(c),expect(screen.getByTestId("test-promo-card")).not.toHaveClass("is-checked"),fireEvent.click(screen.getByRole("checkbox")),expect(screen.getByTestId("test-promo-card")).toHaveClass("is-checked")})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import PromoCard from"./PromoCard";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var meta={component:PromoCard,title:"Layouts/PromoCard",tags:["autodocs"]};export default meta;export var Default={args:{description:"A card that lives online and works anywhere. Easy, secure, and always on hand.",title:"Digital",indicatorLabel:"Free",imageSource:"https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"}};export var Link={args:{description:"A card that lives online and works anywhere. Easy, secure, and always on hand.",title:"Digital",href:"https://wise.com",indicatorLabel:"Free",imageSource:"https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"}};export var Check={args:{description:"A card that lives online and works anywhere. Easy, secure, and always on hand.",title:"Digital",type:"checkbox",indicatorLabel:"Free",imageSource:"https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"}};export var DefaultChecked={args:{description:"A card that lives online and works anywhere. Easy, secure, and always on hand.",title:"Digital",type:"checkbox",indicatorLabel:"Free",defaultChecked:!0,imageSource:"https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"}};export var Disabled={args:{description:"A card that lives online and works anywhere. Easy, secure, and always on hand.",title:"Digital",type:"checkbox",isDisabled:!0,indicatorLabel:"Free",imageSource:"https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"}};export var CustomClass={args:{description:"A card that lives online and works anywhere. Easy, secure, and always on hand.",title:"Digital",href:"https://wise.com",className:"np-CustomPromoCard",indicatorLabel:"Free",imageSource:"https://wise.com/web-art/assets/illustrations/digital-card-medium@2x.webp"},decorators:[function(a){return/*#__PURE__*/_jsxs("div",{children:[/*#__PURE__*/_jsx("style",{children:"\n .np-CustomPromoCard {\n --Card-background-color: var(--color-bright-yellow);\n --Card-indicator-icon-background-color: var(--color-dark-gold);\n --Card-indicator-icon-color: var(--color-contrast);\n }\n "}),/*#__PURE__*/_jsx(a,{})]})}]};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{useContext,createContext}from"react";/**
|
|
2
|
+
* The type of the PromoCard context object.
|
|
3
|
+
*
|
|
4
|
+
* The context object contains the current state of the PromoCard group, whether
|
|
5
|
+
* the group is disabled or not, and a function to call when the group value
|
|
6
|
+
* changes. This value is used to provide context to child PromoCard components,
|
|
7
|
+
* allowing them to interact with the group and update its state.
|
|
8
|
+
*/var defaultPromoCardContext={state:"",isDisabled:!1,// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
9
|
+
onChange:function onChange(){}};/**
|
|
10
|
+
* The PromoCard context object.
|
|
11
|
+
*/export var PromoCardContext=/*#__PURE__*/createContext(defaultPromoCardContext);/**
|
|
12
|
+
* A custom hook for accessing the PromoCard context object.
|
|
13
|
+
*
|
|
14
|
+
* The `usePromoCardContext` hook is used to access the PromoCard context object
|
|
15
|
+
* from within a child PromoCard component. It throws an error if the context
|
|
16
|
+
* object is not available, which can help with debugging and development.
|
|
17
|
+
*
|
|
18
|
+
* @returns {PromoCardContextType} - The PromoCard context object.
|
|
19
|
+
*/export var usePromoCardContext=function(){return useContext(PromoCardContext)};export default PromoCardContext;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.regexp.to-string.js";import{render,screen}from"@testing-library/react";import React from"react";import{PromoCardContext,usePromoCardContext}from"./PromoCardContext";// A simple component that consumes the context
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var TestComponent=function(){var a=usePromoCardContext();return/*#__PURE__*/_jsxs("div",{children:[/*#__PURE__*/_jsx("p",{children:"Value: ".concat(a.state)}),/*#__PURE__*/_jsx("p",{children:"Disabled: ".concat(a.isDisabled.toString())})]})};describe("PromoCardContext",function(){it("default values are accessible",function(){var a={state:"",isDisabled:!1,onChange:jest.fn()// You can mock this function for testing
|
|
3
|
+
};render(/*#__PURE__*/_jsx(PromoCardContext.Provider,{value:a,children:/*#__PURE__*/_jsx(TestComponent,{})})),expect(screen.getByText("Value:")).toBeInTheDocument(),expect(screen.getByText("Disabled: false")).toBeInTheDocument()}),it("context value changes are reflected",function(){var a={state:"new value",isDisabled:!0,onChange:jest.fn()// You can mock this function for testing
|
|
4
|
+
};render(/*#__PURE__*/_jsx(PromoCardContext.Provider,{value:a,children:/*#__PURE__*/_jsx(TestComponent,{})})),expect(screen.getByText("Value: new value")).toBeInTheDocument(),expect(screen.getByText("Disabled: true")).toBeInTheDocument()})});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import classNames from"classnames";import React,{useState,useEffect,useMemo}from"react";import PromoCardContext from"./PromoCardContext";import{jsx as _jsx}from"react/jsx-runtime";/**
|
|
2
|
+
* PromoCardGroup component.
|
|
3
|
+
*
|
|
4
|
+
* A PromoCardGroup is a container for PromoCard components that allows the user to select one or more
|
|
5
|
+
* cards from a group. It can be used to display a set of related options, and can be customized with
|
|
6
|
+
* various props to suit different use cases.
|
|
7
|
+
*
|
|
8
|
+
* @param {ReactNode} children - The PromoCard components to display inside the group.
|
|
9
|
+
* @param {string} className - Optional class name(s) to add to the group container.
|
|
10
|
+
* @param {string} defaultChecked - The default value for the group.
|
|
11
|
+
* @param {string} id - Optional ID to add to the group container.
|
|
12
|
+
* @param {boolean} isDisabled=false - Whether the group is disabled or not.
|
|
13
|
+
* @param {string} label - Optional label to display above the group.
|
|
14
|
+
* @param {Function} onChange - Optional function to call when the group value changes.
|
|
15
|
+
* @param {string} testId - Optional ID to add to the group container for testing purposes.
|
|
16
|
+
* @returns {JSX.Element} - The PromoCardGroup component.
|
|
17
|
+
*/var PromoCardGroup=function(a){var b=a.children,c=a.className,d=a.defaultChecked,e=void 0===d?"":d,f=a.id,g=a.isDisabled,h=void 0!==g&&g,i=a.onChange,j=void 0===i?function(){}:i,k=a.testId,l=useState(e),m=_slicedToArray(l,2),n=m[0],o=m[1],p=useState(null),q=_slicedToArray(p,2),r=q[0],s=q[1],t=useMemo(function(){return{state:n,isDisabled:h,onChange:function handleOnChange(a){o(a),j(a)}}},[n,h,j]),u=classNames(_defineProperty({"np-CardGroup":!0,"is-disabled":h},"".concat(c||""),c));return useEffect(function(){var a,c;o(e);// Collect an array of types from the children PromoCard components
|
|
18
|
+
var d=null!==(a=null===(c=React.Children.map(b,function(a){return/*#__PURE__*/React.isValidElement(a)&&a.props.type?a.props.type:null}))||void 0===c?void 0:c.filter(function(a){return null!==a&&void 0!==a}))&&void 0!==a?a:[],f=d.every(function(a){return a===d[0]});// Check if all types are the same
|
|
19
|
+
s(f&&"radio"===d[0]?"radiogroup":null)},[e,b]),/*#__PURE__*/_jsx(PromoCardContext.Provider,{value:t,children:/*#__PURE__*/_jsx("div",_objectSpread(_objectSpread({},{className:u,id:f,"data-testid":k,role:r// Add the role attribute here
|
|
20
|
+
}),{},{children:b}))})};export default/*#__PURE__*/React.memo(PromoCardGroup);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{render,screen}from"@testing-library/react";import PromoCard from"./PromoCard";import PromoCardGroup from"./PromoCardGroup";import{jsx as _jsx}from"react/jsx-runtime";describe("PromoCardGroup",function(){var a,b={title:"Test Card",description:"Test Description",imageSource:"https://via.placeholder.com/150",type:"radio"},c={testId:"test-promo-card-group",children:[/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),{},{testId:"test-1",value:"radio-1",id:"radio-1"}),"radio-1"),/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),{},{testId:"test-2",value:"radio-2",id:"radio-2"}),"radio-2")]};beforeEach(function(){var b=render(/*#__PURE__*/_jsx(PromoCardGroup,_objectSpread({},c))),d=b.rerender;a=function(a){d(/*#__PURE__*/_jsx(PromoCardGroup,_objectSpread(_objectSpread({},c),a)))}}),it("matches snapshot",function(){var a=render(/*#__PURE__*/_jsx(PromoCardGroup,_objectSpread({},c))),b=a.container;expect(b.firstChild).toMatchSnapshot()}),it("renders",function(){var d=_objectSpread(_objectSpread({},c),{},{children:[/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),{},{type:"checkbox",testId:"test-3",value:"radio-3"}),"radio-3"),/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),{},{type:"checkbox",testId:"test-4",value:"radio-4"}),"radio-4")]});// Change children
|
|
2
|
+
expect(screen.getByTestId("test-promo-card-group")).toBeInTheDocument(),expect(screen.getByTestId("test-promo-card-group")).toHaveClass("np-CardGroup"),expect(screen.getByRole("radiogroup")).toBeInTheDocument(),a(d),expect(screen.getByTestId("test-4")).toBeInTheDocument()}),it("sets the `defaultValue` for the group",function(){var b=_objectSpread(_objectSpread({},c),{},{defaultChecked:"radio-1"});// Change children
|
|
3
|
+
expect(screen.getByTestId("test-1")).not.toHaveClass("is-checked"),a(b),expect(screen.getByTestId("test-1")).toHaveClass("is-checked")}),it("not to render as a `radiogroup` if we have a mix of PromoCard types",function(){var d=_objectSpread(_objectSpread({},c),{},{children:[/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),{},{type:"checkbox",testId:"test-3",value:"radio-3"}),"radio-3"),/*#__PURE__*/_jsx(PromoCard,_objectSpread(_objectSpread({},b),{},{type:"checkbox",testId:"test-4 ",value:"radio-4"}),"radio-4")]});// Change children
|
|
4
|
+
expect(screen.getByRole("radiogroup")).toBeInTheDocument(),a(d),expect(screen.queryByRole("radiogroup")).not.toBeInTheDocument(),expect(screen.getByTestId("test-4")).toBeInTheDocument()}),it("applies `is-disabled` class to all children when isDisabled is true",function(){var b=_objectSpread(_objectSpread({},c),{},{isDisabled:!0});// Change children
|
|
5
|
+
expect(screen.getByTestId("test-1")).not.toHaveClass("is-disabled"),expect(screen.getByTestId("test-2")).not.toHaveClass("is-disabled"),a(b),expect(screen.getByTestId("test-1")).toHaveClass("is-disabled"),expect(screen.getByTestId("test-2")).toHaveClass("is-disabled")})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import PromoCard from"./PromoCard";import PromoCardGroup from"./PromoCardGroup";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PromoCards=function(){return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(PromoCard,{title:"Digital",description:"A card that lives online and works anywhere. Easy, secure, and always on hand.",type:"radio",value:"digital",id:"digital",imageAlt:"",indicatorLabel:"Free",imageSource:"https://wise.com/web-art/assets/illustrations/digital-card-2-medium@2x.webp"}),/*#__PURE__*/_jsx(PromoCard,{title:"Standard",description:"Spend and withdraw money around the world. In your wallet and on your side.",type:"radio",value:"standard",id:"standard",imageAlt:"",indicatorLabel:"7 GBP",imageSource:"https://wise.com/web-art/assets/illustrations/personal-card-medium@2x.webp"}),/*#__PURE__*/_jsx(PromoCard,{title:"Eco",description:"A debit card made to biodegrade \u2014 no toxic gases, no toxic fees.",type:"radio",value:"eco",id:"eco",imageAlt:"",indicatorLabel:"9 GBP",imageSource:"https://wise.com/web-art/assets/illustrations/eco-card-medium@2x.webp"})]})},meta={component:PromoCardGroup,title:"Layouts/PromoCardGroup",tags:["autodocs"]};export default meta;export var Default={args:{children:/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsx(PromoCards,{})})}};export var DefaultChecked={args:{children:/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsx(PromoCards,{})}),defaultChecked:"standard"}};export var Disabled={args:{children:/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsx(PromoCards,{})}),isDisabled:!0}};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","children","label","icon","testid"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{ArrowRight,Check,Download}from"@transferwise/icons";import classNames from"classnames";import Body from"../body";import{Typography}from"../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
|
+
* PromoCardIndicator component.
|
|
3
|
+
*
|
|
4
|
+
* A PromoCardIndicator is a small component that can be used to display
|
|
5
|
+
* additional information or actions related to a PromoCard. It can be
|
|
6
|
+
* customized with various props to suit different use cases.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} className - Optional class name(s) to add to the indicator container.
|
|
9
|
+
* @param {string} label - Optional label to display next to the indicator.
|
|
10
|
+
* @param {string} icon - Optional icon to display in the indicator.
|
|
11
|
+
* @param {string} testid - Optional ID to add to the indicator container for testing purposes.
|
|
12
|
+
* @param {ReactNode} children - Optional children to display inside the indicator.
|
|
13
|
+
* @returns {JSX.Element} - The PromoCardIndicator component.
|
|
14
|
+
* @example
|
|
15
|
+
* <PromoCardIndicator label="Download" icon="download" />
|
|
16
|
+
*/var PromoCardIndicator=function(a){var b=a.className,c=a.children,d=a.label,e=a.icon,f=a.testid,g=_objectWithoutProperties(a,_excluded),h=e&&{check:Check,arrow:ArrowRight,download:Download}[e];return/*#__PURE__*/_jsxs("div",_objectSpread(_objectSpread({className:classNames("np-Card-indicator",b),"data-testid":f},g),{},{children:[d&&/*#__PURE__*/_jsx(Body,{as:"span",type:Typography.BODY_LARGE_BOLD,className:"np-Card-indicatorText",children:d}),h&&/*#__PURE__*/_jsx("span",{className:"np-Card-indicatorIcon",children:/*#__PURE__*/_jsx(h,{size:24,"aria-hidden":"true"})}),c]}))};export default PromoCardIndicator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default}from"./PromoCard";export{default as PromoCardGroup}from"./PromoCardGroup";
|