@caspeco/casper-ui-library 9.6.2 → 9.7.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.
@@ -0,0 +1,4 @@
1
+ export declare const DefaultState: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const CollapsedState: () => import("react/jsx-runtime").JSX.Element;
3
+ export declare const NonCollapsibleContent: () => import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=collapsible.composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapsible.composition.d.ts","sourceRoot":"","sources":["../../../lib/components/collapsible/collapsible.composition.tsx"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY,+CAIxB,CAAC;AAEF,eAAO,MAAM,cAAc,+CAI1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,+CAIjC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { CollapsibleProps } from './types.js';
2
+ export declare const Collapsible: ({ children, collapsedHeight, defaultExpanded, locale, }: CollapsibleProps) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=collapsible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapsible.d.ts","sourceRoot":"","sources":["../../../lib/components/collapsible/collapsible.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,eAAO,MAAM,WAAW,GAAI,yDAKzB,gBAAgB,4CAwFlB,CAAC"}
@@ -0,0 +1,117 @@
1
+ import { jsx as e, jsxs as I } from "react/jsx-runtime";
2
+ import { Collapsible as o, Box as a, Flex as R } from "@chakra-ui/react";
3
+ import { useState as m, useRef as y, useLayoutEffect as O } from "react";
4
+ import { useRemoveAttributes as S } from "../../hooks/use-remove-attributes.js";
5
+ import { translations as f } from "./translations.js";
6
+ import { ThemeSpaceVariable as D, ThemeColorVariable as d } from "../../theme/theme-types.js";
7
+ import { ExpandIcon as E } from "../icon/icons/expand-icon.js";
8
+ const s = "200ms", k = ({
9
+ children: h,
10
+ collapsedHeight: r,
11
+ defaultExpanded: b = !0,
12
+ locale: l = "en-US"
13
+ }) => {
14
+ const [g, C] = m(b), [c, x] = m(!0), i = y(null), t = c ? g : !0;
15
+ return S(i, ["inert"], !t), O(() => {
16
+ const n = i.current;
17
+ if (!n) return;
18
+ const p = () => {
19
+ const v = n.getBoundingClientRect().height;
20
+ x(v > r);
21
+ };
22
+ p();
23
+ const u = new ResizeObserver(p);
24
+ return u.observe(n), () => {
25
+ u.disconnect();
26
+ };
27
+ }, [r]), /* @__PURE__ */ e(
28
+ o.Root,
29
+ {
30
+ collapsedHeight: r,
31
+ open: t,
32
+ onOpenChange: ({ open: n }) => {
33
+ C(n);
34
+ },
35
+ children: /* @__PURE__ */ I(a, { position: "relative", children: [
36
+ /* @__PURE__ */ e(
37
+ o.Content,
38
+ {
39
+ _open: {
40
+ animationDuration: s
41
+ },
42
+ _closed: {
43
+ animationDuration: s
44
+ },
45
+ children: /* @__PURE__ */ e(a, { ref: i, children: h })
46
+ }
47
+ ),
48
+ !t && /* @__PURE__ */ e(T, {}),
49
+ c && /* @__PURE__ */ e(
50
+ R,
51
+ {
52
+ css: t ? {
53
+ position: "relative"
54
+ } : {
55
+ position: "absolute",
56
+ bottom: 0,
57
+ left: 0,
58
+ right: 0,
59
+ transform: `translateY(${D.XSmall})`
60
+ },
61
+ alignItems: "center",
62
+ justifyContent: "center",
63
+ width: "100%",
64
+ children: /* @__PURE__ */ e(o.Trigger, { children: /* @__PURE__ */ e(
65
+ o.Indicator,
66
+ {
67
+ width: 40,
68
+ height: 40,
69
+ display: "flex",
70
+ alignItems: "center",
71
+ justifyContent: "center",
72
+ transition: `transform ${s} ease`,
73
+ "aria-label": t ? f[l].collapseContent : f[l].expandContent,
74
+ _open: { transform: "rotate(180deg)" },
75
+ children: /* @__PURE__ */ e(E, {})
76
+ }
77
+ ) })
78
+ }
79
+ )
80
+ ] })
81
+ }
82
+ );
83
+ }, T = () => /* @__PURE__ */ e(
84
+ a,
85
+ {
86
+ "data-testid": "blur-overlay",
87
+ css: {
88
+ position: "absolute",
89
+ bottom: 0,
90
+ left: 0,
91
+ right: 0,
92
+ height: "36px",
93
+ pointerEvents: "none",
94
+ "&::before": {
95
+ content: '""',
96
+ position: "absolute",
97
+ top: 0,
98
+ left: 0,
99
+ right: 0,
100
+ height: "20px",
101
+ background: `linear-gradient(to bottom, rgba(255, 255, 255, 0.00) 2.18%, ${d.Surface} 97.81%)`
102
+ },
103
+ "&::after": {
104
+ content: '""',
105
+ position: "absolute",
106
+ bottom: 0,
107
+ left: 0,
108
+ right: 0,
109
+ height: "calc(100% - 20px)",
110
+ background: d.Surface
111
+ }
112
+ }
113
+ }
114
+ );
115
+ export {
116
+ k as Collapsible
117
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=collapsible.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapsible.spec.d.ts","sourceRoot":"","sources":["../../../lib/components/collapsible/collapsible.spec.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=collapsible.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapsible.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/collapsible/collapsible.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { Collapsible } from './collapsible.js';
2
+ export type { CollapsibleProps } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/collapsible/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,32 @@
1
+ export type Locales = "en-US" | "nb-NO" | "da-DK" | "sv-SE" | "en-GB" | "fr-FR" | "nl-BE";
2
+ export declare const translations: {
3
+ "sv-SE": {
4
+ collapseContent: string;
5
+ expandContent: string;
6
+ };
7
+ "en-US": {
8
+ collapseContent: string;
9
+ expandContent: string;
10
+ };
11
+ "en-GB": {
12
+ collapseContent: string;
13
+ expandContent: string;
14
+ };
15
+ "nb-NO": {
16
+ collapseContent: string;
17
+ expandContent: string;
18
+ };
19
+ "da-DK": {
20
+ collapseContent: string;
21
+ expandContent: string;
22
+ };
23
+ "fr-FR": {
24
+ collapseContent: string;
25
+ expandContent: string;
26
+ };
27
+ "nl-BE": {
28
+ collapseContent: string;
29
+ expandContent: string;
30
+ };
31
+ };
32
+ //# sourceMappingURL=translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../lib/components/collapsible/translations.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAO1F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBxB,CAAC"}
@@ -0,0 +1,30 @@
1
+ const n = {
2
+ collapseContent: "Collapse content",
3
+ expandContent: "Expand content"
4
+ }, e = {
5
+ "sv-SE": {
6
+ collapseContent: "Kollapsa innehåll",
7
+ expandContent: "Expandera innehåll"
8
+ },
9
+ "en-US": n,
10
+ "en-GB": n,
11
+ "nb-NO": {
12
+ collapseContent: "Skjul innhold",
13
+ expandContent: "Vis innhold"
14
+ },
15
+ "da-DK": {
16
+ collapseContent: "Skjul indhold",
17
+ expandContent: "Vis indhold"
18
+ },
19
+ "fr-FR": {
20
+ collapseContent: "Réduire le contenu",
21
+ expandContent: "Afficher le contenu"
22
+ },
23
+ "nl-BE": {
24
+ collapseContent: "Inhoud samenvouwen",
25
+ expandContent: "Inhoud uitvouwen"
26
+ }
27
+ };
28
+ export {
29
+ e as translations
30
+ };
@@ -0,0 +1,15 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { Locales } from './translations.js';
3
+ export type CollapsibleProps = PropsWithChildren<{
4
+ /** The height (in pixels) at which the content should be collapsed. If the content's height is less than or equal to this value, it will not be collapsible. */
5
+ collapsedHeight: number;
6
+ /** Whether the content should be expanded by default. */
7
+ defaultExpanded?: boolean;
8
+ /**
9
+ * Locale used for translation of text contents native to the collapsible, such as aria-labels for the trigger button.
10
+ * Defaults to 'en-US'.
11
+ */
12
+ locale?: Locales;
13
+ }>;
14
+ export type { Locales };
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/components/collapsible/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;IAChD,gKAAgK;IAChK,eAAe,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC,CAAC;AAEH,YAAY,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Watches an element and strips the given attributes whenever they are added to
4
+ * it or its descendants, keeping them interactive / unstyled even when a parent
5
+ * component would otherwise set those attributes.
6
+ *
7
+ * @param ref - Ref to the root element to observe.
8
+ * @param attributes - One or more attribute names to remove (e.g. `["inert"]`).
9
+ * @param active - Whether the hook should run. Set to `false` when observation
10
+ * is not needed so the MutationObserver is not running unnecessarily.
11
+ * Defaults to `true`.
12
+ */
13
+ export declare const useRemoveAttributes: (ref: RefObject<HTMLElement | null>, attributes: string[], active?: boolean) => void;
14
+ //# sourceMappingURL=use-remove-attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-remove-attributes.d.ts","sourceRoot":"","sources":["../../lib/hooks/use-remove-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAC/B,KAAK,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAClC,YAAY,MAAM,EAAE,EACpB,gBAAa,SAoBb,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { useEffect as b } from "react";
2
+ const f = (o, e, u = !0) => {
3
+ b(() => {
4
+ const t = o.current;
5
+ if (!u || !t || e.length === 0) return;
6
+ const n = () => {
7
+ for (const r of e)
8
+ t.removeAttribute(r), t.querySelectorAll(`[${r}]`).forEach((c) => c.removeAttribute(r));
9
+ };
10
+ n();
11
+ const s = new MutationObserver(n);
12
+ return s.observe(t, { subtree: !0, attributes: !0, attributeFilter: e }), () => s.disconnect();
13
+ }, [o, u, e]);
14
+ };
15
+ export {
16
+ f as useRemoveAttributes
17
+ };
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from './components/breadcrumbs/index.js';
9
9
  export * from './components/button/index.js';
10
10
  export * from './components/checkbox/index.js';
11
11
  export * from './components/checkbox-group/index.js';
12
+ export * from './components/collapsible/index.js';
12
13
  export * from './components/combobox/index.js';
13
14
  export * from './components/date-picker/index.js';
14
15
  export * from './components/divider/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC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