@aortl/admin-react 0.1.0 → 0.3.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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { clsx } from "clsx";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { Children, Fragment as Fragment$1, createContext, createElement, isValidElement, useContext, useMemo, useState } from "react";
3
+ import { Children, Fragment as Fragment$1, createContext, createElement, isValidElement, useContext, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { Button as Button$1 } from "@base-ui/react/button";
5
5
  import { Input as Input$1 } from "@base-ui/react/input";
6
6
  import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
@@ -10,7 +10,8 @@ import { Switch as Switch$1 } from "@base-ui/react/switch";
10
10
  import { Select as Select$1 } from "@base-ui/react/select";
11
11
  import { Field as Field$1 } from "@base-ui/react/field";
12
12
  import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
13
- import { Dialog } from "@base-ui/react/dialog";
13
+ import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
14
+ import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
14
15
  //#region src/Accordion.tsx
15
16
  function AccordionRoot({ className, ...rest }) {
16
17
  return /* @__PURE__ */ jsx("div", {
@@ -711,6 +712,131 @@ var Card = Object.assign(CardRoot, {
711
712
  Actions: CardActions
712
713
  });
713
714
  //#endregion
715
+ //#region src/Dialog.tsx
716
+ var DialogContext = createContext(null);
717
+ function DefaultCloseIcon() {
718
+ return /* @__PURE__ */ jsxs("svg", {
719
+ width: "16",
720
+ height: "16",
721
+ viewBox: "0 0 24 24",
722
+ fill: "none",
723
+ stroke: "currentColor",
724
+ strokeWidth: "2",
725
+ strokeLinecap: "round",
726
+ strokeLinejoin: "round",
727
+ "aria-hidden": "true",
728
+ children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
729
+ });
730
+ }
731
+ /**
732
+ * The bare `<dialog>` primitive — no opinions about header, body, or footer.
733
+ * Use this when the default `<Dialog>` layout doesn't fit (custom header,
734
+ * media block, multi-step content).
735
+ */
736
+ function DialogContainer({ open, onOpenChange, size = "md", closedby = "any", className, children, ...rest }) {
737
+ const ref = useRef(null);
738
+ const onOpenChangeRef = useRef(onOpenChange);
739
+ onOpenChangeRef.current = onOpenChange;
740
+ useEffect(() => {
741
+ const el = ref.current;
742
+ if (!el || open === void 0) return;
743
+ if (open && !el.open) el.showModal();
744
+ else if (!open && el.open) el.close();
745
+ }, [open]);
746
+ useEffect(() => {
747
+ const el = ref.current;
748
+ if (!el) return;
749
+ const handleClose = () => onOpenChangeRef.current?.(false);
750
+ el.addEventListener("close", handleClose);
751
+ return () => el.removeEventListener("close", handleClose);
752
+ }, []);
753
+ return /* @__PURE__ */ jsx(DialogContext.Provider, {
754
+ value: { close: () => ref.current?.close() },
755
+ children: /* @__PURE__ */ jsx("dialog", {
756
+ ref,
757
+ className: clsx("dialog", size !== "md" && `dialog-${size}`, className),
758
+ closedby,
759
+ ...rest,
760
+ children
761
+ })
762
+ });
763
+ }
764
+ function DialogHeader({ className, ...rest }) {
765
+ return /* @__PURE__ */ jsx("div", {
766
+ className: clsx("dialog-header", className),
767
+ ...rest
768
+ });
769
+ }
770
+ function DialogTitle({ icon, className, children, ...rest }) {
771
+ return /* @__PURE__ */ jsxs("h2", {
772
+ className: clsx("dialog-title", className),
773
+ ...rest,
774
+ children: [renderIcon(icon), children]
775
+ });
776
+ }
777
+ function DialogDescription({ className, ...rest }) {
778
+ return /* @__PURE__ */ jsx("p", {
779
+ className: clsx("dialog-description", className),
780
+ ...rest
781
+ });
782
+ }
783
+ function DialogBody({ className, ...rest }) {
784
+ return /* @__PURE__ */ jsx("div", {
785
+ className: clsx("dialog-body", className),
786
+ ...rest
787
+ });
788
+ }
789
+ function DialogFooter({ className, ...rest }) {
790
+ return /* @__PURE__ */ jsx("div", {
791
+ className: clsx("dialog-footer", className),
792
+ ...rest
793
+ });
794
+ }
795
+ function DialogCloseButton({ icon, className, children, onClick, type = "button", "aria-label": ariaLabel = "Close", ...rest }) {
796
+ const ctx = useContext(DialogContext);
797
+ return /* @__PURE__ */ jsx("button", {
798
+ type,
799
+ className: clsx("dialog-close", className),
800
+ "aria-label": ariaLabel,
801
+ onClick: (event) => {
802
+ onClick?.(event);
803
+ if (!event.defaultPrevented) ctx?.close();
804
+ },
805
+ ...rest,
806
+ children: children ?? (icon !== void 0 ? renderIcon(icon) : /* @__PURE__ */ jsx(DefaultCloseIcon, {}))
807
+ });
808
+ }
809
+ /**
810
+ * Standard modal: a `<dialog>` with an opinionated header / body / footer
811
+ * layout driven by shorthand props. For anything outside that shape, use
812
+ * `<Dialog.Container>` and compose by hand.
813
+ */
814
+ function DialogRoot({ icon, title, description, actions, dismissible = true, closeLabel = "Close", children, ...containerProps }) {
815
+ const hasTitle = title !== void 0 || icon !== void 0;
816
+ const showHeader = hasTitle || dismissible;
817
+ return /* @__PURE__ */ jsxs(DialogContainer, {
818
+ ...containerProps,
819
+ children: [
820
+ showHeader ? /* @__PURE__ */ jsxs(DialogHeader, { children: [hasTitle ? /* @__PURE__ */ jsx(DialogTitle, {
821
+ icon,
822
+ children: title
823
+ }) : /* @__PURE__ */ jsx("span", { className: "flex-1" }), dismissible ? /* @__PURE__ */ jsx(DialogCloseButton, { "aria-label": closeLabel }) : null] }) : null,
824
+ description !== void 0 ? /* @__PURE__ */ jsx(DialogDescription, { children: description }) : null,
825
+ children !== void 0 ? /* @__PURE__ */ jsx(DialogBody, { children }) : null,
826
+ actions !== void 0 ? /* @__PURE__ */ jsx(DialogFooter, { children: actions }) : null
827
+ ]
828
+ });
829
+ }
830
+ var Dialog = Object.assign(DialogRoot, {
831
+ Container: DialogContainer,
832
+ Header: DialogHeader,
833
+ Title: DialogTitle,
834
+ Description: DialogDescription,
835
+ Body: DialogBody,
836
+ Footer: DialogFooter,
837
+ CloseButton: DialogCloseButton
838
+ });
839
+ //#endregion
714
840
  //#region src/Field.tsx
715
841
  function FieldRoot({ className, ...rest }) {
716
842
  return /* @__PURE__ */ jsx(Field$1.Root, {
@@ -949,6 +1075,48 @@ var Tabs = Object.assign(TabsRoot, {
949
1075
  Indicator: TabsIndicator
950
1076
  });
951
1077
  //#endregion
1078
+ //#region src/Tooltip.tsx
1079
+ function TooltipProvider(props) {
1080
+ return /* @__PURE__ */ jsx(Tooltip$1.Provider, { ...props });
1081
+ }
1082
+ function TooltipRoot(props) {
1083
+ return /* @__PURE__ */ jsx(Tooltip$1.Root, { ...props });
1084
+ }
1085
+ function TooltipTrigger(props) {
1086
+ return /* @__PURE__ */ jsx(Tooltip$1.Trigger, { ...props });
1087
+ }
1088
+ function TooltipPopup({ size = "md", side = "top", align = "center", sideOffset = 6, role = "tooltip", className, children, ...rest }) {
1089
+ return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsx(Tooltip$1.Positioner, {
1090
+ sideOffset,
1091
+ side,
1092
+ align,
1093
+ children: /* @__PURE__ */ jsx(Tooltip$1.Popup, {
1094
+ role,
1095
+ className: cn(["tooltip", size !== "md" && `tooltip-${size}`], className),
1096
+ ...rest,
1097
+ children
1098
+ })
1099
+ }) });
1100
+ }
1101
+ function TooltipShorthand({ content, side, align, sideOffset, size, children, ...rootProps }) {
1102
+ return /* @__PURE__ */ jsxs(TooltipRoot, {
1103
+ ...rootProps,
1104
+ children: [/* @__PURE__ */ jsx(Tooltip$1.Trigger, { render: children }), /* @__PURE__ */ jsx(TooltipPopup, {
1105
+ side,
1106
+ align,
1107
+ sideOffset,
1108
+ size,
1109
+ children: content
1110
+ })]
1111
+ });
1112
+ }
1113
+ var Tooltip = Object.assign(TooltipShorthand, {
1114
+ Provider: TooltipProvider,
1115
+ Root: TooltipRoot,
1116
+ Trigger: TooltipTrigger,
1117
+ Popup: TooltipPopup
1118
+ });
1119
+ //#endregion
952
1120
  //#region src/Table.tsx
953
1121
  function TableRoot({ striped, bordered, relaxed, sticky, className, ...rest }) {
954
1122
  return /* @__PURE__ */ jsx("table", {
@@ -1020,10 +1188,10 @@ function SidebarRoot({ collapsed, defaultCollapsed, onCollapsedChange, drawerLab
1020
1188
  className: clsx("sidebar", className),
1021
1189
  ...rest,
1022
1190
  children: drawerOpen ? null : children
1023
- }), shell ? /* @__PURE__ */ jsx(Dialog.Root, {
1191
+ }), shell ? /* @__PURE__ */ jsx(Dialog$1.Root, {
1024
1192
  open: drawerOpen,
1025
1193
  onOpenChange: (open) => shell.setMobileDrawerOpen(open),
1026
- children: /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { className: "sidebar-drawer-backdrop" }), /* @__PURE__ */ jsx(Dialog.Popup, {
1194
+ children: /* @__PURE__ */ jsxs(Dialog$1.Portal, { children: [/* @__PURE__ */ jsx(Dialog$1.Backdrop, { className: "sidebar-drawer-backdrop" }), /* @__PURE__ */ jsx(Dialog$1.Popup, {
1027
1195
  className: "sidebar-drawer",
1028
1196
  "aria-label": drawerLabel,
1029
1197
  onClick: (event) => {
@@ -1168,6 +1336,6 @@ var Sidebar = Object.assign(SidebarRoot, {
1168
1336
  CollapseToggle: SidebarCollapseToggle
1169
1337
  });
1170
1338
  //#endregion
1171
- export { Accordion, AdminRoot, Alert, AppShell, Badge, BrandTile, Breadcrumbs, Button, ButtonGroup, Card, Checkbox, Field, FileInput, Footer, Input, InputGroup, Menu, Navbar, Pagination, Progress, Radio, RadioGroup, Select, Sidebar, Spinner, Switch, Table, Tabs, Textarea, getPaginationItems, useAppShell };
1339
+ export { Accordion, AdminRoot, Alert, AppShell, Badge, BrandTile, Breadcrumbs, Button, ButtonGroup, Card, Checkbox, Dialog, Field, FileInput, Footer, Input, InputGroup, Menu, Navbar, Pagination, Progress, Radio, RadioGroup, Select, Sidebar, Spinner, Switch, Table, Tabs, Textarea, Tooltip, getPaginationItems, useAppShell };
1172
1340
 
1173
1341
  //# sourceMappingURL=index.mjs.map