@dxc-technology/halstack-react 0.0.0-d20b360 → 0.0.0-d238e47

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.
Files changed (110) hide show
  1. package/alert/Alert.stories.tsx +170 -0
  2. package/alert/types.d.ts +1 -1
  3. package/box/Box.d.ts +4 -0
  4. package/box/Box.js +4 -30
  5. package/box/{Box.stories.jsx → Box.stories.tsx} +0 -0
  6. package/box/types.d.ts +43 -0
  7. package/box/types.js +5 -0
  8. package/button/Button.d.ts +1 -1
  9. package/button/Button.js +7 -10
  10. package/button/Button.stories.tsx +217 -234
  11. package/button/types.d.ts +11 -11
  12. package/card/Card.js +4 -5
  13. package/card/Card.stories.tsx +201 -0
  14. package/card/ice-cream.jpg +0 -0
  15. package/card/types.d.ts +4 -6
  16. package/checkbox/types.d.ts +1 -1
  17. package/chip/Chip.stories.tsx +121 -0
  18. package/common/variables.js +29 -21
  19. package/date-input/DateInput.stories.tsx +138 -0
  20. package/dialog/Dialog.stories.tsx +212 -0
  21. package/file-input/FileInput.d.ts +4 -0
  22. package/file-input/FileInput.js +7 -28
  23. package/file-input/FileItem.d.ts +14 -0
  24. package/file-input/FileItem.js +4 -15
  25. package/file-input/types.d.ts +87 -0
  26. package/file-input/types.js +5 -0
  27. package/footer/types.d.ts +1 -1
  28. package/header/Header.stories.tsx +162 -0
  29. package/header/types.d.ts +4 -2
  30. package/heading/Heading.d.ts +4 -0
  31. package/heading/Heading.js +6 -23
  32. package/heading/Heading.stories.tsx +53 -0
  33. package/heading/types.d.ts +33 -0
  34. package/heading/types.js +5 -0
  35. package/link/Link.d.ts +3 -0
  36. package/link/Link.js +3 -25
  37. package/link/Link.stories.tsx +146 -0
  38. package/link/types.d.ts +74 -0
  39. package/link/types.js +5 -0
  40. package/number-input/NumberInput.d.ts +4 -0
  41. package/number-input/NumberInput.js +2 -44
  42. package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +0 -0
  43. package/number-input/NumberInputContext.d.ts +4 -0
  44. package/number-input/NumberInputContext.js +5 -2
  45. package/number-input/numberInputContextTypes.d.ts +19 -0
  46. package/number-input/numberInputContextTypes.js +5 -0
  47. package/number-input/types.d.ts +117 -0
  48. package/number-input/types.js +5 -0
  49. package/package.json +1 -1
  50. package/password-input/PasswordInput.d.ts +4 -0
  51. package/password-input/PasswordInput.js +0 -37
  52. package/password-input/{PasswordInput.stories.jsx → PasswordInput.stories.tsx} +1 -1
  53. package/password-input/types.d.ts +105 -0
  54. package/password-input/types.js +5 -0
  55. package/progress-bar/ProgressBar.stories.jsx +58 -0
  56. package/radio/types.d.ts +2 -2
  57. package/resultsetTable/ResultsetTable.d.ts +4 -0
  58. package/resultsetTable/ResultsetTable.js +0 -25
  59. package/resultsetTable/types.d.ts +63 -0
  60. package/resultsetTable/types.js +5 -0
  61. package/select/Select.stories.tsx +572 -0
  62. package/sidenav/Sidenav.d.ts +9 -0
  63. package/sidenav/Sidenav.js +4 -13
  64. package/sidenav/Sidenav.stories.tsx +165 -0
  65. package/sidenav/types.d.ts +50 -0
  66. package/sidenav/types.js +5 -0
  67. package/slider/Slider.d.ts +1 -1
  68. package/slider/Slider.js +41 -30
  69. package/slider/Slider.stories.tsx +177 -0
  70. package/slider/types.d.ts +2 -7
  71. package/spinner/Spinner.d.ts +4 -0
  72. package/spinner/Spinner.js +0 -17
  73. package/spinner/types.d.ts +32 -0
  74. package/spinner/types.js +5 -0
  75. package/switch/Switch.js +2 -2
  76. package/switch/Switch.stories.tsx +160 -0
  77. package/table/Table.d.ts +4 -0
  78. package/table/Table.js +1 -1
  79. package/table/types.d.ts +21 -0
  80. package/table/types.js +5 -0
  81. package/tabs/Tabs.js +3 -1
  82. package/tabs/types.d.ts +2 -3
  83. package/tag/Tag.d.ts +4 -0
  84. package/tag/Tag.js +20 -35
  85. package/tag/Tag.stories.tsx +145 -0
  86. package/tag/types.d.ts +60 -0
  87. package/tag/types.js +5 -0
  88. package/text-input/TextInput.d.ts +4 -0
  89. package/text-input/TextInput.js +4 -44
  90. package/text-input/types.d.ts +157 -0
  91. package/text-input/types.js +5 -0
  92. package/toggle-group/ToggleGroup.stories.tsx +178 -0
  93. package/wizard/Wizard.d.ts +4 -0
  94. package/wizard/Wizard.js +11 -51
  95. package/wizard/Wizard.stories.jsx +224 -0
  96. package/wizard/types.d.ts +64 -0
  97. package/wizard/types.js +5 -0
  98. package/box/index.d.ts +0 -25
  99. package/file-input/index.d.ts +0 -81
  100. package/heading/index.d.ts +0 -17
  101. package/link/index.d.ts +0 -23
  102. package/number-input/index.d.ts +0 -113
  103. package/password-input/index.d.ts +0 -94
  104. package/resultsetTable/index.d.ts +0 -19
  105. package/sidenav/index.d.ts +0 -13
  106. package/spinner/index.d.ts +0 -17
  107. package/table/index.d.ts +0 -13
  108. package/tag/index.d.ts +0 -24
  109. package/text-input/index.d.ts +0 -135
  110. package/wizard/index.d.ts +0 -18
