@dxc-technology/halstack-react 0.0.0-b41d935 → 0.0.0-b4fde6b

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 (205) hide show
  1. package/BackgroundColorContext.d.ts +2 -2
  2. package/BackgroundColorContext.js +1 -1
  3. package/HalstackContext.d.ts +1329 -5
  4. package/HalstackContext.js +117 -77
  5. package/accordion/Accordion.js +13 -24
  6. package/accordion/Accordion.stories.tsx +102 -13
  7. package/accordion/Accordion.test.js +1 -1
  8. package/accordion/types.d.ts +3 -3
  9. package/accordion-group/AccordionGroup.d.ts +4 -3
  10. package/accordion-group/AccordionGroup.js +23 -44
  11. package/accordion-group/AccordionGroup.test.js +1 -1
  12. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  13. package/accordion-group/AccordionGroupAccordion.js +43 -0
  14. package/accordion-group/types.d.ts +2 -2
  15. package/alert/Alert.js +4 -8
  16. package/alert/Alert.stories.tsx +28 -0
  17. package/alert/Alert.test.js +1 -1
  18. package/bleed/Bleed.stories.tsx +1 -0
  19. package/box/Box.d.ts +1 -1
  20. package/box/Box.js +7 -26
  21. package/box/Box.stories.tsx +38 -51
  22. package/box/Box.test.js +1 -1
  23. package/box/types.d.ts +0 -12
  24. package/bulleted-list/BulletedList.js +4 -2
  25. package/bulleted-list/BulletedList.stories.tsx +7 -1
  26. package/bulleted-list/types.d.ts +31 -4
  27. package/button/Button.js +13 -16
  28. package/button/Button.stories.tsx +151 -9
  29. package/button/Button.test.js +1 -1
  30. package/button/types.d.ts +3 -3
  31. package/card/Card.js +12 -13
  32. package/card/Card.stories.tsx +12 -13
  33. package/card/Card.test.js +1 -1
  34. package/checkbox/Checkbox.d.ts +2 -2
  35. package/checkbox/Checkbox.js +7 -6
  36. package/checkbox/Checkbox.stories.tsx +52 -0
  37. package/checkbox/Checkbox.test.js +1 -1
  38. package/checkbox/types.d.ts +6 -2
  39. package/chip/Chip.js +28 -49
  40. package/chip/Chip.stories.tsx +121 -26
  41. package/chip/Chip.test.js +3 -5
  42. package/common/OpenSans.css +68 -80
  43. package/common/coreTokens.d.ts +146 -0
  44. package/common/coreTokens.js +167 -0
  45. package/common/utils.d.ts +1 -0
  46. package/common/utils.js +4 -4
  47. package/common/variables.d.ts +1482 -0
  48. package/common/variables.js +981 -1129
  49. package/date-input/Calendar.d.ts +4 -0
  50. package/date-input/Calendar.js +258 -0
  51. package/date-input/DateInput.js +134 -237
  52. package/date-input/DateInput.stories.tsx +199 -33
  53. package/date-input/DateInput.test.js +494 -138
  54. package/date-input/DatePicker.d.ts +4 -0
  55. package/date-input/DatePicker.js +146 -0
  56. package/date-input/Icons.d.ts +6 -0
  57. package/date-input/Icons.js +75 -0
  58. package/date-input/YearPicker.d.ts +4 -0
  59. package/date-input/YearPicker.js +126 -0
  60. package/date-input/types.d.ts +51 -0
  61. package/dialog/Dialog.d.ts +1 -1
  62. package/dialog/Dialog.js +55 -86
  63. package/dialog/Dialog.stories.tsx +145 -217
  64. package/dialog/Dialog.test.js +302 -3
  65. package/dialog/types.d.ts +0 -13
  66. package/dropdown/Dropdown.js +37 -37
  67. package/dropdown/Dropdown.stories.tsx +210 -84
  68. package/dropdown/Dropdown.test.js +20 -24
  69. package/dropdown/DropdownMenu.js +12 -18
  70. package/dropdown/DropdownMenuItem.js +4 -17
  71. package/dropdown/types.d.ts +3 -3
  72. package/file-input/FileInput.d.ts +2 -2
  73. package/file-input/FileInput.js +14 -15
  74. package/file-input/FileInput.stories.tsx +85 -2
  75. package/file-input/FileInput.test.js +1 -42
  76. package/file-input/FileItem.js +1 -0
  77. package/file-input/types.d.ts +4 -0
  78. package/flex/Flex.js +4 -2
  79. package/flex/Flex.stories.tsx +35 -26
  80. package/flex/types.d.ts +70 -5
  81. package/footer/Footer.d.ts +1 -1
  82. package/footer/Footer.js +8 -23
  83. package/footer/Footer.stories.tsx +18 -15
  84. package/footer/Footer.test.js +14 -26
  85. package/footer/types.d.ts +0 -6
  86. package/grid/Grid.d.ts +7 -0
  87. package/grid/Grid.js +91 -0
  88. package/grid/Grid.stories.tsx +219 -0
  89. package/grid/types.d.ts +115 -0
  90. package/header/Header.d.ts +3 -2
  91. package/header/Header.js +21 -23
  92. package/header/Header.stories.tsx +149 -6
  93. package/header/Header.test.js +2 -2
  94. package/header/types.d.ts +2 -2
  95. package/heading/Heading.js +1 -1
  96. package/heading/Heading.test.js +1 -1
  97. package/inset/Inset.stories.tsx +2 -1
  98. package/layout/ApplicationLayout.d.ts +4 -4
  99. package/layout/ApplicationLayout.js +1 -1
  100. package/layout/types.d.ts +2 -3
  101. package/link/Link.js +4 -4
  102. package/link/Link.stories.tsx +60 -0
  103. package/link/Link.test.js +2 -4
  104. package/link/types.d.ts +2 -2
  105. package/main.d.ts +3 -2
  106. package/main.js +9 -1
  107. package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
  108. package/{tabs-nav → nav-tabs}/NavTabs.js +8 -11
  109. package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +110 -6
  110. package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
  111. package/{tabs-nav → nav-tabs}/Tab.js +48 -32
  112. package/{tabs-nav → nav-tabs}/types.d.ts +8 -9
  113. package/nav-tabs/types.js +5 -0
  114. package/number-input/NumberInput.test.js +6 -7
  115. package/package.json +8 -13
  116. package/paginator/Icons.d.ts +5 -0
  117. package/paginator/Icons.js +16 -28
  118. package/paginator/Paginator.js +7 -15
  119. package/paginator/Paginator.stories.tsx +24 -0
  120. package/paginator/Paginator.test.js +57 -47
  121. package/paragraph/Paragraph.d.ts +3 -4
  122. package/paragraph/Paragraph.js +5 -5
  123. package/password-input/PasswordInput.test.js +1 -1
  124. package/progress-bar/ProgressBar.d.ts +2 -2
  125. package/progress-bar/ProgressBar.js +5 -5
  126. package/progress-bar/ProgressBar.stories.jsx +35 -2
  127. package/progress-bar/ProgressBar.test.js +1 -1
  128. package/progress-bar/types.d.ts +4 -3
  129. package/quick-nav/QuickNav.stories.tsx +14 -0
  130. package/radio-group/Radio.js +10 -10
  131. package/radio-group/RadioGroup.js +8 -10
  132. package/radio-group/RadioGroup.stories.tsx +131 -18
  133. package/radio-group/RadioGroup.test.js +1 -1
  134. package/resultsetTable/Icons.d.ts +7 -0
  135. package/resultsetTable/Icons.js +51 -0
  136. package/resultsetTable/ResultsetTable.js +49 -106
  137. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  138. package/resultsetTable/ResultsetTable.test.js +41 -64
  139. package/resultsetTable/types.d.ts +1 -1
  140. package/select/Listbox.d.ts +1 -1
  141. package/select/Listbox.js +5 -34
  142. package/select/Option.js +11 -24
  143. package/select/Select.js +56 -35
  144. package/select/Select.stories.tsx +494 -150
  145. package/select/Select.test.js +76 -81
  146. package/select/types.d.ts +2 -2
  147. package/sidenav/Icons.d.ts +7 -0
  148. package/sidenav/Icons.js +51 -0
  149. package/sidenav/Sidenav.d.ts +2 -2
  150. package/sidenav/Sidenav.js +66 -96
  151. package/sidenav/Sidenav.stories.tsx +165 -63
  152. package/sidenav/types.d.ts +21 -18
  153. package/slider/Slider.d.ts +2 -2
  154. package/slider/Slider.js +11 -11
  155. package/slider/Slider.stories.tsx +57 -0
  156. package/slider/Slider.test.js +1 -1
  157. package/slider/types.d.ts +6 -2
  158. package/spinner/Spinner.js +17 -23
  159. package/spinner/Spinner.stories.jsx +53 -27
  160. package/spinner/Spinner.test.js +1 -1
  161. package/switch/Switch.d.ts +3 -3
  162. package/switch/Switch.js +7 -6
  163. package/switch/Switch.stories.tsx +33 -0
  164. package/switch/Switch.test.js +1 -1
  165. package/switch/types.d.ts +8 -3
  166. package/table/Table.js +2 -2
  167. package/table/Table.stories.jsx +80 -1
  168. package/table/Table.test.js +2 -2
  169. package/tabs/Tab.js +12 -15
  170. package/tabs/Tabs.js +11 -17
  171. package/tabs/Tabs.stories.tsx +45 -5
  172. package/tabs/Tabs.test.js +4 -5
  173. package/tabs/types.d.ts +2 -2
  174. package/tag/Tag.js +7 -9
  175. package/tag/Tag.stories.tsx +14 -1
  176. package/tag/Tag.test.js +1 -1
  177. package/text-input/Suggestion.js +34 -7
  178. package/text-input/TextInput.js +11 -15
  179. package/text-input/TextInput.stories.tsx +93 -5
  180. package/text-input/TextInput.test.js +587 -635
  181. package/textarea/Textarea.js +3 -4
  182. package/textarea/Textarea.stories.jsx +60 -1
  183. package/textarea/Textarea.test.js +2 -4
  184. package/toggle-group/ToggleGroup.d.ts +2 -2
  185. package/toggle-group/ToggleGroup.js +7 -4
  186. package/toggle-group/ToggleGroup.stories.tsx +42 -0
  187. package/toggle-group/ToggleGroup.test.js +1 -1
  188. package/toggle-group/types.d.ts +1 -1
  189. package/typography/Typography.d.ts +2 -2
  190. package/typography/Typography.js +14 -113
  191. package/typography/Typography.stories.tsx +1 -1
  192. package/useTheme.d.ts +1234 -1
  193. package/useTheme.js +1 -1
  194. package/useTranslatedLabels.d.ts +84 -1
  195. package/utils/BaseTypography.d.ts +21 -0
  196. package/utils/BaseTypography.js +108 -0
  197. package/utils/FocusLock.d.ts +13 -0
  198. package/utils/FocusLock.js +138 -0
  199. package/wizard/Wizard.js +2 -2
  200. package/wizard/Wizard.stories.tsx +20 -0
  201. package/wizard/Wizard.test.js +1 -1
  202. package/wizard/types.d.ts +5 -6
  203. package/common/RequiredComponent.js +0 -32
  204. /package/{tabs-nav → grid}/types.js +0 -0
  205. /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import DxcFooter from "./Footer";
