@dxc-technology/halstack-react 0.0.0-e081e21 → 0.0.0-e1a279c
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/accordion/Accordion.d.ts +4 -0
- package/accordion/Accordion.js +12 -43
- package/accordion/types.d.ts +68 -0
- package/accordion/types.js +5 -0
- package/accordion-group/AccordionGroup.d.ts +7 -0
- package/accordion-group/AccordionGroup.js +58 -72
- package/accordion-group/types.d.ts +72 -0
- package/accordion-group/types.js +5 -0
- package/alert/Alert.stories.tsx +170 -0
- package/box/Box.d.ts +4 -0
- package/box/Box.js +9 -32
- package/box/Box.stories.tsx +132 -0
- package/box/types.d.ts +47 -0
- package/box/types.js +5 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +7 -12
- package/button/Button.stories.tsx +244 -274
- package/button/types.d.ts +10 -10
- package/card/Card.d.ts +4 -0
- package/card/Card.js +13 -48
- package/card/types.d.ts +69 -0
- package/card/types.js +5 -0
- package/checkbox/Checkbox.stories.tsx +192 -0
- package/checkbox/types.d.ts +2 -3
- package/chip/Chip.stories.tsx +121 -0
- package/common/variables.js +30 -22
- package/date-input/DateInput.d.ts +4 -0
- package/date-input/DateInput.js +3 -38
- package/date-input/DateInput.stories.tsx +138 -0
- package/date-input/types.d.ts +100 -0
- package/date-input/types.js +5 -0
- package/dialog/Dialog.d.ts +4 -0
- package/dialog/Dialog.js +4 -23
- package/dialog/Dialog.stories.tsx +212 -0
- package/dialog/types.d.ts +43 -0
- package/dialog/types.js +5 -0
- package/dropdown/Dropdown.d.ts +4 -0
- package/dropdown/Dropdown.js +7 -40
- package/dropdown/types.d.ts +89 -0
- package/dropdown/types.js +5 -0
- package/footer/Footer.d.ts +4 -0
- package/footer/Footer.js +4 -35
- package/footer/Footer.stories.jsx +151 -0
- package/footer/types.d.ts +61 -0
- package/footer/types.js +5 -0
- package/header/Header.d.ts +7 -0
- package/header/Header.js +26 -28
- package/header/Icons.js +2 -27
- package/header/types.d.ts +45 -0
- package/header/types.js +5 -0
- package/link/Link.d.ts +3 -0
- package/link/Link.js +1 -23
- package/link/Link.stories.tsx +70 -0
- package/link/types.d.ts +74 -0
- package/link/types.js +5 -0
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +2 -44
- package/number-input/NumberInput.stories.tsx +115 -0
- package/number-input/types.d.ts +117 -0
- package/number-input/types.js +5 -0
- package/package.json +3 -3
- package/paginator/Paginator.stories.tsx +63 -0
- package/password-input/PasswordInput.d.ts +4 -0
- package/password-input/PasswordInput.js +2 -39
- package/password-input/PasswordInput.stories.tsx +131 -0
- package/password-input/types.d.ts +100 -0
- package/password-input/types.js +5 -0
- package/progress-bar/ProgressBar.d.ts +4 -0
- package/progress-bar/ProgressBar.js +3 -21
- package/progress-bar/ProgressBar.stories.jsx +58 -0
- package/progress-bar/types.d.ts +37 -0
- package/progress-bar/types.js +5 -0
- package/radio/Radio.d.ts +4 -0
- package/radio/Radio.js +3 -24
- package/radio/Radio.stories.tsx +192 -0
- package/radio/types.d.ts +54 -0
- package/radio/types.js +5 -0
- package/select/Select.stories.tsx +572 -0
- package/select/index.d.ts +4 -4
- package/sidenav/Sidenav.d.ts +9 -0
- package/sidenav/Sidenav.js +4 -13
- package/sidenav/types.d.ts +50 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +4 -0
- package/slider/Slider.js +59 -82
- package/slider/Slider.stories.tsx +177 -0
- package/slider/types.d.ts +78 -0
- package/slider/types.js +5 -0
- package/spinner/Spinner.d.ts +4 -0
- package/spinner/Spinner.js +6 -23
- package/spinner/Spinner.stories.jsx +102 -0
- package/spinner/types.d.ts +32 -0
- package/spinner/types.js +5 -0
- package/switch/Switch.js +2 -2
- package/switch/Switch.stories.tsx +160 -0
- package/table/Table.d.ts +4 -0
- package/table/Table.stories.jsx +276 -0
- package/table/types.d.ts +21 -0
- package/table/types.js +5 -0
- package/tabs/Tabs.d.ts +4 -0
- package/tabs/Tabs.js +5 -53
- package/tabs/types.d.ts +71 -0
- package/tabs/types.js +5 -0
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +20 -35
- package/tag/Tag.stories.tsx +145 -0
- package/tag/types.d.ts +60 -0
- package/tag/types.js +5 -0
- package/text-input/index.d.ts +2 -2
- package/textarea/Textarea.stories.jsx +135 -0
- package/toggle-group/ToggleGroup.stories.tsx +178 -0
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +11 -51
- package/wizard/Wizard.stories.jsx +224 -0
- package/wizard/types.d.ts +64 -0
- package/wizard/types.js +5 -0
- package/accordion/index.d.ts +0 -28
- package/accordion-group/index.d.ts +0 -16
- package/box/index.d.ts +0 -25
- package/card/index.d.ts +0 -22
- package/date-input/index.d.ts +0 -95
- package/dialog/index.d.ts +0 -18
- package/dropdown/index.d.ts +0 -26
- package/footer/index.d.ts +0 -25
- package/header/index.d.ts +0 -25
- package/link/index.d.ts +0 -23
- package/number-input/index.d.ts +0 -113
- package/password-input/index.d.ts +0 -94
- package/progress-bar/index.d.ts +0 -18
- package/radio/index.d.ts +0 -23
- package/sidenav/index.d.ts +0 -13
- package/slider/index.d.ts +0 -29
- package/spinner/index.d.ts +0 -17
- package/table/index.d.ts +0 -13
- package/tabs/index.d.ts +0 -19
- package/tag/index.d.ts +0 -24
- package/wizard/index.d.ts +0 -18
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Padding = {
|
|
4
|
+
top?: Space;
|
|
5
|
+
bottom?: Space;
|
|
6
|
+
left?: Space;
|
|
7
|
+
right?: Space;
|
|
8
|
+
};
|
|
9
|
+
declare type Props = {
|
|
10
|
+
/**
|
|
11
|
+
* Wether a contrast line should appear at the bottom of the header.
|
|
12
|
+
*/
|
|
13
|
+
underlined?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Content showed in the header. Take into account that the component applies styles
|
|
16
|
+
* for the first child in the content, so we recommend the use of React.Fragment
|
|
17
|
+
* to be applied correctly. Otherwise, the styles can be modified.
|
|
18
|
+
*/
|
|
19
|
+
content?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Content showed in responsive version. It receives the close menu handler that can
|
|
22
|
+
* be used to add that functionality when a element is clicked.
|
|
23
|
+
*/
|
|
24
|
+
responsiveContent?: (closeHandler: () => void) => React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* This function will be called when the user clicks the header logo.
|
|
27
|
+
*/
|
|
28
|
+
onClick?: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Size of the bottom margin to be applied to the header.
|
|
31
|
+
*/
|
|
32
|
+
margin?: Space;
|
|
33
|
+
/**
|
|
34
|
+
* Size of the padding to be applied to the custom area of the component.
|
|
35
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in
|
|
36
|
+
* order to specify different padding sizes.
|
|
37
|
+
*/
|
|
38
|
+
padding?: Space | Padding;
|
|
39
|
+
/**
|
|
40
|
+
* Value of the tabindex for all interactuable elements, except those inside the
|
|
41
|
+
* custom area.
|
|
42
|
+
*/
|
|
43
|
+
tabIndex?: number;
|
|
44
|
+
};
|
|
45
|
+
export default Props;
|
package/header/types.js
ADDED
package/link/Link.d.ts
ADDED
package/link/Link.js
CHANGED
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
13
|
|
|
16
14
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
@@ -19,8 +17,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
19
17
|
|
|
20
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
19
|
|
|
22
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
23
|
-
|
|
24
20
|
var _variables = require("../common/variables.js");
|
|
25
21
|
|
|
26
22
|
var _useTheme = _interopRequireDefault(require("../useTheme.js"));
|
|
@@ -153,7 +149,7 @@ var LinkIcon = _styledComponents["default"].img(_templateObject5 || (_templateOb
|
|
|
153
149
|
return "".concat(props.iconPosition === "before" ? "margin-right" : "margin-left", ": ").concat(props.theme.iconSpacing);
|
|
154
150
|
});
|
|
155
151
|
|
|
156
|
-
var LinkIconContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", ";\n overflow: hidden;\n
|
|
152
|
+
var LinkIconContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
157
153
|
return props.theme.iconSize;
|
|
158
154
|
}, function (props) {
|
|
159
155
|
return props.theme.iconSize;
|
|
@@ -161,23 +157,5 @@ var LinkIconContainer = _styledComponents["default"].div(_templateObject6 || (_t
|
|
|
161
157
|
return "".concat(props.iconPosition === "before" ? "margin-right" : "margin-left", ": ").concat(props.theme.iconSpacing);
|
|
162
158
|
});
|
|
163
159
|
|
|
164
|
-
DxcLink.propTypes = {
|
|
165
|
-
inheritColor: _propTypes["default"].bool,
|
|
166
|
-
disabled: _propTypes["default"].bool,
|
|
167
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
|
|
168
|
-
iconSrc: _propTypes["default"].string,
|
|
169
|
-
iconPosition: _propTypes["default"].oneOf(["after", "before"]),
|
|
170
|
-
href: _propTypes["default"].string,
|
|
171
|
-
onClick: _propTypes["default"].func,
|
|
172
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
173
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
174
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
175
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
176
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
177
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
178
|
-
newWindow: _propTypes["default"].bool,
|
|
179
|
-
text: _propTypes["default"].string,
|
|
180
|
-
tabIndex: _propTypes["default"].number
|
|
181
|
-
};
|
|
182
160
|
var _default = DxcLink;
|
|
183
161
|
exports["default"] = _default;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import DxcLink from "./Link";
|
|
3
|
+
import Title from "../../.storybook/components/Title";
|
|
4
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "Link",
|
|
8
|
+
component: DxcLink,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const icon = (
|
|
12
|
+
<svg viewBox="0 0 24 24" enable-background="new 0 0 24 24" fill="currentColor">
|
|
13
|
+
<g id="Bounding_Box">
|
|
14
|
+
<rect fill="none" width="24" height="24" />
|
|
15
|
+
</g>
|
|
16
|
+
<g id="Master">
|
|
17
|
+
<path d="M19,9.3V4h-3v2.6L12,3L2,12h3v8h5v-6h4v6h5v-8h3L19,9.3z M10,10c0-1.1,0.9-2,2-2s2,0.9,2,2H10z" />
|
|
18
|
+
</g>
|
|
19
|
+
</svg>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const Chromatic = () => (
|
|
23
|
+
<>
|
|
24
|
+
<ExampleContainer>
|
|
25
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
26
|
+
<DxcLink text="Test" disabled></DxcLink>
|
|
27
|
+
<Title title="Icon before" theme="light" level={4} />
|
|
28
|
+
<DxcLink text="Test" href="https://www.google.com" icon={icon} iconPosition="before"></DxcLink>
|
|
29
|
+
<Title title="Icon after" theme="light" level={4} />
|
|
30
|
+
<DxcLink text="Test" href="https://www.youtube.com/" icon={icon} iconPosition="after"></DxcLink>
|
|
31
|
+
</ExampleContainer>
|
|
32
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
33
|
+
<Title title="With link hovered" theme="light" level={4} />
|
|
34
|
+
<DxcLink text="Test" href="https://www.dxc.com"></DxcLink>
|
|
35
|
+
</ExampleContainer>
|
|
36
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
37
|
+
<Title title="With link focused" theme="light" level={4} />
|
|
38
|
+
<DxcLink text="Test" href="https://www.dxc.com"></DxcLink>
|
|
39
|
+
</ExampleContainer>
|
|
40
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
41
|
+
<Title title="With link active" theme="light" level={4} />
|
|
42
|
+
<DxcLink text="Test" href="https://www.dxc.com"></DxcLink>
|
|
43
|
+
</ExampleContainer>
|
|
44
|
+
<ExampleContainer pseudoState="pseudo-visited">
|
|
45
|
+
<Title title="With link visited" theme="light" level={4} />
|
|
46
|
+
<DxcLink text="Test" href="https://www.amazon.com"></DxcLink>
|
|
47
|
+
</ExampleContainer>
|
|
48
|
+
<ExampleContainer>
|
|
49
|
+
<Title title="Inherit color" theme="light" level={4} />
|
|
50
|
+
This is a <DxcLink text="Test" inheritColor={true}></DxcLink>.
|
|
51
|
+
</ExampleContainer>
|
|
52
|
+
<Title title="Margins" theme="light" level={2} />
|
|
53
|
+
<ExampleContainer>
|
|
54
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
55
|
+
<DxcLink text="Test" margin="xxsmall" href="https://www.facebook.com/"></DxcLink>
|
|
56
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
57
|
+
<DxcLink text="Test" margin="xsmall" href="https://www.linkedin.com/"></DxcLink>
|
|
58
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
59
|
+
<DxcLink text="Test" margin="small" href="https://www.linkedin.com/"></DxcLink>
|
|
60
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
61
|
+
<DxcLink text="Test" margin="medium" href="https://www.linkedin.com/"></DxcLink>
|
|
62
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
63
|
+
<DxcLink text="Test" margin="large" href="https://www.linkedin.com/"></DxcLink>
|
|
64
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
65
|
+
<DxcLink text="Test" margin="xlarge" href="https://www.linkedin.com/"></DxcLink>
|
|
66
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
67
|
+
<DxcLink text="Test" margin="xxlarge" href="https://www.linkedin.com/"></DxcLink>
|
|
68
|
+
</ExampleContainer>
|
|
69
|
+
</>
|
|
70
|
+
);
|
package/link/types.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
|
+
top?: Space;
|
|
5
|
+
bottom?: Space;
|
|
6
|
+
left?: Space;
|
|
7
|
+
right?: Space;
|
|
8
|
+
};
|
|
9
|
+
declare type LinkCommonProps = {
|
|
10
|
+
/**
|
|
11
|
+
* If true, the color is inherited from parent.
|
|
12
|
+
*/
|
|
13
|
+
inheritColor?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* If true, the link is disabled.
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @Deprecated Source of the icon.
|
|
20
|
+
*/
|
|
21
|
+
iconSrc?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates the position of the icon in the component.
|
|
24
|
+
*/
|
|
25
|
+
iconPosition?: "before" | "after";
|
|
26
|
+
/**
|
|
27
|
+
* Page to be opened when the user clicks on the link.
|
|
28
|
+
*/
|
|
29
|
+
href?: string;
|
|
30
|
+
/**
|
|
31
|
+
* If true, the page is opened in a new browser tab.
|
|
32
|
+
*/
|
|
33
|
+
newWindow?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* If defined, the link will be displayed as a button. This
|
|
36
|
+
* function will be called when the user clicks the link.
|
|
37
|
+
*/
|
|
38
|
+
onClick?: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
41
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
42
|
+
*/
|
|
43
|
+
margin?: Space | Margin;
|
|
44
|
+
/**
|
|
45
|
+
* Value of the tabindex.
|
|
46
|
+
*/
|
|
47
|
+
tabIndex?: number;
|
|
48
|
+
};
|
|
49
|
+
export declare type LinkTextProps = LinkCommonProps & {
|
|
50
|
+
/**
|
|
51
|
+
* Link text.
|
|
52
|
+
*/
|
|
53
|
+
text: string;
|
|
54
|
+
/**
|
|
55
|
+
* Element used as the icon that will be placed next to the link text.
|
|
56
|
+
*/
|
|
57
|
+
icon?: SVG;
|
|
58
|
+
};
|
|
59
|
+
export declare type LinkIconProps = LinkCommonProps & {
|
|
60
|
+
/**
|
|
61
|
+
* Link text.
|
|
62
|
+
*/
|
|
63
|
+
text?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Element used as the icon that will be placed next to the link text.
|
|
66
|
+
*/
|
|
67
|
+
icon: SVG;
|
|
68
|
+
};
|
|
69
|
+
declare type Overload = {
|
|
70
|
+
(props: LinkTextProps): JSX.Element;
|
|
71
|
+
(props: LinkIconProps): JSX.Element;
|
|
72
|
+
};
|
|
73
|
+
declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
|
|
74
|
+
export default Overload;
|
package/link/types.js
ADDED
|
@@ -7,22 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
11
|
|
|
14
12
|
var _react = _interopRequireDefault(require("react"));
|
|
15
13
|
|
|
16
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
14
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
15
|
|
|
20
16
|
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
21
17
|
|
|
22
18
|
var _NumberInputContext = _interopRequireDefault(require("./NumberInputContext"));
|
|
23
19
|
|
|
24
|
-
var _variables = require("../common/variables.js");
|
|
25
|
-
|
|
26
20
|
var _templateObject;
|
|
27
21
|
|
|
28
22
|
var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
@@ -45,7 +39,8 @@ var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, r
|
|
|
45
39
|
suffix = _ref$suffix === void 0 ? "" : _ref$suffix,
|
|
46
40
|
min = _ref.min,
|
|
47
41
|
max = _ref.max,
|
|
48
|
-
step = _ref.step,
|
|
42
|
+
_ref$step = _ref.step,
|
|
43
|
+
step = _ref$step === void 0 ? 1 : _ref$step,
|
|
49
44
|
onChange = _ref.onChange,
|
|
50
45
|
onBlur = _ref.onBlur,
|
|
51
46
|
_ref$error = _ref.error,
|
|
@@ -85,44 +80,7 @@ var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, r
|
|
|
85
80
|
})));
|
|
86
81
|
});
|
|
87
82
|
|
|
88
|
-
var sizes = {
|
|
89
|
-
small: "240px",
|
|
90
|
-
medium: "360px",
|
|
91
|
-
large: "480px",
|
|
92
|
-
fillParent: "100%"
|
|
93
|
-
};
|
|
94
|
-
|
|
95
83
|
var NumberInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n // Chrome, Safari, Edge, Opera\n input::-webkit-outer-spin-button,\n input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n // Firefox\n input[type=\"number\"] {\n -moz-appearance: textfield;\n }\n"])));
|
|
96
84
|
|
|
97
|
-
DxcNumberInput.propTypes = {
|
|
98
|
-
label: _propTypes["default"].string,
|
|
99
|
-
name: _propTypes["default"].string,
|
|
100
|
-
value: _propTypes["default"].string,
|
|
101
|
-
helperText: _propTypes["default"].string,
|
|
102
|
-
placeholder: _propTypes["default"].string,
|
|
103
|
-
error: _propTypes["default"].string,
|
|
104
|
-
disabled: _propTypes["default"].bool,
|
|
105
|
-
optional: _propTypes["default"].bool,
|
|
106
|
-
prefix: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape({
|
|
107
|
-
type: _propTypes["default"].oneOf(["svg"])
|
|
108
|
-
})]),
|
|
109
|
-
suffix: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape({
|
|
110
|
-
type: _propTypes["default"].oneOf(["svg"])
|
|
111
|
-
})]),
|
|
112
|
-
min: _propTypes["default"].number,
|
|
113
|
-
max: _propTypes["default"].number,
|
|
114
|
-
step: _propTypes["default"].number,
|
|
115
|
-
onChange: _propTypes["default"].func,
|
|
116
|
-
onBlur: _propTypes["default"].func,
|
|
117
|
-
autocomplete: _propTypes["default"].string,
|
|
118
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
119
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
120
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
121
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
122
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
123
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
124
|
-
size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
|
|
125
|
-
tabIndex: _propTypes["default"].number
|
|
126
|
-
};
|
|
127
85
|
var _default = DxcNumberInput;
|
|
128
86
|
exports["default"] = _default;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
3
|
+
import Title from "../../.storybook/components/Title";
|
|
4
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
6
|
+
import DxcNumberInput from "./NumberInput";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Number input ",
|
|
10
|
+
component: DxcNumberInput,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Chromatic = () => (
|
|
14
|
+
<>
|
|
15
|
+
<ExampleContainer>
|
|
16
|
+
<Title title="Without label" theme="light" level={4} />
|
|
17
|
+
<DxcNumberInput />
|
|
18
|
+
</ExampleContainer>
|
|
19
|
+
<ExampleContainer>
|
|
20
|
+
<Title title="With label and placeholder" theme="light" level={4} />
|
|
21
|
+
<DxcNumberInput label="Number input" placeholder="Placeholder" />
|
|
22
|
+
</ExampleContainer>
|
|
23
|
+
<ExampleContainer>
|
|
24
|
+
<Title title="Helper text, optional and value" theme="light" level={4} />
|
|
25
|
+
<DxcNumberInput label="Number input" value="12" helperText="Help message" optional />
|
|
26
|
+
</ExampleContainer>
|
|
27
|
+
<ExampleContainer>
|
|
28
|
+
<Title title="Disabled and placeholder" theme="light" level={4} />
|
|
29
|
+
<DxcNumberInput label="Disabled number input" disabled placeholder="Placeholder" />
|
|
30
|
+
</ExampleContainer>
|
|
31
|
+
<ExampleContainer>
|
|
32
|
+
<Title title="Disabled, helper text, optional and value" theme="light" level={4} />
|
|
33
|
+
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional value="10" />
|
|
34
|
+
</ExampleContainer>
|
|
35
|
+
<ExampleContainer>
|
|
36
|
+
<Title title="Prefix" theme="light" level={4} />
|
|
37
|
+
<DxcNumberInput label="With prefix" prefix="+34" />
|
|
38
|
+
</ExampleContainer>
|
|
39
|
+
<ExampleContainer>
|
|
40
|
+
<Title title="Suffix" theme="light" level={4} />
|
|
41
|
+
<DxcNumberInput label="With suffix" suffix="USD" />
|
|
42
|
+
</ExampleContainer>
|
|
43
|
+
<ExampleContainer>
|
|
44
|
+
<Title title="Invalid" theme="light" level={4} />
|
|
45
|
+
<DxcNumberInput label="Error number input" helperText="Help message" error="Error message." value="23" optional />
|
|
46
|
+
</ExampleContainer>
|
|
47
|
+
<BackgroundColorProvider color="#333333">
|
|
48
|
+
<DarkContainer>
|
|
49
|
+
<Title title="Dark" theme="dark" level={2} />
|
|
50
|
+
<ExampleContainer>
|
|
51
|
+
<Title title="Helper text, placeholder and optional" theme="dark" level={4} />
|
|
52
|
+
<DxcNumberInput label="Number input" helperText="Help message" placeholder="Placeholder" optional />
|
|
53
|
+
</ExampleContainer>
|
|
54
|
+
<ExampleContainer>
|
|
55
|
+
<Title title="Helper text, value and error" theme="dark" level={4} />
|
|
56
|
+
<DxcNumberInput label="Number input" helperText="Help message" error="Error message." value="199" />
|
|
57
|
+
</ExampleContainer>
|
|
58
|
+
<ExampleContainer>
|
|
59
|
+
<Title title="Disabled and placeholder" theme="dark" level={4} />
|
|
60
|
+
<DxcNumberInput label="Disabled number input" disabled placeholder="Placeholder" />
|
|
61
|
+
</ExampleContainer>
|
|
62
|
+
<ExampleContainer>
|
|
63
|
+
<Title title="Disabled, helper text, optional and value" theme="dark" level={4} />
|
|
64
|
+
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional value="1232454" />
|
|
65
|
+
</ExampleContainer>
|
|
66
|
+
</DarkContainer>
|
|
67
|
+
</BackgroundColorProvider>
|
|
68
|
+
<Title title="Margins" theme="light" level={2} />
|
|
69
|
+
<ExampleContainer>
|
|
70
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
71
|
+
<DxcNumberInput label="Xxsmall" margin="xxsmall" />
|
|
72
|
+
</ExampleContainer>
|
|
73
|
+
<ExampleContainer>
|
|
74
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
75
|
+
<DxcNumberInput label="Xsmall" margin="xsmall" />
|
|
76
|
+
</ExampleContainer>
|
|
77
|
+
<ExampleContainer>
|
|
78
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
79
|
+
<DxcNumberInput label="Small" margin="small" />
|
|
80
|
+
</ExampleContainer>
|
|
81
|
+
<ExampleContainer>
|
|
82
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
83
|
+
<DxcNumberInput label="Medium" margin="medium" />
|
|
84
|
+
</ExampleContainer>
|
|
85
|
+
<ExampleContainer>
|
|
86
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
87
|
+
<DxcNumberInput label="Large" margin="large" />
|
|
88
|
+
</ExampleContainer>
|
|
89
|
+
<ExampleContainer>
|
|
90
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
91
|
+
<DxcNumberInput label="Xlarge" margin="xlarge" />
|
|
92
|
+
</ExampleContainer>
|
|
93
|
+
<ExampleContainer>
|
|
94
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
95
|
+
<DxcNumberInput label="Xxlarge" margin="xxlarge" />
|
|
96
|
+
</ExampleContainer>
|
|
97
|
+
<Title title="Sizes" theme="light" level={2} />
|
|
98
|
+
<ExampleContainer>
|
|
99
|
+
<Title title="Small size" theme="light" level={4} />
|
|
100
|
+
<DxcNumberInput label="Small" size="small" />
|
|
101
|
+
</ExampleContainer>
|
|
102
|
+
<ExampleContainer>
|
|
103
|
+
<Title title="Medium size" theme="light" level={4} />
|
|
104
|
+
<DxcNumberInput label="Medium" size="medium" />
|
|
105
|
+
</ExampleContainer>
|
|
106
|
+
<ExampleContainer>
|
|
107
|
+
<Title title="Large size" theme="light" level={4} />
|
|
108
|
+
<DxcNumberInput label="Large" size="large" />
|
|
109
|
+
</ExampleContainer>
|
|
110
|
+
<ExampleContainer>
|
|
111
|
+
<Title title="FillParent size" theme="light" level={4} />
|
|
112
|
+
<DxcNumberInput label="FillParent" size="fillParent" />
|
|
113
|
+
</ExampleContainer>
|
|
114
|
+
</>
|
|
115
|
+
);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
2
|
+
declare type Margin = {
|
|
3
|
+
top?: Space;
|
|
4
|
+
bottom?: Space;
|
|
5
|
+
left?: Space;
|
|
6
|
+
right?: Space;
|
|
7
|
+
};
|
|
8
|
+
declare type Props = {
|
|
9
|
+
/**
|
|
10
|
+
* Text to be placed above the number.
|
|
11
|
+
*/
|
|
12
|
+
label?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Name attribute of the input element.
|
|
15
|
+
*/
|
|
16
|
+
name?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Value of the input element. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
|
|
19
|
+
*/
|
|
20
|
+
value?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Helper text to be placed above the number.
|
|
23
|
+
*/
|
|
24
|
+
helperText?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Text to be put as placeholder of the number.
|
|
27
|
+
*/
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
/**
|
|
30
|
+
* If true, the component will be disabled.
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* If true, the number will be optional, showing '(Optional)'
|
|
35
|
+
* next to the label. Otherwise, the field will be considered required
|
|
36
|
+
* and an error will be passed as a parameter to the OnBlur and onChange
|
|
37
|
+
* functions when it has not been filled.
|
|
38
|
+
*/
|
|
39
|
+
optional?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Prefix to be placed before the number value.
|
|
42
|
+
*/
|
|
43
|
+
prefix?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Suffix to be placed after the number value.
|
|
46
|
+
*/
|
|
47
|
+
suffix?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Minimum value allowed by the number input. If the typed value by the user is
|
|
50
|
+
* lower than min, the onBlur and onChange functions will be called with
|
|
51
|
+
* the current value and an internal error informing that the current
|
|
52
|
+
* value is not correct. If a valid state is reached, the error parameter
|
|
53
|
+
* will be null in both events.
|
|
54
|
+
*/
|
|
55
|
+
min?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Maximum value allowed by the number input. If the typed value by the user
|
|
58
|
+
* surpasses max, the onBlur and onChange functions will be called with
|
|
59
|
+
* the current value and an internal error informing that the current
|
|
60
|
+
* value is not correct. If a valid state is reached, the error parameter
|
|
61
|
+
* will be null in both events.
|
|
62
|
+
*/
|
|
63
|
+
max?: number;
|
|
64
|
+
/**
|
|
65
|
+
* The step interval to use when using the up and down arrows to adjust the value.
|
|
66
|
+
*/
|
|
67
|
+
step?: number;
|
|
68
|
+
/**
|
|
69
|
+
* This function will be called when the user types within the input
|
|
70
|
+
* element of the component. An object including the current value and
|
|
71
|
+
* the error (if the value entered is not valid) will be passed to this
|
|
72
|
+
* function. If there is no error, error will be null.
|
|
73
|
+
*/
|
|
74
|
+
onChange?: (val: {
|
|
75
|
+
value: string;
|
|
76
|
+
error: string | null;
|
|
77
|
+
}) => void;
|
|
78
|
+
/**
|
|
79
|
+
* This function will be called when the input element loses the focus.
|
|
80
|
+
* An object including the input value and the error (if the value
|
|
81
|
+
* entered is not valid) will be passed to this function. If there is no error,
|
|
82
|
+
* error will be null.
|
|
83
|
+
*/
|
|
84
|
+
onBlur?: (val: {
|
|
85
|
+
value: string;
|
|
86
|
+
error: string | null;
|
|
87
|
+
}) => void;
|
|
88
|
+
/**
|
|
89
|
+
* If it is defined, the component will change its appearance, showing
|
|
90
|
+
* the error below the input component. If it is not defined, the error
|
|
91
|
+
* messages will be managed internally, but never displayed on its own.
|
|
92
|
+
*/
|
|
93
|
+
error?: string;
|
|
94
|
+
/**
|
|
95
|
+
* HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
|
|
96
|
+
* Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
|
|
97
|
+
*/
|
|
98
|
+
autocomplete?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
101
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
102
|
+
*/
|
|
103
|
+
margin?: Space | Margin;
|
|
104
|
+
/**
|
|
105
|
+
* Size of the component ('small' | 'medium' | 'large' | 'fillParent').
|
|
106
|
+
*/
|
|
107
|
+
size?: "small" | "medium" | "large" | "fillParent";
|
|
108
|
+
/**
|
|
109
|
+
* Value of the tabindex attribute.
|
|
110
|
+
*/
|
|
111
|
+
tabIndex?: number;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Reference to the component.
|
|
115
|
+
*/
|
|
116
|
+
export declare type RefType = HTMLDivElement;
|
|
117
|
+
export default Props;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxc-technology/halstack-react",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-e1a279c",
|
|
4
4
|
"description": "DXC Halstack React components library",
|
|
5
5
|
"repository": "dxc-technology/halstack-react",
|
|
6
6
|
"homepage": "http://developer.dxc.com/tools/react",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"@material-ui/lab": "4.0.0-alpha.17",
|
|
25
25
|
"@material-ui/pickers": "3.2.2",
|
|
26
26
|
"@material-ui/styles": "4.0.2",
|
|
27
|
-
"@testing-library/user-event": "^12.6.3",
|
|
28
27
|
"color": "^3.1.3",
|
|
29
28
|
"date-fns": "^2.0.0-beta.4",
|
|
30
29
|
"moment": "2.24.0",
|
|
@@ -53,8 +52,9 @@
|
|
|
53
52
|
"@storybook/addon-essentials": "^6.4.9",
|
|
54
53
|
"@storybook/addon-links": "^6.4.9",
|
|
55
54
|
"@storybook/react": "^6.4.9",
|
|
56
|
-
"@storybook/testing-library": "0.0.7",
|
|
57
55
|
"@testing-library/react": "^11.2.5",
|
|
56
|
+
"@storybook/testing-library": "0.0.7",
|
|
57
|
+
"@testing-library/user-event": "^12.6.3",
|
|
58
58
|
"babel-jest": "^24.8.0",
|
|
59
59
|
"babel-loader": "^8.0.6",
|
|
60
60
|
"chromatic": "^6.3.3",
|