@postenbring/hedwig-react 0.0.85 → 0.0.87
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/accordion/accordion-content.mjs +2 -2
- package/dist/accordion/accordion-header.mjs +2 -2
- package/dist/accordion/accordion-item.mjs +2 -2
- package/dist/accordion/accordion.mjs +5 -5
- package/dist/accordion/context.mjs +1 -1
- package/dist/accordion/index.mjs +5 -5
- package/dist/badge/badge.mjs +2 -2
- package/dist/badge/index.mjs +2 -2
- package/dist/box/box.mjs +2 -2
- package/dist/box/index.mjs +2 -2
- package/dist/breadcrumbs/breadcrumbs.mjs +2 -2
- package/dist/breadcrumbs/index.mjs +2 -2
- package/dist/button/button.mjs +2 -2
- package/dist/button/index.mjs +2 -2
- package/dist/card/card.mjs +2 -2
- package/dist/card/index.mjs +2 -2
- package/dist/{chunk-CCVZAHYA.mjs → chunk-35QRZSEV.mjs} +2 -2
- package/dist/{chunk-AJWSQEDP.mjs → chunk-3OGHJOJF.mjs} +2 -2
- package/dist/{chunk-USXU6ULZ.mjs → chunk-4QZR2H72.mjs} +2 -2
- package/dist/{chunk-FB5GEZNH.mjs → chunk-5UGT7L7R.mjs} +3 -3
- package/dist/{chunk-XFODQH3I.mjs → chunk-6BXKRPR3.mjs} +3 -3
- package/dist/{chunk-IHZ2MRF6.mjs → chunk-6VKQ6IRG.mjs} +8 -12
- package/dist/{chunk-IHZ2MRF6.mjs.map → chunk-6VKQ6IRG.mjs.map} +1 -1
- package/dist/{chunk-F4STR6SD.mjs → chunk-7ROE6ADK.mjs} +2 -3
- package/dist/{chunk-F4STR6SD.mjs.map → chunk-7ROE6ADK.mjs.map} +1 -1
- package/dist/{chunk-YSFZCRWS.mjs → chunk-A42PXOVR.mjs} +2 -2
- package/dist/{chunk-6MR5XZOX.mjs → chunk-AYCHNAU7.mjs} +2 -2
- package/dist/{chunk-NU6OSFAU.mjs → chunk-AZ6X4L5C.mjs} +2 -2
- package/dist/{chunk-SQ63E7KM.mjs → chunk-BHQ46L2O.mjs} +3 -3
- package/dist/{chunk-HMATZX4A.mjs → chunk-C7ZTOZP3.mjs} +2 -2
- package/dist/{chunk-RZZDMBB7.mjs → chunk-CC5QWW52.mjs} +2 -2
- package/dist/{chunk-B6L7IFDX.mjs → chunk-CXX4SXJG.mjs} +5 -5
- package/dist/{chunk-GGQB2WWD.mjs → chunk-DMOMTRIY.mjs} +2 -2
- package/dist/{chunk-L4YBHIS3.mjs → chunk-EMQB6JIS.mjs} +2 -2
- package/dist/{chunk-SKVM7G76.mjs → chunk-EZVEYJOX.mjs} +2 -2
- package/dist/{chunk-KI6WRKZY.mjs → chunk-F4EAUOJX.mjs} +4 -4
- package/dist/{chunk-AXKJB47E.mjs → chunk-FUIKSOJF.mjs} +3 -3
- package/dist/{chunk-O4HIHUMD.mjs → chunk-GUNPGSAS.mjs} +6 -8
- package/dist/{chunk-O4HIHUMD.mjs.map → chunk-GUNPGSAS.mjs.map} +1 -1
- package/dist/{chunk-TDXU2IC6.mjs → chunk-ILFK3VKS.mjs} +7 -12
- package/dist/{chunk-TDXU2IC6.mjs.map → chunk-ILFK3VKS.mjs.map} +1 -1
- package/dist/{chunk-AXQCREUJ.mjs → chunk-J5SCUELT.mjs} +4 -5
- package/dist/{chunk-AXQCREUJ.mjs.map → chunk-J5SCUELT.mjs.map} +1 -1
- package/dist/{chunk-UB2R7TCG.mjs → chunk-JUHJZLH2.mjs} +2 -2
- package/dist/{chunk-VCQIR53Y.mjs → chunk-JZXZYEPG.mjs} +2 -2
- package/dist/{chunk-6FBPKLWB.mjs → chunk-KCEWKQ4W.mjs} +8 -13
- package/dist/{chunk-6FBPKLWB.mjs.map → chunk-KCEWKQ4W.mjs.map} +1 -1
- package/dist/{chunk-QZZIOBF4.mjs → chunk-KNGG6M2I.mjs} +7 -7
- package/dist/{chunk-WHMIHTPC.mjs → chunk-LGEGXOPU.mjs} +2 -2
- package/dist/{chunk-HJYS664B.mjs → chunk-MYVC3HMO.mjs} +2 -2
- package/dist/{chunk-WPCWXROV.mjs → chunk-NIYDN3Y3.mjs} +3 -3
- package/dist/{chunk-I3ZIMS72.mjs → chunk-OFY2FVXB.mjs} +2 -2
- package/dist/{chunk-GRWLX5BC.mjs → chunk-ROQH67YP.mjs} +5 -5
- package/dist/{chunk-GGNMBB3K.mjs → chunk-S3QSGJX2.mjs} +3 -3
- package/dist/{chunk-UP3M3NEZ.mjs → chunk-TC5PD4TA.mjs} +3 -3
- package/dist/{chunk-GQUFERB2.mjs → chunk-TCO3ZAZW.mjs} +2 -2
- package/dist/{chunk-MJ2DZH3N.mjs → chunk-VYS2QNTL.mjs} +2 -2
- package/dist/{chunk-LG7QWKFP.mjs → chunk-WEQIEPMT.mjs} +3 -3
- package/dist/{chunk-JF3HBGAA.mjs → chunk-WLESNP6Z.mjs} +2 -2
- package/dist/{chunk-BVPSZ3JI.mjs → chunk-WUPLEZEY.mjs} +4 -4
- package/dist/{chunk-5UJ3LEKK.mjs → chunk-XQBJ75VD.mjs} +2 -2
- package/dist/{chunk-EVUKWONG.mjs → chunk-YIERXOCG.mjs} +3 -3
- package/dist/{chunk-OIC2CPID.mjs → chunk-YLBJMVIX.mjs} +3 -3
- package/dist/{chunk-R4SQKVDQ.mjs → chunk-YOSPWY5K.mjs} +1 -1
- package/dist/{chunk-D7QPJIUZ.mjs → chunk-YZDURLEY.mjs} +3 -3
- package/dist/{chunk-COEZA7WA.mjs → chunk-Z2ZCM4BE.mjs} +3 -3
- package/dist/{chunk-EMI7NAO2.mjs → chunk-ZOZPWP3N.mjs} +2 -2
- package/dist/{chunk-GJO7Z2YL.mjs → chunk-ZYTUK4B4.mjs} +3 -3
- package/dist/description-list/description-list.mjs +2 -2
- package/dist/description-list/index.mjs +2 -2
- package/dist/footer/footer.mjs +9 -9
- package/dist/footer/index.mjs +9 -9
- package/dist/form/checkbox/checkbox.mjs +4 -4
- package/dist/form/checkbox/index.mjs +4 -4
- package/dist/form/date-picker/date-picker.mjs +5 -5
- package/dist/form/date-picker/index.mjs +5 -5
- package/dist/form/error-message/error-message.mjs +2 -2
- package/dist/form/error-message/index.mjs +2 -2
- package/dist/form/fieldset/fieldset.mjs +3 -3
- package/dist/form/fieldset/index.mjs +3 -3
- package/dist/form/index.js +2 -4
- package/dist/form/index.js.map +1 -1
- package/dist/form/index.mjs +16 -16
- package/dist/form/input/index.mjs +4 -4
- package/dist/form/input/input.mjs +4 -4
- package/dist/form/input-group/index.mjs +3 -3
- package/dist/form/input-group/input-group.mjs +3 -3
- package/dist/form/radiobutton/index.js +2 -4
- package/dist/form/radiobutton/index.js.map +1 -1
- package/dist/form/radiobutton/index.mjs +5 -5
- package/dist/form/radiobutton/radiobutton.js +2 -4
- package/dist/form/radiobutton/radiobutton.js.map +1 -1
- package/dist/form/radiobutton/radiobutton.mjs +5 -5
- package/dist/form/radiobutton/radiogroup.mjs +4 -4
- package/dist/form/select/index.mjs +4 -4
- package/dist/form/select/select.mjs +4 -4
- package/dist/form/textarea/index.mjs +4 -4
- package/dist/form/textarea/textarea.mjs +4 -4
- package/dist/help-text/help-text.mjs +3 -3
- package/dist/help-text/index.mjs +3 -3
- package/dist/index.d.ts +25 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -69
- package/dist/index.mjs.map +1 -1
- package/dist/layout/container/container.mjs +2 -2
- package/dist/layout/grid/grid.js +1 -2
- package/dist/layout/grid/grid.js.map +1 -1
- package/dist/layout/grid/grid.mjs +3 -3
- package/dist/layout/grid/index.js +1 -2
- package/dist/layout/grid/index.js.map +1 -1
- package/dist/layout/grid/index.mjs +3 -3
- package/dist/layout/index.js +1 -2
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/index.mjs +5 -5
- package/dist/layout/responsive.js +1 -2
- package/dist/layout/responsive.js.map +1 -1
- package/dist/layout/responsive.mjs +2 -2
- package/dist/layout/spacing.mjs +1 -1
- package/dist/layout/stack/index.js +1 -2
- package/dist/layout/stack/index.js.map +1 -1
- package/dist/layout/stack/index.mjs +3 -3
- package/dist/layout/stack/stack.js +1 -2
- package/dist/layout/stack/stack.js.map +1 -1
- package/dist/layout/stack/stack.mjs +3 -3
- package/dist/link/index.mjs +2 -2
- package/dist/link/link.mjs +2 -2
- package/dist/list/index.mjs +3 -3
- package/dist/list/link-list.mjs +3 -3
- package/dist/list/list.mjs +2 -2
- package/dist/message/index.mjs +3 -3
- package/dist/message/message.mjs +3 -3
- package/dist/modal/index.js +4 -8
- package/dist/modal/index.js.map +1 -1
- package/dist/modal/index.mjs +4 -4
- package/dist/modal/modal.js +4 -8
- package/dist/modal/modal.js.map +1 -1
- package/dist/modal/modal.mjs +4 -4
- package/dist/navbar/icons.mjs +1 -1
- package/dist/navbar/index.js +6 -11
- package/dist/navbar/index.js.map +1 -1
- package/dist/navbar/index.mjs +4 -4
- package/dist/navbar/navbar-expandable-menu.js +6 -11
- package/dist/navbar/navbar-expandable-menu.js.map +1 -1
- package/dist/navbar/navbar-expandable-menu.mjs +3 -3
- package/dist/navbar/navbar.js +6 -11
- package/dist/navbar/navbar.js.map +1 -1
- package/dist/navbar/navbar.mjs +4 -4
- package/dist/show-more/index.mjs +2 -2
- package/dist/show-more/show-more.mjs +2 -2
- package/dist/skeleton/index.mjs +2 -2
- package/dist/skeleton/skeleton.mjs +2 -2
- package/dist/step-indicator/index.mjs +2 -2
- package/dist/step-indicator/step-indicator.mjs +2 -2
- package/dist/styled-html/index.mjs +2 -2
- package/dist/styled-html/styled-html.mjs +2 -2
- package/dist/table/index.mjs +2 -2
- package/dist/table/table.mjs +2 -2
- package/dist/tabs/context.mjs +1 -1
- package/dist/tabs/index.js +1 -2
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +8 -8
- package/dist/tabs/tabs-content.mjs +2 -2
- package/dist/tabs/tabs-list.js +1 -2
- package/dist/tabs/tabs-list.js.map +1 -1
- package/dist/tabs/tabs-list.mjs +3 -3
- package/dist/tabs/tabs.js +1 -2
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tabs/tabs.mjs +5 -5
- package/dist/text/index.mjs +2 -2
- package/dist/text/text.mjs +2 -2
- package/dist/utils/auto-animate-height.js +5 -10
- package/dist/utils/auto-animate-height.js.map +1 -1
- package/dist/utils/auto-animate-height.mjs +3 -3
- package/dist/utils/index.js +11 -21
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +3 -3
- package/dist/utils/utils.js +6 -11
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/utils.mjs +2 -2
- package/dist/warning-banner/index.mjs +2 -2
- package/dist/warning-banner/warning-banner.mjs +2 -2
- package/package.json +4 -4
- package/dist/chunk-JBWAZQKM.mjs +0 -1
- package/dist/chunk-R4SQKVDQ.mjs.map +0 -1
- package/dist/index-no-css.d.ts +0 -26
- package/dist/index-no-css.d.ts.map +0 -1
- package/dist/index-no-css.js +0 -2622
- package/dist/index-no-css.js.map +0 -1
- package/dist/index-no-css.mjs +0 -299
- package/dist/index-no-css.mjs.map +0 -1
- package/src/index.tsx +0 -11
- /package/dist/{chunk-CCVZAHYA.mjs.map → chunk-35QRZSEV.mjs.map} +0 -0
- /package/dist/{chunk-AJWSQEDP.mjs.map → chunk-3OGHJOJF.mjs.map} +0 -0
- /package/dist/{chunk-USXU6ULZ.mjs.map → chunk-4QZR2H72.mjs.map} +0 -0
- /package/dist/{chunk-FB5GEZNH.mjs.map → chunk-5UGT7L7R.mjs.map} +0 -0
- /package/dist/{chunk-XFODQH3I.mjs.map → chunk-6BXKRPR3.mjs.map} +0 -0
- /package/dist/{chunk-YSFZCRWS.mjs.map → chunk-A42PXOVR.mjs.map} +0 -0
- /package/dist/{chunk-6MR5XZOX.mjs.map → chunk-AYCHNAU7.mjs.map} +0 -0
- /package/dist/{chunk-NU6OSFAU.mjs.map → chunk-AZ6X4L5C.mjs.map} +0 -0
- /package/dist/{chunk-SQ63E7KM.mjs.map → chunk-BHQ46L2O.mjs.map} +0 -0
- /package/dist/{chunk-HMATZX4A.mjs.map → chunk-C7ZTOZP3.mjs.map} +0 -0
- /package/dist/{chunk-RZZDMBB7.mjs.map → chunk-CC5QWW52.mjs.map} +0 -0
- /package/dist/{chunk-B6L7IFDX.mjs.map → chunk-CXX4SXJG.mjs.map} +0 -0
- /package/dist/{chunk-GGQB2WWD.mjs.map → chunk-DMOMTRIY.mjs.map} +0 -0
- /package/dist/{chunk-L4YBHIS3.mjs.map → chunk-EMQB6JIS.mjs.map} +0 -0
- /package/dist/{chunk-SKVM7G76.mjs.map → chunk-EZVEYJOX.mjs.map} +0 -0
- /package/dist/{chunk-KI6WRKZY.mjs.map → chunk-F4EAUOJX.mjs.map} +0 -0
- /package/dist/{chunk-AXKJB47E.mjs.map → chunk-FUIKSOJF.mjs.map} +0 -0
- /package/dist/{chunk-UB2R7TCG.mjs.map → chunk-JUHJZLH2.mjs.map} +0 -0
- /package/dist/{chunk-VCQIR53Y.mjs.map → chunk-JZXZYEPG.mjs.map} +0 -0
- /package/dist/{chunk-QZZIOBF4.mjs.map → chunk-KNGG6M2I.mjs.map} +0 -0
- /package/dist/{chunk-WHMIHTPC.mjs.map → chunk-LGEGXOPU.mjs.map} +0 -0
- /package/dist/{chunk-HJYS664B.mjs.map → chunk-MYVC3HMO.mjs.map} +0 -0
- /package/dist/{chunk-WPCWXROV.mjs.map → chunk-NIYDN3Y3.mjs.map} +0 -0
- /package/dist/{chunk-I3ZIMS72.mjs.map → chunk-OFY2FVXB.mjs.map} +0 -0
- /package/dist/{chunk-GRWLX5BC.mjs.map → chunk-ROQH67YP.mjs.map} +0 -0
- /package/dist/{chunk-GGNMBB3K.mjs.map → chunk-S3QSGJX2.mjs.map} +0 -0
- /package/dist/{chunk-UP3M3NEZ.mjs.map → chunk-TC5PD4TA.mjs.map} +0 -0
- /package/dist/{chunk-GQUFERB2.mjs.map → chunk-TCO3ZAZW.mjs.map} +0 -0
- /package/dist/{chunk-MJ2DZH3N.mjs.map → chunk-VYS2QNTL.mjs.map} +0 -0
- /package/dist/{chunk-LG7QWKFP.mjs.map → chunk-WEQIEPMT.mjs.map} +0 -0
- /package/dist/{chunk-JF3HBGAA.mjs.map → chunk-WLESNP6Z.mjs.map} +0 -0
- /package/dist/{chunk-BVPSZ3JI.mjs.map → chunk-WUPLEZEY.mjs.map} +0 -0
- /package/dist/{chunk-5UJ3LEKK.mjs.map → chunk-XQBJ75VD.mjs.map} +0 -0
- /package/dist/{chunk-EVUKWONG.mjs.map → chunk-YIERXOCG.mjs.map} +0 -0
- /package/dist/{chunk-OIC2CPID.mjs.map → chunk-YLBJMVIX.mjs.map} +0 -0
- /package/dist/{chunk-JBWAZQKM.mjs.map → chunk-YOSPWY5K.mjs.map} +0 -0
- /package/dist/{chunk-D7QPJIUZ.mjs.map → chunk-YZDURLEY.mjs.map} +0 -0
- /package/dist/{chunk-COEZA7WA.mjs.map → chunk-Z2ZCM4BE.mjs.map} +0 -0
- /package/dist/{chunk-EMI7NAO2.mjs.map → chunk-ZOZPWP3N.mjs.map} +0 -0
- /package/dist/{chunk-GJO7Z2YL.mjs.map → chunk-ZYTUK4B4.mjs.map} +0 -0
- /package/src/{index-no-css.tsx → index.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layout/stack/index.tsx","../../../src/layout/stack/stack.tsx","../../../src/layout/spacing.ts","../../../src/layout/responsive.ts"],"sourcesContent":["export { Stack, HStack, VStack } from \"./stack\";\nexport type * from \"./stack\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { getSpacingVariable, type ResponsiveSpacingSizes, type SpacingSizes } from \"../spacing\";\nimport { getResponsiveProps, type ResponsiveProp } from \"../responsive\";\n\ntype CSSPropertiesWithVar = React.CSSProperties & {\n \"--hds-stack-gap\"?: string;\n \"--hds-stack-direction\"?: string;\n \"--hds-stack-wrap\"?: string;\n \"--hds-stack-align\"?: string;\n \"--hds-stack-justify\"?: string;\n};\n\nexport interface StackProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n\n /**\n * Space between items. Both horizontal and vertical.\n *\n * Use the responsive shorthand `12-16` to jump a level at the `large` breakpoint.\n *\n * Or use the responsive object `{ initial: 40, large: 64 }` to set different values at different breakpoints.\n *\n * Use `gapX` and `gapY` to set different values for horizontal and vertical spacing.\n */\n gap?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items horizontally\n */\n gapX?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items vertically\n */\n gapY?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n direction?: ResponsiveProp<React.CSSProperties[\"flexDirection\"]>;\n wrap?: ResponsiveProp<boolean>;\n align?: ResponsiveProp<React.CSSProperties[\"alignItems\"]>;\n justify?: ResponsiveProp<React.CSSProperties[\"justifyContent\"]>;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const Stack = forwardRef<HTMLDivElement, StackProps>(\n (\n {\n children,\n asChild,\n className,\n style: _style,\n gap,\n gapX,\n gapY,\n direction,\n wrap,\n align,\n justify,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : \"div\";\n const style: CSSPropertiesWithVar = {\n ..._style,\n ...getResponsiveProps(\"--hds-stack-gap\", gap, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-x\", gapX, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-y\", gapY, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-direction\", direction),\n ...getResponsiveProps(\"--hds-stack-wrap\", wrap, (value) => (value ? \"wrap\" : \"nowrap\")),\n ...getResponsiveProps(\"--hds-stack-align\", align),\n ...getResponsiveProps(\"--hds-stack-justify\", justify),\n };\n return (\n <Component\n style={style}\n className={clsx(\"hds-stack\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStack.displayName = \"Stack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const HStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"row\" />;\n});\nHStack.displayName = \"HStack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const VStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"column\" />;\n});\nVStack.displayName = \"VStack\";\n","// TODO: Get from tokens package\n// For now it's fine, since it's still in this monorepo\nconst spacingSizes = {\n \"4\": \"4\",\n \"8\": \"8\",\n \"12\": \"12\",\n \"16\": \"16\",\n \"20\": \"20\",\n \"24\": \"24\",\n \"32\": \"32\",\n \"40\": \"40\",\n \"48\": \"48\",\n \"64\": \"64\",\n \"80\": \"80\",\n \"120\": \"120\",\n} as const;\nexport type SpacingSizes = keyof typeof spacingSizes;\n\nconst responsiveSpacingSizes = {\n \"4-8\": \"4-8\",\n \"8-12\": \"8-12\",\n \"12-16\": \"12-16\",\n \"16-20\": \"16-20\",\n \"20-24\": \"20-24\",\n \"24-32\": \"24-32\",\n \"32-40\": \"32-40\",\n \"40-48\": \"40-48\",\n \"48-64\": \"48-64\",\n \"64-80\": \"64-80\",\n \"80-120\": \"80-120\",\n \"120-160\": \"120-160\",\n} as const;\nexport type ResponsiveSpacingSizes = keyof typeof responsiveSpacingSizes;\n\nexport function getSpacingVariable(size: SpacingSizes | ResponsiveSpacingSizes) {\n return `var(--hds-spacing-${size})`;\n}\n","type Breakpoints = \"initial\" | \"small\" | \"medium\" | \"large\" | \"xlarge\";\n\ntype ResponsiveValues<T> = {\n [Breakpoint in Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | ResponsiveValues<T>;\n\nexport function getResponsiveProps<T>(\n variable: `--hds-${string}`,\n inputValues?: ResponsiveProp<T>,\n valueTransformer: (value: T) => string = (value) => String(value),\n) {\n if (!inputValues) return {};\n\n if (typeof inputValues !== \"object\") {\n return { [`${variable}-initial`]: valueTransformer(inputValues) };\n }\n\n const result: Record<string, string> = {};\n for (const [key, value] of Object.entries(inputValues as ResponsiveValues<T>)) {\n result[`${variable}-${key}`] = valueTransformer(value);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,6BAAqB;AACrB,mBAA2B;AAC3B,wBAAqB;;;AC+Bd,SAAS,mBAAmB,MAA6C;AAC9E,SAAO,qBAAqB,IAAI;AAClC;;;AC5BO,SAAS,mBACd,UACA,aACA,mBAAyC,CAAC,UAAU,OAAO,KAAK,GAChE;AACA,MAAI,CAAC
|
|
1
|
+
{"version":3,"sources":["../../../src/layout/stack/index.tsx","../../../src/layout/stack/stack.tsx","../../../src/layout/spacing.ts","../../../src/layout/responsive.ts"],"sourcesContent":["export { Stack, HStack, VStack } from \"./stack\";\nexport type * from \"./stack\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { getSpacingVariable, type ResponsiveSpacingSizes, type SpacingSizes } from \"../spacing\";\nimport { getResponsiveProps, type ResponsiveProp } from \"../responsive\";\n\ntype CSSPropertiesWithVar = React.CSSProperties & {\n \"--hds-stack-gap\"?: string;\n \"--hds-stack-direction\"?: string;\n \"--hds-stack-wrap\"?: string;\n \"--hds-stack-align\"?: string;\n \"--hds-stack-justify\"?: string;\n};\n\nexport interface StackProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n\n /**\n * Space between items. Both horizontal and vertical.\n *\n * Use the responsive shorthand `12-16` to jump a level at the `large` breakpoint.\n *\n * Or use the responsive object `{ initial: 40, large: 64 }` to set different values at different breakpoints.\n *\n * Use `gapX` and `gapY` to set different values for horizontal and vertical spacing.\n */\n gap?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items horizontally\n */\n gapX?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items vertically\n */\n gapY?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n direction?: ResponsiveProp<React.CSSProperties[\"flexDirection\"]>;\n wrap?: ResponsiveProp<boolean>;\n align?: ResponsiveProp<React.CSSProperties[\"alignItems\"]>;\n justify?: ResponsiveProp<React.CSSProperties[\"justifyContent\"]>;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const Stack = forwardRef<HTMLDivElement, StackProps>(\n (\n {\n children,\n asChild,\n className,\n style: _style,\n gap,\n gapX,\n gapY,\n direction,\n wrap,\n align,\n justify,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : \"div\";\n const style: CSSPropertiesWithVar = {\n ..._style,\n ...getResponsiveProps(\"--hds-stack-gap\", gap, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-x\", gapX, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-y\", gapY, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-direction\", direction),\n ...getResponsiveProps(\"--hds-stack-wrap\", wrap, (value) => (value ? \"wrap\" : \"nowrap\")),\n ...getResponsiveProps(\"--hds-stack-align\", align),\n ...getResponsiveProps(\"--hds-stack-justify\", justify),\n };\n return (\n <Component\n style={style}\n className={clsx(\"hds-stack\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStack.displayName = \"Stack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const HStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"row\" />;\n});\nHStack.displayName = \"HStack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const VStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"column\" />;\n});\nVStack.displayName = \"VStack\";\n","// TODO: Get from tokens package\n// For now it's fine, since it's still in this monorepo\nconst spacingSizes = {\n \"4\": \"4\",\n \"8\": \"8\",\n \"12\": \"12\",\n \"16\": \"16\",\n \"20\": \"20\",\n \"24\": \"24\",\n \"32\": \"32\",\n \"40\": \"40\",\n \"48\": \"48\",\n \"64\": \"64\",\n \"80\": \"80\",\n \"120\": \"120\",\n} as const;\nexport type SpacingSizes = keyof typeof spacingSizes;\n\nconst responsiveSpacingSizes = {\n \"4-8\": \"4-8\",\n \"8-12\": \"8-12\",\n \"12-16\": \"12-16\",\n \"16-20\": \"16-20\",\n \"20-24\": \"20-24\",\n \"24-32\": \"24-32\",\n \"32-40\": \"32-40\",\n \"40-48\": \"40-48\",\n \"48-64\": \"48-64\",\n \"64-80\": \"64-80\",\n \"80-120\": \"80-120\",\n \"120-160\": \"120-160\",\n} as const;\nexport type ResponsiveSpacingSizes = keyof typeof responsiveSpacingSizes;\n\nexport function getSpacingVariable(size: SpacingSizes | ResponsiveSpacingSizes) {\n return `var(--hds-spacing-${size})`;\n}\n","type Breakpoints = \"initial\" | \"small\" | \"medium\" | \"large\" | \"xlarge\";\n\ntype ResponsiveValues<T> = {\n [Breakpoint in Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | ResponsiveValues<T>;\n\nexport function getResponsiveProps<T>(\n variable: `--hds-${string}`,\n inputValues?: ResponsiveProp<T>,\n valueTransformer: (value: T) => string = (value) => String(value),\n) {\n if (!inputValues) return {};\n\n if (typeof inputValues !== \"object\") {\n return { [`${variable}-initial`]: valueTransformer(inputValues) };\n }\n\n const result: Record<string, string> = {};\n for (const [key, value] of Object.entries(inputValues as ResponsiveValues<T>)) {\n result[`${variable}-${key}`] = valueTransformer(value);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,6BAAqB;AACrB,mBAA2B;AAC3B,wBAAqB;;;AC+Bd,SAAS,mBAAmB,MAA6C;AAC9E,SAAO,qBAAqB,IAAI;AAClC;;;AC5BO,SAAS,mBACd,UACA,aACA,mBAAyC,CAAC,UAAU,OAAO,KAAK,GAChE;AACA,MAAI,CAAC,YAAa,QAAO,CAAC;AAE1B,MAAI,OAAO,gBAAgB,UAAU;AACnC,WAAO,EAAE,CAAC,GAAG,QAAQ,UAAU,GAAG,iBAAiB,WAAW,EAAE;AAAA,EAClE;AAEA,QAAM,SAAiC,CAAC;AACxC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAkC,GAAG;AAC7E,WAAO,GAAG,QAAQ,IAAI,GAAG,EAAE,IAAI,iBAAiB,KAAK;AAAA,EACvD;AAEA,SAAO;AACT;;;AFiEM;AA9BC,IAAM,YAAQ;AAAA,EACnB,CACE,IAcA,QACG;AAfH,iBACE;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAzEN,IA8DI,IAYK,iBAZL,IAYK;AAAA,MAXH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,YAAY,UAAU,yBAAO;AACnC,UAAM,QAA8B,4HAC/B,SACA,mBAAmB,mBAAmB,KAAK,kBAAkB,IAC7D,mBAAmB,qBAAqB,MAAM,kBAAkB,IAChE,mBAAmB,qBAAqB,MAAM,kBAAkB,IAChE,mBAAmB,yBAAyB,SAAS,IACrD,mBAAmB,oBAAoB,MAAM,CAAC,UAAW,QAAQ,SAAS,QAAS,IACnF,mBAAmB,qBAAqB,KAAK,IAC7C,mBAAmB,uBAAuB,OAAO;AAEtD,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAW,6BAAK,aAAa,SAAsB;AAAA,QACnD;AAAA,SACI,OAJL;AAAA,QAME;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,MAAM,cAAc;AAUb,IAAM,aAAS,yBAA0D,CAAC,OAAO,QAAQ;AAC9F,SAAO,4CAAC,sCAAM,OAAc,QAApB,EAA2B,WAAU,QAAM;AACrD,CAAC;AACD,OAAO,cAAc;AAUd,IAAM,aAAS,yBAA0D,CAAC,OAAO,QAAQ;AAC9F,SAAO,4CAAC,sCAAM,OAAc,QAApB,EAA2B,WAAU,WAAS;AACxD,CAAC;AACD,OAAO,cAAc;","names":[]}
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
HStack,
|
|
4
4
|
Stack,
|
|
5
5
|
VStack
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
6
|
+
} from "../../chunk-FUIKSOJF.mjs";
|
|
7
|
+
import "../../chunk-7ROE6ADK.mjs";
|
|
8
8
|
import "../../chunk-NE6W2PCD.mjs";
|
|
9
|
-
import "../../chunk-
|
|
9
|
+
import "../../chunk-YOSPWY5K.mjs";
|
|
10
10
|
export {
|
|
11
11
|
HStack,
|
|
12
12
|
Stack,
|
|
@@ -66,8 +66,7 @@ function getSpacingVariable(size) {
|
|
|
66
66
|
|
|
67
67
|
// src/layout/responsive.ts
|
|
68
68
|
function getResponsiveProps(variable, inputValues, valueTransformer = (value) => String(value)) {
|
|
69
|
-
if (!inputValues)
|
|
70
|
-
return {};
|
|
69
|
+
if (!inputValues) return {};
|
|
71
70
|
if (typeof inputValues !== "object") {
|
|
72
71
|
return { [`${variable}-initial`]: valueTransformer(inputValues) };
|
|
73
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/layout/stack/stack.tsx","../../../src/layout/spacing.ts","../../../src/layout/responsive.ts"],"sourcesContent":["import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { getSpacingVariable, type ResponsiveSpacingSizes, type SpacingSizes } from \"../spacing\";\nimport { getResponsiveProps, type ResponsiveProp } from \"../responsive\";\n\ntype CSSPropertiesWithVar = React.CSSProperties & {\n \"--hds-stack-gap\"?: string;\n \"--hds-stack-direction\"?: string;\n \"--hds-stack-wrap\"?: string;\n \"--hds-stack-align\"?: string;\n \"--hds-stack-justify\"?: string;\n};\n\nexport interface StackProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n\n /**\n * Space between items. Both horizontal and vertical.\n *\n * Use the responsive shorthand `12-16` to jump a level at the `large` breakpoint.\n *\n * Or use the responsive object `{ initial: 40, large: 64 }` to set different values at different breakpoints.\n *\n * Use `gapX` and `gapY` to set different values for horizontal and vertical spacing.\n */\n gap?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items horizontally\n */\n gapX?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items vertically\n */\n gapY?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n direction?: ResponsiveProp<React.CSSProperties[\"flexDirection\"]>;\n wrap?: ResponsiveProp<boolean>;\n align?: ResponsiveProp<React.CSSProperties[\"alignItems\"]>;\n justify?: ResponsiveProp<React.CSSProperties[\"justifyContent\"]>;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const Stack = forwardRef<HTMLDivElement, StackProps>(\n (\n {\n children,\n asChild,\n className,\n style: _style,\n gap,\n gapX,\n gapY,\n direction,\n wrap,\n align,\n justify,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : \"div\";\n const style: CSSPropertiesWithVar = {\n ..._style,\n ...getResponsiveProps(\"--hds-stack-gap\", gap, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-x\", gapX, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-y\", gapY, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-direction\", direction),\n ...getResponsiveProps(\"--hds-stack-wrap\", wrap, (value) => (value ? \"wrap\" : \"nowrap\")),\n ...getResponsiveProps(\"--hds-stack-align\", align),\n ...getResponsiveProps(\"--hds-stack-justify\", justify),\n };\n return (\n <Component\n style={style}\n className={clsx(\"hds-stack\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStack.displayName = \"Stack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const HStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"row\" />;\n});\nHStack.displayName = \"HStack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const VStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"column\" />;\n});\nVStack.displayName = \"VStack\";\n","// TODO: Get from tokens package\n// For now it's fine, since it's still in this monorepo\nconst spacingSizes = {\n \"4\": \"4\",\n \"8\": \"8\",\n \"12\": \"12\",\n \"16\": \"16\",\n \"20\": \"20\",\n \"24\": \"24\",\n \"32\": \"32\",\n \"40\": \"40\",\n \"48\": \"48\",\n \"64\": \"64\",\n \"80\": \"80\",\n \"120\": \"120\",\n} as const;\nexport type SpacingSizes = keyof typeof spacingSizes;\n\nconst responsiveSpacingSizes = {\n \"4-8\": \"4-8\",\n \"8-12\": \"8-12\",\n \"12-16\": \"12-16\",\n \"16-20\": \"16-20\",\n \"20-24\": \"20-24\",\n \"24-32\": \"24-32\",\n \"32-40\": \"32-40\",\n \"40-48\": \"40-48\",\n \"48-64\": \"48-64\",\n \"64-80\": \"64-80\",\n \"80-120\": \"80-120\",\n \"120-160\": \"120-160\",\n} as const;\nexport type ResponsiveSpacingSizes = keyof typeof responsiveSpacingSizes;\n\nexport function getSpacingVariable(size: SpacingSizes | ResponsiveSpacingSizes) {\n return `var(--hds-spacing-${size})`;\n}\n","type Breakpoints = \"initial\" | \"small\" | \"medium\" | \"large\" | \"xlarge\";\n\ntype ResponsiveValues<T> = {\n [Breakpoint in Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | ResponsiveValues<T>;\n\nexport function getResponsiveProps<T>(\n variable: `--hds-${string}`,\n inputValues?: ResponsiveProp<T>,\n valueTransformer: (value: T) => string = (value) => String(value),\n) {\n if (!inputValues) return {};\n\n if (typeof inputValues !== \"object\") {\n return { [`${variable}-initial`]: valueTransformer(inputValues) };\n }\n\n const result: Record<string, string> = {};\n for (const [key, value] of Object.entries(inputValues as ResponsiveValues<T>)) {\n result[`${variable}-${key}`] = valueTransformer(value);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,6BAAqB;AACrB,mBAA2B;AAC3B,wBAAqB;;;AC+Bd,SAAS,mBAAmB,MAA6C;AAC9E,SAAO,qBAAqB,IAAI;AAClC;;;AC5BO,SAAS,mBACd,UACA,aACA,mBAAyC,CAAC,UAAU,OAAO,KAAK,GAChE;AACA,MAAI,CAAC
|
|
1
|
+
{"version":3,"sources":["../../../src/layout/stack/stack.tsx","../../../src/layout/spacing.ts","../../../src/layout/responsive.ts"],"sourcesContent":["import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { getSpacingVariable, type ResponsiveSpacingSizes, type SpacingSizes } from \"../spacing\";\nimport { getResponsiveProps, type ResponsiveProp } from \"../responsive\";\n\ntype CSSPropertiesWithVar = React.CSSProperties & {\n \"--hds-stack-gap\"?: string;\n \"--hds-stack-direction\"?: string;\n \"--hds-stack-wrap\"?: string;\n \"--hds-stack-align\"?: string;\n \"--hds-stack-justify\"?: string;\n};\n\nexport interface StackProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n\n /**\n * Space between items. Both horizontal and vertical.\n *\n * Use the responsive shorthand `12-16` to jump a level at the `large` breakpoint.\n *\n * Or use the responsive object `{ initial: 40, large: 64 }` to set different values at different breakpoints.\n *\n * Use `gapX` and `gapY` to set different values for horizontal and vertical spacing.\n */\n gap?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items horizontally\n */\n gapX?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n /**\n * Space between items vertically\n */\n gapY?: ResponsiveProp<SpacingSizes> | ResponsiveSpacingSizes;\n\n direction?: ResponsiveProp<React.CSSProperties[\"flexDirection\"]>;\n wrap?: ResponsiveProp<boolean>;\n align?: ResponsiveProp<React.CSSProperties[\"alignItems\"]>;\n justify?: ResponsiveProp<React.CSSProperties[\"justifyContent\"]>;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const Stack = forwardRef<HTMLDivElement, StackProps>(\n (\n {\n children,\n asChild,\n className,\n style: _style,\n gap,\n gapX,\n gapY,\n direction,\n wrap,\n align,\n justify,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : \"div\";\n const style: CSSPropertiesWithVar = {\n ..._style,\n ...getResponsiveProps(\"--hds-stack-gap\", gap, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-x\", gapX, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-gap-y\", gapY, getSpacingVariable),\n ...getResponsiveProps(\"--hds-stack-direction\", direction),\n ...getResponsiveProps(\"--hds-stack-wrap\", wrap, (value) => (value ? \"wrap\" : \"nowrap\")),\n ...getResponsiveProps(\"--hds-stack-align\", align),\n ...getResponsiveProps(\"--hds-stack-justify\", justify),\n };\n return (\n <Component\n style={style}\n className={clsx(\"hds-stack\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStack.displayName = \"Stack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const HStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"row\" />;\n});\nHStack.displayName = \"HStack\";\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n *\n * TODO\n * - [ ] Add more examples\n * - [ ] Document usage\n * - [ ] Document props\n */\nexport const VStack = forwardRef<HTMLDivElement, Omit<StackProps, \"direction\">>((props, ref) => {\n return <Stack ref={ref} {...props} direction=\"column\" />;\n});\nVStack.displayName = \"VStack\";\n","// TODO: Get from tokens package\n// For now it's fine, since it's still in this monorepo\nconst spacingSizes = {\n \"4\": \"4\",\n \"8\": \"8\",\n \"12\": \"12\",\n \"16\": \"16\",\n \"20\": \"20\",\n \"24\": \"24\",\n \"32\": \"32\",\n \"40\": \"40\",\n \"48\": \"48\",\n \"64\": \"64\",\n \"80\": \"80\",\n \"120\": \"120\",\n} as const;\nexport type SpacingSizes = keyof typeof spacingSizes;\n\nconst responsiveSpacingSizes = {\n \"4-8\": \"4-8\",\n \"8-12\": \"8-12\",\n \"12-16\": \"12-16\",\n \"16-20\": \"16-20\",\n \"20-24\": \"20-24\",\n \"24-32\": \"24-32\",\n \"32-40\": \"32-40\",\n \"40-48\": \"40-48\",\n \"48-64\": \"48-64\",\n \"64-80\": \"64-80\",\n \"80-120\": \"80-120\",\n \"120-160\": \"120-160\",\n} as const;\nexport type ResponsiveSpacingSizes = keyof typeof responsiveSpacingSizes;\n\nexport function getSpacingVariable(size: SpacingSizes | ResponsiveSpacingSizes) {\n return `var(--hds-spacing-${size})`;\n}\n","type Breakpoints = \"initial\" | \"small\" | \"medium\" | \"large\" | \"xlarge\";\n\ntype ResponsiveValues<T> = {\n [Breakpoint in Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | ResponsiveValues<T>;\n\nexport function getResponsiveProps<T>(\n variable: `--hds-${string}`,\n inputValues?: ResponsiveProp<T>,\n valueTransformer: (value: T) => string = (value) => String(value),\n) {\n if (!inputValues) return {};\n\n if (typeof inputValues !== \"object\") {\n return { [`${variable}-initial`]: valueTransformer(inputValues) };\n }\n\n const result: Record<string, string> = {};\n for (const [key, value] of Object.entries(inputValues as ResponsiveValues<T>)) {\n result[`${variable}-${key}`] = valueTransformer(value);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,uBAAuB,OAAO;AAEtD,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAW,6BAAK,aAAa,SAAsB;AAAA,QACnD;AAAA,SACI,OAJL;AAAA,QAME;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,MAAM,cAAc;AAUb,IAAM,aAAS,yBAA0D,CAAC,OAAO,QAAQ;AAC9F,SAAO,4CAAC,sCAAM,OAAc,QAApB,EAA2B,WAAU,QAAM;AACrD,CAAC;AACD,OAAO,cAAc;AAUd,IAAM,aAAS,yBAA0D,CAAC,OAAO,QAAQ;AAC9F,SAAO,4CAAC,sCAAM,OAAc,QAApB,EAA2B,WAAU,WAAS;AACxD,CAAC;AACD,OAAO,cAAc;","names":[]}
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
HStack,
|
|
3
3
|
Stack,
|
|
4
4
|
VStack
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
5
|
+
} from "../../chunk-FUIKSOJF.mjs";
|
|
6
|
+
import "../../chunk-7ROE6ADK.mjs";
|
|
7
7
|
import "../../chunk-NE6W2PCD.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-YOSPWY5K.mjs";
|
|
9
9
|
export {
|
|
10
10
|
HStack,
|
|
11
11
|
Stack,
|
package/dist/link/index.mjs
CHANGED
package/dist/link/link.mjs
CHANGED
package/dist/list/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "../chunk-6QV3OV66.mjs";
|
|
2
2
|
import {
|
|
3
3
|
LinkList
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-Z2ZCM4BE.mjs";
|
|
5
5
|
import {
|
|
6
6
|
OrderedList,
|
|
7
7
|
UnorderedList
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-LGEGXOPU.mjs";
|
|
9
|
+
import "../chunk-YOSPWY5K.mjs";
|
|
10
10
|
export {
|
|
11
11
|
LinkList,
|
|
12
12
|
OrderedList,
|
package/dist/list/link-list.mjs
CHANGED
package/dist/list/list.mjs
CHANGED
package/dist/message/index.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
Message,
|
|
4
4
|
MessageDescription,
|
|
5
5
|
MessageTitle
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-BHQ46L2O.mjs";
|
|
7
|
+
import "../chunk-3OGHJOJF.mjs";
|
|
8
|
+
import "../chunk-YOSPWY5K.mjs";
|
|
9
9
|
export {
|
|
10
10
|
Message,
|
|
11
11
|
MessageDescription,
|
package/dist/message/message.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
Message,
|
|
3
3
|
MessageDescription,
|
|
4
4
|
MessageTitle
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-BHQ46L2O.mjs";
|
|
6
|
+
import "../chunk-3OGHJOJF.mjs";
|
|
7
|
+
import "../chunk-YOSPWY5K.mjs";
|
|
8
8
|
export {
|
|
9
9
|
Message,
|
|
10
10
|
MessageDescription,
|
package/dist/modal/index.js
CHANGED
|
@@ -256,16 +256,12 @@ Modal.Content = ModalContent;
|
|
|
256
256
|
Modal.Footer = ModalFooter;
|
|
257
257
|
function useScrollLock(modalRef, bodyClass) {
|
|
258
258
|
(0, import_react3.useEffect)(() => {
|
|
259
|
-
if (!modalRef.current)
|
|
260
|
-
|
|
261
|
-
if (modalRef.current.open)
|
|
262
|
-
document.body.classList.add(bodyClass);
|
|
259
|
+
if (!modalRef.current) return;
|
|
260
|
+
if (modalRef.current.open) document.body.classList.add(bodyClass);
|
|
263
261
|
const observer = new MutationObserver(() => {
|
|
264
262
|
var _a;
|
|
265
|
-
if ((_a = modalRef.current) == null ? void 0 : _a.open)
|
|
266
|
-
|
|
267
|
-
else
|
|
268
|
-
document.body.classList.remove(bodyClass);
|
|
263
|
+
if ((_a = modalRef.current) == null ? void 0 : _a.open) document.body.classList.add(bodyClass);
|
|
264
|
+
else document.body.classList.remove(bodyClass);
|
|
269
265
|
});
|
|
270
266
|
observer.observe(modalRef.current, {
|
|
271
267
|
attributes: true,
|
package/dist/modal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/modal/index.tsx","../../src/modal/modal.tsx","../../src/box/box.tsx","../../src/utils/utils.ts"],"sourcesContent":["export { Modal, ModalHeader, ModalContent, ModalFooter } from \"./modal\";\n\nexport type * from \"./modal\";\n","import { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box } from \"../box/box\";\nimport { useMergeRefs } from \"../utils/utils\";\n\ninterface ModalHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalHeader = forwardRef<HTMLHeadingElement, ModalHeaderProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"h1\";\n return (\n <Component\n className={clsx(\"hds-modal__header\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalHeader.displayName = \"Modal.Header\";\n\ninterface ModalContentProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-modal__content\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalContent.displayName = \"Modal.Content\";\n\ninterface ModalFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalFooter = forwardRef<HTMLDivElement, ModalFooterProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"footer\";\n return (\n <Component\n className={clsx(\"hds-modal__footer\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalFooter.displayName = \"Modal.Footer\";\n\nexport interface ModalProps extends React.HTMLAttributes<HTMLDialogElement> {\n children: React.ReactNode;\n\n /**\n * Controls the open state of the modal\n */\n open?: boolean;\n\n /**\n * Whether to close when clicking on the backdrop.\n */\n closeOnBackdropClick?: boolean;\n}\n\n/**\n * A modal dialog is a window that forces the user to interact with it before they can return to other parts of the application.\n *\n * Uses the native [`dialog`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) element.\n *\n * @example\n * ```tsx\n * const modalRef = useRef<HTMLDialogElement>(null);\n * const onClose = () => modalRef.current?.close();\n *\n * return (\n * <>\n * <Button onClick={() => modalRef.current?.showModal()}>Open Modal</Button>\n * <Modal ref={modalRef}>\n * <Modal.Header>Dialog header</Modal.Header>\n * <Modal.Content>\n * <p>\n * Dialog header Dialog description - a description of what is about to happen and maybe\n * something about the consequences.\n * </p>\n * </Modal.Content>\n * <Modal.Footer>\n * <HStack gap=\"16\" wrap>\n * <Button onClick={onMainAction}>Main action</Button>\n * <Button variant=\"primary-outline\" onClick={onClose}>\n * Cancel\n * </Button>\n * </HStack>\n * </Modal.Footer>\n * </Modal>\n * </>\n * );\n * ```\n */\nexport const Modal = forwardRef<HTMLDialogElement, ModalProps>(\n ({ children, className, open, closeOnBackdropClick, onClick, ...rest }, ref) => {\n const modalRef = useRef<HTMLDialogElement>(null);\n const mergedRef = useMergeRefs([modalRef, ref]);\n\n // The X close button that comes from the `Box` component\n function onCloseButtonClick() {\n modalRef.current?.close();\n return false;\n }\n\n // No scroll when modal is open\n useScrollLock(modalRef, \"hds-modal-scroll-lock\");\n\n // `open` prop\n useEffect(() => {\n if (modalRef.current && open !== undefined) {\n if (open && !modalRef.current.open) {\n modalRef.current.showModal();\n } else if (!open && modalRef.current.open) {\n modalRef.current.close();\n }\n }\n }, [modalRef, open]);\n\n function onDialogClick(e: React.MouseEvent<HTMLElement>) {\n if (closeOnBackdropClick && e.target === modalRef.current) {\n modalRef.current.close();\n }\n onClick?.(e as React.MouseEvent<HTMLDialogElement>);\n }\n\n return (\n <Box\n asChild\n className={clsx(\"hds-modal\", className as undefined)}\n closeable\n onClick={onDialogClick}\n onClose={onCloseButtonClick}\n variant=\"white\"\n >\n <dialog ref={mergedRef} {...rest}>\n {children}\n </dialog>\n </Box>\n );\n },\n) as ModalType;\nModal.displayName = \"Modal\";\n\ntype ModalType = ReturnType<typeof forwardRef<HTMLDialogElement, ModalProps>> & {\n Header: typeof ModalHeader;\n Content: typeof ModalContent;\n Footer: typeof ModalFooter;\n};\n\nModal.Header = ModalHeader;\nModal.Content = ModalContent;\nModal.Footer = ModalFooter;\n\nfunction useScrollLock(modalRef: React.RefObject<HTMLDialogElement>, bodyClass: string) {\n useEffect(() => {\n if (!modalRef.current) return;\n if (modalRef.current.open) document.body.classList.add(bodyClass);\n\n const observer = new MutationObserver(() => {\n if (modalRef.current?.open) document.body.classList.add(bodyClass);\n else document.body.classList.remove(bodyClass);\n });\n observer.observe(modalRef.current, {\n attributes: true,\n attributeFilter: [\"open\"],\n });\n return () => {\n observer.disconnect();\n document.body.classList.remove(bodyClass);\n };\n }, [bodyClass, modalRef]);\n}\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8C;AAC9C,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD;AAAA,IACN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;AAmDtB,IAAM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,MACjC,YAAY;AAAA,MACZ,iBAAiB,CAAC,MAAM;AAAA,IAC1B,CAAC;AACD,WAAO,MAAM;AACX,eAAS,WAAW;AACpB,eAAS,KAAK,UAAU,OAAO,SAAS;AAAA,IAC1C;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,CAAC;AAC1B;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_jsx_runtime","_a"]}
|
|
1
|
+
{"version":3,"sources":["../../src/modal/index.tsx","../../src/modal/modal.tsx","../../src/box/box.tsx","../../src/utils/utils.ts"],"sourcesContent":["export { Modal, ModalHeader, ModalContent, ModalFooter } from \"./modal\";\n\nexport type * from \"./modal\";\n","import { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box } from \"../box/box\";\nimport { useMergeRefs } from \"../utils/utils\";\n\ninterface ModalHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalHeader = forwardRef<HTMLHeadingElement, ModalHeaderProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"h1\";\n return (\n <Component\n className={clsx(\"hds-modal__header\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalHeader.displayName = \"Modal.Header\";\n\ninterface ModalContentProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-modal__content\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalContent.displayName = \"Modal.Content\";\n\ninterface ModalFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalFooter = forwardRef<HTMLDivElement, ModalFooterProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"footer\";\n return (\n <Component\n className={clsx(\"hds-modal__footer\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalFooter.displayName = \"Modal.Footer\";\n\nexport interface ModalProps extends React.HTMLAttributes<HTMLDialogElement> {\n children: React.ReactNode;\n\n /**\n * Controls the open state of the modal\n */\n open?: boolean;\n\n /**\n * Whether to close when clicking on the backdrop.\n */\n closeOnBackdropClick?: boolean;\n}\n\n/**\n * A modal dialog is a window that forces the user to interact with it before they can return to other parts of the application.\n *\n * Uses the native [`dialog`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) element.\n *\n * @example\n * ```tsx\n * const modalRef = useRef<HTMLDialogElement>(null);\n * const onClose = () => modalRef.current?.close();\n *\n * return (\n * <>\n * <Button onClick={() => modalRef.current?.showModal()}>Open Modal</Button>\n * <Modal ref={modalRef}>\n * <Modal.Header>Dialog header</Modal.Header>\n * <Modal.Content>\n * <p>\n * Dialog header Dialog description - a description of what is about to happen and maybe\n * something about the consequences.\n * </p>\n * </Modal.Content>\n * <Modal.Footer>\n * <HStack gap=\"16\" wrap>\n * <Button onClick={onMainAction}>Main action</Button>\n * <Button variant=\"primary-outline\" onClick={onClose}>\n * Cancel\n * </Button>\n * </HStack>\n * </Modal.Footer>\n * </Modal>\n * </>\n * );\n * ```\n */\nexport const Modal = forwardRef<HTMLDialogElement, ModalProps>(\n ({ children, className, open, closeOnBackdropClick, onClick, ...rest }, ref) => {\n const modalRef = useRef<HTMLDialogElement>(null);\n const mergedRef = useMergeRefs([modalRef, ref]);\n\n // The X close button that comes from the `Box` component\n function onCloseButtonClick() {\n modalRef.current?.close();\n return false;\n }\n\n // No scroll when modal is open\n useScrollLock(modalRef, \"hds-modal-scroll-lock\");\n\n // `open` prop\n useEffect(() => {\n if (modalRef.current && open !== undefined) {\n if (open && !modalRef.current.open) {\n modalRef.current.showModal();\n } else if (!open && modalRef.current.open) {\n modalRef.current.close();\n }\n }\n }, [modalRef, open]);\n\n function onDialogClick(e: React.MouseEvent<HTMLElement>) {\n if (closeOnBackdropClick && e.target === modalRef.current) {\n modalRef.current.close();\n }\n onClick?.(e as React.MouseEvent<HTMLDialogElement>);\n }\n\n return (\n <Box\n asChild\n className={clsx(\"hds-modal\", className as undefined)}\n closeable\n onClick={onDialogClick}\n onClose={onCloseButtonClick}\n variant=\"white\"\n >\n <dialog ref={mergedRef} {...rest}>\n {children}\n </dialog>\n </Box>\n );\n },\n) as ModalType;\nModal.displayName = \"Modal\";\n\ntype ModalType = ReturnType<typeof forwardRef<HTMLDialogElement, ModalProps>> & {\n Header: typeof ModalHeader;\n Content: typeof ModalContent;\n Footer: typeof ModalFooter;\n};\n\nModal.Header = ModalHeader;\nModal.Content = ModalContent;\nModal.Footer = ModalFooter;\n\nfunction useScrollLock(modalRef: React.RefObject<HTMLDialogElement>, bodyClass: string) {\n useEffect(() => {\n if (!modalRef.current) return;\n if (modalRef.current.open) document.body.classList.add(bodyClass);\n\n const observer = new MutationObserver(() => {\n if (modalRef.current?.open) document.body.classList.add(bodyClass);\n else document.body.classList.remove(bodyClass);\n });\n observer.observe(modalRef.current, {\n attributes: true,\n attributeFilter: [\"open\"],\n });\n return () => {\n observer.disconnect();\n document.body.classList.remove(bodyClass);\n };\n }, [bodyClass, modalRef]);\n}\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8C;AAC9C,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD;AAAA,IACN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;AAmDtB,IAAM,UA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,YAAY;AAAA,MACZ,iBAAiB,CAAC,MAAM;AAAA,IAC1B,CAAC;AACD,WAAO,MAAM;AACX,eAAS,WAAW;AACpB,eAAS,KAAK,UAAU,OAAO,SAAS;AAAA,IAC1C;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,CAAC;AAC1B;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_jsx_runtime","_a"]}
|
package/dist/modal/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
ModalContent,
|
|
5
5
|
ModalFooter,
|
|
6
6
|
ModalHeader
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-6VKQ6IRG.mjs";
|
|
8
|
+
import "../chunk-ILFK3VKS.mjs";
|
|
9
|
+
import "../chunk-3OGHJOJF.mjs";
|
|
10
|
+
import "../chunk-YOSPWY5K.mjs";
|
|
11
11
|
export {
|
|
12
12
|
Modal,
|
|
13
13
|
ModalContent,
|
package/dist/modal/modal.js
CHANGED
|
@@ -254,16 +254,12 @@ Modal.Content = ModalContent;
|
|
|
254
254
|
Modal.Footer = ModalFooter;
|
|
255
255
|
function useScrollLock(modalRef, bodyClass) {
|
|
256
256
|
(0, import_react3.useEffect)(() => {
|
|
257
|
-
if (!modalRef.current)
|
|
258
|
-
|
|
259
|
-
if (modalRef.current.open)
|
|
260
|
-
document.body.classList.add(bodyClass);
|
|
257
|
+
if (!modalRef.current) return;
|
|
258
|
+
if (modalRef.current.open) document.body.classList.add(bodyClass);
|
|
261
259
|
const observer = new MutationObserver(() => {
|
|
262
260
|
var _a;
|
|
263
|
-
if ((_a = modalRef.current) == null ? void 0 : _a.open)
|
|
264
|
-
|
|
265
|
-
else
|
|
266
|
-
document.body.classList.remove(bodyClass);
|
|
261
|
+
if ((_a = modalRef.current) == null ? void 0 : _a.open) document.body.classList.add(bodyClass);
|
|
262
|
+
else document.body.classList.remove(bodyClass);
|
|
267
263
|
});
|
|
268
264
|
observer.observe(modalRef.current, {
|
|
269
265
|
attributes: true,
|
package/dist/modal/modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/modal/modal.tsx","../../src/box/box.tsx","../../src/utils/utils.ts"],"sourcesContent":["import { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box } from \"../box/box\";\nimport { useMergeRefs } from \"../utils/utils\";\n\ninterface ModalHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalHeader = forwardRef<HTMLHeadingElement, ModalHeaderProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"h1\";\n return (\n <Component\n className={clsx(\"hds-modal__header\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalHeader.displayName = \"Modal.Header\";\n\ninterface ModalContentProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-modal__content\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalContent.displayName = \"Modal.Content\";\n\ninterface ModalFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalFooter = forwardRef<HTMLDivElement, ModalFooterProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"footer\";\n return (\n <Component\n className={clsx(\"hds-modal__footer\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalFooter.displayName = \"Modal.Footer\";\n\nexport interface ModalProps extends React.HTMLAttributes<HTMLDialogElement> {\n children: React.ReactNode;\n\n /**\n * Controls the open state of the modal\n */\n open?: boolean;\n\n /**\n * Whether to close when clicking on the backdrop.\n */\n closeOnBackdropClick?: boolean;\n}\n\n/**\n * A modal dialog is a window that forces the user to interact with it before they can return to other parts of the application.\n *\n * Uses the native [`dialog`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) element.\n *\n * @example\n * ```tsx\n * const modalRef = useRef<HTMLDialogElement>(null);\n * const onClose = () => modalRef.current?.close();\n *\n * return (\n * <>\n * <Button onClick={() => modalRef.current?.showModal()}>Open Modal</Button>\n * <Modal ref={modalRef}>\n * <Modal.Header>Dialog header</Modal.Header>\n * <Modal.Content>\n * <p>\n * Dialog header Dialog description - a description of what is about to happen and maybe\n * something about the consequences.\n * </p>\n * </Modal.Content>\n * <Modal.Footer>\n * <HStack gap=\"16\" wrap>\n * <Button onClick={onMainAction}>Main action</Button>\n * <Button variant=\"primary-outline\" onClick={onClose}>\n * Cancel\n * </Button>\n * </HStack>\n * </Modal.Footer>\n * </Modal>\n * </>\n * );\n * ```\n */\nexport const Modal = forwardRef<HTMLDialogElement, ModalProps>(\n ({ children, className, open, closeOnBackdropClick, onClick, ...rest }, ref) => {\n const modalRef = useRef<HTMLDialogElement>(null);\n const mergedRef = useMergeRefs([modalRef, ref]);\n\n // The X close button that comes from the `Box` component\n function onCloseButtonClick() {\n modalRef.current?.close();\n return false;\n }\n\n // No scroll when modal is open\n useScrollLock(modalRef, \"hds-modal-scroll-lock\");\n\n // `open` prop\n useEffect(() => {\n if (modalRef.current && open !== undefined) {\n if (open && !modalRef.current.open) {\n modalRef.current.showModal();\n } else if (!open && modalRef.current.open) {\n modalRef.current.close();\n }\n }\n }, [modalRef, open]);\n\n function onDialogClick(e: React.MouseEvent<HTMLElement>) {\n if (closeOnBackdropClick && e.target === modalRef.current) {\n modalRef.current.close();\n }\n onClick?.(e as React.MouseEvent<HTMLDialogElement>);\n }\n\n return (\n <Box\n asChild\n className={clsx(\"hds-modal\", className as undefined)}\n closeable\n onClick={onDialogClick}\n onClose={onCloseButtonClick}\n variant=\"white\"\n >\n <dialog ref={mergedRef} {...rest}>\n {children}\n </dialog>\n </Box>\n );\n },\n) as ModalType;\nModal.displayName = \"Modal\";\n\ntype ModalType = ReturnType<typeof forwardRef<HTMLDialogElement, ModalProps>> & {\n Header: typeof ModalHeader;\n Content: typeof ModalContent;\n Footer: typeof ModalFooter;\n};\n\nModal.Header = ModalHeader;\nModal.Content = ModalContent;\nModal.Footer = ModalFooter;\n\nfunction useScrollLock(modalRef: React.RefObject<HTMLDialogElement>, bodyClass: string) {\n useEffect(() => {\n if (!modalRef.current) return;\n if (modalRef.current.open) document.body.classList.add(bodyClass);\n\n const observer = new MutationObserver(() => {\n if (modalRef.current?.open) document.body.classList.add(bodyClass);\n else document.body.classList.remove(bodyClass);\n });\n observer.observe(modalRef.current, {\n attributes: true,\n attributeFilter: [\"open\"],\n });\n return () => {\n observer.disconnect();\n document.body.classList.remove(bodyClass);\n };\n }, [bodyClass, modalRef]);\n}\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;AAC9C,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD;AAAA,IACN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;AAmDtB,IAAM,UAAM;AAAA,EACjB,CACE,IAWA,QACG;AAZH,iBACE;AAAA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IA9EN,IAsEI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,M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name","import_react_slot","import_react","import_jsx_runtime","_a"]}
|
|
1
|
+
{"version":3,"sources":["../../src/modal/modal.tsx","../../src/box/box.tsx","../../src/utils/utils.ts"],"sourcesContent":["import { forwardRef, useEffect, useRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box } from \"../box/box\";\nimport { useMergeRefs } from \"../utils/utils\";\n\ninterface ModalHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalHeader = forwardRef<HTMLHeadingElement, ModalHeaderProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"h1\";\n return (\n <Component\n className={clsx(\"hds-modal__header\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalHeader.displayName = \"Modal.Header\";\n\ninterface ModalContentProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-modal__content\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalContent.displayName = \"Modal.Content\";\n\ninterface ModalFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const ModalFooter = forwardRef<HTMLDivElement, ModalFooterProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"footer\";\n return (\n <Component\n className={clsx(\"hds-modal__footer\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nModalFooter.displayName = \"Modal.Footer\";\n\nexport interface ModalProps extends React.HTMLAttributes<HTMLDialogElement> {\n children: React.ReactNode;\n\n /**\n * Controls the open state of the modal\n */\n open?: boolean;\n\n /**\n * Whether to close when clicking on the backdrop.\n */\n closeOnBackdropClick?: boolean;\n}\n\n/**\n * A modal dialog is a window that forces the user to interact with it before they can return to other parts of the application.\n *\n * Uses the native [`dialog`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) element.\n *\n * @example\n * ```tsx\n * const modalRef = useRef<HTMLDialogElement>(null);\n * const onClose = () => modalRef.current?.close();\n *\n * return (\n * <>\n * <Button onClick={() => modalRef.current?.showModal()}>Open Modal</Button>\n * <Modal ref={modalRef}>\n * <Modal.Header>Dialog header</Modal.Header>\n * <Modal.Content>\n * <p>\n * Dialog header Dialog description - a description of what is about to happen and maybe\n * something about the consequences.\n * </p>\n * </Modal.Content>\n * <Modal.Footer>\n * <HStack gap=\"16\" wrap>\n * <Button onClick={onMainAction}>Main action</Button>\n * <Button variant=\"primary-outline\" onClick={onClose}>\n * Cancel\n * </Button>\n * </HStack>\n * </Modal.Footer>\n * </Modal>\n * </>\n * );\n * ```\n */\nexport const Modal = forwardRef<HTMLDialogElement, ModalProps>(\n ({ children, className, open, closeOnBackdropClick, onClick, ...rest }, ref) => {\n const modalRef = useRef<HTMLDialogElement>(null);\n const mergedRef = useMergeRefs([modalRef, ref]);\n\n // The X close button that comes from the `Box` component\n function onCloseButtonClick() {\n modalRef.current?.close();\n return false;\n }\n\n // No scroll when modal is open\n useScrollLock(modalRef, \"hds-modal-scroll-lock\");\n\n // `open` prop\n useEffect(() => {\n if (modalRef.current && open !== undefined) {\n if (open && !modalRef.current.open) {\n modalRef.current.showModal();\n } else if (!open && modalRef.current.open) {\n modalRef.current.close();\n }\n }\n }, [modalRef, open]);\n\n function onDialogClick(e: React.MouseEvent<HTMLElement>) {\n if (closeOnBackdropClick && e.target === modalRef.current) {\n modalRef.current.close();\n }\n onClick?.(e as React.MouseEvent<HTMLDialogElement>);\n }\n\n return (\n <Box\n asChild\n className={clsx(\"hds-modal\", className as undefined)}\n closeable\n onClick={onDialogClick}\n onClose={onCloseButtonClick}\n variant=\"white\"\n >\n <dialog ref={mergedRef} {...rest}>\n {children}\n </dialog>\n </Box>\n );\n },\n) as ModalType;\nModal.displayName = \"Modal\";\n\ntype ModalType = ReturnType<typeof forwardRef<HTMLDialogElement, ModalProps>> & {\n Header: typeof ModalHeader;\n Content: typeof ModalContent;\n Footer: typeof ModalFooter;\n};\n\nModal.Header = ModalHeader;\nModal.Content = ModalContent;\nModal.Footer = ModalFooter;\n\nfunction useScrollLock(modalRef: React.RefObject<HTMLDialogElement>, bodyClass: string) {\n useEffect(() => {\n if (!modalRef.current) return;\n if (modalRef.current.open) document.body.classList.add(bodyClass);\n\n const observer = new MutationObserver(() => {\n if (modalRef.current?.open) document.body.classList.add(bodyClass);\n else document.body.classList.remove(bodyClass);\n });\n observer.observe(modalRef.current, {\n attributes: true,\n attributeFilter: [\"open\"],\n });\n return () => {\n observer.disconnect();\n document.body.classList.remove(bodyClass);\n };\n }, [bodyClass, modalRef]);\n}\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;AAC9C,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD;AAAA,IACN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;AAmDtB,IAAM,UAAM;AAAA,EACjB,CACE,IAWA,QACG;AAZH,iBACE;AAAA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IA9EN,IAsEI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,aAA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AW,CAAC,QAAQ,SAAS,QAAQ,MAAM;AACzC,mBAAS,QAAQ,MAAM;AAAA,QACzB;AAAA,MACF;AAAA,IACF,GAAG,CAAC,UAAU,IAAI,CAAC;AAEnB,aAAS,cAAc,GAAkC;AACvD,UAAI,wBAAwB,EAAE,WAAW,SAAS,SAAS;AACzD,iBAAS,QAAQ,MAAM;AAAA,MACzB;AACA,yCAAU;AAAA,IACZ;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAO;AAAA,QACP,eAAW,8BAAK,aAAa,SAAsB;AAAA,QACnD,WAAS;AAAA,QACT,SAAS;AAAA,QACT,SAAS;AAAA,QACT,SAAQ;AAAA,QAER,uDAAC,yCAAO,KAAK,aAAe,OAA3B,EACE,WACH;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AACA,MAAM,cAAc;AAQpB,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,SAAS;AAEf,SAAS,cAAc,UAA8C,WAAmB;AACtF,+BAAU,MAAM;AACd,QAAI,CAAC,SAAS,QAAS;AACvB,QAAI,SAAS,QAAQ,KAAM,UAAS,KAAK,UAAU,IAAI,SAAS;AAEhE,UAAM,WAAW,IAAI,iBAAiB,MAAM;AAzLhD;AA0LM,WAAI,cAAS,YAAT,mBAAkB,KAAM,UAAS,KAAK,UAAU,IAAI,SAAS;AAAA,UAC5D,UAAS,KAAK,UAAU,OAAO,SAAS;AAAA,IAC/C,CAAC;AACD,aAAS,QAAQ,SAAS,SAAS;AAAA,MACjC,YAAY;AAAA,MACZ,iBAAiB,CAAC,MAAM;AAAA,IAC1B,CAAC;AACD,WAAO,MAAM;AACX,eAAS,WAAW;AACpB,eAAS,KAAK,UAAU,OAAO,SAAS;AAAA,IAC1C;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,CAAC;AAC1B;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_jsx_runtime","_a"]}
|
package/dist/modal/modal.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
ModalContent,
|
|
4
4
|
ModalFooter,
|
|
5
5
|
ModalHeader
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-6VKQ6IRG.mjs";
|
|
7
|
+
import "../chunk-ILFK3VKS.mjs";
|
|
8
|
+
import "../chunk-3OGHJOJF.mjs";
|
|
9
|
+
import "../chunk-YOSPWY5K.mjs";
|
|
10
10
|
export {
|
|
11
11
|
Modal,
|
|
12
12
|
ModalContent,
|
package/dist/navbar/icons.mjs
CHANGED
package/dist/navbar/index.js
CHANGED
|
@@ -88,20 +88,15 @@ var React = __toESM(require("react"));
|
|
|
88
88
|
var import_react = require("react");
|
|
89
89
|
function focusTrap(element) {
|
|
90
90
|
var _a, _b;
|
|
91
|
-
if (element === document.body)
|
|
92
|
-
|
|
93
|
-
};
|
|
91
|
+
if (element === document.body) return () => {
|
|
92
|
+
};
|
|
94
93
|
let inertElements = [];
|
|
95
94
|
for (let el = element; el; el = el.parentElement) {
|
|
96
|
-
if (el === document.body)
|
|
97
|
-
break;
|
|
95
|
+
if (el === document.body) break;
|
|
98
96
|
for (const sibling of (_b = (_a = el.parentElement) == null ? void 0 : _a.children) != null ? _b : []) {
|
|
99
|
-
if (sibling === el)
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
continue;
|
|
103
|
-
if (sibling.hasAttribute("inert"))
|
|
104
|
-
continue;
|
|
97
|
+
if (sibling === el) continue;
|
|
98
|
+
if (!(sibling instanceof HTMLElement)) continue;
|
|
99
|
+
if (sibling.hasAttribute("inert")) continue;
|
|
105
100
|
sibling.setAttribute("inert", "true");
|
|
106
101
|
inertElements.push(sibling);
|
|
107
102
|
}
|