@cloudscape-design/components 3.0.204 → 3.0.205

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,10 +1,10 @@
1
1
  import React from 'react';
2
- export declare const useVisualContext: (elementRef: React.RefObject<HTMLElement>) => string;
3
2
  interface VisualContextProps {
4
3
  contextName: string;
5
4
  className?: string;
6
5
  children: React.ReactNode;
7
6
  }
7
+ export declare function useVisualContext(elementRef: React.RefObject<HTMLElement>): string;
8
8
  /**
9
9
  * This function returns only the className string needed to apply a
10
10
  * visual context to the DOM. It is used by the default export but
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/visual-context/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,eAAO,MAAM,gBAAgB,eAAgB,MAAM,SAAS,CAAC,WAAW,CAAC,WAQxE,CAAC;AAEF,UAAU,kBAAkB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,UAE5D;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,kBAAkB,eAE7F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/visual-context/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAGzD,UAAU,kBAAkB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAID,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,UAWxE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,UAE5D;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,kBAAkB,eAE7F"}
@@ -1,18 +1,20 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import clsx from 'clsx';
4
- import React, { useState } from 'react';
5
- import { useMutationObserver } from '../../hooks/use-mutation-observer';
4
+ import React, { useLayoutEffect, useState } from 'react';
6
5
  import { findUpUntil } from '../../utils/dom';
7
- export var useVisualContext = function (elementRef) {
8
- var contextMatch = /awsui-context-([\w-]+)/;
6
+ var contextMatch = /awsui-context-([\w-]+)/;
7
+ export function useVisualContext(elementRef) {
9
8
  var _a = useState(''), value = _a[0], setValue = _a[1];
10
- useMutationObserver(elementRef, function (node) {
11
- var contextParent = findUpUntil(node, function (node) { return !!node.className.match(contextMatch); });
12
- setValue(contextParent ? contextParent.className.match(contextMatch)[1] : '');
13
- });
9
+ useLayoutEffect(function () {
10
+ var _a;
11
+ if (elementRef.current) {
12
+ var contextParent = findUpUntil(elementRef.current, function (node) { return !!node.className.match(contextMatch); });
13
+ setValue((_a = contextParent === null || contextParent === void 0 ? void 0 : contextParent.className.match(contextMatch)[1]) !== null && _a !== void 0 ? _a : '');
14
+ }
15
+ }, [elementRef]);
14
16
  return value;
15
- };
17
+ }
16
18
  /**
17
19
  * This function returns only the className string needed to apply a
18
20
  * visual context to the DOM. It is used by the default export but
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/visual-context/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,UAAwC;IACvE,IAAM,YAAY,GAAG,wBAAwB,CAAC;IACxC,IAAA,KAAoB,QAAQ,CAAC,EAAE,CAAC,EAA/B,KAAK,QAAA,EAAE,QAAQ,QAAgB,CAAC;IACvC,mBAAmB,CAAC,UAAU,EAAE,UAAA,IAAI;QAClC,IAAM,aAAa,GAAG,WAAW,CAAC,IAAI,EAAE,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,EAApC,CAAoC,CAAC,CAAC;QACtF,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAQF;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAC3D,OAAO,wBAAiB,WAAW,CAAE,CAAC;AACxC,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAwD;QAAtD,WAAW,iBAAA,EAAE,SAAS,eAAA,EAAE,QAAQ,cAAA;IACtE,OAAO,6BAAK,SAAS,EAAE,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,IAAG,QAAQ,CAAO,CAAC;AACnG,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useState } from 'react';\nimport { useMutationObserver } from '../../hooks/use-mutation-observer';\nimport { findUpUntil } from '../../utils/dom';\n\nexport const useVisualContext = (elementRef: React.RefObject<HTMLElement>) => {\n const contextMatch = /awsui-context-([\\w-]+)/;\n const [value, setValue] = useState('');\n useMutationObserver(elementRef, node => {\n const contextParent = findUpUntil(node, node => !!node.className.match(contextMatch));\n setValue(contextParent ? contextParent.className.match(contextMatch)![1] : '');\n });\n return value;\n};\n\ninterface VisualContextProps {\n contextName: string;\n className?: string;\n children: React.ReactNode;\n}\n\n/**\n * This function returns only the className string needed to apply a\n * visual context to the DOM. It is used by the default export but\n * can also be imported directly for situations where the insertion\n * of a <div> node creates style problems.\n */\nexport function getVisualContextClassname(contextName: string) {\n return `awsui-context-${contextName}`;\n}\n\nexport default function VisualContext({ contextName, className, children }: VisualContextProps) {\n return <div className={clsx(getVisualContextClassname(contextName), className)}>{children}</div>;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/visual-context/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQ9C,IAAM,YAAY,GAAG,wBAAwB,CAAC;AAE9C,MAAM,UAAU,gBAAgB,CAAC,UAAwC;IACjE,IAAA,KAAoB,QAAQ,CAAC,EAAE,CAAC,EAA/B,KAAK,QAAA,EAAE,QAAQ,QAAgB,CAAC;IAEvC,eAAe,CAAC;;QACd,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,IAAM,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,EAApC,CAAoC,CAAC,CAAC;YACpG,QAAQ,CAAC,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,CAAC,KAAK,CAAC,YAAY,EAAG,CAAC,CAAC,mCAAI,EAAE,CAAC,CAAC;SAClE;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAC3D,OAAO,wBAAiB,WAAW,CAAE,CAAC;AACxC,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAwD;QAAtD,WAAW,iBAAA,EAAE,SAAS,eAAA,EAAE,QAAQ,cAAA;IACtE,OAAO,6BAAK,SAAS,EAAE,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,IAAG,QAAQ,CAAO,CAAC;AACnG,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useLayoutEffect, useState } from 'react';\nimport { findUpUntil } from '../../utils/dom';\n\ninterface VisualContextProps {\n contextName: string;\n className?: string;\n children: React.ReactNode;\n}\n\nconst contextMatch = /awsui-context-([\\w-]+)/;\n\nexport function useVisualContext(elementRef: React.RefObject<HTMLElement>) {\n const [value, setValue] = useState('');\n\n useLayoutEffect(() => {\n if (elementRef.current) {\n const contextParent = findUpUntil(elementRef.current, node => !!node.className.match(contextMatch));\n setValue(contextParent?.className.match(contextMatch)![1] ?? '');\n }\n }, [elementRef]);\n\n return value;\n}\n\n/**\n * This function returns only the className string needed to apply a\n * visual context to the DOM. It is used by the default export but\n * can also be imported directly for situations where the insertion\n * of a <div> node creates style problems.\n */\nexport function getVisualContextClassname(contextName: string) {\n return `awsui-context-${contextName}`;\n}\n\nexport default function VisualContext({ contextName, className, children }: VisualContextProps) {\n return <div className={clsx(getVisualContextClassname(contextName), className)}>{children}</div>;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
 
2
2
  export var PACKAGE_SOURCE = 'components';
3
- export var PACKAGE_VERSION = '3.0.0 (869e01f)';
3
+ export var PACKAGE_VERSION = '3.0.0 (fc49ae8)';
4
4
  export var THEME = 'open-source-visual-refresh';
5
5
  export var ALWAYS_VISUAL_REFRESH = true;
6
6
 
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "869e01f1192b53a2729036472506637cc33cba03"
2
+ "commit": "fc49ae884ccfbb8632240c6b82cbd323ce29fddf"
3
3
  }
package/package.json CHANGED
@@ -81,7 +81,7 @@
81
81
  "./internal/base-component/index.js",
82
82
  "./internal/base-component/styles.css.js"
83
83
  ],
84
- "version": "3.0.204",
84
+ "version": "3.0.205",
85
85
  "repository": {
86
86
  "type": "git",
87
87
  "url": "https://github.com/cloudscape-design/components.git"