@nild/components 0.0.28 → 0.0.30

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/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{default as a}from"./button/index.js";import{default as o}from"./checkbox/index.js";import{default as r}from"./divider/Divider.js";import{default as t}from"./popover/Popover.js";import{default as s}from"./radio/index.js";import{default as f}from"./switch/index.js";import{default as m}from"./transition/Transition.js";import{default as i}from"./typography/index.js";/* empty css */export{a as Button,o as Checkbox,r as Divider,t as Popover,s as Radio,f as Switch,m as Transition,i as Typography};
1
+ import{default as a}from"./button/index.js";import{default as o}from"./checkbox/index.js";import{default as r}from"./divider/Divider.js";import{default as t}from"./popover/index.js";import{default as s}from"./radio/index.js";import{default as f}from"./switch/index.js";import{default as m}from"./transition/Transition.js";import{default as i}from"./typography/index.js";/* empty css */export{a as Button,o as Checkbox,r as Divider,t as Popover,s as Radio,f as Switch,m as Transition,i as Typography};
@@ -1,21 +1,4 @@
1
- import { FC, ReactNode } from 'react';
2
- import { default as Portal } from '../portal';
3
- import { default as Trigger, TriggerAction } from '../trigger';
4
- import { Placement, OffsetOptions } from '@floating-ui/dom';
5
- export interface PopoverProps {
6
- children?: ReactNode;
7
- placement?: Placement;
8
- offset?: OffsetOptions;
9
- action?: TriggerAction | TriggerAction[];
10
- open?: boolean;
11
- defaultOpen?: boolean;
12
- onChange?: (open: boolean) => void;
13
- }
14
- /**
15
- * @category Components
16
- */
17
- declare const Popover: FC<PopoverProps> & {
18
- Trigger: typeof Trigger;
19
- Portal: typeof Portal;
20
- };
1
+ import { FC } from 'react';
2
+ import { PopoverProps } from './interfaces';
3
+ declare const Popover: FC<PopoverProps>;
21
4
  export default Popover;
@@ -1 +1 @@
1
- import{jsxs as O,Fragment as P}from"react/jsx-runtime";import{useEffectCallback as t}from"@nild/hooks";import T from"../_shared/hooks/usePopup.js";import"../portal/Arrow.js";import h from"../portal/Portal.js";import x from"../trigger/Trigger.js";const o=({children:a,placement:l,offset:p,action:m,open:f,defaultOpen:s,onChange:e})=>{const[C,{setOpen:n,renderTrigger:i,renderPortal:c}]=T(a,{placement:l,offset:p,open:f,defaultOpen:s}),d=t(()=>{n(r=>(e?.(!r),!r))}),g=t(()=>{n(()=>(e?.(!0),!0))}),u=t(()=>{n(()=>(e?.(!1),!1))});return O(P,{children:[i({action:m,onToggle:d,onOpen:g,onClose:u}),c()]})};o.displayName="Popover",o.Trigger=x,o.Portal=h;export{o as default};
1
+ import{jsx as p}from"react/jsx-runtime";import a from"../popup/index.js";const o=r=>p(a,{...r});o.displayName="Popover";export{o as default};
@@ -1,3 +1,9 @@
1
- import { default as Popover, PopoverProps } from './Popover';
2
- export type { PopoverProps };
1
+ /**
2
+ * @category Components
3
+ */
4
+ declare const Popover: import('react').FC<import('./interfaces').PopoverProps> & {
5
+ Trigger: import('react').FC<import('../popup').TriggerProps>;
6
+ Portal: import('react').ForwardRefExoticComponent<import('../popup').PortalProps & import('react').RefAttributes<HTMLDivElement>>;
7
+ };
8
+ export type * from './interfaces';
3
9
  export default Popover;
