carbon-react 154.10.0 → 154.11.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{forwardRef as r,useState as o,useRef as i,useContext as a,useCallback as l,useEffect as c,useImperativeHandle as s,useMemo as
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{forwardRef as r,useState as o,useRef as i,useContext as a,useCallback as l,useEffect as c,useImperativeHandle as s,useMemo as p}from"react";import{CSSTransition as d}from"react-transition-group";import{offset as u,flip as m}from"@floating-ui/dom";import f from"../../hooks/useMediaQuery/useMediaQuery.js";import{PopoverContainerOpenIcon as b,PopoverContainerCloseIcon as v,PopoverContainerWrapperStyle as h,PopoverContainerContentStyle as y,PopoverContainerHeaderStyle as _,PopoverContainerTitleStyle as O}from"./popover-container.style.js";import g from"../icon/icon.component.js";import j from"../../__internal__/popover/popover.component.js";import x from"../../__internal__/utils/helpers/guid/index.js";import P from"../../style/utils/filter-styled-system-padding-props.js";import C from"../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js";import w from"../../__internal__/utils/helpers/events/events.js";import k from"../../__internal__/focus-trap/focus-trap.component.js";import A from"../modal/__internal__/modal.context.js";import B from"../../hooks/__internal__/useFocusPortalContent/useFocusPortalContent.js";import I from"../../__internal__/utils/helpers/tags/tags.js";import{defaultFocusableSelectors as D}from"../../__internal__/focus-trap/focus-trap-utils.js";import L from"../flat-table/__internal__/flat-table.context.js";import{useGlobalHeader as E}from"../global-header/__internal__/global-header.context.js";function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){S(e,t,n[t])}))}return e}function M(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const W=({tabIndex:t,onClick:n,"data-element":r,ref:o,"aria-label":i,id:a,"aria-expanded":l,"aria-haspopup":c})=>e(b,{tabIndex:t,onClick:n,"data-element":r,ref:o,"aria-label":i,"aria-haspopup":c,"aria-expanded":l,id:a,children:e(g,{type:"settings"})}),R=({"data-element":t,tabIndex:n,onClick:r,ref:o,"aria-label":i,closeButtonDataProps:a})=>e(v,M(F({tabIndex:n,onClick:r,ref:o,"aria-label":i},I("close",F({"data-element":t},a))),{children:e(g,{type:"close"})})),H=r(((r,b)=>{var{children:v,title:g,position:S="right",open:H,onOpen:Q,onClose:T,renderOpenComponent:q=W,renderCloseComponent:z=R,shouldCoverButton:G=!1,ariaDescribedBy:K,openButtonAriaLabel:N,closeButtonAriaLabel:U="close",containerAriaLabel:$,closeButtonDataProps:J,disableAnimation:V=!1,hasFullWidth:X=!1}=r,Y=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(r,["children","title","position","open","onOpen","onClose","renderOpenComponent","renderCloseComponent","shouldCoverButton","ariaDescribedBy","openButtonAriaLabel","closeButtonAriaLabel","containerAriaLabel","closeButtonDataProps","disableAnimation","hasFullWidth"]);const Z=void 0!==H,[ee,te]=o(!1),ne=i(null),re=i(null),oe=i(null),ie=i(x()),ae=i(null),le=g?`PopoverContainer_${ie.current}`:void 0,ce=Z?H:ee,se=!f("screen and (prefers-reduced-motion: no-preference)"),pe=function(e){return p((()=>[u(e?({rects:e})=>({mainAxis:-e.reference.height}):6),m({fallbackStrategy:"initialPlacement"})]),[e])}(G),{isInFlatTable:de}=a(L),ue=l((e=>{var t;Z||te(!1),null==T||T(e),ce&&(null===(t=re.current)||void 0===t||t.focus())}),[Z,ce,T]),me=l((e=>{!w.composedPath(e).find((e=>e instanceof HTMLElement&&"input"===e.getAttribute("data-element")&&"true"===e.getAttribute("aria-expanded")))&&w.isEscKey(e)&&ue(e)}),[ue]);c((()=>(document.addEventListener("keydown",me),()=>{document.removeEventListener("keydown",me)})),[me]),c((()=>{var e;!G&&ce&&(null===(e=ae.current)||void 0===e||e.focus({preventScroll:!0}))}),[ce,G,ae]),B(G?void 0:ae,G?void 0:re,ue);const fe=l((e=>{const t=Array.from(document.querySelectorAll(D)||[]).filter((e=>e===re.current||-1!==Number(e.tabIndex))),n=t.indexOf(re.current);t[n+1].focus(),ue(e)}),[]),be=(e,t)=>{var n;"next"===e&&fe?fe(t):"prev"===e&&(null===(n=re.current)||void 0===n||n.focus())},ve={tabIndex:0,"aria-expanded":ce,"aria-haspopup":"dialog",isOpen:ce,"data-element":"popover-container-open-component",onClick:e=>{Z||te(!ce),ce?null==T||T(e):null==Q||Q(e)},ref:re,"aria-label":N||g,id:ce?void 0:le},he={"data-element":"popover-container-close-component",tabIndex:0,onClick:e=>{ue(e)},ref:ne,"aria-label":U,closeButtonDataProps:J},ye=C((e=>{Z||te(!1),ce&&(null==T||T(e))}),"mousedown"),[_e,Oe]=o(!1),{isWithinGlobalHeader:ge}=E();s(b,(()=>({focusButton(){var e;null===(e=re.current)||void 0===e||e.focus()}})),[]);const je=()=>t(y,M(F({"data-element":"popover-container-content",role:"dialog","aria-labelledby":le,"aria-label":$,"aria-describedby":K,p:"16px 24px",ref:ae,tabIndex:-1,disableAnimation:V||se,zIndex:ge?1e4:2e3},P(Y)),{children:[t(_,{children:[e(O,{id:le,"data-element":"popover-container-title",children:g}),z(he)]}),v]}));return t(h,M(F({onMouseDown:ye,hasFullWidth:X},I("popover-container",Y)),{children:[e("div",{ref:oe,children:q(ve)}),e(d,{nodeRef:ae,timeout:{exit:V?0:300},in:ce,unmountOnExit:!0,onEntered:G?()=>Oe(!0):void 0,onExiting:G?()=>Oe(!1):void 0,children:e(j,{reference:oe,placement:"right"===S?"bottom-start":"bottom-end",popoverStrategy:V||se?"fixed":"absolute",middleware:pe,childRefOverride:ae,disableBackgroundUI:de,children:G?e(A.Provider,{value:{isAnimationComplete:_e},children:e(k,{wrapperRef:ae,isOpen:ce,children:je()})}):t(n,{children:[e("div",{"data-element":"tab-guard-top",tabIndex:0,onFocus:e=>be("prev",e)}),je(),e("div",{"data-element":"tab-guard-bottom",tabIndex:0,onFocus:e=>be("next",e)})]})})})]}))}));export{H as PopoverContainer,H as default,R as renderClose,W as renderOpen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("react-transition-group"),n=require("@floating-ui/dom"),o=require("../../hooks/useMediaQuery/useMediaQuery.js"),a=require("./popover-container.style.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("react-transition-group"),n=require("@floating-ui/dom"),o=require("../../hooks/useMediaQuery/useMediaQuery.js"),a=require("./popover-container.style.js"),l=require("../icon/icon.component.js"),i=require("../../__internal__/popover/popover.component.js"),s=require("../../__internal__/utils/helpers/guid/index.js"),u=require("../../style/utils/filter-styled-system-padding-props.js"),c=require("../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js"),d=require("../../__internal__/utils/helpers/events/events.js"),p=require("../../__internal__/focus-trap/focus-trap.component.js"),f=require("../modal/__internal__/modal.context.js"),b=require("../../hooks/__internal__/useFocusPortalContent/useFocusPortalContent.js"),m=require("../../__internal__/utils/helpers/tags/tags.js"),v=require("../../__internal__/focus-trap/focus-trap-utils.js"),x=require("../flat-table/__internal__/flat-table.context.js"),j=require("../global-header/__internal__/global-header.context.js");function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){y(e,t,r[t])}))}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const O=({tabIndex:t,onClick:r,"data-element":n,ref:o,"aria-label":i,id:s,"aria-expanded":u,"aria-haspopup":c})=>e.jsx(a.PopoverContainerOpenIcon,{tabIndex:t,onClick:r,"data-element":n,ref:o,"aria-label":i,"aria-haspopup":c,"aria-expanded":u,id:s,children:e.jsx(l.default,{type:"settings"})}),g=({"data-element":t,tabIndex:r,onClick:n,ref:o,"aria-label":i,closeButtonDataProps:s})=>e.jsx(a.PopoverContainerCloseIcon,h(_({tabIndex:r,onClick:n,ref:o,"aria-label":i},m.default("close",_({"data-element":t},s))),{children:e.jsx(l.default,{type:"close"})})),C=t.forwardRef(((l,y)=>{var{children:C,title:P,position:k="right",open:q,onOpen:w,onClose:S,renderOpenComponent:A=O,renderCloseComponent:I=g,shouldCoverButton:B=!1,ariaDescribedBy:E,openButtonAriaLabel:D,closeButtonAriaLabel:L="close",containerAriaLabel:F,closeButtonDataProps:R,disableAnimation:M=!1,hasFullWidth:H=!1}=l,W=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(l,["children","title","position","open","onOpen","onClose","renderOpenComponent","renderCloseComponent","shouldCoverButton","ariaDescribedBy","openButtonAriaLabel","closeButtonAriaLabel","containerAriaLabel","closeButtonDataProps","disableAnimation","hasFullWidth"]);const T=void 0!==q,[G,Q]=t.useState(!1),z=t.useRef(null),K=t.useRef(null),N=t.useRef(null),U=t.useRef(s.default()),$=t.useRef(null),J=P?`PopoverContainer_${U.current}`:void 0,V=T?q:G,X=!o.default("screen and (prefers-reduced-motion: no-preference)"),Y=function(e){return t.useMemo((()=>[n.offset(e?({rects:e})=>({mainAxis:-e.reference.height}):6),n.flip({fallbackStrategy:"initialPlacement"})]),[e])}(B),{isInFlatTable:Z}=t.useContext(x.default),ee=t.useCallback((e=>{var t;T||Q(!1),null==S||S(e),V&&(null===(t=K.current)||void 0===t||t.focus())}),[T,V,S]),te=t.useCallback((e=>{!d.default.composedPath(e).find((e=>e instanceof HTMLElement&&"input"===e.getAttribute("data-element")&&"true"===e.getAttribute("aria-expanded")))&&d.default.isEscKey(e)&&ee(e)}),[ee]);t.useEffect((()=>(document.addEventListener("keydown",te),()=>{document.removeEventListener("keydown",te)})),[te]),t.useEffect((()=>{var e;!B&&V&&(null===(e=$.current)||void 0===e||e.focus({preventScroll:!0}))}),[V,B,$]),b.default(B?void 0:$,B?void 0:K,ee);const re=t.useCallback((e=>{const t=Array.from(document.querySelectorAll(v.defaultFocusableSelectors)||[]).filter((e=>e===K.current||-1!==Number(e.tabIndex))),r=t.indexOf(K.current);t[r+1].focus(),ee(e)}),[]),ne=(e,t)=>{var r;"next"===e&&re?re(t):"prev"===e&&(null===(r=K.current)||void 0===r||r.focus())},oe={tabIndex:0,"aria-expanded":V,"aria-haspopup":"dialog",isOpen:V,"data-element":"popover-container-open-component",onClick:e=>{T||Q(!V),V?null==S||S(e):null==w||w(e)},ref:K,"aria-label":D||P,id:V?void 0:J},ae={"data-element":"popover-container-close-component",tabIndex:0,onClick:e=>{ee(e)},ref:z,"aria-label":L,closeButtonDataProps:R},le=c.default((e=>{T||Q(!1),V&&(null==S||S(e))}),"mousedown"),[ie,se]=t.useState(!1),{isWithinGlobalHeader:ue}=j.useGlobalHeader();t.useImperativeHandle(y,(()=>({focusButton(){var e;null===(e=K.current)||void 0===e||e.focus()}})),[]);const ce=()=>e.jsxs(a.PopoverContainerContentStyle,h(_({"data-element":"popover-container-content",role:"dialog","aria-labelledby":J,"aria-label":F,"aria-describedby":E,p:"16px 24px",ref:$,tabIndex:-1,disableAnimation:M||X,zIndex:ue?1e4:2e3},u.default(W)),{children:[e.jsxs(a.PopoverContainerHeaderStyle,{children:[e.jsx(a.PopoverContainerTitleStyle,{id:J,"data-element":"popover-container-title",children:P}),I(ae)]}),C]}));return e.jsxs(a.PopoverContainerWrapperStyle,h(_({onMouseDown:le,hasFullWidth:H},m.default("popover-container",W)),{children:[e.jsx("div",{ref:N,children:A(oe)}),e.jsx(r.CSSTransition,{nodeRef:$,timeout:{exit:M?0:300},in:V,unmountOnExit:!0,onEntered:B?()=>se(!0):void 0,onExiting:B?()=>se(!1):void 0,children:e.jsx(i.default,{reference:N,placement:"right"===k?"bottom-start":"bottom-end",popoverStrategy:M||X?"fixed":"absolute",middleware:Y,childRefOverride:$,disableBackgroundUI:Z,children:B?e.jsx(f.default.Provider,{value:{isAnimationComplete:ie},children:e.jsx(p.default,{wrapperRef:$,isOpen:V,children:ce()})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-element":"tab-guard-top",tabIndex:0,onFocus:e=>ne("prev",e)}),ce(),e.jsx("div",{"data-element":"tab-guard-bottom",tabIndex:0,onFocus:e=>ne("next",e)})]})})})]}))}));exports.PopoverContainer=C,exports.default=C,exports.renderClose=g,exports.renderOpen=O;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "154.
|
|
3
|
+
"version": "154.11.0",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
"@storybook/addon-viewport": "~8.6.12",
|
|
91
91
|
"@storybook/builder-vite": "~8.6.12",
|
|
92
92
|
"@storybook/components": "~8.6.12",
|
|
93
|
+
"@storybook/icons": "1.4.0",
|
|
93
94
|
"@storybook/manager-api": "~8.6.12",
|
|
94
95
|
"@storybook/preview-api": "~8.6.12",
|
|
95
96
|
"@storybook/react": "~8.6.12",
|