@next-degree/pickle-shared-js 0.3.22 → 0.3.24

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.
Files changed (49) hide show
  1. package/dist/app/layout.css +106 -5
  2. package/dist/app/layout.css.map +1 -1
  3. package/dist/app/page.cjs +364 -4
  4. package/dist/app/page.cjs.map +1 -1
  5. package/dist/app/page.js +369 -4
  6. package/dist/app/page.js.map +1 -1
  7. package/dist/components/demos/InputDemo.cjs +175 -0
  8. package/dist/components/demos/InputDemo.cjs.map +1 -0
  9. package/dist/components/demos/InputDemo.d.cts +5 -0
  10. package/dist/components/demos/InputDemo.d.ts +5 -0
  11. package/dist/components/demos/InputDemo.js +152 -0
  12. package/dist/components/demos/InputDemo.js.map +1 -0
  13. package/dist/components/demos/SelectDemo.cjs +323 -0
  14. package/dist/components/demos/SelectDemo.cjs.map +1 -0
  15. package/dist/components/demos/SelectDemo.d.cts +5 -0
  16. package/dist/components/demos/SelectDemo.d.ts +5 -0
  17. package/dist/components/demos/SelectDemo.js +295 -0
  18. package/dist/components/demos/SelectDemo.js.map +1 -0
  19. package/dist/components/demos/index.cjs +362 -2
  20. package/dist/components/demos/index.cjs.map +1 -1
  21. package/dist/components/demos/index.js +367 -2
  22. package/dist/components/demos/index.js.map +1 -1
  23. package/dist/components/ui/ErrorMessage.cjs +41 -0
  24. package/dist/components/ui/ErrorMessage.cjs.map +1 -0
  25. package/dist/components/ui/ErrorMessage.d.cts +9 -0
  26. package/dist/components/ui/ErrorMessage.d.ts +9 -0
  27. package/dist/components/ui/ErrorMessage.js +18 -0
  28. package/dist/components/ui/ErrorMessage.js.map +1 -0
  29. package/dist/components/ui/Input.cjs +159 -0
  30. package/dist/components/ui/Input.cjs.map +1 -0
  31. package/dist/components/ui/Input.d.cts +22 -0
  32. package/dist/components/ui/Input.d.ts +22 -0
  33. package/dist/components/ui/Input.js +138 -0
  34. package/dist/components/ui/Input.js.map +1 -0
  35. package/dist/components/ui/Select.cjs +124 -105
  36. package/dist/components/ui/Select.cjs.map +1 -1
  37. package/dist/components/ui/Select.d.cts +3 -1
  38. package/dist/components/ui/Select.d.ts +3 -1
  39. package/dist/components/ui/Select.js +124 -105
  40. package/dist/components/ui/Select.js.map +1 -1
  41. package/dist/index.cjs +311 -190
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +1 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +301 -181
  46. package/dist/index.js.map +1 -1
  47. package/dist/styles/globals.css +106 -5
  48. package/dist/styles/globals.css.map +1 -1
  49. package/package.json +1 -1
package/dist/app/page.cjs CHANGED
@@ -767,17 +767,377 @@ function ComboboxDemo() {
767
767
  }
768
768
  var ComboboxDemo_default = ComboboxDemo;
769
769
 
770
- // src/components/demos/index.tsx
770
+ // src/components/ui/Select.tsx
771
+ var SelectPrimitive = __toESM(require("@radix-ui/react-select"), 1);
772
+ var import_lucide_react7 = require("lucide-react");
773
+ var import_react5 = require("react");
774
+
775
+ // src/components/ui/ErrorMessage.tsx
771
776
  var import_jsx_runtime12 = require("react/jsx-runtime");