@@ -1 +1 @@
1
- import r from"./Popover.js";export{r as default};
1
+ import r from"../popup/index.js";import o from"./Popover.js";const t=Object.assign(o,{Trigger:r.Trigger,Portal:r.Portal});export{t as default};
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ declare const Arrow: FC;
3
+ export default Arrow;
@@ -0,0 +1 @@
1
+ import{jsx as i}from"react/jsx-runtime";import{usePopupContext as m,useArrowContext as n}from"./contexts/index.js";import{arrowClassNames as p}from"./style/index.js";const r=()=>{const{arrowed:o,size:s,refs:e}=m(),{style:a,orientation:t}=n();return i("div",{className:p({arrowed:o,size:s,orientation:t}),style:a,ref:e.arrow})};r.displayName="Popup.Arrow";export{r as default};
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { PopupProps } from './interfaces';
3
+ declare const Popup: FC<PopupProps>;
4
+ export default Popup;
@@ -0,0 +1 @@
1
+ import{jsxs as B,jsx as s}from"react/jsx-runtime";import{useControllableState as D,useEffectCallback as f,useIsomorphicLayoutEffect as G}from"@nild/hooks";import{isArray as H,makeArray as J,isFunction as K}from"@nild/shared";import{Children as Q,isValidElement as U,useState as W,useMemo as X,useRef as Y}from"react";import Z from"../transition/Transition.js";import{PopupProvider as _,PortalProvider as $,ArrowProvider as ee}from"./contexts/index.js";import re from"./hooks/usePopup.js";import te from"./Portal.js";import C from"./Trigger.js";const k=({children:y,placement:g,offset:x,action:p="click",arrowed:P=!0,size:T="medium",delay:t=100,open:A,defaultOpen:d=!1,disabled:E,onOpen:h,onClose:v})=>{let i,w,n;Q.forEach(y,e=>{if(U(e))switch(e.type){case C:w=e;break;case te:n=e;break;default:i=e;break}});const[a,O]=W(d),[o,R]=D(A,d),[S,j=100]=H(t)?t:[t,t],l=X(()=>new Set(J(p)),[p]),r=Y(),[{triggerRef:u,portalRef:c,portalContext:z,arrowRef:F,arrowContext:I},{update:L,autoUpdate:M}]=re({placement:g,offset:x}),m=f(e=>{E||R(q=>{const b=K(e)?e(q):e;return b?h?.():v?.(),b})}),N=f(()=>{l.has("hover")&&(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{m(!0)},S))}),V=f(()=>{l.has("hover")&&(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{m(!1)},j))});return G(()=>{if(o&&!a)O(!0);else if(o&&a&&u.current&&c.current)return M(u.current,c.current,L)},[o,a]),B(_,{value:{actions:l,arrowed:P,size:T,refs:{trigger:u,portal:c,arrow:F},setOpen:m,enter:N,leave:V},children:[w||i&&s(C,{children:i}),s($,{value:z,children:s(ee,{value:I,children:n&&s(Z,{visible:o,children:a&&n})})})]})};k.displayName="Popup";export{k as default};
@@ -1,6 +1,3 @@
1
1
  import { PortalProps } from './interfaces';
2
- /**
3
- * @category Components
4
- */
5
2
  declare const Portal: import('react').ForwardRefExoticComponent<PortalProps & import('react').RefAttributes<HTMLDivElement>>;
6
3
  export default Portal;
