@dxc-technology/halstack-react 0.0.0-c796a1b → 0.0.0-c8b251f
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/BackgroundColorContext.js +0 -1
- package/ThemeContext.d.ts +4 -9
- package/ThemeContext.js +32 -32
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +11 -43
- package/accordion/Accordion.stories.tsx +307 -0
- package/accordion/Accordion.test.js +72 -0
- package/accordion/types.d.ts +8 -8
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +13 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +151 -0
- package/accordion-group/types.d.ts +8 -8
- package/alert/Alert.test.js +92 -0
- package/badge/Badge.d.ts +4 -0
- package/badge/types.d.ts +4 -0
- package/badge/types.js +5 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +84 -0
- package/bleed/Bleed.stories.tsx +342 -0
- package/bleed/types.d.ts +37 -0
- package/bleed/types.js +5 -0
- package/box/Box.test.js +18 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +9 -17
- package/button/Button.stories.tsx +6 -8
- package/button/Button.test.js +35 -0
- package/button/types.d.ts +3 -7
- package/card/Card.stories.tsx +1 -1
- package/card/Card.test.js +50 -0
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +7 -13
- package/checkbox/Checkbox.stories.tsx +14 -14
- package/checkbox/Checkbox.test.js +78 -0
- package/checkbox/types.d.ts +5 -1
- package/chip/Chip.d.ts +1 -1
- package/chip/Chip.js +16 -54
- package/chip/Chip.stories.tsx +6 -8
- package/chip/Chip.test.js +56 -0
- package/chip/types.d.ts +7 -15
- package/common/variables.js +43 -245
- package/date-input/DateInput.js +50 -39
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +479 -0
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +6 -33
- package/dialog/Dialog.test.js +40 -0
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +12 -34
- package/dropdown/Dropdown.stories.tsx +249 -0
- package/dropdown/Dropdown.test.js +189 -0
- package/dropdown/types.d.ts +5 -14
- package/file-input/FileInput.js +102 -33
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileInput.test.js +457 -0
- package/footer/Footer.js +19 -96
- package/footer/Footer.test.js +109 -0
- package/header/Header.js +20 -44
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +79 -0
- package/heading/Heading.stories.tsx +3 -2
- package/heading/Heading.test.js +186 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +84 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.js +7 -14
- package/link/Link.js +7 -15
- package/link/Link.stories.tsx +6 -1
- package/link/Link.test.js +91 -0
- package/link/types.d.ts +5 -9
- package/list/List.d.ts +3 -6
- package/list/List.js +17 -7
- package/list/List.stories.tsx +25 -0
- package/list/types.d.ts +7 -0
- package/list/types.js +5 -0
- package/main.d.ts +5 -6
- package/main.js +28 -36
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +506 -0
- package/number-input/types.d.ts +16 -9
- package/package.json +6 -3
- package/paginator/Paginator.test.js +266 -0
- package/password-input/PasswordInput.stories.tsx +3 -3
- package/password-input/PasswordInput.test.js +181 -0
- package/password-input/types.d.ts +13 -10
- package/progress-bar/ProgressBar.js +2 -2
- package/progress-bar/ProgressBar.test.js +65 -0
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +66 -0
- package/quick-nav/QuickNav.stories.tsx +237 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio/Radio.test.js +71 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +141 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +280 -0
- package/radio-group/RadioGroup.stories.tsx +100 -0
- package/radio-group/RadioGroup.test.js +695 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.js +5 -2
- package/resultsetTable/ResultsetTable.stories.tsx +7 -8
- package/resultsetTable/ResultsetTable.test.js +306 -0
- package/row/Row.d.ts +3 -11
- package/row/Row.js +12 -9
- package/row/Row.stories.tsx +20 -6
- package/row/types.d.ts +28 -0
- package/row/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +93 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +148 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +110 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +94 -302
- package/select/Select.stories.tsx +91 -81
- package/select/Select.test.js +2057 -0
- package/select/types.d.ts +213 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.stories.tsx +18 -1
- package/sidenav/Sidenav.test.js +56 -0
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +2 -1
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +150 -0
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.stories.jsx +1 -0
- package/spinner/Spinner.test.js +64 -0
- package/stack/Stack.d.ts +3 -10
- package/stack/Stack.js +12 -9
- package/stack/Stack.stories.tsx +20 -6
- package/stack/types.d.ts +24 -0
- package/stack/types.js +5 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +19 -6
- package/switch/Switch.stories.tsx +7 -7
- package/switch/Switch.test.js +98 -0
- package/switch/types.d.ts +4 -0
- package/table/Table.stories.jsx +2 -1
- package/table/Table.test.js +26 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +16 -18
- package/tabs/Tabs.stories.tsx +8 -11
- package/tabs/Tabs.test.js +140 -0
- package/tabs/types.d.ts +27 -15
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +15 -22
- package/tag/Tag.stories.tsx +26 -29
- package/tag/Tag.test.js +60 -0
- package/tag/types.d.ts +23 -14
- package/text/Text.js +1 -1
- package/text-input/TextInput.js +22 -12
- package/text-input/TextInput.stories.tsx +34 -16
- package/text-input/TextInput.test.js +1712 -0
- package/text-input/types.d.ts +18 -11
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +10 -38
- package/textarea/Textarea.stories.jsx +37 -15
- package/textarea/Textarea.test.js +437 -0
- package/textarea/types.d.ts +137 -0
- package/textarea/types.js +5 -0
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +12 -14
- package/toggle-group/ToggleGroup.stories.tsx +27 -32
- package/toggle-group/ToggleGroup.test.js +156 -0
- package/toggle-group/types.d.ts +46 -25
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +71 -16
- package/wizard/{Wizard.stories.jsx → Wizard.stories.tsx} +13 -23
- package/wizard/Wizard.test.js +141 -0
- package/wizard/types.d.ts +8 -8
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/select/index.d.ts +0 -131
- package/textarea/index.d.ts +0 -127
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- package/wizard/Icons.js +0 -65
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export declare type Option = {
|
|
2
|
+
/**
|
|
3
|
+
* Label of the option placed next to the radio input.
|
|
4
|
+
*/
|
|
5
|
+
value: string;
|
|
6
|
+
/**
|
|
7
|
+
* Value of the option. It should be unique and
|
|
8
|
+
* not an empty string, which is reserved to the optional item added
|
|
9
|
+
* by 'optional' prop.
|
|
10
|
+
*/
|
|
11
|
+
label: string;
|
|
12
|
+
/**
|
|
13
|
+
* If true, disables the option.
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare type RadioGroupProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Text to be placed above the radio group.
|
|
20
|
+
*/
|
|
21
|
+
label: string;
|
|
22
|
+
/**
|
|
23
|
+
* Name attribute of the input element. This attribute will allow users
|
|
24
|
+
* to find the component's value during the submit event.
|
|
25
|
+
*/
|
|
26
|
+
name?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Helper text to be placed above the radio group.
|
|
29
|
+
*/
|
|
30
|
+
helperText?: string;
|
|
31
|
+
/**
|
|
32
|
+
* An array of objects representing the selectable options.
|
|
33
|
+
*/
|
|
34
|
+
options: Option[];
|
|
35
|
+
/**
|
|
36
|
+
* If true, the component will be disabled.
|
|
37
|
+
*/
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If true, the radio group will be optional, showing
|
|
41
|
+
* (Optional) next to the label and adding a default last
|
|
42
|
+
* option with an empty string as value. Otherwise, the field will be
|
|
43
|
+
* considered required and an error will be passed as a parameter to the
|
|
44
|
+
* OnBlur functions if an option wasn't selected.
|
|
45
|
+
*/
|
|
46
|
+
optional?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Label of the optional radio input.
|
|
49
|
+
*/
|
|
50
|
+
optionalItemLabel?: string;
|
|
51
|
+
/**
|
|
52
|
+
* If true, the component will be marked as readonly.
|
|
53
|
+
*/
|
|
54
|
+
readonly?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the orientation of the options within the radio group.
|
|
57
|
+
*/
|
|
58
|
+
stacking?: "row" | "column";
|
|
59
|
+
/**
|
|
60
|
+
* Initial value of the radio group, only when it is uncontrolled.
|
|
61
|
+
*/
|
|
62
|
+
defaultValue?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Value of the radio group. If undefined, the component will be
|
|
65
|
+
* uncontrolled and the value will be managed internally by the
|
|
66
|
+
* component.
|
|
67
|
+
*/
|
|
68
|
+
value?: string;
|
|
69
|
+
/**
|
|
70
|
+
* This function will be called when the user chooses an option. The new
|
|
71
|
+
* value will be passed to this function.
|
|
72
|
+
*/
|
|
73
|
+
onChange?: (value: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* This function will be called when the radio group loses the focus. An
|
|
76
|
+
* object including the value and the error will be passed to this
|
|
77
|
+
* function. If there is no error, error will not be defined.
|
|
78
|
+
*/
|
|
79
|
+
onBlur?: (val: {
|
|
80
|
+
value?: string;
|
|
81
|
+
error?: string;
|
|
82
|
+
}) => void;
|
|
83
|
+
/**
|
|
84
|
+
* If it is a defined value and also a truthy string, the component will
|
|
85
|
+
* change its appearance, showing the error below the radio group. If the
|
|
86
|
+
* defined value is an empty string, it will reserve a space below the
|
|
87
|
+
* component for a future error, but it would not change its look. In
|
|
88
|
+
* case of being undefined or null, both the appearance and the space for
|
|
89
|
+
* the error message would not be modified.
|
|
90
|
+
*/
|
|
91
|
+
error?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Value of the tabindex attribute.
|
|
94
|
+
*/
|
|
95
|
+
tabIndex?: number;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Reference to the component.
|
|
99
|
+
*/
|
|
100
|
+
export declare type RefType = HTMLDivElement;
|
|
101
|
+
/**
|
|
102
|
+
* Single radio prop types.
|
|
103
|
+
*/
|
|
104
|
+
export declare type RadioProps = {
|
|
105
|
+
option: Option;
|
|
106
|
+
currentValue?: string;
|
|
107
|
+
onClick: () => void;
|
|
108
|
+
error?: string;
|
|
109
|
+
disabled: boolean;
|
|
110
|
+
focused: boolean;
|
|
111
|
+
readonly: boolean;
|
|
112
|
+
tabIndex: number;
|
|
113
|
+
};
|
|
114
|
+
export default RadioGroupProps;
|
|
@@ -185,7 +185,8 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
185
185
|
onClick: function onClick() {
|
|
186
186
|
return column.isSortable && changeSorting(index);
|
|
187
187
|
},
|
|
188
|
-
tabIndex: column.isSortable ? tabIndex : -1
|
|
188
|
+
tabIndex: column.isSortable ? tabIndex : -1,
|
|
189
|
+
isSortable: column.isSortable
|
|
189
190
|
}, /*#__PURE__*/_react["default"].createElement(TitleDiv, {
|
|
190
191
|
isSortable: column.isSortable
|
|
191
192
|
}, column.displayValue), column.isSortable && /*#__PURE__*/_react["default"].createElement(SortIcon, null, getIconForSortableColumn(index))));
|
|
@@ -227,8 +228,10 @@ var TitleDiv = _styledComponents["default"].div(_templateObject5 || (_templateOb
|
|
|
227
228
|
|
|
228
229
|
var TableHeader = _styledComponents["default"].th(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
229
230
|
|
|
230
|
-
var HeaderContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n width:
|
|
231
|
+
var HeaderContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n width: fit-content;\n :focus {\n ", "\n }\n"])), function (props) {
|
|
231
232
|
return props.theme.headerTextAlign === "center" ? "center" : props.theme.headerTextAlign === "right" ? "flex-end" : "flex-start";
|
|
233
|
+
}, function (props) {
|
|
234
|
+
return props.isSortable && "outline: #0095ff solid 2px; \n outline-offset: 4px;";
|
|
232
235
|
});
|
|
233
236
|
|
|
234
237
|
var HeaderRow = _styledComponents["default"].thead(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 60px;\n"])));
|
|
@@ -10,14 +10,12 @@ export default {
|
|
|
10
10
|
component: DxcResultsetTable,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const deleteIcon = (
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
};
|
|
13
|
+
const deleteIcon = (
|
|
14
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
15
|
+
<path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
|
|
16
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
21
19
|
|
|
22
20
|
const columns = [{ displayValue: "Id" }, { displayValue: "Name" }, { displayValue: "City" }];
|
|
23
21
|
|
|
@@ -216,6 +214,7 @@ export const Chromatic = () => (
|
|
|
216
214
|
<ExampleContainer>
|
|
217
215
|
<Title title="Xxlarge" theme="light" level={4} />
|
|
218
216
|
<DxcResultsetTable columns={columns} rows={rows} margin={"xxlarge"}></DxcResultsetTable>
|
|
217
|
+
<hr />
|
|
219
218
|
</ExampleContainer>
|
|
220
219
|
</>
|
|
221
220
|
);
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
|
+
|
|
11
|
+
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable"));
|
|
12
|
+
|
|
13
|
+
var columns = [{
|
|
14
|
+
displayValue: "Id",
|
|
15
|
+
isSortable: false
|
|
16
|
+
}, {
|
|
17
|
+
displayValue: "Name",
|
|
18
|
+
isSortable: true
|
|
19
|
+
}, {
|
|
20
|
+
displayValue: "City",
|
|
21
|
+
isSortable: false
|
|
22
|
+
}];
|
|
23
|
+
var rows = [[{
|
|
24
|
+
displayValue: "001",
|
|
25
|
+
sortValue: "001"
|
|
26
|
+
}, {
|
|
27
|
+
displayValue: "Peter",
|
|
28
|
+
sortValue: "Peter"
|
|
29
|
+
}, {
|
|
30
|
+
displayValue: "Oviedo",
|
|
31
|
+
sortValue: "Oviedo"
|
|
32
|
+
}], [{
|
|
33
|
+
displayValue: "002",
|
|
34
|
+
sortValue: "002"
|
|
35
|
+
}, {
|
|
36
|
+
displayValue: "Louis",
|
|
37
|
+
sortValue: "Louis"
|
|
38
|
+
}, {
|
|
39
|
+
displayValue: "Oviedo",
|
|
40
|
+
sortValue: "Oviedo"
|
|
41
|
+
}, {
|
|
42
|
+
displayValue: ""
|
|
43
|
+
}], [{
|
|
44
|
+
displayValue: "003",
|
|
45
|
+
sortValue: "003"
|
|
46
|
+
}, {
|
|
47
|
+
displayValue: "Lana",
|
|
48
|
+
sortValue: "Lana"
|
|
49
|
+
}, {
|
|
50
|
+
displayValue: "Albacete",
|
|
51
|
+
sortValue: "Albacete"
|
|
52
|
+
}], [{
|
|
53
|
+
displayValue: "004",
|
|
54
|
+
sortValue: "004"
|
|
55
|
+
}, {
|
|
56
|
+
displayValue: "Rick",
|
|
57
|
+
sortValue: "Rick"
|
|
58
|
+
}, {
|
|
59
|
+
displayValue: "Albacete",
|
|
60
|
+
sortValue: "Albacete"
|
|
61
|
+
}], [{
|
|
62
|
+
displayValue: "005",
|
|
63
|
+
sortValue: "005"
|
|
64
|
+
}, {
|
|
65
|
+
displayValue: "Mark",
|
|
66
|
+
sortValue: "Mark"
|
|
67
|
+
}, {
|
|
68
|
+
displayValue: "Madrid",
|
|
69
|
+
sortValue: "Madrid"
|
|
70
|
+
}], [{
|
|
71
|
+
displayValue: "006",
|
|
72
|
+
sortValue: "006"
|
|
73
|
+
}, {
|
|
74
|
+
displayValue: "Cris",
|
|
75
|
+
sortValue: "Cris"
|
|
76
|
+
}, {
|
|
77
|
+
displayValue: "Barcelona",
|
|
78
|
+
sortValue: "Barcelona"
|
|
79
|
+
}, {
|
|
80
|
+
displayValue: ""
|
|
81
|
+
}], [{
|
|
82
|
+
displayValue: "007",
|
|
83
|
+
sortValue: "007"
|
|
84
|
+
}, {
|
|
85
|
+
displayValue: "Susan",
|
|
86
|
+
sortValue: "Susan"
|
|
87
|
+
}, {
|
|
88
|
+
displayValue: "Madrid",
|
|
89
|
+
sortValue: "Madrid"
|
|
90
|
+
}], [{
|
|
91
|
+
displayValue: "008",
|
|
92
|
+
sortValue: "008"
|
|
93
|
+
}, {
|
|
94
|
+
displayValue: "Tina",
|
|
95
|
+
sortValue: "Tina"
|
|
96
|
+
}, {
|
|
97
|
+
displayValue: "Barcelona",
|
|
98
|
+
sortValue: "Barcelona"
|
|
99
|
+
}], [{
|
|
100
|
+
displayValue: "009",
|
|
101
|
+
sortValue: "009"
|
|
102
|
+
}, {
|
|
103
|
+
displayValue: "Kevin",
|
|
104
|
+
sortValue: "Kevin"
|
|
105
|
+
}, {
|
|
106
|
+
displayValue: "Oviedo",
|
|
107
|
+
sortValue: "Oviedo"
|
|
108
|
+
}, {
|
|
109
|
+
displayValue: ""
|
|
110
|
+
}], [{
|
|
111
|
+
displayValue: "010",
|
|
112
|
+
sortValue: "010"
|
|
113
|
+
}, {
|
|
114
|
+
displayValue: "Cosmin",
|
|
115
|
+
sortValue: "Cosmin"
|
|
116
|
+
}, {
|
|
117
|
+
displayValue: "Barcelona",
|
|
118
|
+
sortValue: "Barcelona"
|
|
119
|
+
}, {
|
|
120
|
+
displayValue: ""
|
|
121
|
+
}]];
|
|
122
|
+
var rows2 = [[{
|
|
123
|
+
displayValue: "546",
|
|
124
|
+
sortValue: "465"
|
|
125
|
+
}, {
|
|
126
|
+
displayValue: "OtherValue",
|
|
127
|
+
sortValue: "OtherValue"
|
|
128
|
+
}, {
|
|
129
|
+
displayValue: "OtherValue",
|
|
130
|
+
sortValue: "OtherValue"
|
|
131
|
+
}], [{
|
|
132
|
+
displayValue: "978",
|
|
133
|
+
sortValue: "465"
|
|
134
|
+
}, {
|
|
135
|
+
displayValue: "OtherValue",
|
|
136
|
+
sortValue: "OtherValue"
|
|
137
|
+
}, {
|
|
138
|
+
displayValue: "OtherValue",
|
|
139
|
+
sortValue: "OtherValue"
|
|
140
|
+
}, {
|
|
141
|
+
displayValue: ""
|
|
142
|
+
}], [{
|
|
143
|
+
displayValue: "678",
|
|
144
|
+
sortValue: "344"
|
|
145
|
+
}, {
|
|
146
|
+
displayValue: "OtherValue",
|
|
147
|
+
sortValue: "OtherValue"
|
|
148
|
+
}, {
|
|
149
|
+
displayValue: "OtherValue",
|
|
150
|
+
sortValue: "OtherValue"
|
|
151
|
+
}]];
|
|
152
|
+
describe("ResultsetTable component tests", function () {
|
|
153
|
+
test("ResultsetTable rendered correctly", function () {
|
|
154
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
155
|
+
columns: columns,
|
|
156
|
+
rows: rows,
|
|
157
|
+
itemsPerPage: 3
|
|
158
|
+
})),
|
|
159
|
+
getByText = _render.getByText;
|
|
160
|
+
|
|
161
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
162
|
+
});
|
|
163
|
+
test("Resultsettable shows as many rows as itemsPerPage", function () {
|
|
164
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
165
|
+
columns: columns,
|
|
166
|
+
rows: rows,
|
|
167
|
+
itemsPerPage: 3
|
|
168
|
+
})),
|
|
169
|
+
getAllByRole = _render2.getAllByRole;
|
|
170
|
+
|
|
171
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
172
|
+
});
|
|
173
|
+
test("Resultsettable shows rows on second page", function () {
|
|
174
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
175
|
+
columns: columns,
|
|
176
|
+
rows: rows,
|
|
177
|
+
itemsPerPage: 3
|
|
178
|
+
})),
|
|
179
|
+
getByText = _render3.getByText,
|
|
180
|
+
getAllByRole = _render3.getAllByRole;
|
|
181
|
+
|
|
182
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
183
|
+
expect(getByText("Louis")).toBeTruthy();
|
|
184
|
+
expect(getByText("Lana")).toBeTruthy();
|
|
185
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
186
|
+
var nextButton = getAllByRole("button")[2];
|
|
187
|
+
|
|
188
|
+
_react2.fireEvent.click(nextButton);
|
|
189
|
+
|
|
190
|
+
expect(getByText("4 to 6 of 10")).toBeTruthy(); // expect(getByText("Page: 2 of 4")).toBeTruthy();
|
|
191
|
+
|
|
192
|
+
expect(getByText("Rick")).toBeTruthy();
|
|
193
|
+
expect(getByText("Mark")).toBeTruthy();
|
|
194
|
+
expect(getByText("Cris")).toBeTruthy();
|
|
195
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
196
|
+
});
|
|
197
|
+
test("Resultsettable goToPage works as expected", function () {
|
|
198
|
+
window.HTMLElement.prototype.scrollIntoView = function () {};
|
|
199
|
+
|
|
200
|
+
window.HTMLElement.prototype.scrollTo = function () {};
|
|
201
|
+
|
|
202
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
203
|
+
columns: columns,
|
|
204
|
+
showGoToPage: true,
|
|
205
|
+
rows: rows,
|
|
206
|
+
itemsPerPage: 3
|
|
207
|
+
})),
|
|
208
|
+
getByText = _render4.getByText,
|
|
209
|
+
getAllByRole = _render4.getAllByRole,
|
|
210
|
+
getByRole = _render4.getByRole;
|
|
211
|
+
|
|
212
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
213
|
+
expect(getByText("Louis")).toBeTruthy();
|
|
214
|
+
expect(getByText("Lana")).toBeTruthy();
|
|
215
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
216
|
+
var goToPageSelect = getAllByRole("button")[2];
|
|
217
|
+
(0, _react2.act)(function () {
|
|
218
|
+
_userEvent["default"].click(goToPageSelect);
|
|
219
|
+
});
|
|
220
|
+
var goToPageOption = getByText("2");
|
|
221
|
+
(0, _react2.act)(function () {
|
|
222
|
+
_userEvent["default"].click(goToPageOption);
|
|
223
|
+
});
|
|
224
|
+
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
225
|
+
expect(getByText("Rick")).toBeTruthy();
|
|
226
|
+
expect(getByText("Mark")).toBeTruthy();
|
|
227
|
+
expect(getByText("Cris")).toBeTruthy();
|
|
228
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
229
|
+
});
|
|
230
|
+
test("Resultsettable going to the last page shows only one row", function () {
|
|
231
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
232
|
+
columns: columns,
|
|
233
|
+
rows: rows,
|
|
234
|
+
itemsPerPage: 3
|
|
235
|
+
})),
|
|
236
|
+
getByText = _render5.getByText,
|
|
237
|
+
getAllByRole = _render5.getAllByRole;
|
|
238
|
+
|
|
239
|
+
var lastButton = getAllByRole("button")[3];
|
|
240
|
+
|
|
241
|
+
_react2.fireEvent.click(lastButton);
|
|
242
|
+
|
|
243
|
+
expect(getByText("10 to 10 of 10")).toBeTruthy();
|
|
244
|
+
expect(getAllByRole("row")).toHaveLength(2);
|
|
245
|
+
expect(getByText("Cosmin")).toBeTruthy();
|
|
246
|
+
});
|
|
247
|
+
test("Resultsettable sort rows by column", function () {
|
|
248
|
+
var component = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
249
|
+
columns: columns,
|
|
250
|
+
rows: rows,
|
|
251
|
+
itemsPerPage: 3
|
|
252
|
+
}));
|
|
253
|
+
expect(component.queryByText("Peter")).toBeTruthy();
|
|
254
|
+
|
|
255
|
+
_react2.fireEvent.click(component.queryByText("Name"));
|
|
256
|
+
|
|
257
|
+
expect(component.queryByText("Tina")).not.toBeTruthy();
|
|
258
|
+
expect(component.queryByText("Cosmin")).toBeTruthy();
|
|
259
|
+
|
|
260
|
+
_react2.fireEvent.click(component.queryByText("Name"));
|
|
261
|
+
|
|
262
|
+
expect(component.queryByText("Tina")).toBeTruthy();
|
|
263
|
+
expect(component.queryByText("Cosmin")).not.toBeTruthy();
|
|
264
|
+
});
|
|
265
|
+
test("Resultsettable change rows should go to first page", function () {
|
|
266
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
267
|
+
columns: columns,
|
|
268
|
+
rows: rows,
|
|
269
|
+
itemsPerPage: 3
|
|
270
|
+
})),
|
|
271
|
+
queryByText = _render6.queryByText,
|
|
272
|
+
rerender = _render6.rerender;
|
|
273
|
+
|
|
274
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
275
|
+
rerender( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
276
|
+
columns: columns,
|
|
277
|
+
rows: rows2,
|
|
278
|
+
itemsPerPage: 3
|
|
279
|
+
}));
|
|
280
|
+
expect(queryByText("1 to 3 of 3")).toBeTruthy();
|
|
281
|
+
});
|
|
282
|
+
test("Resultsettable change itemsPerPage should go to first page", function () {
|
|
283
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
284
|
+
columns: columns,
|
|
285
|
+
rows: rows,
|
|
286
|
+
itemsPerPage: 3,
|
|
287
|
+
itemsPerPageOptions: [2, 3]
|
|
288
|
+
})),
|
|
289
|
+
getAllByRole = _render7.getAllByRole,
|
|
290
|
+
queryByText = _render7.queryByText,
|
|
291
|
+
rerender = _render7.rerender;
|
|
292
|
+
|
|
293
|
+
var lastButton = getAllByRole("button")[3];
|
|
294
|
+
|
|
295
|
+
_react2.fireEvent.click(lastButton);
|
|
296
|
+
|
|
297
|
+
expect(getAllByRole("row").length - 1).toEqual(1);
|
|
298
|
+
rerender( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
299
|
+
columns: columns,
|
|
300
|
+
rows: rows,
|
|
301
|
+
itemsPerPage: 6
|
|
302
|
+
}));
|
|
303
|
+
expect(getAllByRole("row").length - 1).toEqual(6);
|
|
304
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
305
|
+
});
|
|
306
|
+
});
|
package/row/Row.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
align?: "start" | "center" | "end" | "baseline" | "stretch";
|
|
5
|
-
justify?: "start" | "center" | "end" | "spaceBetween" | "spaceAround" | "spaceEvenly";
|
|
6
|
-
wrap?: boolean;
|
|
7
|
-
reverse?: boolean;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
};
|
|
10
|
-
export default function Row({ gutter, align, justify, wrap, reverse, children }: RowProps): JSX.Element;
|
|
11
|
-
export {};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import RowPropsType from "./types";
|
|
3
|
+
export default function Row({ gutter, align, justify, wrap, reverse, children, }: RowPropsType): JSX.Element;
|
package/row/Row.js
CHANGED
|
@@ -34,7 +34,7 @@ function Row(_ref) {
|
|
|
34
34
|
}, children);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
var StyledRow = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n flex-wrap: ", ";\n align-items: ", "
|
|
37
|
+
var StyledRow = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n flex-wrap: ", ";\n align-items: ", ";\n justify-content: ", ";\n gap: ", ";\n"])), function (_ref2) {
|
|
38
38
|
var reverse = _ref2.reverse;
|
|
39
39
|
return reverse ? "row-reverse" : "row";
|
|
40
40
|
}, function (_ref3) {
|
|
@@ -94,30 +94,33 @@ var StyledRow = _styledComponents["default"].div(_templateObject || (_templateOb
|
|
|
94
94
|
case "none":
|
|
95
95
|
return "0";
|
|
96
96
|
|
|
97
|
-
case "
|
|
97
|
+
case "xxxsmall":
|
|
98
98
|
return "0.125rem";
|
|
99
99
|
|
|
100
|
-
case "
|
|
100
|
+
case "xxsmall":
|
|
101
101
|
return "0.25rem";
|
|
102
102
|
|
|
103
|
-
case "
|
|
103
|
+
case "xsmall":
|
|
104
104
|
return "0.5rem";
|
|
105
105
|
|
|
106
|
-
case "
|
|
106
|
+
case "small":
|
|
107
107
|
return "1rem";
|
|
108
108
|
|
|
109
|
-
case "
|
|
109
|
+
case "medium":
|
|
110
110
|
return "1.5rem";
|
|
111
111
|
|
|
112
|
-
case "
|
|
112
|
+
case "large":
|
|
113
113
|
return "2rem";
|
|
114
114
|
|
|
115
|
-
case "
|
|
115
|
+
case "xlarge":
|
|
116
116
|
return "3rem";
|
|
117
117
|
|
|
118
|
-
case "
|
|
118
|
+
case "xxlarge":
|
|
119
119
|
return "4rem";
|
|
120
120
|
|
|
121
|
+
case "xxxlarge":
|
|
122
|
+
return "5rem";
|
|
123
|
+
|
|
121
124
|
default:
|
|
122
125
|
return "0";
|
|
123
126
|
}
|
package/row/Row.stories.tsx
CHANGED
|
@@ -106,6 +106,14 @@ export const Chromatic = () => (
|
|
|
106
106
|
<Placeholder paddingTop={60}></Placeholder>
|
|
107
107
|
</DxcRow>
|
|
108
108
|
</Container>
|
|
109
|
+
<Title title="gutter = xxxsmall" theme="light" level={4} />
|
|
110
|
+
<Container>
|
|
111
|
+
<DxcRow gutter="xxxsmall">
|
|
112
|
+
<Placeholder></Placeholder>
|
|
113
|
+
<Placeholder></Placeholder>
|
|
114
|
+
<Placeholder></Placeholder>
|
|
115
|
+
</DxcRow>
|
|
116
|
+
</Container>
|
|
109
117
|
<Title title="gutter = xxsmall" theme="light" level={4} />
|
|
110
118
|
<Container>
|
|
111
119
|
<DxcRow gutter="xxsmall">
|
|
@@ -162,6 +170,14 @@ export const Chromatic = () => (
|
|
|
162
170
|
<Placeholder></Placeholder>
|
|
163
171
|
</DxcRow>
|
|
164
172
|
</Container>
|
|
173
|
+
<Title title="gutter = xxxlarge" theme="light" level={4} />
|
|
174
|
+
<Container>
|
|
175
|
+
<DxcRow gutter="xxxlarge">
|
|
176
|
+
<Placeholder></Placeholder>
|
|
177
|
+
<Placeholder></Placeholder>
|
|
178
|
+
<Placeholder></Placeholder>
|
|
179
|
+
</DxcRow>
|
|
180
|
+
</Container>
|
|
165
181
|
<Title title="gutter = none" theme="light" level={4} />
|
|
166
182
|
<Container>
|
|
167
183
|
<DxcRow gutter="none">
|
|
@@ -206,18 +222,16 @@ export const Chromatic = () => (
|
|
|
206
222
|
);
|
|
207
223
|
|
|
208
224
|
const Container = styled.div`
|
|
209
|
-
background: #
|
|
225
|
+
background: #f2eafa;
|
|
210
226
|
padding: 10px;
|
|
211
|
-
border-radius: 10px;
|
|
212
227
|
width: ${({ width }) => (width ? `${width}px` : "unset")};
|
|
213
228
|
`;
|
|
214
229
|
|
|
215
230
|
const Placeholder = styled.div`
|
|
216
|
-
min-height:
|
|
231
|
+
min-height: 40px;
|
|
217
232
|
min-width: 120px;
|
|
218
|
-
border: 1px solid #
|
|
219
|
-
background-color: #
|
|
220
|
-
border-radius: 5px;
|
|
233
|
+
border: 1px solid #a46ede;
|
|
234
|
+
background-color: #e5d5f6;
|
|
221
235
|
padding-top: ${({ paddingTop }) => `${paddingTop ?? 0}px`};
|
|
222
236
|
padding-bottom: ${({ paddingBottom }) => `${paddingBottom ?? 0}px`};
|
|
223
237
|
`;
|
package/row/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Props = {
|
|
3
|
+
/**
|
|
4
|
+
* Space applied between each child.
|
|
5
|
+
*/
|
|
6
|
+
gutter?: "none" | "xxxsmall" | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge";
|
|
7
|
+
/**
|
|
8
|
+
* Alignment applied to children.
|
|
9
|
+
*/
|
|
10
|
+
align?: "start" | "center" | "end" | "baseline" | "stretch";
|
|
11
|
+
/**
|
|
12
|
+
* Justification applied to children.
|
|
13
|
+
*/
|
|
14
|
+
justify?: "start" | "center" | "end" | "spaceBetween" | "spaceAround" | "spaceEvenly";
|
|
15
|
+
/**
|
|
16
|
+
* If true, children will wrap onto multiple rows.
|
|
17
|
+
*/
|
|
18
|
+
wrap?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* If true, children are shown in reverse order.
|
|
21
|
+
*/
|
|
22
|
+
reverse?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Custom content inside the row.
|
|
25
|
+
*/
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
};
|
|
28
|
+
export default Props;
|
package/row/types.js
ADDED