@dimaan/ui 0.0.0 → 0.0.2

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.cjs CHANGED
@@ -557,18 +557,11 @@ function SidebarNavItem({
557
557
  }
558
558
  );
559
559
  }
560
- function isSection(entry) {
561
- return "items" in entry && !("label" in entry && "href" in entry) && Array.isArray(entry.items);
562
- }
563
560
  function isGroup(entry) {
564
- return "items" in entry;
565
- }
566
- function normalize(nav) {
567
- if (nav.length === 0) return [];
568
- if (isSection(nav[0])) return nav;
569
- return [{ key: "__root", items: nav }];
561
+ return "items" in entry && Array.isArray(entry.items);
570
562
  }
571
- function renderItem(item) {
563
+ function renderItem(item, fallbackKey) {
564
+ const key = item.key ?? fallbackKey;
572
565
  if (item.render) {
573
566
  return /* @__PURE__ */ jsxRuntime.jsx(
574
567
  SidebarNavItem,
@@ -579,7 +572,7 @@ function renderItem(item) {
579
572
  render: item.render,
580
573
  children: item.label
581
574
  },
582
- item.key
575
+ key
583
576
  );
584
577
  }
585
578
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -591,7 +584,7 @@ function renderItem(item) {
591
584
  endSlot: item.endSlot,
592
585
  children: item.label
593
586
  },
594
- item.key
587
+ key
595
588
  );
596
589
  }
597
590
  function AppShell({
@@ -607,7 +600,6 @@ function AppShell({
607
600
  onCollapsedChange,
608
601
  children
609
602
  }) {
610
- const sections = normalize(nav);
611
603
  return /* @__PURE__ */ jsxRuntime.jsxs(
612
604
  DashboardLayout,
613
605
  {
@@ -620,19 +612,19 @@ function AppShell({
620
612
  brand.logo,
621
613
  brand.name ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-semibold", children: brand.name }) : null
622
614
  ] }),
623
- /* @__PURE__ */ jsxRuntime.jsx(SidebarNav, { children: sections.map((section) => /* @__PURE__ */ jsxRuntime.jsx(SidebarGroup, { label: section.label, children: section.items.map(
624
- (entry) => isGroup(entry) ? /* @__PURE__ */ jsxRuntime.jsx(
615
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarNav, { children: nav.map(
616
+ (entry, index) => isGroup(entry) ? /* @__PURE__ */ jsxRuntime.jsx(
625
617
  SidebarNavGroup,
626
618
  {
627
619
  label: entry.label,
628
620
  icon: entry.icon,
629
621
  active: entry.active,
630
622
  defaultOpen: entry.defaultOpen ?? entry.items.some((i) => i.active),
631
- children: entry.items.map(renderItem)
623
+ children: entry.items.map((item, itemIndex) => renderItem(item, itemIndex))
632
624
  },
633
- entry.key
634
- ) : renderItem(entry)
635
- ) }, section.key)) }),
625
+ entry.key ?? index
626
+ ) : renderItem(entry, index)
627
+ ) }),
636
628
  sidebarFooter ? /* @__PURE__ */ jsxRuntime.jsx(SidebarFooter, { children: sidebarFooter }) : null
637
629
  ] }),
638
630
  /* @__PURE__ */ jsxRuntime.jsxs(DashboardMain, { children: [
@@ -752,6 +744,140 @@ var Checkbox = react.forwardRef(function Checkbox2({
752
744
  )
753
745
  ] });
754
746
  });
