@decisiv/ui-components 2.0.1-alpha.184 → 2.0.1-alpha.186

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 (52) hide show
  1. package/lib/atoms/InputField/HelpMessage.d.ts +1 -1
  2. package/lib/atoms/InputField/HelpMessage.d.ts.map +1 -1
  3. package/lib/atoms/InputField/HelpMessage.js +2 -1
  4. package/lib/atoms/InputField/index.d.ts +1 -0
  5. package/lib/atoms/InputField/index.d.ts.map +1 -1
  6. package/lib/atoms/InputField/index.js +3 -2
  7. package/lib/atoms/OptionsList/types.d.ts +1 -1
  8. package/lib/atoms/OptionsList/types.d.ts.map +1 -1
  9. package/lib/components/Badge/types.d.ts +1 -1
  10. package/lib/components/Filter/ActionFilter/index.d.ts +5 -0
  11. package/lib/components/Filter/ActionFilter/index.d.ts.map +1 -0
  12. package/lib/components/Filter/ActionFilter/index.js +43 -0
  13. package/lib/components/Filter/IconWrapper/index.d.ts +2 -2
  14. package/lib/components/Filter/IconWrapper/index.d.ts.map +1 -1
  15. package/lib/components/Filter/SimplePrimary/index.d.ts +2 -28
  16. package/lib/components/Filter/SimplePrimary/index.d.ts.map +1 -1
  17. package/lib/components/Filter/SimplePrimary/index.js +10 -21
  18. package/lib/components/Filter/StyledFilter.d.ts +2 -2
  19. package/lib/components/Filter/StyledFilter.d.ts.map +1 -1
  20. package/lib/components/Filter/StyledFilter.js +17 -1
  21. package/lib/components/Filter/StyledLabel/index.d.ts +3 -3
  22. package/lib/components/Filter/StyledLabel/index.d.ts.map +1 -1
  23. package/lib/components/Filter/StyledLabel/index.js +14 -6
  24. package/lib/components/Filter/index.d.ts +3 -2
  25. package/lib/components/Filter/index.d.ts.map +1 -1
  26. package/lib/components/Filter/index.js +28 -28
  27. package/lib/components/Filter/index.test.js +1 -5
  28. package/lib/components/Filter/kind.d.ts +4 -3
  29. package/lib/components/Filter/kind.d.ts.map +1 -1
  30. package/lib/components/Filter/kind.js +19 -21
  31. package/lib/components/Filter/schema.d.ts.map +1 -1
  32. package/lib/components/Filter/schema.js +7 -3
  33. package/lib/components/Filter/types.d.ts +21 -8
  34. package/lib/components/Filter/types.d.ts.map +1 -1
  35. package/lib/components/SearchInput/index.d.ts +1 -1
  36. package/lib/components/SearchInput/index.d.ts.map +1 -1
  37. package/lib/components/SearchInput/index.js +56 -75
  38. package/lib/components/SearchInput/index.test.js +183 -0
  39. package/lib/components/SearchInput/schema.d.ts.map +1 -1
  40. package/lib/components/SearchInput/schema.js +12 -1
  41. package/lib/components/SearchInput/styles.d.ts +1176 -0
  42. package/lib/components/SearchInput/styles.d.ts.map +1 -0
  43. package/lib/components/SearchInput/styles.js +97 -0
  44. package/lib/components/SearchInput/types.d.ts +9 -1
  45. package/lib/components/SearchInput/types.d.ts.map +1 -1
  46. package/lib/components/Tag/propTypes.d.ts +1 -1
  47. package/lib/providers/ConfigProvider/utils/translations.d.ts +1 -0
  48. package/lib/providers/ConfigProvider/utils/translations.d.ts.map +1 -1
  49. package/lib/providers/ConfigProvider/utils/translations.js +2 -1
  50. package/lib/utils/commonUIColors.d.ts +1 -1
  51. package/lib/utils/commonUIColors.d.ts.map +1 -1
  52. package/package.json +2 -2
@@ -3,17 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.hoverStyles = void 0;
6
+ exports.default = exports.secondaryStyle = exports.primaryStyle = exports.hoverStyles = void 0;
7
7
 
8
- var _styledTheming = _interopRequireDefault(require("styled-theming"));
8
+ var _designTokens = require("@decisiv/design-tokens");
9
+
10
+ var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"));
11
+
12
+ var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
9
13
 
