@stokr/components-library 2.3.65-beta.4 → 2.3.65-beta.6
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.
- package/dist/components/Icon/Icon.stories.js +108 -0
- package/dist/components/Input/MultiSelect.js +292 -0
- package/dist/components/Input/MultiSelect.stories.js +198 -0
- package/dist/components/Payment/PaymentDetailsCard.js +189 -0
- package/dist/components/Payment/PaymentDetailsCard.stories.js +198 -0
- package/dist/components/StatusTag/StatusTag.js +11 -4
- package/dist/components/StepsProgress/StepIndicator.js +58 -0
- package/dist/components/StepsProgress/StepIndicator.stories.js +153 -0
- package/dist/components/StepsProgress/StepIndicator.styles.js +30 -0
- package/dist/components/TextLink/TextLink.stories.js +35 -0
- package/dist/components/TextLink/TextLink.styles.js +1 -1
- package/dist/index.js +33 -0
- package/dist/static/images/bmn2-logo.svg +9 -0
- package/dist/static/images/plus-icon.svg +4 -0
- package/dist/static/images/transfer-icon.svg +10 -0
- package/dist/utils/formatCurrencyValue.js +43 -3
- package/package.json +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.AllSvgIcons = exports.AllIcons = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Icon = require("./Icon.style");
|
|
9
|
+
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
var _colors = _interopRequireDefault(require("../../styles/colors"));
|
|
12
|
+
var _transferIcon = require("../../static/images/transfer-icon.svg");
|
|
13
|
+
var _plusIcon = require("../../static/images/plus-icon.svg");
|
|
14
|
+
var _documentIcon = require("../../static/images/document-icon.svg");
|
|
15
|
+
var _sentIcon = require("../../static/images/sent-icon.svg");
|
|
16
|
+
var _searchIcon = require("../../static/images/search-icon.svg");
|
|
17
|
+
var _checkIcon = require("../../static/images/check-icon.svg");
|
|
18
|
+
var _crossIcon = require("../../static/images/cross-icon.svg");
|
|
19
|
+
var _copy_icon = require("../../static/images/copy_icon.svg");
|
|
20
|
+
var _usdcLogo = require("../../static/images/usdc-logo.svg");
|
|
21
|
+
var _warningFilled = require("../../static/images/warning-filled.svg");
|
|
22
|
+
var _download_icon = require("../../static/images/download_icon.svg");
|
|
23
|
+
var _profInv = require("../../static/images/prof-inv.svg");
|
|
24
|
+
var _upload = require("../../static/images/upload.svg");
|
|
25
|
+
var _refresh = require("../../static/images/refresh.svg");
|
|
26
|
+
var _logo = require("../../static/images/logo.svg");
|
|
27
|
+
var _earlyAdopter = require("../../static/images/early-adopter.svg");
|
|
28
|
+
var _eth = require("../../static/images/eth.svg");
|
|
29
|
+
var _eur = require("../../static/images/eur.svg");
|
|
30
|
+
var _faceScanIcon = require("../../static/images/face-scan-icon.svg");
|
|
31
|
+
var _adminBadge = require("../../static/images/admin-badge.svg");
|
|
32
|
+
var _arrowDownBlack = require("../../static/images/arrow-down-black.svg");
|
|
33
|
+
var _capsLock = require("../../static/images/caps-lock.svg");
|
|
34
|
+
var _Glassess = require("../../static/images/Glassess.svg");
|
|
35
|
+
var _VerifiedBadge = require("../../static/images/VerifiedBadge.svg");
|
|
36
|
+
var _playBtn = require("../../static/images/play-btn.svg");
|
|
37
|
+
var _mangopay = require("../../static/images/mangopay.svg");
|
|
38
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
39
|
+
// SVG Icons from static/images
|
|
40
|
+
|
|
41
|
+
// Map of all SVG icons for easy iteration
|
|
42
|
+
const svgIcons = {
|
|
43
|
+
'transfer-icon': _transferIcon.ReactComponent,
|
|
44
|
+
'plus-icon': _plusIcon.ReactComponent,
|
|
45
|
+
'document-icon': _documentIcon.ReactComponent,
|
|
46
|
+
'sent-icon': _sentIcon.ReactComponent,
|
|
47
|
+
'search-icon': _searchIcon.ReactComponent,
|
|
48
|
+
'check-icon': _checkIcon.ReactComponent,
|
|
49
|
+
'cross-icon': _crossIcon.ReactComponent,
|
|
50
|
+
'copy-icon': _copy_icon.ReactComponent,
|
|
51
|
+
'usdc-logo': _usdcLogo.ReactComponent,
|
|
52
|
+
'warning-filled': _warningFilled.ReactComponent,
|
|
53
|
+
'download-icon': _download_icon.ReactComponent,
|
|
54
|
+
'prof-inv': _profInv.ReactComponent,
|
|
55
|
+
upload: _upload.ReactComponent,
|
|
56
|
+
refresh: _refresh.ReactComponent,
|
|
57
|
+
logo: _logo.ReactComponent,
|
|
58
|
+
'early-adopter': _earlyAdopter.ReactComponent,
|
|
59
|
+
eth: _eth.ReactComponent,
|
|
60
|
+
eur: _eur.ReactComponent,
|
|
61
|
+
'face-scan-icon': _faceScanIcon.ReactComponent,
|
|
62
|
+
'admin-badge': _adminBadge.ReactComponent,
|
|
63
|
+
'arrow-down-black': _arrowDownBlack.ReactComponent,
|
|
64
|
+
'caps-lock': _capsLock.ReactComponent,
|
|
65
|
+
glasses: _Glassess.ReactComponent,
|
|
66
|
+
'verified-badge': _VerifiedBadge.ReactComponent,
|
|
67
|
+
'play-btn': _playBtn.ReactComponent,
|
|
68
|
+
mangopay: _mangopay.ReactComponent
|
|
69
|
+
};
|
|
70
|
+
const IconsGrid = _styledComponents.default.div.withConfig({
|
|
71
|
+
displayName: "Iconstories__IconsGrid",
|
|
72
|
+
componentId: "sc-ue519l-0"
|
|
73
|
+
})(["display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:24px;padding:24px;"]);
|
|
74
|
+
const IconBox = _styledComponents.default.div.withConfig({
|
|
75
|
+
displayName: "Iconstories__IconBox",
|
|
76
|
+
componentId: "sc-ue519l-1"
|
|
77
|
+
})(["display:flex;flex-direction:column;align-items:center;gap:8px;padding:16px;border:1px solid ", ";border-radius:4px;background:", ";&:hover{background:", ";}"], _colors.default.lightGrey, _colors.default.white, _colors.default.lightGrey);
|
|
78
|
+
const IconName = _styledComponents.default.span.withConfig({
|
|
79
|
+
displayName: "Iconstories__IconName",
|
|
80
|
+
componentId: "sc-ue519l-2"
|
|
81
|
+
})(["font-family:'Open Sans',sans-serif;font-size:11px;color:", ";text-align:center;word-break:break-word;"], _colors.default.grey2);
|
|
82
|
+
var _default = exports.default = {
|
|
83
|
+
title: 'Components Library/Icon',
|
|
84
|
+
component: _Icon.Icon,
|
|
85
|
+
decorators: [Story => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(Story, null))]
|
|
86
|
+
};
|
|
87
|
+
const AllIcons = () => /*#__PURE__*/_react.default.createElement(IconsGrid, null, Object.entries(_Icon.iconsMap).map(_ref => {
|
|
88
|
+
let [name, iconCode] = _ref;
|
|
89
|
+
return /*#__PURE__*/_react.default.createElement(IconBox, {
|
|
90
|
+
key: name
|
|
91
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.Icon, {
|
|
92
|
+
icon: iconCode,
|
|
93
|
+
size: 24,
|
|
94
|
+
color: _colors.default.dark
|
|
95
|
+
}), /*#__PURE__*/_react.default.createElement(IconName, null, name));
|
|
96
|
+
}));
|
|
97
|
+
exports.AllIcons = AllIcons;
|
|
98
|
+
const SvgIconWrapper = _styledComponents.default.div.withConfig({
|
|
99
|
+
displayName: "Iconstories__SvgIconWrapper",
|
|
100
|
+
componentId: "sc-ue519l-3"
|
|
101
|
+
})(["width:32px;height:32px;display:flex;align-items:center;justify-content:center;svg{max-width:100%;max-height:100%;}"]);
|
|
102
|
+
const AllSvgIcons = () => /*#__PURE__*/_react.default.createElement(IconsGrid, null, Object.entries(svgIcons).map(_ref2 => {
|
|
103
|
+
let [name, SvgComponent] = _ref2;
|
|
104
|
+
return /*#__PURE__*/_react.default.createElement(IconBox, {
|
|
105
|
+
key: name
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement(SvgIconWrapper, null, /*#__PURE__*/_react.default.createElement(SvgComponent, null)), /*#__PURE__*/_react.default.createElement(IconName, null, name));
|
|
107
|
+
}));
|
|
108
|
+
exports.AllSvgIcons = AllSvgIcons;
|
|
@@ -0,0 +1,292 @@
|
|
|
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"];
|
|
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;"], _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
|
+
} = props,
|
|
130
|
+
otherProps = _objectWithoutProperties(props, _excluded2);
|
|
131
|
+
const hasValue = (value === null || value === void 0 ? void 0 : value.length) > 0;
|
|
132
|
+
const [labelUp, setLabelUp] = (0, _react.useState)(hasValue);
|
|
133
|
+
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
134
|
+
(0, _react.useEffect)(() => {
|
|
135
|
+
const currentHasValue = (value === null || value === void 0 ? void 0 : value.length) > 0;
|
|
136
|
+
setLabelUp(hasFocus || currentHasValue);
|
|
137
|
+
}, [hasFocus, value]);
|
|
138
|
+
const onFocus = () => {
|
|
139
|
+
props.onFocus && props.onFocus({
|
|
140
|
+
name,
|
|
141
|
+
value
|
|
142
|
+
});
|
|
143
|
+
setHasFocus(true);
|
|
144
|
+
};
|
|
145
|
+
const onBlur = () => {
|
|
146
|
+
props.onBlur && props.onBlur({
|
|
147
|
+
name,
|
|
148
|
+
value
|
|
149
|
+
});
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
setHasFocus(false);
|
|
152
|
+
}, 1);
|
|
153
|
+
};
|
|
154
|
+
const onChange = selectedOptions => {
|
|
155
|
+
const newValue = selectedOptions ? selectedOptions.map(opt => opt.value) : [];
|
|
156
|
+
props.onChange && props.onChange({
|
|
157
|
+
name,
|
|
158
|
+
value: newValue
|
|
159
|
+
});
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
setHasFocus(true);
|
|
162
|
+
}, 1);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Get selected options from value array
|
|
166
|
+
const selectedOptions = options === null || options === void 0 ? void 0 : options.filter(option => value === null || value === void 0 ? void 0 : value.includes(option.value));
|
|
167
|
+
return /*#__PURE__*/_react.default.createElement(_Input.Wrapper, null, label && /*#__PURE__*/_react.default.createElement(_Input.Label, {
|
|
168
|
+
isUp: labelUp,
|
|
169
|
+
active: hasFocus,
|
|
170
|
+
error: error && touched,
|
|
171
|
+
htmlFor: id
|
|
172
|
+
}, label), /*#__PURE__*/_react.default.createElement(_reactSelect.default, _extends({}, otherProps, {
|
|
173
|
+
id: id,
|
|
174
|
+
name: name,
|
|
175
|
+
options: options,
|
|
176
|
+
isDisabled: disabled,
|
|
177
|
+
onChange: onChange,
|
|
178
|
+
onBlur: onBlur,
|
|
179
|
+
onFocus: onFocus,
|
|
180
|
+
value: selectedOptions,
|
|
181
|
+
placeholder: placeholder,
|
|
182
|
+
isSearchable: search,
|
|
183
|
+
isMulti: true,
|
|
184
|
+
openMenuOnFocus: true,
|
|
185
|
+
closeMenuOnSelect: closeMenuOnSelect,
|
|
186
|
+
hideSelectedOptions: hideSelectedOptions,
|
|
187
|
+
maxMenuHeight: menuHeight,
|
|
188
|
+
styles: {
|
|
189
|
+
control: (baseStyle, state) => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
190
|
+
display: 'flex',
|
|
191
|
+
alignItems: 'center',
|
|
192
|
+
// minHeight: '44px',
|
|
193
|
+
padding: '0 10px',
|
|
194
|
+
backgroundColor: _colors.default.white,
|
|
195
|
+
border: "1px solid ".concat(state.isFocused ? _colors.default.grey2 : _colors.default.lightGrey),
|
|
196
|
+
borderRadius: '10px',
|
|
197
|
+
boxShadow: 'none',
|
|
198
|
+
cursor: 'pointer',
|
|
199
|
+
'&:hover': {
|
|
200
|
+
borderColor: _colors.default.grey2
|
|
201
|
+
}
|
|
202
|
+
}),
|
|
203
|
+
menu: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
204
|
+
marginTop: '4px',
|
|
205
|
+
zIndex: 1000,
|
|
206
|
+
borderRadius: '8px',
|
|
207
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
208
|
+
border: "1px solid ".concat(_colors.default.lightGrey),
|
|
209
|
+
overflow: 'hidden'
|
|
210
|
+
}),
|
|
211
|
+
menuList: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
212
|
+
padding: 0
|
|
213
|
+
}),
|
|
214
|
+
option: (baseStyle, state) => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
215
|
+
// When using checkboxes, padding is handled by CheckboxOption
|
|
216
|
+
// Otherwise, add padding for the default option
|
|
217
|
+
padding: showCheckboxes ? 0 : '12px 16px',
|
|
218
|
+
backgroundColor: state.isFocused ? _colors.default.grey : 'transparent',
|
|
219
|
+
color: _colors.default.black,
|
|
220
|
+
cursor: 'pointer',
|
|
221
|
+
fontWeight: state.isSelected ? 600 : 400,
|
|
222
|
+
'&:active': {
|
|
223
|
+
backgroundColor: _colors.default.grey
|
|
224
|
+
}
|
|
225
|
+
}),
|
|
226
|
+
valueContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
227
|
+
padding: 0,
|
|
228
|
+
display: 'flex',
|
|
229
|
+
alignItems: 'center'
|
|
230
|
+
}),
|
|
231
|
+
placeholder: () => ({
|
|
232
|
+
display: 'none' // We handle placeholder in ValueContainer
|
|
233
|
+
}),
|
|
234
|
+
multiValue: () => ({
|
|
235
|
+
display: showCountBadge ? 'none' : 'flex' // Hide tags when showing count
|
|
236
|
+
}),
|
|
237
|
+
input: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
238
|
+
margin: 0,
|
|
239
|
+
padding: 0
|
|
240
|
+
}),
|
|
241
|
+
indicatorsContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
242
|
+
paddingLeft: '8px'
|
|
243
|
+
})
|
|
244
|
+
},
|
|
245
|
+
components: {
|
|
246
|
+
DropdownIndicator,
|
|
247
|
+
IndicatorSeparator: null,
|
|
248
|
+
MenuList: SelectMenuListWithScroll,
|
|
249
|
+
Option: showCheckboxes ? CheckboxOption : _reactSelect.components.Option,
|
|
250
|
+
ValueContainer: showCountBadge ? CountValueContainer : _reactSelect.components.ValueContainer
|
|
251
|
+
}
|
|
252
|
+
})));
|
|
253
|
+
};
|
|
254
|
+
exports.MultiSelect = MultiSelect;
|
|
255
|
+
MultiSelect.propTypes = {
|
|
256
|
+
id: _propTypes.default.string.isRequired,
|
|
257
|
+
name: _propTypes.default.string.isRequired,
|
|
258
|
+
label: _propTypes.default.string,
|
|
259
|
+
error: _propTypes.default.bool,
|
|
260
|
+
touched: _propTypes.default.bool,
|
|
261
|
+
value: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
262
|
+
options: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
263
|
+
key: _propTypes.default.string.isRequired,
|
|
264
|
+
value: _propTypes.default.string.isRequired,
|
|
265
|
+
label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired
|
|
266
|
+
})).isRequired,
|
|
267
|
+
search: _propTypes.default.bool,
|
|
268
|
+
placeholder: _propTypes.default.string,
|
|
269
|
+
onChange: _propTypes.default.func,
|
|
270
|
+
onBlur: _propTypes.default.func,
|
|
271
|
+
onFocus: _propTypes.default.func,
|
|
272
|
+
showCheckboxes: _propTypes.default.bool,
|
|
273
|
+
showCountBadge: _propTypes.default.bool,
|
|
274
|
+
closeMenuOnSelect: _propTypes.default.bool,
|
|
275
|
+
hideSelectedOptions: _propTypes.default.bool
|
|
276
|
+
};
|
|
277
|
+
MultiSelect.defaultProps = {
|
|
278
|
+
label: '',
|
|
279
|
+
value: [],
|
|
280
|
+
search: false,
|
|
281
|
+
error: false,
|
|
282
|
+
touched: false,
|
|
283
|
+
placeholder: 'Select',
|
|
284
|
+
onChange: () => {},
|
|
285
|
+
onBlur: () => {},
|
|
286
|
+
onFocus: () => {},
|
|
287
|
+
showCheckboxes: true,
|
|
288
|
+
showCountBadge: true,
|
|
289
|
+
closeMenuOnSelect: false,
|
|
290
|
+
hideSelectedOptions: false
|
|
291
|
+
};
|
|
292
|
+
var _default = exports.default = MultiSelect;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithoutCheckboxes = exports.WithPreselectedValues = exports.WithManyOptions = exports.MultipleFilters = exports.Disabled = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _MultiSelect = require("./MultiSelect");
|
|
9
|
+
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
10
|
+
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
11
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
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); }
|
|
15
|
+
const StoryContainer = _styledComponents.default.div.withConfig({
|
|
16
|
+
displayName: "MultiSelectstories__StoryContainer",
|
|
17
|
+
componentId: "sc-1vk8pre-0"
|
|
18
|
+
})(["max-width:400px;padding:40px 20px;"]);
|
|
19
|
+
const FiltersRow = _styledComponents.default.div.withConfig({
|
|
20
|
+
displayName: "MultiSelectstories__FiltersRow",
|
|
21
|
+
componentId: "sc-1vk8pre-1"
|
|
22
|
+
})(["display:flex;gap:12px;flex-wrap:wrap;"]);
|
|
23
|
+
var _default = exports.default = {
|
|
24
|
+
title: 'Components Library/Inputs/MultiSelect',
|
|
25
|
+
component: _MultiSelect.MultiSelect,
|
|
26
|
+
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(StoryContainer, null, /*#__PURE__*/_react.default.createElement(Story, null))))]
|
|
27
|
+
};
|
|
28
|
+
const statusOptions = [{
|
|
29
|
+
key: 'initiated',
|
|
30
|
+
value: 'initiated',
|
|
31
|
+
label: 'Initiated'
|
|
32
|
+
}, {
|
|
33
|
+
key: 'declined',
|
|
34
|
+
value: 'declined',
|
|
35
|
+
label: 'Declined'
|
|
36
|
+
}, {
|
|
37
|
+
key: 'confirmed',
|
|
38
|
+
value: 'confirmed',
|
|
39
|
+
label: 'Confirmed'
|
|
40
|
+
}, {
|
|
41
|
+
key: 'transferred',
|
|
42
|
+
value: 'transferred',
|
|
43
|
+
label: 'Transferred'
|
|
44
|
+
}];
|
|
45
|
+
const typeOptions = [{
|
|
46
|
+
key: 'dividend',
|
|
47
|
+
value: 'dividend',
|
|
48
|
+
label: 'Dividend'
|
|
49
|
+
}, {
|
|
50
|
+
key: 'interest',
|
|
51
|
+
value: 'interest',
|
|
52
|
+
label: 'Interest'
|
|
53
|
+
}, {
|
|
54
|
+
key: 'redemption',
|
|
55
|
+
value: 'redemption',
|
|
56
|
+
label: 'Redemption'
|
|
57
|
+
}];
|
|
58
|
+
const countryOptions = [{
|
|
59
|
+
key: 'us',
|
|
60
|
+
value: 'us',
|
|
61
|
+
label: 'United States'
|
|
62
|
+
}, {
|
|
63
|
+
key: 'uk',
|
|
64
|
+
value: 'uk',
|
|
65
|
+
label: 'United Kingdom'
|
|
66
|
+
}, {
|
|
67
|
+
key: 'de',
|
|
68
|
+
value: 'de',
|
|
69
|
+
label: 'Germany'
|
|
70
|
+
}, {
|
|
71
|
+
key: 'fr',
|
|
72
|
+
value: 'fr',
|
|
73
|
+
label: 'France'
|
|
74
|
+
}, {
|
|
75
|
+
key: 'es',
|
|
76
|
+
value: 'es',
|
|
77
|
+
label: 'Spain'
|
|
78
|
+
}, {
|
|
79
|
+
key: 'it',
|
|
80
|
+
value: 'it',
|
|
81
|
+
label: 'Italy'
|
|
82
|
+
}];
|
|
83
|
+
|
|
84
|
+
// Controlled wrapper for interactive stories
|
|
85
|
+
const ControlledMultiSelect = props => {
|
|
86
|
+
const [value, setValue] = (0, _react.useState)(props.value || []);
|
|
87
|
+
const handleChange = _ref => {
|
|
88
|
+
let {
|
|
89
|
+
value: newValue
|
|
90
|
+
} = _ref;
|
|
91
|
+
setValue(newValue);
|
|
92
|
+
console.log('Selected values:', newValue);
|
|
93
|
+
};
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement(_MultiSelect.MultiSelect, _extends({}, props, {
|
|
95
|
+
value: value,
|
|
96
|
+
onChange: handleChange
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Default - Status filter like in the design
|
|
101
|
+
const Default = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
102
|
+
id: "status",
|
|
103
|
+
name: "status",
|
|
104
|
+
placeholder: "Status",
|
|
105
|
+
options: statusOptions
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// With preselected values showing count badge
|
|
109
|
+
exports.Default = Default;
|
|
110
|
+
const WithPreselectedValues = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
111
|
+
id: "status",
|
|
112
|
+
name: "status",
|
|
113
|
+
placeholder: "Status",
|
|
114
|
+
options: statusOptions,
|
|
115
|
+
value: ['initiated', 'confirmed']
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Multiple filters side by side (like in the screenshot)
|
|
119
|
+
exports.WithPreselectedValues = WithPreselectedValues;
|
|
120
|
+
const MultipleFilters = () => {
|
|
121
|
+
const [statusValue, setStatusValue] = (0, _react.useState)(['initiated']);
|
|
122
|
+
const [typeValue, setTypeValue] = (0, _react.useState)([]);
|
|
123
|
+
return /*#__PURE__*/_react.default.createElement(FiltersRow, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
124
|
+
style: {
|
|
125
|
+
width: '140px'
|
|
126
|
+
}
|
|
127
|
+
}, /*#__PURE__*/_react.default.createElement(_MultiSelect.MultiSelect, {
|
|
128
|
+
id: "status",
|
|
129
|
+
name: "status",
|
|
130
|
+
placeholder: "Status",
|
|
131
|
+
options: statusOptions,
|
|
132
|
+
value: statusValue,
|
|
133
|
+
onChange: _ref2 => {
|
|
134
|
+
let {
|
|
135
|
+
value
|
|
136
|
+
} = _ref2;
|
|
137
|
+
return setStatusValue(value);
|
|
138
|
+
}
|
|
139
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
140
|
+
style: {
|
|
141
|
+
width: '120px'
|
|
142
|
+
}
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement(_MultiSelect.MultiSelect, {
|
|
144
|
+
id: "type",
|
|
145
|
+
name: "type",
|
|
146
|
+
placeholder: "Type",
|
|
147
|
+
options: typeOptions,
|
|
148
|
+
value: typeValue,
|
|
149
|
+
onChange: _ref3 => {
|
|
150
|
+
let {
|
|
151
|
+
value
|
|
152
|
+
} = _ref3;
|
|
153
|
+
return setTypeValue(value);
|
|
154
|
+
}
|
|
155
|
+
})));
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Without checkboxes (classic multi-select style)
|
|
159
|
+
exports.MultipleFilters = MultipleFilters;
|
|
160
|
+
const WithoutCheckboxes = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
161
|
+
id: "countries",
|
|
162
|
+
name: "countries",
|
|
163
|
+
placeholder: "Countries",
|
|
164
|
+
options: countryOptions,
|
|
165
|
+
showCheckboxes: false,
|
|
166
|
+
showCountBadge: false
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// With many options
|
|
170
|
+
exports.WithoutCheckboxes = WithoutCheckboxes;
|
|
171
|
+
const WithManyOptions = () => {
|
|
172
|
+
const manyOptions = Array.from({
|
|
173
|
+
length: 20
|
|
174
|
+
}, (_, i) => ({
|
|
175
|
+
key: "option-".concat(i),
|
|
176
|
+
value: "option-".concat(i),
|
|
177
|
+
label: "Option ".concat(i + 1)
|
|
178
|
+
}));
|
|
179
|
+
return /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
180
|
+
id: "many",
|
|
181
|
+
name: "many",
|
|
182
|
+
placeholder: "Select",
|
|
183
|
+
options: manyOptions,
|
|
184
|
+
menuHeight: 250
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Disabled state
|
|
189
|
+
exports.WithManyOptions = WithManyOptions;
|
|
190
|
+
const Disabled = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
191
|
+
id: "status",
|
|
192
|
+
name: "status",
|
|
193
|
+
placeholder: "Status",
|
|
194
|
+
options: statusOptions,
|
|
195
|
+
value: ['initiated'],
|
|
196
|
+
disabled: true
|
|
197
|
+
});
|
|
198
|
+
exports.Disabled = Disabled;
|