@weser/layers 0.0.14 → 0.0.15
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/README.md +1 -20
- package/dist/LayerContext.d.ts +1 -0
- package/dist/useLayer.d.ts +1 -1
- package/dist/useLayer.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
1
|
# @weser/layers
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
# npm
|
|
9
|
-
npm i --save @weser/layers
|
|
10
|
-
# yarn
|
|
11
|
-
yarn add @weser/layers
|
|
12
|
-
# pnpm
|
|
13
|
-
pnpm add @weser/layers
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Documentation
|
|
17
|
-
|
|
18
|
-
## License
|
|
19
|
-
|
|
20
|
-
@weser/layers is licensed under the [MIT License](http://opensource.org/licenses/MIT).<br>
|
|
21
|
-
Documentation is licensed under [Creative Common License](http://creativecommons.org/licenses/by/4.0/).<br>
|
|
22
|
-
Created with ♥ by [@robinweser](http://weser.io).
|
|
3
|
+
[Documentation](https://packages.weser.io/layers)
|
package/dist/LayerContext.d.ts
CHANGED
package/dist/useLayer.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
export default function useLayer<T extends HTMLElement>(visible: boolean): [RefObject<T>, boolean];
|
|
2
|
+
export default function useLayer<T extends HTMLElement>(visible: boolean, data?: Record<string, any>): [RefObject<T>, boolean, string];
|
package/dist/useLayer.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useEffect, useId, useRef } from 'react';
|
|
3
3
|
import useLayerContext from './useLayerContext.js';
|
|
4
|
-
export default function useLayer(visible) {
|
|
4
|
+
export default function useLayer(visible, data) {
|
|
5
5
|
const id = useId();
|
|
6
6
|
const ref = useRef(null);
|
|
7
7
|
const { layers, addLayer, removeLayer, hasLayer } = useLayerContext();
|
|
8
8
|
useEffect(() => {
|
|
9
9
|
if (visible) {
|
|
10
|
-
addLayer({ id, element: ref });
|
|
10
|
+
addLayer({ id, element: ref, data });
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
13
|
if (hasLayer(id)) {
|
|
@@ -17,5 +17,5 @@ export default function useLayer(visible) {
|
|
|
17
17
|
return () => removeLayer(id);
|
|
18
18
|
}, [visible]);
|
|
19
19
|
const active = layers[layers.length - 1]?.id === id;
|
|
20
|
-
return [ref, active];
|
|
20
|
+
return [ref, active, id];
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weser/layers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "React library for working with multiple layers",
|
|
5
5
|
"author": "Robin Weser <robin@weser.io>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"rimraf": "^3.0.2",
|
|
55
55
|
"typescript": "^5.4.5"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "09f1d19b11a34e519fd35cf91cede2b75f38356c"
|
|
58
58
|
}
|