@bonprix-ds/react-collapsible 1.0.4 → 1.0.6

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 CHANGED
@@ -1,9 +1,12 @@
1
- import { FC } from 'react';
1
+ import { default as default_2 } from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { Ref } from 'react';
4
4
  import { RefObject } from 'react';
5
5
 
6
- declare const Collapsible: FC<CollapsibleProps>;
6
+ declare const Collapsible: {
7
+ ({ title, children, initiallyOpened, rootRef, imperativeRef, id, onOpen, onClose, onInitialInView }: CollapsibleProps): default_2.JSX.Element;
8
+ displayName: string;
9
+ };
7
10
  export default Collapsible;
8
11
 
9
12
  export declare interface CollapsibleImperativeHandle {
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ var d = c({
10
10
  root: "preflight",
11
11
  trigger: [
12
12
  "flex gap-6 justify-between w-full my-5 px-0.25 typography-h5 text-clr-on-bg-high text-start",
13
- "rounded-sm focus-visible:outline outline-clr-on-bg-high group hover:text-clr-on-bg-low",
13
+ "rounded-sm focus-visible:outline outline-offset-2 outline-2 outline-clr-on-bg-high group hover:text-clr-on-bg-low",
14
14
  "[[data-bpds=collapsible]_[data-bpds=collapsible]>_&]:mt-0"
15
15
  ],
16
16
  icon: "fill-clr-on-bg-high transition [button[data-state='open']>&]:rotate-180 ease-out duration-300 group-hover:fill-clr-on-bg-low",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/Collapsible.tsx"],"sourcesContent":["import Icon from \"@bonprix-ds/react-icon\";\nimport { useInitialInView, usePrefersReducedMotion, useTransitionAfterInitialRender } from \"@bonprix-ds/utils\";\nimport { motion } from \"motion/react\";\nimport React, { FC, ReactNode, Ref, RefObject, useId, useImperativeHandle, useState } from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst generateClasses = tv({\n slots: {\n root: \"preflight\",\n trigger: [\n \"flex gap-6 justify-between w-full my-5 px-0.25 typography-h5 text-clr-on-bg-high text-start\",\n \"rounded-sm focus-visible:outline outline-clr-on-bg-high group hover:text-clr-on-bg-low\",\n // Reduce spacing between nested Collapsibles\n \"[[data-bpds=collapsible]_[data-bpds=collapsible]>_&]:mt-0\",\n ],\n icon: \"fill-clr-on-bg-high transition [button[data-state='open']>&]:rotate-180 ease-out duration-300 group-hover:fill-clr-on-bg-low\",\n content: \"typography-body1 text-clr-on-bg-high overflow-hidden\",\n },\n variants: {\n isOpen: {\n true: {\n root: \"mb-5\",\n },\n },\n },\n});\n\nexport interface CollapsibleImperativeHandle {\n open: () => void;\n close: () => void;\n}\n\nexport interface Props {\n /** Brief summary or label for the content within the component. */\n title: ReactNode;\n /** Content of the collapsible, which might be collapsed or expanded. */\n children: ReactNode;\n /** If `true`, the collapsible content will be initially opened. */\n initiallyOpened?: boolean;\n /** A reference to the root element. */\n rootRef?: RefObject<HTMLDivElement | null>;\n /** A reference to the imperative handle of the component. */\n imperativeRef?: Ref<CollapsibleImperativeHandle>;\n /** The id of the collapsible component. */\n id?: string;\n /** Callback function that is called when the collapsible component is opened. */\n onOpen?: () => void;\n /** Callback function that is called when the collapsible component is closed. */\n onClose?: () => void;\n /** Callback function that is called when the collapsible component is initially in view. */\n onInitialInView?: () => void;\n}\n\nconst Collapsible: FC<Props> = ({\n title,\n children,\n initiallyOpened = false,\n rootRef,\n imperativeRef,\n id,\n onOpen,\n onClose,\n onInitialInView,\n}) => {\n const [open, setOpen] = useState(initiallyOpened);\n const { root, trigger, icon, content } = generateClasses({ isOpen: open });\n\n const ref = useInitialInView(rootRef, onInitialInView);\n\n useImperativeHandle(imperativeRef, () => ({\n open: () => {\n setOpen(true);\n onOpen?.();\n },\n close: () => {\n setOpen(false);\n onClose?.();\n },\n }));\n\n const generatedId = useId();\n const collapsibleId = id ?? generatedId;\n\n const onOpenChange = () => {\n if (open) {\n if (onClose) onClose();\n } else {\n if (onOpen) onOpen();\n }\n setOpen(!open);\n };\n\n const prefersReducedMotion = usePrefersReducedMotion();\n const { transitionAfterInitialRender } = useTransitionAfterInitialRender();\n const transition = prefersReducedMotion ? { duration: 0 } : transitionAfterInitialRender;\n\n return (\n <div className={root()} ref={ref} data-bpds=\"collapsible\" data-bpds-initially-opened={initiallyOpened}>\n <button\n id={collapsibleId}\n className={trigger()}\n onClick={onOpenChange}\n aria-expanded={open}\n aria-controls={`${collapsibleId}-content`}\n data-state={open ? \"open\" : \"closed\"}\n type=\"button\"\n >\n {title}\n <Icon variant=\"arrow-down\" className={icon()} />\n </button>\n <motion.div\n id={`${collapsibleId}-content`}\n className={content()}\n animate={{ height: open ? \"auto\" : 0 }}\n transition={transition}\n inert={!open}\n >\n {children}\n </motion.div>\n </div>\n );\n};\n\nCollapsible.displayName = \"Collapsible\";\nexport default Collapsible;\n"],"mappings":";;;;;;;AAMA,IAAM,IAAkB,EAAG;CACzB,OAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GAEA;EACF;EACA,MAAM;EACN,SAAS;CACX;CACA,UAAU,EACR,QAAQ,EACN,MAAM,EACJ,MAAM,OACR,EACF,EACF;AACF,CAAC,GA4BK,KAA0B,EAC9B,UACA,aACA,qBAAkB,IAClB,YACA,kBACA,OACA,WACA,YACA,yBACI;CACJ,IAAM,CAAC,GAAM,KAAW,EAAS,CAAe,GAC1C,EAAE,SAAM,YAAS,SAAM,eAAY,EAAgB,EAAE,QAAQ,EAAK,CAAC,GAEnE,IAAM,EAAiB,GAAS,CAAe;CAErD,EAAoB,UAAsB;EACxC,YAAY;GAEV,AADA,EAAQ,EAAI,GACZ,IAAS;EACX;EACA,aAAa;GAEX,AADA,EAAQ,EAAK,GACb,IAAU;EACZ;CACF,EAAE;CAEF,IAAM,IAAc,EAAM,GACpB,IAAgB,KAAM,GAEtB,UAAqB;EAMzB,AALI,IACE,KAAS,EAAQ,IAEjB,KAAQ,EAAO,GAErB,EAAQ,CAAC,CAAI;CACf,GAEM,IAAuB,EAAwB,GAC/C,EAAE,oCAAiC,EAAgC,GACnE,IAAa,IAAuB,EAAE,UAAU,EAAE,IAAI;CAE5D,OACE,kBAAC,OAAD;EAAK,WAAW,EAAK;EAAQ;EAAK,aAAU;EAAc,8BAA4B;EAAtF,UAAA,CACE,kBAAC,UAAD;GACE,IAAI;GACJ,WAAW,EAAQ;GACnB,SAAS;GACT,iBAAe;GACf,iBAAe,GAAG,EAAc;GAChC,cAAY,IAAO,SAAS;GAC5B,MAAK;GAPP,UAAA,CASG,GACD,kBAAC,GAAD;IAAM,SAAQ;IAAa,WAAW,EAAK;GAAI,CAAA,CACzC;EACR,CAAA,GAAA,kBAAC,EAAO,KAAR;GACE,IAAI,GAAG,EAAc;GACrB,WAAW,EAAQ;GACnB,SAAS,EAAE,QAAQ,IAAO,SAAS,EAAE;GACzB;GACZ,OAAO,CAAC;GAEP;EACS,CAAA,CACT;;AAET;AAEA,EAAY,cAAc"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/Collapsible.tsx"],"sourcesContent":["import Icon from \"@bonprix-ds/react-icon\";\nimport { useInitialInView, usePrefersReducedMotion, useTransitionAfterInitialRender } from \"@bonprix-ds/utils\";\nimport { motion } from \"motion/react\";\nimport React, { ReactNode, Ref, RefObject, useId, useImperativeHandle, useState } from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst generateClasses = tv({\n slots: {\n root: \"preflight\",\n trigger: [\n \"flex gap-6 justify-between w-full my-5 px-0.25 typography-h5 text-clr-on-bg-high text-start\",\n \"rounded-sm focus-visible:outline outline-offset-2 outline-2 outline-clr-on-bg-high group hover:text-clr-on-bg-low\",\n // Reduce spacing between nested Collapsibles\n \"[[data-bpds=collapsible]_[data-bpds=collapsible]>_&]:mt-0\",\n ],\n icon: \"fill-clr-on-bg-high transition [button[data-state='open']>&]:rotate-180 ease-out duration-300 group-hover:fill-clr-on-bg-low\",\n content: \"typography-body1 text-clr-on-bg-high overflow-hidden\",\n },\n variants: {\n isOpen: {\n true: {\n root: \"mb-5\",\n },\n },\n },\n});\n\nexport interface CollapsibleImperativeHandle {\n open: () => void;\n close: () => void;\n}\n\nexport interface Props {\n /** Brief summary or label for the content within the component. */\n title: ReactNode;\n /** Content of the collapsible, which might be collapsed or expanded. */\n children: ReactNode;\n /** If `true`, the collapsible content will be initially opened. */\n initiallyOpened?: boolean;\n /** A reference to the root element. */\n rootRef?: RefObject<HTMLDivElement | null>;\n /** A reference to the imperative handle of the component. */\n imperativeRef?: Ref<CollapsibleImperativeHandle>;\n /** The id of the collapsible component. */\n id?: string;\n /** Callback function that is called when the collapsible component is opened. */\n onOpen?: () => void;\n /** Callback function that is called when the collapsible component is closed. */\n onClose?: () => void;\n /** Callback function that is called when the collapsible component is initially in view. */\n onInitialInView?: () => void;\n}\n\nconst Collapsible = ({ title, children, initiallyOpened = false, rootRef, imperativeRef, id, onOpen, onClose, onInitialInView }: Props) => {\n const [open, setOpen] = useState(initiallyOpened);\n const { root, trigger, icon, content } = generateClasses({ isOpen: open });\n\n const ref = useInitialInView(rootRef, onInitialInView);\n\n useImperativeHandle(imperativeRef, () => ({\n open: () => {\n setOpen(true);\n onOpen?.();\n },\n close: () => {\n setOpen(false);\n onClose?.();\n },\n }));\n\n const generatedId = useId();\n const collapsibleId = id ?? generatedId;\n\n const onOpenChange = () => {\n if (open) {\n if (onClose) onClose();\n } else {\n if (onOpen) onOpen();\n }\n setOpen(!open);\n };\n\n const prefersReducedMotion = usePrefersReducedMotion();\n const { transitionAfterInitialRender } = useTransitionAfterInitialRender();\n const transition = prefersReducedMotion ? { duration: 0 } : transitionAfterInitialRender;\n\n return (\n <div className={root()} ref={ref} data-bpds=\"collapsible\" data-bpds-initially-opened={initiallyOpened}>\n <button\n id={collapsibleId}\n className={trigger()}\n onClick={onOpenChange}\n aria-expanded={open}\n aria-controls={`${collapsibleId}-content`}\n data-state={open ? \"open\" : \"closed\"}\n type=\"button\"\n >\n {title}\n <Icon variant=\"arrow-down\" className={icon()} />\n </button>\n <motion.div\n id={`${collapsibleId}-content`}\n className={content()}\n animate={{ height: open ? \"auto\" : 0 }}\n transition={transition}\n inert={!open}\n >\n {children}\n </motion.div>\n </div>\n );\n};\n\nCollapsible.displayName = \"Collapsible\";\nexport default Collapsible;\n"],"mappings":";;;;;;;AAMA,IAAM,IAAkB,EAAG;CACzB,OAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GAEA;EACF;EACA,MAAM;EACN,SAAS;CACX;CACA,UAAU,EACR,QAAQ,EACN,MAAM,EACJ,MAAM,OACR,EACF,EACF;AACF,CAAC,GA4BK,KAAe,EAAE,UAAO,aAAU,qBAAkB,IAAO,YAAS,kBAAe,OAAI,WAAQ,YAAS,yBAA6B;CACzI,IAAM,CAAC,GAAM,KAAW,EAAS,CAAe,GAC1C,EAAE,SAAM,YAAS,SAAM,eAAY,EAAgB,EAAE,QAAQ,EAAK,CAAC,GAEnE,IAAM,EAAiB,GAAS,CAAe;CAErD,EAAoB,UAAsB;EACxC,YAAY;GAEV,AADA,EAAQ,EAAI,GACZ,IAAS;EACX;EACA,aAAa;GAEX,AADA,EAAQ,EAAK,GACb,IAAU;EACZ;CACF,EAAE;CAEF,IAAM,IAAc,EAAM,GACpB,IAAgB,KAAM,GAEtB,UAAqB;EAMzB,AALI,IACE,KAAS,EAAQ,IAEjB,KAAQ,EAAO,GAErB,EAAQ,CAAC,CAAI;CACf,GAEM,IAAuB,EAAwB,GAC/C,EAAE,oCAAiC,EAAgC,GACnE,IAAa,IAAuB,EAAE,UAAU,EAAE,IAAI;CAE5D,OACE,kBAAC,OAAD;EAAK,WAAW,EAAK;EAAQ;EAAK,aAAU;EAAc,8BAA4B;EAAtF,UAAA,CACE,kBAAC,UAAD;GACE,IAAI;GACJ,WAAW,EAAQ;GACnB,SAAS;GACT,iBAAe;GACf,iBAAe,GAAG,EAAc;GAChC,cAAY,IAAO,SAAS;GAC5B,MAAK;GAPP,UAAA,CASG,GACD,kBAAC,GAAD;IAAM,SAAQ;IAAa,WAAW,EAAK;GAAI,CAAA,CACzC;EACR,CAAA,GAAA,kBAAC,EAAO,KAAR;GACE,IAAI,GAAG,EAAc;GACrB,WAAW,EAAQ;GACnB,SAAS,EAAE,QAAQ,IAAO,SAAS,EAAE;GACzB;GACZ,OAAO,CAAC;GAEP;EACS,CAAA,CACT;;AAET;AAEA,EAAY,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-collapsible",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Collapsible component, implemented in React, for the Bonprix Design System.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -22,16 +22,16 @@
22
22
  ],
