@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.js CHANGED
@@ -733,17 +733,382 @@ function ComboboxDemo() {
733
733
  }
734
734
  var ComboboxDemo_default = ComboboxDemo;
735
735
 
736
- // src/components/demos/index.tsx
736
+ // src/components/ui/Select.tsx
737
+ import * as SelectPrimitive from "@radix-ui/react-select";
738
+ import { CheckIcon as CheckIcon2, ChevronDownIcon as ChevronDownIcon2, X as X2 } from "lucide-react";
739
+ import {
740
+ forwardRef as forwardRef8,
741
+ useEffect as useEffect2,
742
+ useRef,
743
+ useState as useState3
744
+ } from "react";
745
+
746
+ // src/components/ui/ErrorMessage.tsx
737
747
  import { jsx as jsx12 } from "react/jsx-runtime";
748
+ function ErrorMessage({ message, className, ...props }) {
749
+ if (!message) return null;
750
+ return /* @__PURE__ */ jsx12("p", { className: cn("px-1 text-xs text-red-600", className), ...props, children: message });
751
+ }
752
+ var ErrorMessage_default = ErrorMessage;
753
+
754
+ // src/components/ui/Chip.tsx
755
+ import { cva as cva4 } from "cva";
756
+ import { twMerge as twMerge2 } from "tailwind-merge";
757
+ import { jsx as jsx13 } from "react/jsx-runtime";
758
+ var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */ jsx13("div", { className: twMerge2(chipVariants({ variant, size, className })), ...props });
759
+ var chipVariants = cva4(["flex", "items-center", "rounded-3xl", "border", "w-fit"], {
760
+ variants: {
761
+ variant: {
762
+ neutral: ["text-grey-80", "border-grey-10"],
763
+ primary: ["text-purple-100", "border-purple-20"],
764
+ danger: ["text-pumpkin-100", "border-pumpkin-20"],
765
+ onboarding: ["text-green-100", "bg-green-10", "cursor-pointer"],
766
+ onboardingSelected: ["text-white", "bg-green-90", "cursor-pointer"]
767
+ },
768
+ size: {
769
+ small: ["text-sm", "leading-5", "px-2", "py-1", "gap-1.5"],
770
+ medium: ["text-base", "leading-6", "px-3", "py-2", "gap-2"]
771
+ }
772
+ },
773
+ defaultVariants: {
774
+ variant: "neutral",
775
+ size: "medium"
776
+ }
777
+ });
778
+ var Chip_default = Chip;
779
+
780
+ // src/components/ui/Select.tsx
781
+ import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
782
+ var Select = forwardRef8(
783
+ ({ label, options, placeholder, multiselect, classNames, error, id, ...props }, ref) => {
784
+ const { value, defaultValue, dir, className, onChange, ...rest } = props;
785
+ const [selected, setSelected] = useState3([]);
786
+ const [open, setOpen] = useState3(false);
787
+ const containerRef = useRef(null);
788
+ useEffect2(() => {
789
+ if (!value) return setSelected([]);
790
+ setSelected(Array.isArray(value) ? value : [value]);
791
+ }, [value]);
792
+ const toggleOpen = () => setOpen((prev) => !prev);
793
+ const closeOnEscape = (event) => event.key === "Escape" && setOpen(false);
794
+ const setValueOnEnter = (event, value2) => event.key === "Enter" && handleChange(value2);
795
+ const chipLabels = selected?.map((s) => options?.find(({ value: value2 }) => value2 === s)).filter(Boolean);
796
+ function handleLabels() {
797
+ if (multiselect) {
798
+ return selected.map((o) => options?.find((option) => option.value === o)?.title).join(", ");
799
+ }
800
+ return options?.find((option) => option.value === selected.join())?.title;
801
+ }
802
+ function handleOnOpenChange(isOpen) {
803
+ if (!multiselect || isOpen) setOpen(isOpen);
804
+ }
805
+ function handleChange(newValue) {
806
+ let newSelected = [];
807
+ setSelected((prev) => {
808
+ newSelected = prev.includes(newValue) ? prev.filter((item) => item !== newValue) : [...prev, newValue];
809
+ return multiselect ? newSelected : [newValue];
810
+ });
811
+ onChange?.(multiselect ? newSelected : newValue);
812
+ }
813
+ return /* @__PURE__ */ jsxs7(
814
+ "div",
815
+ {
816
+ className: cn("flex flex-col space-y-1", className),
817
+ ref: containerRef,
818
+ "data-testid": `${(label ?? id)?.toLowerCase()}-select-element`,
819
+ children: [
820
+ /* @__PURE__ */ jsx14(Label_default, { text: label, className: classNames?.label }),
821
+ /* @__PURE__ */ jsxs7(
822
+ SelectPrimitive.Root,
823
+ {
824
+ open,
825
+ value: selected.join(","),
826
+ onOpenChange: handleOnOpenChange,
827
+ onValueChange: multiselect ? void 0 : handleChange,
828
+ defaultValue: typeof defaultValue === "string" ? defaultValue : void 0,
829
+ dir: dir === "rtl" ? "rtl" : "ltr",
830
+ ...rest,
831
+ children: [
832
+ /* @__PURE__ */ jsxs7(
833
+ SelectPrimitive.Trigger,
834
+ {
835
+ ref,
836
+ className: cn(
837
+ "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",
838
+ classNames?.trigger
839
+ ),
840
+ children: [
841
+ /* @__PURE__ */ jsx14("span", { className: "truncate", children: /* @__PURE__ */ jsx14(
842
+ SelectPrimitive.Value,
843
+ {
844
+ placeholder: placeholder ?? "Select an option",
845
+ "aria-label": handleLabels(),
846
+ children: handleLabels()
847
+ }
848
+ ) }),
849
+ /* @__PURE__ */ jsx14(
850
+ ChevronDownIcon2,
851
+ {
852
+ className: "transform text-black group-data-[state=open]:rotate-180",
853
+ size: "16"
854
+ }
855
+ )
856
+ ]
857
+ }
858
+ ),
859
+ /* @__PURE__ */ jsx14(SelectPrimitive.Portal, { container: containerRef.current, children: /* @__PURE__ */ jsx14(
860
+ SelectPrimitive.Content,
861
+ {
862
+ hideWhenDetached: true,
863
+ 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",
864
+ position: "popper",
865
+ sideOffset: 4,
866
+ onPointerDownOutside: toggleOpen,
867
+ onKeyDown: closeOnEscape,
868
+ children: /* @__PURE__ */ jsxs7(SelectPrimitive.Viewport, { children: [
869
+ multiselect && !!chipLabels?.length && /* @__PURE__ */ jsx14(
870
+ SelectPrimitive.Group,
871
+ {
872
+ className: "mb-2 flex flex-row flex-wrap gap-1 px-2",
873
+ "data-testid": "selected-labels",
874
+ children: chipLabels?.map(
875
+ (chip) => chip && /* @__PURE__ */ jsxs7(Chip_default, { size: "small", variant: "primary", children: [
876
+ /* @__PURE__ */ jsx14("span", { children: chip.title }),
877
+ /* @__PURE__ */ jsx14(
878
+ X2,
879
+ {
880
+ size: 18,
881
+ "data-testid": `chip-remove-${chip.value}`,
882
+ className: "cursor-pointer",
883
+ onClick: () => handleChange(chip.value)
884
+ }
885
+ )
886
+ ] }, chip.title)
887
+ )
888
+ }
889
+ ),
890
+ /* @__PURE__ */ jsx14(Separator, {}),
891
+ options?.map(({ id: id2, title, value: value2 }) => /* @__PURE__ */ jsxs7(
892
+ SelectPrimitive.Item,
893
+ {
894
+ value: value2,
895
+ 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",
896
+ "data-state": selected.includes(value2) ? "checked" : "unchecked",
897
+ onKeyDown: (e) => setValueOnEnter(e, value2),
898
+ onClick: () => handleChange(value2),
899
+ children: [
900
+ /* @__PURE__ */ jsx14(SelectPrimitive.ItemText, { children: title }),
901
+ /* @__PURE__ */ jsx14(
902
+ CheckIcon2,
903
+ {
904
+ className: "absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block",
905
+ size: 16
906
+ }
907
+ )
908
+ ]
909
+ },
910
+ id2
911
+ ))
912
+ ] })
913
+ }
914
+ ) })
915
+ ]
916
+ }
917
+ ),
918
+ /* @__PURE__ */ jsx14(ErrorMessage_default, { message: error, className: "mt-1" })
919
+ ]
920
+ }
921
+ );
922
+ }
923
+ );
924
+ Select.displayName = "Select";
925
+ var Select_default = Select;
926
+
927
+ // src/components/demos/SelectDemo.tsx
928
+ import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
929
+ function SelectDemo() {
930
+ return /* @__PURE__ */ jsxs8("div", { className: "m-4", children: [
931
+ /* @__PURE__ */ jsx15("h3", { children: "Select" }),
932
+ /* @__PURE__ */ jsxs8("div", { className: "flex max-w-sm flex-col gap-4 mt-2", children: [
933
+ /* @__PURE__ */ jsx15(
934
+ Select_default,
935
+ {
936
+ label: "Label - Singleselect",
937
+ placeholder: "Select an option",
938
+ options: [
939
+ { id: "1", value: "1", title: "Option 1" },
940
+ { id: "2", value: "2", title: "Option 2" },
941
+ { id: "3", value: "3", title: "Option 3" }
942
+ ]
943
+ }
944
+ ),
945
+ /* @__PURE__ */ jsx15(
946
+ Select_default,
947
+ {
948
+ multiselect: true,
949
+ label: "Label - Multiselect",
950
+ placeholder: "Select an option",
951
+ options: [
952
+ { id: "1", value: "1", title: "Option 1" },
953
+ { id: "2", value: "2", title: "Option 2" },
954
+ { id: "3", value: "3", title: "Option 3" },
955
+ { id: "4", value: "4", title: "Option 4" },
956
+ { id: "5", value: "5", title: "Option 5" },
957
+ { id: "6", value: "6", title: "Option 6" },
958
+ { id: "7", value: "7", title: "Option 7" },
959
+ { id: "8", value: "8", title: "Option 8" },
960
+ { id: "9", value: "9", title: "Option 9" },
961
+ { id: "10", value: "10", title: "Option 10" }
962
+ ]
963
+ }
964
+ ),
965
+ /* @__PURE__ */ jsx15(
966
+ Select_default,
967
+ {
968
+ disabled: true,
969
+ label: "Label - Disabled",
970
+ placeholder: "Select an option",
971
+ options: [
972
+ { id: "1", value: "1", title: "Option 1" },
973
+ { id: "2", value: "2", title: "Option 2" },
974
+ { id: "3", value: "3", title: "Option 3" }
975
+ ]
976
+ }
977
+ )
978
+ ] })
979
+ ] });
980
+ }
981
+ var SelectDemo_default = SelectDemo;
982
+
983
+ // src/components/ui/Input.tsx
984
+ import { cva as cva5 } from "cva";
985
+ import { icons as icons3, X as X3 } from "lucide-react";
986
+ import { forwardRef as forwardRef9 } from "react";
987
+ import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
988
+ var Input = forwardRef9(
989
+ ({ label, error, theme, icon, onClear, value, onChange, classNames, ...props }, ref) => {
990
+ const handleClear = () => {
991
+ onChange?.({ target: { value: "" } });
992
+ onClear?.();
993
+ };
994
+ const IconComponent = icon && icons3[icon];
995
+ const placeholder = props.placeholder ?? (icon === "Search" ? "Search..." : "");
996
+ const hasIcon = !!icon;
997
+ const iconColor = theme === "dark" ? "text-white" : "text-grey-80";
998
+ return /* @__PURE__ */ jsxs9("div", { className: "group flex w-full flex-col", "data-testid": `input-wrapper-${props.id}`, children: [
999
+ label && /* @__PURE__ */ jsx16(Label_default, { text: label, htmlFor: props.name, className: cn("body mb-1", classNames?.label) }),
1000
+ /* @__PURE__ */ jsxs9("div", { className: "relative flex flex-row items-center", children: [
1001
+ IconComponent && /* @__PURE__ */ jsx16(
1002
+ IconComponent,
1003
+ {
1004
+ className: `absolute left-3 h-4 w-4 ${iconColor} opacity-50 group-hover:opacity-100`
1005
+ }
1006
+ ),
1007
+ /* @__PURE__ */ jsx16(
1008
+ "input",
1009
+ {
1010
+ className: cn(inputVariants({ theme, hasIcon })),
1011
+ ref,
1012
+ placeholder,
1013
+ value,
1014
+ onChange,
1015
+ "data-testid": `input-element-${props.id}`,
1016
+ ...props
1017
+ }
1018
+ ),
1019
+ hasIcon && value && /* @__PURE__ */ jsx16(
1020
+ X3,
1021
+ {
1022
+ className: `absolute right-3 h-4 w-4 cursor-pointer ${iconColor}`,
1023
+ onClick: handleClear,
1024
+ "data-testid": "clear-button"
1025
+ }
1026
+ )
1027
+ ] }),
1028
+ /* @__PURE__ */ jsx16(ErrorMessage_default, { message: error, className: "mt-1" })
1029
+ ] });
1030
+ }
1031
+ );
1032
+ Input.displayName = "Input";
1033
+ var inputVariants = cva5(
1034
+ [
1035
+ "border-input",
1036
+ "placeholder:text-muted-foreground",
1037
+ "focus-visible:ring-ring",
1038
+ "inline-flex",
1039
+ "w-full",
1040
+ "h-11",
1041
+ "items-center",
1042
+ "justify-start",
1043
+ "gap-3",
1044
+ "rounded-lg",
1045
+ "bg-transparent",
1046
+ "px-3",
1047
+ "pt-0.5",
1048
+ "text-sm",
1049
+ "shadow-sm",
1050
+ "ring-grey-50",
1051
+ "transition-colors",
1052
+ "focus-visible:outline-none",
1053
+ "focus-visible:ring-1",
1054
+ "disabled:cursor-not-allowed",
1055
+ "disabled:opacity-50",
1056
+ "appearance-none",
1057
+ "[&::-webkit-search-cancel-button]:appearance-none",
1058
+ "[&::-webkit-search-decoration]:appearance-none",
1059
+ "[&::-webkit-search-results-button]:appearance-none",
1060
+ "[&::-webkit-search-results-decoration]:appearance-none",
1061
+ "[&::-ms-clear]:display-none",
1062
+ "[&::-ms-reveal]:display-none"
1063
+ ],
1064
+ {
1065
+ variants: {
1066
+ theme: {
1067
+ light: "text-grey-80 border",
1068
+ dark: "text-white"
1069
+ },
1070
+ hasIcon: {
1071
+ false: "pl-3",
1072
+ true: "pl-8"
1073
+ }
1074
+ },
1075
+ defaultVariants: {
1076
+ theme: "light",
1077
+ hasIcon: false
1078
+ }
1079
+ }
1080
+ );
1081
+ var Input_default = Input;
1082
+
1083
+ // src/components/demos/InputDemo.tsx
1084
+ import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1085
+ function InputDemo() {
1086
+ return /* @__PURE__ */ jsxs10("div", { className: "m-4", children: [
1087
+ /* @__PURE__ */ jsx17("h3", { children: "Input" }),
1088
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-2 md:flex-row", children: [
1089
+ /* @__PURE__ */ jsx17("div", { className: "bg-green-80 p-2", children: /* @__PURE__ */ jsx17(Input_default, { theme: "dark", icon: "Search" }) }),
1090
+ /* @__PURE__ */ jsx17("div", { className: "p-2", children: /* @__PURE__ */ jsx17(Input_default, {}) }),
1091
+ /* @__PURE__ */ jsx17("div", { className: "p-2", children: /* @__PURE__ */ jsx17(Input_default, { icon: "MapPin" }) })
1092
+ ] })
1093
+ ] });
1094
+ }
1095
+ var InputDemo_default = InputDemo;
1096
+
1097
+ // src/components/demos/index.tsx
1098
+ import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
738
1099
  function Demos() {
739
- return /* @__PURE__ */ jsx12("div", { children: /* @__PURE__ */ jsx12(ComboboxDemo_default, {}) });
1100
+ return /* @__PURE__ */ jsxs11("div", { children: [
1101
+ /* @__PURE__ */ jsx18(ComboboxDemo_default, {}),
1102
+ /* @__PURE__ */ jsx18(SelectDemo_default, {}),
1103
+ /* @__PURE__ */ jsx18(InputDemo_default, {})
1104
+ ] });
740
1105
  }
741
1106
  var demos_default = Demos;
742
1107
 
743
1108
  // src/app/page.tsx
744
- import { jsx as jsx13 } from "react/jsx-runtime";
1109
+ import { jsx as jsx19 } from "react/jsx-runtime";
745
1110
  async function Page() {
746
- return /* @__PURE__ */ jsx13(demos_default, {});
1111
+ return /* @__PURE__ */ jsx19(demos_default, {});
747
1112
  }
748
1113
  var page_default = Page;
749
1114
  export {