@aracna/react 1.0.49 → 1.0.51

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.
Files changed (34) hide show
  1. package/definitions/interfaces.d.ts +1 -1
  2. package/functions/create-base-element-component.d.ts +4 -4
  3. package/functions/create-base-element-component.js +1 -1
  4. package/functions/create-element-component.d.ts +2 -2
  5. package/functions/create-element-component.js +1 -1
  6. package/functions/create-floating-element-component.d.ts +4 -4
  7. package/functions/create-floating-element-component.js +1 -1
  8. package/functions/create-focus-trap-element-component.d.ts +4 -4
  9. package/functions/create-focus-trap-element-component.js +1 -1
  10. package/functions/create-form-control-element-component.d.ts +4 -4
  11. package/functions/create-form-control-element-component.js +1 -1
  12. package/functions/forward-ref.d.ts +1 -1
  13. package/hooks/use-dom-rect.d.ts +2 -2
  14. package/hooks/use-dom-rect.js +1 -1
  15. package/hooks/use-element-ref.d.ts +1 -1
  16. package/hooks/use-element-ref.js +1 -1
  17. package/hooks/use-event-listener.d.ts +2 -2
  18. package/hooks/use-event-listener.js +1 -1
  19. package/hooks/use-intersection-observer.d.ts +3 -3
  20. package/hooks/use-intersection-observer.js +1 -1
  21. package/hooks/use-life-cycle.d.ts +1 -1
  22. package/hooks/use-life-cycle.js +1 -1
  23. package/hooks/use-observable-element-component.d.ts +1 -1
  24. package/hooks/use-observable-element-component.js +1 -1
  25. package/hooks/use-window-event-listener.d.ts +1 -1
  26. package/hooks/use-window-event-listener.js +1 -1
  27. package/hooks/use-window-size.d.ts +1 -1
  28. package/hooks/use-window-size.js +1 -1
  29. package/index.cjs +1 -1
  30. package/index.d.ts +14 -699
  31. package/index.iife.js +1 -1
  32. package/package.json +23 -23
  33. package/definitions/generated-props.d.ts +0 -194
  34. package/definitions/generated-props.js +0 -0
@@ -1,4 +1,4 @@
1
- import type { AttributeChangeEvent, StateChangeEvent } from '@aracna/web';
1
+ import type { AttributeChangeEvent, StateChangeEvent } from '@aracna/web-components';
2
2
  import type { MutableRefObject } from 'react';
3
3
  import type { UseIntersectionObserverElement } from './types.js';
