@stokr/components-library 2.3.65-beta.1 → 2.3.65-beta.10

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 (49) hide show
  1. package/dist/components/2FA/main-flow.js +28 -7
  2. package/dist/components/2FA/main-flow.stories.js +144 -15
  3. package/dist/components/AdminDashboard/Table/ReactTable.js +123 -7
  4. package/dist/components/AdminDashboard/Table/ReactTable.stories.js +509 -2
  5. package/dist/components/Chips/Chip.js +1 -2
  6. package/dist/components/Icon/Icon.stories.js +108 -0
  7. package/dist/components/Input/Input.js +33 -33
  8. package/dist/components/Input/Input.stories.js +83 -8
  9. package/dist/components/Input/MultiSelect.js +319 -0
  10. package/dist/components/Input/MultiSelect.stories.js +264 -0
  11. package/dist/components/Input/SearchInput.js +78 -0
  12. package/dist/components/Input/SearchInput.stories.js +366 -0
  13. package/dist/components/Input/SearchInput.styles.js +25 -0
  14. package/dist/components/Input/Select.js +51 -28
  15. package/dist/components/Input/Select.stories.js +345 -6
  16. package/dist/components/Modal/SideModal.js +82 -0
  17. package/dist/components/Modal/SideModal.stories.js +342 -0
  18. package/dist/components/Modal/SideModal.styles.js +21 -0
  19. package/dist/components/Payment/PaymentDetailsCard.js +189 -0
  20. package/dist/components/Payment/PaymentDetailsCard.stories.js +198 -0
  21. package/dist/components/Payment/PaymentDisplay.js +2 -12
  22. package/dist/components/ProfileBox/ProfileBox.js +2 -1
  23. package/dist/components/Snackbar/Snackbar.js +193 -0
  24. package/dist/components/Snackbar/Snackbar.stories.js +292 -0
  25. package/dist/components/Snackbar/Snackbar.styles.js +97 -0
  26. package/dist/components/Snackbar/SnackbarProvider.js +81 -0
  27. package/dist/components/Snackbar/index.js +32 -0
  28. package/dist/components/Snackbar/useSnackbar.js +43 -0
  29. package/dist/components/StatusTag/StatusTag.js +175 -0
  30. package/dist/components/StatusTag/StatusTag.stories.js +262 -0
  31. package/dist/components/StatusTag/StatusTag.styles.js +37 -0
  32. package/dist/components/StepsProgress/StepIndicator.js +59 -0
  33. package/dist/components/StepsProgress/StepIndicator.stories.js +153 -0
  34. package/dist/components/StepsProgress/StepIndicator.styles.js +30 -0
  35. package/dist/components/TextLink/TextLink.stories.js +35 -0
  36. package/dist/components/TextLink/TextLink.styles.js +1 -1
  37. package/dist/components/Timeline/TimelineStep.js +2 -2
  38. package/dist/components/logo/Logo.stories.js +260 -0
  39. package/dist/constants/globalVariables.js +41 -2
  40. package/dist/context/Checkbox/CheckboxContext.js +0 -1
  41. package/dist/index.js +66 -0
  42. package/dist/static/images/bmn2-logo.svg +9 -0
  43. package/dist/static/images/document-icon.svg +3 -0
  44. package/dist/static/images/plus-icon.svg +4 -0
  45. package/dist/static/images/search-icon.svg +3 -0
  46. package/dist/static/images/sent-icon.svg +10 -0
  47. package/dist/static/images/transfer-icon.svg +10 -0
  48. package/dist/utils/formatCurrencyValue.js +43 -3
  49. package/package.json +1 -1
