@helpdice/ui 2.1.5 → 2.1.8

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.
Files changed (42) hide show
  1. package/dist/auto-complete/index.js +12 -10
  2. package/dist/button/button.d.ts +1 -1
  3. package/dist/button/index.js +73 -16
  4. package/dist/button/styles.d.ts +1 -0
  5. package/dist/carousal/index.js +73 -16
  6. package/dist/copy-to-clipboard/clipboard.d.ts +2 -0
  7. package/dist/copy-to-clipboard/copy.d.ts +2 -0
  8. package/dist/copy-to-clipboard/index.d.ts +2 -0
  9. package/dist/copy-to-clipboard/index.js +1717 -0
  10. package/dist/copy-to-clipboard/toggle-selection.d.ts +1 -0
  11. package/dist/html-renderer/index.js +35 -12
  12. package/dist/index.d.ts +3 -2
  13. package/dist/index.js +539 -220
  14. package/dist/input/index.js +12 -10
  15. package/dist/input/input-props.d.ts +1 -0
  16. package/dist/modal/index.js +73 -16
  17. package/dist/notetip/index.js +690 -0
  18. package/dist/notetip/{index.d.ts → note-tip.d.ts} +2 -2
  19. package/dist/table/index.js +990 -930
  20. package/esm/button/button.d.ts +1 -1
  21. package/esm/button/button.js +51 -5
  22. package/esm/button/styles.d.ts +1 -0
  23. package/esm/button/styles.js +22 -11
  24. package/esm/copy-to-clipboard/clipboard.d.ts +2 -0
  25. package/esm/copy-to-clipboard/copy.d.ts +2 -0
  26. package/esm/copy-to-clipboard/copy.js +105 -0
  27. package/esm/copy-to-clipboard/index.d.ts +2 -0
  28. package/esm/copy-to-clipboard/index.js +2 -0
  29. package/esm/copy-to-clipboard/toggle-selection.d.ts +1 -0
  30. package/esm/copy-to-clipboard/toggle-selection.js +31 -0
  31. package/esm/index.d.ts +3 -2
  32. package/esm/index.js +3 -2
  33. package/esm/input/input-field.js +12 -10
  34. package/esm/input/input-props.d.ts +1 -0
  35. package/esm/notetip/index.js +2 -97
  36. package/esm/notetip/{index.d.ts → note-tip.d.ts} +2 -2
  37. package/esm/notetip/note-tip.js +97 -0
  38. package/esm/table/table-body.js +2 -2
  39. package/esm/table/table-cell.js +1 -1
  40. package/esm/table/table-head.js +4 -2
  41. package/esm/table/table.js +0 -1
  42. package/package.json +14 -7
