@indico-data/design-system 2.56.0 → 2.57.0

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.
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@ var ReactDOM = require('react-dom');
8
8
  var reactFontawesome = require('@fortawesome/react-fontawesome');
9
9
  var n = require('styled-components');
10
10
  var ReactSelect = require('react-select');
11
+ var node_crypto = require('node:crypto');
11
12
 
12
13
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
14
 
@@ -42899,6 +42900,57 @@ function BarSpinner(_a) {
42899
42900
  return (jsxRuntime.jsx("div", Object.assign({ className: `bar-spinner ${className}`, id: id, style: style }, rest, { children: jsxRuntime.jsx("span", {}) })));
42900
42901
  }
42901
42902
 
42903
+ const urlAlphabet =
42904
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
42905
+
42906
+ const POOL_SIZE_MULTIPLIER = 128;
42907
+ let pool, poolOffset;
42908
+ function fillPool(bytes) {
42909
+ if (!pool || pool.length < bytes) {
42910
+ pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
42911
+ node_crypto.webcrypto.getRandomValues(pool);
42912
+ poolOffset = 0;
42913
+ } else if (poolOffset + bytes > pool.length) {
42914
+ node_crypto.webcrypto.getRandomValues(pool);
42915
+ poolOffset = 0;
42916
+ }
42917
+ poolOffset += bytes;
42918
+ }
42919
+ function nanoid(size = 21) {
42920
+ fillPool((size |= 0));
42921
+ let id = '';
42922
+ for (let i = poolOffset - size; i < poolOffset; i++) {
42923
+ id += urlAlphabet[pool[i] & 63];
42924
+ }
42925
+ return id
42926
+ }
42927
+
42928
+ const Truncate = (_a) => {
42929
+ var { lineClamp = 0, truncateString, hasTooltip = true, tooltipId } = _a, rest = __rest(_a, ["lineClamp", "truncateString", "hasTooltip", "tooltipId"]);
42930
+ const [isTruncated, setIsTruncated] = React.useState(false);
42931
+ const id = (tooltipId !== null && tooltipId !== void 0 ? tooltipId : nanoid()).replace(/[^a-zA-Z0-9-_]/g, '_');
42932
+ React.useEffect(() => {
42933
+ const checkTruncation = () => {
42934
+ const element = document.querySelector(`[data-tooltip-id="${id}"]`);
42935
+ if (element) {
42936
+ if (lineClamp === 0) {
42937
+ setIsTruncated(element.scrollWidth > element.clientWidth);
42938
+ }
42939
+ else {
42940
+ setIsTruncated(element.scrollHeight > element.clientHeight);
42941
+ }
42942
+ }
42943
+ };
42944
+ checkTruncation();
42945
+ window.addEventListener('resize', checkTruncation);
42946
+ return () => window.removeEventListener('resize', checkTruncation);
42947
+ }, [id, lineClamp]);
42948
+ const truncateStyle = {
42949
+ '--line-clamp': lineClamp,
42950
+ };
42951
+ return (jsxRuntime.jsxs("div", { className: "truncate-wrapper", style: truncateStyle, children: [jsxRuntime.jsx("span", Object.assign({ "data-testid": `truncate-${id}-${isTruncated ? 'truncated' : 'not-truncated'}`, "data-tooltip-id": id, "data-tooltip-content": isTruncated ? truncateString : undefined, className: lineClamp > 0 ? 'truncate-clip' : 'truncate' }, rest, { children: truncateString })), isTruncated && truncateString && hasTooltip && (jsxRuntime.jsx(Tooltip, { "data-tooltip-delay-hide": 100, id: id, border: "solid 1px var(--pf-border-color)", children: truncateString }))] }));
42952
+ };
42953
+
42902
42954
  exports.Badge = Badge;
42903
42955
  exports.BarSpinner = BarSpinner;
42904
42956
  exports.Button = Button$1;
@@ -42929,6 +42981,7 @@ exports.Textarea = LabeledTextarea;
42929
42981
  exports.TimePicker = TimePicker;
42930
42982
  exports.ToggleInput = Toggle;
42931
42983
  exports.Tooltip = Tooltip;
42984
+ exports.Truncate = Truncate;
42932
42985
  exports.arrow = arrow$2;
42933
42986
  exports.autoPlacement = autoPlacement;
42934
42987
  exports.autoUpdate = autoUpdate$1;