@phillips/seldon 1.90.0 → 1.91.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/components/ContentPeek/ContentPeek.d.ts +9 -0
- package/dist/components/ContentPeek/ContentPeek.js +51 -45
- package/dist/components/ContentPeek/ContentPeek.stories.d.ts +3 -0
- package/dist/components/ContentPeek/utils.d.ts +4 -0
- package/dist/components/ContentPeek/utils.js +4 -0
- package/dist/node_modules/exenv/index.js +1 -1
- package/dist/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { HeightUnits } from './utils';
|
|
2
3
|
export interface ContentPeekProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
/**
|
|
4
5
|
* Unique id for component testing
|
|
@@ -20,6 +21,14 @@ export interface ContentPeekProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
20
21
|
* Maximum height of the content when collapsed
|
|
21
22
|
*/
|
|
22
23
|
maxHeight?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Used to set a minimum height for the content before enabling the Peek functionality. Defaults to the same value as maxHeight if not provided.
|
|
26
|
+
*/
|
|
27
|
+
minHeightThreshold?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The unit used for setting height values. Defaults to 'px'.
|
|
30
|
+
*/
|
|
31
|
+
heightUnits?: HeightUnits;
|
|
23
32
|
}
|
|
24
33
|
/**
|
|
25
34
|
* ## Overview
|
|
@@ -1,55 +1,61 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { getCommonProps as
|
|
5
|
-
import
|
|
6
|
-
import { ButtonVariants as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
1
|
+
import { jsxs as f, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as P, useState as i, useRef as b, useEffect as k, useCallback as R } from "react";
|
|
3
|
+
import d from "../../node_modules/classnames/index.js";
|
|
4
|
+
import { getCommonProps as w } from "../../utils/index.js";
|
|
5
|
+
import E from "../Button/Button.js";
|
|
6
|
+
import { ButtonVariants as M } from "../Button/types.js";
|
|
7
|
+
import O from "../Collapsible/Collapsible.js";
|
|
8
|
+
import S from "../Collapsible/CollapsibleContent.js";
|
|
9
|
+
import j from "../Collapsible/CollapsibleTrigger.js";
|
|
10
|
+
import B from "../../assets/plus.svg.js";
|
|
11
|
+
import I from "../../assets/minus.svg.js";
|
|
12
|
+
import { HeightUnits as L } from "./utils.js";
|
|
13
|
+
const U = P(
|
|
13
14
|
({
|
|
14
|
-
className:
|
|
15
|
-
children:
|
|
16
|
-
contentExpandText:
|
|
17
|
-
contentCollapseText:
|
|
18
|
-
maxHeight:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
className: p,
|
|
16
|
+
children: m,
|
|
17
|
+
contentExpandText: u = "Read More",
|
|
18
|
+
contentCollapseText: v = "Read Less",
|
|
19
|
+
maxHeight: s = 480,
|
|
20
|
+
minHeightThreshold: a,
|
|
21
|
+
heightUnits: C = L.px,
|
|
22
|
+
...t
|
|
23
|
+
}, g) => {
|
|
24
|
+
const { className: e, ...y } = w(t, "ContentPeek"), [r, N] = i(!1), [c, $] = i(!1), n = b(null);
|
|
25
|
+
k(() => {
|
|
26
|
+
if (n.current) {
|
|
27
|
+
const l = a != null ? a : s;
|
|
28
|
+
$(n.current.scrollHeight > l);
|
|
29
|
+
}
|
|
30
|
+
}, [m, s, a]);
|
|
31
|
+
const x = R(() => {
|
|
32
|
+
N((l) => !l);
|
|
27
33
|
}, []);
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
|
|
34
|
+
return /* @__PURE__ */ f(
|
|
35
|
+
O,
|
|
30
36
|
{
|
|
31
|
-
id:
|
|
32
|
-
open:
|
|
33
|
-
onOpenChange:
|
|
34
|
-
className:
|
|
37
|
+
id: t == null ? void 0 : t.id,
|
|
38
|
+
open: r,
|
|
39
|
+
onOpenChange: x,
|
|
40
|
+
className: d(e, p),
|
|
35
41
|
style: {
|
|
36
|
-
"--content-peek-max-height": `${
|
|
42
|
+
"--content-peek-max-height": `${s}${C}`
|
|
37
43
|
},
|
|
38
|
-
ref:
|
|
39
|
-
...
|
|
40
|
-
...
|
|
44
|
+
ref: g,
|
|
45
|
+
...y,
|
|
46
|
+
...t,
|
|
41
47
|
children: [
|
|
42
|
-
/* @__PURE__ */ o(
|
|
43
|
-
|
|
48
|
+
/* @__PURE__ */ o(S, { className: `${e}-content`, ref: n, forceMount: !0, children: m }),
|
|
49
|
+
c ? /* @__PURE__ */ o(
|
|
44
50
|
"div",
|
|
45
51
|
{
|
|
46
|
-
className:
|
|
47
|
-
[`${e}-overlay--expanded`]:
|
|
48
|
-
[`${e}-overlay--gradient`]:
|
|
52
|
+
className: d(`${e}-overlay`, {
|
|
53
|
+
[`${e}-overlay--expanded`]: r,
|
|
54
|
+
[`${e}-overlay--gradient`]: c && !r
|
|
49
55
|
}),
|
|
50
|
-
children: /* @__PURE__ */ o("div", { className: `${e}-overlay-trigger-wrapper`, children: /* @__PURE__ */ o(
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
children: /* @__PURE__ */ o("div", { className: `${e}-overlay-trigger-wrapper`, children: /* @__PURE__ */ o(j, { asChild: !0, className: `${e}-overlay-trigger`, children: /* @__PURE__ */ f(E, { variant: M.secondary, children: [
|
|
57
|
+
r ? /* @__PURE__ */ o(I, {}) : /* @__PURE__ */ o(B, {}),
|
|
58
|
+
r ? v : u
|
|
53
59
|
] }) }) })
|
|
54
60
|
}
|
|
55
61
|
) : null
|
|
@@ -58,7 +64,7 @@ const j = N(
|
|
|
58
64
|
);
|
|
59
65
|
}
|
|
60
66
|
);
|
|
61
|
-
|
|
67
|
+
U.displayName = "ContentPeek";
|
|
62
68
|
export {
|
|
63
|
-
|
|
69
|
+
U as default
|
|
64
70
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as e } from "../../../../_virtual/
|
|
1
|
+
import { __module as e } from "../../../../_virtual/index6.js";
|
|
2
2
|
import { __require as o } from "./cjs/react-is.production.min.js";
|
|
3
3
|
import { __require as t } from "./cjs/react-is.development.js";
|
|
4
4
|
var r;
|