@mittwald/flow-react-components 1.3.0-next.27 → 1.3.0-next.29
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/USAGE.md +14 -6
- package/dist/assets/component-index.json +1 -1
- package/dist/assets/doc-properties.json +1 -1
- package/dist/js/packages/components/src/components/Accordion/Accordion.mjs +4 -1
- package/dist/js/packages/components/src/components/Accordion/Accordion.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -13,10 +13,11 @@ import { useCallback, useId, useState } from "react";
|
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
//#region src/components/Accordion/Accordion.tsx
|
|
15
15
|
var HeaderButton = (props) => {
|
|
16
|
-
const { children, contentId, isExpanded, onToggle } = props;
|
|
16
|
+
const { children, id, contentId, isExpanded, onToggle } = props;
|
|
17
17
|
return /* @__PURE__ */ jsxs(Button, {
|
|
18
18
|
tunnel: null,
|
|
19
19
|
unstyled: true,
|
|
20
|
+
id,
|
|
20
21
|
"aria-expanded": isExpanded,
|
|
21
22
|
className: Accordion_module_default.headerButton,
|
|
22
23
|
onPress: onToggle,
|
|
@@ -36,6 +37,7 @@ var Accordion = flowComponent("Accordion", (props) => {
|
|
|
36
37
|
const contentId = useId();
|
|
37
38
|
const toggle = useCallback(() => setExpanded((expanded) => !expanded), []);
|
|
38
39
|
const renderHeaderButton = (children) => /* @__PURE__ */ jsx(HeaderButton, {
|
|
40
|
+
id: headerId,
|
|
39
41
|
contentId,
|
|
40
42
|
isExpanded: expanded,
|
|
41
43
|
onToggle: toggle,
|
|
@@ -58,6 +60,7 @@ var Accordion = flowComponent("Accordion", (props) => {
|
|
|
58
60
|
},
|
|
59
61
|
Label: {
|
|
60
62
|
className: Accordion_module_default.header,
|
|
63
|
+
elementType: "span",
|
|
61
64
|
children: dynamic((props) => renderHeaderButton(props.children))
|
|
62
65
|
}
|
|
63
66
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.mjs","names":[],"sources":["../../../../../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["import type { ComponentProps, FC, PropsWithChildren, ReactNode } from \"react\";\nimport { useCallback, useId, useState } from \"react\";\nimport clsx from \"clsx\";\nimport styles from \"./Accordion.module.scss\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { dynamic, PropsContextProvider } from \"@/lib/propsContext\";\nimport { Button } from \"@/components/Button\";\nimport { IconChevronDown } from \"@/components/Icon/components/icons\";\nimport { Activity } from \"@/components/Activity\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\n\nexport interface AccordionProps extends PropsWithChildren<\n ComponentProps<\"div\">\n> {\n /** Whether the accordion should be initially expanded. */\n defaultExpanded?: boolean;\n /** The visual variant of the accordion. @default \"default\" */\n variant?: \"default\" | \"outline\";\n}\n\ninterface HeaderButtonProps extends PropsWithChildren {\n contentId: string;\n isExpanded: boolean;\n onToggle: () => void;\n}\n\n/*\n * Declared here and not inside the accordion: a component defined in a render\n * body gets a new identity on every render, so React unmounts and remounts it —\n * and the toggle loses the focus it just received on its own press.\n */\nconst HeaderButton: FC<HeaderButtonProps> = (props) => {\n const { children, contentId, isExpanded, onToggle } = props;\n\n return (\n <Button\n tunnel={null}\n unstyled\n aria-expanded={isExpanded}\n className={styles.headerButton}\n onPress={onToggle}\n aria-controls={contentId}\n >\n {children}\n <IconChevronDown className={styles.chevron} />\n </Button>\n );\n};\n\n/**\n * @flr-generate all\n * @flowStatus beta\n */\nexport const Accordion: FC<AccordionProps> = flowComponent(\n \"Accordion\",\n (props) => {\n const {\n children,\n className,\n defaultExpanded = false,\n variant = \"default\",\n ...rest\n } = props;\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const rootClassName = clsx(\n styles.accordion,\n expanded && styles.expanded,\n variant === \"outline\" && styles.outline,\n className,\n );\n\n const headerId = useId();\n\n const contentId = useId();\n\n const toggle = useCallback(() => setExpanded((expanded) => !expanded), []);\n\n const renderHeaderButton = (children: ReactNode) => (\n <HeaderButton\n contentId={contentId}\n isExpanded={expanded}\n onToggle={toggle}\n >\n {children}\n </HeaderButton>\n );\n\n const propsContext: PropsContext = {\n Content: {\n className: styles.contentInner,\n tunnel: {\n id: \"content\",\n component: \"Accordion\",\n },\n },\n Heading: {\n className: styles.header,\n level: 4,\n size: \"xs\",\n children: dynamic((props) => renderHeaderButton(props.children)),\n Button: { size: \"m\" },\n },\n Label: {\n className: styles.header,\n
|
|
1
|
+
{"version":3,"file":"Accordion.mjs","names":[],"sources":["../../../../../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["import type { ComponentProps, FC, PropsWithChildren, ReactNode } from \"react\";\nimport { useCallback, useId, useState } from \"react\";\nimport clsx from \"clsx\";\nimport styles from \"./Accordion.module.scss\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { dynamic, PropsContextProvider } from \"@/lib/propsContext\";\nimport { Button } from \"@/components/Button\";\nimport { IconChevronDown } from \"@/components/Icon/components/icons\";\nimport { Activity } from \"@/components/Activity\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\n\nexport interface AccordionProps extends PropsWithChildren<\n ComponentProps<\"div\">\n> {\n /** Whether the accordion should be initially expanded. */\n defaultExpanded?: boolean;\n /** The visual variant of the accordion. @default \"default\" */\n variant?: \"default\" | \"outline\";\n}\n\ninterface HeaderButtonProps extends PropsWithChildren {\n id: string;\n contentId: string;\n isExpanded: boolean;\n onToggle: () => void;\n}\n\n/*\n * Declared here and not inside the accordion: a component defined in a render\n * body gets a new identity on every render, so React unmounts and remounts it —\n * and the toggle loses the focus it just received on its own press.\n */\nconst HeaderButton: FC<HeaderButtonProps> = (props) => {\n const { children, id, contentId, isExpanded, onToggle } = props;\n\n return (\n <Button\n tunnel={null}\n unstyled\n id={id}\n aria-expanded={isExpanded}\n className={styles.headerButton}\n onPress={onToggle}\n aria-controls={contentId}\n >\n {children}\n <IconChevronDown className={styles.chevron} />\n </Button>\n );\n};\n\n/**\n * @flr-generate all\n * @flowStatus beta\n */\nexport const Accordion: FC<AccordionProps> = flowComponent(\n \"Accordion\",\n (props) => {\n const {\n children,\n className,\n defaultExpanded = false,\n variant = \"default\",\n ...rest\n } = props;\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const rootClassName = clsx(\n styles.accordion,\n expanded && styles.expanded,\n variant === \"outline\" && styles.outline,\n className,\n );\n\n const headerId = useId();\n\n const contentId = useId();\n\n const toggle = useCallback(() => setExpanded((expanded) => !expanded), []);\n\n const renderHeaderButton = (children: ReactNode) => (\n <HeaderButton\n id={headerId}\n contentId={contentId}\n isExpanded={expanded}\n onToggle={toggle}\n >\n {children}\n </HeaderButton>\n );\n\n const propsContext: PropsContext = {\n Content: {\n className: styles.contentInner,\n tunnel: {\n id: \"content\",\n component: \"Accordion\",\n },\n },\n Heading: {\n className: styles.header,\n level: 4,\n size: \"xs\",\n children: dynamic((props) => renderHeaderButton(props.children)),\n Button: { size: \"m\" },\n },\n Label: {\n className: styles.header,\n /*\n * A <label> names the first labelable element below it — here the\n * toggle, whose own text is the label's only content. The name\n * computation walks into the label, meets the button it started from\n * and stops, so the toggle ends up with an empty name. A <span> names\n * nothing and the name comes from the toggle's content again.\n */\n elementType: \"span\",\n children: dynamic((props) => renderHeaderButton(props.children)),\n },\n };\n\n return (\n <div {...rest} className={rootClassName}>\n {/*\n * The props context is memoized, and the header button takes `expanded`\n * from it – without the dependency the toggle keeps announcing the\n * state it was first rendered with.\n */}\n <PropsContextProvider dependencies={[expanded]} props={propsContext}>\n {children}\n <div\n aria-labelledby={headerId}\n id={contentId}\n role=\"region\"\n hidden={!expanded}\n className={styles.content}\n >\n <Activity isActive={expanded} inactiveDelay={1000}>\n <UiComponentTunnelExit id=\"content\" component=\"Accordion\" />\n </Activity>\n </div>\n </PropsContextProvider>\n </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Q;GAAG,OAAO;GAAvD,UAAA,CACG,UACD,oBAAC,OAAD;IACE,mBAAiB;IACjB,IAAI;IACJ,MAAK;IACL,QAAQ,CAAC;IACT,WAAW,yBAAO;IAElB,UAAA,oBAAC,UAAD;KAAU,UAAU;KAAU,eAAe;KAC3C,UAAA,oBAAC,uBAAD;MAAuB,IAAG;MAAU,WAAU;KAAa,CAAA;IACnD,CAAA;GACP,CAAA,CACe;;CACnB,CAAA;AAET,GACA,EACE,MAAM,SACR,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "1.3.0-next.
|
|
3
|
+
"version": "1.3.0-next.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://flow.mittwald.de",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@internationalized/string-compiler": "^3.4.1",
|
|
84
84
|
"@lezer/common": "^1.5.2",
|
|
85
85
|
"@lezer/highlight": "^1.2.3",
|
|
86
|
-
"@mittwald/flow-icons": "^1.3.0-next.
|
|
86
|
+
"@mittwald/flow-icons": "^1.3.0-next.29",
|
|
87
87
|
"@mittwald/password-tools-js": "^3.0.0",
|
|
88
|
-
"@mittwald/react-tunnel": "^1.3.0-next.
|
|
88
|
+
"@mittwald/react-tunnel": "^1.3.0-next.29",
|
|
89
89
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
90
90
|
"@react-aria/form": "^3.2.1",
|
|
91
91
|
"@react-aria/i18n": "^3.13.1",
|
|
@@ -138,12 +138,12 @@
|
|
|
138
138
|
"@internationalized/date": "^3.12.3",
|
|
139
139
|
"@lezer/generator": "^1.8.0",
|
|
140
140
|
"@lezer/lr": "^1.4.10",
|
|
141
|
-
"@mittwald/flow-core": "1.3.0-next.
|
|
142
|
-
"@mittwald/flow-design-tokens": "1.3.0-next.
|
|
143
|
-
"@mittwald/flow-icons-base": "1.3.0-next.
|
|
141
|
+
"@mittwald/flow-core": "1.3.0-next.29",
|
|
142
|
+
"@mittwald/flow-design-tokens": "1.3.0-next.29",
|
|
143
|
+
"@mittwald/flow-icons-base": "1.3.0-next.29",
|
|
144
144
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
145
145
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.10",
|
|
146
|
-
"@mittwald/typescript-config": "1.3.0-next.
|
|
146
|
+
"@mittwald/typescript-config": "1.3.0-next.29",
|
|
147
147
|
"@nx/storybook": "^22.7.6",
|
|
148
148
|
"@storybook/addon-a11y": "^10.5.10",
|
|
149
149
|
"@storybook/addon-actions": "^9.0.8",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
},
|
|
196
196
|
"peerDependencies": {
|
|
197
197
|
"@internationalized/date": "^3.12.2",
|
|
198
|
-
"@mittwald/flow-icons-pro": "1.3.0-next.
|
|
198
|
+
"@mittwald/flow-icons-pro": "1.3.0-next.29",
|
|
199
199
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
200
200
|
"next": "^16.2.3",
|
|
201
201
|
"react": "^19.2.0",
|
|
@@ -219,5 +219,5 @@
|
|
|
219
219
|
"browserslist": [
|
|
220
220
|
"baseline widely available"
|
|
221
221
|
],
|
|
222
|
-
"gitHead": "
|
|
222
|
+
"gitHead": "3637e9e27119b2db129764c8c029a4c39bc2f05f"
|
|
223
223
|
}
|