@nild/components 0.0.51 → 0.0.52

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.
@@ -23,6 +23,7 @@ interface CollectSlotsResult<Schema extends SlotSchema> {
23
23
  [K in keyof Schema]: SlotValue<Schema[K]>;
24
24
  };
25
25
  plainChildren: PlainChild[];
26
+ restChildren: ReactNode[];
26
27
  }
27
28
  declare const registerSlots: <Schema extends SlotSchema>(schema: Schema) => (children: ReactNode) => CollectSlotsResult<Schema>;
28
29
  export default registerSlots;
@@ -1 +1 @@
1
- import{Children as c,isValidElement as a,Fragment as h}from"react";const m=f=>{const o=Object.entries(f);return p=>{const l=o.reduce((n,[t,e])=>(n[t]=e.multiple?{el:[],seq:[]}:{el:null,seq:-1},n),{}),i=[];let r=0;const u=n=>{c.forEach(n,t=>{if(!(t==null||typeof t=="boolean")){if(a(t)&&t.type===h){u(t.props.children);return}if(typeof t=="string"||typeof t=="number"){i.push({content:t,seq:r}),r+=1;return}if(!a(t)){r+=1;return}for(const[e,s]of o)if(s.isMatched(t)){s.multiple?(l[e].el.push(t),l[e].seq.push(r)):(l[e].el===null||(s.strategy??"last")==="last")&&(l[e].el=t,l[e].seq=r);break}r+=1}})};return u(p),{slots:l,plainChildren:i}}};export{m as default};
1
+ import{Children as f,isValidElement as h,Fragment as m}from"react";const y=c=>{const o=Object.entries(c);return d=>{const r=o.reduce((n,[t,u])=>(n[t]=u.multiple?{el:[],seq:[]}:{el:null,seq:-1},n),{}),p=[],l=[];let s=0;const a=n=>{f.forEach(n,t=>{if(t==null||typeof t=="boolean")return;if(h(t)&&t.type===m){a(t.props.children);return}if(typeof t=="string"||typeof t=="number"){p.push({content:t,seq:s}),l.push(t),s+=1;return}if(!h(t)){l.push(t),s+=1;return}let u=!1;for(const[e,i]of o)if(i.isMatched(t)){u=!0,i.multiple?(r[e].el.push(t),r[e].seq.push(s)):(r[e].el===null||(i.strategy??"last")==="last")&&(r[e].el=t,r[e].seq=s);break}!u&&l.push(t),s+=1})};return a(d),{slots:r,plainChildren:p,restChildren:f.toArray(l)}}};export{y as default};
@@ -1 +1 @@
1
- import{jsxs as m,jsx as r}from"react/jsx-runtime";import{useControllableState as w}from"@nild/hooks";import{Icon as n}from"@nild/icons";import A from"@nild/icons/Caution";import g from"@nild/icons/Close";import k from"@nild/icons/Error";import z from"@nild/icons/Info";import M from"@nild/icons/Success";import{cnMerge as S}from"@nild/shared";import{forwardRef as V}from"react";import B from"../button/index.js";import e from"./style/index.js";const E={info:z,success:M,warning:A,error:k},c=V(({className:p,children:l,title:a,icon:i,role:f="alert",type:o="info",closable:d=!1,visible:u,defaultVisible:h=!0,closeAriaLabel:b="Close",onClose:s,...v},N)=>{const[y,x]=w(u,h);if(!y)return null;const C=r(n,{component:E[o],variant:"filled"}),t=i===void 0?C:i,j=q=>{x(!1),s?.(q)};return m("div",{...v,className:S(e.alert({type:o}),p),ref:N,role:f,children:[t!==!1&&r("span",{"aria-hidden":"true",className:e.icon({type:o}),children:t}),m("div",{className:e.content(),children:[a&&r("div",{className:e.title({type:o}),children:a}),l&&r("div",{className:e.body(),children:l})]}),d&&r(B,{"aria-label":b,className:e.close(),equal:!0,onClick:j,shape:"square",size:"small",variant:"text",children:r(n,{component:g})})]})});c.displayName="Alert";export{c as default};
1
+ import{jsx as r,jsxs as s}from"react/jsx-runtime";import{useControllableState as A}from"@nild/hooks";import{Icon as a}from"@nild/icons";import M from"@nild/icons/Caution";import j from"@nild/icons/Close";import q from"@nild/icons/Error";import w from"@nild/icons/Info";import E from"@nild/icons/Success";import{cnMerge as I}from"@nild/shared";import{forwardRef as k}from"react";import z from"../_shared/utils/register-slots/index.js";import P from"../button/index.js";import{AlertProvider as R}from"./contexts/index.js";import S,{isIconElement as T}from"./Icon.js";import e from"./style/index.js";import{isTitleElement as V}from"./Title.js";const B=z({icon:{isMatched:T},title:{isMatched:V}}),m=k(({className:n,children:c,role:f="alert",type:o="info",closable:p=!1,visible:d,defaultVisible:h=!0,closeAriaLabel:u="Close",onClose:l,...b},v)=>{const[N,C]=A(d,h);if(!N)return null;const{slots:i,restChildren:t}=B(c),y=i.icon.el??r(S,{children:r(a,{component:{info:w,success:E,warning:M,error:q}[o],variant:"filled"})}),g=x=>{C(!1),l?.(x)};return r(R,{value:{type:o},children:s("div",{...b,className:I(e.alert({type:o}),n),ref:v,role:f,children:[y,s("div",{className:e.content(),children:[i.title.el,t.length>0&&r("div",{className:e.body(),children:t})]}),p&&r(P,{"aria-label":u,className:e.close(),equal:!0,onClick:g,shape:"square",size:"small",variant:"text",children:r(a,{component:j})})]})})});m.displayName="Alert";export{m as default};
@@ -0,0 +1,5 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { IconProps } from './interfaces';
3
+ export declare const isIconElement: (child: ReactNode) => child is ReactElement<IconProps>;
4
+ declare const Icon: import('react').ForwardRefExoticComponent<IconProps & import('react').RefAttributes<HTMLSpanElement>>;
5
+ export default Icon;
@@ -0,0 +1 @@
1
+ import{jsx as i}from"react/jsx-runtime";import{isNil as m,cnMerge as l}from"@nild/shared";import{forwardRef as n,isValidElement as p}from"react";import{useAlertContext as c}from"./contexts/index.js";import f from"./style/index.js";const d=e=>p(e)&&e.type===s,s=n(({className:e,children:r,...a},o)=>{const{type:t}=c();return m(r)||r===!1?null:i("span",{...a,"aria-hidden":"true",className:l(f.icon({type:t}),e),ref:o,children:r})});s.displayName="Alert.Icon";export{s as default,d as isIconElement};
@@ -0,0 +1,5 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { TitleProps } from './interfaces';
3
+ export declare const isTitleElement: (child: ReactNode) => child is ReactElement<TitleProps>;
4
+ declare const Title: import('react').ForwardRefExoticComponent<TitleProps & import('react').RefAttributes<HTMLDivElement>>;
5
+ export default Title;
@@ -0,0 +1 @@
1
+ import{jsx as i}from"react/jsx-runtime";import{cnMerge as l}from"@nild/shared";import{forwardRef as o,isValidElement as p}from"react";import{useAlertContext as f}from"./contexts/index.js";import n from"./style/index.js";const c=e=>p(e)&&e.type===t,t=o(({className:e,children:r,...s},a)=>{const{type:m}=f();return i("div",{...s,className:l(n.title({type:m}),e),ref:a,children:r})});t.displayName="Alert.Title";export{t as default,c as isTitleElement};
@@ -0,0 +1,7 @@
1
+ import { AlertType } from '../interfaces';
2
+ declare const AlertProvider: import('react').Provider<{
3
+ type: AlertType;
4
+ }>, useAlertContext: () => {
5
+ type: AlertType;
6
+ };
7
+ export { AlertProvider, useAlertContext };
@@ -0,0 +1 @@
1
+ import{createContextSuite as e}from"@nild/shared";const[t,o]=e({defaultValue:{type:"info"}});export{t as AlertProvider,o as useAlertContext};
@@ -1,3 +1,9 @@
1
- import { default as Alert } from './Alert';
1
+ /**
2
+ * @category Components
3
+ */
4
+ declare const Alert: import('react').ForwardRefExoticComponent<import('./interfaces').AlertProps & import('react').RefAttributes<HTMLDivElement>> & {
5
+ Icon: import('react').ForwardRefExoticComponent<import('./interfaces').IconProps & import('react').RefAttributes<HTMLSpanElement>>;
6
+ Title: import('react').ForwardRefExoticComponent<import('./interfaces').TitleProps & import('react').RefAttributes<HTMLDivElement>>;
7
+ };
2
8
  export type * from './interfaces';
