@cloudscape-design/components 3.0.893 → 3.0.894
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/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-mobile/index.d.ts +1 -0
- package/internal/hooks/use-mobile/index.d.ts.map +1 -1
- package/internal/hooks/use-mobile/index.js +7 -0
- package/internal/hooks/use-mobile/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
package/internal/environment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-mobile/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-mobile/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,eAAwC,CAAC;AA4B3E,eAAO,MAAM,SAAS,eASpB,CAAC"}
|
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { createSingletonState } from '@cloudscape-design/component-toolkit/internal';
|
|
4
4
|
import { getMatchingBreakpoint, mobileBreakpoint } from '../../breakpoints';
|
|
5
|
+
export const forceMobileModeSymbol = Symbol.for('awsui-force-mobile-mode');
|
|
5
6
|
function getIsMobile() {
|
|
7
|
+
// allow overriding the mobile mode in tests
|
|
8
|
+
// any is needed because of this https://github.com/microsoft/TypeScript/issues/36813
|
|
9
|
+
const forceMobileMode = globalThis[forceMobileModeSymbol];
|
|
10
|
+
if (typeof forceMobileMode !== 'undefined') {
|
|
11
|
+
return forceMobileMode;
|
|
12
|
+
}
|
|
6
13
|
if (typeof window === 'undefined') {
|
|
7
14
|
// assume desktop in server-rendering
|
|
8
15
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-mobile/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAErF,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,SAAS,WAAW;IAClB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,qCAAqC;QACrC,OAAO,KAAK,CAAC;KACd;IAED,IAAI,MAAM,CAAC,UAAU,EAAE;QACrB;;;;;;WAMG;QACH,OAAO,MAAM,CAAC,UAAU,CAAC,eAAe,gBAAgB,KAAK,CAAC,CAAC,OAAO,CAAC;KACxE;IAED,OAAO,qBAAqB,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,oBAAoB,CAAU;IACrD,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE;IACjC,OAAO,EAAE,OAAO,CAAC,EAAE;QACjB,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createSingletonState } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getMatchingBreakpoint, mobileBreakpoint } from '../../breakpoints';\n\nfunction getIsMobile() {\n if (typeof window === 'undefined') {\n // assume desktop in server-rendering\n return false;\n }\n\n if (window.matchMedia) {\n /**\n * Some browsers include the scrollbar width in their media query calculations, but\n * some browsers don't. Thus we can't use `window.innerWidth` or\n * `document.documentElement.clientWidth` to get a very accurate result (since we\n * wouldn't know which one of them to use).\n * Instead, we use the media query here in JS too.\n */\n return window.matchMedia(`(max-width: ${mobileBreakpoint}px)`).matches;\n }\n\n return getMatchingBreakpoint(window.innerWidth, ['xs']) !== 'xs';\n}\n\nexport const useMobile = createSingletonState<boolean>({\n initialState: () => getIsMobile(),\n factory: handler => {\n const listener = () => handler(getIsMobile());\n window.addEventListener('resize', listener);\n return () => {\n window.removeEventListener('resize', listener);\n };\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-mobile/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAErF,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE3E,SAAS,WAAW;IAClB,4CAA4C;IAC5C,qFAAqF;IACrF,MAAM,eAAe,GAAI,UAAkB,CAAC,qBAAqB,CAAC,CAAC;IACnE,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE;QAC1C,OAAO,eAAe,CAAC;KACxB;IACD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,qCAAqC;QACrC,OAAO,KAAK,CAAC;KACd;IAED,IAAI,MAAM,CAAC,UAAU,EAAE;QACrB;;;;;;WAMG;QACH,OAAO,MAAM,CAAC,UAAU,CAAC,eAAe,gBAAgB,KAAK,CAAC,CAAC,OAAO,CAAC;KACxE;IAED,OAAO,qBAAqB,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,oBAAoB,CAAU;IACrD,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE;IACjC,OAAO,EAAE,OAAO,CAAC,EAAE;QACjB,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createSingletonState } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getMatchingBreakpoint, mobileBreakpoint } from '../../breakpoints';\n\nexport const forceMobileModeSymbol = Symbol.for('awsui-force-mobile-mode');\n\nfunction getIsMobile() {\n // allow overriding the mobile mode in tests\n // any is needed because of this https://github.com/microsoft/TypeScript/issues/36813\n const forceMobileMode = (globalThis as any)[forceMobileModeSymbol];\n if (typeof forceMobileMode !== 'undefined') {\n return forceMobileMode;\n }\n if (typeof window === 'undefined') {\n // assume desktop in server-rendering\n return false;\n }\n\n if (window.matchMedia) {\n /**\n * Some browsers include the scrollbar width in their media query calculations, but\n * some browsers don't. Thus we can't use `window.innerWidth` or\n * `document.documentElement.clientWidth` to get a very accurate result (since we\n * wouldn't know which one of them to use).\n * Instead, we use the media query here in JS too.\n */\n return window.matchMedia(`(max-width: ${mobileBreakpoint}px)`).matches;\n }\n\n return getMatchingBreakpoint(window.innerWidth, ['xs']) !== 'xs';\n}\n\nexport const useMobile = createSingletonState<boolean>({\n initialState: () => getIsMobile(),\n factory: handler => {\n const listener = () => handler(getIsMobile());\n window.addEventListener('resize', listener);\n return () => {\n window.removeEventListener('resize', listener);\n };\n },\n});\n"]}
|
package/internal/manifest.json
CHANGED
package/package.json
CHANGED