@helpdice/ui 2.6.0-beta.8 → 2.6.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/dist/container/index.js +796 -7
- package/dist/expandable/index.js +1496 -10
- package/dist/index.js +110 -112
- package/esm/container/box.js +1 -1
- package/esm/expandable/expand.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,13 +6,11 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var icons = require('@helpdice/icons');
|
|
7
7
|
var framerMotion = require('framer-motion');
|
|
8
8
|
var reactDom = require('react-dom');
|
|
9
|
-
var Expandable$1 = require('components/expandable');
|
|
10
9
|
var reactDom$1 = require('@floating-ui/react-dom');
|
|
11
10
|
var pro = require('@helpdice/pro');
|
|
12
11
|
var reactSyntaxHighlighter = require('react-syntax-highlighter');
|
|
13
12
|
var prism = require('react-syntax-highlighter/dist/cjs/styles/prism');
|
|
14
13
|
var require$$0 = require('react-is');
|
|
15
|
-
var Button$1 = require('components/button');
|
|
16
14
|
var isEqual = require('react-fast-compare');
|
|
17
15
|
|
|
18
16
|
function _interopNamespaceDefault(e) {
|
|
@@ -13390,6 +13388,115 @@ var GridContainer = withScale(GridContainerComponent);
|
|
|
13390
13388
|
|
|
13391
13389
|
Grid.Container = GridContainer;
|
|
13392
13390
|
|
|
13391
|
+
var Expandable = function Expandable(_ref) {
|
|
13392
|
+
var children = _ref.children,
|
|
13393
|
+
_ref$collapsedHeight = _ref.collapsedHeight,
|
|
13394
|
+
collapsedHeight = _ref$collapsedHeight === void 0 ? 150 : _ref$collapsedHeight,
|
|
13395
|
+
_ref$fadeHeight = _ref.fadeHeight,
|
|
13396
|
+
fadeHeight = _ref$fadeHeight === void 0 ? 40 : _ref$fadeHeight,
|
|
13397
|
+
className = _ref.className,
|
|
13398
|
+
_ref$transitionDurati = _ref.transitionDuration,
|
|
13399
|
+
transitionDuration = _ref$transitionDurati === void 0 ? 300 : _ref$transitionDurati;
|
|
13400
|
+
var contentRef = React.useRef(null);
|
|
13401
|
+
var containerRef = React.useRef(null);
|
|
13402
|
+
var _useState = React.useState(false),
|
|
13403
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13404
|
+
expanded = _useState2[0],
|
|
13405
|
+
setExpanded = _useState2[1];
|
|
13406
|
+
var _useState3 = React.useState(false),
|
|
13407
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
13408
|
+
isOverflowing = _useState4[0],
|
|
13409
|
+
setIsOverflowing = _useState4[1];
|
|
13410
|
+
var _useState5 = React.useState(0),
|
|
13411
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
13412
|
+
contentHeight = _useState6[0],
|
|
13413
|
+
setContentHeight = _useState6[1];
|
|
13414
|
+
var _useState7 = React.useState("#fff"),
|
|
13415
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
13416
|
+
fadeColor = _useState8[0],
|
|
13417
|
+
setFadeColor = _useState8[1];
|
|
13418
|
+
|
|
13419
|
+
// Measure content height and detect overflow
|
|
13420
|
+
React.useEffect(function () {
|
|
13421
|
+
var el = contentRef.current;
|
|
13422
|
+
if (!el) return;
|
|
13423
|
+
var updateHeight = function updateHeight() {
|
|
13424
|
+
var _containerRef$current;
|
|
13425
|
+
var scrollHeight = el.scrollHeight;
|
|
13426
|
+
setContentHeight(scrollHeight);
|
|
13427
|
+
setIsOverflowing(scrollHeight > collapsedHeight);
|
|
13428
|
+
|
|
13429
|
+
// Detect background color dynamically
|
|
13430
|
+
var parentBg = window.getComputedStyle((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 ? _containerRef$current : el).backgroundColor;
|
|
13431
|
+
setFadeColor(parentBg || "#fff");
|
|
13432
|
+
};
|
|
13433
|
+
updateHeight();
|
|
13434
|
+
var observer = new ResizeObserver(updateHeight);
|
|
13435
|
+
observer.observe(el);
|
|
13436
|
+
return function () {
|
|
13437
|
+
return observer.disconnect();
|
|
13438
|
+
};
|
|
13439
|
+
}, [children, collapsedHeight]);
|
|
13440
|
+
var containerHeight = !isOverflowing ? contentHeight : expanded ? contentHeight : collapsedHeight;
|
|
13441
|
+
var fadeStyle = {
|
|
13442
|
+
position: "absolute",
|
|
13443
|
+
bottom: 0,
|
|
13444
|
+
left: 0,
|
|
13445
|
+
right: 0,
|
|
13446
|
+
height: fadeHeight,
|
|
13447
|
+
background: "linear-gradient(to bottom, rgba(255,255,255,0), ".concat(fadeColor, ")"),
|
|
13448
|
+
pointerEvents: "none",
|
|
13449
|
+
transition: "opacity ".concat(transitionDuration, "ms ease"),
|
|
13450
|
+
opacity: !expanded && isOverflowing ? 1 : 0
|
|
13451
|
+
};
|
|
13452
|
+
var toggleExpanded = function toggleExpanded() {
|
|
13453
|
+
return setExpanded(function (prev) {
|
|
13454
|
+
return !prev;
|
|
13455
|
+
});
|
|
13456
|
+
};
|
|
13457
|
+
var handleKey = function handleKey(e) {
|
|
13458
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
13459
|
+
e.preventDefault();
|
|
13460
|
+
toggleExpanded();
|
|
13461
|
+
}
|
|
13462
|
+
};
|
|
13463
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
13464
|
+
ref: containerRef,
|
|
13465
|
+
className: className,
|
|
13466
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
13467
|
+
style: {
|
|
13468
|
+
height: containerHeight,
|
|
13469
|
+
overflow: "hidden",
|
|
13470
|
+
transition: "height ".concat(transitionDuration, "ms ease"),
|
|
13471
|
+
position: "relative"
|
|
13472
|
+
},
|
|
13473
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
13474
|
+
ref: contentRef,
|
|
13475
|
+
children: children
|
|
13476
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
13477
|
+
style: fadeStyle
|
|
13478
|
+
})]
|
|
13479
|
+
}), isOverflowing && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
13480
|
+
"aria-expanded": expanded,
|
|
13481
|
+
onKeyDown: handleKey,
|
|
13482
|
+
margin: 0,
|
|
13483
|
+
padding: 0,
|
|
13484
|
+
onClick: function onClick() {
|
|
13485
|
+
return setExpanded(function (prev) {
|
|
13486
|
+
return !prev;
|
|
13487
|
+
});
|
|
13488
|
+
},
|
|
13489
|
+
effect: false,
|
|
13490
|
+
color: "abort",
|
|
13491
|
+
scale: 2 / 3,
|
|
13492
|
+
auto: true,
|
|
13493
|
+
children: /*#__PURE__*/jsxRuntime.jsx("b", {
|
|
13494
|
+
children: expanded ? 'Show less' : 'Show more'
|
|
13495
|
+
})
|
|
13496
|
+
})]
|
|
13497
|
+
});
|
|
13498
|
+
};
|
|
13499
|
+
|
|
13393
13500
|
var _excluded$B = ["gap", "children", "direction", "justify", "alignItems", "alignContent", "collapse", "className"];
|
|
13394
13501
|
var wrap = tuple('nowrap', 'wrap', 'wrap-reverse');
|
|
13395
13502
|
var Container = function Container(_ref) {
|
|
@@ -13425,7 +13532,7 @@ var Container = function Container(_ref) {
|
|
|
13425
13532
|
return /*#__PURE__*/jsxRuntime.jsxs(GridBasicItem, _objectSpread2(_objectSpread2({
|
|
13426
13533
|
className: classes
|
|
13427
13534
|
}, props), {}, {
|
|
13428
|
-
children: [collapse > 10 ? /*#__PURE__*/jsxRuntime.jsx(Expandable
|
|
13535
|
+
children: [collapse > 10 ? /*#__PURE__*/jsxRuntime.jsx(Expandable, {
|
|
13429
13536
|
collapsedHeight: collapse,
|
|
13430
13537
|
children: children
|
|
13431
13538
|
}) : children, styles]
|
|
@@ -42458,115 +42565,6 @@ function Clipboard(props) {
|
|
|
42458
42565
|
}), _objectSpread2({}, props));
|
|
42459
42566
|
}
|
|
42460
42567
|
|
|
42461
|
-
var Expandable = function Expandable(_ref) {
|
|
42462
|
-
var children = _ref.children,
|
|
42463
|
-
_ref$collapsedHeight = _ref.collapsedHeight,
|
|
42464
|
-
collapsedHeight = _ref$collapsedHeight === void 0 ? 150 : _ref$collapsedHeight,
|
|
42465
|
-
_ref$fadeHeight = _ref.fadeHeight,
|
|
42466
|
-
fadeHeight = _ref$fadeHeight === void 0 ? 40 : _ref$fadeHeight,
|
|
42467
|
-
className = _ref.className,
|
|
42468
|
-
_ref$transitionDurati = _ref.transitionDuration,
|
|
42469
|
-
transitionDuration = _ref$transitionDurati === void 0 ? 300 : _ref$transitionDurati;
|
|
42470
|
-
var contentRef = React.useRef(null);
|
|
42471
|
-
var containerRef = React.useRef(null);
|
|
42472
|
-
var _useState = React.useState(false),
|
|
42473
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
42474
|
-
expanded = _useState2[0],
|
|
42475
|
-
setExpanded = _useState2[1];
|
|
42476
|
-
var _useState3 = React.useState(false),
|
|
42477
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
42478
|
-
isOverflowing = _useState4[0],
|
|
42479
|
-
setIsOverflowing = _useState4[1];
|
|
42480
|
-
var _useState5 = React.useState(0),
|
|
42481
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
42482
|
-
contentHeight = _useState6[0],
|
|
42483
|
-
setContentHeight = _useState6[1];
|
|
42484
|
-
var _useState7 = React.useState("#fff"),
|
|
42485
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
42486
|
-
fadeColor = _useState8[0],
|
|
42487
|
-
setFadeColor = _useState8[1];
|
|
42488
|
-
|
|
42489
|
-
// Measure content height and detect overflow
|
|
42490
|
-
React.useEffect(function () {
|
|
42491
|
-
var el = contentRef.current;
|
|
42492
|
-
if (!el) return;
|
|
42493
|
-
var updateHeight = function updateHeight() {
|
|
42494
|
-
var _containerRef$current;
|
|
42495
|
-
var scrollHeight = el.scrollHeight;
|
|
42496
|
-
setContentHeight(scrollHeight);
|
|
42497
|
-
setIsOverflowing(scrollHeight > collapsedHeight);
|
|
42498
|
-
|
|
42499
|
-
// Detect background color dynamically
|
|
42500
|
-
var parentBg = window.getComputedStyle((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 ? _containerRef$current : el).backgroundColor;
|
|
42501
|
-
setFadeColor(parentBg || "#fff");
|
|
42502
|
-
};
|
|
42503
|
-
updateHeight();
|
|
42504
|
-
var observer = new ResizeObserver(updateHeight);
|
|
42505
|
-
observer.observe(el);
|
|
42506
|
-
return function () {
|
|
42507
|
-
return observer.disconnect();
|
|
42508
|
-
};
|
|
42509
|
-
}, [children, collapsedHeight]);
|
|
42510
|
-
var containerHeight = !isOverflowing ? contentHeight : expanded ? contentHeight : collapsedHeight;
|
|
42511
|
-
var fadeStyle = {
|
|
42512
|
-
position: "absolute",
|
|
42513
|
-
bottom: 0,
|
|
42514
|
-
left: 0,
|
|
42515
|
-
right: 0,
|
|
42516
|
-
height: fadeHeight,
|
|
42517
|
-
background: "linear-gradient(to bottom, rgba(255,255,255,0), ".concat(fadeColor, ")"),
|
|
42518
|
-
pointerEvents: "none",
|
|
42519
|
-
transition: "opacity ".concat(transitionDuration, "ms ease"),
|
|
42520
|
-
opacity: !expanded && isOverflowing ? 1 : 0
|
|
42521
|
-
};
|
|
42522
|
-
var toggleExpanded = function toggleExpanded() {
|
|
42523
|
-
return setExpanded(function (prev) {
|
|
42524
|
-
return !prev;
|
|
42525
|
-
});
|
|
42526
|
-
};
|
|
42527
|
-
var handleKey = function handleKey(e) {
|
|
42528
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
42529
|
-
e.preventDefault();
|
|
42530
|
-
toggleExpanded();
|
|
42531
|
-
}
|
|
42532
|
-
};
|
|
42533
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
42534
|
-
ref: containerRef,
|
|
42535
|
-
className: className,
|
|
42536
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
42537
|
-
style: {
|
|
42538
|
-
height: containerHeight,
|
|
42539
|
-
overflow: "hidden",
|
|
42540
|
-
transition: "height ".concat(transitionDuration, "ms ease"),
|
|
42541
|
-
position: "relative"
|
|
42542
|
-
},
|
|
42543
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
42544
|
-
ref: contentRef,
|
|
42545
|
-
children: children
|
|
42546
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
42547
|
-
style: fadeStyle
|
|
42548
|
-
})]
|
|
42549
|
-
}), isOverflowing && /*#__PURE__*/jsxRuntime.jsx(Button$1, {
|
|
42550
|
-
"aria-expanded": expanded,
|
|
42551
|
-
onKeyDown: handleKey,
|
|
42552
|
-
margin: 0,
|
|
42553
|
-
padding: 0,
|
|
42554
|
-
onClick: function onClick() {
|
|
42555
|
-
return setExpanded(function (prev) {
|
|
42556
|
-
return !prev;
|
|
42557
|
-
});
|
|
42558
|
-
},
|
|
42559
|
-
effect: false,
|
|
42560
|
-
color: "abort",
|
|
42561
|
-
scale: 2 / 3,
|
|
42562
|
-
auto: true,
|
|
42563
|
-
children: /*#__PURE__*/jsxRuntime.jsx("b", {
|
|
42564
|
-
children: expanded ? 'Show less' : 'Show more'
|
|
42565
|
-
})
|
|
42566
|
-
})]
|
|
42567
|
-
});
|
|
42568
|
-
};
|
|
42569
|
-
|
|
42570
42568
|
exports.AutoComplete = AutoComplete;
|
|
42571
42569
|
exports.Avatar = Avatar;
|
|
42572
42570
|
exports.Badge = Badge;
|
package/esm/container/box.js
CHANGED
|
@@ -7,7 +7,7 @@ import GridBasicItem from "../grid/basic-item";
|
|
|
7
7
|
import useScale, { withScale } from '../use-scale';
|
|
8
8
|
import { useClasses } from '@helpdice/theme';
|
|
9
9
|
import { tuple } from '../utils/prop-types';
|
|
10
|
-
import Expandable from "
|
|
10
|
+
import Expandable from "../expandable";
|
|
11
11
|
var wrap = tuple('nowrap', 'wrap', 'wrap-reverse');
|
|
12
12
|
var Container = function Container(_ref) {
|
|
13
13
|
var _ref$gap = _ref.gap,
|
package/esm/expandable/expand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import Button from "
|
|
2
|
+
import Button from "../button";
|
|
3
3
|
import React, { useEffect, useRef, useState } from "react";
|
|
4
4
|
var Expandable = function Expandable(_ref) {
|
|
5
5
|
var children = _ref.children,
|