@nild/components 0.0.51 → 0.0.53
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/_shared/utils/register-slots/index.d.ts +1 -0
- package/dist/_shared/utils/register-slots/index.js +1 -1
- package/dist/alert/Alert.js +1 -1
- package/dist/alert/Icon.d.ts +5 -0
- package/dist/alert/Icon.js +1 -0
- package/dist/alert/Title.d.ts +5 -0
- package/dist/alert/Title.js +1 -0
- package/dist/alert/contexts/index.d.ts +7 -0
- package/dist/alert/contexts/index.js +1 -0
- package/dist/alert/index.d.ts +7 -1
- package/dist/alert/index.js +1 -1
- package/dist/alert/interfaces/index.d.ts +20 -0
- package/dist/alert/style/index.js +1 -1
- package/dist/button/interfaces/index.d.ts +24 -0
- package/dist/checkbox/interfaces/index.d.ts +33 -0
- package/dist/divider/interfaces/index.d.ts +10 -0
- package/dist/field/interfaces/index.d.ts +28 -0
- package/dist/form/interfaces/index.d.ts +32 -0
- package/dist/index.js +1 -1
- package/dist/input/interfaces/index.d.ts +76 -0
- package/dist/modal/interfaces/index.d.ts +64 -0
- package/dist/popover/interfaces/index.d.ts +17 -0
- package/dist/popup/interfaces/index.d.ts +31 -0
- package/dist/radio/interfaces/index.d.ts +33 -0
- package/dist/segment/interfaces/index.d.ts +20 -0
- package/dist/select/interfaces/index.d.ts +46 -0
- package/dist/switch/interfaces/index.d.ts +27 -0
- package/dist/tabs/interfaces/index.d.ts +36 -0
- package/dist/tooltip/interfaces/index.d.ts +16 -0
- package/dist/typography/interfaces/index.d.ts +23 -0
- package/dist/watermark/interfaces/index.d.ts +51 -0
- package/package.json +3 -3
|
@@ -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
|
|
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};
|
package/dist/alert/Alert.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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 @@
|
|
|
1
|
+
import{createContextSuite as e}from"@nild/shared";const[t,o]=e({defaultValue:{type:"info"}});export{t as AlertProvider,o as useAlertContext};
|
package/dist/alert/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
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;
|
package/dist/alert/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
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};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HTMLAttributes, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
export type AlertType = 'info' | 'success' | 'warning' | 'error';
|
|
3
|
+
|
|
4
|
+
export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
5
|
+
type?: AlertType;
|
|
6
|
+
closable?: boolean;
|
|
7
|
+
visible?: boolean;
|
|
8
|
+
defaultVisible?: boolean;
|
|
9
|
+
closeAriaLabel?: string;
|
|
10
|
+
onClose?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IconProps extends HTMLAttributes<HTMLSpanElement> {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TitleProps extends HTMLAttributes<HTMLDivElement> {
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
@@ -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"]),
|
|
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};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
export type ButtonVariant = 'solid' | 'outlined' | 'filled' | 'text';
|
|
3
|
+
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
4
|
+
export type ButtonShape = 'round' | 'square';
|
|
5
|
+
|
|
6
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
|
+
variant?: ButtonVariant;
|
|
8
|
+
size?: ButtonSize;
|
|
9
|
+
shape?: ButtonShape;
|
|
10
|
+
equal?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
block?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type GroupDirection = 'horizontal' | 'vertical';
|
|
16
|
+
|
|
17
|
+
export interface GroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
18
|
+
direction?: GroupDirection;
|
|
19
|
+
variant?: ButtonVariant;
|
|
20
|
+
size?: ButtonSize;
|
|
21
|
+
equal?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
children?: ReactElement<ButtonProps> | ReactElement<ButtonProps>[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type CheckboxVariant = 'solid' | 'outlined';
|
|
3
|
+
export type CheckboxSize = 'small' | 'medium' | 'large';
|
|
4
|
+
|
|
5
|
+
export interface CheckboxProps extends Omit<HTMLAttributes<HTMLLabelElement>, 'onChange' | 'defaultValue'> {
|
|
6
|
+
variant?: CheckboxVariant;
|
|
7
|
+
size?: CheckboxSize;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
value?: unknown;
|
|
12
|
+
onChange?: (checked: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IndicatorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
16
|
+
children?: (checked: boolean) => ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LabelProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
20
|
+
children?: ReactNode | ((checked: boolean) => ReactNode);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type GroupDirection = 'horizontal' | 'vertical';
|
|
24
|
+
|
|
25
|
+
export interface GroupProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
|
|
26
|
+
direction?: GroupDirection;
|
|
27
|
+
variant?: CheckboxVariant;
|
|
28
|
+
size?: CheckboxSize;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
value?: T[];
|
|
31
|
+
defaultValue?: T[];
|
|
32
|
+
onChange?: (value: T[]) => void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type DividerVariant = 'solid' | 'dashed' | 'dotted';
|
|
3
|
+
export type DividerDirection = 'horizontal' | 'vertical';
|
|
4
|
+
export type DividerAlign = 'left' | 'center' | 'right';
|
|
5
|
+
|
|
6
|
+
export interface DividerProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
variant?: DividerVariant;
|
|
8
|
+
direction?: DividerDirection;
|
|
9
|
+
align?: DividerAlign;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type FieldStatus = 'success' | 'warning' | 'error';
|
|
3
|
+
export type FieldBind = 'value' | 'checked';
|
|
4
|
+
|
|
5
|
+
export interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
name?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
bind?: FieldBind;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface LabelProps extends HTMLAttributes<HTMLSpanElement> {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface HelperProps extends HTMLAttributes<HTMLDivElement> {
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface StatusProps extends HTMLAttributes<HTMLDivElement> {
|
|
22
|
+
type?: FieldStatus;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RequiredIndicatorProps extends HTMLAttributes<HTMLSpanElement> {
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FormEvent, FormHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type ValidateTrigger = 'change' | 'submit';
|
|
3
|
+
export type FormValue = Record<string, unknown>;
|
|
4
|
+
export type FormIssue = ReactNode | { message: ReactNode };
|
|
5
|
+
export type FormIssueMap = Record<string, FormIssue | FormIssue[] | undefined>;
|
|
6
|
+
|
|
7
|
+
export interface FormResolverResult {
|
|
8
|
+
value?: FormValue;
|
|
9
|
+
errors?: FormIssueMap;
|
|
10
|
+
warnings?: FormIssueMap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type FormResolver = (value: FormValue) => FormResolverResult | Promise<FormResolverResult>;
|
|
14
|
+
|
|
15
|
+
export interface ActionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FormProps
|
|
20
|
+
extends Omit<
|
|
21
|
+
FormHTMLAttributes<HTMLFormElement>,
|
|
22
|
+
'children' | 'defaultValue' | 'onChange' | 'onInvalid' | 'onSubmit'
|
|
23
|
+
> {
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
defaultValue?: FormValue;
|
|
26
|
+
resolver?: FormResolver;
|
|
27
|
+
validateTrigger?: ValidateTrigger | ValidateTrigger[];
|
|
28
|
+
onChange?: (value: FormValue) => void;
|
|
29
|
+
onInvalid?: (errors: FormIssueMap, value: FormValue, evt: FormEvent<HTMLFormElement>) => void;
|
|
30
|
+
onSubmit?: (value: FormValue, evt: FormEvent<HTMLFormElement>) => void | Promise<void>;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"./alert/
|
|
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};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { InputHTMLAttributes, HTMLAttributes, FocusEvent, ChangeEvent, ReactElement, ReactNode, SyntheticEvent } from 'react';
|
|
2
|
+
export type InputVariant = 'outlined' | 'filled' | 'underlined';
|
|
3
|
+
export type InputSize = 'small' | 'medium' | 'large';
|
|
4
|
+
|
|
5
|
+
export interface InputProps
|
|
6
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'value' | 'defaultValue' | 'onChange'> {
|
|
7
|
+
variant?: InputVariant;
|
|
8
|
+
size?: InputSize;
|
|
9
|
+
block?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
value?: string | number;
|
|
12
|
+
defaultValue?: string | number;
|
|
13
|
+
onChange?: (value: string | number, evt: ChangeEvent<HTMLInputElement>) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type PrefixProps = HTMLAttributes<HTMLSpanElement>;
|
|
17
|
+
export type SuffixProps = HTMLAttributes<HTMLSpanElement>;
|
|
18
|
+
|
|
19
|
+
export type PrependProps = HTMLAttributes<HTMLDivElement>;
|
|
20
|
+
export type AppendProps = HTMLAttributes<HTMLDivElement>;
|
|
21
|
+
|
|
22
|
+
export interface CompositeProps extends HTMLAttributes<HTMLDivElement> {
|
|
23
|
+
variant?: InputVariant;
|
|
24
|
+
size?: InputSize;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
block?: boolean;
|
|
27
|
+
children?:
|
|
28
|
+
| ReactElement<PrependProps | InputProps | AppendProps>
|
|
29
|
+
| Array<ReactElement<PrependProps | InputProps | AppendProps>>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SearchProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange'> {
|
|
33
|
+
value?: string;
|
|
34
|
+
defaultValue?: string;
|
|
35
|
+
keyword?: string;
|
|
36
|
+
defaultKeyword?: string;
|
|
37
|
+
onChange?: (value: string, evt: ChangeEvent<HTMLInputElement>) => void;
|
|
38
|
+
onSearch?: (value: string) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PasswordProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange'> {
|
|
42
|
+
value?: string;
|
|
43
|
+
defaultValue?: string;
|
|
44
|
+
onChange?: (value: string, evt: ChangeEvent<HTMLInputElement>) => void;
|
|
45
|
+
visible?: boolean;
|
|
46
|
+
defaultVisible?: boolean;
|
|
47
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface OTPRef {
|
|
51
|
+
focus: (index?: number) => void;
|
|
52
|
+
blur: () => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface OTPProps
|
|
56
|
+
extends Omit<HTMLAttributes<HTMLSpanElement>, 'placeholder' | 'onFocus' | 'onChange'>,
|
|
57
|
+
Pick<InputProps, 'variant' | 'type' | 'block' | 'size' | 'disabled'> {
|
|
58
|
+
placeholder?: string[];
|
|
59
|
+
length?: number;
|
|
60
|
+
separator?: ReactNode | ((index: number) => ReactNode);
|
|
61
|
+
value?: string[];
|
|
62
|
+
defaultValue?: string[];
|
|
63
|
+
onFocus?: (index: number, evt: FocusEvent<HTMLInputElement>) => void;
|
|
64
|
+
onBlur?: (evt: FocusEvent<HTMLSpanElement>) => void;
|
|
65
|
+
onChange?: (value: string[], evt: SyntheticEvent) => void;
|
|
66
|
+
onComplete?: (value: string[], evt: SyntheticEvent) => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface NumberProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange'> {
|
|
70
|
+
min?: number;
|
|
71
|
+
max?: number;
|
|
72
|
+
step?: number;
|
|
73
|
+
value?: number;
|
|
74
|
+
defaultValue?: number;
|
|
75
|
+
onChange?: (value: number | undefined, evt?: ChangeEvent<HTMLInputElement>) => void;
|
|
76
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ButtonProps } from '../../button';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
export type ModalPlacement = 'center' | 'left' | 'right' | 'top' | 'bottom';
|
|
4
|
+
export type ModalSize = 'small' | 'medium' | 'large' | 'full';
|
|
5
|
+
export type ModalVariant = 'dialog' | 'drawer';
|
|
6
|
+
export type DrawerPlacement = Exclude<ModalPlacement, 'center'>;
|
|
7
|
+
|
|
8
|
+
export interface TriggerProps {
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface PortalProps
|
|
13
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'aria-label' | 'aria-labelledby' | 'aria-describedby'> {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
container?: Element | DocumentFragment;
|
|
16
|
+
overlayless?: boolean;
|
|
17
|
+
overlayClassName?: string;
|
|
18
|
+
surfaceClassName?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface HeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface FooterProps extends HTMLAttributes<HTMLDivElement> {
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type CloseProps = ButtonProps;
|
|
34
|
+
|
|
35
|
+
export interface ModalCommonProps {
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
size?: ModalSize;
|
|
38
|
+
open?: boolean;
|
|
39
|
+
defaultOpen?: boolean;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
closeOnEscape?: boolean;
|
|
42
|
+
closeOnOverlayClick?: boolean;
|
|
43
|
+
trapFocus?: boolean;
|
|
44
|
+
restoreFocus?: boolean;
|
|
45
|
+
lockScroll?: boolean;
|
|
46
|
+
'aria-label'?: string;
|
|
47
|
+
'aria-labelledby'?: string;
|
|
48
|
+
'aria-describedby'?: string;
|
|
49
|
+
onOpen?: () => void;
|
|
50
|
+
onClose?: () => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface DialogProps extends ModalCommonProps {
|
|
54
|
+
variant?: 'dialog';
|
|
55
|
+
placement?: 'center';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface DrawerProps extends ModalCommonProps {
|
|
59
|
+
variant: 'drawer';
|
|
60
|
+
placement?: DrawerPlacement;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type ModalProps = DialogProps | DrawerProps;
|
|
64
|
+
export type ModalAccessibility = Pick<ModalCommonProps, 'aria-label' | 'aria-labelledby' | 'aria-describedby'>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PopupSize, TriggerAction } from '../../popup';
|
|
3
|
+
import { OffsetOptions, Placement } from '@floating-ui/dom';
|
|
4
|
+
export interface PopoverProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
placement?: Placement;
|
|
7
|
+
offset?: OffsetOptions;
|
|
8
|
+
action?: TriggerAction | TriggerAction[];
|
|
9
|
+
arrowed?: boolean;
|
|
10
|
+
size?: PopupSize;
|
|
11
|
+
delay?: number | [number] | [number, number];
|
|
12
|
+
open?: boolean;
|
|
13
|
+
defaultOpen?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
onOpen?: () => void;
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { OffsetOptions, Placement } from '@floating-ui/dom';
|
|
3
|
+
export type ArrowOrientation = 'up' | 'down' | 'left' | 'right';
|
|
4
|
+
|
|
5
|
+
export type TriggerAction = 'click' | 'hover' | 'focus' | 'contextMenu';
|
|
6
|
+
|
|
7
|
+
export interface TriggerProps {
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PortalProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
container?: Element | DocumentFragment;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type PopupSize = 'small' | 'medium' | 'large';
|
|
16
|
+
|
|
17
|
+
export interface PopupProps {
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
placement?: Placement;
|
|
20
|
+
offset?: OffsetOptions;
|
|
21
|
+
action?: TriggerAction | TriggerAction[];
|
|
22
|
+
size?: PopupSize;
|
|
23
|
+
arrowed?: boolean;
|
|
24
|
+
inverse?: boolean;
|
|
25
|
+
delay?: number | [number] | [number, number];
|
|
26
|
+
open?: boolean;
|
|
27
|
+
defaultOpen?: boolean;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
onOpen?: () => void;
|
|
30
|
+
onClose?: () => void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type RadioVariant = 'solid' | 'outlined';
|
|
3
|
+
export type RadioSize = 'small' | 'medium' | 'large';
|
|
4
|
+
|
|
5
|
+
export interface RadioProps extends Omit<HTMLAttributes<HTMLLabelElement>, 'onChange' | 'defaultValue'> {
|
|
6
|
+
variant?: RadioVariant;
|
|
7
|
+
size?: RadioSize;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
value?: unknown;
|
|
12
|
+
onChange?: (checked: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IndicatorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
16
|
+
children?: (checked: boolean) => ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LabelProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
20
|
+
children?: ReactNode | ((checked: boolean) => ReactNode);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type GroupDirection = 'horizontal' | 'vertical';
|
|
24
|
+
|
|
25
|
+
export interface GroupProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
|
|
26
|
+
direction?: GroupDirection;
|
|
27
|
+
variant?: RadioVariant;
|
|
28
|
+
size?: RadioSize;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
value?: T;
|
|
31
|
+
defaultValue?: T;
|
|
32
|
+
onChange?: (value: T) => void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type SegmentSize = 'small' | 'medium' | 'large';
|
|
3
|
+
export type SegmentOrientation = 'horizontal' | 'vertical';
|
|
4
|
+
|
|
5
|
+
export interface SegmentProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
value?: T;
|
|
8
|
+
defaultValue?: T;
|
|
9
|
+
onChange?: (value: T) => void;
|
|
10
|
+
size?: SegmentSize;
|
|
11
|
+
orientation?: SegmentOrientation;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
block?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ItemProps<T = unknown> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onChange'> {
|
|
17
|
+
value: T;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { InputSize, InputVariant } from '../../input';
|
|
2
|
+
import { OffsetOptions, Placement } from '@floating-ui/dom';
|
|
3
|
+
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
4
|
+
export type SelectVariant = InputVariant;
|
|
5
|
+
export type SelectSize = InputSize;
|
|
6
|
+
|
|
7
|
+
export interface SelectCommonProps
|
|
8
|
+
extends Omit<
|
|
9
|
+
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
10
|
+
'children' | 'defaultValue' | 'id' | 'onChange' | 'size' | 'value'
|
|
11
|
+
> {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
variant?: SelectVariant;
|
|
15
|
+
size?: SelectSize;
|
|
16
|
+
block?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
placement?: Placement;
|
|
19
|
+
offset?: OffsetOptions;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SingleSelectProps<T = unknown> extends SelectCommonProps {
|
|
23
|
+
multiple?: false;
|
|
24
|
+
value?: T;
|
|
25
|
+
defaultValue?: T;
|
|
26
|
+
onChange?: (value: T | undefined) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface MultipleSelectProps<T = unknown> extends SelectCommonProps {
|
|
30
|
+
multiple: true;
|
|
31
|
+
value?: T[];
|
|
32
|
+
defaultValue?: T[];
|
|
33
|
+
onChange?: (value: T[]) => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type SelectProps<T = unknown> = SingleSelectProps<T> | MultipleSelectProps<T>;
|
|
37
|
+
|
|
38
|
+
export interface SelectOptionProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'value'> {
|
|
39
|
+
value: T;
|
|
40
|
+
label: string;
|
|
41
|
+
size?: SelectSize;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
selected?: boolean;
|
|
44
|
+
active?: boolean;
|
|
45
|
+
children?: ReactNode;
|
|
46
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type SwitchVariant = 'solid' | 'outlined';
|
|
3
|
+
export type SwitchSize = 'small' | 'medium' | 'large';
|
|
4
|
+
export type SwitchShape = 'round' | 'square';
|
|
5
|
+
|
|
6
|
+
export interface SwitchProps
|
|
7
|
+
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange'> {
|
|
8
|
+
variant?: SwitchVariant;
|
|
9
|
+
size?: SwitchSize;
|
|
10
|
+
shape?: SwitchShape;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
defaultChecked?: boolean;
|
|
13
|
+
value?: boolean;
|
|
14
|
+
defaultValue?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onChange?: (checked: boolean) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type TrackType = 'checked' | 'unchecked';
|
|
20
|
+
|
|
21
|
+
export interface TrackProps extends HTMLAttributes<HTMLDivElement> {
|
|
22
|
+
type: TrackType;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ThumbProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
26
|
+
children?: (checked: boolean) => ReactNode;
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HTMLAttributes, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
export type TabsVariant = 'line' | 'card';
|
|
3
|
+
export type TabsSize = 'small' | 'medium' | 'large';
|
|
4
|
+
export type TabsOrientation = 'horizontal' | 'vertical';
|
|
5
|
+
export type TabsActivation = 'auto' | 'manual';
|
|
6
|
+
|
|
7
|
+
export interface TabsProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
value?: T;
|
|
10
|
+
defaultValue?: T;
|
|
11
|
+
onChange?: (value: T) => void;
|
|
12
|
+
variant?: TabsVariant;
|
|
13
|
+
size?: TabsSize;
|
|
14
|
+
orientation?: TabsOrientation;
|
|
15
|
+
activation?: TabsActivation;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
closable?: boolean;
|
|
18
|
+
onClose?: (value: T, evt: MouseEvent<HTMLButtonElement>) => void;
|
|
19
|
+
destroyOnInactive?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ListProps extends HTMLAttributes<HTMLDivElement> {
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface TabProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
27
|
+
value: T;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
closable?: boolean;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface PanelProps<T = unknown> extends HTMLAttributes<HTMLDivElement> {
|
|
34
|
+
value: T;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PopupSize } from '../../popup';
|
|
3
|
+
import { OffsetOptions, Placement } from '@floating-ui/dom';
|
|
4
|
+
export interface TooltipProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
placement?: Placement;
|
|
7
|
+
offset?: OffsetOptions;
|
|
8
|
+
arrowed?: boolean;
|
|
9
|
+
size?: PopupSize;
|
|
10
|
+
delay?: number | [number] | [number, number];
|
|
11
|
+
open?: boolean;
|
|
12
|
+
defaultOpen?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onOpen?: () => void;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, HTMLAttributes } from 'react';
|
|
2
|
+
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
3
|
+
underlined?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type ParagraphProps = HTMLAttributes<HTMLParagraphElement>;
|
|
8
|
+
|
|
9
|
+
export type TextTag = 'strong' | 'del' | 'u' | 'i' | 'mark' | 'code' | 'kbd';
|
|
10
|
+
|
|
11
|
+
export interface TextProps extends HTMLAttributes<HTMLSpanElement> {
|
|
12
|
+
tags?: TextTag[];
|
|
13
|
+
secondary?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type TitleLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
18
|
+
|
|
19
|
+
export interface TitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
20
|
+
level?: TitleLevel;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type TypographyProps = HTMLAttributes<HTMLElement>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type WatermarkComposition = 'stack' | 'inline' | 'overlay';
|
|
3
|
+
|
|
4
|
+
export type WatermarkGap = number | [number, number];
|
|
5
|
+
export type WatermarkOffset = number | [number, number];
|
|
6
|
+
export type WatermarkImageCrossOrigin = '' | 'anonymous' | 'use-credentials';
|
|
7
|
+
export type WatermarkTamperType = 'removed' | 'reordered' | 'attribute';
|
|
8
|
+
export type WatermarkTamperAttribute = 'aria-hidden' | 'class' | 'hidden' | 'style';
|
|
9
|
+
|
|
10
|
+
export interface WatermarkTamperEvent {
|
|
11
|
+
type: WatermarkTamperType;
|
|
12
|
+
attributeName?: WatermarkTamperAttribute;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface WatermarkImage {
|
|
16
|
+
src: string;
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
scale?: number;
|
|
20
|
+
crossOrigin?: WatermarkImageCrossOrigin;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface WatermarkPattern {
|
|
24
|
+
gap?: WatermarkGap;
|
|
25
|
+
offset?: WatermarkOffset;
|
|
26
|
+
rotate?: number;
|
|
27
|
+
composition?: WatermarkComposition;
|
|
28
|
+
compositionGap?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface WatermarkTextStyle {
|
|
32
|
+
fontSize?: number;
|
|
33
|
+
fontWeight?: string | number;
|
|
34
|
+
fontFamily?: string;
|
|
35
|
+
fontStyle?: string;
|
|
36
|
+
lineHeight?: number;
|
|
37
|
+
color?: string;
|
|
38
|
+
textAlign?: CanvasTextAlign;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface WatermarkProps extends Omit<HTMLAttributes<HTMLDivElement>, 'content' | 'onError'> {
|
|
42
|
+
text?: string | string[];
|
|
43
|
+
image?: string | WatermarkImage;
|
|
44
|
+
pattern?: WatermarkPattern;
|
|
45
|
+
textStyle?: WatermarkTextStyle;
|
|
46
|
+
opacity?: number;
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
preserve?: boolean;
|
|
49
|
+
onTamper?: (event: WatermarkTamperEvent) => void;
|
|
50
|
+
onError?: (error: Event | Error, image: WatermarkImage) => void;
|
|
51
|
+
}
|
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.53",
|
|
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/
|
|
34
|
+
"@nild/hooks": "^0.0.21",
|
|
35
35
|
"@nild/icons": "^0.0.21",
|
|
36
|
-
"@nild/
|
|
36
|
+
"@nild/shared": "^0.0.18"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "vite build --mode PROD",
|