@carbon-labs/react-ui-shell 0.12.0 → 0.14.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 (78) 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
  76. package/scss/styles/_content.scss +24 -0
  77. package/scss/styles/_side-nav.scss +8 -1
  78. package/scss/ui-shell.scss +1 -0
@@ -0,0 +1,63 @@
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
+ * @typedef Key
9
+ * @property key {Array<string>|string}
10
+ * @property which {number}
11
+ * @property keyCode {number}
12
+ */
13
+ /**
14
+ * Check to see if at least one key code matches the key code of the
15
+ * given event.
16
+ *
17
+ * @example
18
+ * import * as keys from '../keys';
19
+ * import { matches } from '../match';
20
+ *
21
+ * function handleOnKeyDown(event) {
22
+ * if (matches(event, [keys.Enter, keys.Space]) {
23
+ * // ...
24
+ * }
25
+ * }
26
+ *
27
+ * @param {Event|React.SyntheticEvent} event
28
+ * @param {Array<Key>} keysToMatch
29
+ * @returns {boolean}
30
+ */
31
+ export function matches(event: Event | React.SyntheticEvent, keysToMatch: Array<Key>): boolean;
32
+ /**
33
+ * Check to see if the given key matches the corresponding keyboard event. Also
34
+ * supports passing in the value directly if you can't used the given event.
35
+ *
36
+ * @example
37
+ * import * as keys from '../keys';
38
+ * import { matches } from '../match';
39
+ *
40
+ * function handleOnKeyDown(event) {
41
+ * if (match(event, keys.Enter) {
42
+ * // ...
43
+ * }
44
+ * }
45
+ *
46
+ * @param {React.SyntheticEvent|Event|number|string} eventOrCode
47
+ * @param {Key} key
48
+ * @returns {boolean}
49
+ */
50
+ export function match(eventOrCode: React.SyntheticEvent | Event | number | string, { key, which, keyCode, code }?: Key): boolean;
51
+ /**
52
+ * Get a string character for a given event or event code (useful for synthetic
53
+ * events)
54
+ *
55
+ * @param {Event|number} eventOrCode
56
+ * @returns {string}
57
+ */
58
+ export function getCharacterFor(eventOrCode: Event | number): string;
59
+ export type Key = {
60
+ key: Array<string> | string;
61
+ which: number;
62
+ keyCode: number;
63
+ };
@@ -0,0 +1,91 @@
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
+ 'use strict';
9
+
10
+ /* eslint-disable jsdoc/require-param-description */
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
+ /**
20
+ * @typedef Key
21
+ * @property key {Array<string>|string}
22
+ * @property which {number}
23
+ * @property keyCode {number}
24
+ */
25
+
26
+ /**
27
+ * Check to see if at least one key code matches the key code of the
28
+ * given event.
29
+ *
30
+ * @example
31
+ * import * as keys from '../keys';
32
+ * import { matches } from '../match';
33
+ *
34
+ * function handleOnKeyDown(event) {
35
+ * if (matches(event, [keys.Enter, keys.Space]) {
36
+ * // ...
37
+ * }
38
+ * }
39
+ *
40
+ * @param {Event|React.SyntheticEvent} event
41
+ * @param {Array<Key>} keysToMatch
42
+ * @returns {boolean}
43
+ */
44
+ function matches(event, keysToMatch) {
45
+ for (let i = 0; i < keysToMatch.length; i++) {
46
+ if (match(event, keysToMatch[i])) {
47
+ return true;
48
+ }
49
+ }
50
+ return false;
51
+ }
52
+
53
+ /**
54
+ * Check to see if the given key matches the corresponding keyboard event. Also
55
+ * supports passing in the value directly if you can't used the given event.
56
+ *
57
+ * @example
58
+ * import * as keys from '../keys';
59
+ * import { matches } from '../match';
60
+ *
61
+ * function handleOnKeyDown(event) {
62
+ * if (match(event, keys.Enter) {
63
+ * // ...
64
+ * }
65
+ * }
66
+ *
67
+ * @param {React.SyntheticEvent|Event|number|string} eventOrCode
68
+ * @param {Key} key
69
+ * @returns {boolean}
70
+ */
71
+ function match(eventOrCode) {
72
+ let {
73
+ key,
74
+ which,
75
+ keyCode,
76
+ code
77
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
78
+ if (typeof eventOrCode === 'string') {
79
+ return eventOrCode === key;
80
+ }
81
+ if (typeof eventOrCode === 'number') {
82
+ return eventOrCode === which || eventOrCode === keyCode;
83
+ }
84
+ if (eventOrCode.key && Array.isArray(key)) {
85
+ return key.indexOf(eventOrCode.key) !== -1;
86
+ }
87
+ return eventOrCode.key === key || eventOrCode.which === which || eventOrCode.keyCode === keyCode || eventOrCode.code === code;
88
+ }
89
+
90
+ exports.match = match;
91
+ exports.matches = 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,58 @@
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
+ 'use strict';
9
+
10
+ var React = require('react');
11
+
12
+ /* eslint-disable jsdoc/require-jsdoc */
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
+ * `useDelayedState` mirrors `useState` but also allows you to add a delay to
23
+ * when your state updates. You can provide a second argument to `setState`,
24
+ * `delayMs`, which will be the time in milliseconds after which the state is
25
+ * updated.
26
+ *
27
+ * This hook will clean up pending timers in `useEffect` and will cancel any
28
+ * pending timers when a `setState` is called before the state is updated from
29
+ * a previous call
30
+ */
31
+
32
+ function useDelayedState(initialState) {
33
+ const [state, setState] = React.useState(initialState);
34
+ const timeoutId = React.useRef(null);
35
+ // We use `useCallback` to match the signature of React's `useState` which will
36
+ // always return the same reference for the `setState` updater
37
+ const setStateWithDelay = React.useCallback(function (stateToSet) {
38
+ let delayMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
39
+ window.clearTimeout(timeoutId.current ?? undefined);
40
+ timeoutId.current = null;
41
+ if (delayMs === 0) {
42
+ setState(stateToSet);
43
+ return;
44
+ }
45
+ timeoutId.current = window.setTimeout(() => {
46
+ setState(stateToSet);
47
+ timeoutId.current = null;
48
+ }, delayMs);
49
+ }, []);
50
+ React.useEffect(() => {
51
+ return () => {
52
+ window.clearTimeout(timeoutId.current ?? undefined);
53
+ };
54
+ }, []);
55
+ return [state, setStateWithDelay];
56
+ }
57
+
58
+ exports.useDelayedState = 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,57 @@
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
+ 'use strict';
9
+
10
+ var React = require('react');
11
+
12
+ /* eslint-disable jsdoc/require-param-description */
13
+ // @ts-check
14
+ /* eslint-disable jsdoc/check-tag-names */
15
+ /**
16
+ * Copyright IBM Corp. 2016, 2023
17
+ *
18
+ * This source code is licensed under the Apache-2.0 license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ */
21
+
22
+
23
+ /**
24
+ * @template {keyof WindowEventMap} E
25
+ * @typedef {(event: WindowEventMap[E]) => void} WindowEventCallback
26
+ */
27
+
28
+ /**
29
+ * @template {keyof WindowEventMap} E
30
+ * @param {E} eventName
31
+ * @param {WindowEventCallback<E>} callback
32
+ */
33
+ function useWindowEvent(eventName, callback) {
34
+ /**
35
+ * @type {MutableRefObject<WindowEventCallback<E> | null>}
36
+ */
37
+ const savedCallback = React.useRef(null);
38
+ React.useEffect(() => {
39
+ savedCallback.current = callback;
40
+ }, [callback]);
41
+ React.useEffect(() => {
42
+ /**
43
+ * @type {WindowEventCallback<E>}
44
+ */
45
+ function handler(event) {
46
+ if (savedCallback.current) {
47
+ savedCallback.current(event);
48
+ }
49
+ }
50
+ window.addEventListener(eventName, handler);
51
+ return () => {
52
+ window.removeEventListener(eventName, handler);
53
+ };
54
+ }, [eventName]);
55
+ }
56
+
57
+ exports.useWindowEvent = useWindowEvent;
@@ -0,0 +1 @@
1
+ export function useMatchMedia(mediaQueryString: any): boolean;
@@ -0,0 +1,54 @@
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
+ 'use strict';
9
+
10
+ var React = require('react');
11
+ var environment = require('./environment.js');
12
+
13
+ /* eslint-disable jsdoc/require-jsdoc */
14
+ /**
15
+ * Copyright IBM Corp. 2016, 2023
16
+ *
17
+ * This source code is licensed under the Apache-2.0 license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ function useMatchMedia(mediaQueryString) {
22
+ const [matches, setMatches] = React.useState(() => {
23
+ if (environment.canUseDOM) {
24
+ const mediaQueryList = window.matchMedia(mediaQueryString);
25
+ return mediaQueryList.matches;
26
+ }
27
+ return false;
28
+ });
29
+ React.useEffect(() => {
30
+ function listener(event) {
31
+ setMatches(event.matches);
32
+ }
33
+ const mediaQueryList = window.matchMedia(mediaQueryString);
34
+ // Support fallback to `addListener` for broader browser support
35
+ if (mediaQueryList.addEventListener) {
36
+ mediaQueryList.addEventListener('change', listener);
37
+ } else {
38
+ mediaQueryList.addListener(listener);
39
+ }
40
+
41
+ // Make sure the media query list is in sync with the matches state
42
+ setMatches(mediaQueryList.matches);
43
+ return () => {
44
+ if (mediaQueryList.addEventListener) {
45
+ mediaQueryList.removeEventListener('change', listener);
46
+ } else {
47
+ mediaQueryList.removeListener(listener);
48
+ }
49
+ };
50
+ }, [mediaQueryString]);
51
+ return matches;
52
+ }
53
+
54
+ exports.useMatchMedia = 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,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
+ 'use strict';
9
+
10
+ var React = require('react');
11
+
12
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
13
+ /* eslint-disable jsdoc/require-param */
14
+ /**
15
+ * Copyright IBM Corp. 2016, 2023
16
+ *
17
+ * This source code is licensed under the Apache-2.0 license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+
22
+ /**
23
+ * Combine multiple refs into a single ref. This use useful when you have two
24
+ * refs from both `React.forwardRef` and `useRef` that you would like to add to
25
+ * the same node.
26
+ */
27
+ const useMergedRefs = refs => {
28
+ return React.useCallback(node => {
29
+ refs.forEach(ref => {
30
+ if (typeof ref === 'function') {
31
+ ref(node);
32
+ } else if (ref !== null && ref !== undefined) {
33
+ ref.current = node;
34
+ }
35
+ });
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, refs);
38
+ };
39
+
40
+ exports.useMergedRefs = 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,26 @@
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
+ 'use strict';
9
+
10
+ var React = require('react');
11
+
12
+ /* eslint-disable jsdoc/require-jsdoc */
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
+ const PrefixContext = /*#__PURE__*/React.createContext('cds');
21
+ function usePrefix() {
22
+ return React.useContext(PrefixContext);
23
+ }
24
+
25
+ exports.PrefixContext = PrefixContext;
26
+ exports.usePrefix = 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,33 @@
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
+ 'use strict';
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 emptyFunction = function () {};
19
+
20
+ function warning(condition, format) {
21
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
22
+ args[_key - 2] = arguments[_key];
23
+ }
24
+ {
25
+ let index = 0;
26
+ const message = format.replace(/%s/g, () => {
27
+ return args[index++];
28
+ });
29
+ console.warn('Warning: ' + message);
30
+ }
31
+ }
32
+
33
+ exports.warning = warning;
@@ -0,0 +1 @@
1
+ export const AriaLabelPropType: [key: string];
@@ -0,0 +1,18 @@
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
+ 'use strict';
9
+
10
+ var PropTypes = require('prop-types');
11
+ var isRequiredOneOf = require('./isRequiredOneOf.js');
12
+
13
+ const AriaLabelPropType = isRequiredOneOf.default({
14
+ 'aria-label': PropTypes.string,
15
+ 'aria-labelledby': PropTypes.string
16
+ });
17
+
18
+ exports.AriaLabelPropType = 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,43 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var warning = require('../internal/warning.js');
13
+
14
+ /* eslint-disable jsdoc/require-jsdoc */
15
+ /**
16
+ * Copyright IBM Corp. 2016, 2023
17
+ *
18
+ * This source code is licensed under the Apache-2.0 license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ */
21
+
22
+ const didWarnAboutDeprecation = {};
23
+ function deprecate(propType, message) {
24
+ function checker(props, propName, componentName) {
25
+ if (props[propName] === undefined) {
26
+ return;
27
+ }
28
+ if (!didWarnAboutDeprecation[componentName] || !didWarnAboutDeprecation[componentName][propName]) {
29
+ didWarnAboutDeprecation[componentName] = {
30
+ ...didWarnAboutDeprecation[componentName],
31
+ [propName]: true
32
+ };
33
+ process.env.NODE_ENV !== "production" ? warning.warning(false, message) : void 0;
34
+ }
35
+ for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
36
+ rest[_key - 3] = arguments[_key];
37
+ }
38
+ return propType(props, propName, componentName, ...rest);
39
+ }
40
+ return checker;
41
+ }
42
+
43
+ exports.default = deprecate;
@@ -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,44 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ /* eslint-disable jsdoc/valid-types */
13
+ /* eslint-disable jsdoc/require-jsdoc */
14
+ /**
15
+ * Copyright IBM Corp. 2016, 2023
16
+ *
17
+ * This source code is licensed under the Apache-2.0 license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * @param {[key: string]: Function)} propTypes The list of type checkers, keyed by prop names.
23
+ * @returns {[key: string]: Function}
24
+ * The new prop type checkers that checks if one of the given props exist,
25
+ * in addition to the original type checkings.
26
+ */
27
+ function isRequiredOneOf(propTypes) {
28
+ const names = Object.keys(propTypes);
29
+ const checker = propType => function (props, propName, componentName) {
30
+ if (process.env.NODE_ENV !== 'production' && names.every(name => typeof props[name] === 'undefined')) {
31
+ return new Error(`${componentName} requires one of the following props: ${names.join(', ')}`);
32
+ }
33
+ for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
34
+ rest[_key - 3] = arguments[_key];
35
+ }
36
+ return propType(props, propName, componentName, ...rest);
37
+ };
38
+ return names.reduce((o, name) => ({
39
+ ...o,
40
+ [name]: checker(propTypes[name])
41
+ }), {});
42
+ }
43
+
44
+ exports.default = isRequiredOneOf;