4
4
  export interface UseIntersectionObserverAreSomeIntersecting {
@@ -1,10 +1,10 @@
1
- import { KeyOf } from '@aracna/core';
2
- import { BaseElementAttributes, BaseElementEventMap } from '@aracna/web';
3
- import { ElementComponent, ElementComponentProps } from '../definitions/types.js';
1
+ import type { KeyOf } from '@aracna/core';
2
+ import type { AracnaBaseElementAttributes, AracnaBaseElementEventMap } from '@aracna/web-components';
3
+ import type { ElementComponent, ElementComponentProps } from '../definitions/types.js';
4
4
  /**
5
5
  * Creates a new React component that renders a custom element which extends `BaseElement`.
6
6
  * Optionally the events can be defined as well.
7
7
  *
8
8
  * [Aracna Reference](https://aracna.dariosechi.it/react/functions/create-base-element-component)
9
9
  */
10
- export declare function createBaseElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends BaseElementAttributes = BaseElementAttributes, Events extends BaseElementEventMap = BaseElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
10
+ export declare function createBaseElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends AracnaBaseElementAttributes = AracnaBaseElementAttributes, Events extends AracnaBaseElementEventMap = AracnaBaseElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
@@ -1 +1 @@
1
- import{createElementComponent as m}from"./create-element-component.js";function f(e,t,n=[]){return m(e,t,["attribute-change","state-change",...n])}export{f as createBaseElementComponent};
1
+ import{createElementComponent as a}from"./create-element-component.js";function o(e,t,n=[]){return a(e,t,["attribute-change","state-change",...n])}export{o as createBaseElementComponent};
@@ -1,5 +1,5 @@
1
- import { KeyOf } from '@aracna/core';
2
- import { ElementComponent, ElementComponentAttributes, ElementComponentEvents, ElementComponentProps } from '../definitions/types.js';
1
+ import { type KeyOf } from '@aracna/core';
2
+ import type { ElementComponent, ElementComponentAttributes, ElementComponentEvents, ElementComponentProps } from '../definitions/types.js';
3
3
  /**
4
4
  * Creates a new React component that renders a custom element.
5
5
  * Optionally the events can be defined as well.
@@ -1 +1 @@
1
- import{getPascalCaseString as E}from"@aracna/core";import{createComponent as r}from"@lit/react";import s from"react";import{DEFAULT_ELEMENT_COMPONENT_EVENTS as p}from"../definitions/constants.js";function N(t,n,m=[]){return r({elementClass:n,events:{...p,...m.reduce((o,e)=>({...o,["on"+E(String(e))]:e}),{})},react:s,tagName:t})}export{N as createElementComponent};
1
+ import{getPascalCaseString as E}from"@aracna/core";import{createComponent as s}from"@lit/react";import p from"react";import{DEFAULT_ELEMENT_COMPONENT_EVENTS as r}from"../definitions/constants.js";function f(t,n,o=[]){return s({elementClass:n,events:{...r,...o.reduce((m,e)=>({...m,["on"+E(String(e))]:e}),{})},react:p,tagName:t})}export{f as createElementComponent};
@@ -1,10 +1,10 @@
1
- import { KeyOf } from '@aracna/core';
2
- import { FloatingElementAttributes, FloatingElementEventMap } from '@aracna/web';
3
- import { ElementComponent, ElementComponentProps } from '../definitions/types.js';
1
+ import type { KeyOf } from '@aracna/core';
2
+ import type { AracnaFloatingElementAttributes, AracnaFloatingElementEventMap } from '@aracna/web-components';
3
+ import type { ElementComponent, ElementComponentProps } from '../definitions/types.js';
4
4
  /**
5
5
  * Creates a new React component that renders a custom element which extends `FloatingElement`.
6
6
  * Optionally the events can be defined as well.
7
7
  *
8
8
  * [Aracna Reference](https://aracna.dariosechi.it/react/functions/create-floating-element-component)
9
9
  */
10
- export declare function createFloatingElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends FloatingElementAttributes = FloatingElementAttributes, Events extends FloatingElementEventMap = FloatingElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
10
+ export declare function createFloatingElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends AracnaFloatingElementAttributes = AracnaFloatingElementAttributes, Events extends AracnaFloatingElementEventMap = AracnaFloatingElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
@@ -1 +1 @@
1
- import{createBaseElementComponent as m}from"./create-base-element-component.js";function f(e,t,n){return m(e,t,n)}export{f as createFloatingElementComponent};
1
+ import{createBaseElementComponent as o}from"./create-base-element-component.js";function m(e,t,n){return o(e,t,n)}export{m as createFloatingElementComponent};
@@ -1,10 +1,10 @@
1
- import { KeyOf } from '@aracna/core';
2
- import { FocusTrapElementAttributes, FocusTrapElementEventMap } from '@aracna/web';
3
- import { ElementComponent, ElementComponentProps } from '../definitions/types.js';
1
+ import type { KeyOf } from '@aracna/core';
2
+ import type { AracnaFocusTrapElementAttributes, AracnaFocusTrapElementEventMap } from '@aracna/web-components';
3
+ import type { ElementComponent, ElementComponentProps } from '../definitions/types.js';
4
4
  /**
5
5
  * Creates a new React component that renders a custom element which extends `FocusTrapElement`.
6
6
  * Optionally the events can be defined as well.
7
7
  *
8
8
  * [Aracna Reference](https://aracna.dariosechi.it/react/functions/create-focus-trap-element-component)
9
9
  */
10
- export declare function createFocusTrapElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends FocusTrapElementAttributes = FocusTrapElementAttributes, Events extends FocusTrapElementEventMap = FocusTrapElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
10
+ export declare function createFocusTrapElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends AracnaFocusTrapElementAttributes = AracnaFocusTrapElementAttributes, Events extends AracnaFocusTrapElementEventMap = AracnaFocusTrapElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
@@ -1 +1 @@
1
- import{createBaseElementComponent as o}from"./create-base-element-component.js";function i(e,t,n=[]){return o(e,t,["focus-trap-activate","focus-trap-deactivate","focus-trap-post-activate","focus-trap-post-deactivate",...n])}export{i as createFocusTrapElementComponent};
1
+ import{createBaseElementComponent as a}from"./create-base-element-component.js";function r(e,t,n=[]){return a(e,t,["focus-trap-activate","focus-trap-deactivate","focus-trap-post-activate","focus-trap-post-deactivate",...n])}export{r as createFocusTrapElementComponent};
@@ -1,10 +1,10 @@
1
- import { KeyOf } from '@aracna/core';
2
- import { FormControlElementAttributes, FormControlElementEventMap } from '@aracna/web';
3
- import { ElementComponent, ElementComponentProps } from '../definitions/types.js';
1
+ import type { KeyOf } from '@aracna/core';
2
+ import type { AracnaFormControlElementAttributes, AracnaFormControlElementEventMap } from '@aracna/web-components';
3
+ import type { ElementComponent, ElementComponentProps } from '../definitions/types.js';
4
4
  /**
5
5
  * Creates a new React component that renders a custom element which extends `FormControlElement`.
6
6
  * Optionally the events can be defined as well.
7
7
  *
8
8
  * [Aracna Reference](https://aracna.dariosechi.it/react/functions/create-form-control-element-component)
9
9
  */
10
- export declare function createFormControlElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends FormControlElementAttributes = FormControlElementAttributes, Events extends FormControlElementEventMap = FormControlElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
10
+ export declare function createFormControlElementComponent<Element extends HTMLElementTagNameMap[Key], Attributes extends AracnaFormControlElementAttributes = AracnaFormControlElementAttributes, Events extends AracnaFormControlElementEventMap = AracnaFormControlElementEventMap, Props extends ElementComponentProps<Element, Attributes, Events> = ElementComponentProps<Element, Attributes, Events>, Key extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap>(tag: Key, element: new () => Element, events?: KeyOf.Shallow<Events>[]): ElementComponent<Element, Props>;
@@ -1 +1 @@
1
- import{createBaseElementComponent as o}from"./create-base-element-component.js";function f(e,t,n){return o(e,t,n)}export{f as createFormControlElementComponent};
1
+ import{createBaseElementComponent as o}from"./create-base-element-component.js";function m(e,t,n){return o(e,t,n)}export{m as createFormControlElementComponent};
@@ -1,4 +1,4 @@
1
- import { ForwardedRef, ReactElement } from 'react';
1
+ import { type ForwardedRef, type ReactElement } from 'react';
2
2
  type ForwardRefRenderFunction<T, P = {}> = (props: P, ref: ForwardedRef<T>) => ReactElement<P>;
3
3
  type NullableForwardRefRenderFunction<T, P = {}> = (props: P, ref: ForwardedRef<T>) => ReactElement<P> | null;
4
4
  type ForwardRefExoticComponent<P = {}> = (props: P) => ReactElement;
@@ -1,5 +1,5 @@
1
- import { DependencyList } from 'react';
2
- import { UseDOMRectElement } from '../index.js';
1
+ import { type DependencyList } from 'react';
2
+ import type { UseDOMRectElement } from '../definitions/types.js';
3
3
  /**
4
4
  * Returns the DOMRect of an element.
5
5
  * Optionally a dependency list can be passed to refresh the DOMRect.
@@ -1 +1 @@
1
- import{StubDOMRect as r}from"@aracna/web";import{useEffect as i,useState as o}from"react";function D(e,n=[]){const[c,t]=o(new r);return i(()=>{if(e instanceof Element){t(e.getBoundingClientRect());return}e?.current instanceof Element&&t(e.current.getBoundingClientRect())},[e,...n]),c}export{D as useDOMRect};
1
+ import{StubDOMRect as i}from"@aracna/web";import{useEffect as r,useState as s}from"react";function u(e,n=[]){const[c,t]=s(new i);return r(()=>{if(e instanceof Element){t(e.getBoundingClientRect());return}e?.current instanceof Element&&t(e.current.getBoundingClientRect())},[e,...n]),c}export{u as useDOMRect};
@@ -1,4 +1,4 @@
1
- import { MutableRefObject } from 'react';
1
+ import { type MutableRefObject } from 'react';
2
2
  /**
3
3
  * Returns a mutable ref object whose `.current` property is initialized with a matching element.
4
4
  *
@@ -1 +1 @@
1
- import{isWindowDefined as n}from"@aracna/core";import{useRef as a}from"react";function f(e,t){return a(n()?document.createElement(e,t):{current:{}})}export{f as useElementRef};
1
+ import{isWindowDefined as n}from"@aracna/core";import{useRef as a}from"react";function i(e,t){return a(n()?document.createElement(e,t):{current:{}})}export{i as useElementRef};
@@ -1,5 +1,5 @@
1
- import { DependencyList } from 'react';
2
- import { UseEventListenerElement } from '../index.js';
1
+ import { type DependencyList } from 'react';
2
+ import type { UseEventListenerElement } from '../definitions/types.js';
3
3
  /**
4
4
  * Adds an event listener to the given element.
5
5
  * Optionally a list of dependencies can be passed to refresh the listener.
@@ -1 +1 @@
1
- import{useEffect as E}from"react";function d(e,n,t,s=[]){E(()=>{if(e instanceof Element)return e.addEventListener(n,t),()=>e.removeEventListener(n,t);if(e?.current instanceof Element)return e.current.addEventListener(n,t),()=>e.current?.removeEventListener(n,t)},[e,n,t,...s])}export{d as useEventListener};
1
+ import{useEffect as i}from"react";function r(e,n,t,s=[]){i(()=>{if(e instanceof Element)return e.addEventListener(n,t),()=>e.removeEventListener(n,t);if(e?.current instanceof Element)return e.current.addEventListener(n,t),()=>e.current?.removeEventListener(n,t)},[e,n,t,...s])}export{r as useEventListener};
@@ -1,6 +1,6 @@
1
- import { DependencyList } from 'react';
2
- import { UseIntersectionObserverReturn } from '../definitions/interfaces.js';
3
- import { UseIntersectionObserverElement } from '../index.js';
1
+ import { type DependencyList } from 'react';
2
+ import type { UseIntersectionObserverReturn } from '../definitions/interfaces.js';
3
+ import type { UseIntersectionObserverElement } from '../definitions/types.js';
4
4
  /**
5
5
  * Creates an IntersectionObserver and observes the given targets.
6
6
  *
@@ -1 +1 @@
1
- import{isArray as b}from"@aracna/core";import{useEffect as y,useRef as a,useState as d}from"react";function L(c,r,u=[]){const t=a(),[s,f]=d([]),o=(...e)=>{const n=b(e[0])?e[0][0]instanceof Element?e[0]:[]:e[0]instanceof Element?e:[];if(n.length>0)return s.filter(i=>n.includes(i.target));const I=b(e[0])?e[0][0]?.current instanceof Element?e[0]:[]:e[0]?.current instanceof Element?e:[];return I.length>0?s.filter(i=>I.some(O=>O.current===i.target)):s},l=(...e)=>o(...e).some(n=>n.isIntersecting),v=(...e)=>o(...e).every(n=>n.isIntersecting),E=(...e)=>l(...e),m=e=>{f(e)};return y(()=>{t.current=new IntersectionObserver(m,r);for(let e of c){if(e instanceof Element){t.current.observe(e);continue}e?.current instanceof Element&&t.current.observe(e.current)}return()=>t.current?.disconnect()},[...c,r?.root,r?.rootMargin,r?.threshold,...u]),{entries:s,observer:t,areSomeIntersecting:l,isEveryIntersecting:v,isIntersecting:E}}export{L as useIntersectionObserver};
1
+ import{isArray as b}from"@aracna/core";import{useEffect as y,useRef as a,useState as d}from"react";function g(c,r,u=[]){const t=a(),[s,f]=d([]),o=(...e)=>{const n=b(e[0])?e[0][0]instanceof Element?e[0]:[]:e[0]instanceof Element?e:[];if(n.length>0)return s.filter(i=>n.includes(i.target));const I=b(e[0])?e[0][0]?.current instanceof Element?e[0]:[]:e[0]?.current instanceof Element?e:[];return I.length>0?s.filter(i=>I.some(O=>O.current===i.target)):s},l=(...e)=>o(...e).some(n=>n.isIntersecting),v=(...e)=>o(...e).every(n=>n.isIntersecting),E=(...e)=>l(...e),m=e=>{f(e)};return y(()=>{t.current=new IntersectionObserver(m,r);for(let e of c){if(e instanceof Element){t.current.observe(e);continue}e?.current instanceof Element&&t.current.observe(e.current)}return()=>t.current?.disconnect()},[...c,r?.root,r?.rootMargin,r?.threshold,...u]),{entries:s,observer:t,areSomeIntersecting:l,isEveryIntersecting:v,isIntersecting:E}}export{g as useIntersectionObserver};
@@ -1,4 +1,4 @@
1
- import { MutableRefObject } from 'react';
1
+ import { type MutableRefObject } from 'react';
2
2
  import { ComponentLifeCycle } from '../definitions/enums.js';
3
3
  /**
4
4
  * Returns the current life cycle of the component.
@@ -1 +1 @@
1
- import{useEffect as n,useRef as o}from"react";import{ComponentLifeCycle as t}from"../definitions/enums.js";function u(){const e=o(t.CONSTRUCTED);return n(()=>(e.current=t.MOUNTED,()=>{e.current=t.UNMOUNTED}),[]),e}export{u as useLifeCycle};
1
+ import{useEffect as n,useRef as o}from"react";import{ComponentLifeCycle as t}from"../definitions/enums.js";function c(){const e=o(t.CONSTRUCTED);return n(()=>(e.current=t.MOUNTED,()=>{e.current=t.UNMOUNTED}),[]),e}export{c as useLifeCycle};
@@ -1,4 +1,4 @@
1
- import { UseObservableElementComponentOptions, UseObservableElementComponentReturn } from '../definitions/interfaces.js';
1
+ import type { UseObservableElementComponentOptions, UseObservableElementComponentReturn } from '../definitions/interfaces.js';
2
2
  /**
3
3
  * Observes a custom element that extends `BaseElement` by listening to its attribute and state changes.
4
4
  *
@@ -1 +1 @@
1
- import{useCallback as i,useEffect as c,useRef as b,useState as d}from"react";import{useDispatch as f}from"./use-dispatch.js";function k(t){const l=b(null),r=f(),[s,n]=d({}),m=i(e=>{e.detail&&(t?.blacklist&&t.blacklist.includes(e.detail.name)||t?.whitelist&&!t.whitelist.includes(e.detail.name)||n(a=>e.detail?{...a,[e.detail.name]:e.detail.value}:a))},[t?.blacklist,t?.whitelist]),u=i(e=>{e.detail&&(t?.blacklist&&t.blacklist.includes(e.detail.name)||t?.whitelist&&!t.whitelist.includes(e.detail.name)||n(a=>e.detail?{...a,[e.detail.name]:e.detail.value}:a))},[t?.blacklist,t?.whitelist]);return c(()=>r(),[l.current]),{element:l.current,onAttributeChange:m,onStateChange:u,properties:s,ref:l}}export{k as useObservableElementComponent};
1
+ import{useCallback as i,useEffect as c,useRef as d,useState as b}from"react";import{useDispatch as f}from"./use-dispatch.js";function g(t){const l=d(null),r=f(),[s,n]=b({}),m=i(e=>{e.detail&&(t?.blacklist&&t.blacklist.includes(e.detail.name)||t?.whitelist&&!t.whitelist.includes(e.detail.name)||n(a=>e.detail?{...a,[e.detail.name]:e.detail.value}:a))},[t?.blacklist,t?.whitelist]),u=i(e=>{e.detail&&(t?.blacklist&&t.blacklist.includes(e.detail.name)||t?.whitelist&&!t.whitelist.includes(e.detail.name)||n(a=>e.detail?{...a,[e.detail.name]:e.detail.value}:a))},[t?.blacklist,t?.whitelist]);return c(()=>r(),[l.current]),{element:l.current,onAttributeChange:m,onStateChange:u,properties:s,ref:l}}export{g as useObservableElementComponent};
@@ -1,4 +1,4 @@
1
- import { DependencyList } from 'react';
1
+ import { type DependencyList } from 'react';
2
2
  /**
3
3
  * Adds an event listener to the window.
4
4
  * Optionally a dependency list can be passed to refresh the listener.
@@ -1 +1 @@
1
- import{useEffect as o}from"react";function r(e,n,t=[]){o(()=>(window.addEventListener(e,n),()=>window.removeEventListener(e,n)),[e,n,...t])}export{r as useWindowEventListener};
1
+ import{useEffect as o}from"react";function i(e,n,t=[]){o(()=>(window.addEventListener(e,n),()=>window.removeEventListener(e,n)),[e,n,...t])}export{i as useWindowEventListener};
@@ -1,4 +1,4 @@
1
- import { DependencyList } from 'react';
1
+ import { type DependencyList } from 'react';
2
2
  /**
3
3
  * Returns the window size.
4
4
  * Optionally a dependency list can be passed to refresh the dimensions.
@@ -1 +1 @@
1
- import{isWindowDefined as e}from"@aracna/core";import{useState as n}from"react";import{useWindowEventListener as W}from"./use-window-event-listener.js";function p(i=[]){const[t,r]=n(e()?window.innerHeight:0),[o,d]=n(e()?window.innerWidth:0),[w,u]=n(e()?window.outerHeight:0),[h,s]=n(e()?window.outerWidth:0);return W("resize",()=>{r(window.innerHeight),d(window.innerWidth),u(window.outerHeight),s(window.outerWidth)},i),{innerHeight:t,innerWidth:o,outerHeight:w,outerWidth:h}}export{p as useWindowSize};
1
+ import{isWindowDefined as e}from"@aracna/core";import{useState as n}from"react";import{useWindowEventListener as W}from"./use-window-event-listener.js";function c(t=[]){const[i,r]=n(e()?window.innerHeight:0),[o,d]=n(e()?window.innerWidth:0),[w,u]=n(e()?window.outerHeight:0),[h,s]=n(e()?window.outerWidth:0);return W("resize",()=>{r(window.innerHeight),d(window.innerWidth),u(window.outerHeight),s(window.outerWidth)},t),{innerHeight:i,innerWidth:o,outerHeight:w,outerWidth:h}}export{c as useWindowSize};
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var V=Object.create;var v=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var n in t)v(e,n,{get:t[n],enumerable:!0})},P=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!q.call(e,s)&&s!==n&&v(e,s,{get:()=>t[s],enumerable:!(o=_(t,s))||o.enumerable});return e};var Q=(e,t,n)=>(n=e!=null?V(G(e)):{},P(t||!e||!e.__esModule?v(n,"default",{value:e,enumerable:!0}):n,e)),X=e=>P(v({},"__esModule",{value:!0}),e);var ae={};J(ae,{ComponentLifeCycle:()=>R,Memo:()=>Y,createBaseElementComponent:()=>l,createElementComponent:()=>g,createFloatingElementComponent:()=>Z,createFocusTrapElementComponent:()=>$,createFormControlElementComponent:()=>ee,forwardRef:()=>te,useDOMRect:()=>ne,useDispatch:()=>T,useElementRef:()=>oe,useEventListener:()=>re,useIntersectionObserver:()=>se,useLifeCycle:()=>C,useObservableElementComponent:()=>ie,useWindowEventListener:()=>O,useWindowSize:()=>me});module.exports=X(ae);var h=require("react");function Y(e){return(0,h.useMemo)(()=>e.children,e.deps??[])}var R=(o=>(o.CONSTRUCTED="CONSTRUCTED",o.MOUNTED="MOUNTED",o.UNMOUNTED="UNMOUNTED",o))(R||{});var N=require("@aracna/core"),K=require("@lit/react"),D=Q(require("react"),1);var L={onAbort:"abort",onAnimationEnd:"animationend",onAnimationIteration:"animationiteration",onAnimationStart:"animationstart",onAuxClick:"auxclick",onBeforeInput:"beforeinput",onBlur:"blur",onCanPlay:"canplay",onCanPlayThrough:"canplaythrough",onChange:"change",onClick:"click",onCompositionEnd:"compositionend",onCompositionStart:"compositionstart",onCompositionUpdate:"compositionupdate",onContextMenu:"contextmenu",onCopy:"copy",onCut:"cut",onDoubleClick:"doubleclick",onDrag:"drag",onDragEnd:"dragend",onDragEnter:"dragenter",onDragExit:"dragexit",onDragLeave:"dragleave",onDragOver:"dragover",onDragStart:"dragstart",onDrop:"drop",onDurationChange:"durationchange",onEmptied:"emptied",onEncrypted:"encrypted",onEnded:"ended",onError:"error",onEventHandler:"eventhandler",onFocus:"focus",onInput:"input",onInvalid:"invalid",onKeyDown:"keydown",onKeyPress:"keypress",onKeyUp:"keyup",onLoad:"load",onLoadStart:"loadstart",onLoadedData:"loadeddata",onLoadedMetadata:"loadedmetadata",onMouseDown:"mousedown",onMouseEnter:"mouseenter",onMouseLeave:"mouseleave",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onPaste:"paste",onPause:"pause",onPlay:"play",onPlaying:"playing",onPointerCancel:"pointercancel",onPointerDown:"pointerdown",onPointerEnter:"pointerenter",onPointerLeave:"pointerleave",onPointerMove:"pointermove",onPointerOut:"pointerout",onPointerOver:"pointerover",onPointerUp:"pointerup",onProgress:"progress",onRateChange:"ratechange",onReset:"reset",onResize:"resize",onScroll:"scroll",onSeeked:"seeked",onSeeking:"seeking",onSelect:"select",onStalled:"stalled",onSubmit:"submit",onSuspend:"suspend",onTimeUpdate:"timeupdate",onTouchCancel:"touchcancel",onTouchEnd:"touchend",onTouchMove:"touchmove",onTouchStart:"touchstart",onTransitionEnd:"transitionend",onVolumeChange:"volumechange",onWaiting:"waiting",onWheel:"wheel"};function g(e,t,n=[]){return(0,K.createComponent)({elementClass:t,events:{...L,...n.reduce((o,s)=>({...o,["on"+(0,N.getPascalCaseString)(String(s))]:s}),{})},react:D.default,tagName:e})}function l(e,t,n=[]){return g(e,t,["attribute-change","state-change",...n])}function Z(e,t,n){return l(e,t,n)}function $(e,t,n=[]){return l(e,t,["focus-trap-activate","focus-trap-deactivate","focus-trap-post-activate","focus-trap-post-deactivate",...n])}function ee(e,t,n){return l(e,t,n)}var A=require("react");function te(...e){return(0,A.forwardRef)(e[0])}var I=require("react");var b=require("react");function C(){let e=(0,b.useRef)("CONSTRUCTED");return(0,b.useEffect)(()=>(e.current="MOUNTED",()=>{e.current="UNMOUNTED"}),[]),e}function T(e){let t=C(),n=(0,I.useReducer)(()=>({}),{});return()=>{switch(t.current){case"CONSTRUCTED":case"UNMOUNTED":break;case"MOUNTED":n[1](),e&&e();break}}}var k=require("@aracna/web"),y=require("react");function ne(e,t=[]){let[n,o]=(0,y.useState)(new k.StubDOMRect);return(0,y.useEffect)(()=>{if(e instanceof Element){o(e.getBoundingClientRect());return}e?.current instanceof Element&&o(e.current.getBoundingClientRect())},[e,...t]),n}var U=require("@aracna/core"),F=require("react");function oe(e,t){return(0,F.useRef)((0,U.isWindowDefined)()?document.createElement(e,t):{current:{}})}var S=require("react");function re(e,t,n,o=[]){(0,S.useEffect)(()=>{if(e instanceof Element)return e.addEventListener(t,n),()=>e.removeEventListener(t,n);if(e?.current instanceof Element)return e.current.addEventListener(t,n),()=>e.current?.removeEventListener(t,n)},[e,t,n,...o])}var x=require("@aracna/core"),u=require("react");function se(e,t,n=[]){let o=(0,u.useRef)(),[s,c]=(0,u.useState)([]),p=(...r)=>{let E=(0,x.isArray)(r[0])?r[0][0]instanceof Element?r[0]:[]:r[0]instanceof Element?r:[];if(E.length>0)return s.filter(M=>E.includes(M.target));let w=(0,x.isArray)(r[0])?r[0][0]?.current instanceof Element?r[0]:[]:r[0]?.current instanceof Element?r:[];return w.length>0?s.filter(M=>w.some(B=>B.current===M.target)):s},i=(...r)=>p(...r).some(E=>E.isIntersecting),m=(...r)=>p(...r).every(E=>E.isIntersecting),W=(...r)=>i(...r),j=r=>{c(r)};return(0,u.useEffect)(()=>{o.current=new IntersectionObserver(j,t);for(let r of e){if(r instanceof Element){o.current.observe(r);continue}r?.current instanceof Element&&o.current.observe(r.current)}return()=>o.current?.disconnect()},[...e,t?.root,t?.rootMargin,t?.threshold,...n]),{entries:s,observer:o,areSomeIntersecting:i,isEveryIntersecting:m,isIntersecting:W}}var a=require("react");function ie(e){let t=(0,a.useRef)(null),n=T(),[o,s]=(0,a.useState)({}),c=(0,a.useCallback)(i=>{i.detail&&(e?.blacklist&&e.blacklist.includes(i.detail.name)||e?.whitelist&&!e.whitelist.includes(i.detail.name)||s(m=>i.detail?{...m,[i.detail.name]:i.detail.value}:m))},[e?.blacklist,e?.whitelist]),p=(0,a.useCallback)(i=>{i.detail&&(e?.blacklist&&e.blacklist.includes(i.detail.name)||e?.whitelist&&!e.whitelist.includes(i.detail.name)||s(m=>i.detail?{...m,[i.detail.name]:i.detail.value}:m))},[e?.blacklist,e?.whitelist]);return(0,a.useEffect)(()=>n(),[t.current]),{element:t.current,onAttributeChange:c,onStateChange:p,properties:o,ref:t}}var H=require("react");function O(e,t,n=[]){(0,H.useEffect)(()=>(window.addEventListener(e,t),()=>window.removeEventListener(e,t)),[e,t,...n])}var d=require("@aracna/core"),f=require("react");function me(e=[]){let[t,n]=(0,f.useState)((0,d.isWindowDefined)()?window.innerHeight:0),[o,s]=(0,f.useState)((0,d.isWindowDefined)()?window.innerWidth:0),[c,p]=(0,f.useState)((0,d.isWindowDefined)()?window.outerHeight:0),[i,m]=(0,f.useState)((0,d.isWindowDefined)()?window.outerWidth:0);return O("resize",()=>{n(window.innerHeight),s(window.innerWidth),p(window.outerHeight),m(window.outerWidth)},e),{innerHeight:t,innerWidth:o,outerHeight:c,outerWidth:i}}
1
+ "use strict";var V=Object.create;var y=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var n in t)y(e,n,{get:t[n],enumerable:!0})},P=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!q.call(e,s)&&s!==n&&y(e,s,{get:()=>t[s],enumerable:!(o=_(t,s))||o.enumerable});return e};var Q=(e,t,n)=>(n=e!=null?V(G(e)):{},P(t||!e||!e.__esModule?y(n,"default",{value:e,enumerable:!0}):n,e)),X=e=>P(y({},"__esModule",{value:!0}),e);var me={};J(me,{ComponentLifeCycle:()=>h,Memo:()=>Y,createBaseElementComponent:()=>p,createElementComponent:()=>g,createFloatingElementComponent:()=>Z,createFocusTrapElementComponent:()=>$,createFormControlElementComponent:()=>ee,forwardRef:()=>te,useDOMRect:()=>ne,useDispatch:()=>T,useElementRef:()=>oe,useEventListener:()=>re,useIntersectionObserver:()=>se,useLifeCycle:()=>C,useObservableElementComponent:()=>ie,useWindowEventListener:()=>O,useWindowSize:()=>ae});module.exports=X(me);var A=require("react");function Y(e){return(0,A.useMemo)(()=>e.children,e.deps??[])}var h=(o=>(o.CONSTRUCTED="CONSTRUCTED",o.MOUNTED="MOUNTED",o.UNMOUNTED="UNMOUNTED",o))(h||{});var L=require("@aracna/core"),N=require("@lit/react"),K=Q(require("react"),1);var R={onAbort:"abort",onAnimationEnd:"animationend",onAnimationIteration:"animationiteration",onAnimationStart:"animationstart",onAuxClick:"auxclick",onBeforeInput:"beforeinput",onBlur:"blur",onCanPlay:"canplay",onCanPlayThrough:"canplaythrough",onChange:"change",onClick:"click",onCompositionEnd:"compositionend",onCompositionStart:"compositionstart",onCompositionUpdate:"compositionupdate",onContextMenu:"contextmenu",onCopy:"copy",onCut:"cut",onDoubleClick:"doubleclick",onDrag:"drag",onDragEnd:"dragend",onDragEnter:"dragenter",onDragExit:"dragexit",onDragLeave:"dragleave",onDragOver:"dragover",onDragStart:"dragstart",onDrop:"drop",onDurationChange:"durationchange",onEmptied:"emptied",onEncrypted:"encrypted",onEnded:"ended",onError:"error",onEventHandler:"eventhandler",onFocus:"focus",onInput:"input",onInvalid:"invalid",onKeyDown:"keydown",onKeyPress:"keypress",onKeyUp:"keyup",onLoad:"load",onLoadStart:"loadstart",onLoadedData:"loadeddata",onLoadedMetadata:"loadedmetadata",onMouseDown:"mousedown",onMouseEnter:"mouseenter",onMouseLeave:"mouseleave",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onPaste:"paste",onPause:"pause",onPlay:"play",onPlaying:"playing",onPointerCancel:"pointercancel",onPointerDown:"pointerdown",onPointerEnter:"pointerenter",onPointerLeave:"pointerleave",onPointerMove:"pointermove",onPointerOut:"pointerout",onPointerOver:"pointerover",onPointerUp:"pointerup",onProgress:"progress",onRateChange:"ratechange",onReset:"reset",onResize:"resize",onScroll:"scroll",onSeeked:"seeked",onSeeking:"seeking",onSelect:"select",onStalled:"stalled",onSubmit:"submit",onSuspend:"suspend",onTimeUpdate:"timeupdate",onTouchCancel:"touchcancel",onTouchEnd:"touchend",onTouchMove:"touchmove",onTouchStart:"touchstart",onTransitionEnd:"transitionend",onVolumeChange:"volumechange",onWaiting:"waiting",onWheel:"wheel"};function g(e,t,n=[]){return(0,N.createComponent)({elementClass:t,events:{...R,...n.reduce((o,s)=>({...o,["on"+(0,L.getPascalCaseString)(String(s))]:s}),{})},react:K.default,tagName:e})}function p(e,t,n=[]){return g(e,t,["attribute-change","state-change",...n])}function Z(e,t,n){return p(e,t,n)}function $(e,t,n=[]){return p(e,t,["focus-trap-activate","focus-trap-deactivate","focus-trap-post-activate","focus-trap-post-deactivate",...n])}function ee(e,t,n){return p(e,t,n)}var D=require("react");function te(...e){return(0,D.forwardRef)(e[0])}var I=require("react");var v=require("react");function C(){let e=(0,v.useRef)("CONSTRUCTED");return(0,v.useEffect)(()=>(e.current="MOUNTED",()=>{e.current="UNMOUNTED"}),[]),e}function T(e){let t=C(),n=(0,I.useReducer)(()=>({}),{});return()=>{switch(t.current){case"CONSTRUCTED":case"UNMOUNTED":break;case"MOUNTED":n[1](),e&&e();break}}}var k=require("@aracna/web"),b=require("react");function ne(e,t=[]){let[n,o]=(0,b.useState)(new k.StubDOMRect);return(0,b.useEffect)(()=>{if(e instanceof Element){o(e.getBoundingClientRect());return}e?.current instanceof Element&&o(e.current.getBoundingClientRect())},[e,...t]),n}var U=require("@aracna/core"),F=require("react");function oe(e,t){return(0,F.useRef)((0,U.isWindowDefined)()?document.createElement(e,t):{current:{}})}var S=require("react");function re(e,t,n,o=[]){(0,S.useEffect)(()=>{if(e instanceof Element)return e.addEventListener(t,n),()=>e.removeEventListener(t,n);if(e?.current instanceof Element)return e.current.addEventListener(t,n),()=>e.current?.removeEventListener(t,n)},[e,t,n,...o])}var x=require("@aracna/core"),E=require("react");function se(e,t,n=[]){let o=(0,E.useRef)(),[s,u]=(0,E.useState)([]),l=(...r)=>{let c=(0,x.isArray)(r[0])?r[0][0]instanceof Element?r[0]:[]:r[0]instanceof Element?r:[];if(c.length>0)return s.filter(M=>c.includes(M.target));let w=(0,x.isArray)(r[0])?r[0][0]?.current instanceof Element?r[0]:[]:r[0]?.current instanceof Element?r:[];return w.length>0?s.filter(M=>w.some(B=>B.current===M.target)):s},i=(...r)=>l(...r).some(c=>c.isIntersecting),a=(...r)=>l(...r).every(c=>c.isIntersecting),j=(...r)=>i(...r),W=r=>{u(r)};return(0,E.useEffect)(()=>{o.current=new IntersectionObserver(W,t);for(let r of e){if(r instanceof Element){o.current.observe(r);continue}r?.current instanceof Element&&o.current.observe(r.current)}return()=>o.current?.disconnect()},[...e,t?.root,t?.rootMargin,t?.threshold,...n]),{entries:s,observer:o,areSomeIntersecting:i,isEveryIntersecting:a,isIntersecting:j}}var m=require("react");function ie(e){let t=(0,m.useRef)(null),n=T(),[o,s]=(0,m.useState)({}),u=(0,m.useCallback)(i=>{i.detail&&(e?.blacklist&&e.blacklist.includes(i.detail.name)||e?.whitelist&&!e.whitelist.includes(i.detail.name)||s(a=>i.detail?{...a,[i.detail.name]:i.detail.value}:a))},[e?.blacklist,e?.whitelist]),l=(0,m.useCallback)(i=>{i.detail&&(e?.blacklist&&e.blacklist.includes(i.detail.name)||e?.whitelist&&!e.whitelist.includes(i.detail.name)||s(a=>i.detail?{...a,[i.detail.name]:i.detail.value}:a))},[e?.blacklist,e?.whitelist]);return(0,m.useEffect)(()=>n(),[t.current]),{element:t.current,onAttributeChange:u,onStateChange:l,properties:o,ref:t}}var H=require("react");function O(e,t,n=[]){(0,H.useEffect)(()=>(window.addEventListener(e,t),()=>window.removeEventListener(e,t)),[e,t,...n])}var d=require("@aracna/core"),f=require("react");function ae(e=[]){let[t,n]=(0,f.useState)((0,d.isWindowDefined)()?window.innerHeight:0),[o,s]=(0,f.useState)((0,d.isWindowDefined)()?window.innerWidth:0),[u,l]=(0,f.useState)((0,d.isWindowDefined)()?window.outerHeight:0),[i,a]=(0,f.useState)((0,d.isWindowDefined)()?window.outerWidth:0);return O("resize",()=>{n(window.innerHeight),s(window.innerWidth),l(window.outerHeight),a(window.outerWidth)},e),{innerHeight:t,innerWidth:o,outerHeight:u,outerWidth:i}}