@@ -0,0 +1,32 @@
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 inside the spinner.
11
+ */
12
+ label?: string;
13
+ /**
14
+ * The value of the progress indicator. If it's received the
15
+ * component is determinate, otherwise is indeterminate.
16
+ */
17
+ value?: number;
18
+ /**
19
+ * If true, the value is displayed inside the spinner..
20
+ */
21
+ showValue?: boolean;
22
+ /**
23
+ * Available modes of the spinner.
24
+ */
25
+ mode?: "large" | "small" | "overlay";
26
+ /**
27
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
28
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
29
+ */
30
+ margin?: Space | Margin;
31
+ };
32
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/switch/Switch.js CHANGED
@@ -113,7 +113,7 @@ var calculateWidth = function calculateWidth(margin, size) {
113
113
  return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
114
114
  };
115
115
 
116
- var SwitchContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n display: inline-flex;\n align-items: center;\n flex-direction: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n\n .MuiSwitch-root {\n align-items: center;\n width: ", ";\n height: 45px;\n margin: 3px;\n\n .Mui-focusVisible {\n border: ", ";\n padding: 7px;\n }\n\n .MuiSwitch-track {\n /*Enabled and unchecked bar*/\n background-color: ", ";\n height: ", ";\n }\n\n .MuiSwitch-switchBase + .MuiSwitch-track {\n opacity: 1;\n }\n\n .MuiIconButton-root {\n /*Enabled and unchecked*/\n top: unset;\n .MuiSwitch-thumb {\n /*Only for thumb in all states*/\n width: ", ";\n height: ", ";\n }\n color: ", ";\n &:hover {\n background-color: transparent;\n }\n &.Mui-disabled {\n /*Disabled and unchecked*/\n color: ", ";\n + .MuiSwitch-track {\n /*Disabled and unchecked bar*/\n background-color: ", ";\n }\n }\n &.Mui-disabled.Mui-checked {\n /*Disabled and checked*/\n color: ", ";\n + .MuiSwitch-track {\n /*Disabled and checked bar*/\n background-color: ", ";\n }\n }\n &.Mui-checked {\n /*Enabled and checked*/\n color: ", ";\n transform: translateX(", ");\n &:hover {\n background-color: transparent;\n }\n + .MuiSwitch-track {\n /*Enabled and checked bar*/\n background-color: ", ";\n }\n }\n }\n }\n"])), function (props) {
116
+ var SwitchContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n display: inline-flex;\n align-items: center;\n flex-direction: ", ";\n \n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n\n .MuiSwitch-root {\n align-items: center;\n width: ", ";\n height: 45px;\n margin: 3px;\n\n .Mui-focusVisible {\n outline: ", ";\n outline-offset: -3px;\n }\n\n .MuiSwitch-track {\n /*Enabled and unchecked bar*/\n background-color: ", ";\n height: ", ";\n }\n\n .MuiSwitch-switchBase + .MuiSwitch-track {\n opacity: 1;\n }\n\n .MuiIconButton-root {\n /*Enabled and unchecked*/\n top: unset;\n .MuiSwitch-thumb {\n /*Only for thumb in all states*/\n width: ", ";\n height: ", ";\n }\n color: ", ";\n &:hover {\n background-color: transparent;\n }\n &.Mui-disabled {\n /*Disabled and unchecked*/\n color: ", ";\n + .MuiSwitch-track {\n /*Disabled and unchecked bar*/\n background-color: ", ";\n }\n }\n &.Mui-disabled.Mui-checked {\n /*Disabled and checked*/\n color: ", ";\n + .MuiSwitch-track {\n /*Disabled and checked bar*/\n background-color: ", ";\n }\n }\n &.Mui-checked {\n /*Enabled and checked*/\n color: ", ";\n transform: translateX(", ");\n &:hover {\n background-color: transparent;\n }\n + .MuiSwitch-track {\n /*Enabled and checked bar*/\n background-color: ", ";\n }\n }\n }\n }\n"])), function (props) {
117
117
  return calculateWidth(props.margin, props.size);