23
23
  "keywords": [],
24
24
  "author": "",
25
- "license": "ISC",
25
+ "license": "UNLICENSED",
26
26
  "repository": {
27
27
  "type": "git",
28
28
  "url": "git+https://github.com/bonprix/design-system.git",
29
29
  "directory": "packages/react/collapsible"
30
30
  },
31
31
  "dependencies": {
32
- "motion": "13.0.0",
33
- "@bonprix-ds/react-icon": "1.1.2",
34
- "@bonprix-ds/utils": "0.2.0"
32
+ "motion": "13.1.1",
33
+ "@bonprix-ds/react-icon": "1.1.3",
34
+ "@bonprix-ds/utils": "0.2.1"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "^19.0.0",
@@ -39,12 +39,12 @@
39
39
  "tailwind-variants": "0.3.1"
40
40
  },
41
41
  "devDependencies": {
42
- "vite": "8.2.1",
42
+ "vite": "8.2.2",
43
43
  "@types/react": "19.2.18",
44
- "@vitejs/plugin-react": "6.0.5",
44
+ "@vitejs/plugin-react": "6.1.0",
45
45
  "rollup-preserve-directives": "1.1.3",
46
46
  "unplugin-dts": "1.0.3",
47
- "@microsoft/api-extractor": "7.58.12"
47
+ "@microsoft/api-extractor": "7.59.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "vite build"