@bonprix-ds/react-wrapper-collapsible 1.0.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/index.d.ts +39 -0
- package/dist/index.js +2 -0
- package/dist/src/Collapsible.js +41 -0
- package/dist/src/Collapsible.js.map +1 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CollapsibleImperativeHandle } from '@bonprix-ds/react-collapsible';
|
|
2
|
+
import { CollapsibleProps as CollapsibleProps_2 } from '@bonprix-ds/react-collapsible';
|
|
3
|
+
import { default as default_2 } from 'react';
|
|
4
|
+
|
|
5
|
+
declare const Collapsible: {
|
|
6
|
+
({ title, children, initiallyOpened, rootRef, imperativeRef, id, onOpen, onClose, onInitialInView }: CollapsibleProps): default_2.JSX.Element;
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
9
|
+
export default Collapsible;
|
|
10
|
+
|
|
11
|
+
export { CollapsibleImperativeHandle }
|
|
12
|
+
|
|
13
|
+
export declare type CollapsibleProps = CollapsibleProps_2;
|
|
14
|
+
|
|
15
|
+
export { }
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
declare module "react" {
|
|
20
|
+
namespace JSX {
|
|
21
|
+
interface IntrinsicElements {
|
|
22
|
+
"bpds-collapsible": React.DetailedHTMLProps<
|
|
23
|
+
React.HTMLAttributes<HTMLElement> & {
|
|
24
|
+
"initially-opened"?: string;
|
|
25
|
+
"onbpds-collapsible-open"?: (
|
|
26
|
+
event: import("@bonprix-ds/bpds-collapsible").CollapsibleCustomEvents["bpds-collapsible-open"],
|
|
27
|
+
) => void;
|
|
28
|
+
"onbpds-collapsible-close"?: (
|
|
29
|
+
event: import("@bonprix-ds/bpds-collapsible").CollapsibleCustomEvents["bpds-collapsible-close"],
|
|
30
|
+
) => void;
|
|
31
|
+
"onbpds-collapsible-initial-in-view"?: (
|
|
32
|
+
event: import("@bonprix-ds/bpds-collapsible").CollapsibleCustomEvents["bpds-collapsible-initial-in-view"],
|
|
33
|
+
) => void;
|
|
34
|
+
},
|
|
35
|
+
HTMLElement
|
|
36
|
+
>;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useImperativeHandle as e, useRef as t } from "react";
|
|
3
|
+
import "@bonprix-ds/bpds-collapsible/collapsible.css";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/Collapsible.tsx
|
|
6
|
+
typeof window < "u" && import("@bonprix-ds/bpds-collapsible").then(({ Collapsible: e }) => {
|
|
7
|
+
customElements.get("bpds-collapsible") || customElements.define("bpds-collapsible", e);
|
|
8
|
+
});
|
|
9
|
+
var i = ({ title: i, children: a, initiallyOpened: o = !1, rootRef: s, imperativeRef: c, id: l, onOpen: u, onClose: d, onInitialInView: f }) => {
|
|
10
|
+
let p = t(null);
|
|
11
|
+
return e(c, () => ({
|
|
12
|
+
open: () => {
|
|
13
|
+
p.current && (p.current.open = !0);
|
|
14
|
+
},
|
|
15
|
+
close: () => {
|
|
16
|
+
p.current && (p.current.open = !1);
|
|
17
|
+
}
|
|
18
|
+
})), /* @__PURE__ */ n("bpds-collapsible", {
|
|
19
|
+
"initially-opened": o ? "true" : void 0,
|
|
20
|
+
ref: s,
|
|
21
|
+
id: l,
|
|
22
|
+
"onbpds-collapsible-open": u,
|
|
23
|
+
"onbpds-collapsible-close": d,
|
|
24
|
+
"onbpds-collapsible-initial-in-view": f,
|
|
25
|
+
children: /* @__PURE__ */ r("details", {
|
|
26
|
+
ref: p,
|
|
27
|
+
open: o,
|
|
28
|
+
children: [/* @__PURE__ */ r("summary", { children: [i, /* @__PURE__ */ n("svg", {
|
|
29
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
30
|
+
className: "icon",
|
|
31
|
+
viewBox: "0 0 24 24",
|
|
32
|
+
children: /* @__PURE__ */ n("path", { d: "m12.046 14.424 6.12-6.121a1.2 1.2 0 0 1 1.698 0 .3.3 0 0 1 0 .424l-6.97 6.97a1.2 1.2 0 0 1-1.697 0l-6.97-6.97a.3.3 0 0 1 0-.424 1.2 1.2 0 0 1 1.697 0l6.122 6.121Z" })
|
|
33
|
+
})] }), /* @__PURE__ */ n("div", { children: /* @__PURE__ */ n("div", { children: a }) })]
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
i.displayName = "Collapsible";
|
|
38
|
+
//#endregion
|
|
39
|
+
export { i as default };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=Collapsible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collapsible.js","names":[],"sources":["../../src/Collapsible.tsx"],"sourcesContent":["\"use client\";\n\nimport type { CollapsibleProps } from \"@bonprix-ds/react-collapsible\";\nimport React, { useImperativeHandle, useRef } from \"react\";\n\nimport \"@bonprix-ds/bpds-collapsible/collapsible.css\";\n\n// The element class is loaded lazily and only in the browser: `class X extends HTMLElement` is\n// evaluated at module scope, and `HTMLElement` does not exist in Node, so a static import would\n// throw while the server renders this component. Registering before the markup arrives is not\n// possible either way; the JSX below renders the open state itself, so the component works without\n// JavaScript and the upgrade only adds the animation and the custom events.\n// The registry check has to sit inside the callback, not beside the window guard: the tag can be\n// registered during the await - `defineCustomElements` from the umbrella does exactly that - and\n// `define` throws `NotSupportedError` on a name that is already taken.\nif (typeof window !== \"undefined\") {\n void import(\"@bonprix-ds/bpds-collapsible\").then(({ Collapsible }) => {\n if (!customElements.get(\"bpds-collapsible\")) customElements.define(\"bpds-collapsible\", Collapsible);\n });\n}\n\nexport type Props = CollapsibleProps;\n\nconst Collapsible = ({ title, children, initiallyOpened = false, rootRef, imperativeRef, id, onOpen, onClose, onInitialInView }: Props) => {\n const detailsRef = useRef<HTMLDetailsElement>(null);\n\n useImperativeHandle(imperativeRef, () => ({\n open: () => {\n if (detailsRef.current) detailsRef.current.open = true;\n },\n close: () => {\n if (detailsRef.current) detailsRef.current.open = false;\n },\n }));\n\n return (\n <bpds-collapsible\n initially-opened={initiallyOpened ? \"true\" : undefined}\n ref={rootRef}\n id={id}\n onbpds-collapsible-open={onOpen}\n onbpds-collapsible-close={onClose}\n onbpds-collapsible-initial-in-view={onInitialInView}\n >\n {/* `open` is rendered here rather than left to the element's connectedCallback so the markup\n is already correct without JavaScript, and hydration finds the DOM it rendered. */}\n <details ref={detailsRef} open={initiallyOpened}>\n <summary>\n {title}\n <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"icon\" viewBox=\"0 0 24 24\">\n <path d=\"m12.046 14.424 6.12-6.121a1.2 1.2 0 0 1 1.698 0 .3.3 0 0 1 0 .424l-6.97 6.97a1.2 1.2 0 0 1-1.697 0l-6.97-6.97a.3.3 0 0 1 0-.424 1.2 1.2 0 0 1 1.697 0l6.122 6.121Z\" />\n </svg>\n </summary>\n <div>\n <div>{children}</div>\n </div>\n </details>\n </bpds-collapsible>\n );\n};\n\nCollapsible.displayName = \"Collapsible\";\n\nexport default Collapsible;\n"],"mappings":";;;;;AAeI,OAAO,SAAW,OACpB,OAAY,+BAA+B,CAAC,MAAM,EAAE,qBAAkB;CACpE,AAAK,eAAe,IAAI,kBAAkB,KAAG,eAAe,OAAO,oBAAoB,CAAW;AACpG,CAAC;AAKH,IAAM,KAAe,EAAE,UAAO,aAAU,qBAAkB,IAAO,YAAS,kBAAe,OAAI,WAAQ,YAAS,yBAA6B;CACzI,IAAM,IAAa,EAA2B,IAAI;CAWlD,OATA,EAAoB,UAAsB;EACxC,YAAY;GACV,AAAI,EAAW,YAAS,EAAW,QAAQ,OAAO;EACpD;EACA,aAAa;GACX,AAAI,EAAW,YAAS,EAAW,QAAQ,OAAO;EACpD;CACF,EAAE,GAGA,kBAAC,oBAAD;EACE,oBAAkB,IAAkB,SAAS,KAAA;EAC7C,KAAK;EACD;EACJ,2BAAyB;EACzB,4BAA0B;EAC1B,sCAAoC;EAIpC,UAAA,kBAAC,WAAD;GAAS,KAAK;GAAY,MAAM;GAAhC,UAAA,CACE,kBAAC,WAAD,EAAA,UAAA,CACG,GACD,kBAAC,OAAD;IAAK,OAAM;IAA6B,WAAU;IAAO,SAAQ;IAC/D,UAAA,kBAAC,QAAD,EAAM,GAAE,qKAAsK,CAAA;GAC3K,CAAA,CACE,EAAA,CAAA,GACT,kBAAC,OAAD,EAAA,UACE,kBAAC,OAAD,EAAM,YAAc,CAAA,EACjB,CAAA,CACE;;CACO,CAAA;AAEtB;AAEA,EAAY,cAAc"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bonprix-ds/react-wrapper-collapsible",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Collapsible component, implemented as a React wrapper around bpds-collapsible, for the Bonprix Design System.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"provenance": true
|
|
9
|
+
},
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"**/*.css"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [],
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "UNLICENSED",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/bonprix/design-system.git",
|
|
31
|
+
"directory": "packages/react-wrappers/collapsible"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@bonprix-ds/bpds-collapsible": "1.0.0",
|
|
35
|
+
"@bonprix-ds/react-collapsible": "1.0.6"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^19.0.0",
|
|
39
|
+
"react-dom": "^19.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"vite": "8.2.2",
|
|
43
|
+
"@types/react": "19.2.18",
|
|
44
|
+
"@vitejs/plugin-react": "6.1.1",
|
|
45
|
+
"rollup-preserve-directives": "1.1.3",
|
|
46
|
+
"unplugin-dts": "1.1.0",
|
|
47
|
+
"@microsoft/api-extractor": "7.59.1"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "vite build"
|
|
51
|
+
}
|
|
52
|
+
}
|