@dxc-technology/halstack-react 0.0.0-090152f → 0.0.0-0a9608a

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 (95) hide show
  1. package/HalstackContext.js +7 -8
  2. package/accordion/Accordion.js +7 -13
  3. package/accordion/Accordion.stories.tsx +52 -12
  4. package/accordion/types.d.ts +1 -0
  5. package/accordion-group/types.d.ts +1 -0
  6. package/box/types.d.ts +1 -0
  7. package/button/Button.js +11 -13
  8. package/button/Button.stories.tsx +58 -1
  9. package/card/types.d.ts +1 -0
  10. package/checkbox/Checkbox.d.ts +2 -2
  11. package/checkbox/Checkbox.js +16 -15
  12. package/checkbox/Checkbox.stories.tsx +79 -59
  13. package/checkbox/types.d.ts +4 -0
  14. package/chip/Chip.js +11 -23
  15. package/chip/Chip.stories.tsx +41 -9
  16. package/common/variables.js +130 -126
  17. package/date-input/Calendar.d.ts +4 -0
  18. package/date-input/Calendar.js +246 -0
  19. package/date-input/DateInput.js +134 -237
  20. package/date-input/DateInput.stories.tsx +137 -38
  21. package/date-input/DateInput.test.js +494 -138
  22. package/date-input/DatePicker.d.ts +4 -0
  23. package/date-input/DatePicker.js +132 -0
  24. package/date-input/Icons.d.ts +6 -0
  25. package/date-input/Icons.js +75 -0
  26. package/date-input/YearPicker.d.ts +4 -0
  27. package/date-input/YearPicker.js +116 -0
  28. package/date-input/types.d.ts +51 -0
  29. package/dialog/types.d.ts +1 -0
  30. package/dropdown/Dropdown.js +38 -37
  31. package/dropdown/Dropdown.stories.tsx +175 -94
  32. package/dropdown/Dropdown.test.js +18 -24
  33. package/dropdown/DropdownMenu.js +8 -18
  34. package/dropdown/DropdownMenuItem.js +4 -15
  35. package/file-input/FileInput.d.ts +2 -2
  36. package/file-input/FileInput.js +177 -219
  37. package/file-input/FileInput.stories.tsx +38 -10
  38. package/file-input/FileInput.test.js +53 -12
  39. package/file-input/FileItem.d.ts +4 -14
  40. package/file-input/FileItem.js +38 -63
  41. package/file-input/types.d.ts +17 -0
  42. package/flex/Flex.d.ts +1 -1
  43. package/flex/Flex.js +31 -19
  44. package/flex/types.d.ts +14 -3
  45. package/footer/types.d.ts +1 -0
  46. package/header/Header.js +18 -20
  47. package/header/Header.stories.tsx +34 -1
  48. package/header/types.d.ts +1 -0
  49. package/link/Link.js +1 -1
  50. package/number-input/NumberInput.test.js +43 -7
  51. package/package.json +7 -12
  52. package/paginator/Icons.d.ts +5 -0
  53. package/paginator/Icons.js +16 -28
  54. package/paginator/Paginator.js +6 -12
  55. package/paginator/Paginator.test.js +18 -11
  56. package/password-input/PasswordInput.test.js +13 -12
  57. package/quick-nav/QuickNav.js +11 -12
  58. package/quick-nav/QuickNav.stories.tsx +97 -19
  59. package/radio-group/RadioGroup.js +9 -5
  60. package/radio-group/RadioGroup.test.js +116 -59
  61. package/resultsetTable/Icons.d.ts +7 -0
  62. package/resultsetTable/Icons.js +51 -0
  63. package/resultsetTable/ResultsetTable.js +48 -107
  64. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  65. package/resultsetTable/ResultsetTable.test.js +40 -63
  66. package/resultsetTable/types.d.ts +2 -2
  67. package/select/Listbox.d.ts +1 -1
  68. package/select/Listbox.js +5 -34
  69. package/select/Option.js +11 -24
  70. package/select/Select.js +46 -25
  71. package/select/Select.stories.tsx +209 -167
  72. package/select/Select.test.js +284 -231
  73. package/select/types.d.ts +2 -2
  74. package/sidenav/Sidenav.js +8 -10
  75. package/sidenav/Sidenav.stories.tsx +59 -50
  76. package/slider/Slider.d.ts +2 -2
  77. package/slider/Slider.js +15 -11
  78. package/slider/types.d.ts +4 -0
  79. package/spinner/Spinner.js +2 -2
  80. package/switch/Switch.d.ts +3 -3
  81. package/switch/Switch.js +5 -4
  82. package/switch/types.d.ts +6 -1
  83. package/table/Table.js +1 -1
  84. package/table/Table.test.js +1 -1
  85. package/tabs/Tab.js +3 -5
  86. package/tabs/Tabs.js +3 -3
  87. package/tabs/Tabs.stories.tsx +7 -5
  88. package/tabs-nav/NavTabs.stories.tsx +8 -6
  89. package/tabs-nav/Tab.js +5 -7
  90. package/text-input/Suggestion.js +32 -5
  91. package/text-input/TextInput.js +172 -162
  92. package/text-input/TextInput.stories.tsx +24 -4
  93. package/text-input/TextInput.test.js +658 -647
  94. package/text-input/types.d.ts +5 -0
  95. package/common/RequiredComponent.js +0 -32
