@carbon-labs/react-ui-shell 0.12.0 → 0.13.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.
Files changed (75) hide show
  1. package/es/components/HeaderPanel.js +6 -6
  2. package/es/components/Link.d.ts +48 -0
  3. package/es/components/Link.js +60 -0
  4. package/es/components/SideNav.d.ts +3 -3
  5. package/es/components/SideNav.js +16 -16
  6. package/es/components/SideNavItems.js +1 -1
  7. package/es/components/SideNavMenu.js +8 -8
  8. package/es/components/SideNavMenuItem.d.ts +1 -1
  9. package/es/components/SideNavMenuItem.js +4 -4
  10. package/es/components/SideNavToggle.js +1 -1
  11. package/es/internal/environment.d.ts +12 -0
  12. package/es/internal/environment.js +15 -0
  13. package/es/internal/keyboard/index.d.ts +3 -0
  14. package/es/internal/keyboard/keys.d.ts +126 -0
  15. package/es/internal/keyboard/keys.js +67 -0
  16. package/es/internal/keyboard/match.d.ts +63 -0
  17. package/es/internal/keyboard/match.js +88 -0
  18. package/es/internal/keyboard/navigation.d.ts +19 -0
  19. package/es/internal/useDelayedState.d.ts +19 -0
  20. package/es/internal/useDelayedState.js +56 -0
  21. package/es/internal/useEvent.d.ts +31 -0
  22. package/es/internal/useEvent.js +55 -0
  23. package/es/internal/useMatchMedia.d.ts +1 -0
  24. package/es/internal/useMatchMedia.js +52 -0
  25. package/es/internal/useMergedRefs.d.ts +13 -0
  26. package/es/internal/useMergedRefs.js +38 -0
  27. package/es/internal/usePrefix.d.ts +9 -0
  28. package/es/internal/usePrefix.js +23 -0
  29. package/es/internal/warning.d.ts +7 -0
  30. package/es/internal/warning.js +31 -0
  31. package/es/prop-types/AriaPropTypes.d.ts +1 -0
  32. package/es/prop-types/AriaPropTypes.js +16 -0
  33. package/es/prop-types/deprecate.d.ts +1 -0
  34. package/es/prop-types/deprecate.js +39 -0
  35. package/es/prop-types/isRequiredOneOf.d.ts +13 -0
  36. package/es/prop-types/isRequiredOneOf.js +40 -0
  37. package/es/types/common.d.ts +29 -0
  38. package/lib/components/HeaderPanel.js +6 -6
  39. package/lib/components/Link.d.ts +48 -0
  40. package/lib/components/Link.js +65 -0
  41. package/lib/components/SideNav.d.ts +3 -3
  42. package/lib/components/SideNav.js +16 -35
  43. package/lib/components/SideNavItems.js +1 -1
  44. package/lib/components/SideNavMenu.js +10 -29
  45. package/lib/components/SideNavMenuItem.d.ts +1 -1
  46. package/lib/components/SideNavMenuItem.js +6 -6
  47. package/lib/components/SideNavToggle.js +1 -1
  48. package/lib/internal/environment.d.ts +12 -0
  49. package/lib/internal/environment.js +17 -0
  50. package/lib/internal/keyboard/index.d.ts +3 -0
  51. package/lib/internal/keyboard/keys.d.ts +126 -0
  52. package/lib/internal/keyboard/keys.js +76 -0
  53. package/lib/internal/keyboard/match.d.ts +63 -0
  54. package/lib/internal/keyboard/match.js +91 -0
  55. package/lib/internal/keyboard/navigation.d.ts +19 -0
  56. package/lib/internal/useDelayedState.d.ts +19 -0
  57. package/lib/internal/useDelayedState.js +58 -0
  58. package/lib/internal/useEvent.d.ts +31 -0
  59. package/lib/internal/useEvent.js +57 -0
  60. package/lib/internal/useMatchMedia.d.ts +1 -0
  61. package/lib/internal/useMatchMedia.js +54 -0
  62. package/lib/internal/useMergedRefs.d.ts +13 -0
  63. package/lib/internal/useMergedRefs.js +40 -0
  64. package/lib/internal/usePrefix.d.ts +9 -0
  65. package/lib/internal/usePrefix.js +26 -0
  66. package/lib/internal/warning.d.ts +7 -0
  67. package/lib/internal/warning.js +33 -0
  68. package/lib/prop-types/AriaPropTypes.d.ts +1 -0
  69. package/lib/prop-types/AriaPropTypes.js +18 -0
  70. package/lib/prop-types/deprecate.d.ts +1 -0
  71. package/lib/prop-types/deprecate.js +43 -0
  72. package/lib/prop-types/isRequiredOneOf.d.ts +13 -0
  73. package/lib/prop-types/isRequiredOneOf.js +44 -0
  74. package/lib/types/common.d.ts +29 -0
  75. package/package.json +2 -2
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /* eslint-disable jsdoc/require-param-description */
9
+ /* eslint-disable jsdoc/require-jsdoc */
10
+ /**
11
+ * Copyright IBM Corp. 2016, 2023
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+
17
+ /**
18
+ * @typedef Key
19
+ * @property key {Array<string>|string}
20
+ * @property which {number}
21
+ * @property keyCode {number}
22
+ */
23
+
24
+ /**
25
+ * Check to see if at least one key code matches the key code of the
26
+ * given event.
27
+ *
28
+ * @example
29
+ * import * as keys from '../keys';
30
+ * import { matches } from '../match';
31
+ *
32
+ * function handleOnKeyDown(event) {
33
+ * if (matches(event, [keys.Enter, keys.Space]) {
34
+ * // ...
35
+ * }
36
+ * }
37
+ *
38
+ * @param {Event|React.SyntheticEvent} event
39
+ * @param {Array<Key>} keysToMatch
40
+ * @returns {boolean}
41
+ */
42
+ function matches(event, keysToMatch) {
43
+ for (let i = 0; i < keysToMatch.length; i++) {
44
+ if (match(event, keysToMatch[i])) {
45
+ return true;
46
+ }
47
+ }
48
+ return false;
49
+ }
50
+
51
+ /**
52
+ * Check to see if the given key matches the corresponding keyboard event. Also
53
+ * supports passing in the value directly if you can't used the given event.
54
+ *
55
+ * @example
56
+ * import * as keys from '../keys';
57
+ * import { matches } from '../match';
58
+ *
59
+ * function handleOnKeyDown(event) {
60
+ * if (match(event, keys.Enter) {
61
+ * // ...
62
+ * }
63
+ * }
64
+ *
65
+ * @param {React.SyntheticEvent|Event|number|string} eventOrCode
66
+ * @param {Key} key
67
+ * @returns {boolean}
68
+ */
69
+ function match(eventOrCode) {
70
+ let {
71
+ key,
72
+ which,
73
+ keyCode,
74
+ code
75
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
76
+ if (typeof eventOrCode === 'string') {
77
+ return eventOrCode === key;
78
+ }
79
+ if (typeof eventOrCode === 'number') {
80
+ return eventOrCode === which || eventOrCode === keyCode;
81
+ }
82
+ if (eventOrCode.key && Array.isArray(key)) {
83
+ return key.indexOf(eventOrCode.key) !== -1;
84
+ }
85
+ return eventOrCode.key === key || eventOrCode.which === which || eventOrCode.keyCode === keyCode || eventOrCode.code === code;
86
+ }
87
+
88
+ export { match, matches };
@@ -0,0 +1,19 @@
1
+ export function getNextIndex(key: string, index: number, arrayLength: number): number | undefined;
2
+ /**
3
+ * A flag `node.compareDocumentPosition(target)` returns,
4
+ * that indicates `target` is located earlier than `node` in the document or `target` contains `node`.
5
+ */
6
+ export const DOCUMENT_POSITION_BROAD_PRECEDING: number | false;
7
+ /**
8
+ * A flag `node.compareDocumentPosition(target)` returns,
9
+ * that indicates `target` is located later than `node` in the document or `node` contains `target`.
10
+ */
11
+ export const DOCUMENT_POSITION_BROAD_FOLLOWING: number | false;
12
+ /**
13
+ * CSS selector that selects major nodes that are sequential-focusable.
14
+ */
15
+ export const selectorTabbable: "\n a[href], area[href], input:not([disabled]):not([tabindex='-1']),\n button:not([disabled]):not([tabindex='-1']),select:not([disabled]):not([tabindex='-1']),\n textarea:not([disabled]):not([tabindex='-1']),\n iframe, object, embed, *[tabindex]:not([tabindex='-1']):not([disabled]), *[contenteditable=true]\n";
16
+ /**
17
+ * CSS selector that selects major nodes that are click focusable
18
+ */
19
+ export const selectorFocusable: "\n a[href], area[href], input:not([disabled]),\n button:not([disabled]),select:not([disabled]),\n textarea:not([disabled]),\n iframe, object, embed, *[tabindex]:not([disabled]), *[contenteditable=true]\n";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { SetStateAction } from 'react';
8
+ /**
9
+ * `useDelayedState` mirrors `useState` but also allows you to add a delay to
10
+ * when your state updates. You can provide a second argument to `setState`,
11
+ * `delayMs`, which will be the time in milliseconds after which the state is
12
+ * updated.
13
+ *
14
+ * This hook will clean up pending timers in `useEffect` and will cancel any
15
+ * pending timers when a `setState` is called before the state is updated from
16
+ * a previous call
17
+ */
18
+ export type DispatchWithDelay<A> = (value: A, delayMS?: number) => void;
19
+ export declare function useDelayedState<S>(initialState: S): [S, DispatchWithDelay<SetStateAction<S>>];
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { useState, useRef, useCallback, useEffect } from 'react';
9
+
10
+ /* eslint-disable jsdoc/require-jsdoc */
11
+ /**
12
+ * Copyright IBM Corp. 2016, 2023
13
+ *
14
+ * This source code is licensed under the Apache-2.0 license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+
18
+
19
+ /**
20
+ * `useDelayedState` mirrors `useState` but also allows you to add a delay to
21
+ * when your state updates. You can provide a second argument to `setState`,
22
+ * `delayMs`, which will be the time in milliseconds after which the state is
23
+ * updated.
24
+ *
25
+ * This hook will clean up pending timers in `useEffect` and will cancel any
26
+ * pending timers when a `setState` is called before the state is updated from
27
+ * a previous call
28
+ */
29
+
30
+ function useDelayedState(initialState) {
31
+ const [state, setState] = useState(initialState);
32
+ const timeoutId = useRef(null);
33
+ // We use `useCallback` to match the signature of React's `useState` which will
34
+ // always return the same reference for the `setState` updater
35
+ const setStateWithDelay = useCallback(function (stateToSet) {
36
+ let delayMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
37
+ window.clearTimeout(timeoutId.current ?? undefined);
38
+ timeoutId.current = null;
39
+ if (delayMs === 0) {
40
+ setState(stateToSet);
41
+ return;
42
+ }
43
+ timeoutId.current = window.setTimeout(() => {
44
+ setState(stateToSet);
45
+ timeoutId.current = null;
46
+ }, delayMs);
47
+ }, []);
48
+ useEffect(() => {
49
+ return () => {
50
+ window.clearTimeout(timeoutId.current ?? undefined);
51
+ };
52
+ }, []);
53
+ return [state, setStateWithDelay];
54
+ }
55
+
56
+ export { useDelayedState };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @template {keyof GlobalEventHandlersEventMap} E
3
+ * @typedef {(event: GlobalEventHandlersEventMap[E]) => void} GlobalEventCallback
4
+ */
5
+ /**
6
+ * @template T
7
+ * @typedef {import('react').MutableRefObject<T>} MutableRefObject<T>
8
+ */
9
+ /**
10
+ * @template {keyof GlobalEventHandlersEventMap} E
11
+ * @param {HTMLElement | MutableRefObject<HTMLElement | null>} elementOrRef
12
+ * @param {E} eventName
13
+ * @param {GlobalEventCallback<E>} callback
14
+ */
15
+ export function useEvent<E extends keyof GlobalEventHandlersEventMap>(elementOrRef: HTMLElement | MutableRefObject<HTMLElement | null>, eventName: E, callback: GlobalEventCallback<E>): void;
16
+ /**
17
+ * @template {keyof WindowEventMap} E
18
+ * @typedef {(event: WindowEventMap[E]) => void} WindowEventCallback
19
+ */
20
+ /**
21
+ * @template {keyof WindowEventMap} E
22
+ * @param {E} eventName
23
+ * @param {WindowEventCallback<E>} callback
24
+ */
25
+ export function useWindowEvent<E extends keyof WindowEventMap>(eventName: E, callback: WindowEventCallback<E>): void;
26
+ export type GlobalEventCallback<E extends keyof GlobalEventHandlersEventMap> = (event: GlobalEventHandlersEventMap[E]) => void;
27
+ /**
28
+ * <T>
29
+ */
30
+ export type MutableRefObject<T> = import('react').MutableRefObject<T>;
31
+ export type WindowEventCallback<E extends keyof WindowEventMap> = (event: WindowEventMap[E]) => void;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { useRef, useEffect } from 'react';
9
+
10
+ /* eslint-disable jsdoc/require-param-description */
11
+ // @ts-check
12
+ /* eslint-disable jsdoc/check-tag-names */
13
+ /**
14
+ * Copyright IBM Corp. 2016, 2023
15
+ *
16
+ * This source code is licensed under the Apache-2.0 license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */
19
+
20
+
21
+ /**
22
+ * @template {keyof WindowEventMap} E
23
+ * @typedef {(event: WindowEventMap[E]) => void} WindowEventCallback
24
+ */
25
+
26
+ /**
27
+ * @template {keyof WindowEventMap} E
28
+ * @param {E} eventName
29
+ * @param {WindowEventCallback<E>} callback
30
+ */
31
+ function useWindowEvent(eventName, callback) {
32
+ /**
33
+ * @type {MutableRefObject<WindowEventCallback<E> | null>}
34
+ */
35
+ const savedCallback = useRef(null);
36
+ useEffect(() => {
37
+ savedCallback.current = callback;
38
+ }, [callback]);
39
+ useEffect(() => {
40
+ /**
41
+ * @type {WindowEventCallback<E>}
42
+ */
43
+ function handler(event) {
44
+ if (savedCallback.current) {
45
+ savedCallback.current(event);
46
+ }
47
+ }
48
+ window.addEventListener(eventName, handler);
49
+ return () => {
50
+ window.removeEventListener(eventName, handler);
51
+ };
52
+ }, [eventName]);
53
+ }
54
+
55
+ export { useWindowEvent };
@@ -0,0 +1 @@
1
+ export function useMatchMedia(mediaQueryString: any): boolean;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { useState, useEffect } from 'react';
9
+ import { canUseDOM } from './environment.js';
10
+
11
+ /* eslint-disable jsdoc/require-jsdoc */
12
+ /**
13
+ * Copyright IBM Corp. 2016, 2023
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+
19
+ function useMatchMedia(mediaQueryString) {
20
+ const [matches, setMatches] = useState(() => {
21
+ if (canUseDOM) {
22
+ const mediaQueryList = window.matchMedia(mediaQueryString);
23
+ return mediaQueryList.matches;
24
+ }
25
+ return false;
26
+ });
27
+ useEffect(() => {
28
+ function listener(event) {
29
+ setMatches(event.matches);
30
+ }
31
+ const mediaQueryList = window.matchMedia(mediaQueryString);
32
+ // Support fallback to `addListener` for broader browser support
33
+ if (mediaQueryList.addEventListener) {
34
+ mediaQueryList.addEventListener('change', listener);
35
+ } else {
36
+ mediaQueryList.addListener(listener);
37
+ }
38
+
39
+ // Make sure the media query list is in sync with the matches state
40
+ setMatches(mediaQueryList.matches);
41
+ return () => {
42
+ if (mediaQueryList.addEventListener) {
43
+ mediaQueryList.removeEventListener('change', listener);
44
+ } else {
45
+ mediaQueryList.removeListener(listener);
46
+ }
47
+ };
48
+ }, [mediaQueryString]);
49
+ return matches;
50
+ }
51
+
52
+ export { useMatchMedia };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Ref, ForwardedRef } from 'react';
8
+ /**
9
+ * Combine multiple refs into a single ref. This use useful when you have two
10
+ * refs from both `React.forwardRef` and `useRef` that you would like to add to
11
+ * the same node.
12
+ */
13
+ export declare const useMergedRefs: <T extends unknown>(refs: ForwardedRef<T>[]) => Ref<T>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { useCallback } from 'react';
9
+
10
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
11
+ /* eslint-disable jsdoc/require-param */
12
+ /**
13
+ * Copyright IBM Corp. 2016, 2023
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+
19
+
20
+ /**
21
+ * Combine multiple refs into a single ref. This use useful when you have two
22
+ * refs from both `React.forwardRef` and `useRef` that you would like to add to
23
+ * the same node.
24
+ */
25
+ const useMergedRefs = refs => {
26
+ return useCallback(node => {
27
+ refs.forEach(ref => {
28
+ if (typeof ref === 'function') {
29
+ ref(node);
30
+ } else if (ref !== null && ref !== undefined) {
31
+ ref.current = node;
32
+ }
33
+ });
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ }, refs);
36
+ };
37
+
38
+ export { useMergedRefs };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ export declare const PrefixContext: React.Context<string>;
9
+ export declare function usePrefix(): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+
10
+ /* eslint-disable jsdoc/require-jsdoc */
11
+ /**
12
+ * Copyright IBM Corp. 2016, 2023
13
+ *
14
+ * This source code is licensed under the Apache-2.0 license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+
18
+ const PrefixContext = /*#__PURE__*/React.createContext('cds');
19
+ function usePrefix() {
20
+ return React.useContext(PrefixContext);
21
+ }
22
+
23
+ export { PrefixContext, usePrefix };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export function warning(condition: any, format: any, ...args: any[]): void;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /* eslint-disable jsdoc/require-jsdoc */
9
+ /**
10
+ * Copyright IBM Corp. 2016, 2023
11
+ *
12
+ * This source code is licensed under the Apache-2.0 license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ */
15
+
16
+ // const emptyFunction = function () {};
17
+
18
+ function warning(condition, format) {
19
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
20
+ args[_key - 2] = arguments[_key];
21
+ }
22
+ {
23
+ let index = 0;
24
+ const message = format.replace(/%s/g, () => {
25
+ return args[index++];
26
+ });
27
+ console.warn('Warning: ' + message);
28
+ }
29
+ }
30
+
31
+ export { warning };
@@ -0,0 +1 @@
1
+ export const AriaLabelPropType: [key: string];
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import PropTypes from 'prop-types';
9
+ import isRequiredOneOf from './isRequiredOneOf.js';
10
+
11
+ const AriaLabelPropType = isRequiredOneOf({
12
+ 'aria-label': PropTypes.string,
13
+ 'aria-labelledby': PropTypes.string
14
+ });
15
+
16
+ export { AriaLabelPropType };
@@ -0,0 +1 @@
1
+ export default function deprecate(propType: any, message: any): (props: any, propName: any, componentName: any, ...rest: any[]) => any;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { warning } from '../internal/warning.js';
9
+
10
+ /* eslint-disable jsdoc/require-jsdoc */
11
+ /**
12
+ * Copyright IBM Corp. 2016, 2023
13
+ *
14
+ * This source code is licensed under the Apache-2.0 license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+
18
+ const didWarnAboutDeprecation = {};
19
+ function deprecate(propType, message) {
20
+ function checker(props, propName, componentName) {
21
+ if (props[propName] === undefined) {
22
+ return;
23
+ }
24
+ if (!didWarnAboutDeprecation[componentName] || !didWarnAboutDeprecation[componentName][propName]) {
25
+ didWarnAboutDeprecation[componentName] = {
26
+ ...didWarnAboutDeprecation[componentName],
27
+ [propName]: true
28
+ };
29
+ process.env.NODE_ENV !== "production" ? warning(false, message) : void 0;
30
+ }
31
+ for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
32
+ rest[_key - 3] = arguments[_key];
33
+ }
34
+ return propType(props, propName, componentName, ...rest);
35
+ }
36
+ return checker;
37
+ }
38
+
39
+ export { deprecate as default };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * @param {[key: string]: Function)} propTypes The list of type checkers, keyed by prop names.
9
+ * @returns {[key: string]: Function}
10
+ * The new prop type checkers that checks if one of the given props exist,
11
+ * in addition to the original type checkings.
12
+ */
13
+ export default function isRequiredOneOf(propTypes: any): [key: string];
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /* eslint-disable jsdoc/valid-types */
9
+ /* eslint-disable jsdoc/require-jsdoc */
10
+ /**
11
+ * Copyright IBM Corp. 2016, 2023
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+
17
+ /**
18
+ * @param {[key: string]: Function)} propTypes The list of type checkers, keyed by prop names.
19
+ * @returns {[key: string]: Function}
20
+ * The new prop type checkers that checks if one of the given props exist,
21
+ * in addition to the original type checkings.
22
+ */
23
+ function isRequiredOneOf(propTypes) {
24
+ const names = Object.keys(propTypes);
25
+ const checker = propType => function (props, propName, componentName) {
26
+ if (process.env.NODE_ENV !== 'production' && names.every(name => typeof props[name] === 'undefined')) {
27
+ return new Error(`${componentName} requires one of the following props: ${names.join(', ')}`);
28
+ }
29
+ for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
30
+ rest[_key - 3] = arguments[_key];
31
+ }
32
+ return propType(props, propName, componentName, ...rest);
33
+ };
34
+ return names.reduce((o, name) => ({
35
+ ...o,
36
+ [name]: checker(propTypes[name])
37
+ }), {});
38
+ }
39
+
40
+ export { isRequiredOneOf as default };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as React from 'react';
8
+ export type ReactAttr<T = HTMLElement> = React.HTMLAttributes<T>;
9
+ export type ForwardRefProps<T, P = unknown> = React.PropsWithoutRef<React.PropsWithChildren<P>> & React.RefAttributes<T>;
10
+ export type ForwardRefReturn<T, P = unknown> = React.ForwardRefExoticComponent<ForwardRefProps<T, P>>;
11
+ /**
12
+ * For "as" props. Creates an "as" property that supports native html tags such as 'span', 'a', 'button' as well as custom functional components
13
+ * All native props for the supplied html tag/component are inferred as part of the base component props, allowing us to use props like `href` on an 'a' element etc
14
+ */
15
+ export type PolymorphicProps<Element extends React.ElementType, Props> = Props & Omit<React.ComponentProps<Element>, 'as'> & {
16
+ as?: Element;
17
+ };
18
+ export interface TranslateWithId<MID = string, ARGS = Record<string, unknown>> {
19
+ /**
20
+ * Supply a method to translate internal strings with your i18n tool of
21
+ * choice.
22
+ */
23
+ translateWithId?(messageId: MID, args?: ARGS): string;
24
+ }
25
+ /**
26
+ * Alias of TranslateWithId. Will be removed in v12
27
+ * @deprecated Use TranslateWithId instead
28
+ */
29
+ export type InternationalProps<MID = string, ARGS = Record<string, unknown>> = TranslateWithId<MID, ARGS>;
@@ -11,11 +11,11 @@ var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.j
11
11
  var index = require('../_virtual/index.js');
