@dxc-technology/halstack-react 0.0.0-5bbb9f7 → 0.0.0-5beed19
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 +1 -4
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +62 -63
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +22 -32
- package/card/Card.js +34 -36
- package/common/variables.js +3 -18
- package/footer/Icons.js +1 -1
- package/inline/Inline.d.ts +4 -0
- package/inline/Inline.js +54 -0
- package/inline/Inline.stories.tsx +240 -0
- package/inline/types.d.ts +32 -0
- package/{radio → inline}/types.js +0 -0
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +33 -33
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +4 -3
- package/layout/ApplicationLayout.js +83 -102
- package/layout/ApplicationLayout.stories.tsx +14 -59
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +5 -10
- package/link/Link.js +15 -10
- package/list/List.js +1 -1
- package/list/List.stories.tsx +16 -22
- package/list/types.d.ts +1 -1
- package/main.d.ts +2 -2
- package/main.js +8 -8
- package/package.json +2 -1
- package/paginator/Paginator.test.js +42 -0
- package/quick-nav/QuickNav.js +4 -4
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +30 -7
- package/select/Select.js +46 -31
- package/select/Select.stories.tsx +130 -98
- package/select/Select.test.js +42 -0
- package/select/types.d.ts +3 -4
- package/sidenav/Sidenav.d.ts +1 -1
- package/sidenav/Sidenav.js +20 -9
- package/stack/Stack.d.ts +2 -1
- package/stack/Stack.js +23 -70
- package/stack/Stack.stories.tsx +120 -81
- package/stack/types.d.ts +11 -7
- package/tabs-nav/NavTabs.d.ts +2 -1
- package/tabs-nav/NavTabs.js +35 -16
- package/tabs-nav/Tab.js +26 -11
- package/tabs-nav/types.d.ts +6 -4
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -173
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
package/select/Select.js
CHANGED
|
@@ -35,6 +35,8 @@ var _Icons = _interopRequireDefault(require("./Icons"));
|
|
|
35
35
|
|
|
36
36
|
var _Listbox = _interopRequireDefault(require("./Listbox"));
|
|
37
37
|
|
|
38
|
+
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
39
|
+
|
|
38
40
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
|
39
41
|
|
|
40
42
|
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); }
|
|
@@ -195,9 +197,13 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
195
197
|
isOpen = _useState10[0],
|
|
196
198
|
changeIsOpen = _useState10[1];
|
|
197
199
|
|
|
198
|
-
var
|
|
200
|
+
var _useState11 = (0, _react.useState)(null),
|
|
201
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
202
|
+
listboxStyles = _useState12[0],
|
|
203
|
+
setListboxStyles = _useState12[1];
|
|
204
|
+
|
|
205
|
+
var selectRef = (0, _react.useRef)(null);
|
|
199
206
|
var selectSearchInputRef = (0, _react.useRef)(null);
|
|
200
|
-
var selectOptionsListRef = (0, _react.useRef)(null);
|
|
201
207
|
var colorsTheme = (0, _useTheme["default"])();
|
|
202
208
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
203
209
|
var optionalItem = {
|
|
@@ -359,26 +365,23 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
359
365
|
!multiple && closeOptions();
|
|
360
366
|
setSearchValue("");
|
|
361
367
|
}, [handleSelectChangeValue, closeOptions, multiple]);
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
top: (selectedListOptionEl === null || selectedListOptionEl === void 0 ? void 0 : selectedListOptionEl.offsetTop) - (listEl === null || listEl === void 0 ? void 0 : listEl.clientHeight) / 2
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}, [isOpen]);
|
|
373
|
-
(0, _react.useLayoutEffect)(function () {
|
|
374
|
-
var _selectOptionsListRef, _visualFocusedOptionE;
|
|
375
|
-
|
|
376
|
-
var visualFocusedOptionEl = selectOptionsListRef === null || selectOptionsListRef === void 0 ? void 0 : (_selectOptionsListRef = selectOptionsListRef.current) === null || _selectOptionsListRef === void 0 ? void 0 : _selectOptionsListRef.querySelectorAll("[role='option']")[visualFocusIndex];
|
|
377
|
-
visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
|
|
378
|
-
block: "nearest",
|
|
379
|
-
inline: "start"
|
|
368
|
+
|
|
369
|
+
var handleListboxResize = function handleListboxResize() {
|
|
370
|
+
var _selectRef$current;
|
|
371
|
+
|
|
372
|
+
var rect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect();
|
|
373
|
+
setListboxStyles({
|
|
374
|
+
width: rect === null || rect === void 0 ? void 0 : rect.width
|
|
380
375
|
});
|
|
381
|
-
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
(0, _react.useEffect)(function () {
|
|
379
|
+
handleListboxResize();
|
|
380
|
+
window.addEventListener("resize", handleListboxResize);
|
|
381
|
+
return function () {
|
|
382
|
+
window.removeEventListener("resize", handleListboxResize);
|
|
383
|
+
};
|
|
384
|
+
}, [setListboxStyles]);
|
|
382
385
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
383
386
|
theme: colorsTheme.select
|
|
384
387
|
}, /*#__PURE__*/_react["default"].createElement(SelectContainer, {
|
|
@@ -389,12 +392,16 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
389
392
|
id: selectLabelId,
|
|
390
393
|
disabled: disabled,
|
|
391
394
|
onClick: function onClick() {
|
|
392
|
-
|
|
395
|
+
selectRef.current.focus();
|
|
393
396
|
},
|
|
394
397
|
helperText: helperText
|
|
395
398
|
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
396
399
|
disabled: disabled
|
|
397
|
-
}, helperText), /*#__PURE__*/_react["default"].createElement(
|
|
400
|
+
}, helperText), /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
401
|
+
open: isOpen
|
|
402
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
403
|
+
asChild: true
|
|
404
|
+
}, /*#__PURE__*/_react["default"].createElement(Select, {
|
|
398
405
|
id: selectId,
|
|
399
406
|
disabled: disabled,
|
|
400
407
|
error: error,
|
|
@@ -402,14 +409,14 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
402
409
|
onClick: handleSelectOnClick,
|
|
403
410
|
onFocus: handleSelectOnFocus,
|
|
404
411
|
onKeyDown: handleSelectOnKeyDown,
|
|
405
|
-
ref:
|
|
412
|
+
ref: selectRef,
|
|
406
413
|
tabIndex: tabIndex,
|
|
407
414
|
role: "combobox",
|
|
408
415
|
"aria-controls": optionsListId,
|
|
409
416
|
"aria-disabled": disabled,
|
|
410
417
|
"aria-expanded": isOpen,
|
|
411
418
|
"aria-haspopup": "listbox",
|
|
412
|
-
"aria-labelledby": selectLabelId,
|
|
419
|
+
"aria-labelledby": label ? selectLabelId : undefined,
|
|
413
420
|
"aria-activedescendant": visualFocusIndex >= 0 ? "option-".concat(visualFocusIndex) : undefined,
|
|
414
421
|
"aria-invalid": error ? "true" : "false",
|
|
415
422
|
"aria-errormessage": error ? errorId : undefined,
|
|
@@ -458,7 +465,17 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
458
465
|
"aria-label": translatedLabels.select.actionClearSearchTitle
|
|
459
466
|
}, _Icons["default"].clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
|
|
460
467
|
disabled: disabled
|
|
461
|
-
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown),
|
|
468
|
+
}, isOpen ? _Icons["default"].arrowUp : _Icons["default"].arrowDown))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
469
|
+
sideOffset: 4,
|
|
470
|
+
onOpenAutoFocus: function onOpenAutoFocus(event) {
|
|
471
|
+
// Avoid select to lose focus when the list is opened
|
|
472
|
+
event.preventDefault();
|
|
473
|
+
},
|
|
474
|
+
onCloseAutoFocus: function onCloseAutoFocus(event) {
|
|
475
|
+
// Avoid select to lose focus when the list is closed
|
|
476
|
+
event.preventDefault();
|
|
477
|
+
}
|
|
478
|
+
}, /*#__PURE__*/_react["default"].createElement(_Listbox["default"], {
|
|
462
479
|
id: optionsListId,
|
|
463
480
|
currentValue: value !== null && value !== void 0 ? value : innerValue,
|
|
464
481
|
options: searchable ? filteredOptions : options,
|
|
@@ -469,8 +486,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
469
486
|
optionalItem: optionalItem,
|
|
470
487
|
searchable: searchable,
|
|
471
488
|
handleOptionOnClick: handleOptionOnClick,
|
|
472
|
-
|
|
473
|
-
})), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
489
|
+
styles: listboxStyles
|
|
490
|
+
}))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
474
491
|
id: errorId,
|
|
475
492
|
"aria-live": error ? "assertive" : "off"
|
|
476
493
|
}, error)));
|
|
@@ -569,9 +586,7 @@ var SelectionNumber = _styledComponents["default"].span(_templateObject7 || (_te
|
|
|
569
586
|
return props.disabled ? "cursor: not-allowed;" : "cursor: default;";
|
|
570
587
|
});
|
|
571
588
|
|
|
572
|
-
var ClearOptionsAction = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n width: 23px;\n height: 22px;\n
|
|
573
|
-
return props.theme.fontFamily;
|
|
574
|
-
}, function (props) {
|
|
589
|
+
var ClearOptionsAction = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n width: 23px;\n height: 22px;\n border: none;\n padding: 0.25rem;\n ", "\n background-color: ", ";\n color: ", ";\n\n :focus-visible {\n outline: none;\n }\n ", "\n\n svg {\n line-height: 18px;\n }\n"])), function (props) {
|
|
575
590
|
return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
|
|
576
591
|
}, function (props) {
|
|
577
592
|
return props.disabled ? "transparent" : props.theme.enabledSelectionIndicatorActionBackgroundColor;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
2
|
import { userEvent, within, waitFor } from "@storybook/testing-library";
|
|
4
|
-
import { fireEvent } from "@testing-library/react";
|
|
5
|
-
|
|
6
3
|
import Title from "../../.storybook/components/Title";
|
|
7
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
8
|
-
|
|
9
5
|
import DxcSelect from "./Select";
|
|
6
|
+
import Listbox from "./Listbox";
|
|
7
|
+
import DxcButton from "../button/Button";
|
|
8
|
+
import DxcCheckbox from "../checkbox/Checkbox";
|
|
10
9
|
|
|
11
10
|
export default {
|
|
12
11
|
title: "Select",
|
|
@@ -340,7 +339,7 @@ const Select = () => (
|
|
|
340
339
|
<DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
|
|
341
340
|
<Title title="Value with ellipsis" theme="light" level={4} />
|
|
342
341
|
<DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" size="medium" />
|
|
343
|
-
<Title title="
|
|
342
|
+
<Title title="Options with ellipsis" theme="light" level={4} />
|
|
344
343
|
<DxcSelect
|
|
345
344
|
label="Label"
|
|
346
345
|
placeholder="Choose an option"
|
|
@@ -351,16 +350,103 @@ const Select = () => (
|
|
|
351
350
|
</ExampleContainer>
|
|
352
351
|
</>
|
|
353
352
|
);
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
353
|
+
const SelectListbox = () => (
|
|
354
|
+
<>
|
|
355
|
+
<Title title="Listbox" theme="light" level={2} />
|
|
356
|
+
<Title title="Default with opened listbox" theme="light" level={3} />
|
|
357
|
+
<ExampleContainer>
|
|
358
|
+
<div style={{ display: "flex", gap: "30px", flexDirection: "column", marginBottom: "80px" }}>
|
|
359
|
+
<DxcSelect label="Label" options={single_options} optional placeholder="Choose an option" />
|
|
360
|
+
<DxcCheckbox
|
|
361
|
+
label="You understand the selection and give your consent"
|
|
362
|
+
onChange={() => {}}
|
|
363
|
+
labelPosition="after"
|
|
364
|
+
/>
|
|
365
|
+
<DxcButton label="Submit" onClick={() => {}} size="medium" />
|
|
366
|
+
</div>
|
|
367
|
+
</ExampleContainer>
|
|
368
|
+
<Title title="Listbox option states" theme="light" level={3} />
|
|
369
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
370
|
+
<Title title="Hovered option" theme="light" level={4} />
|
|
371
|
+
<Listbox
|
|
372
|
+
id="x"
|
|
373
|
+
currentValue=""
|
|
374
|
+
options={one_option}
|
|
375
|
+
visualFocusIndex={-1}
|
|
376
|
+
lastOptionIndex={0}
|
|
377
|
+
multiple={false}
|
|
378
|
+
optional={false}
|
|
379
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
380
|
+
searchable={false}
|
|
381
|
+
handleOptionOnClick={() => {}}
|
|
382
|
+
styles={{ width: 360 }}
|
|
383
|
+
/>
|
|
384
|
+
</ExampleContainer>
|
|
385
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
386
|
+
<Title title="Active option" theme="light" level={4} />
|
|
387
|
+
<Listbox
|
|
388
|
+
id="x"
|
|
389
|
+
currentValue=""
|
|
390
|
+
options={one_option}
|
|
391
|
+
visualFocusIndex={-1}
|
|
392
|
+
lastOptionIndex={0}
|
|
393
|
+
multiple={false}
|
|
394
|
+
optional={false}
|
|
395
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
396
|
+
searchable={false}
|
|
397
|
+
handleOptionOnClick={() => {}}
|
|
398
|
+
styles={{ width: 360 }}
|
|
399
|
+
/>
|
|
400
|
+
</ExampleContainer>
|
|
401
|
+
<ExampleContainer>
|
|
402
|
+
<Title title="Focused option" theme="light" level={4} />
|
|
403
|
+
<Listbox
|
|
404
|
+
id="x"
|
|
405
|
+
currentValue=""
|
|
406
|
+
options={one_option}
|
|
407
|
+
visualFocusIndex={0}
|
|
408
|
+
lastOptionIndex={0}
|
|
409
|
+
multiple={false}
|
|
410
|
+
optional={false}
|
|
411
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
412
|
+
searchable={false}
|
|
413
|
+
handleOptionOnClick={() => {}}
|
|
414
|
+
styles={{ width: 360 }}
|
|
415
|
+
/>
|
|
416
|
+
</ExampleContainer>
|
|
417
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
418
|
+
<Title title="Hovered selected option" theme="light" level={4} />
|
|
419
|
+
<Listbox
|
|
420
|
+
id="x"
|
|
421
|
+
currentValue="1"
|
|
422
|
+
options={single_options}
|
|
423
|
+
visualFocusIndex={-1}
|
|
424
|
+
lastOptionIndex={3}
|
|
425
|
+
multiple={false}
|
|
426
|
+
optional={false}
|
|
427
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
428
|
+
searchable={false}
|
|
429
|
+
handleOptionOnClick={() => {}}
|
|
430
|
+
styles={{ width: 360 }}
|
|
431
|
+
/>
|
|
432
|
+
</ExampleContainer>
|
|
433
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
434
|
+
<Title title="Active selected option" theme="light" level={4} />
|
|
435
|
+
<Listbox
|
|
436
|
+
id="x"
|
|
437
|
+
currentValue="2"
|
|
438
|
+
options={single_options}
|
|
439
|
+
visualFocusIndex={0}
|
|
440
|
+
lastOptionIndex={3}
|
|
441
|
+
multiple={false}
|
|
442
|
+
optional={false}
|
|
443
|
+
optionalItem={{ label: "Empty", value: "" }}
|
|
444
|
+
searchable={false}
|
|
445
|
+
handleOptionOnClick={() => {}}
|
|
446
|
+
styles={{ width: 360 }}
|
|
447
|
+
/>
|
|
448
|
+
</ExampleContainer>
|
|
449
|
+
</>
|
|
364
450
|
);
|
|
365
451
|
const SearchableSelect = () => (
|
|
366
452
|
<ExampleContainer expanded>
|
|
@@ -368,7 +454,7 @@ const SearchableSelect = () => (
|
|
|
368
454
|
<DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
|
|
369
455
|
</ExampleContainer>
|
|
370
456
|
);
|
|
371
|
-
const
|
|
457
|
+
const SearchValue = () => (
|
|
372
458
|
<ExampleContainer expanded>
|
|
373
459
|
<Title title="Searchable select with value" theme="light" level={4} />
|
|
374
460
|
<DxcSelect
|
|
@@ -380,7 +466,6 @@ const SearchableWithValue = () => (
|
|
|
380
466
|
/>
|
|
381
467
|
</ExampleContainer>
|
|
382
468
|
);
|
|
383
|
-
|
|
384
469
|
const MultipleSelect = () => (
|
|
385
470
|
<>
|
|
386
471
|
<ExampleContainer expanded>
|
|
@@ -443,36 +528,7 @@ const MultipleGroupedOptionsSelectWithIcons = () => (
|
|
|
443
528
|
/>
|
|
444
529
|
</ExampleContainer>
|
|
445
530
|
);
|
|
446
|
-
|
|
447
|
-
<ExampleContainer pseudoState="pseudo-hover" expanded>
|
|
448
|
-
<Title title="Hovered Option" theme="light" level={4} />
|
|
449
|
-
<DxcSelect label="Hovered" options={one_option} placeholder="Choose an option" />
|
|
450
|
-
</ExampleContainer>
|
|
451
|
-
);
|
|
452
|
-
const OnlyOneOptionFocused = () => (
|
|
453
|
-
<ExampleContainer pseudoState="pseudo-focus" expanded>
|
|
454
|
-
<Title title="Focused Option" theme="light" level={4} />
|
|
455
|
-
<DxcSelect label="Focused" options={one_option} placeholder="Choose an option" />
|
|
456
|
-
</ExampleContainer>
|
|
457
|
-
);
|
|
458
|
-
const OnlyOneOptionActived = () => (
|
|
459
|
-
<ExampleContainer pseudoState="pseudo-active" expanded>
|
|
460
|
-
<Title title="Actived Option" theme="light" level={4} />
|
|
461
|
-
<DxcSelect label="Actived" options={one_option} placeholder="Choose an option" />
|
|
462
|
-
</ExampleContainer>
|
|
463
|
-
);
|
|
464
|
-
const SelectedOptionHovered = () => (
|
|
465
|
-
<ExampleContainer pseudoState="pseudo-hover" expanded>
|
|
466
|
-
<Title title="Hovered Selected Option" theme="light" level={4} />
|
|
467
|
-
<DxcSelect label="Hovered" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
468
|
-
</ExampleContainer>
|
|
469
|
-
);
|
|
470
|
-
const SelectedOptionActived = () => (
|
|
471
|
-
<ExampleContainer pseudoState="pseudo-active" expanded>
|
|
472
|
-
<Title title="Actived Selected Option" theme="light" level={4} />
|
|
473
|
-
<DxcSelect label="Actived" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
474
|
-
</ExampleContainer>
|
|
475
|
-
);
|
|
531
|
+
|
|
476
532
|
const MultipleSearchable = () => (
|
|
477
533
|
<ExampleContainer expanded>
|
|
478
534
|
<Title title="Searchable multiple select with value" theme="light" level={4} />
|
|
@@ -486,12 +542,20 @@ const MultipleSearchable = () => (
|
|
|
486
542
|
/>
|
|
487
543
|
</ExampleContainer>
|
|
488
544
|
);
|
|
489
|
-
|
|
490
|
-
|
|
545
|
+
|
|
546
|
+
export const Chromatic = Select.bind({});
|
|
547
|
+
Chromatic.play = async ({ canvasElement }) => {
|
|
548
|
+
const canvas = within(canvasElement);
|
|
549
|
+
await userEvent.click(canvas.getAllByRole("combobox")[24]);
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
export const ListboxStates = SelectListbox.bind({});
|
|
553
|
+
ListboxStates.play = async ({ canvasElement }) => {
|
|
491
554
|
const canvas = within(canvasElement);
|
|
492
555
|
const select = canvas.getByRole("combobox");
|
|
493
556
|
await userEvent.click(select);
|
|
494
557
|
};
|
|
558
|
+
|
|
495
559
|
export const Searchable = SearchableSelect.bind({});
|
|
496
560
|
Searchable.play = async ({ canvasElement }) => {
|
|
497
561
|
const canvas = within(canvasElement);
|
|
@@ -500,14 +564,15 @@ Searchable.play = async ({ canvasElement }) => {
|
|
|
500
564
|
userEvent.type(canvas.getByRole("combobox"), "r");
|
|
501
565
|
});
|
|
502
566
|
};
|
|
503
|
-
|
|
504
|
-
|
|
567
|
+
|
|
568
|
+
export const SearchableWithValue = SearchValue.bind({});
|
|
569
|
+
SearchableWithValue.play = async ({ canvasElement }) => {
|
|
505
570
|
const canvas = within(canvasElement);
|
|
506
571
|
await userEvent.click(canvas.getByRole("combobox"));
|
|
507
572
|
};
|
|
508
573
|
|
|
509
|
-
export const
|
|
510
|
-
|
|
574
|
+
export const MultipleSearchableWithValue = MultipleSearchable.bind({});
|
|
575
|
+
MultipleSearchableWithValue.play = async ({ canvasElement }) => {
|
|
511
576
|
const canvas = within(canvasElement);
|
|
512
577
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
513
578
|
};
|
|
@@ -519,75 +584,42 @@ GroupOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
|
519
584
|
await userEvent.click(select);
|
|
520
585
|
};
|
|
521
586
|
|
|
522
|
-
export const
|
|
523
|
-
|
|
587
|
+
export const MultipleOptionsDisplayed = MultipleSelect.bind({});
|
|
588
|
+
MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
524
589
|
const canvas = within(canvasElement);
|
|
525
590
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
526
591
|
};
|
|
527
592
|
|
|
528
|
-
export const
|
|
529
|
-
|
|
530
|
-
const canvas = within(canvasElement);
|
|
531
|
-
const select = canvas.getByRole("combobox");
|
|
532
|
-
await userEvent.click(select);
|
|
533
|
-
};
|
|
534
|
-
export const SelectWithIconsDisplayed = SelectWithIcons.bind({});
|
|
535
|
-
SelectWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
593
|
+
export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
|
|
594
|
+
MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
536
595
|
const canvas = within(canvasElement);
|
|
537
596
|
const select = canvas.getByRole("combobox");
|
|
538
597
|
await userEvent.click(select);
|
|
539
598
|
};
|
|
540
599
|
|
|
541
|
-
export const
|
|
542
|
-
|
|
543
|
-
const canvas = within(canvasElement);
|
|
544
|
-
const select = canvas.getByRole("combobox");
|
|
545
|
-
await userEvent.click(select);
|
|
546
|
-
};
|
|
547
|
-
export const SelectMultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
|
|
548
|
-
SelectMultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
600
|
+
export const WithIconsDisplayed = SelectWithIcons.bind({});
|
|
601
|
+
WithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
549
602
|
const canvas = within(canvasElement);
|
|
550
603
|
const select = canvas.getByRole("combobox");
|
|
551
604
|
await userEvent.click(select);
|
|
552
605
|
};
|
|
553
606
|
|
|
554
|
-
export const
|
|
555
|
-
|
|
607
|
+
export const WithRescaledIconsDisplayed = RescaledIcons.bind({});
|
|
608
|
+
WithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
|
|
556
609
|
const canvas = within(canvasElement);
|
|
557
610
|
const select = canvas.getByRole("combobox");
|
|
558
611
|
await userEvent.click(select);
|
|
559
612
|
};
|
|
560
613
|
|
|
561
|
-
export const
|
|
562
|
-
|
|
614
|
+
export const MultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
|
|
615
|
+
MultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
563
616
|
const canvas = within(canvasElement);
|
|
564
617
|
const select = canvas.getByRole("combobox");
|
|
565
618
|
await userEvent.click(select);
|
|
566
619
|
};
|
|
567
620
|
|
|
568
|
-
export const
|
|
569
|
-
|
|
570
|
-
const canvas = within(canvasElement);
|
|
571
|
-
const select = canvas.getByRole("combobox");
|
|
572
|
-
await userEvent.click(select);
|
|
573
|
-
await waitFor(async () => {
|
|
574
|
-
fireEvent.keyDown(select, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
export const OptionActived = OnlyOneOptionActived.bind({});
|
|
578
|
-
OptionActived.play = async ({ canvasElement }) => {
|
|
579
|
-
const canvas = within(canvasElement);
|
|
580
|
-
const select = canvas.getByRole("combobox");
|
|
581
|
-
await userEvent.click(select);
|
|
582
|
-
};
|
|
583
|
-
export const OptionSelectedHovered = SelectedOptionHovered.bind({});
|
|
584
|
-
OptionSelectedHovered.play = async ({ canvasElement }) => {
|
|
585
|
-
const canvas = within(canvasElement);
|
|
586
|
-
const select = canvas.getByRole("combobox");
|
|
587
|
-
await userEvent.click(select);
|
|
588
|
-
};
|
|
589
|
-
export const OptionSelectedActived = SelectedOptionActived.bind({});
|
|
590
|
-
OptionSelectedActived.play = async ({ canvasElement }) => {
|
|
621
|
+
export const MultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
|
|
622
|
+
MultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
591
623
|
const canvas = within(canvasElement);
|
|
592
624
|
const select = canvas.getByRole("combobox");
|
|
593
625
|
await userEvent.click(select);
|
package/select/Select.test.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
6
|
+
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
|
|
5
9
|
var _react = _interopRequireDefault(require("react"));
|
|
6
10
|
|
|
7
11
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
@@ -10,6 +14,44 @@ var _react2 = require("@testing-library/react");
|
|
|
10
14
|
|
|
11
15
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
12
16
|
|
|
17
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
18
|
+
global.globalThis = global;
|
|
19
|
+
|
|
20
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
21
|
+
function ResizeObserver(cb) {
|
|
22
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
23
|
+
this.cb = cb;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
27
|
+
key: "observe",
|
|
28
|
+
value: function observe() {
|
|
29
|
+
this.cb([{
|
|
30
|
+
borderBoxSize: {
|
|
31
|
+
inlineSize: 0,
|
|
32
|
+
blockSize: 0
|
|
33
|
+
}
|
|
34
|
+
}]);
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "unobserve",
|
|
38
|
+
value: function unobserve() {}
|
|
39
|
+
}]);
|
|
40
|
+
return ResizeObserver;
|
|
41
|
+
}();
|
|
42
|
+
|
|
43
|
+
global.DOMRect = {
|
|
44
|
+
fromRect: function fromRect() {
|
|
45
|
+
return {
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
bottom: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
13
55
|
var single_options = [{
|
|
14
56
|
label: "Option 01",
|
|
15
57
|
value: "1"
|
package/select/types.d.ts
CHANGED
|
@@ -201,11 +201,10 @@ export declare type ListboxProps = {
|
|
|
201
201
|
optionalItem: Option;
|
|
202
202
|
searchable: boolean;
|
|
203
203
|
handleOptionOnClick: (option: Option) => void;
|
|
204
|
+
styles: {
|
|
205
|
+
width: number;
|
|
206
|
+
};
|
|
204
207
|
};
|
|
205
|
-
/**
|
|
206
|
-
* Reference to the listbox component.
|
|
207
|
-
*/
|
|
208
|
-
export declare type ListboxRefType = HTMLUListElement;
|
|
209
208
|
/**
|
|
210
209
|
* Reference to the select component.
|
|
211
210
|
*/
|
package/sidenav/Sidenav.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import SidenavPropsType, { SidenavTitlePropsType, SidenavSubtitlePropsType, SidenavLinkPropsType } from "./types
|
|
2
|
+
import SidenavPropsType, { SidenavTitlePropsType, SidenavSubtitlePropsType, SidenavLinkPropsType } from "./types";
|
|
3
3
|
declare const DxcSidenav: {
|
|
4
4
|
({ padding, children }: SidenavPropsType): JSX.Element;
|
|
5
5
|
Title: ({ children }: SidenavTitlePropsType) => JSX.Element;
|
package/sidenav/Sidenav.js
CHANGED
|
@@ -21,6 +21,8 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
21
21
|
|
|
22
22
|
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
23
23
|
|
|
24
|
+
var _SidenavContext = require("../layout/SidenavContext");
|
|
25
|
+
|
|
24
26
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
25
27
|
|
|
26
28
|
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); }
|
|
@@ -33,7 +35,7 @@ var DxcSidenav = function DxcSidenav(_ref) {
|
|
|
33
35
|
var colorsTheme = (0, _useTheme["default"])();
|
|
34
36
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
35
37
|
theme: colorsTheme.sidenav
|
|
36
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
38
|
+
}, /*#__PURE__*/_react["default"].createElement(SidenavContainer, {
|
|
37
39
|
padding: padding
|
|
38
40
|
}, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
|
|
39
41
|
color: colorsTheme.sidenav.backgroundColor
|
|
@@ -42,12 +44,12 @@ var DxcSidenav = function DxcSidenav(_ref) {
|
|
|
42
44
|
|
|
43
45
|
var Title = function Title(_ref2) {
|
|
44
46
|
var children = _ref2.children;
|
|
45
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
47
|
+
return /*#__PURE__*/_react["default"].createElement(SidenavMenuTitle, null, children);
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
var Subtitle = function Subtitle(_ref3) {
|
|
49
51
|
var children = _ref3.children;
|
|
50
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
52
|
+
return /*#__PURE__*/_react["default"].createElement(SidenavMenuSubTitle, null, children);
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
var Link = function Link(_ref4) {
|
|
@@ -56,15 +58,24 @@ var Link = function Link(_ref4) {
|
|
|
56
58
|
href = _ref4.href,
|
|
57
59
|
onClick = _ref4.onClick,
|
|
58
60
|
children = _ref4.children;
|
|
59
|
-
|
|
61
|
+
var setIsSidenavVisibleResponsive = (0, _SidenavContext.useResponsiveSidenavVisibility)();
|
|
62
|
+
|
|
63
|
+
var handleClick = function handleClick() {
|
|
64
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
65
|
+
setIsSidenavVisibleResponsive === null || setIsSidenavVisibleResponsive === void 0 ? void 0 : setIsSidenavVisibleResponsive(false);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return /*#__PURE__*/_react["default"].createElement(SidenavMenuLink, {
|
|
60
69
|
tabIndex: tabIndex,
|
|
61
70
|
href: href,
|
|
62
|
-
onClick:
|
|
71
|
+
onClick: handleClick
|
|
63
72
|
}, children);
|
|
64
73
|
};
|
|
65
74
|
|
|
66
|
-
var
|
|
75
|
+
var SidenavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n background-color: ", ";\n\n @media (max-width: ", "rem) {\n width: ", ";\n }\n\n width: ", ";\n padding: ", ";\n\n overflow-y: auto;\n overflow-x: hidden;\n ::-webkit-scrollbar {\n width: 2px;\n }\n ::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 3px;\n }\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 3px;\n }\n"])), function (props) {
|
|
67
76
|
return props.theme.backgroundColor;
|
|
77
|
+
}, _variables.responsiveSizes.medium, function (props) {
|
|
78
|
+
return props.padding ? "calc(100vw - ".concat(_variables.spaces[props.padding], " - ").concat(_variables.spaces[props.padding], ")") : "100vw";
|
|
68
79
|
}, function (props) {
|
|
69
80
|
return props.padding ? "calc(300px - ".concat(_variables.spaces[props.padding], " - ").concat(_variables.spaces[props.padding], ")") : "300px";
|
|
70
81
|
}, function (props) {
|
|
@@ -75,7 +86,7 @@ var SideNavContainer = _styledComponents["default"].div(_templateObject || (_tem
|
|
|
75
86
|
return props.theme.scrollBarThumbColor;
|
|
76
87
|
});
|
|
77
88
|
|
|
78
|
-
var
|
|
89
|
+
var SidenavMenuTitle = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n margin-bottom: 16px;\n"])), function (props) {
|
|
79
90
|
return props.theme.titleFontFamily;
|
|
80
91
|
}, function (props) {
|
|
81
92
|
return props.theme.titleFontSize;
|
|
@@ -91,7 +102,7 @@ var SideNavMenuTitle = _styledComponents["default"].div(_templateObject2 || (_te
|
|
|
91
102
|
return props.theme.titleFontTextTransform;
|
|
92
103
|
});
|
|
93
104
|
|
|
94
|
-
var
|
|
105
|
+
var SidenavMenuSubTitle = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n margin-bottom: 4px;\n"])), function (props) {
|
|
95
106
|
return props.theme.subtitleFontFamily;
|
|
96
107
|
}, function (props) {
|
|
97
108
|
return props.theme.subtitleFontSize;
|
|
@@ -107,7 +118,7 @@ var SideNavMenuSubTitle = _styledComponents["default"].div(_templateObject3 || (
|
|
|
107
118
|
return props.theme.subtitleFontTextTransform;
|
|
108
119
|
});
|
|
109
120
|
|
|
110
|
-
var
|
|
121
|
+
var SidenavMenuLink = _styledComponents["default"].a(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n text-decoration: ", ";\n margin: ", ";\n cursor: pointer;\n\n :focus-visible {\n outline: 2px solid ", ";\n outline-offset: 1px;\n }\n"])), function (props) {
|
|
111
122
|
return props.theme.linkFontFamily;
|
|
112
123
|
}, function (props) {
|
|
113
124
|
return props.theme.linkFontSize;
|
package/stack/Stack.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import StackPropsType from "./types";
|
|
3
|
-
|
|
3
|
+
declare const DxcStack: ({ alignX, as, divider, gutter, reverse, children, }: StackPropsType) => JSX.Element;
|
|
4
|
+
export default DxcStack;
|