@stokr/components-library 2.3.65-beta.13 → 2.3.65-beta.14

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,231 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.confirm = exports.ConfirmModal = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _client = require("react-dom/client");
9
+ var _Modal = require("../Modal/Modal");
10
+ var _Grid = require("../Grid/Grid.styles");
11
+ var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
12
+ var _Button = require("../Button/Button.styles");
13
+ var _Text = require("../Text/Text.styles");
14
+ var _ConfirmModal = require("./ConfirmModal.styles");
15
+ 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); }
16
+ 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); }
17
+ // Container for the modal - created once
18
+ let confirmContainer = null;
19
+ let confirmRoot = null;
20
+
21
+ /**
22
+ * Internal ConfirmModal component
23
+ */
24
+ const ConfirmModalComponent = _ref => {
25
+ let {
26
+ isOpen,
27
+ onClose,
28
+ onConfirm,
29
+ onCancel,
30
+ title,
31
+ message,
32
+ content,
33
+ confirmText,
34
+ cancelText,
35
+ showCancel,
36
+ showRedBar,
37
+ lineColor,
38
+ barColor,
39
+ renderFooter,
40
+ modalProps,
41
+ buttonProps,
42
+ cancelButtonProps
43
+ } = _ref;
44
+ const titleRef = (0, _react.useRef)(null);
45
+ const [titleHeight, setTitleHeight] = (0, _react.useState)(0);
46
+
47
+ // ResizeObserver for title height (for the blue line)
48
+ (0, _react.useEffect)(() => {
49
+ if (!titleRef.current) return;
50
+ const resizeObserver = new ResizeObserver(entries => {
51
+ for (const entry of entries) {
52
+ const height = entry.contentRect.height;
53
+ setTitleHeight(height);
54
+ }
55
+ });
56
+ resizeObserver.observe(titleRef.current);
57
+ return () => resizeObserver.disconnect();
58
+ }, []);
59
+ const handleConfirm = (0, _react.useCallback)(function () {
60
+ let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
61
+ onConfirm === null || onConfirm === void 0 || onConfirm(value);
62
+ onClose === null || onClose === void 0 || onClose();
63
+ }, [onConfirm, onClose]);
64
+ const handleCancel = (0, _react.useCallback)(() => {
65
+ onCancel === null || onCancel === void 0 || onCancel();
66
+ onClose === null || onClose === void 0 || onClose();
67
+ }, [onCancel, onClose]);
68
+
69
+ // Handle Escape key
70
+ (0, _react.useEffect)(() => {
71
+ if (!isOpen) return;
72
+ const handleKeyDown = e => {
73
+ if (e.key === 'Escape') {
74
+ handleCancel();
75
+ }
76
+ };
77
+ document.addEventListener('keydown', handleKeyDown);
78
+ return () => document.removeEventListener('keydown', handleKeyDown);
79
+ }, [isOpen, handleCancel]);
80
+ return /*#__PURE__*/_react.default.createElement(_Modal.Modal, _extends({
81
+ isOpen: isOpen,
82
+ onClose: handleCancel,
83
+ maxHeight: "90vh",
84
+ boxStyles: {
85
+ minHeight: 'unset'
86
+ }
87
+ // maxWidth="1500px"
88
+ }, modalProps), /*#__PURE__*/_react.default.createElement(_Grid.Row, null, /*#__PURE__*/_react.default.createElement(_Grid.Column, {
89
+ relative: true,
90
+ part: 14
91
+ }, /*#__PURE__*/_react.default.createElement(_Modal.ModalInner, null, /*#__PURE__*/_react.default.createElement(_ConfirmModal.ContainerWithLine, {
92
+ height: titleHeight,
93
+ lineColor: lineColor
94
+ }, /*#__PURE__*/_react.default.createElement(_Text.Text, null, /*#__PURE__*/_react.default.createElement("div", null, title && /*#__PURE__*/_react.default.createElement("h3", {
95
+ ref: titleRef,
96
+ style: {
97
+ margin: 0
98
+ }
99
+ }, title), message && /*#__PURE__*/_react.default.createElement("p", null, message)), content && /*#__PURE__*/_react.default.createElement("div", {
100
+ style: {
101
+ marginTop: '16px'
102
+ }
103
+ }, content)), renderFooter ? /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, renderFooter({
104
+ onConfirm: handleConfirm,
105
+ onCancel: handleCancel
106
+ })) : /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, {
107
+ noPaddingHorizontal: true,
108
+ flex: true,
109
+ style: {
110
+ gap: 16
111
+ }
112
+ }, showCancel && /*#__PURE__*/_react.default.createElement(_Button.Button, _extends({
113
+ outlineBlack: true,
114
+ minWidth: "120px",
115
+ onClick: handleCancel
116
+ }, cancelButtonProps), cancelText), /*#__PURE__*/_react.default.createElement(_Button.Button, _extends({
117
+ minWidth: "120px",
118
+ onClick: () => handleConfirm(true)
119
+ }, buttonProps), confirmText))))), showRedBar && /*#__PURE__*/_react.default.createElement(_ConfirmModal.RedBar, {
120
+ barColor: barColor
121
+ })));
122
+ };
123
+
124
+ /**
125
+ * Imperative confirm function
126
+ *
127
+ * @param {Object} options - Confirm options
128
+ * @param {string} options.title - Modal title
129
+ * @param {string} options.message - Modal message text
130
+ * @param {React.ReactNode} options.content - Custom content (React components)
131
+ * @param {string} options.confirmText - Confirm button text (default: 'Confirm')
132
+ * @param {string} options.cancelText - Cancel button text (default: 'Cancel')
133
+ * @param {boolean} options.showCancel - Show cancel button (default: true)
134
+ * @param {boolean} options.showRedBar - Show red bar decoration (default: true)
135
+ * @param {string} options.lineColor - Color of the left line (default: blue)
136
+ * @param {string} options.barColor - Color of the bottom bar (default: orangishRed)
137
+ * @param {Function} options.renderFooter - Custom footer renderer: ({ onConfirm, onCancel }) => React.ReactNode
138
+ * @param {Object} options.modalProps - Additional props to pass to Modal component
139
+ * @param {Object} options.buttonProps - Props for the confirm button
140
+ * @param {Object} options.cancelButtonProps - Props for the cancel button
141
+ * @returns {Promise<boolean|any>} - Resolves with true/false or custom value from renderFooter
142
+ */
143
+ exports.ConfirmModal = ConfirmModalComponent;
144
+ const confirm = function () {
145
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
146
+ const {
147
+ title = 'Confirm',
148
+ message = '',
149
+ content = null,
150
+ confirmText = 'Confirm',
151
+ cancelText = 'Cancel',
152
+ showCancel = true,
153
+ showRedBar = true,
154
+ lineColor,
155
+ barColor,
156
+ renderFooter = null,
157
+ modalProps = {},
158
+ buttonProps = {},
159
+ cancelButtonProps = {}
160
+ } = options;
161
+ return new Promise(resolve => {
162
+ // Create container if it doesn't exist
163
+ if (!confirmContainer) {
164
+ confirmContainer = document.createElement('div');
165
+ confirmContainer.id = 'confirm-modal-root';
166
+ document.body.appendChild(confirmContainer);
167
+ confirmRoot = (0, _client.createRoot)(confirmContainer);
168
+ }
169
+ let isResolved = false;
170
+ const handleConfirm = value => {
171
+ if (!isResolved) {
172
+ isResolved = true;
173
+ resolve(value);
174
+ // Render closed state to trigger animation
175
+ renderModal(false);
176
+ // Cleanup after animation
177
+ setTimeout(() => {
178
+ renderModal(null);
179
+ }, 350);
180
+ }
181
+ };
182
+ const handleCancel = () => {
183
+ if (!isResolved) {
184
+ isResolved = true;
185
+ resolve(false);
186
+ renderModal(false);
187
+ setTimeout(() => {
188
+ renderModal(null);
189
+ }, 350);
190
+ }
191
+ };
192
+ const handleClose = () => {
193
+ if (!isResolved) {
194
+ handleCancel();
195
+ }
196
+ };
197
+ const renderModal = isOpen => {
198
+ if (isOpen === null) {
199
+ // Cleanup
200
+ confirmRoot.render(null);
201
+ return;
202
+ }
203
+ confirmRoot.render(/*#__PURE__*/_react.default.createElement(ConfirmModalComponent, {
204
+ isOpen: isOpen,
205
+ onClose: handleClose,
206
+ onConfirm: handleConfirm,
207
+ onCancel: handleCancel,
208
+ title: title,
209
+ message: message,
210
+ content: content,
211
+ confirmText: confirmText,
212
+ cancelText: cancelText,
213
+ showCancel: showCancel,
214
+ showRedBar: showRedBar,
215
+ lineColor: lineColor,
216
+ barColor: barColor,
217
+ renderFooter: renderFooter,
218
+ modalProps: modalProps,
219
+ buttonProps: buttonProps,
220
+ cancelButtonProps: cancelButtonProps
221
+ }));
222
+ };
223
+
224
+ // Render open modal
225
+ renderModal(true);
226
+ });
227
+ };
228
+
229
+ // Also export the component for controlled usage if needed
230
+ exports.confirm = confirm;
231
+ var _default = exports.default = confirm;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RedBar = exports.ContainerWithLine = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _colors = _interopRequireDefault(require("../../styles/colors"));
9
+ var _rwd = _interopRequireDefault(require("../../styles/rwd"));
10
+ var _Text = _interopRequireDefault(require("../Text/Text.styles"));
11
+ var _templateObject;
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
14
+ const ContainerWithLine = exports.ContainerWithLine = (0, _styledComponents.default)(_Text.default).withConfig({
15
+ displayName: "ConfirmModalstyles__ContainerWithLine",
16
+ componentId: "sc-u85j89-0"
17
+ })(["position:relative;padding-left:48px;&::before{content:'';width:11px;height:", "px;background:", ";position:absolute;left:0;top:6px;}"], _ref => {
18
+ let {
19
+ height
20
+ } = _ref;
21
+ return height ? height - 10 : 50;
22
+ }, props => props.lineColor || _colors.default.blue);
23
+ const RedBar = exports.RedBar = _styledComponents.default.div.withConfig({
24
+ displayName: "ConfirmModalstyles__RedBar",
25
+ componentId: "sc-u85j89-1"
26
+ })(["background:", ";bottom:0;height:20%;position:absolute;right:0;width:50%;max-height:85px;max-width:400px;", " @media (max-width:767px){display:none;}"], props => props.barColor || _colors.default.orangishRed, _rwd.default.Medium(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n "]))));
@@ -43,7 +43,8 @@ const CryptoAddress = _ref => {
43
43
  wrapperStyle,
44
44
  bodyStyle,
45
45
  containerStyle,
46
- dataValueStyle
46
+ dataValueStyle,
47
+ valueChildMarginLeft
47
48
  } = _ref;
48
49
  const [copiedAddressToClipboard, setCopiedAddressToClipboard] = (0, _react.useState)(false);
49
50
  return /*#__PURE__*/_react.default.createElement(_CryptoAddress.Container, {
@@ -88,7 +89,8 @@ const CryptoAddress = _ref => {
88
89
  style: dataBoxStyle
89
90
  }, data.value && /*#__PURE__*/_react.default.createElement(_CryptoAddress.Value, {
90
91
  fontSize: fontSize,
91
- style: dataValueStyle
92
+ style: dataValueStyle,
93
+ childMarginLeft: valueChildMarginLeft
92
94
  }, data.unit && "".concat(data.unit, " "), data.shortAddress ? /*#__PURE__*/_react.default.createElement(_reactTippy.Tooltip, {
93
95
  position: "top",
94
96
  title: data.value,
@@ -105,7 +107,9 @@ const CryptoAddress = _ref => {
105
107
  }
106
108
  }, '= ', data.eqUnit && "".concat(data.eqUnit, " "), data.eqValue)), /*#__PURE__*/_react.default.createElement(_CryptoAddress.InfoBox, {
107
109
  style: infoBoxStyle
108
- }, /*#__PURE__*/_react.default.createElement(_CryptoAddress.Value, null, info.unit && /*#__PURE__*/_react.default.createElement("strong", null, info.unit), info.value), info.eqValue && /*#__PURE__*/_react.default.createElement(_CryptoAddress.Equal, {
110
+ }, /*#__PURE__*/_react.default.createElement(_CryptoAddress.Value, {
111
+ childMarginLeft: valueChildMarginLeft
112
+ }, info.unit && /*#__PURE__*/_react.default.createElement("strong", null, info.unit), info.value), info.eqValue && /*#__PURE__*/_react.default.createElement(_CryptoAddress.Equal, {
109
113
  fontSize: eqValueFontSize,
110
114
  style: eqValueStyle
111
115
  }, info.noEqualsToSign ? ' ' : '= ', info.eqUnit && /*#__PURE__*/_react.default.createElement("strong", null, info.eqUnit), " ".concat(info.eqValue)))), sideOptions && /*#__PURE__*/_react.default.createElement(_CryptoAddress.OptionsWrapper, null, sideOptions)))));
