@vighnalabs-packages/react-ui 0.0.0-stage → 0.1.1
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/README.md +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/types/button/button.component.d.ts +3 -0
- package/dist/cjs/types/button/button.interface.d.ts +22 -0
- package/dist/cjs/types/button/index.d.ts +2 -0
- package/dist/cjs/types/circled-letter/circled-letter.component.d.ts +3 -0
- package/dist/cjs/types/circled-letter/circled-letter.interface.d.ts +7 -0
- package/dist/cjs/types/circled-letter/index.d.ts +2 -0
- package/dist/cjs/types/confirmation/confirmation.component.d.ts +3 -0
- package/dist/cjs/types/confirmation/confirmation.interface.d.ts +11 -0
- package/dist/cjs/types/confirmation/index.d.ts +2 -0
- package/dist/cjs/types/constants.d.ts +2 -0
- package/dist/cjs/types/drawer/drawer.component.d.ts +3 -0
- package/dist/cjs/types/drawer/drawer.interface.d.ts +6 -0
- package/dist/cjs/types/drawer/index.d.ts +2 -0
- package/dist/cjs/types/hooks/use-escape-key.d.ts +2 -0
- package/dist/cjs/types/index.d.ts +9 -0
- package/dist/cjs/types/inline-actions/components/action.component.d.ts +3 -0
- package/dist/cjs/types/inline-actions/components/index.d.ts +1 -0
- package/dist/cjs/types/inline-actions/index.d.ts +2 -0
- package/dist/cjs/types/inline-actions/inline-actions.component.d.ts +3 -0
- package/dist/cjs/types/inline-actions/inline-actions.interface.d.ts +30 -0
- package/dist/cjs/types/menu/index.d.ts +2 -0
- package/dist/cjs/types/menu/menu.component.d.ts +3 -0
- package/dist/cjs/types/menu/menu.interface.d.ts +20 -0
- package/dist/cjs/types/overlay/index.d.ts +2 -0
- package/dist/cjs/types/overlay/overlay.component.d.ts +3 -0
- package/dist/cjs/types/overlay/overlay.interface.d.ts +3 -0
- package/dist/cjs/types/page-header/index.d.ts +2 -0
- package/dist/cjs/types/page-header/page-header.component.d.ts +3 -0
- package/dist/cjs/types/page-header/page-header.interface.d.ts +8 -0
- package/dist/cjs/types/pill/index.d.ts +2 -0
- package/dist/cjs/types/pill/pill.component.d.ts +3 -0
- package/dist/cjs/types/pill/pill.interface.d.ts +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/types/button/button.component.d.ts +3 -0
- package/dist/esm/types/button/button.interface.d.ts +22 -0
- package/dist/esm/types/button/index.d.ts +2 -0
- package/dist/esm/types/circled-letter/circled-letter.component.d.ts +3 -0
- package/dist/esm/types/circled-letter/circled-letter.interface.d.ts +7 -0
- package/dist/esm/types/circled-letter/index.d.ts +2 -0
- package/dist/esm/types/confirmation/confirmation.component.d.ts +3 -0
- package/dist/esm/types/confirmation/confirmation.interface.d.ts +11 -0
- package/dist/esm/types/confirmation/index.d.ts +2 -0
- package/dist/esm/types/constants.d.ts +2 -0
- package/dist/esm/types/drawer/drawer.component.d.ts +3 -0
- package/dist/esm/types/drawer/drawer.interface.d.ts +6 -0
- package/dist/esm/types/drawer/index.d.ts +2 -0
- package/dist/esm/types/hooks/use-escape-key.d.ts +2 -0
- package/dist/esm/types/index.d.ts +9 -0
- package/dist/esm/types/inline-actions/components/action.component.d.ts +3 -0
- package/dist/esm/types/inline-actions/components/index.d.ts +1 -0
- package/dist/esm/types/inline-actions/index.d.ts +2 -0
- package/dist/esm/types/inline-actions/inline-actions.component.d.ts +3 -0
- package/dist/esm/types/inline-actions/inline-actions.interface.d.ts +30 -0
- package/dist/esm/types/menu/index.d.ts +2 -0
- package/dist/esm/types/menu/menu.component.d.ts +3 -0
- package/dist/esm/types/menu/menu.interface.d.ts +20 -0
- package/dist/esm/types/overlay/index.d.ts +2 -0
- package/dist/esm/types/overlay/overlay.component.d.ts +3 -0
- package/dist/esm/types/overlay/overlay.interface.d.ts +3 -0
- package/dist/esm/types/page-header/index.d.ts +2 -0
- package/dist/esm/types/page-header/page-header.component.d.ts +3 -0
- package/dist/esm/types/page-header/page-header.interface.d.ts +8 -0
- package/dist/esm/types/pill/index.d.ts +2 -0
- package/dist/esm/types/pill/pill.component.d.ts +3 -0
- package/dist/esm/types/pill/pill.interface.d.ts +7 -0
- package/dist/index.d.ts +141 -0
- package/package.json +59 -5
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# node v24.22.2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react"),t=require("@vighnalabs-packages/react-animation");const n="lightblue",a=t=>{const{label:a,icon:l,onClick:i,type:r="button",disabled:c=!1,ariaLabel:o,variant:s="outline",size:m="xs",pressed:_}=t,d=`_btn _btn-${s}${"md"===m?"":` _btn-${m}`}`,b=_?{"--btn-bg":n}:void 0;return e.createElement("div",{className:"_p-1"},e.createElement("button",{type:r,className:d,disabled:c,"aria-label":o,"aria-pressed":_,style:b,onClick:()=>{i&&i()}},e.createElement("span",null,a),l&&e.createElement("i",{className:`bi bi-${l}`,"aria-hidden":"true"})))},l=n=>{const{isOpen:a}=n;return e.createElement(e.Fragment,null,a&&e.createElement(t.AnimationComponent,{className:"_position-fixed _left-0 _top-0 _bg-black-transperent _full-width _full-height _z-index-100"},e.createElement(e.Fragment,null)))},i=(t,n)=>{e.useEffect(()=>{if(!t)return;const e=e=>{"Escape"===e.key&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n])},r=n=>{const{isOpen:r,onClose:c,onConfirm:o,title:s,subTitle:m,confirmLabel:_="Confirm",cancelLabel:d="Cancel"}=n,b=e.useId(),p=e.useId();return i(r,c),e.createElement(e.Fragment,null,e.createElement(l,{isOpen:r}),r&&e.createElement(t.AnimationComponent,{className:"_position-fixed _left-0 _top-0 _full-width _full-height _row _xcenter _ycenter _z-index-100"},e.createElement("div",{role:"alertdialog","aria-modal":"true","aria-labelledby":b,"aria-describedby":p,className:"_bg-white _p-4 _border-radius-5 _shadow",style:{width:"90%",maxWidth:"400px"}},e.createElement("div",{className:"_row _xend _mb-3"},e.createElement("button",{type:"button","aria-label":"Close",className:"_btn _p-1",onClick:c},e.createElement("i",{className:"bi bi-x-circle _font-14","aria-hidden":"true"}))),e.createElement("div",{className:"_row _ycenter _xcenter _mb-1"},e.createElement("i",{className:"_text-red bi bi-exclamation-circle-fill _font-22","aria-hidden":"true"})),e.createElement("div",{className:"_p-2 _mb-5 _text-center"},e.createElement("div",{id:b,className:"_font-13 _font-weight-900 _mb-1"},s),e.createElement("div",{id:p,className:"_font-12"},m)),e.createElement("div",{className:"_row _xcenter"},e.createElement(a,{label:d,icon:"x-circle",onClick:c})," ",e.createElement(a,{label:_,icon:"check-square",onClick:o})))))},c=t=>{var n,l;const{action:i,context:c}=t,[o,s]=e.useState(!1),m=()=>{i.confirm?s(!0):i.onClick(c)};return e.createElement(e.Fragment,null,i.confirm&&e.createElement(r,{isOpen:o,onClose:()=>s(!1),onConfirm:()=>{s(!1),i.onClick(c)},title:i.confirm.title,subTitle:i.confirm.subTitle,confirmLabel:i.confirm.confirmLabel,cancelLabel:i.confirm.cancelLabel}),"icon"===i.type?e.createElement("button",{type:"button",className:"_btn _p-1","aria-label":null!==(n=i.ariaLabel)&&void 0!==n?n:i.label,title:null!==(l=i.ariaLabel)&&void 0!==l?l:i.label,disabled:i.disabled,onClick:m},e.createElement("i",{className:`bi bi-${i.icon} _font-15`,"aria-hidden":"true"})):e.createElement(a,{label:i.label,icon:i.icon,ariaLabel:i.ariaLabel,disabled:i.disabled,onClick:m}))},o=t=>{const{actions:n,context:a}=t;return e.createElement("div",{className:"_row _ycenter"},n.map((t,n)=>e.createElement("div",{key:`inline-action-${n}`},e.createElement(c,{action:t,context:a}))))};exports.ButtonComponent=a,exports.CircledLetterComponent=t=>{const{text:n="",inlineStyles:a,classNames:l="",size:i="1x"}=t;return e.createElement("div",{className:`_row _xcenter _ycenter _font-weight-bold _circle ${l} _circle-size-${i}`,style:a},(e=>e.trim().split(/\s+/).filter(Boolean).map(e=>e[0].toUpperCase()).join(""))(n))},exports.ConfirmationComponent=r,exports.DrawerComponent=n=>{const{isOpen:a,onClose:r,children:c}=n;i(a,r);const s=[{type:"button",icon:"x-circle",label:"Close",onClick:()=>{r()}}];return e.createElement(e.Fragment,null,e.createElement(l,{isOpen:a}),a&&e.createElement(t.AnimationComponent,{animationName:t.AnimationName.HALF_X_EXPAND,className:"_position-fixed _right-0 _bg-light-grey _top-0 _half-width _full-height _z-index-100 _y-scroll"},e.createElement("div",{role:"dialog","aria-modal":"true",className:"_p-4"},e.createElement("div",{className:"_row _xend _p-4 _mb-4 _bg-white _border-radius-5"},e.createElement(o,{actions:s})),e.createElement("div",null,c))))},exports.InlineActionsComponent=o,exports.MenuComponent=t=>{const{menus:a,navigate:l,pathname:i}=t,r=e=>Object.assign({justifyContent:"flex-start","--btn-hover-bg":n},e&&{"--btn-bg":n});return e.createElement("nav",{className:"_pt-2 _pb-4 _pl-4 _pr-4"},a.map(t=>{var n;return e.createElement("div",{key:t.name,className:"_mb-3"},e.createElement("div",{className:"_mb-3"},e.createElement("span",{className:"_font-13"},t.name)),null===(n=t.items)||void 0===n?void 0:n.map(t=>{var n;const a=(e=>!!e.path&&(i===e.path||i.startsWith(`${e.path}/`)))(t);return e.createElement("button",{key:`${t.name}-${null!==(n=t.path)&&void 0!==n?n:""}`,type:"button",className:"_btn _btn-block _p-1",style:r(a),"aria-current":a?"page":void 0,onClick:()=>(e=>{e.onClick?e.onClick():e.path&&l(e.path)})(t)},t.icon&&e.createElement("i",{className:`bi bi-${t.icon} _font-15`,"aria-hidden":"true"}),e.createElement("span",{className:"_font-13 _font-weight-900"},t.name))}))}))},exports.OverlayComponent=l,exports.PageHeaderComponent=t=>{const{actions:n=[],header:a,subHeader:l,context:i}=t;return e.createElement("div",{className:"_row _ycenter _p-3 _mb-3 _bg-white _border-radius-5"},e.createElement("div",{className:"_col-6"},e.createElement("div",{className:"_font-13 _font-weight-900"},a),l&&e.createElement("div",{className:"_font-10"},l)),e.createElement("div",{className:"_col-6"},e.createElement("div",{className:"_row _xend"},e.createElement(o,{actions:n,context:i}))))},exports.PillComponent=t=>{const{type:n="round",bg:a="light",children:l,text:i}=t;return e.createElement("div",{className:"_p-1"},e.createElement("span",{className:`_font-12 _pill _pill-${n} _bg-${a}`},l&&e.createElement("span",null,l),i&&e.createElement("span",null,i)))};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface IButton {
|
|
2
|
+
label: string;
|
|
3
|
+
icon?: string;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
/** Defaults to "button", so it never submits a form by accident. */
|
|
6
|
+
type?: "button" | "submit" | "reset";
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** Screen reader name when the label alone is not clear enough. */
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
/** vanilla-css button variant (_btn-<variant>). Defaults to "outline". */
|
|
11
|
+
variant?: "primary" | "accent" | "outline" | "outline-light" | "link";
|
|
12
|
+
/**
|
|
13
|
+
* vanilla-css button size: "xs" (_btn-xs, compact, the default), "sm" (_btn-sm),
|
|
14
|
+
* "md" (plain _btn) or "lg" (_btn-lg).
|
|
15
|
+
*/
|
|
16
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
17
|
+
/**
|
|
18
|
+
* Makes it a toggle: sets aria-pressed, and when true highlights the
|
|
19
|
+
* button like the selected menu item. Use for tabs and filters.
|
|
20
|
+
*/
|
|
21
|
+
pressed?: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IConfirmation {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
onConfirm: () => void;
|
|
5
|
+
title: string;
|
|
6
|
+
subTitle: string;
|
|
7
|
+
/** Text of the button that runs onConfirm. Defaults to "Confirm". */
|
|
8
|
+
confirmLabel?: string;
|
|
9
|
+
/** Text of the button that closes without confirming. Defaults to "Cancel". */
|
|
10
|
+
cancelLabel?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./button";
|
|
2
|
+
export * from "./circled-letter";
|
|
3
|
+
export * from "./confirmation";
|
|
4
|
+
export * from "./drawer";
|
|
5
|
+
export * from "./inline-actions";
|
|
6
|
+
export * from "./menu";
|
|
7
|
+
export * from "./overlay";
|
|
8
|
+
export * from "./page-header";
|
|
9
|
+
export * from "./pill";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./action.component";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface IInlineActionConfirm {
|
|
2
|
+
title: string;
|
|
3
|
+
subTitle: string;
|
|
4
|
+
/** Dialog button that runs the action. Defaults to "Confirm". */
|
|
5
|
+
confirmLabel?: string;
|
|
6
|
+
/** Dialog button that closes without running it. Defaults to "Cancel". */
|
|
7
|
+
cancelLabel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IInlineAction {
|
|
10
|
+
/** "button" shows the label, "icon" shows only the icon. Defaults to "button". */
|
|
11
|
+
type?: "button" | "icon";
|
|
12
|
+
/** Button text, or the icon's tooltip and screen reader name. */
|
|
13
|
+
label: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Screen reader name when the label alone is not clear, e.g. "Remove Asha Studio". */
|
|
16
|
+
ariaLabel?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Receives the InlineActions context, e.g. the row the actions belong to. */
|
|
19
|
+
onClick(context?: unknown): void;
|
|
20
|
+
/** Ask before running onClick. */
|
|
21
|
+
confirm?: IInlineActionConfirm;
|
|
22
|
+
}
|
|
23
|
+
export interface IInlineActions {
|
|
24
|
+
actions: IInlineAction[];
|
|
25
|
+
context?: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface IAction {
|
|
28
|
+
action: IInlineAction;
|
|
29
|
+
context?: unknown;
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IMenuItem {
|
|
2
|
+
name: string;
|
|
3
|
+
/** Bootstrap icon name without the "bi-" prefix, e.g. "house". */
|
|
4
|
+
icon?: string;
|
|
5
|
+
/** Navigated to on click, and marks the item active on that page. */
|
|
6
|
+
path?: string;
|
|
7
|
+
/** Runs instead of navigating, e.g. log out. */
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface IMenuSection {
|
|
11
|
+
name: string;
|
|
12
|
+
items?: IMenuItem[];
|
|
13
|
+
}
|
|
14
|
+
export interface IMenu {
|
|
15
|
+
menus: IMenuSection[];
|
|
16
|
+
/** The router's navigate, e.g. useNavigate() from react-router-dom. */
|
|
17
|
+
navigate: (path: string) => void;
|
|
18
|
+
/** The current path, e.g. useLocation().pathname. */
|
|
19
|
+
pathname: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{useEffect as t,useId as a,useState as n}from"react";import{AnimationComponent as l,AnimationName as i}from"@vighnalabs-packages/react-animation";const r="lightblue",c=t=>{const{label:a,icon:n,onClick:l,type:i="button",disabled:c=!1,ariaLabel:s,variant:o="outline",size:m="xs",pressed:_}=t,d=`_btn _btn-${o}${"md"===m?"":` _btn-${m}`}`,b=_?{"--btn-bg":r}:void 0;return e.createElement("div",{className:"_p-1"},e.createElement("button",{type:i,className:d,disabled:c,"aria-label":s,"aria-pressed":_,style:b,onClick:()=>{l&&l()}},e.createElement("span",null,a),n&&e.createElement("i",{className:`bi bi-${n}`,"aria-hidden":"true"})))},s=t=>{const{text:a="",inlineStyles:n,classNames:l="",size:i="1x"}=t;return e.createElement("div",{className:`_row _xcenter _ycenter _font-weight-bold _circle ${l} _circle-size-${i}`,style:n},(e=>e.trim().split(/\s+/).filter(Boolean).map(e=>e[0].toUpperCase()).join(""))(a))},o=t=>{const{isOpen:a}=t;return e.createElement(e.Fragment,null,a&&e.createElement(l,{className:"_position-fixed _left-0 _top-0 _bg-black-transperent _full-width _full-height _z-index-100"},e.createElement(e.Fragment,null)))},m=(e,a)=>{t(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&a()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,a])},_=t=>{const{isOpen:n,onClose:i,onConfirm:r,title:s,subTitle:_,confirmLabel:d="Confirm",cancelLabel:b="Cancel"}=t,p=a(),u=a();return m(n,i),e.createElement(e.Fragment,null,e.createElement(o,{isOpen:n}),n&&e.createElement(l,{className:"_position-fixed _left-0 _top-0 _full-width _full-height _row _xcenter _ycenter _z-index-100"},e.createElement("div",{role:"alertdialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":u,className:"_bg-white _p-4 _border-radius-5 _shadow",style:{width:"90%",maxWidth:"400px"}},e.createElement("div",{className:"_row _xend _mb-3"},e.createElement("button",{type:"button","aria-label":"Close",className:"_btn _p-1",onClick:i},e.createElement("i",{className:"bi bi-x-circle _font-14","aria-hidden":"true"}))),e.createElement("div",{className:"_row _ycenter _xcenter _mb-1"},e.createElement("i",{className:"_text-red bi bi-exclamation-circle-fill _font-22","aria-hidden":"true"})),e.createElement("div",{className:"_p-2 _mb-5 _text-center"},e.createElement("div",{id:p,className:"_font-13 _font-weight-900 _mb-1"},s),e.createElement("div",{id:u,className:"_font-12"},_)),e.createElement("div",{className:"_row _xcenter"},e.createElement(c,{label:b,icon:"x-circle",onClick:i})," ",e.createElement(c,{label:d,icon:"check-square",onClick:r})))))},d=t=>{var a,l;const{action:i,context:r}=t,[s,o]=n(!1),m=()=>{i.confirm?o(!0):i.onClick(r)};return e.createElement(e.Fragment,null,i.confirm&&e.createElement(_,{isOpen:s,onClose:()=>o(!1),onConfirm:()=>{o(!1),i.onClick(r)},title:i.confirm.title,subTitle:i.confirm.subTitle,confirmLabel:i.confirm.confirmLabel,cancelLabel:i.confirm.cancelLabel}),"icon"===i.type?e.createElement("button",{type:"button",className:"_btn _p-1","aria-label":null!==(a=i.ariaLabel)&&void 0!==a?a:i.label,title:null!==(l=i.ariaLabel)&&void 0!==l?l:i.label,disabled:i.disabled,onClick:m},e.createElement("i",{className:`bi bi-${i.icon} _font-15`,"aria-hidden":"true"})):e.createElement(c,{label:i.label,icon:i.icon,ariaLabel:i.ariaLabel,disabled:i.disabled,onClick:m}))},b=t=>{const{actions:a,context:n}=t;return e.createElement("div",{className:"_row _ycenter"},a.map((t,a)=>e.createElement("div",{key:`inline-action-${a}`},e.createElement(d,{action:t,context:n}))))},p=t=>{const{isOpen:a,onClose:n,children:r}=t;m(a,n);const c=[{type:"button",icon:"x-circle",label:"Close",onClick:()=>{n()}}];return e.createElement(e.Fragment,null,e.createElement(o,{isOpen:a}),a&&e.createElement(l,{animationName:i.HALF_X_EXPAND,className:"_position-fixed _right-0 _bg-light-grey _top-0 _half-width _full-height _z-index-100 _y-scroll"},e.createElement("div",{role:"dialog","aria-modal":"true",className:"_p-4"},e.createElement("div",{className:"_row _xend _p-4 _mb-4 _bg-white _border-radius-5"},e.createElement(b,{actions:c})),e.createElement("div",null,r))))},u=t=>{const{menus:a,navigate:n,pathname:l}=t,i=e=>Object.assign({justifyContent:"flex-start","--btn-hover-bg":r},e&&{"--btn-bg":r});return e.createElement("nav",{className:"_pt-2 _pb-4 _pl-4 _pr-4"},a.map(t=>{var a;return e.createElement("div",{key:t.name,className:"_mb-3"},e.createElement("div",{className:"_mb-3"},e.createElement("span",{className:"_font-13"},t.name)),null===(a=t.items)||void 0===a?void 0:a.map(t=>{var a;const r=(e=>!!e.path&&(l===e.path||l.startsWith(`${e.path}/`)))(t);return e.createElement("button",{key:`${t.name}-${null!==(a=t.path)&&void 0!==a?a:""}`,type:"button",className:"_btn _btn-block _p-1",style:i(r),"aria-current":r?"page":void 0,onClick:()=>(e=>{e.onClick?e.onClick():e.path&&n(e.path)})(t)},t.icon&&e.createElement("i",{className:`bi bi-${t.icon} _font-15`,"aria-hidden":"true"}),e.createElement("span",{className:"_font-13 _font-weight-900"},t.name))}))}))},E=t=>{const{actions:a=[],header:n,subHeader:l,context:i}=t;return e.createElement("div",{className:"_row _ycenter _p-3 _mb-3 _bg-white _border-radius-5"},e.createElement("div",{className:"_col-6"},e.createElement("div",{className:"_font-13 _font-weight-900"},n),l&&e.createElement("div",{className:"_font-10"},l)),e.createElement("div",{className:"_col-6"},e.createElement("div",{className:"_row _xend"},e.createElement(b,{actions:a,context:i}))))},f=t=>{const{type:a="round",bg:n="light",children:l,text:i}=t;return e.createElement("div",{className:"_p-1"},e.createElement("span",{className:`_font-12 _pill _pill-${a} _bg-${n}`},l&&e.createElement("span",null,l),i&&e.createElement("span",null,i)))};export{c as ButtonComponent,s as CircledLetterComponent,_ as ConfirmationComponent,p as DrawerComponent,b as InlineActionsComponent,u as MenuComponent,o as OverlayComponent,E as PageHeaderComponent,f as PillComponent};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface IButton {
|
|
2
|
+
label: string;
|
|
3
|
+
icon?: string;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
/** Defaults to "button", so it never submits a form by accident. */
|
|
6
|
+
type?: "button" | "submit" | "reset";
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** Screen reader name when the label alone is not clear enough. */
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
/** vanilla-css button variant (_btn-<variant>). Defaults to "outline". */
|
|
11
|
+
variant?: "primary" | "accent" | "outline" | "outline-light" | "link";
|
|
12
|
+
/**
|
|
13
|
+
* vanilla-css button size: "xs" (_btn-xs, compact, the default), "sm" (_btn-sm),
|
|
14
|
+
* "md" (plain _btn) or "lg" (_btn-lg).
|
|
15
|
+
*/
|
|
16
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
17
|
+
/**
|
|
18
|
+
* Makes it a toggle: sets aria-pressed, and when true highlights the
|
|
19
|
+
* button like the selected menu item. Use for tabs and filters.
|
|
20
|
+
*/
|
|
21
|
+
pressed?: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IConfirmation {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
onConfirm: () => void;
|
|
5
|
+
title: string;
|
|
6
|
+
subTitle: string;
|
|
7
|
+
/** Text of the button that runs onConfirm. Defaults to "Confirm". */
|
|
8
|
+
confirmLabel?: string;
|
|
9
|
+
/** Text of the button that closes without confirming. Defaults to "Cancel". */
|
|
10
|
+
cancelLabel?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./button";
|
|
2
|
+
export * from "./circled-letter";
|
|
3
|
+
export * from "./confirmation";
|
|
4
|
+
export * from "./drawer";
|
|
5
|
+
export * from "./inline-actions";
|
|
6
|
+
export * from "./menu";
|
|
7
|
+
export * from "./overlay";
|
|
8
|
+
export * from "./page-header";
|
|
9
|
+
export * from "./pill";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./action.component";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface IInlineActionConfirm {
|
|
2
|
+
title: string;
|
|
3
|
+
subTitle: string;
|
|
4
|
+
/** Dialog button that runs the action. Defaults to "Confirm". */
|
|
5
|
+
confirmLabel?: string;
|
|
6
|
+
/** Dialog button that closes without running it. Defaults to "Cancel". */
|
|
7
|
+
cancelLabel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IInlineAction {
|
|
10
|
+
/** "button" shows the label, "icon" shows only the icon. Defaults to "button". */
|
|
11
|
+
type?: "button" | "icon";
|
|
12
|
+
/** Button text, or the icon's tooltip and screen reader name. */
|
|
13
|
+
label: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Screen reader name when the label alone is not clear, e.g. "Remove Asha Studio". */
|
|
16
|
+
ariaLabel?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Receives the InlineActions context, e.g. the row the actions belong to. */
|
|
19
|
+
onClick(context?: unknown): void;
|
|
20
|
+
/** Ask before running onClick. */
|
|
21
|
+
confirm?: IInlineActionConfirm;
|
|
22
|
+
}
|
|
23
|
+
export interface IInlineActions {
|
|
24
|
+
actions: IInlineAction[];
|
|
25
|
+
context?: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface IAction {
|
|
28
|
+
action: IInlineAction;
|
|
29
|
+
context?: unknown;
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IMenuItem {
|
|
2
|
+
name: string;
|
|
3
|
+
/** Bootstrap icon name without the "bi-" prefix, e.g. "house". */
|
|
4
|
+
icon?: string;
|
|
5
|
+
/** Navigated to on click, and marks the item active on that page. */
|
|
6
|
+
path?: string;
|
|
7
|
+
/** Runs instead of navigating, e.g. log out. */
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface IMenuSection {
|
|
11
|
+
name: string;
|
|
12
|
+
items?: IMenuItem[];
|
|
13
|
+
}
|
|
14
|
+
export interface IMenu {
|
|
15
|
+
menus: IMenuSection[];
|
|
16
|
+
/** The router's navigate, e.g. useNavigate() from react-router-dom. */
|
|
17
|
+
navigate: (path: string) => void;
|
|
18
|
+
/** The current path, e.g. useLocation().pathname. */
|
|
19
|
+
pathname: string;
|
|
20
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface IButton {
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
/** Defaults to "button", so it never submits a form by accident. */
|
|
8
|
+
type?: "button" | "submit" | "reset";
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Screen reader name when the label alone is not clear enough. */
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
/** vanilla-css button variant (_btn-<variant>). Defaults to "outline". */
|
|
13
|
+
variant?: "primary" | "accent" | "outline" | "outline-light" | "link";
|
|
14
|
+
/**
|
|
15
|
+
* vanilla-css button size: "xs" (_btn-xs, compact, the default), "sm" (_btn-sm),
|
|
16
|
+
* "md" (plain _btn) or "lg" (_btn-lg).
|
|
17
|
+
*/
|
|
18
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
19
|
+
/**
|
|
20
|
+
* Makes it a toggle: sets aria-pressed, and when true highlights the
|
|
21
|
+
* button like the selected menu item. Use for tabs and filters.
|
|
22
|
+
*/
|
|
23
|
+
pressed?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const ButtonComponent: React.FC<IButton>;
|
|
27
|
+
|
|
28
|
+
interface ICircledLetter {
|
|
29
|
+
text: string;
|
|
30
|
+
inlineStyles?: CSSProperties;
|
|
31
|
+
classNames?: string;
|
|
32
|
+
size?: "1x" | "2x" | "3x" | "4x" | "5x";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare const CircledLetterComponent: React.FC<ICircledLetter>;
|
|
36
|
+
|
|
37
|
+
interface IConfirmation {
|
|
38
|
+
isOpen: boolean;
|
|
39
|
+
onClose: () => void;
|
|
40
|
+
onConfirm: () => void;
|
|
41
|
+
title: string;
|
|
42
|
+
subTitle: string;
|
|
43
|
+
/** Text of the button that runs onConfirm. Defaults to "Confirm". */
|
|
44
|
+
confirmLabel?: string;
|
|
45
|
+
/** Text of the button that closes without confirming. Defaults to "Cancel". */
|
|
46
|
+
cancelLabel?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare const ConfirmationComponent: React.FC<IConfirmation>;
|
|
50
|
+
|
|
51
|
+
interface IDrawer {
|
|
52
|
+
isOpen: boolean;
|
|
53
|
+
onClose: () => void;
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare const DrawerComponent: React.FC<IDrawer>;
|
|
58
|
+
|
|
59
|
+
interface IInlineActionConfirm {
|
|
60
|
+
title: string;
|
|
61
|
+
subTitle: string;
|
|
62
|
+
/** Dialog button that runs the action. Defaults to "Confirm". */
|
|
63
|
+
confirmLabel?: string;
|
|
64
|
+
/** Dialog button that closes without running it. Defaults to "Cancel". */
|
|
65
|
+
cancelLabel?: string;
|
|
66
|
+
}
|
|
67
|
+
interface IInlineAction {
|
|
68
|
+
/** "button" shows the label, "icon" shows only the icon. Defaults to "button". */
|
|
69
|
+
type?: "button" | "icon";
|
|
70
|
+
/** Button text, or the icon's tooltip and screen reader name. */
|
|
71
|
+
label: string;
|
|
72
|
+
icon?: string;
|
|
73
|
+
/** Screen reader name when the label alone is not clear, e.g. "Remove Asha Studio". */
|
|
74
|
+
ariaLabel?: string;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
/** Receives the InlineActions context, e.g. the row the actions belong to. */
|
|
77
|
+
onClick(context?: unknown): void;
|
|
78
|
+
/** Ask before running onClick. */
|
|
79
|
+
confirm?: IInlineActionConfirm;
|
|
80
|
+
}
|
|
81
|
+
interface IInlineActions {
|
|
82
|
+
actions: IInlineAction[];
|
|
83
|
+
context?: unknown;
|
|
84
|
+
}
|
|
85
|
+
interface IAction {
|
|
86
|
+
action: IInlineAction;
|
|
87
|
+
context?: unknown;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare const InlineActionsComponent: React.FC<IInlineActions>;
|
|
91
|
+
|
|
92
|
+
interface IMenuItem {
|
|
93
|
+
name: string;
|
|
94
|
+
/** Bootstrap icon name without the "bi-" prefix, e.g. "house". */
|
|
95
|
+
icon?: string;
|
|
96
|
+
/** Navigated to on click, and marks the item active on that page. */
|
|
97
|
+
path?: string;
|
|
98
|
+
/** Runs instead of navigating, e.g. log out. */
|
|
99
|
+
onClick?: () => void;
|
|
100
|
+
}
|
|
101
|
+
interface IMenuSection {
|
|
102
|
+
name: string;
|
|
103
|
+
items?: IMenuItem[];
|
|
104
|
+
}
|
|
105
|
+
interface IMenu {
|
|
106
|
+
menus: IMenuSection[];
|
|
107
|
+
/** The router's navigate, e.g. useNavigate() from react-router-dom. */
|
|
108
|
+
navigate: (path: string) => void;
|
|
109
|
+
/** The current path, e.g. useLocation().pathname. */
|
|
110
|
+
pathname: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
declare const MenuComponent: React.FC<IMenu>;
|
|
114
|
+
|
|
115
|
+
interface IOverlay {
|
|
116
|
+
isOpen: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare const OverlayComponent: React.FC<IOverlay>;
|
|
120
|
+
|
|
121
|
+
interface IPageHeader {
|
|
122
|
+
header?: string;
|
|
123
|
+
subHeader?: string;
|
|
124
|
+
actions?: IInlineAction[];
|
|
125
|
+
/** Passed to every action's onClick. */
|
|
126
|
+
context?: unknown;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare const PageHeaderComponent: React.FC<IPageHeader>;
|
|
130
|
+
|
|
131
|
+
interface IPill {
|
|
132
|
+
type?: "round" | "square";
|
|
133
|
+
bg?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
|
|
134
|
+
children?: ReactNode;
|
|
135
|
+
text?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
declare const PillComponent: React.FC<IPill>;
|
|
139
|
+
|
|
140
|
+
export { ButtonComponent, CircledLetterComponent, ConfirmationComponent, DrawerComponent, InlineActionsComponent, MenuComponent, OverlayComponent, PageHeaderComponent, PillComponent };
|
|
141
|
+
export type { IAction, IButton, ICircledLetter, IConfirmation, IDrawer, IInlineAction, IInlineActionConfirm, IInlineActions, IMenu, IMenuItem, IMenuSection, IOverlay, IPageHeader, IPill };
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@vighnalabs-packages/react-ui",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "react ui components for vighnalabs projects",
|
|
5
|
+
"author": "Sandip Gadekar",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"main": "dist/cjs/index.js",
|
|
8
|
+
"module": "dist/esm/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/esm/index.js",
|
|
17
|
+
"require": "./dist/cjs/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "rollup -c --watch",
|
|
23
|
+
"format": "prettier . --write",
|
|
24
|
+
"format:check": "prettier . --check",
|
|
25
|
+
"lint": "eslint .",
|
|
26
|
+
"lint:fix": "eslint . --fix",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest --watch",
|
|
29
|
+
"test:coverage": "vitest run --coverage",
|
|
30
|
+
"clean": "rm -rf dist",
|
|
31
|
+
"build": "npm run clean && rollup -c",
|
|
32
|
+
"publish:npm": "npm publish --access public"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@vighnalabs-packages/react-animation": "^1.0.2",
|
|
36
|
+
"@vighnalabs-packages/vanilla-css": "^2.4.0",
|
|
37
|
+
"react": "^19.1.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/js": "^10.0.1",
|
|
41
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
42
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
43
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
44
|
+
"@testing-library/react": "^16.3.3",
|
|
45
|
+
"@types/node": "^26.6.5",
|
|
46
|
+
"@types/react": "^19.2.14",
|
|
47
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
48
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
49
|
+
"eslint-config-prettier": "^10.1.8",
|
|
50
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
51
|
+
"jsdom": "^29.1.1",
|
|
52
|
+
"prettier": "^3.9.9",
|
|
53
|
+
"rollup": "^4.14.2",
|
|
54
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
55
|
+
"tslib": "^2.6.2",
|
|
56
|
+
"typescript": "^5.4.5",
|
|
57
|
+
"typescript-eslint": "^8.71.0",
|
|
58
|
+
"vitest": "^5.0.5"
|
|
59
|
+
}
|
|
60
|
+
}
|