3
9
  export default Alert;
@@ -1 +1 @@
1
- import t from"./Alert.js";export{t as default};
1
+ import o from"./Alert.js";import t from"./Icon.js";import r from"./Title.js";const m=Object.assign(o,{Icon:t,Title:r});export{m as default};
@@ -1 +1 @@
1
- import{cva as e}from"@nild/shared";const t=e(["nd-alert",["flex","w-full","items-start","gap-3"],["rounded-md","border","px-4","py-3"],["font-nd","text-md","text-main"]],{variants:{type:{info:["border-brand-muted","bg-brand-subtle"],success:["border-success-muted","bg-success-subtle"],warning:["border-warning-muted","bg-warning-subtle"],error:["border-error-muted","bg-error-subtle"]}}}),r=e(["nd-alert-icon","inline-flex","size-[1lh]","shrink-0","items-center","justify-center","leading-[inherit]"],{variants:{type:{info:"text-brand",success:"text-success",warning:"text-warning",error:"text-error"}}}),n=e(["nd-alert-content","flex","min-w-0","flex-1","flex-col","gap-1"]),s=e(["nd-alert-title","font-medium","leading-[inherit]"],{variants:{type:{info:"text-brand",success:"text-success",warning:"text-warning",error:"text-error"}}}),i=e(["nd-alert-body","text-muted","leading-[inherit]"]),a=e(["nd-alert-close","-mt-px","ms-1","shrink-0","text-muted","enabled:hover:text-main"]),d={alert:t,icon:r,content:n,title:s,body:i,close:a};export{d as default};
1
+ import{cva as e}from"@nild/shared";const t=e(["nd-alert",["flex","w-full","items-start","gap-3"],["rounded-md","border","px-4","py-3"],["font-nd","text-md","text-main"]],{variants:{type:{info:["border-brand-muted","bg-brand-subtle"],success:["border-success-muted","bg-success-subtle"],warning:["border-warning-muted","bg-warning-subtle"],error:["border-error-muted","bg-error-subtle"]}}}),r=e(["nd-alert-icon","inline-flex","size-[1lh]","shrink-0","items-center","justify-center","leading-[inherit]"],{variants:{type:{info:"text-brand",success:"text-success",warning:"text-warning",error:"text-error"}}}),n=e(["nd-alert-content","flex","min-w-0","flex-1","flex-col","gap-1"]),a=e(["nd-alert-title","font-medium","leading-[inherit]"],{variants:{type:{info:"text-brand",success:"text-success",warning:"text-warning",error:"text-error"}}}),s=e(["nd-alert-body","text-muted","leading-[inherit]"]),i=e(["nd-alert-close","-mt-px","ms-1","shrink-0","text-muted","enabled:hover:text-brand","enabled:hover:bg-transparent","enabled:active:bg-transparent"]),d={alert:t,icon:r,content:n,title:a,body:s,close:i};export{d as default};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{default as a}from"./alert/Alert.js";import{default as t}from"./button/index.js";import{default as o}from"./checkbox/index.js";import{default as r}from"./divider/Divider.js";import{default as s}from"./field/index.js";import{default as m}from"./form/index.js";import{default as f}from"./input/index.js";import{default as i}from"./modal/index.js";import{default as e}from"./popover/index.js";import{default as p}from"./radio/index.js";import{default as l}from"./segment/index.js";import{default as d}from"./select/index.js";import{default as u}from"./switch/index.js";import{default as n}from"./tabs/index.js";import{default as T}from"./tooltip/index.js";import{default as S}from"./transition/Transition.js";import{TransitionStatus as c}from"./transition/interfaces/index.js";import{default as b}from"./typography/index.js";import{default as h}from"./watermark/Watermark.js";/* empty css */export{a as Alert,t as Button,o as Checkbox,r as Divider,s as Field,m as Form,f as Input,i as Modal,e as Popover,p as Radio,l as Segment,d as Select,u as Switch,n as Tabs,T as Tooltip,S as Transition,c as TransitionStatus,b as Typography,h as Watermark};
1
+ import{default as a}from"./alert/index.js";import{default as t}from"./button/index.js";import{default as o}from"./checkbox/index.js";import{default as r}from"./divider/Divider.js";import{default as s}from"./field/index.js";import{default as m}from"./form/index.js";import{default as f}from"./input/index.js";import{default as i}from"./modal/index.js";import{default as e}from"./popover/index.js";import{default as p}from"./radio/index.js";import{default as l}from"./segment/index.js";import{default as d}from"./select/index.js";import{default as u}from"./switch/index.js";import{default as n}from"./tabs/index.js";import{default as T}from"./tooltip/index.js";import{default as S}from"./transition/Transition.js";import{TransitionStatus as c}from"./transition/interfaces/index.js";import{default as b}from"./typography/index.js";import{default as h}from"./watermark/Watermark.js";/* empty css */export{a as Alert,t as Button,o as Checkbox,r as Divider,s as Field,m as Form,f as Input,i as Modal,e as Popover,p as Radio,l as Segment,d as Select,u as Switch,n as Tabs,T as Tooltip,S as Transition,c as TransitionStatus,b as Typography,h as Watermark};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nild/components",
3
3
  "private": false,
4
- "version": "0.0.51",
4
+ "version": "0.0.52",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "exports": {