@primer/react 0.0.0-20260303165317 → 0.0.0-20260303165543
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.md +4 -2
- package/dist/Dialog/Dialog-2d417a89.css +2 -0
- package/dist/Dialog/Dialog-2d417a89.css.map +1 -0
- package/dist/Dialog/Dialog.d.ts +11 -0
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +10 -1
- package/dist/Dialog/Dialog.module.css.js +1 -1
- package/dist/UnderlineNav/UnderlineNav-4344d9b0.css +2 -0
- package/dist/UnderlineNav/UnderlineNav-4344d9b0.css.map +1 -0
- package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNav.js +325 -77
- package/dist/UnderlineNav/UnderlineNav.module.css.js +2 -2
- package/dist/UnderlineNav/UnderlineNavContext.d.ts +11 -1
- package/dist/UnderlineNav/UnderlineNavContext.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNavContext.js +4 -1
- package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css +2 -0
- package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css.map +1 -0
- package/dist/UnderlineNav/UnderlineNavItem.d.ts +0 -6
- package/dist/UnderlineNav/UnderlineNavItem.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNavItem.js +36 -28
- package/dist/UnderlineNav/UnderlineNavItem.module.css.js +1 -1
- package/dist/UnderlineNav/styles.d.ts +16 -0
- package/dist/UnderlineNav/styles.d.ts.map +1 -0
- package/dist/UnderlineNav/styles.js +19 -0
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +1 -1
- package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css +2 -0
- package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css.map +1 -0
- package/dist/internal/components/UnderlineTabbedInterface.d.ts +1 -0
- package/dist/internal/components/UnderlineTabbedInterface.d.ts.map +1 -1
- package/dist/internal/components/UnderlineTabbedInterface.js +60 -66
- package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
- package/generated/components.json +22 -1
- package/package.json +1 -1
- package/dist/Dialog/Dialog-b8e961f6.css +0 -2
- package/dist/Dialog/Dialog-b8e961f6.css.map +0 -1
- package/dist/UnderlineNav/UnderlineNav-f506fb23.css +0 -2
- package/dist/UnderlineNav/UnderlineNav-f506fb23.css.map +0 -1
- package/dist/UnderlineNav/UnderlineNavItem-db9dc5d0.css +0 -2
- package/dist/UnderlineNav/UnderlineNavItem-db9dc5d0.css.map +0 -1
- package/dist/internal/components/UnderlineTabbedInterface-be1a162c.css +0 -2
- package/dist/internal/components/UnderlineTabbedInterface-be1a162c.css.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260303165543
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
7
|
- [#7524](https://github.com/primer/react/pull/7524) [`f7bdd1c`](https://github.com/primer/react/commit/f7bdd1c04f8cbb17b6a913ba55f7d0855c8eebf1) Thanks [@francinelucca](https://github.com/francinelucca)! - chore: always render ActionMenu in viewport when inside Dialog under feature flag
|
|
8
8
|
|
|
9
|
+
- [#7594](https://github.com/primer/react/pull/7594) [`0dc2c78`](https://github.com/primer/react/commit/0dc2c78cc035bfd83a458f98262e4bd2903ef041) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Add `align` and `style` props to Dialog component
|
|
10
|
+
|
|
9
11
|
### Patch Changes
|
|
10
12
|
|
|
11
13
|
- Fake entry to force publishing
|
|
12
14
|
|
|
13
|
-
- [#7585](https://github.com/primer/react/pull/7585) [`
|
|
15
|
+
- [#7585](https://github.com/primer/react/pull/7585) [`3dd2c78`](https://github.com/primer/react/commit/3dd2c78f768ad560ee0f37947af2c17ca8d7938c) Thanks [@iansan5653](https://github.com/iansan5653)! - - Fixes a bug where `ActionBar` menu items would be out of order if new items were mounted after the initial render
|
|
14
16
|
|
|
15
17
|
- Improves initial render performance for `ActionBar`
|
|
16
18
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
@property --prc-dialog-scrollgutter{initial-value:0;inherits:false;syntax:"<length>"}@keyframes prc-Dialog-dialog-backdrop-appear-tCG2K{0%{opacity:0}to{opacity:1}}@keyframes prc-Dialog-Overlay--motion-scaleFade-mE6-C{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}@keyframes prc-Dialog-Overlay--motion-slideUp-tPElO{0%{transform:translateY(100%)}}@keyframes prc-Dialog-Overlay--motion-slideInRight-BR-CZ{0%{transform:translateX(-100%)}}@keyframes prc-Dialog-Overlay--motion-slideInLeft-ISmQZ{0%{transform:translateX(100%)}}@keyframes prc-Dialog-detect-scroll-b3i8Q{0%,to{--can-scroll:1}}.prc-Dialog-Backdrop-5Nt2U{animation:prc-Dialog-dialog-backdrop-appear-tCG2K .2s cubic-bezier(.33,1,.68,1);background-color:var(--overlay-backdrop-bgColor,var(--color-overlay-backdrop));bottom:0;display:flex;left:0;position:fixed;right:0;top:0}.prc-Dialog-Backdrop-5Nt2U,.prc-Dialog-Backdrop-5Nt2U[data-position-regular=center]{align-items:center;justify-content:center}.prc-Dialog-Backdrop-5Nt2U[data-position-regular=left]{align-items:center;justify-content:flex-start}.prc-Dialog-Backdrop-5Nt2U[data-position-regular=right]{align-items:center;justify-content:flex-end}.prc-Dialog-Backdrop-5Nt2U[data-align=top]:where(:not([data-position-regular=left]):not([data-position-regular=right])){align-items:flex-start}.prc-Dialog-Backdrop-5Nt2U[data-align=center]:where(:not([data-position-regular=left]):not([data-position-regular=right])){align-items:center}.prc-Dialog-Backdrop-5Nt2U[data-align=bottom]:where(:not([data-position-regular=left]):not([data-position-regular=right])){align-items:flex-end}@media (max-width:767px){.prc-Dialog-Backdrop-5Nt2U[data-position-narrow=center]{align-items:center;justify-content:center}.prc-Dialog-Backdrop-5Nt2U[data-position-narrow=center][data-align=top]{align-items:flex-start}.prc-Dialog-Backdrop-5Nt2U[data-position-narrow=center][data-align=center]{align-items:center}.prc-Dialog-Backdrop-5Nt2U[data-position-narrow=center][data-align=bottom]{align-items:flex-end}.prc-Dialog-Backdrop-5Nt2U[data-position-narrow=bottom]{align-items:end;justify-content:center}}.prc-Dialog-Dialog-G8cDF{background-color:var(--overlay-bgColor,var(--color-canvas-overlay));border-radius:var(--borderRadius-large,.75rem);border-radius:var(--borderRadius-large,var(--borderRadius-large,.75rem));box-shadow:var(--shadow-floating-small,var(--color-overlay-shadow));display:flex;flex-direction:column;height:auto;max-height:calc(100dvh - 64px);max-width:calc(100dvw - 64px);min-width:296px;opacity:1;width:640px}.prc-Dialog-Dialog-G8cDF:where([data-width=small]){width:296px}.prc-Dialog-Dialog-G8cDF:where([data-width=medium]){width:320px}.prc-Dialog-Dialog-G8cDF:where([data-width=large]){width:480px}.prc-Dialog-Dialog-G8cDF:where([data-height=small]){height:480px}.prc-Dialog-Dialog-G8cDF:where([data-height=large]){height:640px}@media screen and (prefers-reduced-motion:no-preference){.prc-Dialog-Dialog-G8cDF{animation:prc-Dialog-Overlay--motion-scaleFade-mE6-C .2s cubic-bezier(.33,1,.68,1) 1ms 1 normal none running}}.prc-Dialog-Dialog-G8cDF[data-position-regular=center]{border-radius:var(--borderRadius-large,var(--borderRadius-large,.75rem))}@media screen and (prefers-reduced-motion:no-preference){.prc-Dialog-Dialog-G8cDF[data-position-regular=center]{animation:prc-Dialog-Overlay--motion-scaleFade-mE6-C .2s cubic-bezier(.33,1,.68,1) 1ms 1 normal none running}}.prc-Dialog-Dialog-G8cDF[data-position-regular=center][data-align=top]{margin-top:var(--base-size-64,4rem)}.prc-Dialog-Dialog-G8cDF[data-position-regular=center][data-align=bottom]{margin-bottom:var(--base-size-64,4rem)}.prc-Dialog-Dialog-G8cDF[data-position-regular=left]{border-radius:var(--borderRadius-large,var(--borderRadius-large,.75rem));border-bottom-left-radius:0;border-top-left-radius:0;height:100dvh;max-height:unset}@media screen and (prefers-reduced-motion:no-preference){.prc-Dialog-Dialog-G8cDF[data-position-regular=left]{animation:prc-Dialog-Overlay--motion-slideInRight-BR-CZ .25s cubic-bezier(.33,1,.68,1) 1ms 1 normal none running}}.prc-Dialog-Dialog-G8cDF[data-position-regular=right]{border-radius:var(--borderRadius-large,var(--borderRadius-large,.75rem));border-bottom-right-radius:0;border-top-right-radius:0;height:100dvh;max-height:unset}@media screen and (prefers-reduced-motion:no-preference){.prc-Dialog-Dialog-G8cDF[data-position-regular=right]{animation:prc-Dialog-Overlay--motion-slideInLeft-ISmQZ .25s cubic-bezier(.33,1,.68,1) 0s 1 normal none running}}@media (max-width:767px){.prc-Dialog-Dialog-G8cDF[data-position-narrow=center]{border-radius:var(--borderRadius-large,var(--borderRadius-large,.75rem));height:auto;width:640px}.prc-Dialog-Dialog-G8cDF[data-position-narrow=center]:where([data-width=small]){width:296px}.prc-Dialog-Dialog-G8cDF[data-position-narrow=center]:where([data-width=medium]){width:320px}.prc-Dialog-Dialog-G8cDF[data-position-narrow=center]:where([data-width=large]){width:480px}.prc-Dialog-Dialog-G8cDF[data-position-narrow=center]:where([data-height=small]){height:480px}.prc-Dialog-Dialog-G8cDF[data-position-narrow=center]:where([data-height=large]){height:640px}@media (max-height:280px){.prc-Dialog-Dialog-G8cDF{max-height:calc(100dvh - 12px);max-width:calc(100dvw - 12px)}}.prc-Dialog-Dialog-G8cDF[data-position-narrow=bottom]{border-radius:var(--borderRadius-large,var(--borderRadius-large,.75rem));border-bottom-left-radius:0;border-bottom-right-radius:0;height:auto;max-height:calc(100dvh - 64px);max-width:100dvw;width:100dvw}.prc-Dialog-Dialog-G8cDF[data-position-narrow=bottom][data-align]{margin-bottom:0;margin-top:0}@media screen and (prefers-reduced-motion:no-preference){.prc-Dialog-Dialog-G8cDF[data-position-narrow=bottom]{animation:prc-Dialog-Overlay--motion-slideUp-tPElO .25s cubic-bezier(.33,1,.68,1) 1ms 1 normal none running}}.prc-Dialog-Dialog-G8cDF[data-position-narrow=fullscreen]{border-radius:unset!important;flex-grow:1;height:100%;max-height:100dvh;max-width:100dvw;width:100%}.prc-Dialog-Dialog-G8cDF[data-position-narrow=fullscreen][data-align]{margin-bottom:0;margin-top:0}@media screen and (prefers-reduced-motion:no-preference){.prc-Dialog-Dialog-G8cDF[data-position-narrow=fullscreen]{animation:prc-Dialog-Overlay--motion-scaleFade-mE6-C .2s cubic-bezier(.33,1,.68,1) 1ms 1 normal none running}}}body:not([data-dialog-scroll-optimized]):has(.prc-Dialog-Dialog-G8cDF.prc-Dialog-DisableScroll-UkWFM){overflow:hidden!important;padding-right:var(--prc-dialog-scrollgutter)!important}body[data-dialog-scroll-disabled]{overflow:hidden!important;padding-right:var(--prc-dialog-scrollgutter)!important}.prc-Dialog-DialogOverflowWrapper-JvHzz{flex-grow:1}.prc-Dialog-Dialog-G8cDF:has(.prc-Dialog-Footer-PMeQk){--can-scroll:0}.prc-Dialog-Dialog-G8cDF:has(.prc-Dialog-Footer-PMeQk) .prc-Dialog-DialogOverflowWrapper-JvHzz{animation:prc-Dialog-detect-scroll-b3i8Q;border-bottom:var(--borderWidth-default,.0625rem) solid var(--borderColor-default,var(--color-border-default));animation-timeline:scroll(self)}@supports (animation-timeline:scroll(self)){.prc-Dialog-Dialog-G8cDF:has(.prc-Dialog-Footer-PMeQk) .prc-Dialog-DialogOverflowWrapper-JvHzz{border-bottom:calc(var(--borderWidth-thin,.0625rem)*var(--can-scroll)) solid var(--borderColor-default,var(--color-border-default))}}.prc-Dialog-Header-f7Me-{box-shadow:0 1px 0 var(--borderColor-default,var(--color-border-default));flex-shrink:0;max-height:35vh;overflow-y:auto;padding:var(--base-size-8,.5rem);z-index:1}.prc-Dialog-HeaderInner-H-fFY{display:flex}.prc-Dialog-HeaderContent-mjAsn{display:flex;flex-direction:column;flex-grow:1;padding-block:var(--base-size-6,.375rem);padding-inline:var(--base-size-8,.5rem)}.prc-Dialog-Title-M-iPn{font-size:var(--text-body-size-medium,.875rem);font-weight:var(--text-title-weight-large,600);margin:0}.prc-Dialog-Subtitle-aBFSq{color:var(--fgColor-muted,var(--color-fg-muted));font-size:var(--text-body-size-small,.75rem);font-weight:var(--base-text-weight-normal,400);margin:0;margin-top:var(--base-size-4,.25rem)}.prc-Dialog-Body-bB903{flex-grow:1;overflow:auto}.prc-Dialog-Body-bB903,.prc-Dialog-Footer-PMeQk{padding:var(--base-size-16,1rem)}.prc-Dialog-Footer-PMeQk{display:flex;flex-flow:wrap;flex-shrink:0;gap:var(--base-size-8,.5rem);justify-content:flex-end;z-index:1}@media (max-height:325px){.prc-Dialog-Footer-PMeQk{flex-direction:row;flex-wrap:nowrap;justify-content:unset;overflow-x:scroll}}
|
|
2
|
+
/*# sourceMappingURL=Dialog-2d417a89.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Dialog/Dialog.module.css.js"],"names":[],"mappings":"AAOA,oCACE,eAAgB,CAChB,cAAe,CACf,iBACF,CAEA,mDACE,GACE,SACF,CAEA,GACE,SACF,CACF,CAEA,sDACE,GACE,SAAU,CACV,mBACF,CAEA,GACE,SAAU,CACV,kBACF,CACF,CAEA,oDACE,GACE,0BACF,CACF,CAEA,yDACE,GACE,2BACF,CACF,CAEA,wDACE,GACE,0BACF,CACF,CAGA,0CACE,MAEE,cACF,CACF,CAEA,2BAQE,+EAAsE,CADtE,8EAAiD,CAHjD,QAAS,CAET,YAAa,CADb,MAAO,CAJP,cAAe,CAEf,OAAQ,CADR,KAkEF,CAxDE,oFAHA,kBAAmB,CACnB,sBAKA,CAEA,uDACE,kBAAmB,CACnB,0BACF,CAEA,wDACE,kBAAmB,CACnB,wBACF,CAME,wHACE,sBACF,CAEA,2HACE,kBACF,CAEA,2HACE,oBACF,CAGF,yBACE,wDACE,kBAAmB,CACnB,sBAcF,CAXE,wEACE,sBACF,CAEA,2EACE,kBACF,CAEA,2EAC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CAGE,yBAA2B,CAD3B,sDAEF,CAEA,wCACE,WACF,CAQA,uDACE,cAYF,CAVE,+FAGE,wCAAwB,CADxB,8GAA0E,CAE1E,+BAKF,CAHE,4CANF,+FAOI,mIAEJ,CADE,CAIJ,yBAME,yEAA8C,CAC9C,aAAc,CALd,eAAgB,CAEhB,eAAgB,CADhB,gCAA2B,CAF3B,SAOF,CAEA,8BACE,YACF,CAEA,gCACE,YAAa,CAGb,qBAAsB,CACtB,WAAY,CAFZ,wCAAiC,CADjC,uCAIF,CAEA,wBAEE,8CAAuC,CACvC,8CAA2C,CAF3C,QAGF,CAEA,2BAKE,gDAA2B,CAF3B,4CAAsC,CACtC,8CAA2C,CAH3C,QAAS,CACT,oCAIF,CAEA,uBAGE,WAAY,CADZ,aAEF,CAEA,gDALE,gCAoBF,CAfA,yBAEE,YAAa,CACb,cAAe,CAIf,aAAc,CADd,4BAAuB,CAFvB,wBAAyB,CAHzB,SAcF,CANE,0BATF,yBAYI,kBAAmB,CAFnB,gBAAiB,CAGjB,qBAAsB,CAFtB,iBAIJ,CADE","file":"Dialog-2d417a89.css","sourcesContent":["/* The --prc-dialog-scrollgutter property is used only on the body element to\n * simulate scrollbar-gutter:stable. This property is not and should not\n * be used elsewhere in the DOM. There is a performance penalty to\n * setting inherited properties which can cause a large style recalc to\n * occur, so it benefits us to prevent inheritance for this property.\n * See https://web.dev/blog/at-property-performance\n */\n@property --prc-dialog-scrollgutter {\n initial-value: 0;\n inherits: false;\n syntax: '<length>';\n}\n\n@keyframes dialog-backdrop-appear {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n@keyframes Overlay--motion-scaleFade {\n 0% {\n opacity: 0;\n transform: scale(0.5);\n }\n\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes Overlay--motion-slideUp {\n from {\n transform: translateY(100%);\n }\n}\n\n@keyframes Overlay--motion-slideInRight {\n from {\n transform: translateX(-100%);\n }\n}\n\n@keyframes Overlay--motion-slideInLeft {\n from {\n transform: translateX(100%);\n }\n}\n\n/* Used to determine whether there should be a border between the body and footer */\n@keyframes detect-scroll {\n from,\n to {\n --can-scroll: 1;\n }\n}\n\n.Backdrop {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: flex;\n background-color: var(--overlay-backdrop-bgColor);\n animation: dialog-backdrop-appear 200ms cubic-bezier(0.33, 1, 0.68, 1);\n align-items: center;\n justify-content: center;\n\n &[data-position-regular='center'] {\n align-items: center;\n justify-content: center;\n }\n\n &[data-position-regular='left'] {\n align-items: center;\n justify-content: flex-start;\n }\n\n &[data-position-regular='right'] {\n align-items: center;\n justify-content: flex-end;\n }\n\n /* align only applies when regular position is center (or absent).\n * :where() zeroes out the :not() specificity so narrow-position rules (coming later)\n * always win when data-position-narrow is bottom or fullscreen. */\n &:where(:not([data-position-regular='left']):not([data-position-regular='right'])) {\n &[data-align='top'] {\n align-items: flex-start;\n }\n\n &[data-align='center'] {\n align-items: center;\n }\n\n &[data-align='bottom'] {\n align-items: flex-end;\n }\n }\n\n @media (max-width: 767px) {\n &[data-position-narrow='center'] {\n align-items: center;\n justify-content: center;\n\n /* align still applies when narrow position is center */\n &[data-align='top'] {\n align-items: flex-start;\n }\n\n &[data-align='center'] {\n align-items: center;\n }\n\n &[data-align='bottom'] {\n align-items: flex-end;\n }\n }\n\n &[data-position-narrow='bottom'] {\n align-items: end;\n justify-content: center;\n }\n }\n}\n\n.Dialog {\n display: flex;\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 640px;\n min-width: 296px;\n max-width: calc(100dvw - 64px);\n height: auto;\n max-height: calc(100dvh - 64px);\n flex-direction: column;\n background-color: var(--overlay-bgColor);\n border-radius: var(--borderRadius-large);\n border-radius: var(--borderRadius-large, var(--borderRadius-large));\n box-shadow: var(--shadow-floating-small);\n opacity: 1;\n\n &:where([data-width='small']) {\n width: 296px;\n }\n\n &:where([data-width='medium']) {\n width: 320px;\n }\n\n &:where([data-width='large']) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 480px;\n }\n\n &:where([data-height='small']) {\n height: 480px;\n }\n\n &:where([data-height='large']) {\n height: 640px;\n }\n\n @media screen and (prefers-reduced-motion: no-preference) {\n animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;\n }\n\n &[data-position-regular='center'] {\n border-radius: var(--borderRadius-large, var(--borderRadius-large));\n\n @media screen and (prefers-reduced-motion: no-preference) {\n animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;\n }\n\n /* align margins only apply when regular position is center */\n &[data-align='top'] {\n margin-top: var(--base-size-64);\n }\n\n &[data-align='bottom'] {\n margin-bottom: var(--base-size-64);\n }\n }\n\n &[data-position-regular='left'] {\n height: 100dvh;\n max-height: unset;\n border-radius: var(--borderRadius-large, var(--borderRadius-large));\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n animation: Overlay--motion-slideInRight 0.25s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;\n }\n }\n\n &[data-position-regular='right'] {\n height: 100dvh;\n max-height: unset;\n border-radius: var(--borderRadius-large, var(--borderRadius-large));\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n animation: Overlay--motion-slideInLeft 0.25s cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running;\n }\n }\n\n @media (max-width: 767px) {\n &[data-position-narrow='center'] {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 640px;\n height: auto;\n border-radius: var(--borderRadius-large, var(--borderRadius-large));\n\n &:where([data-width='small']) {\n width: 296px;\n }\n\n &:where([data-width='medium']) {\n width: 320px;\n }\n\n &:where([data-width='large']) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 480px;\n }\n\n &:where([data-height='small']) {\n height: 480px;\n }\n\n &:where([data-height='large']) {\n height: 640px;\n }\n }\n\n @media (max-height: 280px) {\n max-height: calc(100dvh - 12px);\n max-width: calc(100dvw - 12px);\n }\n\n &[data-position-narrow='bottom'] {\n width: 100dvw;\n max-width: 100dvw;\n height: auto;\n max-height: calc(100dvh - 64px);\n border-radius: var(--borderRadius-large, var(--borderRadius-large));\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n\n /* reset align margins since position wins at narrow */\n &[data-align] {\n margin-top: 0;\n margin-bottom: 0;\n }\n\n @media screen and (prefers-reduced-motion: no-preference) {\n animation: Overlay--motion-slideUp 0.25s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;\n }\n }\n\n &[data-position-narrow='fullscreen'] {\n width: 100%;\n max-width: 100dvw;\n height: 100%;\n max-height: 100dvh;\n border-radius: unset !important;\n flex-grow: 1;\n\n /* reset align margins since fullscreen wins at narrow */\n &[data-align] {\n margin-top: 0;\n margin-bottom: 0;\n }\n\n @media screen and (prefers-reduced-motion: no-preference) {\n animation: Overlay--motion-scaleFade 0.2s cubic-bezier(0.33, 1, 0.68, 1) 1ms 1 normal none running;\n }\n }\n }\n}\n\n/* DisableScroll class is added to Dialog when scroll should be disabled on body */\n.DisableScroll {\n /* This class is used as a selector target for the legacy :has() CSS selector */\n}\n\n/*\n * LEGACY: Scoped :has() selector with negation guard\n * Only evaluates when data-dialog-scroll-optimized is NOT present on body.\n * When the attribute IS present (flag ON), browser skips :has() evaluation\n * because the :not() check fails first (O(1) attribute lookup).\n */\n/* stylelint-disable-next-line selector-no-qualifying-type */\nbody:not([data-dialog-scroll-optimized]):has(.Dialog.DisableScroll) {\n /* stylelint-disable-next-line primer/spacing */\n padding-right: var(--prc-dialog-scrollgutter) !important;\n overflow: hidden !important;\n}\n\n/*\n * PERFORMANCE OPTIMIZATION: Direct attribute on body - O(1) lookup\n * Active when primer_react_css_has_selector_perf flag is ON\n */\n/* stylelint-disable-next-line selector-no-qualifying-type */\nbody[data-dialog-scroll-disabled] {\n /* stylelint-disable-next-line primer/spacing */\n padding-right: var(--prc-dialog-scrollgutter) !important;\n overflow: hidden !important;\n}\n\n.DialogOverflowWrapper {\n flex-grow: 1;\n}\n\n/*\nAdd a border between the body and footer if:\n- the dialog has a footer\n- the dialog has a body that can scroll\n- the browser supports the `animation-timeline` property and its `scroll()` function\n*/\n.Dialog:has(.Footer) {\n --can-scroll: 0;\n\n .DialogOverflowWrapper {\n /* If the browser does not support the `animation-timeline` property, always show a border */\n border-bottom: var(--borderWidth-default) solid var(--borderColor-default);\n animation: detect-scroll;\n animation-timeline: scroll(self);\n\n @supports (animation-timeline: scroll(self)) {\n border-bottom: calc(var(--borderWidth-thin) * var(--can-scroll)) solid var(--borderColor-default);\n }\n }\n}\n\n.Header {\n z-index: 1;\n max-height: 35vh;\n padding: var(--base-size-8);\n overflow-y: auto;\n /* stylelint-disable-next-line primer/box-shadow */\n box-shadow: 0 1px 0 var(--borderColor-default);\n flex-shrink: 0;\n}\n\n.HeaderInner {\n display: flex;\n}\n\n.HeaderContent {\n display: flex;\n padding-inline: var(--base-size-8);\n padding-block: var(--base-size-6);\n flex-direction: column;\n flex-grow: 1;\n}\n\n.Title {\n margin: 0; /* override default margin */\n font-size: var(--text-body-size-medium);\n font-weight: var(--text-title-weight-large);\n}\n\n.Subtitle {\n margin: 0; /* override default margin */\n margin-top: var(--base-size-4);\n font-size: var(--text-body-size-small);\n font-weight: var(--base-text-weight-normal);\n color: var(--fgColor-muted);\n}\n\n.Body {\n padding: var(--base-size-16);\n overflow: auto;\n flex-grow: 1;\n}\n\n.Footer {\n z-index: 1;\n display: flex;\n flex-flow: wrap;\n justify-content: flex-end;\n padding: var(--base-size-16);\n gap: var(--base-size-8);\n flex-shrink: 0;\n\n @media (max-height: 325px) {\n flex-wrap: nowrap;\n overflow-x: scroll;\n flex-direction: row;\n justify-content: unset;\n }\n}\n"]}
|
package/dist/Dialog/Dialog.d.ts
CHANGED
|
@@ -100,6 +100,13 @@ export interface DialogProps {
|
|
|
100
100
|
* The position of the dialog
|
|
101
101
|
*/
|
|
102
102
|
position?: 'center' | 'left' | 'right' | ResponsiveValue<'left' | 'right' | 'bottom' | 'fullscreen' | 'center'>;
|
|
103
|
+
/**
|
|
104
|
+
* The vertical alignment of the dialog. Only applies when position is 'center' (the default).
|
|
105
|
+
* top: positions the Dialog ~4rem from the top of the screen, horizontally centered
|
|
106
|
+
* center: (default) vertically centers the Dialog on the screen
|
|
107
|
+
* bottom: positions the Dialog near the bottom of the screen, horizontally centered
|
|
108
|
+
*/
|
|
109
|
+
align?: 'top' | 'center' | 'bottom';
|
|
103
110
|
/**
|
|
104
111
|
* Return focus to this element when the Dialog closes,
|
|
105
112
|
* instead of the element that had focus immediately before the Dialog opened
|
|
@@ -113,6 +120,10 @@ export interface DialogProps {
|
|
|
113
120
|
* Additional class names to apply to the dialog
|
|
114
121
|
*/
|
|
115
122
|
className?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Additional styles to apply to the dialog
|
|
125
|
+
*/
|
|
126
|
+
style?: React.CSSProperties;
|
|
116
127
|
}
|
|
117
128
|
/**
|
|
118
129
|
* Props that are passed to a component that serves as a dialog header
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAA;AAC1F,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,WAAW,CAAA;AAW1C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAQ/F;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAC7D;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAExD;;OAEG;IAC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AM,QAAQ;;;;;CAKJ,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,QAAQ,CAAA;AAC/C,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,SAAS,CAAA;AA+CjD,eAAO,MAAM,aAAa,mCAAqD,CAAA;AAwP/E,eAAO,MAAM,MAAM;;;;;;;;;;iBAhEuC,iBAAiB,EAAE;;;iBAkCf,MAAM,IAAI;;CAuCtE,CAAA"}
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -91,9 +91,11 @@ const _Dialog = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
91
91
|
height = 'auto',
|
|
92
92
|
footerButtons = defaultFooterButtons,
|
|
93
93
|
position = defaultPosition,
|
|
94
|
+
align,
|
|
94
95
|
returnFocusRef,
|
|
95
96
|
initialFocusRef,
|
|
96
|
-
className
|
|
97
|
+
className,
|
|
98
|
+
style
|
|
97
99
|
} = props;
|
|
98
100
|
const dialogLabelId = useId();
|
|
99
101
|
const dialogDescriptionId = useId();
|
|
@@ -179,6 +181,9 @@ const _Dialog = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
179
181
|
ref: backdropRef,
|
|
180
182
|
className: classes.Backdrop,
|
|
181
183
|
...positionDataAttributes,
|
|
184
|
+
...(align && {
|
|
185
|
+
'data-align': align
|
|
186
|
+
}),
|
|
182
187
|
onClick: onBackdropClick,
|
|
183
188
|
onMouseDown: e => {
|
|
184
189
|
setLastMouseDownIsBackdrop(e.target === e.currentTarget);
|
|
@@ -190,9 +195,13 @@ const _Dialog = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
|
190
195
|
"aria-describedby": dialogDescriptionId,
|
|
191
196
|
"aria-modal": true,
|
|
192
197
|
...positionDataAttributes,
|
|
198
|
+
...(align && {
|
|
199
|
+
'data-align': align
|
|
200
|
+
}),
|
|
193
201
|
"data-width": width,
|
|
194
202
|
"data-height": height,
|
|
195
203
|
className: clsx(className, classes.Dialog),
|
|
204
|
+
style: style,
|
|
196
205
|
children: [header, /*#__PURE__*/jsx(ScrollableRegion, {
|
|
197
206
|
"aria-labelledby": dialogLabelId,
|
|
198
207
|
className: classes.DialogOverflowWrapper,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './Dialog-
|
|
1
|
+
import './Dialog-2d417a89.css';
|
|
2
2
|
|
|
3
3
|
var classes = {"Backdrop":"prc-Dialog-Backdrop-5Nt2U","dialog-backdrop-appear":"prc-Dialog-dialog-backdrop-appear-tCG2K","Dialog":"prc-Dialog-Dialog-G8cDF","Overlay--motion-scaleFade":"prc-Dialog-Overlay--motion-scaleFade-mE6-C","Overlay--motion-slideInRight":"prc-Dialog-Overlay--motion-slideInRight-BR-CZ","Overlay--motion-slideInLeft":"prc-Dialog-Overlay--motion-slideInLeft-ISmQZ","Overlay--motion-slideUp":"prc-Dialog-Overlay--motion-slideUp-tPElO","DisableScroll":"prc-Dialog-DisableScroll-UkWFM","DialogOverflowWrapper":"prc-Dialog-DialogOverflowWrapper-JvHzz","Footer":"prc-Dialog-Footer-PMeQk","detect-scroll":"prc-Dialog-detect-scroll-b3i8Q","Header":"prc-Dialog-Header-f7Me-","HeaderInner":"prc-Dialog-HeaderInner-H-fFY","HeaderContent":"prc-Dialog-HeaderContent-mjAsn","Title":"prc-Dialog-Title-M-iPn","Subtitle":"prc-Dialog-Subtitle-aBFSq","Body":"prc-Dialog-Body-bB903"};
|
|
4
4
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.prc-UnderlineNav-MenuItemContent-3J7gB{align-items:center;display:flex;justify-content:space-between}.prc-UnderlineNav-MoreButton-Y8soj{background:transparent;border:0;box-shadow:none;font-weight:var(--base-text-weight-normal,400);margin:0;padding:var(--base-size-4,.25rem) var(--base-size-8,.5rem)}.prc-UnderlineNav-MoreButton-Y8soj>[data-component=trailingVisual]{margin-left:0}
|
|
2
|
+
/*# sourceMappingURL=UnderlineNav-4344d9b0.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/UnderlineNav/UnderlineNav.module.css.js"],"names":[],"mappings":"AAAA,wCAEE,kBAAmB,CADnB,YAAa,CAEb,6BACF,CAGA,mCAGE,sBAAuB,CADvB,QAAS,CAGT,eAAgB,CADhB,8CAA2C,CAH3C,QAAS,CAQT,0DAKF,CAHE,mEACE,aACF","file":"UnderlineNav-4344d9b0.css","sourcesContent":[".MenuItemContent {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* More button styles migrated from styles.ts (was moreBtnStyles) */\n.MoreButton {\n margin: 0; /* reset Safari extra margin */\n border: 0;\n background: transparent;\n font-weight: var(--base-text-weight-normal);\n box-shadow: none;\n padding-top: var(--base-size-4);\n padding-bottom: var(--base-size-4);\n padding-left: var(--base-size-8);\n padding-right: var(--base-size-8);\n\n & > [data-component='trailingVisual'] {\n margin-left: 0;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6D,MAAM,OAAO,CAAA;AAmBjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAwEhC,eAAO,MAAM,gBAAgB,GAAI,UAAU,KAAK,CAAC,SAAS,KAEgC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAChH,CAAA;AAgCD,eAAO,MAAM,YAAY,mFA8SxB,CAAA"}
|
|
@@ -1,23 +1,119 @@
|
|
|
1
|
-
import React, { forwardRef, useRef, useState, useEffect } from 'react';
|
|
1
|
+
import React, { forwardRef, useRef, useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { UnderlineNavContext } from './UnderlineNavContext.js';
|
|
3
|
+
import { useResizeObserver } from '../hooks/useResizeObserver.js';
|
|
2
4
|
import VisuallyHidden from '../_VisuallyHidden.js';
|
|
5
|
+
import { dividerStyles, baseMenuMinWidth, menuItemStyles } from './styles.js';
|
|
6
|
+
import { UnderlineWrapper, UnderlineItemList, LoadingCounter, GAP } from '../internal/components/UnderlineTabbedInterface.js';
|
|
7
|
+
import { TriangleDownIcon } from '@primer/octicons-react';
|
|
8
|
+
import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
|
|
9
|
+
import { useOnOutsideClick } from '../hooks/useOnOutsideClick.js';
|
|
10
|
+
import { useId } from '../hooks/useId.js';
|
|
3
11
|
import { ActionList } from '../ActionList/index.js';
|
|
4
|
-
import { UnderlineWrapper, UnderlineItemList, LoadingCounter } from '../internal/components/UnderlineTabbedInterface.js';
|
|
5
12
|
import { invariant } from '../utils/invariant.js';
|
|
6
13
|
import classes from './UnderlineNav.module.css.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
-
import { SkeletonText } from '../SkeletonText/SkeletonText.js';
|
|
14
|
+
import { getAnchoredPosition } from '@primer/behaviors';
|
|
15
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
16
|
+
import { ButtonComponent } from '../Button/Button.js';
|
|
12
17
|
import CounterLabel from '../CounterLabel/CounterLabel.js';
|
|
13
|
-
import { ActionMenu } from '../ActionMenu/ActionMenu.js';
|
|
14
18
|
|
|
19
|
+
// When page is loaded, we don't have ref for the more button as it is not on the DOM yet.
|
|
20
|
+
// However, we need to calculate number of possible items when the more button present as well. So using the width of the more button as a constant.
|
|
21
|
+
const MORE_BTN_WIDTH = 86;
|
|
15
22
|
// The height is needed to make sure we don't have a layout shift when the more button is the only item in the nav.
|
|
16
|
-
const MORE_BTN_HEIGHT =
|
|
23
|
+
const MORE_BTN_HEIGHT = 45;
|
|
24
|
+
const overflowEffect = (navWidth, moreMenuWidth, childArray, childWidthArray, noIconChildWidthArray, updateListAndMenu) => {
|
|
25
|
+
let iconsVisible = true;
|
|
26
|
+
if (childWidthArray.length === 0) {
|
|
27
|
+
updateListAndMenu({
|
|
28
|
+
items: childArray,
|
|
29
|
+
menuItems: []
|
|
30
|
+
}, iconsVisible, false);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const numberOfItemsPossible = calculatePossibleItems(childWidthArray, navWidth);
|
|
34
|
+
const numberOfItemsWithoutIconPossible = calculatePossibleItems(noIconChildWidthArray, navWidth);
|
|
35
|
+
// We need to take more menu width into account when calculating the number of items possible
|
|
36
|
+
const numberOfItemsPossibleWithMoreMenu = calculatePossibleItems(noIconChildWidthArray, navWidth, moreMenuWidth || MORE_BTN_WIDTH);
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
const items = [];
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
const menuItems = [];
|
|
41
|
+
|
|
42
|
+
// First, we check if we can fit all the items with their icons
|
|
43
|
+
if (childArray.length <= numberOfItemsPossible) {
|
|
44
|
+
items.push(...childArray);
|
|
45
|
+
} else if (childArray.length <= numberOfItemsWithoutIconPossible) {
|
|
46
|
+
// if we can't fit all the items with their icons, we check if we can fit all the items without their icons
|
|
47
|
+
iconsVisible = false;
|
|
48
|
+
items.push(...childArray);
|
|
49
|
+
} else {
|
|
50
|
+
// if we can't fit all the items without their icons, we keep the icons hidden and show the ones that doesn't fit into the list in the overflow menu
|
|
51
|
+
iconsVisible = false;
|
|
52
|
+
|
|
53
|
+
/* Below is an accessibility requirement. Never show only one item in the overflow menu.
|
|
54
|
+
* If there is only one item left to display in the overflow menu according to the calculation,
|
|
55
|
+
* we need to pull another item from the list into the overflow menu.
|
|
56
|
+
*/
|
|
57
|
+
const numberOfItemsInMenu = childArray.length - numberOfItemsPossibleWithMoreMenu;
|
|
58
|
+
const numberOfListItems = numberOfItemsInMenu === 1 ? numberOfItemsPossibleWithMoreMenu - 1 : numberOfItemsPossibleWithMoreMenu;
|
|
59
|
+
for (const [index, child] of childArray.entries()) {
|
|
60
|
+
if (index < numberOfListItems) {
|
|
61
|
+
items.push(child);
|
|
62
|
+
} else {
|
|
63
|
+
const ariaCurrent = child.props['aria-current'];
|
|
64
|
+
const isCurrent = Boolean(ariaCurrent) && ariaCurrent !== 'false';
|
|
65
|
+
// We need to make sure to keep the selected item always visible.
|
|
66
|
+
// To do that, we swap the selected item with the last item in the list to make it visible. (When there is at least 1 item in the list to swap.)
|
|
67
|
+
if (isCurrent && numberOfListItems > 0) {
|
|
68
|
+
// If selected item couldn't make in to the list, we swap it with the last item in the list.
|
|
69
|
+
const indexToReplaceAt = numberOfListItems - 1; // because we are replacing the last item in the list
|
|
70
|
+
// splice method modifies the array by removing 1 item here at the given index and replace it with the "child" element then returns the removed item.
|
|
71
|
+
const propsectiveAction = items.splice(indexToReplaceAt, 1, child)[0];
|
|
72
|
+
menuItems.push(propsectiveAction);
|
|
73
|
+
} else {
|
|
74
|
+
menuItems.push(child);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
updateListAndMenu({
|
|
80
|
+
items,
|
|
81
|
+
menuItems
|
|
82
|
+
}, iconsVisible, true);
|
|
83
|
+
};
|
|
17
84
|
const getValidChildren = children => {
|
|
18
85
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
86
|
return React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child));
|
|
20
87
|
};
|
|
88
|
+
const calculatePossibleItems = (childWidthArray, navWidth, moreMenuWidth = 0) => {
|
|
89
|
+
const widthToFit = navWidth - moreMenuWidth;
|
|
90
|
+
let breakpoint = childWidthArray.length; // assume all items will fit
|
|
91
|
+
let sumsOfChildWidth = 0;
|
|
92
|
+
for (const [index, childWidth] of childWidthArray.entries()) {
|
|
93
|
+
sumsOfChildWidth = sumsOfChildWidth + childWidth.width + GAP;
|
|
94
|
+
if (sumsOfChildWidth > widthToFit) {
|
|
95
|
+
breakpoint = index;
|
|
96
|
+
break;
|
|
97
|
+
} else {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return breakpoint;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Inline styles converted from baseMenuStyles for use as CSSProperties
|
|
105
|
+
const baseMenuInlineStyles = {
|
|
106
|
+
position: 'absolute',
|
|
107
|
+
zIndex: 1,
|
|
108
|
+
top: '90%',
|
|
109
|
+
boxShadow: '0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)',
|
|
110
|
+
borderRadius: 12,
|
|
111
|
+
background: 'var(--overlay-bgColor)',
|
|
112
|
+
listStyle: 'none',
|
|
113
|
+
minWidth: `${baseMenuMinWidth}px`,
|
|
114
|
+
maxWidth: '640px',
|
|
115
|
+
right: 0
|
|
116
|
+
};
|
|
21
117
|
const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
22
118
|
as = 'nav',
|
|
23
119
|
'aria-label': ariaLabel,
|
|
@@ -26,20 +122,42 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
|
26
122
|
className,
|
|
27
123
|
children
|
|
28
124
|
}, forwardedRef) => {
|
|
29
|
-
var
|
|
125
|
+
var _listRef$current2;
|
|
30
126
|
const backupRef = useRef(null);
|
|
31
127
|
const navRef = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
|
|
32
128
|
const listRef = useRef(null);
|
|
129
|
+
const moreMenuRef = useRef(null);
|
|
130
|
+
const moreMenuBtnRef = useRef(null);
|
|
131
|
+
const containerRef = React.useRef(null);
|
|
132
|
+
const disclosureWidgetId = useId();
|
|
133
|
+
const [isWidgetOpen, setIsWidgetOpen] = useState(false);
|
|
134
|
+
const [iconsVisible, setIconsVisible] = useState(true);
|
|
135
|
+
const [childWidthArray, setChildWidthArray] = useState([]);
|
|
136
|
+
const [noIconChildWidthArray, setNoIconChildWidthArray] = useState([]);
|
|
137
|
+
// Track whether the initial overflow calculation is complete to prevent CLS
|
|
138
|
+
const [isOverflowMeasured, setIsOverflowMeasured] = useState(false);
|
|
139
|
+
const validChildren = getValidChildren(children);
|
|
33
140
|
|
|
34
|
-
|
|
35
|
-
const [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (isOverflowing && !hasEverOverflowed) setHasOverflowed(true);
|
|
40
|
-
if (process.env.NODE_ENV !== "production") {
|
|
41
|
-
const validChildren = getValidChildren(children);
|
|
141
|
+
// Responsive props object manages which items are in the list and which items are in the menu.
|
|
142
|
+
const [responsiveProps, setResponsiveProps] = useState({
|
|
143
|
+
items: validChildren,
|
|
144
|
+
menuItems: []
|
|
145
|
+
});
|
|
42
146
|
|
|
147
|
+
// Make sure to have the fresh props data for list items when children are changed (keeping aria-current up-to-date)
|
|
148
|
+
const listItems = responsiveProps.items.map(item => {
|
|
149
|
+
var _validChildren$find;
|
|
150
|
+
return (_validChildren$find = validChildren.find(child => child.key === item.key)) !== null && _validChildren$find !== void 0 ? _validChildren$find : item;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Make sure to have the fresh props data for menu items when children are changed (keeping aria-current up-to-date)
|
|
154
|
+
const menuItems = responsiveProps.menuItems.map(menuItem => {
|
|
155
|
+
var _validChildren$find2;
|
|
156
|
+
return (_validChildren$find2 = validChildren.find(child => child.key === menuItem.key)) !== null && _validChildren$find2 !== void 0 ? _validChildren$find2 : menuItem;
|
|
157
|
+
});
|
|
158
|
+
// This is the case where the viewport is too narrow to show any list item with the more menu. In this case, we only show the dropdown
|
|
159
|
+
const onlyMenuVisible = responsiveProps.items.length === 0;
|
|
160
|
+
if (process.env.NODE_ENV !== "production") {
|
|
43
161
|
// Practically, this is not a conditional hook, it is just making sure this hook runs only on DEV not PROD.
|
|
44
162
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
45
163
|
useEffect(() => {
|
|
@@ -51,86 +169,216 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
|
51
169
|
!ariaLabel ? process.env.NODE_ENV !== "production" ? invariant(false, 'Use the `aria-label` prop to provide an accessible label for assistive technology') : invariant(false) : void 0;
|
|
52
170
|
});
|
|
53
171
|
}
|
|
172
|
+
function getItemsWidth(itemText) {
|
|
173
|
+
var _noIconChildWidthArra, _noIconChildWidthArra2;
|
|
174
|
+
return (_noIconChildWidthArra = (_noIconChildWidthArra2 = noIconChildWidthArray.find(item => item.text === itemText)) === null || _noIconChildWidthArra2 === void 0 ? void 0 : _noIconChildWidthArra2.width) !== null && _noIconChildWidthArra !== void 0 ? _noIconChildWidthArra : 0;
|
|
175
|
+
}
|
|
176
|
+
const swapMenuItemWithListItem = (prospectiveListItem, indexOfProspectiveListItem, event, callback) => {
|
|
177
|
+
var _navRef$current$getBo, _navRef$current, _listRef$current$getB, _listRef$current;
|
|
178
|
+
// get the selected menu item's width
|
|
179
|
+
const widthToFitIntoList = getItemsWidth(prospectiveListItem.props.children);
|
|
180
|
+
// Check if there is any empty space on the right side of the list
|
|
181
|
+
const availableSpace = ((_navRef$current$getBo = (_navRef$current = navRef.current) === null || _navRef$current === void 0 ? void 0 : _navRef$current.getBoundingClientRect().width) !== null && _navRef$current$getBo !== void 0 ? _navRef$current$getBo : 0) - ((_listRef$current$getB = (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.getBoundingClientRect().width) !== null && _listRef$current$getB !== void 0 ? _listRef$current$getB : 0);
|
|
182
|
+
|
|
183
|
+
// Calculate how many items need to be pulled in to the menu to make room for the selected menu item
|
|
184
|
+
// I.e. if we need to pull 2 items in (index 0 and index 1), breakpoint (index) will return 1.
|
|
185
|
+
const index = getBreakpointForItemSwapping(widthToFitIntoList, availableSpace);
|
|
186
|
+
const indexToSliceAt = responsiveProps.items.length - 1 - index;
|
|
187
|
+
// Form the new list of items
|
|
188
|
+
const itemsLeftInList = [...responsiveProps.items].slice(0, indexToSliceAt);
|
|
189
|
+
const updatedItemList = [...itemsLeftInList, prospectiveListItem];
|
|
190
|
+
// Form the new menu items
|
|
191
|
+
const itemsToAddToMenu = [...responsiveProps.items].slice(indexToSliceAt);
|
|
192
|
+
const updatedMenuItems = [...menuItems];
|
|
193
|
+
// Add itemsToAddToMenu array's items to the menu at the index of the prospectiveListItem and remove 1 count of items (prospectiveListItem)
|
|
194
|
+
updatedMenuItems.splice(indexOfProspectiveListItem, 1, ...itemsToAddToMenu);
|
|
195
|
+
callback({
|
|
196
|
+
items: updatedItemList,
|
|
197
|
+
menuItems: updatedMenuItems
|
|
198
|
+
}, false, true);
|
|
199
|
+
};
|
|
200
|
+
// How many items do we need to pull in to the menu to make room for the selected menu item.
|
|
201
|
+
function getBreakpointForItemSwapping(widthToFitIntoList, availableSpace) {
|
|
202
|
+
let widthToSwap = 0;
|
|
203
|
+
let breakpoint = 0;
|
|
204
|
+
for (const [index, item] of [...responsiveProps.items].reverse().entries()) {
|
|
205
|
+
widthToSwap += getItemsWidth(item.props.children);
|
|
206
|
+
if (widthToFitIntoList < widthToSwap + availableSpace) {
|
|
207
|
+
breakpoint = index;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return breakpoint;
|
|
212
|
+
}
|
|
213
|
+
const updateListAndMenu = useCallback((props, displayIcons, overflowMeasured) => {
|
|
214
|
+
setResponsiveProps(props);
|
|
215
|
+
setIconsVisible(displayIcons);
|
|
216
|
+
if (overflowMeasured) {
|
|
217
|
+
setIsOverflowMeasured(true);
|
|
218
|
+
}
|
|
219
|
+
}, []);
|
|
220
|
+
const setChildrenWidth = useCallback(size => {
|
|
221
|
+
setChildWidthArray(arr => {
|
|
222
|
+
const newArr = [...arr, size];
|
|
223
|
+
return newArr;
|
|
224
|
+
});
|
|
225
|
+
}, []);
|
|
226
|
+
const setNoIconChildrenWidth = useCallback(size => {
|
|
227
|
+
setNoIconChildWidthArray(arr => {
|
|
228
|
+
const newArr = [...arr, size];
|
|
229
|
+
return newArr;
|
|
230
|
+
});
|
|
231
|
+
}, []);
|
|
232
|
+
const closeOverlay = React.useCallback(() => {
|
|
233
|
+
setIsWidgetOpen(false);
|
|
234
|
+
}, [setIsWidgetOpen]);
|
|
235
|
+
const focusOnMoreMenuBtn = React.useCallback(() => {
|
|
236
|
+
var _moreMenuBtnRef$curre;
|
|
237
|
+
(_moreMenuBtnRef$curre = moreMenuBtnRef.current) === null || _moreMenuBtnRef$curre === void 0 ? void 0 : _moreMenuBtnRef$curre.focus();
|
|
238
|
+
}, []);
|
|
239
|
+
const onAnchorClick = useCallback(event => {
|
|
240
|
+
if (event.defaultPrevented || event.button !== 0) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
setIsWidgetOpen(isWidgetOpen => !isWidgetOpen);
|
|
244
|
+
}, []);
|
|
245
|
+
useOnEscapePress(event => {
|
|
246
|
+
if (isWidgetOpen) {
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
closeOverlay();
|
|
249
|
+
focusOnMoreMenuBtn();
|
|
250
|
+
}
|
|
251
|
+
}, [isWidgetOpen]);
|
|
252
|
+
useOnOutsideClick({
|
|
253
|
+
onClickOutside: closeOverlay,
|
|
254
|
+
containerRef,
|
|
255
|
+
ignoreClickRefs: [moreMenuBtnRef]
|
|
256
|
+
});
|
|
257
|
+
useResizeObserver(resizeObserverEntries => {
|
|
258
|
+
var _moreMenuRef$current$, _moreMenuRef$current;
|
|
259
|
+
const navWidth = resizeObserverEntries[0].contentRect.width;
|
|
260
|
+
const moreMenuWidth = (_moreMenuRef$current$ = (_moreMenuRef$current = moreMenuRef.current) === null || _moreMenuRef$current === void 0 ? void 0 : _moreMenuRef$current.getBoundingClientRect().width) !== null && _moreMenuRef$current$ !== void 0 ? _moreMenuRef$current$ : 0;
|
|
261
|
+
navWidth !== 0 && overflowEffect(navWidth, moreMenuWidth, validChildren, childWidthArray, noIconChildWidthArray, updateListAndMenu);
|
|
262
|
+
}, navRef);
|
|
263
|
+
|
|
264
|
+
// Compute menuInlineStyles if needed
|
|
265
|
+
let menuInlineStyles = {
|
|
266
|
+
...baseMenuInlineStyles
|
|
267
|
+
};
|
|
268
|
+
if (containerRef.current && listRef.current) {
|
|
269
|
+
const {
|
|
270
|
+
left
|
|
271
|
+
} = getAnchoredPosition(containerRef.current, listRef.current, {
|
|
272
|
+
align: 'start',
|
|
273
|
+
side: 'outside-bottom'
|
|
274
|
+
});
|
|
275
|
+
menuInlineStyles = {
|
|
276
|
+
...baseMenuInlineStyles,
|
|
277
|
+
right: undefined,
|
|
278
|
+
left
|
|
279
|
+
};
|
|
280
|
+
}
|
|
54
281
|
return /*#__PURE__*/jsxs(UnderlineNavContext.Provider, {
|
|
55
282
|
value: {
|
|
56
|
-
|
|
283
|
+
setChildrenWidth,
|
|
284
|
+
setNoIconChildrenWidth,
|
|
285
|
+
loadingCounters,
|
|
286
|
+
iconsVisible
|
|
57
287
|
},
|
|
58
288
|
children: [ariaLabel && /*#__PURE__*/jsx(VisuallyHidden, {
|
|
59
289
|
as: "h2",
|
|
60
290
|
children: `${ariaLabel} navigation`
|
|
61
|
-
}), /*#__PURE__*/
|
|
291
|
+
}), /*#__PURE__*/jsx(UnderlineWrapper, {
|
|
62
292
|
as: as,
|
|
63
293
|
"aria-label": ariaLabel,
|
|
64
|
-
className:
|
|
294
|
+
className: className,
|
|
65
295
|
ref: navRef,
|
|
66
296
|
"data-variant": variant,
|
|
67
|
-
"data-overflow-
|
|
68
|
-
|
|
69
|
-
,
|
|
70
|
-
"data-hide-icons": hasEverOverflowed ? 'true' : 'false'
|
|
71
|
-
// Ensure button is shown (after initial render) on browsers that don't support scroll-driven animations
|
|
72
|
-
,
|
|
73
|
-
"data-has-overflow": isOverflowing ? 'true' : 'false',
|
|
74
|
-
children: [/*#__PURE__*/jsx(UnderlineItemList, {
|
|
297
|
+
"data-overflow-measured": isOverflowMeasured ? 'true' : 'false',
|
|
298
|
+
children: /*#__PURE__*/jsxs(UnderlineItemList, {
|
|
75
299
|
ref: listRef,
|
|
76
300
|
role: "list",
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
className: classes.MoreButtonDivider
|
|
89
|
-
}), /*#__PURE__*/jsxs(ActionMenu, {
|
|
90
|
-
children: [/*#__PURE__*/jsx(ActionMenu.Button, {
|
|
301
|
+
children: [listItems, menuItems.length > 0 && /*#__PURE__*/jsxs("li", {
|
|
302
|
+
ref: moreMenuRef,
|
|
303
|
+
style: {
|
|
304
|
+
display: 'flex',
|
|
305
|
+
alignItems: 'center',
|
|
306
|
+
height: `${MORE_BTN_HEIGHT}px`
|
|
307
|
+
},
|
|
308
|
+
children: [!onlyMenuVisible && /*#__PURE__*/jsx("div", {
|
|
309
|
+
style: dividerStyles
|
|
310
|
+
}), /*#__PURE__*/jsx(ButtonComponent, {
|
|
311
|
+
ref: moreMenuBtnRef,
|
|
91
312
|
className: classes.MoreButton,
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
313
|
+
"aria-controls": disclosureWidgetId,
|
|
314
|
+
"aria-expanded": isWidgetOpen,
|
|
315
|
+
onClick: onAnchorClick,
|
|
316
|
+
trailingAction: TriangleDownIcon,
|
|
317
|
+
children: /*#__PURE__*/jsx("span", {
|
|
318
|
+
children: onlyMenuVisible ? /*#__PURE__*/jsxs(Fragment, {
|
|
319
|
+
children: [/*#__PURE__*/jsxs(VisuallyHidden, {
|
|
320
|
+
as: "span",
|
|
321
|
+
children: [`${ariaLabel}`, "\xA0"]
|
|
322
|
+
}), "Menu"]
|
|
323
|
+
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
324
|
+
children: ["More", /*#__PURE__*/jsxs(VisuallyHidden, {
|
|
325
|
+
as: "span",
|
|
326
|
+
children: ["\xA0", `${ariaLabel} items`]
|
|
327
|
+
})]
|
|
328
|
+
})
|
|
98
329
|
})
|
|
99
|
-
}), /*#__PURE__*/jsx(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
330
|
+
}), /*#__PURE__*/jsx(ActionList, {
|
|
331
|
+
selectionVariant: "single",
|
|
332
|
+
ref: containerRef,
|
|
333
|
+
id: disclosureWidgetId,
|
|
334
|
+
style: {
|
|
335
|
+
...((_listRef$current2 = listRef.current) !== null && _listRef$current2 !== void 0 && _listRef$current2.clientWidth && listRef.current.clientWidth >= baseMenuMinWidth ? baseMenuInlineStyles : menuInlineStyles),
|
|
336
|
+
display: isWidgetOpen ? 'block' : 'none'
|
|
337
|
+
},
|
|
338
|
+
children: menuItems.map((menuItem, index) => {
|
|
339
|
+
const {
|
|
340
|
+
children: menuItemChildren,
|
|
341
|
+
counter,
|
|
342
|
+
'aria-current': ariaCurrent,
|
|
343
|
+
onSelect,
|
|
344
|
+
...menuItemProps
|
|
345
|
+
} = menuItem.props;
|
|
346
|
+
|
|
347
|
+
// This logic is used to pop the selected item out of the menu and into the list when the navigation is control externally
|
|
348
|
+
if (Boolean(ariaCurrent) && ariaCurrent !== 'false') {
|
|
349
|
+
const event = new MouseEvent('click');
|
|
350
|
+
!onlyMenuVisible && swapMenuItemWithListItem(menuItem, index,
|
|
351
|
+
// @ts-ignore - not a big deal because it is internally creating an event but ask help
|
|
352
|
+
event, updateListAndMenu);
|
|
353
|
+
}
|
|
354
|
+
return /*#__PURE__*/jsx(ActionList.LinkItem, {
|
|
355
|
+
style: menuItemStyles,
|
|
356
|
+
onClick: event => {
|
|
357
|
+
// When there are no items in the list, do not run the swap function as we want to keep everything in the menu.
|
|
358
|
+
!onlyMenuVisible && swapMenuItemWithListItem(menuItem, index, event, updateListAndMenu);
|
|
359
|
+
closeOverlay();
|
|
360
|
+
focusOnMoreMenuBtn();
|
|
361
|
+
// fire onSelect event that comes from the UnderlineNav.Item (if it is defined)
|
|
362
|
+
typeof onSelect === 'function' && onSelect(event);
|
|
363
|
+
},
|
|
364
|
+
...menuItemProps,
|
|
365
|
+
children: /*#__PURE__*/jsxs("span", {
|
|
366
|
+
className: classes.MenuItemContent,
|
|
367
|
+
children: [menuItemChildren, loadingCounters ? /*#__PURE__*/jsx(LoadingCounter, {}) : counter !== undefined && /*#__PURE__*/jsx("span", {
|
|
368
|
+
"data-component": "counter",
|
|
369
|
+
children: /*#__PURE__*/jsx(CounterLabel, {
|
|
370
|
+
children: counter
|
|
123
371
|
})
|
|
124
372
|
})]
|
|
125
|
-
}
|
|
126
|
-
})
|
|
373
|
+
})
|
|
374
|
+
}, menuItemChildren);
|
|
127
375
|
})
|
|
128
376
|
})]
|
|
129
377
|
})]
|
|
130
|
-
})
|
|
378
|
+
})
|
|
131
379
|
})]
|
|
132
380
|
});
|
|
133
381
|
});
|
|
134
382
|
UnderlineNav.displayName = 'UnderlineNav';
|
|
135
383
|
|
|
136
|
-
export { UnderlineNav, getValidChildren };
|
|
384
|
+
export { MORE_BTN_WIDTH, UnderlineNav, getValidChildren };
|