@foundrykit/components 1.0.19 → 1.0.20

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.js CHANGED
@@ -610,130 +610,8 @@ function CommandShortcut({
610
610
  }
611
611
 
612
612
  // src/components/advanced-search-bar/index.tsx
613
- import * as React6 from "react";
614
-
615
- // ../../node_modules/@radix-ui/react-slot/dist/index.mjs
616
- import * as React5 from "react";
617
-
618
- // ../../node_modules/@radix-ui/react-compose-refs/dist/index.mjs
619
613
  import * as React4 from "react";
620
- function setRef(ref, value) {
621
- if (typeof ref === "function") {
622
- return ref(value);
623
- } else if (ref !== null && ref !== void 0) {
624
- ref.current = value;
625
- }
626
- }
627
- function composeRefs(...refs) {
628
- return (node) => {
629
- let hasCleanup = false;
630
- const cleanups = refs.map((ref) => {
631
- const cleanup = setRef(ref, node);
632
- if (!hasCleanup && typeof cleanup == "function") {
633
- hasCleanup = true;
634
- }
635
- return cleanup;
636
- });
637
- if (hasCleanup) {
638
- return () => {
639
- for (let i = 0; i < cleanups.length; i++) {
640
- const cleanup = cleanups[i];
641
- if (typeof cleanup == "function") {
642
- cleanup();
643
- } else {
644
- setRef(refs[i], null);
645
- }
646
- }
647
- };
648
- }
649
- };
650
- }
651
-
652
- // ../../node_modules/@radix-ui/react-slot/dist/index.mjs
653
- import { Fragment as Fragment2, jsx as jsx6 } from "react/jsx-runtime";
654
- // @__NO_SIDE_EFFECTS__
655
- function createSlot(ownerName) {
656
- const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
657
- const Slot2 = React5.forwardRef((props, forwardedRef) => {
658
- const { children, ...slotProps } = props;
659
- const childrenArray = React5.Children.toArray(children);
660
- const slottable = childrenArray.find(isSlottable);
661
- if (slottable) {
662
- const newElement = slottable.props.children;
663
- const newChildren = childrenArray.map((child) => {
664
- if (child === slottable) {
665
- if (React5.Children.count(newElement) > 1) return React5.Children.only(null);
666
- return React5.isValidElement(newElement) ? newElement.props.children : null;
667
- } else {
668
- return child;
669
- }
670
- });
671
- return /* @__PURE__ */ jsx6(SlotClone, { ...slotProps, ref: forwardedRef, children: React5.isValidElement(newElement) ? React5.cloneElement(newElement, void 0, newChildren) : null });
672
- }
673
- return /* @__PURE__ */ jsx6(SlotClone, { ...slotProps, ref: forwardedRef, children });
674
- });
675
- Slot2.displayName = `${ownerName}.Slot`;
676
- return Slot2;
677
- }
678
- var Slot = /* @__PURE__ */ createSlot("Slot");
679
- // @__NO_SIDE_EFFECTS__
680
- function createSlotClone(ownerName) {
681
- const SlotClone = React5.forwardRef((props, forwardedRef) => {
682
- const { children, ...slotProps } = props;
683
- if (React5.isValidElement(children)) {
684
- const childrenRef = getElementRef(children);
685
- const props2 = mergeProps(slotProps, children.props);
686
- if (children.type !== React5.Fragment) {
687
- props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
688
- }
689
- return React5.cloneElement(children, props2);
690
- }
691
- return React5.Children.count(children) > 1 ? React5.Children.only(null) : null;
692
- });
693
- SlotClone.displayName = `${ownerName}.SlotClone`;
694
- return SlotClone;
695
- }
696
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
697
- function isSlottable(child) {
698
- return React5.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
699
- }
700
- function mergeProps(slotProps, childProps) {
701
- const overrideProps = { ...childProps };
702
- for (const propName in childProps) {
703
- const slotPropValue = slotProps[propName];
704
- const childPropValue = childProps[propName];
705
- const isHandler = /^on[A-Z]/.test(propName);
706
- if (isHandler) {
707
- if (slotPropValue && childPropValue) {
708
- overrideProps[propName] = (...args) => {
709
- const result = childPropValue(...args);
710
- slotPropValue(...args);
711
- return result;
712
- };
713
- } else if (slotPropValue) {
714
- overrideProps[propName] = slotPropValue;
715
- }
716
- } else if (propName === "style") {
717
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
718
- } else if (propName === "className") {
719
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
720
- }
721
- }
722
- return { ...slotProps, ...overrideProps };
723
- }
724
- function getElementRef(element) {
725
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
726
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
727
- if (mayWarn) {
728
- return element.ref;
729
- }
730
- getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
731
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
732
- if (mayWarn) {
733
- return element.props.ref;
734
- }
735
- return element.props.ref || element.ref;
736
- }
614
+ import { Slot } from "@radix-ui/react-slot";
737
615
 
738
616
  // ../../node_modules/class-variance-authority/dist/index.mjs
739
617
  import { clsx } from "clsx";
@@ -791,7 +669,7 @@ import { Separator } from "@foundrykit/primitives";
791
669
  import { Badge } from "@foundrykit/primitives";
792
670
  import { Card, CardContent } from "@foundrykit/primitives";
793
671
  import { ScrollArea } from "@foundrykit/primitives";
794
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
672
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
795
673
  function AdvancedSearchProvider({
796
674
  children,
797
675
  onSearch,
@@ -806,11 +684,11 @@ function AdvancedSearchProvider({
806
684
  }
807
685
  }
808
686
  }) {
809
- const [query, setQuery] = React6.useState("");
810
- const [isOpen, setIsOpen] = React6.useState(false);
811
- const [results, setResults] = React6.useState(initialResults);
812
- const [isLoading, setIsLoading] = React6.useState(false);
813
- const debouncedSearch = React6.useCallback(
687
+ const [query, setQuery] = React4.useState("");
688
+ const [isOpen, setIsOpen] = React4.useState(false);
689
+ const [results, setResults] = React4.useState(initialResults);
690
+ const [isLoading, setIsLoading] = React4.useState(false);
691
+ const debouncedSearch = React4.useCallback(
814
692
  (searchQuery) => {
815
693
  const timeoutId = setTimeout(async () => {
816
694
  if (searchQuery.length >= minQueryLength && onSearch) {
@@ -838,13 +716,13 @@ function AdvancedSearchProvider({
838
716
  },
839
717
  [onSearch, debounceMs, minQueryLength, emptyStateBehavior, initialResults]
840
718
  );
841
- const handleSearch = React6.useCallback(
719
+ const handleSearch = React4.useCallback(
842
720
  (searchQuery) => {
843
721
  debouncedSearch(searchQuery);
844
722
  },
845
723
  [debouncedSearch]
846
724
  );
847
- const handleResultSelect = React6.useCallback(
725
+ const handleResultSelect = React4.useCallback(
848
726
  (result) => {
849
727
  onResultSelect?.(result);
850
728
  setQuery(result.title);
@@ -852,7 +730,7 @@ function AdvancedSearchProvider({
852
730
  },
853
731
  [onResultSelect]
854
732
  );
855
- const value = React6.useMemo(
733
+ const value = React4.useMemo(
856
734
  () => ({
857
735
  query,
858
736
  setQuery,
@@ -878,7 +756,7 @@ function AdvancedSearchProvider({
878
756
  minQueryLength
879
757
  ]
880
758
  );
881
- return /* @__PURE__ */ jsx7(SearchContext.Provider, { value, children: /* @__PURE__ */ jsx7(
759
+ return /* @__PURE__ */ jsx6(SearchContext.Provider, { value, children: /* @__PURE__ */ jsx6(
882
760
  "div",
883
761
  {
884
762
  style: {
@@ -922,7 +800,7 @@ var searchResultsVariants = cva("w-full", {
922
800
  size: "lg"
923
801
  }
924
802
  });
925
- var SearchInput = React6.forwardRef(
803
+ var SearchInput = React4.forwardRef(
926
804
  ({
927
805
  className,
928
806
  size,
@@ -985,8 +863,8 @@ var SearchInput = React6.forwardRef(
985
863
  input?.focus();
986
864
  },
987
865
  children: [
988
- showSearchIcon && /* @__PURE__ */ jsx7(Search2, { className: "text-muted-foreground absolute left-3 h-4 w-4" }),
989
- /* @__PURE__ */ jsx7(
866
+ showSearchIcon && /* @__PURE__ */ jsx6(Search2, { className: "text-muted-foreground absolute left-3 h-4 w-4" }),
867
+ /* @__PURE__ */ jsx6(
990
868
  Input3,
991
869
  {
992
870
  ref,
@@ -1005,14 +883,14 @@ var SearchInput = React6.forwardRef(
1005
883
  ...props
1006
884
  }
1007
885
  ),
1008
- showClearButton && query && /* @__PURE__ */ jsx7(
886
+ showClearButton && query && /* @__PURE__ */ jsx6(
1009
887
  Button4,
1010
888
  {
1011
889
  variant: "ghost",
1012
890
  size: "sm",
1013
891
  className: "absolute right-1 h-6 w-6 p-0",
1014
892
  onClick: handleClear,
1015
- children: /* @__PURE__ */ jsx7(X, { className: "h-3 w-3" })
893
+ children: /* @__PURE__ */ jsx6(X, { className: "h-3 w-3" })
1016
894
  }
1017
895
  )
1018
896
  ]
@@ -1021,10 +899,10 @@ var SearchInput = React6.forwardRef(
1021
899
  }
1022
900
  );
1023
901
  SearchInput.displayName = "SearchInput";
1024
- var SearchTrigger = React6.forwardRef(({ className, asChild = false, children, ...props }, ref) => {
902
+ var SearchTrigger = React4.forwardRef(({ className, asChild = false, children, ...props }, ref) => {
1025
903
  const { isOpen, setIsOpen } = useAdvancedSearch();
1026
904
  const Comp = asChild ? Slot : Button4;
1027
- return /* @__PURE__ */ jsx7(
905
+ return /* @__PURE__ */ jsx6(
1028
906
  Comp,
1029
907
  {
1030
908
  ref,
@@ -1036,7 +914,7 @@ var SearchTrigger = React6.forwardRef(({ className, asChild = false, children, .
1036
914
  );
1037
915
  });
1038
916
  SearchTrigger.displayName = "SearchTrigger";
1039
- var SearchResults = React6.forwardRef(
917
+ var SearchResults = React4.forwardRef(
1040
918
  ({
1041
919
  className,
1042
920
  size = "full",
@@ -1056,7 +934,7 @@ var SearchResults = React6.forwardRef(
1056
934
  minQueryLength
1057
935
  } = useAdvancedSearch();
1058
936
  if (isLoading && showLoadingState) {
1059
- return /* @__PURE__ */ jsx7(
937
+ return /* @__PURE__ */ jsx6(
1060
938
  "div",
1061
939
  {
1062
940
  ref,
@@ -1075,7 +953,7 @@ var SearchResults = React6.forwardRef(
1075
953
  if (emptyStateBehavior === "hide-until-min-chars" && query.length > 0 && query.length < minQueryLength) {
1076
954
  return null;
1077
955
  }
1078
- return /* @__PURE__ */ jsx7(
956
+ return /* @__PURE__ */ jsx6(
1079
957
  "div",
1080
958
  {
1081
959
  ref,
@@ -1096,7 +974,7 @@ var SearchResults = React6.forwardRef(
1096
974
  results
1097
975
  }
1098
976
  ];
1099
- return /* @__PURE__ */ jsx7(
977
+ return /* @__PURE__ */ jsx6(
1100
978
  "div",
1101
979
  {
1102
980
  ref,
@@ -1107,12 +985,12 @@ var SearchResults = React6.forwardRef(
1107
985
  ),
1108
986
  "aria-label": "Search results",
1109
987
  ...props,
1110
- children: /* @__PURE__ */ jsx7(ScrollArea, { className: "h-fit max-h-[var(--results-max-height)] *:max-h-[var(--results-max-height)]", children: /* @__PURE__ */ jsx7("div", { className: "space-y-4 p-4", children: displaySections.map((section, index) => /* @__PURE__ */ jsxs5("div", { children: [
1111
- index > 0 && /* @__PURE__ */ jsx7(Separator, { className: "my-4" }),
988
+ children: /* @__PURE__ */ jsx6(ScrollArea, { className: "h-fit max-h-[var(--results-max-height)] *:max-h-[var(--results-max-height)]", children: /* @__PURE__ */ jsx6("div", { className: "space-y-4 p-4", children: displaySections.map((section, index) => /* @__PURE__ */ jsxs5("div", { children: [
989
+ index > 0 && /* @__PURE__ */ jsx6(Separator, { className: "my-4" }),
1112
990
  /* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
1113
- /* @__PURE__ */ jsx7("h3", { className: "text-muted-foreground text-sm font-semibold uppercase tracking-wide", children: section.title }),
991
+ /* @__PURE__ */ jsx6("h3", { className: "text-muted-foreground text-sm font-semibold uppercase tracking-wide", children: section.title }),
1114
992
  /* @__PURE__ */ jsxs5("div", { className: "space-y-1", children: [
1115
- section.results.map((result) => /* @__PURE__ */ jsx7(
993
+ section.results.map((result) => /* @__PURE__ */ jsx6(
1116
994
  SearchResultItem,
1117
995
  {
1118
996
  result,
@@ -1129,7 +1007,7 @@ var SearchResults = React6.forwardRef(
1129
1007
  onClick: section.onShowMore,
1130
1008
  children: [
1131
1009
  "Show more",
1132
- /* @__PURE__ */ jsx7(ChevronDown, { className: "ml-2 h-3 w-3" })
1010
+ /* @__PURE__ */ jsx6(ChevronDown, { className: "ml-2 h-3 w-3" })
1133
1011
  ]
1134
1012
  }
1135
1013
  )
@@ -1143,27 +1021,27 @@ var SearchResults = React6.forwardRef(
1143
1021
  SearchResults.displayName = "SearchResults";
1144
1022
  var SearchResultItem = ({ result, onClick }) => {
1145
1023
  if (result.type === "category") {
1146
- return /* @__PURE__ */ jsx7("div", { className: "text-muted-foreground p-2 text-sm font-medium", children: result.title });
1024
+ return /* @__PURE__ */ jsx6("div", { className: "text-muted-foreground p-2 text-sm font-medium", children: result.title });
1147
1025
  }
1148
1026
  if (result.type === "suggestion") {
1149
- return /* @__PURE__ */ jsx7(
1027
+ return /* @__PURE__ */ jsx6(
1150
1028
  Button4,
1151
1029
  {
1152
1030
  variant: "ghost",
1153
1031
  size: "sm",
1154
1032
  className: "h-auto w-full justify-start p-2",
1155
1033
  onClick,
1156
- children: /* @__PURE__ */ jsx7("span", { className: "text-sm", children: result.title })
1034
+ children: /* @__PURE__ */ jsx6("span", { className: "text-sm", children: result.title })
1157
1035
  }
1158
1036
  );
1159
1037
  }
1160
- return /* @__PURE__ */ jsx7(
1038
+ return /* @__PURE__ */ jsx6(
1161
1039
  Card,
1162
1040
  {
1163
1041
  className: "hover:bg-muted/50 w-full cursor-pointer transition-colors",
1164
1042
  onClick,
1165
- children: /* @__PURE__ */ jsx7(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxs5("div", { className: "flex gap-3", children: [
1166
- result.image && /* @__PURE__ */ jsx7("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx7(
1043
+ children: /* @__PURE__ */ jsx6(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxs5("div", { className: "flex gap-3", children: [
1044
+ result.image && /* @__PURE__ */ jsx6("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx6(
1167
1045
  "img",
1168
1046
  {
1169
1047
  src: result.image,
@@ -1173,36 +1051,36 @@ var SearchResultItem = ({ result, onClick }) => {
1173
1051
  ) }),
1174
1052
  /* @__PURE__ */ jsxs5("div", { className: "min-w-0 flex-1", children: [
1175
1053
  /* @__PURE__ */ jsxs5("div", { className: "flex items-start justify-between gap-2", children: [
1176
- /* @__PURE__ */ jsx7("h4", { className: "truncate text-sm font-semibold", children: result.title }),
1177
- result.badge && /* @__PURE__ */ jsx7(Badge, { variant: "secondary", className: "text-xs", children: result.badge })
1054
+ /* @__PURE__ */ jsx6("h4", { className: "truncate text-sm font-semibold", children: result.title }),
1055
+ result.badge && /* @__PURE__ */ jsx6(Badge, { variant: "secondary", className: "text-xs", children: result.badge })
1178
1056
  ] }),
1179
- result.description && /* @__PURE__ */ jsx7("p", { className: "text-muted-foreground mt-1 line-clamp-2 text-xs", children: result.description })
1057
+ result.description && /* @__PURE__ */ jsx6("p", { className: "text-muted-foreground mt-1 line-clamp-2 text-xs", children: result.description })
1180
1058
  ] })
1181
1059
  ] }) })
1182
1060
  }
1183
1061
  );
1184
1062
  };
1185
- var AdvancedSearchBar = React6.forwardRef(({ className, children, open, ...props }, ref) => {
1063
+ var AdvancedSearchBar = React4.forwardRef(({ className, children, open, ...props }, ref) => {
1186
1064
  const { isOpen } = useAdvancedSearch();
1187
1065
  const isControlled = open !== void 0;
1188
1066
  const isOpenState = isControlled ? open : isOpen;
1189
- const childrenArray = React6.Children.toArray(children);
1067
+ const childrenArray = React4.Children.toArray(children);
1190
1068
  const inputChild = childrenArray.find(
1191
- (child) => React6.isValidElement(child) && child.type === SearchInput
1069
+ (child) => React4.isValidElement(child) && child.type === SearchInput
1192
1070
  );
1193
1071
  const resultsChild = childrenArray.find(
1194
- (child) => React6.isValidElement(child) && child.type === SearchResults
1072
+ (child) => React4.isValidElement(child) && child.type === SearchResults
1195
1073
  );
1196
- const triggerElement = inputChild || /* @__PURE__ */ jsx7(SearchInput, {});
1074
+ const triggerElement = inputChild || /* @__PURE__ */ jsx6(SearchInput, {});
1197
1075
  return /* @__PURE__ */ jsxs5("div", { ref, className: cn6("relative", className), ...props, children: [
1198
- /* @__PURE__ */ jsx7("div", { className: "w-full", children: triggerElement }),
1199
- isOpenState && /* @__PURE__ */ jsx7("div", { className: "absolute left-0 top-full z-50 mt-1 w-full rounded-md border border-gray-200 bg-white shadow-lg", children: resultsChild || /* @__PURE__ */ jsx7(SearchResults, {}) })
1076
+ /* @__PURE__ */ jsx6("div", { className: "w-full", children: triggerElement }),
1077
+ isOpenState && /* @__PURE__ */ jsx6("div", { className: "absolute left-0 top-full z-50 mt-1 w-full rounded-md border border-gray-200 bg-white shadow-lg", children: resultsChild || /* @__PURE__ */ jsx6(SearchResults, {}) })
1200
1078
  ] });
1201
1079
  });
1202
1080
  AdvancedSearchBar.displayName = "AdvancedSearchBar";
1203
- var SearchSection = React6.forwardRef(({ className, title, showMore, onShowMore, children, ...props }, ref) => {
1081
+ var SearchSection = React4.forwardRef(({ className, title, showMore, onShowMore, children, ...props }, ref) => {
1204
1082
  return /* @__PURE__ */ jsxs5("div", { ref, className: cn6("space-y-2", className), ...props, children: [
1205
- title && /* @__PURE__ */ jsx7("h3", { className: "text-muted-foreground text-sm font-semibold uppercase tracking-wide", children: title }),
1083
+ title && /* @__PURE__ */ jsx6("h3", { className: "text-muted-foreground text-sm font-semibold uppercase tracking-wide", children: title }),
1206
1084
  /* @__PURE__ */ jsxs5("div", { className: "space-y-1", children: [
1207
1085
  children,
1208
1086
  showMore && onShowMore && /* @__PURE__ */ jsxs5(
@@ -1214,7 +1092,7 @@ var SearchSection = React6.forwardRef(({ className, title, showMore, onShowMore,
1214
1092
  onClick: onShowMore,
1215
1093
  children: [
1216
1094
  "Show more",
1217
- /* @__PURE__ */ jsx7(ChevronDown, { className: "ml-2 h-3 w-3" })
1095
+ /* @__PURE__ */ jsx6(ChevronDown, { className: "ml-2 h-3 w-3" })
1218
1096
  ]
1219
1097
  }
1220
1098
  )
@@ -1222,7 +1100,7 @@ var SearchSection = React6.forwardRef(({ className, title, showMore, onShowMore,
1222
1100
  ] });
1223
1101
  });
1224
1102
  SearchSection.displayName = "SearchSection ";
1225
- var SearchItem = React6.forwardRef(
1103
+ var SearchItem = React4.forwardRef(
1226
1104
  ({ className, result, onClick, children, ...props }, ref) => {
1227
1105
  const { onResultSelect } = useAdvancedSearch();
1228
1106
  const handleClick = () => {
@@ -1232,7 +1110,7 @@ var SearchItem = React6.forwardRef(
1232
1110
  onClick?.();
1233
1111
  };
1234
1112
  if (children) {
1235
- return /* @__PURE__ */ jsx7(
1113
+ return /* @__PURE__ */ jsx6(
1236
1114
  "div",
1237
1115
  {
1238
1116
  ref,
@@ -1245,7 +1123,7 @@ var SearchItem = React6.forwardRef(
1245
1123
  }
1246
1124
  if (!result) return null;
1247
1125
  if (result.type === "category") {
1248
- return /* @__PURE__ */ jsx7(
1126
+ return /* @__PURE__ */ jsx6(
1249
1127
  "div",
1250
1128
  {
1251
1129
  ref,
@@ -1259,7 +1137,7 @@ var SearchItem = React6.forwardRef(
1259
1137
  );
1260
1138
  }
1261
1139
  if (result.type === "suggestion") {
1262
- return /* @__PURE__ */ jsx7(
1140
+ return /* @__PURE__ */ jsx6(
1263
1141
  Button4,
1264
1142
  {
1265
1143
  ref,
@@ -1268,11 +1146,11 @@ var SearchItem = React6.forwardRef(
1268
1146
  className: cn6("h-auto w-full justify-start p-2", className),
1269
1147
  onClick: handleClick,
1270
1148
  ...props,
1271
- children: /* @__PURE__ */ jsx7("span", { className: "text-sm", children: result.title })
1149
+ children: /* @__PURE__ */ jsx6("span", { className: "text-sm", children: result.title })
1272
1150
  }
1273
1151
  );
1274
1152
  }
1275
- return /* @__PURE__ */ jsx7(
1153
+ return /* @__PURE__ */ jsx6(
1276
1154
  Card,
1277
1155
  {
1278
1156
  ref,
@@ -1282,8 +1160,8 @@ var SearchItem = React6.forwardRef(
1282
1160
  ),
1283
1161
  onClick: handleClick,
1284
1162
  ...props,
1285
- children: /* @__PURE__ */ jsx7(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxs5("div", { className: "flex gap-3", children: [
1286
- result.image && /* @__PURE__ */ jsx7("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx7(
1163
+ children: /* @__PURE__ */ jsx6(CardContent, { className: "p-3", children: /* @__PURE__ */ jsxs5("div", { className: "flex gap-3", children: [
1164
+ result.image && /* @__PURE__ */ jsx6("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx6(
1287
1165
  "img",
1288
1166
  {
1289
1167
  src: result.image,
@@ -1293,10 +1171,10 @@ var SearchItem = React6.forwardRef(
1293
1171
  ) }),
1294
1172
  /* @__PURE__ */ jsxs5("div", { className: "min-w-0 flex-1", children: [
1295
1173
  /* @__PURE__ */ jsxs5("div", { className: "flex items-start justify-between gap-2", children: [
1296
- /* @__PURE__ */ jsx7("h4", { className: "truncate text-sm font-semibold", children: result.title }),
1297
- result.badge && /* @__PURE__ */ jsx7(Badge, { variant: "secondary", className: "text-xs", children: result.badge })
1174
+ /* @__PURE__ */ jsx6("h4", { className: "truncate text-sm font-semibold", children: result.title }),
1175
+ result.badge && /* @__PURE__ */ jsx6(Badge, { variant: "secondary", className: "text-xs", children: result.badge })
1298
1176
  ] }),
1299
- result.description && /* @__PURE__ */ jsx7("p", { className: "text-muted-foreground mt-1 line-clamp-2 text-xs", children: result.description })
1177
+ result.description && /* @__PURE__ */ jsx6("p", { className: "text-muted-foreground mt-1 line-clamp-2 text-xs", children: result.description })
1300
1178
  ] })
1301
1179
  ] }) })
1302
1180
  }
@@ -1364,7 +1242,7 @@ function AdvancedSearchBarWrapper(props = {}) {
1364
1242
  }
1365
1243
  return "Search destinations...";
1366
1244
  };
1367
- return /* @__PURE__ */ jsx7(
1245
+ return /* @__PURE__ */ jsx6(
1368
1246
  AdvancedSearchProvider,
1369
1247
  {
1370
1248
  onSearch: handleSearch,
@@ -1374,10 +1252,10 @@ function AdvancedSearchBarWrapper(props = {}) {
1374
1252
  emptyStateBehavior,
1375
1253
  initialResults: emptyStateBehavior === "show-all-results" ? mockSearchResults : [],
1376
1254
  children: /* @__PURE__ */ jsxs5(AdvancedSearchBar, { children: [
1377
- useCustomTrigger ? /* @__PURE__ */ jsx7(SearchTrigger, { asChild: true, children: /* @__PURE__ */ jsxs5(Button4, { variant: "outline", className: "w-full justify-start", children: [
1378
- /* @__PURE__ */ jsx7(Search2, { className: "mr-2 h-4 w-4" }),
1255
+ useCustomTrigger ? /* @__PURE__ */ jsx6(SearchTrigger, { asChild: true, children: /* @__PURE__ */ jsxs5(Button4, { variant: "outline", className: "w-full justify-start", children: [
1256
+ /* @__PURE__ */ jsx6(Search2, { className: "mr-2 h-4 w-4" }),
1379
1257
  "Click to search..."
1380
- ] }) }) : /* @__PURE__ */ jsx7(
1258
+ ] }) }) : /* @__PURE__ */ jsx6(
1381
1259
  SearchInput,
1382
1260
  {
1383
1261
  placeholder: getPlaceholder(),
@@ -1387,7 +1265,7 @@ function AdvancedSearchBarWrapper(props = {}) {
1387
1265
  showClearButton: true
1388
1266
  }
1389
1267
  ),
1390
- /* @__PURE__ */ jsx7(
1268
+ /* @__PURE__ */ jsx6(
1391
1269
  SearchResults,
1392
1270
  {
1393
1271
  size: size === "sm" ? "sm" : size === "lg" ? "lg" : "md",
@@ -1402,8 +1280,121 @@ function AdvancedSearchBarWrapper(props = {}) {
1402
1280
  );
1403
1281
  }
1404
1282
 
1405
- // src/index.ts
1283
+ // src/components/form/index.tsx
1284
+ import * as React5 from "react";
1285
+ import { Slot as Slot2 } from "@radix-ui/react-slot";
1286
+ import {
1287
+ Controller,
1288
+ FormProvider,
1289
+ useFormContext,
1290
+ useFormState
1291
+ } from "react-hook-form";
1406
1292
  import { cn as cn7 } from "@foundrykit/utils";
1293
+ import { Label } from "@foundrykit/primitives";
1294
+ import { jsx as jsx7 } from "react/jsx-runtime";
1295
+ var Form = FormProvider;
1296
+ var FormFieldContext = React5.createContext(
1297
+ {}
1298
+ );
1299
+ var FormField = ({
1300
+ ...props
1301
+ }) => {
1302
+ return /* @__PURE__ */ jsx7(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx7(Controller, { ...props }) });
1303
+ };
1304
+ var useFormField = () => {
1305
+ const fieldContext = React5.useContext(FormFieldContext);
1306
+ const itemContext = React5.useContext(FormItemContext);
1307
+ const { getFieldState } = useFormContext();
1308
+ const formState = useFormState({ name: fieldContext.name });
1309
+ const fieldState = getFieldState(fieldContext.name, formState);
1310
+ if (!fieldContext) {
1311
+ throw new Error("useFormField should be used within <FormField>");
1312
+ }
1313
+ const { id } = itemContext;
1314
+ return {
1315
+ id,
1316
+ name: fieldContext.name,
1317
+ formItemId: `${id}-form-item`,
1318
+ formDescriptionId: `${id}-form-item-description`,
1319
+ formMessageId: `${id}-form-item-message`,
1320
+ ...fieldState
1321
+ };
1322
+ };
1323
+ var FormItemContext = React5.createContext(
1324
+ {}
1325
+ );
1326
+ function FormItem({ className, ...props }) {
1327
+ const id = React5.useId();
1328
+ return /* @__PURE__ */ jsx7(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx7(
1329
+ "div",
1330
+ {
1331
+ "data-slot": "form-item",
1332
+ className: cn7("grid gap-2", className),
1333
+ ...props
1334
+ }
1335
+ ) });
1336
+ }
1337
+ function FormLabel({
1338
+ className,
1339
+ ...props
1340
+ }) {
1341
+ const { error, formItemId } = useFormField();
1342
+ return /* @__PURE__ */ jsx7(
1343
+ Label,
1344
+ {
1345
+ "data-slot": "form-label",
1346
+ "data-error": !!error,
1347
+ className: cn7("data-[error=true]:text-destructive", className),
1348
+ htmlFor: formItemId,
1349
+ ...props
1350
+ }
1351
+ );
1352
+ }
1353
+ function FormControl({ ...props }) {
1354
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
1355
+ return /* @__PURE__ */ jsx7(
1356
+ Slot2,
1357
+ {
1358
+ "data-slot": "form-control",
1359
+ id: formItemId,
1360
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
1361
+ "aria-invalid": !!error,
1362
+ ...props
1363
+ }
1364
+ );
1365
+ }
1366
+ function FormDescription({ className, ...props }) {
1367
+ const { formDescriptionId } = useFormField();
1368
+ return /* @__PURE__ */ jsx7(
1369
+ "p",
1370
+ {
1371
+ "data-slot": "form-description",
1372
+ id: formDescriptionId,
1373
+ className: cn7("text-muted-foreground text-sm", className),
1374
+ ...props
1375
+ }
1376
+ );
1377
+ }
1378
+ function FormMessage({ className, ...props }) {
1379
+ const { error, formMessageId } = useFormField();
1380
+ const body = error ? String(error?.message ?? "") : props.children;
1381
+ if (!body) {
1382
+ return null;
1383
+ }
1384
+ return /* @__PURE__ */ jsx7(
1385
+ "p",
1386
+ {
1387
+ "data-slot": "form-message",
1388
+ id: formMessageId,
1389
+ className: cn7("text-destructive text-sm", className),
1390
+ ...props,
1391
+ children: body
1392
+ }
1393
+ );
1394
+ }
1395
+
1396
+ // src/index.ts
1397
+ import { cn as cn8 } from "@foundrykit/utils";
1407
1398
  export {
1408
1399
  AdvancedSearchBar,
1409
1400
  AdvancedSearchBarWrapper,
@@ -1419,6 +1410,13 @@ export {
1419
1410
  CommandSeparator,
1420
1411
  CommandShortcut,
1421
1412
  DatePicker,
1413
+ Form,
1414
+ FormControl,
1415
+ FormDescription,
1416
+ FormField,
1417
+ FormItem,
1418
+ FormLabel,
1419
+ FormMessage,
1422
1420
  Pagination,
1423
1421
  PaginationContent,
1424
1422
  PaginationEllipsis,
@@ -1432,6 +1430,7 @@ export {
1432
1430
  SearchResults,
1433
1431
  SearchSection,
1434
1432
  SearchTrigger,
1435
- cn7 as cn
1433
+ cn8 as cn,
1434
+ useFormField
1436
1435
  };
1437
1436
  //# sourceMappingURL=index.js.map