@open-pioneer/react-utils 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -32
- package/README.md +1 -1
- package/TitledSection.d.ts +1 -1
- package/TitledSection.js.map +1 -1
- package/package.json +4 -4
- package/useCommonComponentProps.js.map +1 -1
- package/useEvent.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,54 +1,74 @@
|
|
|
1
1
|
# @open-pioneer/react-utils
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 9477e54: Update dependencies
|
|
8
|
+
|
|
9
|
+
- React 19
|
|
10
|
+
- Vite 6
|
|
11
|
+
- FormatJS 3
|
|
12
|
+
- Open Pioneer Build Tools
|
|
13
|
+
- ...
|
|
14
|
+
|
|
15
|
+
For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [9477e54]
|
|
20
|
+
- @open-pioneer/chakra-integration@3.0.0
|
|
21
|
+
- @open-pioneer/core@3.0.0
|
|
22
|
+
|
|
3
23
|
## 2.4.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
6
26
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
27
|
+
- 1b63ebe: Update dependencies
|
|
28
|
+
- Updated dependencies [1b63ebe]
|
|
29
|
+
- Updated dependencies [e3802fb]
|
|
30
|
+
- @open-pioneer/chakra-integration@2.4.0
|
|
31
|
+
- @open-pioneer/core@2.4.0
|
|
12
32
|
|
|
13
33
|
## 2.3.0
|
|
14
34
|
|
|
15
35
|
### Minor Changes
|
|
16
36
|
|
|
17
|
-
-
|
|
37
|
+
- 2fbaaa0: Use normal `dependencies` instead of `peerDependencies`. Peer dependencies have some usability issues (and bugs) when used at scale.
|
|
18
38
|
|
|
19
39
|
### Patch Changes
|
|
20
40
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
41
|
+
- Updated dependencies [2fbaaa0]
|
|
42
|
+
- @open-pioneer/chakra-integration@2.3.0
|
|
43
|
+
- @open-pioneer/core@2.3.0
|
|
24
44
|
|
|
25
45
|
## 2.2.0
|
|
26
46
|
|
|
27
47
|
### Patch Changes
|
|
28
48
|
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
49
|
+
- 39dad46: Switch to a new versioning strategy.
|
|
50
|
+
From now on, packages released by this repository share a common version number.
|
|
51
|
+
- Updated dependencies [39dad46]
|
|
52
|
+
- @open-pioneer/chakra-integration@2.2.0
|
|
53
|
+
- @open-pioneer/core@2.2.0
|
|
34
54
|
|
|
35
55
|
## 1.0.1
|
|
36
56
|
|
|
37
57
|
### Patch Changes
|
|
38
58
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
59
|
+
- 5c62522: Update wording and harmonize structure
|
|
60
|
+
- e0b2fae: Update dependencies
|
|
61
|
+
- Updated dependencies [5c62522]
|
|
62
|
+
- Updated dependencies [50550d3]
|
|
63
|
+
- Updated dependencies [e0b2fae]
|
|
64
|
+
- @open-pioneer/chakra-integration@1.1.4
|
|
65
|
+
- @open-pioneer/core@1.3.0
|
|
46
66
|
|
|
47
67
|
## 1.0.0
|
|
48
68
|
|
|
49
69
|
### Major Changes
|
|
50
70
|
|
|
51
|
-
-
|
|
71
|
+
- a208b32: **Breaking:** Removed the `ToolButton` component; it has moved to `@open-pioneer/map-ui-components`.
|
|
52
72
|
|
|
53
73
|
If you were previously using the `ToolButton` in your app, you need to update your import statements when updating to this version:
|
|
54
74
|
|
|
@@ -61,17 +81,17 @@
|
|
|
61
81
|
|
|
62
82
|
### Minor Changes
|
|
63
83
|
|
|
64
|
-
-
|
|
84
|
+
- a208b32: Move this package to the core-packages repository.
|
|
65
85
|
|
|
66
86
|
## 0.2.3
|
|
67
87
|
|
|
68
88
|
### Patch Changes
|
|
69
89
|
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
90
|
+
- 4140646: Update trails dependencies
|
|
91
|
+
- 4140646: Update to react 18.3.1
|
|
92
|
+
- 81bc7da: Update trails dependencies
|
|
93
|
+
- 2c092dc: Update dependencies
|
|
94
|
+
- 4140646: Add `sectionHeadingProps` to configure the generated `<SectionHeading>` if `title` is a string.
|
|
75
95
|
|
|
76
96
|
For example:
|
|
77
97
|
|
|
@@ -85,22 +105,22 @@
|
|
|
85
105
|
|
|
86
106
|
### Patch Changes
|
|
87
107
|
|
|
88
|
-
-
|
|
108
|
+
- 1a8ad89: Update package.json metadata
|
|
89
109
|
|
|
90
110
|
## 0.2.1
|
|
91
111
|
|
|
92
112
|
### Patch Changes
|
|
93
113
|
|
|
94
|
-
-
|
|
114
|
+
- 762e7b9: Add 'aria-pressed' attribute to "pressable" tool buttons (when `isActive` is `true` or `false`).
|
|
95
115
|
|
|
96
116
|
## 0.2.0
|
|
97
117
|
|
|
98
118
|
### Minor Changes
|
|
99
119
|
|
|
100
|
-
-
|
|
120
|
+
- 70349a8: Update to new core packages major versions
|
|
101
121
|
|
|
102
122
|
## 0.1.0
|
|
103
123
|
|
|
104
124
|
### Minor Changes
|
|
105
125
|
|
|
106
|
-
-
|
|
126
|
+
- 182da1c: Initial release.
|
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ For the time being, these properties are `className` (combined component class a
|
|
|
54
54
|
Example:
|
|
55
55
|
|
|
56
56
|
```tsx
|
|
57
|
-
// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)
|
|
57
|
+
// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)
|
|
58
58
|
// SPDX-License-Identifier: Apache-2.0
|
|
59
59
|
import { CommonComponentProps, useCommonComponentProps } from "@open-pioneer/react-utils";
|
|
60
60
|
// ...
|
package/TitledSection.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export interface TitledSectionProps {
|
|
|
69
69
|
* </TitledSection>
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
|
-
export declare function TitledSection(props: TitledSectionProps):
|
|
72
|
+
export declare function TitledSection(props: TitledSectionProps): ReactNode;
|
|
73
73
|
/**
|
|
74
74
|
* Properties supported by the {@link SectionHeading} component.
|
|
75
75
|
*
|
package/TitledSection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitledSection.js","sources":["TitledSection.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Heading, HeadingProps } from \"@open-pioneer/chakra-integration\";\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):
|
|
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 \"@open-pioneer/chakra-integration\";\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": "3.0.0",
|
|
5
5
|
"description": "Contains common react utilities used by the open pioneer trails project",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"classnames": "^2.3.2",
|
|
18
|
-
"react": "^
|
|
19
|
-
"@open-pioneer/chakra-integration": "^
|
|
20
|
-
"@open-pioneer/core": "^
|
|
18
|
+
"react": "^19.0.0",
|
|
19
|
+
"@open-pioneer/chakra-integration": "^3.0.0",
|
|
20
|
+
"@open-pioneer/core": "^3.0.0"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
"./package.json": "./package.json",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCommonComponentProps.js","sources":["useCommonComponentProps.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport classNames from \"classnames\";\nimport { HTMLAttributes } from \"react\";\n\n/**\n * Common properties supported by all public react components.\n */\nexport interface CommonComponentProps {\n /**\n * Additional class name(s).\n */\n \"className\"?: string;\n\n /**\n * Used for testing.\n */\n \"data-testid\"?: string;\n}\n\n/**\n * A helper hook that computes react properties for the topmost container in a public react component.\n *\n * Example:\n *\n * ```jsx\n * function MyComponent(props) {\n * const { containerProps } = useCommonComponentProps(\"my-component\", props);\n * // automatically applies css classes and testid\n * return <Box {...containerProps}>Content</Box>;\n * }\n * ```\n */\nexport function useCommonComponentProps(\n componentClassName: string,\n props: CommonComponentProps\n): { containerProps: HTMLAttributes<HTMLElement> } {\n const containerProps = {\n \"className\": classNames(componentClassName, props.className),\n \"data-testid\": props[\"data-testid\"]\n };\n return {\n containerProps\n };\n}\n"],"names":[],"mappings":";;AAiCgB,SAAA,uBAAA,CACZ,oBACA,KAC+C,EAAA;AAC/C,EAAA,MAAM,cAAiB,GAAA;AAAA,IACnB,WAAa,EAAA,UAAA,CAAW,kBAAoB,EAAA,KAAA,CAAM,SAAS,CAAA;AAAA,IAC3D,aAAA,EAAe,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"useCommonComponentProps.js","sources":["useCommonComponentProps.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport classNames from \"classnames\";\nimport { HTMLAttributes } from \"react\";\n\n/**\n * Common properties supported by all public react components.\n */\nexport interface CommonComponentProps {\n /**\n * Additional class name(s).\n */\n \"className\"?: string;\n\n /**\n * Used for testing.\n */\n \"data-testid\"?: string;\n}\n\n/**\n * A helper hook that computes react properties for the topmost container in a public react component.\n *\n * Example:\n *\n * ```jsx\n * function MyComponent(props) {\n * const { containerProps } = useCommonComponentProps(\"my-component\", props);\n * // automatically applies css classes and testid\n * return <Box {...containerProps}>Content</Box>;\n * }\n * ```\n */\nexport function useCommonComponentProps(\n componentClassName: string,\n props: CommonComponentProps\n): { containerProps: HTMLAttributes<HTMLElement> } {\n const containerProps = {\n \"className\": classNames(componentClassName, props.className),\n \"data-testid\": props[\"data-testid\"]\n };\n return {\n containerProps\n };\n}\n"],"names":[],"mappings":";;AAiCgB,SAAA,uBAAA,CACZ,oBACA,KAC+C,EAAA;AAC/C,EAAA,MAAM,cAAiB,GAAA;AAAA,IACnB,WAAa,EAAA,UAAA,CAAW,kBAAoB,EAAA,KAAA,CAAM,SAAS,CAAA;AAAA,IAC3D,aAAA,EAAe,MAAM,aAAa;AAAA,GACtC;AACA,EAAO,OAAA;AAAA,IACH;AAAA,GACJ;AACJ;;;;"}
|
package/useEvent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEvent.js","sources":["useEvent.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useLayoutEffect, useRef } from \"react\";\n\n/**\n * Creates an event handler with stable function identity.\n * The returned function will always invoke the most recent implementation of `handler`.\n *\n * The returned event handler can be used, for example, as an event handler in `useEffect()`.\n * Because the function identity is stable, `useEffect()` will not re-trigger if the implementation changes.\n *\n * > Warning: the function returned by `useEvent` must **not** be called during rendering.\n * > It can only be used in an effect or in a event handler callback.\n *\n * See also: https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md\n */\nexport function useEvent<Args extends unknown[], Ret>(\n handler: (...args: Args) => Ret\n): typeof handler {\n const handlerRef = useRef<typeof handler | null>(null);\n\n useLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n const stableHandler = useCallback((...args: Args): Ret => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const currentHandler = handlerRef.current!;\n return currentHandler(...args);\n }, []);\n return stableHandler;\n}\n"],"names":[],"mappings":";;AAgBO,SAAS,SACZ,OACc,EAAA;AACd,EAAM,MAAA,UAAA,GAAa,OAA8B,IAAI,CAAA
|
|
1
|
+
{"version":3,"file":"useEvent.js","sources":["useEvent.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useLayoutEffect, useRef } from \"react\";\n\n/**\n * Creates an event handler with stable function identity.\n * The returned function will always invoke the most recent implementation of `handler`.\n *\n * The returned event handler can be used, for example, as an event handler in `useEffect()`.\n * Because the function identity is stable, `useEffect()` will not re-trigger if the implementation changes.\n *\n * > Warning: the function returned by `useEvent` must **not** be called during rendering.\n * > It can only be used in an effect or in a event handler callback.\n *\n * See also: https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md\n */\nexport function useEvent<Args extends unknown[], Ret>(\n handler: (...args: Args) => Ret\n): typeof handler {\n const handlerRef = useRef<typeof handler | null>(null);\n\n useLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n const stableHandler = useCallback((...args: Args): Ret => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const currentHandler = handlerRef.current!;\n return currentHandler(...args);\n }, []);\n return stableHandler;\n}\n"],"names":[],"mappings":";;AAgBO,SAAS,SACZ,OACc,EAAA;AACd,EAAM,MAAA,UAAA,GAAa,OAA8B,IAAI,CAAA;AAErD,EAAA,eAAA,CAAgB,MAAM;AAClB,IAAA,UAAA,CAAW,OAAU,GAAA,OAAA;AAAA,GACxB,CAAA;AAED,EAAM,MAAA,aAAA,GAAgB,WAAY,CAAA,CAAA,GAAI,IAAoB,KAAA;AAEtD,IAAA,MAAM,iBAAiB,UAAW,CAAA,OAAA;AAClC,IAAO,OAAA,cAAA,CAAe,GAAG,IAAI,CAAA;AAAA,GACjC,EAAG,EAAE,CAAA;AACL,EAAO,OAAA,aAAA;AACX;;;;"}
|