carbon-react 158.49.2 → 158.50.0-beta.1
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/esm/__spec_helper__/mock-match-media.d.ts +2 -0
- package/esm/__spec_helper__/mock-match-media.js +1 -1
- package/esm/components/tabs/__next__/tabs.style.js +1 -1
- package/esm/components/tokens-wrapper/tokens-wrapper.component.js +1 -1
- package/esm/global.d.ts +2 -0
- package/esm/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +1 -1
- package/esm/hooks/useMediaQuery/useMediaQuery.d.ts +9 -1
- package/esm/hooks/useMediaQuery/useMediaQuery.js +1 -1
- package/lib/__spec_helper__/mock-match-media.d.ts +2 -0
- package/lib/__spec_helper__/mock-match-media.js +1 -1
- package/lib/components/tabs/__next__/tabs.style.js +1 -1
- package/lib/components/tokens-wrapper/tokens-wrapper.component.js +1 -1
- package/lib/global.d.ts +2 -0
- package/lib/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +1 -1
- package/lib/hooks/useMediaQuery/useMediaQuery.d.ts +9 -1
- package/lib/hooks/useMediaQuery/useMediaQuery.js +1 -1
- package/package.json +1 -1
|
@@ -2,3 +2,5 @@ export declare const setupMatchMediaMock: () => void;
|
|
|
2
2
|
export declare const mockMatchMedia: (matches: boolean) => {
|
|
3
3
|
removeEventListener: jest.Mock<any, any, any>;
|
|
4
4
|
};
|
|
5
|
+
/** Simulate a media query change — updates `matches` and fires captured listeners */
|
|
6
|
+
export declare const simulateMediaQueryChange: (matches: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=!1,t=!1;const n=jest.fn()
|
|
1
|
+
let e=!1,t=!1;const n=jest.fn();let o=new Set;const r=()=>{if("undefined"==typeof window)return;const r=()=>{};Object.defineProperty(global.window,"matchMedia",{writable:!0,value:e=>({get matches(){return t},media:e,onchange:null,addEventListener:(e,t)=>{o.add(t)},removeEventListener:(e,t)=>{o.delete(t),n()},dispatchEvent:r})}),e=!0},a=r=>{if(!e)throw new Error("window.matchMedia has not been mocked. Did you call setupMatchMediaMock()?");return t=r,o=new Set,{removeEventListener:n}},d=e=>{t=e,o.forEach((e=>e()))};export{a as mockMatchMedia,r as setupMatchMediaMock,d as simulateMediaQueryChange};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import a,{css as o}from"styled-components";import t from"../../../style/utils/add-focus-styling.js";const i={medium:{fontSize:14,iconMinWidth:84,height:40,paddingX:16,paddingY:8,width:56},large:{fontSize:16,iconMinWidth:104,height:48,paddingX:24,paddingY:0,width:76}},r=a.div.withConfig({displayName:"tabs.style__StyledTabPanel",componentId:"sc-8b5755df-0"})(["padding:0 6px;"]),e=a.div.withConfig({displayName:"tabs.style__StyledTabList",componentId:"sc-8b5755df-1"})(["display:flex;"," width:100%;padding:6px;overflow-x:hidden;"],(({$orientation:a})=>o([""," ",""],"horizontal"===a&&o(["margin-bottom:8px;"]),"vertical"===a&&o(["flex-direction:column;flex-wrap:wrap;margin-right:8px;"])))),d=a.div.withConfig({displayName:"tabs.style__StyledTabListWrapper",componentId:"sc-8b5755df-2"})(["display:flex;z-index:6;",";"],(({$headerWidth:a})=>a&&o(["width:",";"],a))),n=a.div.withConfig({displayName:"tabs.style__Spacer",componentId:"sc-8b5755df-3"})(["align-self:flex-end;background:var(--tab-border-active-alt);flex-grow:1;height:2px;"]),l=a.button.withConfig({displayName:"tabs.style__StyledScrollButton",componentId:"sc-8b5755df-4"})(["height:",";width:",";border-radius:var(--global-radius-none);border-top-right-radius:var(--global-radius-action-m);border-top-left-radius:var(--global-radius-action-m);border-color:var(--tab-border-active-alt);background:white;border:none;border-bottom:2px solid var(--tab-border-active-alt);top:6px;position:relative;"],(({$size:a})=>"medium"===a?"40px":"48px"),(({$size:a})=>"medium"===a?"40px":"48px")),b=a.div.withConfig({displayName:"tabs.style__StyledScrollButtonPlaceholder",componentId:"sc-8b5755df-5"})(["height:",";width:",";border-radius:var(--global-radius-none);border-color:var(--tab-border-active-alt);border:none;border-bottom:2px solid var(--tab-border-active-alt);top:4px;position:relative;"],(({$size:a})=>"medium"===a?"40px":"48px"),(({$size:a})=>"medium"===a?"40px":"48px")),p=a.button.withConfig({displayName:"tabs.style__StyledTab",componentId:"sc-8b5755df-6"})(["background-color:transparent;border:none;border-bottom:2px solid var(--tab-border-default);border-radius:var(--global-radius-action-m) var(--global-radius-action-m) 0 0;white-space:nowrap;height:fit-content;color:var(--tab-label-default);font-weight:var(--fontWeights500);line-height:var(--lineHeights500);position:relative;.tab-title-content-wrapper{"," ","}:hover{background-color:var(--tab-bg-hover);cursor:pointer;}",";",";"," :focus{"," z-index:1;","}"],(({$hasCustomLayout:a})=>!a&&o(["align-items:center;display:flex;gap:8px;"])),(({activeTab:a,$orientation:t,$size:i,error:r,warning:e,info:d,$hasCustomLayout:n})=>a&&o([""," "," ",""],"horizontal"===t&&(r||e||d)&&o(["position:relative;top:1px;"]),"large"===i&&o(["margin-top:-4px;"]),n&&"horizontal"===t&&o(["position:relative;top:-2px;left:1px;"]))),(({$size:a,$hasCustomLayout:t})=>o(["font-size:","px;height:","px;",""],i[a].fontSize,i[a].height,t?o(["padding:0;"]):o(["padding:","px ","px;"],i[a].paddingY,i[a].paddingX))),(({activeTab:a,error:t,info:r,$orientation:e,$size:d,warning:n,$hasCustomLayout:l})=>a&&"horizontal"===e&&o(["background-color:var(--tab-bg-active);border:2px solid var(--tab-border-active-alt);border-bottom:none;color:var(--tab-label-active);",' :hover{background-color:var(--tab-bg-active);}::after{content:"";position:absolute;bottom:0;left:20%;width:60%;height:4px;background-color:',";border-radius:var(--global-radius-container-2-xs);min-width:24px;}"],!l&&o(["padding-top:","px;padding-right:","px;padding-bottom:","px;padding-left:","px;"],i[d].paddingY-4,i[d].paddingX-2,i[d].paddingY,i[d].paddingX-2),(()=>t?"var(--tab-validation-border-error)":n?"var(--tab-validation-border-warning)":r?"#0060a7ff":"black"))),(({activeTab:a,error:t,info:r,$orientation:e,$size:d,warning:n,$hasCustomLayout:l,$headerWidth:b})=>"vertical"===e&&o(["border:none;border-right:2px solid var(--tab-border-default);border-radius:var(--global-radius-action-m) 0 0 var(--global-radius-action-m);max-width:",";width:",";"," ",""],null!=b?b:"200px",null!=b?b:"200px",b&&o(["white-space:normal;height:auto;"]),a&&o(["background-color:var(--tab-bg-active);border:2px solid var(--tab-border-active-alt);border-right:none;"," :hover{background-color:var(--tab-bg-active);}.tab-title-content-wrapper{"," ",' ::after{content:"";position:absolute;right:0;width:4px;'," height:60%;background-color:",";border-radius:var(--global-radius-container-2-xs);min-height:24px;}}"],!l&&o(["padding-top:","px;padding-right:var(--global-space-none);padding-bottom:","px;padding-left:","px;"],"medium"===d?i.medium.paddingY-2:4,"medium"===d?i.medium.paddingY-2:i.large.paddingY,i[d].paddingX-2),b&&!l&&o(["padding-right:18px;"]),l&&o(["width:100%;> *{position:relative;left:-2px;top:-2px;}"]),l&&o(["top:20%;right:0px;"]),(()=>t?"var(--tab-validation-border-error)":n?"var(--tab-validation-border-warning)":r?"#0060a7ff":"black")))),t(),(({$orientation:a})=>o(["border-top-left-radius:var(--global-radius-action-m);border-top-right-radius:",";border-bottom-left-radius:",";border-bottom-right-radius:var(--global-radius-none);"],"horizontal"===a?"var(--global-radius-action-m)":"var(--global-radius-none)","horizontal"===a?"var(--global-radius-none)":"var(--global-radius-action-m)"))),s=a.div.withConfig({displayName:"tabs.style__StyledTabs",componentId:"sc-8b5755df-7"})(["display:flex;",""],(({$orientation:a})=>o(["flex-direction:",";"],"horizontal"===a?"column":"row"))),g=a.div.withConfig({displayName:"tabs.style__StyledTabProvider",componentId:"sc-8b5755df-8"})(["",""],(({visible:a})=>o(["display:",";"],a?"block":"none")));export{n as Spacer,l as StyledScrollButton,b as StyledScrollButtonPlaceholder,p as StyledTab,e as StyledTabList,d as StyledTabListWrapper,r as StyledTabPanel,g as StyledTabProvider,s as StyledTabs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e}from"react/jsx-runtime";import"react";import o,{createGlobalStyle as r}from"styled-components";import n from"./__internal__/static-tokens/index.js";const a=o.div.withConfig({displayName:"tokens-wrapper.component__StyledTokensWrapper",componentId:"sc-
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import"react";import o,{createGlobalStyle as r}from"styled-components";import n from"./__internal__/static-tokens/index.js";const a=o.div.withConfig({displayName:"tokens-wrapper.component__StyledTokensWrapper",componentId:"sc-bb9ec08c-0"})(["height:",";"],(({$height:t})=>t)),p=r(['[data-component="tokens-wrapper"],[class*="carbon-portal"]{',"}"],n),i=({children:o,height:r="auto"})=>t(a,{"data-component":"tokens-wrapper","data-role":"tokens-wrapper",$height:r,children:[e(p,{}),o]});export{i as TokensWrapper,i as default};
|
package/esm/global.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ModalList } from "./__internal__/modal/modal-manager";
|
|
2
|
+
import { type QueryEntry } from "./hooks/useMediaQuery/useMediaQuery";
|
|
2
3
|
|
|
3
4
|
declare global {
|
|
4
5
|
module "*.png";
|
|
@@ -16,6 +17,7 @@ declare global {
|
|
|
16
17
|
originalValues: string[];
|
|
17
18
|
restoreValues?: (() => void) | null;
|
|
18
19
|
};
|
|
20
|
+
__CARBON_INTERNALS_MEDIA_QUERY_CACHE?: Map<string, QueryEntry>;
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../../useMediaQuery/useMediaQuery.js";function i(i){const r=
|
|
1
|
+
import e from"../../useMediaQuery/useMediaQuery.js";function i(i){const r=i?`(min-width:${i}px)`:"",t=e(r);if(r)return t}export{i as default};
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
type Listener = () => void;
|
|
2
|
+
export interface QueryEntry {
|
|
3
|
+
mediaQueryList: MediaQueryList;
|
|
4
|
+
listeners: Set<Listener>;
|
|
5
|
+
nativeHandler: () => void;
|
|
6
|
+
refCount: number;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: (queryInput: string) => boolean | undefined;
|
|
9
|
+
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e,useLayoutEffect as
|
|
1
|
+
import{useState as e,useCallback as t,useLayoutEffect as r,useEffect as n}from"react";import{getWindow as a}from"../../__internal__/dom/globals.js";const s=a(),i=s?r:n,c="__CARBON_INTERNALS_MEDIA_QUERY_CACHE",o=e=>(e[c]||(e[c]=new Map),e[c]);var u=r=>{const n=null==r?void 0:r.replace(/^@media( ?)/m,""),[a,c]=e(void 0),u=t((()=>{if(!s)return;const e=o(s).get(n);e&&c(e.mediaQueryList.matches)}),[n]);return i((()=>{if(!s||!n)return;const{matches:e,unsubscribe:t}=((e,t,r)=>{const{entry:n,cache:a}=((e,t)=>{const r=o(t),n=r.get(e);if(n)return{entry:n,cache:r};const a=t.matchMedia(e),s={mediaQueryList:a,listeners:new Set,nativeHandler:()=>{s.listeners.forEach((e=>e()))},refCount:0};return a.addEventListener("change",s.nativeHandler),r.set(e,s),{entry:s,cache:r}})(e,r);return n.refCount+=1,n.listeners.add(t),{matches:n.mediaQueryList.matches,unsubscribe:()=>{n.listeners.delete(t),n.refCount-=1,n.refCount||(n.mediaQueryList.removeEventListener("change",n.nativeHandler),a.delete(e))}}})(n,u,s);return c(e),t}),[n,u]),a};export{u as default};
|
|
@@ -2,3 +2,5 @@ export declare const setupMatchMediaMock: () => void;
|
|
|
2
2
|
export declare const mockMatchMedia: (matches: boolean) => {
|
|
3
3
|
removeEventListener: jest.Mock<any, any, any>;
|
|
4
4
|
};
|
|
5
|
+
/** Simulate a media query change — updates `matches` and fires captured listeners */
|
|
6
|
+
export declare const simulateMediaQueryChange: (matches: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let e=!1,t=!1;const n=jest.fn();exports.mockMatchMedia=
|
|
1
|
+
"use strict";let e=!1,t=!1;const n=jest.fn();let a=new Set;exports.mockMatchMedia=r=>{if(!e)throw new Error("window.matchMedia has not been mocked. Did you call setupMatchMediaMock()?");return t=r,a=new Set,{removeEventListener:n}},exports.setupMatchMediaMock=()=>{if("undefined"==typeof window)return;const r=()=>{};Object.defineProperty(global.window,"matchMedia",{writable:!0,value:e=>({get matches(){return t},media:e,onchange:null,addEventListener:(e,t)=>{a.add(t)},removeEventListener:(e,t)=>{a.delete(t),n()},dispatchEvent:r})}),e=!0},exports.simulateMediaQueryChange=e=>{t=e,a.forEach((e=>e()))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=require("styled-components"),t=require("../../../style/utils/add-focus-styling.js");function o(a){return a&&a.__esModule?a:{default:a}}var i=o(a);const r={medium:{fontSize:14,iconMinWidth:84,height:40,paddingX:16,paddingY:8,width:56},large:{fontSize:16,iconMinWidth:104,height:48,paddingX:24,paddingY:0,width:76}},e=i.default.div.withConfig({displayName:"tabs.style__StyledTabPanel",componentId:"sc-8b5755df-0"})(["padding:0 6px;"]),d=i.default.div.withConfig({displayName:"tabs.style__StyledTabList",componentId:"sc-8b5755df-1"})(["display:flex;"," width:100%;padding:6px;overflow-x:hidden;"],(({$orientation:t})=>a.css([""," ",""],"horizontal"===t&&a.css(["margin-bottom:8px;"]),"vertical"===t&&a.css(["flex-direction:column;flex-wrap:wrap;margin-right:8px;"])))),n=i.default.div.withConfig({displayName:"tabs.style__StyledTabListWrapper",componentId:"sc-8b5755df-2"})(["display:flex;z-index:6;",";"],(({$headerWidth:t})=>t&&a.css(["width:",";"],t))),l=i.default.div.withConfig({displayName:"tabs.style__Spacer",componentId:"sc-8b5755df-3"})(["align-self:flex-end;background:var(--tab-border-active-alt);flex-grow:1;height:2px;"]),s=i.default.button.withConfig({displayName:"tabs.style__StyledScrollButton",componentId:"sc-8b5755df-4"})(["height:",";width:",";border-radius:var(--global-radius-none);border-top-right-radius:var(--global-radius-action-m);border-top-left-radius:var(--global-radius-action-m);border-color:var(--tab-border-active-alt);background:white;border:none;border-bottom:2px solid var(--tab-border-active-alt);top:6px;position:relative;"],(({$size:a})=>"medium"===a?"40px":"48px"),(({$size:a})=>"medium"===a?"40px":"48px")),p=i.default.div.withConfig({displayName:"tabs.style__StyledScrollButtonPlaceholder",componentId:"sc-8b5755df-5"})(["height:",";width:",";border-radius:var(--global-radius-none);border-color:var(--tab-border-active-alt);border:none;border-bottom:2px solid var(--tab-border-active-alt);top:4px;position:relative;"],(({$size:a})=>"medium"===a?"40px":"48px"),(({$size:a})=>"medium"===a?"40px":"48px")),b=i.default.button.withConfig({displayName:"tabs.style__StyledTab",componentId:"sc-8b5755df-6"})(["background-color:transparent;border:none;border-bottom:2px solid var(--tab-border-default);border-radius:var(--global-radius-action-m) var(--global-radius-action-m) 0 0;white-space:nowrap;height:fit-content;color:var(--tab-label-default);font-weight:var(--fontWeights500);line-height:var(--lineHeights500);position:relative;.tab-title-content-wrapper{"," ","}:hover{background-color:var(--tab-bg-hover);cursor:pointer;}",";",";"," :focus{"," z-index:1;","}"],(({$hasCustomLayout:t})=>!t&&a.css(["align-items:center;display:flex;gap:8px;"])),(({activeTab:t,$orientation:o,$size:i,error:r,warning:e,info:d,$hasCustomLayout:n})=>t&&a.css([""," "," ",""],"horizontal"===o&&(r||e||d)&&a.css(["position:relative;top:1px;"]),"large"===i&&a.css(["margin-top:-4px;"]),n&&"horizontal"===o&&a.css(["position:relative;top:-2px;left:1px;"]))),(({$size:t,$hasCustomLayout:o})=>a.css(["font-size:","px;height:","px;",""],r[t].fontSize,r[t].height,o?a.css(["padding:0;"]):a.css(["padding:","px ","px;"],r[t].paddingY,r[t].paddingX))),(({activeTab:t,error:o,info:i,$orientation:e,$size:d,warning:n,$hasCustomLayout:l})=>t&&"horizontal"===e&&a.css(["background-color:var(--tab-bg-active);border:2px solid var(--tab-border-active-alt);border-bottom:none;color:var(--tab-label-active);",' :hover{background-color:var(--tab-bg-active);}::after{content:"";position:absolute;bottom:0;left:20%;width:60%;height:4px;background-color:',";border-radius:var(--global-radius-container-2-xs);min-width:24px;}"],!l&&a.css(["padding-top:","px;padding-right:","px;padding-bottom:","px;padding-left:","px;"],r[d].paddingY-4,r[d].paddingX-2,r[d].paddingY,r[d].paddingX-2),(()=>o?"var(--tab-validation-border-error)":n?"var(--tab-validation-border-warning)":i?"#0060a7ff":"black"))),(({activeTab:t,error:o,info:i,$orientation:e,$size:d,warning:n,$hasCustomLayout:l,$headerWidth:s})=>"vertical"===e&&a.css(["border:none;border-right:2px solid var(--tab-border-default);border-radius:var(--global-radius-action-m) 0 0 var(--global-radius-action-m);max-width:",";width:",";"," ",""],null!=s?s:"200px",null!=s?s:"200px",s&&a.css(["white-space:normal;height:auto;"]),t&&a.css(["background-color:var(--tab-bg-active);border:2px solid var(--tab-border-active-alt);border-right:none;"," :hover{background-color:var(--tab-bg-active);}.tab-title-content-wrapper{"," ",' ::after{content:"";position:absolute;right:0;width:4px;'," height:60%;background-color:",";border-radius:var(--global-radius-container-2-xs);min-height:24px;}}"],!l&&a.css(["padding-top:","px;padding-right:var(--global-space-none);padding-bottom:","px;padding-left:","px;"],"medium"===d?r.medium.paddingY-2:4,"medium"===d?r.medium.paddingY-2:r.large.paddingY,r[d].paddingX-2),s&&!l&&a.css(["padding-right:18px;"]),l&&a.css(["width:100%;> *{position:relative;left:-2px;top:-2px;}"]),l&&a.css(["top:20%;right:0px;"]),(()=>o?"var(--tab-validation-border-error)":n?"var(--tab-validation-border-warning)":i?"#0060a7ff":"black")))),t.default(),(({$orientation:t})=>a.css(["border-top-left-radius:var(--global-radius-action-m);border-top-right-radius:",";border-bottom-left-radius:",";border-bottom-right-radius:var(--global-radius-none);"],"horizontal"===t?"var(--global-radius-action-m)":"var(--global-radius-none)","horizontal"===t?"var(--global-radius-none)":"var(--global-radius-action-m)"))),c=i.default.div.withConfig({displayName:"tabs.style__StyledTabs",componentId:"sc-8b5755df-7"})(["display:flex;",""],(({$orientation:t})=>a.css(["flex-direction:",";"],"horizontal"===t?"column":"row"))),g=i.default.div.withConfig({displayName:"tabs.style__StyledTabProvider",componentId:"sc-8b5755df-8"})(["",""],(({visible:t})=>a.css(["display:",";"],t?"block":"none")));exports.Spacer=l,exports.StyledScrollButton=s,exports.StyledScrollButtonPlaceholder=p,exports.StyledTab=b,exports.StyledTabList=d,exports.StyledTabListWrapper=n,exports.StyledTabPanel=e,exports.StyledTabProvider=g,exports.StyledTabs=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("react");var t=require("styled-components"),r=require("./__internal__/static-tokens/index.js");function a(e){return e&&e.__esModule?e:{default:e}}const o=a(t).default.div.withConfig({displayName:"tokens-wrapper.component__StyledTokensWrapper",componentId:"sc-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("react");var t=require("styled-components"),r=require("./__internal__/static-tokens/index.js");function a(e){return e&&e.__esModule?e:{default:e}}const o=a(t).default.div.withConfig({displayName:"tokens-wrapper.component__StyledTokensWrapper",componentId:"sc-bb9ec08c-0"})(["height:",";"],(({$height:e})=>e)),n=t.createGlobalStyle(['[data-component="tokens-wrapper"],[class*="carbon-portal"]{',"}"],r.default),s=({children:t,height:r="auto"})=>e.jsxs(o,{"data-component":"tokens-wrapper","data-role":"tokens-wrapper",$height:r,children:[e.jsx(n,{}),t]});exports.TokensWrapper=s,exports.default=s;
|
package/lib/global.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ModalList } from "./__internal__/modal/modal-manager";
|
|
2
|
+
import { type QueryEntry } from "./hooks/useMediaQuery/useMediaQuery";
|
|
2
3
|
|
|
3
4
|
declare global {
|
|
4
5
|
module "*.png";
|
|
@@ -16,6 +17,7 @@ declare global {
|
|
|
16
17
|
originalValues: string[];
|
|
17
18
|
restoreValues?: (() => void) | null;
|
|
18
19
|
};
|
|
20
|
+
__CARBON_INTERNALS_MEDIA_QUERY_CACHE?: Map<string, QueryEntry>;
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../useMediaQuery/useMediaQuery.js");exports.default=function(r){const t=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../useMediaQuery/useMediaQuery.js");exports.default=function(r){const t=r?`(min-width:${r}px)`:"",u=e.default(t);if(t)return u};
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
type Listener = () => void;
|
|
2
|
+
export interface QueryEntry {
|
|
3
|
+
mediaQueryList: MediaQueryList;
|
|
4
|
+
listeners: Set<Listener>;
|
|
5
|
+
nativeHandler: () => void;
|
|
6
|
+
refCount: number;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: (queryInput: string) => boolean | undefined;
|
|
9
|
+
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");const t=require("../../__internal__/dom/globals.js").getWindow(),r=t?e.useLayoutEffect:e.useEffect,n="__CARBON_INTERNALS_MEDIA_QUERY_CACHE",s=e=>(e[n]||(e[n]=new Map),e[n]);exports.default=n=>{const a=null==n?void 0:n.replace(/^@media( ?)/m,""),[i,u]=e.useState(void 0),c=e.useCallback((()=>{if(!t)return;const e=s(t).get(a);e&&u(e.mediaQueryList.matches)}),[a]);return r((()=>{if(!t||!a)return;const{matches:e,unsubscribe:r}=((e,t,r)=>{const{entry:n,cache:a}=((e,t)=>{const r=s(t),n=r.get(e);if(n)return{entry:n,cache:r};const a=t.matchMedia(e),i={mediaQueryList:a,listeners:new Set,nativeHandler:()=>{i.listeners.forEach((e=>e()))},refCount:0};return a.addEventListener("change",i.nativeHandler),r.set(e,i),{entry:i,cache:r}})(e,r);return n.refCount+=1,n.listeners.add(t),{matches:n.mediaQueryList.matches,unsubscribe:()=>{n.listeners.delete(t),n.refCount-=1,n.refCount||(n.mediaQueryList.removeEventListener("change",n.nativeHandler),a.delete(e))}}})(a,c,t);return u(e),r}),[a,c]),i};
|