@nild/components 0.0.27 → 0.0.29
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 +1 -1
- package/dist/popover/Popover.d.ts +3 -20
- package/dist/popover/Popover.js +1 -1
- package/dist/popover/index.d.ts +8 -2
- package/dist/popover/index.js +1 -1
- package/dist/popup/Arrow.d.ts +3 -0
- package/dist/popup/Arrow.js +1 -0
- package/dist/popup/Popup.d.ts +4 -0
- package/dist/popup/Popup.js +1 -0
- package/dist/{portal → popup}/Portal.d.ts +0 -3
- package/dist/popup/Portal.js +1 -0
- package/dist/popup/Trigger.d.ts +4 -0
- package/dist/popup/Trigger.js +1 -0
- package/dist/popup/contexts/index.d.ts +28 -0
- package/dist/popup/contexts/index.js +1 -0
- package/dist/popup/hooks/usePopup.d.ts +28 -0
- package/dist/popup/hooks/usePopup.js +1 -0
- package/dist/popup/index.d.ts +6 -0
- package/dist/popup/index.js +1 -0
- package/dist/popup/style/index.d.ts +7 -0
- package/dist/popup/style/index.js +1 -0
- package/package.json +4 -4
- package/dist/_shared/hooks/usePopup.d.ts +0 -21
- package/dist/_shared/hooks/usePopup.js +0 -1
- package/dist/portal/Arrow.d.ts +0 -3
- package/dist/portal/Arrow.js +0 -1
- package/dist/portal/Portal.js +0 -1
- package/dist/portal/index.d.ts +0 -5
- package/dist/portal/index.js +0 -1
- package/dist/portal/style/index.d.ts +0 -5
- package/dist/portal/style/index.js +0 -1
- package/dist/trigger/Trigger.d.ts +0 -14
- package/dist/trigger/Trigger.js +0 -1
- package/dist/trigger/index.d.ts +0 -3
- package/dist/trigger/index.js +0 -1
- /package/dist/{_shared → popup}/hooks/index.d.ts +0 -0
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/
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
|
|
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;
|
package/dist/popover/Popover.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/popover/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
package/dist/popover/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"./Popover.js";export{
|
|
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 @@
|
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import{usePopupContext as n,useArrowContext as m}from"./contexts/index.js";import{arrowClassNames as p}from"./style/index.js";const r=()=>{const{arrowed:o,size:s,refs:e}=n(),{style:t,orientation:a}=m();return o?i("div",{className:p({orientation:a,size:s}),style:t,ref:e.arrow}):null};r.displayName="Popup.Arrow";export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as V,jsx as a}from"react/jsx-runtime";import{useControllableState as q,useEffectCallback as m,useIsomorphicLayoutEffect as x}from"@nild/hooks";import{makeArray as B,isFunction as D}from"@nild/shared";import{Children as G,isValidElement as H,useMemo as J,useState as K,useRef as N}from"react";import Q from"../transition/Transition.js";import{PopupProvider as W,PortalProvider as X,ArrowProvider as Y}from"./contexts/index.js";import Z from"./hooks/usePopup.js";import _ from"./Portal.js";import P from"./Trigger.js";const T=({children:y,placement:f,offset:p,action:d="click",arrowed:E=!0,size:R="medium",open:S,defaultOpen:h=!1,disabled:g,onOpen:v,onClose:w})=>{let s,b,n;G.forEach(y,e=>{if(H(e))switch(e.type){case P:b=e;break;case _:n=e;break;default:s=e;break}});const i=J(()=>new Set(B(d)),[d]),[o,j]=K(h),[r,z]=q(S,h),t=N(),[{triggerRef:l,portalRef:u,portalContext:A,arrowRef:O,arrowContext:F},{update:k,autoUpdate:I}]=Z({placement:f,offset:p}),c=m(e=>{g||z(U=>{const C=D(e)?e(U):e;return C?v?.():w?.(),C})}),L=m(()=>{i.has("hover")&&(t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{c(!0)},100))}),M=m(()=>{i.has("hover")&&(t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{c(!1)},100))});return x(()=>{r&&!o?j(!0):r&&o&&k()},[r,o]),x(()=>{if(!(!l.current||!u.current||!r))return I(l.current,u.current,k)},[f,p,r]),V(W,{value:{actions:i,arrowed:E,size:R,refs:{trigger:l,portal:u,arrow:O},setOpen:c,enter:L,leave:M},children:[b||s&&a(P,{children:s}),a(X,{value:A,children:a(Y,{value:F,children:n&&a(Q,{visible:r,children:o&&n})})})]})};T.displayName="Popup";export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as C,jsx as N}from"react/jsx-runtime";import{mergeRefs as v,cnMerge as r,getDPR as y}from"@nild/shared";import{forwardRef as P,Children as g,isValidElement as h,cloneElement as E}from"react";import{createPortal as M}from"react-dom";import R from"./Arrow.js";import{usePopupContext as j,usePortalContext as w}from"./contexts/index.js";import{portalContentClassNames as $,portalClassNames as z}from"./style/index.js";const o=P(({className:t,style:l,children:n,container:m=document.body,...i},p)=>{var s;const{size:f,refs:c,enter:d,leave:u}=j(),{coords:a}=w(),e=g.toArray(n).find(x=>h(x));return e?M(C("div",{...i,className:r(z(),t),style:{transform:`translate(${a.x}px, ${a.y}px)`,...y()>=1.5&&{willChange:"transform"},...l},onMouseEnter:d,onMouseLeave:u,ref:v(c.portal,p),children:[E(e,{...e.props,className:r($({size:f}),(s=e?.props)==null?void 0:s.className)}),N(R,{})]}),m):null});o.displayName="Popup.Portal";export{o as default};
|
|
@@ -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,6 @@
|
|
|
1
|
+
declare const Popup: import('react').FC<import('./interfaces').PopupProps> & {
|
|
2
|
+
Trigger: import('react').FC<import('./interfaces').TriggerProps>;
|
|
3
|
+
Portal: import('react').ForwardRefExoticComponent<import('./interfaces').PortalProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
4
|
+
};
|
|
5
|
+
export type * from './interfaces';
|
|
6
|
+
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">) | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cva as r}from"@nild/shared";const e=r(["nd-popup-trigger"]),o=r(["nd-popup-portal",["absolute","top-0","left-0"]]),a=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:{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"]}}});export{t as arrowClassNames,o as portalClassNames,a 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.
|
|
4
|
+
"version": "0.0.29",
|
|
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/
|
|
35
|
-
"@nild/
|
|
36
|
-
"@nild/
|
|
34
|
+
"@nild/hooks": "0.0.15",
|
|
35
|
+
"@nild/shared": "0.0.13",
|
|
36
|
+
"@nild/icons": "0.0.14"
|
|
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};
|
package/dist/portal/Arrow.d.ts
DELETED
package/dist/portal/Arrow.js
DELETED
|
@@ -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};
|
package/dist/portal/Portal.js
DELETED
|
@@ -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};
|
package/dist/portal/index.d.ts
DELETED
package/dist/portal/index.js
DELETED
|
@@ -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;
|
package/dist/trigger/Trigger.js
DELETED
|
@@ -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};
|
package/dist/trigger/index.d.ts
DELETED
package/dist/trigger/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"./Trigger.js";export{e as default};
|
|
File without changes
|