@preply/ds-docs 3.1.1-beta.060c7778978d1ba1488656e79c5f79997a641cf1.0 → 3.1.1-beta.857b0ab30a03b836ac6c63997eeb17f464e3510c.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/dist/assets/{00.LayoutFlex.stories-YROUuJkm.js → 00.LayoutFlex.stories-Dx9Eo2na.js} +1 -1
- package/dist/assets/{00.applications-BPe3Juew.js → 00.applications-4_kAf65R.js} +1 -1
- package/dist/assets/{00.favicons.guide-DWDWSitD.js → 00.favicons.guide-WmsjYzsU.js} +1 -1
- package/dist/assets/{00.token-explorer-DlqZUQi1.js → 00.token-explorer-DDWWO9yw.js} +1 -1
- package/dist/assets/{00.using-responsive-props-BZFzeMkI.js → 00.using-responsive-props-Db1CE2Bn.js} +1 -1
- package/dist/assets/{01.semantic-tokens-B_maulUL.js → 01.semantic-tokens-BGh7M0eY.js} +1 -1
- package/dist/assets/{01.using-shorthand-props-CSdvELZ-.js → 01.using-shorthand-props-DlhDhuqe.js} +1 -1
- package/dist/assets/10.Combinations.stories-Wf-NooK0.js +144 -0
- package/dist/assets/{10.fonts.guide-BLGdEszm.js → 10.fonts.guide-9-b6LwTC.js} +1 -1
- package/dist/assets/{10.ssr-D2wS7usx.js → 10.ssr-VCBg9dbk.js} +1 -1
- package/dist/assets/{11.languageFont.explorer-CYToRovn.js → 11.languageFont.explorer-fCUE9Req.js} +1 -1
- package/dist/assets/{11.ssr.app-router-CCyVK3T0.js → 11.ssr.app-router-DK46wtcG.js} +1 -1
- package/dist/assets/{20.libraries-BSl9ePSH.js → 20.libraries-FpWvhQac.js} +1 -1
- package/dist/assets/{30.icons.explorer-CbyFZ1KX.js → 30.icons.explorer-CIrIe9zZ.js} +1 -1
- package/dist/assets/{30.storybook-DQuFtvdR.js → 30.storybook-8XKIrOG2.js} +1 -1
- package/dist/assets/{40.illustrations.explorer-ZH_64QsN.js → 40.illustrations.explorer-DWDPZG1O.js} +1 -1
- package/dist/assets/{90.advanced-B8SjZIIy.js → 90.advanced-BrSJ75kb.js} +1 -1
- package/dist/assets/{Accordion-CVZIOGNR.js → Accordion-Bn_7bQpK.js} +3 -3
- package/dist/assets/{Accordion.stories-o4h_sY0V.js → Accordion.stories-IHPoH-rI.js} +1 -1
- package/dist/assets/{Accordion.tests.stories-DqGSOkGv.js → Accordion.tests.stories-D80ku7JR.js} +1 -1
- package/dist/assets/{AlertDialog.stories-BuacQngv.js → AlertDialog.stories-BDaUfcmP.js} +1 -1
- package/dist/assets/{Avatar-D_mKYr5W.js → Avatar-BkCAqOuF.js} +1 -1
- package/dist/assets/{Avatar--Me1wFbM.js → Avatar-D6BKQVaH.js} +1 -1
- package/dist/assets/{Avatar.stories-CGQDYNGY.js → Avatar.stories-DnjfAeSV.js} +1 -1
- package/dist/assets/{AvatarWithStatus.stories-5qjPY64Z.js → AvatarWithStatus.stories-CocgTI5A.js} +1 -1
- package/dist/assets/{Badge.stories-DhBazbPH.js → Badge.stories-BxGvNozr.js} +1 -1
- package/dist/assets/{Box.stories-DYxm40b1.js → Box.stories-BCCuYnrC.js} +1 -1
- package/dist/assets/{Button-etPAfZn6.js → Button-BumqXQgN.js} +2 -2
- package/dist/assets/{Button-Cypl3yDn.js → Button-klA2GCDX.js} +1 -1
- package/dist/assets/{Button.stories-zCdl6A4v.js → Button.stories-DA25kI-7.js} +1 -1
- package/dist/assets/{ButtonBase-CiON5Gq9.js → ButtonBase-OAaaGRgi.js} +1 -1
- package/dist/assets/{Checkbox-PK_lzd6o.js → Checkbox-CsXsO8bL.js} +2 -2
- package/dist/assets/{Checkbox.stories-DPCtwQEk.js → Checkbox.stories-C-vlyqxy.js} +1 -1
- package/dist/assets/{Checkbox.tests.stories-CmARszTI.js → Checkbox.tests.stories-Bn0cGiYz.js} +1 -1
- package/dist/assets/{Chips.stories-C3XJafXG.js → Chips.stories-Dln8xBho.js} +1 -1
- package/dist/assets/{Color-YHDXOIA2-R6sgjhMY.js → Color-YHDXOIA2-DdMC8kO4.js} +1 -1
- package/dist/assets/CountryFlag-CJV53jf1.js +48 -0
- package/dist/assets/CountryFlag-p-8M_k5M.css +1 -0
- package/dist/assets/{Dialog.stories-CLyDuYn9.js → Dialog.stories-C7JVGkL3.js} +2 -2
- package/dist/assets/{DocsRenderer-CFRXHY34-Bub8-jZR.js → DocsRenderer-CFRXHY34-BUR9I9U1.js} +1 -1
- package/dist/assets/{FieldButton-Dprr9FF4.js → FieldButton-xxvyfVcj.js} +1 -1
- package/dist/assets/{FieldButton.stories-BuA4NyAH.js → FieldButton.stories-1kY40W8X.js} +1 -1
- package/dist/assets/Flag.stories-Bfpeo5_i.js +110 -0
- package/dist/assets/Flag.test.stories-GCtORN0m.js +27 -0
- package/dist/assets/FormControl-DD3JEwg1.js +5 -0
- package/dist/assets/{FormControl.stories-D83_07EZ.js → FormControl.stories-DoVURnEB.js} +1 -1
- package/dist/assets/{Heading-BSlUFvxo.js → Heading-D79pA8cG.js} +2 -2
- package/dist/assets/{Heading.stories-CsCslhOn.js → Heading.stories-FhR8Ieuz.js} +1 -1
- package/dist/assets/{Icon-Cx1Om39U.js → Icon-D4cMo1we.js} +2 -2
- package/dist/assets/{Icon-RSC-De70zQQg.js → Icon-RSC-Yp03gSP9.js} +1 -1
- package/dist/assets/{Icon-Clsj4XP8.js → Icon-zcBK8bUG.js} +1 -1
- package/dist/assets/{Icon.stories-Batx6hcA.js → Icon.stories-DlJ1cDyb.js} +1 -1
- package/dist/assets/IconButton-DNz6Hldb.js +8 -0
- package/dist/assets/{Input-B5nl0Iyd.js → Input-B7MlX4U9.js} +7 -7
- package/dist/assets/{IntegrationWithReactHookForm.stories-BoWMVLOX.js → IntegrationWithReactHookForm.stories-CFvk5m0u.js} +1 -1
- package/dist/assets/{LayoutFlex-Dp29ojjO.js → LayoutFlex-DsiZkqdg.js} +1 -1
- package/dist/assets/{LayoutFlex-DT7eMWg5.js → LayoutFlex-oRwI31fW.js} +1 -1
- package/dist/assets/LayoutFlexItem-RxfNp994.js +1 -0
- package/dist/assets/{LayoutGrid-D9R6yTYX.js → LayoutGrid-6cTmb1jX.js} +1 -1
- package/dist/assets/LayoutGrid.stories-CAvHZzVw.js +88 -0
- package/dist/assets/LayoutGridItem-AvP_ZkC5.js +1 -0
- package/dist/assets/{LayoutGridItem-B1eMKElL.js → LayoutGridItem-CVWVBh65.js} +1 -1
- package/dist/assets/LayoutGridItem-Dy4Q8woN.css +1 -0
- package/dist/assets/{Link.stories-DWbasHUE.js → Link.stories-Kb5m59aP.js} +2 -2
- package/dist/assets/{Loader.stories-Dv3ubOhZ.js → Loader.stories-CFBO-7A0.js} +1 -1
- package/dist/assets/NumberField-DyKjoAC-.js +4 -0
- package/dist/assets/{NumberField.stories-D74rSbUs.js → NumberField.stories-D-g-_JoA.js} +7 -7
- package/dist/assets/{ObserveIntersection-BM5DGF0-.js → ObserveIntersection-CvDmrhxS.js} +2 -2
- package/dist/assets/{ObserveIntersection.stories-EyGedr3b.js → ObserveIntersection.stories-CJbpJ7AX.js} +1 -1
- package/dist/assets/{OnboardingTooltip-_5vI5YX1.js → OnboardingTooltip-Lspn1J1n.js} +1 -1
- package/dist/assets/{OnboardingTooltip.stories-zAMAeQy1.js → OnboardingTooltip.stories-BSTAbBKq.js} +1 -1
- package/dist/assets/{OnboardingTooltip.tests.stories-DAxkQF6H.js → OnboardingTooltip.tests.stories-C3TfZDQZ.js} +1 -1
- package/dist/assets/{OnboardingTour-Bs65E3B_.js → OnboardingTour-J68z1zuj.js} +1 -1
- package/dist/assets/{OnboardingTour.stories-L4wR5VUD.js → OnboardingTour.stories-D3Z3aBlG.js} +2 -2
- package/dist/assets/{OnboardingTour.tests.stories-D9DB8HzR.js → OnboardingTour.tests.stories-DgM_E88t.js} +1 -1
- package/dist/assets/PasswordField-BkVjxPtF.js +4 -0
- package/dist/assets/{PasswordField.stories-BWnTPMMy.js → PasswordField.stories-CoxGxN0y.js} +7 -7
- package/dist/assets/{PreplyLogo.stories-CKZvG96R.js → PreplyLogo.stories-CoKY5vmY.js} +2 -2
- package/dist/assets/{ProgressBar.stories-BO6-xzZ9.js → ProgressBar.stories-D-zAEKVA.js} +1 -1
- package/dist/assets/{ProgressSteps-ByDec2fC.js → ProgressSteps-CuGX9_Fy.js} +1 -1
- package/dist/assets/{ProgressSteps.stories-CaGz9UvI.js → ProgressSteps.stories-BZpbJxJ4.js} +1 -1
- package/dist/assets/{SelectField-M6d20_vW.js → SelectField-DVUeHaUI.js} +12 -14
- package/dist/assets/{SelectField.stories-C8b5ZtGG.js → SelectField.stories-l2h7AeUs.js} +8 -8
- package/dist/assets/{ShowOnIntersection.stories-CkN1WDGU.js → ShowOnIntersection.stories-B24bNVFn.js} +1 -1
- package/dist/assets/{Steps-C32suZpN.js → Steps-Cnv3Nys-.js} +1 -1
- package/dist/assets/{Steps.stories-Bb8vy8e1.js → Steps.stories-DcSCPhwD.js} +1 -1
- package/dist/assets/{Text-DmTAIIVj.js → Text-C3jprdij.js} +1 -1
- package/dist/assets/{Text.stories-D1y5agve.js → Text.stories-CGHOveiR.js} +1 -1
- package/dist/assets/TextField-872WjatY.js +1 -0
- package/dist/assets/TextField-X8bB9C1g.js +4 -0
- package/dist/assets/{TextField.stories-Db1NKI4j.js → TextField.stories-DQBz69MT.js} +8 -8
- package/dist/assets/{TextHighlighted-CfvNH8PY.js → TextHighlighted-B7-aMGmA.js} +1 -1
- package/dist/assets/{TextHighlighted.stories-PV3yANaI.js → TextHighlighted.stories-BepOj0Ru.js} +1 -1
- package/dist/assets/{TextInline.stories-fEzj3mnz.js → TextInline.stories-E8plGh4A.js} +1 -1
- package/dist/assets/{TextareaField-DzHn3ZB3.js → TextareaField-vuK19L40.js} +12 -14
- package/dist/assets/{TextareaField.stories-BlMt3RhU.js → TextareaField.stories-CykA4cDO.js} +8 -8
- package/dist/assets/{Toast.stories-BeSJa7YF.js → Toast.stories-Bi9S1Grd.js} +1 -1
- package/dist/assets/{Tooltip-DYI-etfB.js → Tooltip-hS-9HVfR.js} +1 -1
- package/dist/assets/{Tooltip.stories-BY_kLvYK.js → Tooltip.stories-B1e9vr5u.js} +1 -1
- package/dist/assets/{Tooltip.tests.stories-CtFfR3fb.js → Tooltip.tests.stories-QA7Lh6Tu.js} +1 -1
- package/dist/assets/align-self-BM6l9H5Z.js +1 -0
- package/dist/assets/{breakpoints-fH9dYJAl.js → breakpoints-CmMCxJmD.js} +1 -1
- package/dist/assets/{breakpoints-20WyVwJ6.js → breakpoints-CpqGBjYO.js} +1 -1
- package/dist/assets/{breakpoints-D63eyxc3.js → breakpoints-ysnexzv-.js} +1 -1
- package/dist/assets/{changelog-CZp0K-Th.js → changelog-COau0gJf.js} +1 -1
- package/dist/assets/componentNames-CVVyamkx.js +1 -0
- package/dist/assets/{entry-preview-Beai-Ttn.js → entry-preview-C4N2xCt5.js} +1 -1
- package/dist/assets/{getTokenVar-CaYACIxq.js → getTokenVar-CUHKNeJD.js} +1 -1
- package/dist/assets/{hover-D1ok7rID.js → hover-DXcaKjLt.js} +1 -1
- package/dist/assets/{hover-BWX0MqdU.js → hover-GSE0CvmS.js} +1 -1
- package/dist/assets/{hover-CSM1irGv.js → hover-VvQeuGyg.js} +1 -1
- package/dist/assets/{iframe-BJQSUUXK.js → iframe-D0A79CBI.js} +2 -2
- package/dist/assets/{index-C9qzZweZ.js → index-DJz3jMTz.js} +3 -3
- package/dist/assets/{index-C4N2QXGu.js → index-DueYSiMN.js} +1 -1
- package/dist/assets/{intro-ukuXiDOx.js → intro-UMrunOuq.js} +1 -1
- package/dist/assets/{migrating-from-less-JoAfxRIi.js → migrating-from-less-BqEJZLZ5.js} +1 -1
- package/dist/assets/{playground-CCc6VR51.css → playground-DBdZFxjC.css} +1 -1
- package/dist/assets/{playground.stories-BODyPOuN.js → playground.stories-BhNG8Jgk.js} +165 -165
- package/dist/assets/{preview-DHlsZwR4.js → preview-Bk7AZmud.js} +1 -1
- package/dist/assets/{preview-DJuzriZr.js → preview-CcucgJy3.js} +1 -1
- package/dist/assets/{preview-QL9aHs0E.js → preview-iHfxidwg.js} +2 -2
- package/dist/assets/{tokens-HWgzrI-u.js → tokens-BuSmlz1z.js} +1 -1
- package/dist/assets/{tokens-BecRNN80.js → tokens-D0SjH8dK.js} +1 -1
- package/dist/assets/{tokens-C8vVARpG.js → tokens-DOJLI2G7.js} +1 -1
- package/dist/assets/{usePortalElement-BtPCQHPX.js → usePortalElement-Byczyvc6.js} +1 -1
- package/dist/assets/{welcome-CN1zQ6D8.js → welcome-CFbV1cfg.js} +1 -1
- package/dist/assets/{zeroheight-C3flYOQk.js → zeroheight-ChMVcLJ3.js} +1 -1
- package/dist/iframe.html +1 -1
- package/dist/index.json +1 -1
- package/dist/preview-stats.json +1125 -1014
- package/dist/project.json +1 -1
- package/package.json +3 -3
- package/dist/assets/10.Combinations.stories-6ywklR8I.js +0 -144
- package/dist/assets/FormControl-V3kzTeDQ.js +0 -7
- package/dist/assets/IconButton-CUUvxhBi.js +0 -8
- package/dist/assets/LayoutFlexItem-CemO2cFY.js +0 -1
- package/dist/assets/LayoutGrid-mQT2ikS8.css +0 -1
- package/dist/assets/LayoutGrid.stories-D1JxCWQq.js +0 -88
- package/dist/assets/NumberField-tAVhOkam.js +0 -6
- package/dist/assets/PasswordField-CmREo8SU.js +0 -6
- package/dist/assets/TextField-CDlYWWnq.js +0 -1
- package/dist/assets/TextField-Cbt-ocgZ.js +0 -6
- package/dist/assets/componentNames-Ba2ybP0W.js +0 -1
- package/dist/assets/layout-relative-BpJIh3YK.js +0 -1
- /package/dist/assets/{layout-relative-C4ATemga.css → align-self-C4ATemga.css} +0 -0
@@ -1,7 +1,7 @@
|
|
1
|
-
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{T as n}from"./Text-
|
1
|
+
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{T as n}from"./Text-C3jprdij.js";import{r as k}from"./index-B3evPFBL.js";import{f as Q}from"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import{g as Z}from"./defaults-B1rzzf6M.js";import{u as ee}from"./useHostname-CH18gHFj.js";import{m as ae,s as x,b as f}from"./classNames-BUL1Zq7e.js";import{w as y}from"./componentNames-CVVyamkx.js";import{a as ne,g as te}from"./index-DdzHuZ-Y.js";import{g as d}from"./getTokenVar-DU_DEzTd.js";import{c as u}from"./tokens-DXy5hgn5.js";import"./text-accent-DZDDtpIt.js";import"./text-centered-CznToR0o.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./constants-BgBLeZzp.js";const re="Link__Jw0hc",ie={Link:re,"Link--inline":"Link--inline__aWJxC","Link--noUnderline":"Link--noUnderline__vuCBO","Link--variant-accentDark":"Link--variant-accentDark__5RCSd","Link--variant-accentDark--dsInternalSimulation-hover":"Link--variant-accentDark--dsInternalSimulation-hover__5vv1U","Link--variant-accentDark--dsInternalSimulation-active":"Link--variant-accentDark--dsInternalSimulation-active__-PYgd","Link--variant-accentDarkInverted":"Link--variant-accentDarkInverted__5GVfk","Link--variant-accentDarkInverted--dsInternalSimulation-hover":"Link--variant-accentDarkInverted--dsInternalSimulation-hover__u7g4B","Link--variant-accentDarkInverted--dsInternalSimulation-active":"Link--variant-accentDarkInverted--dsInternalSimulation-active__4bGgk","Link--variant-neutral":"Link--variant-neutral__v0PFp","Link--variant-neutral--dsInternalSimulation-hover":"Link--variant-neutral--dsInternalSimulation-hover__L-hBv","Link--variant-neutral--dsInternalSimulation-active":"Link--variant-neutral--dsInternalSimulation-active__5rs0z","Link--variant-neutralInverted":"Link--variant-neutralInverted__t9Ijl","Link--variant-neutralInverted--dsInternalSimulation-hover":"Link--variant-neutralInverted--dsInternalSimulation-hover__H50Xt","Link--variant-neutralInverted--dsInternalSimulation-active":"Link--variant-neutralInverted--dsInternalSimulation-active__Irr0h","Link--variant-unsetColors":"Link--variant-unsetColors__EEbF5","Link--variant-unsetColors--dsInternalSimulation-hover":"Link--variant-unsetColors--dsInternalSimulation-hover__vMIu6","Link--variant-unsetColors--dsInternalSimulation-active":"Link--variant-unsetColors--dsInternalSimulation-active__wlGTN"},a=k.forwardRef(function(E,P){const{variant:v=Z,href:R,download:A,opensInNewTab:H,nofollow:M,assistiveText:B,onClick:O,as:p,url:F,dataset:G,children:m,inline:J,dsInternalSimulation:z,noUnderline:W,...X}=E,$=ee(),K=ae(ie,y.Link,[x(`variant-${v}--dsInternalSimulation`,z),x("variant",v),f("inline",void 0,J),f("noUnderline",void 0,W)]),c=R||F,Y=c?ne($,c,H,M):{},h={...Q(X),ref:P,href:c,download:A,"aria-label":B,onClick:O,className:K.join(" "),...te(G,{preplyDsComponent:y.Link})};return p?k.cloneElement(p,{...h},m):e.jsx("a",{...h,...Y,children:m})});try{a.displayName="Link",a.__docgenInfo={description:`This is an inline element and will inherit font-size, line-height and
|
2
2
|
font-weight from the parent context. If you need to customise any of these
|
3
3
|
styles, all you have to do is wrap the <Link> in a Text or TextInline
|
4
|
-
component.`,displayName:"Link",props:{variant:{defaultValue:null,description:"",name:"variant",required:!1,type:{name:"enum",value:[{value:'"accentDark"'},{value:'"
|
4
|
+
component.`,displayName:"Link",props:{variant:{defaultValue:null,description:"",name:"variant",required:!1,type:{name:"enum",value:[{value:'"accentDark"'},{value:'"neutral"'},{value:'"accentDarkInverted"'},{value:'"neutralInverted"'},{value:'"unsetColors"'}]}},href:{defaultValue:null,description:"",name:"href",required:!1,type:{name:"enum",value:[{value:"string"}]}},download:{defaultValue:null,description:`When provided, instructs the browser to download the target (the file
|
5
5
|
specified in the href attribute) when a user clicks on the hyperlink,
|
6
6
|
rather than display it in the browser.`,name:"download",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},opensInNewTab:{defaultValue:null,description:"If `true`, forces internal link to open in a new tab.",name:"opensInNewTab",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},nofollow:{defaultValue:null,description:"",name:"nofollow",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},assistiveText:{defaultValue:null,description:"Provide an `aria-label` to the link.\nThis is useful if the link wraps non-textual elements, eg. an `img`.",name:"assistiveText",required:!1,type:{name:"enum",value:[{value:"string"}]}},onClick:{defaultValue:null,description:"",name:"onClick",required:!1,type:{name:"enum",value:[{value:"MouseEventHandler<Element>"}]}},as:{defaultValue:null,description:"",name:"as",required:!1,type:{name:"enum",value:[{value:"ReactElement<any, string | JSXElementConstructor<any>>"}]}},url:{defaultValue:null,description:"@deprecated Use `href` instead",name:"url",required:!1,type:{name:"enum",value:[{value:"string"}]}},dataset:{defaultValue:null,description:`Sets data attributes on the DOM element.
|
7
7
|
@example <Avatar dataset={{ 'qa-id': 'user-avatar' }} /> // will add data-qa-id="user-avatar" to the HTML element`,name:"dataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},inline:{defaultValue:null,description:"If `true`, allows the link to wrap within text.",name:"inline",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},noUnderline:{defaultValue:null,description:"",name:"noUnderline",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},ref:{defaultValue:null,description:"Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null`\n(or call the ref with `null` if you passed a callback ref).\n@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}",name:"ref",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"(instance: HTMLAnchorElement | null) => void"},{value:"RefObject<HTMLAnchorElement>"}]}},key:{defaultValue:null,description:"",name:"key",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"bigint"}]}}}}}catch{}const Le={title:"components/Link",component:a},r=()=>{const t=d(u.background.primaryInverted);return e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(a,{href:"https://preply.com",variant:"neutral",children:"neutral"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"neutralInverted",children:"neutralInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"accentDark",children:"accentDark"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"accentDarkInverted",children:"accentDarkInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"unsetColors",children:"unsetColors"})]})},i=()=>{const t=d(u.background.primaryInverted);return e.jsxs("div",{style:{display:"flex",gap:"16px",flexDirection:"column"},children:[e.jsx(n,{variant:"default-regular-italic",children:"(use the `unsetColors` variant)"}),e.jsxs("div",{children:[e.jsx(n,{variant:"large-semibold-italic",children:"primary"}),e.jsx(n,{variant:"default-regular-italic",children:"normal"}),e.jsxs(n,{accent:"primary",children:["Lorem ipsum ",e.jsx(a,{variant:"unsetColors",children:"dolor sit amet"})," amet."]}),e.jsx(n,{variant:"default-regular-italic",children:"active"}),e.jsxs(n,{accent:"primary",children:["Lorem ipsum"," ",e.jsx(a,{variant:"unsetColors",dsInternalSimulation:"active",children:"dolor sit amet"})," ","amet."]})]}),e.jsxs("div",{style:{backgroundColor:t},children:[e.jsx(n,{variant:"large-semibold-italic",accent:"inverted",children:"inverted"}),e.jsx(n,{variant:"default-regular-italic",accent:"inverted",children:"normal"}),e.jsxs(n,{accent:"inverted",children:["Lorem ipsum ",e.jsx(a,{variant:"unsetColors",children:"dolor sit amet"})," amet."]}),e.jsx(n,{variant:"default-regular-italic",accent:"inverted",children:"active"}),e.jsxs(n,{accent:"inverted",children:["Lorem ipsum"," ",e.jsx(a,{variant:"unsetColors",dsInternalSimulation:"active",children:"dolor sit amet"})," ","amet."]})]}),e.jsxs("div",{children:[e.jsx(n,{variant:"large-semibold-italic",children:"positive"}),e.jsx(n,{variant:"default-regular-italic",children:"normal"}),e.jsxs(n,{accent:"positive",children:["Lorem ipsum ",e.jsx(a,{variant:"unsetColors",children:"dolor sit amet"})," amet."]}),e.jsx(n,{variant:"default-regular-italic",children:"active"}),e.jsxs(n,{accent:"positive",children:["Lorem ipsum"," ",e.jsx(a,{variant:"unsetColors",dsInternalSimulation:"active",children:"dolor sit amet"})," ","amet."]})]}),e.jsxs("div",{children:[e.jsx(n,{variant:"large-semibold-italic",children:"critical"}),e.jsx(n,{variant:"default-regular-italic",children:"normal"}),e.jsxs(n,{accent:"critical",children:["Lorem ipsum ",e.jsx(a,{variant:"unsetColors",children:"dolor sit amet"})," amet."]}),e.jsx(n,{variant:"default-regular-italic",children:"active"}),e.jsxs(n,{accent:"critical",children:["Lorem ipsum"," ",e.jsx(a,{variant:"unsetColors",dsInternalSimulation:"active",children:"dolor sit amet"})," ","amet."]})]})]})},l=()=>{const t=d(u.background.primaryInverted);return e.jsxs("div",{style:{display:"flex",gap:"16px",flexDirection:"column"},children:[e.jsx(n,{variant:"default-regular-italic",children:"normal"}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(a,{href:"https://preply.com",variant:"neutral",children:"neutral"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"neutralInverted",children:"neutralInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"accentDark",children:"accentDark"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"accentDarkInverted",children:"accentDarkInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"unsetColors",children:"unsetColors"})]}),e.jsx(n,{variant:"default-regular-italic",children:"hover"}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(a,{href:"https://preply.com",variant:"neutral",dsInternalSimulation:"hover",children:"neutral"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"neutralInverted",dsInternalSimulation:"hover",children:"neutralInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"accentDark",dsInternalSimulation:"hover",children:"accentDark"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"accentDarkInverted",dsInternalSimulation:"hover",children:"accentDarkInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"unsetColors",dsInternalSimulation:"hover",children:"unsetColors"})]}),e.jsx(n,{variant:"default-regular-italic",children:"active"}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(a,{href:"https://preply.com",variant:"neutral",dsInternalSimulation:"active",children:"neutral"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"neutralInverted",dsInternalSimulation:"active",children:"neutralInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"accentDark",dsInternalSimulation:"active",children:"accentDark"}),e.jsx("span",{style:{backgroundColor:t},children:e.jsx(a,{href:"https://preply.com",variant:"accentDarkInverted",dsInternalSimulation:"active",children:"accentDarkInverted"})}),e.jsx(a,{href:"https://preply.com",variant:"unsetColors",dsInternalSimulation:"active",children:"unsetColors"})]})]})},s=()=>e.jsxs("p",{style:{width:"12ch"},children:["Unlock your potential;"," ",e.jsx(a,{href:"https://preply.com",variant:"unsetColors",inline:!0,children:"visit Preply"}),"."]}),o={parameters:{chromatic:{disableSnapshot:!0}},args:{children:"Click me",href:"https://preply.com",variant:"neutral",dataset:{qaid:"link"}},argTypes:{dataset:{control:"object"},inline:{control:"boolean"},noUnderline:{control:"boolean"},opensInNewTab:{control:"boolean"},nofollow:{control:"boolean"},download:{control:"boolean"},assistiveText:{control:"text"},href:{control:"text"},url:{table:{disable:!0}}}};var g,L,I;r.parameters={...r.parameters,docs:{...(g=r.parameters)==null?void 0:g.docs,source:{originalSource:`() => {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{r as h}from"./index-B3evPFBL.js";import{f as z}from"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import{S as j}from"./Spinner-BCTJunNM.js";import{m as k,b as R}from"./classNames-BUL1Zq7e.js";import{w as l}from"./componentNames-
|
1
|
+
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{r as h}from"./index-B3evPFBL.js";import{f as z}from"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import{S as j}from"./Spinner-BCTJunNM.js";import{m as k,b as R}from"./classNames-BUL1Zq7e.js";import{w as l}from"./componentNames-CVVyamkx.js";import{g as N}from"./index-DdzHuZ-Y.js";import{S as C}from"./consts-KAYct7Gj.js";import{g as E}from"./getTokenVar-DU_DEzTd.js";import{c as I}from"./tokens-DXy5hgn5.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./defaults-B1rzzf6M.js";import"./constants-BgBLeZzp.js";const P="Loader__Ya6Xk",V={Loader:P,"Loader--normal":"Loader--normal__41Xzt","Loader--inverted":"Loader--inverted__NULSk"},a=h.forwardRef(function({size:t,inverted:y=!1,dataset:L,...b},S){const x=k(V,l.Loader,[R("inverted","normal",y)]),_={...z(b),ref:S,className:x.join(" "),...N(L,{preplyDsComponent:l.Loader})};return e.jsx("span",{..._,children:e.jsx(j,{size:t})})});try{a.displayName="Loader",a.__docgenInfo={description:"",displayName:"Loader",props:{size:{defaultValue:null,description:"",name:"size",required:!1,type:{name:"enum",value:[{value:'"large"'},{value:'"default"'},{value:"ResponsiveProp<SpinnerSize>"}]}},inverted:{defaultValue:{value:"false"},description:"",name:"inverted",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},dataset:{defaultValue:null,description:"",name:"dataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},ref:{defaultValue:null,description:"Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null`\n(or call the ref with `null` if you passed a callback ref).\n@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}",name:"ref",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"(instance: HTMLSpanElement | null) => void"},{value:"RefObject<HTMLSpanElement>"}]}},key:{defaultValue:null,description:"",name:"key",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"bigint"}]}}}}}catch{}const F={title:"components/Loader",component:a,argTypes:{size:{description:C}}},o=()=>e.jsxs("div",{style:{display:"flex",alignItems:"end",gap:"8px"},children:[e.jsx(a,{size:"default"}),e.jsx(a,{size:"large"})]}),n=()=>e.jsx(a,{inverted:!0});n.decorators=[r=>{const t=E(I.background.primaryInverted);return e.jsx("div",{style:{backgroundColor:t},children:r()})}];const s={parameters:{chromatic:{disableSnapshot:!0}},decorators:[(r,{args:t})=>e.jsx("div",{style:{backgroundColor:t.inverted?"black":void 0},children:r()})],args:{size:"default",inverted:!1,dataset:{qaid:"loader"}},argTypes:{dataset:{control:"object"},size:{control:"select"},inverted:{control:"boolean"}}};var d,i,c;o.parameters={...o.parameters,docs:{...(d=o.parameters)==null?void 0:d.docs,source:{originalSource:`() => <div style={{
|
2
2
|
display: 'flex',
|
3
3
|
alignItems: 'end',
|
4
4
|
gap: '8px'
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import{j as u}from"./jsx-runtime-BYouaCF_.js";import{r as q}from"./index-B3evPFBL.js";import{F as V}from"./FormControl-DD3JEwg1.js";import{w as g}from"./componentNames-CVVyamkx.js";import{I as H}from"./Input-B7MlX4U9.js";const t=q.forwardRef(function({id:i,label:d,description:s,error:m,required:o,inputDataset:p,dataset:v,hideLabel:f,onClick:c,onValueChange:e,onChange:a,hasError:y,className:I,style:L,...b},h){const E=l=>{a==null||a(l);const n=l.target.value;e==null||e(n?Number(n):void 0)};return u.jsx(V,{id:i,label:d,description:s,error:m,hasError:y,required:o,dataset:v,hideLabel:f,onClick:c,preplyDsComponent:g.NumberField,children:u.jsx(H,{...b,type:"number",ref:h,dataset:p,onChange:E})})});try{t.displayName="NumberField",t.__docgenInfo={description:"",displayName:"NumberField",props:{id:{defaultValue:null,description:`The id to be passed to the input element.
|
2
|
+
If not provided, will be generated for accessibility purposes.`,name:"id",required:!1,type:{name:"enum",value:[{value:"string"}]}},required:{defaultValue:null,description:`Indicates if the field is required. When false, adds a "Optional"
|
3
|
+
indicator next to the label.`,name:"required",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},hasError:{defaultValue:null,description:"Whether the field has an error.\n@deprecated Use `error` prop to exlicitly describe the error to users",name:"hasError",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},dataset:{defaultValue:null,description:"",name:"dataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},error:{defaultValue:null,description:"Error message to display when the field has an invalid value.",name:"error",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},label:{defaultValue:null,description:"The field label. This is needed for accessibility purposes, but can be\nhidden using the `hideLabel` prop.",name:"label",required:!0,type:{name:"enum",value:[{value:"undefined"},{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},onClick:{defaultValue:null,description:"",name:"onClick",required:!1,type:{name:"enum",value:[{value:"MouseEventHandler<HTMLDivElement> & MouseEventHandler<HTMLInputElement>"}]}},description:{defaultValue:null,description:`Additional descriptive text that appears below the input field
|
4
|
+
to provide more context or instructions to the user.`,name:"description",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},hideLabel:{defaultValue:null,description:"Use this to hide the `label` visually, but keep it in the accessibility\ntree.",name:"hideLabel",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},name:{defaultValue:null,description:"",name:"name",required:!1,type:{name:"enum",value:[{value:"string"}]}},disabled:{defaultValue:null,description:"",name:"disabled",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},onChange:{defaultValue:null,description:"",name:"onChange",required:!1,type:{name:"enum",value:[{value:"ChangeEventHandler<HTMLInputElement>"}]}},onBlur:{defaultValue:null,description:"",name:"onBlur",required:!1,type:{name:"enum",value:[{value:"FocusEventHandler<HTMLInputElement>"}]}},onFocus:{defaultValue:null,description:"",name:"onFocus",required:!1,type:{name:"enum",value:[{value:"FocusEventHandler<HTMLInputElement>"}]}},placeholder:{defaultValue:null,description:"",name:"placeholder",required:!1,type:{name:"enum",value:[{value:"string"}]}},onCopy:{defaultValue:null,description:"",name:"onCopy",required:!1,type:{name:"enum",value:[{value:"ClipboardEventHandler<HTMLInputElement>"}]}},onCut:{defaultValue:null,description:"",name:"onCut",required:!1,type:{name:"enum",value:[{value:"ClipboardEventHandler<HTMLInputElement>"}]}},onPaste:{defaultValue:null,description:"",name:"onPaste",required:!1,type:{name:"enum",value:[{value:"ClipboardEventHandler<HTMLInputElement>"}]}},onKeyDown:{defaultValue:null,description:"",name:"onKeyDown",required:!1,type:{name:"enum",value:[{value:"KeyboardEventHandler<HTMLInputElement>"}]}},onKeyUp:{defaultValue:null,description:"",name:"onKeyUp",required:!1,type:{name:"enum",value:[{value:"KeyboardEventHandler<HTMLInputElement>"}]}},button:{defaultValue:null,description:"",name:"button",required:!1,type:{name:"enum",value:[{value:"ReactElement<any, string | JSXElementConstructor<any>>"}]}},icon:{defaultValue:null,description:"",name:"icon",required:!1,type:{name:"enum",value:[{value:"ReactElement<any, string | JSXElementConstructor<any>>"}]}},readOnly:{defaultValue:null,description:"",name:"readOnly",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},maxLength:{defaultValue:null,description:"",name:"maxLength",required:!1,type:{name:"enum",value:[{value:"number"}]}},value:{defaultValue:null,description:"",name:"value",required:!1,type:{name:"enum",value:[{value:"number"}]}},defaultValue:{defaultValue:null,description:"",name:"defaultValue",required:!1,type:{name:"enum",value:[{value:"number"}]}},onValueChange:{defaultValue:null,description:"",name:"onValueChange",required:!1,type:{name:"enum",value:[{value:"(value: number | undefined) => void"}]}},min:{defaultValue:null,description:"",name:"min",required:!1,type:{name:"enum",value:[{value:"number"}]}},max:{defaultValue:null,description:"",name:"max",required:!1,type:{name:"enum",value:[{value:"number"}]}},step:{defaultValue:null,description:"",name:"step",required:!1,type:{name:"enum",value:[{value:"number"}]}},inputDataset:{defaultValue:null,description:"",name:"inputDataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},ref:{defaultValue:null,description:"Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null`\n(or call the ref with `null` if you passed a callback ref).\n@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}",name:"ref",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"(instance: HTMLInputElement | null) => void"},{value:"RefObject<HTMLInputElement>"}]}},key:{defaultValue:null,description:"",name:"key",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"bigint"}]}}}}}catch{}export{t as N};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as g}from"./jsx-runtime-BYouaCF_.js";import{r as re}from"./index-B3evPFBL.js";import{a as se}from"./chunk-D5ZWXAHU-BhFjjRSl.js";import{f as r,w as x,e as n,u as w}from"./index-DDyIDR-R.js";import{F as te}from"./TokyoUIPhone-BHLDT6dz.js";import{F as ie}from"./TokyoUIAttach-BvBvQVx_.js";import{I as ne}from"./Icon-
|
1
|
+
import{j as g}from"./jsx-runtime-BYouaCF_.js";import{r as re}from"./index-B3evPFBL.js";import{a as se}from"./chunk-D5ZWXAHU-BhFjjRSl.js";import{f as r,w as x,e as n,u as w}from"./index-DDyIDR-R.js";import{F as te}from"./TokyoUIPhone-BHLDT6dz.js";import{F as ie}from"./TokyoUIAttach-BvBvQVx_.js";import{I as ne}from"./Icon-D4cMo1we.js";import{N as ae}from"./NumberField-DyKjoAC-.js";import{F as ce}from"./FieldButton-xxvyfVcj.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./v4-CtRu48qb.js";import"./text-accent-DZDDtpIt.js";import"./classNames-BUL1Zq7e.js";import"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import"./render-icon-CVTdrNe-.js";import"./componentNames-CVVyamkx.js";import"./index-DdzHuZ-Y.js";import"./defaults-B1rzzf6M.js";import"./FormControl-DD3JEwg1.js";import"./index-DRKYGVyc.js";import"./index-BfBdt3zW.js";import"./tslib.es6-BntfKcQG.js";import"./hoist-non-react-statics.cjs-C-Qo8PK8.js";import"./message-BraTJ16C.js";import"./Input-B7MlX4U9.js";import"./InputContainer-C1TOTxt4.js";const qe={title:"components/NumberField",component:ae,args:{name:"number",label:"Number",defaultValue:void 0,placeholder:"Enter a number",dataset:{testid:"field",foo:"bar"},inputDataset:{testid:"input",foo:"bar"},onChange:r(),onValueChange:r(),onBlur:r(),onFocus:r(),onClick:r(),onCopy:r(),onKeyDown:r(),onKeyUp:r(),onPaste:r()}},c={play:async({canvasElement:a,step:e,args:t})=>{const o=x(a),i=o.getByTestId("field"),s=o.getByTestId("input");await e("it should render correct label",async()=>{const oe=x(i).getByTestId("label");n(oe).toHaveTextContent("Number"),n(s).toHaveAccessibleName("Number")}),await e("it should call onFocus when the input is focused",async()=>{s.focus(),n(t.onFocus).toHaveBeenCalled()}),await e("it should call callback when the value changes",async()=>{await w.type(s,"42"),n(t.onValueChange).toHaveBeenCalledWith(42),n(t.onChange).toHaveBeenCalled()}),await e("it should call onBlur when the input is blurred",async()=>{await w.keyboard("{tab}"),n(t.onBlur).toHaveBeenCalled()}),await e("it should render the dataset props",async()=>{n(i).toHaveAttribute("data-testid","field"),n(i).toHaveAttribute("data-foo","bar"),n(s).toHaveAttribute("data-testid","input"),n(s).toHaveAttribute("data-foo","bar")})}},l={render:function(e){const[t,o]=re.useState(e.value);return g.jsx(ae,{...e,value:t,onChange:i=>{var s;o(Number(i.target.value)),(s=e.onChange)==null||s.call(e,i)}})},args:{label:"Controlled NumberField",placeholder:"Enter a number...",value:42},play:async({canvas:a,step:e})=>{await e("it should render the correct initial value",async()=>{const t=a.getByTestId("input");await n(t).toHaveValue(42)}),await e("it should update the value when the user types",async()=>{const t=a.getByTestId("input");await w.clear(t),await w.type(t,"100"),n(t).toHaveValue(100)})}},u={args:{icon:g.jsx(ne,{svg:te,dataset:{testid:"icon"}})},play:async({canvas:a,step:e})=>{await e("it should render the icon",async()=>{const t=a.getByTestId("icon");n(t).toBeInTheDocument()})}},d={args:{description:"Enter a valid number"},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input"),o=a.getByTestId("description");await e("it should render the description",async()=>{n(t).toHaveAccessibleDescription("Enter a valid number"),n(o).toHaveTextContent("Enter a valid number")})}},p={args:{required:!0},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input"),o=a.getByTestId("label");await e("it should render correct label",async()=>{n(t).toHaveAccessibleName("Number"),n(o).toHaveTextContent("Number • Required")}),await e("it should render required attribute",async()=>{n(t).toHaveAttribute("required")})}},m={args:{hideLabel:!0},play:async({canvas:a,step:e})=>{await e("it should render correct a11y label",async()=>{const t=a.getByTestId("input");n(t).toHaveAccessibleName("Number")})}},b={args:{error:"This is an error message"},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input"),o=a.getByTestId("error");await e("it should render the error message",async()=>{n(t).toHaveAccessibleErrorMessage("This is an error message"),n(o).toHaveTextContent("This is an error message")})}},h={args:{disabled:!0},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input");await e("it should render the disabled input",async()=>{n(t).toHaveAttribute("disabled")})}},y={args:{readOnly:!0},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input");await e("it should render the read only input",async()=>{n(t).toHaveAttribute("readonly")})}},v={parameters:{chromatic:{disableSnapshot:!0}},args:{label:"Number of lessons",placeholder:"How about 3?",description:"These lessons will be scheduled automatically"},argTypes:{label:{control:"text"},placeholder:{control:"text"},description:{control:"text"},error:{control:"text"},value:{control:"number"},defaultValue:{control:"number"},inputDataset:{control:"object"},dataset:{control:"object"},id:{control:"text"},required:{control:"boolean"},hideLabel:{control:"boolean"},name:{control:"text"},disabled:{control:"boolean"},readOnly:{control:"boolean"},min:{control:"number"},max:{control:"number"},step:{control:"number"},icon:{options:["None","With Icon"],mapping:{None:void 0,"With Icon":g.jsx(ne,{svg:te})},control:"select"},button:{options:["None","With Button"],mapping:{None:void 0,"With Button":g.jsx(ce,{svg:ie,assistiveText:"Do the thing",onClick:se("field button clicked")})},control:"select"},maxLength:{control:"number"},hasError:{table:{disable:!0}}}};var B,T,H,f,I;c.parameters={...c.parameters,docs:{...(B=c.parameters)==null?void 0:B.docs,source:{originalSource:`{
|
2
2
|
play: async ({
|
3
3
|
canvasElement,
|
4
4
|
step,
|
@@ -9,7 +9,7 @@ import{j as g}from"./jsx-runtime-BYouaCF_.js";import{r as re}from"./index-B3evPF
|
|
9
9
|
const input = canvas.getByTestId('input');
|
10
10
|
await step('it should render correct label', async () => {
|
11
11
|
const label = within(field).getByTestId('label');
|
12
|
-
expect(label).toHaveTextContent('Number
|
12
|
+
expect(label).toHaveTextContent('Number');
|
13
13
|
expect(input).toHaveAccessibleName('Number');
|
14
14
|
});
|
15
15
|
await step('it should call onFocus when the input is focused', async () => {
|
@@ -75,7 +75,7 @@ import{j as g}from"./jsx-runtime-BYouaCF_.js";import{r as re}from"./index-B3evPF
|
|
75
75
|
expect(icon).toBeInTheDocument();
|
76
76
|
});
|
77
77
|
}
|
78
|
-
}`,...(D=(W=u.parameters)==null?void 0:W.docs)==null?void 0:D.source}}};var V,j
|
78
|
+
}`,...(D=(W=u.parameters)==null?void 0:W.docs)==null?void 0:D.source}}};var V,q,j;d.parameters={...d.parameters,docs:{...(V=d.parameters)==null?void 0:V.docs,source:{originalSource:`{
|
79
79
|
args: {
|
80
80
|
description: 'Enter a valid number'
|
81
81
|
},
|
@@ -90,7 +90,7 @@ import{j as g}from"./jsx-runtime-BYouaCF_.js";import{r as re}from"./index-B3evPF
|
|
90
90
|
expect(description).toHaveTextContent('Enter a valid number');
|
91
91
|
});
|
92
92
|
}
|
93
|
-
}`,...(
|
93
|
+
}`,...(j=(q=d.parameters)==null?void 0:q.docs)==null?void 0:j.source}}};var R,k,L;p.parameters={...p.parameters,docs:{...(R=p.parameters)==null?void 0:R.docs,source:{originalSource:`{
|
94
94
|
args: {
|
95
95
|
required: true
|
96
96
|
},
|
@@ -102,13 +102,13 @@ import{j as g}from"./jsx-runtime-BYouaCF_.js";import{r as re}from"./index-B3evPF
|
|
102
102
|
const label = canvas.getByTestId('label');
|
103
103
|
await step('it should render correct label', async () => {
|
104
104
|
expect(input).toHaveAccessibleName('Number');
|
105
|
-
expect(label).toHaveTextContent('Number');
|
105
|
+
expect(label).toHaveTextContent('Number • Required');
|
106
106
|
});
|
107
107
|
await step('it should render required attribute', async () => {
|
108
108
|
expect(input).toHaveAttribute('required');
|
109
109
|
});
|
110
110
|
}
|
111
|
-
}`,...(L=(
|
111
|
+
}`,...(L=(k=p.parameters)==null?void 0:k.docs)==null?void 0:L.source}}};var O,P,K;m.parameters={...m.parameters,docs:{...(O=m.parameters)==null?void 0:O.docs,source:{originalSource:`{
|
112
112
|
args: {
|
113
113
|
hideLabel: true
|
114
114
|
},
|
@@ -251,4 +251,4 @@ import{j as g}from"./jsx-runtime-BYouaCF_.js";import{r as re}from"./index-B3evPF
|
|
251
251
|
}
|
252
252
|
}
|
253
253
|
}
|
254
|
-
}`,...(ee=(Z=v.parameters)==null?void 0:Z.docs)==null?void 0:ee.source}}};const
|
254
|
+
}`,...(ee=(Z=v.parameters)==null?void 0:Z.docs)==null?void 0:ee.source}}};const je=["Basic","Controlled","WithIcon","WithDescription","Required","WithHiddenLabel","HasError","Disabled","ReadOnly","Playground"];export{c as Basic,l as Controlled,h as Disabled,b as HasError,v as Playground,y as ReadOnly,p as Required,d as WithDescription,m as WithHiddenLabel,u as WithIcon,je as __namedExportsOrder,qe as default};
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import{j as b}from"./jsx-runtime-BYouaCF_.js";import{r as s}from"./index-B3evPFBL.js";import{g}from"./index-DdzHuZ-Y.js";import{L as h}from"./defaults-B1rzzf6M.js";import{w as y}from"./componentNames-
|
1
|
+
import{j as b}from"./jsx-runtime-BYouaCF_.js";import{r as s}from"./index-B3evPFBL.js";import{g}from"./index-DdzHuZ-Y.js";import{L as h}from"./defaults-B1rzzf6M.js";import{w as y}from"./componentNames-CVVyamkx.js";const o=({onIntersect:t,once:a,threshold:r,tag:l,dataset:u,children:i})=>{const e=s.useRef(null);s.useEffect(()=>{const v=([d],f)=>{d.isIntersecting&&(t(),a&&e.current&&f.unobserve(e.current))},m={threshold:r},n=new IntersectionObserver(v,m);return e.current&&n.observe(e.current),()=>n.disconnect()},[t,a,r]);const c=l??h,p={ref:e,...g(u,{preplyDsComponent:y.ObserverIntersection})};return b.jsx(c,{...p,children:i})};try{o.displayName="ObserveIntersection",o.__docgenInfo={description:`An [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) wrapper.
|
2
2
|
|
3
3
|
Triggers a callback when the wrapped component intersects with the viewport.
|
4
4
|
|
5
5
|
This can be useful in several use cases. Examples:
|
6
6
|
|
7
7
|
- Track an experiment, once a certain component scrolls into view.
|
8
|
-
- Trigger an animation, or a feature (e.g.: onboarding instructions).`,displayName:"ObserveIntersection",props:{onIntersect:{defaultValue:null,description:"",name:"onIntersect",required:!0,type:{name:"() => void"}},once:{defaultValue:null,description:"",name:"once",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},threshold:{defaultValue:null,description:"",name:"threshold",required:!1,type:{name:"enum",value:[{value:"number"}]}},tag:{defaultValue:null,description:"",name:"tag",required:!1,type:{name:"enum",value:[{value:'"p"'},{value:'"div"'},{value:'"span"'},{value:'"
|
8
|
+
- Trigger an animation, or a feature (e.g.: onboarding instructions).`,displayName:"ObserveIntersection",props:{onIntersect:{defaultValue:null,description:"",name:"onIntersect",required:!0,type:{name:"() => void"}},once:{defaultValue:null,description:"",name:"once",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},threshold:{defaultValue:null,description:"",name:"threshold",required:!1,type:{name:"enum",value:[{value:"number"}]}},tag:{defaultValue:null,description:"",name:"tag",required:!1,type:{name:"enum",value:[{value:'"p"'},{value:'"div"'},{value:'"span"'},{value:'"main"'},{value:'"header"'},{value:'"footer"'},{value:'"article"'},{value:'"section"'},{value:'"ul"'},{value:'"ol"'},{value:'"li"'},{value:'"fieldset"'},{value:'"table"'},{value:'"th"'},{value:'"tr"'},{value:'"td"'},{value:'"thead"'},{value:'"tfoot"'},{value:'"tbody"'},{value:'"caption"'},{value:'"figure"'},{value:'"figcaption"'}]}},dataset:{defaultValue:null,description:"",name:"dataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}}}}}catch{}export{o as O};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as t}from"./jsx-runtime-BYouaCF_.js";import{r as a}from"./index-B3evPFBL.js";import{O as i}from"./ObserveIntersection-
|
1
|
+
import{j as t}from"./jsx-runtime-BYouaCF_.js";import{r as a}from"./index-B3evPFBL.js";import{O as i}from"./ObserveIntersection-CvDmrhxS.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./index-DdzHuZ-Y.js";import"./defaults-B1rzzf6M.js";import"./componentNames-CVVyamkx.js";const h={title:"components/ObserveIntersection",component:i,parameters:{tags:["!test"],chromatic:{disableSnapshot:!0}}},e=()=>{const[o,c]=a.useState(!1);return t.jsxs("div",{tabIndex:0,style:{height:"200px",overflowY:"scroll",position:"relative"},children:[t.jsx("div",{style:{position:"sticky",top:"2px"},children:o?"Intersected":"Scroll down to intersect"}),t.jsx("div",{style:{height:"400px",display:"flex",alignItems:"end"},children:t.jsx(i,{onIntersect:()=>c(!0),children:"Observer"})})]})};e.storyName="ObserveIntersection";var s,n,r;e.parameters={...e.parameters,docs:{...(s=e.parameters)==null?void 0:s.docs,source:{originalSource:`() => {
|
2
2
|
const [isIntersecting, setIsIntersecting] = useState(false);
|
3
3
|
return (
|
4
4
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- This element is interactive; it's scrollable.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as t}from"./jsx-runtime-BYouaCF_.js";import{r as n}from"./index-B3evPFBL.js";import{R as _,A as q,P as x,C as O,a as N,b as E}from"./index-jPlWeKki.js";import{F as k}from"./TokyoUIClose-DFIfVIfy.js";import{I as P}from"./Icon-
|
1
|
+
import{j as t}from"./jsx-runtime-BYouaCF_.js";import{r as n}from"./index-B3evPFBL.js";import{R as _,A as q,P as x,C as O,a as N,b as E}from"./index-jPlWeKki.js";import{F as k}from"./TokyoUIClose-DFIfVIfy.js";import{I as P}from"./Icon-D4cMo1we.js";import{T as j}from"./Text-C3jprdij.js";import{B as D}from"./Button-BumqXQgN.js";import{H as T}from"./Heading-D79pA8cG.js";import{u as S}from"./index-BfBdt3zW.js";import{g as L}from"./shared-strings-CcWGHelY.js";import{g as M}from"./PortalElementProvider-D4ltrA8j.js";import{g as H}from"./index-DdzHuZ-Y.js";import{w as X}from"./componentNames-CVVyamkx.js";import{M as J}from"./message-BraTJ16C.js";const B="content__KHgp9",F="header__CaLti",U="close__3s-VD",A="footer__X5qXF",G="arrow__0pg-s",o={content:B,header:F,close:U,footer:A,arrow:G},z=e=>{e.scrollIntoViewIfNeeded?e.scrollIntoViewIfNeeded(!1):e.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})},m=({open:e,onOpenChange:i,disabled:r,title:u,text:s,children:a,side:l,dataset:h,actionLabel:g=t.jsx(J,{id:"preply-ds.onboardingTooltip.actionLabel",defaultMessage:"Got it",description:"Default onboarding tooltip action label. Used to acknowledge and close the tooltip."}),actionOnClick:b,actionHref:y,counter:C,autoScroll:v=!0})=>{const{formatMessage:I}=S(),w=M(),f=n.useId(),V=n.useId(),d=n.useId(),c=n.useRef(null);return n.useEffect(()=>{e&&c.current&&v&&z(c.current)},[v,e]),r?a:t.jsxs(_,{open:e,onOpenChange:i,children:[t.jsx(q,{ref:c,id:d,asChild:!0,children:a}),t.jsx(x,{container:w,children:t.jsxs(O,{onInteractOutside:R=>{R.preventDefault()},side:l,className:o.content,"aria-labelledby":f,"aria-describedby":`${d} ${V}`,...H(h,{preplyDsComponent:X.OnboardingTooltip}),children:[t.jsxs("div",{className:o.header,children:[t.jsx(N,{className:o.close,"aria-label":I(L.close),"data-testid":"close",children:t.jsx(P,{accent:"inverted",svg:k})}),t.jsx(T,{tag:"h1",variant:"small",accent:"inverted",id:f,"aria-describedby":d,children:u})]}),t.jsx(j,{variant:"default-regular",accent:"inverted",children:s}),t.jsxs("div",{className:o.footer,children:[C,t.jsx(D,{variant:"inverted",size:"small",onClick:b,href:y,dataset:{testid:"action"},wrap:!0,children:g})]}),t.jsx(E,{"aria-hidden":!0,className:o.arrow,width:18,height:11})]})})]})},p=e=>{const[i,r]=n.useState(!0),u=a=>{var l;a||(l=e.onClose)==null||l.call(e),r(a)},s=()=>{var a,l;(a=e.actionOnClick)==null||a.call(e),r(!1),(l=e.onClose)==null||l.call(e)};return t.jsx(m,{...e,open:i,onOpenChange:u,actionOnClick:s})};try{m.displayName="InternalOnboardingTooltip",m.__docgenInfo={description:"",displayName:"InternalOnboardingTooltip",props:{title:{defaultValue:null,description:"",name:"title",required:!0,type:{name:"enum",value:[{value:"undefined"},{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},text:{defaultValue:null,description:"",name:"text",required:!0,type:{name:"enum",value:[{value:"undefined"},{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},disabled:{defaultValue:null,description:"Disables tooltip completely",name:"disabled",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},onClose:{defaultValue:null,description:"Called when the tooltip is closed",name:"onClose",required:!1,type:{name:"enum",value:[{value:"() => void"}]}},actionLabel:{defaultValue:{value:`(
|
2
2
|
<FormattedMessage
|
3
3
|
id="preply-ds.onboardingTooltip.actionLabel"
|
4
4
|
defaultMessage="Got it"
|
package/dist/assets/{OnboardingTooltip.stories-zAMAeQy1.js → OnboardingTooltip.stories-BSTAbBKq.js}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{O as u}from"./OnboardingTooltip-
|
1
|
+
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{O as u}from"./OnboardingTooltip-Lspn1J1n.js";import{I as g}from"./IconButton-DNz6Hldb.js";import{F as x}from"./TokyoUIFav-DGbkVriC.js";import"./index-B3evPFBL.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./index-jPlWeKki.js";import"./PortalElementProvider-D4ltrA8j.js";import"./index-DRKYGVyc.js";import"./index-jEDObK_5.js";import"./index-C66nt8TK.js";import"./Combination-CCYtWL8C.js";import"./tslib.es6-BntfKcQG.js";import"./index-DbgDZDus.js";import"./TokyoUIClose-DFIfVIfy.js";import"./Icon-D4cMo1we.js";import"./text-accent-DZDDtpIt.js";import"./classNames-BUL1Zq7e.js";import"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import"./render-icon-CVTdrNe-.js";import"./componentNames-CVVyamkx.js";import"./index-DdzHuZ-Y.js";import"./defaults-B1rzzf6M.js";import"./Text-C3jprdij.js";import"./text-centered-CznToR0o.js";import"./Button-BumqXQgN.js";import"./ButtonBase-OAaaGRgi.js";import"./Spinner-BCTJunNM.js";import"./useMergeRefs-CeyIhNgY.js";import"./useHostname-CH18gHFj.js";import"./index-CC6DAVyL.js";import"./Heading-D79pA8cG.js";import"./index-BfBdt3zW.js";import"./hoist-non-react-statics.cjs-C-Qo8PK8.js";import"./shared-strings-CcWGHelY.js";import"./message-BraTJ16C.js";const te={title:"Components/OnboardingTooltip",component:u,parameters:{docs:{story:{inline:!1,height:250},description:{component:"Are you looking for a step-by-step tour? Check out [OnboardingTour](/docs/components-onboardingtour--docs)"}},a11y:{config:{rules:[{id:"color-contrast",enabled:!1}]}}},decorators:[t=>e.jsx("div",{style:{margin:"auto",width:"max-content"},children:t()})]},f=t=>[!1,!1],h=t=>a=>{},o=()=>{const[t,a]=f(),v=h();return e.jsx(u,{title:"New Feature Available!",text:"We've added an exciting new feature to enhance your experience.",disabled:a||t,onClose:()=>v(!0),children:e.jsx(g,{variant:"ghost",svg:e.jsx(x,{}),assistiveText:"Favorite"})})};o.storyName="OnboardingTooltip";const r={tags:["!autodocs"],args:{title:"New Feature Available!",text:"We've added an exciting new feature to enhance your experience.",disabled:!1,onClose:()=>{},children:e.jsx(g,{variant:"ghost",svg:e.jsx(x,{}),assistiveText:"Favorite"})},argTypes:{title:{control:"text"},text:{control:"text"},actionLabel:{control:"text"},actionOnClick:{control:!1},actionHref:{control:"text"},disabled:{control:"boolean"},dataset:{control:"object"},onClose:{control:!1},children:{control:!1}},parameters:{docs:{story:{height:450}},chromatic:{disableSnapshot:!0}},decorators:[t=>e.jsx("div",{style:{minHeight:"100vh",display:"flex"},children:e.jsx("div",{style:{margin:"auto",width:"max-content"},children:t()})})]};var i,n,s,l,c;o.parameters={...o.parameters,docs:{...(i=o.parameters)==null?void 0:i.docs,source:{originalSource:`() => {
|
2
2
|
const [wasTooltipSeen, loading] = useIsFeatureActive('new-feature');
|
3
3
|
const setTooltipSeen = useToggleFeature('new-feature');
|
4
4
|
return <OnboardingTooltip title="New Feature Available!" text="We've added an exciting new feature to enhance your experience." disabled={loading || wasTooltipSeen} onClose={() => setTooltipSeen(true)}>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as a}from"./jsx-runtime-BYouaCF_.js";import{O as x}from"./OnboardingTooltip-
|
1
|
+
import{j as a}from"./jsx-runtime-BYouaCF_.js";import{O as x}from"./OnboardingTooltip-Lspn1J1n.js";import{I}from"./IconButton-DNz6Hldb.js";import{F as f}from"./TokyoUIFav-DGbkVriC.js";import{w as s,a as r,e as n,u as d}from"./index-DDyIDR-R.js";import{B as k}from"./Button-BumqXQgN.js";import{L as F}from"./LayoutFlex-oRwI31fW.js";import"./index-B3evPFBL.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./index-jPlWeKki.js";import"./PortalElementProvider-D4ltrA8j.js";import"./index-DRKYGVyc.js";import"./index-jEDObK_5.js";import"./index-C66nt8TK.js";import"./Combination-CCYtWL8C.js";import"./tslib.es6-BntfKcQG.js";import"./index-DbgDZDus.js";import"./TokyoUIClose-DFIfVIfy.js";import"./Icon-D4cMo1we.js";import"./text-accent-DZDDtpIt.js";import"./classNames-BUL1Zq7e.js";import"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import"./render-icon-CVTdrNe-.js";import"./componentNames-CVVyamkx.js";import"./index-DdzHuZ-Y.js";import"./defaults-B1rzzf6M.js";import"./Text-C3jprdij.js";import"./text-centered-CznToR0o.js";import"./Heading-D79pA8cG.js";import"./index-BfBdt3zW.js";import"./hoist-non-react-statics.cjs-C-Qo8PK8.js";import"./shared-strings-CcWGHelY.js";import"./message-BraTJ16C.js";import"./ButtonBase-OAaaGRgi.js";import"./Spinner-BCTJunNM.js";import"./useMergeRefs-CeyIhNgY.js";import"./useHostname-CH18gHFj.js";import"./index-CC6DAVyL.js";import"./layout-relative.module-ed9bC4H4.js";const mt={title:"Components/OnboardingTooltip/Tests",component:x,parameters:{layout:"centered",controls:{disable:!0},chromatic:{disableSnapshot:!0}},tags:["!autodocs","!a11y-test","test"],decorators:[e=>a.jsx("div",{style:{margin:"100px 0"},children:e()})],args:{title:"Title",text:"Body text",actionLabel:"Action label",disabled:!1,onClose:()=>{},dataset:{testid:"tooltip"},children:a.jsx(I,{svg:a.jsx(f,{}),assistiveText:"Favorite"})}},c={play:async({canvasElement:e,step:o})=>{const i=s(e);await o("wait for tooltip to be visible",async()=>{await r(()=>{const t=i.getByTestId("tooltip");return n(t).toBeVisible()})}),await o("close the tooltip",()=>{const u=s(i.getByTestId("tooltip")).getByTestId("close");return d.click(u)}),await o("wait for tooltip to be hidden",async()=>{await r(()=>{const t=i.queryByTestId("tooltip");return n(t).toBeNull()})})}},l={play:async({canvasElement:e,step:o})=>{const i=s(e);await o("wait for tooltip to be visible",async()=>{await r(()=>{const t=i.getByTestId("tooltip");return n(t).toBeVisible()})}),await o("close the tooltip",()=>{const u=s(i.getByTestId("tooltip")).getByTestId("action");return d.click(u)}),await o("wait for tooltip to be hidden",async()=>{await r(()=>{const t=i.queryByTestId("tooltip");return n(t).toBeNull()})})}};function E(e){return new Promise(o=>setTimeout(o,e))}const p={render:e=>a.jsxs(F,{gap:"24",direction:"column",children:[a.jsx(k,{children:"Click outside the tooltip"}),a.jsx(x,{...e,children:a.jsx(I,{svg:a.jsx(f,{}),assistiveText:"Favorite"})})]}),play:async({canvasElement:e,step:o})=>{const i=s(e);await o("wait for tooltip to be visible",async()=>{await r(()=>{const t=i.getByTestId("tooltip");return n(t).toBeVisible()})}),await o("click outside the tooltip",()=>{const t=i.getByText("Click outside the tooltip");return d.click(t)}),await o("check the tooltip remain open",async()=>{await E(1e3);const t=i.getByTestId("tooltip");return n(t).toBeVisible()})}};var m,y,w;c.parameters={...c.parameters,docs:{...(m=c.parameters)==null?void 0:m.docs,source:{originalSource:`{
|
2
2
|
play: async ({
|
3
3
|
canvasElement,
|
4
4
|
step
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as o}from"./jsx-runtime-BYouaCF_.js";import{r as l}from"./index-B3evPFBL.js";import{I as A}from"./OnboardingTooltip-
|
1
|
+
import{j as o}from"./jsx-runtime-BYouaCF_.js";import{r as l}from"./index-B3evPFBL.js";import{I as A}from"./OnboardingTooltip-Lspn1J1n.js";import"./index-BfBdt3zW.js";import{M as f}from"./message-BraTJ16C.js";const T="counter__ArBS-",j={counter:T},v=({totalSteps:n,nextActionLabel:e=o.jsx(f,{id:"preply-ds.onboardingTour.nextActionLabel",defaultMessage:"Next",description:"Onboarding tour next action label"}),completeActionLabel:a=o.jsx(f,{id:"preply-ds.onboardingTour.completeActionLabel",defaultMessage:"Got it",description:"Onboarding tour complete action label"}),onClose:t,onComplete:r,onStepChange:i,disabled:s,children:p,ctx:x})=>{const[b,u]=l.useState(!0),[d,g]=l.useState(0),c={totalSteps:n,nextActionLabel:e,completeActionLabel:a,onClose:()=>{u(!1),t==null||t()},active:!s&&b,currentStep:d,onActionClick:()=>{if(d===n-1)r==null||r(),u(!1);else{const h=d+1;g(h),i==null||i(h)}}};return o.jsx(x.Provider,{value:c,children:p})},_=({ctx:n,...e})=>{const a=l.useContext(n);if(!a)throw new Error("OnboardingTourContext not found");const{currentStep:t,totalSteps:r,onActionClick:i,onClose:s,active:p,nextActionLabel:x,completeActionLabel:b}=a,u=e.step===r-1,d=e.step===t,g=u?b:x,m=()=>{var c;(c=e.actionOnClick)==null||c.call(e),i()},O=c=>{c||s==null||s()};return o.jsx(A,{...e,counter:o.jsx("p",{className:j.counter,children:o.jsx(f,{id:"preply-ds.onboardingTour.counter",defaultMessage:"{currentStep} of {totalSteps}",description:"Onboarding tour step counter, e.g. '1 of 3'",values:{currentStep:t+1,totalSteps:r}})}),open:p&&d,onOpenChange:O,actionLabel:g,actionOnClick:m})},S=()=>{const n=l.createContext(null);return{Provider:t=>o.jsx(v,{...t,ctx:n}),Step:t=>o.jsx(_,{...t,ctx:n})}};try{S.displayName="createOnboardingTour",S.__docgenInfo={description:`Creates a new onboarding tour.
|
2
2
|
|
3
3
|
This factory pattern allows multiple independent tours to be nested within each other
|
4
4
|
without context conflicts, as each tour maintains its own separate context and state.`,displayName:"createOnboardingTour",props:{}}}catch{}export{S as c};
|
package/dist/assets/{OnboardingTour.stories-L4wR5VUD.js → OnboardingTour.stories-D3Z3aBlG.js}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{r as b}from"./index-B3evPFBL.js";import{c as x}from"./OnboardingTour-
|
1
|
+
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{r as b}from"./index-B3evPFBL.js";import{c as x}from"./OnboardingTour-J68z1zuj.js";import{T as n}from"./Text-C3jprdij.js";import{L as y}from"./LayoutFlex-oRwI31fW.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./OnboardingTooltip-Lspn1J1n.js";import"./index-jPlWeKki.js";import"./PortalElementProvider-D4ltrA8j.js";import"./index-DRKYGVyc.js";import"./index-jEDObK_5.js";import"./index-C66nt8TK.js";import"./Combination-CCYtWL8C.js";import"./tslib.es6-BntfKcQG.js";import"./index-DbgDZDus.js";import"./TokyoUIClose-DFIfVIfy.js";import"./Icon-D4cMo1we.js";import"./text-accent-DZDDtpIt.js";import"./classNames-BUL1Zq7e.js";import"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import"./render-icon-CVTdrNe-.js";import"./componentNames-CVVyamkx.js";import"./index-DdzHuZ-Y.js";import"./defaults-B1rzzf6M.js";import"./Button-BumqXQgN.js";import"./ButtonBase-OAaaGRgi.js";import"./Spinner-BCTJunNM.js";import"./useMergeRefs-CeyIhNgY.js";import"./useHostname-CH18gHFj.js";import"./index-CC6DAVyL.js";import"./Heading-D79pA8cG.js";import"./text-centered-CznToR0o.js";import"./index-BfBdt3zW.js";import"./hoist-non-react-statics.cjs-C-Qo8PK8.js";import"./shared-strings-CcWGHelY.js";import"./message-BraTJ16C.js";import"./layout-relative.module-ed9bC4H4.js";const l=t=>null,s=t=>null;try{l.displayName="OnboardingTourProvider",l.__docgenInfo={description:`For some reason, storybook fails to render arg tables for the components
|
2
2
|
when they're created with the \`createOnboardingTour\` function.
|
3
3
|
|
4
4
|
As a workaround, we're manually defining fake components with the same
|
5
|
-
props as originals just for props parsing ¯\\_(ツ)_/¯`,displayName:"OnboardingTourProvider",props:{totalSteps:{defaultValue:null,description:"Total number of steps in the tour",name:"totalSteps",required:!0,type:{name:"number"}},nextActionLabel:{defaultValue:{value:'"Next"'},description:'Label for the "Next" action button',name:"nextActionLabel",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},completeActionLabel:{defaultValue:{value:'"Got it"'},description:'Label for the "Complete" action button',name:"completeActionLabel",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},disabled:{defaultValue:null,description:"Whether the tour is disabled",name:"disabled",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},onClose:{defaultValue:null,description:"Called when the tour is closed",name:"onClose",required:!1,type:{name:"enum",value:[{value:"() => void"}]}},onComplete:{defaultValue:null,description:"Called when the tour is completed",name:"onComplete",required:!1,type:{name:"enum",value:[{value:"() => void"}]}},onStepChange:{defaultValue:null,description:"Called when the current step index changes",name:"onStepChange",required:!1,type:{name:"enum",value:[{value:"(step: number) => void"}]}}}}}catch{}try{s.displayName="OnboardingTourStep",s.__docgenInfo={description:"",displayName:"OnboardingTourStep",props:{dataset:{defaultValue:null,description:"",name:"dataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},
|
5
|
+
props as originals just for props parsing ¯\\_(ツ)_/¯`,displayName:"OnboardingTourProvider",props:{totalSteps:{defaultValue:null,description:"Total number of steps in the tour",name:"totalSteps",required:!0,type:{name:"number"}},nextActionLabel:{defaultValue:{value:'"Next"'},description:'Label for the "Next" action button',name:"nextActionLabel",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},completeActionLabel:{defaultValue:{value:'"Got it"'},description:'Label for the "Complete" action button',name:"completeActionLabel",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},disabled:{defaultValue:null,description:"Whether the tour is disabled",name:"disabled",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},onClose:{defaultValue:null,description:"Called when the tour is closed",name:"onClose",required:!1,type:{name:"enum",value:[{value:"() => void"}]}},onComplete:{defaultValue:null,description:"Called when the tour is completed",name:"onComplete",required:!1,type:{name:"enum",value:[{value:"() => void"}]}},onStepChange:{defaultValue:null,description:"Called when the current step index changes",name:"onStepChange",required:!1,type:{name:"enum",value:[{value:"(step: number) => void"}]}}}}}catch{}try{s.displayName="OnboardingTourStep",s.__docgenInfo={description:"",displayName:"OnboardingTourStep",props:{dataset:{defaultValue:null,description:"",name:"dataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},side:{defaultValue:null,description:"Preferred side of the tooltip to appear from. Use if default side might block important content.",name:"side",required:!1,type:{name:"enum",value:[{value:'"top"'},{value:'"right"'},{value:'"bottom"'},{value:'"left"'}]}},title:{defaultValue:null,description:"",name:"title",required:!0,type:{name:"enum",value:[{value:"undefined"},{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},text:{defaultValue:null,description:"",name:"text",required:!0,type:{name:"enum",value:[{value:"undefined"},{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},actionOnClick:{defaultValue:null,description:"By default, the action button closes the tooltip.\n\nProvide `actionOnClick` to also perform other action.",name:"actionOnClick",required:!1,type:{name:"enum",value:[{value:"() => void"}]}},autoScroll:{defaultValue:{value:"true"},description:"If true, the tooltip will automatically scroll into view when it is opened.",name:"autoScroll",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},step:{defaultValue:null,description:"Zero-based step index",name:"step",required:!0,type:{name:"number"}}}}}catch{}const o=x(),se={title:"Components/OnboardingTour",component:l,subcomponents:{OnboardingTourStep:s},parameters:{docs:{story:{inline:!1,height:250},description:{component:"Are you looking for a tooltip to highlight single element? Check out [OnboardingTooltip](/docs/components-onboardingtooltip--docs)"}},a11y:{config:{rules:[{id:"color-contrast",enabled:!1}]}}},decorators:[t=>e.jsx("div",{style:{margin:"auto",width:"max-content"},children:t()})]},C=t=>[!1,!1],j=t=>i=>{},r=()=>{const[t,i]=C(),T=j();return e.jsxs(o.Provider,{totalSteps:3,disabled:i||t,onComplete:()=>T(!0),children:[e.jsx("div",{style:{height:250},children:e.jsx(o.Step,{step:0,title:"Step 1",text:"This is the first step of the onboarding tour.",children:e.jsx(n,{children:"Step 1"})})}),e.jsx("div",{style:{height:250},children:e.jsx(o.Step,{step:1,title:"Step 2",text:"This is the second step of the onboarding tour.",children:e.jsx(n,{children:"Step 2"})})}),e.jsx("div",{style:{height:250},children:e.jsx(o.Step,{step:2,title:"Step 3",text:"This is the final step of the onboarding tour.",children:e.jsx(n,{children:"Step 3"})})})]})};r.storyName="OnboardingTour";const a=()=>{const[t,i]=b.useState(!0);return e.jsx(o.Provider,{totalSteps:3,children:e.jsxs(y,{gap:"12",children:[e.jsx(o.Step,{step:0,title:"First step",text:"This is the first step of the onboarding tour.",children:e.jsx(n,{children:"Step 1"})}),e.jsx(o.Step,{step:1,title:"Second step",text:"This is the second step of the onboarding tour.",actionOnClick:()=>i(!1),children:e.jsx(n,{children:"Step 2"})}),!t&&e.jsx(o.Step,{step:2,title:"Final step",text:"This is the final step of the onboarding tour.",children:e.jsx(n,{children:"Step 3 (I was hidden)"})})]})})};var u,p,d,c,m;r.parameters={...r.parameters,docs:{...(u=r.parameters)==null?void 0:u.docs,source:{originalSource:`() => {
|
6
6
|
const [wasTourCompleted, loading] = useIsFeatureActive('my-tour');
|
7
7
|
const setTourCompleted = useToggleFeature('my-tour');
|
8
8
|
return <Tour.Provider totalSteps={3} disabled={loading || wasTourCompleted} onComplete={() => setTourCompleted(true)}>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{r as h}from"./index-B3evPFBL.js";import{c as I}from"./OnboardingTour-
|
1
|
+
import{j as e}from"./jsx-runtime-BYouaCF_.js";import{r as h}from"./index-B3evPFBL.js";import{c as I}from"./OnboardingTour-J68z1zuj.js";import{T as u}from"./Text-C3jprdij.js";import{B as m}from"./Button-BumqXQgN.js";import{f as v,w as p,a as c,e as n,u as l}from"./index-DDyIDR-R.js";import{L as C}from"./LayoutFlex-oRwI31fW.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./OnboardingTooltip-Lspn1J1n.js";import"./index-jPlWeKki.js";import"./PortalElementProvider-D4ltrA8j.js";import"./index-DRKYGVyc.js";import"./index-jEDObK_5.js";import"./index-C66nt8TK.js";import"./Combination-CCYtWL8C.js";import"./tslib.es6-BntfKcQG.js";import"./index-DbgDZDus.js";import"./TokyoUIClose-DFIfVIfy.js";import"./Icon-D4cMo1we.js";import"./text-accent-DZDDtpIt.js";import"./classNames-BUL1Zq7e.js";import"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import"./render-icon-CVTdrNe-.js";import"./componentNames-CVVyamkx.js";import"./index-DdzHuZ-Y.js";import"./defaults-B1rzzf6M.js";import"./Heading-D79pA8cG.js";import"./text-centered-CznToR0o.js";import"./index-BfBdt3zW.js";import"./hoist-non-react-statics.cjs-C-Qo8PK8.js";import"./shared-strings-CcWGHelY.js";import"./message-BraTJ16C.js";import"./ButtonBase-OAaaGRgi.js";import"./Spinner-BCTJunNM.js";import"./useMergeRefs-CeyIhNgY.js";import"./useHostname-CH18gHFj.js";import"./index-CC6DAVyL.js";import"./layout-relative.module-ed9bC4H4.js";const d=I(),kt={title:"Components/OnboardingTour/Tests",parameters:{layout:"centered",controls:{disable:!0},chromatic:{disableSnapshot:!0}},tags:["!autodocs","!a11y-test","test"],decorators:[i=>e.jsx("div",{style:{margin:"100px 0"},children:i()})],args:{onComplete:v(),onClose:v(),onStepChange:v()}},y={render:({onComplete:i,onStepChange:s})=>e.jsx(d.Provider,{totalSteps:3,nextActionLabel:"Next",completeActionLabel:"Got it",onComplete:i,onStepChange:s,children:e.jsxs(C,{gap:"24",direction:"column",children:[e.jsx(d.Step,{step:0,title:"Title",text:"Text",dataset:{testid:"step-1"},children:e.jsx(u,{children:"Step 1 Content"})}),e.jsx(d.Step,{step:1,title:"Title",text:"Text",dataset:{testid:"step-2"},children:e.jsx(u,{children:"Step 2 Content"})}),e.jsx(d.Step,{step:2,title:"Title",text:"Text",dataset:{testid:"step-3"},children:e.jsx(u,{children:"Step 3 Content"})})]})}),play:async({canvasElement:i,step:s,args:t})=>{const a=p(i);await s("First step should be visible initially",async()=>{await c(()=>{const o=a.getByTestId("step-1");n(o).toBeVisible()})}),await s("Click Next to advance to second step",async()=>{const r=p(a.getByTestId("step-1")).getByTestId("action");await l.click(r),await c(()=>{const T=a.getByTestId("step-2");n(T).toBeVisible(),n(t.onStepChange).toHaveBeenCalledWith(1)})}),await s("Click Next to advance to final step",async()=>{const r=p(a.getByTestId("step-2")).getByTestId("action");await l.click(r),await c(()=>{const T=a.getByTestId("step-3");n(T).toBeVisible(),n(t.onStepChange).toHaveBeenCalledWith(2)})}),await s("Complete tour",async()=>{const r=p(a.getByTestId("step-3")).getByTestId("action");await l.click(r),await c(()=>{const T=a.queryByTestId("step",{exact:!1});n(T).toBeNull(),n(t.onComplete).toHaveBeenCalled()})})}},x={render:({onClose:i})=>e.jsx(d.Provider,{totalSteps:2,nextActionLabel:"Next",completeActionLabel:"Got it",onClose:i,children:e.jsx(d.Step,{step:0,title:"First step",text:"Try closing this step",dataset:{testid:"step-1"},children:e.jsx(u,{children:"Step 1 Content"})})}),play:async({canvasElement:i,step:s})=>{const t=p(i);await s("Step should be initially visible",async()=>{await c(()=>{const a=t.getByTestId("step-1");n(a).toBeVisible()})}),await s("Click close button to close tour",async({args:a})=>{const r=p(t.getByTestId("step-1")).getByTestId("close");await l.click(r),await c(()=>{const T=t.queryByTestId("step",{exact:!1});n(T).toBeNull(),n(a.onClose).toHaveBeenCalled()})})}},B={render:function(){const[s,t]=h.useState(!0);return e.jsxs(C,{gap:"24",direction:"column",children:[e.jsx(m,{onClick:()=>t(!s),dataset:{testid:"toggle-button"},children:s?"Enable Tour":"Disable Tour"}),e.jsx(d.Provider,{totalSteps:2,nextActionLabel:"Next",completeActionLabel:"Got it",disabled:s,children:e.jsx(d.Step,{step:0,title:"First step",text:"This step should be hidden when disabled",dataset:{testid:"step-1"},children:e.jsx(u,{children:"Step 1 Content"})})})]})},play:async({canvasElement:i,step:s})=>{const t=p(i);await s("Tour should be initially disabled",async()=>{const a=t.queryByTestId("step-1");n(a).toBeNull()}),await s("Click enable button to show tour",async()=>{const a=t.getByTestId("toggle-button");await l.click(a),await c(()=>{const o=t.getByTestId("step-1");n(o).toBeVisible()})})}},g=I(),S=I(),w={render:function(){const[s,t]=h.useState(!1),[a,o]=h.useState(!1);return e.jsxs(g.Provider,{totalSteps:2,disabled:!s,nextActionLabel:"Next",completeActionLabel:"Got it",children:[e.jsx(g.Step,{step:0,title:"Title",text:"Text",dataset:{testid:"outer-step-1"},children:e.jsx(m,{onClick:()=>t(!0),dataset:{testid:"start-outer-tour"},children:"Start outer tour"})}),e.jsxs(S.Provider,{totalSteps:2,disabled:!a,nextActionLabel:"Next",completeActionLabel:"Done",children:[e.jsx(g.Step,{step:1,title:"Title",text:"Text",dataset:{testid:"outer-step-2"},children:e.jsx(u,{children:"Outer Tour Step"})}),e.jsx(S.Step,{step:0,title:"Title",text:"Text",dataset:{testid:"inner-step-1"},children:e.jsx(m,{onClick:()=>o(!0),dataset:{testid:"start-inner-tour"},children:"Start inner tour"})}),e.jsx(S.Step,{step:1,title:"Title",text:"Text",dataset:{testid:"inner-step-2"},children:e.jsx(u,{children:"Inner Tour Step"})})]})]})},play:async({canvasElement:i,step:s})=>{const t=p(i);await s("Start inner tour, step 1 should be visible",async()=>{const a=t.getByTestId("start-inner-tour");await l.click(a),await c(async()=>{const o=t.queryByTestId("inner-step-1");n(o).toBeVisible()})}),await s("Advance inner tour, step 2 should be visible",async()=>{const o=p(t.getByTestId("inner-step-1")).getByTestId("action");await l.click(o),await c(async()=>{const r=t.queryByTestId("inner-step-2");n(r).toBeVisible()})}),await s("Complete inner tour",async()=>{const o=p(t.getByTestId("inner-step-2")).getByTestId("action");await l.click(o),await c(async()=>{const r=t.queryByTestId("inner-step-1",{exact:!1});n(r).toBeNull()})}),await s("Start outer tour, step 1 should be visible",async()=>{const a=t.getByTestId("start-outer-tour");await l.click(a),await c(async()=>{const o=t.queryByTestId("outer-step-1");n(o).toBeVisible()})}),await s("Advance outer tour, step 2 should be visible",async()=>{const o=p(t.getByTestId("outer-step-1")).getByTestId("action");await l.click(o),await c(async()=>{const r=t.queryByTestId("outer-step-2");n(r).toBeVisible()})}),await s("Complete outer tour",async()=>{const o=p(t.getByTestId("outer-step-2")).getByTestId("action");await l.click(o),await c(async()=>{const r=t.queryByTestId("-step-",{exact:!1});n(r).toBeNull()})})}};function W(i){return new Promise(s=>setTimeout(s,i))}const b={render:()=>e.jsxs(C,{gap:"24",direction:"column",children:[e.jsx(m,{children:"Click outside the tooltip"}),e.jsx(d.Provider,{totalSteps:1,nextActionLabel:"Next",completeActionLabel:"Got it",children:e.jsx(d.Step,{step:0,title:"Title",text:"Text",dataset:{testid:"step-1"},children:e.jsx(u,{children:"Step 1 Content"})})})]}),play:async({canvasElement:i,step:s})=>{const t=p(i);await s("Step should be initially visible",async()=>{await c(()=>{const a=t.getByTestId("step-1");n(a).toBeVisible()})}),await s("Click outside the tooltip",()=>{const a=t.getByText("Click outside the tooltip");return l.click(a)}),await s("Wait for tooltip to be hidden",async()=>{await W(1e3);const a=t.getByTestId("step-1");n(a).toBeVisible()})}};var k,j,L;y.parameters={...y.parameters,docs:{...(k=y.parameters)==null?void 0:k.docs,source:{originalSource:`{
|
2
2
|
render: ({
|
3
3
|
onComplete,
|
4
4
|
onStepChange
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import{j as a}from"./jsx-runtime-BYouaCF_.js";import{r as l}from"./index-B3evPFBL.js";import{F as R}from"./FormControl-DD3JEwg1.js";import{F as H,a as I}from"./TokyoUIEye-BsOt8ZdC.js";import{F as M}from"./FieldButton-xxvyfVcj.js";import{u as L,d as F}from"./index-BfBdt3zW.js";import{u as T}from"./useMergeRefs-BKVZOB6R.js";import{w as x}from"./componentNames-CVVyamkx.js";import{I as P}from"./Input-B7MlX4U9.js";const r=F({reveal:{id:"preply-ds.password-field.reveal.button",defaultMessage:"Reveal password",description:'A11y label for the "reveal password" button. Will be announced by screen reader.'},conceal:{id:"preply-ds.password-field.conceal.button",defaultMessage:"Conceal password",description:'A11y label for the "conceal password" button. Will be announced by screen reader.'}}),s=l.forwardRef(function({id:o,label:d,description:m,error:p,required:v,inputDataset:c,dataset:f,hideLabel:y,onClick:h,hasError:b,className:k,style:D,...g},E){const{formatMessage:n}=L(),[e,V]=l.useState(!1),t=l.useRef(null),q=T(t,E),w=e?"text":"password",C=()=>{var u;V(!e),(u=t.current)==null||u.focus()};return a.jsx(R,{id:o,label:d,description:m,error:p,hasError:b,required:v,dataset:f,hideLabel:y,onClick:h,preplyDsComponent:x.PasswordField,children:a.jsx(P,{...g,type:w,ref:q,dataset:c,button:a.jsx(M,{onClick:C,svg:e?H:I,assistiveText:n(e?r.conceal:r.reveal),dataset:{testid:"toggle-password-button"}})})})});try{s.displayName="PasswordField",s.__docgenInfo={description:"",displayName:"PasswordField",props:{id:{defaultValue:null,description:`The id to be passed to the input element.
|
2
|
+
If not provided, will be generated for accessibility purposes.`,name:"id",required:!1,type:{name:"enum",value:[{value:"string"}]}},required:{defaultValue:null,description:`Indicates if the field is required. When false, adds a "Optional"
|
3
|
+
indicator next to the label.`,name:"required",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},hasError:{defaultValue:null,description:"Whether the field has an error.\n@deprecated Use `error` prop to exlicitly describe the error to users",name:"hasError",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},dataset:{defaultValue:null,description:"",name:"dataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},error:{defaultValue:null,description:"Error message to display when the field has an invalid value.",name:"error",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},label:{defaultValue:null,description:"The field label. This is needed for accessibility purposes, but can be\nhidden using the `hideLabel` prop.",name:"label",required:!0,type:{name:"enum",value:[{value:"undefined"},{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},onClick:{defaultValue:null,description:"",name:"onClick",required:!1,type:{name:"enum",value:[{value:"MouseEventHandler<HTMLDivElement> & MouseEventHandler<HTMLInputElement>"}]}},description:{defaultValue:null,description:`Additional descriptive text that appears below the input field
|
4
|
+
to provide more context or instructions to the user.`,name:"description",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"false"},{value:"true"},{value:"ReactElement<any, string | JSXElementConstructor<any>>"},{value:"Iterable<ReactNode>"},{value:"ReactPortal"}]}},hideLabel:{defaultValue:null,description:"Use this to hide the `label` visually, but keep it in the accessibility\ntree.",name:"hideLabel",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},name:{defaultValue:null,description:"",name:"name",required:!1,type:{name:"enum",value:[{value:"string"}]}},disabled:{defaultValue:null,description:"",name:"disabled",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},onChange:{defaultValue:null,description:"",name:"onChange",required:!1,type:{name:"enum",value:[{value:"ChangeEventHandler<HTMLInputElement>"}]}},onBlur:{defaultValue:null,description:"",name:"onBlur",required:!1,type:{name:"enum",value:[{value:"FocusEventHandler<HTMLInputElement>"}]}},onFocus:{defaultValue:null,description:"",name:"onFocus",required:!1,type:{name:"enum",value:[{value:"FocusEventHandler<HTMLInputElement>"}]}},placeholder:{defaultValue:null,description:"",name:"placeholder",required:!1,type:{name:"enum",value:[{value:"string"}]}},onCopy:{defaultValue:null,description:"",name:"onCopy",required:!1,type:{name:"enum",value:[{value:"ClipboardEventHandler<HTMLInputElement>"}]}},onCut:{defaultValue:null,description:"",name:"onCut",required:!1,type:{name:"enum",value:[{value:"ClipboardEventHandler<HTMLInputElement>"}]}},onPaste:{defaultValue:null,description:"",name:"onPaste",required:!1,type:{name:"enum",value:[{value:"ClipboardEventHandler<HTMLInputElement>"}]}},onKeyDown:{defaultValue:null,description:"",name:"onKeyDown",required:!1,type:{name:"enum",value:[{value:"KeyboardEventHandler<HTMLInputElement>"}]}},onKeyUp:{defaultValue:null,description:"",name:"onKeyUp",required:!1,type:{name:"enum",value:[{value:"KeyboardEventHandler<HTMLInputElement>"}]}},icon:{defaultValue:null,description:"",name:"icon",required:!1,type:{name:"enum",value:[{value:"ReactElement<any, string | JSXElementConstructor<any>>"}]}},onValueChange:{defaultValue:null,description:"",name:"onValueChange",required:!1,type:{name:"enum",value:[{value:"(value: string) => void"}]}},readOnly:{defaultValue:null,description:"",name:"readOnly",required:!1,type:{name:"enum",value:[{value:"false"},{value:"true"}]}},maxLength:{defaultValue:null,description:"",name:"maxLength",required:!1,type:{name:"enum",value:[{value:"number"}]}},value:{defaultValue:null,description:"",name:"value",required:!1,type:{name:"enum",value:[{value:"string"}]}},defaultValue:{defaultValue:null,description:"",name:"defaultValue",required:!1,type:{name:"enum",value:[{value:"string"}]}},autoComplete:{defaultValue:null,description:"",name:"autoComplete",required:!1,type:{name:"enum",value:[{value:'"off"'},{value:'"new-password"'},{value:'"current-password"'}]}},inputDataset:{defaultValue:null,description:"",name:"inputDataset",required:!1,type:{name:"enum",value:[{value:"Dataset"}]}},ref:{defaultValue:null,description:"Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null`\n(or call the ref with `null` if you passed a callback ref).\n@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}",name:"ref",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"(instance: HTMLInputElement | null) => void"},{value:"RefObject<HTMLInputElement>"}]}},key:{defaultValue:null,description:"",name:"key",required:!1,type:{name:"enum",value:[{value:"null"},{value:"string"},{value:"number"},{value:"bigint"}]}}}}}catch{}export{s as P};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{j as X}from"./jsx-runtime-BYouaCF_.js";import{r as $}from"./index-B3evPFBL.js";import{P as Y}from"./PasswordField-
|
1
|
+
import{j as X}from"./jsx-runtime-BYouaCF_.js";import{r as $}from"./index-B3evPFBL.js";import{P as Y}from"./PasswordField-BkVjxPtF.js";import{f as o,w,e as n,u as v}from"./index-DDyIDR-R.js";import{F as ee}from"./TokyoUILock-C_glX9Ec.js";import{I as te}from"./Icon-D4cMo1we.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./FormControl-DD3JEwg1.js";import"./index-DRKYGVyc.js";import"./index-BfBdt3zW.js";import"./tslib.es6-BntfKcQG.js";import"./hoist-non-react-statics.cjs-C-Qo8PK8.js";import"./index-DdzHuZ-Y.js";import"./message-BraTJ16C.js";import"./componentNames-CVVyamkx.js";import"./TokyoUIEye-BsOt8ZdC.js";import"./FieldButton-xxvyfVcj.js";import"./filterAttributesPassedByRadixUIAtRuntime-B7QTVwVw.js";import"./classNames-BUL1Zq7e.js";import"./useMergeRefs-BKVZOB6R.js";import"./Input-B7MlX4U9.js";import"./InputContainer-C1TOTxt4.js";import"./text-accent-DZDDtpIt.js";import"./render-icon-CVTdrNe-.js";import"./defaults-B1rzzf6M.js";const Ae={title:"components/PasswordField",component:Y,args:{name:"password",label:"Password",placeholder:"Enter a password",defaultValue:"",dataset:{testid:"field",foo:"bar"},inputDataset:{testid:"input",foo:"bar"},onChange:o(),onValueChange:o(),onBlur:o(),onFocus:o(),onClick:o(),onCopy:o(),onKeyDown:o(),onKeyUp:o(),onPaste:o()}},c={play:async({canvasElement:a,step:e,args:t})=>{const s=w(a),i=s.getByTestId("field"),r=s.getByTestId("input");await e("it should render correct label",async()=>{const Z=w(i).getByTestId("label");n(Z).toHaveTextContent("Password"),n(r).toHaveAccessibleName("Password")}),await e("it should call onFocus when the input is focused",async()=>{r.focus(),n(t.onFocus).toHaveBeenCalled()}),await e("it should call callback when the value changes",async()=>{await v.type(r,"secret123"),n(t.onValueChange).toHaveBeenCalledWith("secret123"),n(t.onChange).toHaveBeenCalled()}),await e("it should call onBlur when the input is blurred",async()=>{await v.keyboard("{tab}"),n(t.onBlur).toHaveBeenCalled()}),await e("it should render the dataset props",async()=>{n(i).toHaveAttribute("data-testid","field"),n(i).toHaveAttribute("data-foo","bar"),n(r).toHaveAttribute("data-testid","input"),n(r).toHaveAttribute("data-foo","bar")}),await e("it should have password type by default",async()=>{n(r).toHaveAttribute("type","password")})}},l={render:function(e){const[t,s]=$.useState(e.value);return X.jsx(Y,{...e,value:t,onChange:i=>{var r;s(i.target.value),(r=e.onChange)==null||r.call(e,i)}})},args:{label:"Controlled PasswordField",placeholder:"Enter your password...",value:"secret123"},play:async({canvas:a,step:e})=>{await e("it should render the correct initial value",async()=>{const t=a.getByTestId("input");await n(t).toHaveValue("secret123")}),await e("it should update the value when the user types",async()=>{const t=a.getByTestId("input");await v.clear(t),await v.type(t,"newpassword"),n(t).toHaveValue("newpassword")})}},d={args:{description:"Include letters, numbers and symbols"},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input"),s=a.getByTestId("description");await e("it should render the description",async()=>{n(t).toHaveAccessibleDescription("Include letters, numbers and symbols"),n(s).toHaveTextContent("Include letters, numbers and symbols")})}},p={args:{required:!0},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input"),s=a.getByTestId("label");await e("it should render correct label",async()=>{n(t).toHaveAccessibleName("Password"),n(s).toHaveTextContent("Password • Required")}),await e("it should render required attribute",async()=>{n(t).toHaveAttribute("required")})}},u={args:{hideLabel:!0},play:async({canvas:a,step:e})=>{await e("it should render correct a11y label",async()=>{const t=a.getByTestId("input");n(t).toHaveAccessibleName("Password")})}},y={args:{error:"This is an error message"},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input"),s=a.getByTestId("error");await e("it should render the error message",async()=>{n(t).toHaveAccessibleErrorMessage("This is an error message"),n(s).toHaveTextContent("This is an error message")})}},b={args:{disabled:!0},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input");await e("it should render the disabled input",async()=>{n(t).toHaveAttribute("disabled")})}},m={args:{readOnly:!0},play:async({canvas:a,step:e})=>{const t=a.getByTestId("input");await e("it should render the read only input",async()=>{n(t).toHaveAttribute("readonly")})}},h={parameters:{chromatic:{disableSnapshot:!0}},args:{label:"Password",placeholder:"e.g.: abc123%pt0!",description:"Include letters, numbers and symbols"},argTypes:{label:{control:"text"},placeholder:{control:"text"},description:{control:"text"},error:{control:"text"},value:{control:"text"},defaultValue:{control:"text"},inputDataset:{control:"object"},dataset:{control:"object"},id:{control:"text"},required:{control:"boolean"},hideLabel:{control:"boolean"},name:{control:"text"},disabled:{control:"boolean"},readOnly:{control:"boolean"},maxLength:{control:"number"},icon:{options:["None","With Icon"],mapping:{None:void 0,"With Icon":X.jsx(te,{svg:ee})},control:"select"},autoComplete:{control:"select"},hasError:{table:{disable:!0}}}};var g,x,H,T,I;c.parameters={...c.parameters,docs:{...(g=c.parameters)==null?void 0:g.docs,source:{originalSource:`{
|
2
2
|
play: async ({
|
3
3
|
canvasElement,
|
4
4
|
step,
|
@@ -9,7 +9,7 @@ import{j as X}from"./jsx-runtime-BYouaCF_.js";import{r as $}from"./index-B3evPFB
|
|
9
9
|
const input = canvas.getByTestId('input');
|
10
10
|
await step('it should render correct label', async () => {
|
11
11
|
const label = within(field).getByTestId('label');
|
12
|
-
expect(label).toHaveTextContent('Password
|
12
|
+
expect(label).toHaveTextContent('Password');
|
13
13
|
expect(input).toHaveAccessibleName('Password');
|
14
14
|
});
|
15
15
|
await step('it should call onFocus when the input is focused', async () => {
|
@@ -78,7 +78,7 @@ import{j as X}from"./jsx-runtime-BYouaCF_.js";import{r as $}from"./index-B3evPFB
|
|
78
78
|
expect(description).toHaveTextContent('Include letters, numbers and symbols');
|
79
79
|
});
|
80
80
|
}
|
81
|
-
}`,...(S=(F=d.parameters)==null?void 0:F.docs)==null?void 0:S.source}}};var V,D
|
81
|
+
}`,...(S=(F=d.parameters)==null?void 0:F.docs)==null?void 0:S.source}}};var V,q,D;p.parameters={...p.parameters,docs:{...(V=p.parameters)==null?void 0:V.docs,source:{originalSource:`{
|
82
82
|
args: {
|
83
83
|
required: true
|
84
84
|
},
|
@@ -90,13 +90,13 @@ import{j as X}from"./jsx-runtime-BYouaCF_.js";import{r as $}from"./index-B3evPFB
|
|
90
90
|
const label = canvas.getByTestId('label');
|
91
91
|
await step('it should render correct label', async () => {
|
92
92
|
expect(input).toHaveAccessibleName('Password');
|
93
|
-
expect(label).toHaveTextContent('Password');
|
93
|
+
expect(label).toHaveTextContent('Password • Required');
|
94
94
|
});
|
95
95
|
await step('it should render required attribute', async () => {
|
96
96
|
expect(input).toHaveAttribute('required');
|
97
97
|
});
|
98
98
|
}
|
99
|
-
}`,...(
|
99
|
+
}`,...(D=(q=p.parameters)==null?void 0:q.docs)==null?void 0:D.source}}};var N,W,L;u.parameters={...u.parameters,docs:{...(N=u.parameters)==null?void 0:N.docs,source:{originalSource:`{
|
100
100
|
args: {
|
101
101
|
hideLabel: true
|
102
102
|
},
|
@@ -109,7 +109,7 @@ import{j as X}from"./jsx-runtime-BYouaCF_.js";import{r as $}from"./index-B3evPFB
|
|
109
109
|
expect(input).toHaveAccessibleName('Password');
|
110
110
|
});
|
111
111
|
}
|
112
|
-
}`,...(L=(W=u.parameters)==null?void 0:W.docs)==null?void 0:L.source}}};var
|
112
|
+
}`,...(L=(W=u.parameters)==null?void 0:W.docs)==null?void 0:L.source}}};var R,j,k;y.parameters={...y.parameters,docs:{...(R=y.parameters)==null?void 0:R.docs,source:{originalSource:`{
|
113
113
|
args: {
|
114
114
|
error: 'This is an error message'
|
115
115
|
},
|
@@ -124,7 +124,7 @@ import{j as X}from"./jsx-runtime-BYouaCF_.js";import{r as $}from"./index-B3evPFB
|
|
124
124
|
expect(error).toHaveTextContent('This is an error message');
|
125
125
|
});
|
126
126
|
}
|
127
|
-
}`,...(k=(j=y.parameters)==null?void 0:j.docs)==null?void 0:k.source}}};var
|
127
|
+
}`,...(k=(j=y.parameters)==null?void 0:j.docs)==null?void 0:k.source}}};var O,K,M;b.parameters={...b.parameters,docs:{...(O=b.parameters)==null?void 0:O.docs,source:{originalSource:`{
|
128
128
|
args: {
|
129
129
|
disabled: true
|
130
130
|
},
|