@stokr/components-library 2.3.62 → 2.3.63-beta.2

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.
@@ -4,13 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.InfoIcon = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _reactTippy = require("react-tippy");
9
+ var _reactTooltip = require("react-tooltip");
10
+ var _colors = _interopRequireDefault(require("../../styles/colors"));
10
11
  var _InfoIcon = require("./InfoIcon.styles");
11
- const _excluded = ["title", "html", "position", "noMargin", "noMarginLeft", "noMarginRight", "noIcon", "disabled", "fullWidth", "containerStyle"];
12
+ const _excluded = ["title", "html", "position", "noMargin", "noMarginLeft", "noMarginRight", "noIcon", "disabled", "fullWidth", "containerStyle", "customStyles", "arrowColor"];
12
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); }
13
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); }
14
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; }
15
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; }
16
23
  const InfoIcon = _ref => {
@@ -24,26 +31,50 @@ const InfoIcon = _ref => {
24
31
  noIcon,
25
32
  disabled,
26
33
  fullWidth,
27
- containerStyle
34
+ containerStyle,
35
+ customStyles,
36
+ arrowColor
28
37
  } = _ref,
29
38
  props = _objectWithoutProperties(_ref, _excluded);
30
- return /*#__PURE__*/_react.default.createElement(_InfoIcon.Container, {
39
+ // Generate stable ID for tooltip (once per component instance)
40
+ const tooltipIdRef = (0, _react.useRef)("info-icon-".concat(Math.random().toString(36).substr(2, 9)));
41
+ const tooltipId = tooltipIdRef.current;
42
+ const content = html || title;
43
+ const styles = _objectSpread({
44
+ borderRadius: '10px',
45
+ fontSize: '13px',
46
+ lineHeight: '20px',
47
+ letterSpacing: '0.4px',
48
+ padding: '20px',
49
+ wordBreak: 'break-word',
50
+ boxShadow: ['0 0 12px 8px rgba(0, 0, 0, 0.03)', '0 0 6px 3px rgba(0, 0, 0, 0.02)'],
51
+ fontWeight: 'normal',
52
+ width: 'auto'
53
+ }, customStyles);
54
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_InfoIcon.Container, {
31
55
  noMargin: noMargin,
32
56
  noMarginLeft: noMarginLeft,
33
57
  noMarginRight: noMarginRight,
34
58
  fullWidth: fullWidth,
35
59
  style: containerStyle
36
- }, /*#__PURE__*/_react.default.createElement(_reactTippy.Tooltip, _extends({}, props, {
37
- position: position,
38
- title: title,
39
- html: html,
40
- theme: "light",
41
- arrow: true,
42
- duration: 200
43
- // onRequestClose={() => console.log('request to close tooltip')}
44
- ,
45
- disabled: disabled
46
- }), noIcon ? props.children : /*#__PURE__*/_react.default.createElement(_InfoIcon.Icon, null)));
60
+ }, /*#__PURE__*/_react.default.createElement("span", _extends({
61
+ "data-tooltip-id": tooltipId
62
+ }, html ? {
63
+ 'data-tooltip-html': html
64
+ } : {
65
+ 'data-tooltip-content': title
66
+ }), noIcon ? props.children : /*#__PURE__*/_react.default.createElement(_InfoIcon.Icon, null))), !disabled && content && /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, _extends({
67
+ id: tooltipId,
68
+ place: position,
69
+ variant: "light",
70
+ arrowColor: arrowColor || _colors.default.blue,
71
+ delayShow: 100,
72
+ delayHide: 100,
73
+ offset: 15,
74
+ opacity: 1,
75
+ arrowSize: 10,
76
+ style: styles
77
+ }, props)));
47
78
  };
48
79
  exports.InfoIcon = InfoIcon;
