@lumx/react 2.2.19 → 2.2.20-alpha-type.1
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/esm/_internal/AutocompleteMultiple.js.map +1 -1
- package/esm/_internal/ButtonRoot.js.map +1 -1
- package/esm/_internal/Checkbox2.js +3 -1
- package/esm/_internal/Checkbox2.js.map +1 -1
- package/esm/_internal/ClickAwayProvider.js +90 -12
- package/esm/_internal/ClickAwayProvider.js.map +1 -1
- package/esm/_internal/DatePickerField.js +18 -11
- package/esm/_internal/DatePickerField.js.map +1 -1
- package/esm/_internal/Dialog2.js +2 -2
- package/esm/_internal/Dialog2.js.map +1 -1
- package/esm/_internal/Dropdown2.js.map +1 -1
- package/esm/_internal/GenericBlock.js +90 -0
- package/esm/_internal/GenericBlock.js.map +1 -0
- package/esm/_internal/Lightbox2.js +2 -2
- package/esm/_internal/Lightbox2.js.map +1 -1
- package/esm/_internal/LinkPreview.js +22 -12
- package/esm/_internal/LinkPreview.js.map +1 -1
- package/esm/_internal/Popover2.js +21 -8
- package/esm/_internal/Popover2.js.map +1 -1
- package/esm/_internal/SelectMultiple.js +16 -4
- package/esm/_internal/SelectMultiple.js.map +1 -1
- package/esm/_internal/TextField.js.map +1 -1
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/alert-dialog.js +2 -2
- package/esm/_internal/autocomplete.js +2 -1
- package/esm/_internal/autocomplete.js.map +1 -1
- package/esm/_internal/button.js +2 -1
- package/esm/_internal/button.js.map +1 -1
- package/esm/_internal/comment-block.js +2 -1
- package/esm/_internal/comment-block.js.map +1 -1
- package/esm/_internal/date-picker.js +3 -2
- package/esm/_internal/date-picker.js.map +1 -1
- package/esm/_internal/dialog.js +2 -2
- package/esm/_internal/dropdown.js +2 -1
- package/esm/_internal/dropdown.js.map +1 -1
- package/esm/_internal/expansion-panel.js +1 -1
- package/esm/_internal/generic-block.js +12 -0
- package/esm/_internal/generic-block.js.map +1 -0
- package/esm/_internal/lightbox.js +3 -2
- package/esm/_internal/lightbox.js.map +1 -1
- package/esm/_internal/popover.js +2 -1
- package/esm/_internal/popover.js.map +1 -1
- package/esm/_internal/select.js +2 -1
- package/esm/_internal/select.js.map +1 -1
- package/esm/_internal/side-navigation.js +2 -1
- package/esm/_internal/side-navigation.js.map +1 -1
- package/esm/_internal/slideshow.js +2 -1
- package/esm/_internal/slideshow.js.map +1 -1
- package/esm/_internal/text-field.js +2 -1
- package/esm/_internal/text-field.js.map +1 -1
- package/esm/_internal/tooltip.js +2 -1
- package/esm/_internal/tooltip.js.map +1 -1
- package/esm/_internal/type.js.map +1 -1
- package/esm/_internal/useFocusTrap.js +62 -78
- package/esm/_internal/useFocusTrap.js.map +1 -1
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/autocomplete/Autocomplete.tsx +4 -4
- package/src/components/button/Button.stories.tsx +1 -0
- package/src/components/button/ButtonRoot.tsx +4 -4
- package/src/components/checkbox/Checkbox.tsx +2 -1
- package/src/components/checkbox/__snapshots__/Checkbox.test.tsx.snap +4 -0
- package/src/components/date-picker/DatePickerField.tsx +15 -16
- package/src/components/date-picker/types.ts +2 -2
- package/src/components/dialog/Dialog.stories.tsx +57 -13
- package/src/components/dialog/Dialog.tsx +3 -3
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +82 -14
- package/src/components/dropdown/Dropdown.tsx +4 -3
- package/src/components/generic-block/GenericBlock.stories.tsx +149 -0
- package/src/components/generic-block/GenericBlock.test.tsx +28 -0
- package/src/components/generic-block/GenericBlock.tsx +120 -0
- package/src/components/generic-block/__snapshots__/GenericBlock.test.tsx.snap +92 -0
- package/src/components/generic-block/index.ts +1 -0
- package/src/components/lightbox/Lightbox.tsx +1 -1
- package/src/components/link-preview/LinkPreview.test.tsx +50 -55
- package/src/components/link-preview/LinkPreview.tsx +43 -16
- package/src/components/popover/Popover.tsx +20 -4
- package/src/components/select/Select.stories.tsx +2 -0
- package/src/components/select/Select.tsx +11 -1
- package/src/components/select/SelectMultiple.stories.tsx +2 -0
- package/src/components/select/SelectMultiple.tsx +11 -1
- package/src/components/select/constants.ts +2 -0
- package/src/components/table/__snapshots__/Table.test.tsx.snap +5 -0
- package/src/components/text-field/TextField.tsx +4 -4
- package/src/components/thumbnail/Thumbnail.tsx +2 -2
- package/src/hooks/useCallbackOnEscape.ts +21 -13
- package/src/hooks/useFocusTrap.ts +68 -51
- package/src/index.ts +1 -0
- package/src/stories/generated/GenericBlock/Demos.stories.tsx +6 -0
- package/src/utils/focus/getFirstAndLastFocusable.test.ts +6 -0
- package/src/utils/focus/getFirstAndLastFocusable.ts +2 -2
- package/src/utils/makeListenerTowerContext.ts +32 -0
- package/src/utils/type.ts +3 -0
- package/types.d.ts +70 -16
- package/src/components/link-preview/__snapshots__/LinkPreview.test.tsx.snap +0 -51
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { DOCUMENT } from '@lumx/react/constants';
|
|
2
2
|
import { Callback, onEscapePressed } from '@lumx/react/utils';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
|
+
import { Listener, makeListenerTowerContext } from '@lumx/react/utils/makeListenerTowerContext';
|
|
5
|
+
|
|
6
|
+
const LISTENERS = makeListenerTowerContext();
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Register a global listener on 'Escape' key pressed.
|
|
10
|
+
*
|
|
11
|
+
* If multiple listener are registered, only the last one is maintained. When a listener is unregistered, the previous
|
|
12
|
+
* one gets activated again.
|
|
7
13
|
*
|
|
8
14
|
* @param callback Callback
|
|
9
15
|
* @param closeOnEscape Disables the hook when false
|
|
10
|
-
* @param rootElement Element on which to listen the escape key
|
|
11
16
|
*/
|
|
12
|
-
export function useCallbackOnEscape(
|
|
13
|
-
callback: Callback | undefined,
|
|
14
|
-
closeOnEscape = true,
|
|
15
|
-
rootElement = DOCUMENT?.body,
|
|
16
|
-
) {
|
|
17
|
+
export function useCallbackOnEscape(callback: Callback | undefined, closeOnEscape = true) {
|
|
17
18
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return () => rootElement.removeEventListener('keydown', onKeyDown);
|
|
19
|
+
const rootElement = DOCUMENT?.body;
|
|
20
|
+
if (!closeOnEscape || !callback || !rootElement) {
|
|
21
|
+
return undefined;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const onKeyDown = onEscapePressed(callback);
|
|
24
|
+
|
|
25
|
+
const listener: Listener = {
|
|
26
|
+
enable: () => rootElement.addEventListener('keydown', onKeyDown),
|
|
27
|
+
disable: () => rootElement.removeEventListener('keydown', onKeyDown),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
LISTENERS.register(listener);
|
|
31
|
+
return () => LISTENERS.unregister(listener);
|
|
32
|
+
}, [callback, closeOnEscape]);
|
|
25
33
|
}
|
|
@@ -2,67 +2,84 @@ import { useEffect } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { DOCUMENT } from '@lumx/react/constants';
|
|
4
4
|
import { getFirstAndLastFocusable } from '@lumx/react/utils/focus/getFirstAndLastFocusable';
|
|
5
|
+
import { Falsy } from '@lumx/react/utils';
|
|
6
|
+
import { Listener, makeListenerTowerContext } from '@lumx/react/utils/makeListenerTowerContext';
|
|
7
|
+
|
|
8
|
+
const FOCUS_TRAPS = makeListenerTowerContext();
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
11
|
+
* Trap 'Tab' focus switch inside the `focusZoneElement`.
|
|
12
|
+
*
|
|
13
|
+
* If multiple focus trap are activated, only the last one is maintained and when a focus trap closes, the previous one
|
|
14
|
+
* gets activated again.
|
|
10
15
|
*
|
|
11
16
|
* @param focusZoneElement The element in which to trap the focus.
|
|
12
|
-
* @param focusElement The element to focus when the focus trap is activated
|
|
13
|
-
*
|
|
17
|
+
* @param focusElement The element to focus when the focus trap is activated (otherwise the first focusable element
|
|
18
|
+
* will be focused).
|
|
14
19
|
*/
|
|
15
|
-
export function useFocusTrap(
|
|
16
|
-
focusZoneElement: HTMLElement | null,
|
|
17
|
-
focusElement?: HTMLElement | null,
|
|
18
|
-
rootElement = DOCUMENT?.body,
|
|
19
|
-
): void {
|
|
20
|
+
export function useFocusTrap(focusZoneElement: HTMLElement | Falsy, focusElement?: HTMLElement | null): void {
|
|
20
21
|
useEffect(() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
// Body element can be undefined in SSR context.
|
|
23
|
+
const rootElement = DOCUMENT?.body;
|
|
24
|
+
|
|
25
|
+
if (!rootElement || !focusZoneElement) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Trap 'Tab' key down focus switch into the focus zone.
|
|
30
|
+
const trapTabFocusInFocusZone = (evt: KeyboardEvent) => {
|
|
31
|
+
const { key } = evt;
|
|
32
|
+
if (key !== 'Tab') {
|
|
33
|
+
return;
|
|
25
34
|
}
|
|
35
|
+
const focusable = getFirstAndLastFocusable(focusZoneElement);
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const focusable = getFirstAndLastFocusable(focusZoneElement);
|
|
37
|
+
// Prevent focus switch if no focusable available.
|
|
38
|
+
if (!focusable.first) {
|
|
39
|
+
evt.preventDefault();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
if (
|
|
44
|
+
// No previous focus
|
|
45
|
+
!document.activeElement ||
|
|
46
|
+
// Previous focus is at the end of the focus zone.
|
|
47
|
+
(!evt.shiftKey && document.activeElement === focusable.last) ||
|
|
48
|
+
// Previous focus is outside the focus zone
|
|
49
|
+
!focusZoneElement.contains(document.activeElement)
|
|
50
|
+
) {
|
|
51
|
+
focusable.first.focus();
|
|
52
|
+
evt.preventDefault();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
56
|
+
if (
|
|
57
|
+
// Focus order reversed
|
|
58
|
+
evt.shiftKey &&
|
|
59
|
+
// Previous focus is at the start of the focus zone.
|
|
60
|
+
document.activeElement === focusable.first
|
|
61
|
+
) {
|
|
62
|
+
focusable.last.focus();
|
|
63
|
+
evt.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
52
66
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
const focusTrap: Listener = {
|
|
68
|
+
enable: () => rootElement.addEventListener('keydown', trapTabFocusInFocusZone),
|
|
69
|
+
disable: () => rootElement.removeEventListener('keydown', trapTabFocusInFocusZone),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// SETUP:
|
|
73
|
+
if (focusElement && focusZoneElement.contains(focusElement)) {
|
|
74
|
+
// Focus the given element.
|
|
75
|
+
focusElement.focus();
|
|
76
|
+
} else {
|
|
77
|
+
// Focus the first focusable element in the zone.
|
|
78
|
+
getFirstAndLastFocusable(focusZoneElement).first?.focus();
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
FOCUS_TRAPS.register(focusTrap);
|
|
81
|
+
|
|
82
|
+
// TEARDOWN:
|
|
83
|
+
return () => FOCUS_TRAPS.unregister(focusTrap);
|
|
84
|
+
}, [focusElement, focusZoneElement]);
|
|
68
85
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './components/dropdown';
|
|
|
15
15
|
export * from './components/expansion-panel';
|
|
16
16
|
export * from './components/flag';
|
|
17
17
|
export * from './components/flex-box';
|
|
18
|
+
export * from './components/generic-block';
|
|
18
19
|
export * from './components/grid';
|
|
19
20
|
export * from './components/icon';
|
|
20
21
|
export * from './components/image-block';
|
|
@@ -124,5 +124,11 @@ describe(getFirstAndLastFocusable.name, () => {
|
|
|
124
124
|
const focusable = getFirstAndLastFocusable(element);
|
|
125
125
|
expect(focusable.first).toMatchInlineSnapshot(`<button />`);
|
|
126
126
|
});
|
|
127
|
+
|
|
128
|
+
it('should skip hidden input', () => {
|
|
129
|
+
const element = htmlToElement(`<div><input hidden /><button /></div>`);
|
|
130
|
+
const focusable = getFirstAndLastFocusable(element);
|
|
131
|
+
expect(focusable.first).toMatchInlineSnapshot(`<button />`);
|
|
132
|
+
});
|
|
127
133
|
});
|
|
128
134
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** CSS selector listing all tabbable elements. */
|
|
2
|
-
const TABBABLE_ELEMENTS_SELECTOR = `a[href], button, textarea, input:not([type="hidden"]), [tabindex]`;
|
|
2
|
+
const TABBABLE_ELEMENTS_SELECTOR = `a[href], button, textarea, input:not([type="hidden"]):not([hidden]), [tabindex]`;
|
|
3
3
|
|
|
4
4
|
/** CSS selector matching element that are disabled (should not receive focus). */
|
|
5
|
-
const DISABLED_SELECTOR = `[tabindex="-1"], [disabled]:not([disabled="false"]), [aria-disabled]:not([aria-disabled="false"])`;
|
|
5
|
+
const DISABLED_SELECTOR = `[hidden], [tabindex="-1"], [disabled]:not([disabled="false"]), [aria-disabled]:not([aria-disabled="false"])`;
|
|
6
6
|
|
|
7
7
|
const isNotDisabled = (element: HTMLElement) => !element.matches(DISABLED_SELECTOR);
|
|
8
8
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import last from 'lodash/last';
|
|
2
|
+
import pull from 'lodash/pull';
|
|
3
|
+
|
|
4
|
+
export type Listener = { enable(): void; disable(): void };
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Keep track of listeners, only the last registered listener gets activated at any point (previously registered
|
|
8
|
+
* listener are disabled).
|
|
9
|
+
* When a listener gets unregistered, the previously registered listener gets enabled again.
|
|
10
|
+
*/
|
|
11
|
+
export function makeListenerTowerContext() {
|
|
12
|
+
const LISTENERS: Listener[] = [];
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
register(listener: Listener) {
|
|
16
|
+
// Disable previous listener.
|
|
17
|
+
last(LISTENERS)?.disable();
|
|
18
|
+
// Keep track of current listener.
|
|
19
|
+
LISTENERS.push(listener);
|
|
20
|
+
// Enable current listener.
|
|
21
|
+
listener.enable();
|
|
22
|
+
},
|
|
23
|
+
unregister(listener: Listener) {
|
|
24
|
+
// Disable current listener.
|
|
25
|
+
listener.disable();
|
|
26
|
+
// Remove current listener.
|
|
27
|
+
pull(LISTENERS, listener);
|
|
28
|
+
// Enable previous listener.
|
|
29
|
+
last(LISTENERS)?.enable();
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
package/src/utils/type.ts
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v5.6.0
|
|
2
2
|
|
|
3
|
-
/// <reference types="
|
|
3
|
+
/// <reference types="cheerio" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="prop-types" />
|
|
6
|
+
|
|
7
|
+
import * as CSS from 'csstype';
|
|
8
|
+
import * as PropTypes from 'prop-types';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { AriaAttributes, ButtonHTMLAttributes, CSSProperties, DetailedHTMLProps, ImgHTMLAttributes, InputHTMLAttributes, Key, KeyboardEventHandler, MouseEventHandler, ReactElement, ReactNode, Ref, RefObject, SetStateAction, SyntheticEvent } from 'react';
|
|
4
11
|
|
|
5
12
|
/** Get types of the values of a record. */
|
|
6
13
|
export declare type ValueOf<T extends Record<any, any>> = T[keyof T];
|
|
@@ -18,6 +25,8 @@ export declare type Comp<P, T = HTMLElement> = {
|
|
|
18
25
|
/** Component base class name. */
|
|
19
26
|
className?: string;
|
|
20
27
|
};
|
|
28
|
+
/** Union type of all heading elements */
|
|
29
|
+
export declare type HeadingElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
21
30
|
/**
|
|
22
31
|
* Define a generic props types.
|
|
23
32
|
*/
|
|
@@ -32,6 +41,11 @@ export interface GenericProps {
|
|
|
32
41
|
* Callback function type alias (use for readability)
|
|
33
42
|
*/
|
|
34
43
|
export declare type Callback = () => void;
|
|
44
|
+
/**
|
|
45
|
+
* JS falsy values.
|
|
46
|
+
* (excluding `NaN` as it can't be distinguished from `number`)
|
|
47
|
+
*/
|
|
48
|
+
export declare type Falsy = false | undefined | null | 0 | "";
|
|
35
49
|
/**
|
|
36
50
|
* Alignments.
|
|
37
51
|
*/
|
|
@@ -259,7 +273,7 @@ export interface AutocompleteProps extends GenericProps {
|
|
|
259
273
|
* Reference to the <input> or <textarea> element.
|
|
260
274
|
* @see {@link TextFieldProps#inputRef}
|
|
261
275
|
*/
|
|
262
|
-
inputRef?:
|
|
276
|
+
inputRef?: TextFieldProps["inputRef"];
|
|
263
277
|
/**
|
|
264
278
|
* The offset that will be applied to the Dropdown position.
|
|
265
279
|
* @see {@link DropdownProps#offset}
|
|
@@ -476,9 +490,7 @@ export declare type HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTM
|
|
|
476
490
|
* Button size definition.
|
|
477
491
|
*/
|
|
478
492
|
export declare type ButtonSize = Extract<Size, "s" | "m">;
|
|
479
|
-
export interface BaseButtonProps extends GenericProps {
|
|
480
|
-
/** ARIA button label. */
|
|
481
|
-
["aria-label"]?: string;
|
|
493
|
+
export interface BaseButtonProps extends GenericProps, Pick<AriaAttributes, "aria-expanded" | "aria-haspopup" | "aria-pressed" | "aria-label"> {
|
|
482
494
|
/** Color variant. */
|
|
483
495
|
color?: Color;
|
|
484
496
|
/** Emphasis variant. */
|
|
@@ -743,7 +755,7 @@ export interface DatePickerProps extends GenericProps {
|
|
|
743
755
|
/** Props to pass to the previous month button (minus those already set by the DatePickerControlled props). */
|
|
744
756
|
previousButtonProps: Pick<IconButtonProps, "label"> & Omit<IconButtonProps, "label" | "onClick" | "icon" | "emphasis">;
|
|
745
757
|
/** Reference to the <button> element corresponding to the current date or the selected date. */
|
|
746
|
-
todayOrSelectedDateRef?:
|
|
758
|
+
todayOrSelectedDateRef?: Ref<HTMLButtonElement>;
|
|
747
759
|
/** Currently selected date. */
|
|
748
760
|
value: Date | undefined;
|
|
749
761
|
/** On change callback. */
|
|
@@ -828,7 +840,7 @@ export interface DialogProps extends GenericProps {
|
|
|
828
840
|
/** Reference to the parent element that triggered modal opening (will get back focus on close). */
|
|
829
841
|
parentElement?: RefObject<HTMLElement>;
|
|
830
842
|
/** Reference to the dialog content element. */
|
|
831
|
-
contentRef?:
|
|
843
|
+
contentRef?: Ref<HTMLDivElement>;
|
|
832
844
|
/** Reference to the of the element that should get the focus when the dialogs opens. By default, the first child will take focus. */
|
|
833
845
|
focusElement?: RefObject<HTMLElement>;
|
|
834
846
|
/** Whether to keep the dialog open on clickaway or escape press. */
|
|
@@ -951,6 +963,8 @@ export interface PopoverProps extends GenericProps {
|
|
|
951
963
|
isOpen: boolean;
|
|
952
964
|
/** Offset placement relative to anchor. */
|
|
953
965
|
offset?: Offset;
|
|
966
|
+
/** Reference to the parent element that triggered the popover (will get back focus on close or else fallback on the anchor element). */
|
|
967
|
+
parentElement?: RefObject<HTMLElement>;
|
|
954
968
|
/** Placement relative to anchor. */
|
|
955
969
|
placement?: Placement;
|
|
956
970
|
/** Whether the popover should be rendered into a DOM node that exists outside the DOM hierarchy of the parent component. */
|
|
@@ -972,10 +986,11 @@ export declare const Popover: Comp<PopoverProps, HTMLDivElement>;
|
|
|
972
986
|
* Defines the props of the component.
|
|
973
987
|
*/
|
|
974
988
|
export interface DropdownProps extends GenericProps {
|
|
975
|
-
/**
|
|
989
|
+
/**
|
|
990
|
+
* Reference to the element around which the dropdown is placed.
|
|
976
991
|
* @see {@link PopoverProps#anchorRef}
|
|
977
992
|
*/
|
|
978
|
-
anchorRef:
|
|
993
|
+
anchorRef: PopoverProps["anchorRef"];
|
|
979
994
|
/** Dropdown content. */
|
|
980
995
|
children: React.ReactNode;
|
|
981
996
|
/**
|
|
@@ -1124,6 +1139,41 @@ export interface FlexBoxProps extends GenericProps {
|
|
|
1124
1139
|
* @return React element.
|
|
1125
1140
|
*/
|
|
1126
1141
|
export declare const FlexBox: Comp<FlexBoxProps, HTMLDivElement>;
|
|
1142
|
+
export interface GenericBlockProps extends FlexBoxProps {
|
|
1143
|
+
/** Component to use as visual element. */
|
|
1144
|
+
figure?: ReactNode;
|
|
1145
|
+
/** Actions to set after the main content. */
|
|
1146
|
+
actions?: ReactNode;
|
|
1147
|
+
/** Main content to display */
|
|
1148
|
+
children: ReactNode;
|
|
1149
|
+
/** Orientation of the 3 sections */
|
|
1150
|
+
orientation?: FlexBoxProps["orientation"];
|
|
1151
|
+
/** Horizontal alignment. */
|
|
1152
|
+
hAlign?: FlexBoxProps["hAlign"];
|
|
1153
|
+
/** Vertical alignment. */
|
|
1154
|
+
vAlign?: FlexBoxProps["vAlign"];
|
|
1155
|
+
/**
|
|
1156
|
+
* The props to forward to the content.
|
|
1157
|
+
* By default, the content will have the same alignment as wrapper.
|
|
1158
|
+
*/
|
|
1159
|
+
contentProps?: Omit<FlexBoxProps, "children">;
|
|
1160
|
+
/** props to forward to the actions element. */
|
|
1161
|
+
actionsProps?: Omit<FlexBoxProps, "children">;
|
|
1162
|
+
/** props to forward to the figure element. */
|
|
1163
|
+
figureProps?: Omit<FlexBoxProps, "children">;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* The GenericBlock is a layout component made of 3 sections that can be
|
|
1167
|
+
* displayed either horizontally of vertically with the same gap between each section.
|
|
1168
|
+
*
|
|
1169
|
+
* The sections are:
|
|
1170
|
+
* * (Optional) `Figure` => A visual element to display before the main content.
|
|
1171
|
+
* * (Required) `Content` => The main content displayed
|
|
1172
|
+
* * (Optional) `Actions` => One or more actions to set after the element.
|
|
1173
|
+
*
|
|
1174
|
+
* @see https://www.figma.com/file/lzzrQmsfaXRaOyRfoEogPZ/DS%3A-playground?node-id=1%3A4076
|
|
1175
|
+
*/
|
|
1176
|
+
export declare const GenericBlock: Comp<GenericBlockProps, HTMLDivElement>;
|
|
1127
1177
|
export declare type GridGutterSize = Extract<Size, "regular" | "big" | "huge">;
|
|
1128
1178
|
/**
|
|
1129
1179
|
* Defines the props of the component.
|
|
@@ -1235,7 +1285,7 @@ export interface ThumbnailProps extends GenericProps {
|
|
|
1235
1285
|
/** Image aspect ratio. */
|
|
1236
1286
|
aspectRatio?: AspectRatio;
|
|
1237
1287
|
/** Badge. */
|
|
1238
|
-
badge?: ReactElement;
|
|
1288
|
+
badge?: ReactElement | Falsy;
|
|
1239
1289
|
/** Image cross origin resource policy. */
|
|
1240
1290
|
crossOrigin?: ImgHTMLProps["crossOrigin"];
|
|
1241
1291
|
/** Fallback icon (SVG path) or react node when image fails to load. */
|
|
@@ -1433,12 +1483,12 @@ export declare const Link: Comp<LinkProps, HTMLAnchorElement | HTMLButtonElement
|
|
|
1433
1483
|
* Defines the props of the component.
|
|
1434
1484
|
*/
|
|
1435
1485
|
export interface LinkPreviewProps extends GenericProps {
|
|
1436
|
-
/** Description
|
|
1437
|
-
description?: string
|
|
1438
|
-
__html: string;
|
|
1439
|
-
};
|
|
1486
|
+
/** Description. */
|
|
1487
|
+
description?: string;
|
|
1440
1488
|
/** Link URL. */
|
|
1441
1489
|
link: string;
|
|
1490
|
+
/** Custom react component for the link (can be used to inject react router Link). */
|
|
1491
|
+
linkAs?: "a" | any;
|
|
1442
1492
|
/** Props to pass to the link (minus those already set by the LinkPreview props). */
|
|
1443
1493
|
linkProps?: Omit<LinkProps, "color" | "colorVariant" | "href" | "target">;
|
|
1444
1494
|
/** Size variant. */
|
|
@@ -1449,6 +1499,8 @@ export interface LinkPreviewProps extends GenericProps {
|
|
|
1449
1499
|
thumbnailProps?: ThumbnailProps;
|
|
1450
1500
|
/** Title. */
|
|
1451
1501
|
title?: string;
|
|
1502
|
+
/** Customize the title heading tag. */
|
|
1503
|
+
titleHeading?: HeadingElement;
|
|
1452
1504
|
}
|
|
1453
1505
|
/**
|
|
1454
1506
|
* LinkPreview component.
|
|
@@ -1858,6 +1910,8 @@ export interface CoreSelectProps extends GenericProps {
|
|
|
1858
1910
|
helper?: string;
|
|
1859
1911
|
/** Whether the select should close on click. */
|
|
1860
1912
|
closeOnClick?: boolean;
|
|
1913
|
+
/** Icon (SVG path). */
|
|
1914
|
+
icon?: string;
|
|
1861
1915
|
/** Whether the component is disabled or not. */
|
|
1862
1916
|
isDisabled?: boolean;
|
|
1863
1917
|
/** Whether the component is required or not. */
|
|
@@ -2512,7 +2566,7 @@ export interface TextFieldProps extends GenericProps {
|
|
|
2512
2566
|
/** Native input id property (generated if not provided to link the label element). */
|
|
2513
2567
|
id?: string;
|
|
2514
2568
|
/** Reference to the <input> or <textarea> element. */
|
|
2515
|
-
inputRef?:
|
|
2569
|
+
inputRef?: Ref<HTMLInputElement | HTMLTextAreaElement>;
|
|
2516
2570
|
/** Whether the component is disabled or not. */
|
|
2517
2571
|
isDisabled?: boolean;
|
|
2518
2572
|
/** Whether the component is required or not. */
|
|
@@ -2532,7 +2586,7 @@ export interface TextFieldProps extends GenericProps {
|
|
|
2532
2586
|
/** Placeholder text. */
|
|
2533
2587
|
placeholder?: string;
|
|
2534
2588
|
/** Reference to the wrapper. */
|
|
2535
|
-
textFieldRef?:
|
|
2589
|
+
textFieldRef?: Ref<HTMLDivElement>;
|
|
2536
2590
|
/** Theme adapting the component to light or dark background. */
|
|
2537
2591
|
theme?: Theme;
|
|
2538
2592
|
/** Value. */
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<LinkPreview> Snapshots and structure should render correctly 1`] = `
|
|
4
|
-
<div
|
|
5
|
-
className="lumx-link-preview lumx-link-preview--size-regular lumx-link-preview--theme-light"
|
|
6
|
-
>
|
|
7
|
-
<div
|
|
8
|
-
className="lumx-link-preview__wrapper"
|
|
9
|
-
>
|
|
10
|
-
<div
|
|
11
|
-
className="lumx-link-preview__container"
|
|
12
|
-
>
|
|
13
|
-
<div
|
|
14
|
-
className="lumx-link-preview__link"
|
|
15
|
-
>
|
|
16
|
-
<Link
|
|
17
|
-
className="lumx-link-preview__link"
|
|
18
|
-
color="primary"
|
|
19
|
-
colorVariant="N"
|
|
20
|
-
target="_blank"
|
|
21
|
-
/>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
exports[`<LinkPreview> Snapshots and structure should render correctly 2`] = `
|
|
29
|
-
<div
|
|
30
|
-
className="lumx-link-preview lumx-link-preview--size-regular lumx-link-preview--theme-light"
|
|
31
|
-
>
|
|
32
|
-
<div
|
|
33
|
-
className="lumx-link-preview__wrapper"
|
|
34
|
-
>
|
|
35
|
-
<div
|
|
36
|
-
className="lumx-link-preview__container"
|
|
37
|
-
>
|
|
38
|
-
<div
|
|
39
|
-
className="lumx-link-preview__link"
|
|
40
|
-
>
|
|
41
|
-
<Link
|
|
42
|
-
className="lumx-link-preview__link"
|
|
43
|
-
color="primary"
|
|
44
|
-
colorVariant="N"
|
|
45
|
-
target="_blank"
|
|
46
|
-
/>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
`;
|