react-zoom-pan-pinch 3.0.2 → 3.0.4
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/.storybook/main.js +23 -0
- package/.storybook/preview-head.html +5 -0
- package/.storybook/preview.js +11 -0
- package/.storybook/theme-overrides.css +49 -0
- package/__tests__/features/props.spec.tsx +11 -0
- package/__tests__/features/rendering.spec.tsx +36 -0
- package/__tests__/shared/render.shared.tsx +41 -0
- package/__tests__/utils/controls.utils.tsx +25 -0
- package/__tests__/utils/example.tsx +81 -0
- package/dist/__tests__/features/props.spec.d.ts +1 -0
- package/dist/__tests__/features/rendering.spec.d.ts +1 -0
- package/dist/__tests__/shared/render.shared.d.ts +11 -0
- package/dist/__tests__/utils/controls.utils.d.ts +3 -0
- package/dist/__tests__/utils/example.d.ts +6 -0
- package/dist/src/stories/docs/handlers.d.ts +12 -0
- package/dist/src/stories/docs/props.d.ts +14 -0
- package/dist/src/stories/examples/content-rerendering/example.d.ts +2 -0
- package/dist/src/stories/examples/image-responsive/example.d.ts +2 -0
- package/dist/src/stories/examples/keep-scale/example.d.ts +2 -0
- package/dist/src/stories/examples/mini-map/example.d.ts +1 -0
- package/dist/src/stories/examples/stress/example.d.ts +2 -0
- package/dist/src/stories/examples/svg-zoom-to-element/example.d.ts +2 -0
- package/dist/src/stories/examples/zoom-to-element/example.d.ts +2 -0
- package/dist/src/stories/types/args.types.d.ts +268 -0
- package/dist/src/stories/utils/args.utils.d.ts +3 -0
- package/dist/src/stories/utils/code.utils.d.ts +6 -0
- package/dist/src/stories/utils/controls.utils.d.ts +3 -0
- package/dist/src/stories/utils/index.d.ts +3 -0
- package/jest.config.ts +45 -0
- package/package.json +1 -1
- package/src/stories/assets/big-image.jpeg +0 -0
- package/src/stories/assets/map.jpg +0 -0
- package/src/stories/assets/medium-image.jpg +0 -0
- package/src/stories/assets/pin.svg +1 -0
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +14 -0
- package/src/stories/docs/Introduction.stories.mdx +174 -0
- package/src/stories/docs/handlers.stories.mdx +48 -0
- package/src/stories/docs/handlers.tsx +107 -0
- package/src/stories/docs/props.stories.mdx +92 -0
- package/src/stories/docs/props.tsx +496 -0
- package/src/stories/examples/content/content.stories.mdx +121 -0
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +45 -0
- package/src/stories/examples/content-rerendering/example.tsx +73 -0
- package/src/stories/examples/controls/controls.stories.mdx +71 -0
- package/src/stories/examples/image-big/image-big.stories.mdx +43 -0
- package/src/stories/examples/image-medium/image-medium.stories.mdx +41 -0
- package/src/stories/examples/image-responsive/example.tsx +103 -0
- package/src/stories/examples/image-responsive/image-responsive.stories.mdx +32 -0
- package/src/stories/examples/image-small/image-small.stories.mdx +41 -0
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +46 -0
- package/src/stories/examples/keep-scale/example.tsx +92 -0
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +45 -0
- package/src/stories/examples/mini-map/example.tsx +54 -0
- package/src/stories/examples/mini-map/mini-map.stories.mdx +33 -0
- package/src/stories/examples/stress/example.tsx +23 -0
- package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
- package/src/stories/examples/svg-zoom-to-element/creativity.svg +143 -0
- package/src/stories/examples/svg-zoom-to-element/example.tsx +57 -0
- package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +28 -0
- package/src/stories/examples/zoom-to-element/example.tsx +94 -0
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +28 -0
- package/src/stories/hooks/use-controls.stories.mdx +24 -0
- package/src/stories/hooks/use-transform-context.stories.mdx +15 -0
- package/src/stories/hooks/use-transform-effect.stories.mdx +29 -0
- package/src/stories/hooks/use-transform-init.stories.mdx +25 -0
- package/src/stories/types/args.types.ts +201 -0
- package/src/stories/utils/args.utils.ts +34 -0
- package/src/stories/utils/code.utils.tsx +24 -0
- package/src/stories/utils/controls.utils.tsx +43 -0
- package/src/stories/utils/index.ts +3 -0
- package/src/stories/utils/styles.module.css +34 -0
package/jest.config.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Config } from "@jest/types";
|
|
2
|
+
|
|
3
|
+
const config: Config.InitialOptions = {
|
|
4
|
+
cacheDirectory: "../../node_modules/.cache/rhf/jest",
|
|
5
|
+
testEnvironment: "jsdom",
|
|
6
|
+
preset: "ts-jest",
|
|
7
|
+
testRegex: [".spec.ts"],
|
|
8
|
+
roots: ["<rootDir>/node_modules", "<rootDir>/src", "<rootDir>/__tests__"],
|
|
9
|
+
coverageProvider: "v8",
|
|
10
|
+
coverageReporters: [
|
|
11
|
+
["lcov", { projectRoot: "../.." }],
|
|
12
|
+
"clover",
|
|
13
|
+
"json",
|
|
14
|
+
"text",
|
|
15
|
+
],
|
|
16
|
+
collectCoverageFrom: ["<rootDir>/src/**/*.ts", "<rootDir>/src/**/*.tsx"],
|
|
17
|
+
coveragePathIgnorePatterns: [
|
|
18
|
+
".spec",
|
|
19
|
+
"test",
|
|
20
|
+
"tests",
|
|
21
|
+
"types",
|
|
22
|
+
"constants",
|
|
23
|
+
"index.ts",
|
|
24
|
+
".d.ts",
|
|
25
|
+
],
|
|
26
|
+
moduleDirectories: ["node_modules", "src"],
|
|
27
|
+
transform: {
|
|
28
|
+
"^.+\\.tsx?$": [
|
|
29
|
+
"ts-jest",
|
|
30
|
+
{
|
|
31
|
+
tsconfig: "./tsconfig.json",
|
|
32
|
+
isolatedModules: true,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
moduleNameMapper: {
|
|
37
|
+
"\\.(css|less|scss|sss|styl)$": "<rootDir>/node_modules/jest-css-modules",
|
|
38
|
+
},
|
|
39
|
+
watchPlugins: [
|
|
40
|
+
"jest-watch-typeahead/filename",
|
|
41
|
+
"jest-watch-typeahead/testname",
|
|
42
|
+
],
|
|
43
|
+
setupFilesAfterEnv: ["jest-extended/all"],
|
|
44
|
+
};
|
|
45
|
+
export default config;
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m12 0c-4.962 0-9 4.066-9 9.065 0 7.103 8.154 14.437 8.501 14.745.143.127.321.19.499.19s.356-.063.499-.189c.347-.309 8.501-7.643 8.501-14.746 0-4.999-4.038-9.065-9-9.065zm0 14c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"/></svg>
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg version="1.1"
|
|
2
|
+
baseProfile="full"
|
|
3
|
+
width="300" height="200"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
id="example-svg"
|
|
6
|
+
>
|
|
7
|
+
|
|
8
|
+
<rect width="100%" height="100%" fill="red" />
|
|
9
|
+
|
|
10
|
+
<circle cx="150" cy="100" r="80" fill="green" />
|
|
11
|
+
|
|
12
|
+
<text x="150" y="125" font-size="30" text-anchor="middle" fill="white" id="text-svg">Example</text>
|
|
13
|
+
|
|
14
|
+
</svg>
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="Docs/Introduction" />
|
|
4
|
+
|
|
5
|
+
# 🖼 React Zoom Pan Pinch
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://bettertyped.com/">
|
|
9
|
+
<img src="https://custom-icon-badges.demolab.com/static/v1?label=&message=BetterTyped&color=333&logo=BT" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/react-zoom-pan-pinch">
|
|
12
|
+
<img src="https://custom-icon-badges.demolab.com/npm/v/react-zoom-pan-pinch.svg?logo=npm&color=e22121" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://github.com/prc5/react-zoom-pan-pinch">
|
|
15
|
+
<img src="https://custom-icon-badges.demolab.com/github/stars/prc5/react-zoom-pan-pinch?logo=star" />
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://github.com/prc5/react-zoom-pan-pinch/blob/main/License.md">
|
|
18
|
+
<img src="https://custom-icon-badges.demolab.com/github/license/prc5/react-zoom-pan-pinch?logo=law&color=yellow" />
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://github.com/semantic-release/semantic-release">
|
|
21
|
+
<img src="https://custom-icon-badges.demolab.com/badge/semver-commitzen-e10079?logo=semantic-release&color=e76f51" />
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://www.npmjs.com/package/react-zoom-pan-pinch">
|
|
24
|
+
<img src="https://custom-icon-badges.demolab.com/npm/dm/react-zoom-pan-pinch?logoColor=fff&logo=trending-up" />
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://www.npmjs.com/package/react-zoom-pan-pinch">
|
|
27
|
+
<img src="https://custom-icon-badges.demolab.com/bundlephobia/minzip/react-zoom-pan-pinch?color=E10098&logo=package" />
|
|
28
|
+
</a>
|
|
29
|
+
<a href="https://github.com/prc5/react-zoom-pan-pinch">
|
|
30
|
+
<img src="https://custom-icon-badges.demolab.com/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" />
|
|
31
|
+
</a>
|
|
32
|
+
<a href="https://hits.sh/github.com/prc5/react-zoom-pan-pinch/">
|
|
33
|
+
<img src="https://hits.sh/github.com/prc5/react-zoom-pan-pinch.svg?color=64BC4B&logo=bookmeter" />
|
|
34
|
+
</a>
|
|
35
|
+
<a href="https://twitter.com/maciej_pyrc">
|
|
36
|
+
<img
|
|
37
|
+
alt="Twitter Follow"
|
|
38
|
+
src="https://img.shields.io/twitter/follow/maciej_pyrc?label=Follow%20&style=social"
|
|
39
|
+
/>
|
|
40
|
+
</a>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
> Super fast and light react npm package for zooming, panning and pinching html
|
|
44
|
+
> elements in easy way
|
|
45
|
+
|
|
46
|
+
- [Demo](https://prc5.github.io/react-zoom-pan-pinch/?path=/story/examples-big-image--big-image)
|
|
47
|
+
- [Docs](https://prc5.github.io/react-zoom-pan-pinch/?path=/story/docs-props--page)
|
|
48
|
+
|
|
49
|
+
## Key Features
|
|
50
|
+
|
|
51
|
+
- 🚀 Fast and easy to use
|
|
52
|
+
- 🏭 Light, without external dependencies
|
|
53
|
+
- 💎 Mobile gestures, touchpad gestures and desktop mouse events support
|
|
54
|
+
- 🎁 Powerful context usage, which gives you a lot of freedom
|
|
55
|
+
- 🔧 Highly customizable
|
|
56
|
+
- 👑 Animations and Utils to create own tools
|
|
57
|
+
- 🔮 Advanced hooks and components
|
|
58
|
+
|
|
59
|
+
## Help me keep working on this project ❤️
|
|
60
|
+
|
|
61
|
+
- [Become a Sponsor on GitHub](https://github.com/sponsors/prc5)
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install --save react-zoom-pan-pinch
|
|
69
|
+
or
|
|
70
|
+
yarn add react-zoom-pan-pinch
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
import React, { Component } from "react";
|
|
77
|
+
|
|
78
|
+
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
|
79
|
+
|
|
80
|
+
const Example = () => {
|
|
81
|
+
return (
|
|
82
|
+
<TransformWrapper>
|
|
83
|
+
<TransformComponent>
|
|
84
|
+
<img src="image.jpg" alt="test" />
|
|
85
|
+
</TransformComponent>
|
|
86
|
+
</TransformWrapper>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
or
|
|
92
|
+
|
|
93
|
+
```jsx
|
|
94
|
+
import React, { Component } from "react";
|
|
95
|
+
|
|
96
|
+
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
|
97
|
+
|
|
98
|
+
const Example = () => {
|
|
99
|
+
return (
|
|
100
|
+
<TransformWrapper
|
|
101
|
+
initialScale={1}
|
|
102
|
+
initialPositionX={200}
|
|
103
|
+
initialPositionY={100}
|
|
104
|
+
>
|
|
105
|
+
{({ zoomIn, zoomOut, resetTransform, ...rest }) => (
|
|
106
|
+
<React.Fragment>
|
|
107
|
+
<div className="tools">
|
|
108
|
+
<button onClick={() => zoomIn()}>+</button>
|
|
109
|
+
<button onClick={() => zoomOut()}>-</button>
|
|
110
|
+
<button onClick={() => resetTransform()}>x</button>
|
|
111
|
+
</div>
|
|
112
|
+
<TransformComponent>
|
|
113
|
+
<img src="image.jpg" alt="test" />
|
|
114
|
+
<div>Example text</div>
|
|
115
|
+
</TransformComponent>
|
|
116
|
+
</React.Fragment>
|
|
117
|
+
)}
|
|
118
|
+
</TransformWrapper>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
or
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import React, { useRef } from "react";
|
|
127
|
+
import {
|
|
128
|
+
TransformWrapper,
|
|
129
|
+
TransformComponent,
|
|
130
|
+
ReactZoomPanPinchRef,
|
|
131
|
+
} from "react-zoom-pan-pinch";
|
|
132
|
+
|
|
133
|
+
const Controls = ({ zoomIn, zoomOut, resetTransform }) => (
|
|
134
|
+
<>
|
|
135
|
+
<button onClick={() => zoomIn()}>+</button>
|
|
136
|
+
<button onClick={() => zoomOut()}>-</button>
|
|
137
|
+
<button onClick={() => resetTransform()}>x</button>
|
|
138
|
+
</>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const Component = () => {
|
|
142
|
+
const transformComponentRef = useRef<ReactZoomPanPinchRef | null>(null);
|
|
143
|
+
|
|
144
|
+
const zoomToImage = () => {
|
|
145
|
+
if (transformComponentRef.current) {
|
|
146
|
+
const { zoomToElement } = transformComponentRef.current;
|
|
147
|
+
zoomToElement("imgExample");
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<TransformWrapper
|
|
153
|
+
initialScale={1}
|
|
154
|
+
initialPositionX={200}
|
|
155
|
+
initialPositionY={100}
|
|
156
|
+
ref={transformComponentRef}
|
|
157
|
+
>
|
|
158
|
+
{(utils) => (
|
|
159
|
+
<React.Fragment>
|
|
160
|
+
<Controls {...utils} />
|
|
161
|
+
<TransformComponent>
|
|
162
|
+
<img src="image.jpg" alt="test" id="imgExample" />
|
|
163
|
+
<div onClick={zoomToImage}>Example text</div>
|
|
164
|
+
</TransformComponent>
|
|
165
|
+
</React.Fragment>
|
|
166
|
+
)}
|
|
167
|
+
</TransformWrapper>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT © [prc5](https://github.com/prc5)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
import { getHandlersTable } from "./handlers.tsx";
|
|
4
|
+
import { Code } from "../utils";
|
|
5
|
+
|
|
6
|
+
<Meta title="Docs/Handlers" />
|
|
7
|
+
|
|
8
|
+
# Handlers
|
|
9
|
+
|
|
10
|
+
List of additionaly added handlers - you can acces them via ref or render props
|
|
11
|
+
|
|
12
|
+
<table className="handlers-table">
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
<th>
|
|
16
|
+
Name
|
|
17
|
+
</th>
|
|
18
|
+
<th>
|
|
19
|
+
Type
|
|
20
|
+
</th>
|
|
21
|
+
<th>
|
|
22
|
+
Default
|
|
23
|
+
</th>
|
|
24
|
+
<th>
|
|
25
|
+
Description
|
|
26
|
+
</th>
|
|
27
|
+
</tr>
|
|
28
|
+
</thead>
|
|
29
|
+
<tbody>
|
|
30
|
+
{getHandlersTable().map(row => (
|
|
31
|
+
<tr className={row.isObjectRow ? "is-object-row" : ""}>
|
|
32
|
+
<td>
|
|
33
|
+
{row.name}
|
|
34
|
+
</td>
|
|
35
|
+
<td>
|
|
36
|
+
{row.type.map(type => (<Code code={type} />))}
|
|
37
|
+
</td>
|
|
38
|
+
<td>
|
|
39
|
+
{row.parameters.map(param => (<Code code={param} />))}
|
|
40
|
+
</td>
|
|
41
|
+
<td>
|
|
42
|
+
{row.description}
|
|
43
|
+
</td>
|
|
44
|
+
</tr>
|
|
45
|
+
))}
|
|
46
|
+
</tbody>
|
|
47
|
+
|
|
48
|
+
</table>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { ReactZoomPanPinchHandlers } from "../../models/context.model";
|
|
4
|
+
|
|
5
|
+
export type ControlsFnOptionsType = {
|
|
6
|
+
name: React.ReactNode;
|
|
7
|
+
type: string[];
|
|
8
|
+
parameters: string[];
|
|
9
|
+
description: string;
|
|
10
|
+
isObjectRow?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ComponentProps = Record<
|
|
14
|
+
keyof ReactZoomPanPinchHandlers,
|
|
15
|
+
| Omit<ControlsFnOptionsType, "name" | "isObjectRow">
|
|
16
|
+
| Record<string, Omit<ControlsFnOptionsType, "name" | "isObjectRow">>
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export const handlersTable: ComponentProps = {
|
|
20
|
+
zoomIn: {
|
|
21
|
+
type: ["function(step, animationTime, animationName)"],
|
|
22
|
+
parameters: [
|
|
23
|
+
"step: number = 0.5",
|
|
24
|
+
"animationTime: number = 300",
|
|
25
|
+
"animationName: string = easeOut",
|
|
26
|
+
],
|
|
27
|
+
description: "Function used for zoom in button",
|
|
28
|
+
},
|
|
29
|
+
zoomOut: {
|
|
30
|
+
type: ["function(step, animationTime, animationName)"],
|
|
31
|
+
parameters: [
|
|
32
|
+
"step: number = 0.5",
|
|
33
|
+
"animationTime: number = 300",
|
|
34
|
+
"animationName: string = easeOut",
|
|
35
|
+
],
|
|
36
|
+
description: "Function used for zoom out button",
|
|
37
|
+
},
|
|
38
|
+
setTransform: {
|
|
39
|
+
type: ["function(x, y, scale, animationTime, animationName)"],
|
|
40
|
+
parameters: [
|
|
41
|
+
"x: number",
|
|
42
|
+
"y: number",
|
|
43
|
+
"scale: number",
|
|
44
|
+
"animationTime: number = 300",
|
|
45
|
+
"animationName: string = easeOut",
|
|
46
|
+
],
|
|
47
|
+
description: "Function used for custom transformation animation",
|
|
48
|
+
},
|
|
49
|
+
resetTransform: {
|
|
50
|
+
type: ["function(animationTime, animationName)"],
|
|
51
|
+
parameters: [
|
|
52
|
+
"animationTime: number = 300",
|
|
53
|
+
"animationName: string = easeOut",
|
|
54
|
+
],
|
|
55
|
+
description: "Function used for reset button",
|
|
56
|
+
},
|
|
57
|
+
centerView: {
|
|
58
|
+
type: ["function(scale, animationTime, animationName)"],
|
|
59
|
+
parameters: [
|
|
60
|
+
"scale: number = undefined",
|
|
61
|
+
"animationTime: number = 300",
|
|
62
|
+
"animationName: string = easeOut",
|
|
63
|
+
],
|
|
64
|
+
description: "Function used for centering the content component",
|
|
65
|
+
},
|
|
66
|
+
zoomToElement: {
|
|
67
|
+
type: ["function(node, customZoom, animationTime, animationName)"],
|
|
68
|
+
parameters: [
|
|
69
|
+
"node: HTMLElement | string",
|
|
70
|
+
"customScale: number = undefined",
|
|
71
|
+
"animationTime: number = 300",
|
|
72
|
+
"animationName: string = easeOut",
|
|
73
|
+
],
|
|
74
|
+
description:
|
|
75
|
+
"This function make a transition for certain node provided to the function(as node element or it's id string). It allows only to zoom elements with offsetWidth and offsetHeight properties - since SVG's doesn't have those, it is impossible to perform it on such elements.",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const getHandlersTable = (): ControlsFnOptionsType[] => {
|
|
80
|
+
return Object.keys(handlersTable).reduce<ControlsFnOptionsType[]>(
|
|
81
|
+
(acc, key) => {
|
|
82
|
+
if (Array.isArray(handlersTable[key]?.type)) {
|
|
83
|
+
acc.push({
|
|
84
|
+
...handlersTable[key],
|
|
85
|
+
name: key,
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
Object.keys(handlersTable[key]).forEach((prop) => {
|
|
89
|
+
acc.push({
|
|
90
|
+
...handlersTable[key][prop],
|
|
91
|
+
isObjectRow: key === prop,
|
|
92
|
+
name:
|
|
93
|
+
key === prop ? (
|
|
94
|
+
<b>{prop}</b>
|
|
95
|
+
) : (
|
|
96
|
+
<>
|
|
97
|
+
{key}.<b>{prop}</b>
|
|
98
|
+
</>
|
|
99
|
+
),
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return acc;
|
|
104
|
+
},
|
|
105
|
+
[],
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
import { componentProps, wrapperProps } from "./props.tsx";
|
|
4
|
+
import { Code } from "../utils";
|
|
5
|
+
|
|
6
|
+
<Meta title="Docs/Props" />
|
|
7
|
+
|
|
8
|
+
# TransformComponent Props
|
|
9
|
+
|
|
10
|
+
List of props
|
|
11
|
+
|
|
12
|
+
<table className="props-table">
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
<th>
|
|
16
|
+
Name
|
|
17
|
+
</th>
|
|
18
|
+
<th>
|
|
19
|
+
Type
|
|
20
|
+
</th>
|
|
21
|
+
<th>
|
|
22
|
+
Default
|
|
23
|
+
</th>
|
|
24
|
+
<th>
|
|
25
|
+
Description
|
|
26
|
+
</th>
|
|
27
|
+
</tr>
|
|
28
|
+
</thead>
|
|
29
|
+
<tbody>
|
|
30
|
+
{componentProps.map(row => (
|
|
31
|
+
<tr className={row.isObjectRow ? "is-object-row" : ""}>
|
|
32
|
+
<td>
|
|
33
|
+
{row.name}
|
|
34
|
+
</td>
|
|
35
|
+
<td>
|
|
36
|
+
{row.type.map(type => (<Code code={type} />))}
|
|
37
|
+
</td>
|
|
38
|
+
<td>
|
|
39
|
+
<Code code={row.defaultValue} />
|
|
40
|
+
</td>
|
|
41
|
+
<td>
|
|
42
|
+
{row.description}
|
|
43
|
+
</td>
|
|
44
|
+
</tr>
|
|
45
|
+
))}
|
|
46
|
+
</tbody>
|
|
47
|
+
|
|
48
|
+
</table>
|
|
49
|
+
|
|
50
|
+
<br />
|
|
51
|
+
|
|
52
|
+
# TransformWrapper Props
|
|
53
|
+
|
|
54
|
+
List of props
|
|
55
|
+
|
|
56
|
+
<table className="props-table">
|
|
57
|
+
<thead>
|
|
58
|
+
<tr>
|
|
59
|
+
<th>
|
|
60
|
+
Name
|
|
61
|
+
</th>
|
|
62
|
+
<th>
|
|
63
|
+
Type
|
|
64
|
+
</th>
|
|
65
|
+
<th>
|
|
66
|
+
Default
|
|
67
|
+
</th>
|
|
68
|
+
<th>
|
|
69
|
+
Description
|
|
70
|
+
</th>
|
|
71
|
+
</tr>
|
|
72
|
+
</thead>
|
|
73
|
+
<tbody>
|
|
74
|
+
{wrapperProps.map(row => (
|
|
75
|
+
<tr className={row.isObjectRow ? "is-object-row" : ""}>
|
|
76
|
+
<td>
|
|
77
|
+
{row.name}
|
|
78
|
+
</td>
|
|
79
|
+
<td>
|
|
80
|
+
{row.type.map(type => (<Code code={type} />))}
|
|
81
|
+
</td>
|
|
82
|
+
<td>
|
|
83
|
+
<Code code={row.defaultValue} />
|
|
84
|
+
</td>
|
|
85
|
+
<td>
|
|
86
|
+
{row.description}
|
|
87
|
+
</td>
|
|
88
|
+
</tr>
|
|
89
|
+
))}
|
|
90
|
+
</tbody>
|
|
91
|
+
|
|
92
|
+
</table>
|