@weser/layers 0.0.14 → 0.0.16

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 CHANGED
@@ -1,22 +1,3 @@
1
1
  # @weser/layers
2
2
 
3
- <img alt="npm version" src="https://badge.fury.io/js/@weser%2Flayers.svg"> <img alt="npm downloads" src="https://img.shields.io/npm/dm/@weser/layers.svg"> <a href="https://bundlephobia.com/result?p=@weser/layers@latest"><img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/@weser/layers.svg"></a>
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)
@@ -2,6 +2,7 @@
2
2
  export type T_Layer = {
3
3
  id: string;
4
4
  element: Object;
5
+ data?: Record<string, any>;
5
6
  };
6
7
  type LayerContext = {
7
8
  layers: Array<T_Layer>;
@@ -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.14",
3
+ "version": "0.0.16",
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": "2844a44c54a0ada9f675baf40226f87fe894c29f"
57
+ "gitHead": "7b2bc4fa318330eb2031b0d1835554a8a9f0f6bd"
58
58
  }