10
14
  var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
11
15
 
12
16
  var _styledComponents = require("styled-components");
13
17
 
14
- var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
15
-
16
- var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"));
18
+ var _styledTheming = _interopRequireDefault(require("styled-theming"));
17
19
 
18
20
  var _ConfigProvider = require("../../providers/ConfigProvider");
19
21
 
@@ -22,24 +24,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
24
  var hoverStyles = (0, _styledComponents.css)(["color:", ";background-color:", ";border:", " solid ", ";svg{color:", ";}"], (0, _toColorString.default)(_color.default.base.snowWhite), (0, _toColorString.default)(_color.default.interaction.indianOcean), (0, _rem.default)(1), (0, _toColorString.default)(_color.default.interaction.indianOcean), (0, _toColorString.default)(_color.default.base.snowWhite));
23
25
  exports.hoverStyles = hoverStyles;
24
26
  var primaryStyle = (0, _styledComponents.css)(["border:", " solid ", ";&:hover{", ";}&:disabled:disabled{background-color:transparent;color:", ";}"], (0, _rem.default)(1), (0, _toColorString.default)(_color.default.base.quarterMoon), hoverStyles, (0, _toColorString.default)(_color.default.opacity.charcoal40));
25
- // light and dark are the same ATM.
26
- var lightStyles = {
27
- primary: primaryStyle
28
- };
29
- var darkStyles = {
30
- primary: primaryStyle
31
- };
32
- var kindStyles = (0, _styledTheming.default)(_ConfigProvider.themeKeys.mode, {
33
- light: function light(_ref) {
34
- var _ref$kind = _ref.kind,
35
- kind = _ref$kind === void 0 ? 'primary' : _ref$kind;
36
- return lightStyles[kind];
27
+ exports.primaryStyle = primaryStyle;
28
+ var secondaryStyle = (0, _styledComponents.css)(["height:", ";font-size:", ";"], (0, _rem.default)(_designTokens.spacing.base * 2.4), (0, _rem.default)(_designTokens.typography.size.alias.paragraph2));
29
+ exports.secondaryStyle = secondaryStyle;
30
+
31
+ var kindStyles = _styledTheming.default.variants(_ConfigProvider.themeKeys.mode, 'kind', {
32
+ primary: {
33
+ light: primaryStyle,
34
+ dark: primaryStyle
37
35
  },
38
- dark: function dark(_ref2) {
39
- var _ref2$kind = _ref2.kind,
40
- kind = _ref2$kind === void 0 ? 'primary' : _ref2$kind;
41
- return darkStyles[kind];
36
+ secondary: {
37
+ light: secondaryStyle,
38
+ right: secondaryStyle
42
39
  }
43
40
  });
41
+
44
42
  var _default = kindStyles;
45
43
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Filter/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,yBAAyB;;;;CAyBpC,CAAC;AAEH,QAAA,MAAM,MAAM,KAAsC,CAAC;AAInD,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Filter/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,yBAAyB;;;;CA0CpC,CAAC;AAEH,QAAA,MAAM,MAAM,KAAsC,CAAC;AAInD,eAAe,MAAM,CAAC"}
@@ -17,10 +17,14 @@ var makeFilterSchemaPropTypes = function makeFilterSchemaPropTypes(extensions) {
17
17
  return _objectSpread({
18
18
  text: _reactDesc.PropTypes.string.description("The Filter's text"),
19
19
  active: _reactDesc.PropTypes.bool.description("The Filter's active status. Use when you want to control the Filter with onClick.").defaultValue('false'),
20
- badgeIcon: _reactDesc.PropTypes.element.description('Which `iconix` icon to render'),
21
- badgeColor: _reactDesc.PropTypes.string.description('Which color to use as background for the icon. It always displays when an icon is provided.').defaultValue('information'),
20
+ badgeIcon: _reactDesc.PropTypes.element.description('Which `iconix` icon to render, only usable with the "simple" variant'),
21
+ badgeColor: _reactDesc.PropTypes.string.description('Which color to use as background for the icon. It always displays when an icon is provided. Only usable with the "simple" variant').defaultValue('information'),
22
22
  count: _reactDesc.PropTypes.number.description("The Filter's count, displayed to the left of the text. When not provided, no count is rendered."),
23
- disabled: _reactDesc.PropTypes.bool.description("The Filter's displayed status of disabled or enabled.").defaultValue('false')
23
+ disabled: _reactDesc.PropTypes.bool.description("The Filter's displayed status of disabled or enabled.").defaultValue('false'),
24
+ kind: _reactDesc.PropTypes.oneOf(['primary', 'secondary']).defaultValue('primary'),
25
+ variant: _reactDesc.PropTypes.oneOf(['simple', 'action']).description('Use the variant to define the type of filter that you want to use').defaultValue('simple'),
26
+ startIcon: _reactDesc.PropTypes.element.description('Which `iconix` icon to render before the filter text, only usable with the "action" variant'),
27
+ endIcon: _reactDesc.PropTypes.element.description('Which `iconix` icon to render after the filter text, only usable with the "action" variant')
24
28
  }, extensions);
25
29
  };
26
30
 
@@ -2,17 +2,30 @@ import { ButtonHTMLAttributes } from 'react';
2
2
  import { IconProps } from '@decisiv/iconix';
3
3
  import { CommonUIColorKeys } from '../../utils/commonUIColors';
4
4
  import { TranslatedText } from '../../utils/useTranslations';
5
- export declare type Variant = 'simple';
6
- export declare type Kind = 'primary';
5
+ export declare type Variant = 'simple' | 'action';
6
+ export declare type Kind = 'primary' | 'secondary';
7
7
  export declare type IconComponent = (props: IconProps) => JSX.Element;
8
- export interface FilterProps extends ButtonHTMLAttributes<HTMLButtonElement> {
9
- active?: boolean;
10
- count?: number;
11
- badgeIcon?: IconComponent;
12
- badgeColor?: CommonUIColorKeys;
8
+ export interface BaseFilterProps extends ButtonHTMLAttributes<HTMLButtonElement> {
13
9
  kind?: Kind;
14
- text: TranslatedText;
15
10
  variant?: Variant;
11
+ text: TranslatedText;
12
+ count?: number;
13
+ active?: boolean;
16
14
  disabled?: boolean;
17
15
  }
16
+ export interface SimpleFilterProps extends BaseFilterProps {
17
+ variant: 'simple';
18
+ badgeIcon?: IconComponent;
19
+ badgeColor?: CommonUIColorKeys;
20
+ startIcon?: never;
21
+ endIcon?: never;
22
+ }
23
+ export interface ActionFilterProps extends BaseFilterProps {
24
+ variant: 'action';
25
+ startIcon?: IconComponent;
26
+ endIcon?: IconComponent;
27
+ badgeIcon?: never;
28
+ badgeColor?: never;
29
+ }
30
+ export declare type FilterProps = SimpleFilterProps | ActionFilterProps;
18
31
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Filter/types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,oBAAY,OAAO,GAAG,QAAQ,CAAC;AAC/B,oBAAY,IAAI,GAAG,SAAS,CAAC;AAC7B,oBAAY,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAE9D,MAAM,WAAW,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC1E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Filter/types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,oBAAY,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC1C,oBAAY,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC;AAC3C,oBAAY,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAE9D,MAAM,WAAW,eACf,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC/C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,oBAAY,WAAW,GAAG,iBAAiB,GAAG,iBAAiB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { SearchInputProps, SearchItem, StyledFlexProps } from './types';
3
- declare function SearchInput({ onSearch, value, onChange, size, disabled, searchDisabled, searchOn, ...props }: SearchInputProps): JSX.Element;
3
+ declare function SearchInput({ onSearch, value, onChange, size, disabled, searchDisabled, searchOn, searchByOptions, searchByLabel, searchByValue, searchByName, searchByDefaultValue, searchByWidth, onSearchByChange, warningMessage, helpMessage, ...props }: SearchInputProps): JSX.Element;
4
4
  declare namespace SearchInput {
5
5
  var defaultProps: {
6
6
  size: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SearchInput/index.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAkExE,iBAAwB,WAAW,CAAC,EAClC,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,QAAmB,EACnB,GAAG,KAAK,EACT,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CA0GhC;kBAnHuB,WAAW;;;;;eAAX,WAAW;AAyHnC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SearchInput/index.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAiBxE,iBAAwB,WAAW,CAAC,EAClC,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,QAAmB,EACnB,eAAoB,EACpB,aAAkB,EAClB,aAAa,EACb,YAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,GAAG,KAAK,EACT,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAsIhC;kBAxJuB,WAAW;;;;;eAAX,WAAW;AA8JnC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
@@ -25,38 +25,30 @@ Object.defineProperty(exports, "StyledFlexProps", {
25
25
 
26
26
  var _react = _interopRequireWildcard(require("react"));
27
27
 
28
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
29
+
28
30
  var _Times = _interopRequireDefault(require("@decisiv/iconix/lib/components/Times"));
29
31
 
30
32
  var _Search = _interopRequireDefault(require("@decisiv/iconix/lib/components/Search"));
31
33
 
32
- var _styledComponents = _interopRequireDefault(require("styled-components"));
33
-
34
- var _spacing = _interopRequireDefault(require("@decisiv/design-tokens/lib/spacing"));
35
-
36
- var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
37
-
38
- var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"));
39
-
40
- var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
41
-
42
34
  var _useTranslations = _interopRequireDefault(require("../../utils/useTranslations"));
43
35
 
44
- var _Flex = _interopRequireDefault(require("../Flex"));
45
-
46
36
  var _Button = _interopRequireDefault(require("../Button"));
47
37
 
48
38
  var _InputField = _interopRequireDefault(require("../../atoms/InputField"));
49
39
 
50
- var _Tooltip = _interopRequireDefault(require("../Tooltip"));
40
+ var _HelpMessage = _interopRequireDefault(require("../../atoms/InputField/HelpMessage"));
51
41
 
52
- var _focusRingWithColor = _interopRequireDefault(require("../../utils/focusRingWithColor"));
42
+ var _Tooltip = _interopRequireDefault(require("../Tooltip"));
53
43
 
54
44
  var _types = require("./types");
55
45
 
56
- var _Input = _interopRequireDefault(require("../TextField/Input"));
46
+ var _styles = require("./styles");
57
47
 
58
48
  var _useUpdateEffect = _interopRequireDefault(require("../../utils/useUpdateEffect"));
59
49
 
50
+ var _Select = _interopRequireDefault(require("../Select"));
51
+
60
52
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
53
 
62
54
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
@@ -67,59 +59,28 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
67
59
 
68
60
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
69
61
 
70
- var StyledFlex = (0, _styledComponents.default)(_Flex.default).withConfig({
71
- displayName: "SearchInput__StyledFlex",
72
- componentId: "sc-1lgi0sd-0"
73
- })(["align-items:center;[cursor='text']{height:", "px;> div{", ";padding-bottom:", ";}}"], function (_ref) {
74
- var mediumSized = _ref.mediumSized;
75
- return mediumSized ? 50 : 32;
76
- }, function (_ref2) {
77
- var mediumSized = _ref2.mediumSized;
78
- return !mediumSized && "padding-top: ".concat((0, _rem.default)(_spacing.default.base * 0.1));
79
- }, function (_ref3) {
80
- var mediumSized = _ref3.mediumSized;
81
- return (0, _rem.default)(_spacing.default.base * (mediumSized ? 0.6 : 0.1));
82
- });
83
- var StyledBody = (0, _styledComponents.default)(_Flex.default).withConfig({
84
- displayName: "SearchInput__StyledBody",
85
- componentId: "sc-1lgi0sd-1"
86
- })(["flex:1;align-items:center;height:inherit;"]);
87
- var ButtonGroup = (0, _styledComponents.default)(_Flex.default).withConfig({
88
- displayName: "SearchInput__ButtonGroup",
89
- componentId: "sc-1lgi0sd-2"
90
- })(["align-items:center;margin-right:", ";cursor:default;"], function (_ref4) {
91
- var mediumSized = _ref4.mediumSized;
92
- return (0, _rem.default)(_spacing.default.base * (mediumSized ? 1 : 0.3));
93
- });
94
- var SearchIconWrapper = (0, _styledComponents.default)(_Flex.default).withConfig({
95
- displayName: "SearchInput__SearchIconWrapper",
96
- componentId: "sc-1lgi0sd-3"
97
- })(["color:", ";margin-right:", ";margin-left:", ";align-items:center;"], (0, _toColorString.default)(_color.default.base.alaskanHusky), (0, _rem.default)(_spacing.default.base * 1.5), function (_ref5) {
98
- var inputSize = _ref5.inputSize;
99
- return inputSize === 'small' ? 0 : (0, _rem.default)(_spacing.default.base * 0.5);
100
- });
101
- var TimesIconWrapper = (0, _styledComponents.default)(_Flex.default).withConfig({
102
- displayName: "SearchInput__TimesIconWrapper",
103
- componentId: "sc-1lgi0sd-4"
104
- })(["height:inherit;visibility:", ";margin-right:", ";color:", ";align-items:center;border:1px solid transparent;border-radius:2px;&:hover{color:", ";}&:focus{outline:none;border:1px solid ", ";", "}"], function (_ref6) {
105
- var visible = _ref6.visible;
106
- return visible ? 'visible' : 'hidden';
107
- }, (0, _rem.default)(_spacing.default.base), (0, _toColorString.default)(_color.default.interaction.pacificOcean), (0, _toColorString.default)(_color.default.status.danger.medium), (0, _toColorString.default)(_color.default.interaction.pacificOcean), (0, _focusRingWithColor.default)(_color.default.interaction.pacificOcean40));
108
- var StyledInput = (0, _styledComponents.default)(_Input.default).withConfig({
109
- displayName: "SearchInput__StyledInput",
110
- componentId: "sc-1lgi0sd-5"
111
- })(["padding:0;color:", ";"], (0, _toColorString.default)(_color.default.base.charcoal));
112
-
113
- function SearchInput(_ref7) {
114
- var onSearch = _ref7.onSearch,
115
- value = _ref7.value,
116
- onChange = _ref7.onChange,
117
- size = _ref7.size,
118
- disabled = _ref7.disabled,
119
- searchDisabled = _ref7.searchDisabled,
120
- _ref7$searchOn = _ref7.searchOn,
121
- searchOn = _ref7$searchOn === void 0 ? 'submit' : _ref7$searchOn,
122
- props = _objectWithoutProperties(_ref7, ["onSearch", "value", "onChange", "size", "disabled", "searchDisabled", "searchOn"]);
62
+ function SearchInput(_ref) {
63
+ var onSearch = _ref.onSearch,
64
+ value = _ref.value,
65
+ onChange = _ref.onChange,
66
+ size = _ref.size,
67
+ disabled = _ref.disabled,
68
+ searchDisabled = _ref.searchDisabled,
69
+ _ref$searchOn = _ref.searchOn,
70
+ searchOn = _ref$searchOn === void 0 ? 'submit' : _ref$searchOn,
71
+ _ref$searchByOptions = _ref.searchByOptions,
72
+ searchByOptions = _ref$searchByOptions === void 0 ? [] : _ref$searchByOptions,
73
+ _ref$searchByLabel = _ref.searchByLabel,
74
+ searchByLabel = _ref$searchByLabel === void 0 ? '' : _ref$searchByLabel,
75
+ searchByValue = _ref.searchByValue,
76
+ _ref$searchByName = _ref.searchByName,
77
+ searchByName = _ref$searchByName === void 0 ? '' : _ref$searchByName,
78
+ searchByDefaultValue = _ref.searchByDefaultValue,
79
+ searchByWidth = _ref.searchByWidth,
80
+ onSearchByChange = _ref.onSearchByChange,
81
+ warningMessage = _ref.warningMessage,
82
+ helpMessage = _ref.helpMessage,
83
+ props = _objectWithoutProperties(_ref, ["onSearch", "value", "onChange", "size", "disabled", "searchDisabled", "searchOn", "searchByOptions", "searchByLabel", "searchByValue", "searchByName", "searchByDefaultValue", "searchByWidth", "onSearchByChange", "warningMessage", "helpMessage"]);
123
84
 
124
85
  var translate = (0, _useTranslations.default)();
125
86
  var handleSearch = (0, _react.useCallback)(function () {
@@ -127,6 +88,7 @@ function SearchInput(_ref7) {
127
88
  }, [disabled, searchDisabled, onSearch, value]);
128
89
  var mediumSized = size === 'medium';
129
90
  var hasText = !!value && !!value.length;
91
+ var showSearchBy = !(0, _isEmpty.default)(searchByOptions);
130
92
  var handleClear = (0, _react.useCallback)(function () {
131
93
  !disabled && onChange && onChange({
132
94
  target: {
@@ -143,30 +105,45 @@ function SearchInput(_ref7) {
143
105
  }
144
106
  }, [searchOn, value]);
145
107
  var renderLeftIcon = searchOn === 'change' || searchOn === 'submit' && mediumSized;
146
- return _react.default.createElement(StyledFlex, {
108
+ return _react.default.createElement(_styles.SearchInputContainer, null, _react.default.createElement(_styles.StyledFlex, {
147
109
  flex: 1,
148
110
  mediumSized: mediumSized,
149
111
  "data-testid": "search-container"
150
- }, _react.default.createElement(_InputField.default, _extends({
112
+ }, showSearchBy && _react.default.createElement(_styles.SelectWrapper, {
113
+ width: searchByWidth
114
+ }, _react.default.createElement(_Select.default, {
115
+ "aria-label": translate(undefined, 'searchInput.searchBy'),
116
+ disabled: disabled,
117
+ hideClearButton: true,
118
+ hideLabel: !mediumSized,
119
+ label: searchByLabel,
120
+ name: searchByName,
121
+ options: searchByOptions,
122
+ value: searchByValue,
123
+ withWarningIntent: !!warningMessage,
124
+ onChange: onSearchByChange,
125
+ defaultValue: searchByDefaultValue
126
+ })), _react.default.createElement(_InputField.default, _extends({
151
127
  label: "",
152
128
  hideLabel: true,
153
129
  disabled: disabled,
154
- value: value
130
+ value: value,
131
+ withWarningIntent: !!warningMessage
155
132
  }, props), function (p) {
156
- return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(StyledBody, null, renderLeftIcon && _react.default.createElement(SearchIconWrapper, {
133
+ return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_styles.StyledBody, null, renderLeftIcon && _react.default.createElement(_styles.SearchIconWrapper, {
157
134
  inputSize: size
158
135
  }, _react.default.createElement(_Search.default, {
159
136
  size: "medium",
160
137
  "data-testid": "search-icon"
161
- })), _react.default.createElement(StyledInput, _extends({}, p, {
138
+ })), _react.default.createElement(_styles.StyledInput, _extends({}, p, {
162
139
  onChange: onChange,
163
140
  onKeyPress: handleKeyPress
164
- })), _react.default.createElement(ButtonGroup, {
141
+ })), _react.default.createElement(_styles.ButtonGroup, {
165
142
  mediumSized: mediumSized
166
143
  }, !disabled && _react.default.createElement(_Tooltip.default, {
167
144
  placement: "top",
168
145
  target: // eslint-disable-next-line react/jsx-wrap-multilines
169
- _react.default.createElement(TimesIconWrapper, {
146
+ _react.default.createElement(_styles.TimesIconWrapper, {
170
147
  tabIndex: 0,
171
148
  "aria-label": translate(undefined, 'searchInput.clearSearch'),
172
149
  onClick: handleClear,
@@ -183,6 +160,10 @@ function SearchInput(_ref7) {
183
160
  size: size,
184
161
  onClick: handleSearch
185
162
  }))));
163
+ })), !(0, _isEmpty.default)(warningMessage) && _react.default.createElement(_styles.WarningMessage, {
164
+ intent: "warning"
165
+ }, warningMessage), _react.default.createElement(_HelpMessage.default, {
166
+ helpMessage: helpMessage
186
167
  }));
187
168
  }
188
169
 
@@ -20,8 +20,24 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
20
20
 
21
21
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
22
22
 
23
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
+
23
25
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
26
 
27
+ // Prevent warnings about missing document methods (createRange, etc.)
28
+ jest.mock('popper.js', function () {
29
+ var _class, _temp;
30
+
31
+ var PopperJS = jest.requireActual('popper.js');
32
+ return _temp = _class = function _class() {
33
+ _classCallCheck(this, _class);
34
+
35
+ return {
36
+ destroy: function destroy() {},
37
+ scheduleUpdate: function scheduleUpdate() {}
38
+ };
39
+ }, _defineProperty(_class, "placements", PopperJS.placements), _temp;
40
+ });
25
41
  beforeAll(function () {
26
42
  var root = document.createElement('div');
27
43
  root.setAttribute('id', 'popovers-root');
@@ -474,4 +490,171 @@ describe('Search input', function () {
474
490
  }, _callee14);
475
491
  })));
476
492
  });
493
+ describe('searchBy selector', function () {
494
+ var searchByOptions = [{
495
+ id: 'Value 1',
496
+ label: 'Value 1'
497
+ }, {
498
+ id: 'Value 2',
499
+ label: 'Value 2'
500
+ }, {
501
+ id: 'Value 3',
502
+ label: 'Value 3'
503
+ }];
504
+ it('renders list of options', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() {
505
+ var _render2, getByLabelText, getByText;
506
+
507
+ return regeneratorRuntime.wrap(function _callee15$(_context15) {
508
+ while (1) {
509
+ switch (_context15.prev = _context15.next) {
510
+ case 0:
511
+ _render2 = render(_react.default.createElement(_.default, {
512
+ searchByOptions: searchByOptions,
513
+ searchByLabel: "Search By",
514
+ searchByName: "search-by",
515
+ value: "Searched value",
516
+ onChange: onChangeMock,
517
+ onSearch: onSearchMock
518
+ })), getByLabelText = _render2.getByLabelText, getByText = _render2.getByText;
519
+ expect(getByLabelText('Search By')).toBeInTheDocument();
520
+
521
+ _react2.fireEvent.click(getByLabelText('Search By'));
522
+
523
+ searchByOptions.forEach(function (_ref17) {
524
+ var label = _ref17.label;
525
+ expect(getByText(label)).toBeInTheDocument();
526
+ });
527
+
528
+ case 4:
529
+ case "end":
530
+ return _context15.stop();
531
+ }
532
+ }
533
+ }, _callee15);
534
+ })));
535
+ it('calls searchBy callback', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() {
536
+ var mockedFn, _render3, getByLabelText, getByText;
537
+
538
+ return regeneratorRuntime.wrap(function _callee16$(_context16) {
539
+ while (1) {
540
+ switch (_context16.prev = _context16.next) {
541
+ case 0:
542
+ mockedFn = jest.fn();
543
+ _render3 = render(_react.default.createElement(_.default, {
544
+ searchByOptions: searchByOptions,
545
+ searchByLabel: "Search By",
546
+ searchByName: "search-by",
547
+ onSearchByChange: mockedFn,
548
+ value: "Searched value",
549
+ onChange: onChangeMock,
550
+ onSearch: onSearchMock
551
+ })), getByLabelText = _render3.getByLabelText, getByText = _render3.getByText;
552
+ expect(getByLabelText('Search By')).toBeInTheDocument();
553
+
554
+ _react2.fireEvent.click(getByLabelText('Search By'));
555
+
556
+ searchByOptions.forEach(function (_ref19) {
557
+ var label = _ref19.label;
558
+ expect(getByText(label)).toBeInTheDocument();
559
+ });
560
+
561
+ _react2.fireEvent.click(getByText(searchByOptions[0].label));
562
+
563
+ expect(mockedFn).toHaveBeenCalledWith(searchByOptions[0].label);
564
+
565
+ case 7:
566
+ case "end":
567
+ return _context16.stop();
568
+ }
569
+ }
570
+ }, _callee16);
571
+ })));
572
+ describe('small', function () {
573
+ it('does not renders label', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() {
574
+ var _render4, queryByText;
575
+
576
+ return regeneratorRuntime.wrap(function _callee17$(_context17) {
577
+ while (1) {
578
+ switch (_context17.prev = _context17.next) {
579
+ case 0:
580
+ _render4 = render(_react.default.createElement(_.default, {
581
+ searchByOptions: searchByOptions,
582
+ searchByLabel: "Search By",
583
+ searchByName: "search-by",
584
+ value: "Searched value",
585
+ onChange: onChangeMock,
586
+ onSearch: onSearchMock,
587
+ size: "small"
588
+ })), queryByText = _render4.queryByText;
589
+ expect(queryByText('Search By')).not.toBeVisible();
590
+
591
+ case 2:
592
+ case "end":
593
+ return _context17.stop();
594
+ }
595
+ }
596
+ }, _callee17);
597
+ })));
598
+ });
599
+ describe('warning message', function () {
600
+ it('renders warning message', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() {
601
+ var _render5, getByLabelText, getByText;
602
+
603
+ return regeneratorRuntime.wrap(function _callee18$(_context18) {
604
+ while (1) {
605
+ switch (_context18.prev = _context18.next) {
606
+ case 0:
607
+ _render5 = render(_react.default.createElement(_.default, {
608
+ searchByOptions: searchByOptions,
609
+ searchByLabel: "Search By",
610
+ searchByName: "search-by",
611
+ value: "Searched value",
612
+ onChange: onChangeMock,
613
+ onSearch: onSearchMock,
614
+ warningMessage: "warning message"
615
+ })), getByLabelText = _render5.getByLabelText, getByText = _render5.getByText;
616
+ expect(getByLabelText('Search By')).toBeInTheDocument();
617
+ expect(getByText('warning message')).toBeInTheDocument();
618
+
619
+ case 3:
620
+ case "end":
621
+ return _context18.stop();
622
+ }
623
+ }
624
+ }, _callee18);
625
+ })));
626
+ });
627
+ describe('help message', function () {
628
+ it('renders warning message', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
629
+ var _render6, getByLabelText, getByText;
630
+
631
+ return regeneratorRuntime.wrap(function _callee19$(_context19) {
632
+ while (1) {
633
+ switch (_context19.prev = _context19.next) {
634
+ case 0:
635
+ _render6 = render(_react.default.createElement(_.default, {
636
+ searchByOptions: searchByOptions,
637
+ searchByLabel: "Search By",
638
+ searchByName: "search-by",
639
+ value: "Searched value",
640
+ onChange: onChangeMock,
641
+ onSearch: onSearchMock,
642
+ warningMessage: "warning message",
643
+ helpMessage: "help message",
644
+ searchByDefaultValue: "Value 1",
645
+ searchByWidth: "100px"
646
+ })), getByLabelText = _render6.getByLabelText, getByText = _render6.getByText;
647
+ expect(getByLabelText('Search By')).toBeInTheDocument();
648
+ expect(getByText('warning message')).toBeInTheDocument();
649
+ expect(getByText('help message')).toBeInTheDocument();
650
+
651
+ case 4:
652
+ case "end":
653
+ return _context19.stop();
654
+ }
655
+ }
656
+ }, _callee19);
657
+ })));
658
+ });
659
+ });
477
660
  });
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/SearchInput/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAA2C,CAAC;AAsCxD,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/SearchInput/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAA2C,CAAC;AAwExD,eAAe,MAAM,CAAC"}
@@ -19,7 +19,18 @@ schema.propTypes = {
19
19
  searchDisabled: _reactDesc.PropTypes.bool.description('Boolean indicating whether only the search button is disabled.'),
20
20
  value: _reactDesc.PropTypes.string.description('A text value to be displayed on the input field'),
21
21
  onSearch: _reactDesc.PropTypes.func.description('A callback that is invoked with the input value when the the search action is performed'),
22
- onChange: _reactDesc.PropTypes.func.description('A callback that is invoked when the value of the search field changes')
22
+ onChange: _reactDesc.PropTypes.func.description('A callback that is invoked when the value of the search field changes'),
23
+ searchByValue: _reactDesc.PropTypes.string.description('The ID of the option that is selected in the search by field. If provided, controlling the search by field must be handled externally.'),
24
+ searchByLabel: _reactDesc.PropTypes.string.description('Label for the search by field'),
25
+ searchByName: _reactDesc.PropTypes.string.description('Name for the search by field'),
26
+ onSearchByChange: _reactDesc.PropTypes.func.description('A callback that is invoked when the value of the search by field changes'),
27
+ searchByOptions: _reactDesc.PropTypes.arrayOf(_reactDesc.PropTypes.shape({
28
+ id: _reactDesc.PropTypes.string.description('The id for an option in the search by list.'),
29
+ label: _reactDesc.PropTypes.string.description('The label text for an option in the search by list.'),
30
+ value: _reactDesc.PropTypes.string.description('The value for an option in the search by list.')
31
+ })).description('The array of data for the options that will be rendered in the search by field'),
32
+ searchByDefaultValue: _reactDesc.PropTypes.string.description('The ID of the option that should be selected by default in the search by field.'),
33
+ searchByWidth: _reactDesc.PropTypes.string.description('A pass-through CSS value for the search by field width attribute.')
23
34
  };
24
35
  var _default = schema;
25
36
  exports.default = _default;