carbon-react 111.9.0 → 111.10.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.
- package/esm/__internal__/focus-trap/focus-trap-utils.js +21 -1
- package/esm/__internal__/focus-trap/focus-trap.component.js +4 -0
- package/esm/components/grouped-character/grouped-character.component.d.ts +30 -0
- package/esm/components/grouped-character/grouped-character.component.js +544 -41
- package/esm/components/grouped-character/grouped-character.utils.d.ts +2 -0
- package/esm/components/grouped-character/index.d.ts +2 -1
- package/esm/components/note/__internal__/status-icon/index.d.ts +1 -0
- package/esm/components/note/__internal__/status-icon/index.js +1 -0
- package/esm/components/note/__internal__/status-icon/status-icon.component.d.ts +9 -0
- package/esm/components/note/__internal__/{status-with-tooltip/status.component.js → status-icon/status-icon.component.js} +4 -6
- package/esm/components/note/__internal__/status-icon/status-icon.style.d.ts +2 -0
- package/esm/components/note/__internal__/{status-with-tooltip/status.style.js → status-icon/status-icon.style.js} +0 -0
- package/esm/components/note/index.d.ts +2 -2
- package/esm/components/note/note.component.d.ts +28 -0
- package/esm/components/note/note.component.js +188 -46
- package/esm/components/note/note.style.d.ts +13 -0
- package/esm/components/note/note.style.js +0 -5
- package/esm/components/numeral-date/index.d.ts +2 -1
- package/esm/components/numeral-date/numeral-date.component.d.ts +81 -0
- package/esm/components/numeral-date/numeral-date.component.js +237 -128
- package/esm/components/numeral-date/numeral-date.style.d.ts +11 -0
- package/esm/components/sidebar/sidebar.component.d.ts +2 -2
- package/esm/components/sidebar/sidebar.component.js +106 -2
- package/esm/components/sidebar/sidebar.style.d.ts +1 -6
- package/esm/components/sidebar/sidebar.style.js +7 -2
- package/esm/components/text-editor/__internal__/decorators/index.d.ts +3 -0
- package/esm/components/text-editor/__internal__/decorators/link-decorator.d.ts +7 -0
- package/esm/components/text-editor/__internal__/utils/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/utils/utils.d.ts +28 -0
- package/esm/components/text-editor/text-editor.component.d.ts +8 -0
- package/esm/components/text-editor/text-editor.style.d.ts +3 -0
- package/esm/style/utils/width.d.ts +1 -1
- package/lib/__internal__/focus-trap/focus-trap-utils.js +21 -1
- package/lib/__internal__/focus-trap/focus-trap.component.js +4 -0
- package/lib/components/grouped-character/grouped-character.component.d.ts +30 -0
- package/lib/components/grouped-character/grouped-character.component.js +545 -45
- package/lib/components/grouped-character/grouped-character.utils.d.ts +2 -0
- package/lib/components/grouped-character/index.d.ts +2 -1
- package/lib/components/note/__internal__/status-icon/index.d.ts +1 -0
- package/lib/components/note/__internal__/{status-with-tooltip → status-icon}/index.js +2 -2
- package/lib/components/note/__internal__/{status-with-tooltip → status-icon}/package.json +1 -1
- package/lib/components/note/__internal__/status-icon/status-icon.component.d.ts +9 -0
- package/lib/components/note/__internal__/{status-with-tooltip/status.component.js → status-icon/status-icon.component.js} +5 -7
- package/lib/components/note/__internal__/status-icon/status-icon.style.d.ts +2 -0
- package/lib/components/note/__internal__/{status-with-tooltip/status.style.js → status-icon/status-icon.style.js} +0 -0
- package/lib/components/note/index.d.ts +2 -2
- package/lib/components/note/note.component.d.ts +28 -0
- package/lib/components/note/note.component.js +195 -55
- package/lib/components/note/note.style.d.ts +13 -0
- package/lib/components/note/note.style.js +0 -6
- package/lib/components/numeral-date/index.d.ts +2 -1
- package/lib/components/numeral-date/numeral-date.component.d.ts +81 -0
- package/lib/components/numeral-date/numeral-date.component.js +237 -128
- package/lib/components/numeral-date/numeral-date.style.d.ts +11 -0
- package/lib/components/sidebar/sidebar.component.d.ts +2 -2
- package/lib/components/sidebar/sidebar.component.js +106 -2
- package/lib/components/sidebar/sidebar.style.d.ts +1 -6
- package/lib/components/sidebar/sidebar.style.js +8 -2
- package/lib/components/text-editor/__internal__/decorators/index.d.ts +3 -0
- package/lib/components/text-editor/__internal__/decorators/link-decorator.d.ts +7 -0
- package/lib/components/text-editor/__internal__/utils/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/utils/utils.d.ts +28 -0
- package/lib/components/text-editor/text-editor.component.d.ts +8 -0
- package/lib/components/text-editor/text-editor.style.d.ts +3 -0
- package/lib/style/utils/width.d.ts +1 -1
- package/package.json +3 -2
- package/esm/components/grouped-character/grouped-character.d.ts +0 -23
- package/esm/components/note/__internal__/status-with-tooltip/index.js +0 -1
- package/esm/components/note/note.d.ts +0 -30
- package/esm/components/numeral-date/numeral-date.d.ts +0 -97
- package/lib/components/grouped-character/grouped-character.d.ts +0 -23
- package/lib/components/note/note.d.ts +0 -30
- package/lib/components/numeral-date/numeral-date.d.ts +0 -97
|
@@ -41,6 +41,19 @@ const getRadioElementToFocus = (groupName, shiftKey) => {
|
|
|
41
41
|
|
|
42
42
|
const getNextElement = (element, focusableElements, shiftKey) => {
|
|
43
43
|
const currentIndex = focusableElements.indexOf(element);
|
|
44
|
+
|
|
45
|
+
if (currentIndex === -1) {
|
|
46
|
+
// we're not currently on a focusable element - most likely because the focusableElements come from a different focus trap!
|
|
47
|
+
// So we need to leave focus where it is.
|
|
48
|
+
// The exception is when the focus is on the document body - perhaps because the previously-focused element was dynamically removed.
|
|
49
|
+
// In that case focus the first element.
|
|
50
|
+
if (element === document.body) {
|
|
51
|
+
return focusableElements[0];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return element;
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
const increment = shiftKey ? -1 : 1;
|
|
45
58
|
let nextIndex = currentIndex;
|
|
46
59
|
let foundElement;
|
|
@@ -61,7 +74,14 @@ const getNextElement = (element, focusableElements, shiftKey) => {
|
|
|
61
74
|
if (nextElement === element) {
|
|
62
75
|
// guard in case there is only one focusable element (or only a single radio group) in the trap.
|
|
63
76
|
// If this happens we don't want to freeze the browser by looping forever, and it's OK to just focus
|
|
64
|
-
// the same element we're already on
|
|
77
|
+
// the same element we're already on.
|
|
78
|
+
// There is an exception though: if we're in a single radio group, we need to ensure we focus on
|
|
79
|
+
// the correct one. This may not be "element" if it's not currently focused (due to the focus actually
|
|
80
|
+
// being on a wrapper element and this function being called with the first/last element as "element").
|
|
81
|
+
if (isRadio(element) && document.activeElement !== element) {
|
|
82
|
+
return getRadioElementToFocus(element.getAttribute("name"), shiftKey);
|
|
83
|
+
}
|
|
84
|
+
|
|
65
85
|
return element;
|
|
66
86
|
}
|
|
67
87
|
|
|
@@ -94,6 +94,10 @@ const FocusTrap = ({
|
|
|
94
94
|
elementToFocus = getNextElement(activeElement, focusableElements, ev.shiftKey);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
setElementFocus(elementToFocus);
|
|
98
|
+
ev.preventDefault();
|
|
99
|
+
} else if (activeElement === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
|
|
100
|
+
const elementToFocus = getNextElement(lastElement, focusableElements, ev.shiftKey);
|
|
97
101
|
setElementFocus(elementToFocus);
|
|
98
102
|
ev.preventDefault();
|
|
99
103
|
} else {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextboxProps } from "../textbox";
|
|
3
|
+
declare type EventValue = {
|
|
4
|
+
formattedValue: string;
|
|
5
|
+
rawValue: string;
|
|
6
|
+
};
|
|
7
|
+
declare type CustomTarget = {
|
|
8
|
+
name?: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
value: EventValue;
|
|
11
|
+
};
|
|
12
|
+
export interface CustomEvent extends Omit<React.ChangeEvent<HTMLInputElement>, "target"> {
|
|
13
|
+
target: CustomTarget;
|
|
14
|
+
}
|
|
15
|
+
export interface GroupedCharacterProps extends Omit<TextboxProps, "onChange" | "onBlur"> {
|
|
16
|
+
/** Default input value if component is meant to be used as an uncontrolled component */
|
|
17
|
+
defaultValue?: string;
|
|
18
|
+
/** pattern by which input value should be grouped */
|
|
19
|
+
groups: number[];
|
|
20
|
+
/** Handler for blur event */
|
|
21
|
+
onBlur?: (ev: CustomEvent) => void;
|
|
22
|
+
/** Handler for change event if input is meant to be used as a controlled component */
|
|
23
|
+
onChange?: (ev: CustomEvent) => void;
|
|
24
|
+
/** character to be used as separator - has to be a 1 character string */
|
|
25
|
+
separator: string;
|
|
26
|
+
/** Input value if component is meant to be used as a controlled component */
|
|
27
|
+
value?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const GroupedCharacter: ({ defaultValue, groups, onBlur, onChange, separator: rawSeparator, value: externalValue, ...rest }: GroupedCharacterProps) => JSX.Element;
|
|
30
|
+
export default GroupedCharacter;
|