118
118
  }, function (props) {
119
119
  return props.labelPosition === "after" ? "row" : "row-reverse";
@@ -159,7 +159,7 @@ var SwitchContainer = _styledComponents["default"].div(_templateObject || (_temp
159
159
  return props.backgroundType === "dark" ? props.theme.checkedTrackBackgroundColorOnDark : props.theme.checkedTrackBackgroundColor;
160
160
  });
161
161
 
162
- var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n opacity: 1;\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n cursor: ", ";\n ", "\n"])), function (props) {
162
+ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: ", ";\n opacity: 1;\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n cursor: ", ";\n ", "\n"])), function (props) {
163
163
  return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor : props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
164
164
  }, function (props) {
165
165
  return props.theme.labelFontFamily;
@@ -0,0 +1,160 @@
1
+ import React from "react";
2
+ import { userEvent, within } from "@storybook/testing-library";
3
+ import DxcSwitch from "./Switch";
4
+ import { BackgroundColorProvider } from "../BackgroundColorContext";
5
+ import Title from "../../.storybook/components/Title";
6
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
7
+ import DarkContainer from "../../.storybook/components/DarkSection";
8
+
9
+ export default {
10
+ title: "Switch",
11
+ component: DxcSwitch,
12
+ };
13
+
14
+ export const Chromatic = () => (
15
+ <>
16
+ <ExampleContainer>
17
+ <Title title="With label after" theme="light" level={4} />
18
+ <DxcSwitch label="Switch" labelPosition="after" />
19
+ </ExampleContainer>
20
+ <ExampleContainer>
21
+ <Title title="Without label" theme="light" level={4} />
22
+ <DxcSwitch />
23
+ </ExampleContainer>
24
+ <ExampleContainer>
25
+ <Title title="Checked" theme="light" level={4} />
26
+ <DxcSwitch label="Switch" checked />
27
+ </ExampleContainer>
28
+ <ExampleContainer>
29
+ <Title title="Required" theme="light" level={4} />
30
+ <DxcSwitch label="Switch" required />
31
+ </ExampleContainer>
32
+ <ExampleContainer>
33
+ <Title title="Disabled" theme="light" level={4} />
34
+ <DxcSwitch label="Switch" disabled />
35
+ </ExampleContainer>
36
+ <ExampleContainer>
37
+ <Title title="Disabled required" theme="light" level={4} />
38
+ <DxcSwitch label="Switch" disabled required labelPosition="after" />
39
+ </ExampleContainer>
40
+ <ExampleContainer>
41
+ <Title title="Disabled checked" theme="light" level={4} />
42
+ <DxcSwitch label="Switch" disabled checked labelPosition="after" />
43
+ </ExampleContainer>
44
+ <BackgroundColorProvider color="#333333">
45
+ <DarkContainer>
46
+ <ExampleContainer>
47
+ <Title title="With label" theme="dark" level={4} />
48
+ <DxcSwitch label="Switch" />
49
+ </ExampleContainer>
50
+ <ExampleContainer>
51
+ <Title title="Checked" theme="dark" level={4} />
52
+ <DxcSwitch label="Switch" checked />
53
+ </ExampleContainer>
54
+ <ExampleContainer>
55
+ <Title title="Required" theme="dark" level={4} />
56
+ <DxcSwitch label="Switch" required />
57
+ </ExampleContainer>
58
+ <ExampleContainer>
59
+ <Title title="Disabled" theme="dark" level={4} />
60
+ <DxcSwitch label="Switch" disabled />
61
+ </ExampleContainer>
62
+ <ExampleContainer>
63
+ <Title title="Disabled required" theme="dark" level={4} />
64
+ <DxcSwitch label="Switch" disabled required labelPosition="after" />
65
+ </ExampleContainer>
66
+ <ExampleContainer>
67
+ <Title title="Disabled checked" theme="dark" level={4} />
68
+ <DxcSwitch label="Switch" disabled checked labelPosition="after" />
69
+ </ExampleContainer>
70
+ </DarkContainer>
71
+ </BackgroundColorProvider>
72
+ <Title title="Margins" theme="light" level={2} />
73
+ <ExampleContainer>
74
+ <Title title="Xxsmall margin" theme="light" level={4} />
75
+ <DxcSwitch label="Xxsmmall" margin="xxsmall" />
76
+ </ExampleContainer>
77
+ <ExampleContainer>
78
+ <Title title="Xsmall margin" theme="light" level={4} />
79
+ <DxcSwitch label="Xsmall" margin="xsmall" />
80
+ </ExampleContainer>
81
+ <ExampleContainer>
82
+ <Title title="Small margin" theme="light" level={4} />
83
+ <DxcSwitch label="Small" margin="small" />
84
+ </ExampleContainer>
85
+ <ExampleContainer>
86
+ <Title title="Medium margin" theme="light" level={4} />
87
+ <DxcSwitch label="Medium" margin="medium" />
88
+ </ExampleContainer>
89
+ <ExampleContainer>
90
+ <Title title="Large margin" theme="light" level={4} />
91
+ <DxcSwitch label="Large" margin="large" />
92
+ </ExampleContainer>
93
+ <ExampleContainer>
94
+ <Title title="Xlarge margin" theme="light" level={4} />
95
+ <DxcSwitch label="Xlarge" margin="xlarge" />
96
+ </ExampleContainer>
97
+ <ExampleContainer>
98
+ <Title title="Xxlarge margin" theme="light" level={4} />
99
+ <DxcSwitch label="Xxlarge" margin="xxlarge" />
100
+ </ExampleContainer>
101
+ <Title title="Sizes" theme="light" level={2} />
102
+ <ExampleContainer>
103
+ <Title title="Small size" theme="light" level={4} />
104
+ <DxcSwitch label="Small" size="small" />
105
+ </ExampleContainer>
106
+ <ExampleContainer>
107
+ <Title title="Medium size (with large label)" theme="light" level={4} />
108
+ <DxcSwitch label="Very very very large label or even huge" size="medium" />
109
+ </ExampleContainer>
110
+ <ExampleContainer>
111
+ <Title title="Medium size (with long label)" theme="light" level={4} />
112
+ <DxcSwitch
113
+ label="Large texttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt"
114
+ labelPosition="after"
115
+ size="medium"
116
+ />
117
+ </ExampleContainer>
118
+ <ExampleContainer>
119
+ <Title title="Large size" theme="light" level={4} />
120
+ <DxcSwitch label="Large" size="large" />
121
+ </ExampleContainer>
122
+ <ExampleContainer>
123
+ <Title title="FillParent size" theme="light" level={4} />
124
+ <DxcSwitch label="FillParent" size="fillParent" />
125
+ </ExampleContainer>
126
+ <ExampleContainer>
127
+ <Title title="FitContent size" theme="light" level={4} />
128
+ <DxcSwitch label="FitContent" size="fitContent" />
129
+ </ExampleContainer>
130
+ </>
131
+ );
132
+
133
+ const Switch = () => (
134
+ <ExampleContainer>
135
+ <Title title="Focused" theme="light" level={4} />
136
+ <DxcSwitch label="Switch" />
137
+ </ExampleContainer>
138
+ );
139
+ export const FocusedSwitch = Switch.bind({});
140
+ FocusedSwitch.play = async ({ canvasElement }) => {
141
+ const canvas = within(canvasElement);
142
+ canvas.getByRole("checkbox").focus();
143
+ };
144
+
145
+ const DarkSwitch = () => (
146
+ <BackgroundColorProvider color="#333333">
147
+ <DarkContainer>
148
+ <ExampleContainer>
149
+ <Title title="Focused" theme="dark" level={4} />
150
+ <DxcSwitch label="Switch" />
151
+ </ExampleContainer>
152
+ </DarkContainer>
153
+ </BackgroundColorProvider>
154
+ );
155
+
156
+ export const FocusedSwitchOnDark = DarkSwitch.bind({});
157
+ FocusedSwitchOnDark.play = async ({ canvasElement }) => {
158
+ const canvas = within(canvasElement);
159
+ canvas.getByRole("checkbox").focus();
160
+ };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import TablePropsType from "./types";
3
+ declare const DxcTable: ({ children, margin }: TablePropsType) => JSX.Element;
4
+ export default DxcTable;
package/table/Table.js CHANGED
@@ -48,7 +48,7 @@ var calculateWidth = function calculateWidth(margin) {
48
48
  return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
49
49
  };
50
50
 
51
- var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow: hidden auto;\n &::-webkit-scrollbar {\n width: 8px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 6px;\n }\n &::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 6px;\n }\n"])), function (props) {
51
+ var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow: auto;\n &::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 6px;\n }\n &::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 6px;\n }\n"])), function (props) {
52
52
  return calculateWidth(props.margin);