49
80
  InfoIcon.propTypes = {
@@ -52,7 +83,8 @@ InfoIcon.propTypes = {
52
83
  position: _propTypes.default.oneOf(['top', 'bottom', 'left', 'right']),
53
84
  noMargin: _propTypes.default.bool,
54
85
  noMarginLeft: _propTypes.default.bool,
55
- noMarginRight: _propTypes.default.bool
86
+ noMarginRight: _propTypes.default.bool,
87
+ arrowColor: _propTypes.default.string
56
88
  };
57
89
  InfoIcon.defaultProps = {
58
90
  title: null,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.InfoIconTop = exports.InfoIconBottom = void 0;
6
+ exports.default = exports.WithHTML = exports.RedArrow = exports.Positions = exports.NoMargins = exports.MultipleTooltips = exports.LongText = exports.InContext = exports.Disabled = exports.Default = exports.CustomChildren = exports.ArrowColorComparison = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _InfoIcon = require("./InfoIcon");
9
9
  var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
@@ -15,35 +15,285 @@ var _default = exports.default = {
15
15
  argTypes: {
16
16
  title: {
17
17
  type: 'string',
18
- defaultValue: 'default is null/ add some title'
18
+ description: 'Text content to display in the tooltip',
19
+ control: 'text'
19
20
  },
20
21
  html: {
21
- type: 'node',
22
- defaultValue: 'default is null/ add some html'
22
+ type: 'string',
23
+ description: 'HTML content to display in the tooltip (takes precedence over title)',
24
+ control: 'text'
23
25
  },
24
26
  position: {
25
- type: 'string',
26
- defaultValue: 'bottom'
27
+ type: 'select',
28
+ options: ['top', 'bottom', 'left', 'right'],
29
+ description: 'Position of the tooltip relative to the icon',
30
+ control: 'select'
27
31
  },
28
32
  noMargin: {
29
33
  type: 'boolean',
30
- defaultValue: false
34
+ description: 'Remove all margins from the container',
35
+ control: 'boolean'
31
36
  },
32
37
  noMarginLeft: {
33
38
  type: 'boolean',
34
- defaultValue: false
39
+ description: 'Remove left margin from the container',
40
+ control: 'boolean'
35
41
  },
36
42
  noMarginRight: {
37
43
  type: 'boolean',
38
- defaultValue: false
44
+ description: 'Remove right margin from the container',
45
+ control: 'boolean'
46
+ },
47
+ noIcon: {
48
+ type: 'boolean',
49
+ description: 'Hide the info icon and show children instead',
50
+ control: 'boolean'
51
+ },
52
+ disabled: {
53
+ type: 'boolean',
54
+ description: 'Disable the tooltip',
55
+ control: 'boolean'
56
+ },
57
+ fullWidth: {
58
+ type: 'boolean',
59
+ description: 'Make the container full width',
60
+ control: 'boolean'
39
61
  }
62
+ },
63
+ 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(Story, null)))]
64
+ }; // Default example
65
+ const Default = exports.Default = {
66
+ args: {
67
+ title: 'This is a helpful tooltip with some information',
68
+ position: 'bottom'
40
69
  }
41
70
  };
