@stokr/components-library 2.3.65-beta.4 → 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.
@@ -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,188 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+ var _colors = _interopRequireDefault(require("../../styles/colors"));
10
+ var _InfoIcon = require("../InfoIcon/InfoIcon");
11
+ var _formatCurrencyValue = require("../../utils/formatCurrencyValue");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ const CardContainer = _styledComponents.default.div.withConfig({
14
+ displayName: "PaymentDetailsCard__CardContainer",
15
+ componentId: "sc-e830fo-0"
16
+ })(["background:", ";border-radius:15px;border:1px solid ", ";padding:20px 32px;"], _colors.default.white, _colors.default.lightGrey);
17
+ const CardTitle = _styledComponents.default.div.withConfig({
18
+ displayName: "PaymentDetailsCard__CardTitle",
19
+ componentId: "sc-e830fo-1"
20
+ })(["font-size:16px;font-weight:600;margin-bottom:20px;color:", ";"], _colors.default.black);
21
+ const AmountSection = _styledComponents.default.div.withConfig({
22
+ displayName: "PaymentDetailsCard__AmountSection",
23
+ componentId: "sc-e830fo-2"
24
+ })([""]);
25
+ const AmountLabel = _styledComponents.default.div.withConfig({
26
+ displayName: "PaymentDetailsCard__AmountLabel",
27
+ componentId: "sc-e830fo-3"
28
+ })(["font-size:14px;font-weight:300;line-height:20px;letter-spacing:0.08px;margin-bottom:12px;color:", ";"], _colors.default.grey2);
29
+ const AmountDisplay = _styledComponents.default.div.withConfig({
30
+ displayName: "PaymentDetailsCard__AmountDisplay",
31
+ componentId: "sc-e830fo-4"
32
+ })(["display:flex;align-items:center;gap:16px;"]);
33
+ const CurrencyLogo = _styledComponents.default.div.withConfig({
34
+ displayName: "PaymentDetailsCard__CurrencyLogo",
35
+ componentId: "sc-e830fo-5"
36
+ })(["width:32px;height:32px;border-radius:50%;background-color:", ";display:flex;align-items:center;justify-content:center;flex-shrink:0;color:", ";font-size:14px;font-weight:600;overflow:hidden;"], props => props.color || _colors.default.black, _colors.default.white);
37
+ const CurrencyIcon = _styledComponents.default.img.withConfig({
38
+ displayName: "PaymentDetailsCard__CurrencyIcon",
39
+ componentId: "sc-e830fo-6"
40
+ })(["width:100%;height:100%;object-fit:contain;"]);
41
+ const AmountValue = _styledComponents.default.div.withConfig({
42
+ displayName: "PaymentDetailsCard__AmountValue",
43
+ componentId: "sc-e830fo-7"
44
+ })(["font-size:34px;font-weight:800;text-transform:uppercase;line-height:40px;letter-spacing:1.5px;word-wrap:break-word;"]);
45
+ const Separator = _styledComponents.default.hr.withConfig({
46
+ displayName: "PaymentDetailsCard__Separator",
47
+ componentId: "sc-e830fo-8"
48
+ })(["border:none;border-top:1px solid ", ";margin:20px -32px;"], _colors.default.lightGrey);
49
+ const DetailsSection = _styledComponents.default.div.withConfig({
50
+ displayName: "PaymentDetailsCard__DetailsSection",
51
+ componentId: "sc-e830fo-9"
52
+ })(["margin-bottom:", ";"], props => props.noMargin ? '0' : '24px');
53
+ const DetailRow = _styledComponents.default.div.withConfig({
54
+ displayName: "PaymentDetailsCard__DetailRow",
55
+ componentId: "sc-e830fo-10"
56
+ })(["display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:12px;&:last-child{margin-bottom:0;}"]);
57
+ const DetailLabel = _styledComponents.default.div.withConfig({
58
+ displayName: "PaymentDetailsCard__DetailLabel",
59
+ componentId: "sc-e830fo-11"
60
+ })(["display:flex;align-items:center;gap:10px;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0.1px;"]);
61
+ const DetailValue = _styledComponents.default.div.withConfig({
62
+ displayName: "PaymentDetailsCard__DetailValue",
63
+ componentId: "sc-e830fo-12"
64
+ })(["font-size:16px;font-weight:700;line-height:24px;letter-spacing:0.1px;word-wrap:break-word;text-align:right;max-width:60%;color:", ";"], _colors.default.black);
65
+ const PlaceholderValue = _styledComponents.default.span.withConfig({
66
+ displayName: "PaymentDetailsCard__PlaceholderValue",
67
+ componentId: "sc-e830fo-13"
68
+ })(["color:", ";font-weight:400;"], _colors.default.grey2);
69
+ const InfoSectionContainer = _styledComponents.default.div.withConfig({
70
+ displayName: "PaymentDetailsCard__InfoSectionContainer",
71
+ componentId: "sc-e830fo-14"
72
+ })(["margin-top:24px;"]);
73
+
74
+ /**
75
+ * Renders a single detail row
76
+ */
77
+ const DetailItem = _ref => {
78
+ let {
79
+ label,
80
+ value,
81
+ tooltip,
82
+ placeholder,
83
+ isCustom
84
+ } = _ref;
85
+ // If value is a custom component (React element), render it directly
86
+ const renderValue = () => {
87
+ if (isCustom && value) {
88
+ return value;
89
+ }
90
+ if (value !== undefined && value !== null && value !== '') {
91
+ return value;
92
+ }
93
+ if (placeholder) {
94
+ return /*#__PURE__*/_react.default.createElement(PlaceholderValue, null, placeholder);
95
+ }
96
+ return /*#__PURE__*/_react.default.createElement(PlaceholderValue, null, "-");
97
+ };
98
+ return /*#__PURE__*/_react.default.createElement(DetailRow, null, /*#__PURE__*/_react.default.createElement(DetailLabel, null, label, tooltip && /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
99
+ containerStyle: {
100
+ width: 14,
101
+ height: 14
102
+ },
103
+ title: tooltip,
104
+ noMargin: true
105
+ })), /*#__PURE__*/_react.default.createElement(DetailValue, null, renderValue()));
106
+ };
107
+
108
+ /**
109
+ * PaymentDetailsCard - Fully customizable details card
110
+ *
111
+ * @param {string} title - Optional card title
112
+ * @param {object|node} amountSection - Amount section config or custom node
113
+ * - If object: { label, amount, currency, currencyColor, icon }
114
+ * - If node: renders custom component
115
+ * @param {array} details - Array of detail items
116
+ * - { label, value (string|node), tooltip, placeholder, isCustom }
117
+ * @param {node} infoSection - Optional custom node for bottom info section
118
+ * @param {boolean} showSeparators - Whether to show separators between sections
119
+ */
120
+ const PaymentDetailsCard = _ref2 => {
121
+ let {
122
+ title,
123
+ amountSection,
124
+ details,
125
+ infoSection,
126
+ showSeparators = true
127
+ } = _ref2;
128
+ // Render amount section
129
+ const renderAmountSection = () => {
130
+ if (!amountSection) return null;
131
+
132
+ // If it's a React element, render it directly
133
+ if (/*#__PURE__*/_react.default.isValidElement(amountSection)) {
134
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, amountSection, showSeparators && /*#__PURE__*/_react.default.createElement(Separator, null));
135
+ }
136
+
137
+ // Otherwise, render the default amount layout
138
+ const {
139
+ label = 'Amount',
140
+ amount,
141
+ currency,
142
+ currencyColor,
143
+ icon
144
+ } = amountSection;
145
+ const displayAmount = (0, _formatCurrencyValue.formatCurrencyValue)(currency, amount, 2, {
146
+ valueFirst: true
147
+ });
148
+ const currencyIcon = (0, _formatCurrencyValue.getCurrencyIcon)(currency, icon);
149
+ const logoColor = currencyColor || _colors.default.black;
150
+ const renderCurrencyLogo = () => {
151
+ if (currencyIcon) {
152
+ return /*#__PURE__*/_react.default.createElement(CurrencyLogo, {
153
+ color: 'transparent'
154
+ }, /*#__PURE__*/_react.default.createElement(CurrencyIcon, {
155
+ src: currencyIcon,
156
+ alt: currency || 'currency'
157
+ }));
158
+ }
159
+ return /*#__PURE__*/_react.default.createElement(CurrencyLogo, {
160
+ color: logoColor
161
+ }, currency ? currency.charAt(0).toUpperCase() : '?');
162
+ };
163
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(AmountSection, null, /*#__PURE__*/_react.default.createElement(AmountLabel, null, label), /*#__PURE__*/_react.default.createElement(AmountDisplay, null, renderCurrencyLogo(), /*#__PURE__*/_react.default.createElement(AmountValue, null, displayAmount))), showSeparators && /*#__PURE__*/_react.default.createElement(Separator, null));
164
+ };
165
+
166
+ // Render details section
167
+ const renderDetailsSection = () => {
168
+ if (!details || details.length === 0) return null;
169
+ return /*#__PURE__*/_react.default.createElement(DetailsSection, {
170
+ noMargin: !infoSection
171
+ }, details.map((detail, index) => /*#__PURE__*/_react.default.createElement(DetailItem, {
172
+ key: detail.key || index,
173
+ label: detail.label,
174
+ value: detail.value,
175
+ tooltip: detail.tooltip,
176
+ placeholder: detail.placeholder,
177
+ isCustom: detail.isCustom
178
+ })));
179
+ };
180
+
181
+ // Render info section
182
+ const renderInfoSection = () => {
183
+ if (!infoSection) return null;
184
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showSeparators && /*#__PURE__*/_react.default.createElement(Separator, null), /*#__PURE__*/_react.default.createElement(InfoSectionContainer, null, infoSection));
185
+ };
186
+ return /*#__PURE__*/_react.default.createElement(CardContainer, null, title && /*#__PURE__*/_react.default.createElement(CardTitle, null, title), renderAmountSection(), renderDetailsSection(), renderInfoSection());
187
+ };
188
+ var _default = exports.default = PaymentDetailsCard;