12
12
  var PropTypes = require('prop-types');
13
13
  var React = require('react');
14
- var usePrefix = require('@carbon/react/lib/internal/usePrefix');
15
- var keys = require('@carbon/react/lib/internal/keyboard/keys');
16
- var match = require('@carbon/react/lib/internal/keyboard/match');
17
- var useEvent = require('@carbon/react/lib/internal/useEvent');
18
- var useMergedRefs = require('@carbon/react/lib/internal/useMergedRefs');
14
+ var usePrefix = require('../internal/usePrefix.js');
15
+ var keys = require('../internal/keyboard/keys.js');
16
+ var match = require('../internal/keyboard/match.js');
17
+ var useEvent = require('../internal/useEvent.js');
18
+ var useMergedRefs = require('../internal/useMergedRefs.js');
19
19
 
20
20
  const noopFn = () => {};
21
21
  const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel(_ref, ref) {
@@ -51,7 +51,7 @@ const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel(_ref, ref
51
51
  }
52
52
  };
53
53
  eventHandlers.onKeyDown = event => {
54
- if (match.match(event, keys.keys.Escape)) {
54
+ if (match.match(event, keys.Escape)) {
55
55
  setExpandedState(false);
56
56
  onHeaderPanelFocus();
57
57
  if (href) {