@@ -7,65 +7,64 @@ exports.default = exports.Input = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _Input = require("./Input.styles");
10
+ const _excluded = ["type", "id", "name", "label", "placeholder", "value", "error", "touched", "readOnly", "inverted", "dashboard", "disabled", "inputWrapStyle", "wrapperStyle", "autoHeightLabel", "onChange", "onBlur", "onFocus"];
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
12
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
13
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
14
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
15
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
16
  const Input = props => {
14
17
  const {
15
- type,
16
- id,
17
- name,
18
- label,
19
- placeholder,
20
- value,
21
- error,
22
- touched,
23
- readOnly,
24
- inverted,
25
- dashboard,
26
- disabled,
27
- inputWrapStyle,
28
- wrapperStyle,
29
- autoHeightLabel
30
- } = props;
18
+ type,
19
+ id,
20
+ name,
21
+ label,
22
+ placeholder,
23
+ value,
24
+ error,
25
+ touched,
26
+ readOnly,
27
+ inverted,
28
+ dashboard,
29
+ disabled,
30
+ inputWrapStyle,
31
+ wrapperStyle,
32
+ autoHeightLabel,
33
+ // Destructure these so they don't get spread to the input
34
+ onChange: onChangeProp,
35
+ onBlur: onBlurProp,
36
+ onFocus: onFocusProp
37
+ } = props,
38
+ restProps = _objectWithoutProperties(props, _excluded);
31
39
  const [labelUp, setLabelUp] = (0, _react.useState)(false);
32
40
  const [hasFocus, setHasFocus] = (0, _react.useState)(false);
33
41
  (0, _react.useEffect)(() => {
34
42
  checkLabel(false);
35
43
  }, []);
36
44
  (0, _react.useEffect)(() => {
37
- checkLabel(false);
38
- }, [hasFocus, value]);
45
+ if (!!value && !labelUp) {
46
+ checkLabel(false);
47
+ }
48
+ }, [labelUp, value]);
39
49
  (0, _react.useEffect)(() => {
40
50
  if (value && !labelUp) setLabelUp(true);
41
51
  }, [value, labelUp]);
42
52
  const onBlur = (e, field) => {
43
- const {
44
- onBlur
45
- } = props;
46
-
47
53
  // formik handler MUST be called before our logic !
48
- onBlur && onBlur(e, field);
54
+ onBlurProp && onBlurProp(e, field);
49
55
 
50
56
  // our logic follows
51
57
  checkLabel(false);
52
58
  };
53
59
  const onFocus = (e, field) => {
54
- const {
55
- onFocus
56
- } = props;
57
-
58
60
  // formik handler MUST be called before our logic !
59
- onFocus && onFocus(e, field);
61
+ onFocusProp && onFocusProp(e, field);
60
62
 
61
63
  // our logic follows
62
64
  checkLabel(true);
63
65
  };
64
66
  const onChange = (e, field) => {
65
- const {
66
- onChange
67
- } = props;
68
- onChange && onChange(e, field); // formik handler
67
+ onChangeProp && onChangeProp(e, field); // formik handler
69
68
  };
70
69
  const checkLabel = focus => {
71
70
  setHasFocus(focus);
@@ -96,11 +95,12 @@ const Input = props => {
96
95
  onFocus: onFocus,
97
96
  readOnly: readOnly,
98
97
  placeholder: placeholder,
98
+ disabled: disabled,
99
99
  style: {
100
100
  WebkitAppearance: 'none',
101
101
  WebkitBorderRadius: 0
102
102
  }
103
- }, props))));
103
+ }, restProps))));
104
104
  };
105
105
  exports.Input = Input;
106
106
  Input.propTypes = {
@@ -3,16 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.InputLabeled = exports.InputFilled = exports.InputFillInverted = exports.InputEmpty = void 0;
6
+ exports.default = exports.InputLabeled = exports.InputFilled = exports.InputFillInverted = exports.InputEmpty = exports.AllStates = void 0;
7
7
  var _viewport = require("storybook/viewport");
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
  var _Input = require("./Input");
10
10
  var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
11
11
  var _global = _interopRequireDefault(require("../../styles/global"));
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
13
15
  var _default = exports.default = {
14
16
  title: 'Components Library/Inputs/Input',
15
17
  component: _Input.Input,
18
+ decorators: [Story => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(Story, null)))],
16
19
  argTypes: {
17
20
  type: {
18
21
  type: 'string'
@@ -79,8 +82,19 @@ var _default = exports.default = {
79
82
  defaultViewport: 'resetviewport'
80
83
  }
81
84
  }
85
+ }; // Controlled wrapper for interactive stories
86
+ const ControlledInput = props => {
87
+ const [value, setValue] = (0, _react.useState)(props.value || '');
88
+ return /*#__PURE__*/_react.default.createElement(_Input.Input, _extends({}, props, {
89
+ value: value,
90
+ onChange: e => {
91
+ var _props$onChange;
92
+ setValue(e.target.value);
93
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, e);
94
+ }
95
+ }));
82
96
  };