3
3
  import Title from "../../.storybook/components/Title";
4
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
+ import { HalstackProvider } from "../HalstackContext";
5
6
 
6
7
  const social = [
7
8
  {
@@ -85,6 +86,15 @@ export default {
85
86
  component: DxcFooter,
86
87
  };
87
88
 
89
+ const opinionatedTheme = {
90
+ footer: {
91
+ baseColor: "#000000",
92
+ fontColor: "#ffffff",
93
+ accentColor: "#0095ff",
94
+ logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/2021_Facebook_icon.svg/2048px-2021_Facebook_icon.svg.png",
95
+ },
96
+ };
97
+
88
98
  export const Chromatic = () => (
89
99
  <>
90
100
  <ExampleContainer>
@@ -116,22 +126,15 @@ export const Chromatic = () => (
116
126
  <Title title="Xxlarge margin" theme="light" level={4} />
117
127
  <DxcFooter margin="xxlarge"></DxcFooter>
118
128
  </ExampleContainer>
119
- <Title title="Padding" theme="light" level={2} />
129
+ <Title title="Opinionated theme" theme="light" level={2} />
120
130
  <ExampleContainer>
121
- <Title title="Xxsmall padding" theme="light" level={4} />
122
- <DxcFooter padding="xxsmall"></DxcFooter>
123
- <Title title="Xsmall padding" theme="light" level={4} />
124
- <DxcFooter padding="xsmall"></DxcFooter>
125
- <Title title="Small padding" theme="light" level={4} />
126
- <DxcFooter padding="small"></DxcFooter>
127
- <Title title="Medium padding" theme="light" level={4} />
128
- <DxcFooter padding="medium"></DxcFooter>
129
- <Title title="Large padding" theme="light" level={4} />
130
- <DxcFooter padding="large"></DxcFooter>
131
- <Title title="Xlarge padding" theme="light" level={4} />
132
- <DxcFooter padding="xlarge"></DxcFooter>
133
- <Title title="Xxlarge padding" theme="light" level={4} />
134
- <DxcFooter padding="xxlarge"></DxcFooter>
131
+ <HalstackProvider theme={opinionatedTheme}>
132
+ <DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}>
133
+ <div>
134
+ <a href="https://www.linkedin.com/company/dxctechnology">Linkedin</a>
135
+ </div>
136
+ </DxcFooter>
137
+ </HalstackProvider>
135
138
  </ExampleContainer>
136
139
  </>
137
140
  );
@@ -6,10 +6,16 @@ var _react = _interopRequireDefault(require("react"));
6
6
 
7
7
  var _react2 = require("@testing-library/react");
8
8
 
9
- var _linkedin = _interopRequireDefault(require("../../app/src/images/linkedin.svg"));
10
-
11
- var _Footer = _interopRequireDefault(require("./Footer"));
12
-
9
+ var _Footer = _interopRequireDefault(require("./Footer.tsx"));
10
+
11
+ var social = [{
12
+ href: "https://www.test.com/social",
13
+ logo: "https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons/images/icon-and-image-large-icon-settings_2x.png"
14
+ }];
15
+ var bottom = [{
16
+ href: "https://www.test.com/bottom",
17
+ text: "bottom-link-text"
18
+ }];
13
19
  describe("Footer component tests", function () {
14
20
  test("Footer renders with default logo", function () {
15
21
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Footer["default"], null)),
@@ -18,32 +24,22 @@ describe("Footer component tests", function () {
18
24
  expect(getByTitle("DXC Logo")).toBeTruthy();
19
25
  });
20
26
  test("Footer renders with social links", function () {
21
- var social = [{
22
- href: "https://www.test.com/test",
23
- logo: _linkedin["default"]
24
- }];
25
-
26
27
  var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Footer["default"], {
27
28
  socialLinks: social
28
29
  })),
29
30
  getByRole = _render2.getByRole;
30
31
 
31
32
  var socialIcon = getByRole("link");
32
- expect(socialIcon.getAttribute("href")).toBe("https://www.test.com/test");
33
+ expect(socialIcon.getAttribute("href")).toBe("https://www.test.com/social");
33
34
  });
34
35
  test("Footer renders with bottom links", function () {
35
- var bottom = [{
36
- href: "https://www.test.com/test",
37
- text: "bottom-link-text"
38
- }];
39
-
40
36
  var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Footer["default"], {
41
37
  bottomLinks: bottom
42
38
  })),
43
39
  getByText = _render3.getByText;
44
40
 
45
41
  var link = getByText("bottom-link-text");
46
- expect(link.getAttribute("href")).toBe("https://www.test.com/test");
42
+ expect(link.getAttribute("href")).toBe("https://www.test.com/bottom");
47
43
  });