747
+
748
+ // src/components/input/inputVariants.ts
749
+ var inputVariantClass = {
750
+ default: "border border-input bg-background hover:border-ring",
751
+ filled: "border border-transparent bg-muted hover:bg-muted/80",
752
+ ghost: "border border-transparent bg-transparent hover:bg-accent"
753
+ };
754
+ var inputSizeClass = {
755
+ sm: "h-8 rounded-md px-2.5 text-sm gap-1.5",
756
+ md: "h-9 rounded-md px-3 text-sm gap-2",
757
+ lg: "h-11 rounded-md px-4 text-base gap-2.5"
758
+ };
759
+ var inputBaseClass = "group/input relative inline-flex w-full items-center text-foreground outline-none transition-[background-color,border-color,box-shadow] focus-within:ring-2 focus-within:ring-ring/40 focus-within:ring-offset-1 focus-within:ring-offset-background aria-[invalid=true]:border-destructive aria-[invalid=true]:focus-within:ring-destructive/40 has-[input:disabled]:pointer-events-none has-[input:disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0";
760
+ var Input = react.forwardRef(function Input2({
761
+ variant = "default",
762
+ inputSize = "md",
763
+ label,
764
+ helperText,
765
+ error,
766
+ leadingIcon,
767
+ trailingIcon,
768
+ fullWidth = true,
769
+ type = "text",
770
+ id,
771
+ className,
772
+ wrapperClassName,
773
+ containerClassName,
774
+ "aria-invalid": ariaInvalidProp,
775
+ "aria-describedby": ariaDescribedByProp,
776
+ disabled,
777
+ ...props
778
+ }, ref) {
779
+ const generatedId = react.useId();
780
+ const inputId = id ?? generatedId;
781
+ const helperId = `${inputId}-helper`;
782
+ const errorId = `${inputId}-error`;
783
+ const hasError = error !== void 0 && error !== null && error !== false;
784
+ const ariaInvalid = ariaInvalidProp ?? (hasError ? true : void 0);
785
+ const describedByIds = [
786
+ ariaDescribedByProp,
787
+ hasError ? errorId : null,
788
+ !hasError && helperText ? helperId : null
789
+ ].filter(Boolean).join(" ");
790
+ const ariaDescribedBy = describedByIds.length > 0 ? describedByIds : void 0;
791
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1.5", fullWidth && "w-full", containerClassName), children: [
792
+ label !== void 0 && label !== null && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: inputId, className: "text-sm font-medium text-foreground select-none", children: label }),
793
+ /* @__PURE__ */ jsxRuntime.jsxs(
794
+ "div",
795
+ {
796
+ "data-slot": "input-wrapper",
797
+ className: cn(
798
+ inputBaseClass,
799
+ inputVariantClass[variant],
800
+ inputSizeClass[inputSize],
801
+ wrapperClassName
802
+ ),
803
+ "aria-invalid": ariaInvalid,
804
+ "data-disabled": disabled ? "true" : void 0,
805
+ children: [
806
+ leadingIcon ? /* @__PURE__ */ jsxRuntime.jsx(
807
+ "span",
808
+ {
809
+ "aria-hidden": "true",
810
+ className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
811
+ children: leadingIcon
812
+ }
813
+ ) : null,
814
+ /* @__PURE__ */ jsxRuntime.jsx(
815
+ "input",
816
+ {
817
+ ref,
818
+ id: inputId,
819
+ type,
820
+ disabled,
821
+ "aria-invalid": ariaInvalid,
822
+ "aria-describedby": ariaDescribedBy,
823
+ className: cn(
824
+ "h-full w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
825
+ className
826
+ ),
827
+ ...props
828
+ }
829
+ ),
830
+ trailingIcon ? /* @__PURE__ */ jsxRuntime.jsx(
831
+ "span",
832
+ {
833
+ "aria-hidden": "true",
834
+ className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
835
+ children: trailingIcon
836
+ }
837
+ ) : null
838
+ ]
839
+ }
840
+ ),
841
+ hasError ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: errorId, className: "text-xs text-destructive", children: error }) : helperText ? /* @__PURE__ */ jsxRuntime.jsx("p", { id: helperId, className: "text-xs text-muted-foreground", children: helperText }) : null
842
+ ] });
843
+ });
844
+ function LanguageSwitcher({
845
+ languages,
846
+ value,
847
+ onChange,
848
+ ariaLabel = "Language",
849
+ className,
850
+ ...props
851
+ }) {
852
+ return /* @__PURE__ */ jsxRuntime.jsx(
853
+ "fieldset",
854
+ {
855
+ "aria-label": ariaLabel,
856
+ className: cn(
857
+ "inline-flex items-center rounded-md border border-border bg-background p-0.5 text-xs",
858
+ className
859
+ ),
860
+ ...props,
861
+ children: languages.map((lang) => {
862
+ const isActive = lang.code === value;
863
+ return /* @__PURE__ */ jsxRuntime.jsx(
864
+ "button",
865
+ {
866
+ type: "button",
867
+ onClick: () => onChange(lang.code),
868
+ "aria-pressed": isActive,
869
+ className: cn(
870
+ "rounded px-2 py-1 font-medium transition-colors",
871
+ isActive ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground"
872
+ ),
873
+ children: lang.label ?? lang.code.toUpperCase()
874
+ },
875
+ lang.code
876
+ );
877
+ })
878
+ }
879
+ );
880
+ }
755
881
  function readDocumentDirection() {
756
882
  if (typeof document === "undefined") return "ltr";
757
883
  const dir = document.documentElement.getAttribute("dir");
@@ -1273,6 +1399,8 @@ exports.HeaderCollapseTrigger = HeaderCollapseTrigger;
1273
1399
  exports.HeaderMobileTrigger = HeaderMobileTrigger;
1274
1400
  exports.HeaderSearch = HeaderSearch;
1275
1401
  exports.HeaderTitle = HeaderTitle;
1402
+ exports.Input = Input;
1403
+ exports.LanguageSwitcher = LanguageSwitcher;
1276
1404
  exports.Sidebar = Sidebar;
1277
1405
  exports.SidebarFooter = SidebarFooter;
1278
1406
  exports.SidebarGroup = SidebarGroup;
@@ -1285,6 +1413,9 @@ exports.buttonBaseClass = buttonBaseClass;
1285
1413
  exports.buttonSizeClass = buttonSizeClass;
1286
1414
  exports.buttonVariantClass = buttonVariantClass;
1287
1415
  exports.cn = cn;
1416
+ exports.inputBaseClass = inputBaseClass;
1417
+ exports.inputSizeClass = inputSizeClass;
1418
+ exports.inputVariantClass = inputVariantClass;
1288
1419
  exports.tableAlignClass = alignClass;
1289
1420
  exports.tableBaseClass = tableBaseClass;
1290
1421
  exports.tableSelectedRowClass = selectedRowClass;