@vighnalabs-packages/react-ui 0.1.0 → 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.
Files changed (68) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/types/button/button.component.d.ts +3 -0
  3. package/dist/cjs/types/button/button.interface.d.ts +22 -0
  4. package/dist/cjs/types/button/index.d.ts +2 -0
  5. package/dist/cjs/types/circled-letter/circled-letter.component.d.ts +3 -0
  6. package/dist/cjs/types/circled-letter/circled-letter.interface.d.ts +7 -0
  7. package/dist/cjs/types/circled-letter/index.d.ts +2 -0
  8. package/dist/cjs/types/confirmation/confirmation.component.d.ts +3 -0
  9. package/dist/cjs/types/confirmation/confirmation.interface.d.ts +11 -0
  10. package/dist/cjs/types/confirmation/index.d.ts +2 -0
  11. package/dist/cjs/types/constants.d.ts +2 -0
  12. package/dist/cjs/types/drawer/drawer.component.d.ts +3 -0
  13. package/dist/cjs/types/drawer/drawer.interface.d.ts +6 -0
  14. package/dist/cjs/types/drawer/index.d.ts +2 -0
  15. package/dist/cjs/types/hooks/use-escape-key.d.ts +2 -0
  16. package/dist/cjs/types/index.d.ts +9 -0
  17. package/dist/cjs/types/inline-actions/components/action.component.d.ts +3 -0
  18. package/dist/cjs/types/inline-actions/components/index.d.ts +1 -0
  19. package/dist/cjs/types/inline-actions/index.d.ts +2 -0
  20. package/dist/cjs/types/inline-actions/inline-actions.component.d.ts +3 -0
  21. package/dist/cjs/types/inline-actions/inline-actions.interface.d.ts +30 -0
  22. package/dist/cjs/types/menu/index.d.ts +2 -0
  23. package/dist/cjs/types/menu/menu.component.d.ts +3 -0
  24. package/dist/cjs/types/menu/menu.interface.d.ts +20 -0
  25. package/dist/cjs/types/overlay/index.d.ts +2 -0
  26. package/dist/cjs/types/overlay/overlay.component.d.ts +3 -0
  27. package/dist/cjs/types/overlay/overlay.interface.d.ts +3 -0
  28. package/dist/cjs/types/page-header/index.d.ts +2 -0
  29. package/dist/cjs/types/page-header/page-header.component.d.ts +3 -0
  30. package/dist/cjs/types/page-header/page-header.interface.d.ts +8 -0
  31. package/dist/cjs/types/pill/index.d.ts +2 -0
  32. package/dist/cjs/types/pill/pill.component.d.ts +3 -0
  33. package/dist/cjs/types/pill/pill.interface.d.ts +7 -0
  34. package/dist/esm/index.js +1 -0
  35. package/dist/esm/types/button/button.component.d.ts +3 -0
  36. package/dist/esm/types/button/button.interface.d.ts +22 -0
  37. package/dist/esm/types/button/index.d.ts +2 -0
  38. package/dist/esm/types/circled-letter/circled-letter.component.d.ts +3 -0
  39. package/dist/esm/types/circled-letter/circled-letter.interface.d.ts +7 -0
  40. package/dist/esm/types/circled-letter/index.d.ts +2 -0
  41. package/dist/esm/types/confirmation/confirmation.component.d.ts +3 -0
  42. package/dist/esm/types/confirmation/confirmation.interface.d.ts +11 -0
  43. package/dist/esm/types/confirmation/index.d.ts +2 -0
  44. package/dist/esm/types/constants.d.ts +2 -0
  45. package/dist/esm/types/drawer/drawer.component.d.ts +3 -0
  46. package/dist/esm/types/drawer/drawer.interface.d.ts +6 -0
  47. package/dist/esm/types/drawer/index.d.ts +2 -0
  48. package/dist/esm/types/hooks/use-escape-key.d.ts +2 -0
  49. package/dist/esm/types/index.d.ts +9 -0
  50. package/dist/esm/types/inline-actions/components/action.component.d.ts +3 -0
  51. package/dist/esm/types/inline-actions/components/index.d.ts +1 -0
  52. package/dist/esm/types/inline-actions/index.d.ts +2 -0
  53. package/dist/esm/types/inline-actions/inline-actions.component.d.ts +3 -0
  54. package/dist/esm/types/inline-actions/inline-actions.interface.d.ts +30 -0
  55. package/dist/esm/types/menu/index.d.ts +2 -0
  56. package/dist/esm/types/menu/menu.component.d.ts +3 -0
  57. package/dist/esm/types/menu/menu.interface.d.ts +20 -0
  58. package/dist/esm/types/overlay/index.d.ts +2 -0
  59. package/dist/esm/types/overlay/overlay.component.d.ts +3 -0
  60. package/dist/esm/types/overlay/overlay.interface.d.ts +3 -0
  61. package/dist/esm/types/page-header/index.d.ts +2 -0
  62. package/dist/esm/types/page-header/page-header.component.d.ts +3 -0
  63. package/dist/esm/types/page-header/page-header.interface.d.ts +8 -0
  64. package/dist/esm/types/pill/index.d.ts +2 -0
  65. package/dist/esm/types/pill/pill.component.d.ts +3 -0
  66. package/dist/esm/types/pill/pill.interface.d.ts +7 -0
  67. package/dist/index.d.ts +141 -0
  68. package/package.json +1 -1