@@ -15,6 +15,8 @@ const iconSVG = (
15
15
  </svg>
16
16
  );
17
17
 
18
+ const largeIcon = "https://www.iconpacks.net/icons/1/free-pin-icon-48-thumb.png"
19
+
18
20
  export const Chromatic = () => (
19
21
  <>
20
22
  <ExampleContainer>
@@ -93,10 +95,10 @@ export const Chromatic = () => (
93
95
  <DxcNavTabs.Tab href="#" disabled icon={iconSVG}>
94
96
  Tab 2
95
97
  </DxcNavTabs.Tab>
96
- <DxcNavTabs.Tab href="#" icon={iconSVG}>
98
+ <DxcNavTabs.Tab href="#" icon={largeIcon}>
97
99
  Tab 3
98
100
  </DxcNavTabs.Tab>
99
- <DxcNavTabs.Tab href="#" icon={iconSVG}>
101
+ <DxcNavTabs.Tab href="#" icon={largeIcon}>
100
102
  Tab 4
101
103
  </DxcNavTabs.Tab>
102
104
  </DxcNavTabs>
@@ -104,7 +106,7 @@ export const Chromatic = () => (
104
106
  <ExampleContainer>
105
107
  <Title title="With icon position left" theme="light" level={4} />
106
108
  <DxcNavTabs iconPosition="left">
107
- <DxcNavTabs.Tab href="#" active icon={iconSVG}>
109
+ <DxcNavTabs.Tab href="#" active icon={largeIcon}>
108
110
  Tab 1
109
111
  </DxcNavTabs.Tab>
110
112
  <DxcNavTabs.Tab href="#" disabled icon={iconSVG}>
@@ -121,7 +123,7 @@ export const Chromatic = () => (
121
123
  <ExampleContainer>
122
124
  <Title title="With icon and notification number" theme="light" level={4} />
123
125
  <DxcNavTabs>
124
- <DxcNavTabs.Tab href="#" active icon={iconSVG} notificationNumber>
126
+ <DxcNavTabs.Tab href="#" active icon={largeIcon} notificationNumber>
125
127
  Tab 1
126
128
  </DxcNavTabs.Tab>
127
129
  <DxcNavTabs.Tab href="#" disabled icon={iconSVG} notificationNumber={5}>
@@ -130,7 +132,7 @@ export const Chromatic = () => (
130
132
  <DxcNavTabs.Tab href="#" icon={iconSVG} notificationNumber={120}>
131
133
  Tab 3
132
134
  </DxcNavTabs.Tab>
133
- <DxcNavTabs.Tab href="#" icon={iconSVG}>
135
+ <DxcNavTabs.Tab href="#" icon={largeIcon}>
134
136
  Tab 4
135
137
  </DxcNavTabs.Tab>
136
138
  </DxcNavTabs>
@@ -144,7 +146,7 @@ export const Chromatic = () => (
144
146
  <DxcNavTabs.Tab href="#" disabled icon={iconSVG} notificationNumber={5}>
145
147
  Tab 2
146
148
  </DxcNavTabs.Tab>
147
- <DxcNavTabs.Tab href="#" icon={iconSVG} notificationNumber={120}>
149
+ <DxcNavTabs.Tab href="#" icon={largeIcon} notificationNumber={120}>
148
150
  Tab 3
149
151
  </DxcNavTabs.Tab>
150
152
  <DxcNavTabs.Tab href="#" icon={iconSVG}>
package/tabs-nav/Tab.js CHANGED
@@ -23,7 +23,7 @@ var _Badge = _interopRequireDefault(require("../badge/Badge"));
23
23
 
24
24
  var _NavTabs = require("./NavTabs");
25
25
 
26
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
26
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
27
27
 
28
28
  var _excluded = ["href", "active", "icon", "disabled", "notificationNumber", "children"];
29
29
 
@@ -90,7 +90,7 @@ var DxcTab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, _ref2) {
90
90
  tabIndex: active ? tabIndex : -1
91
91
  }, otherProps), icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
92
92
  iconPosition: iconPosition
93
- }, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(TabIcon, {
93
+ }, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
94
94
  src: icon
95
95
  }) : icon), /*#__PURE__*/_react["default"].createElement(LabelContainer, null, children, notificationNumber && /*#__PURE__*/_react["default"].createElement(BadgeContainer, null, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
96
96
  notificationText: notificationNumber > 99 ? "+99" : notificationNumber,
@@ -114,17 +114,15 @@ var Tab = _styledComponents["default"].a(_templateObject2 || (_templateObject2 =
114
114
  return !props.disabled && ":hover {\n background: #0000000D;\n }\n\n :focus {\n outline: 2px solid #33aaff};\n }\n\n :active {\n background: #0000001A;\n outline: 2px solid #33aaff};\n }";
115
115
  });
116
116
 
117
- var TabIcon = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""])));
118
-
119
- var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 24px;\n max-width: 24px;\n margin-bottom: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n align-items: center;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
117
+ var TabIconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-bottom: ", ";\n margin-right: ", ";\n\n img,\n svg {\n height: 24px;\n width: 24px;\n }\n"])), function (props) {
120
118
  return props.iconPosition === "top" && "0.375rem";