42
- const Template = args => /*#__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(_InfoIcon.InfoIcon, args)));
43
- const InfoIconBottom = exports.InfoIconBottom = Template.bind({});
44
- InfoIconBottom.args = {};
45
- const InfoIconTop = exports.InfoIconTop = Template.bind({});
46
- InfoIconTop.args = {
47
- position: 'top',
48
- title: 'This is a title'
49
- };
71
+
72
+ // All positions
73
+ const Positions = () => /*#__PURE__*/_react.default.createElement("div", {
74
+ style: {
75
+ display: 'flex',
76
+ gap: '40px',
77
+ flexWrap: 'wrap',
78
+ padding: '60px'
79
+ }
80
+ }, /*#__PURE__*/_react.default.createElement("div", {
81
+ style: {
82
+ textAlign: 'center'
83
+ }
84
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
85
+ position: "top",
86
+ title: "Tooltip on top"
87
+ }), /*#__PURE__*/_react.default.createElement("div", {
88
+ style: {
89
+ marginTop: '10px',
90
+ fontSize: '12px'
91
+ }
92
+ }, "Top")), /*#__PURE__*/_react.default.createElement("div", {
93
+ style: {
94
+ textAlign: 'center'
95
+ }
96
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
97
+ position: "bottom",
98
+ title: "Tooltip on bottom"
99
+ }), /*#__PURE__*/_react.default.createElement("div", {
100
+ style: {
101
+ marginTop: '10px',
102
+ fontSize: '12px'
103
+ }
104
+ }, "Bottom")), /*#__PURE__*/_react.default.createElement("div", {
105
+ style: {
106
+ textAlign: 'center'
107
+ }
108
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
109
+ position: "left",
110
+ title: "Tooltip on left"
111
+ }), /*#__PURE__*/_react.default.createElement("div", {
112
+ style: {
113
+ marginTop: '10px',
114
+ fontSize: '12px'
115
+ }
116
+ }, "Left")), /*#__PURE__*/_react.default.createElement("div", {
117
+ style: {
118
+ textAlign: 'center'
119
+ }
120
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
121
+ position: "right",
122
+ title: "Tooltip on right"
123
+ }), /*#__PURE__*/_react.default.createElement("div", {
124
+ style: {
125
+ marginTop: '10px',
126
+ fontSize: '12px'
127
+ }
128
+ }, "Right")));
129
+
130
+ // With HTML content
131
+ exports.Positions = Positions;
132
+ const WithHTML = exports.WithHTML = {
133
+ args: {
134
+ html: '<strong>Bold text</strong> and <em>italic text</em><br/>With a line break',
135
+ position: 'bottom'
136
+ }
137
+ };
138
+
139
+ // With long text
140
+ const LongText = exports.LongText = {
141
+ args: {
142
+ title: 'This is a very long tooltip text that demonstrates how the tooltip handles longer content. It should wrap nicely and maintain good readability.',
143
+ position: 'bottom'
144
+ }
145
+ };
146
+
147
+ // No margins
148
+ const NoMargins = () => /*#__PURE__*/_react.default.createElement("div", {
149
+ style: {
150
+ display: 'flex',
151
+ gap: '20px',
152
+ alignItems: 'center'
153
+ }
154
+ }, /*#__PURE__*/_react.default.createElement("span", null, "Text before"), /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
155
+ title: "No margin",
156
+ noMargin: true
157
+ }), /*#__PURE__*/_react.default.createElement("span", null, "Text after"));
158
+
159
+ // Custom children (no icon)
160
+ exports.NoMargins = NoMargins;
161
+ const CustomChildren = exports.CustomChildren = {
162
+ args: {
163
+ title: 'Custom content instead of icon',
164
+ noIcon: true,
165
+ children: /*#__PURE__*/_react.default.createElement("span", {
166
+ style: {
167
+ textDecoration: 'underline'
168
+ }
169
+ }, "Hover me")
170
+ }
171
+ };
172
+
173
+ // Disabled
174
+ const Disabled = exports.Disabled = {
175
+ args: {
176
+ title: 'This tooltip is disabled',
177
+ disabled: true
178
+ }
179
+ };
180
+
181
+ // In context example
182
+ const InContext = () => /*#__PURE__*/_react.default.createElement("div", {
183
+ style: {
184
+ padding: '40px',
185
+ maxWidth: '500px'
186
+ }
187
+ }, /*#__PURE__*/_react.default.createElement("h3", {
188
+ style: {
189
+ display: 'inline-flex',
190
+ alignItems: 'center',
191
+ gap: '8px'
192
+ }
193
+ }, "Investment Amount", /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
194
+ title: "Enter the amount you wish to invest in this project. Minimum investment is \u20AC1,000.",
195
+ position: "top"
196
+ })), /*#__PURE__*/_react.default.createElement("input", {
197
+ type: "number",
198
+ placeholder: "Enter amount",
199
+ style: {
200
+ marginTop: '10px',
201
+ padding: '8px',
202
+ width: '100%',
203
+ border: '1px solid #ccc',
204
+ borderRadius: '4px'
205
+ }
206
+ }), /*#__PURE__*/_react.default.createElement("p", {
207
+ style: {
208
+ marginTop: '20px',
209
+ fontSize: '14px',
210
+ color: '#666'
211
+ }
212
+ }, "Need help?", ' ', /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
213
+ title: "Contact our support team for assistance",
214
+ noMarginLeft: true,
215
+ noMarginRight: true
216
+ })));
217
+
218
+ // Multiple tooltips
219
+ exports.InContext = InContext;
220
+ const MultipleTooltips = () => /*#__PURE__*/_react.default.createElement("div", {
221
+ style: {
222
+ padding: '40px'
223
+ }
224
+ }, /*#__PURE__*/_react.default.createElement("div", {
225
+ style: {
226
+ marginBottom: '20px'
227
+ }
228
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
229
+ title: "First tooltip",
230
+ position: "top"
231
+ }), /*#__PURE__*/_react.default.createElement("span", {
232
+ style: {
233
+ marginLeft: '10px'
234
+ }
235
+ }, "First example")), /*#__PURE__*/_react.default.createElement("div", {
236
+ style: {
237
+ marginBottom: '20px'
238
+ }
239
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
240
+ title: "Second tooltip",
241
+ position: "bottom"
242
+ }), /*#__PURE__*/_react.default.createElement("span", {
243
+ style: {
244
+ marginLeft: '10px'
245
+ }
246
+ }, "Second example")), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
247
+ html: "<strong>HTML</strong> tooltip with <em>formatting</em>",
248
+ position: "right"
249
+ }), /*#__PURE__*/_react.default.createElement("span", {
250
+ style: {
251
+ marginLeft: '10px'
252
+ }
253
+ }, "Third example with HTML")));
254
+
255
+ // Custom arrow color (red)
256
+ exports.MultipleTooltips = MultipleTooltips;
257
+ const RedArrow = exports.RedArrow = {
258
+ args: {
259
+ title: 'This tooltip has a red arrow instead of the default blue',
260
+ position: 'bottom',
261
+ arrowColor: '#ee220d' // Using red from colors
262
+ }
263
+ };
264
+
265
+ // Comparison: Blue vs Red arrow
266
+ const ArrowColorComparison = () => /*#__PURE__*/_react.default.createElement("div", {
267
+ style: {
268
+ padding: '40px',
269
+ display: 'flex',
270
+ gap: '40px',
271
+ alignItems: 'center'
272
+ }
273
+ }, /*#__PURE__*/_react.default.createElement("div", {
274
+ style: {
275
+ textAlign: 'center'
276
+ }
277
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
278
+ title: "Default blue arrow",
279
+ position: "bottom"
280
+ }), /*#__PURE__*/_react.default.createElement("div", {
281
+ style: {
282
+ marginTop: '10px',
283
+ fontSize: '12px'
284
+ }
285
+ }, "Blue (default)")), /*#__PURE__*/_react.default.createElement("div", {
286
+ style: {
287
+ textAlign: 'center'
288
+ }
289
+ }, /*#__PURE__*/_react.default.createElement(_InfoIcon.InfoIcon, {
290
+ title: "Custom red arrow",
291
+ position: "bottom",
292
+ arrowColor: "#ee220d"
293
+ }), /*#__PURE__*/_react.default.createElement("div", {
294
+ style: {
295
+ marginTop: '10px',
296
+ fontSize: '12px'
297
+ }
298
+ }, "Red (custom)")));
299
+ exports.ArrowColorComparison = ArrowColorComparison;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.3.62",
3
+ "version": "2.3.63-beta.2",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -67,6 +67,7 @@
67
67
  "react-slick": "^0.31.0",
68
68
  "react-table": "^7.8.0",
69
69
  "react-tippy": "^1.4.0",
70
+ "react-tooltip": "^5.30.0",
70
71
  "react-transition-group": "^4.4.5",
71
72
  "react-visibility-sensor": "^5.1.1",
72
73
  "scroll-to-element": "^2.0.3",
@@ -75,6 +76,9 @@
75
76
  "styled-components": "^6.0.7",
76
77
  "yup": "^1.0.0"
77
78
  },
79
+ "peerDependencies": {
80
+ "react-tooltip": ">=5.0.0"
81
+ },
78
82
  "devDependencies": {
79
83
  "@babel/cli": "^7.20.7",
80
84
  "@babel/core": "^7.20.12",