@dxc-technology/halstack-react 0.0.0-adde6ce → 0.0.0-adfc848
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/README.md +46 -0
- package/dist/index.d.mts +4011 -0
- package/dist/index.d.ts +4011 -0
- package/dist/index.js +14933 -0
- package/dist/index.mjs +14844 -0
- package/package.json +86 -71
- package/BackgroundColorContext.d.ts +0 -10
- package/BackgroundColorContext.js +0 -47
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -243
- 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/accordion/Accordion.d.ts +0 -4
- package/accordion/Accordion.js +0 -258
- package/accordion/Accordion.stories.tsx +0 -307
- package/accordion/types.d.ts +0 -68
- package/accordion/types.js +0 -5
- package/accordion-group/AccordionGroup.d.ts +0 -7
- package/accordion-group/AccordionGroup.js +0 -170
- package/accordion-group/AccordionGroup.stories.tsx +0 -225
- package/accordion-group/types.d.ts +0 -72
- package/accordion-group/types.js +0 -5
- package/alert/Alert.d.ts +0 -4
- package/alert/Alert.js +0 -290
- package/alert/Alert.stories.tsx +0 -170
- package/alert/types.d.ts +0 -49
- package/alert/types.js +0 -5
- package/badge/Badge.js +0 -59
- package/box/Box.d.ts +0 -4
- package/box/Box.js +0 -126
- package/box/Box.stories.tsx +0 -132
- package/box/types.d.ts +0 -43
- package/box/types.js +0 -5
- package/button/Button.d.ts +0 -4
- package/button/Button.js +0 -179
- package/button/Button.stories.tsx +0 -276
- package/button/types.d.ts +0 -57
- package/button/types.js +0 -5
- package/card/Card.d.ts +0 -4
- package/card/Card.js +0 -164
- package/card/Card.stories.tsx +0 -201
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +0 -67
- package/card/types.js +0 -5
- package/checkbox/Checkbox.d.ts +0 -4
- package/checkbox/Checkbox.js +0 -253
- package/checkbox/Checkbox.stories.tsx +0 -192
- package/checkbox/types.d.ts +0 -60
- package/checkbox/types.js +0 -5
- package/chip/Chip.d.ts +0 -4
- package/chip/Chip.js +0 -199
- package/chip/Chip.stories.tsx +0 -121
- package/chip/types.d.ts +0 -53
- package/chip/types.js +0 -5
- package/common/OpenSans.css +0 -81
- package/common/RequiredComponent.js +0 -32
- package/common/fonts/OpenSans-Bold.ttf +0 -0
- package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-Italic.ttf +0 -0
- package/common/fonts/OpenSans-Light.ttf +0 -0
- package/common/fonts/OpenSans-LightItalic.ttf +0 -0
- package/common/fonts/OpenSans-Regular.ttf +0 -0
- package/common/fonts/OpenSans-SemiBold.ttf +0 -0
- package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/common/utils.js +0 -22
- package/common/variables.js +0 -1612
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/date-input/DateInput.d.ts +0 -4
- package/date-input/DateInput.js +0 -358
- package/date-input/DateInput.stories.tsx +0 -138
- package/date-input/types.d.ts +0 -100
- package/date-input/types.js +0 -5
- package/dialog/Dialog.d.ts +0 -4
- package/dialog/Dialog.js +0 -166
- package/dialog/Dialog.stories.tsx +0 -212
- package/dialog/types.d.ts +0 -43
- package/dialog/types.js +0 -5
- package/dropdown/Dropdown.d.ts +0 -4
- package/dropdown/Dropdown.js +0 -417
- package/dropdown/Dropdown.stories.tsx +0 -247
- package/dropdown/types.d.ts +0 -89
- package/dropdown/types.js +0 -5
- package/file-input/FileInput.d.ts +0 -4
- package/file-input/FileInput.js +0 -590
- package/file-input/FileInput.stories.tsx +0 -507
- package/file-input/FileItem.d.ts +0 -14
- package/file-input/FileItem.js +0 -184
- package/file-input/types.d.ts +0 -112
- package/file-input/types.js +0 -5
- package/footer/Footer.d.ts +0 -4
- package/footer/Footer.js +0 -260
- package/footer/Footer.stories.tsx +0 -130
- package/footer/Icons.d.ts +0 -2
- package/footer/Icons.js +0 -77
- package/footer/types.d.ts +0 -65
- package/footer/types.js +0 -5
- package/header/Header.d.ts +0 -7
- package/header/Header.js +0 -324
- package/header/Header.stories.tsx +0 -162
- package/header/Icons.d.ts +0 -2
- package/header/Icons.js +0 -34
- package/header/types.d.ts +0 -47
- package/header/types.js +0 -5
- package/heading/Heading.d.ts +0 -4
- package/heading/Heading.js +0 -159
- package/heading/Heading.stories.tsx +0 -54
- package/heading/types.d.ts +0 -33
- package/heading/types.js +0 -5
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/layout/ApplicationLayout.d.ts +0 -10
- package/layout/ApplicationLayout.js +0 -225
- package/layout/ApplicationLayout.stories.tsx +0 -171
- package/layout/Icons.js +0 -55
- package/layout/types.d.ts +0 -57
- package/layout/types.js +0 -5
- package/link/Link.d.ts +0 -3
- package/link/Link.js +0 -161
- package/link/Link.stories.tsx +0 -146
- package/link/types.d.ts +0 -74
- package/link/types.js +0 -5
- package/list/List.d.ts +0 -8
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/main.d.ts +0 -48
- package/main.js +0 -395
- package/number-input/NumberInput.d.ts +0 -4
- package/number-input/NumberInput.js +0 -83
- package/number-input/NumberInput.stories.tsx +0 -115
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/number-input/numberInputContextTypes.js +0 -5
- package/number-input/types.d.ts +0 -117
- package/number-input/types.js +0 -5
- package/paginator/Icons.js +0 -66
- package/paginator/Paginator.d.ts +0 -4
- package/paginator/Paginator.js +0 -192
- package/paginator/Paginator.stories.tsx +0 -63
- package/paginator/types.d.ts +0 -38
- package/paginator/types.js +0 -5
- package/password-input/PasswordInput.d.ts +0 -4
- package/password-input/PasswordInput.js +0 -163
- package/password-input/PasswordInput.stories.tsx +0 -131
- package/password-input/types.d.ts +0 -107
- package/password-input/types.js +0 -5
- package/progress-bar/ProgressBar.d.ts +0 -4
- package/progress-bar/ProgressBar.js +0 -170
- package/progress-bar/ProgressBar.stories.jsx +0 -58
- package/progress-bar/types.d.ts +0 -37
- package/progress-bar/types.js +0 -5
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/radio/types.js +0 -5
- package/radio-group/Radio.d.ts +0 -4
- package/radio-group/Radio.js +0 -130
- package/radio-group/RadioGroup.d.ts +0 -4
- package/radio-group/RadioGroup.js +0 -268
- package/radio-group/RadioGroup.stories.tsx +0 -79
- package/radio-group/types.d.ts +0 -36
- package/radio-group/types.js +0 -5
- package/resultsetTable/ResultsetTable.d.ts +0 -4
- package/resultsetTable/ResultsetTable.js +0 -251
- package/resultsetTable/ResultsetTable.stories.tsx +0 -277
- package/resultsetTable/types.d.ts +0 -67
- package/resultsetTable/types.js +0 -5
- package/row/Row.d.ts +0 -11
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -239
- package/select/Select.d.ts +0 -4
- package/select/Select.js +0 -863
- package/select/Select.stories.tsx +0 -572
- package/select/types.d.ts +0 -170
- package/select/types.js +0 -5
- package/sidenav/Sidenav.d.ts +0 -9
- package/sidenav/Sidenav.js +0 -136
- package/sidenav/Sidenav.stories.tsx +0 -182
- package/sidenav/types.d.ts +0 -50
- package/sidenav/types.js +0 -5
- package/slider/Slider.d.ts +0 -4
- package/slider/Slider.js +0 -317
- package/slider/Slider.stories.tsx +0 -177
- package/slider/types.d.ts +0 -78
- package/slider/types.js +0 -5
- package/spinner/Spinner.d.ts +0 -4
- package/spinner/Spinner.js +0 -250
- package/spinner/Spinner.stories.jsx +0 -103
- package/spinner/types.d.ts +0 -32
- package/spinner/types.js +0 -5
- package/stack/Stack.d.ts +0 -10
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -166
- package/switch/Switch.d.ts +0 -4
- package/switch/Switch.js +0 -179
- package/switch/Switch.stories.tsx +0 -160
- package/switch/types.d.ts +0 -58
- package/switch/types.js +0 -5
- package/table/Table.d.ts +0 -4
- package/table/Table.js +0 -118
- package/table/Table.stories.jsx +0 -277
- package/table/types.d.ts +0 -21
- package/table/types.js +0 -5
- package/tabs/Tabs.d.ts +0 -4
- package/tabs/Tabs.js +0 -213
- package/tabs/Tabs.stories.tsx +0 -122
- package/tabs/types.d.ts +0 -70
- package/tabs/types.js +0 -5
- package/tag/Tag.d.ts +0 -4
- package/tag/Tag.js +0 -193
- package/tag/Tag.stories.tsx +0 -145
- package/tag/types.d.ts +0 -60
- package/tag/types.js +0 -5
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/text-input/TextInput.d.ts +0 -4
- package/text-input/TextInput.js +0 -786
- package/text-input/TextInput.stories.tsx +0 -456
- package/text-input/types.d.ts +0 -159
- package/text-input/types.js +0 -5
- package/textarea/Textarea.d.ts +0 -4
- package/textarea/Textarea.js +0 -284
- package/textarea/Textarea.stories.jsx +0 -136
- package/textarea/types.d.ts +0 -130
- package/textarea/types.js +0 -5
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/toggle-group/ToggleGroup.d.ts +0 -4
- package/toggle-group/ToggleGroup.js +0 -214
- package/toggle-group/ToggleGroup.stories.tsx +0 -173
- package/toggle-group/types.d.ts +0 -97
- package/toggle-group/types.js +0 -5
- 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/useTheme.d.ts +0 -2
- package/useTheme.js +0 -22
- package/wizard/Wizard.d.ts +0 -4
- package/wizard/Wizard.js +0 -281
- package/wizard/Wizard.stories.tsx +0 -224
- package/wizard/types.d.ts +0 -60
- package/wizard/types.js +0 -5
|
@@ -1,268 +0,0 @@
|
|
|
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 _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
|
-
var _uuid = require("uuid");
|
|
23
|
-
|
|
24
|
-
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
|
-
|
|
26
|
-
var _Radio = _interopRequireDefault(require("./Radio"));
|
|
27
|
-
|
|
28
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
29
|
-
|
|
30
|
-
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); }
|
|
31
|
-
|
|
32
|
-
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; }
|
|
33
|
-
|
|
34
|
-
var getInitialFocusIndex = function getInitialFocusIndex(innerOptions, value) {
|
|
35
|
-
var initialSelectedOptionIndex = innerOptions.findIndex(function (option) {
|
|
36
|
-
return option.value === value;
|
|
37
|
-
});
|
|
38
|
-
return initialSelectedOptionIndex !== -1 ? initialSelectedOptionIndex : 0;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
42
|
-
var label = _ref.label,
|
|
43
|
-
name = _ref.name,
|
|
44
|
-
helperText = _ref.helperText,
|
|
45
|
-
options = _ref.options,
|
|
46
|
-
_ref$disabled = _ref.disabled,
|
|
47
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
48
|
-
_ref$optional = _ref.optional,
|
|
49
|
-
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
50
|
-
_ref$optionalItemLabe = _ref.optionalItemLabel,
|
|
51
|
-
optionalItemLabel = _ref$optionalItemLabe === void 0 ? "N/A" : _ref$optionalItemLabe,
|
|
52
|
-
_ref$readonly = _ref.readonly,
|
|
53
|
-
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
54
|
-
_ref$stacking = _ref.stacking,
|
|
55
|
-
stacking = _ref$stacking === void 0 ? "column" : _ref$stacking,
|
|
56
|
-
defaultValue = _ref.defaultValue,
|
|
57
|
-
value = _ref.value,
|
|
58
|
-
onChange = _ref.onChange,
|
|
59
|
-
onBlur = _ref.onBlur,
|
|
60
|
-
error = _ref.error;
|
|
61
|
-
|
|
62
|
-
var _useState = (0, _react.useState)("select-".concat((0, _uuid.v4)())),
|
|
63
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
64
|
-
radioGroupId = _useState2[0];
|
|
65
|
-
|
|
66
|
-
var radioGroupLabelId = "label-".concat(radioGroupId);
|
|
67
|
-
|
|
68
|
-
var _useState3 = (0, _react.useState)(defaultValue),
|
|
69
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
70
|
-
innerValue = _useState4[0],
|
|
71
|
-
setInnerValue = _useState4[1];
|
|
72
|
-
|
|
73
|
-
var _useState5 = (0, _react.useState)(true),
|
|
74
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
75
|
-
firstTimeFocus = _useState6[0],
|
|
76
|
-
setFirstTimeFocus = _useState6[1];
|
|
77
|
-
|
|
78
|
-
var optionalItem = {
|
|
79
|
-
label: optionalItemLabel,
|
|
80
|
-
value: "",
|
|
81
|
-
disabled: disabled
|
|
82
|
-
};
|
|
83
|
-
var innerOptions = (0, _react.useMemo)(function () {
|
|
84
|
-
return optional ? [].concat((0, _toConsumableArray2["default"])(options), [optionalItem]) : options;
|
|
85
|
-
}, [optional, options]);
|
|
86
|
-
|
|
87
|
-
var _useState7 = (0, _react.useState)(getInitialFocusIndex(innerOptions, value !== null && value !== void 0 ? value : innerValue)),
|
|
88
|
-
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
89
|
-
currentFocusIndex = _useState8[0],
|
|
90
|
-
setCurrentFocusIndex = _useState8[1];
|
|
91
|
-
|
|
92
|
-
var colorsTheme = (0, _useTheme["default"])();
|
|
93
|
-
var handleOnChange = (0, _react.useCallback)(function (newValue) {
|
|
94
|
-
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
95
|
-
|
|
96
|
-
if (newValue !== currentValue && !readonly) {
|
|
97
|
-
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
98
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
99
|
-
}
|
|
100
|
-
}, [value, innerValue, setInnerValue, onChange]);
|
|
101
|
-
|
|
102
|
-
var handleOnBlur = function handleOnBlur(e) {
|
|
103
|
-
// If the radio group loses the focus to an element not contained inside it...
|
|
104
|
-
!e.currentTarget.contains(e.relatedTarget) && setFirstTimeFocus(true);
|
|
105
|
-
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
106
|
-
!optional && !Boolean(currentValue) ? onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
107
|
-
value: currentValue,
|
|
108
|
-
error: "This field is required. Please, choose an option."
|
|
109
|
-
}) : onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
110
|
-
value: currentValue
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
var setPreviousRadioChecked = function setPreviousRadioChecked() {
|
|
115
|
-
if (!disabled) {
|
|
116
|
-
setCurrentFocusIndex(function (currentFocusIndex) {
|
|
117
|
-
var index = currentFocusIndex === 0 ? innerOptions.length - 1 : currentFocusIndex - 1;
|
|
118
|
-
|
|
119
|
-
while (innerOptions[index].disabled) {
|
|
120
|
-
index = index === 0 ? innerOptions.length - 1 : index - 1;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return index;
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
var setNextRadioChecked = function setNextRadioChecked() {
|
|
129
|
-
if (!disabled) {
|
|
130
|
-
setCurrentFocusIndex(function (currentFocusIndex) {
|
|
131
|
-
var index = currentFocusIndex === innerOptions.length - 1 ? 0 : currentFocusIndex + 1;
|
|
132
|
-
|
|
133
|
-
while (innerOptions[index].disabled) {
|
|
134
|
-
index = index === innerOptions.length - 1 ? 0 : index + 1;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return index;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
143
|
-
switch (event.keyCode) {
|
|
144
|
-
case 37: // arrow left
|
|
145
|
-
|
|
146
|
-
case 38:
|
|
147
|
-
// arrow up
|
|
148
|
-
event.preventDefault();
|
|
149
|
-
setPreviousRadioChecked();
|
|
150
|
-
break;
|
|
151
|
-
|
|
152
|
-
case 39: // arrow right
|
|
153
|
-
|
|
154
|
-
case 40:
|
|
155
|
-
// arrow down
|
|
156
|
-
event.preventDefault();
|
|
157
|
-
setNextRadioChecked();
|
|
158
|
-
break;
|
|
159
|
-
|
|
160
|
-
case 13: // enter
|
|
161
|
-
|
|
162
|
-
case 32:
|
|
163
|
-
// space
|
|
164
|
-
event.preventDefault();
|
|
165
|
-
handleOnChange(innerOptions[currentFocusIndex].value);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
171
|
-
theme: colorsTheme.radioGroup
|
|
172
|
-
}, /*#__PURE__*/_react["default"].createElement(RadioGroupContainer, {
|
|
173
|
-
ref: ref
|
|
174
|
-
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
175
|
-
id: radioGroupLabelId,
|
|
176
|
-
helperText: helperText,
|
|
177
|
-
disabled: disabled
|
|
178
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, "(Optional)")), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
179
|
-
disabled: disabled
|
|
180
|
-
}, helperText), /*#__PURE__*/_react["default"].createElement(RadioGroup, {
|
|
181
|
-
onBlur: handleOnBlur,
|
|
182
|
-
onKeyDown: handleOnKeyDown,
|
|
183
|
-
stacking: stacking,
|
|
184
|
-
role: "radiogroup",
|
|
185
|
-
"aria-disabled": disabled,
|
|
186
|
-
"aria-labelledby": radioGroupLabelId,
|
|
187
|
-
"aria-invalid": error ? "true" : "false",
|
|
188
|
-
"aria-required": !optional
|
|
189
|
-
}, /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
190
|
-
name: name,
|
|
191
|
-
value: value !== null && value !== void 0 ? value : innerValue,
|
|
192
|
-
readOnly: true,
|
|
193
|
-
"aria-hidden": "true"
|
|
194
|
-
}), innerOptions.map(function (option, index) {
|
|
195
|
-
return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
|
|
196
|
-
option: option,
|
|
197
|
-
currentValue: value !== null && value !== void 0 ? value : innerValue,
|
|
198
|
-
onClick: function onClick() {
|
|
199
|
-
handleOnChange(option.value);
|
|
200
|
-
setCurrentFocusIndex(index);
|
|
201
|
-
},
|
|
202
|
-
onFocus: function onFocus() {
|
|
203
|
-
!firstTimeFocus ? handleOnChange(option.value) : setFirstTimeFocus(false);
|
|
204
|
-
},
|
|
205
|
-
error: error,
|
|
206
|
-
disabled: option.disabled || disabled,
|
|
207
|
-
focused: currentFocusIndex === index,
|
|
208
|
-
readonly: readonly
|
|
209
|
-
});
|
|
210
|
-
})), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, null, error)));
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
var RadioGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n"])));
|
|
214
|
-
|
|
215
|
-
var Label = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
|
|
216
|
-
return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
|
|
217
|
-
}, function (props) {
|
|
218
|
-
return props.theme.fontFamily;
|
|
219
|
-
}, function (props) {
|
|
220
|
-
return props.theme.labelFontSize;
|
|
221
|
-
}, function (props) {
|
|
222
|
-
return props.theme.labelFontStyle;
|
|
223
|
-
}, function (props) {
|
|
224
|
-
return props.theme.labelFontWeight;
|
|
225
|
-
}, function (props) {
|
|
226
|
-
return props.theme.labelLineHeight;
|
|
227
|
-
}, function (props) {
|
|
228
|
-
return !props.helperText && "margin-bottom: ".concat(props.theme.groupLabelMargin);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
232
|
-
return props.theme.optionalLabelFontWeight;
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
var HelperText = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin-bottom: ", ";\n"])), function (props) {
|
|
236
|
-
return props.disabled ? props.theme.disabledHelperTextFontColor : props.theme.helperTextFontColor;
|
|
237
|
-
}, function (props) {
|
|
238
|
-
return props.theme.fontFamily;
|
|
239
|
-
}, function (props) {
|
|
240
|
-
return props.theme.helperTextFontSize;
|
|
241
|
-
}, function (props) {
|
|
242
|
-
return props.theme.helperTextFontStyle;
|
|
243
|
-
}, function (props) {
|
|
244
|
-
return props.theme.helperTextFontWeight;
|
|
245
|
-
}, function (props) {
|
|
246
|
-
return props.theme.helperTextLineHeight;
|
|
247
|
-
}, function (props) {
|
|
248
|
-
return props.theme.groupLabelMargin;
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
var RadioGroup = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n\n row-gap: ", ";\n column-gap: ", ";\n"])), function (props) {
|
|
252
|
-
return props.stacking;
|
|
253
|
-
}, function (props) {
|
|
254
|
-
return props.theme.groupVerticalGutter;
|
|
255
|
-
}, function (props) {
|
|
256
|
-
return props.theme.groupHorizontalGutter;
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
var ValueInput = _styledComponents["default"].input(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
|
|
260
|
-
|
|
261
|
-
var Error = _styledComponents["default"].span(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n margin-top: 0.5rem;\n"])), function (props) {
|
|
262
|
-
return props.theme.errorMessageColor;
|
|
263
|
-
}, function (props) {
|
|
264
|
-
return props.theme.fontFamily;
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
var _default = DxcRadioGroup;
|
|
268
|
-
exports["default"] = _default;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
2
|
-
import Title from "../../.storybook/components/Title";
|
|
3
|
-
import DxcRadioGroup from "./RadioGroup";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: "Radio Group",
|
|
7
|
-
component: DxcRadioGroup,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const options = [
|
|
11
|
-
{ label: "Option 1", value: "1" },
|
|
12
|
-
{ label: "Option 2", value: "2" },
|
|
13
|
-
{ label: "Option 3", value: "3" },
|
|
14
|
-
{ label: "Option 4", value: "4" },
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
const single_disabled_options = [
|
|
18
|
-
{ label: "Option 1", value: "1" },
|
|
19
|
-
{ label: "Option 2", value: "2", disabled: true },
|
|
20
|
-
{ label: "Option 3", value: "3" },
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
export const Chromatic = () => (
|
|
24
|
-
<>
|
|
25
|
-
<ExampleContainer>
|
|
26
|
-
<Title title="Label only" theme="light" level={4} />
|
|
27
|
-
<DxcRadioGroup label="Example of label" options={options}/>
|
|
28
|
-
</ExampleContainer>
|
|
29
|
-
<ExampleContainer>
|
|
30
|
-
<Title title="Column" theme="light" level={4} />
|
|
31
|
-
<DxcRadioGroup label="Example" helperText="Helper text" options={options} defaultValue="3" />
|
|
32
|
-
</ExampleContainer>
|
|
33
|
-
<ExampleContainer>
|
|
34
|
-
<Title title="Row" theme="light" level={4} />
|
|
35
|
-
<DxcRadioGroup label="Example" helperText="Helper text" options={options} stacking="row" />
|
|
36
|
-
</ExampleContainer>
|
|
37
|
-
<ExampleContainer>
|
|
38
|
-
<Title title="Disabled" theme="light" level={4} />
|
|
39
|
-
<DxcRadioGroup
|
|
40
|
-
label="Disabled"
|
|
41
|
-
error="Error message"
|
|
42
|
-
helperText="Helper text"
|
|
43
|
-
options={options}
|
|
44
|
-
disabled
|
|
45
|
-
optional
|
|
46
|
-
defaultValue="2"
|
|
47
|
-
/>
|
|
48
|
-
</ExampleContainer>
|
|
49
|
-
<ExampleContainer>
|
|
50
|
-
<Title title="Single disabled" theme="light" level={4} />
|
|
51
|
-
<DxcRadioGroup label="Disabled" helperText="Helper text" options={single_disabled_options} defaultValue="3" />
|
|
52
|
-
</ExampleContainer>
|
|
53
|
-
<ExampleContainer>
|
|
54
|
-
<Title title="Optional" theme="light" level={4} />
|
|
55
|
-
<DxcRadioGroup
|
|
56
|
-
label="Example"
|
|
57
|
-
optionalItemLabel="No selection"
|
|
58
|
-
optional
|
|
59
|
-
helperText="Helper text"
|
|
60
|
-
options={options}
|
|
61
|
-
stacking="row"
|
|
62
|
-
/>
|
|
63
|
-
</ExampleContainer>
|
|
64
|
-
<ExampleContainer>
|
|
65
|
-
<Title title="Error" theme="light" level={4} />
|
|
66
|
-
<DxcRadioGroup
|
|
67
|
-
label="Example"
|
|
68
|
-
error="Error message"
|
|
69
|
-
helperText="Helper text"
|
|
70
|
-
options={options}
|
|
71
|
-
defaultValue="2"
|
|
72
|
-
/>
|
|
73
|
-
</ExampleContainer>
|
|
74
|
-
<ExampleContainer>
|
|
75
|
-
<Title title="Readonly" theme="light" level={4} />
|
|
76
|
-
<DxcRadioGroup label="Example" readonly helperText="Helper text" options={options} defaultValue="2" />
|
|
77
|
-
</ExampleContainer>
|
|
78
|
-
</>
|
|
79
|
-
);
|
package/radio-group/types.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export declare type Option = {
|
|
2
|
-
value: string;
|
|
3
|
-
label: string;
|
|
4
|
-
disabled?: boolean;
|
|
5
|
-
};
|
|
6
|
-
declare type RadioGroupProps = {
|
|
7
|
-
label: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
helperText?: string;
|
|
10
|
-
options: Option[];
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
optional?: boolean;
|
|
13
|
-
optionalItemLabel?: string;
|
|
14
|
-
readonly?: boolean;
|
|
15
|
-
stacking?: "row" | "column";
|
|
16
|
-
defaultValue?: string;
|
|
17
|
-
value?: string;
|
|
18
|
-
onChange?: (value: string) => void;
|
|
19
|
-
onBlur?: (val: {
|
|
20
|
-
value?: string;
|
|
21
|
-
error?: string;
|
|
22
|
-
}) => void;
|
|
23
|
-
error?: string;
|
|
24
|
-
};
|
|
25
|
-
export declare type RefType = HTMLDivElement;
|
|
26
|
-
export declare type RadioProps = {
|
|
27
|
-
option: Option;
|
|
28
|
-
currentValue?: string;
|
|
29
|
-
onClick: () => void;
|
|
30
|
-
onFocus: () => void;
|
|
31
|
-
error?: string;
|
|
32
|
-
disabled: boolean;
|
|
33
|
-
focused: boolean;
|
|
34
|
-
readonly: boolean;
|
|
35
|
-
};
|
|
36
|
-
export default RadioGroupProps;
|
package/radio-group/types.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import ResultsetTablePropsType from "./types";
|
|
3
|
-
declare const DxcResultsetTable: ({ columns, rows, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, margin, tabIndex, }: ResultsetTablePropsType) => JSX.Element;
|
|
4
|
-
export default DxcResultsetTable;
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
|
|
12
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
-
|
|
18
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
|
-
var _variables = require("../common/variables.js");
|
|
23
|
-
|
|
24
|
-
var _Table = _interopRequireDefault(require("../table/Table"));
|
|
25
|
-
|
|
26
|
-
var _Paginator = _interopRequireDefault(require("../paginator/Paginator"));
|
|
27
|
-
|
|
28
|
-
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
29
|
-
|
|
30
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
31
|
-
|
|
32
|
-
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
|
-
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
35
|
-
|
|
36
|
-
function normalizeSortValue(sortValue) {
|
|
37
|
-
return typeof sortValue === "string" ? sortValue.toUpperCase() : sortValue;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function sortArray(index, order, resultset) {
|
|
41
|
-
return resultset.slice().sort(function (element1, element2) {
|
|
42
|
-
var sortValueA = normalizeSortValue(element1[index].sortValue || element1[index].displayValue);
|
|
43
|
-
var sortValueB = normalizeSortValue(element2[index].sortValue || element2[index].displayValue);
|
|
44
|
-
var comparison = 0;
|
|
45
|
-
|
|
46
|
-
if ((0, _typeof2["default"])(sortValueA) === "object") {
|
|
47
|
-
comparison = -1;
|
|
48
|
-
} else if ((0, _typeof2["default"])(sortValueB) === "object") {
|
|
49
|
-
comparison = 1;
|
|
50
|
-
} else if (sortValueA > sortValueB) {
|
|
51
|
-
comparison = 1;
|
|
52
|
-
} else if (sortValueA < sortValueB) {
|
|
53
|
-
comparison = -1;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return order === "desc" ? comparison * -1 : comparison;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var getMinItemsPerPageIndex = function getMinItemsPerPageIndex(currentPageInternal, itemsPerPage, page) {
|
|
61
|
-
return currentPageInternal === 1 ? 0 : itemsPerPage * (page - 1);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
var getMaxItemsPerPageIndex = function getMaxItemsPerPageIndex(minItemsPerPageIndex, itemsPerPage, resultset, page) {
|
|
65
|
-
return minItemsPerPageIndex + itemsPerPage > resultset.length ? resultset.length : itemsPerPage * page - 1;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var ArrowUp = function ArrowUp() {
|
|
69
|
-
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
70
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
71
|
-
height: "24",
|
|
72
|
-
viewBox: "0 0 24 24",
|
|
73
|
-
width: "24",
|
|
74
|
-
fill: "currentColor"
|
|
75
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
76
|
-
d: "M0 0h24v24H0V0z",
|
|
77
|
-
fill: "none"
|
|
78
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
79
|
-
d: "M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"
|
|
80
|
-
}));
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
var ArrowDown = function ArrowDown() {
|
|
84
|
-
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
85
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
86
|
-
height: "24",
|
|
87
|
-
viewBox: "0 0 24 24",
|
|
88
|
-
width: "24",
|
|
89
|
-
fill: "currentColor"
|
|
90
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
91
|
-
d: "M0 0h24v24H0V0z",
|
|
92
|
-
fill: "none"
|
|
93
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
94
|
-
d: "M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
|
|
95
|
-
}));
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
var BothArrows = function BothArrows() {
|
|
99
|
-
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
100
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
101
|
-
height: "24",
|
|
102
|
-
viewBox: "0 0 24 24",
|
|
103
|
-
width: "24",
|
|
104
|
-
fill: "currentColor"
|
|
105
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
106
|
-
d: "M0 0h24v24H0z",
|
|
107
|
-
fill: "none"
|
|
108
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
109
|
-
d: "M12 5.83L15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9 12 5.83zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15 12 18.17z"
|
|
110
|
-
}));
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
114
|
-
var columns = _ref.columns,
|
|
115
|
-
rows = _ref.rows,
|
|
116
|
-
_ref$showGoToPage = _ref.showGoToPage,
|
|
117
|
-
showGoToPage = _ref$showGoToPage === void 0 ? true : _ref$showGoToPage,
|
|
118
|
-
_ref$itemsPerPage = _ref.itemsPerPage,
|
|
119
|
-
itemsPerPage = _ref$itemsPerPage === void 0 ? 5 : _ref$itemsPerPage,
|
|
120
|
-
itemsPerPageOptions = _ref.itemsPerPageOptions,
|
|
121
|
-
itemsPerPageFunction = _ref.itemsPerPageFunction,
|
|
122
|
-
margin = _ref.margin,
|
|
123
|
-
_ref$tabIndex = _ref.tabIndex,
|
|
124
|
-
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
125
|
-
var colorsTheme = (0, _useTheme["default"])();
|
|
126
|
-
|
|
127
|
-
var _useState = (0, _react.useState)(1),
|
|
128
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
129
|
-
page = _useState2[0],
|
|
130
|
-
changePage = _useState2[1];
|
|
131
|
-
|
|
132
|
-
var _useState3 = (0, _react.useState)(""),
|
|
133
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
134
|
-
sortColumnIndex = _useState4[0],
|
|
135
|
-
changeSortColumnIndex = _useState4[1];
|
|
136
|
-
|
|
137
|
-
var _useState5 = (0, _react.useState)("asc"),
|
|
138
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
139
|
-
sortOrder = _useState6[0],
|
|
140
|
-
changeSortOrder = _useState6[1];
|
|
141
|
-
|
|
142
|
-
var minItemsPerPageIndex = (0, _react.useMemo)(function () {
|
|
143
|
-
return getMinItemsPerPageIndex(page, itemsPerPage, page);
|
|
144
|
-
}, [itemsPerPage, page]);
|
|
145
|
-
var maxItemsPerPageIndex = (0, _react.useMemo)(function () {
|
|
146
|
-
return getMaxItemsPerPageIndex(minItemsPerPageIndex, itemsPerPage, rows, page);
|
|
147
|
-
}, [itemsPerPage, minItemsPerPageIndex, page, rows]);
|
|
148
|
-
|
|
149
|
-
var goToPage = function goToPage(newPage) {
|
|
150
|
-
changePage(newPage);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
var changeSorting = function changeSorting(columnIndex) {
|
|
154
|
-
changePage(1);
|
|
155
|
-
changeSortColumnIndex(columnIndex);
|
|
156
|
-
changeSortOrder(sortColumnIndex === "" || sortColumnIndex !== columnIndex ? "asc" : sortOrder === "asc" ? "desc" : "asc");
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
var getIconForSortableColumn = function getIconForSortableColumn(clickedColumnIndex) {
|
|
160
|
-
return sortColumnIndex === clickedColumnIndex ? sortOrder === "asc" ? /*#__PURE__*/_react["default"].createElement(ArrowUp, null) : /*#__PURE__*/_react["default"].createElement(ArrowDown, null) : /*#__PURE__*/_react["default"].createElement(BothArrows, null);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
(0, _react.useEffect)(function () {
|
|
164
|
-
if (rows.length > 0) {
|
|
165
|
-
changePage(1);
|
|
166
|
-
} else {
|
|
167
|
-
changePage(0);
|
|
168
|
-
}
|
|
169
|
-
}, [rows.length, itemsPerPage]);
|
|
170
|
-
var sortedResultset = (0, _react.useMemo)(function () {
|
|
171
|
-
return sortColumnIndex !== "" ? sortArray(sortColumnIndex, sortOrder, rows) : rows;
|
|
172
|
-
}, [sortColumnIndex, sortOrder, rows]);
|
|
173
|
-
var filteredResultset = (0, _react.useMemo)(function () {
|
|
174
|
-
return sortedResultset && sortedResultset.slice(minItemsPerPageIndex, maxItemsPerPageIndex + 1);
|
|
175
|
-
}, [sortedResultset, minItemsPerPageIndex, maxItemsPerPageIndex]);
|
|
176
|
-
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
177
|
-
theme: colorsTheme.table
|
|
178
|
-
}, /*#__PURE__*/_react["default"].createElement(DxcResultsetTableContainer, {
|
|
179
|
-
margin: margin
|
|
180
|
-
}, /*#__PURE__*/_react["default"].createElement(TableContainer, null, /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement(HeaderRow, null, /*#__PURE__*/_react["default"].createElement("tr", null, columns.map(function (column, index) {
|
|
181
|
-
return /*#__PURE__*/_react["default"].createElement(TableHeader, {
|
|
182
|
-
key: "tableHeader_".concat(index)
|
|
183
|
-
}, /*#__PURE__*/_react["default"].createElement(HeaderContainer, {
|
|
184
|
-
key: "headerContainer_".concat(index),
|
|
185
|
-
onClick: function onClick() {
|
|
186
|
-
return column.isSortable && changeSorting(index);
|
|
187
|
-
},
|
|
188
|
-
tabIndex: column.isSortable ? tabIndex : -1
|
|
189
|
-
}, /*#__PURE__*/_react["default"].createElement(TitleDiv, {
|
|
190
|
-
isSortable: column.isSortable
|
|
191
|
-
}, column.displayValue), column.isSortable && /*#__PURE__*/_react["default"].createElement(SortIcon, null, getIconForSortableColumn(index))));
|
|
192
|
-
}))), /*#__PURE__*/_react["default"].createElement(TableRowGroup, null, filteredResultset.map(function (cells, index) {
|
|
193
|
-
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
194
|
-
key: "resultSetTableCell_".concat(index)
|
|
195
|
-
}, cells.map(function (cellContent, index) {
|
|
196
|
-
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
197
|
-
key: "resultSetTableCellContent_".concat(index)
|
|
198
|
-
}, cellContent.displayValue);
|
|
199
|
-
}));
|
|
200
|
-
})))), /*#__PURE__*/_react["default"].createElement(PaginatorContainer, null, /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
201
|
-
totalItems: rows.length,
|
|
202
|
-
itemsPerPage: itemsPerPage,
|
|
203
|
-
itemsPerPageOptions: itemsPerPageOptions,
|
|
204
|
-
itemsPerPageFunction: itemsPerPageFunction,
|
|
205
|
-
currentPage: page,
|
|
206
|
-
showGoToPage: showGoToPage,
|
|
207
|
-
onPageChange: goToPage,
|
|
208
|
-
tabIndex: tabIndex
|
|
209
|
-
}))));
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
var TableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n & table {\n table-layout: auto;\n }\n"])));
|
|
213
|
-
|
|
214
|
-
var PaginatorContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
215
|
-
|
|
216
|
-
var TableRowGroup = _styledComponents["default"].tbody(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n > div:nth-child(1) {\n position: absolute;\n left: calc(50% - 68.5px);\n bottom: calc(50% - 68.5px - 30px);\n }\n & tr {\n height: ", ";\n }\n"])), function (props) {
|
|
217
|
-
return props.theme.rowHeight || "70px";
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
var SortIcon = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n top: 409px;\n left: 390px;\n height: 14px;\n cursor: pointer;\n color: ", ";\n\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
221
|
-
return props.theme.sortIconColor;
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
var TitleDiv = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n cursor: ", ";\n"])), function (props) {
|
|
225
|
-
return props.isSortable && "pointer" || "default";
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
var TableHeader = _styledComponents["default"].th(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
229
|
-
|
|
230
|
-
var HeaderContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n width: 100%;\n :focus {\n outline: #0095ff auto 1px;\n }\n"])), function (props) {
|
|
231
|
-
return props.theme.headerTextAlign === "center" ? "center" : props.theme.headerTextAlign === "right" ? "flex-end" : "flex-start";
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
var HeaderRow = _styledComponents["default"].thead(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 60px;\n"])));
|
|
235
|
-
|
|
236
|
-
var DxcResultsetTableContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
237
|
-
return props.theme.fontSizeBase;
|
|
238
|
-
}, function (props) {
|
|
239
|
-
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
240
|
-
}, function (props) {
|
|
241
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
242
|
-
}, function (props) {
|
|
243
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
|
|
244
|
-
}, function (props) {
|
|
245
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
246
|
-
}, function (props) {
|
|
247
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
var _default = DxcResultsetTable;
|
|
251
|
-
exports["default"] = _default;
|