53
53
  }, function (props) {
54
54
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
@@ -0,0 +1,21 @@
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 Props = {
10
+ /**
11
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
12
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
13
+ */
14
+ margin?: Space | Margin;
15
+ /**
16
+ * The center section of the table. Can be used to render custom
17
+ * content in this area.
18
+ */
19
+ children: React.ReactNode;
20
+ };
21
+ export default Props;
package/table/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/tabs/Tabs.js CHANGED
@@ -135,7 +135,7 @@ var Underline = _styledComponents["default"].div(_templateObject6 || (_templateO
135
135
  return props.theme.dividerColor;
136
136
  });
137
137
 
138
- var DxCTabs = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n .MuiTabs-root {\n background: white;\n min-height: ", ";\n\n .MuiTabs-scroller {\n .MuiTabs-flexContainer + span {\n z-index: 4;\n }\n }\n .MuiTab-root {\n text-transform: ", " !important;\n }\n .MuiButtonBase-root {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n\n padding: ", ";\n height: ", ";\n min-width: 90px;\n max-width: 360px;\n min-height: ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n font-weight: ", ";\n }\n &:not(.Mui-selected) {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-selected {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-disabled {\n cursor: not-allowed !important;\n pointer-events: all;\n color: ", ";\n font-style: ", ";\n svg {\n color: ", ";\n }\n }\n &:focus {\n outline: ", " auto 1px;\n }\n }\n .MuiTabs-indicator {\n background-color: ", ";\n height: ", ";\n }\n .MuiTabs-scrollButtons {\n min-width: ", ";\n width: ", ";\n padding: 0;\n }\n @media (max-width: 599.95px) {\n .MuiTabs-scrollButtonsDesktop {\n display: flex;\n }\n }\n }\n"])), function (props) {
138
+ var DxCTabs = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n .MuiTabs-root {\n background: white;\n min-height: ", ";\n\n .MuiTabs-scroller {\n .MuiTabs-flexContainer + span {\n z-index: 4;\n }\n }\n .MuiTab-root {\n text-transform: ", " !important;\n }\n .MuiButtonBase-root {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n\n padding: ", ";\n height: ", ";\n min-width: 90px;\n max-width: 360px;\n min-height: ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n font-weight: ", ";\n }\n &:not(.Mui-selected) {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-selected {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-disabled {\n background-color: ", " !important;\n cursor: not-allowed !important;\n pointer-events: all;\n color: ", ";\n font-style: ", ";\n svg {\n color: ", ";\n }\n outline: none !important;\n }\n &:focus {\n outline: ", " auto 1px;\n }\n }\n .MuiTabs-indicator {\n background-color: ", ";\n height: ", ";\n }\n .MuiTabs-scrollButtons {\n min-width: ", ";\n width: ", ";\n padding: 0;\n }\n @media (max-width: 599.95px) {\n .MuiTabs-scrollButtonsDesktop {\n display: flex;\n }\n }\n }\n"])), function (props) {
139
139
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
140
140
  }, function (props) {
141
141
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
@@ -181,6 +181,8 @@ var DxCTabs = _styledComponents["default"].div(_templateObject7 || (_templateObj
181
181
  return props.theme.selectedFontColor;
182
182
  }, function (props) {
183
183
  return props.theme.selectedIconColor;
184
+ }, function (props) {
185
+ return props.theme.unselectedBackgroundColor;
184
186
  }, function (props) {
185
187
  return props.theme.disabledFontColor;
186
188
  }, function (props) {
package/tabs/types.d.ts CHANGED
@@ -58,9 +58,8 @@ declare type Props = {
58
58
  */
59
59
  onTabHover?: (tabIndex: number) => void;
60
60
  /**
61
- * Size of the margin to be applied to the component. You can pass an object
62
- * with 'top', 'bottom', 'left' and 'right' properties in order to specify
63
- * different margin sizes.
61
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
62
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
64
63
  */
65
64
  margin?: Space | Margin;
66
65
  /**
package/tag/Tag.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import TagPropsType from "./types";
3
+ declare const DxcTag: ({ icon, iconSrc, label, linkHref, onClick, iconBgColor, labelPosition, newWindow, margin, size, tabIndex, }: TagPropsType) => JSX.Element;
4
+ export default DxcTag;
package/tag/Tag.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"));
@@ -21,12 +19,12 @@ var _react = _interopRequireWildcard(require("react"));
21
19
 
22
20
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
23
21
 
24
- var _propTypes = _interopRequireDefault(require("prop-types"));
25
-
26
22
  var _variables = require("../common/variables.js");
27
23
 
28
24
  var _useTheme = _interopRequireDefault(require("../useTheme.js"));
29
25
 
26
+ var _utils = require("../common/utils.js");
27
+
30
28
  var _Box = _interopRequireDefault(require("../box/Box"));
31
29
 
32
30
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
@@ -38,8 +36,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
38
36
  var DxcTag = function DxcTag(_ref) {
39
37
  var icon = _ref.icon,
40
38
  iconSrc = _ref.iconSrc,
41
- label = _ref.label,
42
- margin = _ref.margin,
39
+ _ref$label = _ref.label,
40
+ label = _ref$label === void 0 ? "" : _ref$label,
43
41
  linkHref = _ref.linkHref,
44
42
  onClick = _ref.onClick,
45
43
  _ref$iconBgColor = _ref.iconBgColor,
@@ -48,6 +46,7 @@ var DxcTag = function DxcTag(_ref) {
48
46
  labelPosition = _ref$labelPosition === void 0 ? "after" : _ref$labelPosition,
49
47
  _ref$newWindow = _ref.newWindow,
50
48
  newWindow = _ref$newWindow === void 0 ? false : _ref$newWindow,
49
+ margin = _ref.margin,
51
50
  _ref$size = _ref.size,
52
51
  size = _ref$size === void 0 ? "fitContent" : _ref$size,
53
52
  _ref$tabIndex = _ref.tabIndex,
@@ -67,8 +66,7 @@ var DxcTag = function DxcTag(_ref) {
67
66
  size: size,
68
67
  shadowDepth: isHovered && (onClick || linkHref) && 2 || 1
69
68
  }, /*#__PURE__*/_react["default"].createElement(TagContent, {
70
- labelPosition: labelPosition,
71
- size: size
69
+ labelPosition: labelPosition
72
70
  }, /*#__PURE__*/_react["default"].createElement(IconContainer, {
73
71
  iconBgColor: iconBgColor
74
72
  }, icon ? /*#__PURE__*/_react["default"].createElement(TagIconContainer, null, (0, _typeof2["default"])(icon) === "object" ? icon : /*#__PURE__*/_react["default"].createElement(icon)) : /*#__PURE__*/_react["default"].createElement(TagIcon, {
@@ -79,6 +77,7 @@ var DxcTag = function DxcTag(_ref) {
79
77
  theme: colorsTheme.tag
80
78
  }, /*#__PURE__*/_react["default"].createElement(StyledDxcTag, {
81
79
  margin: margin,
80
+ size: size,
82
81
  onMouseEnter: function onMouseEnter() {
83
82
  return changeIsHovered(true);
84
83
  },
@@ -104,11 +103,11 @@ var sizes = {
104
103
  fitContent: "unset"
105
104
  };
106
105
 
107
- var calculateWidth = function calculateWidth(size) {
108
- return sizes[size];
106
+ var calculateWidth = function calculateWidth(margin, size) {
107
+ return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
109
108
  };
110
109
 
111
- var StyledDxcTag = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (_ref2) {
110
+ var StyledDxcTag = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n width: ", ";\n height: ", ";\n"])), function (_ref2) {
112
111
  var hasAction = _ref2.hasAction;
113
112
  return hasAction && "pointer" || "unset";
114
113
  }, function (_ref3) {
@@ -126,22 +125,24 @@ var StyledDxcTag = _styledComponents["default"].div(_templateObject || (_templat
126
125
  }, function (_ref7) {
127
126
  var margin = _ref7.margin;
128
127
  return margin && margin.left ? _variables.spaces[margin.left] : "";
128
+ }, function (props) {
129
+ return calculateWidth(props.margin, props.size);
130
+ }, function (props) {
131
+ return props.theme.height;
129
132
  });
130
133
 
131
- var TagContent = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n flex-direction: ", ";\n width: ", ";\n height: ", ";\n"])), function (_ref8) {
134
+ var TagContent = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n flex-direction: ", ";\n width: 100%;\n height: ", ";\n"])), function (_ref8) {
132
135
  var labelPosition = _ref8.labelPosition;
133
136
  return labelPosition === "before" && "row-reverse" || "row";
134
- }, function (props) {
135
- return calculateWidth(props.size);
136
137
  }, function (props) {
137
138
  return props.theme.height;
138
139
  });
139
140
 
140
- var StyledLink = _styledComponents["default"].a(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n text-decoration: none;\n border-radius: 4px;\n\n :focus {\n outline: 2px solid ", ";\n outline-offset: 0px;\n }\n"])), function (props) {
141
+ var StyledLink = _styledComponents["default"].a(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n text-decoration: none;\n border-radius: 4px;\n width: 100%;\n :focus {\n outline: 2px solid ", ";\n outline-offset: 0px;\n }\n"])), function (props) {
141
142
  return props.theme.focusColor;
142
143
  });
143
144
 
144
- var StyledButton = _styledComponents["default"].button(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n background: none;\n border-radius: 4px;\n border: none;\n padding: 0;\n cursor: pointer;\n font-family: inherit;\n\n :focus {\n outline: 2px solid ", ";\n }\n"])), function (props) {
145
+ var StyledButton = _styledComponents["default"].button(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n background: none;\n border-radius: 4px;\n border: none;\n padding: 0;\n cursor: pointer;\n font-family: inherit;\n width: 100%;\n :focus {\n outline: 2px solid ", ";\n }\n"])), function (props) {
145
146
  return props.theme.focusColor;
146
147
  });
147
148
 
@@ -157,13 +158,15 @@ var TagIconContainer = _styledComponents["default"].div(_templateObject6 || (_te
157
158
  return props.theme.iconHeight;
158
159
  });
159
160
 
160
- var IconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n background: ", ";\n width: ", ";\n height: 100%;\n justify-content: center;\n align-items: center;\n color: ", ";\n"])), function (_ref9) {
161
+ var IconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n background: ", ";\n width: ", ";\n height: 100%;\n justify-content: center;\n align-items: center;\n color: ", ";\n min-width: ", ";\n"])), function (_ref9) {
161
162
  var iconBgColor = _ref9.iconBgColor;
162
163
  return iconBgColor;
163
164
  }, function (props) {
164
165
  return props.theme.iconSectionWidth;
165
166
  }, function (props) {
166
167
  return props.theme.iconColor;
168
+ }, function (props) {
169
+ return props.theme.iconSectionWidth;
167
170
  });
168
171
 
169
172
  var TagLabel = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n flex-grow: 1;\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n"])), function (props) {
@@ -186,23 +189,5 @@ var TagLabel = _styledComponents["default"].div(_templateObject8 || (_templateOb
186
189
  return props.theme.labelPaddingRight;
187
190
  });
188
191
 
189
- DxcTag.propTypes = {
190
- size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
191
- icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
192
- iconSrc: _propTypes["default"].string,
193
- iconBgColor: _propTypes["default"].string,
194
- label: _propTypes["default"].string,
195
- labelPosition: _propTypes["default"].oneOf(["before", "after"]),
196
- linkHref: _propTypes["default"].string,
197
- onClick: _propTypes["default"].func,
198
- newWindow: _propTypes["default"].bool,
199
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
200
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
201
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
202
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
203
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
204
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
205
- tabIndex: _propTypes["default"].number
206
- };
207
192
  var _default = DxcTag;
208
193
  exports["default"] = _default;
@@ -0,0 +1,145 @@
1
+ import React from "react";
2
+ import { userEvent, within } from "@storybook/testing-library";
3
+ import Title from "../../.storybook/components/Title";
4
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
+ import DxcTag from "./Tag";
6
+
7
+ export default {
8
+ title: "Tag",
9
+ component: DxcTag,
10
+ };
11
+
12
+ const icon = () => {
13
+ return (
14
+ <svg viewBox="0 0 24 24" fill="currentColor">
15
+ <path d="M0 0h24v24H0z" fill="none" />
16
+ <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
17
+ </svg>
18
+ );
19
+ };
20
+ const largeIcon = () => {
21
+ return (
22
+ <svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
23
+ <path d="M0 0h24v24H0V0z" fill="none" />
24
+ <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" />
25
+ </svg>
26
+ );
27
+ };
28
+
29
+ export const Chromatic = () => (
30
+ <>
31
+ <ExampleContainer>
32
+ <Title title="Without label" theme="light" level={4} />
33
+ <DxcTag />
34
+ </ExampleContainer>
35
+ <ExampleContainer>
36
+ <Title title="With icon" theme="light" level={4} />
37
+ <DxcTag icon={icon} />
38
+ </ExampleContainer>
39
+ <ExampleContainer>
40
+ <Title title="With large icon" theme="light" level={4} />
41
+ <DxcTag icon={largeIcon} />
42
+ </ExampleContainer>
43
+ <ExampleContainer>
44
+ <Title title="With label" theme="light" level={4} />
45
+ <DxcTag label="Tag" />
46
+ </ExampleContainer>
47
+ <ExampleContainer>
48
+ <Title title="With label and icon" theme="light" level={4} />
49
+ <DxcTag label="Tag" icon={icon} />
50
+ </ExampleContainer>
51
+ <ExampleContainer>
52
+ <Title title="With right icon" theme="light" level={4} />
53
+ <DxcTag label="Tag" icon={icon} labelPosition="before" />
54
+ </ExampleContainer>
55
+ <ExampleContainer>
56
+ <Title title="Icon background color" theme="light" level={4} />
57
+ <DxcTag label="Tag" icon={icon} iconBgColor="#fabada" />
58
+ </ExampleContainer>
59
+ <ExampleContainer pseudoState="pseudo-focus">
60
+ <Title title="With link focused" theme="light" level={4} />
61
+ <DxcTag icon={icon} label="Tag" linkHref="https://www.dxc.com" />
62
+ </ExampleContainer>
63
+ <ExampleContainer pseudoState="pseudo-focus">
64
+ <Title title="With action focused" theme="light" level={4} />
65
+ <DxcTag
66
+ icon={icon}
67
+ label="Tag"
68
+ onClick={() => {
69
+ console.log("click");
70
+ }}
71
+ />
72
+ </ExampleContainer>
73
+ <Title title="Margins" theme="light" level={2} />
74
+ <ExampleContainer>
75
+ <Title title="Xxsmall margin" theme="light" level={4} />
76
+ <DxcTag label="Xxsmall" margin="xxsmall" />
77
+ </ExampleContainer>
78
+ <ExampleContainer>
79
+ <Title title="Xsmall margin" theme="light" level={4} />
80
+ <DxcTag label="Xsmall" margin="xsmall" />
81
+ </ExampleContainer>
82
+ <ExampleContainer>
83
+ <Title title="Small margin" theme="light" level={4} />
84
+ <DxcTag label="Small" margin="small" />
85
+ </ExampleContainer>
86
+ <ExampleContainer>
87
+ <Title title="Medium margin" theme="light" level={4} />
88
+ <DxcTag label="Medium" margin="medium" />
89
+ </ExampleContainer>
90
+ <ExampleContainer>
91
+ <Title title="Large margin" theme="light" level={4} />
92
+ <DxcTag label="Large" margin="large" />
93
+ </ExampleContainer>
94
+ <ExampleContainer>
95
+ <Title title="Xlarge margin" theme="light" level={4} />
96
+ <DxcTag label="Xlarge" margin="xlarge" />
97
+ </ExampleContainer>
98
+ <ExampleContainer>
99
+ <Title title="Xxlarge margin" theme="light" level={4} />
100
+ <DxcTag label="Xxlarge" margin="xxlarge" />
101
+ </ExampleContainer>
102
+ <Title title="Sizes" theme="light" level={2} />
103
+ <ExampleContainer>
104
+ <Title title="Small size" theme="light" level={4} />
105
+ <DxcTag label="Small" size="small" />
106
+ </ExampleContainer>
107
+ <ExampleContainer>
108
+ <Title title="Medium size" theme="light" level={4} />
109
+ <DxcTag label="Medium size medium s" size="medium" />
110
+ </ExampleContainer>
111
+ <ExampleContainer>
112
+ <Title title="Medium size with ellipsis" theme="light" level={4} />
113
+ <DxcTag label="Medium size medium si medium" size="medium" />
114
+ </ExampleContainer>
115
+ <ExampleContainer>
116
+ <Title title="Large size" theme="light" level={4} />
117
+ <DxcTag label="Large size large size large size large size large size" size="large" />
118
+ </ExampleContainer>
119
+ <ExampleContainer>
120
+ <Title title="Large size with ellipsis" theme="light" level={4} />
121
+ <DxcTag label="Large size large size large size large size large size large size" size="large" />
122
+ </ExampleContainer>
123
+ <ExampleContainer>
124
+ <Title title="FillParent size" theme="light" level={4} />
125
+ <DxcTag label="FillParent" size="fillParent" />
126
+ </ExampleContainer>
127
+ <ExampleContainer>
128
+ <Title title="FitContent size" theme="light" level={4} />
129
+ <DxcTag label="FitContent" size="fitContent" />
130
+ </ExampleContainer>
131
+ </>
132
+ );
133
+
134
+ const LinkTag = () => (
135
+ <ExampleContainer>
136
+ <Title title="Hover link tag" theme="light" level={4} />
137
+ <DxcTag label="Tag" icon={icon} linkHref="https://www.dxc.com" />
138
+ </ExampleContainer>
139
+ );
140
+
141
+ export const HoverLinkTag = LinkTag.bind({});
142
+ HoverLinkTag.play = async ({ canvasElement }) => {
143
+ const canvas = within(canvasElement);
144
+ await userEvent.hover(canvas.getByText("Tag"));
145
+ };