@dxc-technology/halstack-react 7.0.0 → 9.0.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/HalstackContext.js +98 -50
- package/accordion/Accordion.js +7 -13
- package/accordion/Accordion.stories.tsx +102 -13
- package/alert/Alert.stories.tsx +28 -0
- package/box/Box.js +1 -3
- package/box/Box.stories.tsx +15 -0
- package/button/Button.js +11 -13
- package/button/Button.stories.tsx +150 -8
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +16 -15
- package/checkbox/Checkbox.stories.tsx +131 -59
- package/checkbox/types.d.ts +4 -0
- package/chip/Chip.js +16 -22
- package/chip/Chip.stories.tsx +96 -9
- package/common/variables.js +286 -290
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +134 -237
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +494 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +51 -0
- package/dialog/Dialog.js +60 -73
- package/dialog/Dialog.stories.tsx +211 -159
- package/dialog/Dialog.test.js +301 -2
- package/dropdown/Dropdown.js +35 -35
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +17 -22
- package/dropdown/DropdownMenu.js +8 -18
- package/dropdown/DropdownMenuItem.js +4 -15
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +169 -222
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +12 -53
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +39 -63
- package/file-input/types.d.ts +17 -0
- package/footer/Footer.stories.tsx +91 -0
- package/header/Header.js +18 -20
- package/header/Header.stories.tsx +149 -6
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +60 -0
- package/main.d.ts +1 -1
- package/main.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
- package/{tabs-nav → nav-tabs}/Tab.js +35 -15
- package/number-input/NumberInput.test.js +5 -6
- package/package.json +7 -12
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +5 -11
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +17 -10
- package/progress-bar/ProgressBar.js +4 -4
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +48 -105
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +40 -63
- package/resultsetTable/types.d.ts +2 -2
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +43 -24
- package/select/Select.stories.tsx +494 -150
- package/select/Select.test.js +17 -22
- package/select/types.d.ts +2 -2
- package/sidenav/Sidenav.js +8 -10
- package/sidenav/Sidenav.stories.tsx +148 -46
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +9 -8
- package/slider/Slider.stories.tsx +57 -0
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +2 -2
- package/spinner/Spinner.stories.jsx +27 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +5 -4
- package/switch/Switch.stories.tsx +33 -0
- package/switch/types.d.ts +6 -1
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +1 -1
- package/tabs/Tab.js +3 -5
- package/tabs/Tabs.js +3 -3
- package/tabs/Tabs.stories.tsx +45 -5
- package/tag/Tag.stories.tsx +14 -1
- package/text-input/Suggestion.js +32 -5
- package/text-input/TextInput.js +7 -11
- package/text-input/TextInput.stories.tsx +92 -4
- package/text-input/TextInput.test.js +587 -634
- package/textarea/Textarea.stories.jsx +60 -1
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +139 -0
- package/wizard/Wizard.stories.tsx +20 -0
- package/common/RequiredComponent.js +0 -32
- /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/NavTabs.test.js +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.js +0 -0
|
@@ -4,12 +4,20 @@ import Title from "../../.storybook/components/Title";
|
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
6
6
|
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: "Textarea",
|
|
10
11
|
component: DxcTextarea,
|
|
11
12
|
};
|
|
12
13
|
|
|
14
|
+
const opinionatedTheme = {
|
|
15
|
+
textarea: {
|
|
16
|
+
fontColor: "#000000",
|
|
17
|
+
hoverBorderColor: "#a46ede",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
export const Chromatic = () => (
|
|
14
22
|
<>
|
|
15
23
|
<>
|
|
@@ -151,7 +159,58 @@ export const Chromatic = () => (
|
|
|
151
159
|
<ExampleContainer>
|
|
152
160
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
153
161
|
<DxcTextarea label="Xxlarge" margin="xxlarge" />
|
|
154
|
-
|
|
162
|
+
</ExampleContainer>
|
|
163
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
164
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
165
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
166
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
167
|
+
<DxcTextarea label="Hovered" helperText="Sample text" placeholder="Placeholder" />
|
|
168
|
+
</HalstackProvider>
|
|
169
|
+
</ExampleContainer>
|
|
170
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
171
|
+
<Title title="Focused" theme="light" level={4} />
|
|
172
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
173
|
+
<DxcTextarea label="Focused" helperText="Sample text" />
|
|
174
|
+
</HalstackProvider>
|
|
175
|
+
</ExampleContainer>
|
|
176
|
+
<ExampleContainer>
|
|
177
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
178
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
179
|
+
<DxcTextarea
|
|
180
|
+
label="Disabled"
|
|
181
|
+
optional
|
|
182
|
+
helperText="Sample text"
|
|
183
|
+
placeholder="Enter your text here..."
|
|
184
|
+
disabled
|
|
185
|
+
/>
|
|
186
|
+
</HalstackProvider>
|
|
187
|
+
</ExampleContainer>
|
|
188
|
+
<ExampleContainer>
|
|
189
|
+
<Title title="Disabled with value" theme="light" level={4} />
|
|
190
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
191
|
+
<DxcTextarea label="Disabled" helperText="Sample text" defaultValue="Example text" disabled />
|
|
192
|
+
</HalstackProvider>
|
|
193
|
+
</ExampleContainer>
|
|
194
|
+
<ExampleContainer>
|
|
195
|
+
<Title title="With error" theme="light" level={4} />
|
|
196
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
197
|
+
<DxcTextarea
|
|
198
|
+
label="Textarea with error"
|
|
199
|
+
helperText="Helper text"
|
|
200
|
+
placeholder="Enter your text here..."
|
|
201
|
+
error="Error message."
|
|
202
|
+
/>
|
|
203
|
+
</HalstackProvider>
|
|
204
|
+
</ExampleContainer>
|
|
205
|
+
<ExampleContainer>
|
|
206
|
+
<Title title="Grow manual" theme="light" level={4} />{" "}
|
|
207
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
208
|
+
<DxcTextarea
|
|
209
|
+
label="Manual vertical grow"
|
|
210
|
+
verticalGrow="manual"
|
|
211
|
+
defaultValue="Long textttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"
|
|
212
|
+
/>
|
|
213
|
+
</HalstackProvider>
|
|
155
214
|
</ExampleContainer>
|
|
156
215
|
</>
|
|
157
216
|
);
|
|
@@ -3,6 +3,7 @@ import { userEvent, within } from "@storybook/testing-library";
|
|
|
3
3
|
import DxcToggleGroup from "./ToggleGroup";
|
|
4
4
|
import Title from "../../.storybook/components/Title";
|
|
5
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "ToggleGroup",
|
|
@@ -89,6 +90,16 @@ const twoOptions = [
|
|
|
89
90
|
label: "Twitter",
|
|
90
91
|
},
|
|
91
92
|
];
|
|
93
|
+
|
|
94
|
+
const opinionatedTheme = {
|
|
95
|
+
toggleGroup: {
|
|
96
|
+
selectedBaseColor: "#5f249f",
|
|
97
|
+
selectedFontColor: "#ffffff",
|
|
98
|
+
unselectedBaseColor: "#e6e6e6",
|
|
99
|
+
unselectedFontColor: "#000000",
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
92
103
|
export const Chromatic = () => (
|
|
93
104
|
<>
|
|
94
105
|
<ExampleContainer>
|
|
@@ -154,6 +165,37 @@ export const Chromatic = () => (
|
|
|
154
165
|
<Title title="xxLarge" theme="light" level={4} />
|
|
155
166
|
<DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
|
|
156
167
|
</ExampleContainer>
|
|
168
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
169
|
+
<ExampleContainer>
|
|
170
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
171
|
+
<Title title="Selected" theme="light" level={4} />
|
|
172
|
+
<DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
|
|
173
|
+
</HalstackProvider>
|
|
174
|
+
</ExampleContainer>
|
|
175
|
+
<ExampleContainer>
|
|
176
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
177
|
+
<Title title="Icons & label toggle group" theme="light" level={4} />
|
|
178
|
+
<DxcToggleGroup label="Icons & label" options={optionsWithIconAndLabel} />
|
|
179
|
+
</HalstackProvider>
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
<ExampleContainer>
|
|
182
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
183
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
184
|
+
<DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
|
|
185
|
+
</HalstackProvider>
|
|
186
|
+
</ExampleContainer>
|
|
187
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
188
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
189
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
190
|
+
<DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
|
|
191
|
+
</HalstackProvider>
|
|
192
|
+
</ExampleContainer>
|
|
193
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
194
|
+
<Title title="Actived" theme="light" level={4} />
|
|
195
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
196
|
+
<DxcToggleGroup label="Actived" options={twoOptions} defaultValue={2} />
|
|
197
|
+
</HalstackProvider>
|
|
198
|
+
</ExampleContainer>
|
|
157
199
|
</>
|
|
158
200
|
);
|
|
159
201
|
const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Traps the focus inside the children of the component. It will focus the first focusable element when the component is mounted.
|
|
4
|
+
* When the focus is on the last focusable element and the user tries to focus the next element, it will focus the first element.
|
|
5
|
+
* When the focus is on the first focusable element and the user tries to focus the previous element, it will focus the last element.
|
|
6
|
+
* The focus can't be moved outside the children unless the children are removed from the DOM (for example, a Dialog, a Modal, etc).
|
|
7
|
+
* @param children: React.ReactNode
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const FocusLock: ({ children }: {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}) => JSX.Element;
|
|
13
|
+
export default FocusLock;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
var not = {
|
|
21
|
+
inert: ":not([inert]):not([inert] *)",
|
|
22
|
+
negTabIndex: ':not([tabindex^="-"])',
|
|
23
|
+
disabled: ":not(:disabled):not([aria-disabled='true'])"
|
|
24
|
+
};
|
|
25
|
+
var focusableQuery = ["a[href]".concat(not.inert).concat(not.negTabIndex), "area[href]".concat(not.inert).concat(not.negTabIndex), "input:not([type=\"hidden\"])".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "select".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "textarea".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "button".concat(not.inert).concat(not.negTabIndex).concat(not.disabled), "details".concat(not.inert, " > summary:first-of-type").concat(not.negTabIndex), "iframe".concat(not.inert).concat(not.negTabIndex), "audio[controls]".concat(not.inert).concat(not.negTabIndex), "video[controls]".concat(not.inert).concat(not.negTabIndex), "[contenteditable]".concat(not.inert).concat(not.negTabIndex), "[tabindex]".concat(not.inert).concat(not.negTabIndex).concat(not.disabled)].join(",");
|
|
26
|
+
|
|
27
|
+
var getFocusableElements = function getFocusableElements(container) {
|
|
28
|
+
return Array.prototype.slice.call(container.querySelectorAll(focusableQuery)).filter(function (element) {
|
|
29
|
+
return element.getAttribute("aria-hidden") !== "true" && window.getComputedStyle(element).display !== "none" && window.getComputedStyle(element).visibility !== "hidden";
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* This function will try to focus the element and return true if it was able to receive the focus.
|
|
34
|
+
* Even if the element is focusable (passes any of the conditions of our selector), there is the possibility
|
|
35
|
+
* that the element may not be focusable at all.
|
|
36
|
+
* @param element: HTMLElement
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var attempFocus = function attempFocus(element) {
|
|
42
|
+
element === null || element === void 0 ? void 0 : element.focus();
|
|
43
|
+
return document.activeElement === element;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* @param element: HTMLElement
|
|
47
|
+
* @returns boolean: true if element is contained inside a Radix Portal, false otherwise.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
var radixPortalContains = function radixPortalContains(activeElement) {
|
|
52
|
+
var radixPortals = document.querySelectorAll("[data-radix-portal]");
|
|
53
|
+
return Array.prototype.slice.call(radixPortals).some(function (portal) {
|
|
54
|
+
return portal.contains(activeElement);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Custom hook that returns an array of focusable elements inside a container.
|
|
59
|
+
* @param ref: React.MutableRefObject<HTMLDivElement>
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
var useFocusableElements = function useFocusableElements(ref) {
|
|
65
|
+
var _useState = (0, _react.useState)(),
|
|
66
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
67
|
+
focusableElements = _useState2[0],
|
|
68
|
+
setFocusableElements = _useState2[1];
|
|
69
|
+
|
|
70
|
+
(0, _react.useEffect)(function () {
|
|
71
|
+
if (ref.current != null) {
|
|
72
|
+
setFocusableElements(getFocusableElements(ref.current));
|
|
73
|
+
var observer = new MutationObserver(function () {
|
|
74
|
+
setFocusableElements(getFocusableElements(ref.current));
|
|
75
|
+
});
|
|
76
|
+
observer.observe(ref.current, {
|
|
77
|
+
childList: true,
|
|
78
|
+
subtree: true,
|
|
79
|
+
attributes: true
|
|
80
|
+
});
|
|
81
|
+
return function () {
|
|
82
|
+
observer.disconnect();
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}, []);
|
|
86
|
+
return focusableElements;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Traps the focus inside the children of the component. It will focus the first focusable element when the component is mounted.
|
|
90
|
+
* When the focus is on the last focusable element and the user tries to focus the next element, it will focus the first element.
|
|
91
|
+
* When the focus is on the first focusable element and the user tries to focus the previous element, it will focus the last element.
|
|
92
|
+
* The focus can't be moved outside the children unless the children are removed from the DOM (for example, a Dialog, a Modal, etc).
|
|
93
|
+
* @param children: React.ReactNode
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
var FocusLock = function FocusLock(_ref) {
|
|
99
|
+
var children = _ref.children;
|
|
100
|
+
var childrenContainerRef = (0, _react.useRef)();
|
|
101
|
+
var focusableElements = useFocusableElements(childrenContainerRef);
|
|
102
|
+
var focusFirst = (0, _react.useCallback)(function () {
|
|
103
|
+
var _childrenContainerRef;
|
|
104
|
+
|
|
105
|
+
if ((focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.length) === 0) (_childrenContainerRef = childrenContainerRef.current) === null || _childrenContainerRef === void 0 ? void 0 : _childrenContainerRef.focus();else if ((focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.length) > 0) for (var i = 0; i < focusableElements.length; i++) {
|
|
106
|
+
if (attempFocus(focusableElements[i])) return;
|
|
107
|
+
}
|
|
108
|
+
}, [focusableElements]);
|
|
109
|
+
|
|
110
|
+
var focusLast = function focusLast() {
|
|
111
|
+
for (var i = focusableElements.length - 1; i >= 0; i--) {
|
|
112
|
+
if (attempFocus(focusableElements[i])) return;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var focusLock = function focusLock(event) {
|
|
117
|
+
if (event.key === "Tab") focusableElements.length === 0 && event.preventDefault();else if (event.key === "Tab" && event.key === "Shift") focusableElements.length === 0 && event.preventDefault();
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
(0, _react.useEffect)(function () {
|
|
121
|
+
var _childrenContainerRef2;
|
|
122
|
+
|
|
123
|
+
if (!((_childrenContainerRef2 = childrenContainerRef.current) !== null && _childrenContainerRef2 !== void 0 && _childrenContainerRef2.contains(document.activeElement)) && !radixPortalContains(document.activeElement)) focusFirst();
|
|
124
|
+
}, [focusFirst]);
|
|
125
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
126
|
+
onFocus: focusLast,
|
|
127
|
+
tabIndex: 0
|
|
128
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
129
|
+
onKeyDown: focusLock,
|
|
130
|
+
ref: childrenContainerRef,
|
|
131
|
+
tabIndex: (focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.length) === 0 ? 0 : -1
|
|
132
|
+
}, children), /*#__PURE__*/_react["default"].createElement("div", {
|
|
133
|
+
onFocus: focusFirst,
|
|
134
|
+
tabIndex: 0
|
|
135
|
+
}));
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
var _default = FocusLock;
|
|
139
|
+
exports["default"] = _default;
|
|
@@ -3,6 +3,7 @@ import DxcWizard from "./Wizard";
|
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { userEvent, within } from "@storybook/testing-library";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "Wizard",
|
|
@@ -36,6 +37,7 @@ const stepWithLabel = [
|
|
|
36
37
|
label: "Forth step",
|
|
37
38
|
},
|
|
38
39
|
];
|
|
40
|
+
|
|
39
41
|
const stepWithLabelDescription = [
|
|
40
42
|
{
|
|
41
43
|
label: "First step",
|
|
@@ -56,6 +58,7 @@ const stepWithLabelDescription = [
|
|
|
56
58
|
valid: false,
|
|
57
59
|
},
|
|
58
60
|
];
|
|
61
|
+
|
|
59
62
|
const stepWithLongDescription = [
|
|
60
63
|
{
|
|
61
64
|
label: "First step",
|
|
@@ -73,6 +76,7 @@ const stepWithLongDescription = [
|
|
|
73
76
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ",
|
|
74
77
|
},
|
|
75
78
|
];
|
|
79
|
+
|
|
76
80
|
const stepDisabled = [
|
|
77
81
|
{
|
|
78
82
|
label: "First step",
|
|
@@ -98,6 +102,7 @@ const stepDisabled = [
|
|
|
98
102
|
disabled: true,
|
|
99
103
|
},
|
|
100
104
|
];
|
|
105
|
+
|
|
101
106
|
const stepIcons = [
|
|
102
107
|
{
|
|
103
108
|
label: "First step",
|
|
@@ -112,6 +117,7 @@ const stepIcons = [
|
|
|
112
117
|
icon: favoriteSVG,
|
|
113
118
|
},
|
|
114
119
|
];
|
|
120
|
+
|
|
115
121
|
const stepLargeIcons = [
|
|
116
122
|
{
|
|
117
123
|
label: "First step",
|
|
@@ -127,6 +133,14 @@ const stepLargeIcons = [
|
|
|
127
133
|
},
|
|
128
134
|
];
|
|
129
135
|
|
|
136
|
+
const opinionatedTheme = {
|
|
137
|
+
wizard: {
|
|
138
|
+
baseColor: "#5f249f",
|
|
139
|
+
fontColor: "#000000",
|
|
140
|
+
selectedStepFontColor: "#ffffff",
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
130
144
|
export const Chromatic = () => (
|
|
131
145
|
<>
|
|
132
146
|
<ExampleContainer>
|
|
@@ -215,6 +229,12 @@ export const Chromatic = () => (
|
|
|
215
229
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
216
230
|
<DxcWizard mode="vertical" margin="xxlarge" steps={stepWithLabel}></DxcWizard>
|
|
217
231
|
</ExampleContainer>
|
|
232
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
233
|
+
<ExampleContainer>
|
|
234
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
235
|
+
<DxcWizard defaultCurrentStep={2} steps={stepWithLabelDescription}></DxcWizard>
|
|
236
|
+
</HalstackProvider>
|
|
237
|
+
</ExampleContainer>
|
|
218
238
|
</>
|
|
219
239
|
);
|
|
220
240
|
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
-
|
|
16
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
|
-
var _templateObject;
|
|
19
|
-
|
|
20
|
-
var DxcRequired = function DxcRequired(_ref) {
|
|
21
|
-
var _ref$theme = _ref.theme,
|
|
22
|
-
theme = _ref$theme === void 0 ? "light" : _ref$theme;
|
|
23
|
-
return /*#__PURE__*/_react["default"].createElement(RequiredSpan, null, "*");
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
var RequiredSpan = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: #d0011b;\n margin-right: 1px;\n cursor: default;\n"])));
|
|
27
|
-
|
|
28
|
-
DxcRequired.propTypes = {
|
|
29
|
-
theme: _propTypes["default"].oneOf(["dark", "light"])
|
|
30
|
-
};
|
|
31
|
-
var _default = DxcRequired;
|
|
32
|
-
exports["default"] = _default;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|