@stokr/components-library 2.3.64 → 2.3.65-beta.1
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.
|
@@ -8,7 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _reactTippy = require("react-tippy");
|
|
10
10
|
var _InfoIcon = require("./InfoIcon.styles");
|
|
11
|
-
const _excluded = ["title", "html", "position", "noMargin", "noMarginLeft", "noMarginRight", "noIcon", "disabled", "fullWidth", "containerStyle"];
|
|
11
|
+
const _excluded = ["title", "html", "position", "noMargin", "noMarginLeft", "noMarginRight", "noIcon", "disabled", "fullWidth", "outline", "containerStyle"];
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
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
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; }
|
|
@@ -24,6 +24,7 @@ const InfoIcon = _ref => {
|
|
|
24
24
|
noIcon,
|
|
25
25
|
disabled,
|
|
26
26
|
fullWidth,
|
|
27
|
+
outline,
|
|
27
28
|
containerStyle
|
|
28
29
|
} = _ref,
|
|
29
30
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -43,7 +44,9 @@ const InfoIcon = _ref => {
|
|
|
43
44
|
// onRequestClose={() => console.log('request to close tooltip')}
|
|
44
45
|
,
|
|
45
46
|
disabled: disabled
|
|
46
|
-
}), noIcon ? props.children : /*#__PURE__*/_react.default.createElement(_InfoIcon.Icon,
|
|
47
|
+
}), noIcon ? props.children : /*#__PURE__*/_react.default.createElement(_InfoIcon.Icon, {
|
|
48
|
+
outline: outline
|
|
49
|
+
})));
|
|
47
50
|
};
|
|
48
51
|
exports.InfoIcon = InfoIcon;
|
|
49
52
|
InfoIcon.propTypes = {
|
|
@@ -52,7 +55,8 @@ InfoIcon.propTypes = {
|
|
|
52
55
|
position: _propTypes.default.oneOf(['top', 'bottom', 'left', 'right']),
|
|
53
56
|
noMargin: _propTypes.default.bool,
|
|
54
57
|
noMarginLeft: _propTypes.default.bool,
|
|
55
|
-
noMarginRight: _propTypes.default.bool
|
|
58
|
+
noMarginRight: _propTypes.default.bool,
|
|
59
|
+
outline: _propTypes.default.bool
|
|
56
60
|
};
|
|
57
61
|
InfoIcon.defaultProps = {
|
|
58
62
|
title: null,
|
|
@@ -60,6 +64,7 @@ InfoIcon.defaultProps = {
|
|
|
60
64
|
position: 'bottom',
|
|
61
65
|
noMargin: false,
|
|
62
66
|
noMarginLeft: false,
|
|
63
|
-
noMarginRight: false
|
|
67
|
+
noMarginRight: false,
|
|
68
|
+
outline: false
|
|
64
69
|
};
|
|
65
70
|
var _default = exports.default = InfoIcon;
|
|
@@ -11,9 +11,9 @@ const Container = exports.Container = _styledComponents.default.div.withConfig({
|
|
|
11
11
|
displayName: "InfoIconstyles__Container",
|
|
12
12
|
componentId: "sc-d3sdn3-0"
|
|
13
13
|
})(["display:inline-block;vertical-align:middle;margin:0 12px;font-size:0;line-height:0;", " ", " ", " ", " & > div{position:relative;display:inline-block !important;", "}"], props => props.noMargin && "\n margin: 0;\n ", props => props.noMarginLeft && "\n margin-left: 0;\n ", props => props.noMarginRight && "\n margin-right: 0;\n ", props => props.fullWidth && "\n width: 100%;\n height: 100%;\n ", props => props.fullWidth && "\n width: 100%;\n height: 100%;\n display: flex !important;\n align-content: center;\n flex-wrap: wrap;\n justify-content: center;\n ");
|
|
14
|
-
const Icon = exports.Icon = _styledComponents.default.i.attrs({
|
|
15
|
-
className: 'ion ion-md-information-circle'
|
|
16
|
-
}).withConfig({
|
|
14
|
+
const Icon = exports.Icon = _styledComponents.default.i.attrs(props => ({
|
|
15
|
+
className: props.outline ? 'ion ion-md-information-circle-outline' : 'ion ion-md-information-circle'
|
|
16
|
+
})).withConfig({
|
|
17
17
|
displayName: "InfoIconstyles__Icon",
|
|
18
18
|
componentId: "sc-d3sdn3-1"
|
|
19
19
|
})(["position:relative;left:-0.4px;display:inline-block;vertical-align:middle;font-size:16px;line-height:16px;vertical-align:middle;color:", ";transition:color 0.2s;&:hover{color:", ";}"], props => _theme.default.cGrey2, props => _theme.default.cPrimary);
|
|
@@ -12,7 +12,6 @@ const Timeline = _ref => {
|
|
|
12
12
|
let {
|
|
13
13
|
steps = [],
|
|
14
14
|
maxWidth,
|
|
15
|
-
dateFormat,
|
|
16
15
|
showInfoIcons = true,
|
|
17
16
|
infoIconPosition = 'right',
|
|
18
17
|
// Style props
|
|
@@ -41,7 +40,6 @@ const Timeline = _ref => {
|
|
|
41
40
|
customIcon: step.customIcon,
|
|
42
41
|
showInfoIcon: showInfoIcons,
|
|
43
42
|
infoIconPosition: infoIconPosition,
|
|
44
|
-
dateFormat: dateFormat,
|
|
45
43
|
stepStyle: step.stepStyle || stepStyle,
|
|
46
44
|
iconStyle: step.iconStyle || iconStyle,
|
|
47
45
|
contentStyle: step.contentStyle || contentStyle,
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useCheckboxes = exports.CheckboxProvider = void 0;
|
|
6
|
+
exports.useCheckboxes = exports.useCheckboxActions = exports.CheckboxProvider = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _fetchDataPublic = _interopRequireDefault(require("../../api/fetchDataPublic"));
|
|
9
|
+
var _fetchData = _interopRequireDefault(require("../../api/fetchData"));
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
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); }
|
|
11
12
|
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,6 +21,7 @@ const CheckboxProvider = _ref => {
|
|
|
20
21
|
} = _ref;
|
|
21
22
|
const [checkboxes, setCheckboxes] = (0, _react.useState)({});
|
|
22
23
|
const [loadingStates, setLoadingStates] = (0, _react.useState)({});
|
|
24
|
+
const [errorStates, setErrorStates] = (0, _react.useState)({});
|
|
23
25
|
const fetchCheckboxes = async function (key) {
|
|
24
26
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
27
|
const {
|
|
@@ -27,13 +29,18 @@ const CheckboxProvider = _ref => {
|
|
|
27
29
|
labels
|
|
28
30
|
} = options;
|
|
29
31
|
|
|
30
|
-
// Don't fetch if already loading or
|
|
31
|
-
if (loadingStates[key] || checkboxes[key]) {
|
|
32
|
+
// Don't fetch if already loading, already fetched, or previously failed
|
|
33
|
+
if (loadingStates[key] || checkboxes[key] !== undefined || errorStates[key]) {
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
setLoadingStates(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
35
37
|
[key]: true
|
|
36
38
|
}));
|
|
39
|
+
setErrorStates(prev => {
|
|
40
|
+
const newState = _objectSpread({}, prev);
|
|
41
|
+
delete newState[key]; // Clear previous error if retrying
|
|
42
|
+
return newState;
|
|
43
|
+
});
|
|
37
44
|
try {
|
|
38
45
|
let response;
|
|
39
46
|
if (group) {
|
|
@@ -54,6 +61,14 @@ const CheckboxProvider = _ref => {
|
|
|
54
61
|
}));
|
|
55
62
|
} catch (error) {
|
|
56
63
|
console.error("Failed to fetch checkboxes for key: ".concat(key), error);
|
|
64
|
+
// Mark as failed to prevent infinite retries
|
|
65
|
+
setErrorStates(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
66
|
+
[key]: error
|
|
67
|
+
}));
|
|
68
|
+
// Set checkboxes to null to indicate fetch was attempted but failed
|
|
69
|
+
setCheckboxes(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
70
|
+
[key]: null
|
|
71
|
+
}));
|
|
57
72
|
} finally {
|
|
58
73
|
setLoadingStates(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
59
74
|
[key]: false
|
|
@@ -62,16 +77,56 @@ const CheckboxProvider = _ref => {
|
|
|
62
77
|
};
|
|
63
78
|
const getCheckboxes = function (key) {
|
|
64
79
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
65
|
-
// Auto-fetch if not already loaded
|
|
66
|
-
if (
|
|
80
|
+
// Auto-fetch if not already loaded, not loading, and not in error state
|
|
81
|
+
if (checkboxes[key] === undefined && !loadingStates[key] && !errorStates[key]) {
|
|
67
82
|
fetchCheckboxes(key, options);
|
|
68
83
|
}
|
|
69
84
|
return {
|
|
70
85
|
checkboxes: checkboxes[key] || null,
|
|
71
86
|
isLoading: loadingStates[key] || false,
|
|
72
|
-
|
|
87
|
+
error: errorStates[key] || null,
|
|
88
|
+
refetch: () => {
|
|
89
|
+
// Clear error state to allow retry
|
|
90
|
+
setErrorStates(prev => {
|
|
91
|
+
const newState = _objectSpread({}, prev);
|
|
92
|
+
delete newState[key];
|
|
93
|
+
return newState;
|
|
94
|
+
});
|
|
95
|
+
setCheckboxes(prev => {
|
|
96
|
+
const newState = _objectSpread({}, prev);
|
|
97
|
+
delete newState[key];
|
|
98
|
+
return newState;
|
|
99
|
+
});
|
|
100
|
+
fetchCheckboxes(key, options);
|
|
101
|
+
}
|
|
73
102
|
};
|
|
74
103
|
};
|
|
104
|
+
const checkCheckbox = async function (checkboxId) {
|
|
105
|
+
let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
106
|
+
const {
|
|
107
|
+
userId,
|
|
108
|
+
investmentId = '',
|
|
109
|
+
privateInvestorId = ''
|
|
110
|
+
} = data;
|
|
111
|
+
if (!userId) {
|
|
112
|
+
throw new Error('userId is required to check checkbox');
|
|
113
|
+
}
|
|
114
|
+
if (!checkboxId) {
|
|
115
|
+
throw new Error('checkboxId is required');
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const response = await (0, _fetchData.default)('compliance/check-checkbox', {
|
|
119
|
+
userId,
|
|
120
|
+
checkboxId,
|
|
121
|
+
investmentId,
|
|
122
|
+
privateInvestorId
|
|
123
|
+
});
|
|
124
|
+
return response;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.error("Failed to check checkbox: ".concat(checkboxId), error);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
75
130
|
const clearCheckboxes = key => {
|
|
76
131
|
if (key) {
|
|
77
132
|
// Clear specific key
|
|
@@ -85,14 +140,21 @@ const CheckboxProvider = _ref => {
|
|
|
85
140
|
delete newState[key];
|
|
86
141
|
return newState;
|
|
87
142
|
});
|
|
143
|
+
setErrorStates(prev => {
|
|
144
|
+
const newState = _objectSpread({}, prev);
|
|
145
|
+
delete newState[key];
|
|
146
|
+
return newState;
|
|
147
|
+
});
|
|
88
148
|
} else {
|
|
89
149
|
// Clear all checkboxes
|
|
90
150
|
setCheckboxes({});
|
|
91
151
|
setLoadingStates({});
|
|
152
|
+
setErrorStates({});
|
|
92
153
|
}
|
|
93
154
|
};
|
|
94
155
|
const value = {
|
|
95
156
|
getCheckboxes,
|
|
157
|
+
checkCheckbox,
|
|
96
158
|
clearCheckboxes
|
|
97
159
|
};
|
|
98
160
|
return /*#__PURE__*/_react.default.createElement(CheckboxContext.Provider, {
|
|
@@ -111,4 +173,16 @@ const useCheckboxes = function (key) {
|
|
|
111
173
|
}
|
|
112
174
|
return context.getCheckboxes(key, options);
|
|
113
175
|
};
|
|
114
|
-
exports.useCheckboxes = useCheckboxes;
|
|
176
|
+
exports.useCheckboxes = useCheckboxes;
|
|
177
|
+
const useCheckboxActions = () => {
|
|
178
|
+
const context = (0, _react.useContext)(CheckboxContext);
|
|
179
|
+
if (!context) {
|
|
180
|
+
throw new Error('useCheckboxActions must be used within CheckboxProvider');
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
checkCheckbox: context.checkCheckbox,
|
|
184
|
+
uncheckCheckbox: context.uncheckCheckbox,
|
|
185
|
+
clearCheckboxes: context.clearCheckboxes
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
exports.useCheckboxActions = useCheckboxActions;
|