121
119
  }, function (props) {
122
120
  return props.iconPosition === "left" && "0.625rem";
123
121
  });
124
122
 
125
- var LabelContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n"])));
123
+ var LabelContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n"])));
126
124
 
127
- var BadgeContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 0.5rem;\n"])));
125
+ var BadgeContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 0.5rem;\n"])));
128
126
 
129
127
  var _default = DxcTab;
130
128
  exports["default"] = _default;
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -9,12 +11,33 @@ exports["default"] = void 0;
9
11
 
10
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
13
 
12
- var _react = _interopRequireDefault(require("react"));
14
+ var _react = _interopRequireWildcard(require("react"));
13
15
 
14
16
  var _styledComponents = _interopRequireDefault(require("styled-components"));
15
17
 
16
18
  var _templateObject, _templateObject2;
17
19
 
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ var transformSpecialChars = function transformSpecialChars(str) {
25
+ var specialCharsRegex = /[\\*()\[\]{}+?/]/;
26
+ var value = str;
27
+
28
+ if (specialCharsRegex.test(value)) {
29
+ var regexAsString = specialCharsRegex.toString().split("");
30
+ var uniqueSpecialChars = regexAsString.filter(function (item, index) {
31
+ return regexAsString.indexOf(item) === index;
32
+ });
33
+ uniqueSpecialChars.forEach(function (specialChar) {
34
+ if (str.includes(specialChar)) value = value.replace(specialChar, "\\" + specialChar);
35
+ });
36
+ }
37
+
38
+ return value;
39
+ };
40
+
18
41
  var Suggestion = function Suggestion(_ref) {
19
42
  var id = _ref.id,
20
43
  value = _ref.value,
@@ -23,9 +46,13 @@ var Suggestion = function Suggestion(_ref) {
23
46
  isLast = _ref.isLast,
24
47
  visuallyFocused = _ref.visuallyFocused,
25
48
  highlighted = _ref.highlighted;
26
- var regEx = new RegExp(value, "i");
27
- var matchedWords = suggestion.match(regEx);
28
- var noMatchedWords = suggestion.replace(regEx, "");
49
+ var matchedSuggestion = (0, _react.useMemo)(function () {
50
+ var regEx = new RegExp(transformSpecialChars(value), "i");
51
+ return {
52
+ matchedWords: suggestion.match(regEx),
53
+ noMatchedWords: suggestion.replace(regEx, "")
54
+ };
55
+ }, [value, suggestion]);
29
56
  return /*#__PURE__*/_react["default"].createElement(SuggestionContainer, {
30
57
  id: id,
31
58
  onClick: function onClick() {
@@ -37,7 +64,7 @@ var Suggestion = function Suggestion(_ref) {
37
64
  }, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
38
65
  last: isLast,
39
66
  visuallyFocused: visuallyFocused
40
- }, highlighted ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords) : suggestion));
67
+ }, highlighted ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedSuggestion.matchedWords), matchedSuggestion.noMatchedWords) : suggestion));
41
68
  };
42
69
 
43
70
  var SuggestionContainer = _styledComponents["default"].li(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0 0.5rem;\n line-height: 1.715em;\n cursor: pointer;\n box-shadow: inset 0 0 0 2px\n ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {