@dxc-technology/halstack-react 0.0.0-301f60b → 0.0.0-335f028
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HalstackContext.d.ts +10 -0
- package/{ThemeContext.js → HalstackContext.js} +6 -6
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +7 -28
- package/accordion/Accordion.stories.tsx +11 -11
- package/accordion/Accordion.test.js +19 -4
- package/accordion/types.d.ts +4 -0
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +13 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +24 -6
- package/accordion-group/types.d.ts +4 -0
- package/bleed/types.d.ts +24 -0
- package/button/Button.js +14 -11
- package/card/Card.js +27 -28
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +40 -39
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +13 -0
- package/checkbox/types.d.ts +7 -3
- package/common/variables.js +6 -7
- package/date-input/DateInput.js +50 -39
- package/date-input/DateInput.stories.tsx +7 -7
- package/date-input/DateInput.test.js +69 -59
- package/date-input/types.d.ts +16 -9
- package/dialog/Dialog.js +4 -32
- package/dropdown/Dropdown.js +13 -17
- package/footer/Footer.js +10 -85
- package/header/Header.js +20 -44
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- package/inset/types.d.ts +24 -0
- package/layout/ApplicationLayout.js +5 -18
- package/link/Link.d.ts +3 -2
- package/link/Link.js +65 -56
- package/link/Link.stories.tsx +87 -52
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +8 -23
- package/main.d.ts +3 -2
- package/main.js +13 -5
- package/number-input/NumberInput.js +11 -18
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +2 -4
- package/number-input/types.d.ts +16 -9
- package/package.json +6 -5
- package/password-input/PasswordInput.test.js +2 -4
- package/password-input/types.d.ts +13 -10
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +64 -0
- package/quick-nav/QuickNav.stories.tsx +237 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio/Radio.js +10 -11
- package/row/types.d.ts +18 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +148 -0
- package/select/Option.js +1 -1
- package/select/Select.js +71 -156
- package/select/Select.stories.tsx +19 -19
- package/select/Select.test.js +405 -248
- package/select/types.d.ts +42 -12
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +2 -1
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +31 -10
- package/slider/types.d.ts +4 -0
- package/stack/types.d.ts +15 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +32 -19
- package/switch/Switch.stories.tsx +14 -14
- package/switch/Switch.test.js +25 -0
- package/switch/types.d.ts +6 -2
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +9 -11
- package/tabs/Tabs.stories.tsx +0 -8
- package/tabs/Tabs.test.js +26 -9
- package/tabs/types.d.ts +4 -0
- package/tag/Tag.js +14 -19
- package/tag/Tag.stories.tsx +12 -8
- package/text-input/TextInput.js +2 -4
- package/text-input/TextInput.test.js +21 -34
- package/text-input/types.d.ts +13 -10
- package/textarea/Textarea.js +2 -4
- package/textarea/Textarea.test.js +10 -20
- package/textarea/types.d.ts +13 -10
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +35 -4
- package/toggle-group/types.d.ts +8 -0
- package/useTheme.js +2 -2
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +28 -19
- package/wizard/Wizard.stories.tsx +13 -23
- package/wizard/Wizard.test.js +36 -23
- package/wizard/types.d.ts +6 -2
- package/ThemeContext.d.ts +0 -10
package/link/types.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
-
declare type Margin = {
|
|
2
|
+
export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
export declare type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type
|
|
9
|
+
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
10
|
+
export declare type LinkProps = {
|
|
10
11
|
/**
|
|
11
12
|
* If true, the color is inherited from parent.
|
|
12
13
|
*/
|
|
@@ -41,30 +42,14 @@ declare type LinkCommonProps = {
|
|
|
41
42
|
* Value of the tabindex.
|
|
42
43
|
*/
|
|
43
44
|
tabIndex?: number;
|
|
44
|
-
};
|
|
45
|
-
export declare type LinkTextProps = LinkCommonProps & {
|
|
46
45
|
/**
|
|
47
|
-
* Link
|
|
46
|
+
* Content of the link. To use the component with other libraries (such as React Router or Next.js Link) pass the custom link as a child.
|
|
47
|
+
* The component will apply the styles to the custom link.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
children?: React.ReactNode;
|
|
50
50
|
/**
|
|
51
51
|
* Element or path used as the icon that will be placed next to the link text.
|
|
52
52
|
*/
|
|
53
53
|
icon?: string | SVG;
|
|
54
54
|
};
|
|
55
|
-
export
|
|
56
|
-
/**
|
|
57
|
-
* Link text.
|
|
58
|
-
*/
|
|
59
|
-
text?: string;
|
|
60
|
-
/**
|
|
61
|
-
* Element or path used as the icon that will be placed next to the link text.
|
|
62
|
-
*/
|
|
63
|
-
icon: string | SVG;
|
|
64
|
-
};
|
|
65
|
-
declare type Overload = {
|
|
66
|
-
(props: LinkTextProps): JSX.Element;
|
|
67
|
-
(props: LinkIconProps): JSX.Element;
|
|
68
|
-
};
|
|
69
|
-
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
70
|
-
export default Overload;
|
|
55
|
+
export {};
|
package/main.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ import DxcList from "./list/List";
|
|
|
41
41
|
import DxcRadioGroup from "./radio-group/RadioGroup";
|
|
42
42
|
import DxcBleed from "./bleed/Bleed";
|
|
43
43
|
import DxcInset from "./inset/Inset";
|
|
44
|
-
import
|
|
44
|
+
import DxcQuickNav from "./quick-nav/QuickNav";
|
|
45
|
+
import HalstackContext, { HalstackProvider } from "./HalstackContext";
|
|
45
46
|
import { BackgroundColorProvider } from "./BackgroundColorContext";
|
|
46
|
-
export { DxcAlert, DxcButton, DxcFooter, DxcCheckbox, DxcTextInput, DxcDropdown, DxcSwitch, DxcSlider, DxcRadio, DxcHeader, DxcTable, DxcTabs, DxcToggleGroup, DxcDialog, DxcCard, DxcProgressBar, DxcAccordion, DxcSpinner, DxcBox, DxcTag, DxcPaginator, DxcSidenav, DxcWizard, DxcLink, DxcHeading, DxcResultsetTable, DxcChip, DxcApplicationLayout,
|
|
47
|
+
export { DxcAlert, DxcButton, DxcFooter, DxcCheckbox, DxcTextInput, DxcDropdown, DxcSwitch, DxcSlider, DxcRadio, DxcHeader, DxcTable, DxcTabs, DxcToggleGroup, DxcDialog, DxcCard, DxcProgressBar, DxcAccordion, DxcSpinner, DxcBox, DxcTag, DxcPaginator, DxcSidenav, DxcWizard, DxcLink, DxcHeading, DxcResultsetTable, DxcChip, DxcApplicationLayout, HalstackContext, HalstackProvider, BackgroundColorProvider, DxcAccordionGroup, DxcBadge, DxcPasswordInput, DxcDateInput, DxcNumberInput, DxcTextarea, DxcSelect, DxcFileInput, DxcStack, DxcRow, DxcText, DxcList, DxcRadioGroup, DxcBleed, DxcInset, DxcQuickNav, };
|
package/main.js
CHANGED
|
@@ -163,6 +163,12 @@ Object.defineProperty(exports, "DxcProgressBar", {
|
|
|
163
163
|
return _ProgressBar["default"];
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
+
Object.defineProperty(exports, "DxcQuickNav", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function get() {
|
|
169
|
+
return _QuickNav["default"];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
166
172
|
Object.defineProperty(exports, "DxcRadio", {
|
|
167
173
|
enumerable: true,
|
|
168
174
|
get: function get() {
|
|
@@ -271,16 +277,16 @@ Object.defineProperty(exports, "DxcWizard", {
|
|
|
271
277
|
return _Wizard["default"];
|
|
272
278
|
}
|
|
273
279
|
});
|
|
274
|
-
Object.defineProperty(exports, "
|
|
280
|
+
Object.defineProperty(exports, "HalstackContext", {
|
|
275
281
|
enumerable: true,
|
|
276
282
|
get: function get() {
|
|
277
|
-
return
|
|
283
|
+
return _HalstackContext["default"];
|
|
278
284
|
}
|
|
279
285
|
});
|
|
280
|
-
Object.defineProperty(exports, "
|
|
286
|
+
Object.defineProperty(exports, "HalstackProvider", {
|
|
281
287
|
enumerable: true,
|
|
282
288
|
get: function get() {
|
|
283
|
-
return
|
|
289
|
+
return _HalstackContext.HalstackProvider;
|
|
284
290
|
}
|
|
285
291
|
});
|
|
286
292
|
|
|
@@ -370,7 +376,9 @@ var _Bleed = _interopRequireDefault(require("./bleed/Bleed"));
|
|
|
370
376
|
|
|
371
377
|
var _Inset = _interopRequireDefault(require("./inset/Inset"));
|
|
372
378
|
|
|
373
|
-
var
|
|
379
|
+
var _QuickNav = _interopRequireDefault(require("./quick-nav/QuickNav"));
|
|
380
|
+
|
|
381
|
+
var _HalstackContext = _interopRequireWildcard(require("./HalstackContext"));
|
|
374
382
|
|
|
375
383
|
var _BackgroundColorContext = require("./BackgroundColorContext");
|
|
376
384
|
|
|
@@ -21,20 +21,15 @@ var _templateObject;
|
|
|
21
21
|
|
|
22
22
|
var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
23
23
|
var label = _ref.label,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
name = _ref.name,
|
|
25
|
+
defaultValue = _ref.defaultValue,
|
|
26
26
|
value = _ref.value,
|
|
27
27
|
helperText = _ref.helperText,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
34
|
-
_ref$prefix = _ref.prefix,
|
|
35
|
-
prefix = _ref$prefix === void 0 ? "" : _ref$prefix,
|
|
36
|
-
_ref$suffix = _ref.suffix,
|
|
37
|
-
suffix = _ref$suffix === void 0 ? "" : _ref$suffix,
|
|
28
|
+
placeholder = _ref.placeholder,
|
|
29
|
+
disabled = _ref.disabled,
|
|
30
|
+
optional = _ref.optional,
|
|
31
|
+
prefix = _ref.prefix,
|
|
32
|
+
suffix = _ref.suffix,
|
|
38
33
|
min = _ref.min,
|
|
39
34
|
max = _ref.max,
|
|
40
35
|
_ref$step = _ref.step,
|
|
@@ -42,13 +37,10 @@ var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, r
|
|
|
42
37
|
onChange = _ref.onChange,
|
|
43
38
|
onBlur = _ref.onBlur,
|
|
44
39
|
error = _ref.error,
|
|
45
|
-
|
|
46
|
-
autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
|
|
40
|
+
autocomplete = _ref.autocomplete,
|
|
47
41
|
margin = _ref.margin,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_ref$tabIndex = _ref.tabIndex,
|
|
51
|
-
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
42
|
+
size = _ref.size,
|
|
43
|
+
tabIndex = _ref.tabIndex;
|
|
52
44
|
return /*#__PURE__*/_react["default"].createElement(_NumberInputContext["default"].Provider, {
|
|
53
45
|
value: {
|
|
54
46
|
typeNumber: "number",
|
|
@@ -59,6 +51,7 @@ var DxcNumberInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, r
|
|
|
59
51
|
}, /*#__PURE__*/_react["default"].createElement(NumberInputContainer, null, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
60
52
|
label: label,
|
|
61
53
|
name: name,
|
|
54
|
+
defaultValue: defaultValue,
|
|
62
55
|
value: value,
|
|
63
56
|
helperText: helperText,
|
|
64
57
|
placeholder: placeholder,
|
|
@@ -22,7 +22,7 @@ export const Chromatic = () => (
|
|
|
22
22
|
</ExampleContainer>
|
|
23
23
|
<ExampleContainer>
|
|
24
24
|
<Title title="Helper text, optional and value" theme="light" level={4} />
|
|
25
|
-
<DxcNumberInput label="Number input"
|
|
25
|
+
<DxcNumberInput label="Number input" defaultValue="12" helperText="Help message" optional />
|
|
26
26
|
</ExampleContainer>
|
|
27
27
|
<ExampleContainer>
|
|
28
28
|
<Title title="Disabled and placeholder" theme="light" level={4} />
|
|
@@ -30,7 +30,7 @@ export const Chromatic = () => (
|
|
|
30
30
|
</ExampleContainer>
|
|
31
31
|
<ExampleContainer>
|
|
32
32
|
<Title title="Disabled, helper text, optional and value" theme="light" level={4} />
|
|
33
|
-
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional
|
|
33
|
+
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional defaultValue="10" />
|
|
34
34
|
</ExampleContainer>
|
|
35
35
|
<ExampleContainer>
|
|
36
36
|
<Title title="Prefix" theme="light" level={4} />
|
|
@@ -42,7 +42,7 @@ export const Chromatic = () => (
|
|
|
42
42
|
</ExampleContainer>
|
|
43
43
|
<ExampleContainer>
|
|
44
44
|
<Title title="Invalid" theme="light" level={4} />
|
|
45
|
-
<DxcNumberInput label="Error number input" helperText="Help message" error="Error message."
|
|
45
|
+
<DxcNumberInput label="Error number input" helperText="Help message" error="Error message." defaultValue="23" optional />
|
|
46
46
|
</ExampleContainer>
|
|
47
47
|
<BackgroundColorProvider color="#333333">
|
|
48
48
|
<DarkContainer>
|
|
@@ -53,7 +53,7 @@ export const Chromatic = () => (
|
|
|
53
53
|
</ExampleContainer>
|
|
54
54
|
<ExampleContainer>
|
|
55
55
|
<Title title="Helper text, value and error" theme="dark" level={4} />
|
|
56
|
-
<DxcNumberInput label="Number input" helperText="Help message" error="Error message."
|
|
56
|
+
<DxcNumberInput label="Number input" helperText="Help message" error="Error message." defaultValue="199" />
|
|
57
57
|
</ExampleContainer>
|
|
58
58
|
<ExampleContainer>
|
|
59
59
|
<Title title="Disabled and placeholder" theme="dark" level={4} />
|
|
@@ -61,7 +61,7 @@ export const Chromatic = () => (
|
|
|
61
61
|
</ExampleContainer>
|
|
62
62
|
<ExampleContainer>
|
|
63
63
|
<Title title="Disabled, helper text, optional and value" theme="dark" level={4} />
|
|
64
|
-
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional
|
|
64
|
+
<DxcNumberInput label="Disabled number input" helperText="Help message" disabled optional defaultValue="1232454" />
|
|
65
65
|
</ExampleContainer>
|
|
66
66
|
</DarkContainer>
|
|
67
67
|
</BackgroundColorProvider>
|
|
@@ -135,16 +135,14 @@ describe("Number input component tests", function () {
|
|
|
135
135
|
_userEvent["default"].type(number, "t");
|
|
136
136
|
|
|
137
137
|
expect(onChange).not.toHaveBeenCalledWith({
|
|
138
|
-
value: "t"
|
|
139
|
-
error: null
|
|
138
|
+
value: "t"
|
|
140
139
|
});
|
|
141
140
|
expect(number.value).toBe("");
|
|
142
141
|
|
|
143
142
|
_userEvent["default"].type(number, "1");
|
|
144
143
|
|
|
145
144
|
expect(onChange).toHaveBeenCalledWith({
|
|
146
|
-
value: "1"
|
|
147
|
-
error: null
|
|
145
|
+
value: "1"
|
|
148
146
|
});
|
|
149
147
|
expect(number.value).toBe("1");
|
|
150
148
|
});
|
package/number-input/types.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ declare type Props = {
|
|
|
14
14
|
* Name attribute of the input element.
|
|
15
15
|
*/
|
|
16
16
|
name?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Initial value of the input element, only when it is uncontrolled.
|
|
19
|
+
*/
|
|
20
|
+
defaultValue?: string;
|
|
17
21
|
/**
|
|
18
22
|
* Value of the input element. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
|
|
19
23
|
*/
|
|
@@ -50,7 +54,7 @@ declare type Props = {
|
|
|
50
54
|
* lower than min, the onBlur and onChange functions will be called with
|
|
51
55
|
* the current value and an internal error informing that the current
|
|
52
56
|
* value is not correct. If a valid state is reached, the error parameter
|
|
53
|
-
* will be
|
|
57
|
+
* will not be defined in both events.
|
|
54
58
|
*/
|
|
55
59
|
min?: number;
|
|
56
60
|
/**
|
|
@@ -58,7 +62,7 @@ declare type Props = {
|
|
|
58
62
|
* surpasses max, the onBlur and onChange functions will be called with
|
|
59
63
|
* the current value and an internal error informing that the current
|
|
60
64
|
* value is not correct. If a valid state is reached, the error parameter
|
|
61
|
-
* will be
|
|
65
|
+
* will not be defined in both events.
|
|
62
66
|
*/
|
|
63
67
|
max?: number;
|
|
64
68
|
/**
|
|
@@ -69,26 +73,29 @@ declare type Props = {
|
|
|
69
73
|
* This function will be called when the user types within the input
|
|
70
74
|
* element of the component. An object including the current value and
|
|
71
75
|
* the error (if the value entered is not valid) will be passed to this
|
|
72
|
-
* function. If there is no error, error will be
|
|
76
|
+
* function. If there is no error, error will not be defined.
|
|
73
77
|
*/
|
|
74
78
|
onChange?: (val: {
|
|
75
79
|
value: string;
|
|
76
|
-
error
|
|
80
|
+
error?: string;
|
|
77
81
|
}) => void;
|
|
78
82
|
/**
|
|
79
83
|
* This function will be called when the input element loses the focus.
|
|
80
84
|
* An object including the input value and the error (if the value
|
|
81
85
|
* entered is not valid) will be passed to this function. If there is no error,
|
|
82
|
-
* error will be
|
|
86
|
+
* error will not be defined.
|
|
83
87
|
*/
|
|
84
88
|
onBlur?: (val: {
|
|
85
89
|
value: string;
|
|
86
|
-
error
|
|
90
|
+
error?: string;
|
|
87
91
|
}) => void;
|
|
88
92
|
/**
|
|
89
|
-
* If it is defined
|
|
90
|
-
* the error below the input component. If
|
|
91
|
-
*
|
|
93
|
+
* If it is a defined value and also a truthy string, the component will
|
|
94
|
+
* change its appearance, showing the error below the input component. If
|
|
95
|
+
* the defined value is an empty string, it will reserve a space below
|
|
96
|
+
* the component for a future error, but it would not change its look. In
|
|
97
|
+
* case of being undefined or null, both the appearance and the space for
|
|
98
|
+
* the error message would not be modified.
|
|
92
99
|
*/
|
|
93
100
|
error?: string;
|
|
94
101
|
/**
|
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-335f028",
|
|
4
4
|
"description": "DXC Halstack React components library",
|
|
5
5
|
"repository": "dxc-technology/halstack-react",
|
|
6
6
|
"homepage": "http://developer.dxc.com/tools/react",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"styled-components": "^5.0.1"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@date-io/
|
|
21
|
+
"@date-io/dayjs": "^1.3.9",
|
|
22
22
|
"@material-ui/core": "4.11.1",
|
|
23
23
|
"@material-ui/icons": "4.4.3",
|
|
24
24
|
"@material-ui/lab": "4.0.0-alpha.17",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"@types/styled-components": "^5.1.24",
|
|
28
28
|
"@types/uuid": "^8.3.4",
|
|
29
29
|
"color": "^3.1.3",
|
|
30
|
-
"
|
|
31
|
-
"moment": "2.24.0",
|
|
30
|
+
"dayjs": "^1.11.1",
|
|
32
31
|
"prop-types": "^15.7.2",
|
|
33
32
|
"rgb-hex": "^3.0.0",
|
|
33
|
+
"slugify": "^1.6.5",
|
|
34
34
|
"uuid": "^8.3.2"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"test": "jest",
|
|
38
38
|
"test:watch": "npm test -- --watch --coverage",
|
|
39
39
|
"build": "babel src --extensions .js,.jsx,.ts,.tsx --out-dir ../dist --copy-files --verbose && node ../scripts/build/copy-package.js && tsc ",
|
|
40
|
-
"build:watch": "babel src --watch --out-dir ../dist --copy-files --verbose",
|
|
40
|
+
"build:watch": "babel src --watch --extensions .js,.jsx,.ts,.tsx --out-dir ../dist --copy-files --verbose",
|
|
41
41
|
"storybook": "start-storybook -p 6006",
|
|
42
42
|
"build-storybook": "build-storybook"
|
|
43
43
|
},
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@storybook/testing-library": "0.0.7",
|
|
58
58
|
"@testing-library/react": "^11.2.5",
|
|
59
59
|
"@testing-library/user-event": "^12.6.3",
|
|
60
|
+
"@types/react": "16.9.5",
|
|
60
61
|
"babel-jest": "^24.8.0",
|
|
61
62
|
"babel-loader": "^8.0.6",
|
|
62
63
|
"chromatic": "^6.3.3",
|
|
@@ -53,8 +53,7 @@ describe("Password input component tests", function () {
|
|
|
53
53
|
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
54
54
|
|
|
55
55
|
expect(onChange).toHaveBeenCalledWith({
|
|
56
|
-
value: "P"
|
|
57
|
-
error: null
|
|
56
|
+
value: "P"
|
|
58
57
|
});
|
|
59
58
|
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
60
59
|
});
|
|
@@ -74,8 +73,7 @@ describe("Password input component tests", function () {
|
|
|
74
73
|
_react2.fireEvent.blur(passwordInput);
|
|
75
74
|
|
|
76
75
|
expect(onBlur).toHaveBeenCalledWith({
|
|
77
|
-
value: "Pa$$w0rd"
|
|
78
|
-
error: null
|
|
76
|
+
value: "Pa$$w0rd"
|
|
79
77
|
});
|
|
80
78
|
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
81
79
|
});
|
|
@@ -30,25 +30,28 @@ declare type Props = {
|
|
|
30
30
|
* This function will be called when the user types within the input
|
|
31
31
|
* element of the component. An object including the current value and
|
|
32
32
|
* the error (if the value entered is not valid) will be passed to this
|
|
33
|
-
* function. If there is no error, error will be
|
|
33
|
+
* function. If there is no error, error will not be defined.
|
|
34
34
|
* */
|
|
35
35
|
onChange?: (val: {
|
|
36
36
|
value: string;
|
|
37
|
-
error
|
|
37
|
+
error?: string;
|
|
38
38
|
}) => void;
|
|
39
39
|
/**
|
|
40
40
|
* This function will be called when the input element loses the focus.
|
|
41
41
|
* An object including the input value and the error (if the value entered is
|
|
42
|
-
* not valid) will be passed to this function. If there is no error, error will be
|
|
42
|
+
* not valid) will be passed to this function. If there is no error, error will not be defined.
|
|
43
43
|
*/
|
|
44
44
|
onBlur?: (val: {
|
|
45
45
|
value: string;
|
|
46
|
-
error
|
|
46
|
+
error?: string;
|
|
47
47
|
}) => void;
|
|
48
48
|
/**
|
|
49
|
-
* If it is defined
|
|
50
|
-
* the error below the password input
|
|
51
|
-
*
|
|
49
|
+
* If it is a defined value and also a truthy string, the component will
|
|
50
|
+
* change its appearance, showing the error below the password input
|
|
51
|
+
* component. If the defined value is an empty string, it will reserve a
|
|
52
|
+
* space below the component for a future error, but it would not change
|
|
53
|
+
* its look. In case of being undefined or null, both the appearance and
|
|
54
|
+
* the space for the error message would not be modified.
|
|
52
55
|
*/
|
|
53
56
|
error?: string;
|
|
54
57
|
/**
|
|
@@ -58,7 +61,7 @@ declare type Props = {
|
|
|
58
61
|
* the pattern, the onBlur and onChange functions will be called with the
|
|
59
62
|
* current value and an internal error informing that this value does not
|
|
60
63
|
* match the pattern. If the pattern is met, the error parameter of both
|
|
61
|
-
* events will be
|
|
64
|
+
* events will not be defined.
|
|
62
65
|
*/
|
|
63
66
|
pattern?: string;
|
|
64
67
|
/**
|
|
@@ -68,7 +71,7 @@ declare type Props = {
|
|
|
68
71
|
* comply the minimum length, the onBlur and onChange functions will be called
|
|
69
72
|
* with the current value and an internal error informing that the value
|
|
70
73
|
* length does not comply the specified range. If a valid length is
|
|
71
|
-
* reached, the error parameter of both events will be
|
|
74
|
+
* reached, the error parameter of both events will not be defined.
|
|
72
75
|
*/
|
|
73
76
|
minLength?: number;
|
|
74
77
|
/**
|
|
@@ -78,7 +81,7 @@ declare type Props = {
|
|
|
78
81
|
* comply the maximum length, the onBlur and onChange functions will be called
|
|
79
82
|
* with the current value and an internal error informing that the value
|
|
80
83
|
* length does not comply the specified range. If a valid length is
|
|
81
|
-
* reached, the error parameter of both events will be
|
|
84
|
+
* reached, the error parameter of both events will not be defined.
|
|
82
85
|
*/
|
|
83
86
|
maxLength?: number;
|
|
84
87
|
/**
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _slugify = _interopRequireDefault(require("slugify"));
|
|
17
|
+
|
|
18
|
+
var _Heading = _interopRequireDefault(require("../heading/Heading"));
|
|
19
|
+
|
|
20
|
+
var _Stack = _interopRequireDefault(require("../stack/Stack"));
|
|
21
|
+
|
|
22
|
+
var _Inset = _interopRequireDefault(require("../inset/Inset"));
|
|
23
|
+
|
|
24
|
+
var _List = _interopRequireDefault(require("../list/List"));
|
|
25
|
+
|
|
26
|
+
var _Text = _interopRequireDefault(require("../text/Text"));
|
|
27
|
+
|
|
28
|
+
var _templateObject, _templateObject2;
|
|
29
|
+
|
|
30
|
+
var DxcQuickNav = function DxcQuickNav(_ref) {
|
|
31
|
+
var title = _ref.title,
|
|
32
|
+
links = _ref.links;
|
|
33
|
+
return /*#__PURE__*/_react["default"].createElement(QuickNavContainer, null, /*#__PURE__*/_react["default"].createElement(_Stack["default"], {
|
|
34
|
+
gutter: "small"
|
|
35
|
+
}, /*#__PURE__*/_react["default"].createElement(_Heading["default"], {
|
|
36
|
+
level: 4,
|
|
37
|
+
text: title
|
|
38
|
+
}), /*#__PURE__*/_react["default"].createElement(_List["default"], null, links.map(function (link) {
|
|
39
|
+
var _link$links;
|
|
40
|
+
|
|
41
|
+
return /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
|
|
42
|
+
space: "xxsmall"
|
|
43
|
+
}, /*#__PURE__*/_react["default"].createElement(_Text["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
|
|
44
|
+
href: "#".concat((0, _slugify["default"])(link === null || link === void 0 ? void 0 : link.label, {
|
|
45
|
+
lower: true
|
|
46
|
+
}))
|
|
47
|
+
}, link === null || link === void 0 ? void 0 : link.label), (_link$links = link.links) === null || _link$links === void 0 ? void 0 : _link$links.map(function (sublink) {
|
|
48
|
+
return /*#__PURE__*/_react["default"].createElement(_Inset["default"], {
|
|
49
|
+
horizontal: "xsmall"
|
|
50
|
+
}, /*#__PURE__*/_react["default"].createElement(_Text["default"], null, /*#__PURE__*/_react["default"].createElement(Link, {
|
|
51
|
+
href: "#".concat((0, _slugify["default"])(sublink === null || sublink === void 0 ? void 0 : sublink.label, {
|
|
52
|
+
lower: true
|
|
53
|
+
}))
|
|
54
|
+
}, sublink === null || sublink === void 0 ? void 0 : sublink.label)));
|
|
55
|
+
})));
|
|
56
|
+
}))));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var QuickNavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n padding: 5px 15px;\n border-left: 2px solid #bfbfbf;\n li {\n div:first-child {\n display: none;\n }\n }\n"])));
|
|
60
|
+
|
|
61
|
+
var Link = _styledComponents["default"].a(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n text-decoration: none;\n font-size: 14px;\n color: #666666;\n &:hover {\n color: #ab63cf;\n }\n &:focus {\n border-radius: 2px;\n border-color: #0095ff;\n }\n"])));
|
|
62
|
+
|
|
63
|
+
var _default = DxcQuickNav;
|
|
64
|
+
exports["default"] = _default;
|