@dimaan/ui 0.0.0 → 0.0.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.
package/dist/index.cjs CHANGED
@@ -752,6 +752,103 @@ var Checkbox = react.forwardRef(function Checkbox2({
752
752
  )
753
753
  ] });
754
754
  });
755
+
756
+ // src/components/input/inputVariants.ts
757
+ var inputVariantClass = {
758
+ default: "border border-input bg-background hover:border-ring",
759
+ filled: "border border-transparent bg-muted hover:bg-muted/80",
760
+ ghost: "border border-transparent bg-transparent hover:bg-accent"
761
+ };
762
+ var inputSizeClass = {
763
+ sm: "h-8 rounded-md px-2.5 text-sm gap-1.5",
764
+ md: "h-9 rounded-md px-3 text-sm gap-2",
765
+ lg: "h-11 rounded-md px-4 text-base gap-2.5"
766
+ };
767
+ 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";
768
+ var Input = react.forwardRef(function Input2({
769
+ variant = "default",
770
+ inputSize = "md",
771
+ label,
772
+ helperText,
773
+ error,
774
+ leadingIcon,
775
+ trailingIcon,
776
+ fullWidth = true,
777
+ type = "text",
778
+ id,
779
+ className,
780
+ wrapperClassName,
781
+ containerClassName,
782
+ "aria-invalid": ariaInvalidProp,
783
+ "aria-describedby": ariaDescribedByProp,
784
+ disabled,
785
+ ...props
786
+ }, ref) {
787
+ const generatedId = react.useId();
788
+ const inputId = id ?? generatedId;
789
+ const helperId = `${inputId}-helper`;
790
+ const errorId = `${inputId}-error`;
791
+ const hasError = error !== void 0 && error !== null && error !== false;
792
+ const ariaInvalid = ariaInvalidProp ?? (hasError ? true : void 0);
793
+ const describedByIds = [
794
+ ariaDescribedByProp,
795
+ hasError ? errorId : null,
796
+ !hasError && helperText ? helperId : null
797
+ ].filter(Boolean).join(" ");
798
+ const ariaDescribedBy = describedByIds.length > 0 ? describedByIds : void 0;
799
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1.5", fullWidth && "w-full", containerClassName), children: [
800
+ label !== void 0 && label !== null && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: inputId, className: "text-sm font-medium text-foreground select-none", children: label }),
801
+ /* @__PURE__ */ jsxRuntime.jsxs(
802
+ "div",
803
+ {
804
+ "data-slot": "input-wrapper",
805
+ className: cn(
806
+ inputBaseClass,
807
+ inputVariantClass[variant],
808
+ inputSizeClass[inputSize],
809
+ wrapperClassName
810
+ ),
811
+ "aria-invalid": ariaInvalid,
812
+ "data-disabled": disabled ? "true" : void 0,
813
+ children: [
814
+ leadingIcon ? /* @__PURE__ */ jsxRuntime.jsx(
815
+ "span",
816
+ {
817
+ "aria-hidden": "true",
818
+ className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
819
+ children: leadingIcon
820
+ }
821
+ ) : null,
822
+ /* @__PURE__ */ jsxRuntime.jsx(
823
+ "input",
824
+ {
825
+ ref,
826
+ id: inputId,
827
+ type,
828
+ disabled,
829
+ "aria-invalid": ariaInvalid,
830
+ "aria-describedby": ariaDescribedBy,
831
+ className: cn(
832
+ "h-full w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed",
833
+ className
834
+ ),
835
+ ...props
836
+ }
837
+ ),
838
+ trailingIcon ? /* @__PURE__ */ jsxRuntime.jsx(
839
+ "span",
840
+ {
841
+ "aria-hidden": "true",
842
+ className: "inline-flex h-4 w-4 items-center justify-center text-muted-foreground",
843
+ children: trailingIcon
844
+ }
845
+ ) : null
846
+ ]
847
+ }
848
+ ),
849
+ 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
850
+ ] });
851
+ });
755
852
  function readDocumentDirection() {
756
853
  if (typeof document === "undefined") return "ltr";
757
854
  const dir = document.documentElement.getAttribute("dir");
@@ -1273,6 +1370,7 @@ exports.HeaderCollapseTrigger = HeaderCollapseTrigger;
1273
1370
  exports.HeaderMobileTrigger = HeaderMobileTrigger;
1274
1371
  exports.HeaderSearch = HeaderSearch;
1275
1372
  exports.HeaderTitle = HeaderTitle;
1373
+ exports.Input = Input;
1276
1374
  exports.Sidebar = Sidebar;
1277
1375
  exports.SidebarFooter = SidebarFooter;
1278
1376
  exports.SidebarGroup = SidebarGroup;
@@ -1285,6 +1383,9 @@ exports.buttonBaseClass = buttonBaseClass;
1285
1383
  exports.buttonSizeClass = buttonSizeClass;
1286
1384
  exports.buttonVariantClass = buttonVariantClass;
1287
1385
  exports.cn = cn;
1386
+ exports.inputBaseClass = inputBaseClass;
1387
+ exports.inputSizeClass = inputSizeClass;
1388
+ exports.inputVariantClass = inputVariantClass;
1288
1389
  exports.tableAlignClass = alignClass;
1289
1390
  exports.tableBaseClass = tableBaseClass;
1290
1391
  exports.tableSelectedRowClass = selectedRowClass;