@alexandregme/zljs 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -18,9 +18,9 @@ type DataColor = "blue" | "red" | "yellow" | "green" | "gray" | "orange";
18
18
  /**
19
19
  * Sizes shared by every sized component (Icon, Button, Input, etc.)
20
20
  */
21
- type Size = "sm" | "md";
21
+ type Size = "sm" | "md" | "lg";
22
22
 
23
- declare const iconNames: readonly ["Check", "X", "Plus", "Minus", "Search", "Menu", "ChevronDown", "ChevronUp", "ChevronLeft", "ChevronRight", "Pencil", "Trash2", "Save", "RefreshCw", "Home", "MessageSquare", "Users", "Store", "ShoppingCart", "BarChart3", "Brain", "Send", "LogOut", "User", "Key", "Contact", "Package", "Warehouse", "HandCoins", "Stethoscope", "LogIn", "Megaphone", "LayoutDashboard", "Smile", "Frown", "Cat", "ArrowRight", "Loader", "CheckCircle", "XCircle", "AlertTriangle", "Info", "SiWhatsapp", "SiFacebook", "SiInstagram", "SiShopify"];
23
+ declare const iconNames: readonly ["Check", "X", "Plus", "Minus", "Search", "Menu", "ChevronDown", "ChevronUp", "ChevronLeft", "ChevronRight", "Pencil", "Trash2", "Save", "RefreshCw", "Home", "MessageSquare", "Users", "Store", "ShoppingCart", "BarChart3", "Brain", "Send", "LogOut", "User", "Key", "Contact", "Package", "Warehouse", "HandCoins", "Stethoscope", "LogIn", "Megaphone", "LayoutDashboard", "Smile", "Frown", "Cat", "ArrowRight", "Loader", "LoaderCircle", "CheckCircle", "XCircle", "AlertTriangle", "Info", "SiWhatsapp", "SiFacebook", "SiInstagram", "SiShopify"];
24
24
 
25
25
  type IconName = (typeof iconNames)[number];