@@ -149,7 +153,9 @@ CryptoAddress.propTypes = {
149
153
  headStyle: _propTypes.default.object,
150
154
  infoBoxStyle: _propTypes.default.object,
151
155
  wrapperStyle: _propTypes.default.object,
152
- dataValueStyle: _propTypes.default.object
156
+ dataValueStyle: _propTypes.default.object,
157
+ /** Margin-left for child divs inside Value (default: '30px') */
158
+ valueChildMarginLeft: _propTypes.default.string
153
159
  };
154
160
  //address not required in IIS, instead wrapping {address &&( .. now doing both which is redundant
155
161
 
@@ -89,7 +89,7 @@ const InfoBox = exports.InfoBox = _styledComponents.default.div.withConfig({
89
89
  const Value = exports.Value = _styledComponents.default.div.withConfig({
90
90
  displayName: "CryptoAddressstyles__Value",
91
91
  componentId: "sc-1wjvdgu-12"
92
- })(["position:relative;font-weight:300;font-size:22px;font-size:", "px;line-height:28px;letter-spacing:0.4px;strong{font-weight:normal;&:after{content:' ';}}& > div{display:inline-block;margin-left:30px;& svg{max-width:16px;max-height:16px;}}"], props => props.fontSize);
92
+ })(["position:relative;font-weight:300;font-size:22px;font-size:", "px;line-height:28px;letter-spacing:0.4px;strong{font-weight:normal;&:after{content:' ';}}& > div{display:inline-block;margin-left:", ";& svg{max-width:16px;max-height:16px;}}"], props => props.fontSize, props => props.childMarginLeft !== undefined ? props.childMarginLeft : '30px');
93
93
  const Equal = exports.Equal = _styledComponents.default.div.withConfig({
94
94
  displayName: "CryptoAddressstyles__Equal",
95
95
  componentId: "sc-1wjvdgu-13"
@@ -80,7 +80,8 @@ const Modal = _ref => {
80
80
  isRegisterEntity,
81
81
  background,
82
82
  maxHeight,
83
- boxStyles
83
+ boxStyles,
84
+ maxWidth
84
85
  } = _ref;
85
86
  (0, _react.useEffect)(() => {
86
87
  //if modal open, disable scroll on the background
@@ -117,7 +118,8 @@ const Modal = _ref => {
117
118
  thin: thin,
118
119
  isRegisterEntity: isRegisterEntity,
119
120
  style: boxStyles,
120
- maxHeight: maxHeight
121
+ maxHeight: maxHeight,
122
+ maxWidth: maxWidth
121
123
  }, /*#__PURE__*/_react.default.createElement(_Modal.ModalClose, {
122
124
  onClick: onClose
123
125
  }), children)))));