777
+ function ErrorMessage({ message, className, ...props }) {
778
+ if (!message) return null;
779
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: cn("px-1 text-xs text-red-600", className), ...props, children: message });
780
+ }
781
+ var ErrorMessage_default = ErrorMessage;
782
+
783
+ // src/components/ui/Chip.tsx
784
+ var import_cva4 = require("cva");
785
+ var import_tailwind_merge2 = require("tailwind-merge");
786
+ var import_jsx_runtime13 = require("react/jsx-runtime");
787
+ var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: (0, import_tailwind_merge2.twMerge)(chipVariants({ variant, size, className })), ...props });
788
+ var chipVariants = (0, import_cva4.cva)(["flex", "items-center", "rounded-3xl", "border", "w-fit"], {
789
+ variants: {
790
+ variant: {
791
+ neutral: ["text-grey-80", "border-grey-10"],
792
+ primary: ["text-purple-100", "border-purple-20"],
793
+ danger: ["text-pumpkin-100", "border-pumpkin-20"],
794
+ onboarding: ["text-green-100", "bg-green-10", "cursor-pointer"],
795
+ onboardingSelected: ["text-white", "bg-green-90", "cursor-pointer"]
796
+ },
797
+ size: {
798
+ small: ["text-sm", "leading-5", "px-2", "py-1", "gap-1.5"],
799
+ medium: ["text-base", "leading-6", "px-3", "py-2", "gap-2"]
800
+ }
801
+ },
802
+ defaultVariants: {
803
+ variant: "neutral",
804
+ size: "medium"
805
+ }
806
+ });
807
+ var Chip_default = Chip;
808
+
809
+ // src/components/ui/Select.tsx
810
+ var import_jsx_runtime14 = require("react/jsx-runtime");
811
+ var Select = (0, import_react5.forwardRef)(
812
+ ({ label, options, placeholder, multiselect, classNames, error, id, ...props }, ref) => {
813
+ const { value, defaultValue, dir, className, onChange, ...rest } = props;
814
+ const [selected, setSelected] = (0, import_react5.useState)([]);
815
+ const [open, setOpen] = (0, import_react5.useState)(false);
816
+ const containerRef = (0, import_react5.useRef)(null);
817
+ (0, import_react5.useEffect)(() => {
818
+ if (!value) return setSelected([]);
819
+ setSelected(Array.isArray(value) ? value : [value]);
820
+ }, [value]);
821
+ const toggleOpen = () => setOpen((prev) => !prev);
822
+ const closeOnEscape = (event) => event.key === "Escape" && setOpen(false);
823
+ const setValueOnEnter = (event, value2) => event.key === "Enter" && handleChange(value2);
824
+ const chipLabels = selected?.map((s) => options?.find(({ value: value2 }) => value2 === s)).filter(Boolean);
825
+ function handleLabels() {
826
+ if (multiselect) {
827
+ return selected.map((o) => options?.find((option) => option.value === o)?.title).join(", ");
828
+ }
829
+ return options?.find((option) => option.value === selected.join())?.title;
830
+ }
831
+ function handleOnOpenChange(isOpen) {
832
+ if (!multiselect || isOpen) setOpen(isOpen);
833
+ }
834
+ function handleChange(newValue) {
835
+ let newSelected = [];
836
+ setSelected((prev) => {
837
+ newSelected = prev.includes(newValue) ? prev.filter((item) => item !== newValue) : [...prev, newValue];
838
+ return multiselect ? newSelected : [newValue];
839
+ });
840
+ onChange?.(multiselect ? newSelected : newValue);
841
+ }
842
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
843
+ "div",
844
+ {
845
+ className: cn("flex flex-col space-y-1", className),
846
+ ref: containerRef,
847
+ "data-testid": `${(label ?? id)?.toLowerCase()}-select-element`,
848
+ children: [
849
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Label_default, { text: label, className: classNames?.label }),
850
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
851
+ SelectPrimitive.Root,
852
+ {
853
+ open,
854
+ value: selected.join(","),
855
+ onOpenChange: handleOnOpenChange,
856
+ onValueChange: multiselect ? void 0 : handleChange,
857
+ defaultValue: typeof defaultValue === "string" ? defaultValue : void 0,
858
+ dir: dir === "rtl" ? "rtl" : "ltr",
859
+ ...rest,
860
+ children: [
861
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
862
+ SelectPrimitive.Trigger,
863
+ {
864
+ ref,
865
+ className: cn(
866
+ "group flex h-11 min-w-80 flex-row items-center justify-between gap-3 rounded-lg border px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40",
867
+ classNames?.trigger
868
+ ),
869
+ children: [
870
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "truncate", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
871
+ SelectPrimitive.Value,
872
+ {
873
+ placeholder: placeholder ?? "Select an option",
874
+ "aria-label": handleLabels(),
875
+ children: handleLabels()
876
+ }
877
+ ) }),
878
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
879
+ import_lucide_react7.ChevronDownIcon,
880
+ {
881
+ className: "transform text-black group-data-[state=open]:rotate-180",
882
+ size: "16"
883
+ }
884
+ )
885
+ ]
886
+ }
887
+ ),
888
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectPrimitive.Portal, { container: containerRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
889
+ SelectPrimitive.Content,
890
+ {
891
+ hideWhenDetached: true,
892
+ className: "z-10 max-h-[var(--radix-select-content-available-height)] w-[var(--radix-select-trigger-width)] overflow-hidden rounded-md bg-white py-2 shadow-lg",
893
+ position: "popper",
894
+ sideOffset: 4,
895
+ onPointerDownOutside: toggleOpen,
896
+ onKeyDown: closeOnEscape,
897
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(SelectPrimitive.Viewport, { children: [
898
+ multiselect && !!chipLabels?.length && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
899
+ SelectPrimitive.Group,
900
+ {
901
+ className: "mb-2 flex flex-row flex-wrap gap-1 px-2",
902
+ "data-testid": "selected-labels",
903
+ children: chipLabels?.map(
904
+ (chip) => chip && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Chip_default, { size: "small", variant: "primary", children: [
905
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: chip.title }),
906
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
907
+ import_lucide_react7.X,
908
+ {
909
+ size: 18,
910
+ "data-testid": `chip-remove-${chip.value}`,
911
+ className: "cursor-pointer",
912
+ onClick: () => handleChange(chip.value)
913
+ }
914
+ )
915
+ ] }, chip.title)
916
+ )
917
+ }
918
+ ),
919
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Separator, {}),
920
+ options?.map(({ id: id2, title, value: value2 }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
921
+ SelectPrimitive.Item,
922
+ {
923
+ value: value2,
924
+ className: "group relative cursor-pointer px-4 py-2 text-left text-sm hover:bg-purple-50 focus:bg-purple-50 focus:outline-none data-[state=checked]:bg-purple-50 data-[state=checked]:pr-10 data-[state=checked]:text-purple-100",
925
+ "data-state": selected.includes(value2) ? "checked" : "unchecked",
926
+ onKeyDown: (e) => setValueOnEnter(e, value2),
927
+ onClick: () => handleChange(value2),
928
+ children: [
929
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SelectPrimitive.ItemText, { children: title }),
930
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
931
+ import_lucide_react7.CheckIcon,
932
+ {
933
+ className: "absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block",
934
+ size: 16
935
+ }
936
+ )
937
+ ]
938
+ },
939
+ id2
940
+ ))
941
+ ] })
942
+ }
943
+ ) })
944
+ ]
945
+ }
946
+ ),
947
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ErrorMessage_default, { message: error, className: "mt-1" })
948
+ ]
949
+ }
950
+ );
951
+ }
952
+ );
953
+ Select.displayName = "Select";
954
+ var Select_default = Select;
955
+
956
+ // src/components/demos/SelectDemo.tsx
957
+ var import_jsx_runtime15 = require("react/jsx-runtime");
958
+ function SelectDemo() {
959
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "m-4", children: [
960
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h3", { children: "Select" }),
961
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex max-w-sm flex-col gap-4 mt-2", children: [
962
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
963
+ Select_default,
964
+ {
965
+ label: "Label - Singleselect",
966
+ placeholder: "Select an option",
967
+ options: [
968
+ { id: "1", value: "1", title: "Option 1" },
969
+ { id: "2", value: "2", title: "Option 2" },
970
+ { id: "3", value: "3", title: "Option 3" }
971
+ ]
972
+ }
973
+ ),
974
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
975
+ Select_default,
976
+ {
977
+ multiselect: true,
978
+ label: "Label - Multiselect",
979
+ placeholder: "Select an option",
980
+ options: [
981
+ { id: "1", value: "1", title: "Option 1" },
982
+ { id: "2", value: "2", title: "Option 2" },
983
+ { id: "3", value: "3", title: "Option 3" },
984
+ { id: "4", value: "4", title: "Option 4" },
985
+ { id: "5", value: "5", title: "Option 5" },
986
+ { id: "6", value: "6", title: "Option 6" },
987
+ { id: "7", value: "7", title: "Option 7" },
988
+ { id: "8", value: "8", title: "Option 8" },
989
+ { id: "9", value: "9", title: "Option 9" },
990
+ { id: "10", value: "10", title: "Option 10" }
991
+ ]
992
+ }
993
+ ),
994
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
995
+ Select_default,
996
+ {
997
+ disabled: true,
998
+ label: "Label - Disabled",
999
+ placeholder: "Select an option",
1000
+ options: [
1001
+ { id: "1", value: "1", title: "Option 1" },
1002
+ { id: "2", value: "2", title: "Option 2" },
1003
+ { id: "3", value: "3", title: "Option 3" }
1004
+ ]
1005
+ }
1006
+ )
1007
+ ] })
1008
+ ] });
1009
+ }
1010
+ var SelectDemo_default = SelectDemo;
1011
+
1012
+ // src/components/ui/Input.tsx
1013
+ var import_cva5 = require("cva");
1014
+ var import_lucide_react8 = require("lucide-react");
1015
+ var import_react6 = require("react");
1016
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1017
+ var Input = (0, import_react6.forwardRef)(
1018
+ ({ label, error, theme, icon, onClear, value, onChange, classNames, ...props }, ref) => {
1019
+ const handleClear = () => {
1020
+ onChange?.({ target: { value: "" } });
1021
+ onClear?.();
1022
+ };
1023
+ const IconComponent = icon && import_lucide_react8.icons[icon];
1024
+ const placeholder = props.placeholder ?? (icon === "Search" ? "Search..." : "");
1025
+ const hasIcon = !!icon;
1026
+ const iconColor = theme === "dark" ? "text-white" : "text-grey-80";
1027
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "group flex w-full flex-col", "data-testid": `input-wrapper-${props.id}`, children: [
1028
+ label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label_default, { text: label, htmlFor: props.name, className: cn("body mb-1", classNames?.label) }),
1029
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "relative flex flex-row items-center", children: [
1030
+ IconComponent && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1031
+ IconComponent,
1032
+ {
1033
+ className: `absolute left-3 h-4 w-4 ${iconColor} opacity-50 group-hover:opacity-100`
1034
+ }
1035
+ ),
1036
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1037
+ "input",
1038
+ {
1039
+ className: cn(inputVariants({ theme, hasIcon })),
1040
+ ref,
1041
+ placeholder,
1042
+ value,
1043
+ onChange,
1044
+ "data-testid": `input-element-${props.id}`,
1045
+ ...props
1046
+ }
1047
+ ),
1048
+ hasIcon && value && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1049
+ import_lucide_react8.X,
1050
+ {
1051
+ className: `absolute right-3 h-4 w-4 cursor-pointer ${iconColor}`,
1052
+ onClick: handleClear,
1053
+ "data-testid": "clear-button"
1054
+ }
1055
+ )
1056
+ ] }),
1057
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ErrorMessage_default, { message: error, className: "mt-1" })
1058
+ ] });
1059
+ }
1060
+ );
1061
+ Input.displayName = "Input";
1062
+ var inputVariants = (0, import_cva5.cva)(
1063
+ [
1064
+ "border-input",
1065
+ "placeholder:text-muted-foreground",
1066
+ "focus-visible:ring-ring",
1067
+ "inline-flex",
1068
+ "w-full",
1069
+ "h-11",
1070
+ "items-center",
1071
+ "justify-start",
1072
+ "gap-3",
1073
+ "rounded-lg",
1074
+ "bg-transparent",
1075
+ "px-3",
1076
+ "pt-0.5",
1077
+ "text-sm",
1078
+ "shadow-sm",
1079
+ "ring-grey-50",
1080
+ "transition-colors",
1081
+ "focus-visible:outline-none",
1082
+ "focus-visible:ring-1",
1083
+ "disabled:cursor-not-allowed",
1084
+ "disabled:opacity-50",
1085
+ "appearance-none",
1086
+ "[&::-webkit-search-cancel-button]:appearance-none",
1087
+ "[&::-webkit-search-decoration]:appearance-none",
1088
+ "[&::-webkit-search-results-button]:appearance-none",
1089
+ "[&::-webkit-search-results-decoration]:appearance-none",
1090
+ "[&::-ms-clear]:display-none",
1091
+ "[&::-ms-reveal]:display-none"
1092
+ ],
1093
+ {
1094
+ variants: {
1095
+ theme: {
1096
+ light: "text-grey-80 border",
1097
+ dark: "text-white"
1098
+ },
1099
+ hasIcon: {
1100
+ false: "pl-3",
1101
+ true: "pl-8"
1102
+ }
1103
+ },
1104
+ defaultVariants: {
1105
+ theme: "light",
1106
+ hasIcon: false
1107
+ }
1108
+ }
1109
+ );
1110
+ var Input_default = Input;
1111
+
1112
+ // src/components/demos/InputDemo.tsx
1113
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1114
+ function InputDemo() {
1115
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "m-4", children: [
1116
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h3", { children: "Input" }),
1117
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-2 md:flex-row", children: [
1118
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "bg-green-80 p-2", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Input_default, { theme: "dark", icon: "Search" }) }),
1119
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "p-2", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Input_default, {}) }),
1120
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "p-2", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Input_default, { icon: "MapPin" }) })
1121
+ ] })
1122
+ ] });
1123
+ }
1124
+ var InputDemo_default = InputDemo;
1125
+
1126
+ // src/components/demos/index.tsx
1127
+ var import_jsx_runtime18 = require("react/jsx-runtime");
772
1128
  function Demos() {
773
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ComboboxDemo_default, {}) });
1129
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
1130
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ComboboxDemo_default, {}),
1131
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectDemo_default, {}),
1132
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(InputDemo_default, {})
1133
+ ] });
774
1134
  }
775
1135
  var demos_default = Demos;
776
1136
 
777
1137
  // src/app/page.tsx
778
- var import_jsx_runtime13 = require("react/jsx-runtime");
1138
+ var import_jsx_runtime19 = require("react/jsx-runtime");
779
1139
  async function Page() {
780
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(demos_default, {});
1140
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(demos_default, {});
781
1141
  }
782
1142
  var page_default = Page;
783
1143
  //# sourceMappingURL=page.cjs.map