26
26
  interface IconProps {
@@ -400,11 +400,13 @@ interface ConnectedModalProps {
400
400
 
401
401
  declare const ConnectedModal: ({ modalId, title, description, size, children, }: ConnectedModalProps) => react.JSX.Element;
402
402
 
403
+ type SpinnerVariant = "circle" | "dots" | "refresh";
403
404
  interface SpinnerProps {
404
- className?: string;
405
+ variant?: SpinnerVariant;
406
+ size?: Size;
405
407
  }
406
408
 
407
- declare const Spinner: ({ className }: SpinnerProps) => react.JSX.Element;
409
+ declare const Spinner: ({ variant, size }: SpinnerProps) => react.JSX.Element;
408
410
 
409
411
  interface LoaderProps {
410
412
  label?: string;
@@ -453,4 +455,4 @@ declare class HTTPClient {
453
455
  }
454
456
 
455
457
  export { AppWrapper, Button, Checkbox, ConnectedModal, DataGrid, DocumentWrapper, Error, Form, GlobalState, HTTPClient, Heading, Icon, Input, Loader, Modal, PageWrapper, Radio, Select, Sidebar, Spinner, StatsCard, Tag, Text, TextArea, Toaster, WhatsAppButton, splitURLasPath, useAppStore, useModalStore, usePageStore, useRouterStore, useToastStore };
456
- export type { AppState, AppWrapperProps, ButtonProps, ButtonVariant, CheckboxProps, ConnectedModalProps, DataGridColumn, DataGridProps, DocumentWrapperProps, ErrorProps, ExtendedStore, FormProps, GlobalStateProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, InitPageFunction, InputProps, LoaderProps, ModalEntry, ModalProps, ModalState, PageState, PageWrapperProps, RadioProps, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, SpinnerProps, StatsCardProps, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps };
458
+ export type { AppState, AppWrapperProps, ButtonProps, ButtonVariant, CheckboxProps, ConnectedModalProps, DataGridColumn, DataGridProps, DocumentWrapperProps, ErrorProps, ExtendedStore, FormProps, GlobalStateProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, InitPageFunction, InputProps, LoaderProps, ModalEntry, ModalProps, ModalState, PageState, PageWrapperProps, RadioProps, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, SpinnerProps, SpinnerVariant, StatsCardProps, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps };
package/dist/index.js CHANGED
@@ -19,7 +19,8 @@ var iconBrands = {
19
19
  };
20
20
  var iconSizes = {
21
21
  sm: 12,
22
- md: 16
22
+ md: 16,
23
+ lg: 24
23
24
  };
24
25
 
25
26
  // core/icon/icon.tsx
@@ -52,7 +53,8 @@ var button = tv({
52
53
  },
53
54
  size: {
54
55
  sm: "",
55
- md: ""
56
+ md: "",
57
+ lg: ""
56
58
  }
57
59
  },
58
60
  compoundVariants: [
@@ -66,6 +68,16 @@ var button = tv({
66
68
  size: "sm",
67
69
  class: "p-0.5"
68
70
  },
71
+ {
72
+ variant: "default",
73
+ size: "lg",
74
+ class: "px-6 py-3 text-base gap-2"
75
+ },
76
+ {
77
+ variant: "icon",
78
+ size: "lg",
79
+ class: "p-2"
80
+ },
69
81
  {
70
82
  variant: "link",
71
83
  color: "primary",
@@ -589,45 +601,53 @@ var DataGrid = ({
589
601
  );
590
602
  };
591
603
 
592
- // core/stats-card/stats-card.tsx
593
- import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
594
- var colorClasses = {
595
- blue: {
596
- card: "bg-blue-100",
597
- label: "text-blue-800",
598
- value: "text-blue-900"
599
- },
600
- red: {
601
- card: "bg-red-100",
602
- label: "text-red-800",
603
- value: "text-red-900"
604
- },
605
- yellow: {
606
- card: "bg-yellow-100",
607
- label: "text-yellow-800",
608
- value: "text-yellow-900"
609
- },
610
- green: {
611
- card: "bg-green-100",
612
- label: "text-green-800",
613
- value: "text-green-900"
614
- },
615
- gray: {
616
- card: "bg-gray-100",
617
- label: "text-gray-800",
618
- value: "text-gray-900"
604
+ // core/text/text.styles.ts
605
+ import { tv as tv8 } from "tailwind-variants";
606
+ var text = tv8({
607
+ variants: {
608
+ variant: {
609
+ body: "text-base",
610
+ caption: "text-sm",
611
+ display: "text-3xl font-bold"
612
+ }
619
613
  },
620
- orange: {
621
- card: "bg-orange-100",
622
- label: "text-orange-800",
623
- value: "text-orange-900"
614
+ defaultVariants: {
615
+ variant: "body"
624
616
  }
617
+ });
618
+
619
+ // core/text/text.tsx
620
+ import { jsx as jsx12 } from "react/jsx-runtime";
621
+ var Text = ({
622
+ children,
623
+ as: Tag2 = "p",
624
+ variant = "body"
625
+ }) => {
626
+ return /* @__PURE__ */ jsx12(Tag2, { "data-testid": "text", className: text({ variant }), children });
625
627
  };
628
+
629
+ // core/stats-card/stats-card.styles.ts
630
+ import { tv as tv9 } from "tailwind-variants";
631
+ var statsCard = tv9({
632
+ base: "p-4 rounded-lg",
633
+ variants: {
634
+ color: {
635
+ blue: "bg-blue-100 text-blue-900",
636
+ red: "bg-red-100 text-red-900",
637
+ yellow: "bg-yellow-100 text-yellow-900",
638
+ green: "bg-green-100 text-green-900",
639
+ gray: "bg-gray-100 text-gray-900",
640
+ orange: "bg-orange-100 text-orange-900"
641
+ }
642
+ }
643
+ });
644
+
645
+ // core/stats-card/stats-card.tsx
646
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
626
647
  var StatsCard = ({ label: label5, value, color }) => {
627
- const styles = colorClasses[color];
628
- return /* @__PURE__ */ jsxs10("div", { "data-testid": "stats-card", className: `${styles.card} p-4 rounded-lg`, children: [
629
- /* @__PURE__ */ jsx12("p", { className: `text-sm ${styles.label}`, children: label5 }),
630
- /* @__PURE__ */ jsx12("p", { className: `text-3xl font-bold ${styles.value}`, children: value })
648
+ return /* @__PURE__ */ jsxs10("div", { "data-testid": "stats-card", className: statsCard({ color }), children: [
649
+ /* @__PURE__ */ jsx13(Text, { variant: "caption", children: label5 }),
650
+ /* @__PURE__ */ jsx13(Text, { variant: "display", children: value })
631
651
  ] });
632
652
  };
633
653
 
@@ -635,11 +655,11 @@ var StatsCard = ({ label: label5, value, color }) => {
635
655
  import * as Dialog from "@radix-ui/react-dialog";
636
656
 
637
657
  // core/modal/modal.styles.ts
638
- import { tv as tv8 } from "tailwind-variants";
639
- var overlay = tv8({
658
+ import { tv as tv10 } from "tailwind-variants";
659
+ var overlay = tv10({
640
660
  base: "fixed inset-0 bg-black/50"
641
661
  });
642
- var content = tv8({
662
+ var content = tv10({
643
663
  base: "fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-white rounded-lg shadow-lg p-6 w-full focus:outline-none max-h-[90vh] overflow-y-auto",
644
664
  variants: {
645
665
  size: {
@@ -654,21 +674,21 @@ var content = tv8({
654
674
  size: "md"
655
675
  }
656
676
  });
657
- var header = tv8({
677
+ var header = tv10({
658
678
  base: "flex items-start justify-between"
659
679
  });
660
- var title = tv8({
680
+ var title = tv10({
661
681
  base: "text-lg font-semibold text-gray-900 m-0"
662
682
  });
663
- var description = tv8({
683
+ var description = tv10({
664
684
  base: "text-sm text-gray-600 mt-2"
665
685
  });
666
- var body = tv8({
686
+ var body = tv10({
667
687
  base: "mt-4"
668
688
  });
669
689
 
670
690
  // core/modal/modal.tsx
671
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
691
+ import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
672
692
  var Modal = ({
673
693
  open,
674
694
  onClose,
@@ -677,8 +697,8 @@ var Modal = ({
677
697
  children,
678
698
  size = "md"
679
699
  }) => {
680
- return /* @__PURE__ */ jsx13(Dialog.Root, { open, onOpenChange: (isOpen) => !isOpen && onClose(), children: /* @__PURE__ */ jsxs11(Dialog.Portal, { children: [
681
- /* @__PURE__ */ jsx13(Dialog.Overlay, { className: overlay() }),
700
+ return /* @__PURE__ */ jsx14(Dialog.Root, { open, onOpenChange: (isOpen) => !isOpen && onClose(), children: /* @__PURE__ */ jsxs11(Dialog.Portal, { children: [
701
+ /* @__PURE__ */ jsx14(Dialog.Overlay, { className: overlay() }),
682
702
  /* @__PURE__ */ jsxs11(
683
703
  Dialog.Content,
684
704
  {
@@ -686,19 +706,24 @@ var Modal = ({
686
706
  ...!description2 && { "aria-describedby": void 0 },
687
707
  children: [
688
708
  /* @__PURE__ */ jsxs11("div", { className: header(), children: [
689
- /* @__PURE__ */ jsx13(Dialog.Title, { className: title(), children: title2 }),
690
- /* @__PURE__ */ jsx13(Button, { icon: "X", "aria-label": "Close", onClick: onClose })
709
+ /* @__PURE__ */ jsx14(Dialog.Title, { className: title(), children: title2 }),
710
+ /* @__PURE__ */ jsx14(Button, { icon: "X", "aria-label": "Close", onClick: onClose })
691
711
  ] }),
692
- description2 && /* @__PURE__ */ jsx13(Dialog.Description, { className: description(), children: description2 }),
693
- children && /* @__PURE__ */ jsx13("div", { className: body(), children })
712
+ description2 && /* @__PURE__ */ jsx14(Dialog.Description, { className: description(), children: description2 }),
713
+ children && /* @__PURE__ */ jsx14("div", { className: body(), children })
694
714
  ]
695
715
  }
696
716
  )
697
717
  ] }) });
698
718
  };
699
719
 
720
+ // core/whatsapp-button/whatsapp-button.const.ts
721
+ var whatsappWebUrl = "https://wa.me";
722
+ var whatsappBusinessUrl = "whatsapp-business://send";
723
+ var whatsappMobileUserAgent = /Android|iPhone|iPad|iPod/i;
724
+
700
725
  // core/whatsapp-button/whatsapp-button.tsx
701
- import { jsx as jsx14 } from "react/jsx-runtime";
726
+ import { jsx as jsx15 } from "react/jsx-runtime";
702
727
  var WhatsAppButton = ({
703
728
  phone,
704
729
  message,
@@ -707,23 +732,23 @@ var WhatsAppButton = ({
707
732
  }) => {
708
733
  const handleClick = () => {
709
734
  const userAgent = navigator?.userAgent ?? "";
710
- const isMobile = /Android|iPhone|iPad|iPod/i.test(userAgent);
735
+ const isMobile = whatsappMobileUserAgent.test(userAgent);
711
736
  const hasMessage = Boolean(message);
712
737
  const encodedMessage = hasMessage ? encodeURIComponent(message) : "";
713
- const whatsappUrl = hasMessage ? `https://wa.me/${phone}?text=${encodedMessage}` : `https://wa.me/${phone}`;
714
- const whatsappBusinessUrl = hasMessage ? `whatsapp-business://send?phone=${phone}&text=${encodedMessage}` : `whatsapp-business://send?phone=${phone}`;
738
+ const webUrl = hasMessage ? `${whatsappWebUrl}/${phone}?text=${encodedMessage}` : `${whatsappWebUrl}/${phone}`;
739
+ const businessUrl = hasMessage ? `${whatsappBusinessUrl}?phone=${phone}&text=${encodedMessage}` : `${whatsappBusinessUrl}?phone=${phone}`;
715
740
  if (isMobile) {
716
741
  if (window.location?.assign) {
717
- window.location.assign(whatsappBusinessUrl);
742
+ window.location.assign(businessUrl);
718
743
  } else {
719
- window.location.href = whatsappBusinessUrl;
744
+ window.location.href = businessUrl;
720
745
  }
721
746
  } else {
722
- window.open(whatsappUrl, "_blank");
747
+ window.open(webUrl, "_blank");
723
748
  }
724
749
  onClick?.();
725
750
  };
726
- return /* @__PURE__ */ jsx14(Button, { color: "success", icon: "SiWhatsapp", onClick: handleClick, children });
751
+ return /* @__PURE__ */ jsx15(Button, { color: "success", icon: "SiWhatsapp", onClick: handleClick, children });
727
752
  };
728
753
 
729
754
  // core/heading/heading.const.ts
@@ -737,8 +762,8 @@ var headingTags = {
737
762
  };
738
763
 
739
764
  // core/heading/heading.styles.ts
740
- import { tv as tv9 } from "tailwind-variants";
741
- var heading = tv9({
765
+ import { tv as tv11 } from "tailwind-variants";
766
+ var heading = tv11({
742
767
  variants: {
743
768
  level: {
744
769
  1: "text-3xl font-bold",
@@ -763,35 +788,10 @@ var heading = tv9({
763
788
  });
764
789
 
765
790
  // core/heading/heading.tsx
766
- import { jsx as jsx15 } from "react/jsx-runtime";
791
+ import { jsx as jsx16 } from "react/jsx-runtime";
767
792
  var Heading = ({ children, level = 1, color }) => {
768
793
  const Tag2 = headingTags[level];
769
- return /* @__PURE__ */ jsx15(Tag2, { className: heading({ level, color }), children });
770
- };
771
-
772
- // core/text/text.styles.ts
773
- import { tv as tv10 } from "tailwind-variants";
774
- var text = tv10({
775
- variants: {
776
- variant: {
777
- body: "text-base",
778
- caption: "text-sm",
779
- display: "text-3xl font-bold"
780
- }
781
- },
782
- defaultVariants: {
783
- variant: "body"
784
- }
785
- });
786
-
787
- // core/text/text.tsx
788
- import { jsx as jsx16 } from "react/jsx-runtime";
789
- var Text = ({
790
- children,
791
- as: Tag2 = "p",
792
- variant = "body"
793
- }) => {
794
- return /* @__PURE__ */ jsx16(Tag2, { "data-testid": "text", className: text({ variant }), children });
794
+ return /* @__PURE__ */ jsx16(Tag2, { className: heading({ level, color }), children });
795
795
  };
796
796
 
797
797
  // core/sidebar/sidebar.tsx
@@ -799,8 +799,8 @@ import { useState as useState3 } from "react";
799
799
  import Link from "next/link";
800
800
 
801
801
  // core/sidebar/sidebar.styles.ts
802
- import { tv as tv11 } from "tailwind-variants";
803
- var sidebar = tv11({
802
+ import { tv as tv12 } from "tailwind-variants";
803
+ var sidebar = tv12({
804
804
  base: "h-screen bg-neutral-800 text-neutral-300 flex flex-col overflow-hidden transition-all duration-200",
805
805
  variants: {
806
806
  collapsed: {
@@ -812,16 +812,16 @@ var sidebar = tv11({
812
812
  collapsed: false
813
813
  }
814
814
  });
815
- var nav = tv11({
815
+ var nav = tv12({
816
816
  base: "flex-1 min-h-0 overflow-y-auto overflow-x-hidden"
817
817
  });
818
- var header2 = tv11({
818
+ var header2 = tv12({
819
819
  base: "shrink-0 border-b border-neutral-600/50 grid p-2"
820
820
  });
821
- var section = tv11({
821
+ var section = tv12({
822
822
  base: "border-b border-neutral-600/50 last:border-b-0 grid gap-1 p-2"
823
823
  });
824
- var item = tv11({
824
+ var item = tv12({
825
825
  base: "flex w-full items-center rounded-md text-sm whitespace-nowrap transition-colors cursor-pointer p-1",
826
826
  variants: {
827
827
  active: {
@@ -833,10 +833,10 @@ var item = tv11({
833
833
  active: false
834
834
  }
835
835
  });
836
- var itemIcon = tv11({
836
+ var itemIcon = tv12({
837
837
  base: "p-2"
838
838
  });
839
- var itemLabel = tv11({
839
+ var itemLabel = tv12({
840
840
  base: "truncate transition-all duration-200",
841
841
  variants: {
842
842
  collapsed: {
@@ -848,22 +848,22 @@ var itemLabel = tv11({
848
848
  collapsed: false
849
849
  }
850
850
  });
851
- var footer = tv11({
851
+ var footer = tv12({
852
852
  base: "shrink-0 border-t border-neutral-600/50 p-3 flex items-center gap-3 whitespace-nowrap"
853
853
  });
854
- var avatar = tv11({
854
+ var avatar = tv12({
855
855
  base: "shrink-0 w-8 h-8 rounded-full bg-neutral-600 text-white text-xs font-medium flex items-center justify-center"
856
856
  });
857
- var userInfo = tv11({
857
+ var userInfo = tv12({
858
858
  base: "flex flex-col min-w-0"
859
859
  });
860
- var userName = tv11({
860
+ var userName = tv12({
861
861
  base: "text-sm text-white truncate"
862
862
  });
863
- var userEmail = tv11({
863
+ var userEmail = tv12({
864
864
  base: "text-xs text-neutral-400"
865
865
  });
866
- var toggleButton = tv11({
866
+ var toggleButton = tv12({
867
867
  base: "shrink-0 border-t border-neutral-600/50 grid p-2 [&>button]:justify-start [&>button]:overflow-hidden [&>button]:whitespace-nowrap"
868
868
  });
869
869
 
@@ -1223,22 +1223,26 @@ var ConnectedModal = ({
1223
1223
  );
1224
1224
  };
1225
1225
 
1226
- // core/spinner/spinner.tsx
1227
- import { LoaderCircle } from "lucide-react";
1226
+ // core/spinner/spinner.const.ts
1227
+ var spinnerIcons = {
1228
+ circle: "LoaderCircle",
1229
+ dots: "Loader",
1230
+ refresh: "RefreshCw"
1231
+ };
1228
1232
 
1229
1233
  // core/spinner/spinner.styles.ts
1230
- import { tv as tv12 } from "tailwind-variants";
1231
- var spinner = tv12({
1232
- base: "animate-spin w-20 h-20 text-white stroke-[0.3]"
1234
+ import { tv as tv13 } from "tailwind-variants";
1235
+ var spinner = tv13({
1236
+ base: "inline-flex animate-spin text-white"
1233
1237
  });
1234
1238
 
1235
1239
  // core/spinner/spinner.tsx
1236
1240
  import { jsx as jsx22 } from "react/jsx-runtime";
1237
- var Spinner = ({ className }) => /* @__PURE__ */ jsx22(LoaderCircle, { className: spinner({ className }), strokeWidth: 1 });
1241
+ var Spinner = ({ variant = "circle", size = "md" }) => /* @__PURE__ */ jsx22("span", { "data-testid": "spinner", className: spinner(), children: /* @__PURE__ */ jsx22(Icon, { name: spinnerIcons[variant], size }) });
1238
1242
 
1239
1243
  // core/loader/loader.styles.ts
1240
- import { tv as tv13 } from "tailwind-variants";
1241
- var overlay2 = tv13({
1244
+ import { tv as tv14 } from "tailwind-variants";
1245
+ var overlay2 = tv14({
1242
1246
  base: "flex fixed justify-center items-center w-full h-full bg-black/20 z-50"
1243
1247
  });
1244
1248
 
@@ -1247,7 +1251,7 @@ import { jsx as jsx23 } from "react/jsx-runtime";
1247
1251
  var Loader = ({ label: label5 = "Loading" }) => {
1248
1252
  const fetching = useAppStore((s) => s.fetching);
1249
1253
  if (!fetching) return null;
1250
- return /* @__PURE__ */ jsx23("div", { role: "status", "aria-label": label5, className: overlay2(), children: /* @__PURE__ */ jsx23(Spinner, {}) });
1254
+ return /* @__PURE__ */ jsx23("div", { role: "status", "aria-label": label5, className: overlay2(), children: /* @__PURE__ */ jsx23(Spinner, { size: "lg" }) });
1251
1255
  };
1252
1256
 
1253
1257
  // core/app-wrapper/app-wrapper.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexandregme/zljs",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",