@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.
- package/internal/components/visual-context/index.d.ts +1 -1
- package/internal/components/visual-context/index.d.ts.map +1 -1
- package/internal/components/visual-context/index.js +11 -9
- package/internal/components/visual-context/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
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
|
-
|
|
8
|
-
|
|
6
|
+
var contextMatch = /awsui-context-([\w-]+)/;
|
|
7
|
+
export function useVisualContext(elementRef) {
|
|
9
8
|
var _a = useState(''), value = _a[0], setValue = _a[1];
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/visual-context/index.tsx"],"names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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"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
package/package.json
CHANGED