48
44
  test("Footer renders with copyright text", function () {
49
45
  var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Footer["default"], {
@@ -54,7 +50,7 @@ describe("Footer component tests", function () {
54
50
  expect(getByText("test-copyright")).toBeTruthy();
55
51
  });
56
52
  test("Footer renders with correct children", function () {
57
- //We need to force the offsetWidth value
53
+ // We need to force the offsetWidth value
58
54
  Object.defineProperty(HTMLElement.prototype, "offsetWidth", {
59
55
  configurable: true,
60
56
  value: 1024
@@ -66,7 +62,7 @@ describe("Footer component tests", function () {
66
62
  expect(getByText("footer-child-text")).toBeTruthy();
67
63
  });
68
64
  test("Footer renders with children in mobile", function () {
69
- //425 is mobile width
65
+ // 425 is mobile width
70
66
  Object.defineProperty(HTMLElement.prototype, "offsetWidth", {
71
67
  configurable: true,
72
68
  value: 425
@@ -82,14 +78,6 @@ describe("Footer component tests", function () {
82
78
  configurable: true,
83
79
  value: 1024
84
80
  });
85
- var social = [{
86
- href: "https://www.test.com/social",
87
- logo: _linkedin["default"]
88
- }];
89
- var bottom = [{
90
- href: "https://www.test.com/bottom",
91
- text: "bottom-link-text"
92
- }];
93
81
 
94
82
  var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Footer["default"], {
95
83
  socialLinks: social,
package/footer/types.d.ts CHANGED
@@ -56,11 +56,5 @@ declare type FooterPropsType = {
56
56
  * Size of the top margin to be applied to the footer.
57
57
  */
58
58
  margin?: Space | Size;
59
- /**
60
- * @deprecated This prop will be removed shortly, consider using the Inset component for this purpose.
61
- * Size of the padding to be applied to the custom area of the component.
62
- * You can pass an object with properties in order to specify different padding sizes.
63
- */
64
- padding?: Space | Size;
65
59
  };
66
60
  export default FooterPropsType;
package/grid/Grid.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import GridPropsType, { GridItemProps } from "./types";
3
+ declare const DxcGrid: {
4
+ (props: GridPropsType): JSX.Element;
5
+ GridItem: import("styled-components").StyledComponent<"div", any, GridItemProps, never>;
6
+ };
7
+ export default DxcGrid;
package/grid/Grid.js ADDED
@@ -0,0 +1,91 @@
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 _templateObject, _templateObject2;
17
+
18
+ var DxcGrid = function DxcGrid(props) {
19
+ return /*#__PURE__*/_react["default"].createElement(Grid, props);
20
+ };
21
+
22
+ var Grid = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: grid;\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n \n ", "\n ", "\n ", "\n ", "\n"])), function (_ref) {
23
+ var templateColumns = _ref.templateColumns;
24
+ return templateColumns && "grid-template-columns: ".concat(templateColumns.join(" "), ";");
25
+ }, function (_ref2) {
26
+ var templateRows = _ref2.templateRows;
27
+ return templateRows && "grid-template-rows: ".concat(templateRows.join(" "), ";");
28
+ }, function (_ref3) {
29
+ var templateAreas = _ref3.templateAreas;
30
+ return templateAreas && "grid-template-areas: ".concat(templateAreas.map(function (row) {
31
+ return "\"".concat(row, "\"");
32
+ }).join(" "), ";");
33
+ }, function (_ref4) {
34
+ var autoColumns = _ref4.autoColumns;
35
+ return autoColumns && "grid-auto-columns: ".concat(autoColumns, ";");
36
+ }, function (_ref5) {
37
+ var autoRows = _ref5.autoRows;
38
+ return autoRows && "grid-auto-rows: ".concat(autoRows, ";");
39
+ }, function (_ref6) {
40
+ var autoFlow = _ref6.autoFlow;
41
+ return autoFlow && "grid-auto-flow: ".concat(autoFlow, ";");
42
+ }, function (_ref7) {
43
+ var _gap$rowGap, _gap$columnGap;
44
+
45
+ var gap = _ref7.gap;
46
+ return gap != null && (typeof gap === "string" ? "gap: ".concat(gap, ";") : "row-gap: ".concat((_gap$rowGap = gap.rowGap) !== null && _gap$rowGap !== void 0 ? _gap$rowGap : "", "; column-gap: ").concat((_gap$columnGap = gap.columnGap) !== null && _gap$columnGap !== void 0 ? _gap$columnGap : "", ";"));
47
+ }, function (_ref8) {
48
+ var _placeItems$alignItem, _placeItems$justifyIt;
49
+
50
+ var placeItems = _ref8.placeItems;
51
+ return placeItems && (typeof placeItems === "string" ? "place-items: ".concat(placeItems) : "align-items: ".concat((_placeItems$alignItem = placeItems.alignItems) !== null && _placeItems$alignItem !== void 0 ? _placeItems$alignItem : "", "; justify-items: ").concat((_placeItems$justifyIt = placeItems.justifyItems) !== null && _placeItems$justifyIt !== void 0 ? _placeItems$justifyIt : "", ";"));
52
+ }, function (_ref9) {
53
+ var _placeContent$alignCo, _placeContent$justify;
54
+
55
+ var placeContent = _ref9.placeContent;
56
+ return placeContent && (typeof placeContent === "string" ? "place-content: ".concat(placeContent) : "align-content: ".concat((_placeContent$alignCo = placeContent.alignContent) !== null && _placeContent$alignCo !== void 0 ? _placeContent$alignCo : "", "; justify-content: ").concat((_placeContent$justify = placeContent.justifyContent) !== null && _placeContent$justify !== void 0 ? _placeContent$justify : "", ";"));
57
+ }, function (_ref10) {
58
+ var areaName = _ref10.areaName;
59
+ return areaName && "grid-area: ".concat(areaName, ";");
60
+ }, function (_ref11) {
61
+ var column = _ref11.column;
62
+ return column && "grid-column: ".concat(typeof column === "string" || typeof column === "number" ? column : "".concat(column.start, " / ").concat(column.end, ";"), ";");
63
+ }, function (_ref12) {
64
+ var row = _ref12.row;
65
+ return row && "grid-row: ".concat(typeof row === "string" || typeof row === "number" ? row : "".concat(row.start, " / ").concat(row.end, ";"), ";");
66
+ }, function (_ref13) {
67
+ var _placeSelf$alignSelf, _placeSelf$justifySel;
68
+
69
+ var placeSelf = _ref13.placeSelf;
70
+ return placeSelf && (typeof placeSelf === "string" ? "place-self: ".concat(placeSelf) : "align-self: ".concat((_placeSelf$alignSelf = placeSelf.alignSelf) !== null && _placeSelf$alignSelf !== void 0 ? _placeSelf$alignSelf : "", "; justify-self: ").concat((_placeSelf$justifySel = placeSelf.justifySelf) !== null && _placeSelf$justifySel !== void 0 ? _placeSelf$justifySel : "", ";"));
71
+ });
72
+
73
+ var GridItem = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n ", "\n ", "\n ", "\n ", "\n"])), function (_ref14) {
74
+ var areaName = _ref14.areaName;
75
+ return areaName && "grid-area: ".concat(areaName, ";");
76
+ }, function (_ref15) {
77
+ var column = _ref15.column;
78
+ return column && "grid-column: ".concat(typeof column === "string" || typeof column === "number" ? column : "".concat(column.start, " / ").concat(column.end, ";"), ";");
79
+ }, function (_ref16) {
80
+ var row = _ref16.row;
81
+ return row && "grid-row: ".concat(typeof row === "string" || typeof row === "number" ? row : "".concat(row.start, " / ").concat(row.end, ";"), ";");
82
+ }, function (_ref17) {
83
+ var _placeSelf$alignSelf2, _placeSelf$justifySel2;
84
+
85
+ var placeSelf = _ref17.placeSelf;
86
+ return placeSelf && (typeof placeSelf === "string" ? "place-self: ".concat(placeSelf) : "align-self: ".concat((_placeSelf$alignSelf2 = placeSelf.alignSelf) !== null && _placeSelf$alignSelf2 !== void 0 ? _placeSelf$alignSelf2 : "", "; justify-self: ").concat((_placeSelf$justifySel2 = placeSelf.justifySelf) !== null && _placeSelf$justifySel2 !== void 0 ? _placeSelf$justifySel2 : "", ";"));
87
+ });
88
+
89
+ DxcGrid.GridItem = GridItem;
90
+ var _default = DxcGrid;
91
+ exports["default"] = _default;
@@ -0,0 +1,219 @@
1
+ import React from "react";
2
+ import Title from "../../.storybook/components/Title";
3
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
4
+ import styled from "styled-components";
5
+ import DxcGrid from "./Grid";
6
+ import DxcInset from "../inset/Inset";
7
+
8
+ export default {
9
+ title: "Grid",
10
+ component: DxcGrid,
11
+ };
12
+
13
+ export const Chromatic = () => (
14
+ <>
15
+ <Title title="Default" level={4} />
16
+ <ExampleContainer>
17
+ <DxcGrid>
18
+ <ColoredContainer />
19
+ <ColoredContainer />
20
+ <ColoredContainer />
21
+ </DxcGrid>
22
+ </ExampleContainer>
23
+ <Title title="Place items" level={4} />
24
+ <ExampleContainer>
25
+ <DxcGrid templateRows={["200px"]} placeItems="center">
26
+ <ColoredContainer height="50px" width="50px" />
27
+ </DxcGrid>
28
+ <DxcGrid placeItems={{ justifyItems: "end" }}>
29
+ <ColoredContainer />
30
+ <ColoredContainer />
31
+ <ColoredContainer />
32
+ </DxcGrid>
33
+ <DxcGrid templateRows={["repeat(3, 100px)"]} placeItems={{ alignItems: "end", justifyItems: "center" }}>
34
+ <ColoredContainer height="50px" width="50px" />
35
+ <ColoredContainer height="50px" width="50px" />
36
+ <ColoredContainer height="50px" width="50px" />
37
+ </DxcGrid>
38
+ </ExampleContainer>
39
+ <Title title="Place content" level={4} />
40
+ <Container height="200px">
41
+ <DxcGrid placeContent="center">
42
+ <ColoredContainer height="50px" width="50px" />
43
+ <ColoredContainer height="50px" width="50px" />
44
+ </DxcGrid>
45
+ </Container>
46
+ <Container height="200px">
47
+ <DxcGrid placeContent={{ alignContent: "center" }}>
48
+ <ColoredContainer height="50px" width="50px" />
49
+ </DxcGrid>
50
+ </Container>
51
+ <Container height="200px">
52
+ <DxcGrid placeContent={{ alignContent: "center", justifyContent: "end" }}>
53
+ <ColoredContainer height="50px" width="50px" />
54
+ </DxcGrid>
55
+ </Container>
56
+ <Title title="Place self" level={4} />
57
+ <ExampleContainer>
58
+ <DxcGrid templateRows={["repeat(3, 100px)"]}>
59
+ <DxcGrid.GridItem placeSelf="center">
60
+ <ColoredContainer height="50px" width="50px" />
61
+ </DxcGrid.GridItem>
62
+ <DxcGrid.GridItem placeSelf={{ alignSelf: "end" }}>
63
+ <ColoredContainer height="40px" width="40px" />
64
+ <ColoredContainer height="30px" width="30px" />
65
+ </DxcGrid.GridItem>
66
+ <DxcGrid.GridItem placeSelf={{ alignSelf: "center", justifySelf: "end" }}>
67
+ <ColoredContainer height="50px" width="50px" />
68
+ </DxcGrid.GridItem>
69
+ </DxcGrid>
70
+ </ExampleContainer>
71
+ <Title title="Halstack layout using template areas" level={4} />
72
+ <ExampleContainer>
73
+ <DxcGrid
74
+ templateColumns={["repeat(4, 1fr)"]}
75
+ templateRows={["40px", "200px", "60px"]}
76
+ templateAreas={["header header header header", "sidenav main main main", "sidenav footer footer footer"]}
77
+ gap={{ rowGap: "0.5rem", columnGap: "1rem" }}
78
+ >
79
+ <DxcGrid.GridItem areaName="header" as="header">
80
+ <ColoredContainer height="100%" />
81
+ </DxcGrid.GridItem>
82
+ <DxcGrid.GridItem areaName="main" as="main">
83
+ <ColoredContainer height="100%" />
84
+ </DxcGrid.GridItem>
85
+ <DxcGrid.GridItem areaName="sidenav" as="nav">
86
+ <ColoredContainer height="100%" />
87
+ </DxcGrid.GridItem>
88
+ <DxcGrid.GridItem areaName="footer" as="footer">
89
+ <ColoredContainer height="100%" />
90
+ </DxcGrid.GridItem>
91
+ </DxcGrid>
92
+ </ExampleContainer>
93
+ <Title title="Template rows and columns with flexible sizes" level={4} />
94
+ <ExampleContainer>
95
+ <DxcGrid templateColumns={["1fr", "1fr", "1fr"]} templateRows={["1fr", "3fr", "1fr"]} gap="0.5rem">
96
+ <DxcGrid.GridItem column={{ start: 1, end: -1 }}>
97
+ <ColoredContainer color="yellow" height="100%">
98
+ Header
99
+ </ColoredContainer>
100
+ </DxcGrid.GridItem>
101
+ <DxcGrid.GridItem column={1}>
102
+ <ColoredContainer color="lightcyan" height="100%">
103
+ Sidenav
104
+ </ColoredContainer>
105
+ </DxcGrid.GridItem>
106
+ <DxcGrid
107
+ column={{ start: 2, end: -1 }}
108
+ templateRows={["repeat(4, 1fr)"]}
109
+ templateColumns={["repeat(2, 1fr)"]}
110
+ gap="1rem"
111
+ >
112
+ <ColoredContainer />
113
+ <ColoredContainer />
114
+ <ColoredContainer />
115
+ <ColoredContainer />
116
+ <ColoredContainer />
117
+ <ColoredContainer />
118
+ <ColoredContainer />
119
+ <ColoredContainer />
120
+ </DxcGrid>
121
+ <DxcGrid.GridItem column={{ start: 1, end: -1 }}>
122
+ <ColoredContainer color="black" height="100%">
123
+ Footer
124
+ </ColoredContainer>
125
+ </DxcGrid.GridItem>
126
+ </DxcGrid>
127
+ </ExampleContainer>
128
+ <Title title="Overlapping" level={4} />
129
+ <DxcInset bottom="2rem">
130
+ <ExampleContainer>
131
+ <DxcGrid templateRows={["50px", "50px"]}>
132
+ <ColoredContainer color="yellow" height="100px">
133
+ 1
134
+ </ColoredContainer>
135
+ <ColoredContainer color="transparent" height="100px">
136
+ 2
137
+ </ColoredContainer>
138
+ </DxcGrid>
139
+ </ExampleContainer>
140
+ </DxcInset>
141
+ <Title title="Implicit rows and columns" level={4} />
142
+ <ExampleContainer>
143
+ <DxcGrid templateColumns={["50px"]} templateRows={["50px", "50px"]} autoRows="50px" autoColumns="50px">
144
+ <DxcGrid.GridItem>
145
+ <ColoredContainer height="50px">1</ColoredContainer>
146
+ </DxcGrid.GridItem>
147
+ <DxcGrid.GridItem row={2}>
148
+ <ColoredContainer height="50px">3</ColoredContainer>
149
+ </DxcGrid.GridItem>
150
+ <DxcGrid.GridItem row={6} column={1}>
151
+ <ColoredContainer height="50px">5</ColoredContainer>
152
+ </DxcGrid.GridItem>
153
+ <DxcGrid.GridItem row={3}>
154
+ <ColoredContainer height="50px">4</ColoredContainer>
155
+ </DxcGrid.GridItem>
156
+ <DxcGrid.GridItem row={{ start: 1, end: 2 }} column={{ start: 5, end: "span 2" }}>
157
+ <ColoredContainer height="50px">2</ColoredContainer>
158
+ </DxcGrid.GridItem>
159
+ </DxcGrid>
160
+ </ExampleContainer>
161
+ <Title title="Autoflow 'row' (default)" level={4} />
162
+ <ExampleContainer>
163
+ <DxcGrid templateColumns={["repeat(5, 1fr)"]} templateRows={["1fr", "1fr"]} autoFlow="row" autoColumns="1fr">
164
+ <DxcGrid.GridItem row={{ start: 1, end: "span 2" }} column={1}>
165
+ <ColoredContainer height="100%">1</ColoredContainer>
166
+ </DxcGrid.GridItem>
167
+ <ColoredContainer color="lightyellow">2</ColoredContainer>
168
+ <ColoredContainer color="lightcyan">3</ColoredContainer>
169
+ <ColoredContainer color="lightgreen">4</ColoredContainer>
170
+ <DxcGrid.GridItem row={{ start: 1, end: -1 }} column={-2}>
171
+ <ColoredContainer color="lightpink" height="100%">
172
+ 5
173
+ </ColoredContainer>
174
+ </DxcGrid.GridItem>
175
+ </DxcGrid>
176
+ </ExampleContainer>
177
+ <Title title="Autoflow 'column'" level={4} />
178
+ <ExampleContainer>
179
+ <DxcGrid templateColumns={["repeat(5, 1fr)"]} templateRows={["1fr", "1fr"]} autoFlow="column" autoColumns="1fr">
180
+ <DxcGrid.GridItem row={{ start: 1, end: -1 }} column={1}>
181
+ <ColoredContainer height="100%">1</ColoredContainer>
182
+ </DxcGrid.GridItem>
183
+ <ColoredContainer color="lightyellow">2</ColoredContainer>
184
+ <ColoredContainer color="lightcyan">3</ColoredContainer>
185
+ <ColoredContainer color="lightgreen">4</ColoredContainer>
186
+ <DxcGrid.GridItem row={{ start: 1, end: -1 }} column={-2}>
187
+ <ColoredContainer color="lightpink" height="100%">
188
+ 5
189
+ </ColoredContainer>
190
+ </DxcGrid.GridItem>
191
+ </DxcGrid>
192
+ </ExampleContainer>
193
+ </>
194
+ );
195
+
196
+ const Container = styled.div<{ height?: string }>`
197
+ display: grid;
198
+ overflow: auto;
199
+ margin: 2.5rem;
200
+ ${({ height }) => height && `height: ${height}`};
201
+ `;
202
+
203
+ const ColoredContainer = styled.div<{ color?: string; width?: string; height?: string }>`
204
+ box-sizing: border-box;
205
+ display: flex;
206
+ justify-content: center;
207
+ align-items: center;
208
+ background-color: ${({ color }) => color ?? "#e5d5f6"};
209
+ padding: 1rem;
210
+ border: 1px solid #a46ede;
211
+ border-radius: 0.5rem;
212
+ font-family: Open Sans, sans-serif;
213
+ font-size: 1.5rem;
214
+ font-weight: bold;
215
+ color: #a46ede;
216
+
217
+ ${({ width }) => width && `width: ${width}`};
218
+ ${({ height }) => height && `height: ${height}`};
219
+ `;
@@ -0,0 +1,115 @@
1
+ /// <reference types="react" />
2
+ declare type Spaces = "0rem" | "0.125rem" | "0.25rem" | "0.5rem" | "1rem" | "1.5rem" | "2rem" | "3rem" | "4rem" | "5rem";
3
+ declare type Gap = {
4
+ rowGap: Spaces;
5
+ columnGap?: Spaces;
6
+ } | {
7
+ rowGap?: Spaces;
8
+ columnGap: Spaces;
9
+ } | Spaces;
10
+ declare type GridCell = {
11
+ start: number | string;
12
+ end: number | string;
13
+ };
14
+ declare type PlaceSelfValues = "auto" | "start" | "end" | "center" | "stretch" | "baseline";
15
+ declare type PlaceContentValues = "normal" | "start" | "end" | "center" | "stretch" | "space-between" | "space-around" | "space-evenly" | "baseline";
16
+ declare type PlaceItemsValues = "normal" | "start" | "end" | "center" | "stretch" | "baseline";
17
+ declare type PlaceObject<Type, Suffix extends string> = {
18
+ [Property in keyof Type as `${string & Property}${Capitalize<string & Suffix>}`]: Type[Property];
19
+ };
20
+ declare type PlaceGeneric<PlaceValues, Element extends string> = PlaceObject<{
21
+ justify?: PlaceValues;
22
+ align: PlaceValues;
23
+ }, Element> | PlaceObject<{
24
+ justify: PlaceValues;
25
+ align?: PlaceValues;
26
+ }, Element> | PlaceValues;
27
+ export declare type GridItemProps = {
28
+ /**
29
+ * Sets the name of an item so that it can be referenced by a template created with the grid-template-areas property.
30
+ */
31
+ areaName?: string;
32
+ /**
33
+ * Sets the grid-column CSS property.
34
+ *
35
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column
36
+ */
37
+ column?: number | string | GridCell;
38
+ /**
39
+ * Sets the grid-row CSS property.
40
+ *
41
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row
42
+ */
43
+ row?: number | string | GridCell;
44
+ /**
45
+ * Sets the place-self CSS property.
46
+ *
47
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/place-self
48
+ */
49
+ placeSelf?: PlaceGeneric<PlaceSelfValues, "self">;
50
+ /**
51
+ * Sets a custom HTML tag.
52
+ */
53
+ as?: keyof HTMLElementTagNameMap;
54
+ /**
55
+ * Custom content inside the grid container.
56
+ */
57
+ children: React.ReactNode;
58
+ };
59
+ declare type Props = GridItemProps & {
60
+ /**
61
+ * Sets the grid-auto-columns CSS property.
62
+ *
63
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns
64
+ */
65
+ autoColumns?: string;
66
+ /**
67
+ * Sets the grid-auto-flow CSS property.
68
+ *
69
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow
70
+ */
71
+ autoFlow?: "row" | "column" | "row dense" | "column dense";
72
+ /**
73
+ * Sets the grid-auto-rows CSS property.
74
+ *
75
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows
76
+ */
77
+ autoRows?: string;
78
+ /**
79
+ * Sets the gap CSS property.
80
+ *
81
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/gap
82
+ */
83
+ gap?: Spaces | Gap;
84
+ /**
85
+ * Sets the place-content CSS property.
86
+ *
87
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/place-content
88
+ */
89
+ placeContent?: PlaceGeneric<PlaceContentValues, "content">;
90
+ /**
91
+ * Sets the place-items CSS property.
92
+ *
93
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/place-items
94
+ */
95
+ placeItems?: PlaceGeneric<PlaceItemsValues, "items">;
96
+ /**
97
+ * Sets the grid-template-areas CSS property.
98
+ *
99
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas
100
+ */
101
+ templateAreas?: string[];
102
+ /**
103
+ * Sets the grid-template-columns CSS property.
104
+ *
105
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
106
+ */
107
+ templateColumns?: string[];
108
+ /**
109
+ * Sets the grid-template-rows CSS property.
110
+ *
111
+ * See MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows
112
+ */
113
+ templateRows?: string[];
114
+ };
115
+ export default Props;
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
+ import DxcDropdown from "../dropdown/Dropdown";
2
3
  import HeaderPropsType from "./types";
3
4
  declare const DxcHeader: {
4
5
  ({ underlined, content, responsiveContent, onClick, margin, padding, tabIndex, }: HeaderPropsType): JSX.Element;
5
- Dropdown: (props: any) => JSX.Element;
6
+ Dropdown: (props: React.ComponentProps<typeof DxcDropdown>) => JSX.Element;
6
7
  };
7
8
  export default DxcHeader;