@@ -132,7 +134,10 @@ Modal.propTypes = {
132
134
  isOpen: _propTypes.default.bool.isRequired,
133
135
  onClose: _propTypes.default.func.isRequired,
134
136
  background: _propTypes.default.string,
135
- boxStyle: _propTypes.default.object
137
+ boxStyle: _propTypes.default.object,
138
+ maxHeight: _propTypes.default.string,
139
+ /** Max width limit in pixels (e.g., '1200px'). Uses min(percentage, maxWidth) */
140
+ maxWidth: _propTypes.default.string
136
141
  };
137
142
  Modal.defaultProps = {
138
143
  className: '',
@@ -24,12 +24,12 @@ const Dimmer = exports.Dimmer = _styledComponents.default.div.withConfig({
24
24
  const Box = exports.Box = _styledComponents.default.div.withConfig({
25
25
  displayName: "Modalstyles__Box",
26
26
  componentId: "sc-9hc271-2"
27
- })(["display:inline-block;vertical-align:middle;position:relative;left:0;top:0;width:100%;background-color:", ";font-size:10px;text-align:left;box-shadow:0 2px 20px 0 rgba(0,0,0,0.1);max-height:", ";", " ", " ", " ", " @media screen and (max-width:767px){min-height:100vh;}", ""], _colors.default.white, props => props.maxHeight || 'unset', props => props.fullscreen && "\n height: 90vh;\n ", props => props.kyc && "\n width: 100vw;\n height: 100vh;\n max-width: 1024px!important;\n max-height: 768px!important;\n ", _rwd.default.Medium(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-width: ", ";\n\n ", "\n "])), (0, _grid.default)(12), props => props.thin && "\n max-width: ".concat((0, _grid.default)(8), ";\n ")), _rwd.default.XLarge(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n //max-width: ", ";\n\n ", "\n "])), (0, _grid.default)(11), props => props.thin && "\n max-width: ".concat((0, _grid.default)(8), ";\n ")), _ref => {
27
+ })(["display:inline-block;vertical-align:middle;position:relative;left:0;top:0;width:100%;background-color:", ";font-size:10px;text-align:left;box-shadow:0 2px 20px 0 rgba(0,0,0,0.1);max-height:", ";", " ", " ", " ", " @media screen and (max-width:767px){min-height:100vh;}", " ", ""], _colors.default.white, props => props.maxHeight || 'unset', props => props.fullscreen && "\n height: 90vh;\n ", props => props.kyc && "\n width: 100vw;\n height: 100vh;\n max-width: 1024px!important;\n max-height: 768px!important;\n ", _rwd.default.Medium(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-width: min(", ", ", ");\n\n ", "\n "])), (0, _grid.default)(12), props => props.maxWidth || '1200px', props => props.thin && "\n max-width: min(".concat((0, _grid.default)(8), ", ").concat(props.maxWidth || '800px', ");\n ")), _rwd.default.XLarge(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n max-width: min(", ", ", ");\n\n ", "\n "])), (0, _grid.default)(12), props => props.maxWidth || '1500px', props => props.thin && "\n max-width: min(".concat((0, _grid.default)(8), ", ").concat(props.maxWidth || '800px', ");\n ")), _ref => {
28
28
  let {
29
29
  isRegisterEntity
30
30
  } = _ref;
31
31
  return isRegisterEntity && (0, _styledComponents.css)(["max-width:55% !important;height:65vh;"]);
32
- });
32
+ }, props => props.maxWidth && "\n max-width: ".concat(props.maxWidth, " !important;\n "));
33
33
  const ModalInnerSmartContractAddress = exports.ModalInnerSmartContractAddress = _styledComponents.default.input.withConfig({
34
34
  displayName: "Modalstyles__ModalInnerSmartContractAddress",
35
35
  componentId: "sc-9hc271-3"
package/dist/index.js CHANGED
@@ -652,6 +652,17 @@ Object.keys(_SideModal).forEach(function (key) {
652
652
  }
653
653
  });
654
654
  });
655
+ var _ConfirmModal = require("./components/ConfirmModal/ConfirmModal");
656
+ Object.keys(_ConfirmModal).forEach(function (key) {
657
+ if (key === "default" || key === "__esModule") return;
658
+ if (key in exports && exports[key] === _ConfirmModal[key]) return;
659
+ Object.defineProperty(exports, key, {
660
+ enumerable: true,
661
+ get: function () {
662
+ return _ConfirmModal[key];
663
+ }
664
+ });
665
+ });
655
666
  var _MultiProgressBar = require("./components/MultiProgressBar/MultiProgressBar");
656
667
  Object.keys(_MultiProgressBar).forEach(function (key) {
657
668
  if (key === "default" || key === "__esModule") return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.3.65-beta.13",
3
+ "version": "2.3.65-beta.14",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",