@fea-ui/react 0.1.0-alpha.3 → 0.1.0-alpha.6

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,8 +1,8 @@
1
1
  import { cn, cn as cn$1, tv } from "tailwind-variants";
2
- import { Accordion, AlertDialog, Avatar, Button, Checkbox, CheckboxGroup, Dialog, Field, Input, Menu, Meter, Progress, Separator, Slider, Switch, Tabs, Toggle } from "@base-ui/react";
2
+ import { Accordion, AlertDialog, Avatar, Button, Checkbox, CheckboxGroup, Dialog, Field, Fieldset, Input, Menu, Meter, Progress, Separator, Slider, Switch, Tabs, Toggle } from "@base-ui/react";
3
3
  import { LucideCheck, LucideChevronDown, LucideMenu, LucideX } from "lucide-react";
4
4
  import React, { createContext, useCallback, useContext, useMemo, useState } from "react";
5
- import { jsx } from "react/jsx-runtime";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
6
 
7
7
  //#region src/components/accordion/accordion.context.ts
8
8
  const AccordionContext = createContext(null);
@@ -605,6 +605,117 @@ Dialog$1.Trigger = DialogTrigger;
605
605
  Dialog$1.Viewport = DialogViewport;
606
606
  var dialog_default = Dialog$1;
607
607
 
608
+ //#endregion
609
+ //#region src/components/drawer/drawer.context.ts
610
+ const DrawerContext = createContext(null);
611
+
612
+ //#endregion
613
+ //#region src/components/drawer/drawer.variants.ts
614
+ const drawerVariants = tv({
615
+ defaultVariants: { position: "left" },
616
+ slots: {
617
+ backdrop: "drawer__backdrop",
618
+ close: "drawer__close",
619
+ description: "drawer__description",
620
+ popup: "drawer__popup",
621
+ portal: "drawer__portal",
622
+ root: "drawer",
623
+ title: "drawer__title",
624
+ trigger: "drawer__trigger",
625
+ viewport: "drawer__viewport"
626
+ },
627
+ variants: { position: {
628
+ bottom: { popup: "drawer--bottom" },
629
+ left: { popup: "drawer--left" },
630
+ right: { popup: "drawer--right" },
631
+ top: { popup: "drawer--top" }
632
+ } }
633
+ });
634
+
635
+ //#endregion
636
+ //#region src/components/drawer/use-drawer.ts
637
+ const useDrawer = () => {
638
+ const context = useContext(DrawerContext);
639
+ if (!context) throw new Error("useDrawer must be used within a DrawerProvider");
640
+ return context;
641
+ };
642
+
643
+ //#endregion
644
+ //#region src/components/drawer/drawer.tsx
645
+ const Drawer = ({ position, ...props }) => {
646
+ return /* @__PURE__ */ jsx(DrawerContext, {
647
+ value: { slots: useMemo(() => drawerVariants({ position }), [position]) },
648
+ children: /* @__PURE__ */ jsx(Dialog.Root, { ...props })
649
+ });
650
+ };
651
+ const DrawerTrigger = ({ className, ...props }) => {
652
+ const { slots } = useDrawer();
653
+ return /* @__PURE__ */ jsx(Dialog.Trigger, {
654
+ className: cn$1(slots.trigger(), className),
655
+ ...props
656
+ });
657
+ };
658
+ const DrawerPortal = ({ className, ...props }) => {
659
+ const { slots } = useDrawer();
660
+ return /* @__PURE__ */ jsx(Dialog.Portal, {
661
+ className: cn$1(slots.portal(), className),
662
+ ...props
663
+ });
664
+ };
665
+ const DrawerBackdrop = ({ className, ...props }) => {
666
+ const { slots } = useDrawer();
667
+ return /* @__PURE__ */ jsx(Dialog.Backdrop, {
668
+ className: cn$1(slots.backdrop(), className),
669
+ ...props
670
+ });
671
+ };
672
+ const DrawerViewport = ({ className, ...props }) => {
673
+ const { slots } = useDrawer();
674
+ return /* @__PURE__ */ jsx(Dialog.Viewport, {
675
+ className: cn$1(slots.viewport(), className),
676
+ ...props
677
+ });
678
+ };
679
+ const DrawerPopup = ({ className, ...props }) => {
680
+ const { slots } = useDrawer();
681
+ return /* @__PURE__ */ jsx(Dialog.Popup, {
682
+ className: cn$1(slots.popup(), className),
683
+ ...props
684
+ });
685
+ };
686
+ const DrawerTitle = ({ className, ...props }) => {
687
+ const { slots } = useDrawer();
688
+ return /* @__PURE__ */ jsx(Dialog.Title, {
689
+ className: cn$1(slots.title(), className),
690
+ ...props
691
+ });
692
+ };
693
+ const DrawerDescription = ({ className, ...props }) => {
694
+ const { slots } = useDrawer();
695
+ return /* @__PURE__ */ jsx(Dialog.Description, {
696
+ className: cn$1(slots.description(), className),
697
+ ...props
698
+ });
699
+ };
700
+ const DrawerClose = ({ className, children, ...props }) => {
701
+ const { slots } = useDrawer();
702
+ return /* @__PURE__ */ jsx(Dialog.Close, {
703
+ className: cn$1(slots.close(), className),
704
+ ...props,
705
+ children: children ?? /* @__PURE__ */ jsx(LucideX, {})
706
+ });
707
+ };
708
+ Drawer.Root = Drawer;
709
+ Drawer.Trigger = DrawerTrigger;
710
+ Drawer.Portal = DrawerPortal;
711
+ Drawer.Backdrop = DrawerBackdrop;
712
+ Drawer.Viewport = DrawerViewport;
713
+ Drawer.Popup = DrawerPopup;
714
+ Drawer.Title = DrawerTitle;
715
+ Drawer.Description = DrawerDescription;
716
+ Drawer.Close = DrawerClose;
717
+ var drawer_default = Drawer;
718
+
608
719
  //#endregion
