@dxc-technology/halstack-react 0.0.0-ecc45e2 → 0.0.0-ede733c
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.d.ts +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1329 -5
- package/HalstackContext.js +117 -77
- package/accordion/Accordion.js +118 -110
- package/accordion/Accordion.stories.tsx +103 -15
- package/accordion/Accordion.test.js +10 -11
- package/accordion/types.d.ts +1 -0
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +24 -65
- package/accordion-group/AccordionGroup.stories.tsx +27 -1
- package/accordion-group/AccordionGroup.test.js +21 -46
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +7 -0
- package/alert/Alert.js +5 -9
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.js +4 -6
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +1 -0
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.js +13 -16
- package/button/Button.stories.tsx +151 -9
- package/button/Button.test.js +1 -1
- package/button/types.d.ts +3 -3
- package/card/Card.js +12 -13
- package/card/Card.stories.tsx +12 -13
- package/card/Card.test.js +1 -1
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +94 -101
- package/checkbox/Checkbox.stories.tsx +131 -59
- package/checkbox/Checkbox.test.js +94 -17
- package/checkbox/types.d.ts +4 -0
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1482 -0
- package/common/variables.js +994 -1137
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +134 -237
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +494 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +51 -0
- package/dialog/Dialog.js +60 -73
- package/dialog/Dialog.stories.tsx +229 -121
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +3 -2
- package/dropdown/Dropdown.js +43 -42
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +22 -27
- package/dropdown/DropdownMenu.js +12 -18
- package/dropdown/DropdownMenuItem.js +5 -18
- package/dropdown/types.d.ts +3 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +174 -220
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +14 -14
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +39 -63
- package/file-input/types.d.ts +17 -0
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +33 -19
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +83 -7
- package/footer/Footer.js +6 -8
- package/footer/Footer.stories.tsx +99 -1
- package/footer/Footer.test.js +14 -26
- package/footer/types.d.ts +1 -0
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +3 -2
- package/header/Header.js +21 -23
- package/header/Header.stories.tsx +152 -9
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +3 -2
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +3 -3
- package/layout/ApplicationLayout.js +1 -1
- package/layout/ApplicationLayout.stories.tsx +1 -0
- package/layout/types.d.ts +2 -3
- package/link/Link.js +4 -4
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +2 -4
- package/link/types.d.ts +2 -2
- package/main.d.ts +3 -2
- package/main.js +9 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +38 -18
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.test.js +44 -8
- package/package.json +15 -20
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +7 -15
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +45 -48
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/PasswordInput.test.js +14 -13
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/progress-bar/ProgressBar.test.js +1 -1
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.js +11 -12
- package/quick-nav/QuickNav.stories.tsx +111 -19
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +15 -13
- package/radio-group/RadioGroup.stories.tsx +132 -18
- package/radio-group/RadioGroup.test.js +124 -97
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -108
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +41 -64
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -35
- package/select/Option.js +11 -24
- package/select/Select.js +59 -36
- package/select/Select.stories.tsx +494 -150
- package/select/Select.test.js +341 -288
- package/select/types.d.ts +2 -2
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +66 -96
- package/sidenav/Sidenav.stories.tsx +165 -63
- package/sidenav/types.d.ts +21 -18
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +119 -95
- package/slider/Slider.stories.tsx +64 -1
- package/slider/Slider.test.js +88 -25
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +17 -23
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +96 -85
- package/switch/Switch.stories.tsx +33 -0
- package/switch/Switch.test.js +27 -14
- package/switch/types.d.ts +8 -3
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +132 -0
- package/tabs/Tabs.js +358 -108
- package/tabs/Tabs.stories.tsx +119 -5
- package/tabs/Tabs.test.js +220 -10
- package/tabs/types.d.ts +12 -2
- package/tag/Tag.js +8 -10
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.js +40 -11
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +189 -277
- package/text-input/TextInput.stories.tsx +280 -184
- package/text-input/TextInput.test.js +736 -725
- package/text-input/types.d.ts +21 -2
- package/textarea/Textarea.js +3 -4
- package/textarea/Textarea.stories.jsx +60 -1
- package/textarea/Textarea.test.js +2 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +7 -4
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +1 -1
- package/useTranslatedLabels.d.ts +84 -1
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +2 -2
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +5 -6
- package/common/RequiredComponent.js +0 -32
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
package/text-input/types.d.ts
CHANGED
|
@@ -159,20 +159,39 @@ declare type Props = {
|
|
|
159
159
|
*/
|
|
160
160
|
tabIndex?: number;
|
|
161
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* List of suggestions of an Text Input component.
|
|
164
|
+
*/
|
|
165
|
+
export declare type SuggestionsProps = {
|
|
166
|
+
id: string;
|
|
167
|
+
value: string;
|
|
168
|
+
suggestions: string[];
|
|
169
|
+
visualFocusIndex: number;
|
|
170
|
+
highlightedSuggestions: boolean;
|
|
171
|
+
searchHasErrors: boolean;
|
|
172
|
+
isSearching: boolean;
|
|
173
|
+
suggestionOnClick: (suggestion: string) => void;
|
|
174
|
+
getTextInputWidth: () => number;
|
|
175
|
+
};
|
|
162
176
|
/**
|
|
163
177
|
* Reference to the component.
|
|
164
178
|
*/
|
|
165
179
|
export declare type RefType = HTMLDivElement;
|
|
166
180
|
/**
|
|
167
|
-
* Single suggestion of
|
|
181
|
+
* Single suggestion of an Text Input component.
|
|
168
182
|
*/
|
|
169
183
|
export declare type SuggestionProps = {
|
|
170
184
|
id: string;
|
|
171
185
|
value: string;
|
|
172
|
-
onClick: () => void;
|
|
186
|
+
onClick: (suggestion: string) => void;
|
|
173
187
|
suggestion: string;
|
|
174
188
|
isLast: boolean;
|
|
175
189
|
visuallyFocused: boolean;
|
|
176
190
|
highlighted: boolean;
|
|
177
191
|
};
|
|
192
|
+
export declare type AutosuggestWrapperProps = {
|
|
193
|
+
condition: boolean;
|
|
194
|
+
wrapper: (children: React.ReactNode) => JSX.Element;
|
|
195
|
+
children: React.ReactNode;
|
|
196
|
+
};
|
|
178
197
|
export default Props;
|
package/textarea/Textarea.js
CHANGED
|
@@ -19,13 +19,13 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _utils = require("../common/utils
|
|
22
|
+
var _utils = require("../common/utils");
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
26
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
27
|
|
|
28
|
-
var _variables = require("../common/variables
|
|
28
|
+
var _variables = require("../common/variables");
|
|
29
29
|
|
|
30
30
|
var _uuid = require("uuid");
|
|
31
31
|
|
|
@@ -171,7 +171,6 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
171
171
|
backgroundType: backgroundType,
|
|
172
172
|
ref: textareaRef,
|
|
173
173
|
tabIndex: tabIndex,
|
|
174
|
-
"aria-disabled": disabled,
|
|
175
174
|
"aria-invalid": error ? "true" : "false",
|
|
176
175
|
"aria-errormessage": error ? errorId : undefined,
|
|
177
176
|
"aria-required": optional ? "false" : "true"
|
|
@@ -193,7 +192,7 @@ var calculateWidth = function calculateWidth(margin, size) {
|
|
|
193
192
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
194
193
|
};
|
|
195
194
|
|
|
196
|
-
var TextareaContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n
|
|
195
|
+
var TextareaContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
197
196
|
return calculateWidth(props.margin, props.size);
|
|
198
197
|
}, function (props) {
|
|
199
198
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -4,12 +4,20 @@ import Title from "../../.storybook/components/Title";
|
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
6
6
|
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: "Textarea",
|
|
10
11
|
component: DxcTextarea,
|
|
11
12
|
};
|
|
12
13
|
|
|
14
|
+
const opinionatedTheme = {
|
|
15
|
+
textarea: {
|
|
16
|
+
fontColor: "#000000",
|
|
17
|
+
hoverBorderColor: "#a46ede",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
export const Chromatic = () => (
|
|
14
22
|
<>
|
|
15
23
|
<>
|
|
@@ -151,7 +159,58 @@ export const Chromatic = () => (
|
|
|
151
159
|
<ExampleContainer>
|
|
152
160
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
153
161
|
<DxcTextarea label="Xxlarge" margin="xxlarge" />
|
|
154
|
-
|
|
162
|
+
</ExampleContainer>
|
|
163
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
164
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
165
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
166
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
167
|
+
<DxcTextarea label="Hovered" helperText="Sample text" placeholder="Placeholder" />
|
|
168
|
+
</HalstackProvider>
|
|
169
|
+
</ExampleContainer>
|
|
170
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
171
|
+
<Title title="Focused" theme="light" level={4} />
|
|
172
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
173
|
+
<DxcTextarea label="Focused" helperText="Sample text" />
|
|
174
|
+
</HalstackProvider>
|
|
175
|
+
</ExampleContainer>
|
|
176
|
+
<ExampleContainer>
|
|
177
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
178
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
179
|
+
<DxcTextarea
|
|
180
|
+
label="Disabled"
|
|
181
|
+
optional
|
|
182
|
+
helperText="Sample text"
|
|
183
|
+
placeholder="Enter your text here..."
|
|
184
|
+
disabled
|
|
185
|
+
/>
|
|
186
|
+
</HalstackProvider>
|
|
187
|
+
</ExampleContainer>
|
|
188
|
+
<ExampleContainer>
|
|
189
|
+
<Title title="Disabled with value" theme="light" level={4} />
|
|
190
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
191
|
+
<DxcTextarea label="Disabled" helperText="Sample text" defaultValue="Example text" disabled />
|
|
192
|
+
</HalstackProvider>
|
|
193
|
+
</ExampleContainer>
|
|
194
|
+
<ExampleContainer>
|
|
195
|
+
<Title title="With error" theme="light" level={4} />
|
|
196
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
197
|
+
<DxcTextarea
|
|
198
|
+
label="Textarea with error"
|
|
199
|
+
helperText="Helper text"
|
|
200
|
+
placeholder="Enter your text here..."
|
|
201
|
+
error="Error message."
|
|
202
|
+
/>
|
|
203
|
+
</HalstackProvider>
|
|
204
|
+
</ExampleContainer>
|
|
205
|
+
<ExampleContainer>
|
|
206
|
+
<Title title="Grow manual" theme="light" level={4} />{" "}
|
|
207
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
208
|
+
<DxcTextarea
|
|
209
|
+
label="Manual vertical grow"
|
|
210
|
+
verticalGrow="manual"
|
|
211
|
+
defaultValue="Long textttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"
|
|
212
|
+
/>
|
|
213
|
+
</HalstackProvider>
|
|
155
214
|
</ExampleContainer>
|
|
156
215
|
</>
|
|
157
216
|
);
|
|
@@ -8,7 +8,7 @@ var _react2 = require("@testing-library/react");
|
|
|
8
8
|
|
|
9
9
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
10
|
|
|
11
|
-
var _Textarea = _interopRequireDefault(require("./Textarea"));
|
|
11
|
+
var _Textarea = _interopRequireDefault(require("./Textarea.tsx"));
|
|
12
12
|
|
|
13
13
|
describe("Textarea component tests", function () {
|
|
14
14
|
test("Renders with correct label", function () {
|
|
@@ -85,7 +85,6 @@ describe("Textarea component tests", function () {
|
|
|
85
85
|
getByLabelText = _render7.getByLabelText;
|
|
86
86
|
|
|
87
87
|
var textarea = getByLabelText("Example label");
|
|
88
|
-
expect(textarea.getAttribute("aria-disabled")).toBe("false");
|
|
89
88
|
expect(textarea.getAttribute("aria-invalid")).toBe("false");
|
|
90
89
|
expect(textarea.getAttribute("aria-describedBy")).toBeNull();
|
|
91
90
|
expect(textarea.getAttribute("aria-required")).toBe("true");
|
|
@@ -101,7 +100,7 @@ describe("Textarea component tests", function () {
|
|
|
101
100
|
var textarea = getByLabelText("Example label");
|
|
102
101
|
expect(textarea.value).toBe("Example text");
|
|
103
102
|
});
|
|
104
|
-
test("Disabled textarea
|
|
103
|
+
test("Disabled textarea can not be modified", function () {
|
|
105
104
|
var onChange = jest.fn();
|
|
106
105
|
|
|
107
106
|
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
@@ -112,7 +111,6 @@ describe("Textarea component tests", function () {
|
|
|
112
111
|
getByLabelText = _render9.getByLabelText;
|
|
113
112
|
|
|
114
113
|
var textarea = getByLabelText("Example label");
|
|
115
|
-
expect(textarea.getAttribute("aria-disabled")).toBe("true");
|
|
116
114
|
|
|
117
115
|
_userEvent["default"].type(textarea, "Test");
|
|
118
116
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
declare const DxcToggleGroup: ({ label, helperText, defaultValue, value, onChange, disabled, options, margin, multiple, tabIndex, }:
|
|
2
|
+
import ToggleGroupPropsType from "./types";
|
|
3
|
+
declare const DxcToggleGroup: ({ label, helperText, defaultValue, value, onChange, disabled, options, margin, multiple, tabIndex, }: ToggleGroupPropsType) => JSX.Element;
|
|
4
4
|
export default DxcToggleGroup;
|
|
@@ -21,10 +21,12 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _uuid = require("uuid");
|
|
23
23
|
|
|
24
|
-
var _variables = require("../common/variables
|
|
24
|
+
var _variables = require("../common/variables");
|
|
25
25
|
|
|
26
26
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
27
27
|
|
|
28
|
+
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
29
|
+
|
|
28
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
29
31
|
|
|
30
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); }
|
|
@@ -56,6 +58,8 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
56
58
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
57
59
|
toggleGroupId = _useState4[0];
|
|
58
60
|
|
|
61
|
+
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
62
|
+
|
|
59
63
|
var handleToggleChange = function handleToggleChange(selectedOption) {
|
|
60
64
|
var newSelectedOptions;
|
|
61
65
|
|
|
@@ -97,8 +101,7 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
97
101
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
98
102
|
theme: colorsTheme.toggleGroup
|
|
99
103
|
}, /*#__PURE__*/_react["default"].createElement(ToggleGroup, {
|
|
100
|
-
margin: margin
|
|
101
|
-
disabled: disabled
|
|
104
|
+
margin: margin
|
|
102
105
|
}, /*#__PURE__*/_react["default"].createElement(Label, {
|
|
103
106
|
htmlFor: toggleGroupId,
|
|
104
107
|
disabled: disabled
|
|
@@ -111,12 +114,12 @@ var DxcToggleGroup = function DxcToggleGroup(_ref) {
|
|
|
111
114
|
return /*#__PURE__*/_react["default"].createElement(ToggleContainer, {
|
|
112
115
|
selected: multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
|
|
113
116
|
role: multiple ? "switch" : "radio",
|
|
117
|
+
backgroundType: backgroundType,
|
|
114
118
|
"aria-checked": multiple ? value ? Array.isArray(value) && value.includes(option.value) : Array.isArray(selectedValue) && selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
|
|
115
119
|
tabIndex: !disabled ? tabIndex : -1,
|
|
116
120
|
onClick: function onClick() {
|
|
117
121
|
return !disabled && handleToggleChange(option.value);
|
|
118
122
|
},
|
|
119
|
-
isFirst: i === 0,
|
|
120
123
|
isLast: i === options.length - 1,
|
|
121
124
|
isIcon: option.icon,
|
|
122
125
|
optionLabel: option.label,
|
|
@@ -3,6 +3,7 @@ import { userEvent, within } from "@storybook/testing-library";
|
|
|
3
3
|
import DxcToggleGroup from "./ToggleGroup";
|
|
4
4
|
import Title from "../../.storybook/components/Title";
|
|
5
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
title: "ToggleGroup",
|
|
@@ -89,6 +90,16 @@ const twoOptions = [
|
|
|
89
90
|
label: "Twitter",
|
|
90
91
|
},
|
|
91
92
|
];
|
|
93
|
+
|
|
94
|
+
const opinionatedTheme = {
|
|
95
|
+
toggleGroup: {
|
|
96
|
+
selectedBaseColor: "#5f249f",
|
|
97
|
+
selectedFontColor: "#ffffff",
|
|
98
|
+
unselectedBaseColor: "#e6e6e6",
|
|
99
|
+
unselectedFontColor: "#000000",
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
92
103
|
export const Chromatic = () => (
|
|
93
104
|
<>
|
|
94
105
|
<ExampleContainer>
|
|
@@ -154,6 +165,37 @@ export const Chromatic = () => (
|
|
|
154
165
|
<Title title="xxLarge" theme="light" level={4} />
|
|
155
166
|
<DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
|
|
156
167
|
</ExampleContainer>
|
|
168
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
169
|
+
<ExampleContainer>
|
|
170
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
171
|
+
<Title title="Selected" theme="light" level={4} />
|
|
172
|
+
<DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
|
|
173
|
+
</HalstackProvider>
|
|
174
|
+
</ExampleContainer>
|
|
175
|
+
<ExampleContainer>
|
|
176
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
177
|
+
<Title title="Icons & label toggle group" theme="light" level={4} />
|
|
178
|
+
<DxcToggleGroup label="Icons & label" options={optionsWithIconAndLabel} />
|
|
179
|
+
</HalstackProvider>
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
<ExampleContainer>
|
|
182
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
183
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
184
|
+
<DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
|
|
185
|
+
</HalstackProvider>
|
|
186
|
+
</ExampleContainer>
|
|
187
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
188
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
189
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
190
|
+
<DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
|
|
191
|
+
</HalstackProvider>
|
|
192
|
+
</ExampleContainer>
|
|
193
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
194
|
+
<Title title="Actived" theme="light" level={4} />
|
|
195
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
196
|
+
<DxcToggleGroup label="Actived" options={twoOptions} defaultValue={2} />
|
|
197
|
+
</HalstackProvider>
|
|
198
|
+
</ExampleContainer>
|
|
157
199
|
</>
|
|
158
200
|
);
|
|
159
201
|
const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
|
|
@@ -6,7 +6,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
6
6
|
|
|
7
7
|
var _react2 = require("@testing-library/react");
|
|
8
8
|
|
|
9
|
-
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup"));
|
|
9
|
+
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup.tsx"));
|
|
10
10
|
|
|
11
11
|
var options = [{
|
|
12
12
|
value: 1,
|
package/toggle-group/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import TypographyPropsTypes from "./types";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const DxcTypography: ({ textOverflow, whiteSpace, children, ...props }: TypographyPropsTypes) => JSX.Element;
|
|
4
|
+
export default DxcTypography;
|
package/typography/Typography.js
CHANGED
|
@@ -2,130 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
9
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
17
11
|
|
|
18
|
-
var
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
19
13
|
|
|
20
|
-
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
var _BaseTypography = _interopRequireDefault(require("../utils/BaseTypography"));
|
|
23
17
|
|
|
24
|
-
var
|
|
18
|
+
var _excluded = ["textOverflow", "whiteSpace", "children"];
|
|
25
19
|
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
display = _ref.display,
|
|
29
|
-
fontFamily = _ref.fontFamily,
|
|
30
|
-
fontSize = _ref.fontSize,
|
|
31
|
-
fontStyle = _ref.fontStyle,
|
|
32
|
-
fontWeight = _ref.fontWeight,
|
|
33
|
-
letterSpacing = _ref.letterSpacing,
|
|
34
|
-
lineHeight = _ref.lineHeight,
|
|
35
|
-
textAlign = _ref.textAlign,
|
|
36
|
-
color = _ref.color,
|
|
37
|
-
textDecoration = _ref.textDecoration,
|
|
38
|
-
textOverflow = _ref.textOverflow,
|
|
20
|
+
var DxcTypography = function DxcTypography(_ref) {
|
|
21
|
+
var textOverflow = _ref.textOverflow,
|
|
39
22
|
whiteSpace = _ref.whiteSpace,
|
|
40
|
-
children = _ref.children
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var fontStyleValue = fontStyle !== null && fontStyle !== void 0 ? fontStyle : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.fontStyle) || "normal";
|
|
47
|
-
var fontWeightValue = fontWeight !== null && fontWeight !== void 0 ? fontWeight : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.fontWeight) || "400";
|
|
48
|
-
var letterSpacingValue = letterSpacing !== null && letterSpacing !== void 0 ? letterSpacing : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.letterSpacing) || "0em";
|
|
49
|
-
var lineHeightValue = lineHeight !== null && lineHeight !== void 0 ? lineHeight : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.lineHeight) || "1.5em";
|
|
50
|
-
var textAlignValue = textAlign !== null && textAlign !== void 0 ? textAlign : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.textAlign) || "left";
|
|
51
|
-
var colorValue = color !== null && color !== void 0 ? color : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.color) || "#000000";
|
|
52
|
-
var textDecorationValue = textDecoration !== null && textDecoration !== void 0 ? textDecoration : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.textDecoration) || "none";
|
|
53
|
-
var textOverflowValue = textOverflow !== null && textOverflow !== void 0 ? textOverflow : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.textOverflow) || "unset";
|
|
54
|
-
var whiteSpaceValue = whiteSpace !== null && whiteSpace !== void 0 ? whiteSpace : (componentContext === null || componentContext === void 0 ? void 0 : componentContext.whiteSpace) || "normal";
|
|
55
|
-
return /*#__PURE__*/_react["default"].createElement(TypographyContext.Provider, {
|
|
56
|
-
value: {
|
|
57
|
-
as: asValue,
|
|
58
|
-
display: displayValue,
|
|
59
|
-
fontFamily: fontFamilyValue,
|
|
60
|
-
fontSize: fontSizeValue,
|
|
61
|
-
fontStyle: fontStyleValue,
|
|
62
|
-
fontWeight: fontWeightValue,
|
|
63
|
-
letterSpacing: letterSpacingValue,
|
|
64
|
-
lineHeight: lineHeightValue,
|
|
65
|
-
textAlign: textAlignValue,
|
|
66
|
-
color: colorValue,
|
|
67
|
-
textDecoration: textDecorationValue,
|
|
68
|
-
textOverflow: textOverflowValue,
|
|
69
|
-
whiteSpace: whiteSpaceValue
|
|
70
|
-
}
|
|
71
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledTypography, {
|
|
72
|
-
as: asValue,
|
|
73
|
-
display: displayValue,
|
|
74
|
-
fontFamily: fontFamilyValue,
|
|
75
|
-
fontSize: fontSizeValue,
|
|
76
|
-
fontStyle: fontStyleValue,
|
|
77
|
-
fontWeight: fontWeightValue,
|
|
78
|
-
letterSpacing: letterSpacingValue,
|
|
79
|
-
lineHeight: lineHeightValue,
|
|
80
|
-
textAlign: textAlignValue,
|
|
81
|
-
color: colorValue,
|
|
82
|
-
textDecoration: textDecorationValue,
|
|
83
|
-
textOverflow: textOverflowValue,
|
|
84
|
-
whiteSpace: whiteSpaceValue
|
|
85
|
-
}, children));
|
|
23
|
+
children = _ref.children,
|
|
24
|
+
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
25
|
+
return /*#__PURE__*/_react["default"].createElement(_BaseTypography["default"], (0, _extends2["default"])({
|
|
26
|
+
textOverflow: textOverflow,
|
|
27
|
+
whiteSpace: whiteSpace == null && textOverflow != null && textOverflow !== "unset" ? "nowrap" : whiteSpace
|
|
28
|
+
}, props), children);
|
|
86
29
|
};
|
|
87
30
|
|
|
88
|
-
var
|
|
89
|
-
var display = _ref2.display;
|
|
90
|
-
return display;
|
|
91
|
-
}, function (_ref3) {
|
|
92
|
-
var color = _ref3.color;
|
|
93
|
-
return color;
|
|
94
|
-
}, function (_ref4) {
|
|
95
|
-
var fontFamily = _ref4.fontFamily;
|
|
96
|
-
return fontFamily;
|
|
97
|
-
}, function (_ref5) {
|
|
98
|
-
var fontSize = _ref5.fontSize;
|
|
99
|
-
return fontSize;
|
|
100
|
-
}, function (_ref6) {
|
|
101
|
-
var fontStyle = _ref6.fontStyle;
|
|
102
|
-
return fontStyle;
|
|
103
|
-
}, function (_ref7) {
|
|
104
|
-
var fontWeight = _ref7.fontWeight;
|
|
105
|
-
return fontWeight;
|
|
106
|
-
}, function (_ref8) {
|
|
107
|
-
var letterSpacing = _ref8.letterSpacing;
|
|
108
|
-
return letterSpacing;
|
|
109
|
-
}, function (_ref9) {
|
|
110
|
-
var textAlign = _ref9.textAlign;
|
|
111
|
-
return textAlign;
|
|
112
|
-
}, function (_ref10) {
|
|
113
|
-
var lineHeight = _ref10.lineHeight;
|
|
114
|
-
return lineHeight;
|
|
115
|
-
}, function (_ref11) {
|
|
116
|
-
var textDecoration = _ref11.textDecoration;
|
|
117
|
-
return textDecoration;
|
|
118
|
-
}, function (_ref12) {
|
|
119
|
-
var textOverflow = _ref12.textOverflow;
|
|
120
|
-
return textOverflow;
|
|
121
|
-
}, function (_ref13) {
|
|
122
|
-
var whiteSpace = _ref13.whiteSpace,
|
|
123
|
-
textOverflow = _ref13.textOverflow;
|
|
124
|
-
return whiteSpace !== "normal" ? whiteSpace : textOverflow !== "unset" ? "nowrap" : "normal";
|
|
125
|
-
}, function (_ref14) {
|
|
126
|
-
var textOverflow = _ref14.textOverflow;
|
|
127
|
-
return textOverflow !== "unset" ? "hidden" : "visible";
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
var _default = Typography;
|
|
31
|
+
var _default = DxcTypography;
|
|
131
32
|
exports["default"] = _default;
|
|
@@ -140,7 +140,7 @@ export const Chromatic = () => (
|
|
|
140
140
|
<ExampleContainer>
|
|
141
141
|
<Title title="Typography whitespace" theme="light" level={4} />
|
|
142
142
|
<div style={{ margin: "50px", border: "1px solid red", width: "125px" }}>
|
|
143
|
-
<DxcTypography
|
|
143
|
+
<DxcTypography fontSize="2rem">
|
|
144
144
|
{" "} Normal: A bunch of words you see.
|
|
145
145
|
</DxcTypography>
|
|
146
146
|
</div>
|