@lets-events/react 10.0.1 → 10.1.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.
Files changed (47) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +19 -18
  3. package/CHANGELOG.md +12 -0
  4. package/dist/index.d.mts +426 -1
  5. package/dist/index.d.ts +426 -1
  6. package/dist/index.js +340 -20
  7. package/dist/index.mjs +331 -19
  8. package/package.json +3 -1
  9. package/src/components/Alert.tsx +303 -303
  10. package/src/components/Avatar.tsx +55 -55
  11. package/src/components/Badge.tsx +128 -128
  12. package/src/components/Box.tsx +3 -3
  13. package/src/components/Button/index.tsx +12 -12
  14. package/src/components/Button/styledComponents.ts +250 -250
  15. package/src/components/ButtonGroup.tsx +484 -484
  16. package/src/components/Calendar/index.tsx +136 -136
  17. package/src/components/Calendar/styledComponents.ts +208 -208
  18. package/src/components/Card.tsx +69 -69
  19. package/src/components/CheckboxGroup.tsx +214 -214
  20. package/src/components/Container.tsx +39 -39
  21. package/src/components/Dropdown.tsx +167 -167
  22. package/src/components/Filter.tsx +164 -164
  23. package/src/components/Flex.tsx +118 -118
  24. package/src/components/Grid.tsx +137 -137
  25. package/src/components/Icon.tsx +47 -47
  26. package/src/components/Modal.tsx +90 -90
  27. package/src/components/RadioGroup.tsx +210 -210
  28. package/src/components/Section.tsx +33 -33
  29. package/src/components/Step.tsx +164 -164
  30. package/src/components/Switch.tsx +108 -108
  31. package/src/components/Text.tsx +30 -30
  32. package/src/components/TextField.tsx +299 -299
  33. package/src/components/TextareaField.tsx +101 -101
  34. package/src/components/TimePicker.tsx +280 -239
  35. package/src/components/Toast/components/ToastItem.tsx +41 -0
  36. package/src/components/Toast/components/ToastProvider.tsx +63 -0
  37. package/src/components/Toast/hooks/useToast.ts +12 -0
  38. package/src/components/Toast/index.tsx +5 -0
  39. package/src/components/Toast/styles/index.ts +135 -0
  40. package/src/components/Toast/types/index.ts +46 -0
  41. package/src/components/Tooltip/index.tsx +67 -0
  42. package/src/components/Tooltip/styles.ts +78 -0
  43. package/src/hooks/useOnClickOutside.tsx +20 -20
  44. package/src/index.tsx +33 -31
  45. package/src/styles/index.ts +38 -38
  46. package/src/types/typographyValues.ts +178 -178
  47. package/tsconfig.json +3 -3
package/dist/index.mjs CHANGED
@@ -7888,8 +7888,21 @@ var InputStyled = styled("input", {
7888
7888
  color: "$dark400",
7889
7889
  border: "1px solid $dark200",
7890
7890
  cursor: "not-allowed"
7891
+ },
7892
+ inputMode: "numeric",
7893
+ "&::-webkit-inner-spin-button": {
7894
+ WebkitAppearance: "none",
7895
+ margin: 0
7896
+ },
7897
+ "&::-webkit-outer-spin-button": {
7898
+ WebkitAppearance: "none",
7899
+ margin: 0
7900
+ },
7901
+ "&[type='number']": {
7902
+ MozAppearance: "textfield"
7891
7903
  }
7892
7904
  });
