@purpur/library 9.6.0 → 9.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +45 -0
- package/CHANGELOG.md +19 -1
- package/dist/LICENSE.txt +7 -7
- package/dist/ThemeProvider-D7oXcAde.js +2 -0
- package/dist/{ThemeProvider-Dy771oix.js.map → ThemeProvider-D7oXcAde.js.map} +1 -1
- package/dist/ThemeProvider-DiDBfyFA.mjs +348 -0
- package/dist/{ThemeProvider-CkX-BNWN.mjs.map → ThemeProvider-DiDBfyFA.mjs.map} +1 -1
- package/dist/carousel-BIKcwvYz.mjs +1658 -0
- package/dist/carousel-BIKcwvYz.mjs.map +1 -0
- package/dist/carousel-DnSaLDZf.js +2 -0
- package/dist/carousel-DnSaLDZf.js.map +1 -0
- package/dist/carousel.cjs.js +1 -1
- package/dist/carousel.es.js +1 -1
- package/dist/{comparison-table-Nhp5W6Yc.js → comparison-table-0UDB2BTU.js} +2 -2
- package/dist/{comparison-table-Nhp5W6Yc.js.map → comparison-table-0UDB2BTU.js.map} +1 -1
- package/dist/{comparison-table-CZMKl1TX.mjs → comparison-table-CjTE-fHN.mjs} +48 -48
- package/dist/{comparison-table-CZMKl1TX.mjs.map → comparison-table-CjTE-fHN.mjs.map} +1 -1
- package/dist/comparison-table.cjs.js +1 -1
- package/dist/comparison-table.es.js +1 -1
- package/dist/components/button/src/button.visual.fixtures.d.ts +43 -0
- package/dist/components/button/src/button.visual.fixtures.d.ts.map +1 -0
- package/dist/components/carousel/src/carousel.d.ts.map +1 -1
- package/dist/components/date-picker/src/date-picker.d.ts +8 -0
- package/dist/components/date-picker/src/date-picker.d.ts.map +1 -1
- package/dist/components/drawer/src/drawer-content.d.ts +21 -0
- package/dist/components/drawer/src/drawer-content.d.ts.map +1 -1
- package/dist/components/hero-banner/src/hero-banner.visual.fixtures.d.ts +14 -0
- package/dist/components/hero-banner/src/hero-banner.visual.fixtures.d.ts.map +1 -0
- package/dist/components/modal/src/modal-content.d.ts +21 -0
- package/dist/components/modal/src/modal-content.d.ts.map +1 -1
- package/dist/components/modal/src/modal.d.ts +2 -0
- package/dist/components/modal/src/modal.d.ts.map +1 -1
- package/dist/components/popover/src/popover-content.d.ts +14 -0
- package/dist/components/popover/src/popover-content.d.ts.map +1 -1
- package/dist/components/radio-card-group/src/is-radio-card-item.d.ts +4 -0
- package/dist/components/radio-card-group/src/is-radio-card-item.d.ts.map +1 -0
- package/dist/components/radio-card-group/src/radio-card-group.constants.d.ts +5 -0
- package/dist/components/radio-card-group/src/radio-card-group.constants.d.ts.map +1 -0
- package/dist/components/radio-card-group/src/radio-card-group.d.ts +5 -6
- package/dist/components/radio-card-group/src/radio-card-group.d.ts.map +1 -1
- package/dist/components/radio-card-group/src/radio-card-item.d.ts +1 -2
- package/dist/components/radio-card-group/src/radio-card-item.d.ts.map +1 -1
- package/dist/components/search-field/src/search-field-autocomplete.d.ts +6 -3
- package/dist/components/search-field/src/search-field-autocomplete.d.ts.map +1 -1
- package/dist/components/search-field/src/search-field-base.d.ts +10 -3
- package/dist/components/search-field/src/search-field-base.d.ts.map +1 -1
- package/dist/components/search-field/src/search-field-button.d.ts +3 -1
- package/dist/components/search-field/src/search-field-button.d.ts.map +1 -1
- package/dist/components/search-field/src/search-field.d.ts +12 -6
- package/dist/components/search-field/src/search-field.d.ts.map +1 -1
- package/dist/components/table/src/drag-indicator-circle.d.ts +8 -1
- package/dist/components/table/src/drag-indicator-circle.d.ts.map +1 -1
- package/dist/components/table/src/table.d.ts.map +1 -1
- package/dist/components/tooltip/src/tooltip.d.ts +21 -0
- package/dist/components/tooltip/src/tooltip.d.ts.map +1 -1
- package/dist/components-metadata.js +0 -2
- package/dist/date-picker-CIizn3Pv.js +2 -0
- package/dist/{date-picker-uyPKJulK.js.map → date-picker-CIizn3Pv.js.map} +1 -1
- package/dist/date-picker-DixxW60s.mjs +1617 -0
- package/dist/{date-picker-CzxhZxsw.mjs.map → date-picker-DixxW60s.mjs.map} +1 -1
- package/dist/date-picker.cjs.js +1 -1
- package/dist/date-picker.es.js +1 -1
- package/dist/drawer-BzkRd9F0.mjs +577 -0
- package/dist/drawer-BzkRd9F0.mjs.map +1 -0
- package/dist/drawer-DyhsP34o.js +2 -0
- package/dist/drawer-DyhsP34o.js.map +1 -0
- package/dist/drawer.cjs.js +1 -1
- package/dist/drawer.es.js +1 -1
- package/dist/{footer-D9AcPwlH.js → footer-3Y-664-8.js} +2 -2
- package/dist/{footer-D9AcPwlH.js.map → footer-3Y-664-8.js.map} +1 -1
- package/dist/{footer-BLPlXaZK.mjs → footer-DenAcikt.mjs} +3 -3
- package/dist/{footer-BLPlXaZK.mjs.map → footer-DenAcikt.mjs.map} +1 -1
- package/dist/footer.cjs.js +1 -1
- package/dist/footer.es.js +1 -1
- package/dist/{hero-banner-DkC_BqM7.mjs → hero-banner-B7xrDfzN.mjs} +2 -2
- package/dist/{hero-banner-DkC_BqM7.mjs.map → hero-banner-B7xrDfzN.mjs.map} +1 -1
- package/dist/{hero-banner-D1A-_qou.js → hero-banner-DthITuQ7.js} +2 -2
- package/dist/{hero-banner-D1A-_qou.js.map → hero-banner-DthITuQ7.js.map} +1 -1
- package/dist/hero-banner.cjs.js +1 -1
- package/dist/hero-banner.es.js +1 -1
- package/dist/libraries/theme/src/ThemeProvider.d.ts.map +1 -1
- package/dist/libraries/theme/src/theme.d.ts +1 -0
- package/dist/libraries/theme/src/theme.d.ts.map +1 -1
- package/dist/libraries/theme/src/types.d.ts +7 -0
- package/dist/libraries/theme/src/types.d.ts.map +1 -1
- package/dist/libraries/theme/src/useThemePortalContainer.d.ts +12 -0
- package/dist/libraries/theme/src/useThemePortalContainer.d.ts.map +1 -0
- package/dist/library.cjs.js +1 -1
- package/dist/library.es.js +469 -469
- package/dist/library.es.js.map +1 -1
- package/dist/modal-DJn9idcw.js +2 -0
- package/dist/modal-DJn9idcw.js.map +1 -0
- package/dist/{modal-fp37VbrH.mjs → modal-EIP36327.mjs} +83 -80
- package/dist/modal-EIP36327.mjs.map +1 -0
- package/dist/modal.cjs.js +1 -1
- package/dist/modal.es.js +1 -1
- package/dist/{popover-I26xNbTz.mjs → popover-DERrvReO.mjs} +328 -325
- package/dist/popover-DERrvReO.mjs.map +1 -0
- package/dist/popover-DnGgzfQr.js +2 -0
- package/dist/popover-DnGgzfQr.js.map +1 -0
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.es.js +1 -1
- package/dist/{promotion-card-BiHnQvhn.mjs → promotion-card-BnzIVNQ4.mjs} +2 -2
- package/dist/{promotion-card-BiHnQvhn.mjs.map → promotion-card-BnzIVNQ4.mjs.map} +1 -1
- package/dist/{promotion-card-Bag64gqP.js → promotion-card-DKc2Cx1h.js} +2 -2
- package/dist/{promotion-card-Bag64gqP.js.map → promotion-card-DKc2Cx1h.js.map} +1 -1
- package/dist/promotion-card.cjs.js +1 -1
- package/dist/promotion-card.es.js +1 -1
- package/dist/purpur.css +1 -1
- package/dist/radio-card-group-ZBXjYcQs.mjs +166 -0
- package/dist/radio-card-group-ZBXjYcQs.mjs.map +1 -0
- package/dist/radio-card-group-nrDi5EPK.js +2 -0
- package/dist/radio-card-group-nrDi5EPK.js.map +1 -0
- package/dist/radio-card-group.cjs.js +1 -1
- package/dist/radio-card-group.es.js +3 -5
- package/dist/search-field-2vdDbiT0.js +2 -0
- package/dist/search-field-2vdDbiT0.js.map +1 -0
- package/dist/search-field-DKyNh7pE.mjs +167 -0
- package/dist/search-field-DKyNh7pE.mjs.map +1 -0
- package/dist/search-field.cjs.js +1 -1
- package/dist/search-field.es.js +1 -1
- package/dist/{stepper-CWR2vGPj.mjs → stepper-BDsSa6yr.mjs} +2 -2
- package/dist/{stepper-CWR2vGPj.mjs.map → stepper-BDsSa6yr.mjs.map} +1 -1
- package/dist/{stepper-Df4X7DDR.js → stepper-DpauItjx.js} +2 -2
- package/dist/{stepper-Df4X7DDR.js.map → stepper-DpauItjx.js.map} +1 -1
- package/dist/stepper.cjs.js +1 -1
- package/dist/stepper.es.js +1 -1
- package/dist/{table-gnGUejtb.js → table-BOCcBzSO.js} +4 -4
- package/dist/table-BOCcBzSO.js.map +1 -0
- package/dist/{table-g_n68i4s.mjs → table-i1Gs9e0e.mjs} +440 -440
- package/dist/table-i1Gs9e0e.mjs.map +1 -0
- package/dist/table.cjs.js +1 -1
- package/dist/table.es.js +1 -1
- package/dist/{text-area-peNKG7g4.js → text-area-D0truMT1.js} +2 -2
- package/dist/{text-area-peNKG7g4.js.map → text-area-D0truMT1.js.map} +1 -1
- package/dist/{text-area-kJvg6cFp.mjs → text-area-IVH-k4MM.mjs} +3 -3
- package/dist/{text-area-kJvg6cFp.mjs.map → text-area-IVH-k4MM.mjs.map} +1 -1
- package/dist/text-area.cjs.js +1 -1
- package/dist/text-area.es.js +1 -1
- package/dist/theme.cjs.js +1 -1
- package/dist/theme.es.js +8 -6
- package/dist/theme.es.js.map +1 -1
- package/dist/tooltip-CJGmJDFQ.js +2 -0
- package/dist/{tooltip-C8Zxnqdb.js.map → tooltip-CJGmJDFQ.js.map} +1 -1
- package/dist/{tooltip-LU2Cy-QC.mjs → tooltip-RA-03bKs.mjs} +277 -274
- package/dist/{tooltip-LU2Cy-QC.mjs.map → tooltip-RA-03bKs.mjs.map} +1 -1
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.es.js +1 -1
- package/dist/{useColorScheme-tAkY9LHt.mjs → useColorScheme-B9DWd-LN.mjs} +2 -2
- package/dist/{useColorScheme-tAkY9LHt.mjs.map → useColorScheme-B9DWd-LN.mjs.map} +1 -1
- package/dist/useColorScheme-DbTQjxNB.js +2 -0
- package/dist/{useColorScheme-DNyjsWX9.js.map → useColorScheme-DbTQjxNB.js.map} +1 -1
- package/dist/useThemePortalContainer-D9BYjEvT.js +2 -0
- package/dist/useThemePortalContainer-D9BYjEvT.js.map +1 -0
- package/dist/useThemePortalContainer-tFLTaYKN.mjs +9 -0
- package/dist/useThemePortalContainer-tFLTaYKN.mjs.map +1 -0
- package/package.json +26 -26
- package/src/library.ts +2 -71
- package/dist/ThemeProvider-CkX-BNWN.mjs +0 -337
- package/dist/ThemeProvider-Dy771oix.js +0 -2
- package/dist/carousel-DLkTL9sj.mjs +0 -1633
- package/dist/carousel-DLkTL9sj.mjs.map +0 -1
- package/dist/carousel-DXrtxRz5.js +0 -2
- package/dist/carousel-DXrtxRz5.js.map +0 -1
- package/dist/date-picker-CzxhZxsw.mjs +0 -1611
- package/dist/date-picker-uyPKJulK.js +0 -2
- package/dist/drawer-8Acg4wkV.mjs +0 -574
- package/dist/drawer-8Acg4wkV.mjs.map +0 -1
- package/dist/drawer-BLHgcEqb.js +0 -2
- package/dist/drawer-BLHgcEqb.js.map +0 -1
- package/dist/modal-Baisuc6m.js +0 -2
- package/dist/modal-Baisuc6m.js.map +0 -1
- package/dist/modal-fp37VbrH.mjs.map +0 -1
- package/dist/popover-B0XJZ5mj.js +0 -2
- package/dist/popover-B0XJZ5mj.js.map +0 -1
- package/dist/popover-I26xNbTz.mjs.map +0 -1
- package/dist/radio-card-group-CneOprGY.mjs +0 -168
- package/dist/radio-card-group-CneOprGY.mjs.map +0 -1
- package/dist/radio-card-group-Ctuvg61o.js +0 -2
- package/dist/radio-card-group-Ctuvg61o.js.map +0 -1
- package/dist/search-field-CpkHGIYi.mjs +0 -151
- package/dist/search-field-CpkHGIYi.mjs.map +0 -1
- package/dist/search-field-Z0PqDARl.js +0 -2
- package/dist/search-field-Z0PqDARl.js.map +0 -1
- package/dist/table-g_n68i4s.mjs.map +0 -1
- package/dist/table-gnGUejtb.js.map +0 -1
- package/dist/tooltip-C8Zxnqdb.js +0 -2
- package/dist/useColorScheme-DNyjsWX9.js +0 -2
- package/tokens/_dark.scss +0 -9
- package/tokens/_index.scss +0 -9
- package/tokens/border/variables.css +0 -13
- package/tokens/border/variables.d.ts +0 -10
- package/tokens/border/variables.dark.css +0 -12
- package/tokens/border/variables.dark.d.ts +0 -10
- package/tokens/border/variables.dark.js +0 -10
- package/tokens/border/variables.dark.json +0 -18
- package/tokens/border/variables.dark.scss +0 -10
- package/tokens/border/variables.js +0 -10
- package/tokens/border/variables.json +0 -18
- package/tokens/border/variables.scss +0 -10
- package/tokens/breakpoint/variables.css +0 -11
- package/tokens/breakpoint/variables.d.ts +0 -8
- package/tokens/breakpoint/variables.dark.css +0 -10
- package/tokens/breakpoint/variables.dark.d.ts +0 -8
- package/tokens/breakpoint/variables.dark.js +0 -8
- package/tokens/breakpoint/variables.dark.json +0 -14
- package/tokens/breakpoint/variables.dark.scss +0 -8
- package/tokens/breakpoint/variables.js +0 -8
- package/tokens/breakpoint/variables.json +0 -14
- package/tokens/breakpoint/variables.scss +0 -8
- package/tokens/color/variables.css +0 -262
- package/tokens/color/variables.d.ts +0 -253
- package/tokens/color/variables.dark.css +0 -262
- package/tokens/color/variables.dark.d.ts +0 -252
- package/tokens/color/variables.dark.js +0 -252
- package/tokens/color/variables.dark.json +0 -306
- package/tokens/color/variables.dark.scss +0 -252
- package/tokens/color/variables.js +0 -253
- package/tokens/color/variables.json +0 -307
- package/tokens/color/variables.scss +0 -253
- package/tokens/dark.css +0 -9
- package/tokens/dark.d.ts +0 -9
- package/tokens/dark.js +0 -9
- package/tokens/filter/variables.css +0 -4
- package/tokens/filter/variables.d.ts +0 -1
- package/tokens/filter/variables.dark.css +0 -3
- package/tokens/filter/variables.dark.d.ts +0 -1
- package/tokens/filter/variables.dark.js +0 -1
- package/tokens/filter/variables.dark.json +0 -7
- package/tokens/filter/variables.dark.scss +0 -1
- package/tokens/filter/variables.js +0 -1
- package/tokens/filter/variables.json +0 -7
- package/tokens/filter/variables.scss +0 -1
- package/tokens/gradient/variables.css +0 -53
- package/tokens/gradient/variables.d.ts +0 -9
- package/tokens/gradient/variables.dark.css +0 -51
- package/tokens/gradient/variables.dark.d.ts +0 -9
- package/tokens/gradient/variables.dark.js +0 -18
- package/tokens/gradient/variables.dark.json +0 -27
- package/tokens/gradient/variables.dark.scss +0 -36
- package/tokens/gradient/variables.js +0 -18
- package/tokens/gradient/variables.json +0 -27
- package/tokens/gradient/variables.scss +0 -42
- package/tokens/index.css +0 -18
- package/tokens/index.d.ts +0 -9
- package/tokens/index.js +0 -9
- package/tokens/motion/variables.css +0 -14
- package/tokens/motion/variables.d.ts +0 -11
- package/tokens/motion/variables.dark.css +0 -13
- package/tokens/motion/variables.dark.d.ts +0 -11
- package/tokens/motion/variables.dark.js +0 -11
- package/tokens/motion/variables.dark.json +0 -19
- package/tokens/motion/variables.dark.scss +0 -11
- package/tokens/motion/variables.js +0 -11
- package/tokens/motion/variables.json +0 -19
- package/tokens/motion/variables.scss +0 -11
- package/tokens/shadow/variables.css +0 -11
- package/tokens/shadow/variables.d.ts +0 -4
- package/tokens/shadow/variables.dark.css +0 -10
- package/tokens/shadow/variables.dark.d.ts +0 -4
- package/tokens/shadow/variables.dark.js +0 -4
- package/tokens/shadow/variables.dark.json +0 -8
- package/tokens/shadow/variables.dark.scss +0 -4
- package/tokens/shadow/variables.js +0 -4
- package/tokens/shadow/variables.json +0 -8
- package/tokens/shadow/variables.scss +0 -4
- package/tokens/spacing/variables.css +0 -26
- package/tokens/spacing/variables.d.ts +0 -23
- package/tokens/spacing/variables.dark.css +0 -17
- package/tokens/spacing/variables.dark.d.ts +0 -15
- package/tokens/spacing/variables.dark.js +0 -15
- package/tokens/spacing/variables.dark.json +0 -19
- package/tokens/spacing/variables.dark.scss +0 -15
- package/tokens/spacing/variables.js +0 -23
- package/tokens/spacing/variables.json +0 -31
- package/tokens/spacing/variables.scss +0 -23
- package/tokens/typography/variables.css +0 -30
- package/tokens/typography/variables.d.ts +0 -26
- package/tokens/typography/variables.dark.css +0 -29
- package/tokens/typography/variables.dark.d.ts +0 -26
- package/tokens/typography/variables.dark.js +0 -28
- package/tokens/typography/variables.dark.json +0 -38
- package/tokens/typography/variables.dark.scss +0 -26
- package/tokens/typography/variables.js +0 -28
- package/tokens/typography/variables.json +0 -38
- package/tokens/typography/variables.scss +0 -26
package/dist/library.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"library.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),c=require("./index-2cFVyGXq.js"),s=require("react"),V=require("./button-DmybVApa.js"),K=require("./heading-drD5ugCC.js"),k=require("./close.es-VL3lKi1O.js"),G=require("./paragraph-By4jMjnH.js");require("./ThemeProvider-D7oXcAde.js");const J=require("./useThemePortalContainer-D9BYjEvT.js"),Q=require("./visually-hidden-C2CKovZx.js"),X=require("./bind-DeUYJ6m9.js"),Y="_fadeIn_1nrj3_1",Z="_fadeOut_1nrj3_1",ee="_slideUp_1nrj3_1",te="_slideDown_1nrj3_1",re={"purpur-modal-content":"_purpur-modal-content_1nrj3_1",fadeIn:Y,fadeOut:Z,slideUp:ee,slideDown:te,"purpur-modal-content__overlay":"_purpur-modal-content__overlay_1nrj3_49","purpur-modal-content__close-button":"_purpur-modal-content__close-button_1nrj3_65","purpur-modal-content__wrapper":"_purpur-modal-content__wrapper_1nrj3_75","purpur-modal-content__wrapper-inner":"_purpur-modal-content__wrapper-inner_1nrj3_85","purpur-modal-content__image-wrapper":"_purpur-modal-content__image-wrapper_1nrj3_89","purpur-modal-content__header":"_purpur-modal-content__header_1nrj3_112","purpur-modal-content__title":"_purpur-modal-content__title_1nrj3_125","purpur-modal-content__heading":"_purpur-modal-content__heading_1nrj3_128","purpur-modal-content__description":"_purpur-modal-content__description_1nrj3_131","purpur-modal-content__body":"_purpur-modal-content__body_1nrj3_134","purpur-modal-content__body-inner":"_purpur-modal-content__body-inner_1nrj3_142","purpur-modal-content__actions-buttons":"_purpur-modal-content__actions-buttons_1nrj3_154","purpur-modal-content__notification":"_purpur-modal-content__notification_1nrj3_172","purpur-modal-content--with-image":"_purpur-modal-content--with-image_1nrj3_175","purpur-modal-content--overflow":"_purpur-modal-content--overflow_1nrj3_175","purpur-modal-content__actions":"_purpur-modal-content__actions_1nrj3_154","purpur-modal-content__actions-separator":"_purpur-modal-content__actions-separator_1nrj3_206","purpur-modal-content--sticky-footer":"_purpur-modal-content--sticky-footer_1nrj3_216"},N=n=>n.showCloseButton===!0,r=X.c.bind(re),t="purpur-modal-content",ne=s.forwardRef(({["data-testid"]:n,actions:o,children:a,className:u,description:_,disableCloseOnClickOutside:y,hideDescription:b,image:p,stickyButtons:v=!0,title:D,notification:x=void 0,zIndex:$,container:C,onCloseAutoFocus:O,...g},P)=>{const{closeButtonAriaLabel:h,showCloseButton:E,...H}=g,[I,M]=s.useState(!1),[S,T]=s.useState(0),m=s.useRef(null),j=s.useRef(null),B=J.useThemePortalContainer(),W=C===void 0?B:C??void 0,z=r(t,{[`${t}--with-image`]:!!p},{[`${t}--overflow`]:I},{[`${t}--sticky-footer`]:v},u),d=l=>n?`${n} ${l}`:void 0,A=l=>{y&&l.preventDefault()},i=s.useCallback(()=>{if(!m.current||!j.current)return;const l=window.getComputedStyle(m.current,null),f=parseFloat(l.getPropertyValue("height")),U=j.current.offsetHeight;M(f<U),T((m.current.offsetWidth??0)-(m.current.clientWidth??0))},[]),F=()=>{const l=j.current;if(l){const f=l.querySelector("h2");f&&setTimeout(()=>{f.focus()})}},L=l=>{y&&!E&&l.preventDefault()};return s.useEffect(()=>(window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}),[i]),s.useEffect(()=>{i()},[x,a,i]),e.jsxs(c.Portal,{container:W,children:[e.jsx(c.Overlay,{className:r(`${t}__overlay`),style:{zIndex:$}}),e.jsxs(c.Content,{...H,className:z,"data-testid":n,ref:P,...!_&&{"aria-describedby":void 0},onPointerDownOutside:A,onOpenAutoFocus:()=>{i(),F()},onEscapeKeyDown:L,onCloseAutoFocus:O,style:{zIndex:`calc(${$} + 1)`},children:[e.jsxs("div",{ref:m,className:r(`${t}__wrapper`),children:[N(g)&&h&&p&&e.jsx(q,{"aria-label":h,hasImage:!0,scrollbarWidth:S,"data-testid":d("close-button")}),e.jsxs("div",{ref:j,className:r(`${t}__wrapper-inner`),children:[e.jsxs("div",{className:r(`${t}__header`),children:[N(g)&&h&&!p&&e.jsx(q,{"aria-label":h,"data-testid":d("close-button")}),e.jsx(c.Title,{asChild:!0,className:r(`${t}__title`),"data-testid":d("title"),children:e.jsx(K.Heading,{tag:"h2",variant:"display-10",tabIndex:-1,className:r(`${t}__heading`),children:D})})]}),p&&e.jsx("div",{className:r(`${t}__image-wrapper`),"data-testid":d("image"),children:p}),e.jsx("div",{className:r(`${t}__body`),children:e.jsxs("div",{className:r(`${t}__body-inner`),children:[_&&b&&e.jsx(Q.VisuallyHidden,{asChild:!0,children:e.jsx(c.Description,{"data-testid":d("description"),children:_})}),_&&!b&&e.jsx(c.Description,{asChild:!0,className:r(`${t}__description`),"data-testid":d("description"),children:e.jsx(G.Paragraph,{variant:"paragraph-100",children:_})}),e.jsx("div",{children:a}),!v&&e.jsx(R,{actions:o,notification:x})]})})]})]}),v&&e.jsx(R,{actions:o,notification:x})]})]})}),q=({["aria-label"]:n,hasImage:o,scrollbarWidth:a,["data-testid"]:u})=>e.jsx(c.Close,{asChild:!0,children:e.jsx(V.Button,{variant:o?"primary":"tertiary-purple",negative:o,size:"sm",iconOnly:!0,"aria-label":n,className:r(`${t}__close-button`),style:{right:`calc(var(--purpur-spacing-100) + ${a||0}px)`},"data-testid":u,children:e.jsx(k.r,{})})}),R=({actions:n,notification:o})=>{const a=s.useRef(null);return s.useEffect(()=>{o&&a?.current?.scrollIntoView?.(!1)},[o]),n?e.jsxs("div",{className:r(`${t}__actions`),children:[e.jsx("div",{className:r(`${t}__actions-buttons`),"data-testid":"modal actions",children:n}),o&&e.jsx("div",{className:r(`${t}__notification`),ref:a,children:o}),e.jsx("span",{className:r(`${t}__actions-separator`)})]}):null},oe=s.forwardRef(({children:n,...o},a)=>e.jsx(c.Trigger,{asChild:!0,ref:a,...o,children:n})),w=({["data-testid"]:n,children:o,open:a,onOpenChange:u})=>e.jsx(c.Root,{open:a,onOpenChange:u,"data-testid":n,children:o});w.Trigger=oe;w.Content=ne;w.displayName="Modal";exports.Modal=w;
|
|
2
|
+
//# sourceMappingURL=modal-DJn9idcw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal-DJn9idcw.js","sources":["../../../components/modal/src/modal-content.tsx","../../../components/modal/src/modal-trigger.tsx","../../../components/modal/src/modal.tsx"],"sourcesContent":["import React, { forwardRef, type ReactNode, useCallback, useEffect, useRef, useState } from \"react\";\nimport { Button } from \"@purpur/button\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Heading } from \"@purpur/heading\";\nimport { IconClose } from \"@purpur/icon/close\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport { useThemePortalContainer } from \"@purpur/theme\";\nimport { VisuallyHidden } from \"@purpur/visually-hidden\";\nimport {\n Close as RadixClose,\n Content as RadixContent,\n Description as RadixDescription,\n Overlay as RadixOverlay,\n Portal as RadixPortal,\n Title as RadixTitle,\n} from \"@radix-ui/react-dialog\";\nimport c from \"classnames/bind\";\n\nimport \"@purpur/notification/styles\";\nimport styles from \"./modal-content.module.scss\";\n\nexport type DefaultProps = Omit<BaseProps, \"children\"> & {\n /**\n * One or several CTA links or buttons\n * */\n actions?: ReactNode;\n children: ReactNode;\n /**\n * An optional accessible description to be announced when the dialog is opened.\n * */\n description?: string;\n /**\n * Prevents the modal from closing on click outside if set to `true`.\n * */\n disableCloseOnClickOutside?: boolean;\n /**\n * Visually hides the description if set to `true`.\n * */\n hideDescription?: boolean;\n /**\n * An optional image to be displayed at the top of the modal.\n * */\n image?: ReactNode;\n /**\n * Provide a Purpur Notification which will render beneath the modal buttons, otherwise leave it undefined.\n * */\n notification?: ReactNode;\n /**\n * Determines whether the button group should be fixed at the bottom or scroll with the content.\n * */\n stickyButtons?: boolean;\n /**\n * An accessible title to be announced when the dialog is opened.\n * */\n title: string;\n /**\n * z-index of the modal\n * */\n zIndex?: number;\n /**\n * Optional DOM element to portal the modal content into. When omitted,\n * the modal renders inside the nearest `ThemeProvider` so it inherits\n * the active color scheme. Pass `document.body` (or any other element) to\n * override. Pass `null` to fall back to Radix' default (`document.body`).\n * */\n container?: HTMLElement | null;\n /**\n * Event handler called when focus moves to the trigger after closing.\n * */\n onCloseAutoFocus?: (e: Event) => void;\n};\n\ntype NoCloseButtonProps = {\n /**\n * An accessible label for the close button.\n * */\n closeButtonAriaLabel?: never;\n /**\n * Shows the close button if set to `true`. Must be used in conjunction with `closeButtonAriaLabel`.\n * */\n showCloseButton?: false;\n};\n\ntype CloseButtonProps = {\n /**\n * An accessible label for the close button.\n * */\n closeButtonAriaLabel: string;\n /**\n * Shows the close button if set to `true`. Must be used in conjunction with `closeButtonAriaLabel`.\n * */\n showCloseButton: true;\n};\n\nexport type ModalContentProps = DefaultProps & (CloseButtonProps | NoCloseButtonProps);\n\nconst hasCloseButtonProps = (\n props: CloseButtonProps | NoCloseButtonProps\n): props is CloseButtonProps => (props as CloseButtonProps).showCloseButton === true;\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-modal-content\";\n\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n actions,\n children,\n className,\n description,\n disableCloseOnClickOutside,\n hideDescription,\n image,\n stickyButtons = true,\n title,\n notification = undefined,\n zIndex,\n container,\n onCloseAutoFocus,\n ...props\n },\n ref\n ) => {\n const { closeButtonAriaLabel, showCloseButton, ...rest } = props;\n const [contentOverflow, setContentOverflow] = useState(false);\n const [scrollbarWidth, setScrollbarWidth] = useState(0);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const wrapperInnerRef = useRef<HTMLDivElement>(null);\n const themePortalContainer = useThemePortalContainer();\n const portalContainer =\n container === undefined ? themePortalContainer : container ?? undefined;\n\n const classes = cx(\n rootClassName,\n { [`${rootClassName}--with-image`]: !!image },\n { [`${rootClassName}--overflow`]: contentOverflow },\n { [`${rootClassName}--sticky-footer`]: stickyButtons },\n className\n );\n\n const getTestId = (id: string) => (dataTestId ? `${dataTestId} ${id}` : undefined);\n\n const handlePointerDownOutside = (event: CustomEvent<{ originalEvent: PointerEvent }>) => {\n if (disableCloseOnClickOutside) {\n event.preventDefault();\n }\n };\n\n const handleContentOverflow = useCallback(() => {\n if (!wrapperRef.current || !wrapperInnerRef.current) {\n return;\n }\n\n const computedStyle = window.getComputedStyle(wrapperRef.current, null);\n const wrapperHeight = parseFloat(computedStyle.getPropertyValue(\"height\"));\n const innerHeight = wrapperInnerRef.current.offsetHeight;\n\n setContentOverflow(wrapperHeight < innerHeight);\n\n setScrollbarWidth(\n (wrapperRef.current.offsetWidth ?? 0) - (wrapperRef.current.clientWidth ?? 0)\n );\n }, []);\n\n const handleInitialFocus = () => {\n const frame = wrapperInnerRef.current;\n if (frame) {\n const heading = frame.querySelector(\"h2\");\n\n heading &&\n setTimeout(() => {\n heading.focus();\n });\n }\n };\n\n const handleEscapeKeyDown = (event: KeyboardEvent) => {\n if (disableCloseOnClickOutside && !showCloseButton) {\n event.preventDefault();\n }\n };\n\n useEffect(() => {\n window.addEventListener(\"resize\", handleContentOverflow);\n\n return () => {\n window.removeEventListener(\"resize\", handleContentOverflow);\n };\n }, [handleContentOverflow]);\n\n useEffect(() => {\n handleContentOverflow();\n }, [notification, children, handleContentOverflow]);\n\n return (\n <RadixPortal container={portalContainer}>\n <RadixOverlay className={cx(`${rootClassName}__overlay`)} style={{ zIndex }} />\n <RadixContent\n {...rest}\n className={classes}\n data-testid={dataTestId}\n ref={ref}\n {...(!description && { [\"aria-describedby\"]: undefined })}\n onPointerDownOutside={handlePointerDownOutside}\n onOpenAutoFocus={() => {\n handleContentOverflow();\n handleInitialFocus();\n }}\n onEscapeKeyDown={handleEscapeKeyDown}\n onCloseAutoFocus={onCloseAutoFocus}\n style={{ zIndex: `calc(${zIndex} + 1)` }}\n >\n <div ref={wrapperRef} className={cx(`${rootClassName}__wrapper`)}>\n {hasCloseButtonProps(props) && closeButtonAriaLabel && image && (\n <CloseButton\n aria-label={closeButtonAriaLabel}\n hasImage\n scrollbarWidth={scrollbarWidth}\n data-testid={getTestId(\"close-button\")}\n />\n )}\n <div ref={wrapperInnerRef} className={cx(`${rootClassName}__wrapper-inner`)}>\n <div className={cx(`${rootClassName}__header`)}>\n {hasCloseButtonProps(props) && closeButtonAriaLabel && !image && (\n <CloseButton\n aria-label={closeButtonAriaLabel}\n data-testid={getTestId(\"close-button\")}\n />\n )}\n <RadixTitle\n asChild\n className={cx(`${rootClassName}__title`)}\n data-testid={getTestId(\"title\")}\n >\n <Heading\n tag=\"h2\"\n variant=\"display-10\"\n tabIndex={-1}\n className={cx(`${rootClassName}__heading`)}\n >\n {title}\n </Heading>\n </RadixTitle>\n </div>\n {image && (\n <div\n className={cx(`${rootClassName}__image-wrapper`)}\n data-testid={getTestId(\"image\")}\n >\n {image}\n </div>\n )}\n <div className={cx(`${rootClassName}__body`)}>\n <div className={cx(`${rootClassName}__body-inner`)}>\n {description && hideDescription && (\n <VisuallyHidden asChild>\n <RadixDescription data-testid={getTestId(\"description\")}>\n {description}\n </RadixDescription>\n </VisuallyHidden>\n )}\n {description && !hideDescription && (\n <RadixDescription\n asChild\n className={cx(`${rootClassName}__description`)}\n data-testid={getTestId(\"description\")}\n >\n <Paragraph variant=\"paragraph-100\">{description}</Paragraph>\n </RadixDescription>\n )}\n <div>{children}</div>\n {!stickyButtons && <ModalActions actions={actions} notification={notification} />}\n </div>\n </div>\n </div>\n </div>\n\n {stickyButtons && <ModalActions actions={actions} notification={notification} />}\n </RadixContent>\n </RadixPortal>\n );\n }\n);\n\nconst CloseButton = ({\n [\"aria-label\"]: ariaLabel,\n hasImage,\n scrollbarWidth,\n [\"data-testid\"]: dataTestId,\n}: {\n [\"aria-label\"]: string;\n hasImage?: boolean;\n scrollbarWidth?: number;\n [\"data-testid\"]?: string;\n}) => (\n <RadixClose asChild>\n <Button\n variant={hasImage ? \"primary\" : \"tertiary-purple\"}\n negative={hasImage}\n size=\"sm\"\n iconOnly\n aria-label={ariaLabel}\n className={cx(`${rootClassName}__close-button`)}\n style={{ right: `calc(var(--purpur-spacing-100) + ${scrollbarWidth || 0}px)` }}\n data-testid={dataTestId}\n >\n <IconClose />\n </Button>\n </RadixClose>\n);\n\nexport const MAX_NUMBER_OF_ACTIONS = 3;\n\nexport const ModalActions = ({\n actions,\n notification,\n}: Pick<ModalContentProps, \"actions\" | \"notification\">) => {\n const notificationRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (notification) {\n notificationRef?.current?.scrollIntoView?.(false);\n }\n }, [notification]);\n\n return actions ? (\n <div className={cx(`${rootClassName}__actions`)}>\n <div className={cx(`${rootClassName}__actions-buttons`)} data-testid=\"modal actions\">\n {actions}\n </div>\n {notification && (\n <div className={cx(`${rootClassName}__notification`)} ref={notificationRef}>\n {notification}\n </div>\n )}\n <span className={cx(`${rootClassName}__actions-separator`)} />\n </div>\n ) : null;\n};\n","import React, { forwardRef, type ReactNode } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Trigger as RadixTrigger } from \"@radix-ui/react-dialog\";\n\nexport type ModalTriggerProps = Omit<BaseProps<\"button\">, \"children\"> & {\n children: ReactNode;\n};\n\nexport const ModalTrigger = forwardRef<HTMLButtonElement, ModalTriggerProps>(\n ({ children, ...props }, ref) => {\n return (\n <RadixTrigger asChild ref={ref} {...props}>\n {children}\n </RadixTrigger>\n );\n }\n);\n","import React, { type ReactNode } from \"react\";\nimport { Root as RadixRoot } from \"@radix-ui/react-dialog\";\n\nimport { ModalContent } from \"./modal-content\";\nimport { ModalTrigger } from \"./modal-trigger\";\n\nexport type ModalProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n /**\n * Event handler called when the open state of the dialog changes.\n * */\n onOpenChange?: (value: boolean) => void;\n /**\n * The controlled open state of the dialog. Must be used in conjunction with `onOpenChange`.\n * */\n open?: boolean;\n};\n\nexport const Modal = ({\n [\"data-testid\"]: dataTestId,\n children,\n open,\n onOpenChange,\n}: ModalProps) => (\n <RadixRoot open={open} onOpenChange={onOpenChange} data-testid={dataTestId}>\n {children}\n </RadixRoot>\n);\n\nModal.Trigger = ModalTrigger;\nModal.Content = ModalContent;\n\nModal.displayName = \"Modal\";\n"],"names":["hasCloseButtonProps","props","cx","c","styles","rootClassName","ModalContent","forwardRef","dataTestId","actions","children","className","description","disableCloseOnClickOutside","hideDescription","image","stickyButtons","title","notification","zIndex","container","onCloseAutoFocus","ref","closeButtonAriaLabel","showCloseButton","rest","contentOverflow","setContentOverflow","useState","scrollbarWidth","setScrollbarWidth","wrapperRef","useRef","wrapperInnerRef","themePortalContainer","useThemePortalContainer","portalContainer","classes","getTestId","id","handlePointerDownOutside","event","handleContentOverflow","useCallback","computedStyle","wrapperHeight","innerHeight","handleInitialFocus","frame","heading","handleEscapeKeyDown","useEffect","jsxs","RadixPortal","jsx","RadixOverlay","RadixContent","CloseButton","RadixTitle","Heading","VisuallyHidden","RadixDescription","Paragraph","ModalActions","ariaLabel","hasImage","RadixClose","Button","IconClose","notificationRef","ModalTrigger","RadixTrigger","Modal","open","onOpenChange","RadixRoot"],"mappings":"ogEAgGMA,EACJC,GAC+BA,EAA2B,kBAAoB,GAE1EC,EAAKC,EAAAA,EAAE,KAAKC,EAAM,EAClBC,EAAgB,uBAETC,GAAeC,EAAAA,WAC1B,CACE,CACE,CAAC,eAAgBC,EACjB,QAAAC,EACA,SAAAC,EACA,UAAAC,EACA,YAAAC,EACA,2BAAAC,EACA,gBAAAC,EACA,MAAAC,EACA,cAAAC,EAAgB,GAChB,MAAAC,EACA,aAAAC,EAAe,OACf,OAAAC,EACA,UAAAC,EACA,iBAAAC,EACA,GAAGpB,CAAA,EAELqB,IACG,CACH,KAAM,CAAE,qBAAAC,EAAsB,gBAAAC,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,EAC7D,SAAAE,CAAA,CACH,EAGF8D,EAAM,QAAUF,GAChBE,EAAM,QAAUlE,GAEhBkE,EAAM,YAAc"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { P as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { b as
|
|
5
|
-
import { H as
|
|
6
|
-
import { r as
|
|
7
|
-
import { P as
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { P as J, O as Q, C as X, T as Y, D as O, a as Z, b as tt, R as et } from "./index-3NV-ckDX.mjs";
|
|
3
|
+
import { forwardRef as I, useState as P, useRef as b, useCallback as rt, useEffect as g } from "react";
|
|
4
|
+
import { b as nt } from "./button-4-yWOgtD.mjs";
|
|
5
|
+
import { H as ot } from "./heading-xwBuT_-9.mjs";
|
|
6
|
+
import { r as at } from "./close.es-BPmk2wkU.mjs";
|
|
7
|
+
import { P as st } from "./paragraph-DSxXmX_0.mjs";
|
|
8
|
+
import "./ThemeProvider-DiDBfyFA.mjs";
|
|
9
|
+
import { u as lt } from "./useThemePortalContainer-tFLTaYKN.mjs";
|
|
10
|
+
import { V as _t } from "./visually-hidden-BYFkJEp1.mjs";
|
|
11
|
+
import { c as dt } from "./bind-CU-R61T-.mjs";
|
|
12
|
+
const it = "_fadeIn_1nrj3_1", ct = "_fadeOut_1nrj3_1", ut = "_slideUp_1nrj3_1", pt = "_slideDown_1nrj3_1", mt = {
|
|
11
13
|
"purpur-modal-content": "_purpur-modal-content_1nrj3_1",
|
|
12
|
-
fadeIn:
|
|
13
|
-
fadeOut:
|
|
14
|
-
slideUp:
|
|
15
|
-
slideDown:
|
|
14
|
+
fadeIn: it,
|
|
15
|
+
fadeOut: ct,
|
|
16
|
+
slideUp: ut,
|
|
17
|
+
slideDown: pt,
|
|
16
18
|
"purpur-modal-content__overlay": "_purpur-modal-content__overlay_1nrj3_49",
|
|
17
19
|
"purpur-modal-content__close-button": "_purpur-modal-content__close-button_1nrj3_65",
|
|
18
20
|
"purpur-modal-content__wrapper": "_purpur-modal-content__wrapper_1nrj3_75",
|
|
@@ -31,104 +33,105 @@ const lt = "_fadeIn_1nrj3_1", st = "_fadeOut_1nrj3_1", _t = "_slideUp_1nrj3_1",
|
|
|
31
33
|
"purpur-modal-content__actions": "_purpur-modal-content__actions_1nrj3_154",
|
|
32
34
|
"purpur-modal-content__actions-separator": "_purpur-modal-content__actions-separator_1nrj3_206",
|
|
33
35
|
"purpur-modal-content--sticky-footer": "_purpur-modal-content--sticky-footer_1nrj3_216"
|
|
34
|
-
},
|
|
36
|
+
}, R = (n) => n.showCloseButton === !0, r = dt.bind(mt), e = "purpur-modal-content", ht = I(
|
|
35
37
|
({
|
|
36
38
|
["data-testid"]: n,
|
|
37
39
|
actions: o,
|
|
38
40
|
children: a,
|
|
39
|
-
className:
|
|
40
|
-
description:
|
|
41
|
+
className: i,
|
|
42
|
+
description: c,
|
|
41
43
|
disableCloseOnClickOutside: $,
|
|
42
|
-
hideDescription:
|
|
44
|
+
hideDescription: C,
|
|
43
45
|
image: u,
|
|
44
46
|
stickyButtons: w = !0,
|
|
45
|
-
title:
|
|
47
|
+
title: M,
|
|
46
48
|
notification: v = void 0,
|
|
47
|
-
zIndex:
|
|
48
|
-
|
|
49
|
+
zIndex: N,
|
|
50
|
+
container: D,
|
|
51
|
+
onCloseAutoFocus: T,
|
|
49
52
|
...y
|
|
50
53
|
}, E) => {
|
|
51
|
-
const { closeButtonAriaLabel: m, showCloseButton: S, ...
|
|
54
|
+
const { closeButtonAriaLabel: m, showCloseButton: S, ...B } = y, [V, W] = P(!1), [z, A] = P(0), p = b(null), h = b(null), F = lt(), L = D === void 0 ? F : D ?? void 0, U = r(
|
|
52
55
|
e,
|
|
53
56
|
{ [`${e}--with-image`]: !!u },
|
|
54
|
-
{ [`${e}--overflow`]:
|
|
57
|
+
{ [`${e}--overflow`]: V },
|
|
55
58
|
{ [`${e}--sticky-footer`]: w },
|
|
56
|
-
|
|
57
|
-
), _ = (
|
|
58
|
-
$ &&
|
|
59
|
-
}, d =
|
|
59
|
+
i
|
|
60
|
+
), _ = (s) => n ? `${n} ${s}` : void 0, K = (s) => {
|
|
61
|
+
$ && s.preventDefault();
|
|
62
|
+
}, d = rt(() => {
|
|
60
63
|
if (!p.current || !h.current)
|
|
61
64
|
return;
|
|
62
|
-
const
|
|
63
|
-
|
|
65
|
+
const s = window.getComputedStyle(p.current, null), f = parseFloat(s.getPropertyValue("height")), G = h.current.offsetHeight;
|
|
66
|
+
W(f < G), A(
|
|
64
67
|
(p.current.offsetWidth ?? 0) - (p.current.clientWidth ?? 0)
|
|
65
68
|
);
|
|
66
|
-
}, []),
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
const f =
|
|
69
|
+
}, []), k = () => {
|
|
70
|
+
const s = h.current;
|
|
71
|
+
if (s) {
|
|
72
|
+
const f = s.querySelector("h2");
|
|
70
73
|
f && setTimeout(() => {
|
|
71
74
|
f.focus();
|
|
72
75
|
});
|
|
73
76
|
}
|
|
74
|
-
},
|
|
75
|
-
$ && !S &&
|
|
77
|
+
}, q = (s) => {
|
|
78
|
+
$ && !S && s.preventDefault();
|
|
76
79
|
};
|
|
77
80
|
return g(() => (window.addEventListener("resize", d), () => {
|
|
78
81
|
window.removeEventListener("resize", d);
|
|
79
82
|
}), [d]), g(() => {
|
|
80
83
|
d();
|
|
81
|
-
}, [v, a, d]), /* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */ t(
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
84
|
+
}, [v, a, d]), /* @__PURE__ */ l(J, { container: L, children: [
|
|
85
|
+
/* @__PURE__ */ t(Q, { className: r(`${e}__overlay`), style: { zIndex: N } }),
|
|
86
|
+
/* @__PURE__ */ l(
|
|
87
|
+
X,
|
|
85
88
|
{
|
|
86
|
-
...
|
|
87
|
-
className:
|
|
89
|
+
...B,
|
|
90
|
+
className: U,
|
|
88
91
|
"data-testid": n,
|
|
89
92
|
ref: E,
|
|
90
|
-
...!
|
|
91
|
-
onPointerDownOutside:
|
|
93
|
+
...!c && { "aria-describedby": void 0 },
|
|
94
|
+
onPointerDownOutside: K,
|
|
92
95
|
onOpenAutoFocus: () => {
|
|
93
|
-
d(),
|
|
96
|
+
d(), k();
|
|
94
97
|
},
|
|
95
|
-
onEscapeKeyDown:
|
|
96
|
-
onCloseAutoFocus:
|
|
97
|
-
style: { zIndex: `calc(${
|
|
98
|
+
onEscapeKeyDown: q,
|
|
99
|
+
onCloseAutoFocus: T,
|
|
100
|
+
style: { zIndex: `calc(${N} + 1)` },
|
|
98
101
|
children: [
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
/* @__PURE__ */ l("div", { ref: p, className: r(`${e}__wrapper`), children: [
|
|
103
|
+
R(y) && m && u && /* @__PURE__ */ t(
|
|
104
|
+
x,
|
|
102
105
|
{
|
|
103
106
|
"aria-label": m,
|
|
104
107
|
hasImage: !0,
|
|
105
|
-
scrollbarWidth:
|
|
108
|
+
scrollbarWidth: z,
|
|
106
109
|
"data-testid": _("close-button")
|
|
107
110
|
}
|
|
108
111
|
),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
/* @__PURE__ */ l("div", { ref: h, className: r(`${e}__wrapper-inner`), children: [
|
|
113
|
+
/* @__PURE__ */ l("div", { className: r(`${e}__header`), children: [
|
|
114
|
+
R(y) && m && !u && /* @__PURE__ */ t(
|
|
115
|
+
x,
|
|
113
116
|
{
|
|
114
117
|
"aria-label": m,
|
|
115
118
|
"data-testid": _("close-button")
|
|
116
119
|
}
|
|
117
120
|
),
|
|
118
121
|
/* @__PURE__ */ t(
|
|
119
|
-
|
|
122
|
+
Y,
|
|
120
123
|
{
|
|
121
124
|
asChild: !0,
|
|
122
125
|
className: r(`${e}__title`),
|
|
123
126
|
"data-testid": _("title"),
|
|
124
127
|
children: /* @__PURE__ */ t(
|
|
125
|
-
|
|
128
|
+
ot,
|
|
126
129
|
{
|
|
127
130
|
tag: "h2",
|
|
128
131
|
variant: "display-10",
|
|
129
132
|
tabIndex: -1,
|
|
130
133
|
className: r(`${e}__heading`),
|
|
131
|
-
children:
|
|
134
|
+
children: M
|
|
132
135
|
}
|
|
133
136
|
)
|
|
134
137
|
}
|
|
@@ -142,35 +145,35 @@ const lt = "_fadeIn_1nrj3_1", st = "_fadeOut_1nrj3_1", _t = "_slideUp_1nrj3_1",
|
|
|
142
145
|
children: u
|
|
143
146
|
}
|
|
144
147
|
),
|
|
145
|
-
/* @__PURE__ */ t("div", { className: r(`${e}__body`), children: /* @__PURE__ */
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
/* @__PURE__ */ t("div", { className: r(`${e}__body`), children: /* @__PURE__ */ l("div", { className: r(`${e}__body-inner`), children: [
|
|
149
|
+
c && C && /* @__PURE__ */ t(_t, { asChild: !0, children: /* @__PURE__ */ t(O, { "data-testid": _("description"), children: c }) }),
|
|
150
|
+
c && !C && /* @__PURE__ */ t(
|
|
151
|
+
O,
|
|
149
152
|
{
|
|
150
153
|
asChild: !0,
|
|
151
154
|
className: r(`${e}__description`),
|
|
152
155
|
"data-testid": _("description"),
|
|
153
|
-
children: /* @__PURE__ */ t(
|
|
156
|
+
children: /* @__PURE__ */ t(st, { variant: "paragraph-100", children: c })
|
|
154
157
|
}
|
|
155
158
|
),
|
|
156
159
|
/* @__PURE__ */ t("div", { children: a }),
|
|
157
|
-
!w && /* @__PURE__ */ t(
|
|
160
|
+
!w && /* @__PURE__ */ t(H, { actions: o, notification: v })
|
|
158
161
|
] }) })
|
|
159
162
|
] })
|
|
160
163
|
] }),
|
|
161
|
-
w && /* @__PURE__ */ t(
|
|
164
|
+
w && /* @__PURE__ */ t(H, { actions: o, notification: v })
|
|
162
165
|
]
|
|
163
166
|
}
|
|
164
167
|
)
|
|
165
168
|
] });
|
|
166
169
|
}
|
|
167
|
-
),
|
|
170
|
+
), x = ({
|
|
168
171
|
["aria-label"]: n,
|
|
169
172
|
hasImage: o,
|
|
170
173
|
scrollbarWidth: a,
|
|
171
|
-
["data-testid"]:
|
|
172
|
-
}) => /* @__PURE__ */ t(
|
|
173
|
-
|
|
174
|
+
["data-testid"]: i
|
|
175
|
+
}) => /* @__PURE__ */ t(Z, { asChild: !0, children: /* @__PURE__ */ t(
|
|
176
|
+
nt,
|
|
174
177
|
{
|
|
175
178
|
variant: o ? "primary" : "tertiary-purple",
|
|
176
179
|
negative: o,
|
|
@@ -179,33 +182,33 @@ const lt = "_fadeIn_1nrj3_1", st = "_fadeOut_1nrj3_1", _t = "_slideUp_1nrj3_1",
|
|
|
179
182
|
"aria-label": n,
|
|
180
183
|
className: r(`${e}__close-button`),
|
|
181
184
|
style: { right: `calc(var(--purpur-spacing-100) + ${a || 0}px)` },
|
|
182
|
-
"data-testid":
|
|
183
|
-
children: /* @__PURE__ */ t(
|
|
185
|
+
"data-testid": i,
|
|
186
|
+
children: /* @__PURE__ */ t(at, {})
|
|
184
187
|
}
|
|
185
|
-
) }),
|
|
188
|
+
) }), H = ({
|
|
186
189
|
actions: n,
|
|
187
190
|
notification: o
|
|
188
191
|
}) => {
|
|
189
192
|
const a = b(null);
|
|
190
193
|
return g(() => {
|
|
191
194
|
o && a?.current?.scrollIntoView?.(!1);
|
|
192
|
-
}, [o]), n ? /* @__PURE__ */
|
|
195
|
+
}, [o]), n ? /* @__PURE__ */ l("div", { className: r(`${e}__actions`), children: [
|
|
193
196
|
/* @__PURE__ */ t("div", { className: r(`${e}__actions-buttons`), "data-testid": "modal actions", children: n }),
|
|
194
197
|
o && /* @__PURE__ */ t("div", { className: r(`${e}__notification`), ref: a, children: o }),
|
|
195
198
|
/* @__PURE__ */ t("span", { className: r(`${e}__actions-separator`) })
|
|
196
199
|
] }) : null;
|
|
197
|
-
},
|
|
198
|
-
({ children: n, ...o }, a) => /* @__PURE__ */ t(
|
|
200
|
+
}, ft = I(
|
|
201
|
+
({ children: n, ...o }, a) => /* @__PURE__ */ t(tt, { asChild: !0, ref: a, ...o, children: n })
|
|
199
202
|
), j = ({
|
|
200
203
|
["data-testid"]: n,
|
|
201
204
|
children: o,
|
|
202
205
|
open: a,
|
|
203
|
-
onOpenChange:
|
|
204
|
-
}) => /* @__PURE__ */ t(
|
|
205
|
-
j.Trigger =
|
|
206
|
-
j.Content =
|
|
206
|
+
onOpenChange: i
|
|
207
|
+
}) => /* @__PURE__ */ t(et, { open: a, onOpenChange: i, "data-testid": n, children: o });
|
|
208
|
+
j.Trigger = ft;
|
|
209
|
+
j.Content = ht;
|
|
207
210
|
j.displayName = "Modal";
|
|
208
211
|
export {
|
|
209
212
|
j as M
|
|
210
213
|
};
|
|
211
|
-
//# sourceMappingURL=modal-
|
|
214
|
+
//# sourceMappingURL=modal-EIP36327.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal-EIP36327.mjs","sources":["../../../components/modal/src/modal-content.tsx","../../../components/modal/src/modal-trigger.tsx","../../../components/modal/src/modal.tsx"],"sourcesContent":["import React, { forwardRef, type ReactNode, useCallback, useEffect, useRef, useState } from \"react\";\nimport { Button } from \"@purpur/button\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Heading } from \"@purpur/heading\";\nimport { IconClose } from \"@purpur/icon/close\";\nimport { Paragraph } from \"@purpur/paragraph\";\nimport { useThemePortalContainer } from \"@purpur/theme\";\nimport { VisuallyHidden } from \"@purpur/visually-hidden\";\nimport {\n Close as RadixClose,\n Content as RadixContent,\n Description as RadixDescription,\n Overlay as RadixOverlay,\n Portal as RadixPortal,\n Title as RadixTitle,\n} from \"@radix-ui/react-dialog\";\nimport c from \"classnames/bind\";\n\nimport \"@purpur/notification/styles\";\nimport styles from \"./modal-content.module.scss\";\n\nexport type DefaultProps = Omit<BaseProps, \"children\"> & {\n /**\n * One or several CTA links or buttons\n * */\n actions?: ReactNode;\n children: ReactNode;\n /**\n * An optional accessible description to be announced when the dialog is opened.\n * */\n description?: string;\n /**\n * Prevents the modal from closing on click outside if set to `true`.\n * */\n disableCloseOnClickOutside?: boolean;\n /**\n * Visually hides the description if set to `true`.\n * */\n hideDescription?: boolean;\n /**\n * An optional image to be displayed at the top of the modal.\n * */\n image?: ReactNode;\n /**\n * Provide a Purpur Notification which will render beneath the modal buttons, otherwise leave it undefined.\n * */\n notification?: ReactNode;\n /**\n * Determines whether the button group should be fixed at the bottom or scroll with the content.\n * */\n stickyButtons?: boolean;\n /**\n * An accessible title to be announced when the dialog is opened.\n * */\n title: string;\n /**\n * z-index of the modal\n * */\n zIndex?: number;\n /**\n * Optional DOM element to portal the modal content into. When omitted,\n * the modal renders inside the nearest `ThemeProvider` so it inherits\n * the active color scheme. Pass `document.body` (or any other element) to\n * override. Pass `null` to fall back to Radix' default (`document.body`).\n * */\n container?: HTMLElement | null;\n /**\n * Event handler called when focus moves to the trigger after closing.\n * */\n onCloseAutoFocus?: (e: Event) => void;\n};\n\ntype NoCloseButtonProps = {\n /**\n * An accessible label for the close button.\n * */\n closeButtonAriaLabel?: never;\n /**\n * Shows the close button if set to `true`. Must be used in conjunction with `closeButtonAriaLabel`.\n * */\n showCloseButton?: false;\n};\n\ntype CloseButtonProps = {\n /**\n * An accessible label for the close button.\n * */\n closeButtonAriaLabel: string;\n /**\n * Shows the close button if set to `true`. Must be used in conjunction with `closeButtonAriaLabel`.\n * */\n showCloseButton: true;\n};\n\nexport type ModalContentProps = DefaultProps & (CloseButtonProps | NoCloseButtonProps);\n\nconst hasCloseButtonProps = (\n props: CloseButtonProps | NoCloseButtonProps\n): props is CloseButtonProps => (props as CloseButtonProps).showCloseButton === true;\n\nconst cx = c.bind(styles);\nconst rootClassName = \"purpur-modal-content\";\n\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n (\n {\n [\"data-testid\"]: dataTestId,\n actions,\n children,\n className,\n description,\n disableCloseOnClickOutside,\n hideDescription,\n image,\n stickyButtons = true,\n title,\n notification = undefined,\n zIndex,\n container,\n onCloseAutoFocus,\n ...props\n },\n ref\n ) => {\n const { closeButtonAriaLabel, showCloseButton, ...rest } = props;\n const [contentOverflow, setContentOverflow] = useState(false);\n const [scrollbarWidth, setScrollbarWidth] = useState(0);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const wrapperInnerRef = useRef<HTMLDivElement>(null);\n const themePortalContainer = useThemePortalContainer();\n const portalContainer =\n container === undefined ? themePortalContainer : container ?? undefined;\n\n const classes = cx(\n rootClassName,\n { [`${rootClassName}--with-image`]: !!image },\n { [`${rootClassName}--overflow`]: contentOverflow },\n { [`${rootClassName}--sticky-footer`]: stickyButtons },\n className\n );\n\n const getTestId = (id: string) => (dataTestId ? `${dataTestId} ${id}` : undefined);\n\n const handlePointerDownOutside = (event: CustomEvent<{ originalEvent: PointerEvent }>) => {\n if (disableCloseOnClickOutside) {\n event.preventDefault();\n }\n };\n\n const handleContentOverflow = useCallback(() => {\n if (!wrapperRef.current || !wrapperInnerRef.current) {\n return;\n }\n\n const computedStyle = window.getComputedStyle(wrapperRef.current, null);\n const wrapperHeight = parseFloat(computedStyle.getPropertyValue(\"height\"));\n const innerHeight = wrapperInnerRef.current.offsetHeight;\n\n setContentOverflow(wrapperHeight < innerHeight);\n\n setScrollbarWidth(\n (wrapperRef.current.offsetWidth ?? 0) - (wrapperRef.current.clientWidth ?? 0)\n );\n }, []);\n\n const handleInitialFocus = () => {\n const frame = wrapperInnerRef.current;\n if (frame) {\n const heading = frame.querySelector(\"h2\");\n\n heading &&\n setTimeout(() => {\n heading.focus();\n });\n }\n };\n\n const handleEscapeKeyDown = (event: KeyboardEvent) => {\n if (disableCloseOnClickOutside && !showCloseButton) {\n event.preventDefault();\n }\n };\n\n useEffect(() => {\n window.addEventListener(\"resize\", handleContentOverflow);\n\n return () => {\n window.removeEventListener(\"resize\", handleContentOverflow);\n };\n }, [handleContentOverflow]);\n\n useEffect(() => {\n handleContentOverflow();\n }, [notification, children, handleContentOverflow]);\n\n return (\n <RadixPortal container={portalContainer}>\n <RadixOverlay className={cx(`${rootClassName}__overlay`)} style={{ zIndex }} />\n <RadixContent\n {...rest}\n className={classes}\n data-testid={dataTestId}\n ref={ref}\n {...(!description && { [\"aria-describedby\"]: undefined })}\n onPointerDownOutside={handlePointerDownOutside}\n onOpenAutoFocus={() => {\n handleContentOverflow();\n handleInitialFocus();\n }}\n onEscapeKeyDown={handleEscapeKeyDown}\n onCloseAutoFocus={onCloseAutoFocus}\n style={{ zIndex: `calc(${zIndex} + 1)` }}\n >\n <div ref={wrapperRef} className={cx(`${rootClassName}__wrapper`)}>\n {hasCloseButtonProps(props) && closeButtonAriaLabel && image && (\n <CloseButton\n aria-label={closeButtonAriaLabel}\n hasImage\n scrollbarWidth={scrollbarWidth}\n data-testid={getTestId(\"close-button\")}\n />\n )}\n <div ref={wrapperInnerRef} className={cx(`${rootClassName}__wrapper-inner`)}>\n <div className={cx(`${rootClassName}__header`)}>\n {hasCloseButtonProps(props) && closeButtonAriaLabel && !image && (\n <CloseButton\n aria-label={closeButtonAriaLabel}\n data-testid={getTestId(\"close-button\")}\n />\n )}\n <RadixTitle\n asChild\n className={cx(`${rootClassName}__title`)}\n data-testid={getTestId(\"title\")}\n >\n <Heading\n tag=\"h2\"\n variant=\"display-10\"\n tabIndex={-1}\n className={cx(`${rootClassName}__heading`)}\n >\n {title}\n </Heading>\n </RadixTitle>\n </div>\n {image && (\n <div\n className={cx(`${rootClassName}__image-wrapper`)}\n data-testid={getTestId(\"image\")}\n >\n {image}\n </div>\n )}\n <div className={cx(`${rootClassName}__body`)}>\n <div className={cx(`${rootClassName}__body-inner`)}>\n {description && hideDescription && (\n <VisuallyHidden asChild>\n <RadixDescription data-testid={getTestId(\"description\")}>\n {description}\n </RadixDescription>\n </VisuallyHidden>\n )}\n {description && !hideDescription && (\n <RadixDescription\n asChild\n className={cx(`${rootClassName}__description`)}\n data-testid={getTestId(\"description\")}\n >\n <Paragraph variant=\"paragraph-100\">{description}</Paragraph>\n </RadixDescription>\n )}\n <div>{children}</div>\n {!stickyButtons && <ModalActions actions={actions} notification={notification} />}\n </div>\n </div>\n </div>\n </div>\n\n {stickyButtons && <ModalActions actions={actions} notification={notification} />}\n </RadixContent>\n </RadixPortal>\n );\n }\n);\n\nconst CloseButton = ({\n [\"aria-label\"]: ariaLabel,\n hasImage,\n scrollbarWidth,\n [\"data-testid\"]: dataTestId,\n}: {\n [\"aria-label\"]: string;\n hasImage?: boolean;\n scrollbarWidth?: number;\n [\"data-testid\"]?: string;\n}) => (\n <RadixClose asChild>\n <Button\n variant={hasImage ? \"primary\" : \"tertiary-purple\"}\n negative={hasImage}\n size=\"sm\"\n iconOnly\n aria-label={ariaLabel}\n className={cx(`${rootClassName}__close-button`)}\n style={{ right: `calc(var(--purpur-spacing-100) + ${scrollbarWidth || 0}px)` }}\n data-testid={dataTestId}\n >\n <IconClose />\n </Button>\n </RadixClose>\n);\n\nexport const MAX_NUMBER_OF_ACTIONS = 3;\n\nexport const ModalActions = ({\n actions,\n notification,\n}: Pick<ModalContentProps, \"actions\" | \"notification\">) => {\n const notificationRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (notification) {\n notificationRef?.current?.scrollIntoView?.(false);\n }\n }, [notification]);\n\n return actions ? (\n <div className={cx(`${rootClassName}__actions`)}>\n <div className={cx(`${rootClassName}__actions-buttons`)} data-testid=\"modal actions\">\n {actions}\n </div>\n {notification && (\n <div className={cx(`${rootClassName}__notification`)} ref={notificationRef}>\n {notification}\n </div>\n )}\n <span className={cx(`${rootClassName}__actions-separator`)} />\n </div>\n ) : null;\n};\n","import React, { forwardRef, type ReactNode } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport { Trigger as RadixTrigger } from \"@radix-ui/react-dialog\";\n\nexport type ModalTriggerProps = Omit<BaseProps<\"button\">, \"children\"> & {\n children: ReactNode;\n};\n\nexport const ModalTrigger = forwardRef<HTMLButtonElement, ModalTriggerProps>(\n ({ children, ...props }, ref) => {\n return (\n <RadixTrigger asChild ref={ref} {...props}>\n {children}\n </RadixTrigger>\n );\n }\n);\n","import React, { type ReactNode } from \"react\";\nimport { Root as RadixRoot } from \"@radix-ui/react-dialog\";\n\nimport { ModalContent } from \"./modal-content\";\nimport { ModalTrigger } from \"./modal-trigger\";\n\nexport type ModalProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n /**\n * Event handler called when the open state of the dialog changes.\n * */\n onOpenChange?: (value: boolean) => void;\n /**\n * The controlled open state of the dialog. Must be used in conjunction with `onOpenChange`.\n * */\n open?: boolean;\n};\n\nexport const Modal = ({\n [\"data-testid\"]: dataTestId,\n children,\n open,\n onOpenChange,\n}: ModalProps) => (\n <RadixRoot open={open} onOpenChange={onOpenChange} data-testid={dataTestId}>\n {children}\n </RadixRoot>\n);\n\nModal.Trigger = ModalTrigger;\nModal.Content = ModalContent;\n\nModal.displayName = \"Modal\";\n"],"names":["hasCloseButtonProps","props","cx","c","styles","rootClassName","ModalContent","forwardRef","dataTestId","actions","children","className","description","disableCloseOnClickOutside","hideDescription","image","stickyButtons","title","notification","zIndex","container","onCloseAutoFocus","ref","closeButtonAriaLabel","showCloseButton","rest","contentOverflow","setContentOverflow","useState","scrollbarWidth","setScrollbarWidth","wrapperRef","useRef","wrapperInnerRef","themePortalContainer","useThemePortalContainer","portalContainer","classes","getTestId","id","handlePointerDownOutside","event","handleContentOverflow","useCallback","computedStyle","wrapperHeight","innerHeight","handleInitialFocus","frame","heading","handleEscapeKeyDown","useEffect","jsxs","RadixPortal","jsx","RadixOverlay","RadixContent","CloseButton","RadixTitle","Heading","VisuallyHidden","RadixDescription","Paragraph","ModalActions","ariaLabel","hasImage","RadixClose","Button","IconClose","notificationRef","ModalTrigger","RadixTrigger","Modal","open","onOpenChange","RadixRoot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGMA,IAAsB,CAC1BC,MAC+BA,E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D,UAAAE,EAAA,CACH;AAGF8D,EAAM,UAAUF;AAChBE,EAAM,UAAUlE;AAEhBkE,EAAM,cAAc;"}
|
package/dist/modal.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./modal-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./modal-DJn9idcw.js");exports.Modal=e.Modal;
|
|
2
2
|
//# sourceMappingURL=modal.cjs.js.map
|
package/dist/modal.es.js
CHANGED