@@ -0,0 +1,690 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var reactDom = require('@floating-ui/react-dom');
7
+ var theme = require('@helpdice/theme');
8
+ var reactDom$1 = require('react-dom');
9
+
10
+ function _arrayLikeToArray(r, a) {
11
+ (null == a || a > r.length) && (a = r.length);
12
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
13
+ return n;
14
+ }
15
+ function _arrayWithHoles(r) {
16
+ if (Array.isArray(r)) return r;
17
+ }
18
+ function _iterableToArrayLimit(r, l) {
19
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
20
+ if (null != t) {
21
+ var e,
22
+ n,
23
+ i,
24
+ u,
25
+ a = [],
26
+ f = true,
27
+ o = false;
28
+ try {
29
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
30
+ } catch (r) {
31
+ o = true, n = r;
32
+ } finally {
33
+ try {
34
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
35
+ } finally {
36
+ if (o) throw n;
37
+ }
38
+ }
39
+ return a;
40
+ }
41
+ }
42
+ function _nonIterableRest() {
43
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
+ }
45
+ function _slicedToArray(r, e) {
46
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
47
+ }
48
+ function _unsupportedIterableToArray(r, a) {
49
+ if (r) {
50
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
51
+ var t = {}.toString.call(r).slice(8, -1);
52
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
53
+ }
54
+ }
55
+
56
+ function getDefaultExportFromCjs (x) {
57
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
58
+ }
59
+
60
+ var index = {};
61
+
62
+ var hasRequiredIndex;
63
+
64
+ function requireIndex () {
65
+ if (hasRequiredIndex) return index;
66
+ hasRequiredIndex = 1;
67
+ var React$1 = React;
68
+
69
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
70
+
71
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
72
+
73
+ /*
74
+ Based on Glamor's sheet
75
+ https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
76
+ */ function _defineProperties(target, props) {
77
+ for(var i = 0; i < props.length; i++){
78
+ var descriptor = props[i];
79
+ descriptor.enumerable = descriptor.enumerable || false;
80
+ descriptor.configurable = true;
81
+ if ("value" in descriptor) descriptor.writable = true;
82
+ Object.defineProperty(target, descriptor.key, descriptor);
83
+ }
84
+ }
85
+ function _createClass(Constructor, protoProps, staticProps) {
86
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
87
+ return Constructor;
88
+ }
89
+ var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
90
+ var isString = function(o) {
91
+ return Object.prototype.toString.call(o) === "[object String]";
92
+ };
93
+ var StyleSheet = /*#__PURE__*/ function() {
94
+ function StyleSheet(param) {
95
+ var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
96
+ invariant$1(isString(name), "`name` must be a string");
97
+ this._name = name;
98
+ this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
99
+ invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
100
+ this._optimizeForSpeed = optimizeForSpeed;
101
+ this._serverSheet = undefined;
102
+ this._tags = [];
103
+ this._injected = false;
104
+ this._rulesCount = 0;
105
+ var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
106
+ this._nonce = node ? node.getAttribute("content") : null;
107
+ }
108
+ var _proto = StyleSheet.prototype;
109
+ _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
110
+ invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
111
+ invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
112
+ this.flush();
113
+ this._optimizeForSpeed = bool;
114
+ this.inject();
115
+ };
116
+ _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
117
+ return this._optimizeForSpeed;
118
+ };
119
+ _proto.inject = function inject() {
120
+ var _this = this;
121
+ invariant$1(!this._injected, "sheet already injected");
122
+ this._injected = true;
123
+ if (typeof window !== "undefined" && this._optimizeForSpeed) {
124
+ this._tags[0] = this.makeStyleTag(this._name);
125
+ this._optimizeForSpeed = "insertRule" in this.getSheet();
126
+ if (!this._optimizeForSpeed) {
127
+ if (!isProd) {
128
+ console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
129
+ }
130
+ this.flush();
131
+ this._injected = true;
132
+ }
133
+ return;
134
+ }
135
+ this._serverSheet = {
136
+ cssRules: [],
137
+ insertRule: function(rule, index) {
138
+ if (typeof index === "number") {
139
+ _this._serverSheet.cssRules[index] = {
140
+ cssText: rule
141
+ };
142
+ } else {
143
+ _this._serverSheet.cssRules.push({
144
+ cssText: rule
145
+ });
146
+ }
147
+ return index;
148
+ },
149
+ deleteRule: function(index) {
150
+ _this._serverSheet.cssRules[index] = null;
151
+ }
152
+ };
153
+ };
154
+ _proto.getSheetForTag = function getSheetForTag(tag) {
155
+ if (tag.sheet) {
156
+ return tag.sheet;
157
+ }
158
+ // this weirdness brought to you by firefox
159
+ for(var i = 0; i < document.styleSheets.length; i++){
160
+ if (document.styleSheets[i].ownerNode === tag) {
161
+ return document.styleSheets[i];
162
+ }
163
+ }
164
+ };
165
+ _proto.getSheet = function getSheet() {
166
+ return this.getSheetForTag(this._tags[this._tags.length - 1]);
167
+ };
168
+ _proto.insertRule = function insertRule(rule, index) {
169
+ invariant$1(isString(rule), "`insertRule` accepts only strings");
170
+ if (typeof window === "undefined") {
171
+ if (typeof index !== "number") {
172
+ index = this._serverSheet.cssRules.length;
173
+ }
174
+ this._serverSheet.insertRule(rule, index);
175
+ return this._rulesCount++;
176
+ }
177
+ if (this._optimizeForSpeed) {
178
+ var sheet = this.getSheet();
179
+ if (typeof index !== "number") {
180
+ index = sheet.cssRules.length;
181
+ }
182
+ // this weirdness for perf, and chrome's weird bug
183
+ // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
184
+ try {
185
+ sheet.insertRule(rule, index);
186
+ } catch (error) {
187
+ if (!isProd) {
188
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
189
+ }
190
+ return -1;
191
+ }
192
+ } else {
193
+ var insertionPoint = this._tags[index];
194
+ this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
195
+ }
196
+ return this._rulesCount++;
197
+ };
198
+ _proto.replaceRule = function replaceRule(index, rule) {
199
+ if (this._optimizeForSpeed || typeof window === "undefined") {
200
+ var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
201
+ if (!rule.trim()) {
202
+ rule = this._deletedRulePlaceholder;
203
+ }
204
+ if (!sheet.cssRules[index]) {
205
+ // @TBD Should we throw an error?
206
+ return index;
207
+ }
208
+ sheet.deleteRule(index);
209
+ try {
210
+ sheet.insertRule(rule, index);
211
+ } catch (error) {
212
+ if (!isProd) {
213
+ console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
214
+ }
215
+ // In order to preserve the indices we insert a deleteRulePlaceholder
216
+ sheet.insertRule(this._deletedRulePlaceholder, index);
217
+ }
218
+ } else {
219
+ var tag = this._tags[index];
220
+ invariant$1(tag, "old rule at index `" + index + "` not found");
221
+ tag.textContent = rule;
222
+ }
223
+ return index;
224
+ };
225
+ _proto.deleteRule = function deleteRule(index) {
226
+ if (typeof window === "undefined") {
227
+ this._serverSheet.deleteRule(index);
228
+ return;
229
+ }
230
+ if (this._optimizeForSpeed) {
231
+ this.replaceRule(index, "");
232
+ } else {
233
+ var tag = this._tags[index];
234
+ invariant$1(tag, "rule at index `" + index + "` not found");
235
+ tag.parentNode.removeChild(tag);
236
+ this._tags[index] = null;
237
+ }
238
+ };
239
+ _proto.flush = function flush() {
240
+ this._injected = false;
241
+ this._rulesCount = 0;
242
+ if (typeof window !== "undefined") {
243
+ this._tags.forEach(function(tag) {
244
+ return tag && tag.parentNode.removeChild(tag);
245
+ });
246
+ this._tags = [];
247
+ } else {
248
+ // simpler on server
249
+ this._serverSheet.cssRules = [];
250
+ }
251
+ };
252
+ _proto.cssRules = function cssRules() {
253
+ var _this = this;
254
+ if (typeof window === "undefined") {
255
+ return this._serverSheet.cssRules;
256
+ }
257
+ return this._tags.reduce(function(rules, tag) {
258
+ if (tag) {
259
+ rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
260
+ return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
261
+ }));
262
+ } else {
263
+ rules.push(null);
264
+ }
265
+ return rules;
266
+ }, []);
267
+ };
268
+ _proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
269
+ if (cssString) {
270
+ invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
271
+ }
272
+ var tag = document.createElement("style");
273
+ if (this._nonce) tag.setAttribute("nonce", this._nonce);
274
+ tag.type = "text/css";
275
+ tag.setAttribute("data-" + name, "");
276
+ if (cssString) {
277
+ tag.appendChild(document.createTextNode(cssString));
278
+ }
279
+ var head = document.head || document.getElementsByTagName("head")[0];
280
+ if (relativeToTag) {
281
+ head.insertBefore(tag, relativeToTag);
282
+ } else {
283
+ head.appendChild(tag);
284
+ }
285
+ return tag;
286
+ };
287
+ _createClass(StyleSheet, [
288
+ {
289
+ key: "length",
290
+ get: function get() {
291
+ return this._rulesCount;
292
+ }
293
+ }
294
+ ]);
295
+ return StyleSheet;
296
+ }();
297
+ function invariant$1(condition, message) {
298
+ if (!condition) {
299
+ throw new Error("StyleSheet: " + message + ".");
300
+ }
301
+ }
302
+
303
+ function hash(str) {
304
+ var _$hash = 5381, i = str.length;
305
+ while(i){
306
+ _$hash = _$hash * 33 ^ str.charCodeAt(--i);
307
+ }
308
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
309
+ * integers. Since we want the results to be always positive, convert the
310
+ * signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
311
+ }
312
+ var stringHash = hash;
313
+
314
+ var sanitize = function(rule) {
315
+ return rule.replace(/\/style/gi, "\\/style");
316
+ };
317
+ var cache = {};
318
+ /**
319
+ * computeId
320
+ *
321
+ * Compute and memoize a jsx id from a basedId and optionally props.
322
+ */ function computeId(baseId, props) {
323
+ if (!props) {
324
+ return "jsx-" + baseId;
325
+ }
326
+ var propsToString = String(props);
327
+ var key = baseId + propsToString;
328
+ if (!cache[key]) {
329
+ cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
330
+ }
331
+ return cache[key];
332
+ }
333
+ /**
334
+ * computeSelector
335
+ *
336
+ * Compute and memoize dynamic selectors.
337
+ */ function computeSelector(id, css) {
338
+ var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
339
+ // Sanitize SSR-ed CSS.
340
+ // Client side code doesn't need to be sanitized since we use
341
+ // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
342
+ if (typeof window === "undefined") {
343
+ css = sanitize(css);
344
+ }
345
+ var idcss = id + css;
346
+ if (!cache[idcss]) {
347
+ cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
348
+ }
349
+ return cache[idcss];
350
+ }
351
+
352
+ function mapRulesToStyle(cssRules, options) {
353
+ if (options === void 0) options = {};
354
+ return cssRules.map(function(args) {
355
+ var id = args[0];
356
+ var css = args[1];
357
+ return /*#__PURE__*/ React__default["default"].createElement("style", {
358
+ id: "__" + id,
359
+ // Avoid warnings upon render with a key
360
+ key: "__" + id,
361
+ nonce: options.nonce ? options.nonce : undefined,
362
+ dangerouslySetInnerHTML: {
363
+ __html: css
364
+ }
365
+ });
366
+ });
367
+ }
368
+ var StyleSheetRegistry = /*#__PURE__*/ function() {
369
+ function StyleSheetRegistry(param) {
370
+ var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
371
+ this._sheet = styleSheet || new StyleSheet({
372
+ name: "styled-jsx",
373
+ optimizeForSpeed: optimizeForSpeed
374
+ });
375
+ this._sheet.inject();
376
+ if (styleSheet && typeof optimizeForSpeed === "boolean") {
377
+ this._sheet.setOptimizeForSpeed(optimizeForSpeed);
378
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
379
+ }
380
+ this._fromServer = undefined;
381
+ this._indices = {};
382
+ this._instancesCounts = {};
383
+ }
384
+ var _proto = StyleSheetRegistry.prototype;
385
+ _proto.add = function add(props) {
386
+ var _this = this;
387
+ if (undefined === this._optimizeForSpeed) {
388
+ this._optimizeForSpeed = Array.isArray(props.children);
389
+ this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
390
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
391
+ }
392
+ if (typeof window !== "undefined" && !this._fromServer) {
393
+ this._fromServer = this.selectFromServer();
394
+ this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
395
+ acc[tagName] = 0;
396
+ return acc;
397
+ }, {});
398
+ }
399
+ var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
400
+ // Deduping: just increase the instances count.
401
+ if (styleId in this._instancesCounts) {
402
+ this._instancesCounts[styleId] += 1;
403
+ return;
404
+ }
405
+ var indices = rules.map(function(rule) {
406
+ return _this._sheet.insertRule(rule);
407
+ })// Filter out invalid rules
408
+ .filter(function(index) {
409
+ return index !== -1;
410
+ });
411
+ this._indices[styleId] = indices;
412
+ this._instancesCounts[styleId] = 1;
413
+ };
414
+ _proto.remove = function remove(props) {
415
+ var _this = this;
416
+ var styleId = this.getIdAndRules(props).styleId;
417
+ invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
418
+ this._instancesCounts[styleId] -= 1;
419
+ if (this._instancesCounts[styleId] < 1) {
420
+ var tagFromServer = this._fromServer && this._fromServer[styleId];
421
+ if (tagFromServer) {
422
+ tagFromServer.parentNode.removeChild(tagFromServer);
423
+ delete this._fromServer[styleId];
424
+ } else {
425
+ this._indices[styleId].forEach(function(index) {
426
+ return _this._sheet.deleteRule(index);
427
+ });
428
+ delete this._indices[styleId];
429
+ }
430
+ delete this._instancesCounts[styleId];
431
+ }
432
+ };
433
+ _proto.update = function update(props, nextProps) {
434
+ this.add(nextProps);
435
+ this.remove(props);
436
+ };
437
+ _proto.flush = function flush() {
438
+ this._sheet.flush();
439
+ this._sheet.inject();
440
+ this._fromServer = undefined;
441
+ this._indices = {};
442
+ this._instancesCounts = {};
443
+ };
444
+ _proto.cssRules = function cssRules() {
445
+ var _this = this;
446
+ var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
447
+ return [
448
+ styleId,
449
+ _this._fromServer[styleId]
450
+ ];
451
+ }) : [];
452
+ var cssRules = this._sheet.cssRules();
453
+ return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
454
+ return [
455
+ styleId,
456
+ _this._indices[styleId].map(function(index) {
457
+ return cssRules[index].cssText;
458
+ }).join(_this._optimizeForSpeed ? "" : "\n")
459
+ ];
460
+ })// filter out empty rules
461
+ .filter(function(rule) {
462
+ return Boolean(rule[1]);
463
+ }));
464
+ };
465
+ _proto.styles = function styles(options) {
466
+ return mapRulesToStyle(this.cssRules(), options);
467
+ };
468
+ _proto.getIdAndRules = function getIdAndRules(props) {
469
+ var css = props.children, dynamic = props.dynamic, id = props.id;
470
+ if (dynamic) {
471
+ var styleId = computeId(id, dynamic);
472
+ return {
473
+ styleId: styleId,
474
+ rules: Array.isArray(css) ? css.map(function(rule) {
475
+ return computeSelector(styleId, rule);
476
+ }) : [
477
+ computeSelector(styleId, css)
478
+ ]
479
+ };
480
+ }
481
+ return {
482
+ styleId: computeId(id),
483
+ rules: Array.isArray(css) ? css : [
484
+ css
485
+ ]
486
+ };
487
+ };
488
+ /**
489
+ * selectFromServer
490
+ *
491
+ * Collects style tags from the document with id __jsx-XXX
492
+ */ _proto.selectFromServer = function selectFromServer() {
493
+ var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
494
+ return elements.reduce(function(acc, element) {
495
+ var id = element.id.slice(2);
496
+ acc[id] = element;
497
+ return acc;
498
+ }, {});
499
+ };
500
+ return StyleSheetRegistry;
501
+ }();
502
+ function invariant(condition, message) {
503
+ if (!condition) {
504
+ throw new Error("StyleSheetRegistry: " + message + ".");
505
+ }
506
+ }
507
+ var StyleSheetContext = /*#__PURE__*/ React$1.createContext(null);
508
+ StyleSheetContext.displayName = "StyleSheetContext";
509
+ function createStyleRegistry() {
510
+ return new StyleSheetRegistry();
511
+ }
512
+ function StyleRegistry(param) {
513
+ var configuredRegistry = param.registry, children = param.children;
514
+ var rootRegistry = React$1.useContext(StyleSheetContext);
515
+ var ref = React$1.useState(function() {
516
+ return rootRegistry || configuredRegistry || createStyleRegistry();
517
+ }), registry = ref[0];
518
+ return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
519
+ value: registry
520
+ }, children);
521
+ }
522
+ function useStyleRegistry() {
523
+ return React$1.useContext(StyleSheetContext);
524
+ }
525
+
526
+ // Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
527
+ // https://github.com/reactwg/react-18/discussions/110
528
+ var useInsertionEffect = React__default["default"].useInsertionEffect || React$1.useLayoutEffect;
529
+ var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
530
+ function JSXStyle(props) {
531
+ var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
532
+ var insertionEffectCalled = React$1.useRef(false);
533
+ // `registry` might not exist while server-side rendering
534
+ if (!registry) {
535
+ return null;
536
+ }
537
+ if (typeof window === "undefined") {
538
+ registry.add(props);
539
+ return null;
540
+ }
541
+ useInsertionEffect(function() {
542
+ // ReactDOM removes all DOM during hydration in certain cases
543
+ if (!document.head) {
544
+ return;
545
+ }
546
+ registry.add(props);
547
+ insertionEffectCalled.current = true;
548
+ return function() {
549
+ insertionEffectCalled.current = false;
550
+ registry.remove(props);
551
+ };
552
+ }, [
553
+ props.id,
554
+ String(props.dynamic)
555
+ ]);
556
+ React$1.useLayoutEffect(function() {
557
+ if (!document.head || insertionEffectCalled.current) {
558
+ return;
559
+ }
560
+ registry.add(props);
561
+ return function() {
562
+ registry.remove(props);
563
+ };
564
+ // props.children can be string[], will be striped since id is identical
565
+ }, [
566
+ props.id,
567
+ String(props.dynamic)
568
+ ]);
569
+ return null;
570
+ }
571
+ JSXStyle.dynamic = function(info) {
572
+ return info.map(function(tagInfo) {
573
+ var baseId = tagInfo[0];
574
+ var props = tagInfo[1];
575
+ return computeId(baseId, props);
576
+ }).join(" ");
577
+ };
578
+
579
+ index.StyleRegistry = StyleRegistry;
580
+ index.createStyleRegistry = createStyleRegistry;
581
+ index.style = JSXStyle;
582
+ index.useStyleRegistry = useStyleRegistry;
583
+ return index;
584
+ }
585
+
586
+ var style;
587
+ var hasRequiredStyle;
588
+
589
+ function requireStyle () {
590
+ if (hasRequiredStyle) return style;
591
+ hasRequiredStyle = 1;
592
+ style = requireIndex().style;
593
+ return style;
594
+ }
595
+
596
+ var styleExports = requireStyle();
597
+ var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);
598
+
599
+ var Notetip = function Notetip(_ref) {
600
+ var children = _ref.children,
601
+ text = _ref.text,
602
+ _ref$placement = _ref.placement,
603
+ placement = _ref$placement === void 0 ? 'top' : _ref$placement,
604
+ _ref$delay = _ref.delay,
605
+ delay = _ref$delay === void 0 ? 0 : _ref$delay,
606
+ _ref$duration = _ref.duration,
607
+ duration = _ref$duration === void 0 ? 200 : _ref$duration,
608
+ _ref$animation = _ref.animation,
609
+ animation = _ref$animation === void 0 ? 'fade' : _ref$animation;
610
+ var theme$1 = theme.useTheme();
611
+ var _useState = React.useState(false),
612
+ _useState2 = _slicedToArray(_useState, 2),
613
+ open = _useState2[0],
614
+ setOpen = _useState2[1];
615
+ var _useState3 = React.useState(false),
616
+ _useState4 = _slicedToArray(_useState3, 2),
617
+ show = _useState4[0],
618
+ setShow = _useState4[1];
619
+ var arrowRef = React.useRef(null);
620
+ var _useFloating = reactDom.useFloating({
621
+ placement: placement,
622
+ middleware: [reactDom.offset(8), reactDom.flip(), reactDom.shift({
623
+ padding: 5
624
+ }), reactDom.arrow({
625
+ element: arrowRef
626
+ })]
627
+ }),
628
+ x = _useFloating.x,
629
+ y = _useFloating.y,
630
+ refs = _useFloating.refs,
631
+ strategy = _useFloating.strategy;
632
+ React.useEffect(function () {
633
+ var timer;
634
+ if (open) {
635
+ timer = setTimeout(function () {
636
+ return setShow(true);
637
+ }, delay);
638
+ } else {
639
+ setShow(false);
640
+ }
641
+ return function () {
642
+ return clearTimeout(timer);
643
+ };
644
+ }, [open, delay]);
645
+ var handleMouseEnter = function handleMouseEnter() {
646
+ return setOpen(true);
647
+ };
648
+ var handleMouseLeave = function handleMouseLeave() {
649
+ return setOpen(false);
650
+ };
651
+ var handleTouchStart = function handleTouchStart() {
652
+ setOpen(true);
653
+ setTimeout(function () {
654
+ return setOpen(false);
655
+ }, 2000); // auto-hide
656
+ };
657
+
658
+ // const staticSide = {
659
+ // top: 'bottom',
660
+ // right: 'left',
661
+ // bottom: 'top',
662
+ // left: 'right',
663
+ // }[finalPlacement.split('-')[0]];
664
+
665
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
666
+ ref: refs.setReference,
667
+ onMouseEnter: handleMouseEnter,
668
+ onMouseLeave: handleMouseLeave,
669
+ onTouchStart: handleTouchStart,
670
+ className: _JSXStyle.dynamic([["4210526695", [theme$1.palette.accents_1, duration, duration, duration]]]) + " " + "tooltip-reference"
671
+ }, children), show && x != null && y != null && text != null ? /*#__PURE__*/reactDom$1.createPortal(/*#__PURE__*/React.createElement("div", {
672
+ ref: refs.setFloating,
673
+ style: {
674
+ position: strategy,
675
+ top: y !== null && y !== void 0 ? y : 0,
676
+ left: x !== null && x !== void 0 ? x : 0,
677
+ zIndex: 9999,
678
+ // opacity: show ? 1 : 0,
679
+ // visibility: x == null || y == null ? 'hidden' : 'visible',
680
+ transitionProperty: 'opacity, transform',
681
+ transitionDuration: "".concat(duration, "ms")
682
+ },
683
+ className: _JSXStyle.dynamic([["4210526695", [theme$1.palette.accents_1, duration, duration, duration]]]) + " " + "tooltip-box ".concat(animation)
684
+ }, text), document.body) : null, /*#__PURE__*/React.createElement(_JSXStyle, {
685
+ id: "4210526695",
686
+ dynamic: [theme$1.palette.accents_1, duration, duration, duration]
687
+ }, ".tooltip-box.__jsx-style-dynamic-selector{background:".concat(theme$1.palette.accents_1, ";padding:4px 10px;border-radius:4px;font-size:12px;white-space:nowrap;z-index:9999;opacity:0;}.fade.__jsx-style-dynamic-selector{-webkit-animation:fadeIn-__jsx-style-dynamic-selector ").concat(duration, "ms ease forwards;animation:fadeIn-__jsx-style-dynamic-selector ").concat(duration, "ms ease forwards;}@-webkit-keyframes fadeIn-__jsx-style-dynamic-selector{from{opacity:0;}to{opacity:1;}}@keyframes fadeIn-__jsx-style-dynamic-selector{from{opacity:0;}to{opacity:1;}}.scale.__jsx-style-dynamic-selector{-webkit-animation:scaleIn-__jsx-style-dynamic-selector ").concat(duration, "ms ease forwards;animation:scaleIn-__jsx-style-dynamic-selector ").concat(duration, "ms ease forwards;}@-webkit-keyframes scaleIn-__jsx-style-dynamic-selector{from{opacity:0;-webkit-transform:scale(0.95);-ms-transform:scale(0.95);transform:scale(0.95);}to{opacity:1;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}}@keyframes scaleIn-__jsx-style-dynamic-selector{from{opacity:0;-webkit-transform:scale(0.95);-ms-transform:scale(0.95);transform:scale(0.95);}to{opacity:1;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}}.slide.__jsx-style-dynamic-selector{-webkit-animation:slideIn-__jsx-style-dynamic-selector ").concat(duration, "ms ease forwards;animation:slideIn-__jsx-style-dynamic-selector ").concat(duration, "ms ease forwards;}@-webkit-keyframes slideIn-__jsx-style-dynamic-selector{from{opacity:0;-webkit-transform:translateY(5px);-ms-transform:translateY(5px);transform:translateY(5px);}to{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}}@keyframes slideIn-__jsx-style-dynamic-selector{from{opacity:0;-webkit-transform:translateY(5px);-ms-transform:translateY(5px);transform:translateY(5px);}to{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}}")));
688
+ };
689
+
690
+ exports.default = Notetip;
@@ -9,5 +9,5 @@ export type NotetipProps = {
9
9
  duration?: number;
10
10
  animation?: AnimationVariant;
11
11
  };
12
- declare const Tooltip: React.FC<NotetipProps>;
13
- export default Tooltip;
12
+ declare const Notetip: React.FC<NotetipProps>;
13
+ export default Notetip;