7905
+ var pad = (num) => String(num).padStart(2, "0");
7893
7906
  function TimePicker({
7894
7907
  selected,
7895
7908
  setSelected,
@@ -7897,25 +7910,21 @@ function TimePicker({
7897
7910
  }) {
7898
7911
  const [hours, setHours] = useState2("00");
7899
7912
  const [minutes, setMinutes] = useState2("00");
7913
+ const [rawHours, setRawHours] = useState2("00");
7914
+ const [rawMinutes, setRawMinutes] = useState2("00");
7900
7915
  const [isOpen, setIsOpen] = useState2(false);
7901
7916
  const dropdownRef = useRef2(null);
7902
7917
  useOnClickOutside(dropdownRef, () => setIsOpen(false));
7903
- const pad = (num) => String(num).padStart(2, "0");
7904
- const handleInputValue = useCallback(
7905
- (time) => {
7906
- setSelected(time);
7907
- setIsOpen(false);
7908
- },
7909
- [setSelected]
7910
- );
7911
7918
  const handleIncrement = useCallback(
7912
7919
  (type) => {
7913
7920
  if (type === "hours") {
7914
7921
  const next = (parseInt(hours) + 1) % 24;
7915
7922
  setHours(pad(next));
7923
+ setRawHours(pad(next));
7916
7924
  } else {
7917
7925
  const next = (parseInt(minutes) + 1) % 60;
7918
7926
  setMinutes(pad(next));
7927
+ setRawMinutes(pad(next));
7919
7928
  }
7920
7929
  },
7921
7930
  [hours, minutes]
@@ -7925,9 +7934,11 @@ function TimePicker({
7925
7934
  if (type === "hours") {
7926
7935
  const prev = (parseInt(hours) - 1 + 24) % 24;
7927
7936
  setHours(pad(prev));
7937
+ setRawHours(pad(prev));
7928
7938
  } else {
7929
7939
  const prev = (parseInt(minutes) - 1 + 60) % 60;
7930
7940
  setMinutes(pad(prev));
7941
+ setRawMinutes(pad(prev));
7931
7942
  }
7932
7943
  },
7933
7944
  [hours, minutes]
@@ -7998,10 +8009,39 @@ function TimePicker({
7998
8009
  /* @__PURE__ */ jsx15(
7999
8010
  InputStyled,
8000
8011
  {
8001
- value: unit === "hours" ? hours : minutes,
8002
- onChange: (e) => handleInputValue(e.target.value),
8012
+ inputMode: "numeric",
8013
+ pattern: "[0-9]*",
8003
8014
  type: "text",
8004
- placeholder: "00"
8015
+ placeholder: "00",
8016
+ value: unit === "hours" ? rawHours : rawMinutes,
8017
+ onChange: (e) => {
8018
+ const rawValue = e.target.value.replace(/\D/g, "");
8019
+ if (unit === "hours") {
8020
+ setRawHours(rawValue);
8021
+ } else {
8022
+ setRawMinutes(rawValue);
8023
+ }
8024
+ },
8025
+ onBlur: () => {
8026
+ let num = 0;
8027
+ if (unit === "hours") {
8028
+ num = Math.min(parseInt(rawHours || "0", 10), 23);
8029
+ const padded = pad(num);
8030
+ setHours(padded);
8031
+ setRawHours(padded);
8032
+ } else {
8033
+ num = Math.min(parseInt(rawMinutes || "0", 10), 59);
8034
+ const padded = pad(num);
8035
+ setMinutes(padded);
8036
+ setRawMinutes(padded);
8037
+ }
8038
+ },
8039
+ onPaste: (e) => {
8040
+ const paste = e.clipboardData.getData("Text");
8041
+ if (!/^\d{1,2}$/.test(paste)) {
8042
+ e.preventDefault();
8043
+ }
8044
+ }
8005
8045
  }
8006
8046
  ),
8007
8047
  /* @__PURE__ */ jsx15(
@@ -8050,7 +8090,10 @@ function TimePicker({
8050
8090
  type: "button",
8051
8091
  variant: "text",
8052
8092
  color: "brand",
8053
- onClick: () => handleInputValue(`${hours}:${minutes}`),
8093
+ onClick: () => {
8094
+ setSelected(`${hours}:${minutes}`);
8095
+ setIsOpen(false);
8096
+ },
8054
8097
  typography: "buttonMedium",
8055
8098
  fontWeight: "medium",
8056
8099
  children: "Aplicar"
@@ -8673,9 +8716,270 @@ function TextareaField(_a) {
8673
8716
  ] });
8674
8717
  }
8675
8718
 
8719
+ // src/components/Toast/components/ToastItem.tsx
8720
+ import { useState as useState3 } from "react";
8721
+
8722
+ // src/components/Toast/styles/index.ts
8723
+ import { keyframes as keyframes2 } from "@stitches/react";
8724
+ import * as ToastPrimitive from "@radix-ui/react-toast";
8725
+ var slideIn = keyframes2({
8726
+ from: {
8727
+ transform: "translateX(calc(100% + 25px))",
8728
+ opacity: 0
8729
+ },
8730
+ to: {
8731
+ transform: "translateX(0)",
8732
+ opacity: 1
8733
+ }
8734
+ });
8735
+ var slideOut = keyframes2({
8736
+ from: {
8737
+ transform: "translateX(0)",
8738
+ opacity: 1
8739
+ },
8740
+ to: {
8741
+ transform: "translateX(calc(100% + 25px))",
8742
+ opacity: 0
8743
+ }
8744
+ });
8745
+ var swipeOut = keyframes2({
8746
+ from: {
8747
+ transform: "translateX(var(--radix-toast-swipe-end-x))",
8748
+ opacity: 1
8749
+ },
8750
+ to: {
8751
+ transform: "translateX(calc(100% + 25px))",
8752
+ opacity: 0
8753
+ }
8754
+ });
8755
+ var ToastViewport = styled(ToastPrimitive.Viewport, {
8756
+ position: "fixed",
8757
+ top: 0,
8758
+ right: 0,
8759
+ display: "flex",
8760
+ flexDirection: "column",
8761
+ padding: 25,
8762
+ gap: 10,
8763
+ width: 390,
8764
+ maxWidth: "100vw",
8765
+ margin: 0,
8766
+ listStyle: "none",
8767
+ zIndex: 2147483647,
8768
+ outline: "none"
8769
+ });
8770
+ var ToastRoot = styled(ToastPrimitive.Root, {
8771
+ backgroundColor: "$neutral50",
8772
+ borderRadius: "$sm",
8773
+ boxShadow: "hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
8774
+ padding: "$16",
8775
+ gap: "$8",
8776
+ display: "flex",
8777
+ alignItems: "center",
8778
+ border: "1px solid",
8779
+ position: "relative",
8780
+ zIndex: 9999,
8781
+ '&[data-state="open"]': {
8782
+ animation: `${slideIn} 150ms cubic-bezier(0.16, 1, 0.3, 1)`
8783
+ },
8784
+ '&[data-state="closed"]': {
8785
+ animation: `${slideOut} 100ms ease-in`
8786
+ },
8787
+ '&[data-swipe="move"]': {
8788
+ transform: "translateX(var(--radix-toast-swipe-move-x))"
8789
+ },
8790
+ '&[data-swipe="cancel"]': {
8791
+ transform: "translateX(0)",
8792
+ transition: "transform 200ms ease-out"
8793
+ },
8794
+ '&[data-swipe="end"]': {
8795
+ animation: `${swipeOut} 100ms ease-out`
8796
+ },
8797
+ $$toastColor: "inherit",
8798
+ color: "$$toastColor",
8799
+ borderColor: "$$toastColor",
8800
+ variants: {
8801
+ type: {
8802
+ success: {
8803
+ $$toastColor: "$colors$success600",
8804
+ backgroundColor: "$success50"
8805
+ },
8806
+ error: {
8807
+ $$toastColor: "$colors$error600",
8808
+ backgroundColor: "$error50"
8809
+ },
8810
+ warning: {
8811
+ $$toastColor: "$colors$warning600",
8812
+ backgroundColor: "$warning50"
8813
+ },
8814
+ info: {
8815
+ $$toastColor: "$colors$info600",
8816
+ backgroundColor: "$info50"
8817
+ }
8818
+ }
8819
+ },
8820
+ defaultVariants: {
8821
+ type: "info"
8822
+ }
8823
+ });
8824
+ var ToastClose = styled(ToastPrimitive.Close, {
8825
+ border: "none",
8826
+ backgroundColor: "transparent",
8827
+ display: "flex",
8828
+ alignItems: "center",
8829
+ justifyContent: "center",
8830
+ color: "inherit",
8831
+ borderRadius: 4,
8832
+ padding: 4,
8833
+ cursor: "pointer",
8834
+ opacity: 0.7,
8835
+ "&:hover": {
8836
+ opacity: 1,
8837
+ backgroundColor: "rgba(0, 0, 0, 0.05)"
8838
+ },
8839
+ "&:focus": {
8840
+ boxShadow: "0 0 0 2px currentColor",
8841
+ opacity: 1
8842
+ }
8843
+ });
8844
+
8845
+ // src/components/Toast/components/ToastItem.tsx
8846
+ import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
8847
+ function ToastItem({
8848
+ toast,
8849
+ onRemove
8850
+ }) {
8851
+ const [open, setOpen] = useState3(true);
8852
+ const handleOpenChange = (open2) => {
8853
+ setOpen(open2);
8854
+ if (!open2) {
8855
+ onRemove(toast.id);
8856
+ }
8857
+ };
8858
+ return /* @__PURE__ */ jsxs9(
8859
+ ToastRoot,
8860
+ {
8861
+ type: toast.type,
8862
+ duration: toast.duration,
8863
+ open,
8864
+ onOpenChange: handleOpenChange,
8865
+ children: [
8866
+ (toast == null ? void 0 : toast.icon) && /* @__PURE__ */ jsx21(Icon_default, { name: toast.icon, size: "xl" }),
8867
+ /* @__PURE__ */ jsx21("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsx21(Text, { typography: "bodyS", fontWeight: "medium", children: toast.message }) }),
8868
+ /* @__PURE__ */ jsx21(ToastClose, { "aria-label": "Close", children: /* @__PURE__ */ jsx21(Icon_default, { name: "xmark", size: "md" }) })
8869
+ ]
8870
+ }
8871
+ );
8872
+ }
8873
+
8874
+ // src/components/Toast/components/ToastProvider.tsx
8875
+ import { createContext, useState as useState4 } from "react";
8876
+ import * as ToastPrimitive2 from "@radix-ui/react-toast";
8877
+ import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
8878
+ var ToastContext = createContext(null);
8879
+ function ToastProvider({
8880
+ children,
8881
+ defaultDuration = 5e3,
8882
+ maxToasts = 5,
8883
+ swipeDirection = "right"
8884
+ }) {
8885
+ const [toasts, setToasts] = useState4([]);
8886
+ const addToast = (toastData) => {
8887
+ const id = Math.random().toString(36).substr(2, 9);
8888
+ const newToast = __spreadProps(__spreadValues({
8889
+ id
8890
+ }, toastData), {
8891
+ type: (toastData == null ? void 0 : toastData.type) || "info",
8892
+ duration: (toastData == null ? void 0 : toastData.duration) || defaultDuration,
8893
+ createdAt: Date.now()
8894
+ });
8895
+ setToasts((prevToasts) => {
8896
+ const updatedToasts = [...prevToasts, newToast];
8897
+ return updatedToasts.slice(-maxToasts);
8898
+ });
8899
+ return id;
8900
+ };
8901
+ const removeToast = (id) => {
8902
+ setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));
8903
+ };
8904
+ const removeAllToasts = () => {
8905
+ setToasts([]);
8906
+ };
8907
+ const contextValue = {
8908
+ toasts,
8909
+ addToast,
8910
+ removeToast,
8911
+ removeAllToasts
8912
+ };
8913
+ return /* @__PURE__ */ jsx22(ToastContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs10(ToastPrimitive2.Provider, { swipeDirection, children: [
8914
+ children,
8915
+ toasts.map((toast) => /* @__PURE__ */ jsx22(ToastItem, { toast, onRemove: removeToast }, toast.id)),
8916
+ /* @__PURE__ */ jsx22(ToastViewport, {})
8917
+ ] }) });
8918
+ }
8919
+
8920
+ // src/components/Toast/hooks/useToast.ts
8921
+ import { useContext } from "react";
8922
+ var useToast = () => {
8923
+ const context = useContext(ToastContext);
8924
+ if (!context) {
8925
+ throw new Error("useToast deve ser usado dentro de um ToastProvider");
8926
+ }
8927
+ return context;
8928
+ };
8929
+
8930
+ // src/components/Tooltip/index.tsx
8931
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
8932
+ import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
8933
+ var TooltipProvider = TooltipPrimitive.Provider;
8934
+ var TooltipRoot = TooltipPrimitive.Root;
8935
+ var TooltipTrigger = TooltipPrimitive.Trigger;
8936
+ var TooltipContent = styled(TooltipPrimitive.Content, {
8937
+ backgroundColor: "$dark800",
8938
+ color: "$neutral50",
8939
+ borderRadius: "4px",
8940
+ padding: "10px 15px",
8941
+ fontSize: "14px",
8942
+ lineHeight: 1,
8943
+ zIndex: 100,
8944
+ boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)",
8945
+ userSelect: "none",
8946
+ animationDuration: "400ms",
8947
+ animationTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)",
8948
+ willChange: "transform, opacity",
8949
+ '&[data-state="delayed-open"][data-side="top"]': {
8950
+ animationName: "slideDownAndFade"
8951
+ },
8952
+ '&[data-state="delayed-open"][data-side="right"]': {
8953
+ animationName: "slideLeftAndFade"
8954
+ },
8955
+ '&[data-state="delayed-open"][data-side="bottom"]': {
8956
+ animationName: "slideUpAndFade"
8957
+ },
8958
+ '&[data-state="delayed-open"][data-side="left"]': {
8959
+ animationName: "slideRightAndFade"
8960
+ }
8961
+ });
8962
+ var TooltipArrow = styled(TooltipPrimitive.Arrow, {
8963
+ fill: "$dark800"
8964
+ });
8965
+ function Tooltip({
8966
+ children,
8967
+ content,
8968
+ delayDuration = 200,
8969
+ side = "top"
8970
+ }) {
8971
+ return /* @__PURE__ */ jsx23(TooltipProvider, { children: /* @__PURE__ */ jsxs11(TooltipRoot, { delayDuration, children: [
8972
+ /* @__PURE__ */ jsx23(TooltipTrigger, { asChild: true, children }),
8973
+ /* @__PURE__ */ jsxs11(TooltipContent, { side, sideOffset: 5, children: [
8974
+ typeof content === "string" ? /* @__PURE__ */ jsx23(Text, { typography: "tooltip", children: content }) : content,
8975
+ /* @__PURE__ */ jsx23(TooltipArrow, {})
8976
+ ] })
8977
+ ] }) });
8978
+ }
8979
+
8676
8980
  // src/components/Grid.tsx
8677
8981
  import { Grid as GridRadix } from "@radix-ui/themes";
8678
- import { jsx as jsx21 } from "react/jsx-runtime";
8982
+ import { jsx as jsx24 } from "react/jsx-runtime";
8679
8983
  var GridStyled = styled(GridRadix, {
8680
8984
  display: "grid",
8681
8985
  variants: {
@@ -8797,12 +9101,12 @@ var GridStyled = styled(GridRadix, {
8797
9101
  });
8798
9102
  function Grid(_a) {
8799
9103
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
8800
- return /* @__PURE__ */ jsx21(GridStyled, __spreadProps(__spreadValues({}, props), { children }));
9104
+ return /* @__PURE__ */ jsx24(GridStyled, __spreadProps(__spreadValues({}, props), { children }));
8801
9105
  }
8802
9106
 
8803
9107
  // src/components/Container.tsx
8804
9108
  import { Container as ContainerRadix } from "@radix-ui/themes";
8805
- import { jsx as jsx22 } from "react/jsx-runtime";
9109
+ import { jsx as jsx25 } from "react/jsx-runtime";
8806
9110
  var ContainerStyled = styled(ContainerRadix, {
8807
9111
  variants: {
8808
9112
  size: {
@@ -8832,12 +9136,12 @@ var ContainerStyled = styled(ContainerRadix, {
8832
9136
  });
8833
9137
  function Container(_a) {
8834
9138
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
8835
- return /* @__PURE__ */ jsx22(ContainerStyled, __spreadProps(__spreadValues({}, props), { children }));
9139
+ return /* @__PURE__ */ jsx25(ContainerStyled, __spreadProps(__spreadValues({}, props), { children }));
8836
9140
  }
8837
9141
 
8838
9142
  // src/components/Section.tsx
8839
9143
  import { Section as SectionRadix } from "@radix-ui/themes";
8840
- import { jsx as jsx23 } from "react/jsx-runtime";
9144
+ import { jsx as jsx26 } from "react/jsx-runtime";
8841
9145
  var SectionStyled = styled(SectionRadix, {
8842
9146
  variants: {
8843
9147
  size: {
@@ -8861,7 +9165,7 @@ var SectionStyled = styled(SectionRadix, {
8861
9165
  });
8862
9166
  function Section(_a) {
8863
9167
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
8864
- return /* @__PURE__ */ jsx23(SectionStyled, __spreadProps(__spreadValues({}, props), { children }));
9168
+ return /* @__PURE__ */ jsx26(SectionStyled, __spreadProps(__spreadValues({}, props), { children }));
8865
9169
  }
8866
9170
  export {
8867
9171
  Alert,
@@ -8928,8 +9232,16 @@ export {
8928
9232
  TimePickerFooterStyled,
8929
9233
  TimePickerStyled,
8930
9234
  TimerPickerContentStyled,
9235
+ ToastItem,
9236
+ ToastProvider,
9237
+ Tooltip,
9238
+ TooltipContent,
9239
+ TooltipProvider,
9240
+ TooltipRoot,
9241
+ TooltipTrigger,
8931
9242
  maskFormat,
8932
- maskUnformat
9243
+ maskUnformat,
9244
+ useToast
8933
9245
  };
8934
9246
  /*! Bundled license information:
8935
9247
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "10.0.1",
3
+ "version": "10.1.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -31,6 +31,8 @@
31
31
  "@fortawesome/free-regular-svg-icons": "^6.7.2",
32
32
  "@fortawesome/free-solid-svg-icons": "^6.7.2",
33
33
  "@fortawesome/react-fontawesome": "^0.2.2",
34
+ "@radix-ui/react-toast": "^1.2.14",
35
+ "@radix-ui/react-tooltip": "^1.2.7",
34
36
  "@radix-ui/themes": "^3.2.1",
35
37
  "@react-input/mask": "^2.0.4",
36
38
  "@stitches/react": "^1.2.8",