609
720
  //#region src/components/field/field.context.ts
610
721
  const FieldContext = createContext(null);
@@ -682,6 +793,48 @@ Field$1.Label = FieldLabel;
682
793
  Field$1.Root = Field$1;
683
794
  var field_default = Field$1;
684
795
 
796
+ //#endregion
797
+ //#region src/components/fieldset/fieldset.context.ts
798
+ const FieldsetContext = createContext(null);
799
+
800
+ //#endregion
801
+ //#region src/components/fieldset/fieldset.variants.ts
802
+ const fieldsetVariants = tv({ slots: {
803
+ legend: "fieldset__legend",
804
+ root: "fieldset"
805
+ } });
806
+
807
+ //#endregion
808
+ //#region src/components/fieldset/use-fieldset.ts
809
+ const useFieldset = () => {
810
+ const context = useContext(FieldsetContext);
811
+ if (!context) throw new Error("useFieldset must be used within a FieldsetProvider");
812
+ return context;
813
+ };
814
+
815
+ //#endregion
816
+ //#region src/components/fieldset/fieldset.tsx
817
+ const Fieldset$1 = ({ className, ...props }) => {
818
+ const slots = useMemo(() => fieldsetVariants(), []);
819
+ return /* @__PURE__ */ jsx(FieldsetContext, {
820
+ value: { slots },
821
+ children: /* @__PURE__ */ jsx(Fieldset.Root, {
822
+ className: cn$1(className, slots.root()),
823
+ ...props
824
+ })
825
+ });
826
+ };
827
+ const FieldsetLegend = ({ className, ...props }) => {
828
+ const { slots } = useFieldset();
829
+ return /* @__PURE__ */ jsx(Fieldset.Legend, {
830
+ className: cn$1(slots.legend(), className),
831
+ ...props
832
+ });
833
+ };
834
+ Fieldset$1.Root = Fieldset$1;
835
+ Fieldset$1.Legend = FieldsetLegend;
836
+ var fieldset_default = Fieldset$1;
837
+
685
838
  //#endregion
686
839
  //#region src/components/form/form.variants.ts
687
840
  const formVariants = tv({ base: "form" });
@@ -1042,6 +1195,27 @@ Meter$1.Track = MeterTrack;
1042
1195
  Meter$1.Value = MeterValue;
1043
1196
  var meter_default = Meter$1;
1044
1197
 
1198
+ //#endregion
1199
+ //#region src/components/separator/separator.variants.ts
1200
+ const separatorVariants = tv({
1201
+ base: "separator",
1202
+ defaultVariants: { orientation: "horizontal" },
1203
+ variants: { orientation: {
1204
+ horizontal: "separator--horizontal",
1205
+ vertical: "separator--vertical"
1206
+ } }
1207
+ });
1208
+
1209
+ //#endregion
1210
+ //#region src/components/separator/separator.tsx
1211
+ const Separator$1 = ({ className, orientation, ...props }) => {
1212
+ return /* @__PURE__ */ jsx(Separator, {
1213
+ className: cn$1(className, separatorVariants({ orientation })),
1214
+ ...props
1215
+ });
1216
+ };
1217
+ var separator_default = Separator$1;
1218
+
1045
1219
  //#endregion
1046
1220
  //#region src/components/navbar/navbar.context.ts
1047
1221
  const NavbarContext = createContext(null);
@@ -1127,12 +1301,20 @@ const NavbarToggle = ({ className, ...props }) => {
1127
1301
  children: /* @__PURE__ */ jsx(Icon, { className: "size-5" })
1128
1302
  });
1129
1303
  };