@@ -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,3 @@
1
+ import { IButton } from "./button.interface";
2
+ import React from "react";
3
+ export declare const ButtonComponent: React.FC<IButton>;
@@ -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,2 @@
1
+ export * from "./button.component";
2
+ export * from "./button.interface";
@@ -0,0 +1,3 @@
1
+ import { ICircledLetter } from "./circled-letter.interface";
2
+ import React from "react";
3
+ export declare const CircledLetterComponent: React.FC<ICircledLetter>;
@@ -0,0 +1,7 @@
1
+ import { CSSProperties } from "react";
2
+ export interface ICircledLetter {
3
+ text: string;
4
+ inlineStyles?: CSSProperties;
5
+ classNames?: string;
6
+ size?: "1x" | "2x" | "3x" | "4x" | "5x";
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./circled-letter.component";
2
+ export * from "./circled-letter.interface";
@@ -0,0 +1,3 @@
1
+ import { IConfirmation } from "./confirmation.interface";
2
+ import React from "react";
3
+ export declare const ConfirmationComponent: React.FC<IConfirmation>;
@@ -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,2 @@
1
+ export * from "./confirmation.component";
2
+ export * from "./confirmation.interface";
@@ -0,0 +1,2 @@
1
+ /** Background for the selected menu item and a pressed button. */
2
+ export declare const ACTIVE_BG = "lightblue";
@@ -0,0 +1,3 @@
1
+ import { IDrawer } from "./drawer.interface";
2
+ import React from "react";
3
+ export declare const DrawerComponent: React.FC<IDrawer>;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ export interface IDrawer {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ children?: ReactNode;
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./drawer.component";
2
+ export * from "./drawer.interface";
@@ -0,0 +1,2 @@
1
+ /** Calls onEscape when Escape is pressed, only while active. */
2
+ export declare const useEscapeKey: (active: boolean, onEscape: () => void) => void;
@@ -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,3 @@
1
+ import { IAction } from "../inline-actions.interface";
2
+ import React from "react";
3
+ export declare const ActionComponent: React.FC<IAction>;
@@ -0,0 +1 @@
1
+ export * from "./action.component";
@@ -0,0 +1,2 @@
1
+ export * from "./inline-actions.component";
2
+ export * from "./inline-actions.interface";
@@ -0,0 +1,3 @@
1
+ import { IInlineActions } from "./inline-actions.interface";
2
+ import React from "react";
3
+ export declare const InlineActionsComponent: React.FC<IInlineActions>;
@@ -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,2 @@
1
+ export * from "./menu.component";
2
+ export * from "./menu.interface";
@@ -0,0 +1,3 @@
1
+ import { IMenu } from "./menu.interface";
2
+ import React from "react";
3
+ export declare const MenuComponent: React.FC<IMenu>;
@@ -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,2 @@
1
+ export * from "./overlay.component";
2
+ export * from "./overlay.interface";
@@ -0,0 +1,3 @@
1
+ import { IOverlay } from "./overlay.interface";
2
+ import React from "react";
3
+ export declare const OverlayComponent: React.FC<IOverlay>;
@@ -0,0 +1,3 @@
1
+ export interface IOverlay {
2
+ isOpen: boolean;
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./page-header.component";
2
+ export * from "./page-header.interface";
@@ -0,0 +1,3 @@
1
+ import { IPageHeader } from "./page-header.interface";
2
+ import React from "react";
3
+ export declare const PageHeaderComponent: React.FC<IPageHeader>;
@@ -0,0 +1,8 @@
1
+ import { IInlineAction } from "../inline-actions";
2
+ export interface IPageHeader {
3
+ header?: string;
4
+ subHeader?: string;
5
+ actions?: IInlineAction[];
6
+ /** Passed to every action's onClick. */
7
+ context?: unknown;
8
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./pill.component";
2
+ export * from "./pill.interface";
@@ -0,0 +1,3 @@
1
+ import { IPill } from "./pill.interface";
2
+ import React from "react";
3
+ export declare const PillComponent: React.FC<IPill>;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from "react";
2
+ export interface IPill {
3
+ type?: "round" | "square";
4
+ bg?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
5
+ children?: ReactNode;
6
+ text?: string;
7
+ }
@@ -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,3 @@
1
+ import { IButton } from "./button.interface";
2
+ import React from "react";
3
+ export declare const ButtonComponent: React.FC<IButton>;
@@ -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,2 @@
1
+ export * from "./button.component";
2
+ export * from "./button.interface";
@@ -0,0 +1,3 @@
1
+ import { ICircledLetter } from "./circled-letter.interface";
2
+ import React from "react";
3
+ export declare const CircledLetterComponent: React.FC<ICircledLetter>;
@@ -0,0 +1,7 @@
1
+ import { CSSProperties } from "react";
2
+ export interface ICircledLetter {
3
+ text: string;
4
+ inlineStyles?: CSSProperties;
5
+ classNames?: string;
6
+ size?: "1x" | "2x" | "3x" | "4x" | "5x";
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./circled-letter.component";
2
+ export * from "./circled-letter.interface";
@@ -0,0 +1,3 @@
1
+ import { IConfirmation } from "./confirmation.interface";
2
+ import React from "react";
3
+ export declare const ConfirmationComponent: React.FC<IConfirmation>;
@@ -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,2 @@
1
+ export * from "./confirmation.component";
2
+ export * from "./confirmation.interface";
@@ -0,0 +1,2 @@
1
+ /** Background for the selected menu item and a pressed button. */
2
+ export declare const ACTIVE_BG = "lightblue";
@@ -0,0 +1,3 @@
1
+ import { IDrawer } from "./drawer.interface";
2
+ import React from "react";
3
+ export declare const DrawerComponent: React.FC<IDrawer>;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ export interface IDrawer {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ children?: ReactNode;
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./drawer.component";
2
+ export * from "./drawer.interface";
@@ -0,0 +1,2 @@
1
+ /** Calls onEscape when Escape is pressed, only while active. */
2
+ export declare const useEscapeKey: (active: boolean, onEscape: () => void) => void;
@@ -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,3 @@
1
+ import { IAction } from "../inline-actions.interface";
2
+ import React from "react";
3
+ export declare const ActionComponent: React.FC<IAction>;
@@ -0,0 +1 @@
1
+ export * from "./action.component";
@@ -0,0 +1,2 @@
1
+ export * from "./inline-actions.component";
2
+ export * from "./inline-actions.interface";
@@ -0,0 +1,3 @@
1
+ import { IInlineActions } from "./inline-actions.interface";
2
+ import React from "react";
3
+ export declare const InlineActionsComponent: React.FC<IInlineActions>;
@@ -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,2 @@
1
+ export * from "./menu.component";
2
+ export * from "./menu.interface";
@@ -0,0 +1,3 @@
1
+ import { IMenu } from "./menu.interface";
2
+ import React from "react";
3
+ export declare const MenuComponent: React.FC<IMenu>;
@@ -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,2 @@
1
+ export * from "./overlay.component";
2
+ export * from "./overlay.interface";
@@ -0,0 +1,3 @@
1
+ import { IOverlay } from "./overlay.interface";
2
+ import React from "react";
3
+ export declare const OverlayComponent: React.FC<IOverlay>;
@@ -0,0 +1,3 @@
1
+ export interface IOverlay {
2
+ isOpen: boolean;
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./page-header.component";
2
+ export * from "./page-header.interface";
@@ -0,0 +1,3 @@
1
+ import { IPageHeader } from "./page-header.interface";
2
+ import React from "react";
3
+ export declare const PageHeaderComponent: React.FC<IPageHeader>;
@@ -0,0 +1,8 @@
1
+ import { IInlineAction } from "../inline-actions";
2
+ export interface IPageHeader {
3
+ header?: string;
4
+ subHeader?: string;
5
+ actions?: IInlineAction[];
6
+ /** Passed to every action's onClick. */
7
+ context?: unknown;
8
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./pill.component";
2
+ export * from "./pill.interface";
@@ -0,0 +1,3 @@
1
+ import { IPill } from "./pill.interface";
2
+ import React from "react";
3
+ export declare const PillComponent: React.FC<IPill>;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from "react";
2
+ export interface IPill {
3
+ type?: "round" | "square";
4
+ bg?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
5
+ children?: ReactNode;
6
+ text?: string;
7
+ }
@@ -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,6 @@
1
1
  {
2
2
  "name": "@vighnalabs-packages/react-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "react ui components for vighnalabs projects",
5
5
  "author": "Sandip Gadekar",
6
6
  "license": "ISC",