@@ -0,0 +1 @@
1
+ import{jsxs as E,jsx as M}from"react/jsx-runtime";import{useEffectCallback as t}from"@nild/hooks";import{mergeRefs as P,cnMerge as n,getDPR as g}from"@nild/shared";import{forwardRef as h,Children as R,isValidElement as b,cloneElement as j}from"react";import{createPortal as w}from"react-dom";import z from"./Arrow.js";import{usePopupContext as L,usePortalContext as $}from"./contexts/index.js";import{portalContentClassNames as k,portalClassNames as A}from"./style/index.js";const m=h(({className:i,style:p,children:f,container:u=document.body,...a},c)=>{var r;const{size:d,refs:v,enter:x,leave:C}=L(),{coords:l}=$(),s=R.toArray(f).find(o=>b(o)),N=t(o=>{var e;(e=a?.onMouseEnter)==null||e.call(a,o),x()}),y=t(o=>{var e;(e=a?.onMouseLeave)==null||e.call(a,o),C()});return s?w(E("div",{...a,className:n(A(),i),style:{transform:`translate(${l.x}px, ${l.y}px)`,...g()>=1.5&&{willChange:"transform"},...p},onMouseEnter:N,onMouseLeave:y,ref:P(v.portal,c),children:[j(s,{...s.props,className:n(k({size:d}),(r=s?.props)==null?void 0:r.className)}),M(z,{})]}),u):null});m.displayName="Popup.Portal";export{m as default};
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { TriggerProps } from './interfaces';
3
+ declare const Trigger: FC<TriggerProps>;
4
+ export default Trigger;
@@ -0,0 +1 @@
1
+ import{useEffectCallback as u,useEventListener as m}from"@nild/hooks";import{mergeRefs as N,cnJoin as w}from"@nild/shared";import{Children as y,isValidElement as B,cloneElement as F}from"react";import{usePopupContext as P}from"./contexts/index.js";import{triggerClassNames as b}from"./style/index.js";const f=({children:g})=>{var p,v;const{actions:r,refs:a,setOpen:s,enter:h,leave:x}=P(),n=y.toArray(g).find(e=>B(e)),d=r.has("click")||r.has("contextMenu")?window:null,E=u(e=>{var o,l;(l=(o=n?.props)==null?void 0:o.onMouseEnter)==null||l.call(o,e),h()}),M=u(e=>{var o,l;(l=(o=n?.props)==null?void 0:o.onMouseLeave)==null||l.call(o,e),x()}),k=u(e=>{var o,l;(l=(o=n?.props)==null?void 0:o.onFocus)==null||l.call(o,e),r.has("focus")&&s(!0)}),C=u(e=>{var o,l;(l=(o=n?.props)==null?void 0:o.onBlur)==null||l.call(o,e),r.has("focus")&&s(!1)});return m(d,"click",e=>{var o,l;const t=e.target,i=(o=a.trigger.current)==null?void 0:o.contains(t),c=(l=a.portal.current)==null?void 0:l.contains(t);i?(r.has("click")&&s(L=>!L),r.has("contextMenu")&&s(!1)):!c&&s(!1)}),m(d,"contextmenu",e=>{var o,l;const t=e.target,i=(o=a.trigger.current)==null?void 0:o.contains(t),c=(l=a.portal.current)==null?void 0:l.contains(t);i?r.has("contextMenu")&&(e.preventDefault(),s(!0)):!c&&s(!1)}),n?F(n,{...n?.props,className:w(b(),(p=n?.props)==null?void 0:p.className),onMouseEnter:E,onMouseLeave:M,onFocus:k,onBlur:C,ref:N(a.trigger,(v=n?.props)==null?void 0:v.ref)}):null};f.displayName="Popup.Trigger";export{f as default};
@@ -0,0 +1,28 @@
1
+ import { CSSProperties, Dispatch, RefObject, SetStateAction } from 'react';
2
+ import { ArrowOrientation, PopupProps, TriggerAction } from '../interfaces';
3
+ import { Coords } from '@floating-ui/dom';
4
+ export interface PopupContextValue extends Pick<PopupProps, 'arrowed' | 'size'> {
5
+ actions: Set<TriggerAction>;
6
+ refs: {
7
+ trigger: RefObject<Element>;
8
+ portal: RefObject<HTMLDivElement>;
9
+ arrow: RefObject<HTMLDivElement>;
10
+ };
11
+ setOpen: Dispatch<SetStateAction<boolean>>;
12
+ enter: () => void;
13
+ leave: () => void;
14
+ }
15
+ declare const PopupProvider: import('react').Provider<PopupContextValue>, usePopupContext: () => PopupContextValue;
16
+ declare const PortalProvider: import('react').Provider<{
17
+ coords: Coords;
18
+ }>, usePortalContext: () => {
19
+ coords: Coords;
20
+ };
21
+ declare const ArrowProvider: import('react').Provider<{
22
+ style: CSSProperties;
23
+ orientation: ArrowOrientation;
24
+ }>, useArrowContext: () => {
25
+ style: CSSProperties;
26
+ orientation: ArrowOrientation;
27
+ };
28
+ export { PopupProvider, PortalProvider, ArrowProvider, usePopupContext, usePortalContext, useArrowContext };
@@ -0,0 +1 @@
1
+ import{createContextSuite as e}from"@nild/shared";const[r,t]=e({defaultValue:{actions:new Set,refs:{trigger:{current:null},portal:{current:null},arrow:{current:null}},setOpen:()=>{},enter:()=>{},leave:()=>{}}}),[o,a]=e({defaultValue:{coords:{x:0,y:0}}}),[u,l]=e({defaultValue:{style:{},orientation:"up"}});export{u as ArrowProvider,r as PopupProvider,o as PortalProvider,l as useArrowContext,t as usePopupContext,a as usePortalContext};
@@ -0,0 +1,28 @@
1
+ import { autoUpdate, Placement, Strategy, OffsetOptions, Coords } from '@floating-ui/dom';
2
+ import { CSSProperties, RefObject } from 'react';
3
+ import { ArrowOrientation } from '../interfaces';
4
+ interface UsePopupOptions {
5
+ placement?: Placement;
6
+ strategy?: Strategy;
7
+ offset?: OffsetOptions;
8
+ }
9
+ type UsePopupReturn = [
10
+ {
11
+ triggerRef: RefObject<Element>;
12
+ portalRef: RefObject<HTMLDivElement>;
13
+ portalContext: {
14
+ coords: Coords;
15
+ };
16
+ arrowRef: RefObject<HTMLDivElement>;
17
+ arrowContext: {
18
+ style: CSSProperties;
19
+ orientation: ArrowOrientation;
20
+ };
21
+ },
22
+ {
23
+ update: () => void;
24
+ autoUpdate: typeof autoUpdate;
25
+ }
26
+ ];
27
+ declare const usePopup: ({ placement, strategy, offset, }?: UsePopupOptions) => UsePopupReturn;
28
+ export default usePopup;
@@ -0,0 +1 @@
1
+ import{computePosition as D,offset as k,shift as v,flip as B,arrow as E,autoUpdate as P}from"../../_lib/floating-ui.dom.js";import{useEffectCallback as S}from"@nild/hooks";import{roundByDPR as r}from"@nild/shared/utils";import{useRef as u,useState as p}from"react";const U=({placement:f="bottom",strategy:y="absolute",offset:d=12}={})=>{const a=u(null),l=u(null),s=u(null),[n,x]=p({x:0,y:0}),[e,g]=p({x:0,y:0}),[t,b]=p(f.split("-")[0]),i=t==="top"||t==="bottom",w={coords:n},h={style:{[t==="left"?"right":"left"]:i?e.x:e.x-n.x,[t==="top"?"bottom":"top"]:i?e.y-n.y:e.y},orientation:{top:"down",bottom:"up",left:"right",right:"left"}[t]},R=S(()=>{!a.current||!l.current||D(a.current,l.current,{placement:f,strategy:y,middleware:[k(d),v(),B(),s.current&&E({element:s.current})]}).then(({x:m,y:c,placement:C,middlewareData:{arrow:o}})=>{x({x:r(m),y:r(c)}),b(C.split("-")[0]),g({x:r(o?.x??m),y:r(o?.y??c)})})});return[{triggerRef:a,portalRef:l,portalContext:w,arrowRef:s,arrowContext:h},{update:R,autoUpdate:P}]};export{U as default};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @category Components
3
+ */
4
+ declare const Popup: import('react').FC<import('./interfaces').PopupProps> & {
5
+ Trigger: import('react').FC<import('./interfaces').TriggerProps>;
6
+ Portal: import('react').ForwardRefExoticComponent<import('./interfaces').PortalProps & import('react').RefAttributes<HTMLDivElement>>;
7
+ };
8
+ export type * from './interfaces';
9
+ export default Popup;
@@ -0,0 +1 @@
1
+ import r from"./Popup.js";import o from"./Portal.js";import t from"./Trigger.js";const m=Object.assign(r,{Trigger:t,Portal:o});export{m as default};
@@ -0,0 +1,7 @@
1
+ import { ArrowOrientation, PopupProps, PortalProps } from '../interfaces';
2
+ export declare const triggerClassNames: (props?: object | undefined) => string;
3
+ export declare const portalClassNames: (props?: PortalProps | undefined) => string;
4
+ export declare const portalContentClassNames: (props?: Pick<PopupProps, "size"> | undefined) => string;
5
+ export declare const arrowClassNames: (props?: ({
6
+ orientation: ArrowOrientation;
7
+ } & Pick<PopupProps, "size" | "arrowed">) | undefined) => string;
@@ -0,0 +1 @@
1
+ import{cva as r}from"@nild/shared";const e=r(["nd-popup-trigger"]),a=r(["nd-popup-portal",["absolute","top-0","left-0"]]),o=r(["bg-container","rounded-md",["outline-solid","outline-1","outline-edge"],"shadow-lg"],{variants:{size:{small:["px-2","py-1"],medium:["px-4","py-3"],large:["px-6","py-5"]}}}),t=r(["nd-popup-arrow","absolute","bg-container",["border-solid","border-edge"]],{variants:{arrowed:{true:"",false:["opacity-0","invisible"]},size:{small:["w-1.5","h-1.5"],medium:["w-3","h-3"],large:["w-4.5","h-4.5"]},orientation:{up:["transform-[translateY(-50%)_rotate(45deg)]",["rounded-tl-sm","border-l-1","border-t-1"]],down:["transform-[translateY(50%)_rotate(45deg)]",["rounded-br-sm","border-r-1","border-b-1"]],left:["transform-[translateX(-50%)_rotate(45deg)]",["rounded-bl-sm","border-l-1","border-b-1"]],right:["transform-[translateX(50%)_rotate(45deg)]",["rounded-tr-sm","border-r-1","border-t-1"]]}}});export{t as arrowClassNames,a as portalClassNames,o as portalContentClassNames,e as triggerClassNames};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nild/components",
3
3
  "private": false,
