@lets-events/react 11.0.5 → 11.1.0

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.mjs CHANGED
@@ -2537,14 +2537,14 @@ var TextFieldStyled = styled(TextFieldRadix.Root, {
2537
2537
  color: {
2538
2538
  default: {
2539
2539
  color: "$dark400",
2540
- border: "1px solid $dark200",
2540
+ border: "1px solid $dark300",
2541
2541
  "&:has(input:focus)": {
2542
2542
  border: "2px solid $brand300"
2543
2543
  },
2544
2544
  "&:has(input:disabled)": {
2545
2545
  backgroundColor: "$dark100",
2546
2546
  color: "$dark400",
2547
- border: "1px solid $dark200",
2547
+ border: "1px solid $dark300",
2548
2548
  cursor: "not-allowed"
2549
2549
  }
2550
2550
  },
@@ -8696,7 +8696,6 @@ var TextareaContainer = styled("div", {
8696
8696
  overflow: "hidden",
8697
8697
  width: "100%",
8698
8698
  border: "1px solid",
8699
- borderColor: "$dark300",
8700
8699
  borderRadius: "$sm",
8701
8700
  "&:has(textarea:focus)": {
8702
8701
  border: "1px solid $brand300"
@@ -8706,6 +8705,19 @@ var TextareaContainer = styled("div", {
8706
8705
  color: "$dark400",
8707
8706
  border: "1px solid $dark200",
8708
8707
  cursor: "not-allowed"
8708
+ },
8709
+ variants: {
8710
+ color: {
8711
+ default: {
8712
+ borderColor: "$dark300"
8713
+ },
8714
+ error: {
8715
+ borderColor: "$error400"
8716
+ }
8717
+ }
8718
+ },
8719
+ defaultVariants: {
8720
+ color: "default"
8709
8721
  }
8710
8722
  });
8711
8723
  var TextareaLimitIndicator = styled("div", {
@@ -8723,7 +8735,7 @@ var TextareaLimitIndicator = styled("div", {
8723
8735
  }
8724
8736
  });
8725
8737
  var TextareaField = React6.forwardRef((_a, fowardedRef) => {
8726
- var _b = _a, { maxLength } = _b, props = __objRest(_b, ["maxLength"]);
8738
+ var _b = _a, { maxLength, color } = _b, props = __objRest(_b, ["maxLength", "color"]);
8727
8739
  const inputRef = useRef3(null);
8728
8740
  const badgeRef = useRef3(null);
8729
8741
  const updateCharCountBadge = () => {
@@ -8737,11 +8749,11 @@ var TextareaField = React6.forwardRef((_a, fowardedRef) => {
8737
8749
  updateCharCountBadge();
8738
8750
  (_a2 = props.onInput) == null ? void 0 : _a2.call(props, e);
8739
8751
  };
8740
- return /* @__PURE__ */ jsxs8(TextareaContainer, { children: [
8752
+ return /* @__PURE__ */ jsxs8(TextareaContainer, { color, children: [
8741
8753
  /* @__PURE__ */ jsx20(
8742
8754
  TextareaFieldStyle,
8743
8755
  __spreadValues({
8744
- rows: 3,
8756
+ rows: 4,
8745
8757
  ref: (r) => {
8746
8758
  if (!r) return;
8747
8759
  inputRef.current = r;
@@ -9211,6 +9223,121 @@ function Section(_a) {
9211
9223
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
9212
9224
  return /* @__PURE__ */ jsx26(SectionStyled, __spreadProps(__spreadValues({}, props), { children }));
9213
9225
  }
9226
+
9227
+ // src/components/FormFields/ErrorFormMessage.tsx
9228
+ import { faXmarkCircle } from "@fortawesome/free-solid-svg-icons";
9229
+ import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
9230
+ import { jsx as jsx27, jsxs as jsxs12 } from "react/jsx-runtime";
9231
+ var ErrorFormMessage = ({ message: message2 }) => {
9232
+ if (!message2) return;
9233
+ if (typeof message2 !== "string") {
9234
+ return null;
9235
+ }
9236
+ return /* @__PURE__ */ jsxs12(Flex2, { justify: "start", align: "center", gap: 6, children: [
9237
+ /* @__PURE__ */ jsx27(FontAwesomeIcon2, { icon: faXmarkCircle, color: colors.error600, size: "1x" }),
9238
+ /* @__PURE__ */ jsx27(Text, { typography: "bodyXS", fontWeight: "medium", color: "error600", children: message2 })
9239
+ ] });
9240
+ };
9241
+
9242
+ // src/components/FormFields/FormLabel.tsx
9243
+ import { jsx as jsx28, jsxs as jsxs13 } from "react/jsx-runtime";
9244
+ var FormLabel = ({
9245
+ name,
9246
+ label,
9247
+ haveError,
9248
+ required
9249
+ }) => {
9250
+ if (!label) return null;
9251
+ return /* @__PURE__ */ jsxs13(
9252
+ Text,
9253
+ {
9254
+ typography: "labelMedium",
9255
+ fontWeight: "medium",
9256
+ color: haveError ? "error600" : "dark700",
9257
+ id: `${name}-label`,
9258
+ children: [
9259
+ label,
9260
+ !required && /* @__PURE__ */ jsx28(Text, { color: "dark500", children: " (opcional)" })
9261
+ ]
9262
+ }
9263
+ );
9264
+ };
9265
+
9266
+ // src/components/FormFields/TextAreaFormField.tsx
9267
+ import { useFormContext } from "react-hook-form";
9268
+ import { jsx as jsx29, jsxs as jsxs14 } from "react/jsx-runtime";
9269
+ var TextAreaFormField = ({
9270
+ name,
9271
+ label,
9272
+ required,
9273
+ placeholder
9274
+ }) => {
9275
+ var _a;
9276
+ const {
9277
+ register,
9278
+ formState: { errors }
9279
+ } = useFormContext();
9280
+ const haveError = !!errors[name];
9281
+ const errorMsg = (_a = errors[name]) == null ? void 0 : _a.message;
9282
+ return /* @__PURE__ */ jsxs14(Flex2, { direction: "column", children: [
9283
+ /* @__PURE__ */ jsx29(
9284
+ FormLabel,
9285
+ {
9286
+ name,
9287
+ label,
9288
+ required,
9289
+ haveError
9290
+ }
9291
+ ),
9292
+ /* @__PURE__ */ jsx29(
9293
+ TextareaField,
9294
+ __spreadProps(__spreadValues({}, register(name, { required })), {
9295
+ placeholder,
9296
+ color: haveError ? "error" : "default",
9297
+ "aria-labelledby": `${name}-label`
9298
+ })
9299
+ ),
9300
+ /* @__PURE__ */ jsx29(ErrorFormMessage, { message: errorMsg })
9301
+ ] });
9302
+ };
9303
+
9304
+ // src/components/FormFields/TextFormField.tsx
9305
+ import { useFormContext as useFormContext2 } from "react-hook-form";
9306
+ import { jsx as jsx30, jsxs as jsxs15 } from "react/jsx-runtime";
9307
+ var TextFormField = ({
9308
+ name,
9309
+ label,
9310
+ required,
9311
+ placeholder
9312
+ }) => {
9313
+ var _a;
9314
+ const {
9315
+ register,
9316
+ formState: { errors }
9317
+ } = useFormContext2();
9318
+ const haveError = !!errors[name];
9319
+ const errorMsg = (_a = errors[name]) == null ? void 0 : _a.message;
9320
+ return /* @__PURE__ */ jsxs15(Flex2, { direction: "column", children: [
9321
+ /* @__PURE__ */ jsx30(
9322
+ FormLabel,
9323
+ {
9324
+ name,
9325
+ label,
9326
+ required,
9327
+ haveError
9328
+ }
9329
+ ),
9330
+ /* @__PURE__ */ jsx30(
9331
+ TextField,
9332
+ __spreadProps(__spreadValues({}, register(name, { required })), {
9333
+ placeholder,
9334
+ color: haveError ? "error" : "default",
9335
+ "aria-labelledby": `${name}-label`
9336
+ })
9337
+ ),
9338
+ /* @__PURE__ */ jsx30(ErrorFormMessage, { message: errorMsg })
9339
+ ] });
9340
+ };
9214
9341
  export {
9215
9342
  Alert,
9216
9343
  AlertDialogCompleteStyled,
@@ -9240,10 +9367,12 @@ export {
9240
9367
  ContainerStyled,
9241
9368
  DropdownMenu2 as DropdownMenu,
9242
9369
  DropdownMenuItem,
9370
+ ErrorFormMessage,
9243
9371
  Filter,
9244
9372
  FilterItem,
9245
9373
  Flex2 as Flex,
9246
9374
  FlexStyled,
9375
+ FormLabel,
9247
9376
  Grid,
9248
9377
  GridStyled,
9249
9378
  Icon,
@@ -9263,10 +9392,12 @@ export {
9263
9392
  Switch,
9264
9393
  SwitchStyled,
9265
9394
  Text,
9395
+ TextAreaFormField,
9266
9396
  TextField,
9267
9397
  TextFieldSlot,
9268
9398
  TextFieldSlotStyled,
9269
9399
  TextFieldStyled,
9400
+ TextFormField,
9270
9401
  TextStyle,
9271
9402
  TextareaField,
9272
9403
  TextareaFieldStyle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "11.0.5",
3
+ "version": "11.1.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -36,7 +36,10 @@
36
36
  "@radix-ui/themes": "^3.2.1",
37
37
  "@react-input/mask": "^2.0.4",
38
38
  "@stitches/react": "^1.2.8",
39
+ "install": "^0.13.0",
40
+ "npm": "^11.4.2",
39
41
  "radix-ui": "^1.4.2",
40
- "react-day-picker": "^9.6.7"
42
+ "react-day-picker": "^9.6.7",
43
+ "react-hook-form": "^7.57.0"
41
44
  }
42
45
  }
@@ -0,0 +1,36 @@
1
+ import { faXmarkCircle } from "@fortawesome/free-solid-svg-icons";
2
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3
+ import { colors } from "@lets-events/tokens";
4
+ import { Flex } from "../Flex";
5
+ import { Text } from "../Text";
6
+ import {
7
+ FieldError,
8
+ FieldErrorsImpl,
9
+ FieldValues,
10
+ Merge,
11
+ } from "react-hook-form";
12
+
13
+ export type ErrorFormMessageProps = {
14
+ message?:
15
+ | string
16
+ | FieldError
17
+ | Merge<FieldError, FieldErrorsImpl<any>>
18
+ | undefined;
19
+ };
20
+
21
+ export const ErrorFormMessage = ({ message }: ErrorFormMessageProps) => {
22
+ if (!message) return;
23
+
24
+ if (typeof message !== "string") {
25
+ return null;
26
+ }
27
+
28
+ return (
29
+ <Flex justify={"start"} align={"center"} gap={6}>
30
+ <FontAwesomeIcon icon={faXmarkCircle} color={colors.error600} size="1x" />
31
+ <Text typography={"bodyXS"} fontWeight={"medium"} color="error600">
32
+ {message}
33
+ </Text>
34
+ </Flex>
35
+ );
36
+ };
@@ -0,0 +1,29 @@
1
+ import { Text } from "../Text";
2
+
3
+ export type FormLabelProps = {
4
+ name: string;
5
+ label?: string;
6
+ haveError?: boolean;
7
+ required?: boolean;
8
+ };
9
+
10
+ export const FormLabel = ({
11
+ name,
12
+ label,
13
+ haveError,
14
+ required,
15
+ }: FormLabelProps) => {
16
+ if (!label) return null;
17
+
18
+ return (
19
+ <Text
20
+ typography={"labelMedium"}
21
+ fontWeight={"medium"}
22
+ color={haveError ? "error600" : "dark700"}
23
+ id={`${name}-label`}
24
+ >
25
+ {label}
26
+ {!required && <Text color="dark500"> (opcional)</Text>}
27
+ </Text>
28
+ );
29
+ };
@@ -0,0 +1,46 @@
1
+ import { useFormContext } from "react-hook-form";
2
+ import { Flex } from "../Flex";
3
+ import { FormLabel } from "./FormLabel";
4
+ import { ErrorFormMessage } from "./ErrorFormMessage";
5
+ import { TextareaField } from "../TextareaField";
6
+
7
+ export type TextAreaFormFieldProps = {
8
+ name: string;
9
+ label?: string;
10
+ required?: boolean;
11
+ placeholder?: string;
12
+ };
13
+
14
+ export const TextAreaFormField = ({
15
+ name,
16
+ label,
17
+ required,
18
+ placeholder,
19
+ }: TextAreaFormFieldProps) => {
20
+ const {
21
+ register,
22
+ formState: { errors },
23
+ } = useFormContext();
24
+
25
+ const haveError = !!errors[name];
26
+
27
+ const errorMsg = errors[name]?.message;
28
+
29
+ return (
30
+ <Flex direction={"column"}>
31
+ <FormLabel
32
+ name={name}
33
+ label={label}
34
+ required={required}
35
+ haveError={haveError}
36
+ />
37
+ <TextareaField
38
+ {...register(name, { required })}
39
+ placeholder={placeholder}
40
+ color={haveError ? "error" : "default"}
41
+ aria-labelledby={`${name}-label`}
42
+ />
43
+ <ErrorFormMessage message={errorMsg} />
44
+ </Flex>
45
+ );
46
+ };
@@ -0,0 +1,46 @@
1
+ import { useFormContext } from "react-hook-form";
2
+ import { Flex } from "../Flex";
3
+ import { FormLabel } from "./FormLabel";
4
+ import { TextField } from "../TextField";
5
+ import { ErrorFormMessage } from "./ErrorFormMessage";
6
+
7
+ export type TextFormFieldProps = {
8
+ name: string;
9
+ label?: string;
10
+ required?: boolean;
11
+ placeholder?: string;
12
+ };
13
+
14
+ export const TextFormField = ({
15
+ name,
16
+ label,
17
+ required,
18
+ placeholder,
19
+ }: TextFormFieldProps) => {
20
+ const {
21
+ register,
22
+ formState: { errors },
23
+ } = useFormContext();
24
+
25
+ const haveError = !!errors[name];
26
+
27
+ const errorMsg = errors[name]?.message;
28
+
29
+ return (
30
+ <Flex direction={"column"}>
31
+ <FormLabel
32
+ name={name}
33
+ label={label}
34
+ required={required}
35
+ haveError={haveError}
36
+ />
37
+ <TextField
38
+ {...register(name, { required })}
39
+ placeholder={placeholder}
40
+ color={haveError ? "error" : "default"}
41
+ aria-labelledby={`${name}-label`}
42
+ />
43
+ <ErrorFormMessage message={errorMsg} />
44
+ </Flex>
45
+ );
46
+ };
@@ -45,14 +45,14 @@ export const TextFieldStyled = styled(TextFieldRadix.Root, {
45
45
  color: {
46
46
  default: {
47
47
  color: "$dark400",
48
- border: "1px solid $dark200",
48
+ border: "1px solid $dark300",
49
49
  "&:has(input:focus)": {
50
50
  border: "2px solid $brand300",
51
51
  },
52
52
  "&:has(input:disabled)": {
53
53
  backgroundColor: "$dark100",
54
54
  color: "$dark400",
55
- border: "1px solid $dark200",
55
+ border: "1px solid $dark300",
56
56
  cursor: "not-allowed",
57
57
  },
58
58
  },
@@ -25,17 +25,12 @@ export const TextareaFieldStyle = styled(TextAreaRadix, {
25
25
  },
26
26
  });
27
27
 
28
- export type TextareaFieldProps = ComponentProps<typeof TextareaFieldStyle> & {
29
- limit: number;
30
- };
31
-
32
28
  const TextareaContainer = styled("div", {
33
29
  display: "flex",
34
30
  flexDirection: "column",
35
31
  overflow: "hidden",
36
32
  width: "100%",
37
33
  border: "1px solid",
38
- borderColor: "$dark300",
39
34
  borderRadius: "$sm",
40
35
 
41
36
  "&:has(textarea:focus)": {
@@ -47,8 +42,29 @@ const TextareaContainer = styled("div", {
47
42
  border: "1px solid $dark200",
48
43
  cursor: "not-allowed",
49
44
  },
45
+
46
+ variants: {
47
+ color: {
48
+ default: {
49
+ borderColor: "$dark300",
50
+ },
51
+ error: {
52
+ borderColor: "$error400",
53
+ },
54
+ },
55
+ },
56
+
57
+ defaultVariants: {
58
+ color: "default",
59
+ },
50
60
  });
51
61
 
62
+ export type TextareaFieldProps = Omit<
63
+ ComponentProps<typeof TextareaFieldStyle>,
64
+ "color"
65
+ > &
66
+ ComponentProps<typeof TextareaContainer>;
67
+
52
68
  const TextareaLimitIndicator = styled("div", {
53
69
  padding: "$12 $16",
54
70
  borderTop: "1px solid $neutral300",
@@ -67,7 +83,7 @@ const TextareaLimitIndicator = styled("div", {
67
83
  export const TextareaField = React.forwardRef<
68
84
  HTMLTextAreaElement,
69
85
  TextareaFieldProps
70
- >(({ maxLength, ...props }, fowardedRef) => {
86
+ >(({ maxLength, color, ...props }, fowardedRef) => {
71
87
  const inputRef = useRef<HTMLTextAreaElement>(null);
72
88
  const badgeRef = useRef<HTMLSpanElement>(null);
73
89
 
@@ -83,9 +99,9 @@ export const TextareaField = React.forwardRef<
83
99
  };
84
100
 
85
101
  return (
86
- <TextareaContainer>
102
+ <TextareaContainer color={color}>
87
103
  <TextareaFieldStyle
88
- rows={3}
104
+ rows={4}
89
105
  ref={(r) => {
90
106
  if (!r) return;
91
107
  inputRef.current = r;
package/src/index.tsx CHANGED
@@ -31,3 +31,10 @@ export * from './components/Box'
31
31
  export * from './components/Grid'
32
32
  export * from './components/Container'
33
33
  export * from './components/Section'
34
+
35
+
36
+ //Form
37
+ export * from './components/FormFields/ErrorFormMessage'
38
+ export * from './components/FormFields/FormLabel'
39
+ export * from './components/FormFields/TextAreaFormField'
40
+ export * from './components/FormFields/TextFormField'