lithesome 0.12.1 → 0.12.2

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.
@@ -7,7 +7,7 @@ interface FloatingConfig {
7
7
  constrainViewport?: boolean;
8
8
  sameWidth?: boolean;
9
9
  }
10
- export declare const useFloating: (target: HTMLElement, config: FloatingConfig) => {
10
+ export declare const useFloating: (node: HTMLElement, config: FloatingConfig) => {
11
11
  destroy(): void;
12
12
  } | undefined;
13
13
  export {};
@@ -1,6 +1,6 @@
1
1
  import { computePosition, flip, shift, autoUpdate, size, arrow as floatingArrow } from '@floating-ui/dom';
2
2
  import { defaultConfig, setNodeStyles, setNodeProps } from '../index.js';
3
- export const useFloating = (target, config) => {
3
+ export const useFloating = (node, config) => {
4
4
  const { anchor, arrow, placement, constrainViewport, sameWidth } = defaultConfig(config, {
5
5
  anchor: null,
6
6
  arrow: null,
@@ -11,8 +11,8 @@ export const useFloating = (target, config) => {
11
11
  if (!anchor)
12
12
  return;
13
13
  let cleanUp = null;
14
- cleanUp = autoUpdate(anchor, target, () => {
15
- computePosition(anchor, target, {
14
+ cleanUp = autoUpdate(anchor, node, () => {
15
+ computePosition(anchor, node, {
16
16
  placement,
17
17
  middleware: [
18
18
  arrow ? floatingArrow({ element: arrow }) : undefined,
@@ -25,7 +25,7 @@ export const useFloating = (target, config) => {
25
25
  if (sameWidth)
26
26
  elements.floating.style.width = elements.reference.getBoundingClientRect().width + 'px';
27
27
  if (constrainViewport) {
28
- setNodeStyles(anchor, {
28
+ setNodeStyles(node, {
29
29
  maxWidth: `${availableWidth}px`,
30
30
  maxHeight: `${availableHeight}px`
31
31
  });
@@ -35,12 +35,12 @@ export const useFloating = (target, config) => {
35
35
  ]
36
36
  }).then(({ x, y, placement, middlewareData }) => {
37
37
  const [side, alignment] = placement.split('-');
38
- setNodeStyles(target, {
38
+ setNodeStyles(node, {
39
39
  left: `${x}px`,
40
40
  top: `${y}px`,
41
41
  position: 'absolute'
42
42
  });
43
- setNodeProps(target, {
43
+ setNodeProps(node, {
44
44
  'data-side': side,
45
45
  'data-alignment': alignment || 'center'
46
46
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lithesome",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",