@open-pioneer/react-utils 3.0.0-dev.20250221111321 → 4.0.0-dev-chakra-3.20250225100939
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/CHANGELOG.md +9 -3
- package/TitledSection.d.ts +1 -1
- package/TitledSection.js +1 -1
- package/TitledSection.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# @open-pioneer/react-utils
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 4.0.0-dev-chakra-3.20250225100939
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @open-pioneer/core@4.0.0-dev-chakra-3.20250225100939
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
|
6
12
|
|
|
@@ -17,8 +23,8 @@
|
|
|
17
23
|
### Patch Changes
|
|
18
24
|
|
|
19
25
|
- Updated dependencies [9477e54]
|
|
20
|
-
- @open-pioneer/chakra-integration@3.0.0
|
|
21
|
-
- @open-pioneer/core@3.0.0
|
|
26
|
+
- @open-pioneer/chakra-integration@3.0.0
|
|
27
|
+
- @open-pioneer/core@3.0.0
|
|
22
28
|
|
|
23
29
|
## 2.4.0
|
|
24
30
|
|
package/TitledSection.d.ts
CHANGED
package/TitledSection.js
CHANGED
package/TitledSection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitledSection.js","sources":["TitledSection.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Heading, HeadingProps } from \"@
|
|
1
|
+
{"version":3,"file":"TitledSection.js","sources":["TitledSection.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Heading, HeadingProps } from \"@chakra-ui/react\";\nimport { FC, ForwardedRef, ReactNode, createContext, forwardRef, useContext } from \"react\";\n\nconst DEFAULT_LEVEL = 1;\n\nconst LevelContext = createContext(DEFAULT_LEVEL);\nLevelContext.displayName = \"LevelContext\";\n\n/** Properties of the {@link TitledSection} component. */\nexport interface TitledSectionProps {\n /**\n * The title component.\n *\n * Strings are automatically wrapped in a {@link SectionHeading}.\n * More complex nodes should use the {@link SectionHeading} internally.\n */\n title?: string | ReactNode | undefined;\n\n /**\n * Properties for the automatically generated section heading.\n *\n * NOTE: This is only applied if `title` is a string.\n */\n sectionHeadingProps?: SectionHeadingProps | undefined;\n\n /**\n * Children are rendered without any modifications.\n */\n children?: ReactNode | undefined;\n\n /**\n * Allows to substitute the heading level that is used up from this section.\n * This should only be used to configure the initial level\n * or if it is actually intended to adjust the DOM structure.\n */\n substituteHeadingLevel?: HeadingLevel | undefined;\n}\n\n/**\n * Automatically manages the level of html headings such as `h1` and `h2`.\n *\n * Use this component's `title` property instead of manual heading tags.\n * Nested sections will automatically use the correct level for their current location.\n *\n * Titles are rendered as [Chakra Headings](https://chakra-ui.com/docs/components/heading) by default.\n *\n * **Example:** Simple string headings (1, 2 and 3 will be rendered as h1, h2 and h3):\n *\n * ```jsx\n * <TitledSection title=\"1\">\n * Top level content\n *\n * <TitledSection title=\"2\" sectionHeadingProps={...}>\n * Nested content\n *\n * <TitledSection title=\"3\">\n * Deeply nested content\n * </TitledSection>\n * </TitledSection>\n * </TitledSection>\n * ```\n *\n * When using using a string for the `title` prop, you can specify the `sectionHeadingProps` to\n * customize the properties of the automatically generated heading component.\n *\n * **Example:** custom title rendering\n *\n * You can also use completely custom components for the title.\n * In this case, you should ensure that you use the `SectionHeading` component within the `title` in some place.\n * The section heading does not need to be the immediate child, you can wrap it any way you want.\n *\n * ```jsx\n * <TitledSection\n * title={\n * <SectionHeading size=\"4xl\">Heading</SectionHeading>\n * }\n * >\n * Content\n * </TitledSection>\n * ```\n */\nexport function TitledSection(props: TitledSectionProps): ReactNode {\n const { title, sectionHeadingProps, children } = props;\n const currentLevel = useContext(LevelContext);\n const heading =\n typeof title === \"string\" ? (\n <SectionHeading {...sectionHeadingProps}>{title}</SectionHeading>\n ) : (\n title\n );\n\n return (\n <>\n {heading}\n <LevelContext.Provider value={currentLevel + 1}>{children}</LevelContext.Provider>\n </>\n );\n}\n\n/**\n * Properties supported by the {@link SectionHeading} component.\n *\n * All chakra properties are forwarded to the [Heading](https://chakra-ui.com/docs/components/heading) component.\n */\nexport interface SectionHeadingProps extends HeadingProps {\n children?: ReactNode | undefined;\n}\n\n/**\n * Renders an appropriate heading tag for the current heading level (`h1` through `h6`).\n * This component should only be used as part of the `title` prop of the {@link TitledSection}.\n *\n * Headings are rendered as [Chakra Headings](https://chakra-ui.com/docs/components/heading).\n *\n * Heading levels are managed by nesting {@link TitledSection}.\n */\nexport const SectionHeading = forwardRef(function SectionHeading(\n props: SectionHeadingProps,\n forwardedRef: ForwardedRef<HTMLHeadingElement>\n): ReactNode {\n const { children, ...rest } = props;\n const level = useHeadingLevel();\n const tag = getHeadingTag(level);\n return (\n <Heading as={tag} ref={forwardedRef} {...rest}>\n {children}\n </Heading>\n );\n});\n\n/**\n * Properties for the {@link ConfigureTitledSection} component.\n */\nexport interface ConfigureTitledSectionProps {\n level: HeadingLevel;\n children?: ReactNode;\n}\n\n/**\n * Overrides the heading level for all children.\n *\n * TitledSection components nested in `children` will start with the configured level.\n * Nested TitledSections will continue to use the next appropriate heading level.\n *\n * Example: Changing the global heading level for your application\n *\n * If your application is embedded into another site, it should often not use the `h1` tag\n * but start with a higher heading level instead. To achieve that, simply wrap your application\n * with `<ConfigureTitledSectionProps>`. No other code changes are necessary:\n *\n * ```jsx\n * <ConfigureTitledSection level={2}>\n * <TheRestOfYourApplication />\n * </ConfigureTitledSection>\n * ```\n *\n * Example: Embedding a widget\n *\n * Given a `<Widget />` (that we cannot easily change) that internally uses `TitledSection`,\n * this is how we can embed it with a custom heading level.\n * This can be appropriate in some circumstances, for example when the react component tree does not match the DOM\n * tree (portals etc.).\n *\n * ```jsx\n * <ConfigureTitledSection level={5}>\n * <Widget />\n * </ConfigureTitledSection>\n * ```\n *\n * The headings used by `Widget` will start with `h5`.\n *\n */\nexport const ConfigureTitledSection: FC<ConfigureTitledSectionProps> = (props) => {\n return <LevelContext.Provider value={props.level}>{props.children}</LevelContext.Provider>;\n};\n\n/** The level of a html heading. */\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Returns the current heading level.\n *\n * This hook should be used in the `title` property of a {@link TitledSection}.\n */\nexport function useHeadingLevel(): HeadingLevel {\n const level = useContext(LevelContext);\n return Math.min(level, 6) as HeadingLevel;\n}\n\nfunction getHeadingTag(level: HeadingLevel): `h${HeadingLevel}` {\n return `h${level}`;\n}\n"],"names":["SectionHeading"],"mappings":";;;;AAKA,MAAM,aAAgB,GAAA,CAAA;AAEtB,MAAM,YAAA,GAAe,cAAc,aAAa,CAAA;AAChD,YAAA,CAAa,WAAc,GAAA,cAAA;AA2EpB,SAAS,cAAc,KAAsC,EAAA;AAChE,EAAA,MAAM,EAAE,KAAA,EAAO,mBAAqB,EAAA,QAAA,EAAa,GAAA,KAAA;AACjD,EAAM,MAAA,YAAA,GAAe,WAAW,YAAY,CAAA;AAC5C,EAAM,MAAA,OAAA,GACF,OAAO,KAAU,KAAA,QAAA,uBACZ,cAAgB,EAAA,EAAA,GAAG,mBAAsB,EAAA,QAAA,EAAA,KAAA,EAAM,CAEhD,GAAA,KAAA;AAGR,EAAA,uBAES,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,IAAA,OAAA;AAAA,wBACA,YAAa,CAAA,QAAA,EAAb,EAAsB,KAAO,EAAA,YAAA,GAAe,GAAI,QAAS,EAAA;AAAA,GAC9D,EAAA,CAAA;AAER;AAmBO,MAAM,cAAiB,GAAA,UAAA,CAAW,SAASA,eAAAA,CAC9C,OACA,YACS,EAAA;AACT,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,IAAA,EAAS,GAAA,KAAA;AAC9B,EAAA,MAAM,QAAQ,eAAgB,EAAA;AAC9B,EAAM,MAAA,GAAA,GAAM,cAAc,KAAK,CAAA;AAC/B,EACI,uBAAA,GAAA,CAAC,WAAQ,EAAI,EAAA,GAAA,EAAK,KAAK,YAAe,EAAA,GAAG,MACpC,QACL,EAAA,CAAA;AAER,CAAC;AA4CY,MAAA,sBAAA,GAA0D,CAAC,KAAU,KAAA;AAC9E,EAAO,uBAAA,GAAA,CAAC,aAAa,QAAb,EAAA,EAAsB,OAAO,KAAM,CAAA,KAAA,EAAQ,gBAAM,QAAS,EAAA,CAAA;AACtE;AAUO,SAAS,eAAgC,GAAA;AAC5C,EAAM,MAAA,KAAA,GAAQ,WAAW,YAAY,CAAA;AACrC,EAAO,OAAA,IAAA,CAAK,GAAI,CAAA,KAAA,EAAO,CAAC,CAAA;AAC5B;AAEA,SAAS,cAAc,KAAyC,EAAA;AAC5D,EAAA,OAAO,IAAI,KAAK,CAAA,CAAA;AACpB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/react-utils",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-dev-chakra-3.20250225100939",
|
|
5
5
|
"description": "Contains common react utilities used by the open pioneer trails project",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"directory": "src/packages/react-utils"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@chakra-ui/react": "^3.8.1",
|
|
17
18
|
"classnames": "^2.3.2",
|
|
18
19
|
"react": "^19.0.0",
|
|
19
|
-
"@open-pioneer/
|
|
20
|
-
"@open-pioneer/core": "^3.0.0-dev.20250221111321"
|
|
20
|
+
"@open-pioneer/core": "^4.0.0-dev-chakra-3.20250225100939"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
"./package.json": "./package.json",
|