@stokr/components-library 2.3.65-beta.3 → 2.3.65-beta.5
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 +187 -0
- package/dist/components/Input/MultiSelect.stories.js +141 -0
- package/dist/components/Modal/SideModal.js +82 -0
- package/dist/components/Modal/SideModal.stories.js +342 -0
- package/dist/components/Modal/SideModal.styles.js +21 -0
- package/dist/components/Payment/PaymentDetailsCard.js +188 -0
- package/dist/components/Payment/PaymentDetailsCard.stories.js +198 -0
- package/dist/components/StatusTag/StatusTag.js +175 -0
- package/dist/components/StatusTag/StatusTag.stories.js +262 -0
- package/dist/components/StatusTag/StatusTag.styles.js +37 -0
- package/dist/components/TextLink/TextLink.stories.js +25 -0
- package/dist/index.js +33 -0
- package/dist/static/images/bmn2-logo.svg +9 -0
- package/dist/static/images/document-icon.svg +3 -0
- package/dist/static/images/plus-icon.svg +4 -0
- package/dist/static/images/sent-icon.svg +10 -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,187 @@
|
|
|
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 _Input = require("./Input.styles");
|
|
11
|
+
var _Select = require("./Select.styles");
|
|
12
|
+
const _excluded = ["id", "name", "label", "options", "search", "error", "touched", "value", "disabled", "menuHeight", "placeholder"];
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
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); }
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
20
|
+
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); }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
const DropdownIndicator = props => {
|
|
24
|
+
const {
|
|
25
|
+
selectProps
|
|
26
|
+
} = props;
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_reactSelect.components.DropdownIndicator, props, /*#__PURE__*/_react.default.createElement(_Select.SelectIcon, {
|
|
28
|
+
isMenuOpen: selectProps.menuIsOpen
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
DropdownIndicator.propTypes = {
|
|
32
|
+
selectProps: _propTypes.default.instanceOf(Object).isRequired
|
|
33
|
+
};
|
|
34
|
+
const SelectMenuListWithScroll = props => {
|
|
35
|
+
const {
|
|
36
|
+
children,
|
|
37
|
+
selectProps
|
|
38
|
+
} = props;
|
|
39
|
+
const {
|
|
40
|
+
maxMenuHeight = 300
|
|
41
|
+
} = selectProps;
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_Select.SelectMenuList, {
|
|
43
|
+
autoHeight: true,
|
|
44
|
+
autoHeightMax: maxMenuHeight,
|
|
45
|
+
fullHeight: true
|
|
46
|
+
}, children);
|
|
47
|
+
};
|
|
48
|
+
SelectMenuListWithScroll.propTypes = {
|
|
49
|
+
children: _propTypes.default.node.isRequired
|
|
50
|
+
};
|
|
51
|
+
const MultiSelect = props => {
|
|
52
|
+
const {
|
|
53
|
+
id,
|
|
54
|
+
name,
|
|
55
|
+
label,
|
|
56
|
+
options,
|
|
57
|
+
search,
|
|
58
|
+
error,
|
|
59
|
+
touched,
|
|
60
|
+
value,
|
|
61
|
+
disabled,
|
|
62
|
+
menuHeight,
|
|
63
|
+
placeholder
|
|
64
|
+
} = props,
|
|
65
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
66
|
+
const hasValue = (value === null || value === void 0 ? void 0 : value.length) > 0;
|
|
67
|
+
const [labelUp, setLabelUp] = (0, _react.useState)(hasValue);
|
|
68
|
+
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
69
|
+
(0, _react.useEffect)(() => {
|
|
70
|
+
const currentHasValue = (value === null || value === void 0 ? void 0 : value.length) > 0;
|
|
71
|
+
setLabelUp(hasFocus || currentHasValue);
|
|
72
|
+
}, [hasFocus, value]);
|
|
73
|
+
const onFocus = () => {
|
|
74
|
+
props.onFocus && props.onFocus({
|
|
75
|
+
name,
|
|
76
|
+
value
|
|
77
|
+
});
|
|
78
|
+
setHasFocus(true);
|
|
79
|
+
};
|
|
80
|
+
const onBlur = () => {
|
|
81
|
+
props.onBlur && props.onBlur({
|
|
82
|
+
name,
|
|
83
|
+
value
|
|
84
|
+
});
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
setHasFocus(false);
|
|
87
|
+
}, 1);
|
|
88
|
+
};
|
|
89
|
+
const onChange = selectedOptions => {
|
|
90
|
+
const newValue = selectedOptions ? selectedOptions.map(opt => opt.value) : [];
|
|
91
|
+
props.onChange && props.onChange({
|
|
92
|
+
name,
|
|
93
|
+
value: newValue
|
|
94
|
+
});
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
setHasFocus(true);
|
|
97
|
+
}, 1);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Get selected options from value array
|
|
101
|
+
const selectedOptions = options === null || options === void 0 ? void 0 : options.filter(option => value === null || value === void 0 ? void 0 : value.includes(option.value));
|
|
102
|
+
return /*#__PURE__*/_react.default.createElement(_Input.Wrapper, null, label && /*#__PURE__*/_react.default.createElement(_Input.Label, {
|
|
103
|
+
isUp: labelUp,
|
|
104
|
+
active: hasFocus,
|
|
105
|
+
error: error && touched,
|
|
106
|
+
htmlFor: id
|
|
107
|
+
}, label), /*#__PURE__*/_react.default.createElement(_reactSelect.default, _extends({}, otherProps, {
|
|
108
|
+
id: id,
|
|
109
|
+
name: name,
|
|
110
|
+
options: options,
|
|
111
|
+
isDisabled: disabled,
|
|
112
|
+
onChange: onChange,
|
|
113
|
+
onBlur: onBlur,
|
|
114
|
+
onFocus: onFocus,
|
|
115
|
+
value: selectedOptions,
|
|
116
|
+
placeholder: placeholder,
|
|
117
|
+
isSearchable: search,
|
|
118
|
+
isMulti: true,
|
|
119
|
+
maxMenuHeight: menuHeight,
|
|
120
|
+
styles: {
|
|
121
|
+
control: () => _Select.SelectControl,
|
|
122
|
+
menu: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
123
|
+
marginTop: 0,
|
|
124
|
+
zIndex: 1000,
|
|
125
|
+
SelectMenu: _Select.SelectMenu
|
|
126
|
+
}),
|
|
127
|
+
option: (baseStyle, state) => _objectSpread({
|
|
128
|
+
fontWeight: state.isSelected || state.isFocused ? 'bold' : 'normal',
|
|
129
|
+
cursor: 'pointer'
|
|
130
|
+
}, _Select.SelectOption),
|
|
131
|
+
selectContainer: () => _Select.SelectContainer,
|
|
132
|
+
valueContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
133
|
+
padding: 0
|
|
134
|
+
}),
|
|
135
|
+
multiValue: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
136
|
+
backgroundColor: '#f0f0f0',
|
|
137
|
+
borderRadius: '4px'
|
|
138
|
+
}),
|
|
139
|
+
multiValueLabel: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
140
|
+
fontSize: '14px',
|
|
141
|
+
padding: '2px 6px'
|
|
142
|
+
}),
|
|
143
|
+
multiValueRemove: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
144
|
+
cursor: 'pointer',
|
|
145
|
+
':hover': {
|
|
146
|
+
backgroundColor: '#e0e0e0'
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
},
|
|
150
|
+
components: {
|
|
151
|
+
DropdownIndicator,
|
|
152
|
+
IndicatorSeparator: null,
|
|
153
|
+
MenuList: SelectMenuListWithScroll
|
|
154
|
+
}
|
|
155
|
+
})));
|
|
156
|
+
};
|
|
157
|
+
exports.MultiSelect = MultiSelect;
|
|
158
|
+
MultiSelect.propTypes = {
|
|
159
|
+
id: _propTypes.default.string.isRequired,
|
|
160
|
+
name: _propTypes.default.string.isRequired,
|
|
161
|
+
label: _propTypes.default.string,
|
|
162
|
+
error: _propTypes.default.bool,
|
|
163
|
+
touched: _propTypes.default.bool,
|
|
164
|
+
value: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
165
|
+
options: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
166
|
+
key: _propTypes.default.string.isRequired,
|
|
167
|
+
value: _propTypes.default.string.isRequired,
|
|
168
|
+
label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired
|
|
169
|
+
})).isRequired,
|
|
170
|
+
search: _propTypes.default.bool,
|
|
171
|
+
placeholder: _propTypes.default.string,
|
|
172
|
+
onChange: _propTypes.default.func,
|
|
173
|
+
onBlur: _propTypes.default.func,
|
|
174
|
+
onFocus: _propTypes.default.func
|
|
175
|
+
};
|
|
176
|
+
MultiSelect.defaultProps = {
|
|
177
|
+
label: '',
|
|
178
|
+
value: [],
|
|
179
|
+
search: true,
|
|
180
|
+
error: false,
|
|
181
|
+
touched: false,
|
|
182
|
+
placeholder: '',
|
|
183
|
+
onChange: () => {},
|
|
184
|
+
onBlur: () => {},
|
|
185
|
+
onFocus: () => {}
|
|
186
|
+
};
|
|
187
|
+
var _default = exports.default = MultiSelect;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithPreselectedValues = exports.WithPlaceholder = exports.WithManyOptions = 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
|
+
var _default = exports.default = {
|
|
20
|
+
title: 'Components Library/Inputs/MultiSelect',
|
|
21
|
+
component: _MultiSelect.MultiSelect,
|
|
22
|
+
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))))]
|
|
23
|
+
};
|
|
24
|
+
const countryOptions = [{
|
|
25
|
+
key: 'us',
|
|
26
|
+
value: 'us',
|
|
27
|
+
label: 'United States'
|
|
28
|
+
}, {
|
|
29
|
+
key: 'uk',
|
|
30
|
+
value: 'uk',
|
|
31
|
+
label: 'United Kingdom'
|
|
32
|
+
}, {
|
|
33
|
+
key: 'de',
|
|
34
|
+
value: 'de',
|
|
35
|
+
label: 'Germany'
|
|
36
|
+
}, {
|
|
37
|
+
key: 'fr',
|
|
38
|
+
value: 'fr',
|
|
39
|
+
label: 'France'
|
|
40
|
+
}, {
|
|
41
|
+
key: 'es',
|
|
42
|
+
value: 'es',
|
|
43
|
+
label: 'Spain'
|
|
44
|
+
}, {
|
|
45
|
+
key: 'it',
|
|
46
|
+
value: 'it',
|
|
47
|
+
label: 'Italy'
|
|
48
|
+
}, {
|
|
49
|
+
key: 'nl',
|
|
50
|
+
value: 'nl',
|
|
51
|
+
label: 'Netherlands'
|
|
52
|
+
}, {
|
|
53
|
+
key: 'ch',
|
|
54
|
+
value: 'ch',
|
|
55
|
+
label: 'Switzerland'
|
|
56
|
+
}];
|
|
57
|
+
const tagOptions = [{
|
|
58
|
+
key: 'tech',
|
|
59
|
+
value: 'tech',
|
|
60
|
+
label: 'Technology'
|
|
61
|
+
}, {
|
|
62
|
+
key: 'finance',
|
|
63
|
+
value: 'finance',
|
|
64
|
+
label: 'Finance'
|
|
65
|
+
}, {
|
|
66
|
+
key: 'health',
|
|
67
|
+
value: 'health',
|
|
68
|
+
label: 'Healthcare'
|
|
69
|
+
}, {
|
|
70
|
+
key: 'education',
|
|
71
|
+
value: 'education',
|
|
72
|
+
label: 'Education'
|
|
73
|
+
}, {
|
|
74
|
+
key: 'retail',
|
|
75
|
+
value: 'retail',
|
|
76
|
+
label: 'Retail'
|
|
77
|
+
}];
|
|
78
|
+
|
|
79
|
+
// Controlled wrapper for interactive stories
|
|
80
|
+
const ControlledMultiSelect = props => {
|
|
81
|
+
const [value, setValue] = (0, _react.useState)(props.value || []);
|
|
82
|
+
const handleChange = _ref => {
|
|
83
|
+
let {
|
|
84
|
+
value: newValue
|
|
85
|
+
} = _ref;
|
|
86
|
+
setValue(newValue);
|
|
87
|
+
console.log('Selected values:', newValue);
|
|
88
|
+
};
|
|
89
|
+
return /*#__PURE__*/_react.default.createElement(_MultiSelect.MultiSelect, _extends({}, props, {
|
|
90
|
+
value: value,
|
|
91
|
+
onChange: handleChange
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
const Default = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
95
|
+
id: "countries",
|
|
96
|
+
name: "countries",
|
|
97
|
+
label: "Select Countries",
|
|
98
|
+
options: countryOptions
|
|
99
|
+
});
|
|
100
|
+
exports.Default = Default;
|
|
101
|
+
const WithPreselectedValues = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
102
|
+
id: "countries",
|
|
103
|
+
name: "countries",
|
|
104
|
+
label: "Select Countries",
|
|
105
|
+
options: countryOptions,
|
|
106
|
+
value: ['us', 'de']
|
|
107
|
+
});
|
|
108
|
+
exports.WithPreselectedValues = WithPreselectedValues;
|
|
109
|
+
const WithPlaceholder = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
110
|
+
id: "tags",
|
|
111
|
+
name: "tags",
|
|
112
|
+
options: tagOptions,
|
|
113
|
+
placeholder: "Choose tags..."
|
|
114
|
+
});
|
|
115
|
+
exports.WithPlaceholder = WithPlaceholder;
|
|
116
|
+
const Disabled = () => /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
117
|
+
id: "countries",
|
|
118
|
+
name: "countries",
|
|
119
|
+
label: "Select Countries",
|
|
120
|
+
options: countryOptions,
|
|
121
|
+
value: ['uk', 'fr'],
|
|
122
|
+
disabled: true
|
|
123
|
+
});
|
|
124
|
+
exports.Disabled = Disabled;
|
|
125
|
+
const WithManyOptions = () => {
|
|
126
|
+
const manyOptions = Array.from({
|
|
127
|
+
length: 50
|
|
128
|
+
}, (_, i) => ({
|
|
129
|
+
key: "option-".concat(i),
|
|
130
|
+
value: "option-".concat(i),
|
|
131
|
+
label: "Option ".concat(i + 1)
|
|
132
|
+
}));
|
|
133
|
+
return /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
134
|
+
id: "many",
|
|
135
|
+
name: "many",
|
|
136
|
+
label: "Select Multiple",
|
|
137
|
+
options: manyOptions,
|
|
138
|
+
menuHeight: 200
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
exports.WithManyOptions = WithManyOptions;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SideModal = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactDom = require("react-dom");
|
|
9
|
+
var _SideModal = require("./SideModal.styles");
|
|
10
|
+
var _Modal = require("./Modal.styles");
|
|
11
|
+
const _excluded = ["children", "isOpen", "onClose", "width", "minWidth", "className", "containerStyle", "closeOnDimmerClick", "showCloseButton"];
|
|
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); }
|
|
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; }
|
|
16
|
+
const SideModal = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
isOpen,
|
|
20
|
+
onClose,
|
|
21
|
+
width = 40,
|
|
22
|
+
minWidth = 400,
|
|
23
|
+
className,
|
|
24
|
+
containerStyle,
|
|
25
|
+
closeOnDimmerClick = true,
|
|
26
|
+
showCloseButton = true
|
|
27
|
+
} = _ref,
|
|
28
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
const [isVisible, setIsVisible] = (0, _react.useState)(false);
|
|
30
|
+
(0, _react.useEffect)(() => {
|
|
31
|
+
// Disable scroll on background when modal is open
|
|
32
|
+
if (isOpen) {
|
|
33
|
+
document.body.style.overflow = 'hidden';
|
|
34
|
+
// Small delay to trigger animation
|
|
35
|
+
setTimeout(() => setIsVisible(true), 10);
|
|
36
|
+
} else {
|
|
37
|
+
document.body.style.overflow = 'unset';
|
|
38
|
+
setIsVisible(false);
|
|
39
|
+
}
|
|
40
|
+
return () => {
|
|
41
|
+
document.body.style.overflow = 'unset';
|
|
42
|
+
};
|
|
43
|
+
}, [isOpen]);
|
|
44
|
+
|
|
45
|
+
// Handle escape key
|
|
46
|
+
(0, _react.useEffect)(() => {
|
|
47
|
+
const handleEscape = e => {
|
|
48
|
+
if (e.key === 'Escape' && isOpen) {
|
|
49
|
+
onClose();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
if (isOpen) {
|
|
53
|
+
document.addEventListener('keydown', handleEscape);
|
|
54
|
+
}
|
|
55
|
+
return () => {
|
|
56
|
+
document.removeEventListener('keydown', handleEscape);
|
|
57
|
+
};
|
|
58
|
+
}, [isOpen, onClose]);
|
|
59
|
+
const handleDimmerClick = e => {
|
|
60
|
+
if (closeOnDimmerClick && e.target === e.currentTarget) {
|
|
61
|
+
onClose();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
if (!isOpen) return null;
|
|
65
|
+
const modalContent = /*#__PURE__*/_react.default.createElement(_SideModal.SideModalRoot, _extends({
|
|
66
|
+
className: className,
|
|
67
|
+
style: containerStyle
|
|
68
|
+
}, props), /*#__PURE__*/_react.default.createElement(_SideModal.Dimmer, {
|
|
69
|
+
onClick: handleDimmerClick,
|
|
70
|
+
isVisible: isVisible
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement(_SideModal.SideModalBox, {
|
|
72
|
+
width: width,
|
|
73
|
+
minWidth: minWidth,
|
|
74
|
+
isVisible: isVisible,
|
|
75
|
+
onClick: e => e.stopPropagation()
|
|
76
|
+
}, showCloseButton && /*#__PURE__*/_react.default.createElement(_Modal.ModalClose, {
|
|
77
|
+
onClick: onClose
|
|
78
|
+
}), children)));
|
|
79
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(modalContent, document.body);
|
|
80
|
+
};
|
|
81
|
+
exports.SideModal = SideModal;
|
|
82
|
+
var _default = exports.default = SideModal;
|