83
- const Template = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_Input.Input, args)));
97
+ const Template = args => /*#__PURE__*/_react.default.createElement(ControlledInput, args);
84
98
 
85
99
  //trying to integrate state:
86
100
  // const Template = args => {
@@ -135,8 +149,69 @@ InputEmpty.parameters = {
135
149
  }
136
150
  };
137
151
 
138
- //doublecheck:
139
-
140
- // state?
141
- // make error true version?
142
- // why can I not fill in the input in storybook on page? not important?
152
+ // All states example
153
+ const AllStates = () => {
154
+ const [value1, setValue1] = (0, _react.useState)('');
155
+ const [value2, setValue2] = (0, _react.useState)('Filled value');
156
+ const [value3, setValue3] = (0, _react.useState)('');
157
+ const [value4, setValue4] = (0, _react.useState)('Error text');
158
+ return /*#__PURE__*/_react.default.createElement("div", {
159
+ style: {
160
+ display: 'flex',
161
+ flexDirection: 'column',
162
+ gap: '32px'
163
+ }
164
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
165
+ style: {
166
+ marginBottom: '8px',
167
+ fontSize: '12px',
168
+ color: '#666'
169
+ }
170
+ }, "Empty - Click to see blue label on focus"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
171
+ id: "empty",
172
+ name: "empty",
173
+ label: "Empty Input",
174
+ value: value1,
175
+ onChange: e => setValue1(e.target.value)
176
+ })), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
177
+ style: {
178
+ marginBottom: '8px',
179
+ fontSize: '12px',
180
+ color: '#666'
181
+ }
182
+ }, "With value"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
183
+ id: "filled",
184
+ name: "filled",
185
+ label: "Filled Input",
186
+ value: value2,
187
+ onChange: e => setValue2(e.target.value)
188
+ })), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
189
+ style: {
190
+ marginBottom: '8px',
191
+ fontSize: '12px',
192
+ color: '#666'
193
+ }
194
+ }, "Disabled"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
195
+ id: "disabled",
196
+ name: "disabled",
197
+ label: "Disabled Input",
198
+ value: "Cannot edit",
199
+ disabled: true,
200
+ onChange: () => {}
201
+ })), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
202
+ style: {
203
+ marginBottom: '8px',
204
+ fontSize: '12px',
205
+ color: '#666'
206
+ }
207
+ }, "Error state"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
208
+ id: "error",
209
+ name: "error",
210
+ label: "Error Input",
211
+ value: value4,
212
+ onChange: e => setValue4(e.target.value),
213
+ error: true,
214
+ touched: true
215
+ })));
216
+ };
217
+ exports.AllStates = AllStates;
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.MultiSelect = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _reactSelect = _interopRequireWildcard(require("react-select"));
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+ var _Input = require("./Input.styles");
12
+ var _colors = _interopRequireDefault(require("../../styles/colors"));
13
+ var _checkIcon = require("../../static/images/check-icon.svg");
14
+ var _Select = require("./Select.styles");
15
+ const _excluded = ["children", "selectProps"],
16
+ _excluded2 = ["id", "name", "label", "options", "search", "error", "touched", "value", "disabled", "menuHeight", "placeholder", "showCheckboxes", "showCountBadge", "closeMenuOnSelect", "hideSelectedOptions", "width", "minMenuWidth", "maxMenuWidth"];
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
19
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
25
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
26
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
27
+ const CountBadge = _styledComponents.default.span.withConfig({
28
+ displayName: "MultiSelect__CountBadge",
29
+ componentId: "sc-1udb3q8-0"
30
+ })(["display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 6px;background-color:", ";color:", ";border-radius:10px;font-size:12px;font-weight:600;margin-left:8px;"], _colors.default.black, _colors.default.white);
31
+ const CheckboxWrapper = _styledComponents.default.div.withConfig({
32
+ displayName: "MultiSelect__CheckboxWrapper",
33
+ componentId: "sc-1udb3q8-1"
34
+ })(["display:flex;align-items:center;padding:16px 12px;cursor:pointer;transition:background-color 0.15s ease;&:hover{background-color:", ";}"], _colors.default.grey);
35
+ const Checkbox = _styledComponents.default.div.withConfig({
36
+ displayName: "MultiSelect__Checkbox",
37
+ componentId: "sc-1udb3q8-2"
38
+ })(["width:14px;height:14px;border:1px solid ", ";border-radius:3px;margin-right:12px;display:flex;align-items:center;justify-content:center;background-color:", ";transition:all 0.15s ease;flex-shrink:0;svg{opacity:", ";transition:opacity 0.15s ease;width:8px;height:8px;}svg path{stroke:", ";}"], props => props.isSelected ? _colors.default.black : _colors.default.grey2, props => props.isSelected ? _colors.default.white : _colors.default.white, props => props.isSelected ? 1 : 0, _colors.default.blue);
39
+ const OptionLabel = _styledComponents.default.span.withConfig({
40
+ displayName: "MultiSelect__OptionLabel",
41
+ componentId: "sc-1udb3q8-3"
42
+ })(["font-size:14px;color:", ";font-weight:400;letter-spacing:0.6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0;"], _colors.default.black);
43
+ const PlaceholderText = _styledComponents.default.span.withConfig({
44
+ displayName: "MultiSelect__PlaceholderText",
45
+ componentId: "sc-1udb3q8-4"
46
+ })(["font-size:14px;color:", ";font-weight:400;"], _colors.default.black);
47
+
48
+ // Custom Option with Checkbox
49
+ const CheckboxOption = props => {
50
+ const {
51
+ isSelected,
52
+ label,
53
+ innerRef,
54
+ innerProps
55
+ } = props;
56
+ return /*#__PURE__*/_react.default.createElement(CheckboxWrapper, _extends({
57
+ ref: innerRef
58
+ }, innerProps), /*#__PURE__*/_react.default.createElement(Checkbox, {
59
+ isSelected: isSelected
60
+ }, /*#__PURE__*/_react.default.createElement(_checkIcon.ReactComponent, null)), /*#__PURE__*/_react.default.createElement(OptionLabel, null, label));
61
+ };
62
+
63
+ // Custom ValueContainer that shows count badge
64
+ const CountValueContainer = _ref => {
65
+ let {
66
+ children,
67
+ selectProps
68
+ } = _ref,
69
+ props = _objectWithoutProperties(_ref, _excluded);
70
+ const {
71
+ value,
72
+ placeholder
73
+ } = selectProps;
74
+ const count = (value === null || value === void 0 ? void 0 : value.length) || 0;
75
+ return /*#__PURE__*/_react.default.createElement(_reactSelect.components.ValueContainer, _extends({}, props, {
76
+ selectProps: selectProps
77
+ }), /*#__PURE__*/_react.default.createElement("div", {
78
+ style: {
79
+ display: 'flex',
80
+ alignItems: 'center'
81
+ }
82
+ }, /*#__PURE__*/_react.default.createElement(PlaceholderText, null, placeholder), count > 0 && /*#__PURE__*/_react.default.createElement(CountBadge, null, count)), children);
83
+ };
84
+ const DropdownIndicator = props => {
85
+ const {
86
+ selectProps
87
+ } = props;
88
+ return /*#__PURE__*/_react.default.createElement(_reactSelect.components.DropdownIndicator, props, /*#__PURE__*/_react.default.createElement(_Select.SelectIcon, {
89
+ isMenuOpen: selectProps.menuIsOpen
90
+ }));
91
+ };
92
+ DropdownIndicator.propTypes = {
93
+ selectProps: _propTypes.default.instanceOf(Object).isRequired
94
+ };
95
+ const SelectMenuListWithScroll = props => {
96
+ const {
97
+ children,
98
+ selectProps
99
+ } = props;
100
+ const {
101
+ maxMenuHeight = 300
102
+ } = selectProps;
103
+ return /*#__PURE__*/_react.default.createElement(_Select.SelectMenuList, {
104
+ autoHeight: true,
105
+ autoHeightMax: maxMenuHeight,
106
+ fullHeight: true
107
+ }, children);
108
+ };
109
+ SelectMenuListWithScroll.propTypes = {
110
+ children: _propTypes.default.node.isRequired
111
+ };
112
+ const MultiSelect = props => {
113
+ const {
114
+ id,
115
+ name,
116
+ label,
117
+ options,
118
+ search,
119
+ error,
120
+ touched,
121
+ value,
122
+ disabled,
123
+ menuHeight,
124
+ placeholder,
125
+ showCheckboxes = true,
126
+ showCountBadge = true,
127
+ closeMenuOnSelect = false,
128
+ hideSelectedOptions = false,
129
+ width,
130
+ minMenuWidth = 150,
131
+ maxMenuWidth = 300
132
+ } = props,
133
+ otherProps = _objectWithoutProperties(props, _excluded2);
134
+ const hasValue = (value === null || value === void 0 ? void 0 : value.length) > 0;
135
+ const [labelUp, setLabelUp] = (0, _react.useState)(hasValue);
136
+ const [hasFocus, setHasFocus] = (0, _react.useState)(false);
137
+ (0, _react.useEffect)(() => {
138
+ const currentHasValue = (value === null || value === void 0 ? void 0 : value.length) > 0;
139
+ setLabelUp(hasFocus || currentHasValue);
140
+ }, [hasFocus, value]);
141
+ const onFocus = () => {
142
+ props.onFocus && props.onFocus({
143
+ name,
144
+ value
145
+ });
146
+ setHasFocus(true);
147
+ };
148
+ const onBlur = () => {
149
+ props.onBlur && props.onBlur({
150
+ name,
151
+ value
152
+ });
153
+ setTimeout(() => {
154
+ setHasFocus(false);
155
+ }, 1);
156
+ };
157
+ const onChange = selectedOptions => {
158
+ const newValue = selectedOptions ? selectedOptions.map(opt => opt.value) : [];
159
+ props.onChange && props.onChange({
160
+ name,
161
+ value: newValue
162
+ });
163
+ setTimeout(() => {
164
+ setHasFocus(true);
165
+ }, 1);
166
+ };
167
+
168
+ // Get selected options from value array
169
+ const selectedOptions = options === null || options === void 0 ? void 0 : options.filter(option => value === null || value === void 0 ? void 0 : value.includes(option.value));
170
+ return /*#__PURE__*/_react.default.createElement(_Input.Wrapper, {
171
+ style: {
172
+ width: width || 'auto'
173
+ }
174
+ }, label && /*#__PURE__*/_react.default.createElement(_Input.Label, {
175
+ isUp: labelUp,
176
+ active: hasFocus,
177
+ error: error && touched,
178
+ htmlFor: id
179
+ }, label), /*#__PURE__*/_react.default.createElement(_reactSelect.default, _extends({}, otherProps, {
180
+ id: id,
181
+ name: name,
182
+ options: options,
183
+ isDisabled: disabled,
184
+ onChange: onChange,
185
+ onBlur: onBlur,
186
+ onFocus: onFocus,
187
+ value: selectedOptions,
188
+ placeholder: placeholder,
189
+ isSearchable: search,
190
+ isMulti: true,
191
+ openMenuOnFocus: true,
192
+ closeMenuOnSelect: closeMenuOnSelect,
193
+ hideSelectedOptions: hideSelectedOptions,
194
+ maxMenuHeight: menuHeight,
195
+ styles: {
196
+ control: (baseStyle, state) => _objectSpread(_objectSpread({}, baseStyle), {}, {
197
+ display: 'flex',
198
+ alignItems: 'center',
199
+ // minHeight: '44px',
200
+ padding: '0 10px',
201
+ backgroundColor: _colors.default.white,
202
+ border: "1px solid ".concat(state.isFocused ? _colors.default.grey2 : _colors.default.lightGrey),
203
+ borderRadius: '10px',
204
+ boxShadow: 'none',
205
+ cursor: 'pointer',
206
+ '&:hover': {
207
+ borderColor: _colors.default.grey2
208
+ }
209
+ }),
210
+ menu: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
211
+ marginTop: '4px',
212
+ zIndex: 1000,
213
+ borderRadius: '8px',
214
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
215
+ border: "1px solid ".concat(_colors.default.lightGrey),
216
+ overflow: 'hidden',
217
+ minWidth: minMenuWidth,
218
+ maxWidth: maxMenuWidth,
219
+ width: 'auto'
220
+ }),
221
+ menuList: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
222
+ padding: 0
223
+ }),
224
+ option: (baseStyle, state) => _objectSpread(_objectSpread({}, baseStyle), {}, {
225
+ // When using checkboxes, padding is handled by CheckboxOption
226
+ // Otherwise, add padding for the default option
227
+ padding: showCheckboxes ? 0 : '12px 16px',
228
+ backgroundColor: state.isFocused ? _colors.default.grey : 'transparent',
229
+ color: _colors.default.black,
230
+ cursor: 'pointer',
231
+ fontWeight: state.isSelected ? 600 : 400,
232
+ whiteSpace: 'nowrap',
233
+ overflow: 'hidden',
234
+ textOverflow: 'ellipsis',
235
+ '&:active': {
236
+ backgroundColor: _colors.default.grey
237
+ }
238
+ }),
239
+ valueContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
240
+ padding: 0,
241
+ display: 'flex',
242
+ alignItems: 'center'
243
+ }),
244
+ placeholder: () => ({
245
+ display: 'none' // We handle placeholder in ValueContainer
246
+ }),
247
+ multiValue: () => ({
248
+ display: showCountBadge ? 'none' : 'flex' // Hide tags when showing count
249
+ }),
250
+ input: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
251
+ margin: 0,
252
+ padding: 0
253
+ }),
254
+ indicatorsContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
255
+ padding: 0,
256
+ gap: '4px'
257
+ }),
258
+ dropdownIndicator: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
259
+ padding: '4px'
260
+ }),
261
+ clearIndicator: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
262
+ padding: '4px'
263
+ // display: 'none',
264
+ })
265
+ },
266
+ components: {
267
+ DropdownIndicator,
268
+ IndicatorSeparator: null,
269
+ MenuList: SelectMenuListWithScroll,
270
+ Option: showCheckboxes ? CheckboxOption : _reactSelect.components.Option,
271
+ ValueContainer: showCountBadge ? CountValueContainer : _reactSelect.components.ValueContainer
272
+ }
273
+ })));
274
+ };
275
+ exports.MultiSelect = MultiSelect;
276
+ MultiSelect.propTypes = {
277
+ id: _propTypes.default.string.isRequired,
278
+ name: _propTypes.default.string.isRequired,
279
+ label: _propTypes.default.string,
280
+ error: _propTypes.default.bool,
281
+ touched: _propTypes.default.bool,
282
+ value: _propTypes.default.arrayOf(_propTypes.default.string),
283
+ options: _propTypes.default.arrayOf(_propTypes.default.shape({
284
+ key: _propTypes.default.string.isRequired,
285
+ value: _propTypes.default.string.isRequired,
286
+ label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired
287
+ })).isRequired,
288
+ search: _propTypes.default.bool,
289
+ placeholder: _propTypes.default.string,
290
+ onChange: _propTypes.default.func,
291
+ onBlur: _propTypes.default.func,
292
+ onFocus: _propTypes.default.func,
293
+ showCheckboxes: _propTypes.default.bool,
294
+ showCountBadge: _propTypes.default.bool,
295
+ closeMenuOnSelect: _propTypes.default.bool,
296
+ hideSelectedOptions: _propTypes.default.bool,
297
+ width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
298
+ minMenuWidth: _propTypes.default.number,
299
+ maxMenuWidth: _propTypes.default.number
300
+ };
301
+ MultiSelect.defaultProps = {
302
+ label: '',
303
+ value: [],
304
+ search: false,
305
+ error: false,
306
+ touched: false,
307
+ placeholder: 'Select',
308
+ onChange: () => {},
309
+ onBlur: () => {},
310
+ onFocus: () => {},
311
+ showCheckboxes: true,
312
+ showCountBadge: true,
313
+ closeMenuOnSelect: false,
314
+ hideSelectedOptions: false,
315
+ width: undefined,
316
+ minMenuWidth: 150,
317
+ maxMenuWidth: 300
318
+ };
319
+ var _default = exports.default = MultiSelect;