4
- "version": "0.0.28",
4
+ "version": "0.0.30",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "exports": {
@@ -31,9 +31,9 @@
31
31
  "peerDependencies": {
32
32
  "react": "^18.2.0",
33
33
  "react-dom": "^18.2.0",
34
- "@nild/shared": "0.0.13",
34
+ "@nild/hooks": "0.0.15",
35
35
  "@nild/icons": "0.0.14",
36
- "@nild/hooks": "0.0.15"
36
+ "@nild/shared": "0.0.13"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "vite build --mode PROD",
@@ -1,21 +0,0 @@
1
- import { ReactNode, ReactElement, Dispatch } from 'react';
2
- import { PortalProps } from '../../portal';
3
- import { TriggerProps } from '../../trigger';
4
- import { Placement, Strategy, OffsetOptions } from '@floating-ui/dom';
5
- interface UsePopupOptions {
6
- placement?: Placement;
7
- strategy?: Strategy;
8
- offset?: OffsetOptions;
9
- open?: boolean;
10
- defaultOpen?: boolean;
11
- }
12
- type UsePopupReturn = [
13
- boolean,
14
- {
15
- setOpen: Dispatch<React.SetStateAction<boolean>>;
16
- renderTrigger: (props?: TriggerProps) => ReactElement | undefined;
17
- renderPortal: (props?: PortalProps) => ReactElement | undefined;
18
- }
19
- ];
20
- declare const usePopup: (children: ReactNode, { placement, strategy, offset, open: externalOpen, defaultOpen, }?: UsePopupOptions) => UsePopupReturn;
21
- export default usePopup;
@@ -1 +0,0 @@
1
- import{jsx as k}from"react/jsx-runtime";import{computePosition as H,offset as J,shift as K,flip as M,arrow as N,autoUpdate as Q}from"../../_lib/floating-ui.dom.js";import{useControllableState as W,usePureCallback as O,useEffectCallback as X,useIsomorphicLayoutEffect as S}from"@nild/hooks";import{getDPR as Y,roundByDPR as p}from"@nild/shared/utils";import{useRef as x,useState as u,Children as Z,isValidElement as h,cloneElement as $}from"react";import"../../portal/Arrow.js";import D from"../../portal/Portal.js";import q from"../../transition/Transition.js";import g from"../../trigger/Trigger.js";const _=(I,{placement:m="bottom",strategy:b="absolute",offset:w=12,open:L,defaultOpen:C=!1}={})=>{const t=x(null),o=x(null),c=x(null),[l,R]=u(C),[r,T]=W(L,C),[n,U]=u({x:0,y:0}),[s,V]=u({x:0,y:0}),[a,j]=u(m.split("-")[0]),E=a==="top"||a==="bottom",z={[a==="left"?"right":"left"]:E?s.x:s.x-n.x,[a==="top"?"bottom":"top"]:E?s.y-n.y:s.y},A={top:"down",bottom:"up",left:"right",right:"left"}[a];let y,d,i;Z.forEach(I,e=>{h(e)&&e.type!==g&&e.type!==D&&(y=e),h(e)&&e.type===g&&(d=e),h(e)&&e.type===D&&(i=e)});const B=O(e=>{if(d)return $(d,{...e,ref:t});if(y)return k(g,{...e,ref:t,children:y})}),F=O(e=>{if(i)return k(q,{visible:r,children:l&&$(i,{...i.props,...e,style:{transform:`translate(${n.x}px, ${n.y}px)`,...Y()>=1.5&&{willChange:"transform"}},ref:o,arrow:{ref:c,style:z,orientation:A}})})}),v=X(()=>{!t.current||!o.current||H(t.current,o.current,{placement:m,strategy:b,middleware:[J(w),K(),M(),c.current&&N({element:c.current})]}).then(({x:e,y:P,placement:G,middlewareData:{arrow:f}})=>{U({x:p(e),y:p(P)}),j(G.split("-")[0]),V({x:p(f?.x??e),y:p(f?.y??P)})})});return S(()=>{r&&!l?R(!0):r&&l&&v()},[r,l]),S(()=>{if(!(!t.current||!o.current||!r))return Q(t.current,o.current,v)},[m,b,w,r]),[r,{setOpen:T,renderTrigger:B,renderPortal:F}]};export{_ as default};
@@ -1,3 +0,0 @@
1
- import { ArrowProps } from './interfaces';
2
- declare const Arrow: import('react').ForwardRefExoticComponent<ArrowProps & import('react').RefAttributes<HTMLDivElement>>;
3
- export default Arrow;
@@ -1 +0,0 @@
1
- import{jsx as m}from"react/jsx-runtime";import{cnMerge as t}from"@nild/shared";import{forwardRef as f}from"react";import{arrowClassNames as p}from"./style/index.js";const r=f(({className:a,orientation:s="up",size:o="medium",...e},i)=>m("div",{...e,className:t(p({orientation:s,size:o}),a),ref:i}));r.displayName="Arrow";export{r as default};
@@ -1 +0,0 @@
1
- import{jsxs as p,jsx as f}from"react/jsx-runtime";import{cnMerge as e,cnJoin as N}from"@nild/shared";import{forwardRef as u,Children as C,isValidElement as v,cloneElement as x}from"react";import{createPortal as y}from"react-dom";import g from"./Arrow.js";import{portalContentClassNames as h,portalArrowClassNames as j,portalClassNames as w}from"./style/index.js";const o=u(({className:l,children:m,container:t=document.body,paddingSize:i="medium",arrow:s=!1,...n},d)=>{var r;const a=C.toArray(m).find(c=>v(c));return a?y(p("div",{...n,className:e(w(),l),ref:d,children:[x(a,{...a.props,className:e(h({paddingSize:i}),(r=a?.props)==null?void 0:r.className)}),s!==!1&&f(g,{...s,className:N(j(),s.className)})]}),t):null});o.displayName="Portal";export{o as default};
@@ -1,5 +0,0 @@
1
- import { default as Arrow } from './Arrow';
2
- import { default as Portal } from './Portal';
3
- export type * from './interfaces';
4
- export { Arrow };
5
- export default Portal;
@@ -1 +0,0 @@
1
- import{default as o}from"./Arrow.js";import r from"./Portal.js";export{o as Arrow,r as default};
@@ -1,5 +0,0 @@
1
- import { ArrowProps, PortalProps } from '../interfaces';
2
- export declare const arrowClassNames: (props?: ArrowProps | undefined) => string;
3
- export declare const portalClassNames: (props?: PortalProps | undefined) => string;
4
- export declare const portalContentClassNames: (props?: PortalProps | undefined) => string;
5
- export declare const portalArrowClassNames: (props?: ArrowProps | undefined) => string;
@@ -1 +0,0 @@
1
- import{cva as r}from"@nild/shared";const e=r(["nd-arrow","bg-container",["border-solid","border-edge"]],{variants:{orientation:{up:["transform-[translateY(-50%)_rotate(45deg)]",["rounded-tl-sm","border-l-1","border-t-1"]],down:["transform-[translateY(50%)_rotate(45deg)]",["rounded-br-sm","border-r-1","border-b-1"]],left:["transform-[translateX(-50%)_rotate(45deg)]",["rounded-bl-sm","border-l-1","border-b-1"]],right:["transform-[translateX(50%)_rotate(45deg)]",["rounded-tr-sm","border-r-1","border-t-1"]]},size:{small:["w-1.5","h-1.5"],medium:["w-3","h-3"],large:["w-4.5","h-4.5"]}}}),a=r(["nd-portal",["absolute","top-0","left-0"]]),o=r(["bg-container","rounded-md",["outline-solid","outline-1","outline-edge"],"shadow-lg"],{variants:{paddingSize:{small:["px-2","py-1"],medium:["px-4","py-3"],large:["px-6","py-5"]}}}),t=r(["absolute"]);export{e as arrowClassNames,t as portalArrowClassNames,a as portalClassNames,o as portalContentClassNames};
@@ -1,14 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export type TriggerAction = 'click' | 'hover' | 'focus' | 'contextMenu';
3
- export interface TriggerProps {
4
- children?: ReactNode;
5
- action?: TriggerAction | TriggerAction[];
6
- onToggle?: () => void;
7
- onOpen?: () => void;
8
- onClose?: () => void;
9
- }
10
- /**
11
- * @category Components
12
- */
13
- declare const Trigger: import('react').ForwardRefExoticComponent<TriggerProps & import('react').RefAttributes<Element>>;
14
- export default Trigger;
@@ -1 +0,0 @@
1
- import{useEffectCallback as o}from"@nild/hooks";import{mergeRefs as x,cnJoin as y}from"@nild/shared";import{forwardRef as C,Children as E,isValidElement as A,cloneElement as N}from"react";const a=C(({children:t,action:s="click",onToggle:u,onOpen:l,onClose:i,...v},f)=>{var r,d;const n=E.toArray(t).find(c=>A(c)),e=Array.isArray(s)?s:[s],m=o(()=>e.includes("click")&&u?.()),p=o(()=>e.includes("hover")&&l?.()),g=o(()=>e.includes("hover")&&i?.()),k=o(()=>e.includes("focus")&&l?.()),M=o(()=>(e.includes("click")||e.includes("focus")||e.includes("contextMenu"))&&i?.()),h=o(c=>e.includes("contextMenu")&&(c.preventDefault(),l?.()));return n?N(n,{...v,className:y("nd-trigger",(r=n?.props)==null?void 0:r.className),ref:x(f,(d=n?.props)==null?void 0:d.ref),onClick:m,onMouseEnter:p,onMouseLeave:g,onFocus:k,onBlur:M,onContextMenu:h}):null});a.displayName="Trigger";export{a as default};
@@ -1,3 +0,0 @@
1
- import { default as Trigger, TriggerProps, TriggerAction } from './Trigger';
2
- export type { TriggerProps, TriggerAction };
3
- export default Trigger;
@@ -1 +0,0 @@
1
- import e from"./Trigger.js";export{e as default};
File without changes