carbon-react 157.2.0 → 157.3.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,7 +1,7 @@
|
|
|
1
1
|
import React, { RefObject } from "react";
|
|
2
2
|
import { PaddingProps, WidthProps } from "styled-system";
|
|
3
3
|
import { ModalProps } from "../modal";
|
|
4
|
-
import { TagProps } from "../../__internal__/utils/helpers/tags
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
5
|
export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<ModalProps, "topModalOverride" | "restoreFocusOnClose"> {
|
|
6
6
|
/** Prop to specify the aria-describedby property of the component */
|
|
7
7
|
"aria-describedby"?: string;
|
|
@@ -18,6 +18,8 @@ export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<M
|
|
|
18
18
|
"aria-labelledby"?: string;
|
|
19
19
|
/** Modal content */
|
|
20
20
|
children?: React.ReactNode;
|
|
21
|
+
/** Data tag prop bag for close Button */
|
|
22
|
+
closeButtonDataProps?: Pick<TagProps, "data-role" | "data-element">;
|
|
21
23
|
/** Determines if the Esc Key closes the modal */
|
|
22
24
|
disableEscKey?: boolean;
|
|
23
25
|
/** Set this prop to false to hide the translucent background when the dialog is open. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import o,{useRef as t,useCallback as a}from"react";import n from"../modal/modal.component.js";import{StyledSidebar as i,StyledSidebarContent as l}from"./sidebar.style.js";import s from"../icon-button/icon-button.component.js";import c from"../icon/icon.component.js";import d from"../../__internal__/focus-trap/focus-trap.component.js";import
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import o,{useRef as t,useCallback as a}from"react";import n from"../modal/modal.component.js";import{StyledSidebar as i,StyledSidebarContent as l}from"./sidebar.style.js";import s from"../icon-button/icon-button.component.js";import c from"../icon/icon.component.js";import d from"../../__internal__/focus-trap/focus-trap.component.js";import u,{SidebarSubHeader as b}from"./__internal__/sidebar-header/sidebar-header.component.js";import p from"../../__internal__/utils/helpers/guid/index.js";import m from"../../hooks/__internal__/useLocale/useLocale.js";import f from"../../style/utils/filter-styled-system-padding-props.js";import y from"../../__internal__/utils/helpers/tags/tags.js";import O from"../../hooks/__internal__/useModalAria/useModalAria.js";import h from"./__internal__/sidebar.context.js";function j(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function g(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),t.forEach((function(r){j(e,r,o[r])}))}return e}function _(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r}(Object(r)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})),e}const P=o.forwardRef(((o,j)=>{var{"aria-describedby":P,"aria-label":w,"aria-labelledby":v,"data-element":k="sidebar","data-role":F,open:S,bespokeFocusTrap:C,closeButtonDataProps:E,disableAutoFocus:x=!1,disableEscKey:D=!1,enableBackgroundUI:I=!1,header:B,headerVariant:M="light",subHeader:A,position:H="right",size:N="medium",children:z,onCancel:K,role:L="dialog",focusFirstElement:R,focusableContainers:T,focusableSelectors:U,width:V,headerPadding:W={},subHeaderPadding:q={},topModalOverride:G,restoreFocusOnClose:J=!0,className:Q}=o,X=function(e,r){if(null==e)return{};var o,t,a=function(e,r){if(null==e)return{};var o,t,a={},n=Object.keys(e);for(t=0;t<n.length;t++)o=n[t],r.indexOf(o)>=0||(a[o]=e[o]);return a}(e,r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(t=0;t<n.length;t++)o=n[t],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(a[o]=e[o])}return a}(o,["aria-describedby","aria-label","aria-labelledby","data-element","data-role","open","bespokeFocusTrap","closeButtonDataProps","disableAutoFocus","disableEscKey","enableBackgroundUI","header","headerVariant","subHeader","position","size","children","onCancel","role","focusFirstElement","focusableContainers","focusableSelectors","width","headerPadding","subHeaderPadding","topModalOverride","restoreFocusOnClose","className"]);const Y=m(),{current:Z}=t(p()),{current:$}=t(p()),ee=t(null),re=a((e=>{ee.current=e,j&&("object"==typeof j&&(j.current=e),"function"==typeof j&&j(e))}),[j]),oe=O(ee),te=()=>K?r(s,_(g({"aria-label":Y.sidebar.ariaLabels.close(),onClick:K},y("close",g({"data-element":"close"},E))),{children:r(c,{type:"close"})})):null,ae=e(i,{"aria-modal":!I&&oe,"aria-describedby":P||$,"aria-label":w,"aria-labelledby":v||w?v:Z,"data-component":"sidebar","data-element":k,"data-role":F,ref:re,position:H,size:N,onCancel:K,role:L,width:V,className:Q,children:[B&&r(u,_(g({headerVariant:M,closeIcon:te()},W),{id:Z,children:B})),A&&r(b,_(g({},q),{id:$,children:A})),!B&&te(),r(l,_(g({"data-element":"sidebar-content","data-role":"sidebar-content"},f(X)),{children:r(h.Provider,{value:{isInSidebar:!0},children:z})}))]});return r(n,{open:S,onCancel:K,disableEscKey:D,enableBackgroundUI:I,topModalOverride:G,restoreFocusOnClose:J,children:I?ae:r(d,{wrapperRef:ee,isOpen:S,additionalWrapperRefs:T,focusableSelectors:U,focusFirstElement:R,autoFocus:!x,bespokeTrap:C,children:ae})})}));P.displayName="Sidebar";export{P as Sidebar,P as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { RefObject } from "react";
|
|
2
2
|
import { PaddingProps, WidthProps } from "styled-system";
|
|
3
3
|
import { ModalProps } from "../modal";
|
|
4
|
-
import { TagProps } from "../../__internal__/utils/helpers/tags
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
5
|
export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<ModalProps, "topModalOverride" | "restoreFocusOnClose"> {
|
|
6
6
|
/** Prop to specify the aria-describedby property of the component */
|
|
7
7
|
"aria-describedby"?: string;
|
|
@@ -18,6 +18,8 @@ export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<M
|
|
|
18
18
|
"aria-labelledby"?: string;
|
|
19
19
|
/** Modal content */
|
|
20
20
|
children?: React.ReactNode;
|
|
21
|
+
/** Data tag prop bag for close Button */
|
|
22
|
+
closeButtonDataProps?: Pick<TagProps, "data-role" | "data-element">;
|
|
21
23
|
/** Determines if the Esc Key closes the modal */
|
|
22
24
|
disableEscKey?: boolean;
|
|
23
25
|
/** Set this prop to false to hide the translucent background when the dialog is open. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../modal/modal.component.js"),a=require("./sidebar.style.js"),n=require("../icon-button/icon-button.component.js"),o=require("../icon/icon.component.js"),l=require("../../__internal__/focus-trap/focus-trap.component.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../modal/modal.component.js"),a=require("./sidebar.style.js"),n=require("../icon-button/icon-button.component.js"),o=require("../icon/icon.component.js"),l=require("../../__internal__/focus-trap/focus-trap.component.js"),s=require("./__internal__/sidebar-header/sidebar-header.component.js"),i=require("../../__internal__/utils/helpers/guid/index.js"),d=require("../../hooks/__internal__/useLocale/useLocale.js"),c=require("../../style/utils/filter-styled-system-padding-props.js"),u=require("../../__internal__/utils/helpers/tags/tags.js"),b=require("../../hooks/__internal__/useModalAria/useModalAria.js"),p=require("./__internal__/sidebar.context.js");function f(e){return e&&e.__esModule?e:{default:e}}function y(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function j(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),a.forEach((function(r){y(e,r,t[r])}))}return e}function O(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}const h=f(r).default.forwardRef(((f,y)=>{var{"aria-describedby":h,"aria-label":m,"aria-labelledby":_,"data-element":g="sidebar","data-role":P,open:S,bespokeFocusTrap:x,closeButtonDataProps:v,disableAutoFocus:w=!1,disableEscKey:q=!1,enableBackgroundUI:k=!1,header:C,headerVariant:F="light",subHeader:E,position:M="right",size:D="medium",children:I,onCancel:R,role:B="dialog",focusFirstElement:H,focusableContainers:A,focusableSelectors:N,width:z,headerPadding:K={},subHeaderPadding:L={},topModalOverride:T,restoreFocusOnClose:U=!0,className:V}=f,W=function(e,r){if(null==e)return{};var t,a,n=function(e,r){if(null==e)return{};var t,a,n={},o=Object.keys(e);for(a=0;a<o.length;a++)t=o[a],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)t=o[a],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(f,["aria-describedby","aria-label","aria-labelledby","data-element","data-role","open","bespokeFocusTrap","closeButtonDataProps","disableAutoFocus","disableEscKey","enableBackgroundUI","header","headerVariant","subHeader","position","size","children","onCancel","role","focusFirstElement","focusableContainers","focusableSelectors","width","headerPadding","subHeaderPadding","topModalOverride","restoreFocusOnClose","className"]);const G=d.default(),{current:J}=r.useRef(i.default()),{current:Q}=r.useRef(i.default()),X=r.useRef(null),Y=r.useCallback((e=>{X.current=e,y&&("object"==typeof y&&(y.current=e),"function"==typeof y&&y(e))}),[y]),Z=b.default(X),$=()=>R?e.jsx(n.default,O(j({"aria-label":G.sidebar.ariaLabels.close(),onClick:R},u.default("close",j({"data-element":"close"},v))),{children:e.jsx(o.default,{type:"close"})})):null,ee=e.jsxs(a.StyledSidebar,{"aria-modal":!k&&Z,"aria-describedby":h||Q,"aria-label":m,"aria-labelledby":_||m?_:J,"data-component":"sidebar","data-element":g,"data-role":P,ref:Y,position:M,size:D,onCancel:R,role:B,width:z,className:V,children:[C&&e.jsx(s.default,O(j({headerVariant:F,closeIcon:$()},K),{id:J,children:C})),E&&e.jsx(s.SidebarSubHeader,O(j({},L),{id:Q,children:E})),!C&&$(),e.jsx(a.StyledSidebarContent,O(j({"data-element":"sidebar-content","data-role":"sidebar-content"},c.default(W)),{children:e.jsx(p.default.Provider,{value:{isInSidebar:!0},children:I})}))]});return e.jsx(t.default,{open:S,onCancel:R,disableEscKey:q,enableBackgroundUI:k,topModalOverride:T,restoreFocusOnClose:U,children:k?ee:e.jsx(l.default,{wrapperRef:X,isOpen:S,additionalWrapperRefs:A,focusableSelectors:N,focusFirstElement:H,autoFocus:!w,bespokeTrap:x,children:ee})})}));h.displayName="Sidebar",exports.Sidebar=h,exports.default=h;
|