1130
- const NavbarMenu = ({ className, ...props }) => {
1131
- const { slots, isOpen } = useNavbar();
1132
- return /* @__PURE__ */ jsx("ul", {
1133
- className: cn$1(slots.menu(), className),
1134
- "data-expanded": isOpen ? "true" : "false",
1135
- ...props
1304
+ const NavbarMenu = ({ className, header, ...props }) => {
1305
+ const { slots, isOpen, onOpenChange } = useNavbar();
1306
+ return /* @__PURE__ */ jsx(drawer_default, {
1307
+ onOpenChange,
1308
+ open: isOpen,
1309
+ children: /* @__PURE__ */ jsxs(drawer_default.Portal, { children: [/* @__PURE__ */ jsx(drawer_default.Backdrop, {}), /* @__PURE__ */ jsx(drawer_default.Viewport, { children: /* @__PURE__ */ jsxs(drawer_default.Popup, { children: [
1310
+ header,
1311
+ /* @__PURE__ */ jsx(drawer_default.Close, {}),
1312
+ /* @__PURE__ */ jsx(separator_default, {}),
1313
+ /* @__PURE__ */ jsx("ul", {
1314
+ className: cn$1(slots.menu(), className),
1315
+ ...props
1316
+ })
1317
+ ] }) })] })
1136
1318
  });
1137
1319
  };
1138
1320
  const NavbarMenuItem = ({ className, ...props }) => {
@@ -1221,27 +1403,6 @@ Progress$1.Indicator = ProgressIndicator;
1221
1403
  Progress$1.Root = Progress$1;
1222
1404
  var progress_default = Progress$1;
1223
1405
 
1224
- //#endregion
1225
- //#region src/components/separator/separator.variants.ts
1226
- const separatorVariants = tv({
1227
- base: "separator",
1228
- defaultVariants: { orientation: "horizontal" },
1229
- variants: { orientation: {
1230
- horizontal: "separator--horizontal",
1231
- vertical: "separator--vertical"
1232
- } }
1233
- });
1234
-
1235
- //#endregion
1236
- //#region src/components/separator/separator.tsx
1237
- const Separator$1 = ({ className, orientation, ...props }) => {
1238
- return /* @__PURE__ */ jsx(Separator, {
1239
- className: cn$1(className, separatorVariants({ orientation })),
1240
- ...props
1241
- });
1242
- };
1243
- var separator_default = Separator$1;
1244
-
1245
1406
  //#endregion
1246
1407
  //#region src/components/slider/slider.context.ts
1247
1408
  const SliderContext = createContext(null);
@@ -1579,5 +1740,5 @@ const ToggleButton = ({ className, variant, size, ...props }) => {
1579
1740
  var toggle_button_default = ToggleButton;
1580
1741
 
1581
1742
  //#endregion
1582
- export { accordion_default as Accordion, alert_dialog_default as AlertDialog, avatar_default as Avatar, button_default as Button, button_group_default as ButtonGroup, card_default as Card, checkbox_default as Checkbox, checkbox_group_default as CheckboxGroup, chip_default as Chip, container_default as Container, dialog_default as Dialog, field_default as Field, form_default as Form, input_default as Input, label_default as Label, link_default as Link, list_default as List, menu_default as Menu, meter_default as Meter, navbar_default as Navbar, progress_default as Progress, separator_default as Separator, slider_default as Slider, switch_default as Switch, table_default as Table, tabs_default as Tabs, text_default as Text, textarea_default as Textarea, toggle_button_default as ToggleButton, accordionVariants, alertDialogVariants, avatarVariants, buttonGroupVariants, buttonVariants, cardVariants, checkboxGroupVariants, checkboxVariants, chipVariants, cn, containerVariants, dialogVariants, fieldVariants, formVariants, inputVariants, labelVariants, linkVariants, listVariants, menuVariants, meterVariants, navbarVariants, progressVariants, separatorVariants, sliderVariants, switchVariants, tableVariants, tabsVariants, textVariants, textareaVariants, toggleButtonVariants };
1743
+ export { accordion_default as Accordion, alert_dialog_default as AlertDialog, avatar_default as Avatar, button_default as Button, button_group_default as ButtonGroup, card_default as Card, checkbox_default as Checkbox, checkbox_group_default as CheckboxGroup, chip_default as Chip, container_default as Container, dialog_default as Dialog, drawer_default as Drawer, field_default as Field, fieldset_default as Fieldset, form_default as Form, input_default as Input, label_default as Label, link_default as Link, list_default as List, menu_default as Menu, meter_default as Meter, navbar_default as Navbar, progress_default as Progress, separator_default as Separator, slider_default as Slider, switch_default as Switch, table_default as Table, tabs_default as Tabs, text_default as Text, textarea_default as Textarea, toggle_button_default as ToggleButton, accordionVariants, alertDialogVariants, avatarVariants, buttonGroupVariants, buttonVariants, cardVariants, checkboxGroupVariants, checkboxVariants, chipVariants, cn, containerVariants, dialogVariants, drawerVariants, fieldVariants, fieldsetVariants, formVariants, inputVariants, labelVariants, linkVariants, listVariants, menuVariants, meterVariants, navbarVariants, progressVariants, separatorVariants, sliderVariants, switchVariants, tableVariants, tabsVariants, textVariants, textareaVariants, toggleButtonVariants };
1583
1744
  //# sourceMappingURL=index.mjs.map